@whook/create 15.0.0 → 16.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/services/createWhook.d.ts +5 -4
- package/dist/services/createWhook.js +28 -28
- package/dist/services/createWhook.js.map +1 -1
- package/dist/services/createWhook.test.js +79 -76
- package/dist/services/createWhook.test.js.map +1 -1
- package/package.json +12 -11
- package/src/index.ts +7 -11
- package/src/services/__snapshots__/createWhook.test.ts.snap +194 -190
- package/src/services/createWhook.test.ts +79 -76
- package/src/services/createWhook.ts +41 -45
|
@@ -54,7 +54,7 @@ describe('initCreateWhook', () => {
|
|
|
54
54
|
name: 'super-project',
|
|
55
55
|
directory: '/home/whoiam/projects/yolo',
|
|
56
56
|
};
|
|
57
|
-
const
|
|
57
|
+
const outputFile = jest.fn<(file: PathLike, data: Buffer) => Promise<void>>();
|
|
58
58
|
const readFile = jest.fn<(file: PathLike) => Promise<Buffer>>();
|
|
59
59
|
const readdir = jest.fn<(file: PathLike) => Promise<string[]>>();
|
|
60
60
|
const exec = jest.fn<any>();
|
|
@@ -69,7 +69,7 @@ describe('initCreateWhook', () => {
|
|
|
69
69
|
|
|
70
70
|
beforeEach(() => {
|
|
71
71
|
axios.mockReset();
|
|
72
|
-
|
|
72
|
+
outputFile.mockReset();
|
|
73
73
|
readFile.mockReset();
|
|
74
74
|
readdir.mockReset();
|
|
75
75
|
exec.mockReset();
|
|
@@ -118,9 +118,9 @@ describe('initCreateWhook', () => {
|
|
|
118
118
|
axios.mockResolvedValueOnce({
|
|
119
119
|
data: 'node_modules',
|
|
120
120
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
122
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
123
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
124
124
|
exec.mockImplementationOnce((_, _2, cb) =>
|
|
125
125
|
cb(null, 'Initialized an empty git repository!'),
|
|
126
126
|
);
|
|
@@ -133,7 +133,7 @@ describe('initCreateWhook', () => {
|
|
|
133
133
|
SOURCE_DIR,
|
|
134
134
|
author,
|
|
135
135
|
project,
|
|
136
|
-
|
|
136
|
+
outputFile: outputFile as any,
|
|
137
137
|
readFile: readFile as any,
|
|
138
138
|
readdir: readdir as any,
|
|
139
139
|
exec: exec as any,
|
|
@@ -147,7 +147,7 @@ describe('initCreateWhook', () => {
|
|
|
147
147
|
|
|
148
148
|
expect(
|
|
149
149
|
JSON.parse(
|
|
150
|
-
|
|
150
|
+
outputFile.mock.calls
|
|
151
151
|
.find((call) => call[0].toString().endsWith('package.json'))?.[1]
|
|
152
152
|
?.toString() || '',
|
|
153
153
|
),
|
|
@@ -165,16 +165,16 @@ describe('initCreateWhook', () => {
|
|
|
165
165
|
"@whook/http-transaction": "<current_version>",
|
|
166
166
|
"@whook/swagger-ui": "<current_version>",
|
|
167
167
|
"@whook/whook": "<current_version>",
|
|
168
|
-
"application-services": "^
|
|
169
|
-
"common-services": "^
|
|
170
|
-
"http-auth-utils": "^
|
|
168
|
+
"application-services": "^6.0.0",
|
|
169
|
+
"common-services": "^16.0.1",
|
|
170
|
+
"http-auth-utils": "^6.0.0",
|
|
171
171
|
"jwt-service": "^10.0.4",
|
|
172
172
|
"knifecycle": "^17.0.1",
|
|
173
173
|
"openapi-schema-validator": "^12.1.3",
|
|
174
174
|
"openapi-types": "^12.1.3",
|
|
175
175
|
"pkg-dir": "^8.0.0",
|
|
176
|
-
"strict-qs": "^8.0.
|
|
177
|
-
"type-fest": "^4.
|
|
176
|
+
"strict-qs": "^8.0.2",
|
|
177
|
+
"type-fest": "^4.10.3",
|
|
178
178
|
"yerror": "^8.0.0",
|
|
179
179
|
"yhttperror": "^8.0.0",
|
|
180
180
|
},
|
|
@@ -186,7 +186,7 @@ describe('initCreateWhook', () => {
|
|
|
186
186
|
"@swc/jest": "^0.2.29",
|
|
187
187
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
188
188
|
"@typescript-eslint/parser": "^6.8.0",
|
|
189
|
-
"axios": "^1.6.
|
|
189
|
+
"axios": "^1.6.7",
|
|
190
190
|
"chokidar": "^3.5.3",
|
|
191
191
|
"esbuild-node-externals": "^1.9.0",
|
|
192
192
|
"eslint": "^8.52.0",
|
|
@@ -197,11 +197,11 @@ describe('initCreateWhook', () => {
|
|
|
197
197
|
"prettier": "^3.0.3",
|
|
198
198
|
"rimraf": "^5.0.5",
|
|
199
199
|
"schema2dts": "^5.3.0",
|
|
200
|
-
"
|
|
200
|
+
"tsx": "^4.7.1",
|
|
201
201
|
"typescript": "^5.2.2",
|
|
202
202
|
},
|
|
203
203
|
"engines": {
|
|
204
|
-
"node": ">=
|
|
204
|
+
"node": ">=20.11.1",
|
|
205
205
|
},
|
|
206
206
|
"eslintConfig": {
|
|
207
207
|
"env": {
|
|
@@ -286,21 +286,22 @@ describe('initCreateWhook', () => {
|
|
|
286
286
|
"architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
|
|
287
287
|
"build": "rimraf 'dist' && tsc --outDir dist",
|
|
288
288
|
"cover": "npm run jest -- --coverage",
|
|
289
|
-
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook}
|
|
290
|
-
"dev": "
|
|
289
|
+
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/dev",
|
|
290
|
+
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/dev.js",
|
|
291
|
+
"format": "npm run prettier",
|
|
291
292
|
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
|
|
292
293
|
"lint": "eslint 'src/**/*.ts'",
|
|
293
|
-
"postbuild": "
|
|
294
|
+
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
|
|
294
295
|
"prettier": "prettier --write 'src/**/*.ts'",
|
|
295
296
|
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
|
|
296
|
-
"
|
|
297
|
+
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/repl.js",
|
|
298
|
+
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
|
|
297
299
|
"test": "NODE_ENV=test npm run build && npm run jest",
|
|
298
300
|
"type-check": "tsc --pretty --noEmit",
|
|
299
|
-
"watch": "
|
|
300
|
-
"whook": "
|
|
301
|
-
"whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'}
|
|
302
|
-
"whook-dev": "
|
|
303
|
-
"whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
|
|
301
|
+
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
|
|
302
|
+
"whook": "NODE_ENV=\${NODE_ENV:-development} whook",
|
|
303
|
+
"whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
|
|
304
|
+
"whook-dev": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js",
|
|
304
305
|
},
|
|
305
306
|
"type": "module",
|
|
306
307
|
"types": "dist/index.d.ts",
|
|
@@ -309,7 +310,7 @@ describe('initCreateWhook', () => {
|
|
|
309
310
|
`);
|
|
310
311
|
expect({
|
|
311
312
|
copyCalls: copy.mock.calls,
|
|
312
|
-
|
|
313
|
+
outputFileCalls: outputFile.mock.calls,
|
|
313
314
|
readFileCalls: readFile.mock.calls,
|
|
314
315
|
execCalls: exec.mock.calls,
|
|
315
316
|
oraCalls: ora.mock.calls,
|
|
@@ -341,9 +342,9 @@ describe('initCreateWhook', () => {
|
|
|
341
342
|
),
|
|
342
343
|
);
|
|
343
344
|
axios.mockRejectedValueOnce(new YError('E_NETWORK'));
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
346
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
347
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
347
348
|
exec.mockImplementationOnce((_, _2, cb) => cb(new YError('E_ACCESS')));
|
|
348
349
|
exec.mockImplementationOnce((_, _2, cb) =>
|
|
349
350
|
cb(null, 'Installed dependencies!'),
|
|
@@ -354,7 +355,7 @@ describe('initCreateWhook', () => {
|
|
|
354
355
|
SOURCE_DIR,
|
|
355
356
|
author,
|
|
356
357
|
project,
|
|
357
|
-
|
|
358
|
+
outputFile: outputFile as any,
|
|
358
359
|
readFile: readFile as any,
|
|
359
360
|
readdir: readdir as any,
|
|
360
361
|
exec: exec as any,
|
|
@@ -368,7 +369,7 @@ describe('initCreateWhook', () => {
|
|
|
368
369
|
|
|
369
370
|
expect(
|
|
370
371
|
JSON.parse(
|
|
371
|
-
|
|
372
|
+
outputFile.mock.calls
|
|
372
373
|
.find((call) => call[0].toString().endsWith('package.json'))?.[1]
|
|
373
374
|
?.toString() || '',
|
|
374
375
|
),
|
|
@@ -386,16 +387,16 @@ describe('initCreateWhook', () => {
|
|
|
386
387
|
"@whook/http-transaction": "<current_version>",
|
|
387
388
|
"@whook/swagger-ui": "<current_version>",
|
|
388
389
|
"@whook/whook": "<current_version>",
|
|
389
|
-
"application-services": "^
|
|
390
|
-
"common-services": "^
|
|
391
|
-
"http-auth-utils": "^
|
|
390
|
+
"application-services": "^6.0.0",
|
|
391
|
+
"common-services": "^16.0.1",
|
|
392
|
+
"http-auth-utils": "^6.0.0",
|
|
392
393
|
"jwt-service": "^10.0.4",
|
|
393
394
|
"knifecycle": "^17.0.1",
|
|
394
395
|
"openapi-schema-validator": "^12.1.3",
|
|
395
396
|
"openapi-types": "^12.1.3",
|
|
396
397
|
"pkg-dir": "^8.0.0",
|
|
397
|
-
"strict-qs": "^8.0.
|
|
398
|
-
"type-fest": "^4.
|
|
398
|
+
"strict-qs": "^8.0.2",
|
|
399
|
+
"type-fest": "^4.10.3",
|
|
399
400
|
"yerror": "^8.0.0",
|
|
400
401
|
"yhttperror": "^8.0.0",
|
|
401
402
|
},
|
|
@@ -407,7 +408,7 @@ describe('initCreateWhook', () => {
|
|
|
407
408
|
"@swc/jest": "^0.2.29",
|
|
408
409
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
409
410
|
"@typescript-eslint/parser": "^6.8.0",
|
|
410
|
-
"axios": "^1.6.
|
|
411
|
+
"axios": "^1.6.7",
|
|
411
412
|
"chokidar": "^3.5.3",
|
|
412
413
|
"esbuild-node-externals": "^1.9.0",
|
|
413
414
|
"eslint": "^8.52.0",
|
|
@@ -418,11 +419,11 @@ describe('initCreateWhook', () => {
|
|
|
418
419
|
"prettier": "^3.0.3",
|
|
419
420
|
"rimraf": "^5.0.5",
|
|
420
421
|
"schema2dts": "^5.3.0",
|
|
421
|
-
"
|
|
422
|
+
"tsx": "^4.7.1",
|
|
422
423
|
"typescript": "^5.2.2",
|
|
423
424
|
},
|
|
424
425
|
"engines": {
|
|
425
|
-
"node": ">=
|
|
426
|
+
"node": ">=20.11.1",
|
|
426
427
|
},
|
|
427
428
|
"eslintConfig": {
|
|
428
429
|
"env": {
|
|
@@ -507,21 +508,22 @@ describe('initCreateWhook', () => {
|
|
|
507
508
|
"architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
|
|
508
509
|
"build": "rimraf 'dist' && tsc --outDir dist",
|
|
509
510
|
"cover": "npm run jest -- --coverage",
|
|
510
|
-
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook}
|
|
511
|
-
"dev": "
|
|
511
|
+
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/dev",
|
|
512
|
+
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/dev.js",
|
|
513
|
+
"format": "npm run prettier",
|
|
512
514
|
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
|
|
513
515
|
"lint": "eslint 'src/**/*.ts'",
|
|
514
|
-
"postbuild": "
|
|
516
|
+
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
|
|
515
517
|
"prettier": "prettier --write 'src/**/*.ts'",
|
|
516
518
|
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
|
|
517
|
-
"
|
|
519
|
+
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/repl.js",
|
|
520
|
+
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
|
|
518
521
|
"test": "NODE_ENV=test npm run build && npm run jest",
|
|
519
522
|
"type-check": "tsc --pretty --noEmit",
|
|
520
|
-
"watch": "
|
|
521
|
-
"whook": "
|
|
522
|
-
"whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'}
|
|
523
|
-
"whook-dev": "
|
|
524
|
-
"whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
|
|
523
|
+
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
|
|
524
|
+
"whook": "NODE_ENV=\${NODE_ENV:-development} whook",
|
|
525
|
+
"whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
|
|
526
|
+
"whook-dev": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js",
|
|
525
527
|
},
|
|
526
528
|
"type": "module",
|
|
527
529
|
"types": "dist/index.d.ts",
|
|
@@ -530,7 +532,7 @@ describe('initCreateWhook', () => {
|
|
|
530
532
|
`);
|
|
531
533
|
expect({
|
|
532
534
|
copyCalls: copy.mock.calls,
|
|
533
|
-
|
|
535
|
+
outputFileCalls: outputFile.mock.calls,
|
|
534
536
|
readFileCalls: readFile.mock.calls,
|
|
535
537
|
execCalls: exec.mock.calls,
|
|
536
538
|
oraCalls: ora.mock.calls,
|
|
@@ -547,9 +549,9 @@ describe('initCreateWhook', () => {
|
|
|
547
549
|
axios.mockResolvedValueOnce({
|
|
548
550
|
data: 'node_modules',
|
|
549
551
|
});
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
552
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
553
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
554
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
553
555
|
exec.mockImplementationOnce((_, _2, cb) => cb(new YError('E_ACCESS')));
|
|
554
556
|
exec.mockImplementationOnce((_, _2, cb) =>
|
|
555
557
|
cb(null, 'Installed dependencies!'),
|
|
@@ -560,7 +562,7 @@ describe('initCreateWhook', () => {
|
|
|
560
562
|
SOURCE_DIR,
|
|
561
563
|
author,
|
|
562
564
|
project,
|
|
563
|
-
|
|
565
|
+
outputFile: outputFile as any,
|
|
564
566
|
readFile: readFile as any,
|
|
565
567
|
readdir: readdir as any,
|
|
566
568
|
exec: exec as any,
|
|
@@ -574,7 +576,7 @@ describe('initCreateWhook', () => {
|
|
|
574
576
|
|
|
575
577
|
expect(
|
|
576
578
|
JSON.parse(
|
|
577
|
-
|
|
579
|
+
outputFile.mock.calls
|
|
578
580
|
.find((call) => call[0].toString().endsWith('package.json'))?.[1]
|
|
579
581
|
?.toString() || '',
|
|
580
582
|
),
|
|
@@ -592,16 +594,16 @@ describe('initCreateWhook', () => {
|
|
|
592
594
|
"@whook/http-transaction": "<current_version>",
|
|
593
595
|
"@whook/swagger-ui": "<current_version>",
|
|
594
596
|
"@whook/whook": "<current_version>",
|
|
595
|
-
"application-services": "^
|
|
596
|
-
"common-services": "^
|
|
597
|
-
"http-auth-utils": "^
|
|
597
|
+
"application-services": "^6.0.0",
|
|
598
|
+
"common-services": "^16.0.1",
|
|
599
|
+
"http-auth-utils": "^6.0.0",
|
|
598
600
|
"jwt-service": "^10.0.4",
|
|
599
601
|
"knifecycle": "^17.0.1",
|
|
600
602
|
"openapi-schema-validator": "^12.1.3",
|
|
601
603
|
"openapi-types": "^12.1.3",
|
|
602
604
|
"pkg-dir": "^8.0.0",
|
|
603
|
-
"strict-qs": "^8.0.
|
|
604
|
-
"type-fest": "^4.
|
|
605
|
+
"strict-qs": "^8.0.2",
|
|
606
|
+
"type-fest": "^4.10.3",
|
|
605
607
|
"yerror": "^8.0.0",
|
|
606
608
|
"yhttperror": "^8.0.0",
|
|
607
609
|
},
|
|
@@ -613,7 +615,7 @@ describe('initCreateWhook', () => {
|
|
|
613
615
|
"@swc/jest": "^0.2.29",
|
|
614
616
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
615
617
|
"@typescript-eslint/parser": "^6.8.0",
|
|
616
|
-
"axios": "^1.6.
|
|
618
|
+
"axios": "^1.6.7",
|
|
617
619
|
"chokidar": "^3.5.3",
|
|
618
620
|
"esbuild-node-externals": "^1.9.0",
|
|
619
621
|
"eslint": "^8.52.0",
|
|
@@ -624,11 +626,11 @@ describe('initCreateWhook', () => {
|
|
|
624
626
|
"prettier": "^3.0.3",
|
|
625
627
|
"rimraf": "^5.0.5",
|
|
626
628
|
"schema2dts": "^5.3.0",
|
|
627
|
-
"
|
|
629
|
+
"tsx": "^4.7.1",
|
|
628
630
|
"typescript": "^5.2.2",
|
|
629
631
|
},
|
|
630
632
|
"engines": {
|
|
631
|
-
"node": ">=
|
|
633
|
+
"node": ">=20.11.1",
|
|
632
634
|
},
|
|
633
635
|
"eslintConfig": {
|
|
634
636
|
"env": {
|
|
@@ -713,21 +715,22 @@ describe('initCreateWhook', () => {
|
|
|
713
715
|
"architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
|
|
714
716
|
"build": "rimraf 'dist' && tsc --outDir dist",
|
|
715
717
|
"cover": "npm run jest -- --coverage",
|
|
716
|
-
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook}
|
|
717
|
-
"dev": "
|
|
718
|
+
"debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} tsx bin/dev",
|
|
719
|
+
"dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/dev.js",
|
|
720
|
+
"format": "npm run prettier",
|
|
718
721
|
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
|
|
719
722
|
"lint": "eslint 'src/**/*.ts'",
|
|
720
|
-
"postbuild": "
|
|
723
|
+
"postbuild": "NODE_ENV=\${NODE_ENV:-development} tsx bin/build.js",
|
|
721
724
|
"prettier": "prettier --write 'src/**/*.ts'",
|
|
722
725
|
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
|
|
723
|
-
"
|
|
726
|
+
"repl": "NODE_ENV=\${NODE_ENV:-development} tsx bin/repl.js",
|
|
727
|
+
"start": "NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
|
|
724
728
|
"test": "NODE_ENV=test npm run build && npm run jest",
|
|
725
729
|
"type-check": "tsc --pretty --noEmit",
|
|
726
|
-
"watch": "
|
|
727
|
-
"whook": "
|
|
728
|
-
"whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'}
|
|
729
|
-
"whook-dev": "
|
|
730
|
-
"whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
|
|
730
|
+
"watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 tsx bin/watch.js",
|
|
731
|
+
"whook": "NODE_ENV=\${NODE_ENV:-development} whook",
|
|
732
|
+
"whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} tsx bin/whook.js",
|
|
733
|
+
"whook-dev": "NODE_ENV=\${NODE_ENV:-development} tsx bin/whook.js",
|
|
731
734
|
},
|
|
732
735
|
"type": "module",
|
|
733
736
|
"types": "dist/index.d.ts",
|
|
@@ -736,7 +739,7 @@ describe('initCreateWhook', () => {
|
|
|
736
739
|
`);
|
|
737
740
|
expect({
|
|
738
741
|
copyCalls: copy.mock.calls,
|
|
739
|
-
|
|
742
|
+
outputFileCalls: outputFile.mock.calls,
|
|
740
743
|
readFileCalls: readFile.mock.calls,
|
|
741
744
|
execCalls: exec.mock.calls,
|
|
742
745
|
oraCalls: ora.mock.calls,
|
|
@@ -753,9 +756,9 @@ describe('initCreateWhook', () => {
|
|
|
753
756
|
axios.mockResolvedValueOnce({
|
|
754
757
|
data: 'node_modules',
|
|
755
758
|
});
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
760
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
761
|
+
outputFile.mockResolvedValueOnce(undefined);
|
|
759
762
|
exec.mockImplementationOnce((_, _2, cb) => cb(null, ''));
|
|
760
763
|
exec.mockImplementationOnce((_, _2, cb) =>
|
|
761
764
|
cb(null, 'Installed dependencies!'),
|
|
@@ -767,7 +770,7 @@ describe('initCreateWhook', () => {
|
|
|
767
770
|
SOURCE_DIR,
|
|
768
771
|
author,
|
|
769
772
|
project,
|
|
770
|
-
|
|
773
|
+
outputFile: outputFile as any,
|
|
771
774
|
readFile: readFile as any,
|
|
772
775
|
readdir: readdir as any,
|
|
773
776
|
exec: exec as any,
|
|
@@ -792,7 +795,7 @@ describe('initCreateWhook', () => {
|
|
|
792
795
|
`);
|
|
793
796
|
expect({
|
|
794
797
|
copyCalls: copy.mock.calls,
|
|
795
|
-
|
|
798
|
+
outputFileCalls: outputFile.mock.calls,
|
|
796
799
|
readFileCalls: readFile.mock.calls,
|
|
797
800
|
execCalls: exec.mock.calls,
|
|
798
801
|
oraCalls: ora.mock.calls,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { autoService } from 'knifecycle';
|
|
2
|
-
import
|
|
2
|
+
import { exec as _exec } from 'node:child_process';
|
|
3
|
+
import { readFile as _readFile, readdir as _readdir } from 'node:fs/promises';
|
|
4
|
+
import { copy as _copy, outputFile as _outputFile } from 'fs-extra';
|
|
5
|
+
import { join, relative } from 'node:path';
|
|
3
6
|
import _axios from 'axios';
|
|
4
7
|
import _ora from 'ora';
|
|
5
8
|
import { printStackTrace, YError } from 'yerror';
|
|
6
|
-
import { exec as _exec } from 'child_process';
|
|
7
|
-
import { default as fsExtra } from 'fs-extra';
|
|
8
9
|
import type { LogService } from 'common-services';
|
|
9
10
|
import type { ProjectService } from './project.js';
|
|
10
11
|
import type { AuthorService } from './author.js';
|
|
@@ -13,12 +14,6 @@ const GIT_IGNORE_URL =
|
|
|
13
14
|
'https://www.toptal.com/developers/gitignore/api/osx,node,linux';
|
|
14
15
|
const README_REGEXP =
|
|
15
16
|
/^(?:[^]*)\[\/\/\]: # \(::contents:start\)\r?\n\r?\n([^]*)\r?\n\r?\n\[\/\/\]: # \(::contents:end\)(?:[^]*)$/gm;
|
|
16
|
-
const {
|
|
17
|
-
writeFile: _writeFile,
|
|
18
|
-
readFile: _readFile,
|
|
19
|
-
copy: _copy,
|
|
20
|
-
readdir: _readdir,
|
|
21
|
-
} = fsExtra;
|
|
22
17
|
|
|
23
18
|
export type CreateWhookService = () => Promise<void>;
|
|
24
19
|
|
|
@@ -27,7 +22,7 @@ export default autoService(async function initCreateWhook({
|
|
|
27
22
|
SOURCE_DIR,
|
|
28
23
|
author,
|
|
29
24
|
project,
|
|
30
|
-
|
|
25
|
+
outputFile = _outputFile,
|
|
31
26
|
readFile = _readFile,
|
|
32
27
|
readdir = _readdir,
|
|
33
28
|
exec = _exec,
|
|
@@ -40,7 +35,7 @@ export default autoService(async function initCreateWhook({
|
|
|
40
35
|
SOURCE_DIR: string;
|
|
41
36
|
author: AuthorService;
|
|
42
37
|
project: ProjectService;
|
|
43
|
-
|
|
38
|
+
outputFile: typeof _outputFile;
|
|
44
39
|
readFile: typeof _readFile;
|
|
45
40
|
readdir: typeof _readdir;
|
|
46
41
|
exec: typeof _exec;
|
|
@@ -53,7 +48,7 @@ export default autoService(async function initCreateWhook({
|
|
|
53
48
|
log('warning', "🏁️ - Starting Whook project's creation!");
|
|
54
49
|
|
|
55
50
|
const basePackageJSON = JSON.parse(
|
|
56
|
-
(await readFile(
|
|
51
|
+
(await readFile(join(SOURCE_DIR, 'package.json'))).toString(),
|
|
57
52
|
);
|
|
58
53
|
|
|
59
54
|
const finalPackageJSON = {
|
|
@@ -89,37 +84,44 @@ export default autoService(async function initCreateWhook({
|
|
|
89
84
|
metapak: undefined,
|
|
90
85
|
};
|
|
91
86
|
|
|
87
|
+
await readFile(join(SOURCE_DIR, 'src/watch.ts')).then((data) => {
|
|
88
|
+
return outputFile(
|
|
89
|
+
join(project.directory, 'src/watch.ts'),
|
|
90
|
+
data.toString().replace('../../', './'),
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
92
94
|
await Promise.all([
|
|
93
95
|
copy(SOURCE_DIR, project.directory, {
|
|
94
96
|
filter: (src, dest) => {
|
|
95
97
|
if (
|
|
96
|
-
src.startsWith(
|
|
97
|
-
src.startsWith(
|
|
98
|
-
src.startsWith(
|
|
98
|
+
src.startsWith(join(SOURCE_DIR, 'node_modules')) ||
|
|
99
|
+
src.startsWith(join(SOURCE_DIR, 'dist')) ||
|
|
100
|
+
src.startsWith(join(SOURCE_DIR, 'coverage')) ||
|
|
99
101
|
[
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
join(SOURCE_DIR, 'package.json'),
|
|
103
|
+
join(SOURCE_DIR, 'package-lock.json'),
|
|
104
|
+
join(SOURCE_DIR, 'LICENSE'),
|
|
105
|
+
join(SOURCE_DIR, 'README.md'),
|
|
106
|
+
join(SOURCE_DIR, 'src/watch.ts'),
|
|
105
107
|
].includes(src)
|
|
106
108
|
) {
|
|
107
109
|
log(
|
|
108
110
|
'debug',
|
|
109
|
-
|
|
111
|
+
`💱 - Discarding "${src}" => "${dest} ("${relative(
|
|
110
112
|
src,
|
|
111
113
|
SOURCE_DIR,
|
|
112
114
|
)}").`,
|
|
113
115
|
);
|
|
114
116
|
return false;
|
|
115
117
|
}
|
|
116
|
-
log('debug',
|
|
118
|
+
log('debug', `💱 - Moving "${src}" => "${dest}".`);
|
|
117
119
|
return true;
|
|
118
120
|
},
|
|
119
121
|
}),
|
|
120
|
-
readFile(
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
readFile(join(SOURCE_DIR, 'README.md')).then((data) =>
|
|
123
|
+
outputFile(
|
|
124
|
+
join(project.directory, 'README.md'),
|
|
123
125
|
`# ${project.name}
|
|
124
126
|
|
|
125
127
|
${data.toString().replace(README_REGEXP, '$1')}
|
|
@@ -130,12 +132,12 @@ ${author.name}
|
|
|
130
132
|
`,
|
|
131
133
|
),
|
|
132
134
|
),
|
|
133
|
-
...(await readdir(
|
|
135
|
+
...(await readdir(join(SOURCE_DIR, 'src', 'config'))).map(
|
|
134
136
|
(environment) =>
|
|
135
137
|
environment === 'common'
|
|
136
138
|
? Promise.resolve()
|
|
137
|
-
:
|
|
138
|
-
|
|
139
|
+
: outputFile(
|
|
140
|
+
join(project.directory, `.env.app.${environment}`),
|
|
139
141
|
`# Loaded when APP_ENV=${environment}
|
|
140
142
|
|
|
141
143
|
# For JWT signing
|
|
@@ -143,8 +145,8 @@ JWT_SECRET=oudelali
|
|
|
143
145
|
`,
|
|
144
146
|
),
|
|
145
147
|
),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
outputFile(
|
|
149
|
+
join(project.directory, '.env.node.development'),
|
|
148
150
|
`# Loaded when NODE_ENV=development
|
|
149
151
|
|
|
150
152
|
# Allow to kill the process with still open sockets
|
|
@@ -154,18 +156,12 @@ DESTROY_SOCKETS=1'
|
|
|
154
156
|
DEV_MODE=1
|
|
155
157
|
`,
|
|
156
158
|
),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
outputFile(
|
|
160
|
+
join(project.directory, 'package.json'),
|
|
159
161
|
JSON.stringify(finalPackageJSON, null, 2),
|
|
160
162
|
),
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
path.join(project.directory, 'src/watch.ts'),
|
|
164
|
-
data.toString().replace('../../', './'),
|
|
165
|
-
);
|
|
166
|
-
}),
|
|
167
|
-
writeFile(
|
|
168
|
-
path.join(project.directory, 'tsconfig.json'),
|
|
163
|
+
outputFile(
|
|
164
|
+
join(project.directory, 'tsconfig.json'),
|
|
169
165
|
JSON.stringify(
|
|
170
166
|
{
|
|
171
167
|
compilerOptions: {
|
|
@@ -189,8 +185,8 @@ DEV_MODE=1
|
|
|
189
185
|
2,
|
|
190
186
|
),
|
|
191
187
|
),
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
outputFile(
|
|
189
|
+
join(project.directory, 'LICENSE'),
|
|
194
190
|
`Copyright ${author.name}, all rights reserved.`,
|
|
195
191
|
),
|
|
196
192
|
axios({
|
|
@@ -202,8 +198,8 @@ DEV_MODE=1
|
|
|
202
198
|
},
|
|
203
199
|
})
|
|
204
200
|
.then((response) =>
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
outputFile(
|
|
202
|
+
join(project.directory, '.gitignore'),
|
|
207
203
|
`${response.data.toString()}
|
|
208
204
|
|
|
209
205
|
# Whook's files
|
|
@@ -277,7 +273,7 @@ builds/
|
|
|
277
273
|
|
|
278
274
|
log(
|
|
279
275
|
'warning',
|
|
280
|
-
`➕ - Run \`cd ${
|
|
276
|
+
`➕ - Run \`cd ${relative(
|
|
281
277
|
CWD,
|
|
282
278
|
project.directory,
|
|
283
279
|
)}\` to enter the project.`,
|