create-gasket-app 7.0.0-next.3 → 7.0.0-next.30

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 (37) hide show
  1. package/lib/commands/create.js +43 -328
  2. package/lib/config/default-plugins.js +2 -2
  3. package/lib/index.d.ts +104 -45
  4. package/lib/index.js +3 -2
  5. package/lib/scaffold/action-wrapper.js +6 -4
  6. package/lib/scaffold/actions/create-hooks.js +4 -5
  7. package/lib/scaffold/actions/generate-files.js +1 -1
  8. package/lib/scaffold/actions/global-prompts.js +39 -41
  9. package/lib/scaffold/actions/index.js +5 -12
  10. package/lib/scaffold/actions/install-modules.js +1 -4
  11. package/lib/scaffold/actions/link-modules.js +1 -3
  12. package/lib/scaffold/actions/load-preset.js +48 -71
  13. package/lib/scaffold/actions/mkdir.js +1 -1
  14. package/lib/scaffold/actions/post-create-hooks.js +3 -5
  15. package/lib/scaffold/actions/preset-config-hooks.js +13 -0
  16. package/lib/scaffold/actions/preset-prompt-hooks.js +6 -3
  17. package/lib/scaffold/actions/print-report.js +1 -1
  18. package/lib/scaffold/actions/prompt-hooks.js +7 -53
  19. package/lib/scaffold/actions/setup-pkg.js +11 -22
  20. package/lib/scaffold/actions/write-gasket-config.js +97 -12
  21. package/lib/scaffold/actions/write-pkg.js +1 -4
  22. package/lib/scaffold/config-builder.js +88 -12
  23. package/lib/scaffold/create-context.js +20 -28
  24. package/lib/scaffold/dump-error-context.js +3 -3
  25. package/lib/scaffold/files.js +1 -1
  26. package/lib/scaffold/utils.js +2 -87
  27. package/lib/utils/index.js +1 -2
  28. package/lib/utils/process-command.js +3 -1
  29. package/package.json +15 -14
  30. package/lib/config/utils.js +0 -59
  31. package/lib/main.js +0 -19
  32. package/lib/scaffold/actions/apply-preset-config.js +0 -29
  33. package/lib/scaffold/actions/cli-version.js +0 -88
  34. package/lib/scaffold/actions/load-pkg-for-debug.js +0 -24
  35. package/lib/scaffold/create-engine.js +0 -21
  36. package/lib/scaffold/fetcher.js +0 -194
  37. package/lib/utils/warn-if-outdated.js +0 -76
@@ -1,34 +1,27 @@
1
- /* eslint-disable max-statements */
2
- import ora from 'ora';
1
+ /* eslint-disable max-statements, no-unused-vars */
3
2
  import chalk from 'chalk';
4
3
  import { makeCreateContext } from '../scaffold/create-context.js';
5
4
  import { dumpErrorContext } from '../scaffold/dump-error-context.js';
5
+ import { rm } from 'fs/promises';
6
+ import { makeGasket } from '@gasket/core';
7
+ import { defaultPlugins } from '../config/default-plugins.js';
6
8
  import {
7
- applyPresetConfig,
8
- cliVersion,
9
9
  createHooks,
10
10
  generateFiles,
11
11
  globalPrompts,
12
12
  installModules,
13
13
  linkModules,
14
- loadPkgForDebug,
15
14
  loadPreset,
16
15
  mkDir,
17
16
  postCreateHooks,
18
17
  printReport,
19
18
  presetPromptHooks,
19
+ presetConfigHooks,
20
20
  promptHooks,
21
21
  setupPkg,
22
22
  writeGasketConfig,
23
23
  writePkg
24
24
  } from '../scaffold/actions/index.js';
25
- import path from 'path';
26
- import os from 'os';
27
- import { mkdtemp, rm } from 'fs/promises';
28
- import { default as gasketUtils } from '@gasket/utils';
29
- import { makeGasket } from '@gasket/core';
30
- import { createRequire } from 'module';
31
- const require = createRequire(import.meta.url);
32
25
 
