create-gasket-app 7.4.16 → 7.4.18

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.
@@ -108,8 +108,8 @@ const createCommand = {
108
108
 
109
109
  /**
110
110
  * validateOption - We require at least one of the options to be provided
111
- * @param {import('../internal.js').PartialCreateContext} context
112
- * @returns {import('../internal.js').PartialCreateContext}
111
+ * @param {import('../internal.js').PartialCreateContext} context - Create context
112
+ * @returns {import('../internal.js').PartialCreateContext} Validated context
113
113
  */
114
114
  function validateOptions(context) {
115
115
  const hasOption = (context) => Boolean(context.template || context.templatePath || context.rawPresets.length || context.localPresets.length);
@@ -124,8 +124,8 @@ function validateOptions(context) {
124
124
 
125
125
  /**
126
126
  * handleTemplate - Handles the template creation
127
- * @param {import('../internal.js').PartialCreateContext} context
128
- * @returns {Promise<void>}
127
+ * @param {import('../internal.js').PartialCreateContext} context - Create context
128
+ * @returns {Promise<void>} Promise that resolves when template is created
129
129
  */
130
130
  async function handleTemplate(context) {
131
131
  await mkDir({ context });
@@ -140,8 +140,8 @@ async function handleTemplate(context) {
140
140
 
141
141
  /**
142
142
  * handlePresets - Handles the preset creation
143
- * @param {import('../internal.js').PartialCreateContext} context
144
- * @returns {Promise<void>}
143
+ * @param {import('../internal.js').PartialCreateContext} context - Create context
144
+ * @returns {Promise<void>} Promise that resolves when presets are applied
145
145
  */
146
146
  async function handlePresets(context) {
147
147
  await loadPreset({ context });
@@ -175,8 +175,8 @@ async function handlePresets(context) {
175
175
 
176
176
  /**
177
177
  * handleCreate - Handles the create creation
178
- * @param {import('../internal.js').PartialCreateContext} context
179
- * @returns {Promise<void>}
178
+ * @param {import('../internal.js').PartialCreateContext} context - Create context
179
+ * @returns {Promise<void>} Promise that resolves when app is created
180
180
  */
181
181
  async function handleCreate(context) {
182
182
  const { template, templatePath } = context;
@@ -200,7 +200,6 @@ createCommand.action = async function run(appname, options, command) {
200
200
  try {
201
201
  await handleCreate(context);
202
202
  } catch (err) {
203
- // eslint-disable-next-line no-console
204
203
  console.error(chalk.red('Exiting with errors.'));
205
204
  dumpErrorContext(context, err);
206
205
  throw err;
@@ -1,8 +1,36 @@
1
1
  import path from 'path';
2
2
  import { withSpinner } from '../with-spinner.js';
3
- import { cp, readdir } from 'fs/promises';
3
+ import { cp, readdir, rename } from 'fs/promises';
4
4
 
5
5
  const EXCLUDED_FILES = ['node_modules'];
6
+ const TEMPLATE_SUFFIX = '.template';
7
+
8
+ /**
9
+ * Recursively processes .template files in a directory,
10
+ * renaming them to remove the .template suffix.
11
+ * @param {string} dir - Directory to process
12
+ * @returns {Promise<string[]>} - List of renamed files (destination paths)
13
+ */
14
+ async function processTemplateFiles(dir) {
15
+ const renamedFiles = [];
16
+ const entries = await readdir(dir, { withFileTypes: true });
17
+
18
+ for (const entry of entries) {
19
+ const fullPath = path.join(dir, entry.name);
20
+
21
+ if (entry.isDirectory()) {
22
+ const nested = await processTemplateFiles(fullPath);
23
+ renamedFiles.push(...nested);
24
+ } else if (entry.name.endsWith(TEMPLATE_SUFFIX)) {
25
+ const newName = entry.name.slice(0, -TEMPLATE_SUFFIX.length);
26
+ const newPath = path.join(dir, newName);
27
+ await rename(fullPath, newPath);
28
+ renamedFiles.push(newPath);
29
+ }
30
+ }
31
+
32
+ return renamedFiles;
33
+ }
6
34
 
7
35
  /** @type {import('../../internal.d.ts').copyTemplate} */
8
36
  async function copyTemplate({ context }) {
@@ -17,6 +45,16 @@ async function copyTemplate({ context }) {
17
45
  await cp(sourcePath, destPath, { recursive: true });
18
46
  context.generatedFiles.add(path.relative(context.cwd, destPath));
19
47
  }
48
+
49
+ // Process .template files recursively
50
+ const renamedFiles = await processTemplateFiles(context.dest);
51
+
52
+ for (const filePath of renamedFiles) {
53
+ // Remove the old .template entry and add the renamed one
54
+ const templatePath = filePath + TEMPLATE_SUFFIX;
55
+ context.generatedFiles.delete(path.relative(context.cwd, templatePath));
56
+ context.generatedFiles.add(path.relative(context.cwd, filePath));
57
+ }
20
58
  }
21
59
 
22
60
  export default withSpinner('Copy template files', copyTemplate);
@@ -1,15 +1,13 @@
1
1
  import { default as diagnostics } from 'diagnostics';
2
2
  const debug = diagnostics('gasket:cli:generate-files');
3
3
  import fs from 'fs/promises';
4
- import { promisify } from 'util';
5
4
  import Handlebars from 'handlebars';
6
5
  import path from 'path';
7
6
  import mkdirp from 'mkdirp';
8
7
  import chalk from 'chalk';
9
8
  const { dim } = chalk;
10
9
  import { withSpinner } from '../with-spinner.js';
11
- import * as syncGlob from 'glob';
12
- const glob = promisify(syncGlob.default);
10
+ import { glob } from 'glob';
13
11
 
14
12
  const flatten = (acc, values) => (acc || []).concat(values);
15
13
  const reSep = /[/\\]+/;
@@ -8,7 +8,6 @@ import { logo } from '../../utils/index.js';
8
8
  * @private
9
9
  */
10
10
  const newline = () => {
11
- // eslint-disable-next-line no-console
12
11
  console.log('');
13
12
  };
14
13
 
@@ -59,7 +58,6 @@ async function printReport({ context }) {
59
58
  const report = buildReport(context);
60
59
  const { warnings, errors } = context;
61
60
 
62
- // eslint-disable-next-line no-console
63
61
  console.log(`✨Success!
64
62
 
65
63
  Finished with ${warnings.length} warnings and ${errors.length} errors using
@@ -68,13 +66,10 @@ Finished with ${warnings.length} warnings and ${errors.length} errors using
68
66
  Object.entries(report).forEach(([k, v]) => {
69
67
  if (!v || !v.length) return;
70
68
  newline();
71
- // eslint-disable-next-line no-console
72
69
  console.log(`${bold(toSpaceCase(k))}`);
73
70
  if (Array.isArray(v)) {
74
- // eslint-disable-next-line no-console
75
71
  v.map(o => console.log(` ${o}`));
76
72
  } else {
77
- // eslint-disable-next-line no-console
78
73
  console.log(` ${v}`);
79
74
  }
80
75
  });
@@ -57,8 +57,8 @@ function isValidVersion(v) {
57
57
  export class ConfigBuilder {
58
58
  /**
59
59
  * ConfigBuilder
60
- * @param fields
61
- * @param options
60
+ * @param {object} fields - Initial fields
61
+ * @param {object} options - Configuration options
62
62
  */
63
63
  constructor(fields = {}, options = {}) {
64
64
  this.fields = Object.assign({}, fields);
@@ -134,9 +134,9 @@ export class ConfigBuilder {
134
134
 
135
135
  /**
136
136
  * Adds all `[key, value]` pairs in the `fields` provided.
137
- * @param {object|function(current):object} fields - Object to merge.
137
+ * @param {object|function(object):object} fields - Object to merge.
138
138
  * Can be a function that accepts the current fields and object to merge.
139
- * @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.
140
140
  *
141
141
  * Adapted from @vue/cli under MIT License:
142
142
  * https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/GeneratorAPI.js#L117-L150
@@ -413,7 +413,7 @@ export class ConfigBuilder {
413
413
  * - If ¬∃ prev ––> set and blame [dep, ver]
414
414
  * - If ver > prev ––> set and blame [dep, ver]
415
415
  * - If ¬(ver ∩ prev) ––> Conflict. Print.
416
- * @param {object} options
416
+ * @param {object} options - Merge options
417
417
  * @param {string} options.key {devD,peerD,optionalD,d}ependencies
418
418
  * @param {object} options.value Updates for { name: version } pairs
419
419
  * @param {object} options.existing Existing { name: version } pairs
@@ -543,7 +543,7 @@ export class ConfigBuilder {
543
543
  * keys are ordered lexographically.
544
544
  * @param {object} obj Object to transform to ordered keys
545
545
  * @param {string[]} [orderBy] Explicit key order to use.
546
- * @returns {object} Shallow clone of `obj` with ordered keys
546
+ * @returns {object | undefined} Shallow clone of `obj` with ordered keys
547
547
  *
548
548
  * Adapted from @vue/cli under MIT License:
549
549
  * https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/util/sortObject.js
@@ -560,13 +560,11 @@ export class ConfigBuilder {
560
560
  }, {});
561
561
  }
562
562
 
563
- /*
564
- * Sorts based on the `order` defined above.
565
- */
566
563
  /**
567
- *
568
- * @param a
569
- * @param b
564
+ * Sorts based on the `order` defined above.
565
+ * @param {string} a - First key to compare
566
+ * @param {string} b - Second key to compare
567
+ * @returns {number} Comparison result
570
568
  */
571
569
  function sortByOrder(a, b) {
572
570
  const indexA = typeof order[a] === 'undefined'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-gasket-app",
3
- "version": "7.4.16",
3
+ "version": "7.4.18",
4
4
  "description": "starter pack for creating a gasket app",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,30 +25,30 @@
25
25
  "commander": "^12.1.0",
26
26
  "deepmerge": "^4.3.1",
27
27
  "diagnostics": "^2.0.2",
28
- "glob": "^8.1.0",
28
+ "glob": "^13.0.0",
29
29
  "handlebars": "^4.7.8",
30
30
  "inquirer": "^6.5.2",
31
31
  "json5": "^2.2.3",
32
32
  "mkdirp": "^1.0.4",
33
33
  "ora": "^3.4.0",
34
34
  "semver": "^7.7.1",
35
- "@gasket/core": "^7.7.0",
36
- "@gasket/plugin-command": "^7.6.1",
37
- "@gasket/plugin-docs": "^7.5.1",
35
+ "@gasket/plugin-command": "^7.6.3",
36
+ "@gasket/plugin-docs": "^7.5.3",
38
37
  "@gasket/plugin-docusaurus": "^7.5.0",
39
38
  "@gasket/plugin-dynamic-plugins": "^7.5.0",
40
- "@gasket/plugin-git": "^7.4.7",
39
+ "@gasket/plugin-git": "^7.4.8",
41
40
  "@gasket/plugin-logger": "^7.4.0",
42
- "@gasket/plugin-metadata": "^7.5.6",
43
- "@gasket/request": "^7.5.4",
44
- "@gasket/utils": "^7.6.3"
41
+ "@gasket/plugin-metadata": "^7.5.8",
42
+ "@gasket/request": "^7.5.5",
43
+ "@gasket/utils": "^7.6.4",
44
+ "@gasket/core": "^7.7.2"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@typescript-eslint/parser": "^8.38.0",
48
48
  "@vitest/coverage-v8": "^3.2.0",
49
49
  "dotenv": "^16.4.7",
50
50
  "vitest": "^3.2.0",
51
- "@gasket/request": "^7.5.4"
51
+ "@gasket/request": "^7.5.5"
52
52
  },
53
53
  "scripts": {
54
54
  "lint": "eslint .",