Skip to content

Commit 5f1444f

Browse files
authored
Reorganize as a Monorepo (#235)
* use lerna to make this a monorepo * 🔥 'weak' package because hard to install * add embedding example * 💀 global tsc causes everything to compile * 💀 get tsc to compile * get cli to run * 💀 cli code imports the puzzlescript package * 🎉 cli plays with sounds! * 🎉 Website plays games again! * 👕 lint * 🎉 web tests pass again * 🎉 `lerna run test` works! but the replay/integration tests do not work yet * upgrade jest & babel so tests run * ⬆️ upgrade puzzlescript dependencies * ⬆️ upgrade typescript * ⬆️ upgrade puzzlescript-web * example app can now import puzzlescript-web * add version field to package.json * v6.0.0-alpha.0 * add some ignores to trigger version bump * v6.0.0-alpha.1 * include only certain directories in the package * v6.0.0-alpha.2 * 👕 lint * add github actions * add mute mode for cli (& CI tests) * add integration tests * update README
1 parent b8cf008 commit 5f1444f

File tree

697 files changed

+39282
-10462
lines changed

Some content is hidden

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

697 files changed

+39282
-10462
lines changed

.github/workflows/test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: tests
3+
on:
4+
pull_request:
5+
jobs:
6+
tests:
7+
timeout-minutes: 30
8+
runs-on: ubuntu-18.04
9+
steps:
10+
- name: System dependencies
11+
if: runner.os == 'Linux'
12+
run: |
13+
sudo apt update
14+
sudo apt-get update
15+
sudo apt-get -y install libasound2-dev
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 2
19+
# See https://github.com/lerna/lerna/issues/2542
20+
# pulls all commits (needed for lerna / semantic release to correctly version)
21+
# fetch-depth: "0"
22+
# pulls all tags (needed for lerna / semantic release to correctly version)
23+
# - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
24+
- uses: actions/setup-node@v2
25+
with:
26+
node-version: '14'
27+
- name: Prerequisites
28+
run: npm install
29+
- name: Setup
30+
run: ./node_modules/.bin/lerna bootstrap --force-local
31+
- name: Compile
32+
run: ./node_modules/.bin/lerna run compile
33+
- name: Test
34+
run: ./node_modules/.bin/lerna run test --stream
35+
- name: Upload Code Coverage
36+
uses: codecov/codecov-action@v2
37+
- name: Lint
38+
run: ./node_modules/.bin/lerna run lint
39+
- name: Integration Tests
40+
# if: github.ref == 'refs/heads/main'
41+
run: ./node_modules/.bin/lerna run test:integration --stream

.gitignore

Lines changed: 6 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,7 @@
1-
# ---
2-
# Start: Node-built files and documentation
3-
# ---
1+
node_modules
2+
/lerna-debug.log
3+
/lib
4+
/packages/puzzlescript/lib
5+
/packages/puzzlescript-cli/lib
46

5-
/docs/
6-
/lib/
7-
8-
# ---
9-
# ProgressiveWebApp (PWA) files. built using `yarn build`
10-
# ---
11-
12-
/index.xhtml
13-
/precache-manifest.*.js
14-
/puzzlescript.js
15-
/puzzlescript.js.map
16-
/puzzlescript-webworker.js
17-
/puzzlescript-webworker.js.map
18-
/pwa-app.js
19-
/pwa-app.js.map
20-
/pwa-service-worker.js
21-
22-
/game-thumbnails/*.png
23-
/game-thumbnails/*.svg
24-
25-
# ---
26-
# Misc files
27-
# ---
28-
29-
# Logs
30-
logs
31-
*.log
32-
npm-debug.log*
33-
yarn-debug.log*
34-
yarn-error.log*
35-
36-
37-
# Runtime data
38-
pids
39-
*.pid
40-
*.seed
41-
*.pid.lock
42-
43-
# Coverage directory used by tools like istanbul
44-
/coverage/
45-
/.nyc_output/
46-
47-
# Compiled binary addons (http://nodejs.org/api/addons.html)
48-
build/Release
49-
50-
# Dependency directories
51-
/node_modules/
52-
53-
# Optional npm cache directory
54-
.npm
55-
56-
# Optional eslint cache
57-
.eslintcache
58-
59-
# Optional REPL history
60-
.node_repl_history
61-
62-
# Output of 'npm pack'
63-
*.tgz
64-
65-
# Yarn Integrity file
66-
.yarn-integrity
67-
68-
# dotenv environment variables file
69-
.env
70-
71-
72-
73-
/games/__test/script.txt
74-
*.cpuprofile
75-
/src/parser/grammar.ts
76-
/webpack-stats*.json
7+
yarn-error.log

.node-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.npmignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

README.md

Lines changed: 33 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
# Accessible PuzzleScript
22
[![NPM version][npm-image]][npm-url]
33
[![Downloads][downloads-image]][downloads-url]
4-
[![Build status][travis-image]][travis-url]
5-
[![Dependency status][dependency-image]][dependency-url]
6-
[![Dev dependency status][dev-dependency-image]][dev-dependency-url]
74
[![Code coverage][coverage-image]][coverage-url]
85

9-
This is a program that allows people to play [PuzzleScript](https://www.puzzlescript.net) games in a browser **or** in a terminal.
10-
11-
Also, it is **accessible**, meaning that [blind or visually impaired people can play these games](#video-games-that-blind-people-can-play) too! See [blog post](https://philschatz.com/2018/09/22/puzzlescript/) for more info or **[try the demo](https://philschatz.com/puzzlescript/)**.
12-
13-
146
## Play in a browser or on your mobile device
157

16-
1. Visit the [demo site](https://philschatz.com/puzzlescript)
8+
1. Visit the [website](https://philschatz.com/puzzlescript)
179
1. Click the "Add" button at the bottom to keep playing even without an internet connection
1810
1. Plug in a :video_game: controller! (tested with PS3/4/XBox)
1911

2012
<details>
2113

2214
<summary>If you are using <strong>iOS (Apple phone or tablet)</strong> click here for instructions</summary>
2315

24-
1. Visit https://philschatz.com/puzzlescript
16+
1. Visit the [website](https://philschatz.com/puzzlescript)
2517
1. Click the Share button in Safari
2618
1. Scroll over and click "Add to Home Screen"
2719

@@ -32,9 +24,7 @@ Also, it is **accessible**, meaning that [blind or visually impaired people can
3224

3325
## Play from the command line terminal
3426

35-
1. Run `npm install -g puzzlescript` to install
36-
1. Run `puzzlescript` to start playing
37-
27+
1. Run `npx puzzlescript-cli` to start playing!
3828

3929
# Screencaps
4030

@@ -108,91 +98,47 @@ The goal of this project is to do 3 things:
10898
To use https://chromevox.com, table navigation keys on the Mac are <kbd>Ctrl</kbd> + <kbd>Command</kbd> + <kbd>Up</kbd>.
10999

110100

111-
# Research
112-
113-
To convert a game to JSON, run the following:
114-
115-
```js
116-
import { Parser } from 'puzzlescript'
117-
import Serializer from 'puzzlescript/lib/parser/serializer'
118-
119-
const { data } = Parser.parse(gameSource)
120-
const json = new Serializer(data).toJson()
121-
const reparsedData = Serializer.fromJson(json, gameSource)
122-
```
123-
124-
## Commands
125-
126-
- `npm run docs` generates docs in the `./docs/` directory
127-
- `npm start` runs a game in the [./games/](./games/) directory without debugging info (10x faster) (uses `NODE_ENV=production`)
128-
- `npm run start:dev` runs a game in the [./games/](./games/) directory with sprite info (useful for debugging)
129-
- `npm run start:debug` runs a game in the [./games/](./games/) directory with a Chrome Debugger open so you can set breakpoints
130-
- `npm demo` runs all of the games in the [./games/](./games/) directory with a few sample moves (up/down/left/right/action)
131-
- `npm test` runs all of the unit tests (including solutions in the [./game-solutions/](./game-solutions/) directory)
132-
- `npm run watch` Run the tests and when you update the source, it re-runs the tests
133-
- `npm run test:debug` Run the tests but opens a debugger (remember to add a `debugger` line into the JavaScript)
134-
- `npm test; open coverage/lcov-report/index.html` to see test coverage
135-
- `npm run coverage` generates a coverage report which includes the JS code as well as any games that you ran in dev mode (using `npm run dev`)
136-
- See the module dependency tree by running `npm run build:stats` and then uploading `webpack-stats.json` to https://webpack.github.io/analyse/#modules
101+
# Development Instructions
137102

103+
1. Install [lerna](https://lerna.js.org)
104+
1. `lerna bootstrap --force-local`
105+
1. `lerna run compile`
106+
1. `lerna run test --stream`
107+
- you can run `test:unit` or `test:web` to just run tests specific to a package
108+
1. `lerna run test:integration --stream` (this runs several games and takes about 30min)
109+
1. `lerna run start:server --stream` to start up a server
138110

139-
## Embed in a Browser
111+
## Maintainer Instructions
140112

141-
See [./src/browser/spec/html-table.xhtml](./src/browser/spec/html-table.xhtml) for an example of embedding in a browser.
113+
To publish a new version of the packages:
142114

143-
```js
144-
// Include <script src="node_modules/puzzlescript/puzzlescript.js"></script>
145-
// and then the following:
146-
table = document.querySelector('table') // selector to the <table> that will be used
147-
engine = new PuzzleScript.SyncTableEngine(table, optionalEventHandler)
148-
engine.setGame(gameSourceString, 0 /*startLevel*/)
115+
```sh
116+
lerna publish prerelease
149117
```
150118

