@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.
- package/README.md +2 -2
- package/dist/index.js +8 -10
- package/dist/index.js.map +1 -1
- package/dist/services/author.js.map +1 -1
- package/dist/services/author.test.js +1 -0
- package/dist/services/author.test.js.map +1 -1
- package/dist/services/createWhook.js +4 -0
- package/dist/services/createWhook.js.map +1 -1
- package/dist/services/createWhook.test.js +503 -481
- package/dist/services/createWhook.test.js.map +1 -1
- package/dist/services/project.js.map +1 -1
- package/dist/services/project.test.js +1 -0
- package/dist/services/project.test.js.map +1 -1
- package/package.json +52 -50
- package/src/index.ts +11 -10
- package/src/services/__snapshots__/createWhook.test.ts.snap +217 -152
- package/src/services/author.test.ts +1 -0
- package/src/services/author.ts +1 -1
- package/src/services/createWhook.test.ts +505 -482
- package/src/services/createWhook.ts +18 -12
- package/src/services/project.test.ts +1 -0
- package/src/services/project.ts +1 -1
|
@@ -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.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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
|
-
|
|
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
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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
|
-
|
|
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',
|