Skip to content

Commit

Permalink
fix(@whook/example): fix whook example run scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Dec 5, 2024
1 parent 3415505 commit 38c0992
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 109 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ npm init @whook;
cd my_project_name;

# Check install with a dry run of the server
DRY_RUN=1 npm run start
npm run dev -- __inject httpServer,process,dryRun

# Run tests
npm t
Expand All @@ -46,8 +46,14 @@ npm run watch
# Build the project
npm run build

# Start the compiled project
npm start

# Start the built project
node builds/local/server/start.js

# Create a new handler/service/provider
npx whook create
npm run whook -- create
```

## Why use Whook?
Expand All @@ -59,7 +65,7 @@ npx whook create
anylith era
- easy to test: TDD, E2E tests made easy
- feature complete for most API use cases
- simplify your life but embrace projects complexity
- ease your work but embrace projects complexity

## Usage

Expand All @@ -69,6 +75,7 @@ A tutorial is still to be written, expect it to come very soon. The above
That said you can check the following "How to" PRs:

- [add GraphQL](https://github.com/nfroidure/whook/pull/62)
- [deploy with Docker](https://github.com/nfroidure/whook/pull/164)
- [deploy on AWS Lambda](https://github.com/nfroidure/whook/pull/54)
- [deploy with GCP Cloud Functions](https://github.com/nfroidure/whook/pull/66)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ DEV_MODE=1
"build": "rimraf 'dist' && tsc --outDir dist",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=\${NODE_ENV:-development} whook"
},
"files": [
Expand Down Expand Up @@ -311,7 +311,7 @@ exports[`initCreateWhook should handle git initialization problems 2`] = `
],
[
"warning",
"➕ - Then run \`DRY_RUN=1 npm run dev\` to check installation.",
"➕ - Then run \`npm run dev -- __inject httpServer,process,dryRun\` to check installation.",
],
[
"warning",
Expand Down Expand Up @@ -410,18 +410,18 @@ DEV_MODE=1
"build": "rimraf 'dist' && tsc --outDir dist",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=\${NODE_ENV:-development} whook"
},
"files": [
Expand Down Expand Up @@ -656,7 +656,7 @@ exports[`initCreateWhook should handle network issues 2`] = `
],
[
"warning",
"➕ - Then run \`DRY_RUN=1 npm run dev\` to check installation.",
"➕ - Then run \`npm run dev -- __inject httpServer,process,dryRun\` to check installation.",
],
[
"warning",
Expand Down Expand Up @@ -755,18 +755,18 @@ DEV_MODE=1
"build": "rimraf 'dist' && tsc --outDir dist",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=\${NODE_ENV:-development} whook"
},
"files": [
Expand Down Expand Up @@ -984,7 +984,7 @@ exports[`initCreateWhook should work 2`] = `
],
[
"warning",
"➕ - Then run \`DRY_RUN=1 npm run dev\` to check installation.",
"➕ - Then run \`npm run dev -- __inject httpServer,process,dryRun\` to check installation.",
],
[
"warning",
Expand Down Expand Up @@ -1083,18 +1083,18 @@ DEV_MODE=1
"build": "rimraf 'dist' && tsc --outDir dist",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=\${NODE_ENV:-development} whook"
},
"files": [
Expand Down
66 changes: 33 additions & 33 deletions packages/whook-create/src/services/createWhook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ describe('initCreateWhook', () => {
await createWhook();

expect(
JSON.parse(
outputFile.mock.calls
.find((call) => call[0].toString().endsWith('package.json'))?.[1]
?.toString() || '',
),
).toMatchInlineSnapshot(`
JSON.parse(
outputFile.mock.calls.
find((call) => call[0].toString().endsWith('package.json'))?.[1]?.
toString() || ''
)
).toMatchInlineSnapshot(`
{
"author": {
"email": "[email protected]",
Expand Down Expand Up @@ -262,18 +262,18 @@ describe('initCreateWhook', () => {
"build": "rimraf 'dist' && tsc --outDir dist",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=\${NODE_ENV:-development} whook",
},
"type": "module",
Expand Down Expand Up @@ -341,12 +341,12 @@ describe('initCreateWhook', () => {
await createWhook();

expect(
JSON.parse(
outputFile.mock.calls
.find((call) => call[0].toString().endsWith('package.json'))?.[1]
?.toString() || '',
),
).toMatchInlineSnapshot(`
JSON.parse(
outputFile.mock.calls.
find((call) => call[0].toString().endsWith('package.json'))?.[1]?.
toString() || ''
)
).toMatchInlineSnapshot(`
{
"author": {
"email": "[email protected]",
Expand Down Expand Up @@ -457,18 +457,18 @@ describe('initCreateWhook', () => {
"build": "rimraf 'dist' && tsc --outDir dist",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=\${NODE_ENV:-development} whook",
},
"type": "module",
Expand Down Expand Up @@ -521,12 +521,12 @@ describe('initCreateWhook', () => {
await createWhook();

expect(
JSON.parse(
outputFile.mock.calls
.find((call) => call[0].toString().endsWith('package.json'))?.[1]
?.toString() || '',
),
).toMatchInlineSnapshot(`
JSON.parse(
outputFile.mock.calls.
find((call) => call[0].toString().endsWith('package.json'))?.[1]?.
toString() || ''
)
).toMatchInlineSnapshot(`
{
"author": {
"email": "[email protected]",
Expand Down Expand Up @@ -637,18 +637,18 @@ describe('initCreateWhook', () => {
"build": "rimraf 'dist' && tsc --outDir dist",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=\${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=\${NODE_ENV:-development} whook",
},
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/whook-create/src/services/createWhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ builds/
);
log(
'warning',
`➕ - Then run \`DRY_RUN=1 npm run dev\` to check installation.`,
`➕ - Then run \`npm run dev -- __inject httpServer,process,dryRun\` to check installation.`,
);
log('warning', `➕ - And finally run \`npm run watch\` to start dev!`);
};
Expand Down
3 changes: 0 additions & 3 deletions packages/whook-example/bin/build.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/whook-example/bin/watch.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/whook-example/bin/whook.js

This file was deleted.

10 changes: 5 additions & 5 deletions packages/whook-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@
"cli": "env NODE_ENV=${NODE_ENV:-cli}",
"cover": "npm run jest -- --coverage",
"debug": "NODE_OPTIONS=${NODE_OPTIONS:-'--inspect'} NODE_ENV=${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=${DEBUG:-whook} tsx bin/whook.js",
"dev": "NODE_ENV=${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/whook.js",
"dev": "NODE_ENV=${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/run.js",
"format": "npm run prettier",
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
"lint": "eslint 'src/**/*.ts'",
"metapak": "metapak",
"postbuild": "NODE_ENV=${NODE_ENV:-development} tsx bin/build.js",
"postbuild": "NODE_ENV=${NODE_ENV:-development} tsx src/runBuild.js",
"prettier": "prettier --write 'src/**/*.ts'",
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
"repl": "NODE_ENV=${NODE_ENV:-development} tsx bin/whook.js -- __inject repl",
"start": "NODE_ENV=${NODE_ENV:-development} node bin/whook.js",
"repl": "NODE_ENV=${NODE_ENV:-development} tsx src/run.js -- __inject repl",
"start": "NODE_ENV=${NODE_ENV:-development} node dist/run.js",
"test": "NODE_ENV=test npm run build && npm run jest",
"type-check": "tsc --pretty --noEmit",
"watch": "NODE_ENV=${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
"watch": "NODE_ENV=${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx src/runWatch.js",
"whook": "NODE_ENV=${NODE_ENV:-development} whook"
},
"author": {
Expand Down
Loading

0 comments on commit 38c0992

Please sign in to comment.