151-
Or, if the game is slow, it can be played using a [Webworker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers):
152-
153-
```js
154-
worker = new Worker('path/from/browser/to/puzzlescript-webworker.js')
155-
engine = new PuzzleScript.WebworkerTableEngine(worker, table, optionalEventHandler)
156-
...
157-
```
158-
159-
## Objects
160-
161-
- **Level** contains a table of Cells which contain a set of Sprites that should be rendered
162-
- **Rule** contains the conditions and actions to be executed.
163-
- It also contains methods for checking if the Rule matches a Cell and methods for how to change the Cell
164-
- **Cell** contains a set of Sprites and is used to represent the current state of the Game
165-
166-
167-
# TODO
168-
169-
Want to help? Here is a roadmap of things that need to be implemented:
170-
171-
- [ ] support tabbing through the sprites to say where they are and how many of them are in the puzzle
172-
- [ ] output which sprites changed when the player moves or presses undo
173-
- [ ] improve the sound effects (needs an implementation of [BiquadFilter](https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode) in NodeJS)
174-
- [ ] support the `RIGID` keyword
175-
- [x] output a simple `BEL` (ASCII character 7) when the `speaker` package is not installed
176-
- [ ] output sound effects when any of the following occur:
177-
- a sprite is `CREATE`, `DESTROY`, `CANTMOVE`
178-
- a sprite is moved
179-
- `RESTART`, `UNDO`, `TITLESCREEN`, `STARTGAME`, `STARTLEVEL`, `ENDLEVEL`, `ENDGAME`, `SHOWMESSAGE`, `CLOSEMESSAGE`
180-
- [x] use HTML Tables to render in the browser
181-
- [x] Cache Improvements
182-
- [x] cache the `SimpleNeighbor.matchesCell()` function so we do not have to recompute if a cell matches a Neighbor
183-
- [x] de-duplicate `SimpleNeighbor` that have a direction but none of the tiles depend on the direction (causes fewer caches to be updated)
184-
- [x] improve `getMatches(level)` by storing a cache of all the sprites in each row/column so we can skip the row/column entirely if the necessary sprites are not available
119+
## TODO
120+
121+
- [x] Move to a monorepo
122+
- [x] Add embedding example
123+
- [ ] Upgrade dependencies
124+
- [x] Move CLI code into a separate package
125+
- [x] Update so that the puzzlescript package (or puzzlescript-web package) has 0 dependencies
126+
- [x] Get CI tests running again
127+
- [x] get Codecov reporting
128+
- [x] Lint again
129+
- [ ] Support when `<table>` does not have an aria-live caption (by adding one)
130+
- [ ] change the web handler to create a different event when a checkpoint occurs (so saving is easier)
131+
- [ ] change the CLI so that you can specify the path to a puzzlescript game.
132+
- [ ] get code coverage up to 100% by skipping untested code
133+
- [ ] Generate ESModules and CJS: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html
134+
- [ ] convert puzzlescript-web to use Cypress and sourcemaps
135+
- [ ] move the games and solutions into a separate package (`puzzlescript-games`)
136+
- [ ] :fire: default exports because they are hard on IDEs and make for a confusing API
185137

