@whook/create 12.1.0 → 13.1.0

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.
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { describe, it, beforeEach, jest, expect } from '@jest/globals';
2
3
  import initCreateWhook from './createWhook.js';
3
4
  import { YError } from 'yerror';
@@ -8,6 +9,26 @@ import type { PathLike } from 'fs-extra';
8
9
  const _packageJSON = JSON.parse(
9
10
  readFileSync('../whook-example/package.json').toString(),
10
11
  );
12
+ const FILE_CONTENTS = {
13
+ 'README.md': `
14
+ # test
15
+ > yolo
16
+
17
+ [//]: # (::contents:start)
18
+
19
+ YOLO
20
+
21
+ [//]: # (::contents:end)
22
+
23
+ # Authors
24
+ Mr Bean
25
+ `,
26
+ 'watch.ts': `
27
+ the watch.ts file contents
28
+ with'../../' replaced so
29
+ equal to './'!
30
+ `,
31
+ };
11
32
 
12
33
  describe('initCreateWhook', () => {
13
34
  const CWD = '/home/whoiam/projects/';
@@ -59,27 +80,23 @@ describe('initCreateWhook', () => {
59
80
  oraInstance.start.mockReset();
60
81
  oraInstance.start.mockReturnValue(oraInstance);
61
82
  oraInstance.stopAndPersist.mockReset();
62
- readFile.mockResolvedValue(
63
- Buffer.from(`
64
- # test
65
- > yolo
66
-
67
- [//]: # (::contents:start)
68
-
69
- YOLO
70
-
71
- [//]: # (::contents:end)
72
-
73
- # Authors
74
- Mr Bean
83
+ readFile.mockImplementation(async (file) => {
84
+ if (file.toString().endsWith('package.json')) {
85
+ return Buffer.from(JSON.stringify(packageJSON));
86
+ }
87
+ const key = Object.keys(FILE_CONTENTS).find((key) =>
88
+ file.toString().endsWith(key),
89
+ );
75
90
 
76
- `),
77
- );
91
+ if (key) {
92
+ return Buffer.from(FILE_CONTENTS[key]);
93
+ }
94
+ return Buffer.from('NO_FILE_CONTENTS');
95
+ });
78
96
  });
79
97
 