33
26
  /**
34
27
  * Parses comma separated option input to array
@@ -57,13 +50,6 @@ const createCommand = {
57
50
  Or other (multiple) custom presets (e.g. --presets my-gasket-preset@1.0.0.beta-1,nextjs@^1.0.0)`,
58
51
  parse: commasToArray
59
52
  },
60
- {
61
- name: 'plugins',
62
- description: `Additional plugin(s) to install. Can be set as
63
- multiple flags (e.g. --plugins jest --plugins zkconfig@^1.0.0)
64
- comma-separated values: --plugins=jest,zkconfig^1.0.0`,
65
- parse: commasToArray
66
- },
67
53
  {
68
54
  name: 'package-manager',
69
55
  description: `Selects which package manager you would like to use during
@@ -75,18 +61,6 @@ const createCommand = {
75
61
  description: 'Require module(s) before Gasket is initialized',
76
62
  parse: commasToArray
77
63
  },
78
- {
79
- name: 'no-bootstrap',
80
- description: '(INTERNAL) If provided, skip the bootstrap phase',
81
- type: 'boolean',
82
- hidden: true
83
- },
84
- {
85
- name: 'no-generate',
86
- description: '(INTERNAL) If provided, skip the generate phase',
87
- type: 'boolean',
88
- hidden: true
89
- },
90
64
  {
91
65
  name: 'npm-link',
92
66
  description: `(INTERNAL) Local packages to be linked. Can be set as
@@ -113,207 +87,14 @@ const createCommand = {
113
87
  conflicts: ['config']
114
88
  },
115
89
  {
116
- name: 'prompts',
90
+ name: 'no-prompts',
117
91
  description: '(INTERNAL) Disable to skip the prompts',
118
- default: true,
119
92
  type: 'boolean',
120
93
  hidden: true
121
94
  }
122
95
  ]
123
96
  };
124
97
 
125
- async function wait(ms = 50) {
126
- return new Promise(resolve => {
127
- console.log('waiting...')
128
- setTimeout(resolve, ms);
129
- });
130
- }
131
-
132
- function evaluatePreset(preset) {
133
- const parts = preset.split('@').filter(Boolean);
134
- if (parts.length > 1) {
135
- return {
136
- name: `@${parts[0]}`,
137
- version: parts[1]
138
- };
139
- } else if (parts.length === 1) {
140
- return {
141
- name: `@${parts[0]}`,
142
- version: null
143
- };
144
- }
145
-
146
- return preset;
147
- }
148
-
149
- createCommand.action = async function run(appname, options, command) {
150
- // temp
151
- process.env.GASKET_DEBUG_NPM = 'true';
152
- // temp
153
- const context = makeCreateContext([appname], options);
154
- const {
155
- presets = [],
156
- presetPath = [],
157
- } = options;
158
-
159
- const tmpDir = await mkdtemp(path.join(os.tmpdir(), `gasket-create-${context.appName}`));
160
- const modPath = path.join(tmpDir, 'node_modules');
161
- console.log(tmpDir);
162
- await globalPrompts(context);
163
-
164
- const pkgManager = new gasketUtils.PackageManager({ packageManager: context.packageManager, dest: tmpDir });
165
- const pkgVerb = pkgManager.isYarn ? 'add' : 'install';
166
-
167
- const remotePresets = await Promise.all(presets.map(async preset => {
168
- await pkgManager.exec(pkgVerb, [preset]);
169
- const pkgFile = require(path.join(modPath, preset, 'package.json'));
170
- const presetMod = await import(pkgFile.name, { from: modPath });
171
-
172
- const dependencies = Object.entries(pkgFile.dependencies || {})
173
- .filter(([name]) => name.startsWith('@gasket'))
174
- .map(([name, version]) => ({ name, version }));
175
-
176
- const plugins = await Promise.all(dependencies.map(async ({ name }) => {
177
- const mod = await import(name, { from: modPath });
178
- return mod.default || mod;
179
- }));
180
-
181
- return {
182
- pkgFile,
183
- dependencies,
184
- plugins: [
185
- presetMod.default || presetMod,
186
- ...plugins
187
- ]
188
- }
189
- }));
190
-
191
- const localPresets = await Promise.all(presetPath.map(async localPreset => {
192
- await pkgManager.exec(pkgVerb, [localPreset]);
193
- const pkgFile = require(path.join(localPreset, 'package.json'));
194
- const presetMod = await import(pkgFile.name, { from: modPath });
195
-
196
- const dependencies = Object.entries(pkgFile.dependencies || {})
197
- .filter(([name]) => name.startsWith('@gasket'))
198
- .map(([name, version]) => ({ name, version }));
199
-
200
- const plugins = await Promise.all(dependencies.map(async ({ name }) => {
201
- const mod = await import(name, { from: modPath });
202
- return mod.default || mod;
203
- }));
204
-
205
- return {
206
- module: presetMod.default || presetMod,
207
- pkgFile,
208
- dependencies,
209
- plugins
210
- };
211
- }));
212
-
213
-
214
- const configuredPresets = await Promise.all([
215
- ...remotePresets,
216
- ...localPresets
217
- ]);
218
-
219
- const presetPlugins = configuredPresets.reduce((acc, p) => {
220
- return [
221
- ...acc,
222
- p.module
223
- ];
224
- }, []);
225
-
226
- const presetGasket = makeGasket({
227
- plugins: presetPlugins
228
- });
229
-
230
- console.log(presetGasket);
231
-
232
- await presetPromptHooks(presetGasket, context);
233
- console.log(context);
234
- const presetConfig = await presetGasket.execWaterfall('presetConfig', context);
235
-
236
- console.log(configuredPresets)
237
- console.log(configuredPresets[0].dependencies)
238
- console.log(configuredPresets[0].plugins)
239
- console.log(presetConfig);
240
-
241
- // Check preset plugins vs the plugins from the presetConfig
242
-
243
-
244
-
245
- // await globalPrompts(context);
246
- // presetPrompt
247
- // presetConfig
248
-
249
- // const gasketPlugins = makeGasket({
250
- // // plugins
251
- // })
252
-
253
- // promptHooks
254
-
255
-
256
- // applyPresetConfig(context);
257
- // await globalPrompts(context);
258
- // await mkDir(context);
259
- // await setupPkg(context);
260
- // await writePkg(context);
261
- // await installModules(context);
262
- // await linkModules(context);
263
- // await promptHooks(gasketPlugins, context);
264
- // await createHooks(context);
265
- // await generateFiles(context);
266
- // await writeGasketConfig(context);
267
- // await writePkg.update(context);
268
- // await installModules.update(context);
269
- // await linkModules.update(context); // relink any that were messed up by re-install
270
- // await postCreateHooks(context);
271
-
272
-
273
- // download preset to os temp dir
274
- // import preset to CGA
275
- // makeGasket with preset
276
- // exec presetPrompt
277
- // exec presetConfig
278
- // makeGasket with presetConfig
279
- // exec prompt
280
- // exec create
281
-
282
- // console.log('Deleting tmp dir...')
283
- // await rm(tmpDir, { recursive: true });
284
- }
285
-
286
- /**
287
- * bootstrap - Bootstrap the application
288
- * @param {CreateContext} context - Create context
289
- */
290
- // async function bootstrapHandler(context) {
291
- // await loadPreset(context);
292
- // cliVersion(context);
293
- // applyPresetConfig(context);
294
- // await globalPrompts(context);
295
- // await mkDir(context);
296
- // await setupPkg(context);
297
- // await writePkg(context);
298
- // await installModules(context);
299
- // await linkModules(context);
300
- // }
301
-
302
- /**
303
- * generate - Generate the application
304
- * @param {CreateContext} context - Create context
305
- */
306
- // async function generateHandler(context) {
307
- // await promptHooks(context);
308
- // await createHooks(context);
309
- // await generateFiles(context);
310
- // await writeGasketConfig(context);
311
- // await writePkg.update(context);
312
- // await installModules.update(context);
313
- // await linkModules.update(context); // relink any that were messed up by re-install
314
- // await postCreateHooks(context);
315
- // }
316
-
317
98
  /**
318
99
  * createCommand action
319
100
  * @param {string} appname Required cmd arg - name of the app to create
@@ -321,113 +102,47 @@ createCommand.action = async function run(appname, options, command) {
321
102
  * @param {Command} command - the command instance
322
103
  * @returns {Promise<void>} void
323
104
  */
