create-gasket-app 7.0.0-next.2 → 7.0.0-next.21

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 (41) hide show
  1. package/lib/commands/create.js +40 -85
  2. package/lib/config/default-plugins.js +6 -6
  3. package/lib/index.d.ts +81 -25
  4. package/lib/index.js +7 -6
  5. package/lib/main.js +5 -4
  6. package/lib/scaffold/action-wrapper.js +8 -7
  7. package/lib/scaffold/actions/create-hooks.js +8 -9
  8. package/lib/scaffold/actions/generate-files.js +17 -15
  9. package/lib/scaffold/actions/global-prompts.js +11 -26
  10. package/lib/scaffold/actions/index.js +18 -21
  11. package/lib/scaffold/actions/install-modules.js +3 -6
  12. package/lib/scaffold/actions/link-modules.js +3 -5
  13. package/lib/scaffold/actions/load-preset.js +50 -72
  14. package/lib/scaffold/actions/mkdir.js +4 -4
  15. package/lib/scaffold/actions/post-create-hooks.js +6 -8
  16. package/lib/scaffold/actions/preset-config-hooks.js +13 -0
  17. package/lib/scaffold/actions/preset-prompt-hooks.js +17 -0
  18. package/lib/scaffold/actions/print-report.js +8 -7
  19. package/lib/scaffold/actions/prompt-hooks.js +10 -57
  20. package/lib/scaffold/actions/setup-pkg.js +17 -29
  21. package/lib/scaffold/actions/write-gasket-config.js +102 -17
  22. package/lib/scaffold/actions/write-pkg.js +5 -9
  23. package/lib/scaffold/config-builder.js +82 -7
  24. package/lib/scaffold/create-context.js +15 -21
  25. package/lib/scaffold/dump-error-context.js +5 -5
  26. package/lib/scaffold/files.js +2 -2
  27. package/lib/scaffold/utils.js +4 -97
  28. package/lib/utils/create-option.js +2 -4
  29. package/lib/utils/index.js +6 -16
  30. package/lib/utils/logo.js +1 -3
  31. package/lib/utils/process-args.js +1 -3
  32. package/lib/utils/process-command.js +3 -7
  33. package/lib/utils/process-options.js +1 -3
  34. package/lib/utils/warn-if-outdated.js +11 -9
  35. package/package.json +14 -12
  36. package/lib/scaffold/actions/apply-preset-config.js +0 -29
  37. package/lib/scaffold/actions/cli-version.js +0 -84
  38. package/lib/scaffold/actions/load-pkg-for-debug.js +0 -24
  39. package/lib/scaffold/create-engine.js +0 -21
  40. package/lib/scaffold/fetcher.js +0 -194
  41. package/lib/utils/setup.js +0 -25
@@ -1,26 +1,27 @@
1
- /* eslint-disable max-statements */
2
- const ora = require('ora');
3
- const chalk = require('chalk');
4
- const makeCreateContext = require('../scaffold/create-context');
5
- const dumpErrorContext = require('../scaffold/dump-error-context');
6
- const {
7
- applyPresetConfig,
8
- cliVersion,
1
+ /* eslint-disable max-statements, no-unused-vars */
2
+ import chalk from 'chalk';
3
+ import { makeCreateContext } from '../scaffold/create-context.js';
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';
8
+ import {
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,
18
+ presetPromptHooks,
19
+ presetConfigHooks,
19
20
  promptHooks,
20
21
  setupPkg,
21
22
  writeGasketConfig,
22
23
  writePkg
23
- } = require('../scaffold/actions');
24
+ } from '../scaffold/actions/index.js';
24
25
 
