@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.
Files changed (42) hide show
  1. package/README.md +2 -2
  2. package/bin/create.js +2 -2
  3. package/dist/index.js +47 -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 +8 -11
  10. package/dist/services/createWhook.js +142 -144
  11. package/dist/services/createWhook.js.map +1 -1
  12. package/dist/services/createWhook.test.js +392 -506
  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 +50 -96
  20. package/src/index.ts +24 -17
  21. package/src/services/__snapshots__/author.test.ts.snap +3 -3
  22. package/src/services/__snapshots__/createWhook.test.ts.snap +712 -4
  23. package/src/services/author.test.ts +8 -6
  24. package/src/services/author.ts +2 -2
  25. package/src/services/createWhook.test.ts +197 -312
  26. package/src/services/createWhook.ts +38 -13
  27. package/src/services/project.test.ts +11 -6
  28. package/src/services/project.ts +3 -2
  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 -834
  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
package/package.json CHANGED
@@ -1,7 +1,13 @@
1
1
  {
2
2
  "name": "@whook/create",
3
- "version": "9.0.1",
3
+ "version": "10.0.2",
4
4
  "description": "Kickstart a new Whook server",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "create": "bin/create.js"
10
+ },
5
11
  "keywords": [
6
12
  "whook",
7
13
  "knifecycle",
@@ -12,20 +18,13 @@
12
18
  "service",
13
19
  "creator"
14
20
  ],
15
- "main": "dist/index",
16
- "module": "dist/index.mjs",
17
- "types": "dist/index.d.ts",
18
- "bin": {
19
- "create": "bin/create.js"
20
- },
21
21
  "metapak": {
22
22
  "configs": [
23
23
  "main",
24
24
  "readme",
25
+ "tsesm",
25
26
  "eslint",
26
- "babel",
27
- "jest",
28
- "typescript"
27
+ "jest"
29
28
  ],
30
29
  "data": {
31
30
  "childPackage": true,
@@ -42,22 +41,15 @@
42
41
  }
43
42
  },
44
43
  "scripts": {
44
+ "build": "rimraf -f 'dist' && tsc --outDir dist",
45
45
  "cli": "env NODE_ENV=${NODE_ENV:-cli}",
46
- "compile": "rimraf -f 'dist' && npm run compile:cjs && npm run compile:mjs",
47
- "compile:cjs": "babel --env-name=cjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
48
- "compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --extensions '.ts,.js' --source-maps=true src",
49
46
  "cover": "npm run jest -- --coverage",
50
- "debug": "NODE_ENV=${NODE_ENV:-development} DESTROY_SOCKETS=1 babel-node --inspect bin/dev",
51
- "dev": "NODE_ENV=${NODE_ENV:-development} DESTROY_SOCKETS=1 babel-node bin/dev",
52
47
  "genPackagelock": "npm i --package-lock-only",
53
- "jest": "NODE_ENV=test jest",
48
+ "jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
54
49
  "lint": "eslint 'src/**/*.ts'",
55
50
  "metapak": "metapak",
56
51
  "prettier": "prettier --write 'src/**/*.ts'",
57
- "start": "NODE_ENV=${NODE_ENV:-development} node bin/start",
58
- "test": "npm run jest",
59
- "types": "rimraf -f 'dist/**/*.d.ts' && tsc --project . --declaration --emitDeclarationOnly --outDir dist",
60
- "whook": "NODE_ENV=${NODE_ENV:-development} whook"
52
+ "test": "npm run jest"
61
53
  },
62
54
  "author": {
63
55
  "name": "Nicolas Froidure",
@@ -74,45 +66,36 @@
74
66
  },
75
67
  "homepage": "https://github.com/nfroidure/whook",
76
68
  "dependencies": {
77
- "@whook/cli": "^9.0.1",
78
- "@whook/example": "^9.0.1",
69
+ "@whook/cli": "^10.0.2",
70
+ "@whook/example": "^10.0.2",
79
71
  "axios": "^0.27.2",
80
- "common-services": "^10.0.2",
72
+ "common-services": "^11.0.1",
81
73
  "debug": "^4.3.4",
82
- "fs-extra": "^10.0.0",
83
- "inquirer": "^8.2.4",
84
- "knifecycle": "^12.0.4",
85
- "ora": "^5.4.0",
86
- "yerror": "^6.0.2"
74
+ "fs-extra": "^10.1.0",
75
+ "inquirer": "^9.0.0",
76
+ "knifecycle": "^14.0.0",
77
+ "ora": "^6.1.0",
78
+ "yerror": "^6.1.1"
87
79
  },