186138

187139
[npm-image]: https://img.shields.io/npm/v/puzzlescript.svg
188140
[npm-url]: https://npmjs.org/package/puzzlescript
189141
[downloads-image]: https://img.shields.io/npm/dm/puzzlescript.svg
190142
[downloads-url]: https://npmjs.org/package/puzzlescript
191-
[travis-image]: https://img.shields.io/travis/philschatz/puzzlescript.svg
192-
[travis-url]: https://travis-ci.org/philschatz/puzzlescript
193-
[dependency-image]: https://img.shields.io/david/philschatz/puzzlescript.svg
194-
[dependency-url]: https://david-dm.org/philschatz/puzzlescript
195-
[dev-dependency-image]: https://img.shields.io/david/dev/philschatz/puzzlescript.svg
196-
[dev-dependency-url]: https://david-dm.org/philschatz/puzzlescript?type=dev
197143
[coverage-image]: https://img.shields.io/codecov/c/github/philschatz/puzzlescript.svg
198144
[coverage-url]: https://codecov.io/gh/philschatz/puzzlescript

TODO.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
TO DOs:
2+
3+
- [x] remove custom nearley
4+
- [ ] move sound effects hacks into their respective Node/Browser repos (or find a way so puzzlescript core does not depend on it)
5+
- [ ] move PWA to separate repos
6+
- [ ] move playgame tests to something other than unit tests (so the unit tests will run faster)
7+
- [ ] move the games and solutions into a separate package
8+
- [ ] bring browser tests back
9+
- [ ] bring code coverage back for all packages
10+
- [ ] use ts-node to run scripts like `node ./lib/script/buildGameIcons.js`

game-thumbnails/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

jest-puppeteer.config.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

lerna.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"packages": [
3+
"packages/*"
4+
],
5+
"npmClient": "yarn",
6+
"version": "6.0.0-alpha.2"
7+
}

0 commit comments

Comments
 (0)