324
- // createCommand.action = async function run(appname, options, command) {
325
- // const argv = [appname];
326
- // const { bootstrap = true, generate = true } = options;
105
+ createCommand.action = async function run(appname, options, command) {
106
+ process.env.GASKET_ENV = 'create';
107
+ const context = makeCreateContext([appname], options);
108
+ const { rawPresets, localPresets } = context;
327
109
 
328
- // let context;
329
- // try {
330
- // context = makeCreateContext(argv, options);
331
- // } catch (error) {
332
- // console.error(chalk.red(error) + '\n');
333
- // command.help();
334
- // }
110
+ try {
111
+ await globalPrompts({ context });
335
112
 
336
- // try {
337
- // if (bootstrap) {
338
- // await bootstrapHandler(context);
339
- // } else {
340
- // ora('Bootstrap phase skipped.').warn();
341
- // if (generate) {
342
- // await loadPkgForDebug(context);
343
- // }
344
- // }
113
+ if (rawPresets.length || localPresets.length) {
114
+ await loadPreset({ context });
345
115
 
346
- // if (generate) {
347
- // await generateHandler(context);
348
- // } else {
349
- // ora('Generate phase skipped.').warn();
350
- // }
116
+ const presetGasket = makeGasket({
117
+ plugins: context.presets
118
+ });
351
119
 
352
- // printReport(context);
120
+ await presetPromptHooks({ gasket: presetGasket, context });
121
+ await presetConfigHooks({ gasket: presetGasket, context });
122
+ }
353
123
 
354
- // } catch (err) {
355
- // console.error(chalk.red('Exiting with errors.'));
356
- // dumpErrorContext(context, err);
357
- // throw err;
358
- // }
359
- // };
124
+ const pluginGasket = makeGasket({
125
+ ...context.presetConfig,
126
+ plugins: context.presets.concat(context.presetConfig.plugins, defaultPlugins)
127
+ });
128
+
129
+ await promptHooks({ gasket: pluginGasket, context });
130
+ await mkDir({ context });
131
+ await setupPkg({ context });
132
+ await createHooks({ gasket: pluginGasket, context });
133
+ await writePkg({ context });
134
+ await generateFiles({ context });
135
+ await writeGasketConfig({ context });
136
+ await installModules({ context });
137
+ await linkModules({ context });
138
+ await postCreateHooks({ gasket: pluginGasket, context });
139
+ if (context.tmpDir) await rm(context.tmpDir, { recursive: true });
140
+ printReport({ context });
141
+ } catch (err) {
142
+ console.error(chalk.red('Exiting with errors.'));
143
+ dumpErrorContext(context, err);
144
+ throw err;
145
+ }
146
+ };
360
147
 
