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

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 +36 -91
  2. package/lib/config/default-plugins.js +6 -6
  3. package/lib/config/utils.js +59 -0
  4. package/lib/index.d.ts +6 -0
  5. package/lib/index.js +8 -7
  6. package/lib/scaffold/action-wrapper.js +4 -5
  7. package/lib/scaffold/actions/apply-preset-config.js +3 -3
  8. package/lib/scaffold/actions/cli-version.js +9 -5
  9. package/lib/scaffold/actions/create-hooks.js +7 -8
  10. package/lib/scaffold/actions/generate-files.js +17 -15
  11. package/lib/scaffold/actions/global-prompts.js +20 -20
  12. package/lib/scaffold/actions/index.js +24 -18
  13. package/lib/scaffold/actions/install-modules.js +4 -4
  14. package/lib/scaffold/actions/link-modules.js +4 -4
  15. package/lib/scaffold/actions/load-pkg-for-debug.js +5 -5
  16. package/lib/scaffold/actions/load-preset.js +31 -77
  17. package/lib/scaffold/actions/mkdir.js +4 -4
  18. package/lib/scaffold/actions/post-create-hooks.js +5 -7
  19. package/lib/scaffold/actions/preset-config-hooks.js +13 -0
  20. package/lib/scaffold/actions/preset-prompt-hooks.js +13 -0
  21. package/lib/scaffold/actions/print-report.js +8 -7
  22. package/lib/scaffold/actions/prompt-hooks.js +9 -13
  23. package/lib/scaffold/actions/setup-pkg.js +23 -25
  24. package/lib/scaffold/actions/write-gasket-config.js +71 -17
  25. package/lib/scaffold/actions/write-pkg.js +6 -7
  26. package/lib/scaffold/config-builder.js +26 -7
  27. package/lib/scaffold/create-context.js +9 -12
  28. package/lib/scaffold/create-engine.js +5 -5
  29. package/lib/scaffold/dump-error-context.js +3 -3
  30. package/lib/scaffold/fetcher.js +19 -19
  31. package/lib/scaffold/files.js +1 -1
  32. package/lib/scaffold/utils.js +8 -16
  33. package/lib/utils/create-option.js +2 -4
  34. package/lib/utils/index.js +6 -16
  35. package/lib/utils/logo.js +1 -3
  36. package/lib/utils/process-args.js +1 -3
  37. package/lib/utils/process-command.js +3 -7
  38. package/lib/utils/process-options.js +1 -3
  39. package/lib/utils/warn-if-outdated.js +8 -8
  40. package/package.json +11 -10
  41. package/lib/utils/setup.js +0 -25
@@ -1,26 +1,27 @@
1
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,
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
@@ -114,79 +96,42 @@ const createCommand = {
114
96
  ]
115
97
  };
116
98
 
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
- /**
149
- * createCommand action
150
- * @param {string} appname Required cmd arg - name of the app to create
151
- * @param {object} options cmd options
152
- * @param {Command} command - the command instance
153
- * @returns {Promise<void>} void
154
- */
155
99
  createCommand.action = async function run(appname, options, command) {
156
- const argv = [appname];
157
- const { bootstrap = true, generate = true } = options;
100
+ const context = makeCreateContext([appname], options);
158
101
 
159
- let context;
160
102
  try {
161
- context = makeCreateContext(argv, options);
162
- } catch (error) {
163
- console.error(chalk.red(error) + '\n');
164
- command.help();
165
- }
103
+ await loadPreset(null, context);
104
+ await globalPrompts(null, context);
166
105
 
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
- }
106
+ const presetGasket = makeGasket({
107
+ plugins: context.presets
108
+ });
176
109
 
177
- if (generate) {
178
- await generateHandler(context);
179
- } else {
180
- ora('Generate phase skipped.').warn();
181
- }
110
+ await presetPromptHooks(presetGasket, context);
111
+ await presetConfigHooks(presetGasket, context);
182
112
 