25
26
  /**
26
27
  * Parses comma separated option input to array
@@ -49,13 +50,6 @@ const createCommand = {
49
50
  Or other (multiple) custom presets (e.g. --presets my-gasket-preset@1.0.0.beta-1,nextjs@^1.0.0)`,
50
51
  parse: commasToArray
51
52
  },
52
- {
53
- name: 'plugins',
54
- description: `Additional plugin(s) to install. Can be set as
55
- multiple flags (e.g. --plugins jest --plugins zkconfig@^1.0.0)
56
- comma-separated values: --plugins=jest,zkconfig^1.0.0`,
57
- parse: commasToArray
58
- },
59
53
  {
60
54
  name: 'package-manager',
61
55
  description: `Selects which package manager you would like to use during
@@ -67,18 +61,6 @@ const createCommand = {
67
61
  description: 'Require module(s) before Gasket is initialized',
68
62
  parse: commasToArray
69
63
  },
70
- {
71
- name: 'no-bootstrap',
72
- description: '(INTERNAL) If provided, skip the bootstrap phase',
73
- type: 'boolean',
74
- hidden: true
75
- },
76
- {
77
- name: 'no-generate',
78
- description: '(INTERNAL) If provided, skip the generate phase',
79
- type: 'boolean',
80
- hidden: true
81
- },
82
64
  {
83
65
  name: 'npm-link',
84
66
  description: `(INTERNAL) Local packages to be linked. Can be set as
@@ -105,46 +87,14 @@ const createCommand = {
105
87
  conflicts: ['config']
106
88
  },
107
89
  {
108
- name: 'prompts',
90
+ name: 'no-prompts',
109
91
  description: '(INTERNAL) Disable to skip the prompts',
110
- default: true,
111
92
  type: 'boolean',
112
93
  hidden: true
113
94
  }
114
95
  ]
115
96
  };
116
97
 
117
- /**
118
- * bootstrap - Bootstrap the application
119
- * @param {CreateContext} context - Create context
120
- */
121
- async function bootstrapHandler(context) {
122
- await loadPreset(context);
123
- cliVersion(context);
124
- applyPresetConfig(context);
125
- await globalPrompts(context);
126
- await mkDir(context);
127
- await setupPkg(context);
128
- await writePkg(context);
129
- await installModules(context);
130
- await linkModules(context);
131
- }
132
-
133
- /**
134
- * generate - Generate the application
135
- * @param {CreateContext} context - Create context
136
- */
137
- async function generateHandler(context) {
138
- await promptHooks(context);
139
- await createHooks(context);
140
- await generateFiles(context);
141
- await writeGasketConfig(context);
142
- await writePkg.update(context);
143
- await installModules.update(context);
144
- await linkModules.update(context); // relink any that were messed up by re-install
145
- await postCreateHooks(context);
146
- }
147
-
148
98
  /**
149
99
  * createCommand action
150
100
  * @param {string} appname Required cmd arg - name of the app to create
@@ -153,35 +103,40 @@ async function generateHandler(context) {
153
103
  * @returns {Promise<void>} void
154
104
  */
