diff --git a/.github/workflows/wasp-app-runner.yml b/.github/workflows/wasp-app-runner.yml new file mode 100644 index 0000000000..2fcfd64c9c --- /dev/null +++ b/.github/workflows/wasp-app-runner.yml @@ -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 }} diff --git a/.github/workflows/waspc-ci.yaml b/.github/workflows/waspc-ci.yaml index 9d738dccce..35faaaad11 100644 --- a/.github/workflows/waspc-ci.yaml +++ b/.github/workflows/waspc-ci.yaml @@ -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' @@ -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 diff --git a/wasp-app-runner/.npmignore b/wasp-app-runner/.npmignore new file mode 100644 index 0000000000..a3f930dc7c --- /dev/null +++ b/wasp-app-runner/.npmignore @@ -0,0 +1,2 @@ +src/ +node_modules/ diff --git a/wasp-app-runner/README.md b/wasp-app-runner/README.md index a302d2a77a..6efa15fd0b 100644 --- a/wasp-app-runner/README.md +++ b/wasp-app-runner/README.md @@ -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 --app-name [--db-type ] [--skip-cli-install ] +npx wasp-app-runner --app-path --app-name [--db-type ] [--skip-cli-install ] ``` -### 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 @@ -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 --app-name [--db-type ] [--skip-cli-install ] [--] +``` diff --git a/wasp-app-runner/package.json b/wasp-app-runner/package.json index 094e6f6c2b..d4259a7d1e 100644 --- a/wasp-app-runner/package.json +++ b/wasp-app-runner/package.json @@ -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", diff --git a/wasp-app-runner/src/cli.ts b/wasp-app-runner/src/cli.ts index a56fb38685..7a913f7414 100644 --- a/wasp-app-runner/src/cli.ts +++ b/wasp-app-runner/src/cli.ts @@ -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"]; @@ -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"], }; } diff --git a/wasp-app-runner/src/index.ts b/wasp-app-runner/src/index.ts index d4931ea3be..60d193d883 100755 --- a/wasp-app-runner/src/index.ts +++ b/wasp-app-runner/src/index.ts @@ -34,7 +34,7 @@ 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, @@ -42,7 +42,7 @@ async function main() { await processManager.spawnWithLog({ name: "start-app", - cmd: "wasp-cli", + cmd: options.waspCliCmd, args: ["start"], cwd: options.pathToApp, extraEnv,