183
- printReport(context);
113
+ const pluginGasket = makeGasket({
114
+ ...context.presetConfig,
115
+ plugins: context.presets.concat(context.presetConfig.plugins, defaultPlugins)
116
+ });
184
117
 
118
+ await promptHooks(pluginGasket, context);
119
+ await mkDir(null, context);
120
+ await setupPkg(null, context);
121
+ await createHooks(pluginGasket, context);
122
+ await writePkg(null, context);
123
+ await generateFiles(null, context);
124
+ await writeGasketConfig(null, context);
125
+ await installModules(null, context);
126
+ await linkModules(null, context);
127
+ await postCreateHooks(pluginGasket, context);
128
+ await rm(context.tmpDir, { recursive: true });
129
+ printReport(context);
185
130
  } catch (err) {
186
131
  console.error(chalk.red('Exiting with errors.'));
187
132
  dumpErrorContext(context, err);
188
133
  throw err;
189
134
  }
190
- };
135
+ }
191
136
 
192
- module.exports = createCommand;
137
+ 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
  ];
@@ -0,0 +1,59 @@
1
+ import { default as diagnostics } from 'diagnostics';
2
+ import { pluginIdentifier } from '@gasket/resolve';
3
+ import { defaultPlugins } from './default-plugins.js';
4
+ const debug = diagnostics('gasket:cli:config:utils');
5
+
6
+ /**
7
+ * Returns specified env option if set or appropriate fallback
8
+ *
9
+ * @param {Object} options - CLI Option
10
+ * @param {string} commandId - Name of the command
11
+ * @param {function} warn - Warning logger
12
+ * @returns {string} environment
13
+ */
14
+ export function getEnvironment(options, commandId, warn) {
15
+ if (options.env) {
16
+ debug('Environment was passed through command line options', options.env);
17
+ return options.env;
18
+ }
19
+
20
+ // special snowflake case to match up `local` env with command unless set
21
+ if (commandId === 'local') {
22
+ debug('Environment defaulting to `local` due to `local` command');
23
+ return 'local';
24
+ }
25
+
26
+ const { NODE_ENV } = process.env;
27
+ if (NODE_ENV) {
28
+ warn(`No env specified, falling back to NODE_ENV: "${ NODE_ENV }".`);
29
+ return NODE_ENV;
30
+ }
31
+
32
+ warn('No env specified, falling back to "development".');
33
+ return 'development';
34
+ }
35
+
36
+ /**
37
+ * Inject the default plugins into the loaded config
38
+ *
39
+ * @param {Object} gasketConfig - Gasket config
40
+ * @returns {Object} updated config
41
+ */
42
+ export function addDefaultPlugins(gasketConfig) {
43
+ const pluginsConfig = gasketConfig.plugins || {};
44
+ const { add = [], remove = [] } = pluginsConfig;
45
+ const filteredNames = new Set(
46
+ add.concat(remove).map(p => {
47
+ const name = typeof p === 'string' ? p : p.name;
48
+ return pluginIdentifier(name).fullName;
49
+ })
50
+ );
51
+ const pluginsToAdd = defaultPlugins.filter(p => !filteredNames.has(pluginIdentifier(p.name).fullName));
52
+ return {
53
+ ...gasketConfig,
54
+ plugins: {
55
+ ...pluginsConfig,
56
+ add: (add).concat(pluginsToAdd)
57
+ }
58
+ };
59
+ }
package/lib/index.d.ts CHANGED
@@ -62,6 +62,12 @@ export interface ConfigBuilder<Config> {
62
62
  value: Config[Key],
63
63
  options?: { force?: boolean }
64
64
  ): void;
65
+
66
+ // TODO Document
67
+ addPlugin(pluginImport: string, pluginName: string): void;
68
+ addImport(importName: string, importPath: string, isDefault?: boolean): ConfigBuilder;
69
+ useImport(configPath: string, importName: string): void;
70
+
65
71
  }
