create-gasket-app 7.4.15 → 7.4.17
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.
package/lib/commands/create.js
CHANGED
|
@@ -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,9 +1,54 @@
|
|
|
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, writeFile, access } from 'fs/promises';
|
|
4
4
|
|
|
5
5
|
const EXCLUDED_FILES = ['node_modules'];
|
|
6
6
|
|
|
7
|
+
/**
|
|
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>}
|
|
14
|
+
*/
|
|
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;
|
|
33
|
+
}
|
|
34
|
+
|
|
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));
|
|
50
|
+
}
|
|
51
|
+
|
|
7
52
|
/** @type {import('../../internal.d.ts').copyTemplate} */
|
|
8
53
|
async function copyTemplate({ context }) {
|
|
9
54
|
if (!context.templateDir) return;
|
|
@@ -17,6 +62,9 @@ async function copyTemplate({ context }) {
|
|
|
17
62
|
await cp(sourcePath, destPath, { recursive: true });
|
|
18
63
|
context.generatedFiles.add(path.relative(context.cwd, destPath));
|
|
19
64
|
}
|
|
65
|
+
|
|
66
|
+
// Ensure .gitignore is properly created
|
|
67
|
+
await ensureGitignore(context);
|
|
20
68
|
}
|
|
21
69
|
|
|
22
70
|
export default withSpinner('Copy template files', copyTemplate);
|
|
@@ -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(
|
|
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.
|
|
3
|
+
"version": "7.4.17",
|
|
4
4
|
"description": "starter pack for creating a gasket app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,23 +32,23 @@
|
|
|
32
32
|
"mkdirp": "^1.0.4",
|
|
33
33
|
"ora": "^3.4.0",
|
|
34
34
|
"semver": "^7.7.1",
|
|
35
|
-
"@gasket/core": "^7.
|
|
36
|
-
"@gasket/plugin-command": "^7.6.
|
|
37
|
-
"@gasket/plugin-docs": "^7.5.
|
|
35
|
+
"@gasket/core": "^7.7.1",
|
|
36
|
+
"@gasket/plugin-command": "^7.6.2",
|
|
37
|
+
"@gasket/plugin-docs": "^7.5.2",
|
|
38
38
|
"@gasket/plugin-docusaurus": "^7.5.0",
|
|
39
39
|
"@gasket/plugin-dynamic-plugins": "^7.5.0",
|
|
40
|
-
"@gasket/plugin-git": "^7.4.
|
|
40
|
+
"@gasket/plugin-git": "^7.4.8",
|
|
41
41
|
"@gasket/plugin-logger": "^7.4.0",
|
|
42
|
-
"@gasket/plugin-metadata": "^7.5.
|
|
43
|
-
"@gasket/request": "^7.5.
|
|
44
|
-
"@gasket/utils": "^7.6.
|
|
42
|
+
"@gasket/plugin-metadata": "^7.5.7",
|
|
43
|
+
"@gasket/request": "^7.5.5",
|
|
44
|
+
"@gasket/utils": "^7.6.4"
|
|
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.
|
|
51
|
+
"@gasket/request": "^7.5.5"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"lint": "eslint .",
|