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