Skip to content

Commit 8a5a01e

Browse files
committed
docs(@whook/example): improve the example docs
1 parent 1f2cbcd commit 8a5a01e

3 files changed

Lines changed: 427 additions & 306 deletions

File tree

packages/whook-example/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To run the server in production:
2323
# For the first time create a strong JWT secret
2424
echo 'JWT_SECRET=$(openssl rand -base64 10)' > .env.app.production
2525
# And install the dependencies
26-
npm it
26+
npm i
2727

2828
# Then and later, just run build and run the server
2929
npm run build
@@ -39,8 +39,8 @@ that explains the notes.
3939
Feel free to continue creating architecture notes and to regenerate the markdown
4040
file by running:
4141

42-
```
43-
npm run architecture
42+
```sh
43+
node --run architecture
4444
```
4545

4646
## Dev
@@ -55,6 +55,15 @@ node --run dev
5555
node --run watch
5656
```
5757

58+
Run and update tests:
59+
```sh
60+
# Run the tests
61+
npm t
62+
63+
# Updating tests snapshots
64+
node --run jest -- -u
65+
```
66+
5867
Create a new route / cron / service / provider or command:
5968

6069
```sh

packages/whook-example/src/cli.test.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, test, expect, jest } from '@jest/globals';
22
import { exec } from 'node:child_process';
33
import { YError } from 'yerror';
4+
import { join as joinPaths } from 'node:path';
45

56
jest.setTimeout(30000);
67

@@ -11,11 +12,11 @@ describe('commands should work', () => {
1112
);
1213

1314
expect({
14-
stdout: stdout.replace(/( |"|')([^ ]+)\/whook\//g, ' /whook/'),
15-
stderr: stderr.replace(/( |"|')([^ ]+)\/whook\//g, ' /whook/'),
15+
stdout: replacePaths(stdout),
16+
stderr: replacePaths(stderr),
1617
}).toMatchInlineSnapshot(`
1718
{
18-
"stderr": "⚡ - Loading configurations from /whook/packages/whook-example/dist/config/local/config.js".
19+
"stderr": "⚡ - Loading configurations from "file:///project/dist/config/local/config.js".
1920
🤖 - Initializing the \`$autoload\` service.
2021
🔴 - Running with "local" application environment.
2122
🔂 - Running with "test" node environment.
@@ -56,11 +57,11 @@ On air 🚀🌕
5657
);
5758

5859
expect({
59-
stdout: stdout.replace(/( |"|')([^ ]+)\/whook\//g, ' /whook/'),
60-
stderr: stderr.replace(/( |"|')([^ ]+)\/whook\//g, ' /whook/'),
60+
stdout: replacePaths(stdout),
61+
stderr: replacePaths(stderr),
6162
}).toMatchInlineSnapshot(`
6263
{
63-
"stderr": "⚡ - Loading configurations from /whook/packages/whook-example/dist/config/local/config.js".
64+
"stderr": "⚡ - Loading configurations from "file:///project/dist/config/local/config.js".
6465
🤖 - Initializing the \`$autoload\` service.
6566
🔴 - Running with "local" application environment.
6667
🔂 - Running with "test" node environment.
@@ -80,11 +81,11 @@ On air 🚀🌕
8081
);
8182

8283
expect({
83-
stdout: stdout.replace(/( |"|')([^ ]+)\/whook\//g, ' /whook/'),
84-
stderr: stderr.replace(/( |"|')([^ ]+)\/whook\//g, ' /whook/'),
84+
stdout: replacePaths(stdout),
85+
stderr: replacePaths(stderr),
8586
}).toMatchInlineSnapshot(`
8687
{
87-
"stderr": "⚡ - Loading configurations from /whook/packages/whook-example/dist/config/local/config.js".
88+
"stderr": "⚡ - Loading configurations from "file:///project/dist/config/local/config.js".
8889
🤖 - Initializing the \`$autoload\` service.
8990
🔴 - Running with "local" application environment.
9091
🔂 - Running with "test" node environment.
@@ -112,3 +113,10 @@ async function execCommand(
112113
});
113114
});
114115
}
116+
117+
function replacePaths(text: string) {
118+
return text.replaceAll(
119+
joinPaths(import.meta.dirname, '..').replace(/^file:\/\//, ''),
120+
'/project',
121+
);
122+
}

0 commit comments

Comments
 (0)