@whook/create 8.5.1 → 10.0.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.
Files changed (42) hide show
  1. package/README.md +2 -3
  2. package/bin/create.js +2 -2
  3. package/dist/index.js +46 -68
  4. package/dist/index.js.map +1 -1
  5. package/dist/services/author.js +46 -72
  6. package/dist/services/author.js.map +1 -1
  7. package/dist/services/author.test.js +86 -92
  8. package/dist/services/author.test.js.map +1 -1
  9. package/dist/services/createWhook.d.ts +10 -11
  10. package/dist/services/createWhook.js +124 -144
  11. package/dist/services/createWhook.js.map +1 -1
  12. package/dist/services/createWhook.test.js +413 -521
  13. package/dist/services/createWhook.test.js.map +1 -1
  14. package/dist/services/project.d.ts +2 -2
  15. package/dist/services/project.js +40 -62
  16. package/dist/services/project.js.map +1 -1
  17. package/dist/services/project.test.js +73 -80
  18. package/dist/services/project.test.js.map +1 -1
  19. package/package.json +52 -98
  20. package/src/index.ts +24 -18
  21. package/src/services/__snapshots__/author.test.ts.snap +3 -3
  22. package/src/services/__snapshots__/createWhook.test.ts.snap +4 -4
  23. package/src/services/author.test.ts +10 -7
  24. package/src/services/author.ts +12 -15
  25. package/src/services/createWhook.test.ts +220 -329
  26. package/src/services/createWhook.ts +20 -20
  27. package/src/services/project.test.ts +13 -8
  28. package/src/services/project.ts +6 -5
  29. package/dist/index.mjs +0 -47
  30. package/dist/index.mjs.map +0 -1
  31. package/dist/services/author.mjs +0 -63
  32. package/dist/services/author.mjs.map +0 -1
  33. package/dist/services/author.test.mjs +0 -94
  34. package/dist/services/author.test.mjs.map +0 -1
  35. package/dist/services/createWhook.mjs +0 -135
  36. package/dist/services/createWhook.mjs.map +0 -1
  37. package/dist/services/createWhook.test.mjs +0 -828
  38. package/dist/services/createWhook.test.mjs.map +0 -1
  39. package/dist/services/project.mjs +0 -50
  40. package/dist/services/project.mjs.map +0 -1
  41. package/dist/services/project.test.mjs +0 -80
  42. package/dist/services/project.test.mjs.map +0 -1
@@ -1,8 +1,13 @@
1
- import initCreateWhook from './createWhook';
2
- import YError from 'yerror';
1
+ import { jest } from '@jest/globals';
2
+ import initCreateWhook from './createWhook.js';
3
+ import { YError } from 'yerror';
4
+ import { readFileSync } from 'fs';
5
+ import type { LogService } from 'common-services';
6
+ import type { PathLike } from 'fs-extra';
3
7
 
4
- // eslint-disable-next-line
5
- const _packageJSON = require('@whook/example/package.json');
8
+ const _packageJSON = JSON.parse(
9
+ readFileSync('../whook-example/package.json').toString(),
10
+ );
6
11
 
