@emulsify/cli 2.4.2 → 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 +57 -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 +1 -0
- package/dist/schemas/variant.json +8 -0
- 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 +13 -27
- package/package.json +16 -18
- package/dist/handlers/hofs/withProgressBar.js +0 -10
|
@@ -1,14 +1,29 @@
|
|
|
1
|
+
import { isCancel } from '@clack/prompts';
|
|
1
2
|
import CliError from '../../lib/CliError.js';
|
|
2
|
-
export
|
|
3
|
-
|
|
3
|
+
export const PROMPT_CANCELLED_EXIT_CODE = 130;
|
|
4
|
+
export const PROMPT_CANCELLED_MESSAGE = 'Cancelled. Nothing was changed.';
|
|
5
|
+
export class PromptCancelledError extends CliError {
|
|
6
|
+
constructor(message = PROMPT_CANCELLED_MESSAGE) {
|
|
7
|
+
super(message, PROMPT_CANCELLED_EXIT_CODE);
|
|
8
|
+
this.name = 'PromptCancelledError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function isInteractiveTerminal(input = process.stdin, environment = process.env) {
|
|
12
|
+
return input.isTTY === true && !environment.CI;
|
|
4
13
|
}
|
|
5
14
|
export function requireInteractiveTerminal(nonInteractiveError) {
|
|
6
15
|
if (!isInteractiveTerminal()) {
|
|
7
16
|
throw new CliError(nonInteractiveError);
|
|
8
17
|
}
|
|
9
18
|
}
|
|
10
|
-
export function
|
|
11
|
-
return error instanceof
|
|
19
|
+
export function isPromptCancelledError(error) {
|
|
20
|
+
return error instanceof PromptCancelledError;
|
|
21
|
+
}
|
|
22
|
+
export function unwrapPromptResult(result) {
|
|
23
|
+
if (isCancel(result)) {
|
|
24
|
+
throw new PromptCancelledError();
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
12
27
|
}
|
|
13
28
|
export async function runPrompt({ prompt, nonInteractive, accept, }) {
|
|
14
29
|
if (accept?.when === true) {
|
|
@@ -16,10 +31,10 @@ export async function runPrompt({ prompt, nonInteractive, accept, }) {
|
|
|
16
31
|
}
|
|
17
32
|
if ('error' in nonInteractive) {
|
|
18
33
|
requireInteractiveTerminal(nonInteractive.error);
|
|
19
|
-
return prompt();
|
|
34
|
+
return unwrapPromptResult(await prompt());
|
|
20
35
|
}
|
|
21
36
|
if (!isInteractiveTerminal()) {
|
|
22
37
|
return nonInteractive.value;
|
|
23
38
|
}
|
|
24
|
-
return prompt();
|
|
39
|
+
return unwrapPromptResult(await prompt());
|
|
25
40
|
}
|
|
@@ -1,45 +1,27 @@
|
|
|
1
1
|
import { Ajv } from 'ajv';
|
|
2
2
|
import addFormats from 'ajv-formats';
|
|
3
|
+
import { lt, valid } from 'semver';
|
|
3
4
|
import CliError from '../../lib/CliError.js';
|
|
4
5
|
import log from '../../lib/log.js';
|
|
5
6
|
const upgradeCommand = 'npm i -g @emulsify/cli@latest';
|
|
6
|
-
async function
|
|
7
|
-
const [{ default: systemSchema }, { default: variantSchema }] = await Promise.all([
|
|
7
|
+
async function createValidator() {
|
|
8
|
+
const [{ default: systemSchema }, { default: variantSchema }, { default: packageInfo },] = await Promise.all([
|
|
8
9
|
import('../../schemas/system.json', { with: { type: 'json' } }),
|
|
9
10
|
import('../../schemas/variant.json', { with: { type: 'json' } }),
|
|
10
|
-
]);
|
|
11
|
-
return { systemSchema, variantSchema };
|
|
12
|
-
}
|
|
13
|
-
async function createValidator() {
|
|
14
|
-
const [schemas, { default: packageInfo }] = await Promise.all([
|
|
15
|
-
loadSchemas(),
|
|
16
11
|
import('../../../package.json', { with: { type: 'json' } }),
|
|
17
12
|
]);
|
|
18
13
|
const ajv = new Ajv();
|
|
19
14
|
addFormats(ajv, ['uri']);
|
|
20
|
-
ajv.
|
|
15
|
+
ajv.addFormat('semver', (value) => valid(value) !== null);
|
|
16
|
+
ajv.addSchema(variantSchema, 'variant.json');
|
|
21
17
|
return {
|
|
22
|
-
validate: ajv.compile(
|
|
23
|
-
schemas,
|
|
18
|
+
validate: ajv.compile(systemSchema),
|
|
19
|
+
schemas: { systemSchema, variantSchema },
|
|
24
20
|
runningVersion: packageInfo.version,
|
|
25
21
|
};
|
|
26
22
|
}
|
|
27
23
|
let validatorPromise;
|
|
28
|
-
function
|
|
29
|
-
if (minimumCliVersion === undefined)
|
|
30
|
-
return;
|
|
31
|
-
const minimum = minimumCliVersion.match(/^(\d+)\.(\d+)\.(\d+)(?:[-+].+)?$/);
|
|
32
|
-
if (!minimum) {
|
|
33
|
-
throw new CliError(`The ${JSON.stringify(name)} system has an invalid minimumCliVersion ${JSON.stringify(minimumCliVersion)}. Use a version such as "2.5.0".`);
|
|
34
|
-
}
|
|
35
|
-
const running = runningVersion.split(/[.+-]/, 3).map(Number);
|
|
36
|
-
const required = minimum.slice(1).map(Number);
|
|
37
|
-
const index = required.findIndex((part, i) => part !== running[i]);
|
|
38
|
-
if (index !== -1 && running[index] < required[index]) {
|
|
39
|
-
throw new CliError(`The ${JSON.stringify(name)} system requires Emulsify CLI ${minimumCliVersion} or newer. You are running ${runningVersion}. Upgrade with: ${upgradeCommand}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function warnUnknownProperties(systemConfig, { systemSchema, variantSchema }) {
|
|
24
|
+
function warnUnknownProperties(systemConfig, { systemSchema, variantSchema, }) {
|
|
43
25
|
const unknown = [];
|
|
44
26
|
const collect = (value, properties, location) => {
|
|
45
27
|
const keys = Object.keys(value).filter((key) => !Object.hasOwn(properties, key));
|
|
@@ -72,7 +54,11 @@ export default async function validateSystemConfig(systemConfig) {
|
|
|
72
54
|
const { validate, schemas, runningVersion } = await (validatorPromise ??=
|
|
73
55
|
createValidator());
|
|
74
56
|
if (validate(systemConfig)) {
|
|
75
|
-
|
|
57
|
+
const { name, minimumCliVersion } = systemConfig;
|
|
58
|
+
if (minimumCliVersion !== undefined &&
|
|
59
|
+
lt(runningVersion.split(/[+-]/, 1)[0], minimumCliVersion.split(/[+-]/, 1)[0])) {
|
|
60
|
+
throw new CliError(`The ${JSON.stringify(name)} system requires Emulsify CLI ${minimumCliVersion} or newer. You are running ${runningVersion}. Upgrade with: ${upgradeCommand}`);
|
|
61
|
+
}
|
|
76
62
|
warnUnknownProperties(systemConfig, schemas);
|
|
77
63
|
return { valid: true, systemConfig };
|
|
78
64
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emulsify/cli",
|
|
3
3
|
"productName": "Emulsify CLI",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"description": "Build and use component systems in Drupal, WordPress, or standalone front ends.",
|
|
6
6
|
"repository": "git@github.com:emulsify-ds/emulsify-cli.git",
|
|
7
7
|
"author": "Patrick Coffey <patrickcoffey48@gmail.com>",
|
|
@@ -49,37 +49,35 @@
|
|
|
49
49
|
"prepare": "husky"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@commitlint/cli": "^21.2.
|
|
53
|
-
"@commitlint/config-conventional": "^21.2.
|
|
52
|
+
"@commitlint/cli": "^21.2.4",
|
|
53
|
+
"@commitlint/config-conventional": "^21.2.4",
|
|
54
54
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
55
|
-
"@semantic-release/github": "^12.0.
|
|
56
|
-
"@semantic-release/npm": "^13.
|
|
55
|
+
"@semantic-release/github": "^12.0.11",
|
|
56
|
+
"@semantic-release/npm": "^13.2.0",
|
|
57
57
|
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
58
58
|
"@types/fs-extra": "^11.0.4",
|
|
59
59
|
"@types/jest": "^30.0.0",
|
|
60
|
-
"@types/node": "^26.
|
|
61
|
-
"@types/
|
|
60
|
+
"@types/node": "^26.6.10",
|
|
61
|
+
"@types/semver": "^7.8.0",
|
|
62
62
|
"husky": "^9.1.7",
|
|
63
|
-
"jest": "^30.5.
|
|
63
|
+
"jest": "^30.5.2",
|
|
64
64
|
"json-schema-to-typescript": "^16.0.0",
|
|
65
|
-
"lint-staged": "^17.
|
|
65
|
+
"lint-staged": "^17.6.2",
|
|
66
66
|
"nodemon": "^3.1.14",
|
|
67
|
-
"prettier": "^3.
|
|
67
|
+
"prettier": "^3.10.1",
|
|
68
68
|
"semantic-release": "^25.0.9",
|
|
69
|
-
"ts-jest": "^29.4.
|
|
69
|
+
"ts-jest": "^29.4.15",
|
|
70
70
|
"ts-node": "^10.9.2",
|
|
71
71
|
"typescript": "^6.0.3"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@
|
|
74
|
+
"@clack/prompts": "^1.9.0",
|
|
75
75
|
"ajv": "^8.20.0",
|
|
76
76
|
"ajv-formats": "^3.0.1",
|
|
77
|
-
"boxen": "^8.0.1",
|
|
78
77
|
"colorette": "^2.0.20",
|
|
79
|
-
"commander": "^15.
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"simple-git": "^4.0.2"
|
|
78
|
+
"commander": "^15.1.0",
|
|
79
|
+
"fs-extra": "^11.4.1",
|
|
80
|
+
"semver": "^7.8.6",
|
|
81
|
+
"simple-git": "^4.1.0"
|
|
84
82
|
}
|
|
85
83
|
}
|