@emulsify/cli 2.4.1 → 2.5.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 +10 -3
- package/dist/handlers/cacheClear.js +5 -6
- package/dist/handlers/componentCreate.js +8 -8
- package/dist/handlers/componentEjectTemplates.js +22 -20
- package/dist/handlers/componentInstall.js +74 -69
- package/dist/handlers/componentList.js +51 -4
- package/dist/handlers/hofs/withEmulsifySystem.js +3 -1
- package/dist/handlers/hofs/withSession.js +8 -0
- package/dist/handlers/init.js +144 -132
- package/dist/handlers/systemCreate.js +31 -25
- package/dist/handlers/systemDetach.js +5 -5
- package/dist/handlers/systemInstall.js +59 -53
- package/dist/handlers/systemList.js +13 -2
- package/dist/index.js +57 -34
- package/dist/lib/log.js +21 -24
- package/dist/lib/rootHelp.js +30 -5
- package/dist/lib/session.js +141 -0
- package/dist/schemas/system.json +5 -2
- package/dist/schemas/variant.json +8 -5
- package/dist/util/cache/cloneIntoCache.js +25 -8
- package/dist/util/cache/getCachedItemPath.js +3 -1
- package/dist/util/fs/writeToJsonFile.js +4 -1
- package/dist/util/getGitRepoNameFromUrl.js +21 -10
- package/dist/util/getNonInteractiveGitEnvironment.js +1 -1
- package/dist/util/platform/getInitSuccessMessageForPlatform.js +15 -9
- package/dist/util/project/componentNpmDependencies.js +169 -0
- package/dist/util/project/componentNpmManifest.js +164 -0
- package/dist/util/project/generateComponent.js +98 -39
- package/dist/util/project/installComponentNpmDependencies.js +197 -0
- package/dist/util/project/installDependencies.js +10 -3
- package/dist/util/project/resolveComponentTemplate.js +11 -1
- package/dist/util/prompt/index.js +21 -6
- package/dist/util/system/validateSystemConfig.js +51 -13
- package/package.json +16 -18
- package/dist/handlers/hofs/withProgressBar.js +0 -10
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { dirname, join } from 'path';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
-
import { confirm,
|
|
3
|
+
import { confirm, select, text } from '@clack/prompts';
|
|
4
4
|
import { EMULSIFY_PROJECT_CONFIG_FILE, EMULSIFY_SYSTEM_CONFIG_FILE, EMULSIFY_PROJECT_HOOK_FOLDER, EMULSIFY_PROJECT_HOOK_SYSTEM_INSTALL, } from '../lib/constants.js';
|
|
5
5
|
import log from '../lib/log.js';
|
|
6
6
|
import CliError from '../lib/CliError.js';
|
|
7
|
+
import { note } from '../lib/session.js';
|
|
7
8
|
import getAvailableSystems from '../util/system/getAvailableSystems.js';
|
|
8
9
|
import getGitRepoNameFromUrl from '../util/getGitRepoNameFromUrl.js';
|
|
9
10
|
import cloneIntoCache from '../util/cache/cloneIntoCache.js';
|
|
10
11
|
import getCachedItemCheckout from '../util/cache/getCachedItemCheckout.js';
|
|
11
12
|
import getRepositoryLatestTag from '../util/getRepositoryLatestTag.js';
|
|
12
13
|
import installComponentFromCache from '../util/project/installComponentFromCache.js';
|
|
14
|
+
import { applyComponentNpmInstall, confirmComponentNpmInstall, formatAddedNpmPackages, getComponentNpmInstallReview, prepareComponentNpmInstall, } from '../util/project/installComponentNpmDependencies.js';
|
|
13
15
|
import installGeneralAssetsFromCache from '../util/project/installGeneralAssetsFromCache.js';
|
|
14
16
|
import getJsonFromCachedFile from '../util/cache/getJsonFromCachedFile.js';
|
|
15
17
|
import setEmulsifyConfig from '../util/project/setEmulsifyConfig.js';
|
|
@@ -22,16 +24,13 @@ import { runPrompt } from '../util/prompt/index.js';
|
|
|
22
24
|
import buildSystemInstallPlan, { selectSystemComponents, } from '../util/system/buildSystemInstallPlan.js';
|
|
23
25
|
const MISSING_SYSTEM_SOURCE_ERROR = 'No component system source was provided. Pass a built-in system name as the positional argument, or pass both --repository <repository> and --checkout <branch, tag, or commit>.';
|
|
24
26
|
const INVALID_SYSTEM_SOURCE_ERROR = 'Unable to resolve the requested component system source. Pass a valid built-in system name as the positional argument, or pass both --repository <repository> and --checkout <branch, tag, or commit>.';
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return
|
|
27
|
+
const CANCELLED_SUMMARY = 'System install cancelled.';
|
|
28
|
+
const DECLINED_SUMMARY = 'System install cancelled. No project files were changed.';
|
|
29
|
+
function formatWizardStep(step, total) {
|
|
30
|
+
return total ? `Step ${step} of ${total}` : `Step ${step}`;
|
|
29
31
|
}
|
|
30
32
|
function showWizardStep(step, total) {
|
|
31
|
-
log('info',
|
|
32
|
-
}
|
|
33
|
-
function formatChoice(label, description) {
|
|
34
|
-
return `${label.padEnd(22)}${description}`;
|
|
33
|
+
log('info', formatWizardStep(step, total));
|
|
35
34
|
}
|
|
36
35
|
function pluralize(count, singular, plural = `${singular}s`) {
|
|
37
36
|
return `${count} ${count === 1 ? singular : plural}`;
|
|
@@ -78,8 +77,8 @@ function formatRepositorySource(repository) {
|
|
|
78
77
|
}
|
|
79
78
|
function validateRepositoryInput(repository) {
|
|
80
79
|
try {
|
|
81
|
-
return getGitRepoNameFromUrl(repository.trim())
|
|
82
|
-
?
|
|
80
|
+
return getGitRepoNameFromUrl((repository || '').trim())
|
|
81
|
+
? undefined
|
|
83
82
|
: 'Enter a Git repository with a recognizable name.';
|
|
84
83
|
}
|
|
85
84
|
catch (error) {
|
|
@@ -131,21 +130,21 @@ async function promptForSystemInstallChoice() {
|
|
|
131
130
|
showWizardStep(1);
|
|
132
131
|
return select({
|
|
133
132
|
message: 'Which system?',
|
|
134
|
-
|
|
133
|
+
options: [
|
|
135
134
|
...availableSystems.map((reference) => ({
|
|
136
|
-
name: formatChoice(reference.label, reference.description),
|
|
137
135
|
value: { kind: 'built-in', reference },
|
|
138
|
-
|
|
136
|
+
label: reference.label,
|
|
137
|
+
hint: reference.description,
|
|
139
138
|
})),
|
|
140
139
|
{
|
|
141
|
-
name: formatChoice('Bring your own', 'Install from a git repository you control.'),
|
|
142
140
|
value: { kind: 'custom' },
|
|
143
|
-
|
|
141
|
+
label: 'Bring your own',
|
|
142
|
+
hint: 'Install from a git repository you control.',
|
|
144
143
|
},
|
|
145
|
-
new Separator('────────────'),
|
|
146
144
|
{
|
|
147
|
-
name: 'Cancel',
|
|
148
145
|
value: { kind: 'cancel' },
|
|
146
|
+
label: 'Cancel',
|
|
147
|
+
hint: 'Leave this project unchanged.',
|
|
149
148
|
},
|
|
150
149
|
],
|
|
151
150
|
});
|
|
@@ -153,7 +152,6 @@ async function promptForSystemInstallChoice() {
|
|
|
153
152
|
nonInteractive: { error: MISSING_SYSTEM_SOURCE_ERROR },
|
|
154
153
|
});
|
|
155
154
|
if (selectedSource.kind === 'cancel') {
|
|
156
|
-
log('info', 'System install cancelled.');
|
|
157
155
|
return;
|
|
158
156
|
}
|
|
159
157
|
return selectedSource;
|
|
@@ -162,8 +160,8 @@ async function promptForCustomRepository(step, total) {
|
|
|
162
160
|
return runPrompt({
|
|
163
161
|
prompt: () => {
|
|
164
162
|
showWizardStep(step, total);
|
|
165
|
-
return
|
|
166
|
-
message: 'Repository URL or local path
|
|
163
|
+
return text({
|
|
164
|
+
message: 'Repository URL or local path',
|
|
167
165
|
validate: validateRepositoryInput,
|
|
168
166
|
});
|
|
169
167
|
},
|
|
@@ -176,9 +174,11 @@ async function promptForCustomCheckout(step, total) {
|
|
|
176
174
|
return runPrompt({
|
|
177
175
|
prompt: () => {
|
|
178
176
|
showWizardStep(step, total);
|
|
179
|
-
return
|
|
180
|
-
message: 'Checkout (branch, tag, or commit)
|
|
181
|
-
validate: (value) => value.trim().length > 0
|
|
177
|
+
return text({
|
|
178
|
+
message: 'Checkout (branch, tag, or commit)',
|
|
179
|
+
validate: (value) => (value || '').trim().length > 0
|
|
180
|
+
? undefined
|
|
181
|
+
: 'Enter a branch, tag, or commit.',
|
|
182
182
|
});
|
|
183
183
|
},
|
|
184
184
|
nonInteractive: {
|
|
@@ -222,20 +222,20 @@ async function promptForVariantChoice(variants, projectPlatform, systemName, non
|
|
|
222
222
|
message: wizardStep
|
|
223
223
|
? 'Which component set?'
|
|
224
224
|
: `Which ${formatSystemLabel(systemName)} component set should be used?`,
|
|
225
|
-
|
|
225
|
+
options: rankedVariants.map(({ variant, index }) => {
|
|
226
226
|
const componentCount = variant.components.length;
|
|
227
227
|
const requiredCount = variant.components.filter(({ required }) => required === true).length;
|
|
228
|
-
const counts =
|
|
228
|
+
const counts = `${pluralize(componentCount, 'component')}, ${pluralize(requiredCount, 'required component')}`;
|
|
229
229
|
const recommended = recommendedVariants.has(variant)
|
|
230
|
-
? '
|
|
230
|
+
? 'Recommended · '
|
|
231
231
|
: '';
|
|
232
232
|
return {
|
|
233
|
-
name: `${formatPlatformLabel(variant.platform)} (${variant.platform})${recommended}${counts}`,
|
|
234
233
|
value: index,
|
|
235
|
-
|
|
234
|
+
label: `${formatPlatformLabel(variant.platform)} (${variant.platform})`,
|
|
235
|
+
hint: `${recommended}${counts}`,
|
|
236
236
|
};
|
|
237
237
|
}),
|
|
238
|
-
|
|
238
|
+
initialValue: defaultChoice,
|
|
239
239
|
});
|
|
240
240
|
},
|
|
241
241
|
nonInteractive: { error: nonInteractiveError },
|
|
@@ -272,19 +272,19 @@ async function promptForInstallScope(variant, step, total) {
|
|
|
272
272
|
showWizardStep(step, total);
|
|
273
273
|
return select({
|
|
274
274
|
message: 'How much do you want to install?',
|
|
275
|
-
|
|
275
|
+
options: [
|
|
276
276
|
{
|
|
277
|
-
name: formatChoice('Essentials only', pluralize(requiredComponentCount, 'required component')),
|
|
278
277
|
value: false,
|
|
279
|
-
|
|
278
|
+
label: 'Essentials only',
|
|
279
|
+
hint: pluralize(requiredComponentCount, 'required component'),
|
|
280
280
|
},
|
|
281
281
|
{
|
|
282
|
-
name: formatChoice('Everything', pluralize(variant.components.length, 'component')),
|
|
283
282
|
value: true,
|
|
284
|
-
|
|
283
|
+
label: 'Everything',
|
|
284
|
+
hint: pluralize(variant.components.length, 'component'),
|
|
285
285
|
},
|
|
286
286
|
],
|
|
287
|
-
|
|
287
|
+
initialValue: false,
|
|
288
288
|
});
|
|
289
289
|
},
|
|
290
290
|
nonInteractive: {
|
|
@@ -300,7 +300,7 @@ function formatDirectoryDestinations(destinations) {
|
|
|
300
300
|
? destination
|
|
301
301
|
: `${destination}/`));
|
|
302
302
|
}
|
|
303
|
-
export function formatSystemInstallReview(systemLabel, repository, checkout, variant, plan, installAll) {
|
|
303
|
+
export function formatSystemInstallReview(systemLabel, repository, checkout, variant, plan, installAll, npmPackages = []) {
|
|
304
304
|
const continuationIndent = ' ';
|
|
305
305
|
const installRows = [
|
|
306
306
|
`${pluralize(plan.components.length, 'component')} → ${formatDirectoryDestinations(plan.componentParentDestinations)}`,
|
|
@@ -318,15 +318,16 @@ export function formatSystemInstallReview(systemLabel, repository, checkout, var
|
|
|
318
318
|
` Scope ${installAll ? 'Everything' : 'Essentials only'}`,
|
|
319
319
|
` Will install ${installRows[0]}`,
|
|
320
320
|
...installRows.slice(1).map((row) => `${continuationIndent}${row}`),
|
|
321
|
+
` npm packages ${npmPackages.join(`\n${continuationIndent}`) || 'none'}`,
|
|
321
322
|
].join('\n');
|
|
322
323
|
}
|
|
323
324
|
async function promptForInstallConfirmation(review, step, total, accept) {
|
|
324
325
|
showWizardStep(step, total);
|
|
325
|
-
|
|
326
|
+
note(review, 'Review');
|
|
326
327
|
return runPrompt({
|
|
327
328
|
prompt: () => confirm({
|
|
328
329
|
message: 'Install now?',
|
|
329
|
-
|
|
330
|
+
initialValue: true,
|
|
330
331
|
}),
|
|
331
332
|
nonInteractive: {
|
|
332
333
|
error: 'Installation confirmation is required in non-interactive mode. Pass --yes to accept the reviewed installation.',
|
|
@@ -353,7 +354,7 @@ export default async function systemInstall(name, options) {
|
|
|
353
354
|
if (guidedInstall) {
|
|
354
355
|
const source = await promptForSystemInstallChoice();
|
|
355
356
|
if (!source) {
|
|
356
|
-
return;
|
|
357
|
+
return CANCELLED_SUMMARY;
|
|
357
358
|
}
|
|
358
359
|
if (source.kind === 'built-in') {
|
|
359
360
|
const { reference } = source;
|
|
@@ -409,6 +410,8 @@ export default async function systemInstall(name, options) {
|
|
|
409
410
|
}
|
|
410
411
|
}
|
|
411
412
|
catch (e) {
|
|
413
|
+
if (e instanceof CliError)
|
|
414
|
+
throw e;
|
|
412
415
|
console.error('System configuration errors:', e);
|
|
413
416
|
throw new CliError(`The system install failed due to the validation errors reported above. Please fix the errors in the "${systemConf.name}" configuration and try again.`);
|
|
414
417
|
}
|
|
@@ -427,9 +430,6 @@ export default async function systemInstall(name, options) {
|
|
|
427
430
|
throw new CliError('Unable to determine which system checkout was loaded. Retry with --checkout <branch, tag, or commit>.');
|
|
428
431
|
}
|
|
429
432
|
systemLabel ||= formatSystemLabel(systemConf.name);
|
|
430
|
-
if (guidedInstall) {
|
|
431
|
-
log('info', `Loaded ${systemLabel} · ${repo.checkout}.`);
|
|
432
|
-
}
|
|
433
433
|
const projectPlatform = projectConfig.project.platform;
|
|
434
434
|
if (!isPlatform(projectPlatform)) {
|
|
435
435
|
throw new CliError('This project does not declare a supported platform. Set project.platform in project.emulsify.json to none, drupal, or wordpress before installing a component system.');
|
|
@@ -448,20 +448,25 @@ export default async function systemInstall(name, options) {
|
|
|
448
448
|
const installAll = guidedInstall && !options.all
|
|
449
449
|
? await promptForInstallScope(variantConf, ++wizardStep, wizardTotalSteps)
|
|
450
450
|
: options.all === true;
|
|
451
|
-
|
|
451
|
+
const componentsToInstall = selectSystemComponents(variantConf, installAll);
|
|
452
|
+
const projectConfigPath = findFileInCurrentPath(EMULSIFY_PROJECT_CONFIG_FILE);
|
|
453
|
+
const skipNpm = options.skipNpm === true;
|
|
454
|
+
const npmPlan = await prepareComponentNpmInstall(systemConf.name, componentsToInstall, projectConfigPath, skipNpm);
|
|
455
|
+
let acceptedNpm = !skipNpm;
|
|
452
456
|
if (guidedInstall) {
|
|
453
|
-
const projectConfigPath = findFileInCurrentPath(EMULSIFY_PROJECT_CONFIG_FILE);
|
|
454
457
|
if (!projectConfigPath) {
|
|
455
458
|
throw new CliError('Unable to find the Emulsify project configuration for the installation review.');
|
|
456
459
|
}
|
|
457
460
|
const plan = buildSystemInstallPlan(systemConf, variantConf, installAll, projectConfigPath);
|
|
458
|
-
|
|
459
|
-
const confirmed = await promptForInstallConfirmation(formatSystemInstallReview(systemLabel, repo.repository, repo.checkout, variantConf, plan, installAll), ++wizardStep, wizardTotalSteps, options.yes === true);
|
|
461
|
+
const confirmed = await promptForInstallConfirmation(formatSystemInstallReview(systemLabel, repo.repository, repo.checkout, variantConf, plan, installAll, getComponentNpmInstallReview(npmPlan, skipNpm)?.lines), ++wizardStep, wizardTotalSteps, options.yes === true);
|
|
460
462
|
if (!confirmed) {
|
|
461
|
-
|
|
462
|
-
return;
|
|
463
|
+
return DECLINED_SUMMARY;
|
|
463
464
|
}
|
|
464
465
|
}
|
|
466
|
+
else {
|
|
467
|
+
acceptedNpm = await confirmComponentNpmInstall(npmPlan, skipNpm, options.yes === true, `The ${JSON.stringify(systemConf.name)} system`);
|
|
468
|
+
}
|
|
469
|
+
let added = 0;
|
|
465
470
|
try {
|
|
466
471
|
await setEmulsifyConfig({
|
|
467
472
|
system: {
|
|
@@ -482,7 +487,7 @@ export default async function systemInstall(name, options) {
|
|
|
482
487
|
await installComponentFromCache(systemConf, variantConf, component.name, true);
|
|
483
488
|
}
|
|
484
489
|
await installGeneralAssetsFromCache(systemConf, variantConf);
|
|
485
|
-
|
|
490
|
+
added = await applyComponentNpmInstall(npmPlan, acceptedNpm);
|
|
486
491
|
const hookPath = projectConfigPath
|
|
487
492
|
? join(dirname(projectConfigPath), EMULSIFY_PROJECT_HOOK_FOLDER, EMULSIFY_PROJECT_HOOK_SYSTEM_INSTALL)
|
|
488
493
|
: undefined;
|
|
@@ -491,9 +496,10 @@ export default async function systemInstall(name, options) {
|
|
|
491
496
|
}
|
|
492
497
|
}
|
|
493
498
|
catch (e) {
|
|
499
|
+
if (e instanceof CliError)
|
|
500
|
+
throw e;
|
|
494
501
|
throw new CliError(`Unable to install system assets and/or required components: ${String(e)}`);
|
|
495
502
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
: `Successfully installed the ${systemConf.name} system using the ${variantConf.platform} variant.`);
|
|
503
|
+
const summary = `${systemLabel} installed · ${variantConf.platform} component set`;
|
|
504
|
+
return added ? `${summary} · ${formatAddedNpmPackages(added)}` : summary;
|
|
499
505
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { note } from '../lib/session.js';
|
|
2
2
|
import getAvailableSystems from '../util/system/getAvailableSystems.js';
|
|
3
|
+
export function formatSystemList(systems) {
|
|
4
|
+
if (systems.length === 0) {
|
|
5
|
+
return 'No built-in systems are available.';
|
|
6
|
+
}
|
|
7
|
+
const nameWidth = Math.max(...systems.map(({ name }) => name.length));
|
|
8
|
+
return systems
|
|
9
|
+
.map(({ name, repository }) => `${name.padEnd(nameWidth)} ${repository}`)
|
|
10
|
+
.join('\n');
|
|
11
|
+
}
|
|
3
12
|
export default async function systemList() {
|
|
4
|
-
|
|
13
|
+
const systems = await getAvailableSystems();
|
|
14
|
+
note(formatSystemList(systems), 'Built-in systems');
|
|
15
|
+
return `${systems.length} system${systems.length === 1 ? '' : 's'} · install one with emulsify system install`;
|
|
5
16
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { program } from 'commander';
|
|
3
|
-
import
|
|
3
|
+
import withSession from './handlers/hofs/withSession.js';
|
|
4
4
|
import init from './handlers/init.js';
|
|
5
5
|
import systemList from './handlers/systemList.js';
|
|
6
6
|
import systemInstall from './handlers/systemInstall.js';
|
|
@@ -15,12 +15,42 @@ import cacheClear from './handlers/cacheClear.js';
|
|
|
15
15
|
import CliError from './lib/CliError.js';
|
|
16
16
|
import log from './lib/log.js';
|
|
17
17
|
import getRootHelp from './lib/rootHelp.js';
|
|
18
|
-
import getTerminalColors
|
|
19
|
-
import {
|
|
18
|
+
import getTerminalColors from './lib/terminalColors.js';
|
|
19
|
+
import { cancelSession, getSessionFailureSummary, isSessionOpen, startSession, } from './lib/session.js';
|
|
20
|
+
import { isPromptCancelledError } from './util/prompt/index.js';
|
|
20
21
|
import { createRequire } from 'module';
|
|
21
|
-
import boxen from 'boxen';
|
|
22
22
|
const packageInfo = createRequire(import.meta.url)('../package.json');
|
|
23
|
-
|
|
23
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
24
|
+
stream.on('error', (error) => {
|
|
25
|
+
if (error.code !== 'EPIPE')
|
|
26
|
+
throw error;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function renderCommanderError(text) {
|
|
30
|
+
const [summary, ...hints] = text
|
|
31
|
+
.split('\n')
|
|
32
|
+
.map((line) => line.replace(/^error:\s*/i, '').trim())
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
if (!summary) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
startSession('emulsify');
|
|
38
|
+
log('error', summary);
|
|
39
|
+
for (const hint of hints) {
|
|
40
|
+
log('info', hint);
|
|
41
|
+
}
|
|
42
|
+
cancelSession('Run emulsify --help for the full command list.');
|
|
43
|
+
}
|
|
44
|
+
function closeFailedSession(message) {
|
|
45
|
+
if (isSessionOpen()) {
|
|
46
|
+
cancelSession(message);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
program
|
|
50
|
+
.name('emulsify')
|
|
51
|
+
.enablePositionalOptions()
|
|
52
|
+
.showSuggestionAfterError()
|
|
53
|
+
.configureOutput({ outputError: renderCommanderError });
|
|
24
54
|
program
|
|
25
55
|
.command('init [name] [path]')
|
|
26
56
|
.description('Create a new Emulsify project from a starter repository')
|
|
@@ -29,7 +59,7 @@ program
|
|
|
29
59
|
.option('-c, --checkout <commit/branch/tag>', 'Starter commit, branch, or tag to check out after clone.')
|
|
30
60
|
.option('-p, --platform <none|drupal|wordpress>', 'Project platform to use when auto-detection is unavailable or should be overridden.')
|
|
31
61
|
.option('-y, --yes', 'Accept default init values for any missing options without prompting.')
|
|
32
|
-
.action(
|
|
62
|
+
.action(withSession('emulsify init', init));
|
|
33
63
|
program
|
|
34
64
|
.command('audit [args...]')
|
|
35
65
|
.description('Run the project-installed Emulsify Core audit')
|
|
@@ -44,7 +74,7 @@ system
|
|
|
44
74
|
.command('list')
|
|
45
75
|
.description('List built-in systems available for installation')
|
|
46
76
|
.alias('ls')
|
|
47
|
-
.action(systemList);
|
|
77
|
+
.action(withSession('emulsify system list', systemList));
|
|
48
78
|
system
|
|
49
79
|
.command('create [name]')
|
|
50
80
|
.description('Scaffold a standalone component-system repository')
|
|
@@ -56,7 +86,7 @@ system
|
|
|
56
86
|
.option('--repository <url>', 'Repository URI; overrides the generated TODO.invalid placeholder.')
|
|
57
87
|
.option('-y, --yes', 'Accept defaults for all missing system scaffold values without prompting.')
|
|
58
88
|
.option('--dry-run', 'Preview the system scaffold without creating files or initializing Git.')
|
|
59
|
-
.action(systemCreate);
|
|
89
|
+
.action(withSession('emulsify system create', systemCreate));
|
|
60
90
|
system
|
|
61
91
|
.command('install [name]')
|
|
62
92
|
.description('Install a component system or open the guided installer')
|
|
@@ -64,13 +94,14 @@ system
|
|
|
64
94
|
.option('-c, --checkout <commit/branch/tag>', 'Commit, branch, or tag to check out. Required when --repository is used.')
|
|
65
95
|
.option('--variant <platform-expression>', 'Exact system variant platform expression to install.')
|
|
66
96
|
.option('-a, --all', 'Install every component in the selected variant. Without this flag, only required components are installed.')
|
|
67
|
-
.option('-y, --yes', 'Accept the
|
|
68
|
-
.
|
|
97
|
+
.option('-y, --yes', 'Accept the guided-install review or npm packages without prompting.')
|
|
98
|
+
.option('--skip-npm', 'Report component npm packages without installing them.')
|
|
99
|
+
.action(withSession('emulsify system install', systemInstall));
|
|
69
100
|
system
|
|
70
101
|
.command('detach')
|
|
71
102
|
.description('Detach the configured system and keep project components')
|
|
72
103
|
.option('-y, --yes', 'Detach without prompting for confirmation.')
|
|
73
|
-
.action(systemDetach);
|
|
104
|
+
.action(withSession('emulsify system detach', systemDetach));
|
|
74
105
|
const component = program
|
|
75
106
|
.command('component')
|
|
76
107
|
.alias('components')
|
|
@@ -80,36 +111,38 @@ component
|
|
|
80
111
|
.description('List components available from the installed system and variant')
|
|
81
112
|
.option('--refresh', 'Check the configured system remote before reusing its local cache entry.')
|
|
82
113
|
.alias('ls')
|
|
83
|
-
.action(componentList);
|
|
114
|
+
.action(withSession('emulsify component list', componentList));
|
|
84
115
|
component
|
|
85
116
|
.command('install [name]')
|
|
86
117
|
.description('Install one component from the installed system and variant')
|
|
87
118
|
.option('-f, --force', 'Replace an existing component destination.')
|
|
119
|
+
.option('-y, --yes', 'Accept the npm packages a component requires without prompting.')
|
|
88
120
|
.option('-a, --all', 'Install all available components instead of one named component.')
|
|
89
121
|
.option('--dry-run', 'Preview component installs without copying or removing files.')
|
|
122
|
+
.option('--skip-npm', 'Report component npm packages without installing them.')
|
|
90
123
|
.option('--refresh', 'Check the configured system remote before reusing its local cache entry.')
|
|
91
124
|
.alias('i')
|
|
92
|
-
.action(componentInstall);
|
|
125
|
+
.action(withSession('emulsify component install', componentInstall));
|
|
93
126
|
component
|
|
94
127
|
.command('create [name]')
|
|
95
128
|
.option('-d, --directory <directory>', 'Variant structure name where the component should be created.')
|
|
96
129
|
.option('-t, --type <twig|twig-sdc|react|web-component>', 'Component implementation type to generate.')
|
|
97
130
|
.option('--tag-name <tag-name>', 'Custom element tag name for a Web Component.')
|
|
98
|
-
.option('
|
|
99
|
-
.option('--force', 'Replace an existing generated component without prompting.')
|
|
131
|
+
.option('--format <default|sdc>', 'Deprecated alias: default maps to twig and sdc maps to twig-sdc.')
|
|
132
|
+
.option('-f, --force', 'Replace an existing generated component without prompting.')
|
|
100
133
|
.option('-y, --yes', 'Compatibility alias for --force when replacing an existing component.')
|
|
101
134
|
.option('--dry-run', 'Preview generated component files without writing or removing files.')
|
|
102
135
|
.option('--refresh', 'Check the configured system remote before reusing its local cache entry.')
|
|
103
136
|
.alias('c')
|
|
104
137
|
.description('Generate a new local component in the current project')
|
|
105
|
-
.action(componentCreate);
|
|
138
|
+
.action(withSession('emulsify component create', componentCreate));
|
|
106
139
|
component
|
|
107
140
|
.command('eject-templates [type]')
|
|
108
141
|
.description('Write editable copies of the built-in component templates')
|
|
109
142
|
.option('-a, --all', 'Eject templates for every supported component type.')
|
|
110
143
|
.option('-f, --force', 'Replace existing template files in the selected type set.')
|
|
111
144
|
.option('--dry-run', 'Preview template destinations and conflicts without writing files.')
|
|
112
|
-
.action(componentEjectTemplates);
|
|
145
|
+
.action(withSession('emulsify component eject-templates', componentEjectTemplates));
|
|
113
146
|
const cache = program
|
|
114
147
|
.command('cache')
|
|
115
148
|
.description('Inspect or clear locally cached repositories');
|
|
@@ -117,20 +150,8 @@ cache
|
|
|
117
150
|
.command('clear')
|
|
118
151
|
.description('Remove all locally cached Emulsify repositories')
|
|
119
152
|
.option('--dry-run', 'Report cache contents without removing files.')
|
|
120
|
-
.action(cacheClear);
|
|
121
|
-
|
|
122
|
-
const title = cyan(packageInfo.productName);
|
|
123
|
-
const message = `Version: ${green(packageInfo.version)}`;
|
|
124
|
-
const boxedMessage = boxen(message, {
|
|
125
|
-
title: title,
|
|
126
|
-
borderStyle: 'round',
|
|
127
|
-
padding: 1,
|
|
128
|
-
margin: 1,
|
|
129
|
-
...(terminalSupportsColor()
|
|
130
|
-
? { backgroundColor: 'black', borderColor: 'blue' }
|
|
131
|
-
: {}),
|
|
132
|
-
});
|
|
133
|
-
program.version(boxedMessage);
|
|
153
|
+
.action(withSession('emulsify cache clear', cacheClear));
|
|
154
|
+
program.version(packageInfo.version, '-V, --version', 'Print the CLI version');
|
|
134
155
|
const rootHelpRequested = process.argv.length <= 2 ||
|
|
135
156
|
(process.argv.length === 3 &&
|
|
136
157
|
['--help', '-h', 'help'].includes(process.argv[2]));
|
|
@@ -148,17 +169,19 @@ try {
|
|
|
148
169
|
await program.parseAsync(process.argv);
|
|
149
170
|
}
|
|
150
171
|
catch (err) {
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
process.exitCode =
|
|
172
|
+
if (isPromptCancelledError(err)) {
|
|
173
|
+
closeFailedSession(getSessionFailureSummary(err.message));
|
|
174
|
+
process.exitCode = err.exitCode;
|
|
154
175
|
}
|
|
155
176
|
else if (err instanceof CliError) {
|
|
156
177
|
log('error', err.message);
|
|
178
|
+
closeFailedSession(getSessionFailureSummary());
|
|
157
179
|
process.exitCode = err.exitCode;
|
|
158
180
|
}
|
|
159
181
|
else {
|
|
160
182
|
const message = err instanceof Error ? err.message : String(err);
|
|
161
183
|
log('error', message);
|
|
184
|
+
closeFailedSession(getSessionFailureSummary());
|
|
162
185
|
process.exitCode = 1;
|
|
163
186
|
}
|
|
164
187
|
}
|
package/dist/lib/log.js
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
success: green,
|
|
12
|
-
};
|
|
13
|
-
logger(logMethodColorMap[method](message));
|
|
14
|
-
};
|
|
15
|
-
export default function log(method, message) {
|
|
1
|
+
import { log as render } from '@clack/prompts';
|
|
2
|
+
import { dim } from 'colorette';
|
|
3
|
+
import { getRendererOutput, isInteractiveOutput, stripAnsi, } from './session.js';
|
|
4
|
+
export default function log(method, message, { stdout, stderr, } = process) {
|
|
5
|
+
const stream = method === 'error' || method === 'warn' ? stderr : stdout;
|
|
6
|
+
if (!isInteractiveOutput(stream)) {
|
|
7
|
+
stream.write(`${stripAnsi(message)}\n`);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const options = { output: getRendererOutput(stream) };
|
|
16
11
|
switch (method) {
|
|
17
12
|
case 'error':
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
case 'info':
|
|
21
|
-
withColor(consolaGlobalInstance.info)(method, message);
|
|
22
|
-
break;
|
|
13
|
+
render.error(message, options);
|
|
14
|
+
return;
|
|
23
15
|
case 'warn':
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
render.warn(message, options);
|
|
17
|
+
return;
|
|
18
|
+
case 'info':
|
|
19
|
+
render.info(message, options);
|
|
20
|
+
return;
|
|
21
|
+
case 'success':
|
|
22
|
+
render.success(message, options);
|
|
23
|
+
return;
|
|
26
24
|
default:
|
|
27
|
-
|
|
25
|
+
render.message(dim(message), options);
|
|
28
26
|
}
|
|
29
|
-
return;
|
|
30
27
|
}
|
package/dist/lib/rootHelp.js
CHANGED
|
@@ -67,11 +67,21 @@ const sections = [
|
|
|
67
67
|
label: '-f, --force',
|
|
68
68
|
description: 'Replace an existing destination',
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
kind: 'option',
|
|
72
|
+
label: '-y, --yes',
|
|
73
|
+
description: 'Accept npm packages without prompting',
|
|
74
|
+
},
|
|
70
75
|
{
|
|
71
76
|
kind: 'option',
|
|
72
77
|
label: '--dry-run',
|
|
73
78
|
description: 'Preview without writing files',
|
|
74
79
|
},
|
|
80
|
+
{
|
|
81
|
+
kind: 'option',
|
|
82
|
+
label: '--skip-npm',
|
|
83
|
+
description: 'Report npm packages without installing them',
|
|
84
|
+
},
|
|
75
85
|
{
|
|
76
86
|
kind: 'command',
|
|
77
87
|
label: 'component create [name]',
|
|
@@ -94,19 +104,24 @@ const sections = [
|
|
|
94
104
|
},
|
|
95
105
|
{
|
|
96
106
|
kind: 'option',
|
|
97
|
-
label: '-f, --
|
|
98
|
-
description: '
|
|
107
|
+
label: '-f, --force',
|
|
108
|
+
description: 'Replace an existing generated component',
|
|
99
109
|
},
|
|
100
110
|
{
|
|
101
111
|
kind: 'option',
|
|
102
|
-
label: '--
|
|
103
|
-
description: '
|
|
112
|
+
label: '-y, --yes',
|
|
113
|
+
description: 'Compatibility alias for --force',
|
|
104
114
|
},
|
|
105
115
|
{
|
|
106
116
|
kind: 'option',
|
|
107
117
|
label: '--dry-run',
|
|
108
118
|
description: 'Preview without writing files',
|
|
109
119
|
},
|
|
120
|
+
{
|
|
121
|
+
kind: 'option',
|
|
122
|
+
label: '--refresh',
|
|
123
|
+
description: 'Check the system remote before reuse',
|
|
124
|
+
},
|
|
110
125
|
{
|
|
111
126
|
kind: 'command',
|
|
112
127
|
label: 'component eject-templates [type]',
|
|
@@ -157,6 +172,16 @@ const sections = [
|
|
|
157
172
|
label: '-a, --all',
|
|
158
173
|
description: 'Install every component, not just required',
|
|
159
174
|
},
|
|
175
|
+
{
|
|
176
|
+
kind: 'option',
|
|
177
|
+
label: '-y, --yes',
|
|
178
|
+
description: 'Accept the install review or npm packages',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
kind: 'option',
|
|
182
|
+
label: '--skip-npm',
|
|
183
|
+
description: 'Report npm packages without installing them',
|
|
184
|
+
},
|
|
160
185
|
{
|
|
161
186
|
kind: 'command',
|
|
162
187
|
label: 'system detach',
|
|
@@ -304,7 +329,7 @@ export default function getRootHelp({ colors, columns, description, productName,
|
|
|
304
329
|
}
|
|
305
330
|
lines.push('');
|
|
306
331
|
}
|
|
307
|
-
const refresh = '--refresh
|
|
332
|
+
const refresh = '--refresh: component list, install, create.';
|
|
308
333
|
const switches = '-V, --version -h, --help';
|
|
309
334
|
if (width >= NATURAL_WIDTH) {
|
|
310
335
|
lines.push(colors.dim(` ${refresh} ${switches}`));
|