create-gasket-app 7.0.4 → 7.0.9

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.
@@ -2,10 +2,7 @@ import action from '../action-wrapper.js';
2
2
 
3
3
  /**
4
4
  * Links local packages using the selected package manager
5
- *
6
- * @param {CreateContext} context - Create context
7
- * @param {Spinner} spinner - Spinner
8
- * @returns {Promise} promise
5
+ * @type {import('../../internal').linkModules}
9
6
  */
10
7
  async function linkModules({ context, spinner }) {
11
8
  const { pkgLinks, pkgManager } = context;
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import os from 'os';
3
3
  import action from '../action-wrapper.js';
4
- import { default as gasketUtils } from '@gasket/utils';
4
+ import { PackageManager } from '@gasket/utils';
5
5
  import { mkdtemp } from 'fs/promises';
6
6
  import { createRequire } from 'module';
7
7
  const require = createRequire(import.meta.url);
@@ -9,14 +9,14 @@ const hasVersionOrTag = /@([\^~]?\d+\.\d+\.\d+(?:-[\d\w.-]+)?|[\^~]?\d+\.\d+\.\d
9
9
 
10
10
  /**
11
11
  * loadPresets - Load presets to temp directory
12
- * @param {CreateContext} context - Create context
12
+ * @type {import('../../internal').loadPresets}
13
13
  */
14
14
  async function loadPresets({ context }) {
15
15
  const tmpDir = await mkdtemp(path.join(os.tmpdir(), `gasket-create-${context.appName}`));
16
16
  context.tmpDir = tmpDir;
17
17
 
18
18
  const modPath = path.join(tmpDir, 'node_modules');
19
- const pkgManager = new gasketUtils.PackageManager({
19
+ const pkgManager = new PackageManager({
20
20
  packageManager: context.packageManager,
21
21
  dest: tmpDir
22
22
  });
@@ -3,12 +3,9 @@ import action from '../action-wrapper.js';
3
3
 
4
4
  /**
5
5
  * Validates this instance can execute without common blockers:
6
- * - Target destination on disk is available. Validate by acquiring
7
- * a lock through `mkdir`.
8
- *
9
- * @param {CreateContext} context - Create context
10
- * @param {Spinner} spinner - Spinner
11
- * @returns {Promise} promise
6
+ * - Target destination on disk is available. Validate by acquiring
7
+ * a lock through `mkdir`.
8
+ * @type {import('../../internal').mkDir}
12
9
  */
13
10
  async function mkDir({ context, spinner }) {
14
11
  const { dest, relDest, extant, destOverride } = context;
@@ -3,17 +3,14 @@ import { runShellCommand } from '@gasket/utils';
3
3
 
4
4
  /**
5
5
  * Executes the `postCreate` hook for all registered plugins.
6
- *
7
- * @param {GasketEngine} gasket - Gasket API
8
- * @param {CreateContext} context - Create context
9
- * @returns {Promise} promise
6
+ * @type {import('../../internal').postCreateHooks}
10
7
  */
11
8
  async function postCreateHooks({ gasket, context }) {
12
9
  const { dest } = context;
13
10
 
14
11
  /**
15
12
  * Run an npm script in the context of the created application
16
- * @param {String} script name of script
13
+ * @param {string} script name of script
17
14
  * @returns {Promise} A promise represents if npm succeeds or fails.
18
15
  */
19
16
  async function runScript(script) {
@@ -2,8 +2,7 @@ import action from '../action-wrapper.js';
2
2
 
3
3
  /**
4
4
  * presetConfigHooks - exec `presetConfig` hook
5
- * @param {Gasket} gasket - Preset gasket instance
6
- * @param {CreateContext} context - Create context
5
+ * @type {import('../../internal').presetConfigHooks}
7
6
  */
8
7
  async function presetConfigHooks({ gasket, context }) {
9
8
  const config = await gasket.execWaterfall('presetConfig', context);
@@ -3,8 +3,7 @@ import action from '../action-wrapper.js';
3
3
 
4
4
  /**
5
5
  * presetPromptHooks - exec `presetPrompt` hook
6
- * @param {Gasket} gasket - Preset gasket instance
7
- * @param {CreateContext} context - Create context
6
+ * @type {import('../../internal').presetPromptHooks}
8
7
  */
9
8
  async function presetPromptHooks({ gasket, context }) {
10
9
  const prompt = context.prompts ? inquirer.createPromptModule() : () => ({});
@@ -13,8 +13,7 @@ const newline = () => {
13
13
 
14
14
  /**
15
15
  * Converts a camelCase string to Space Case
16
- * @see: https://stackoverflow.com/questions/4149276/javascript-camelcase-to-regular-form?answertab=active#tab-top
17
- *
16
+ * https://stackoverflow.com/questions/4149276/javascript-camelcase-to-regular-form?answertab=active#tab-top
18
17
  * @param {string} str - camelCase string to fixup
19
18
  * @returns {string} result
20
19
  * @private
@@ -24,17 +23,13 @@ const toSpaceCase = str => str.replace(/([A-Z])/g, ' $1')
24
23
 
25
24
  /**
26
25
  * Builds the report object from context
27
- *
28
- * @param {CreateContext} context - Create context
29
- * @returns {Object} report
26
+ * @type {import('../../internal').buildReport}
30
27
  * @private
31
28
  */
32
29
  function buildReport(context) {
33
30
  const {
34
31
  appName,
35
32
  dest,
36
- fullPresets,
37
- plugins,
38
33
  generatedFiles: generatedFilesSet,
39
34
  messages,
40
35
  warnings,
@@ -44,12 +39,9 @@ function buildReport(context) {
44
39
 
45
40
  const generatedFiles = Array.from(generatedFilesSet);
46
41
  generatedFiles.sort();
47
-
48
42
  return {
49
43
  appName,
50
44
  output: dest,
51
- presets: fullPresets,
52
- plugins,
53
45
  generatedFiles,
54
46
  messages,
55
47
  warnings,
@@ -60,8 +52,7 @@ function buildReport(context) {
60
52
 
61
53
  /**
62
54
  * Outputs create command details to the console
63
-
64
- * @param {CreateContext} context - Create context
55
+ * @type {import('../../internal').printReport}
65
56
  */
66
57
  async function printReport({ context }) {
67
58
  const report = buildReport(context);
@@ -4,12 +4,7 @@ import action from '../action-wrapper.js';
4
4
  /**
5
5
  * Initializes engine with provide preset and plugins
6
6
  * to execute their prompt lifecycle hooks.
7
- *
8
- * @param {CreateContext} context - Create context
9
- * @param {String[]} plugins - plugins to load
10
- * @param {String} [presets] - presets to load
11
- * @returns {Promise} promise
12
- * @private
7
+ * @type {import('../../internal').execPluginPrompts}
13
8
  */
14
9
  async function execPluginPrompts(gasket, context) {
15
10
  //
@@ -26,18 +21,14 @@ async function execPluginPrompts(gasket, context) {
26
21
  /**
27
22
  * Executes the `prompt` hook for all registered plugins.
28
23
  * Adds `prompt` util function for prompting features.
29
- *
30
- * @param {GasketEngine} gasket - Gasket API
31
- * @param {CreateContext} context - Create context
32
- * @returns {Promise} promise
24
+ * @type {import('../../internal').promptHooks}
33
25
  */
34
26
  async function promptHooks({ gasket, context }) {
35
27
  //
36
28
  // Because `execPluginPrompts` is recursively, we need to start it
37
29
  // with the processPlugins and presets from our initial context
38
30
  //
39
- const { plugins } = context;
40
- await execPluginPrompts(gasket, context, plugins);
31
+ await execPluginPrompts(gasket, context);
41
32
  }
42
33
 
43
34
  export default action('Plugin prompts', promptHooks, { startSpinner: false });
@@ -1,15 +1,13 @@
1
1
  import action from '../action-wrapper.js';
2
2
  import { ConfigBuilder } from '../config-builder.js';
3
- import { default as gasketUtils } from '@gasket/utils';
3
+ import { PackageManager } from '@gasket/utils';
4
4
  import { createRequire } from 'module';
5
5
  const require = createRequire(import.meta.url);
6
6
  const { dependencies } = require('../../../package.json');
7
7
 
8
8
  /**
9
9
  * Initializes the ConfigBuilder builder and adds to context.
10
- *
11
- * @param {CreateContext} context - Create context
12
- * @returns {Promise} promise
10
+ * @type {import('../../internal').setupPkg}
13
11
  */
14
12
  async function setupPkg({ context }) {
15
13
  const { appName, appDescription, warnings } = context;
@@ -27,7 +25,7 @@ async function setupPkg({ context }) {
27
25
  '@gasket/utils': dependencies['@gasket/utils']
28
26
  });
29
27
 
30
- const pkgManager = new gasketUtils.PackageManager(context);
28
+ const pkgManager = new PackageManager(context);
31
29
  Object.assign(context, { pkg, pkgManager });
32
30
  }
33
31
 
@@ -5,8 +5,7 @@ import action from '../action-wrapper.js';
5
5
 
6
6
  /**
7
7
  * writePluginImports - Write string imports as value(s)
8
- * @param {string[]} plugins - Array of plugin import names
9
- * @returns {string} - Array of plugin imports as string
8
+ * @type {import('../../internal').writePluginImports}
10
9
  */
11
10
  function writePluginImports(plugins) {
12
11
  return plugins.reduce((acc, cur, index) => {
@@ -17,8 +16,7 @@ function writePluginImports(plugins) {
17
16
 
18
17
  /**
19
18
  * writeImports - Write imports to file using key value pairs
20
- * @param {{[pluginImport: string]: string}[]} imports - Array of key value pairs for imports
21
- * @returns {string} - import declarations as string
19
+ * @type {import('../../internal').writeImports}
22
20
  */
23
21
  function writeImports(imports) {
24
22
  if (!imports) return '';
@@ -27,9 +25,7 @@ function writeImports(imports) {
27
25
 
28
26
  /**
29
27
  * createInjectionAssignments - replace object path with a temp string value
30
- * @param {GasketConfigDefinition} config - gasket config object
31
- * @param {{ [configKey]: string }} assignments - key value pairs of config keys to replace
32
- * @returns {string} - string if assignments is falsy
28
+ * @type {import('../../internal').createInjectionAssignments}
33
29
  */
34
30
  function createInjectionAssignments(config, assignments) {
35
31
  if (!assignments) return '';
@@ -48,9 +44,7 @@ function createInjectionAssignments(config, assignments) {
48
44
 
49
45
  /**
50
46
  * replaceInjectionAssignments - replace temp string value with actual value
51
- * @param {string} content
52
- * @param {{ [configKey]: string }} assignments - key value pairs of config keys to replace
53
- * @returns {string} - content with replaced values
47
+ * @type {import('../../internal').replaceInjectionAssignments}
54
48
  */
55
49
  function replaceInjectionAssignments(content, assignments) {
56
50
  if (!assignments) return content;
@@ -63,8 +57,7 @@ function replaceInjectionAssignments(content, assignments) {
63
57
 
64
58
  /**
65
59
  * writeExpressions - Write expressions to file
66
- * @param {string} expressions - programmatic expressions as string
67
- * @returns {string} - expressions as string
60
+ * @type {import('../../internal').writeExpressions}
68
61
  */
69
62
  function writeExpressions(expressions) {
70
63
  if (!expressions) return '';
@@ -73,7 +66,7 @@ function writeExpressions(expressions) {
73
66
 
74
67
  /**
75
68
  * cleanupFields - Remove fields from config object
76
- * @param {GasketConfigDefinition} config - gasket config object
69
+ * @type {import('../../internal').cleanupFields}
77
70
  */
78
71
  function cleanupFields(config) {
79
72
  delete config.fields.imports;
@@ -84,9 +77,7 @@ function cleanupFields(config) {
84
77
 
85
78
  /**
86
79
  * Writes the contents of `pkg` to the app's package.json.
87
- *
88
- * @param {CreateContext} context - Create context
89
- * @returns {Promise} promise
80
+ * @type {import('../../internal').writeGasketConfig}
90
81
  */
91
82
  async function writeGasketConfig({ context }) {
92
83
  const { dest, gasketConfig, generatedFiles, typescript } = context;
@@ -4,9 +4,7 @@ import action from '../action-wrapper.js';
4
4
 
5
5
  /**
6
6
  * Writes the contents of `pkg` to the app's package.json.
7
- *
8
- * @param {CreateContext} context - Create context
9
- * @returns {Promise} promise
7
+ * @type {import('../../internal').writePkg}
10
8
  */
11
9
  async function writePkg({ context }) {
12
10
  const { dest, pkg, generatedFiles } = context;
@@ -7,9 +7,8 @@ const debug = diagnostics('gasket:cli:package');
7
7
  /**
8
8
  * Simple object check without bringing in a large
9
9
  * utility library.
10
- *
11
10
  * @param {*} value - What to test if an object
12
- * @returns {Boolean} results
11
+ * @returns {boolean} results
13
12
  */
14
13
  function isObject(value) {
15
14
  return value && typeof value === 'object';
@@ -35,7 +34,6 @@ const versionTypes = {
35
34
  /**
36
35
  * Validates if the version `v` is valid for `package.json`
37
36
  * dependencies, devDependencies, etc.
38
- *
39
37
  * @param {string} v Version in package.json field.
40
38
  * @returns {boolean} Value indicating if npm accepts the value
41
39
  */
@@ -48,25 +46,19 @@ function isValidVersion(v) {
48
46
  return v === 'latest'
49
47
  || v.match(versionTypes.uri) != null // eslint-disable-line eqeqeq
50
48
  || v.match(versionTypes.github) != null // eslint-disable-line eqeqeq
51
- || semver.validRange(v);
49
+ || !!semver.validRange(v);
52
50
  }
53
51
 
54
52
  /**
55
53
  * ConfigBuilder is an extensible data structure for **specifically**
56
54
  * managing `package.json` data.
57
- *
58
- * @type {ConfigBuilder}
55
+ * @type {import('../index').ConfigBuilder}
59
56
  */
60
57
  export class ConfigBuilder {
61
58
  /**
62
59
  * ConfigBuilder
63
- *
64
- * @param {Object} [fields] - Initial fields
65
- * @param {Object} [options] - Additional setup options
66
- * @param {String[]} [options.orderBy] - Preferred order to sort top-level keys
67
- * @param {String[]} [options.orderedFields] - Fields that should be sorted
68
- * @param {String[]} [options.objectFields] - Fields that are required to be object type
69
- * @param {String[]} [options.semverFields] - Fields that are aware of semantic versioning
60
+ * @param fields
61
+ * @param options
70
62
  */
71
63
  constructor(fields = {}, options = {}) {
72
64
  this.fields = Object.assign({}, fields);
@@ -80,6 +72,7 @@ export class ConfigBuilder {
80
72
  this.objectFields = options.objectFields;
81
73
  this.semverFields = options.semverFields;
82
74
  this.warnings = options.warnings;
75
+ this.source = options.source;
83
76
 
84
77
  // Any semverFields are also object fields and ordered fields.
85
78
  if (Array.isArray(this.semverFields)) {
@@ -90,9 +83,8 @@ export class ConfigBuilder {
90
83
 
91
84
  /**
92
85
  * Creator method to get a new instance
93
- *
94
- * @param {Object} [fields] - Initial fields
95
- * @param {Object} [options] - Additional setup options
86
+ * @param {object} [fields] - Initial fields
87
+ * @param {object} [options] - Additional setup options
96
88
  * @returns {ConfigBuilder} instance
97
89
  */
98
90
  static create(fields = {}, options = {}) {
@@ -101,9 +93,8 @@ export class ConfigBuilder {
101
93
 
102
94
  /**
103
95
  * Create an instance configured with options for package.json files
104
- *
105
- * @param {Object} [fields] - Initial fields
106
- * @param {Object} [options] - Additional setup options
96
+ * @param {object} [fields] - Initial fields
97
+ * @param {object} [options] - Additional setup options
107
98
  * @returns {ConfigBuilder} instance
108
99
  */
109
100
  static createPackageJson(fields = {}, options = {}) {
@@ -143,9 +134,9 @@ export class ConfigBuilder {
143
134
 
144
135
  /**
145
136
  * Adds all `[key, value]` pairs in the `fields` provided.
146
- * @param {object|function(current)} fields - Object to merge.
137
+ * @param {object|function(current):object} fields - Object to merge.
147
138
  * Can be a function that accepts the current fields and object to merge.
148
- * @param {Object} source Plugin to blame if conflicts arise from this operation.
139
+ * @param {object} source Plugin to blame if conflicts arise from this operation.
149
140
  *
150
141
  * Adapted from @vue/cli under MIT License:
151
142
  * https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/GeneratorAPI.js#L117-L150
@@ -171,7 +162,7 @@ export class ConfigBuilder {
171
162
  * the given `key` into the package.json fields associated with this instance.
172
163
  * @param {string} key - Field in package.json to add or extend.
173
164
  * @param {*} value - Target value to set for key provided.
174
- * @param {Object} source - Plugin to blame if conflicts arise from this operation.
165
+ * @param {object} source - Plugin to blame if conflicts arise from this operation.
175
166
  * @param {object} [options] - Optional arguments for add behavior
176
167
  * @param {boolean} [options.force] - Should the semver version override other attempts
177
168
  *
@@ -305,9 +296,9 @@ export class ConfigBuilder {
305
296
 
306
297
  /**
307
298
  * Checks if a dependency has been already added
308
- * @param {String} key Dependency bucket
309
- * @param {String} value Dependency to search
310
- * @returns {Bool} True if the dependency exists on the bucket
299
+ * @param {string} key Dependency bucket
300
+ * @param {string} value Dependency to search
301
+ * @returns {boolean} True if the dependency exists on the bucket
311
302
  */
312
303
  has(key, value) {
313
304
  const existing = this.fields[key];
@@ -352,10 +343,10 @@ export class ConfigBuilder {
352
343
  * - If ¬∃ prev ––> set and blame [dep, ver]
353
344
  * - If ver > prev ––> set and blame [dep, ver]
354
345
  * - If ¬(ver ∩ prev) ––> Conflict. Print.
355
- *
346
+ * @param {object} options
356
347
  * @param {string} options.key {devD,peerD,optionalD,d}ependencies
357
- * @param {Object} options.value Updates for { name: version } pairs
358
- * @param {Object} options.existing Existing { name: version } pairs
348
+ * @param {object} options.value Updates for { name: version } pairs
349
+ * @param {object} options.existing Existing { name: version } pairs
359
350
  * @param {string} options.name Plugin name providing merge `value``
360
351
  * @param {boolean} [options.force] Should the semver version override other attempts
361
352
  *
@@ -366,6 +357,7 @@ export class ConfigBuilder {
366
357
 
367
358
  const setBlame = blameId => {
368
359
  this.blame.set(blameId, [name]);
360
+ // debugger;
369
361
  if (force) this.force.add(blameId);
370
362
  };
371
363
 
@@ -425,9 +417,9 @@ export class ConfigBuilder {
425
417
  /**
426
418
  * Normalizes a potential semver range into a semver string
427
419
  * and returns the newest version
428
- * @param {String} r1 Semver string (potentially invalid).
429
- * @param {String} r2 Semver string (potentially invalid).
430
- * @returns {String|undefined} Newest semver version.
420
+ * @param {string} r1 Semver string (potentially invalid).
421
+ * @param {string} r2 Semver string (potentially invalid).
422
+ * @returns {string | undefined} Newest semver version.
431
423
  *
432
424
  * Adapted from @vue/cli under MIT License:
433
425
  * https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/util/mergeDeps.js#L58-L64
@@ -448,7 +440,6 @@ export class ConfigBuilder {
448
440
  * Performs a naive attempt to take a transform a semver range
449
441
  * into a concrete version that may be used for "newness"
450
442
  * comparison.
451
- *
452
443
  * @param {string} range Valid "basic" semver: ^X.Y.Z, ~A.B.C, >=2.3.x, 1.x.x
453
444
  * @returns {string} Concrete as possible version: X.Y.Z, A.B.C, 2.3.0, 1.0.0
454
445
  */
@@ -462,7 +453,7 @@ export class ConfigBuilder {
462
453
  /**
463
454
  * Orders top-level keys by `orderBy` options with any fields specified in
464
455
  * the `orderFields` options having their keys sorted.
465
- * @returns {Object} Ready to be serialized JavaScript object.
456
+ * @returns {object} Ready to be serialized JavaScript object.
466
457
  */
467
458
  toJSON() {
468
459
  if (Array.isArray(this.orderedFields)) {
@@ -480,9 +471,9 @@ export class ConfigBuilder {
480
471
  * Orders the given object, `obj`, applying any (optional)
481
472
  * key order specified via `orderBy`. If no `orderBy` is provided
482
473
  * keys are ordered lexographically.
483
- * @param {Object} obj Object to transform to ordered keys
474
+ * @param {object} obj Object to transform to ordered keys
484
475
  * @param {string[]} [orderBy] Explicit key order to use.
485
- * @returns {Object} Shallow clone of `obj` with ordered keys
476
+ * @returns {object} Shallow clone of `obj` with ordered keys
486
477
  *
487
478
  * Adapted from @vue/cli under MIT License:
488
479
  * https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/util/sortObject.js
@@ -502,6 +493,11 @@ export class ConfigBuilder {
502
493
  /*
503
494
  * Sorts based on the `order` defined above.
504
495
  */
496
+ /**
497
+ *
498
+ * @param a
499
+ * @param b
500
+ */
505
501
  function sortByOrder(a, b) {
506
502
  const indexA = typeof order[a] === 'undefined'
507
503
  ? Infinity
@@ -7,11 +7,7 @@ import { readConfig } from '../scaffold/utils.js';
7
7
  * The CreateRuntime represents a shallow proxy to a CreateContext
8
8
  * that automatically adds transactional information for providing
9
9
  * CLI users with blame information in the event of conflicts.
10
- *
11
- * @param {CreateContext} context - Create context.
12
- * @param {Plugin} source - Gasket plugin the create context is within.
13
- * @returns {Proxy} Shallow proxy to the `context` provided that will
14
- * pass `source` to `context.{files,pkg}.*` methods.
10
+ * @type {import('../internal').makeCreateRuntime}
15
11
  */
16
12
  function makeCreateRuntime(context, source) {
17
13
  //
@@ -47,6 +43,7 @@ function makeCreateRuntime(context, source) {
47
43
  set(obj, key, value) {
48
44
  if (key !== 'pkg' && key !== 'files' && key !== 'source') {
49
45
  obj[key] = value;
46
+ return true; // The set trap in a Proxy must return a boolean value indicating whether the property was successfully set
50
47
  }
51
48
  }
52
49
  });
@@ -56,57 +53,6 @@ function flatten(acc, values) {
56
53
  return acc.concat(values);
57
54
  }
58
55
 
59
- /**
60
- * Create Context
61
- *
62
- * @type {CreateContext}
63
- *
64
- * -- Added by command args and options
65
- *
66
- * @property {String} appName - Short name of the app
67
- * @property {String} cwd - Current work directory
68
- * @property {String} dest - Path to the target app (Default: cwd/appName)
69
- * @property {String} relDest - Relative path to the target app
70
- * @property {Boolean} extant - Whether or not target directory already exists
71
- * @property {[String]} localPresets - paths to the local presets packages
72
- * @property {PresetDesc[]} rawPresets - Raw preset desc from args. Can include version constraint. Added by load-preset if using localPresets.
73
- * @property {String[]} pkgLinks - Local packages that should be linked
74
- * @property {String[]} messages - non-error/warning messages to report
75
- * @property {String[]} warnings - warnings messages to report
76
- * @property {String[]} errors - error messages to report but do not exit process
77
- * @property {String[]} nextSteps - any next steps to report for user
78
- * @property {Set<String>} generatedFiles - any generated files to show in report
79
- * @property {any[]} presets - Default empty array, populated by load-preset with actual imports
80
- * @property {Object} presetConfig - Default to object w/empty plugins array to be populated by `presetConfig` hook
81
- *
82
- * -- Added by `global-prompts`
83
- *
84
- * @property {String} appDescription - Description of app
85
- * @property {Boolean} gitInit - Should a git repo be initialized and first commit
86
- * @property {String} testPlugins - Array of testing plugins
87
- * @property {String} packageManager - Which package manager to use (Default: 'npm')
88
- * @property {String} installCmd - Derived install command (Default: 'npm install')
89
- * @property {String} localCmd - Derived local run command (Default: 'npx gasket local')
90
- * @property {Boolean} destOverride - Whether or not the user wants to override an extant directory
91
- *
92
- * -- Added by `load-preset`
93
- *
94
- * @property {PresetName[]} presets - Short name of presets
95
- *
96
- *
97
- * -- Added by `setup-pkg`
98
- *
99
- * @property {ConfigBuilder} pkg - package.json builder
100
- * @property {PackageManager} pkgManager - manager to execute npm or yarn commands
101
- *
102
- * -- Added by `setup-gasket-config`
103
- *
104
- * @property {ConfigBuilder} gasketConfig - gasket.config builder
105
- *
106
- * -- Added by `create-hooks`
107
- *
108
- * @property {Files} files - Use to add files and templates to generate
109
- */
110
56
  export class CreateContext {
111
57
  constructor(initContext = {}) {
112
58
  Object.assign(this, initContext);
@@ -117,13 +63,7 @@ export class CreateContext {
117
63
  }
118
64
  }
119
65
 
120
- /**
121
- * Makes the initial context used through the create command flow.
122
- *
123
- * @param {String[]} argv - Commands args
124
- * @param {Object} options - Command options
125
- * @returns {CreateContext} context
126
- */
66
+ /** @type {import('../internal').makeCreateContext} */
127
67
  export function makeCreateContext(argv = [], options = {}) {
128
68
  const appName = argv[0] || 'templated-app';
129
69
  const {
@@ -149,9 +89,8 @@ export function makeCreateContext(argv = [], options = {}) {
149
89
 
150
90
  /**
151
91
  * Input context which will be appended by prompts and passed to create hooks
152
- *
153
- * @type {CreateContext}
154
- */
92
+ * @type {import('../internal').PartialCreateContext}
93
+ */
155
94
  const context = new CreateContext({
156
95
  destOverride: true,
157
96
  cwd,
@@ -4,10 +4,7 @@ import { writeFile } from 'fs/promises';
4
4
  /**
5
5
  * If an error occurs during create, dump the context for debugging.
6
6
  * The error which cause the exit is also included in the log.
7
- *
8
- * @param {CreateContext} context - Create context
9
- * @param {Error} error - Exiting error
10
- * @returns {Promise<void>} promise
7
+ * @type {import('../internal').dumpErrorContext}
11
8
  */
12
9
  export async function dumpErrorContext(context, error) {
13
10
  const { cwd } = context;
@@ -1,16 +1,18 @@
1
1
  /**
2
2
  * Utility for plugins to add files and templates for generating
3
- *
4
- * @type {Files}
3
+ * @type {import('../index').Files}
5
4
  */
6
5
  export class Files {
7
6
  constructor() {
7
+ /**
8
+ * Array of glob sets, each containing an array of globs and a source object.
9
+ * @type {Array<{globs: string[], source: object}>}
10
+ */
8
11
  this.globSets = [];
9
12
  }
10
13
 
11
14
  /**
12
15
  * Return array of globs
13
- *
14
16
  * @deprecated
15
17
  * @returns {string[]} `globby` compatible patterns
16
18
  */
@@ -21,8 +23,9 @@ export class Files {
21
23
  /**
22
24
  * Adds the specified `globby` compatible patterns, `globs`,
23
25
  * into the set of all sources for this set of files.
24
- * @param {string[]} globs - `globby` compatible patterns
25
- * @param {Object} source - Plugin to blame if conflicts arise from this operation.
26
+ * @param {object} params - Object containing `globs` and `source`
27
+ * @param {string[]} params.globs - `globby` compatible patterns
28
+ * @param {object} params.source - Plugin to blame if conflicts arise from this operation.
26
29
  */
27
30
  add({ globs, source }) {
28
31
  this.globSets.push({ globs, source });
@@ -2,14 +2,7 @@ import path from 'path';
2
2
  import { createRequire } from 'module';
3
3
  const require = createRequire(import.meta.url);
4
4
 
5
- /**
6
- * Parses JSON file or string to assign to context
7
- *
8
- * @param {CreateContext} context - Create context.
9
- * @param {Object} configFlags - flags to read config from
10
- * @param {string} configFlags.config - JSON string of config values
11
- * @param {string} configFlags.configFile - path to JSON file of config values
12
- */
5
+ /** @type {import('../internal').readConfig} */
13
6
  export function readConfig(context, { config, configFile }) {
14
7
  if (config) {
15
8
  const parsedConfig = JSON.parse(config);
@@ -19,4 +12,3 @@ export function readConfig(context, { config, configFile }) {
19
12
  Object.assign(context, parsedConfigFile);
20
13
  }
21
14
  }
22
-
@@ -2,8 +2,7 @@ import { Option } from 'commander';
2
2
 
3
3
  /**
4
4
  * createOption - Create a commander option
5
- * @param {CLICommandOption} definition - The option configuration
6
- * @returns {CommnaderOption} option
5
+ * @type {import('../internal').createOption}
7
6
  */
8
7
  export function createOption(definition) {
9
8
  const option = new Option(...definition.options);