88
80
  "devDependencies": {
89
- "@babel/cli": "^7.17.10",
90
- "@babel/core": "^7.18.2",
91
- "@babel/eslint-parser": "^7.18.2",
92
- "@babel/node": "^7.13.13",
93
- "@babel/plugin-proposal-class-properties": "^7.17.12",
94
- "@babel/plugin-proposal-object-rest-spread": "^7.18.0",
95
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
96
- "@babel/plugin-syntax-import-meta": "^7.10.4",
97
- "@babel/preset-env": "^7.18.2",
98
- "@babel/preset-typescript": "^7.17.12",
99
- "@babel/register": "^7.17.7",
100
- "@types/jest": "^27.0.2",
101
- "@typescript-eslint/eslint-plugin": "^5.26.0",
102
- "@typescript-eslint/parser": "^5.26.0",
103
- "babel-plugin-knifecycle": "^5.0.3",
104
- "eslint": "^8.16.0",
81
+ "@types/jest": "^28.1.1",
82
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
83
+ "@typescript-eslint/parser": "^5.27.0",
84
+ "esbuild": "^0.14.46",
85
+ "esbuild-jest": "^0.5.0",
86
+ "eslint": "^8.17.0",
87
+ "eslint-config-prettier": "^8.5.0",
105
88
  "eslint-plugin-prettier": "^4.0.0",
106
89
  "jest": "^28.1.0",
107
90
  "metapak": "^4.0.4",
108
- "metapak-nfroidure": "11.2.1",
91
+ "metapak-nfroidure": "12.1.0",
109
92
  "prettier": "^2.6.2",
110
93
  "rimraf": "^3.0.2",
111
- "typescript": "^4.7.2"
94
+ "typescript": "^4.7.3"
112
95
  },
113
96
  "contributors": [],
114
97
  "engines": {
115
- "node": ">=12.19.0"
98
+ "node": ">=16.15.0"
116
99
  },
