@emulsify/cli 2.4.2 → 2.5.1
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 +101 -73
- 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 +62 -55
- 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/emulsifyProjectConfig.json +11 -0
- package/dist/schemas/system.json +1 -0
- package/dist/schemas/variant.json +8 -0
- package/dist/util/cache/cloneIntoCache.js +25 -8
- package/dist/util/cache/copyItemFromCache.js +7 -1
- 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/installGeneralAssetsFromCache.js +2 -1
- package/dist/util/project/resolveComponentTemplate.js +11 -1
- package/dist/util/project/rewriteComponentIds.js +69 -0
- package/dist/util/prompt/index.js +21 -6
- package/dist/util/system/validateSystemConfig.js +13 -27
- package/package.json +16 -18
- package/dist/handlers/hofs/withProgressBar.js +0 -10
|
@@ -1,16 +1,19 @@
|
|
|
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';
|
|
16
|
+
import { logComponentIdRewrites } from '../util/project/rewriteComponentIds.js';
|
|
14
17
|
import getJsonFromCachedFile from '../util/cache/getJsonFromCachedFile.js';
|
|
15
18
|
import setEmulsifyConfig from '../util/project/setEmulsifyConfig.js';
|
|
16
19
|
import getEmulsifyConfig from '../util/project/getEmulsifyConfig.js';
|
|
@@ -22,16 +25,13 @@ import { runPrompt } from '../util/prompt/index.js';
|
|
|
22
25
|
import buildSystemInstallPlan, { selectSystemComponents, } from '../util/system/buildSystemInstallPlan.js';
|
|
23
26
|
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
27
|
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
|
|
28
|
+
const CANCELLED_SUMMARY = 'System install cancelled.';
|
|
29
|
+
const DECLINED_SUMMARY = 'System install cancelled. No project files were changed.';
|
|
30
|
+
function formatWizardStep(step, total) {
|
|
31
|
+
return total ? `Step ${step} of ${total}` : `Step ${step}`;
|
|
29
32
|
}
|
|
30
33
|
function showWizardStep(step, total) {
|
|
31
|
-
log('info',
|
|
32
|
-
}
|
|
33
|
-
function formatChoice(label, description) {
|
|
34
|
-
return `${label.padEnd(22)}${description}`;
|
|
34
|
+
log('info', formatWizardStep(step, total));
|
|
35
35
|
}
|
|
36
36
|
function pluralize(count, singular, plural = `${singular}s`) {
|
|
37
37
|
return `${count} ${count === 1 ? singular : plural}`;
|
|
@@ -78,8 +78,8 @@ function formatRepositorySource(repository) {
|
|
|
78
78
|
}
|
|
79
79
|
function validateRepositoryInput(repository) {
|
|
80
80
|
try {
|
|
81
|
-
return getGitRepoNameFromUrl(repository.trim())
|
|
82
|
-
?
|
|
81
|
+
return getGitRepoNameFromUrl((repository || '').trim())
|
|
82
|
+
? undefined
|
|
83
83
|
: 'Enter a Git repository with a recognizable name.';
|
|
84
84
|
}
|
|
85
85
|
catch (error) {
|
|
@@ -131,21 +131,21 @@ async function promptForSystemInstallChoice() {
|
|
|
131
131
|
showWizardStep(1);
|
|
132
132
|
return select({
|
|
133
133
|
message: 'Which system?',
|
|
134
|
-
|
|
134
|
+
options: [
|
|
135
135
|
...availableSystems.map((reference) => ({
|
|
136
|
-
name: formatChoice(reference.label, reference.description),
|
|
137
136
|
value: { kind: 'built-in', reference },
|
|
138
|
-
|
|
137
|
+
label: reference.label,
|
|
138
|
+
hint: reference.description,
|
|
139
139
|
})),
|
|
140
140
|
{
|
|
141
|
-
name: formatChoice('Bring your own', 'Install from a git repository you control.'),
|
|
142
141
|
value: { kind: 'custom' },
|
|
143
|
-
|
|
142
|
+
label: 'Bring your own',
|
|
143
|
+
hint: 'Install from a git repository you control.',
|
|
144
144
|
},
|
|
145
|
-
new Separator('────────────'),
|
|
146
145
|
{
|
|
147
|
-
name: 'Cancel',
|
|
148
146
|
value: { kind: 'cancel' },
|
|
147
|
+
label: 'Cancel',
|
|
148
|
+
hint: 'Leave this project unchanged.',
|
|
149
149
|
},
|
|
150
150
|
],
|
|
151
151
|
});
|
|
@@ -153,7 +153,6 @@ async function promptForSystemInstallChoice() {
|
|
|
153
153
|
nonInteractive: { error: MISSING_SYSTEM_SOURCE_ERROR },
|
|
154
154
|
});
|
|
155
155
|
if (selectedSource.kind === 'cancel') {
|
|
156
|
-
log('info', 'System install cancelled.');
|
|
157
156
|
return;
|
|
158
157
|
}
|
|
159
158
|
return selectedSource;
|
|
@@ -162,8 +161,8 @@ async function promptForCustomRepository(step, total) {
|
|
|
162
161
|
return runPrompt({
|
|
163
162
|
prompt: () => {
|
|
164
163
|
showWizardStep(step, total);
|
|
165
|
-
return
|
|
166
|
-
message: 'Repository URL or local path
|
|
164
|
+
return text({
|
|
165
|
+
message: 'Repository URL or local path',
|
|
167
166
|
validate: validateRepositoryInput,
|
|
168
167
|
});
|
|
169
168
|
},
|
|
@@ -176,9 +175,11 @@ async function promptForCustomCheckout(step, total) {
|
|
|
176
175
|
return runPrompt({
|
|
177
176
|
prompt: () => {
|
|
178
177
|
showWizardStep(step, total);
|
|
179
|
-
return
|
|
180
|
-
message: 'Checkout (branch, tag, or commit)
|
|
181
|
-
validate: (value) => value.trim().length > 0
|
|
178
|
+
return text({
|
|
179
|
+
message: 'Checkout (branch, tag, or commit)',
|
|
180
|
+
validate: (value) => (value || '').trim().length > 0
|
|
181
|
+
? undefined
|
|
182
|
+
: 'Enter a branch, tag, or commit.',
|
|
182
183
|
});
|
|
183
184
|
},
|
|
184
185
|
nonInteractive: {
|
|
@@ -222,20 +223,20 @@ async function promptForVariantChoice(variants, projectPlatform, systemName, non
|
|
|
222
223
|
message: wizardStep
|
|
223
224
|
? 'Which component set?'
|
|
224
225
|
: `Which ${formatSystemLabel(systemName)} component set should be used?`,
|
|
225
|
-
|
|
226
|
+
options: rankedVariants.map(({ variant, index }) => {
|
|
226
227
|
const componentCount = variant.components.length;
|
|
227
228
|
const requiredCount = variant.components.filter(({ required }) => required === true).length;
|
|
228
|
-
const counts =
|
|
229
|
+
const counts = `${pluralize(componentCount, 'component')}, ${pluralize(requiredCount, 'required component')}`;
|
|
229
230
|
const recommended = recommendedVariants.has(variant)
|
|
230
|
-
? '
|
|
231
|
+
? 'Recommended · '
|
|
231
232
|
: '';
|
|
232
233
|
return {
|
|
233
|
-
name: `${formatPlatformLabel(variant.platform)} (${variant.platform})${recommended}${counts}`,
|
|
234
234
|
value: index,
|
|
235
|
-
|
|
235
|
+
label: `${formatPlatformLabel(variant.platform)} (${variant.platform})`,
|
|
236
|
+
hint: `${recommended}${counts}`,
|
|
236
237
|
};
|
|
237
238
|
}),
|
|
238
|
-
|
|
239
|
+
initialValue: defaultChoice,
|
|
239
240
|
});
|
|
240
241
|
},
|
|
241
242
|
nonInteractive: { error: nonInteractiveError },
|
|
@@ -272,19 +273,19 @@ async function promptForInstallScope(variant, step, total) {
|
|
|
272
273
|
showWizardStep(step, total);
|
|
273
274
|
return select({
|
|
274
275
|
message: 'How much do you want to install?',
|
|
275
|
-
|
|
276
|
+
options: [
|
|
276
277
|
{
|
|
277
|
-
name: formatChoice('Essentials only', pluralize(requiredComponentCount, 'required component')),
|
|
278
278
|
value: false,
|
|
279
|
-
|
|
279
|
+
label: 'Essentials only',
|
|
280
|
+
hint: pluralize(requiredComponentCount, 'required component'),
|
|
280
281
|
},
|
|
281
282
|
{
|
|
282
|
-
name: formatChoice('Everything', pluralize(variant.components.length, 'component')),
|
|
283
283
|
value: true,
|
|
284
|
-
|
|
284
|
+
label: 'Everything',
|
|
285
|
+
hint: pluralize(variant.components.length, 'component'),
|
|
285
286
|
},
|
|
286
287
|
],
|
|
287
|
-
|
|
288
|
+
initialValue: false,
|
|
288
289
|
});
|
|
289
290
|
},
|
|
290
291
|
nonInteractive: {
|
|
@@ -300,7 +301,7 @@ function formatDirectoryDestinations(destinations) {
|
|
|
300
301
|
? destination
|
|
301
302
|
: `${destination}/`));
|
|
302
303
|
}
|
|
303
|
-
export function formatSystemInstallReview(systemLabel, repository, checkout, variant, plan, installAll) {
|
|
304
|
+
export function formatSystemInstallReview(systemLabel, repository, checkout, variant, plan, installAll, npmPackages = []) {
|
|
304
305
|
const continuationIndent = ' ';
|
|
305
306
|
const installRows = [
|
|
306
307
|
`${pluralize(plan.components.length, 'component')} → ${formatDirectoryDestinations(plan.componentParentDestinations)}`,
|
|
@@ -318,15 +319,16 @@ export function formatSystemInstallReview(systemLabel, repository, checkout, var
|
|
|
318
319
|
` Scope ${installAll ? 'Everything' : 'Essentials only'}`,
|
|
319
320
|
` Will install ${installRows[0]}`,
|
|
320
321
|
...installRows.slice(1).map((row) => `${continuationIndent}${row}`),
|
|
322
|
+
` npm packages ${npmPackages.join(`\n${continuationIndent}`) || 'none'}`,
|
|
321
323
|
].join('\n');
|
|
322
324
|
}
|
|
323
325
|
async function promptForInstallConfirmation(review, step, total, accept) {
|
|
324
326
|
showWizardStep(step, total);
|
|
325
|
-
|
|
327
|
+
note(review, 'Review');
|
|
326
328
|
return runPrompt({
|
|
327
329
|
prompt: () => confirm({
|
|
328
330
|
message: 'Install now?',
|
|
329
|
-
|
|
331
|
+
initialValue: true,
|
|
330
332
|
}),
|
|
331
333
|
nonInteractive: {
|
|
332
334
|
error: 'Installation confirmation is required in non-interactive mode. Pass --yes to accept the reviewed installation.',
|
|
@@ -353,7 +355,7 @@ export default async function systemInstall(name, options) {
|
|
|
353
355
|
if (guidedInstall) {
|
|
354
356
|
const source = await promptForSystemInstallChoice();
|
|
355
357
|
if (!source) {
|
|
356
|
-
return;
|
|
358
|
+
return CANCELLED_SUMMARY;
|
|
357
359
|
}
|
|
358
360
|
if (source.kind === 'built-in') {
|
|
359
361
|
const { reference } = source;
|
|
@@ -429,9 +431,6 @@ export default async function systemInstall(name, options) {
|
|
|
429
431
|
throw new CliError('Unable to determine which system checkout was loaded. Retry with --checkout <branch, tag, or commit>.');
|
|
430
432
|
}
|
|
431
433
|
systemLabel ||= formatSystemLabel(systemConf.name);
|
|
432
|
-
if (guidedInstall) {
|
|
433
|
-
log('info', `Loaded ${systemLabel} · ${repo.checkout}.`);
|
|
434
|
-
}
|
|
435
434
|
const projectPlatform = projectConfig.project.platform;
|
|
436
435
|
if (!isPlatform(projectPlatform)) {
|
|
437
436
|
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.');
|
|
@@ -450,20 +449,25 @@ export default async function systemInstall(name, options) {
|
|
|
450
449
|
const installAll = guidedInstall && !options.all
|
|
451
450
|
? await promptForInstallScope(variantConf, ++wizardStep, wizardTotalSteps)
|
|
452
451
|
: options.all === true;
|
|
453
|
-
|
|
452
|
+
const componentsToInstall = selectSystemComponents(variantConf, installAll);
|
|
453
|
+
const projectConfigPath = findFileInCurrentPath(EMULSIFY_PROJECT_CONFIG_FILE);
|
|
454
|
+
const skipNpm = options.skipNpm === true;
|
|
455
|
+
const npmPlan = await prepareComponentNpmInstall(systemConf.name, componentsToInstall, projectConfigPath, skipNpm);
|
|
456
|
+
let acceptedNpm = !skipNpm;
|
|
454
457
|
if (guidedInstall) {
|
|
455
|
-
const projectConfigPath = findFileInCurrentPath(EMULSIFY_PROJECT_CONFIG_FILE);
|
|
456
458
|
if (!projectConfigPath) {
|
|
457
459
|
throw new CliError('Unable to find the Emulsify project configuration for the installation review.');
|
|
458
460
|
}
|
|
459
461
|
const plan = buildSystemInstallPlan(systemConf, variantConf, installAll, projectConfigPath);
|
|
460
|
-
|
|
461
|
-
const confirmed = await promptForInstallConfirmation(formatSystemInstallReview(systemLabel, repo.repository, repo.checkout, variantConf, plan, installAll), ++wizardStep, wizardTotalSteps, options.yes === true);
|
|
462
|
+
const confirmed = await promptForInstallConfirmation(formatSystemInstallReview(systemLabel, repo.repository, repo.checkout, variantConf, plan, installAll, getComponentNpmInstallReview(npmPlan, skipNpm)?.lines), ++wizardStep, wizardTotalSteps, options.yes === true);
|
|
462
463
|
if (!confirmed) {
|
|
463
|
-
|
|
464
|
-
return;
|
|
464
|
+
return DECLINED_SUMMARY;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
+
else {
|
|
468
|
+
acceptedNpm = await confirmComponentNpmInstall(npmPlan, skipNpm, options.yes === true, `The ${JSON.stringify(systemConf.name)} system`);
|
|
469
|
+
}
|
|
470
|
+
let added = 0;
|
|
467
471
|
try {
|
|
468
472
|
await setEmulsifyConfig({
|
|
469
473
|
system: {
|
|
@@ -480,11 +484,13 @@ export default async function systemInstall(name, options) {
|
|
|
480
484
|
throw new CliError('Unable to update your Emulsify project configuration.');
|
|
481
485
|
}
|
|
482
486
|
try {
|
|
487
|
+
let rewritten = 0;
|
|
483
488
|
for (const component of componentsToInstall) {
|
|
484
|
-
await installComponentFromCache(systemConf, variantConf, component.name, true);
|
|
489
|
+
rewritten += await installComponentFromCache(systemConf, variantConf, component.name, true);
|
|
485
490
|
}
|
|
486
|
-
await installGeneralAssetsFromCache(systemConf, variantConf);
|
|
487
|
-
|
|
491
|
+
rewritten += await installGeneralAssetsFromCache(systemConf, variantConf);
|
|
492
|
+
logComponentIdRewrites(rewritten);
|
|
493
|
+
added = await applyComponentNpmInstall(npmPlan, acceptedNpm);
|
|
488
494
|
const hookPath = projectConfigPath
|
|
489
495
|
? join(dirname(projectConfigPath), EMULSIFY_PROJECT_HOOK_FOLDER, EMULSIFY_PROJECT_HOOK_SYSTEM_INSTALL)
|
|
490
496
|
: undefined;
|
|
@@ -493,9 +499,10 @@ export default async function systemInstall(name, options) {
|
|
|
493
499
|
}
|
|
494
500
|
}
|
|
495
501
|
catch (e) {
|
|
502
|
+
if (e instanceof CliError)
|
|
503
|
+
throw e;
|
|
496
504
|
throw new CliError(`Unable to install system assets and/or required components: ${String(e)}`);
|
|
497
505
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
: `Successfully installed the ${systemConf.name} system using the ${variantConf.platform} variant.`);
|
|
506
|
+
const summary = `${systemLabel} installed · ${variantConf.platform} component set`;
|
|
507
|
+
return added ? `${summary} · ${formatAddedNpmPackages(added)}` : summary;
|
|
501
508
|
}
|
|
@@ -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}`));
|