create-gasket-app 7.4.17 → 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.
@@ -1,52 +1,35 @@
1
1
  import path from 'path';
2
2
  import { withSpinner } from '../with-spinner.js';
3
- import { cp, readdir, writeFile, access } 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';
6
7
 
7
8
  /**
8
- * Ensures a .gitignore exists in the generated app.
9
- * npm intentionally strips .gitignore files from published packages.
10
- * We will need to update our templates to use a different name
11
- * such as gitignore or .gitignore.template to survive installing.
12
- * @param {import("../../internal.d.ts").PartialCreateContext} context - Create context
13
- * @returns {Promise<void>}
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)
14
13
  */
15
- export async function ensureGitignore(context) {
16
- const destPath = path.join(context.dest, '.gitignore');
17
-
18
- const exists = await access(destPath)
19
- .then(() => true)
20
- .catch(() => false);
21
-
22
- if (exists) {
23
- return;
24
- }
25
-
26
- const npmignorePath = path.join(context.dest, '.npmignore');
27
- try {
28
- await cp(npmignorePath, destPath);
29
- context.generatedFiles.add(path.relative(context.cwd, destPath));
30
- return;
31
- } catch (err) {
32
- if (err.code !== 'ENOENT') throw err;
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
+ }
33
30
  }
34
31
 
35
- // No template gitignore found, create a basic one
36
- const basicGitignore = [
37
- '# Dependencies',
38
- 'node_modules',
39
- '',
40
- '# Logs',
41
- '*.log',
42
- '',
43
- '# Env files',
44
- '.env',
45
- '.env.local'
46
- ].join('\n');
47
-
48
- await writeFile(destPath, basicGitignore, 'utf8');
49
- context.generatedFiles.add(path.relative(context.cwd, destPath));
32
+ return renamedFiles;
50
33
  }
51
34
 
52
35
  /** @type {import('../../internal.d.ts').copyTemplate} */
@@ -63,8 +46,15 @@ async function copyTemplate({ context }) {
63
46
  context.generatedFiles.add(path.relative(context.cwd, destPath));
64
47
  }
65
48
 
66
- // Ensure .gitignore is properly created
67
- await ensureGitignore(context);
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
+ }
68
58
  }
69
59
 
70
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 = /[/\\]+/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-gasket-app",
3
- "version": "7.4.17",
3
+ "version": "7.4.18",
4
4
  "description": "starter pack for creating a gasket app",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,23 +25,23 @@
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.1",
36
- "@gasket/plugin-command": "^7.6.2",
37
- "@gasket/plugin-docs": "^7.5.2",
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
39
  "@gasket/plugin-git": "^7.4.8",
41
40
  "@gasket/plugin-logger": "^7.4.0",
42
- "@gasket/plugin-metadata": "^7.5.7",
41
+ "@gasket/plugin-metadata": "^7.5.8",
43
42
  "@gasket/request": "^7.5.5",
44
- "@gasket/utils": "^7.6.4"
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",