117
100
  "files": [
118
101
  "dist",
@@ -124,12 +107,13 @@
124
107
  "eslintConfig": {
125
108
  "extends": [
126
109
  "eslint:recommended",
110
+ "plugin:prettier/recommended",
127
111
  "plugin:@typescript-eslint/eslint-recommended",
128
112
  "plugin:@typescript-eslint/recommended"
129
113
  ],
130
114
  "parserOptions": {
131
115
  "ecmaVersion": 2018,
132
- "sourceType": "module",
116
+ "sourceType": "script",
133
117
  "modules": true
134
118
  },
135
119
  "env": {
@@ -156,53 +140,6 @@
156
140
  "trailingComma": "all",
157
141
  "proseWrap": "always"
158
142
  },
159
- "babel": {
160
- "presets": [
161
- "@babel/typescript",
162
- [
163
- "@babel/env",
164
- {
165
- "targets": {
166
- "node": "12.19.0"
167
- }
168
- }
169
- ]
170
- ],
171
- "plugins": [
172
- "@babel/proposal-class-properties",
173
- "@babel/plugin-proposal-object-rest-spread",
174
- "babel-plugin-knifecycle"
175
- ],
176
- "env": {
177
- "cjs": {
178
- "presets": [
179
- [
180
- "@babel/env",
181
- {
182
- "targets": {
183
- "node": "10"
184
- },
185
- "modules": "commonjs"
186
- }
187
- ]
188
- ]
189
- },
190
- "mjs": {
191
- "presets": [
192
- [
193
- "@babel/env",
194
- {
195
- "targets": {
196
- "node": "12"
197
- },
198
- "modules": false
199
- }
200
- ]
201
- ]
202
- }
203
- },
204
- "sourceMaps": true
205
- },
206
143
  "jest": {
207
144
  "coverageReporters": [
208
145
  "lcov",
@@ -213,7 +150,24 @@
213
150
  ],
214
151
  "roots": [
215
152
  "<rootDir>/src"
153
+ ],
154
+ "testEnvironment": "node",
155
+ "transform": {
156
+ "^.+\\.tsx?$": [
157
+ "esbuild-jest",
158
+ {
159
+ "sourcemap": true,
160
+ "format": "esm"
161
+ }
162
+ ]
163
+ },
164
+ "moduleNameMapper": {
165
+ "#(.*)": "<rootDir>/../../node_modules/$1",
166
+ "(.+)\\.js": "$1"
167
+ },
168
+ "extensionsToTreatAsEsm": [
169
+ ".ts"
216
170
  ]
217
171
  },
218
- "gitHead": "a5620b3eacf3b500a5db59db9997bf7ed60668d5"
172
+ "gitHead": "9a91f940bb084998baa83917bf143ec198bdf143"
219
173
  }
package/src/index.ts CHANGED
@@ -1,27 +1,36 @@
1
- import Knifecycle, { constant } from 'knifecycle';
1
+ import { Knifecycle, constant } from 'knifecycle';
2
2
  import { exec as _exec } from 'child_process';
3
- import {
4
- writeFile as _writeFile,
5
- readFile as _readFile,
6
- copy as _copy,
7
- ensureDir as _ensureDir,
8
- } from 'fs-extra';
3
+ import { default as fsExtra } from 'fs-extra';
9
4
  import debug from 'debug';
10
5
  import path from 'path';
11
6
  import inquirer from 'inquirer';
7
+ import { createRequire } from 'module';
12
8
  import {
13
9
  initLogService,
14
10
  initLockService,
15
11
  initDelayService,
16
12
  } from 'common-services';
17
- import initAuthor from './services/author';
18
- import initProject from './services/project';
19
- import initCreateWhook from './services/createWhook';
20
- import type { CreateWhookService } from './services/createWhook';
13
+ import initAuthor from './services/author.js';
14
+ import initProject from './services/project.js';
15
+ import initCreateWhook from './services/createWhook.js';
16
+ import type { CreateWhookService } from './services/createWhook.js';
17
+ import type { Logger } from 'common-services';
18
+
19
+ const {
20
+ writeFile: _writeFile,
21
+ readFile: _readFile,
22
+ copy: _copy,
23
+ ensureDir: _ensureDir,
24
+ } = fsExtra;
21
25
 
22
26
  export async function runCreateWhook(): Promise<void> {
23
27
  try {
24
28
  const $ = new Knifecycle();
29
+ // TODO: Use import.meta when Jest will support it
30
+ const require = createRequire(
31
+ import.meta.url ||
32
+ path.join(process.cwd(), 'src', 'services', 'API.test.ts'),
33
+ );
25
34
 
26
35
  $.register(constant('CWD', process.cwd()));
27
36
  $.register(constant('inquirer', inquirer));
@@ -36,16 +45,14 @@ export async function runCreateWhook(): Promise<void> {
36
45
  path.resolve(path.dirname(require.resolve('@whook/example')), '..'),
37
46
  ),
38
47
  );
39
- $.register(constant('debug', debug('whook')));
40
48
  $.register(
41
49
  constant('logger', {
42
50
  // eslint-disable-next-line
43
- error: console.error.bind(console),
44
- // eslint-disable-next-line
45
- info: console.info.bind(console),
51
+ output: console.log.bind(console),
46
52
  // eslint-disable-next-line
47
- warning: console.log.bind(console),
48
- }),
53
+ error: console.error.bind(console),
54
+ debug: debug('whook'),
55
+ } as Logger),
49
56
  );
50
57
  $.register(initLogService);
51
58
  $.register(initLockService);
@@ -26,7 +26,7 @@ Object {
26
26
  },
27
27
  Object {
28
28
  "default": undefined,
29
- "message": "You email?",
29
+ "message": "Your email?",
30
30
  "name": "authorEmail",
31
31
  },
32
32
  ],
@@ -91,7 +91,7 @@ Object {
91
91
  },
92
92
  Object {
93
93
  "default": "wayne@warner.com",
94
- "message": "You email?",
94
+ "message": "Your email?",
95
95
  "name": "authorEmail",
96
96
  },
97
97
  ],
@@ -142,7 +142,7 @@ Object {
142
142
  },
143
143
  Object {
144
144
  "default": "wayne@warner.com",
145
- "message": "You email?",
145
+ "message": "Your email?",
146
146
  "name": "authorEmail",
147
147
  },
148
148
  ],