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