7
12
  describe('initCreateWhook', () => {
8
13
  const CWD = '/home/whoiam/projects/';
@@ -28,18 +33,18 @@ describe('initCreateWhook', () => {
28
33
  name: 'super-project',
29
34
  directory: '/home/whoiam/projects/yolo',
30
35
  };
31
- const writeFile = jest.fn();
32
- const readFile = jest.fn();
33
- const readdir = jest.fn();
34
- const exec = jest.fn();
35
- const copy = jest.fn();
36
- const axios = jest.fn();
37
- const ora = jest.fn();
36
+ const writeFile = jest.fn<(file: PathLike, data: Buffer) => Promise<void>>();
37
+ const readFile = jest.fn<(file: PathLike) => Promise<Buffer>>();
38
+ const readdir = jest.fn<(file: PathLike) => Promise<string[]>>();
39
+ const exec = jest.fn<any>();
40
+ const axios = jest.fn<any>();
41
+ const ora = jest.fn<any>();
42
+ const copy = jest.fn<any>();
38
43
  const oraInstance = {
39
- start: jest.fn(),
40
- stopAndPersist: jest.fn(),
44
+ start: jest.fn<any>(),
45
+ stopAndPersist: jest.fn<any>(),
41
46
  };
42
- const log = jest.fn();
47
+ const log = jest.fn<LogService>();
43
48
 
44
49
  beforeEach(() => {
45
50
  axios.mockReset();
@@ -73,7 +78,7 @@ Mr Bean
73
78
  });
74
79
 
75
80
  it('should work', async () => {
76
- readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));
81
+ readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
77
82
  readdir.mockResolvedValueOnce(['development', 'production']);
78
83
  copy.mockImplementationOnce((_, _2, { filter }) =>
79
84
  Promise.all(
@@ -111,9 +116,9 @@ Mr Bean
111
116
  SOURCE_DIR,
112
117
  author,
113
118
  project,
114
- writeFile,
115
- readFile,
116
- readdir,
119
+ writeFile: writeFile as any,
120
+ readFile: readFile as any,
121
+ readdir: readdir as any,
117
122
  exec: exec as any,
118
123
  copy,
119
124
  axios: axios as any,
@@ -125,9 +130,9 @@ Mr Bean
125
130
 
126
131
  expect(
127
132
  JSON.parse(
128
- writeFile.mock.calls.find((call) =>
129
- call[0].endsWith('package.json'),
130
- )[1],
133
+ writeFile.mock.calls
134
+ .find((call) => call[0].toString().endsWith('package.json'))?.[1]
135
+ ?.toString() || '',
131
136
  ),
132
137
  ).toMatchInlineSnapshot(`
133
138
  Object {
@@ -135,102 +140,50 @@ Mr Bean
135
140
  "email": "wayne@warner.com",
136
141
  "name": "Wayne Campbell",
137
142
  },
138
- "babel": Object {
139
- "env": Object {
140
- "cjs": Object {
141
- "presets": Array [
142
- Array [
143
- "@babel/env",
144
- Object {
145
- "modules": "commonjs",
146
- "targets": Object {
147
- "node": "10",
148
- },
149
- },
150
- ],
151
- ],
152
- },
153
- "mjs": Object {
154
- "presets": Array [
155
- Array [
156
- "@babel/env",
157
- Object {
158
- "modules": false,
159
- "targets": Object {
160
- "node": "12",
161
- },
162
- },
163
- ],
164
- ],
165
- },
166
- },
167
- "plugins": Array [
168
- "@babel/proposal-class-properties",
169
- "@babel/plugin-proposal-object-rest-spread",
170
- "babel-plugin-knifecycle",
171
- ],
172
- "presets": Array [
173
- "@babel/typescript",
174
- Array [
175
- "@babel/env",
176
- Object {
177
- "targets": Object {
178
- "node": "12.19.0",
179
- },
180
- },
181
- ],
182
- ],
183
- "sourceMaps": true,
184
- },
185
143
  "dependencies": Object {
186
144
  "@whook/authorization": "<current_version>",
187
145
  "@whook/cli": "<current_version>",
188
146
  "@whook/cors": "<current_version>",
189
147
  "@whook/http-router": "<current_version>",
148
+ "@whook/http-server": "^9.0.1",
190
149
  "@whook/http-transaction": "<current_version>",
191
150
  "@whook/swagger-ui": "<current_version>",
192
151
  "@whook/whook": "<current_version>",
193
- "common-services": "^9.0.1",
194
- "http-auth-utils": "^3.0.1",
195
- "jwt-service": "^7.1.3",
196
- "knifecycle": "^11.1.1",
197
- "strict-qs": "^6.1.4",
198
- "type-fest": "^2.3.3",
199
- "yerror": "^6.0.1",
200
- "yhttperror": "^6.0.1",
152
+ "common-services": "^11.0.1",
153
+ "http-auth-utils": "^3.0.3",
154
+ "jwt-service": "^9.0.1",
155
+ "knifecycle": "^14.0.0",
156
+ "openapi-schema-validator": "^12.0.0",
157
+ "openapi-types": "^12.0.0",
158
+ "strict-qs": "^7.0.0",
159
+ "type-fest": "^2.13.1",
160
+ "yerror": "^6.1.1",
161
+ "yhttperror": "^6.1.1",
201
162
  },
202
163
  "description": "A new Whook project",
203
164
  "devDependencies": Object {
204
- "@babel/cli": "^7.13.14",
205
- "@babel/core": "^7.13.15",
206
- "@babel/eslint-parser": "^7.13.14",
207
- "@babel/node": "^7.13.13",
208
- "@babel/plugin-proposal-class-properties": "^7.13.0",
209
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
210
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
211
- "@babel/plugin-syntax-import-meta": "^7.10.4",
212
- "@babel/preset-env": "^7.13.15",
213
- "@babel/preset-typescript": "^7.13.0",
214
- "@babel/register": "^7.13.14",
215
- "@types/jest": "^26.0.22",
216
- "@typescript-eslint/eslint-plugin": "^4.21.0",
217
- "@typescript-eslint/parser": "^4.21.0",
218
- "axios": "^0.21.4",
219
- "babel-plugin-knifecycle": "^5.0.1",
165
+ "@types/jest": "^28.1.1",
166
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
167
+ "@typescript-eslint/parser": "^5.27.0",
168
+ "axios": "^0.27.2",
220
169
  "chokidar": "^3.5.1",
221
- "eslint": "^7.23.0",
222
- "eslint-plugin-prettier": "^3.3.1",
223
- "jest": "^26.6.3",
224
- "jsarch": "^4.0.1",
225
- "openapi-schema-validator": "^8.0.0",
170
+ "esbuild": "^0.14.46",
171
+ "esbuild-jest": "^0.5.0",
172
+ "esbuild-node-externals": "^1.4.1",
173
+ "eslint": "^8.17.0",
174
+ "eslint-config-prettier": "^8.5.0",
175
+ "eslint-plugin-prettier": "^4.0.0",
176
+ "jest": "^28.1.0",
177
+ "jsarch": "^5.0.1",
226
178
  "parse-gitignore": "^1.0.1",
227
- "prettier": "^2.2.1",
179
+ "prettier": "^2.6.2",
228
180
  "rimraf": "^3.0.2",
229
- "schema2dts": "^3.0.0",
230
- "typescript": "^4.2.4",
181
+ "schema2dts": "^4.1.1",
182
+ "ts-node": "^10.8.1",
183
+ "typescript": "^4.7.3",
231
184
  },
232
185
  "engines": Object {
233
- "node": ">=12.19.0",
186
+ "node": ">=16.15.0",
234
187
  },
235
188
  "eslintConfig": Object {
236
189
  "env": Object {
@@ -241,6 +194,7 @@ Mr Bean
241
194
  },
242
195
  "extends": Array [
243
196
  "eslint:recommended",
197
+ "plugin:prettier/recommended",
244
198
  "plugin:@typescript-eslint/eslint-recommended",
245
199
  "plugin:@typescript-eslint/recommended",
246
200
  ],
@@ -251,7 +205,7 @@ Mr Bean
251
205
  "parserOptions": Object {
252
206
  "ecmaVersion": 2018,
253
207
  "modules": true,
254
- "sourceType": "module",
208
+ "sourceType": "script",
255
209
  },
256
210
  "plugins": Array [
257
211
  "prettier",
@@ -273,6 +227,13 @@ Mr Bean
273
227
  "lcov",
274
228
  "html",
275
229
  ],
230
+ "extensionsToTreatAsEsm": Array [
231
+ ".ts",
232
+ ],
233
+ "moduleNameMapper": Object {
234
+ "#(.*)": "<rootDir>/../../node_modules/$1",
235
+ "(.+)\\\\.js": "$1",
236
+ },
276
237
  "roots": Array [
277
238
  "<rootDir>/src",
278
239
  ],
@@ -280,13 +241,21 @@ Mr Bean
280
241
  "testPathIgnorePatterns": Array [
281
242
  "/node_modules/",
282
243
  ],
244
+ "transform": Object {
245
+ "^.+\\\\.tsx?$": Array [
246
+ "esbuild-jest",
247
+ Object {
248
+ "format": "esm",
249
+ "sourcemap": true,
250
+ },
251
+ ],
252
+ },
283
253
  },
284
254
  "keywords": Array [
285
255
  "whook",
286
256
  ],
287
257
  "license": "SEE LICENSE",
288
- "main": "dist/index",
289
- "module": "dist/index.mjs",
258
+ "main": "dist/index.js",
290
259
  "name": "super-project",
291
260
  "prettier": Object {
292
261
  "printWidth": 80,
@@ -299,25 +268,23 @@ Mr Bean
299
268
  "scripts": Object {
300
269
  "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
301
270
  "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
302
- "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build",
303
- "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs",
304
- "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
305
- "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
271
+ "build": "rimraf -f 'dist' && tsc --outDir dist",
306
272
  "cover": "npm run jest -- --coverage",
307
- "debug": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev",
308
- "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev",
273
+ "debug": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --inspect bin/dev",
274
+ "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --files bin/dev.js",
309
275
  "genPackagelock": "npm i --package-lock-only",
310
- "jest": "NODE_ENV=test jest",
276
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
311
277
  "lint": "eslint 'src/**/*.ts'",
278
+ "postbuild": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
312
279
  "prettier": "prettier --write 'src/**/*.ts'",
313
- "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start",
314
- "test": "npm run jest",
315
- "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist",
316
- "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch",
280
+ "start": "PROJECT_SRC=\\"$PWD/dist\\" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
281
+ "test": "NODE_ENV=test npm run build && npm run jest",
282
+ "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --files bin/watch.js",
317
283
  "whook": "NODE_ENV=\${NODE_ENV:-development} whook",
318
- "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js",
319
- "whook-repl": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js",
284
+ "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/whook.js",
285
+ "whook-repl": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/repl.js",
320
286
  },
287
+ "type": "module",
321
288
  "types": "dist/index.d.ts",
322
289
  "version": "0.0.0",
323
290
  }
@@ -336,7 +303,7 @@ Mr Bean
336
303
  });
337
304
 
338
305
  it('should handle network issues', async () => {
339
- readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));
306
+ readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
340
307
  readdir.mockResolvedValueOnce(['development', 'production']);
341
308
  copy.mockImplementationOnce((_, _2, { filter }) =>
342
309
  Promise.all(
@@ -370,9 +337,9 @@ Mr Bean
370
337
  SOURCE_DIR,
371
338
  author,
372
339
  project,
373
- writeFile,
374
- readFile,
375
- readdir,
340
+ writeFile: writeFile as any,
341
+ readFile: readFile as any,
342
+ readdir: readdir as any,
376
343
  exec: exec as any,
377
344
  copy,
378
345
  axios: axios as any,
@@ -384,9 +351,9 @@ Mr Bean
384
351
 
385
352
  expect(
386
353
  JSON.parse(
387
- writeFile.mock.calls.find((call) =>
388
- call[0].endsWith('package.json'),
389
- )[1],
354
+ writeFile.mock.calls
355
+ .find((call) => call[0].toString().endsWith('package.json'))?.[1]
356
+ ?.toString() || '',
390
357
  ),
391
358
  ).toMatchInlineSnapshot(`
392
359
  Object {
@@ -394,102 +361,50 @@ Mr Bean
394
361
  "email": "wayne@warner.com",
395
362
  "name": "Wayne Campbell",
396
363
  },
397
- "babel": Object {
398
- "env": Object {
399
- "cjs": Object {
400
- "presets": Array [
401
- Array [
402
- "@babel/env",
403
- Object {
404
- "modules": "commonjs",
405
- "targets": Object {
406
- "node": "10",
407
- },
408
- },
409
- ],
410
- ],
411
- },
412
- "mjs": Object {
413
- "presets": Array [
414
- Array [
415
- "@babel/env",
416
- Object {
417
- "modules": false,
418
- "targets": Object {
419
- "node": "12",
420
- },
421
- },
422
- ],
423
- ],
424
- },
425
- },
426
- "plugins": Array [
427
- "@babel/proposal-class-properties",
428
- "@babel/plugin-proposal-object-rest-spread",
429
- "babel-plugin-knifecycle",
430
- ],
431
- "presets": Array [
432
- "@babel/typescript",
433
- Array [
434
- "@babel/env",
435
- Object {
436
- "targets": Object {
437
- "node": "12.19.0",
438
- },
439
- },
440
- ],
441
- ],
442
- "sourceMaps": true,
443
- },
444
364
  "dependencies": Object {
445
365
  "@whook/authorization": "<current_version>",
446
366
  "@whook/cli": "<current_version>",
447
367
  "@whook/cors": "<current_version>",
448
368
  "@whook/http-router": "<current_version>",
369
+ "@whook/http-server": "^9.0.1",
449
370
  "@whook/http-transaction": "<current_version>",
450
371
  "@whook/swagger-ui": "<current_version>",
451
372
  "@whook/whook": "<current_version>",
452
- "common-services": "^9.0.1",
453
- "http-auth-utils": "^3.0.1",
454
- "jwt-service": "^7.1.3",
455
- "knifecycle": "^11.1.1",
456
- "strict-qs": "^6.1.4",
457
- "type-fest": "^2.3.3",
458
- "yerror": "^6.0.1",
459
- "yhttperror": "^6.0.1",
373
+ "common-services": "^11.0.1",
374
+ "http-auth-utils": "^3.0.3",
375
+ "jwt-service": "^9.0.1",
376
+ "knifecycle": "^14.0.0",
377
+ "openapi-schema-validator": "^12.0.0",
378
+ "openapi-types": "^12.0.0",
379
+ "strict-qs": "^7.0.0",
380
+ "type-fest": "^2.13.1",
381
+ "yerror": "^6.1.1",
382
+ "yhttperror": "^6.1.1",
460
383
  },
461
384
  "description": "A new Whook project",
462
385
  "devDependencies": Object {
463
- "@babel/cli": "^7.13.14",
464
- "@babel/core": "^7.13.15",
465
- "@babel/eslint-parser": "^7.13.14",
466
- "@babel/node": "^7.13.13",
467
- "@babel/plugin-proposal-class-properties": "^7.13.0",
468
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
469
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
470
- "@babel/plugin-syntax-import-meta": "^7.10.4",
471
- "@babel/preset-env": "^7.13.15",
472
- "@babel/preset-typescript": "^7.13.0",
473
- "@babel/register": "^7.13.14",
474
- "@types/jest": "^26.0.22",
475
- "@typescript-eslint/eslint-plugin": "^4.21.0",
476
- "@typescript-eslint/parser": "^4.21.0",
477
- "axios": "^0.21.4",
478
- "babel-plugin-knifecycle": "^5.0.1",
386
+ "@types/jest": "^28.1.1",
387
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
388
+ "@typescript-eslint/parser": "^5.27.0",
389
+ "axios": "^0.27.2",
479
390
  "chokidar": "^3.5.1",
480
- "eslint": "^7.23.0",
481
- "eslint-plugin-prettier": "^3.3.1",
482
- "jest": "^26.6.3",
483
- "jsarch": "^4.0.1",
484
- "openapi-schema-validator": "^8.0.0",
391
+ "esbuild": "^0.14.46",
392
+ "esbuild-jest": "^0.5.0",
393
+ "esbuild-node-externals": "^1.4.1",
394
+ "eslint": "^8.17.0",
395
+ "eslint-config-prettier": "^8.5.0",
396
+ "eslint-plugin-prettier": "^4.0.0",
397
+ "jest": "^28.1.0",
398
+ "jsarch": "^5.0.1",
485
399
  "parse-gitignore": "^1.0.1",
486
- "prettier": "^2.2.1",
400
+ "prettier": "^2.6.2",
487
401
  "rimraf": "^3.0.2",
488
- "schema2dts": "^3.0.0",
489
- "typescript": "^4.2.4",
402
+ "schema2dts": "^4.1.1",
403
+ "ts-node": "^10.8.1",
404
+ "typescript": "^4.7.3",
490
405
  },
491
406
  "engines": Object {
492
- "node": ">=12.19.0",
407
+ "node": ">=16.15.0",
493
408
  },
494
409
  "eslintConfig": Object {
495
410
  "env": Object {
@@ -500,6 +415,7 @@ Mr Bean
500
415
  },
501
416
  "extends": Array [
502
417
  "eslint:recommended",
418
+ "plugin:prettier/recommended",
503
419
  "plugin:@typescript-eslint/eslint-recommended",
504
420
  "plugin:@typescript-eslint/recommended",
505
421
  ],
@@ -510,7 +426,7 @@ Mr Bean
510
426
  "parserOptions": Object {
511
427
  "ecmaVersion": 2018,
512
428
  "modules": true,
513
- "sourceType": "module",
429
+ "sourceType": "script",
514
430
  },
515
431
  "plugins": Array [
516
432
  "prettier",
@@ -532,6 +448,13 @@ Mr Bean
532
448
  "lcov",
533
449
  "html",
534
450
  ],
451
+ "extensionsToTreatAsEsm": Array [
452
+ ".ts",
453
+ ],
454
+ "moduleNameMapper": Object {
455
+ "#(.*)": "<rootDir>/../../node_modules/$1",
456
+ "(.+)\\\\.js": "$1",
457
+ },
535
458
  "roots": Array [
536
459
  "<rootDir>/src",
537
460
  ],
@@ -539,13 +462,21 @@ Mr Bean
539
462
  "testPathIgnorePatterns": Array [
540
463
  "/node_modules/",
541
464
  ],
465
+ "transform": Object {
466
+ "^.+\\\\.tsx?$": Array [
467
+ "esbuild-jest",
468
+ Object {
469
+ "format": "esm",
470
+ "sourcemap": true,
471
+ },
472
+ ],
473
+ },
542
474
  },
543
475
  "keywords": Array [
544
476
  "whook",
545
477
  ],
546
478
  "license": "SEE LICENSE",
547
- "main": "dist/index",
548
- "module": "dist/index.mjs",
479
+ "main": "dist/index.js",
549
480
  "name": "super-project",
550
481
  "prettier": Object {
551
482
  "printWidth": 80,
@@ -558,25 +489,23 @@ Mr Bean
558
489
  "scripts": Object {
559
490
  "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
560
491
  "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
561
- "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build",
562
- "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs",
563
- "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
564
- "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
492
+ "build": "rimraf -f 'dist' && tsc --outDir dist",
565
493
  "cover": "npm run jest -- --coverage",
566
- "debug": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev",
567
- "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev",
494
+ "debug": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --inspect bin/dev",
495
+ "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --files bin/dev.js",
568
496
  "genPackagelock": "npm i --package-lock-only",
569
- "jest": "NODE_ENV=test jest",
497
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
570
498
  "lint": "eslint 'src/**/*.ts'",
499
+ "postbuild": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
571
500
  "prettier": "prettier --write 'src/**/*.ts'",
572
- "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start",
573
- "test": "npm run jest",
574
- "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist",
575
- "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch",
501
+ "start": "PROJECT_SRC=\\"$PWD/dist\\" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
502
+ "test": "NODE_ENV=test npm run build && npm run jest",
503
+ "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --files bin/watch.js",
576
504
  "whook": "NODE_ENV=\${NODE_ENV:-development} whook",
577
- "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js",
578
- "whook-repl": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js",
505
+ "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/whook.js",
506
+ "whook-repl": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/repl.js",
579
507
  },
508
+ "type": "module",
580
509
  "types": "dist/index.d.ts",
581
510
  "version": "0.0.0",
582
511
  }
@@ -595,7 +524,7 @@ Mr Bean
595
524
  });
596
525
 
597
526
  it('should handle git initialization problems', async () => {
598
- readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));
527
+ readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
599
528
  readdir.mockResolvedValueOnce(['development', 'production']);
600
529
  copy.mockResolvedValueOnce(new YError('E_ACCESS'));
601
530
  axios.mockResolvedValueOnce({
@@ -614,9 +543,9 @@ Mr Bean
614
543
  SOURCE_DIR,
615
544
  author,
616
545
  project,
617
- writeFile,
618
- readFile,
619
- readdir,
546
+ writeFile: writeFile as any,
547
+ readFile: readFile as any,
548
+ readdir: readdir as any,
620
549
  exec: exec as any,
621
550
  copy,
622
551
  axios: axios as any,
@@ -628,9 +557,9 @@ Mr Bean
628
557
 
629
558
  expect(
630
559
  JSON.parse(
631
- writeFile.mock.calls.find((call) =>
632
- call[0].endsWith('package.json'),
633
- )[1],
560
+ writeFile.mock.calls
561
+ .find((call) => call[0].toString().endsWith('package.json'))?.[1]
562
+ ?.toString() || '',
634
563
  ),
635
564
  ).toMatchInlineSnapshot(`
636
565
  Object {
@@ -638,102 +567,50 @@ Mr Bean
638
567
  "email": "wayne@warner.com",
639
568
  "name": "Wayne Campbell",
640
569
  },
641
- "babel": Object {
642
- "env": Object {
643
- "cjs": Object {
644
- "presets": Array [
645
- Array [
646
- "@babel/env",
647
- Object {
648
- "modules": "commonjs",
649
- "targets": Object {
650
- "node": "10",
651
- },
652
- },
653
- ],
654
- ],
655
- },
656
- "mjs": Object {
657
- "presets": Array [
658
- Array [
659
- "@babel/env",
660
- Object {
661
- "modules": false,
662
- "targets": Object {
663
- "node": "12",
664
- },
665
- },
666
- ],
667
- ],
668
- },
669
- },
670
- "plugins": Array [
671
- "@babel/proposal-class-properties",
672
- "@babel/plugin-proposal-object-rest-spread",
673
- "babel-plugin-knifecycle",
674
- ],
675
- "presets": Array [
676
- "@babel/typescript",
677
- Array [
678
- "@babel/env",
679
- Object {
680
- "targets": Object {
681
- "node": "12.19.0",
682
- },
683
- },
684
- ],
685
- ],
686
- "sourceMaps": true,
687
- },
688
570
  "dependencies": Object {
689
571
  "@whook/authorization": "<current_version>",
690
572
  "@whook/cli": "<current_version>",
691
573
  "@whook/cors": "<current_version>",
692
574
  "@whook/http-router": "<current_version>",
575
+ "@whook/http-server": "^9.0.1",
693
576
  "@whook/http-transaction": "<current_version>",
694
577
  "@whook/swagger-ui": "<current_version>",
695
578
  "@whook/whook": "<current_version>",
696
- "common-services": "^9.0.1",
697
- "http-auth-utils": "^3.0.1",
698
- "jwt-service": "^7.1.3",
699
- "knifecycle": "^11.1.1",
700
- "strict-qs": "^6.1.4",
701
- "type-fest": "^2.3.3",
702
- "yerror": "^6.0.1",
703
- "yhttperror": "^6.0.1",
579
+ "common-services": "^11.0.1",
580
+ "http-auth-utils": "^3.0.3",
581
+ "jwt-service": "^9.0.1",
582
+ "knifecycle": "^14.0.0",
583
+ "openapi-schema-validator": "^12.0.0",
584
+ "openapi-types": "^12.0.0",
585
+ "strict-qs": "^7.0.0",
586
+ "type-fest": "^2.13.1",
587
+ "yerror": "^6.1.1",
588
+ "yhttperror": "^6.1.1",
704
589
  },
705
590
  "description": "A new Whook project",
706
591
  "devDependencies": Object {
707
- "@babel/cli": "^7.13.14",
708
- "@babel/core": "^7.13.15",
709
- "@babel/eslint-parser": "^7.13.14",
710
- "@babel/node": "^7.13.13",
711
- "@babel/plugin-proposal-class-properties": "^7.13.0",
712
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
713
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
714
- "@babel/plugin-syntax-import-meta": "^7.10.4",
715
- "@babel/preset-env": "^7.13.15",
716
- "@babel/preset-typescript": "^7.13.0",
717
- "@babel/register": "^7.13.14",
718
- "@types/jest": "^26.0.22",
719
- "@typescript-eslint/eslint-plugin": "^4.21.0",
720
- "@typescript-eslint/parser": "^4.21.0",
721
- "axios": "^0.21.4",
722
- "babel-plugin-knifecycle": "^5.0.1",
592
+ "@types/jest": "^28.1.1",
593
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
594
+ "@typescript-eslint/parser": "^5.27.0",
595
+ "axios": "^0.27.2",
723
596
  "chokidar": "^3.5.1",
724
- "eslint": "^7.23.0",
725
- "eslint-plugin-prettier": "^3.3.1",
726
- "jest": "^26.6.3",
727
- "jsarch": "^4.0.1",
728
- "openapi-schema-validator": "^8.0.0",
597
+ "esbuild": "^0.14.46",
598
+ "esbuild-jest": "^0.5.0",
599
+ "esbuild-node-externals": "^1.4.1",
600
+ "eslint": "^8.17.0",
601
+ "eslint-config-prettier": "^8.5.0",
602
+ "eslint-plugin-prettier": "^4.0.0",
603
+ "jest": "^28.1.0",
604
+ "jsarch": "^5.0.1",
729
605
  "parse-gitignore": "^1.0.1",
730
- "prettier": "^2.2.1",
606
+ "prettier": "^2.6.2",
731
607
  "rimraf": "^3.0.2",
732
- "schema2dts": "^3.0.0",
733
- "typescript": "^4.2.4",
608
+ "schema2dts": "^4.1.1",
609
+ "ts-node": "^10.8.1",
610
+ "typescript": "^4.7.3",
734
611
  },
735
612
  "engines": Object {
736
- "node": ">=12.19.0",
613
+ "node": ">=16.15.0",
737
614
  },
738
615
  "eslintConfig": Object {
739
616
  "env": Object {
@@ -744,6 +621,7 @@ Mr Bean
744
621
  },
745
622
  "extends": Array [
746
623
  "eslint:recommended",
624
+ "plugin:prettier/recommended",
747
625
  "plugin:@typescript-eslint/eslint-recommended",
748
626
  "plugin:@typescript-eslint/recommended",
749
627
  ],
@@ -754,7 +632,7 @@ Mr Bean
754
632
  "parserOptions": Object {
755
633
  "ecmaVersion": 2018,
756
634
  "modules": true,
757
- "sourceType": "module",
635
+ "sourceType": "script",
758
636
  },
759
637
  "plugins": Array [
760
638
  "prettier",
@@ -776,6 +654,13 @@ Mr Bean
776
654
  "lcov",
777
655
  "html",
778
656
  ],
657
+ "extensionsToTreatAsEsm": Array [
658
+ ".ts",
659
+ ],
660
+ "moduleNameMapper": Object {
661
+ "#(.*)": "<rootDir>/../../node_modules/$1",
662
+ "(.+)\\\\.js": "$1",
663
+ },
779
664
  "roots": Array [
780
665
  "<rootDir>/src",
781
666
  ],
@@ -783,13 +668,21 @@ Mr Bean
783
668
  "testPathIgnorePatterns": Array [
784
669
  "/node_modules/",
785
670
  ],
671
+ "transform": Object {
672
+ "^.+\\\\.tsx?$": Array [
673
+ "esbuild-jest",
674
+ Object {
675
+ "format": "esm",
676
+ "sourcemap": true,
677
+ },
678
+ ],
679
+ },
786
680
  },
787
681
  "keywords": Array [
788
682
  "whook",
789
683
  ],
790
684
  "license": "SEE LICENSE",
791
- "main": "dist/index",
792
- "module": "dist/index.mjs",
685
+ "main": "dist/index.js",
793
686
  "name": "super-project",
794
687
  "prettier": Object {
795
688
  "printWidth": 80,
@@ -802,25 +695,23 @@ Mr Bean
802
695
  "scripts": Object {
803
696
  "apitypes": "npm run --silent whook -- generateOpenAPISchema --authenticated=true | npm run --silent whook -- generateOpenAPITypes > src/openAPISchema.d.ts",
804
697
  "architecture": "jsarch 'src/**/*.ts' > ARCHITECTURE.md && git add ARCHITECTURE.md",
805
- "build": "npm run compile && NODE_ENV=\${NODE_ENV:-development} node bin/build",
806
- "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs",
807
- "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
808
- "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
698
+ "build": "rimraf -f 'dist' && tsc --outDir dist",
809
699
  "cover": "npm run jest -- --coverage",
810
- "debug": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} babel-node --extensions '.ts,.js' --inspect bin/dev",
811
- "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/dev",
700
+ "debug": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 DEBUG=\${DEBUG:-whook} ts-node --esm --inspect bin/dev",
701
+ "dev": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --files bin/dev.js",
812
702
  "genPackagelock": "npm i --package-lock-only",
813
- "jest": "NODE_ENV=test jest",
703
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
814
704
  "lint": "eslint 'src/**/*.ts'",
705
+ "postbuild": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/build.js",
815
706
  "prettier": "prettier --write 'src/**/*.ts'",
816
- "start": "NODE_ENV=\${NODE_ENV:-development} node bin/start",
817
- "test": "npm run jest",
818
- "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist",
819
- "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 babel-node --extensions '.ts,.js' bin/watch",
707
+ "start": "PROJECT_SRC=\\"$PWD/dist\\" NODE_ENV=\${NODE_ENV:-development} node bin/start.js",
708
+ "test": "NODE_ENV=test npm run build && npm run jest",
709
+ "watch": "NODE_ENV=\${NODE_ENV:-development} DEV_MODE=1 DESTROY_SOCKETS=1 ts-node --esm --files bin/watch.js",
820
710
  "whook": "NODE_ENV=\${NODE_ENV:-development} whook",
821
- "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- node_modules/@whook/cli/bin/whook.js",
822
- "whook-repl": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} babel-node --extensions '.ts,.js' -- bin/repl.js",
711
+ "whook-dev": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/whook.js",
712
+ "whook-repl": "PROJECT_SRC=\\"$PWD/src\\" NODE_ENV=\${NODE_ENV:-development} ts-node --esm --files -- bin/repl.js",
823
713
  },
714
+ "type": "module",
824
715
  "types": "dist/index.d.ts",
825
716
  "version": "0.0.0",
826
717
  }
@@ -839,7 +730,7 @@ Mr Bean
839
730
  });
840
731
 
841
732
  it('should fail with access problems', async () => {
842
- readFile.mockResolvedValueOnce(JSON.stringify(packageJSON));
733
+ readFile.mockResolvedValueOnce(Buffer.from(JSON.stringify(packageJSON)));
843
734
  readdir.mockResolvedValueOnce(['development', 'production']);
844
735
  copy.mockRejectedValueOnce(new YError('E_ACCESS'));
845
736
  axios.mockResolvedValueOnce({
@@ -859,9 +750,9 @@ Mr Bean
859
750
  SOURCE_DIR,
860
751
  author,
861
752
  project,
862
- writeFile,
863
- readFile,
864
- readdir,
753
+ writeFile: writeFile as any,
754
+ readFile: readFile as any,
755
+ readdir: readdir as any,
865
756
  exec: exec as any,
866
757
  copy,
867
758
  axios: axios as any,
@@ -874,8 +765,8 @@ Mr Bean
874
765
  throw new YError('E_UNEXPECTED_SUCCESS');
875
766
  } catch (err) {
876
767
  expect({
877
- errorCode: err.code,
878
- errorParams: err.params,
768
+ errorCode: (err as YError).code,
769
+ errorParams: (err as YError).params,
879
770
  }).toMatchInlineSnapshot(`
880
771
  Object {
881
772
  "errorCode": "E_ACCESS",