@emulsify/cli 2.3.1 → 2.4.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 +96 -16
- package/dist/handlers/componentCreate.js +37 -5
- package/dist/handlers/componentEjectTemplates.js +317 -0
- package/dist/handlers/componentInstall.js +54 -14
- package/dist/handlers/hofs/withEmulsifySystem.js +1 -1
- package/dist/handlers/init.js +75 -32
- package/dist/handlers/systemCreate.js +222 -0
- package/dist/handlers/systemDetach.js +50 -0
- package/dist/handlers/systemInstall.js +339 -101
- package/dist/index.js +67 -110
- package/dist/lib/log.js +12 -9
- package/dist/lib/rootHelp.js +321 -0
- package/dist/lib/terminalColors.js +10 -0
- package/dist/util/cache/cloneIntoCache.js +2 -4
- package/dist/util/deriveComponentNames.js +5 -0
- package/dist/util/deriveCustomElementTagName.js +25 -0
- package/dist/util/fs/writeToJsonFile.js +21 -5
- package/dist/util/getGitRepoNameFromUrl.js +47 -3
- package/dist/util/getNonInteractiveGitEnvironment.js +7 -0
- package/dist/util/getRepositoryLatestTag.js +17 -2
- package/dist/util/platform/platformCompatibility.js +18 -7
- package/dist/util/project/componentTemplates/buildComponentArtifacts.js +121 -0
- package/dist/util/project/componentTemplates/index.js +5 -0
- package/dist/util/project/componentTemplates/react.js +20 -0
- package/dist/util/project/componentTemplates/reactStories.js +18 -0
- package/dist/util/project/componentTemplates/scss.js +2 -3
- package/dist/util/project/componentTemplates/sdcStories.js +2 -2
- package/dist/util/project/componentTemplates/stories.js +2 -2
- package/dist/util/project/componentTemplates/twig.js +2 -3
- package/dist/util/project/componentTemplates/webComponent.js +49 -0
- package/dist/util/project/componentTemplates/webComponentStories.js +19 -0
- package/dist/util/project/componentTypes.js +71 -0
- package/dist/util/project/generateComponent.js +139 -101
- package/dist/util/project/renderTemplate.js +24 -4
- package/dist/util/project/resolveComponentTemplate.js +24 -11
- package/dist/util/project/unsetEmulsifyConfig.js +16 -0
- package/dist/util/prompt/index.js +25 -0
- package/dist/util/system/buildSystemInstallPlan.js +53 -0
- package/dist/util/system/buildSystemScaffold.js +99 -0
- package/dist/util/system/getAvailableSystems.js +4 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,115 +4,31 @@ import withProgressBar from './handlers/hofs/withProgressBar.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';
|
|
7
|
+
import systemCreate from './handlers/systemCreate.js';
|
|
8
|
+
import systemDetach from './handlers/systemDetach.js';
|
|
7
9
|
import componentList from './handlers/componentList.js';
|
|
8
10
|
import componentInstall from './handlers/componentInstall.js';
|
|
9
11
|
import componentCreate from './handlers/componentCreate.js';
|
|
12
|
+
import componentEjectTemplates from './handlers/componentEjectTemplates.js';
|
|
10
13
|
import audit from './handlers/audit.js';
|
|
11
14
|
import cacheClear from './handlers/cacheClear.js';
|
|
12
15
|
import CliError from './lib/CliError.js';
|
|
13
16
|
import log from './lib/log.js';
|
|
17
|
+
import getRootHelp from './lib/rootHelp.js';
|
|
18
|
+
import getTerminalColors, { terminalSupportsColor, } from './lib/terminalColors.js';
|
|
19
|
+
import { isExitPromptError } from './util/prompt/index.js';
|
|
14
20
|
import { createRequire } from 'module';
|
|
15
|
-
import { cyan, green } from 'colorette';
|
|
16
21
|
import boxen from 'boxen';
|
|
17
22
|
const packageInfo = createRequire(import.meta.url)('../package.json');
|
|
18
|
-
function getRootHelp() {
|
|
19
|
-
return [
|
|
20
|
-
`${packageInfo.productName} ${packageInfo.version}`,
|
|
21
|
-
'',
|
|
22
|
-
'Create Emulsify projects, choose component systems, install components, generate local components, and route audits to Emulsify Core.',
|
|
23
|
-
'',
|
|
24
|
-
'Usage:',
|
|
25
|
-
' emulsify',
|
|
26
|
-
' emulsify --help',
|
|
27
|
-
' emulsify <command> --help',
|
|
28
|
-
' emulsify init [name] [path] [options]',
|
|
29
|
-
' emulsify audit [...args]',
|
|
30
|
-
' emulsify system install [name] [options]',
|
|
31
|
-
' emulsify component <command> [options]',
|
|
32
|
-
' emulsify cache clear [options]',
|
|
33
|
-
'',
|
|
34
|
-
'Common workflow:',
|
|
35
|
-
' emulsify init',
|
|
36
|
-
' emulsify system install',
|
|
37
|
-
' emulsify component list',
|
|
38
|
-
' emulsify component install <name>',
|
|
39
|
-
' emulsify component create <name>',
|
|
40
|
-
'',
|
|
41
|
-
'Commands:',
|
|
42
|
-
' init [name] [path]',
|
|
43
|
-
' Create a project from a starter repository. Prompts for project name, target directory,',
|
|
44
|
-
' and platform when values are missing in an interactive terminal.',
|
|
45
|
-
' Options:',
|
|
46
|
-
' -m, --machineName <machineName> Set the project folder/config machine name.',
|
|
47
|
-
' -s, --starter <repository> Use a custom starter repository.',
|
|
48
|
-
' -c, --checkout <commit/branch/tag> Checkout for the starter repository.',
|
|
49
|
-
' -p, --platform <none|drupal|wordpress>',
|
|
50
|
-
' Select the project platform when auto-detection is unavailable.',
|
|
51
|
-
' Built-in platforms: drupal, wordpress, none.',
|
|
52
|
-
' -y, --yes Accept defaults for missing init values without prompting.',
|
|
53
|
-
'',
|
|
54
|
-
' audit [...args]',
|
|
55
|
-
' Run the project-installed Emulsify Core audit with unchanged arguments, output, and exit status.',
|
|
56
|
-
' Run "emulsify audit --help" for Core-owned audit options.',
|
|
57
|
-
'',
|
|
58
|
-
' system list',
|
|
59
|
-
' List built-in component systems available for installation. Alias: system ls.',
|
|
60
|
-
'',
|
|
61
|
-
' system install [name]',
|
|
62
|
-
' Install a built-in or repository-backed component system. With no name or repository in',
|
|
63
|
-
' an interactive terminal, prompts for compound, emulsify-ui-kit, create a new system,',
|
|
64
|
-
' or cancel.',
|
|
65
|
-
' Options:',
|
|
66
|
-
' -r, --repository <repository> Install from a custom system repository ending in .git.',
|
|
67
|
-
' -c, --checkout <commit/branch/tag> Checkout to use with --repository.',
|
|
68
|
-
' --variant <platform-expression> Select an exact variant platform expression.',
|
|
69
|
-
' -a, --all Install every component in the selected variant.',
|
|
70
|
-
'',
|
|
71
|
-
' component list',
|
|
72
|
-
' List components available from the installed system and selected variant. Alias: component ls.',
|
|
73
|
-
' Options:',
|
|
74
|
-
' --refresh Check the system remote before reusing the local cache.',
|
|
75
|
-
'',
|
|
76
|
-
' component install [name]',
|
|
77
|
-
' Install one component, dependencies, or all components from the installed system. Alias: component i.',
|
|
78
|
-
' Options:',
|
|
79
|
-
' -f, --force Replace an existing component destination.',
|
|
80
|
-
' -a, --all Install all available components.',
|
|
81
|
-
' --dry-run Preview installs without writing files.',
|
|
82
|
-
' --refresh Check the system remote before reusing the local cache.',
|
|
83
|
-
'',
|
|
84
|
-
' component create [name]',
|
|
85
|
-
' Generate a new local component in this project. Alias: component c.',
|
|
86
|
-
' Options:',
|
|
87
|
-
' -d, --directory <directory> Variant structure where the component should be created.',
|
|
88
|
-
' -f, --format <default|sdc> Component format to generate.',
|
|
89
|
-
' -y, --yes Replace existing generated components without prompting.',
|
|
90
|
-
' --dry-run Preview generated files without writing them.',
|
|
91
|
-
' --refresh Check the system remote before reusing the local cache.',
|
|
92
|
-
'',
|
|
93
|
-
' cache clear',
|
|
94
|
-
' Remove all locally cached Emulsify repositories.',
|
|
95
|
-
' Options:',
|
|
96
|
-
' --dry-run Report cache contents without removing files.',
|
|
97
|
-
'',
|
|
98
|
-
' help [command]',
|
|
99
|
-
' Show help for a command.',
|
|
100
|
-
'',
|
|
101
|
-
'Global options:',
|
|
102
|
-
' -V, --version Show the installed CLI version.',
|
|
103
|
-
' -h, --help Show this help output.',
|
|
104
|
-
'',
|
|
105
|
-
].join('\n');
|
|
106
|
-
}
|
|
107
23
|
program.name('emulsify').enablePositionalOptions();
|
|
108
24
|
program
|
|
109
25
|
.command('init [name] [path]')
|
|
110
26
|
.description('Create a new Emulsify project from a starter repository')
|
|
111
|
-
.option('-m --machineName <machineName>', 'Machine-friendly project folder and config name. If omitted, this is generated from the project name.')
|
|
112
|
-
.option('-s --starter <repository>', 'Starter Git repository to clone.')
|
|
113
|
-
.option('-c --checkout <commit/branch/tag>', 'Starter commit, branch, or tag to check out after clone.')
|
|
114
|
-
.option('-p --platform <none|drupal|wordpress>', 'Project platform to use when auto-detection is unavailable or should be overridden.')
|
|
115
|
-
.option('-y --yes', 'Accept default init values for any missing options without prompting.')
|
|
27
|
+
.option('-m, --machineName <machineName>', 'Machine-friendly project folder and config name. If omitted, this is generated from the project name.')
|
|
28
|
+
.option('-s, --starter <repository>', 'Starter Git repository to clone.')
|
|
29
|
+
.option('-c, --checkout <commit/branch/tag>', 'Starter commit, branch, or tag to check out after clone.')
|
|
30
|
+
.option('-p, --platform <none|drupal|wordpress>', 'Project platform to use when auto-detection is unavailable or should be overridden.')
|
|
31
|
+
.option('-y, --yes', 'Accept default init values for any missing options without prompting.')
|
|
116
32
|
.action(withProgressBar(init));
|
|
117
33
|
program
|
|
118
34
|
.command('audit [args...]')
|
|
@@ -123,23 +39,42 @@ program
|
|
|
123
39
|
.action((args) => audit(args));
|
|
124
40
|
const system = program
|
|
125
41
|
.command('system')
|
|
126
|
-
.description('List, install, or
|
|
42
|
+
.description('List, create, install, or detach component systems');
|
|
127
43
|
system
|
|
128
44
|
.command('list')
|
|
129
45
|
.description('List built-in systems available for installation')
|
|
130
46
|
.alias('ls')
|
|
131
47
|
.action(systemList);
|
|
48
|
+
system
|
|
49
|
+
.command('create [name]')
|
|
50
|
+
.description('Scaffold a standalone component-system repository')
|
|
51
|
+
.option('-d, --directory <directory>', 'Parent directory in which to create the new system repository.')
|
|
52
|
+
.option('-p, --platform <platform-expression>', 'Platform compatibility expression for the first variant.')
|
|
53
|
+
.option('--git', 'Initialize a Git repository on branch main.')
|
|
54
|
+
.option('--no-git', 'Do not initialize a Git repository.')
|
|
55
|
+
.option('--homepage <url>', 'Homepage URI; overrides the generated TODO.invalid placeholder.')
|
|
56
|
+
.option('--repository <url>', 'Repository URI; overrides the generated TODO.invalid placeholder.')
|
|
57
|
+
.option('-y, --yes', 'Accept defaults for all missing system scaffold values without prompting.')
|
|
58
|
+
.option('--dry-run', 'Preview the system scaffold without creating files or initializing Git.')
|
|
59
|
+
.action(systemCreate);
|
|
132
60
|
system
|
|
133
61
|
.command('install [name]')
|
|
134
|
-
.description('Install a component system
|
|
135
|
-
.option('-r --repository <repository>', 'Git repository containing the system to install.
|
|
136
|
-
.option('-c --checkout <commit/branch/tag>', 'Commit, branch, or tag to check out. Required when --repository is used.')
|
|
62
|
+
.description('Install a component system or open the guided installer')
|
|
63
|
+
.option('-r, --repository <repository>', 'Git repository containing the system to install. Remote URLs must end in .git; local paths are accepted.')
|
|
64
|
+
.option('-c, --checkout <commit/branch/tag>', 'Commit, branch, or tag to check out. Required when --repository is used.')
|
|
137
65
|
.option('--variant <platform-expression>', 'Exact system variant platform expression to install.')
|
|
138
|
-
.option('-a --all', 'Install every component in the selected variant. Without this flag, only required components are installed.')
|
|
66
|
+
.option('-a, --all', 'Install every component in the selected variant. Without this flag, only required components are installed.')
|
|
67
|
+
.option('-y, --yes', 'Accept the final guided-install review without prompting.')
|
|
139
68
|
.action(systemInstall);
|
|
69
|
+
system
|
|
70
|
+
.command('detach')
|
|
71
|
+
.description('Detach the configured system and keep project components')
|
|
72
|
+
.option('-y, --yes', 'Detach without prompting for confirmation.')
|
|
73
|
+
.action(systemDetach);
|
|
140
74
|
const component = program
|
|
141
75
|
.command('component')
|
|
142
|
-
.
|
|
76
|
+
.alias('components')
|
|
77
|
+
.description('List, install, create, or customize components');
|
|
143
78
|
component
|
|
144
79
|
.command('list')
|
|
145
80
|
.description('List components available from the installed system and variant')
|
|
@@ -149,22 +84,32 @@ component
|
|
|
149
84
|
component
|
|
150
85
|
.command('install [name]')
|
|
151
86
|
.description('Install one component from the installed system and variant')
|
|
152
|
-
.option('-f --force', 'Replace an existing component destination.')
|
|
153
|
-
.option('-a --all', 'Install all available components instead of one named component.')
|
|
87
|
+
.option('-f, --force', 'Replace an existing component destination.')
|
|
88
|
+
.option('-a, --all', 'Install all available components instead of one named component.')
|
|
154
89
|
.option('--dry-run', 'Preview component installs without copying or removing files.')
|
|
155
90
|
.option('--refresh', 'Check the configured system remote before reusing its local cache entry.')
|
|
156
91
|
.alias('i')
|
|
157
92
|
.action(componentInstall);
|
|
158
93
|
component
|
|
159
94
|
.command('create [name]')
|
|
160
|
-
.option('-d --directory <directory>', 'Variant structure name where the component should be created.')
|
|
161
|
-
.option('-
|
|
162
|
-
.option('-
|
|
95
|
+
.option('-d, --directory <directory>', 'Variant structure name where the component should be created.')
|
|
96
|
+
.option('-t, --type <twig|twig-sdc|react|web-component>', 'Component implementation type to generate.')
|
|
97
|
+
.option('--tag-name <tag-name>', 'Custom element tag name for a Web Component.')
|
|
98
|
+
.option('-f, --format <default|sdc>', 'Deprecated alias: default maps to twig and sdc maps to twig-sdc.')
|
|
99
|
+
.option('--force', 'Replace an existing generated component without prompting.')
|
|
100
|
+
.option('-y, --yes', 'Compatibility alias for --force when replacing an existing component.')
|
|
163
101
|
.option('--dry-run', 'Preview generated component files without writing or removing files.')
|
|
164
102
|
.option('--refresh', 'Check the configured system remote before reusing its local cache entry.')
|
|
165
103
|
.alias('c')
|
|
166
104
|
.description('Generate a new local component in the current project')
|
|
167
105
|
.action(componentCreate);
|
|
106
|
+
component
|
|
107
|
+
.command('eject-templates [type]')
|
|
108
|
+
.description('Write editable copies of the built-in component templates')
|
|
109
|
+
.option('-a, --all', 'Eject templates for every supported component type.')
|
|
110
|
+
.option('-f, --force', 'Replace existing template files in the selected type set.')
|
|
111
|
+
.option('--dry-run', 'Preview template destinations and conflicts without writing files.')
|
|
112
|
+
.action(componentEjectTemplates);
|
|
168
113
|
const cache = program
|
|
169
114
|
.command('cache')
|
|
170
115
|
.description('Inspect or clear locally cached repositories');
|
|
@@ -173,29 +118,41 @@ cache
|
|
|
173
118
|
.description('Remove all locally cached Emulsify repositories')
|
|
174
119
|
.option('--dry-run', 'Report cache contents without removing files.')
|
|
175
120
|
.action(cacheClear);
|
|
121
|
+
const { cyan, green } = getTerminalColors();
|
|
176
122
|
const title = cyan(packageInfo.productName);
|
|
177
123
|
const message = `Version: ${green(packageInfo.version)}`;
|
|
178
124
|
const boxedMessage = boxen(message, {
|
|
179
125
|
title: title,
|
|
180
|
-
backgroundColor: 'black',
|
|
181
126
|
borderStyle: 'round',
|
|
182
|
-
borderColor: 'blue',
|
|
183
127
|
padding: 1,
|
|
184
128
|
margin: 1,
|
|
129
|
+
...(terminalSupportsColor()
|
|
130
|
+
? { backgroundColor: 'black', borderColor: 'blue' }
|
|
131
|
+
: {}),
|
|
185
132
|
});
|
|
186
133
|
program.version(boxedMessage);
|
|
187
134
|
const rootHelpRequested = process.argv.length <= 2 ||
|
|
188
135
|
(process.argv.length === 3 &&
|
|
189
136
|
['--help', '-h', 'help'].includes(process.argv[2]));
|
|
190
137
|
if (rootHelpRequested) {
|
|
191
|
-
process.stdout.write(getRootHelp(
|
|
138
|
+
process.stdout.write(getRootHelp({
|
|
139
|
+
colors: getTerminalColors(),
|
|
140
|
+
columns: process.stdout.isTTY === true ? process.stdout.columns : undefined,
|
|
141
|
+
description: packageInfo.description,
|
|
142
|
+
productName: packageInfo.productName,
|
|
143
|
+
version: packageInfo.version,
|
|
144
|
+
}));
|
|
192
145
|
process.exit(0);
|
|
193
146
|
}
|
|
194
147
|
try {
|
|
195
148
|
await program.parseAsync(process.argv);
|
|
196
149
|
}
|
|
197
150
|
catch (err) {
|
|
198
|
-
if (err
|
|
151
|
+
if (isExitPromptError(err)) {
|
|
152
|
+
log('info', 'Cancelled.');
|
|
153
|
+
process.exitCode = 130;
|
|
154
|
+
}
|
|
155
|
+
else if (err instanceof CliError) {
|
|
199
156
|
log('error', err.message);
|
|
200
157
|
process.exitCode = err.exitCode;
|
|
201
158
|
}
|
package/dist/lib/log.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { cyan, red, yellow, green, dim, bold } from 'colorette';
|
|
2
1
|
import consolaGlobalInstance from 'consola';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import getTerminalColors from './terminalColors.js';
|
|
3
|
+
const withColor = (logger) => (method, message) => {
|
|
4
|
+
const { bold, cyan, dim, green, red, yellow } = getTerminalColors();
|
|
5
|
+
const logMethodColorMap = {
|
|
6
|
+
info: cyan,
|
|
7
|
+
error: (value) => bold(red(value)),
|
|
8
|
+
warn: (value) => bold(yellow(value)),
|
|
9
|
+
debug: dim,
|
|
10
|
+
verbose: dim,
|
|
11
|
+
success: green,
|
|
12
|
+
};
|
|
13
|
+
logger(logMethodColorMap[method](message));
|
|
10
14
|
};
|
|
11
|
-
const withColor = (logger) => (method, message) => logger(logMethodColorMap[method](message));
|
|
12
15
|
export default function log(method, message) {
|
|
13
16
|
switch (method) {
|
|
14
17
|
case 'error':
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
const NATURAL_WIDTH = 80;
|
|
2
|
+
const COMMAND_COLUMN_WIDTH = 32;
|
|
3
|
+
const OPTION_COLUMN_WIDTH = 31;
|
|
4
|
+
const STEP_COMMAND_WIDTH = 36;
|
|
5
|
+
const steps = [
|
|
6
|
+
['emulsify init', 'create the project'],
|
|
7
|
+
['emulsify system install', 'pick a component system'],
|
|
8
|
+
['emulsify component list', 'see what you can install'],
|
|
9
|
+
['emulsify component install <name>', 'add a component'],
|
|
10
|
+
];
|
|
11
|
+
const sections = [
|
|
12
|
+
{
|
|
13
|
+
heading: 'PROJECTS',
|
|
14
|
+
rows: [
|
|
15
|
+
{
|
|
16
|
+
kind: 'command',
|
|
17
|
+
label: 'init [name] [path]',
|
|
18
|
+
description: 'Create a project from a starter repository',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
kind: 'option',
|
|
22
|
+
label: '-m, --machineName <name>',
|
|
23
|
+
description: 'Folder and config machine name',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
kind: 'option',
|
|
27
|
+
label: '-s, --starter <repository>',
|
|
28
|
+
description: 'Use a custom starter repository',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
kind: 'option',
|
|
32
|
+
label: '-c, --checkout <ref>',
|
|
33
|
+
description: 'Starter commit, branch, or tag',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
kind: 'option',
|
|
37
|
+
label: '-p, --platform <platform>',
|
|
38
|
+
description: 'none | drupal | wordpress',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
kind: 'option',
|
|
42
|
+
label: '-y, --yes',
|
|
43
|
+
description: 'Accept defaults without prompting',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
heading: 'COMPONENTS',
|
|
49
|
+
rows: [
|
|
50
|
+
{
|
|
51
|
+
kind: 'command',
|
|
52
|
+
label: 'component list',
|
|
53
|
+
description: 'Show what the installed system offers',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
kind: 'command',
|
|
57
|
+
label: 'component install [name]',
|
|
58
|
+
description: 'Copy a component into your project',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
kind: 'option',
|
|
62
|
+
label: '-a, --all',
|
|
63
|
+
description: 'Install every available component',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
kind: 'option',
|
|
67
|
+
label: '-f, --force',
|
|
68
|
+
description: 'Replace an existing destination',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
kind: 'option',
|
|
72
|
+
label: '--dry-run',
|
|
73
|
+
description: 'Preview without writing files',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
kind: 'command',
|
|
77
|
+
label: 'component create [name]',
|
|
78
|
+
description: 'Generate a new local component',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
kind: 'option',
|
|
82
|
+
label: '-d, --directory <dir>',
|
|
83
|
+
description: 'Variant structure to create it in',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
kind: 'option',
|
|
87
|
+
label: '-t, --type <type>',
|
|
88
|
+
description: 'twig | twig-sdc | react | web-component',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
kind: 'option',
|
|
92
|
+
label: '--tag-name <name>',
|
|
93
|
+
description: 'Set the Web Component custom element tag',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
kind: 'option',
|
|
97
|
+
label: '-f, --format <default|sdc>',
|
|
98
|
+
description: 'Deprecated Twig type alias',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
kind: 'option',
|
|
102
|
+
label: '--force',
|
|
103
|
+
description: 'Replace an existing generated component',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
kind: 'option',
|
|
107
|
+
label: '--dry-run',
|
|
108
|
+
description: 'Preview without writing files',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
kind: 'command',
|
|
112
|
+
label: 'component eject-templates [type]',
|
|
113
|
+
description: 'Write editable built-in templates',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
kind: 'option',
|
|
117
|
+
label: '-a, --all',
|
|
118
|
+
description: 'Eject every component template type',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
kind: 'option',
|
|
122
|
+
label: '-f, --force',
|
|
123
|
+
description: 'Replace existing template files',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
kind: 'option',
|
|
127
|
+
label: '--dry-run',
|
|
128
|
+
description: 'Preview paths and conflicts',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
heading: 'SYSTEMS',
|
|
134
|
+
rows: [
|
|
135
|
+
{
|
|
136
|
+
kind: 'command',
|
|
137
|
+
label: 'system list',
|
|
138
|
+
description: 'Show built-in systems',
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
kind: 'command',
|
|
142
|
+
label: 'system install [name]',
|
|
143
|
+
description: 'Add a component system to this project',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
kind: 'option',
|
|
147
|
+
label: '-r, --repository <repo>',
|
|
148
|
+
description: 'Install from a git repository',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
kind: 'option',
|
|
152
|
+
label: '-c, --checkout <ref>',
|
|
153
|
+
description: 'Commit, branch, or tag',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
kind: 'option',
|
|
157
|
+
label: '-a, --all',
|
|
158
|
+
description: 'Install every component, not just required',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
kind: 'command',
|
|
162
|
+
label: 'system detach',
|
|
163
|
+
description: 'Detach the system and keep project components',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
kind: 'option',
|
|
167
|
+
label: '-y, --yes',
|
|
168
|
+
description: 'Skip the confirmation prompt',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
kind: 'command',
|
|
172
|
+
label: 'system create [name]',
|
|
173
|
+
description: 'Scaffold a system others can install from',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
kind: 'option',
|
|
177
|
+
label: '--homepage <url>',
|
|
178
|
+
description: 'Replace TODO.invalid homepage metadata',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
kind: 'option',
|
|
182
|
+
label: '--repository <url>',
|
|
183
|
+
description: 'Replace TODO.invalid repository metadata',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
kind: 'option',
|
|
187
|
+
label: '--dry-run',
|
|
188
|
+
description: 'Preview files and Git setup',
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
heading: 'MAINTENANCE',
|
|
194
|
+
rows: [
|
|
195
|
+
{
|
|
196
|
+
kind: 'command',
|
|
197
|
+
label: 'audit [args...]',
|
|
198
|
+
description: 'Run the Emulsify Core audit',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
kind: 'command',
|
|
202
|
+
label: 'cache clear',
|
|
203
|
+
description: 'Remove cached system repositories',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
kind: 'option',
|
|
207
|
+
label: '--dry-run',
|
|
208
|
+
description: 'Preview cache removal',
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
function normalizeWidth(columns) {
|
|
214
|
+
return typeof columns === 'number' && Number.isFinite(columns) && columns > 0
|
|
215
|
+
? Math.floor(columns)
|
|
216
|
+
: NATURAL_WIDTH;
|
|
217
|
+
}
|
|
218
|
+
function wrapWords(text, width) {
|
|
219
|
+
const lines = [];
|
|
220
|
+
let current = '';
|
|
221
|
+
for (const word of text.split(/\s+/)) {
|
|
222
|
+
if (current && current.length + word.length + 1 <= width) {
|
|
223
|
+
current += ` ${word}`;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (current) {
|
|
227
|
+
lines.push(current);
|
|
228
|
+
current = '';
|
|
229
|
+
}
|
|
230
|
+
let remainder = word;
|
|
231
|
+
while (remainder.length > width) {
|
|
232
|
+
lines.push(remainder.slice(0, width));
|
|
233
|
+
remainder = remainder.slice(width);
|
|
234
|
+
}
|
|
235
|
+
current = remainder;
|
|
236
|
+
}
|
|
237
|
+
if (current) {
|
|
238
|
+
lines.push(current);
|
|
239
|
+
}
|
|
240
|
+
return lines;
|
|
241
|
+
}
|
|
242
|
+
function wrapIndented(text, indent, width) {
|
|
243
|
+
const usableIndent = Math.min(indent, Math.max(0, width - 1));
|
|
244
|
+
const prefix = ' '.repeat(usableIndent);
|
|
245
|
+
const contentWidth = Math.max(1, width - usableIndent);
|
|
246
|
+
return wrapWords(text, contentWidth).map((line) => `${prefix}${line}`);
|
|
247
|
+
}
|
|
248
|
+
function renderStackedRow(row, width, colors) {
|
|
249
|
+
const labelIndent = row.kind === 'option' ? 6 : 2;
|
|
250
|
+
const descriptionIndent = row.kind === 'option' ? 8 : 4;
|
|
251
|
+
const style = row.kind === 'option' ? colors.dim : colors.bold;
|
|
252
|
+
const descriptionStyle = row.kind === 'option' ? colors.dim : (value) => value;
|
|
253
|
+
return [
|
|
254
|
+
...wrapIndented(row.label, labelIndent, width).map(style),
|
|
255
|
+
...wrapIndented(row.description, descriptionIndent, width).map(descriptionStyle),
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
function renderRow(row, width, colors) {
|
|
259
|
+
const indent = row.kind === 'option' ? ' ' : ' ';
|
|
260
|
+
const columnWidth = row.kind === 'option' ? OPTION_COLUMN_WIDTH : COMMAND_COLUMN_WIDTH;
|
|
261
|
+
const gap = ' '.repeat(Math.max(2, columnWidth - row.label.length));
|
|
262
|
+
const plainLine = `${indent}${row.label}${gap}${row.description}`;
|
|
263
|
+
if (width < NATURAL_WIDTH || plainLine.length > width) {
|
|
264
|
+
return renderStackedRow(row, width, colors);
|
|
265
|
+
}
|
|
266
|
+
if (row.kind === 'option') {
|
|
267
|
+
return [colors.dim(plainLine)];
|
|
268
|
+
}
|
|
269
|
+
return [`${indent}${colors.bold(row.label)}${gap}${row.description}`];
|
|
270
|
+
}
|
|
271
|
+
function renderStep(step, index, width, colors) {
|
|
272
|
+
const [command, description] = step;
|
|
273
|
+
const prefix = ` ${index + 1} `;
|
|
274
|
+
const gap = ' '.repeat(Math.max(2, STEP_COMMAND_WIDTH - command.length));
|
|
275
|
+
const plainLine = `${prefix}${command}${gap}${description}`;
|
|
276
|
+
if (width < NATURAL_WIDTH || plainLine.length > width) {
|
|
277
|
+
const commandPrefix = ` ${index + 1} `;
|
|
278
|
+
const continuationPrefix = ' '.repeat(commandPrefix.length);
|
|
279
|
+
const commandLines = wrapWords(command, Math.max(1, width - commandPrefix.length));
|
|
280
|
+
return [
|
|
281
|
+
...commandLines.map((line, commandLineIndex) => colors.bold(`${commandLineIndex === 0 ? commandPrefix : continuationPrefix}${line}`)),
|
|
282
|
+
...wrapIndented(description, 7, width),
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
return [`${prefix}${colors.bold(command)}${gap}${description}`];
|
|
286
|
+
}
|
|
287
|
+
export default function getRootHelp({ colors, columns, description, productName, version, }) {
|
|
288
|
+
const width = normalizeWidth(columns);
|
|
289
|
+
const lines = [
|
|
290
|
+
...wrapWords(`${productName} ${version}`, width).map((line) => colors.bold(colors.cyan(line))),
|
|
291
|
+
'',
|
|
292
|
+
...wrapWords(description, width),
|
|
293
|
+
'',
|
|
294
|
+
...wrapIndented('New here? Run these in order:', 2, width).map(colors.bold),
|
|
295
|
+
];
|
|
296
|
+
for (const [index, step] of steps.entries()) {
|
|
297
|
+
lines.push(...renderStep(step, index, width, colors));
|
|
298
|
+
}
|
|
299
|
+
lines.push('');
|
|
300
|
+
for (const section of sections) {
|
|
301
|
+
lines.push(colors.bold(colors.cyan(section.heading)));
|
|
302
|
+
for (const row of section.rows) {
|
|
303
|
+
lines.push(...renderRow(row, width, colors));
|
|
304
|
+
}
|
|
305
|
+
lines.push('');
|
|
306
|
+
}
|
|
307
|
+
const refresh = '--refresh works on list, install, and create.';
|
|
308
|
+
const switches = '-V, --version -h, --help';
|
|
309
|
+
if (width >= NATURAL_WIDTH) {
|
|
310
|
+
lines.push(colors.dim(` ${refresh} ${switches}`));
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
lines.push(...wrapIndented(refresh, 2, width).map(colors.dim));
|
|
314
|
+
const switchLine = ` ${switches}`;
|
|
315
|
+
lines.push(...(switchLine.length <= width
|
|
316
|
+
? [colors.dim(switchLine)]
|
|
317
|
+
: wrapIndented(switches, 2, width).map(colors.dim)));
|
|
318
|
+
}
|
|
319
|
+
lines.push(...wrapIndented('emulsify <command> --help for the full option list.', 2, width), '');
|
|
320
|
+
return lines.join('\n');
|
|
321
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createColors } from 'colorette';
|
|
2
|
+
export function terminalSupportsColor(output = process.stdout, environment = process.env) {
|
|
3
|
+
return (output.isTTY === true &&
|
|
4
|
+
!Object.prototype.hasOwnProperty.call(environment, 'NO_COLOR'));
|
|
5
|
+
}
|
|
6
|
+
export default function getTerminalColors(output = process.stdout, environment = process.env) {
|
|
7
|
+
return createColors({
|
|
8
|
+
useColor: terminalSupportsColor(output, environment),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -4,6 +4,7 @@ import { basename, dirname, join } from 'path';
|
|
|
4
4
|
import { EMULSIFY_CACHE_METADATA_FILE } from '../../lib/constants.js';
|
|
5
5
|
import getCachedItemPath from './getCachedItemPath.js';
|
|
6
6
|
import normalizeRepositoryUrl from './normalizeRepositoryUrl.js';
|
|
7
|
+
import getNonInteractiveGitEnvironment from '../getNonInteractiveGitEnvironment.js';
|
|
7
8
|
const REMOTE_REF_LOOKUP_TIMEOUT_MS = 2_000;
|
|
8
9
|
const TEMP_DIRECTORY_MARKER = '.tmp-';
|
|
9
10
|
const ABANDONED_TEMP_DIRECTORY_AGE_MS = 24 * 60 * 60 * 1_000;
|
|
@@ -98,10 +99,7 @@ async function getRemoteResolvedRef(repository, checkout) {
|
|
|
98
99
|
stdOut: false,
|
|
99
100
|
stdErr: false,
|
|
100
101
|
},
|
|
101
|
-
}).env(
|
|
102
|
-
...process.env,
|
|
103
|
-
GIT_TERMINAL_PROMPT: '0',
|
|
104
|
-
});
|
|
102
|
+
}).env(getNonInteractiveGitEnvironment());
|
|
105
103
|
const output = await git.listRemote([repository, ...remoteRefs]);
|
|
106
104
|
const resolvedRefs = new Map();
|
|
107
105
|
for (const line of output.trim().split(/\r?\n/)) {
|
|
@@ -11,6 +11,10 @@ export default function deriveComponentNames(componentName) {
|
|
|
11
11
|
const filename = strToMachineName(sanitizedName.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/-/g, ' '));
|
|
12
12
|
const className = filename;
|
|
13
13
|
const camelName = filename.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
14
|
+
const pascalCandidate = `${camelName.charAt(0).toUpperCase()}${camelName.slice(1)}`;
|
|
15
|
+
const pascalName = /^[A-Za-z_$]/.test(pascalCandidate)
|
|
16
|
+
? pascalCandidate
|
|
17
|
+
: `Component${pascalCandidate}`;
|
|
14
18
|
const snakeName = filename.replace(/-/g, '_');
|
|
15
19
|
const humanName = filename
|
|
16
20
|
.split('-')
|
|
@@ -20,6 +24,7 @@ export default function deriveComponentNames(componentName) {
|
|
|
20
24
|
filename,
|
|
21
25
|
className,
|
|
22
26
|
camelName,
|
|
27
|
+
pascalName,
|
|
23
28
|
snakeName,
|
|
24
29
|
humanName,
|
|
25
30
|
};
|