create-gasket-app 7.0.0-next.8 → 7.0.0
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/README.md +53 -53
- package/lib/commands/create.js +17 -15
- package/lib/config/default-plugins.js +9 -1
- package/lib/index.d.ts +133 -79
- package/lib/index.js +2 -1
- package/lib/scaffold/action-wrapper.js +5 -3
- package/lib/scaffold/actions/create-hooks.js +5 -2
- package/lib/scaffold/actions/generate-files.js +5 -1
- package/lib/scaffold/actions/global-prompts.js +42 -35
- package/lib/scaffold/actions/install-modules.js +1 -1
- package/lib/scaffold/actions/link-modules.js +1 -1
- package/lib/scaffold/actions/load-preset.js +7 -7
- package/lib/scaffold/actions/mkdir.js +1 -1
- package/lib/scaffold/actions/post-create-hooks.js +2 -1
- package/lib/scaffold/actions/preset-config-hooks.js +1 -1
- package/lib/scaffold/actions/preset-prompt-hooks.js +1 -1
- package/lib/scaffold/actions/print-report.js +1 -1
- package/lib/scaffold/actions/prompt-hooks.js +2 -1
- package/lib/scaffold/actions/setup-pkg.js +11 -2
- package/lib/scaffold/actions/write-gasket-config.js +7 -5
- package/lib/scaffold/actions/write-pkg.js +1 -4
- package/lib/scaffold/config-builder.js +10 -7
- package/lib/scaffold/create-context.js +3 -2
- package/lib/scaffold/readme.js +51 -0
- package/lib/utils/index.js +0 -1
- package/lib/utils/logo.js +10 -10
- package/lib/utils/process-command.js +3 -1
- package/package.json +18 -13
- package/lib/config/utils.js +0 -32
- package/lib/main.js +0 -20
- package/lib/utils/warn-if-outdated.js +0 -78
|
@@ -39,19 +39,14 @@ async function choosePackageManager(context, prompt) {
|
|
|
39
39
|
name: 'packageManager',
|
|
40
40
|
message: 'Which packager would you like to use?',
|
|
41
41
|
type: 'list',
|
|
42
|
-
choices: [{ name: 'npm' }, { name: 'yarn' }]
|
|
42
|
+
choices: [{ name: 'npm' }, { name: 'pnpm' }, { name: 'yarn' }]
|
|
43
43
|
}
|
|
44
44
|
])
|
|
45
45
|
).packageManager;
|
|
46
46
|
|
|
47
47
|
const installCmd = context.installCmd || `${packageManager} install`;
|
|
48
48
|
|
|
49
|
-
const
|
|
50
|
-
npm: 'npx',
|
|
51
|
-
yarn: 'yarn'
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const localCmd = context.localCmd || `${runners[packageManager]} gasket local`;
|
|
49
|
+
const localCmd = context.localCmd || `${packageManager} run local`;
|
|
55
50
|
|
|
56
51
|
Object.assign(context, {
|
|
57
52
|
packageManager,
|
|
@@ -61,42 +56,54 @@ async function choosePackageManager(context, prompt) {
|
|
|
61
56
|
}
|
|
62
57
|
|
|
63
58
|
/**
|
|
64
|
-
* Choose your unit test suite
|
|
59
|
+
* Choose your unit test suite and integration test suite
|
|
65
60
|
*
|
|
66
61
|
* @param {CreateContext} context - Create context
|
|
67
62
|
* @param {function} prompt - function to prompt user
|
|
68
63
|
* @returns {Promise} promise
|
|
69
64
|
*/
|
|
70
|
-
async function
|
|
71
|
-
const knownTestPlugins = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
async function chooseTestPlugins(context, prompt) {
|
|
66
|
+
const knownTestPlugins = {
|
|
67
|
+
unit: { mocha: '@gasket/plugin-mocha', jest: '@gasket/plugin-jest' },
|
|
68
|
+
integration: { cypress: '@gasket/plugin-cypress' }
|
|
69
|
+
};
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
const testTypes = ['unit', 'integration'];
|
|
72
|
+
const testPlugins = [];
|
|
73
|
+
|
|
74
|
+
if (!('testPlugins' in context)) {
|
|
75
|
+
for (const type of testTypes) {
|
|
76
|
+
if (type + 'TestSuite' in context) {
|
|
77
|
+
const testSuite = knownTestPlugins[type][context[type + 'TestSuite']];
|
|
78
|
+
if (testSuite) testPlugins.push(testSuite);
|
|
79
|
+
} else {
|
|
80
|
+
const plugin = await promptForTestPlugin(
|
|
81
|
+
prompt,
|
|
82
|
+
`Choose your ${type} test suite`,
|
|
83
|
+
Object.entries(knownTestPlugins[type]).map(([name, value]) => ({ name, value }))
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (plugin) testPlugins.push(plugin);
|
|
87
|
+
}
|
|
78
88
|
}
|
|
79
89
|
|
|
80
|
-
if (
|
|
81
|
-
({
|
|
82
|
-
{
|
|
83
|
-
name: 'testPlugin',
|
|
84
|
-
message: 'Choose your unit test suite',
|
|
85
|
-
type: 'list',
|
|
86
|
-
choices: [
|
|
87
|
-
{ name: 'none (not recommended)', value: 'none' },
|
|
88
|
-
{ name: 'mocha + nyc + sinon + chai', value: '@gasket/plugin-mocha' },
|
|
89
|
-
{ name: 'jest', value: '@gasket/plugin-jest' },
|
|
90
|
-
{ name: 'cypress', value: '@gasket/plugin-cypress' }
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
]));
|
|
90
|
+
if (testPlugins.length > 0) {
|
|
91
|
+
Object.assign(context, { testPlugins });
|
|
94
92
|
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
async function promptForTestPlugin(prompt, message, choices) {
|
|
97
|
+
const { testPlugin } = await prompt([
|
|
98
|
+
{
|
|
99
|
+
name: 'testPlugin',
|
|
100
|
+
message,
|
|
101
|
+
type: 'list',
|
|
102
|
+
choices: [{ name: 'none', value: 'none' }, ...choices]
|
|
98
103
|
}
|
|
99
|
-
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
return testPlugin !== 'none' ? testPlugin : null;
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
/**
|
|
@@ -126,7 +133,7 @@ async function allowExtantOverwriting(context, prompt) {
|
|
|
126
133
|
export const questions = [
|
|
127
134
|
chooseAppDescription,
|
|
128
135
|
choosePackageManager,
|
|
129
|
-
|
|
136
|
+
chooseTestPlugins,
|
|
130
137
|
allowExtantOverwriting
|
|
131
138
|
];
|
|
132
139
|
|
|
@@ -136,8 +143,8 @@ export const questions = [
|
|
|
136
143
|
* @param {CreateContext} context - Create context
|
|
137
144
|
* @returns {Promise} promise
|
|
138
145
|
*/
|
|
139
|
-
async function globalPrompts(
|
|
140
|
-
const prompt = context.prompts ? inquirer.
|
|
146
|
+
async function globalPrompts({ context }) {
|
|
147
|
+
const prompt = context.prompts ? inquirer.createPromptModule() : () => ({});
|
|
141
148
|
for (var fn of questions) {
|
|
142
149
|
await fn(context, prompt);
|
|
143
150
|
}
|
|
@@ -6,7 +6,7 @@ import action from '../action-wrapper.js';
|
|
|
6
6
|
* @param {CreateContext} context - Create context
|
|
7
7
|
* @returns {Promise} promise
|
|
8
8
|
*/
|
|
9
|
-
async function installModules(
|
|
9
|
+
async function installModules({ context }) {
|
|
10
10
|
const { pkgManager } = context;
|
|
11
11
|
|
|
12
12
|
await pkgManager.install();
|
|
@@ -7,7 +7,7 @@ import action from '../action-wrapper.js';
|
|
|
7
7
|
* @param {Spinner} spinner - Spinner
|
|
8
8
|
* @returns {Promise} promise
|
|
9
9
|
*/
|
|
10
|
-
async function linkModules(
|
|
10
|
+
async function linkModules({ context, spinner }) {
|
|
11
11
|
const { pkgLinks, pkgManager } = context;
|
|
12
12
|
|
|
13
13
|
if (pkgLinks && pkgLinks.length) {
|
|
@@ -5,13 +5,13 @@ import { default as gasketUtils } from '@gasket/utils';
|
|
|
5
5
|
import { mkdtemp } from 'fs/promises';
|
|
6
6
|
import { createRequire } from 'module';
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
|
+
const hasVersionOrTag = /@([\^~]?\d+\.\d+\.\d+(?:-[\d\w.-]+)?|[\^~]?\d+\.\d+\.\d+|[a-zA-Z]+|file:.+)$/;
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* loadPresets - Load presets to temp directory
|
|
11
|
-
* @param {null} _ - no input
|
|
12
12
|
* @param {CreateContext} context - Create context
|
|
13
13
|
*/
|
|
14
|
-
async function loadPresets(
|
|
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
|
|
|
@@ -20,10 +20,10 @@ async function loadPresets(_, context) {
|
|
|
20
20
|
packageManager: context.packageManager,
|
|
21
21
|
dest: tmpDir
|
|
22
22
|
});
|
|
23
|
-
const pkgVerb = pkgManager.
|
|
23
|
+
const pkgVerb = pkgManager.manager === 'npm' ? 'install' : 'add';
|
|
24
24
|
|
|
25
25
|
const remotePresets = context.rawPresets.map(async preset => {
|
|
26
|
-
const parts =
|
|
26
|
+
const parts = hasVersionOrTag.test(preset) && preset.split('@').filter(Boolean);
|
|
27
27
|
const name = parts ? `@${parts[0]}` : preset;
|
|
28
28
|
const version = parts ? `@${parts[1]}` : '@latest';
|
|
29
29
|
|
|
@@ -36,9 +36,9 @@ async function loadPresets(_, context) {
|
|
|
36
36
|
// We can't specify the cwd for the import, so we need to use the full path
|
|
37
37
|
// expects type:module & "main": "lib/fullpath.js"
|
|
38
38
|
const mod = await import(`${modPath}/${name}/${pkgFile.main}`);
|
|
39
|
-
return mod.default || mod;
|
|
39
|
+
return mod.default?.default || mod.default || mod;
|
|
40
40
|
} catch (err) {
|
|
41
|
-
throw new Error(`Failed to install preset ${name}${version}`);
|
|
41
|
+
throw new Error(`Failed to install preset ${name}${version}: ${err.message}`);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ async function loadPresets(_, context) {
|
|
|
48
48
|
await pkgManager.exec(pkgVerb, [localPresetPath]);
|
|
49
49
|
const pkgFile = require(path.join(localPresetPath, 'package.json'));
|
|
50
50
|
const mod = await import(`${modPath}/${pkgFile.name}/${pkgFile.main}`);
|
|
51
|
-
return mod.default || mod;
|
|
51
|
+
return mod.default?.default || mod.default || mod;
|
|
52
52
|
} catch (err) {
|
|
53
53
|
throw new Error(`Failed to install local preset ${localPresetPath}`);
|
|
54
54
|
}
|
|
@@ -10,7 +10,7 @@ import action from '../action-wrapper.js';
|
|
|
10
10
|
* @param {Spinner} spinner - Spinner
|
|
11
11
|
* @returns {Promise} promise
|
|
12
12
|
*/
|
|
13
|
-
async function mkDir(
|
|
13
|
+
async function mkDir({ context, spinner }) {
|
|
14
14
|
const { dest, relDest, extant, destOverride } = context;
|
|
15
15
|
|
|
16
16
|
// At this point, either the directory does not exist, or the user has
|
|
@@ -4,10 +4,11 @@ import { runShellCommand } from '@gasket/utils';
|
|
|
4
4
|
/**
|
|
5
5
|
* Executes the `postCreate` hook for all registered plugins.
|
|
6
6
|
*
|
|
7
|
+
* @param {GasketEngine} gasket - Gasket API
|
|
7
8
|
* @param {CreateContext} context - Create context
|
|
8
9
|
* @returns {Promise} promise
|
|
9
10
|
*/
|
|
10
|
-
async function postCreateHooks(gasket, context) {
|
|
11
|
+
async function postCreateHooks({ gasket, context }) {
|
|
11
12
|
const { dest } = context;
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -5,7 +5,7 @@ import action from '../action-wrapper.js';
|
|
|
5
5
|
* @param {Gasket} gasket - Preset gasket instance
|
|
6
6
|
* @param {CreateContext} context - Create context
|
|
7
7
|
*/
|
|
8
|
-
async function presetConfigHooks(gasket, context) {
|
|
8
|
+
async function presetConfigHooks({ gasket, context }) {
|
|
9
9
|
const config = await gasket.execWaterfall('presetConfig', context);
|
|
10
10
|
Object.assign(context.presetConfig, config);
|
|
11
11
|
}
|
|
@@ -6,7 +6,7 @@ import action from '../action-wrapper.js';
|
|
|
6
6
|
* @param {Gasket} gasket - Preset gasket instance
|
|
7
7
|
* @param {CreateContext} context - Create context
|
|
8
8
|
*/
|
|
9
|
-
async function presetPromptHooks(gasket, context) {
|
|
9
|
+
async function presetPromptHooks({ gasket, context }) {
|
|
10
10
|
const prompt = context.prompts ? inquirer.createPromptModule() : () => ({});
|
|
11
11
|
|
|
12
12
|
const nextContext = await gasket.execWaterfall('presetPrompt', context, { prompt });
|
|
@@ -63,7 +63,7 @@ function buildReport(context) {
|
|
|
63
63
|
|
|
64
64
|
* @param {CreateContext} context - Create context
|
|
65
65
|
*/
|
|
66
|
-
async function printReport(
|
|
66
|
+
async function printReport({ context }) {
|
|
67
67
|
const report = buildReport(context);
|
|
68
68
|
const { warnings, errors } = context;
|
|
69
69
|
|
|
@@ -27,10 +27,11 @@ async function execPluginPrompts(gasket, context) {
|
|
|
27
27
|
* Executes the `prompt` hook for all registered plugins.
|
|
28
28
|
* Adds `prompt` util function for prompting features.
|
|
29
29
|
*
|
|
30
|
+
* @param {GasketEngine} gasket - Gasket API
|
|
30
31
|
* @param {CreateContext} context - Create context
|
|
31
32
|
* @returns {Promise} promise
|
|
32
33
|
*/
|
|
33
|
-
async function promptHooks(gasket, context) {
|
|
34
|
+
async function promptHooks({ gasket, context }) {
|
|
34
35
|
//
|
|
35
36
|
// Because `execPluginPrompts` is recursively, we need to start it
|
|
36
37
|
// with the processPlugins and presets from our initial context
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import action from '../action-wrapper.js';
|
|
2
2
|
import { ConfigBuilder } from '../config-builder.js';
|
|
3
3
|
import { default as gasketUtils } from '@gasket/utils';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const { dependencies } = require('../../../package.json');
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Initializes the ConfigBuilder builder and adds to context.
|
|
@@ -8,16 +11,22 @@ import { default as gasketUtils } from '@gasket/utils';
|
|
|
8
11
|
* @param {CreateContext} context - Create context
|
|
9
12
|
* @returns {Promise} promise
|
|
10
13
|
*/
|
|
11
|
-
async function setupPkg(
|
|
14
|
+
async function setupPkg({ context }) {
|
|
12
15
|
const { appName, appDescription, warnings } = context;
|
|
13
16
|
|
|
14
17
|
const pkg = ConfigBuilder.createPackageJson({
|
|
15
18
|
name: appName,
|
|
16
19
|
version: '0.0.0',
|
|
17
20
|
description: appDescription,
|
|
18
|
-
type:
|
|
21
|
+
type: 'module'
|
|
19
22
|
}, { warnings });
|
|
20
23
|
|
|
24
|
+
// Add critical dependencies
|
|
25
|
+
pkg.add('dependencies', {
|
|
26
|
+
'@gasket/core': dependencies['@gasket/core'],
|
|
27
|
+
'@gasket/utils': dependencies['@gasket/utils']
|
|
28
|
+
});
|
|
29
|
+
|
|
21
30
|
const pkgManager = new gasketUtils.PackageManager(context);
|
|
22
31
|
Object.assign(context, { pkg, pkgManager });
|
|
23
32
|
}
|
|
@@ -88,9 +88,9 @@ function cleanupFields(config) {
|
|
|
88
88
|
* @param {CreateContext} context - Create context
|
|
89
89
|
* @returns {Promise} promise
|
|
90
90
|
*/
|
|
91
|
-
async function writeGasketConfig(
|
|
92
|
-
const { dest, gasketConfig, generatedFiles } = context;
|
|
93
|
-
const fileName =
|
|
91
|
+
async function writeGasketConfig({ context }) {
|
|
92
|
+
const { dest, gasketConfig, generatedFiles, typescript } = context;
|
|
93
|
+
const fileName = typescript ? 'gasket.ts' : 'gasket.js';
|
|
94
94
|
const filePath = path.join(dest, fileName);
|
|
95
95
|
const plugins = gasketConfig.fields.plugins;
|
|
96
96
|
const assignments = gasketConfig.fields.injectionAssignments || null;
|
|
@@ -98,6 +98,7 @@ async function writeGasketConfig(gasket, context) {
|
|
|
98
98
|
gasketConfig.fields.plugins = 'PLUGIN_REPLACE';
|
|
99
99
|
|
|
100
100
|
let contents = '';
|
|
101
|
+
if (typescript) contents += `import type { GasketConfigDefinition } from '@gasket/core';\n`;
|
|
101
102
|
contents += `import { makeGasket } from '@gasket/core';\n`;
|
|
102
103
|
contents += writeImports(gasketConfig.fields.pluginImports);
|
|
103
104
|
contents += writeImports(gasketConfig.fields.imports);
|
|
@@ -105,8 +106,9 @@ async function writeGasketConfig(gasket, context) {
|
|
|
105
106
|
createInjectionAssignments(gasketConfig.fields, assignments);
|
|
106
107
|
cleanupFields(gasketConfig);
|
|
107
108
|
|
|
108
|
-
const pluginImports = `[\n${writePluginImports(plugins)}\n
|
|
109
|
-
|
|
109
|
+
const pluginImports = `[\n${writePluginImports(plugins)}\n ]`;
|
|
110
|
+
const typeCoercion = typescript ? ' as GasketConfigDefinition' : '';
|
|
111
|
+
contents += `\nexport default makeGasket(${JSON5.stringify(gasketConfig.fields, null, 2)}${typeCoercion});\n`;
|
|
110
112
|
contents = contents.replace('\'PLUGIN_REPLACE\'', pluginImports);
|
|
111
113
|
contents = replaceInjectionAssignments(contents, assignments);
|
|
112
114
|
|
|
@@ -6,10 +6,9 @@ import action from '../action-wrapper.js';
|
|
|
6
6
|
* Writes the contents of `pkg` to the app's package.json.
|
|
7
7
|
*
|
|
8
8
|
* @param {CreateContext} context - Create context
|
|
9
|
-
* @param {Boolean} update - Is an update step
|
|
10
9
|
* @returns {Promise} promise
|
|
11
10
|
*/
|
|
12
|
-
async function writePkg(
|
|
11
|
+
async function writePkg({ context }) {
|
|
13
12
|
const { dest, pkg, generatedFiles } = context;
|
|
14
13
|
const fileName = 'package.json';
|
|
15
14
|
const filePath = path.join(dest, fileName);
|
|
@@ -18,5 +17,3 @@ async function writePkg(gasket, context) {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export default action('Write package.json', writePkg);
|
|
21
|
-
|
|
22
|
-
export const writePkgUpdate = action('Update package.json', writePkg);
|
|
@@ -376,9 +376,12 @@ export class ConfigBuilder {
|
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
// If a prerelease version, strip the range prefix
|
|
380
|
+
const version = ver.includes('-') ? ver.replace(/^[\^~]/, '') : ver;
|
|
381
|
+
|
|
379
382
|
const blameId = `${key}.${dep}`;
|
|
380
383
|
if (!prev) {
|
|
381
|
-
existing[dep] =
|
|
384
|
+
existing[dep] = version;
|
|
382
385
|
setBlame(blameId);
|
|
383
386
|
return;
|
|
384
387
|
}
|
|
@@ -386,7 +389,7 @@ export class ConfigBuilder {
|
|
|
386
389
|
const blamed = this.blame.get(blameId);
|
|
387
390
|
const forced = this.force.has(blameId);
|
|
388
391
|
|
|
389
|
-
if (prev ===
|
|
392
|
+
if (prev === version) {
|
|
390
393
|
if (forced) return;
|
|
391
394
|
if (force) {
|
|
392
395
|
setBlame(blameId);
|
|
@@ -398,21 +401,21 @@ export class ConfigBuilder {
|
|
|
398
401
|
|
|
399
402
|
const prevName = blamed.join(', ');
|
|
400
403
|
if (!forced) {
|
|
401
|
-
const newer = force ?
|
|
402
|
-
const overridden = newer ===
|
|
404
|
+
const newer = force ? version : this.tryGetNewerRange(prev, version);
|
|
405
|
+
const overridden = newer === version;
|
|
403
406
|
if (overridden) {
|
|
404
|
-
existing[dep] =
|
|
407
|
+
existing[dep] = version;
|
|
405
408
|
setBlame(blameId);
|
|
406
409
|
}
|
|
407
410
|
}
|
|
408
411
|
|
|
409
|
-
if (!semver.validRange(prev) || !semver.validRange(
|
|
412
|
+
if (!semver.validRange(prev) || !semver.validRange(version) || !semver.intersects(prev, version)) {
|
|
410
413
|
let forceMsg = force ? '(forced)' : '';
|
|
411
414
|
forceMsg = forced && force ? '(cannot be forced)' : forceMsg;
|
|
412
415
|
this.warn(`
|
|
413
416
|
Conflicting versions for ${dep} in "${key}":
|
|
414
417
|
- ${prev} provided by ${prevName} ${forced && '(forced)' || ''}
|
|
415
|
-
- ${
|
|
418
|
+
- ${version} provided by ${name} ${forceMsg}
|
|
416
419
|
Using ${existing[dep]}, but this may cause unexpected behavior.
|
|
417
420
|
`);
|
|
418
421
|
}
|
|
@@ -83,7 +83,7 @@ function flatten(acc, values) {
|
|
|
83
83
|
*
|
|
84
84
|
* @property {String} appDescription - Description of app
|
|
85
85
|
* @property {Boolean} gitInit - Should a git repo be initialized and first commit
|
|
86
|
-
* @property {String}
|
|
86
|
+
* @property {String} testPlugins - Array of testing plugins
|
|
87
87
|
* @property {String} packageManager - Which package manager to use (Default: 'npm')
|
|
88
88
|
* @property {String} installCmd - Derived install command (Default: 'npm install')
|
|
89
89
|
* @property {String} localCmd - Derived local run command (Default: 'npx gasket local')
|
|
@@ -170,7 +170,8 @@ export function makeCreateContext(argv = [], options = {}) {
|
|
|
170
170
|
presets: [],
|
|
171
171
|
presetConfig: {
|
|
172
172
|
plugins: []
|
|
173
|
-
}
|
|
173
|
+
},
|
|
174
|
+
readme: []
|
|
174
175
|
});
|
|
175
176
|
|
|
176
177
|
readConfig(context, { config, configFile });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
|
|
3
|
+
/** @type {import('../index').Readme} */
|
|
4
|
+
export default class Readme {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.markdown = [];
|
|
7
|
+
this.links = [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
addNewLine() {
|
|
11
|
+
this.markdown.push('');
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
heading(content, level = 2) {
|
|
16
|
+
this.markdown.push(`${'#'.repeat(level)} ${content}`);
|
|
17
|
+
return this.addNewLine();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
subHeading(content) {
|
|
21
|
+
return this.heading(content, 3);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
content(content) {
|
|
25
|
+
this.markdown.push(content);
|
|
26
|
+
return this.addNewLine();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
list(items) {
|
|
30
|
+
this.markdown.push(...items.map(item => `- ${item}`));
|
|
31
|
+
return this.addNewLine();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
link(content, href) {
|
|
35
|
+
this.links.push(`[${content}]: ${href}`);
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
codeBlock(content, syntax = '') {
|
|
40
|
+
this.markdown.push(`\`\`\`${syntax}`);
|
|
41
|
+
this.markdown.push(content);
|
|
42
|
+
this.markdown.push('```');
|
|
43
|
+
return this.addNewLine();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async markdownFile(path) {
|
|
47
|
+
const content = await readFile(path, 'utf8');
|
|
48
|
+
this.markdown.push(content);
|
|
49
|
+
return this.addNewLine();
|
|
50
|
+
}
|
|
51
|
+
}
|
package/lib/utils/index.js
CHANGED
package/lib/utils/logo.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export const logo = `
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
█▀▀█
|
|
7
|
-
█▄▄█
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
▄▄▄▄████▀▀█▄
|
|
3
|
+
▄████▀▀▀▀▀▀█▄▄██
|
|
4
|
+
███▀ ▄▄▄▄▄ ▀██▌ ▄▄▄
|
|
5
|
+
▄███ ███▀▀▀▀██ ██ ██ ██
|
|
6
|
+
█▀▀█ ██▌ ▐█▌ ▄▀▀▀█▄ ▄█▀▀▀▄ ██ ▐██▀ ▄█▀▀█▄ ▀██▀▀
|
|
7
|
+
█▄▄█ ██▌ ▀▀██ ▐█▌ ▄▄▄▄██ ▀▀█▄▄▄ █████ ██▄▄██ ██
|
|
8
|
+
▀███ ███▄▄▄▄██ ██ ▀▄▄▄▀█▄ ▀▄▄▄█▀ ▄██▄ ██▄ ▀█▄▄▄▄ ▀█▄▄
|
|
9
|
+
███▄ ▀▀▀ ▀▀ ▄██▌
|
|
10
|
+
▀████▄▄▄▄▄▄█▀▀██
|
|
11
|
+
▀▀▀▀████▄▄█▀
|
|
12
12
|
`;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { processArgs
|
|
2
|
+
import { processArgs } from './process-args.js';
|
|
3
|
+
import { processOptions } from './process-options.js';
|
|
4
|
+
import { createOption } from './create-option.js';
|
|
3
5
|
const program = new Command();
|
|
4
6
|
|
|
5
7
|
/**
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-gasket-app",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "starter pack for creating a gasket app",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"create-gasket-app": "./lib/index.js"
|
|
8
8
|
},
|
|
9
|
+
"main": "lib/index.js",
|
|
10
|
+
"types": "lib/index.d.ts",
|
|
9
11
|
"files": [
|
|
10
12
|
"lib"
|
|
11
13
|
],
|
|
12
|
-
"type": "module",
|
|
13
14
|
"scripts": {
|
|
14
15
|
"lint": "eslint .",
|
|
15
16
|
"lint:fix": "npm run lint -- --fix",
|
|
16
17
|
"test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
|
|
17
|
-
"test:watch": "
|
|
18
|
+
"test:watch": "npm run test -- --watch",
|
|
18
19
|
"test:coverage": "jest --coverage",
|
|
19
20
|
"posttest": "npm run lint"
|
|
20
21
|
},
|
|
@@ -32,11 +33,14 @@
|
|
|
32
33
|
},
|
|
33
34
|
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/create-gasket-app",
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@gasket/core": "
|
|
36
|
-
"@gasket/
|
|
37
|
-
"@gasket/plugin-
|
|
38
|
-
"@gasket/plugin-
|
|
39
|
-
"@gasket/
|
|
36
|
+
"@gasket/core": "7.0.0",
|
|
37
|
+
"@gasket/plugin-command": "7.0.0",
|
|
38
|
+
"@gasket/plugin-docs": "7.0.0",
|
|
39
|
+
"@gasket/plugin-docusaurus": "7.0.0",
|
|
40
|
+
"@gasket/plugin-git": "7.0.0",
|
|
41
|
+
"@gasket/plugin-logger": "7.0.0",
|
|
42
|
+
"@gasket/plugin-metadata": "7.0.0",
|
|
43
|
+
"@gasket/utils": "7.0.0",
|
|
40
44
|
"commander": "^12.0.0",
|
|
41
45
|
"deepmerge": "^4.3.1",
|
|
42
46
|
"glob": "^8.1.0",
|
|
@@ -51,14 +55,15 @@
|
|
|
51
55
|
"untildify": "^4.0.0"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
58
|
+
"@types/inquirer": "^9.0.7",
|
|
54
59
|
"cross-env": "^7.0.3",
|
|
55
60
|
"diagnostics": "^2.0.2",
|
|
56
61
|
"dotenv": "^16.4.5",
|
|
57
62
|
"eslint": "^8.56.0",
|
|
58
|
-
"eslint-config-godaddy": "^7.
|
|
59
|
-
"eslint-plugin-jest": "^
|
|
63
|
+
"eslint-config-godaddy": "^7.1.1",
|
|
64
|
+
"eslint-plugin-jest": "^28.6.0",
|
|
60
65
|
"eslint-plugin-json": "^3.1.0",
|
|
61
|
-
"eslint-plugin-unicorn": "^
|
|
66
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
62
67
|
"jest": "^29.7.0"
|
|
63
68
|
},
|
|
64
69
|
"eslintConfig": {
|
|
@@ -79,5 +84,5 @@
|
|
|
79
84
|
"jest": {
|
|
80
85
|
"transform": {}
|
|
81
86
|
},
|
|
82
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "0d353a2d81f967662947ae4ed2cd949505417dab"
|
|
83
88
|
}
|
package/lib/config/utils.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { default as diagnostics } from 'diagnostics';
|
|
2
|
-
const debug = diagnostics('gasket:cli:config:utils');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns specified env option if set or appropriate fallback
|
|
6
|
-
*
|
|
7
|
-
* @param {Object} options - CLI Option
|
|
8
|
-
* @param {string} commandId - Name of the command
|
|
9
|
-
* @param {function} warn - Warning logger
|
|
10
|
-
* @returns {string} environment
|
|
11
|
-
*/
|
|
12
|
-
export function getEnvironment(options, commandId, warn) {
|
|
13
|
-
if (options.env) {
|
|
14
|
-
debug('Environment was passed through command line options', options.env);
|
|
15
|
-
return options.env;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// special snowflake case to match up `local` env with command unless set
|
|
19
|
-
if (commandId === 'local') {
|
|
20
|
-
debug('Environment defaulting to `local` due to `local` command');
|
|
21
|
-
return 'local';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const { NODE_ENV } = process.env;
|
|
25
|
-
if (NODE_ENV) {
|
|
26
|
-
warn(`No env specified, falling back to NODE_ENV: "${ NODE_ENV }".`);
|
|
27
|
-
return NODE_ENV;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
warn('No env specified, falling back to "development".');
|
|
31
|
-
return 'development';
|
|
32
|
-
}
|
package/lib/main.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { fork } from 'child_process';
|
|
2
|
-
import { createRequire } from 'module';
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Executes the @gasket/cli passing through the create command and any arguments.
|
|
7
|
-
*
|
|
8
|
-
* @param {string[]} args - create command arguments
|
|
9
|
-
* @returns {ChildProcess} process
|
|
10
|
-
*/
|
|
11
|
-
export default function main(...args) {
|
|
12
|
-
// import.meta.resolve is not available in Jest without babel transform
|
|
13
|
-
const gasketBin = require.resolve('@gasket/cli/bin/run');
|
|
14
|
-
|
|
15
|
-
return fork(
|
|
16
|
-
gasketBin,
|
|
17
|
-
['create', ...args],
|
|
18
|
-
{ stdio: 'inherit', stdin: 'inherit', stderr: 'inherit' }
|
|
19
|
-
);
|
|
20
|
-
}
|