Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert project to npm monorepo #284

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
34 changes: 15 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,30 @@ jobs:
name: Build w4 CLI
runs-on: ubuntu-latest
needs: build-native-runtime
defaults:
run:
working-directory: cli

steps:
- uses: actions/checkout@v2
- name: Build web-devtools
working-directory: devtools/web
run: |
npm ci
- uses: actions/setup-node@v2
with:
node-version: '16.13.1'
cache: 'npm'
- name: install
run: npm ci
- name: Build web runtime
working-directory: runtimes/web
run: |
npm ci
npm run build
npm -w wasm4-runtime run build

- name: Import web runtime
run: |
rm -f assets/runtime
cp -r ../runtimes/web/dist assets/runtime
rm -f cli/assets/runtime
cp -r runtimes/web/dist cli/assets/runtime

- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Import native runtimes
working-directory: cli
run: |
mkdir -p assets/natives
ls -R ../artifacts
Expand All @@ -99,13 +96,12 @@ jobs:

- name: Build CLI
run: |
cp ../README.md ../LICENSE.txt .
mkdir -p ../cli-build
mv `npm pack` ../cli-build/wasm4-npm.tar.gz

npm ci
cp README.md LICENSE.txt cli
mkdir -p cli-build
npm pack -w wasm4 --pack-destination cli-build
mv $(echo cli-build/wasm4-*) cli-build/wasm4-npm.tar.gz
npm install -g pkg
pkg --compress Brotli --out-path ../cli-build --targets node12-win,node12-mac,node12-linux .
pkg --compress Brotli --out-path cli-build --targets node12-win,node12-mac,node12-linux cli

- name: Upload artifacts
uses: actions/upload-artifact@v2
Expand Down
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
**/node_modules

# Misc
.DS_Store
Expand All @@ -14,3 +14,14 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Ignore non `npm` lock files
**/yarn.lock
**/pnpm-lock.yaml
**/pnpm-lock.yml

# Do not commit npm lockfiles accidentally defined inside workspaces
devtools/web/package-lock.json
site/package-lock.json
runtimes/web/package-lock.json
cli/package-lock.json
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.1
28 changes: 26 additions & 2 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
# wasm4 cli

## Description

This directory contains the `w4` command-line tool.

## Development

First run `npm install` to install dependencies.
Read the [development-guide](/development-guide.md) first.

### Install dependencies

This package is managed by the `wasm4-monorepo`, to install
set `wasm4/` as working directory then run `npm i`.


### Develop locally

Run `npm link` in this directory to install a `w4` symlink for local development.
You will also want to build the runtime, by running:

```bash
# working directory: wasm4/
npm -w wasm4-runtime run build
```

For quick development you can also run the cli directly:

```bash
# working directory: wasm4/
node cli/cli.js --help
```

You will also want to build the runtime, by running `npm run build` in /runtimes/web.

We use [pkg](https://www.npmjs.com/package/pkg) to bundle node-free binaries. Make sure that all
file resources that need to be loaded at runtime go in the assets directory in order to be included.
Loading