361
148
  export { createCommand };
362
-
363
-
364
-
365
- // fire global prompts to inform pkgmanager
366
-
367
- // const tmpDir = await mkdtemp(path.join(os.tmpdir(), `gasket-create-${context.appName}`));
368
- // console.log(tmpDir);
369
-
370
-
371
-
372
- // new PackageManager https://github.com/godaddy/gasket/blob/v7/packages/gasket-utils/lib/package-manager.js#L75
373
- // const remotePresets = context.rawPresets.map(async preset => {
374
- // const { name: presetName, version: presetVersion } = evaluatePreset(preset)
375
-
376
- // // await runShellCommand('npm', ['i', `${presetName}@${presetVersion}`], { cwd: tmpDir }, true);
377
- // const modPath = path.join(tmpDir, 'node_modules');
378
- // const pkgFile = require(path.join(modPath, presetName, 'package.json'));
379
- // const presetMod = await import(presetName, { from: modPath });
380
-
381
- // const dependencies = Object.entries(pkgFile.dependencies || {})
382
- // .filter(([name]) => name.startsWith('@gasket'))
383
- // .map(([name, version]) => ({ name, version }));
384
-
385
- // const plugins = await Promise.all(dependencies.map(async ({ name }) => {
386
- // const mod = await import(name, { from: modPath });
387
- // return mod.default || mod;
388
- // }));
389
-
390
- // console.log(plugins)
391
- // return {
392
- // // module: await import(preset, { from: modPath }),
393
- // pkgFile,
394
- // dependencies,
395
- // plugins: [
396
- // presetMod.default || presetMod,
397
- // ...plugins
398
- // ]
399
- // }
400
- // });
401
-
402
- // const localPresets = context.localPresets.map(async localPreset => {
403
- // await runShellCommand('npm', ['i', localPreset], { cwd: tmpDir }, true);
404
-
405
- // const modPath = path.join(tmpDir, 'node_modules');
406
- // const pkgFile = require(path.join(localPreset, 'package.json'));
407
- // const presetMod = await import(pkgFile.name, { from: modPath });
408
-
409
-
410
- // const dependencies = Object.entries(pkgFile.dependencies || {})
411
- // .filter(([name]) => name.startsWith('@gasket'))
412
- // .map(([name, version]) => ({ name, version }));
413
-
414
- // const plugins = await Promise.all(dependencies.map(async ({ name }) => {
415
- // const mod = await import(name, { from: modPath });
416
- // return mod.default || mod;
417
- // }));
418
-
419
- // return {
420
- // // module: await import(preset, { from: modPath }),
421
- // pkgFile,
422
- // dependencies,
423
- // plugins: [
424
- // presetMod.default || presetMod,
425
- // ...plugins
426
- // ]
427
- // }
428
- // });
429
-
430
- // const presets = await Promise.all([
431
- // ...remotePresets,
432
- // ...localPresets
433
- // ]);
@@ -1,7 +1,7 @@
1
- import pluginMetadata from '@gasket/plugin-metadata';
2
1
  import pluginGit from '@gasket/plugin-git';