80
98
  it('should work', async () => {
81
- readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
82
- readdir.mockResolvedValueOnce(['development', 'production']);
99
+ readdir.mockResolvedValueOnce(['local', 'production']);
83
100
  copy.mockImplementationOnce((_, _2, { filter }) =>
84
101
  Promise.all(
85
102
  [
@@ -135,159 +152,162 @@ Mr Bean
135
152
  ?.toString() || '',
136
153
  ),
137
154
  ).toMatchInlineSnapshot(`
138
- {
139
- "author": {
140
- "email": "wayne@warner.com",
141
- "name": "Wayne Campbell",
142
- },
143
- "dependencies": {
144
- "@whook/authorization": "<current_version>",
145
- "@whook/cors": "<current_version>",
146
- "@whook/http-router": "<current_version>",
147
- "@whook/http-server": "<current_version>",
148
- "@whook/http-transaction": "<current_version>",
149
- "@whook/swagger-ui": "<current_version>",
150
- "@whook/whook": "<current_version>",
151
- "common-services": "^12.1.0",
152
- "http-auth-utils": "^3.0.5",
153
- "jwt-service": "^9.0.4",
154
- "knifecycle": "^14.1.0",
155
- "openapi-schema-validator": "^12.0.2",
156
- "openapi-types": "^12.1.0",
157
- "pkg-dir": "^7.0.0",
158
- "strict-qs": "^7.0.2",
159
- "type-fest": "^3.4.0",
160
- "yerror": "^6.2.1",
161
- "yhttperror": "^6.1.2",
162
- },
163
- "description": "A new Whook project",
164
- "devDependencies": {
165
- "@typescript-eslint/eslint-plugin": "^5.36.0",
166
- "@typescript-eslint/parser": "^5.36.0",
167
- "axios": "^1.2.1",
168
- "chokidar": "^3.5.1",
169
- "esbuild": "^0.15.6",
170
- "esbuild-jest": "^0.5.0",
171
- "esbuild-node-externals": "^1.5.0",
172
- "eslint": "^8.23.0",
173
- "eslint-config-prettier": "^8.5.0",
174
- "eslint-plugin-prettier": "^4.2.1",
175
- "jest": "^29.0.1",
176
- "jsarch": "^6.0.0",
177
- "parse-gitignore": "^1.0.1",
178
- "prettier": "^2.7.1",
179
- "rimraf": "^3.0.2",
180
- "schema2dts": "^4.1.4",
181
- "ts-node": "^10.8.1",
182
- "typescript": "^4.8.2",
183
- },
184
- "engines": {
185
- "node": ">=16.15.0",
186
- },
187
- "eslintConfig": {
188
- "env": {
189
- "es6": true,
190
- "jest": true,
191
- "mocha": true,
192
- "node": true,
193
- },
194
- "extends": [
195
- "eslint:recommended",
196
- "plugin:prettier/recommended",
197
- "plugin:@typescript-eslint/eslint-recommended",
198
- "plugin:@typescript-eslint/recommended",
199
- ],
200
- "ignorePatterns": [
201
- "*.d.ts",
202
- ],
203
- "parser": "@typescript-eslint/parser",
204
- "parserOptions": {
205
- "ecmaVersion": 2018,
206
- "modules": true,
207
- "sourceType": "script",
208
- },
209
- "plugins": [
210
- "prettier",
211
- ],
212
- "rules": {
213
- "prettier/prettier": "error",
214
- },
215
- },
216
- "files": [
217
- "bin",
218
- "dist",
219
- "src",
220
- "LICENSE",
221
- "README.md",
222
- "CHANGELOG.md",
223
- ],
224
- "jest": {
225
- "coverageReporters": [
226
- "lcov",
227
- "html",
228
- ],
229
- "extensionsToTreatAsEsm": [
230
- ".ts",
231
- ],
232
- "moduleNameMapper": {
233
- "#(.*)": "<rootDir>/../../node_modules/$1",
234
- "(.+)\\.js": "$1",
235
- },
236
- "roots": [
237
- "<rootDir>/src",
238
- ],
239
- "testEnvironment": "node",
240
- "testPathIgnorePatterns": [
241
- "/node_modules/",
242
- ],
243
- "transform": {
244
- "^.+\\.tsx?$": [
245
- "esbuild-jest",
246
- {
247
- "format": "esm",
248
- "sourcemap": true,
249
- },
250
- ],
251
- },
252
- },
253
- "keywords": [
254
- "whook",
255
- ],
256
- "license": "SEE LICENSE",
257
- "main": "dist/index.js",
258
- "name": "super-project",
259
- "prettier": {
260
- "printWidth": 80,
261
- "proseWrap": "always",
262
- "semi": true,
263
- "singleQuote": true,
264
- "trailingComma": "all",
265
- },
266
- "private": true,
267
- "scripts": {
268
- "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
269
- "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
270
- "build": "rimraf -f 'dist' && tsc --outDir dist",
271
- "cover": "npm run jest -- --coverage",
272
- "debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --logError bin/dev",
273
- "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/dev.js",
274
- "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
275
- "lint": "eslint 'src/**/*.ts'",
276
- "postbuild": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
277
- "prettier": "prettier --write 'src/**/*.ts'",
278
- "start": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
279
- "test": "NODE_ENV=test npm run build && npm run jest",
280
- "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/watch.js",
281
- "whook": "NODE_ENV=\${NODE_ENV:-development} whook",
282
- "whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} ts-node --esm --logError --files -- bin/whook.js",
283
- "whook-dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/whook.js",
284
- "whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
285
- },
286
- "type": "module",
287
- "types": "dist/index.d.ts",
288
- "version": "0.0.0",
289
- }
290
- `);
155
+ {
156
+ "author": {
157
+ "email": "wayne@warner.com",
158
+ "name": "Wayne Campbell",
159
+ },
160
+ "dependencies": {
161
+ "@whook/authorization": "<current_version>",
162
+ "@whook/cors": "<current_version>",
163
+ "@whook/http-router": "<current_version>",
164
+ "@whook/http-server": "<current_version>",
165
+ "@whook/http-transaction": "<current_version>",
166
+ "@whook/swagger-ui": "<current_version>",
167
+ "@whook/whook": "<current_version>",
168
+ "application-services": "^4.0.0",
169
+ "common-services": "^15.0.0",
170
+ "http-auth-utils": "^5.0.1",
171
+ "jwt-service": "^10.0.4",
172
+ "knifecycle": "^17.0.1",
173
+ "openapi-schema-validator": "^12.1.3",
174
+ "openapi-types": "^12.1.3",
175
+ "pkg-dir": "^7.0.0",
176
+ "strict-qs": "^8.0.1",
177
+ "type-fest": "^4.2.0",
178
+ "yerror": "^8.0.0",
179
+ "yhttperror": "^8.0.0",
180
+ },
181
+ "description": "A new Whook project",
182
+ "devDependencies": {
183
+ "@swc/cli": "^0.1.62",
184
+ "@swc/core": "^1.3.77",
185
+ "@swc/helpers": "^0.5.1",
186
+ "@swc/jest": "^0.2.29",
187
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
188
+ "@typescript-eslint/parser": "^6.4.0",
189
+ "axios": "^1.4.0",
190
+ "chokidar": "^3.5.1",
191
+ "esbuild-node-externals": "^1.5.0",
192
+ "eslint": "^8.47.0",
193
+ "eslint-config-prettier": "^9.0.0",
194
+ "eslint-plugin-prettier": "^5.0.0",
195
+ "jest": "^29.6.2",
196
+ "jsarch": "^6.0.3",
197
+ "parse-gitignore": "^1.0.1",
198
+ "prettier": "^3.0.2",
199
+ "rimraf": "^5.0.1",
200
+ "schema2dts": "^5.0.1",
201
+ "ts-node": "^10.8.1",
202
+ "typescript": "^5.1.6",
203
+ },
204
+ "engines": {
205
+ "node": ">=18.16.0",
206
+ },
207
+ "eslintConfig": {
208
+ "env": {
209
+ "es6": true,
210
+ "jest": true,
211
+ "mocha": true,
212
+ "node": true,
213
+ },
214
+ "extends": [
215
+ "eslint:recommended",
216
+ "plugin:prettier/recommended",
217
+ "plugin:@typescript-eslint/eslint-recommended",
218
+ "plugin:@typescript-eslint/recommended",
219
+ ],
220
+ "ignorePatterns": [
221
+ "*.d.ts",
222
+ ],
223
+ "parser": "@typescript-eslint/parser",
224
+ "parserOptions": {
225
+ "ecmaVersion": 2018,
226
+ "modules": true,
227
+ "sourceType": "script",
228
+ },
229
+ "plugins": [
230
+ "prettier",
231
+ ],
232
+ "rules": {
233
+ "prettier/prettier": "error",
234
+ },
235
+ },
236
+ "files": [
237
+ "bin",
238
+ "dist",
239
+ "src",
240
+ "LICENSE",
241
+ "README.md",
242
+ "CHANGELOG.md",
243
+ ],
244
+ "jest": {
245
+ "coverageReporters": [
246
+ "lcov",
247
+ "html",
248
+ ],
249
+ "extensionsToTreatAsEsm": [
250
+ ".ts",
251
+ ],
252
+ "moduleNameMapper": {
253
+ "#(.*)": "<rootDir>/../../node_modules/$1",
254
+ "(.+)\\.js": "$1",
255
+ },
256
+ "prettierPath": null,
257
+ "roots": [
258
+ "<rootDir>/src",
259
+ ],
260
+ "testEnvironment": "node",
261
+ "testPathIgnorePatterns": [
262
+ "/node_modules/",
263
+ ],
264
+ "transform": {
265
+ "^.+\\.tsx?$": [
266
+ "@swc/jest",
267
+ {},
268
+ ],
269
+ },
270
+ },
271
+ "keywords": [
272
+ "whook",
273
+ ],
274
+ "license": "SEE LICENSE",
275
+ "main": "dist/index.js",
276
+ "name": "super-project",
277
+ "prettier": {
278
+ "printWidth": 80,
279
+ "proseWrap": "always",
280
+ "semi": true,
281
+ "singleQuote": true,
282
+ "trailingComma": "all",
283
+ },
284
+ "private": true,
285
+ "scripts": {
286
+ "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
287
+ "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
288
+ "build": "rimraf 'dist' && tsc --outDir dist",
289
+ "cover": "npm run jest -- --coverage",
290
+ "debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --logError bin/dev",
291
+ "dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/dev.js",
292
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
293
+ "lint": "eslint 'src/**/*.ts'",
294
+ "postbuild": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
295
+ "prettier": "prettier --write 'src/**/*.ts'",
296
+ "rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
297
+ "start": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
298
+ "test": "NODE_ENV=test npm run build && npm run jest",
299
+ "type-check": "tsc --pretty --noEmit",
300
+ "watch": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/watch.js",
301
+ "whook": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} whook",
302
+ "whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} ts-node --esm --logError --files -- bin/whook.js",
303
+ "whook-dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/whook.js",
304
+ "whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
305
+ },
306
+ "type": "module",
307
+ "types": "dist/index.d.ts",
308
+ "version": "0.0.0",
309
+ }
310
+ `);
291
311
  expect({
292
312
  copyCalls: copy.mock.calls,
293
313
  writeFileCalls: writeFile.mock.calls,
@@ -302,8 +322,7 @@ Mr Bean
302
322
  });
303
323
 
304
324
  it('should handle network issues', async () => {
305
- readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
306
- readdir.mockResolvedValueOnce(['development', 'production']);
325
+ readdir.mockResolvedValueOnce(['local', 'production']);
307
326
  copy.mockImplementationOnce((_, _2, { filter }) =>
308
327
  Promise.all(
309
328
  [
@@ -355,159 +374,162 @@ Mr Bean
355
374
  ?.toString() || '',
356
375
  ),
357
376
  ).toMatchInlineSnapshot(`
358
- {
359
- "author": {
360
- "email": "wayne@warner.com",
361
- "name": "Wayne Campbell",
362
- },
363
- "dependencies": {
364
- "@whook/authorization": "<current_version>",
365
- "@whook/cors": "<current_version>",
366
- "@whook/http-router": "<current_version>",
367
- "@whook/http-server": "<current_version>",
368
- "@whook/http-transaction": "<current_version>",
369
- "@whook/swagger-ui": "<current_version>",
370
- "@whook/whook": "<current_version>",
371
- "common-services": "^12.1.0",
372
- "http-auth-utils": "^3.0.5",
373
- "jwt-service": "^9.0.4",
374
- "knifecycle": "^14.1.0",
375
- "openapi-schema-validator": "^12.0.2",
376
- "openapi-types": "^12.1.0",
377
- "pkg-dir": "^7.0.0",
378
- "strict-qs": "^7.0.2",
379
- "type-fest": "^3.4.0",
380
- "yerror": "^6.2.1",
381
- "yhttperror": "^6.1.2",
382
- },
383
- "description": "A new Whook project",
384
- "devDependencies": {
385
- "@typescript-eslint/eslint-plugin": "^5.36.0",
386
- "@typescript-eslint/parser": "^5.36.0",
387
- "axios": "^1.2.1",
388
- "chokidar": "^3.5.1",
389
- "esbuild": "^0.15.6",
390
- "esbuild-jest": "^0.5.0",
391
- "esbuild-node-externals": "^1.5.0",
392
- "eslint": "^8.23.0",
393
- "eslint-config-prettier": "^8.5.0",
394
- "eslint-plugin-prettier": "^4.2.1",
395
- "jest": "^29.0.1",
396
- "jsarch": "^6.0.0",
397
- "parse-gitignore": "^1.0.1",
398
- "prettier": "^2.7.1",
399
- "rimraf": "^3.0.2",
400
- "schema2dts": "^4.1.4",
401
- "ts-node": "^10.8.1",
402
- "typescript": "^4.8.2",
403
- },
404
- "engines": {
405
- "node": ">=16.15.0",
406
- },
407
- "eslintConfig": {
408
- "env": {
409
- "es6": true,
410
- "jest": true,
411
- "mocha": true,
412
- "node": true,
413
- },
414
- "extends": [
415
- "eslint:recommended",
416
- "plugin:prettier/recommended",
417
- "plugin:@typescript-eslint/eslint-recommended",
418
- "plugin:@typescript-eslint/recommended",
419
- ],
420
- "ignorePatterns": [
421
- "*.d.ts",
422
- ],
423
- "parser": "@typescript-eslint/parser",
424
- "parserOptions": {
425
- "ecmaVersion": 2018,
426
- "modules": true,
427
- "sourceType": "script",
428
- },
429
- "plugins": [
430
- "prettier",
431
- ],
432
- "rules": {
433
- "prettier/prettier": "error",
434
- },
435
- },
436
- "files": [
437
- "bin",
438
- "dist",
439
- "src",
440
- "LICENSE",
441
- "README.md",
442
- "CHANGELOG.md",
443
- ],
444
- "jest": {
445
- "coverageReporters": [
446
- "lcov",
447
- "html",
448
- ],
449
- "extensionsToTreatAsEsm": [
450
- ".ts",
451
- ],
452
- "moduleNameMapper": {
453
- "#(.*)": "<rootDir>/../../node_modules/$1",
454
- "(.+)\\.js": "$1",
455
- },
456
- "roots": [
457
- "<rootDir>/src",
458
- ],
459
- "testEnvironment": "node",
460
- "testPathIgnorePatterns": [
461
- "/node_modules/",
462
- ],
463
- "transform": {
464
- "^.+\\.tsx?$": [
465
- "esbuild-jest",
466
- {
467
- "format": "esm",
468
- "sourcemap": true,
469
- },
470
- ],
471
- },
472
- },
473
- "keywords": [
474
- "whook",
475
- ],
476
- "license": "SEE LICENSE",
477
- "main": "dist/index.js",
478
- "name": "super-project",
479
- "prettier": {
480
- "printWidth": 80,
481
- "proseWrap": "always",
482
- "semi": true,
483
- "singleQuote": true,
484
- "trailingComma": "all",
485
- },
486
- "private": true,
487
- "scripts": {
488
- "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
489
- "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
490
- "build": "rimraf -f 'dist' && tsc --outDir dist",
491
- "cover": "npm run jest -- --coverage",
492
- "debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --logError bin/dev",
493
- "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/dev.js",
494
- "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
495
- "lint": "eslint 'src/**/*.ts'",
496
- "postbuild": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
497
- "prettier": "prettier --write 'src/**/*.ts'",
498
- "start": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
499
- "test": "NODE_ENV=test npm run build && npm run jest",
500
- "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/watch.js",
501
- "whook": "NODE_ENV=\${NODE_ENV:-development} whook",
502
- "whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} ts-node --esm --logError --files -- bin/whook.js",
503
- "whook-dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/whook.js",
504
- "whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
505
- },
506
- "type": "module",
507
- "types": "dist/index.d.ts",
508
- "version": "0.0.0",
509
- }
510
- `);
377
+ {
378
+ "author": {
379
+ "email": "wayne@warner.com",
380
+ "name": "Wayne Campbell",
381
+ },
382
+ "dependencies": {
383
+ "@whook/authorization": "<current_version>",
384
+ "@whook/cors": "<current_version>",
385
+ "@whook/http-router": "<current_version>",
386
+ "@whook/http-server": "<current_version>",
387
+ "@whook/http-transaction": "<current_version>",
388
+ "@whook/swagger-ui": "<current_version>",
389
+ "@whook/whook": "<current_version>",
390
+ "application-services": "^4.0.0",
391
+ "common-services": "^15.0.0",
392
+ "http-auth-utils": "^5.0.1",
393
+ "jwt-service": "^10.0.4",
394
+ "knifecycle": "^17.0.1",
395
+ "openapi-schema-validator": "^12.1.3",
396
+ "openapi-types": "^12.1.3",
397
+ "pkg-dir": "^7.0.0",
398
+ "strict-qs": "^8.0.1",
399
+ "type-fest": "^4.2.0",
400
+ "yerror": "^8.0.0",
401
+ "yhttperror": "^8.0.0",
402
+ },
403
+ "description": "A new Whook project",
404
+ "devDependencies": {
405
+ "@swc/cli": "^0.1.62",
406
+ "@swc/core": "^1.3.77",
407
+ "@swc/helpers": "^0.5.1",
408
+ "@swc/jest": "^0.2.29",
409
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
410
+ "@typescript-eslint/parser": "^6.4.0",
411
+ "axios": "^1.4.0",
412
+ "chokidar": "^3.5.1",
413
+ "esbuild-node-externals": "^1.5.0",
414
+ "eslint": "^8.47.0",
415
+ "eslint-config-prettier": "^9.0.0",
416
+ "eslint-plugin-prettier": "^5.0.0",
417
+ "jest": "^29.6.2",
418
+ "jsarch": "^6.0.3",
419
+ "parse-gitignore": "^1.0.1",
420
+ "prettier": "^3.0.2",
421
+ "rimraf": "^5.0.1",
422
+ "schema2dts": "^5.0.1",
423
+ "ts-node": "^10.8.1",
424
+ "typescript": "^5.1.6",
425
+ },
426
+ "engines": {
427
+ "node": ">=18.16.0",
428
+ },
429
+ "eslintConfig": {
430
+ "env": {
431
+ "es6": true,
432
+ "jest": true,
433
+ "mocha": true,
434
+ "node": true,
435
+ },
436
+ "extends": [
437
+ "eslint:recommended",
438
+ "plugin:prettier/recommended",
439
+ "plugin:@typescript-eslint/eslint-recommended",
440
+ "plugin:@typescript-eslint/recommended",
441
+ ],
442
+ "ignorePatterns": [
443
+ "*.d.ts",
444
+ ],
445
+ "parser": "@typescript-eslint/parser",
446
+ "parserOptions": {
447
+ "ecmaVersion": 2018,
448
+ "modules": true,
449
+ "sourceType": "script",
450
+ },
451
+ "plugins": [
452
+ "prettier",
453
+ ],
454
+ "rules": {
455
+ "prettier/prettier": "error",
456
+ },
457
+ },
458
+ "files": [
459
+ "bin",
460
+ "dist",
461
+ "src",
462
+ "LICENSE",
463
+ "README.md",
464
+ "CHANGELOG.md",
465
+ ],
466
+ "jest": {
467
+ "coverageReporters": [
468
+ "lcov",
469
+ "html",
470
+ ],
471
+ "extensionsToTreatAsEsm": [
472
+ ".ts",
473
+ ],
474
+ "moduleNameMapper": {
475
+ "#(.*)": "<rootDir>/../../node_modules/$1",
476
+ "(.+)\\.js": "$1",
477
+ },
478
+ "prettierPath": null,
479
+ "roots": [
480
+ "<rootDir>/src",
481
+ ],
482
+ "testEnvironment": "node",
483
+ "testPathIgnorePatterns": [
484
+ "/node_modules/",
485
+ ],
486
+ "transform": {
487
+ "^.+\\.tsx?$": [
488
+ "@swc/jest",
489
+ {},
490
+ ],
491
+ },
492
+ },
493
+ "keywords": [
494
+ "whook",
495
+ ],
496
+ "license": "SEE LICENSE",
497
+ "main": "dist/index.js",
498
+ "name": "super-project",
499
+ "prettier": {
500
+ "printWidth": 80,
501
+ "proseWrap": "always",
502
+ "semi": true,
503
+ "singleQuote": true,
504
+ "trailingComma": "all",
505
+ },
506
+ "private": true,
507
+ "scripts": {
508
+ "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
509
+ "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
510
+ "build": "rimraf 'dist' && tsc --outDir dist",
511
+ "cover": "npm run jest -- --coverage",
512
+ "debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --logError bin/dev",
513
+ "dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/dev.js",
514
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
515
+ "lint": "eslint 'src/**/*.ts'",
516
+ "postbuild": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
517
+ "prettier": "prettier --write 'src/**/*.ts'",
518
+ "rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
519
+ "start": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
520
+ "test": "NODE_ENV=test npm run build && npm run jest",
521
+ "type-check": "tsc --pretty --noEmit",
522
+ "watch": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/watch.js",
523
+ "whook": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} whook",
524
+ "whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} ts-node --esm --logError --files -- bin/whook.js",
525
+ "whook-dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/whook.js",
526
+ "whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
527
+ },
528
+ "type": "module",
529
+ "types": "dist/index.d.ts",
530
+ "version": "0.0.0",
531
+ }
532
+ `);
511
533
  expect({
512
534
  copyCalls: copy.mock.calls,
513
535
  writeFileCalls: writeFile.mock.calls,
@@ -522,8 +544,7 @@ Mr Bean
522
544
  });
523
545
 
524
546
  it('should handle git initialization problems', async () => {
525
- readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
526
- readdir.mockResolvedValueOnce(['development', 'production']);
547
+ readdir.mockResolvedValueOnce(['local', 'production']);
527
548
  copy.mockResolvedValueOnce(new YError('E_ACCESS'));
528
549
  axios.mockResolvedValueOnce({
529
550
  data: 'node_modules',
@@ -560,159 +581,162 @@ Mr Bean
560
581
  ?.toString() || '',
561
582
  ),
562
583
  ).toMatchInlineSnapshot(`
563
- {
564
- "author": {
565
- "email": "wayne@warner.com",
566
- "name": "Wayne Campbell",
567
- },
568
- "dependencies": {
569
- "@whook/authorization": "<current_version>",
570
- "@whook/cors": "<current_version>",
571
- "@whook/http-router": "<current_version>",
572
- "@whook/http-server": "<current_version>",
573
- "@whook/http-transaction": "<current_version>",
574
- "@whook/swagger-ui": "<current_version>",
575
- "@whook/whook": "<current_version>",
576
- "common-services": "^12.1.0",
577
- "http-auth-utils": "^3.0.5",
578
- "jwt-service": "^9.0.4",
579
- "knifecycle": "^14.1.0",
580
- "openapi-schema-validator": "^12.0.2",
581
- "openapi-types": "^12.1.0",
582
- "pkg-dir": "^7.0.0",
583
- "strict-qs": "^7.0.2",
584
- "type-fest": "^3.4.0",
585
- "yerror": "^6.2.1",
586
- "yhttperror": "^6.1.2",
587
- },
588
- "description": "A new Whook project",
589
- "devDependencies": {
590
- "@typescript-eslint/eslint-plugin": "^5.36.0",
591
- "@typescript-eslint/parser": "^5.36.0",
592
- "axios": "^1.2.1",
593
- "chokidar": "^3.5.1",
594
- "esbuild": "^0.15.6",
595
- "esbuild-jest": "^0.5.0",
596
- "esbuild-node-externals": "^1.5.0",
597
- "eslint": "^8.23.0",
598
- "eslint-config-prettier": "^8.5.0",
599
- "eslint-plugin-prettier": "^4.2.1",
600
- "jest": "^29.0.1",
601
- "jsarch": "^6.0.0",
602
- "parse-gitignore": "^1.0.1",
603
- "prettier": "^2.7.1",
604
- "rimraf": "^3.0.2",
605
- "schema2dts": "^4.1.4",
606
- "ts-node": "^10.8.1",
607
- "typescript": "^4.8.2",
608
- },
609
- "engines": {
610
- "node": ">=16.15.0",
611
- },
612
- "eslintConfig": {
613
- "env": {
614
- "es6": true,
615
- "jest": true,
616
- "mocha": true,
617
- "node": true,
618
- },
619
- "extends": [
620
- "eslint:recommended",
621
- "plugin:prettier/recommended",
622
- "plugin:@typescript-eslint/eslint-recommended",
623
- "plugin:@typescript-eslint/recommended",
624
- ],
625
- "ignorePatterns": [
626
- "*.d.ts",
627
- ],
628
- "parser": "@typescript-eslint/parser",
629
- "parserOptions": {
630
- "ecmaVersion": 2018,
631
- "modules": true,
632
- "sourceType": "script",
633
- },
634
- "plugins": [
635
- "prettier",
636
- ],
637
- "rules": {
638
- "prettier/prettier": "error",
639
- },
640
- },
641
- "files": [
642
- "bin",
643
- "dist",
644
- "src",
645
- "LICENSE",
646
- "README.md",
647
- "CHANGELOG.md",
648
- ],
649
- "jest": {
650
- "coverageReporters": [
651
- "lcov",
652
- "html",
653
- ],
654
- "extensionsToTreatAsEsm": [
655
- ".ts",
656
- ],
657
- "moduleNameMapper": {
658
- "#(.*)": "<rootDir>/../../node_modules/$1",
659
- "(.+)\\.js": "$1",
660
- },
661
- "roots": [
662
- "<rootDir>/src",
663
- ],
664
- "testEnvironment": "node",
665
- "testPathIgnorePatterns": [
666
- "/node_modules/",
667
- ],
668
- "transform": {
669
- "^.+\\.tsx?$": [
670
- "esbuild-jest",
671
- {
672
- "format": "esm",
673
- "sourcemap": true,
674
- },
675
- ],
676
- },
677
- },
678
- "keywords": [
679
- "whook",
680
- ],
681
- "license": "SEE LICENSE",
682
- "main": "dist/index.js",
683
- "name": "super-project",
684
- "prettier": {
685
- "printWidth": 80,
686
- "proseWrap": "always",
687
- "semi": true,
688
- "singleQuote": true,
689
- "trailingComma": "all",
690
- },
691
- "private": true,
692
- "scripts": {
693
- "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
694
- "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
695
- "build": "rimraf -f 'dist' && tsc --outDir dist",
696
- "cover": "npm run jest -- --coverage",
697
- "debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --logError bin/dev",
698
- "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/dev.js",
699
- "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
700
- "lint": "eslint 'src/**/*.ts'",
701
- "postbuild": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
702
- "prettier": "prettier --write 'src/**/*.ts'",
703
- "start": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
704
- "test": "NODE_ENV=test npm run build && npm run jest",
705
- "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/watch.js",
706
- "whook": "NODE_ENV=\${NODE_ENV:-development} whook",
707
- "whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} ts-node --esm --logError --files -- bin/whook.js",
708
- "whook-dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/whook.js",
709
- "whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
710
- },
711
- "type": "module",
712
- "types": "dist/index.d.ts",
713
- "version": "0.0.0",
714
- }
715
- `);
584
+ {
585
+ "author": {
586
+ "email": "wayne@warner.com",
587
+ "name": "Wayne Campbell",
588
+ },
589
+ "dependencies": {
590
+ "@whook/authorization": "<current_version>",
591
+ "@whook/cors": "<current_version>",
592
+ "@whook/http-router": "<current_version>",
593
+ "@whook/http-server": "<current_version>",
594
+ "@whook/http-transaction": "<current_version>",
595
+ "@whook/swagger-ui": "<current_version>",
596
+ "@whook/whook": "<current_version>",
597
+ "application-services": "^4.0.0",
598
+ "common-services": "^15.0.0",
599
+ "http-auth-utils": "^5.0.1",
600
+ "jwt-service": "^10.0.4",
601
+ "knifecycle": "^17.0.1",
602
+ "openapi-schema-validator": "^12.1.3",
603
+ "openapi-types": "^12.1.3",
604
+ "pkg-dir": "^7.0.0",
605
+ "strict-qs": "^8.0.1",
606
+ "type-fest": "^4.2.0",
607
+ "yerror": "^8.0.0",
608
+ "yhttperror": "^8.0.0",
609
+ },
610
+ "description": "A new Whook project",
611
+ "devDependencies": {
612
+ "@swc/cli": "^0.1.62",
613
+ "@swc/core": "^1.3.77",
614
+ "@swc/helpers": "^0.5.1",
615
+ "@swc/jest": "^0.2.29",
616
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
617
+ "@typescript-eslint/parser": "^6.4.0",
618
+ "axios": "^1.4.0",
619
+ "chokidar": "^3.5.1",
620
+ "esbuild-node-externals": "^1.5.0",
621
+ "eslint": "^8.47.0",
622
+ "eslint-config-prettier": "^9.0.0",
623
+ "eslint-plugin-prettier": "^5.0.0",
624
+ "jest": "^29.6.2",
625
+ "jsarch": "^6.0.3",
626
+ "parse-gitignore": "^1.0.1",
627
+ "prettier": "^3.0.2",
628
+ "rimraf": "^5.0.1",
629
+ "schema2dts": "^5.0.1",
630
+ "ts-node": "^10.8.1",
631
+ "typescript": "^5.1.6",
632
+ },
633
+ "engines": {
634
+ "node": ">=18.16.0",
635
+ },
636
+ "eslintConfig": {
637
+ "env": {
638
+ "es6": true,
639
+ "jest": true,
640
+ "mocha": true,
641
+ "node": true,
642
+ },
643
+ "extends": [
644
+ "eslint:recommended",
645
+ "plugin:prettier/recommended",
646
+ "plugin:@typescript-eslint/eslint-recommended",
647
+ "plugin:@typescript-eslint/recommended",
648
+ ],
649
+ "ignorePatterns": [
650
+ "*.d.ts",
651
+ ],
652
+ "parser": "@typescript-eslint/parser",
653
+ "parserOptions": {
654
+ "ecmaVersion": 2018,
655
+ "modules": true,
656
+ "sourceType": "script",
657
+ },
658
+ "plugins": [
659
+ "prettier",
660
+ ],
661
+ "rules": {
662
+ "prettier/prettier": "error",
663
+ },
664
+ },
665
+ "files": [
666
+ "bin",
667
+ "dist",
668
+ "src",
669
+ "LICENSE",
670
+ "README.md",
671
+ "CHANGELOG.md",
672
+ ],
673
+ "jest": {
674
+ "coverageReporters": [
675
+ "lcov",
676
+ "html",
677
+ ],
678
+ "extensionsToTreatAsEsm": [
679
+ ".ts",
680
+ ],
681
+ "moduleNameMapper": {
682
+ "#(.*)": "<rootDir>/../../node_modules/$1",
683
+ "(.+)\\.js": "$1",
684
+ },
685
+ "prettierPath": null,
686
+ "roots": [
687
+ "<rootDir>/src",
688
+ ],
689
+ "testEnvironment": "node",
690
+ "testPathIgnorePatterns": [
691
+ "/node_modules/",
692
+ ],
693
+ "transform": {
694
+ "^.+\\.tsx?$": [
695
+ "@swc/jest",
696
+ {},
697
+ ],
698
+ },
699
+ },
700
+ "keywords": [
701
+ "whook",
702
+ ],
703
+ "license": "SEE LICENSE",
704
+ "main": "dist/index.js",
705
+ "name": "super-project",
706
+ "prettier": {
707
+ "printWidth": 80,
708
+ "proseWrap": "always",
709
+ "semi": true,
710
+ "singleQuote": true,
711
+ "trailingComma": "all",
712
+ },
713
+ "private": true,
714
+ "scripts": {
715
+ "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
716
+ "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
717
+ "build": "rimraf 'dist' && tsc --outDir dist",
718
+ "cover": "npm run jest -- --coverage",
719
+ "debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --logError bin/dev",
720
+ "dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/dev.js",
721
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
722
+ "lint": "eslint 'src/**/*.ts'",
723
+ "postbuild": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
724
+ "prettier": "prettier --write 'src/**/*.ts'",
725
+ "rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
726
+ "start": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
727
+ "test": "NODE_ENV=test npm run build && npm run jest",
728
+ "type-check": "tsc --pretty --noEmit",
729
+ "watch": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --logError --files bin/watch.js",
730
+ "whook": "PROJECT_SRC="$PWD/dist" NODE_ENV=\${NODE_ENV:-development} whook",
731
+ "whook-debug": "NODE_OPTIONS=\${NODE_OPTIONS:-'--inspect'} PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} DEBUG=\${DEBUG:-whook} ts-node --esm --logError --files -- bin/whook.js",
732
+ "whook-dev": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/whook.js",
733
+ "whook-repl": "PROJECT_SRC="$PWD/src" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --logError --files -- bin/repl.js",
734
+ },
735
+ "type": "module",
736
+ "types": "dist/index.d.ts",
737
+ "version": "0.0.0",
738
+ }
739
+ `);
716
740
  expect({
717
741
  copyCalls: copy.mock.calls,
718
742
  writeFileCalls: writeFile.mock.calls,
@@ -727,8 +751,7 @@ Mr Bean
727
751
  });
728
752
 
729
753
  it('should fail with access problems', async () => {
730
- readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
731
- readdir.mockResolvedValueOnce(['development', 'production']);
754
+ readdir.mockResolvedValueOnce(['local', 'production']);
732
755
  copy.mockRejectedValueOnce(new YError('E_ACCESS'));
733
756
  axios.mockResolvedValueOnce({
734
757
  data: 'node_modules',