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