66
72
 
67
73
  export interface PackageJsonBuilder extends ConfigBuilder<PackageJson> {
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,8 +18,8 @@ const gasketBin = program
17
18
 
18
19
 
19
20
  async function main() {
20
- const { command, hidden, isDefault } = processCommand(CreateCommand);
21
- await warnIfOutdated(pkg.name, pkg.version);
21
+ const { command, hidden, isDefault } = processCommand(createCommand);
22
+ // await warnIfOutdated(pkg.name, pkg.version);
22
23
  gasketBin.addCommand(command, { hidden, isDefault });
23
24
 
24
25
  process.argv.splice(2, 0, 'create');
@@ -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,18 @@ 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
17
  * @param {CreateContext} context - Create context
19
18
  * @returns {Promise} promise
20
19
  */
21
- async function wrapper(context) {
20
+ async function wrapper(gasket = {}, context) {
22
21
  const spinner = ora(label);
23
22
  if (startSpinner) spinner.start();
24
23
  try {
25
- await fn(context, spinner);
24
+ await fn(gasket, context, spinner);
26
25
  if (spinner.isSpinning) spinner.succeed();
27
26
  } catch (err) {
28
27
  spinner.fail();
@@ -1,5 +1,5 @@
1
- const { flattenPresets } = require('@gasket/resolve');
2
- const action = require('../action-wrapper');
1
+ import { flattenPresets } from '@gasket/resolve';
2
+ import action from '../action-wrapper.js';
3
3
 
4
4
  /**
5
5
  * Extracts predefined createContext from presets and applies to context.
@@ -26,4 +26,4 @@ function applyPresetConfig(context) {
26
26
  Object.assign(context, presetContext);
27
27
  }
28
28
 
29
- module.exports = action('Apply preset context', applyPresetConfig, { startSpinner: false });
29
+ export default action('Apply preset context', applyPresetConfig, { startSpinner: false });
@@ -1,7 +1,11 @@
1
- const semver = require('semver');
2
- const { flattenPresets } = require('@gasket/resolve');
3
- const action = require('../action-wrapper');
4
- const pkgVersion = require('../../../package.json').version;
1
+ import semver from 'semver';
2
+ import { flattenPresets } from '@gasket/resolve';
3
+ import action from '../action-wrapper.js';
4
+ import { createRequire } from 'node:module';
5
+ const require = createRequire(import.meta.url);
6
+ const pkg = require('../../../package.json');
7
+
8
+ const pkgVersion = pkg.version;
5
9
  const pkgVersionCompatible = `^${pkgVersion}`;
6
10
 
7
11
  /**
@@ -81,4 +85,4 @@ function resolveCliVersion(context, spinner) {
81
85
  });
82
86
  }
83
87
 
84
- module.exports = action('Resolve CLI versions', resolveCliVersion, { startSpinner: false });
88
+ export default action('Resolve CLI versions', resolveCliVersion, { startSpinner: false });
@@ -1,7 +1,7 @@
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 { createEngine } from '../create-engine.js';
2
+ import action from '../action-wrapper.js';
3
+ import { ConfigBuilder } from '../config-builder.js';
4
+ import { Files } from '../files.js';
5
5
 
6
6
  /**
7
7
  * Executes the `create` hook for all registered plugins.
@@ -10,17 +10,16 @@ const Files = require('../files');
10
10
  * @param {CreateContext} context - Create context
11
11
  * @returns {Promise} promise
12
12
  */
13
- async function createHooks(context) {
13
+ async function createHooks(gasket, context) {
14
14
  const { dest, presets = [], 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(gasket, 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,8 @@
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';
3
+
4
+ import { pluginIdentifier, flattenPresets } from '@gasket/resolve';
5
+ import { addPluginsToContext } from '../utils.js';
5
6
 
6
7
  /**
7
8
  * What is your app description?
@@ -74,16 +75,17 @@ async function chooseTestPlugin(context, prompt) {
74
75
  const { presetInfos = [], plugins = [] } = context;
75
76
 
76
77
  // 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);
78
+ // const allPlugins = flattenPresets(presetInfos)
79
+ // .map((presetInfo) => presetInfo.plugins || [])
80
+ // .reduce((acc, arr) => acc.concat(arr), [])
81
+ // .map((pluginInfo) => pluginIdentifier(pluginInfo.name).shortName)
82
+ // .concat(plugins);
82
83
 
83
- const knownTestPlugins = { mocha: '@gasket/mocha', jest: '@gasket/jest', cypress: '@gasket/cypress' };
84
+ const knownTestPlugins = { mocha: '@gasket/plugin-mocha', jest: '@gasket/plugin-jest', cypress: '@gasket/plugin-cypress' };
84
85
 
85
86
  if (!('testPlugin' in context)) {
86
- let testPlugin = Object.values(knownTestPlugins).find((p) => allPlugins.includes(p));
87
+ // let testPlugin = Object.values(knownTestPlugins).find((p) => allPlugins.includes(p));
88
+ let testPlugin;
87
89
 
88
90
  if ('testSuite' in context) {
89
91
  testPlugin = knownTestPlugins[context.testSuite];
@@ -97,16 +99,16 @@ async function chooseTestPlugin(context, prompt) {
97
99
  type: 'list',
98
100
  choices: [
99
101
  { 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' }
102
+ { name: 'mocha + nyc + sinon + chai', value: '@gasket/plugin-mocha' },
103
+ { name: 'jest', value: '@gasket/plugin-jest' },
104
+ { name: 'cypress', value: '@gasket/plugin-cypress' }
103
105
  ]
104
106
  }
105
107
  ]));
106
108
  }
107
109
 
108
110
  if (testPlugin && testPlugin !== 'none') {
109
- addPluginsToContext([testPlugin], context);
111
+ // addPluginsToContext([testPlugin], context);
110
112
  Object.assign(context, { testPlugin });
111
113
  }
112
114
  }
@@ -136,7 +138,7 @@ async function allowExtantOverwriting(context, prompt) {
136
138
  }
137
139
  }
138
140
 
139
- const questions = [
141
+ export const questions = [
140
142
  chooseAppDescription,
141
143
  choosePackageManager,
142
144
  chooseTestPlugin,
@@ -149,13 +151,11 @@ const questions = [
149
151
  * @param {CreateContext} context - Create context
150
152
  * @returns {Promise} promise
151
153
  */
152
- async function globalPrompts(context) {
154
+ async function globalPrompts(gasket, context) {
153
155
  const prompt = context.prompts ? inquirer.prompt : () => ({});
154
156
  for (var fn of questions) {
155
157
  await fn(context, prompt);
156
158
  }
157
159
  }
158
160
 
159
- module.exports = action('Global prompts', globalPrompts, { startSpinner: false });
160
-
161
- module.exports.questions = questions;
161
+ export default action('Global prompts', globalPrompts, { startSpinner: false });
@@ -1,32 +1,38 @@
1
+ import mkDir from './mkdir.js';
2
+ import loadPreset from './load-preset.js';
3
+ import cliVersion from './cli-version.js';
4
+ import globalPrompts from './global-prompts.js';
5
+ import setupPkg from './setup-pkg.js';
6
+ import writePkg, { writePkgUpdate } from './write-pkg.js';
7
+ import installModules, { installModulesUpdate } from './install-modules.js';
8
+ import linkModules, { linkModulesUpdate } from './link-modules.js';
9
+ import writeGasketConfig from './write-gasket-config.js';
10
+ import loadPkgForDebug from './load-pkg-for-debug.js';
11
+ import presetPromptHooks from './preset-prompt-hooks.js';
12
+ import presetConfigHooks from './preset-config-hooks.js';
13
+ import promptHooks from './prompt-hooks.js';
14
+ import createHooks from './create-hooks.js';
15
+ import generateFiles from './generate-files.js';
16
+ import postCreateHooks from './post-create-hooks.js';
17
+ import applyPresetConfig from './apply-preset-config.js';
18
+ import printReport from './print-report.js';
1
19
 
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 = {
20
+ export {
20
21
  mkDir,
21
22
  loadPreset,
22
23
  cliVersion,
23
24
  globalPrompts,
24
25
  setupPkg,
25
26
  writePkg,
27
+ writePkgUpdate,
26
28
  installModules,
29
+ installModulesUpdate,
27
30
  linkModules,
31
+ linkModulesUpdate,
28
32
  writeGasketConfig,
29
33
  loadPkgForDebug,
34
+ presetPromptHooks,
35
+ presetConfigHooks,
30
36
  promptHooks,
31
37
  createHooks,
32
38
  postCreateHooks,
@@ -1,4 +1,4 @@
1
- const action = require('../action-wrapper');
1
+ import action from '../action-wrapper.js';
2
2
 
3
3
  /**
4
4
  * Installs node_modules using the selected package manager
@@ -6,13 +6,13 @@ const action = require('../action-wrapper');
6
6
  * @param {CreateContext} context - Create context
7
7
  * @returns {Promise} promise
8
8
  */
9
- async function installModules(context) {
9
+ async function installModules(gasket, context) {
10
10
  const { pkgManager } = context;
11
11
 
12
12
  await pkgManager.install();
13
13
  }
14
14
 
15
15
 
16
- module.exports = action('Install node modules', installModules);
16
+ export default action('Install node modules', installModules);
17
17
 
18
- module.exports.update = action('Update node modules', installModules);
18
+ export const installModulesUpdate = action('Update node modules', installModules);
@@ -1,4 +1,4 @@
1
- const action = require('../action-wrapper');
1
+ import action from '../action-wrapper.js';
2
2
 
3
3
  /**
4
4
  * Links local packages using the selected package manager
@@ -7,7 +7,7 @@ const action = require('../action-wrapper');
7
7
  * @param {Spinner} spinner - Spinner
8
8
  * @returns {Promise} promise
9
9
  */
10
- async function linkModules(context, spinner) {
10
+ async function linkModules(gasket, context, spinner) {
11
11
  const { pkgLinks, pkgManager } = context;
12
12
 
13
13
  if (pkgLinks && pkgLinks.length) {
@@ -16,6 +16,6 @@ async function linkModules(context, spinner) {
16
16
  }
17
17
  }
18
18
 
19
- module.exports = action('Link node modules', linkModules, { startSpinner: false });
19
+ export default action('Link node modules', linkModules, { startSpinner: false });
20
20
 
21
- module.exports.update = action('Relink node modules', linkModules, { startSpinner: false });
21
+ export const linkModulesUpdate = action('Relink node modules', linkModules, { startSpinner: false });
@@ -1,7 +1,7 @@
1
- const path = require('path');
2
- const fs = require('fs').promises;
3
- const action = require('../action-wrapper');
4
- const ConfigBuilder = require('../config-builder');
1
+ import path from 'path';
2
+ import fs from 'fs/promises';
3
+ import action from '../action-wrapper.js';
4
+ import { ConfigBuilder } from '../config-builder.js';
5
5
 
6
6
  /**
7
7
  * Debug-only load existing app package.json for context.pkg
@@ -21,4 +21,4 @@ async function loadPkForDebug(context) {
21
21
  Object.assign(context, { pkg });
22
22
  }
23
23
 
24
- module.exports = action('Load package.json for debug. 🐲 Here be dragons!', loadPkForDebug);
24
+ export default action('Load package.json for debug. 🐲 Here be dragons!', loadPkForDebug);