2
+ import pluginLogger from '@gasket/plugin-logger';
3
3
 
4
4
  export const defaultPlugins = [
5
- pluginMetadata,
5
+ pluginLogger,
6
6
  pluginGit
7
7
  ];
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { GasketConfigDefinition, MaybeAsync } from '@gasket/engine';
1
+ import type { GasketConfigDefinition, MaybeAsync, Plugin, GasketEngine } from '@gasket/core';
2
2
  import type { PackageManager } from '@gasket/utils';
3
3
 
4
4
  export interface Dependencies {
@@ -9,17 +9,18 @@ export interface Dependencies {
9
9
 
10
10
  export interface PackageJson extends Dependencies {
11
11
  name: string;
12
- version: string;
12
+ version?: string;
13
13
  description?: string;
14
14
  license?: string;
15
15
  repository?:
16
16
  | string
17
17
  | {
18
- type: 'git';
19
- url: string;
20
- };
18
+ type: 'git';
19
+ url: string;
20
+ };
21
21
  scripts?: Record<string, string>;
22
22
  optionalDependencies?: Record<string, string>;
23
+ homepage?: string;
23
24
  }
24
25
 
25
26
  export interface ModuleInfo {
@@ -30,11 +31,9 @@ export interface ModuleInfo {
30
31
  version?: string;
31
32
  }
32
33
 
33
- export interface PresetInfo extends ModuleInfo {
34
- }
34
+ export interface PresetInfo extends ModuleInfo {}
35
35
 
36
- export interface PluginInfo extends ModuleInfo {
37
- }
36
+ export interface PluginInfo extends ModuleInfo {}
38
37
 
39
38
  export interface ConfigBuilder<Config> {
40
39
  /**
@@ -62,20 +61,86 @@ export interface ConfigBuilder<Config> {
62
61
  value: Config[Key],
63
62
  options?: { force?: boolean }
64
63
  ): void;
64
+
65
+ /**
66
+ * addPlugin - Add plugin import to the gasket file and use the value in the plugins array
67
+ * @param {string} pluginImport - name of the import used as a value - `import pluginImport...`
68
+ * @param {string} pluginName - name of the plugin import/package - `from 'pluginName'`
69
+ * @example
70
+ * addPlugin('pluginA', '@gasket/plugin-a')
71
+ *
72
+ * // gasket.js
73
+ * import pluginA from '@gasket/plugin-a';
74
+ *
75
+ * export default makeGasket({
76
+ * plugins: [
77
+ * pluginA
78
+ * ]
79
+ * });
80
+ */
81
+ addPlugin(pluginImport: string, pluginName: string): void;
82
+
83
+ /**
84
+ * addImport - Add a non-plugin import to the gasket file
85
+ * @param {string} importName - name of the import used as a value - `import fs...`
86
+ * @param {string} importPath - path of the import - `from 'fs'`
87
+ * @returns {ConfigBuilder} - instance for chaining
88
+ * @example
89
+ * Can be default or named import
90
+ * addImport('{ readFileSync }', 'fs')
91
+ * addImport('fs', 'fs')
92
+ *
93
+ * // gasket.js
94
+ * import { readFileSync } from 'fs';
95
+ * import fs from 'fs';
96
+ */
97
+ addImport(importName: string, importPath: string): ConfigBuilder<Config>;
98
+
99
+ /**
100
+ * addExpression - add programmatic expression to the gasket file
101
+ * @param {string} expression - expression to add after imports
102
+ * @returns {ConfigBuilder} - instance for chaining
103
+ * @example
104
+ *
105
+ * .addImport('fs', 'fs')
106
+ * .addExpression('const file = fs.readFileSync(\'./file.txt\')')
107
+ *
108
+ * // gasket.js
109
+ * import fs from 'fs';
110
+ * const file = fs.readFileSync('./file.txt');
111
+ */
112
+ addExpression(expression: string): ConfigBuilder<Config>;
113
+
114
+ /**
115
+ * injectValue - Inject a value into the gasket config object
116
+ * @param {string} configKey - collapsed object path to inject value into - `express.config.routes`
117
+ * @param {string} injectedValue - string used as a value
118
+ * @example
119
+ * .addImport('{ routes }', './routes')
120
+ * .injectValue('express.routes', 'routes');
121
+ *
122
+ * // gasket.js
123
+ * export default makeGasket({
124
+ * express: {
125
+ * routes: routes
126
+ * }
127
+ * });
128
+ */
129
+ injectValue(configKey: string, injectedValue: string): void;
65
130
  }
66
131
 
67
132
  export interface PackageJsonBuilder extends ConfigBuilder<PackageJson> {
68
133
  /**
69
- * Checks if a dependency has been already added
70
- * @param key - Dependency bucket
71
- * @param value - Dependency to search
72
- * @returns True if the dependency exists on the bucket
134
+ * Checks if a property exists on the package.json fields.
135
+ * @param key - Field to search
136
+ * @param value - Value to search for
137
+ * @returns True if the property exists and matches the value
73
138
  */
74
- has(key: keyof Dependencies, value: string): boolean;
139
+ has(key: keyof PackageJson, value: string): boolean;
75
140
  }
76
141
 
77
142
  export interface Files {
78
- add(...args: string[]): void
143
+ add(...args: string[]): void;
79
144
  }
80
145
 
81
146
  export interface CreateContext {
@@ -101,12 +166,6 @@ export interface CreateContext {
101
166
  * load-preset if using localPresets. */
102
167
  rawPresets: Array<string>;
103
168
 
104
- /** Raw plugin desc from flags, prompts, etc. Can include constraints. */
105
- rawPlugins: Array<string>;
106
-
107
- /** Short names of plugins */
108
- plugins: Array<string>;
109
-
110
169
  /** Local packages that should be linked */
111
170
  pkgLinks: Array<string>;
112
171
 
@@ -125,6 +184,12 @@ export interface CreateContext {
125
184
  /** any generated files to show in report */
126
185
  generatedFiles: Set<string>;
127
186
 
187
+ /** Default empty array, populated by load-preset with actual imports */
188
+ presets: Array<Plugin>;
189
+
190
+ /** Default to object w/empty plugins array to be populated by `presetConfig` hook */
191
+ presetConfig: GasketConfigDefinition;
192
+
128
193
  // Added by `global-prompts`
129
194
 
130
195
  /** Description of app */
@@ -133,8 +198,8 @@ export interface CreateContext {
133
198
  /** Should a git repo be initialized and first commit */
134
199
  gitInit: boolean;
135
200
 
136
- /** Name of the plugin for unit tests */
137
- testPlugin: string;
201
+ /** Names of the plugins that add unit and integration tests */
202
+ testPlugins: Array<string>;
138
203
 
139
204
  /** Which package manager to use (Default: 'npm') */
140
205
  packageManager: string;
@@ -148,23 +213,6 @@ export interface CreateContext {
148
213
  /** Whether or not the user wants to override an extant directory */
149
214
  destOverride: boolean;
150
215
 
151
- // Added by `load-preset`
152
-
153
- /** Short name of presets */
154
- presets: Array<string>;
155
-
156
- /** Shallow load of presets with meta data */
157
- presetInfos: Array<PresetInfo>;
158
-
159
- // Added by `cli-version`
160
-
161
- /** Version of current CLI used to issue `create` command */
162
- cliVersion: string;
163
-
164
- /** Version of CLI to install, either current or min compatible version
165
- * required by preset(s) */
166
- cliVersionRequired: string;
167
-
168
216
  // Added by `setup-pkg`
169
217
 
170
218
  /** package.json builder */
@@ -184,13 +232,23 @@ export interface CreateContext {
184
232
  files: Files;
185
233
  }
186
234
 
187
- declare module '@gasket/engine' {
235
+ export interface ActionWrapperParams {
236
+ gasket: GasketEngine;
237
+ context: CreateContext;
238
+ spinner?: any;
239
+ }
240
+
241
+ declare module '@gasket/core' {
188
242
  export interface HookExecTypes {
243
+ presetPrompt(context: CreateContext): Promise<void>;
244
+ presetConfig(context: CreateContext): Promise<CreateContext['presetConfig']>;
189
245
  prompt(
190
246
  context: CreateContext,
191
247
  utils: {
192
- prompt: (prompts: Array<Record<string, any>>) => Promise<Record<string, any>>,
193
- addPlugins: (plugins: Array<string>) => Promise<void>
248
+ prompt: (
249
+ prompts: Array<Record<string, any>>
250
+ ) => Promise<Record<string, any>>;
251
+ addPlugins: (plugins: Array<string>) => Promise<void>;
194
252
  }
195
253
  ): MaybeAsync<CreateContext>;
196
254
 
@@ -199,7 +257,8 @@ declare module '@gasket/engine' {
199
257
  postCreate(
200
258
  context: CreateContext,
201
259
  utils: {
202
- runScript: (script: string) => Promise<void>
203
- }): MaybeAsync<void>;
260
+ runScript: (script: string) => Promise<void>;
261
+ }
262
+ ): MaybeAsync<void>;
204
263
  }
205
264
  }
package/lib/index.js CHANGED
@@ -2,7 +2,8 @@
2
2
  import { Command } from 'commander';
3
3
  import { createRequire } from 'module';
4
4
  import { createCommand } from './commands/create.js';
5
- import { processCommand, logo, warnIfOutdated } from './utils/index.js';
5
+ import { processCommand, logo } from './utils/index.js';
6
+ import { warnIfOutdated } from '@gasket/utils';
6
7
 
7
8
  const require = createRequire(import.meta.url);
8
9
  const pkg = require('../package.json');
@@ -19,7 +20,7 @@ const gasketBin = program
19
20
 
20
21
  async function main() {
21
22
  const { command, hidden, isDefault } = processCommand(createCommand);
22
- // await warnIfOutdated(pkg.name, pkg.version);
23
+ await warnIfOutdated(pkg.name, pkg.version);
23
24
  gasketBin.addCommand(command, { hidden, isDefault });
24
25
 
25
26
  process.argv.splice(2, 0, 'create');