Skip to content

Commit 2698f4e

Browse files
committed
Initial commit
0 parents  commit 2698f4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+16021
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.txt text eol=lf

.github/.kodiak.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# .kodiak.toml
2+
# Minimal config. version is the only required field.
3+
version = 1
4+
[merge.automerge_dependencies]
5+
# only auto merge "minor" and "patch" version upgrades.
6+
# do not automerge "major" version upgrades.
7+
versions = ["minor", "patch"]
8+
usernames = ["dependabot"]
9+
[merge]
10+
method = "squash"
11+
[merge.message]
12+
include_coauthors = true

.github/ISSUE_TEMPLATE/bug_report.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/dependabot.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
labels:
6+
- "dependencies"
7+
schedule:
8+
interval: monthly
9+
open-pull-requests-limit: 10

.github/workflows/deploy.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
# Runs on pushes targeting tags
5+
push:
6+
tags:
7+
- 'v*' # Trigger on tags that start with 'v'
8+
# Allow the ability to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read # read contents of repository
14+
pages: write # to deploy to Pages
15+
id-token: write # to verify the deployment originates from an appropriate source
16+
17+
# Ensure that GitHub Actions only runs one deployment at a time by making all jobs that run from this workflow part of the "pages" concurrency group.
18+
# GitHub Actions will only run one job per concurrency group at a time.
19+
# Don't cancel any runs that are in progress though, as the deployment should be run to completion.
20+
concurrency:
21+
group: 'pages'
22+
cancel-in-progress: false
23+
24+
jobs:
25+
deploy:
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
- name: Install dependencies
38+
run: npm install
39+
- name: Build
40+
run: npm run build
41+
- name: Setup Pages
42+
uses: actions/configure-pages@v4
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
# Upload just the 'build' directory
47+
path: './build'
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v4

.github/workflows/run-tests.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run Tests
2+
on: [push]
3+
jobs:
4+
test-game-logic:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- run: echo "Checking out ${{ github.ref }} from ${{ github.repository }}."
8+
- name: Check out repository code
9+
uses: actions/checkout@v3
10+
- name: Run node -v
11+
run: node -v
12+
- name: Run npm install
13+
run: npm install
14+
- name: Run test
15+
run: npm run test
16+
# cypress-run:
17+
# runs-on: ubuntu-latest
18+
# steps:
19+
# - run: echo "Checking out ${{ github.ref }} from ${{ github.repository }}."
20+
# - name: Check out repository code
21+
# uses: actions/checkout@v3
22+
# - name: Run Cypress tests
23+
# uses: cypress-io/github-action@v4

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
build
3+
4+
state.json
5+
preferences.json
6+
7+
# Cypress output
8+
cypress/videos
9+
cypress/screenshots
10+
11+
.DS_Store

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.github
2+
node_modules
3+
*.html
4+
*.md
5+
*.yml

.prettierrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"tabWidth": 4,
3+
"printWidth": 100,
4+
"overrides": [
5+
{
6+
"files": "package*.json",
7+
"options": {
8+
"tabWidth": 2
9+
}
10+
}
11+
]
12+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"liveServer.settings.ignoreFiles": ["test/**"]
3+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2024 James Cote
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# 2048-clone
2+
3+
[![Run Tests](https://github.com/Coteh/2048-clone/actions/workflows/run-tests.yml/badge.svg)](https://github.com/Coteh/2048-clone/actions/workflows/run-tests.yml)
4+
5+
### [**Click here to play**](https://coteh.github.io/2048-clone)
6+
7+
![Browser Game Screenshot](screenshot.gif "Browser Game Screenshot")
8+
9+
A clone of [2048](https://play2048.co/), and also a remake of my first 2048 clone, [2048Clone](https://github.com/Coteh/2048Clone).
10+
11+
## Setup
12+
13+
### Browser
14+
15+
[Click here to play on the browser](https://coteh.github.io/2048-clone)
16+
17+
## Features
18+
19+
- Base game
20+
21+
## Development
22+
23+
Clone this repository, then run the following:
24+
25+
```
26+
npm install
27+
```
28+
29+
At this point, you can run a local web server on the project directory, and the game should render when navigating to the port of the server from your browser.
30+
31+
## Testing
32+
33+
Run the following to launch unit tests:
34+
35+
```
36+
npm run test
37+
```
38+
39+
Cypress tests can be accessed by running the following:
40+
41+
```
42+
npm run cypress open
43+
```
44+
45+
This will launch the tests in the Cypress UI.
46+
47+
Alternatively, you can run the tests directly on CLI:
48+
49+
```
50+
npm run cypress run
51+
```

__mocks__/fs.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { fs } = require("memfs");
2+
module.exports = fs;

cypress.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { defineConfig } = require("cypress");
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
setupNodeEvents(on, config) {
6+
// implement node event listeners here
7+
8+
// Log messages in command line output using Node.js runner
9+
// Adapted from https://stackoverflow.com/a/67533232
10+
on("task", {
11+
log(message) {
12+
console.log(message);
13+
return null;
14+
},
15+
});
16+
},
17+
},
18+
screenshotOnRunFailure: process.env.CI === undefined,
19+
video: process.env.CI === undefined,
20+
videoCompression: 0,
21+
blockHosts: ["*.google-analytics.com"],
22+
});

0 commit comments

Comments
 (0)