Skip to content

Commit

Permalink
Add a publishing workflow. Options update.
Browse files Browse the repository at this point in the history
  • Loading branch information
infomiho committed Jan 30, 2025
1 parent 4cbc123 commit f8e9e76
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 34 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/wasp-app-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Wasp App Runner
on:
push:
paths:
- "wasp-app-runner/**"
branches:
- release

defaults:
run:
shell: bash
working-directory: wasp-app-runner

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20"
- run: npm ci
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
11 changes: 2 additions & 9 deletions .github/workflows/waspc-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ jobs:
path: ~/.npm
key: node-modules-${{ hashFiles('./waspc/headless-test/package-lock.json') }}-${{ matrix.os }}-${{ matrix.node-version }}

# TODO: remove this once we start publishing the wasp-app-runner
# as a npm package
- name: Headless - Setup the Wasp app runner
id: headless-setup-wasp-app-runner
if: matrix.os == 'ubuntu-20.04'
Expand Down Expand Up @@ -218,15 +220,6 @@ jobs:
# Runs the tests with the debug flag so that we can see Wasp output
DEBUG=pw:webserver npx playwright test --config headless-tests/
- name: Headless - Run Playwright Tests 2
id: headless-run-playwright-tests-2
if: matrix.os == 'ubuntu-20.04'
run: |
cd ../examples/todo-typescript
npm ci
# Runs the tests with the debug flag so that we can see Wasp output
DEBUG=pw:webserver npx playwright test --config headless-tests/
- name: Run e2e tests
run: cabal test e2e-test

Expand Down
2 changes: 2 additions & 0 deletions wasp-app-runner/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/
node_modules/
45 changes: 24 additions & 21 deletions wasp-app-runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,23 @@

A robust script to run your Wasp application with PostgreSQL, including automated database setup and migrations.

## Installation

```bash
npm install
# Installs wasp-app-runner globally
npm install -g
```

## Usage

```
node ./src/index.js --app-path <path-to-app> --app-name <app-name> [--db-type <db-type>] [--skip-cli-install <true/false>]
npx wasp-app-runner --app-path <path-to-app> --app-name <app-name> [--db-type <db-type>] [--skip-cli-install <true/false>]
```

### Arguments Table

| Argument | Description | Example |
| -------------------- | --------------------------------------- | --------------- |
| `--app-path` | Path to your Wasp application directory | `./my-wasp-app` |
| `--app-name` | Unique name for your application | `myapp` |
| `--db-type` | Choices: `postgres`, `sqlite` | `postgres` |
| `--skip-cli-install` | Skip installing Wasp CLI | `true` |
This runs the package without installing it globally.

### Example Command
### Arguments Table

```
node run-app.js --app-path ~/projects/my-wasp-app --app-name awesome-app
```
| Argument | Description | Example |
| -------------------- | -------------------------------------------------- | --------------- |
| `--app-path` | Path to your Wasp application directory | `./my-wasp-app` |
| `--app-name` | Unique name for your application | `myapp` |
| `--db-type` | Choices: `postgres`, `sqlite`, default: `postgres` | `postgres` |
| `--skip-cli-install` | Skip installing Wasp CLI | `true` |
| `--wasp-cli-cmd` | Wasp CLI command, default: `wasp-cli` | `wasp` |

## Environment File Handling

Expand All @@ -54,3 +43,17 @@ If Postgres is used, the script automatically sets the `DATABASE_URL` env variab
```
DATABASE_URL=postgresql://postgres:devpass@localhost:5432/postgres
```

## Development

```bash
npm install
# Installs wasp-app-runner globally from the local directory
npm install -g
```

You can also run the script directly:

```bash
node ./src/index.js --app-path <path-to-app> --app-name <app-name> [--db-type <db-type>] [--skip-cli-install <true/false>] [--]
```
6 changes: 4 additions & 2 deletions wasp-app-runner/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"version": "0.0.3",
"name": "wasp-app-runner",
"type": "module",
"bin": {
"wasp-app-runner": "./bin/index.js"
"wasp-app-runner": "bin/index.js"
},
"scripts": {
"build": "tsc",
"start": "npm run build && node ./dist/index.js",
"install:global": "npm run build && npm install -g"
"install:global": "npm run build && npm install -g",
"prepublishOnly": "npm ci && npm run build"
},
"dependencies": {
"typescript": "^5.7.3",
Expand Down
6 changes: 6 additions & 0 deletions wasp-app-runner/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const argv = yargs(hideBin(process.argv))
default: false,
description: "Skip installing Wasp CLI globally",
},
"wasp-cli-cmd": {
type: "string",
description: "Command to use for Wasp CLI",
default: "wasp-cli",
},
})
.check((argv) => {
const appName = argv["app-name"];
Expand All @@ -43,6 +48,7 @@ export function getOptions() {
appName: argv["app-name"],
dbType: argv["db-type"] as DbType,
skipCliInstall: argv["skip-cli-install"],
waspCliCmd: argv["wasp-cli-cmd"],
};
}

Expand Down
4 changes: 2 additions & 2 deletions wasp-app-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ async function main() {
await executeWithDb(options, async ({ extraEnv }) => {
await processManager.spawnWithLog({
name: "migrate-db",
cmd: "wasp-cli",
cmd: options.waspCliCmd,
args: ["db", "migrate-dev"],
cwd: options.pathToApp,
extraEnv,
});

await processManager.spawnWithLog({
name: "start-app",
cmd: "wasp-cli",
cmd: options.waspCliCmd,
args: ["start"],
cwd: options.pathToApp,
extraEnv,
Expand Down

0 comments on commit f8e9e76

Please sign in to comment.