155
105
  createCommand.action = async function run(appname, options, command) {
156
- const argv = [appname];
157
- const { bootstrap = true, generate = true } = options;
106
+ const context = makeCreateContext([appname], options);
107
+ const { rawPresets, localPresets } = context;
158
108
 
159
- let context;
160
109
  try {
161
- context = makeCreateContext(argv, options);
162
- } catch (error) {
163
- console.error(chalk.red(error) + '\n');
164
- command.help();
165
- }
110
+ await globalPrompts({ context });
166
111
 
167
- try {
168
- if (bootstrap) {
169
- await bootstrapHandler(context);
170
- } else {
171
- ora('Bootstrap phase skipped.').warn();
172
- if (generate) {
173
- await loadPkgForDebug(context);
174
- }
175
- }
112
+ if (rawPresets.length || localPresets.length) {
113
+ await loadPreset({ context });
114
+
115
+ const presetGasket = makeGasket({
116
+ plugins: context.presets
117
+ });
176
118
 
177
- if (generate) {
178
- await generateHandler(context);
179
- } else {
180
- ora('Generate phase skipped.').warn();
119
+ await presetPromptHooks({ gasket: presetGasket, context });
120
+ await presetConfigHooks({ gasket: presetGasket, context });
181
121
  }
182
122
 
183
- printReport(context);
123
+ const pluginGasket = makeGasket({
124
+ ...context.presetConfig,
125
+ plugins: context.presets.concat(context.presetConfig.plugins, defaultPlugins)
126
+ });
184
127
 
128
+ await promptHooks({ gasket: pluginGasket, context });
129
+ await mkDir({ context });
130
+ await setupPkg({ context });
131
+ await createHooks({ gasket: pluginGasket, context });
132
+ await writePkg({ context });
133
+ await generateFiles({ context });
134
+ await writeGasketConfig({ context });
135
+ await installModules({ context });
136
+ await linkModules({ context });
137
+ await postCreateHooks({ gasket: pluginGasket, context });
138
+ if (context.tmpDir) await rm(context.tmpDir, { recursive: true });
139
+ printReport({ context });
185
140
  } catch (err) {
186
141
  console.error(chalk.red('Exiting with errors.'));
187
142
  dumpErrorContext(context, err);
@@ -189,4 +144,4 @@ createCommand.action = async function run(appname, options, command) {
189
144
  }
190
145
  };
191
146
 
192
- module.exports = createCommand;
147
+ export { createCommand };
@@ -1,7 +1,7 @@
1
- module.exports = [
2
- require('@gasket/plugin-lifecycle'),
3
- require('@gasket/plugin-metadata'),
4
- require('@gasket/plugin-start'),
5
- require('@gasket/plugin-git'),
6
- require('@gasket/plugin-logger')
1
+ import pluginGit from '@gasket/plugin-git';
2
+ import pluginLogger from '@gasket/plugin-logger';
3
+
4
+ export const defaultPlugins = [
5
+ pluginLogger,
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/engine';
2
2
  import type { PackageManager } from '@gasket/utils';
3
3
 
4
4
  export interface Dependencies {
@@ -62,6 +62,72 @@ export interface ConfigBuilder<Config> {
62
62
  value: Config[Key],
63
63
  options?: { force?: boolean }
64
64
  ): void;
65
+
66
+ /**
67
+ * addPlugin - Add plugin import to the gasket file and use the value in the plugins array
68
+ * @param {string} pluginImport - name of the import used as a value - `import pluginImport...`
69
+ * @param {string} pluginName - name of the plugin import/package - `from 'pluginName'`
70
+ * @example
71
+ * addPlugin('pluginA', '@gasket/plugin-a')
72
+ *
73
+ * // gasket.js
74
+ * import pluginA from '@gasket/plugin-a';
75
+ *
76
+ * export default makeGasket({
77
+ * plugins: [
78
+ * pluginA
79
+ * ]
80
+ * });
81
+ */
82
+ addPlugin(pluginImport: string, pluginName: string): void;
83
+
84
+ /**
85
+ * addImport - Add a non-plugin import to the gasket file
86
+ * @param {string} importName - name of the import used as a value - `import fs...`
87
+ * @param {string} importPath - path of the import - `from 'fs'`
88
+ * @returns {ConfigBuilder} - instance for chaining
89
+ * @example
90
+ * Can be default or named import
91
+ * addImport('{ readFileSync }', 'fs')
92
+ * addImport('fs', 'fs')
93
+ *
94
+ * // gasket.js
95
+ * import { readFileSync } from 'fs';
96
+ * import fs from 'fs';
97
+ */
98
+ addImport(importName: string, importPath: string): ConfigBuilder<Config>;
99
+
100
+ /**
101
+ * addExpression - add programmatic expression to the gasket file
102
+ * @param {string} expression - expression to add after imports
103
+ * @returns {ConfigBuilder} - instance for chaining
104
+ * @example
105
+ *
106
+ * .addImport('fs', 'fs')
107
+ * .addExpression('const file = fs.readFileSync(\'./file.txt\')')
108
+ *
109
+ * // gasket.js
110
+ * import fs from 'fs';
111
+ * const file = fs.readFileSync('./file.txt');
112
+ */
113
+ addExpression(expression: string): ConfigBuilder<Config>;
114
+
115
+ /**
116
+ * injectValue - Inject a value into the gasket config object
117
+ * @param {string} configKey - collapsed object path to inject value into - `express.config.routes`
118
+ * @param {string} injectedValue - string used as a value
119
+ * @example
120
+ * .addImport('{ routes }', './routes')
121
+ * .injectValue('express.routes', 'routes');
122
+ *
123
+ * // gasket.js
124
+ * export default makeGasket({
125
+ * express: {
126
+ * routes: routes
127
+ * }
128
+ * });
129
+ */
130
+ injectValue(configKey: string, injectedValue: string): void;
65
131
  }
66
132
 
67
133
  export interface PackageJsonBuilder extends ConfigBuilder<PackageJson> {
@@ -101,12 +167,6 @@ export interface CreateContext {
101
167
  * load-preset if using localPresets. */
102
168
  rawPresets: Array<string>;
103
169
 
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
170
  /** Local packages that should be linked */
111
171
  pkgLinks: Array<string>;
112
172
 
@@ -125,6 +185,12 @@ export interface CreateContext {
125
185
  /** any generated files to show in report */
126
186
  generatedFiles: Set<string>;
127
187
 
188
+ /** Default empty array, populated by load-preset with actual imports */
189
+ presets: Array<Plugin>;
190
+
191
+ /** Default to object w/empty plugins array to be populated by `presetConfig` hook */
192
+ presetConfig: GasketConfigDefinition;
193
+
128
194
  // Added by `global-prompts`
129
195
 
130
196
  /** Description of app */
@@ -148,23 +214,6 @@ export interface CreateContext {
148
214
  /** Whether or not the user wants to override an extant directory */
149
215
  destOverride: boolean;
150
216
 
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
217
  // Added by `setup-pkg`
169
218
 
170
219
  /** package.json builder */
@@ -184,13 +233,20 @@ export interface CreateContext {
184
233
  files: Files;
185
234
  }
186
235
 
236
+ export interface ActionWrapperParams {
237
+ gasket: GasketEngine;
238
+ context: CreateContext;
239
+ spinner?: any;
240
+ }
241
+
187
242
  declare module '@gasket/engine' {
188
243
  export interface HookExecTypes {
244
+ presetPrompt(context: CreateContext): Promise<void>;
245
+ presetConfig(context: CreateContext): Promise<CreateContext['presetConfig']>;
189
246
  prompt(
190
247
  context: CreateContext,
191
248
  utils: {
192
249
  prompt: (prompts: Array<Record<string, any>>) => Promise<Record<string, any>>,
193
- addPlugins: (plugins: Array<string>) => Promise<void>
194
250
  }
195
251
  ): MaybeAsync<CreateContext>;
196
252
 
package/lib/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
- require('./utils/setup');
2
+ import { Command } from 'commander';
3
+ import { createRequire } from 'module';
4
+ import { createCommand } from './commands/create.js';
5
+ import { processCommand, logo, warnIfOutdated } from './utils/index.js';
6
+
7
+ const require = createRequire(import.meta.url);
3
8
  const pkg = require('../package.json');
4
- const { Command } = require('commander');
5
9
  const program = new Command();
6
- const CreateCommand = require('./commands/create');
7
-
8
- const { processCommand, logo, warnIfOutdated } = require('./utils');
9
10
 
10
11
  // Create Gasket CLI
11
12
  const gasketBin = program
@@ -17,7 +18,7 @@ const gasketBin = program
17
18
 
18
19
 
19
20
  async function main() {
20
- const { command, hidden, isDefault } = processCommand(CreateCommand);
21
+ const { command, hidden, isDefault } = processCommand(createCommand);
21
22
  await warnIfOutdated(pkg.name, pkg.version);
22
23
  gasketBin.addCommand(command, { hidden, isDefault });
23
24
 
package/lib/main.js CHANGED
@@ -1,4 +1,6 @@
1
- const { fork } = require('child_process');
1
+ import { fork } from 'child_process';
2
+ import { createRequire } from 'module';
3
+ const require = createRequire(import.meta.url);
2
4
 
3
5
  /**
4
6
  * Executes the @gasket/cli passing through the create command and any arguments.
@@ -6,7 +8,8 @@ const { fork } = require('child_process');
6
8
  * @param {string[]} args - create command arguments
7
9
  * @returns {ChildProcess} process
8
10
  */
9
- function main(...args) {
11
+ export default function main(...args) {
12
+ // import.meta.resolve is not available in Jest without babel transform
10
13
  const gasketBin = require.resolve('@gasket/cli/bin/run');
11
14
 
12
15
  return fork(
@@ -15,5 +18,3 @@ function main(...args) {
15
18
  { stdio: 'inherit', stdin: 'inherit', stderr: 'inherit' }
16
19
  );
17
20
  }
18
-
19
- module.exports = main;
@@ -1,4 +1,4 @@
1
- const ora = require('ora');
1
+ import ora from 'ora';
2
2
 
3
3
  /**
4
4
  * Decorate a create action with spinner.
@@ -10,19 +10,20 @@ const ora = require('ora');
10
10
  * @param {Boolean} startSpinner - Should the spinner start
11
11
  * @returns {Function} decorated action
12
12
  */
13
- module.exports = function withSpinner(label, fn, { startSpinner = true } = {}) {
14
-
13
+ export default function withSpinner(label, fn, { startSpinner = true } = {}) {
15
14
  /**
16
15
  * Decorated function
17
16
  *
18
- * @param {CreateContext} context - Create context
17
+ * @param {ActionWrapperParams} params - ActionWrapperParams
18
+ * @param {GasketEngine} params.gasket - Gasket config
19
+ * @param {CreateContext} params.context - Create context
19
20
  * @returns {Promise} promise
20
21
  */
21
- async function wrapper(context) {
22
+ async function wrapper({ gasket = {}, context }) {
22
23
  const spinner = ora(label);
23
24
  if (startSpinner) spinner.start();
24
25
  try {
25
- await fn(context, spinner);
26
+ await fn({ gasket, context, spinner });
26
27
  if (spinner.isSpinning) spinner.succeed();
27
28
  } catch (err) {
28
29
  spinner.fail();
@@ -33,4 +34,4 @@ module.exports = function withSpinner(label, fn, { startSpinner = true } = {}) {
33
34
 
34
35
  wrapper.wrapped = fn;
35
36
  return wrapper;
36
- };
37
+ }
@@ -1,26 +1,25 @@
1
- const createEngine = require('../create-engine');
2
- const action = require('../action-wrapper');
3
- const ConfigBuilder = require('../config-builder');
4
- const Files = require('../files');
1
+ import action from '../action-wrapper.js';
2
+ import { ConfigBuilder } from '../config-builder.js';
3
+ import { Files } from '../files.js';
5
4
 
6
5
  /**
7
6
  * Executes the `create` hook for all registered plugins.
8
7
  * Adds `files` to context for plugins to add their files and templates.
9
8
  *
9
+ * @param {GasketEngine} gasket - Gasket API
10
10
  * @param {CreateContext} context - Create context
11
11
  * @returns {Promise} promise
12
12
  */
13
- async function createHooks(context) {
14
- const { dest, presets = [], plugins = [], warnings } = context;
13
+ async function createHooks({ gasket, context }) {
14
+ const { plugins = [], warnings } = context;
15
15
 
16
16
  const files = new Files();
17
- const gasketConfig = ConfigBuilder.create({}, { orderBy: ['plugins'], warnings });
17
+ const gasketConfig = ConfigBuilder.create({}, { orderBy: ['plugins'], warnings, plugins });
18
18
  Object.assign(context, { files, gasketConfig });
19
19
 
20
- const gasket = await createEngine({ dest, presets, plugins });
21
20
  await gasket.execApply('create', async function applyCreate(plugin, handler) {
22
21
  await handler(context.runWith(plugin));
23
22
  });
24
23
  }
25
24
 
26
- module.exports = action('Execute create hooks', createHooks);
25
+ export default action('Execute create hooks', createHooks);
@@ -1,14 +1,16 @@
1
- /* eslint-disable max-statements */
2
- const debug = require('diagnostics')('gasket:create-gasket-app:generate-files');
3
- const fs = require('fs').promises;
4
- const { promisify } = require('util');
5
- const Handlebars = require('handlebars');
6
- const path = require('path');
7
- const mkdirp = require('mkdirp');
8
- const { dim } = require('chalk');
9
- const action = require('../action-wrapper');
10
-
11
- const glob = promisify(require('glob'));
1
+ import { default as diagnostics } from 'diagnostics';
2
+ const debug = diagnostics('gasket:cli:generate-files');
3
+ import fs from 'fs/promises';
4
+ import { promisify } from 'util';
5
+ import Handlebars from 'handlebars';
6
+ import path from 'path';
7
+ import mkdirp from 'mkdirp';
8
+ import chalk from 'chalk';
9
+ const { dim } = chalk;
10
+ import action from '../action-wrapper.js';
11
+ import * as syncGlob from 'glob';
12
+ const glob = promisify(syncGlob.default);
13
+
12
14
  const flatten = (acc, values) => (acc || []).concat(values);
13
15
  const reSep = /[/\\]+/;
14
16
  const joinSep = pthArr => pthArr.join(path.sep);
@@ -162,7 +164,7 @@ async function performGenerate(context, descriptors) {
162
164
  * @param {Spinner} spinner - Spinner
163
165
  * @returns {Promise} promise
164
166
  */
165
- async function generateFiles(context, spinner) {
167
+ async function generateFiles({ context, spinner }) {
166
168
  const { files } = context;
167
169
 
168
170
  if (!files.globSets.length) {
@@ -177,7 +179,7 @@ async function generateFiles(context, spinner) {
177
179
  if (hasError) spinner.fail();
178
180
  }
179
181
 
180
- module.exports = action('Generate app contents', generateFiles);
182
+ export default action('Generate app contents', generateFiles);
181
183
  // exported for unit testing
182
- module.exports._getDescriptors = getDescriptors;
183
- module.exports._assembleDescriptors = assembleDescriptors;
184
+ export const _getDescriptors = getDescriptors;
185
+ export const _assembleDescriptors = assembleDescriptors;
@@ -1,7 +1,5 @@
1
- const inquirer = require('inquirer');
2
- const { pluginIdentifier, flattenPresets } = require('@gasket/resolve');
3
- const action = require('../action-wrapper');
4
- const { addPluginsToContext } = require('../utils');
1
+ import inquirer from 'inquirer';
2
+ import action from '../action-wrapper.js';
5
3
 
6
4
  /**
7
5
  * What is your app description?
@@ -70,22 +68,12 @@ async function choosePackageManager(context, prompt) {
70
68
  * @returns {Promise} promise
71
69
  */
72
70
  async function chooseTestPlugin(context, prompt) {
73
- // Combine user-provided plugins with preset-provided plugins.
74
- const { presetInfos = [], plugins = [] } = context;
75
-
76
- // Flatten all plugins from presets and concat short names with cli plugins
77
- const allPlugins = flattenPresets(presetInfos)
78
- .map((presetInfo) => presetInfo.plugins || [])
79
- .reduce((acc, arr) => acc.concat(arr), [])
80
- .map((pluginInfo) => pluginIdentifier(pluginInfo.name).shortName)
81
- .concat(plugins);
82
-
83
- const knownTestPlugins = { mocha: '@gasket/mocha', jest: '@gasket/jest', cypress: '@gasket/cypress' };
71
+ const knownTestPlugins = { mocha: '@gasket/plugin-mocha', jest: '@gasket/plugin-jest', cypress: '@gasket/plugin-cypress' };
84
72
 
85
73
  if (!('testPlugin' in context)) {
86
- let testPlugin = Object.values(knownTestPlugins).find((p) => allPlugins.includes(p));
74
+ let testPlugin;
87
75
 
88
- if ('testSuite' in context) {
76
+ if ('testSuite' in context) {
89
77
  testPlugin = knownTestPlugins[context.testSuite];
90
78
  }
91
79
 
@@ -97,16 +85,15 @@ async function chooseTestPlugin(context, prompt) {
97
85
  type: 'list',
98
86
  choices: [
99
87
  { name: 'none (not recommended)', value: 'none' },
100
- { name: 'mocha + nyc + sinon + chai', value: '@gasket/mocha' },
101
- { name: 'jest', value: '@gasket/jest' },
102
- { name: 'cypress', value: '@gasket/cypress' }
88
+ { name: 'mocha + nyc + sinon + chai', value: '@gasket/plugin-mocha' },
89
+ { name: 'jest', value: '@gasket/plugin-jest' },
90
+ { name: 'cypress', value: '@gasket/plugin-cypress' }
103
91
  ]
104
92
  }
105
93
  ]));
106
94
  }
107
95
 
108
96
  if (testPlugin && testPlugin !== 'none') {
109
- addPluginsToContext([testPlugin], context);
110
97
  Object.assign(context, { testPlugin });
111
98
  }
112
99
  }
@@ -136,7 +123,7 @@ async function allowExtantOverwriting(context, prompt) {
136
123
  }
137
124
  }
138
125
 
139
- const questions = [
126
+ export const questions = [
140
127
  chooseAppDescription,
141
128
  choosePackageManager,
142
129
  chooseTestPlugin,
@@ -149,13 +136,11 @@ const questions = [
149
136
  * @param {CreateContext} context - Create context
150
137
  * @returns {Promise} promise
151
138
  */
152
- async function globalPrompts(context) {
139
+ async function globalPrompts({ context }) {
153
140
  const prompt = context.prompts ? inquirer.prompt : () => ({});
154
141
  for (var fn of questions) {
155
142
  await fn(context, prompt);
156
143
  }
157
144
  }
158
145
 
159
- module.exports = action('Global prompts', globalPrompts, { startSpinner: false });
160
-
161
- module.exports.questions = questions;
146
+ export default action('Global prompts', globalPrompts, { startSpinner: false });
@@ -1,36 +1,33 @@
1
+ import mkDir from './mkdir.js';
2
+ import loadPreset from './load-preset.js';
3
+ import globalPrompts from './global-prompts.js';
4
+ import setupPkg from './setup-pkg.js';
5
+ import writePkg from './write-pkg.js';
6
+ import installModules from './install-modules.js';
7
+ import linkModules from './link-modules.js';
8
+ import writeGasketConfig from './write-gasket-config.js';
9
+ import presetPromptHooks from './preset-prompt-hooks.js';
10
+ import presetConfigHooks from './preset-config-hooks.js';
11
+ import promptHooks from './prompt-hooks.js';
12
+ import createHooks from './create-hooks.js';
13
+ import generateFiles from './generate-files.js';
14
+ import postCreateHooks from './post-create-hooks.js';
15
+ import printReport from './print-report.js';
1
16
 
2
- const mkDir = require('./mkdir');
3
- const loadPreset = require('./load-preset');
4
- const cliVersion = require('./cli-version');
5
- const globalPrompts = require('./global-prompts');
6
- const setupPkg = require('./setup-pkg');
7
- const writePkg = require('./write-pkg');
8
- const installModules = require('./install-modules');
9
- const linkModules = require('./link-modules');
10
- const writeGasketConfig = require('./write-gasket-config');
11
- const loadPkgForDebug = require('./load-pkg-for-debug');
12
- const promptHooks = require('./prompt-hooks');
13
- const createHooks = require('./create-hooks');
14
- const generateFiles = require('./generate-files');
15
- const postCreateHooks = require('./post-create-hooks');
16
- const applyPresetConfig = require('./apply-preset-config');
17
- const printReport = require('./print-report');
18
-
19
- module.exports = {
17
+ export {
20
18
  mkDir,
21
19
  loadPreset,
22
- cliVersion,
23
20
  globalPrompts,
24
21
  setupPkg,
25
22
  writePkg,
26
23
  installModules,
27
24
  linkModules,
28
25
  writeGasketConfig,
29
- loadPkgForDebug,
26
+ presetPromptHooks,
27
+ presetConfigHooks,
30
28
  promptHooks,
31
29
  createHooks,
32
30
  postCreateHooks,
33
31
  generateFiles,
34
- applyPresetConfig,
35
32
  printReport
36
33
  };