Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark authored Dec 19, 2024
0 parents commit 036e2e1
Show file tree
Hide file tree
Showing 48 changed files with 9,269 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"body-max-line-length": [1, "always", 100]
}
}
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
VITE_APP_HOMEPAGE=$npm_package_homepage
VITE_APP_NAME=$npm_package_name
VITE_APP_VERSION=$npm_package_version
VITE_GOOGLE_ANALYTICS_ID=
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* @remarkablemark

/package-lock.json
/package.json
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
groups:
commitlint:
patterns:
- '@commitlint/*'
eslint:
patterns:
- '@eslint/*'
prettier:
patterns:
- prettier
- eslint-plugin-prettier
typescript-eslint:
patterns:
- '@typescript-eslint/*'

- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'daily'
8 changes: 8 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pull_request_rules:
- name: automatic merge for Dependabot pull requests
conditions:
- author=dependabot[bot]
- check-success=build
actions:
merge:
method: squash
49 changes: 49 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: build
on: [push, pull_request]

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci --prefer-offline

- name: Lint commit message
run: npx commitlint --from=HEAD~1

- name: Run ESLint
run: npm run lint

- name: Type check
run: npm run lint:tsc

- name: Set environment variables
run: |
echo "VITE_APP_HOMEPAGE=$(jq -r .homepage package.json)" >> $GITHUB_ENV
echo "VITE_APP_VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
- name: Build
run: npm run build -- --base /${{ github.event.repository.name }}/
env:
VITE_GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }}

- name: Deploy
if: github.ref_name == 'master'
uses: remarkablemark/gitploy-action@v1
with:
directory: dist
62 changes: 62 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: release-please
on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}

steps:
- name: Release Please
uses: googleapis/release-please-action@v4
id: release
with:
release-type: node

deploy:
needs: release
runs-on: ubuntu-latest
if: ${{ needs.release.outputs.release_created }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: .nvmrc

- name: Install dependencies
run: npm ci --prefer-offline

- name: Read package version
run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV

- name: Build
run: npm run bundle
env:
VITE_GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }}

- name: Setup butler
uses: remarkablegames/setup-butler@v1

- name: Upload to itch.io
run: butler push dist ${{ github.repository }}:html5 --userversion ${{ env.VERSION }}
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}

- name: Upload Release Artifact
run: gh release upload ${{ needs.release.outputs.tag_name }} dist/${{ github.event.repository.name }}-${{ env.VERSION }}.zip
env:
GITHUB_TOKEN: ${{ github.token }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# vite
/dist

# misc
*.swp
.DS_Store

npm-debug.log*
yarn-debug.log*
yarn-error.log*
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.{js,jsx,mjs,mts,ts,tsx}": "eslint --fix",
"*.{css,html,json,md,yml}": "prettier --write"
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2024 Menglin "Mark" Xu <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<p align="center">
<img src="https://github.com/remarkablegames/phaser-template/blob/master/public/logo192.png" alt="Phaser Template">
</p>

# Phaser Template

![release](https://img.shields.io/github/v/release/remarkablegames/phaser-template)
[![build](https://github.com/remarkablegames/phaser-template/actions/workflows/build.yml/badge.svg)](https://github.com/remarkablegames/phaser-template/actions/workflows/build.yml)

<kbd>phaser-template</kbd> is a template for making [Phaser](https://phaser.io/) games.

Inspired by the tutorial "[Making your first Phaser 3 game](https://phaser.io/tutorials/making-your-first-phaser-3-game)".

Play the game on:

- [remarkablegames](https://remarkablegames.org/phaser-template/)
- [CodeSandbox](https://codesandbox.io/s/phaser-template-4fy4y)

## Prerequisites

- [nvm](https://github.com/nvm-sh/nvm#readme)

## Install

Clone the repository:

```sh
git clone https://github.com/remarkablegames/phaser-template.git
cd phaser-template
```

Install the dependencies:

```sh
npm install
```

Rename the project:

```sh
git grep -l phaser-template | xargs sed -i '' -e 's/phaser-template/my-game/g'
git grep -l 'Phaser Template' | xargs sed -i '' -e 's/Phaser Template/My Game/g'
```

Update the files:

- [ ] `README.md`
- [ ] `package.json`
- [ ] `index.html`
- [ ] `public/manifest.json`
- [ ] `src/index.ts`

Initialize a new repository:

```sh
rm -rf .git
git init
```

Make your first commit:

```sh
git add .
git commit -m 'feat: initialize project from phaser-template'
```

> [!NOTE]
> Commit messages follow [Conventional Commits](https://conventionalcommits.org/), which helps with release.
Once you're ready, [push the local repository to GitHub](https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/) (or another remote repository):

```sh
git remote add origin <remote-repository-url>
git push origin -u origin master
```

## Environment Variables

Set the environment variables:

```sh
less .env
```

Update the **Secrets** in the repository **Settings**.

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the game in the development mode.

Open [http://localhost:5173](http://localhost:5173) to view it in the browser.

The page will reload if you make edits.

You will also see any errors in the console.

### `npm run build`

Builds the game for production to the `dist` folder.

It correctly bundles in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.

Your game is ready to be deployed!

### `npm run bundle`

Builds the game and packages it into a Zip file in the `dist` folder.

Your game can be uploaded to your server, [Itch.io](https://itch.io/), [Newgrounds](https://www.newgrounds.com/), etc.

## License

[MIT](LICENSE)
50 changes: 50 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import { includeIgnoreFile } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import prettier from 'eslint-plugin-prettier';
import simpleImportSort from 'eslint-plugin-simple-import-sort';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, '.gitignore');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
includeIgnoreFile(gitignorePath),

...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
),

{
plugins: {
'@typescript-eslint': typescriptEslint,
prettier,
'simple-import-sort': simpleImportSort,
},

languageOptions: {
parser: tsParser,
},

rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
'no-console': 'error',
'no-debugger': 'error',
'prettier/prettier': 'error',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
},
},
];
Loading

0 comments on commit 036e2e1

Please sign in to comment.