trix-ui 0.1.9 → 0.2.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/dist/commands/add-collection.d.ts +1 -0
- package/dist/commands/add-collection.js +2 -0
- package/dist/commands/add-collection.js.map +1 -0
- package/dist/commands/add-section.js +162 -60
- package/dist/commands/add-section.js.map +1 -1
- package/dist/commands/add-wrapper.js +162 -60
- package/dist/commands/add-wrapper.js.map +1 -1
- package/dist/commands/shared/add-collection.d.ts +49 -0
- package/dist/commands/shared/add-collection.js +210 -0
- package/dist/commands/shared/add-collection.js.map +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./shared/add-collection.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-collection.js","sourceRoot":"","sources":["../../src/commands/add-collection.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
@@ -1,94 +1,196 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import { Command } from "commander";
|
|
4
|
+
import ora from "ora";
|
|
3
5
|
import { loadConfig } from "../lib/config.js";
|
|
4
|
-
import {
|
|
5
|
-
import { installRegistryEntries } from "../lib/install.js";
|
|
6
|
+
import { directoryExists } from "../lib/fs.js";
|
|
6
7
|
import { loadLockfile, saveLockfile } from "../lib/lockfile.js";
|
|
7
|
-
import {
|
|
8
|
+
import { logger } from "../lib/logger.js";
|
|
8
9
|
import { getRegistrySections, loadRegistry } from "../lib/registry.js";
|
|
10
|
+
import { analyzeEntryDependencies, confirmOverwrite, createEmptyResult, displayInstallationPlan, displayResults, getEntryNames, installEntries, normalizeEntryNames, validateEntries } from "./shared/add-collection.js";
|
|
11
|
+
import { ensureProjectFiles } from "./add/project-files.js";
|
|
12
|
+
import { confirmDependencyInstallation, confirmInstallation } from "./add/prompts.js";
|
|
13
|
+
import { displayManualInstallInstructions } from "./add/ui.js";
|
|
14
|
+
import { installNpmDependencies } from "./add/install.js";
|
|
15
|
+
function toAddConfig(config) {
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
const SECTION_LABELS = {
|
|
19
|
+
entrySingular: "section",
|
|
20
|
+
entryPlural: "sections"
|
|
21
|
+
};
|
|
9
22
|
export const addSectionCommand = new Command("add-section")
|
|
10
23
|
.description("Add prebuilt sections to your project")
|
|
11
|
-
.argument("<sections...>", "section names")
|
|
12
|
-
.option("--force", "overwrite existing files")
|
|
24
|
+
.argument("<sections...>", "section names (or 'all' to install everything)")
|
|
25
|
+
.option("-f, --force", "overwrite existing files", false)
|
|
26
|
+
.option("-y, --yes", "skip confirmation prompts", false)
|
|
27
|
+
.option("-s, --silent", "suppress output messages", false)
|
|
28
|
+
.option("-c, --cwd <path>", "working directory to add sections")
|
|
29
|
+
.option("--skip-deps", "skip dependency installation", false)
|
|
13
30
|
.action(async (sections, options) => {
|
|
31
|
+
const spinner = options.silent ? null : ora({ color: "blue" });
|
|
32
|
+
const shouldLog = !options.silent;
|
|
33
|
+
const shouldPrompt = !options.yes && !options.silent;
|
|
14
34
|
try {
|
|
15
|
-
const cwd = process.cwd();
|
|
16
|
-
|
|
35
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
36
|
+
if (shouldLog) {
|
|
37
|
+
logger.info({ cwd }, "Adding sections");
|
|
38
|
+
}
|
|
39
|
+
if (!(await directoryExists(cwd))) {
|
|
40
|
+
logger.error(`Directory does not exist: ${cwd}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
spinner?.start("Loading configuration...");
|
|
44
|
+
const config = toAddConfig(await loadConfig(cwd));
|
|
45
|
+
spinner?.succeed("Configuration loaded");
|
|
46
|
+
spinner?.start("Loading registry and lockfile...");
|
|
17
47
|
const registry = await loadRegistry(config, cwd);
|
|
18
48
|
const lockfile = await loadLockfile(cwd);
|
|
49
|
+
spinner?.succeed("Registry and lockfile loaded");
|
|
19
50
|
const availableSections = getRegistrySections(registry);
|
|
20
51
|
if (availableSections.length === 0) {
|
|
21
|
-
|
|
52
|
+
logger.error("No sections available in the registry.");
|
|
53
|
+
process.exit(1);
|
|
22
54
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const missing = uniqueSections.filter((name) => !sectionMap.has(name));
|
|
28
|
-
if (missing.length) {
|
|
29
|
-
throw new Error(`Unknown sections: ${missing.join(", ")}`);
|
|
55
|
+
let requestedSections = normalizeEntryNames(sections);
|
|
56
|
+
if (requestedSections.length === 0) {
|
|
57
|
+
logger.error("No section names provided.");
|
|
58
|
+
process.exit(1);
|
|
30
59
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
60
|
+
if (requestedSections.includes("all")) {
|
|
61
|
+
const allSections = getEntryNames(availableSections);
|
|
62
|
+
if (shouldLog) {
|
|
63
|
+
console.log(chalk.yellow(`\nThis will install ${allSections.length} sections:`));
|
|
64
|
+
console.log(chalk.gray(allSections.join(", ")));
|
|
65
|
+
}
|
|
66
|
+
const shouldContinue = shouldPrompt
|
|
67
|
+
? await confirmInstallation(`all ${allSections.length} sections`)
|
|
68
|
+
: true;
|
|
69
|
+
if (!shouldContinue) {
|
|
70
|
+
logger.info("Installation cancelled");
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
requestedSections = allSections;
|
|
34
74
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
75
|
+
spinner?.start("Validating sections...");
|
|
76
|
+
const validation = validateEntries(requestedSections, availableSections);
|
|
77
|
+
spinner?.stop();
|
|
78
|
+
if (validation.invalid.length > 0) {
|
|
79
|
+
logger.error("The following sections were not found:");
|
|
80
|
+
validation.invalid.forEach((name) => logger.error(` \u0007 ${name}`));
|
|
81
|
+
if (validation.suggestions.length > 0 && shouldLog) {
|
|
82
|
+
console.log(chalk.yellow("\nDid you mean:"));
|
|
83
|
+
validation.suggestions.forEach((suggestion) => console.log(chalk.gray(` \u0007 ${suggestion}`)));
|
|
84
|
+
}
|
|
85
|
+
process.exit(1);
|
|
86
|
+
return;
|
|
38
87
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
88
|
+
spinner?.start("Analyzing dependencies...");
|
|
89
|
+
const analysis = analyzeEntryDependencies(validation.valid, availableSections, registry, lockfile, "sections");
|
|
90
|
+
spinner?.stop();
|
|
91
|
+
if (shouldLog) {
|
|
92
|
+
displayInstallationPlan(analysis, options, SECTION_LABELS);
|
|
43
93
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
94
|
+
let forceInstall = Boolean(options.force);
|
|
95
|
+
if (analysis.conflicts.length > 0 && !forceInstall) {
|
|
96
|
+
if (shouldLog) {
|
|
97
|
+
logger.warn("The following sections or dependencies already exist:");
|
|
98
|
+
analysis.conflicts.forEach((name) => logger.warn(` \u0007 ${name}`));
|
|
99
|
+
}
|
|
100
|
+
if (options.yes) {
|
|
101
|
+
forceInstall = true;
|
|
102
|
+
}
|
|
103
|
+
else if (shouldPrompt) {
|
|
104
|
+
const shouldOverwrite = await confirmOverwrite(SECTION_LABELS.entryPlural);
|
|
105
|
+
if (!shouldOverwrite) {
|
|
106
|
+
logger.info("Installation cancelled");
|
|
107
|
+
process.exit(0);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
forceInstall = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const installCount = forceInstall
|
|
114
|
+
? analysis.totalTargets
|
|
115
|
+
: analysis.totalToInstall;
|
|
116
|
+
if (shouldPrompt && installCount > 0) {
|
|
117
|
+
const label = analysis.componentDependencies.length > 0
|
|
118
|
+
? `${installCount} item${installCount > 1 ? "s" : ""}`
|
|
119
|
+
: `${installCount} ${SECTION_LABELS.entrySingular}${installCount > 1 ? "s" : ""}`;
|
|
120
|
+
const shouldInstall = await confirmInstallation(label);
|
|
121
|
+
if (!shouldInstall) {
|
|
122
|
+
logger.info("Installation cancelled");
|
|
123
|
+
process.exit(0);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
spinner?.start("Verifying project setup...");
|
|
128
|
+
await ensureProjectFiles(cwd, config);
|
|
129
|
+
spinner?.succeed("Project setup verified");
|
|
130
|
+
const dependenciesResult = analysis.componentDependencies.length > 0
|
|
131
|
+
? await installEntries(registry.components, analysis.componentDependencies, lockfile.components, {
|
|
49
132
|
cwd,
|
|
50
133
|
config,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
dependencyInstalled = dependencySummary.installed;
|
|
58
|
-
dependencySkipped = dependencySummary.skipped;
|
|
59
|
-
dependencySummary.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
60
|
-
}
|
|
61
|
-
const sectionSummary = await installRegistryEntries({
|
|
134
|
+
force: forceInstall,
|
|
135
|
+
spinner,
|
|
136
|
+
itemLabel: "component"
|
|
137
|
+
})
|
|
138
|
+
: createEmptyResult();
|
|
139
|
+
const sectionsResult = await installEntries(availableSections, validation.valid, lockfile.sections, {
|
|
62
140
|
cwd,
|
|
63
141
|
config,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
force: Boolean(options.force),
|
|
68
|
-
itemLabel: "sections"
|
|
142
|
+
force: forceInstall,
|
|
143
|
+
spinner,
|
|
144
|
+
itemLabel: "section"
|
|
69
145
|
});
|
|
70
|
-
|
|
146
|
+
const npmDependencies = new Set();
|
|
147
|
+
dependenciesResult.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
148
|
+
sectionsResult.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
149
|
+
spinner?.start("Updating lockfile...");
|
|
71
150
|
await saveLockfile(cwd, lockfile);
|
|
72
|
-
|
|
73
|
-
|
|
151
|
+
spinner?.succeed("Lockfile updated");
|
|
152
|
+
const combinedResult = {
|
|
153
|
+
entries: sectionsResult,
|
|
154
|
+
dependencies: dependenciesResult,
|
|
155
|
+
npmDependencies,
|
|
156
|
+
conflicts: analysis.conflicts
|
|
157
|
+
};
|
|
158
|
+
if (npmDependencies.size > 0 && !options.skipDeps) {
|
|
159
|
+
const shouldInstallDeps = shouldPrompt
|
|
160
|
+
? await confirmDependencyInstallation(npmDependencies)
|
|
161
|
+
: true;
|
|
162
|
+
if (shouldInstallDeps) {
|
|
163
|
+
await installNpmDependencies({
|
|
164
|
+
cwd,
|
|
165
|
+
dependencies: npmDependencies,
|
|
166
|
+
spinner
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (shouldLog) {
|
|
171
|
+
await displayManualInstallInstructions(npmDependencies, cwd);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
74
174
|
}
|
|
75
|
-
if (
|
|
76
|
-
|
|
175
|
+
else if (npmDependencies.size > 0 && shouldLog) {
|
|
176
|
+
await displayManualInstallInstructions(npmDependencies, cwd);
|
|
77
177
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
178
|
+
if (shouldLog) {
|
|
179
|
+
displayResults(combinedResult, { ...options, force: forceInstall }, SECTION_LABELS);
|
|
80
180
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (npmDependencies.size) {
|
|
85
|
-
console.log(`\nInstall dependencies:`);
|
|
86
|
-
console.log(`npm install ${[...npmDependencies].join(" ")}`);
|
|
181
|
+
if (sectionsResult.failed.length > 0 || dependenciesResult.failed.length > 0) {
|
|
182
|
+
process.exit(1);
|
|
183
|
+
return;
|
|
87
184
|
}
|
|
88
185
|
}
|
|
89
186
|
catch (error) {
|
|
90
|
-
|
|
187
|
+
spinner?.fail("Installation failed");
|
|
188
|
+
logger.error(error.message);
|
|
189
|
+
if (process.env.DEBUG) {
|
|
190
|
+
console.error(error);
|
|
191
|
+
}
|
|
91
192
|
process.exit(1);
|
|
193
|
+
return;
|
|
92
194
|
}
|
|
93
195
|
});
|
|
94
196
|
//# sourceMappingURL=add-section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-section.js","sourceRoot":"","sources":["../../src/commands/add-section.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"add-section.js","sourceRoot":"","sources":["../../src/commands/add-section.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,GAAiB,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,cAAc,EACd,mBAAmB,EAEnB,eAAe,EAChB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,EACpB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,gCAAgC,EACjC,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAGzD,SAAS,WAAW,CAAC,MAAoB;IACvC,OAAO,MAAmB,CA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AE,CAAC;YACd,cAAc,CACZ,cAAc,EACd,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EACnC,cAAc,CACf,CAAA;QACH,CAAC;QAED,IAAI,cAAc,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACf,OAAM;QACR,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;QACpC,MAAM,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAA;QACtC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACf,OAAM;IACR,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,94 +1,196 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import { Command } from "commander";
|
|
4
|
+
import ora from "ora";
|
|
3
5
|
import { loadConfig } from "../lib/config.js";
|
|
4
|
-
import {
|
|
5
|
-
import { installRegistryEntries } from "../lib/install.js";
|
|
6
|
+
import { directoryExists } from "../lib/fs.js";
|
|
6
7
|
import { loadLockfile, saveLockfile } from "../lib/lockfile.js";
|
|
7
|
-
import {
|
|
8
|
+
import { logger } from "../lib/logger.js";
|
|
8
9
|
import { getRegistryWrappers, loadRegistry } from "../lib/registry.js";
|
|
10
|
+
import { analyzeEntryDependencies, confirmOverwrite, createEmptyResult, displayInstallationPlan, displayResults, getEntryNames, installEntries, normalizeEntryNames, validateEntries } from "./add-collection.js";
|
|
11
|
+
import { ensureProjectFiles } from "./add/project-files.js";
|
|
12
|
+
import { confirmDependencyInstallation, confirmInstallation } from "./add/prompts.js";
|
|
13
|
+
import { displayManualInstallInstructions } from "./add/ui.js";
|
|
14
|
+
import { installNpmDependencies } from "./add/install.js";
|
|
15
|
+
const WRAPPER_LABELS = {
|
|
16
|
+
entrySingular: "wrapper",
|
|
17
|
+
entryPlural: "wrappers"
|
|
18
|
+
};
|
|
19
|
+
function toAddConfig(config) {
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
9
22
|
export const addWrapperCommand = new Command("add-wrapper")
|
|
10
23
|
.description("Add prebuilt wrappers to your project")
|
|
11
|
-
.argument("<wrappers...>", "wrapper names")
|
|
12
|
-
.option("--force", "overwrite existing files")
|
|
24
|
+
.argument("<wrappers...>", "wrapper names (or 'all' to install everything)")
|
|
25
|
+
.option("-f, --force", "overwrite existing files", false)
|
|
26
|
+
.option("-y, --yes", "skip confirmation prompts", false)
|
|
27
|
+
.option("-s, --silent", "suppress output messages", false)
|
|
28
|
+
.option("-c, --cwd <path>", "working directory to add wrappers")
|
|
29
|
+
.option("--skip-deps", "skip dependency installation", false)
|
|
13
30
|
.action(async (wrappers, options) => {
|
|
31
|
+
const spinner = options.silent ? null : ora({ color: "blue" });
|
|
32
|
+
const shouldLog = !options.silent;
|
|
33
|
+
const shouldPrompt = !options.yes && !options.silent;
|
|
14
34
|
try {
|
|
15
|
-
const cwd = process.cwd();
|
|
16
|
-
|
|
35
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
36
|
+
if (shouldLog) {
|
|
37
|
+
logger.info({ cwd }, "Adding wrappers");
|
|
38
|
+
}
|
|
39
|
+
if (!(await directoryExists(cwd))) {
|
|
40
|
+
logger.error(`Directory does not exist: ${cwd}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
spinner?.start("Loading configuration...");
|
|
44
|
+
const config = toAddConfig(await loadConfig(cwd));
|
|
45
|
+
spinner?.succeed("Configuration loaded");
|
|
46
|
+
spinner?.start("Loading registry and lockfile...");
|
|
17
47
|
const registry = await loadRegistry(config, cwd);
|
|
18
48
|
const lockfile = await loadLockfile(cwd);
|
|
49
|
+
spinner?.succeed("Registry and lockfile loaded");
|
|
19
50
|
const availableWrappers = getRegistryWrappers(registry);
|
|
20
51
|
if (availableWrappers.length === 0) {
|
|
21
|
-
|
|
52
|
+
logger.error("No wrappers available in the registry.");
|
|
53
|
+
process.exit(1);
|
|
22
54
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const missing = uniqueWrappers.filter((name) => !wrapperMap.has(name));
|
|
28
|
-
if (missing.length) {
|
|
29
|
-
throw new Error(`Unknown wrappers: ${missing.join(", ")}`);
|
|
55
|
+
let requestedWrappers = normalizeEntryNames(wrappers);
|
|
56
|
+
if (requestedWrappers.length === 0) {
|
|
57
|
+
logger.error("No wrapper names provided.");
|
|
58
|
+
process.exit(1);
|
|
30
59
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
60
|
+
if (requestedWrappers.includes("all")) {
|
|
61
|
+
const allWrappers = getEntryNames(availableWrappers);
|
|
62
|
+
if (shouldLog) {
|
|
63
|
+
console.log(chalk.yellow(`\nThis will install ${allWrappers.length} wrappers:`));
|
|
64
|
+
console.log(chalk.gray(allWrappers.join(", ")));
|
|
65
|
+
}
|
|
66
|
+
const shouldContinue = shouldPrompt
|
|
67
|
+
? await confirmInstallation(`all ${allWrappers.length} wrappers`)
|
|
68
|
+
: true;
|
|
69
|
+
if (!shouldContinue) {
|
|
70
|
+
logger.info("Installation cancelled");
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
requestedWrappers = allWrappers;
|
|
34
74
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
75
|
+
spinner?.start("Validating wrappers...");
|
|
76
|
+
const validation = validateEntries(requestedWrappers, availableWrappers);
|
|
77
|
+
spinner?.stop();
|
|
78
|
+
if (validation.invalid.length > 0) {
|
|
79
|
+
logger.error("The following wrappers were not found:");
|
|
80
|
+
validation.invalid.forEach((name) => logger.error(` \u0007 ${name}`));
|
|
81
|
+
if (validation.suggestions.length > 0 && shouldLog) {
|
|
82
|
+
console.log(chalk.yellow("\nDid you mean:"));
|
|
83
|
+
validation.suggestions.forEach((suggestion) => console.log(chalk.gray(` \u0007 ${suggestion}`)));
|
|
84
|
+
}
|
|
85
|
+
process.exit(1);
|
|
86
|
+
return;
|
|
38
87
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
88
|
+
spinner?.start("Analyzing dependencies...");
|
|
89
|
+
const analysis = analyzeEntryDependencies(validation.valid, availableWrappers, registry, lockfile, "wrappers");
|
|
90
|
+
spinner?.stop();
|
|
91
|
+
if (shouldLog) {
|
|
92
|
+
displayInstallationPlan(analysis, options, WRAPPER_LABELS);
|
|
43
93
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
94
|
+
let forceInstall = Boolean(options.force);
|
|
95
|
+
if (analysis.conflicts.length > 0 && !forceInstall) {
|
|
96
|
+
if (shouldLog) {
|
|
97
|
+
logger.warn("The following wrappers or dependencies already exist:");
|
|
98
|
+
analysis.conflicts.forEach((name) => logger.warn(` \u0007 ${name}`));
|
|
99
|
+
}
|
|
100
|
+
if (options.yes) {
|
|
101
|
+
forceInstall = true;
|
|
102
|
+
}
|
|
103
|
+
else if (shouldPrompt) {
|
|
104
|
+
const shouldOverwrite = await confirmOverwrite(WRAPPER_LABELS.entryPlural);
|
|
105
|
+
if (!shouldOverwrite) {
|
|
106
|
+
logger.info("Installation cancelled");
|
|
107
|
+
process.exit(0);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
forceInstall = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const installCount = forceInstall
|
|
114
|
+
? analysis.totalTargets
|
|
115
|
+
: analysis.totalToInstall;
|
|
116
|
+
if (shouldPrompt && installCount > 0) {
|
|
117
|
+
const label = analysis.componentDependencies.length > 0
|
|
118
|
+
? `${installCount} item${installCount > 1 ? "s" : ""}`
|
|
119
|
+
: `${installCount} ${WRAPPER_LABELS.entrySingular}${installCount > 1 ? "s" : ""}`;
|
|
120
|
+
const shouldInstall = await confirmInstallation(label);
|
|
121
|
+
if (!shouldInstall) {
|
|
122
|
+
logger.info("Installation cancelled");
|
|
123
|
+
process.exit(0);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
spinner?.start("Verifying project setup...");
|
|
128
|
+
await ensureProjectFiles(cwd, config);
|
|
129
|
+
spinner?.succeed("Project setup verified");
|
|
130
|
+
const dependenciesResult = analysis.componentDependencies.length > 0
|
|
131
|
+
? await installEntries(registry.components, analysis.componentDependencies, lockfile.components, {
|
|
49
132
|
cwd,
|
|
50
133
|
config,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
dependencyInstalled = dependencySummary.installed;
|
|
58
|
-
dependencySkipped = dependencySummary.skipped;
|
|
59
|
-
dependencySummary.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
60
|
-
}
|
|
61
|
-
const wrapperSummary = await installRegistryEntries({
|
|
134
|
+
force: forceInstall,
|
|
135
|
+
spinner,
|
|
136
|
+
itemLabel: "component"
|
|
137
|
+
})
|
|
138
|
+
: createEmptyResult();
|
|
139
|
+
const wrappersResult = await installEntries(availableWrappers, validation.valid, lockfile.wrappers, {
|
|
62
140
|
cwd,
|
|
63
141
|
config,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
force: Boolean(options.force),
|
|
68
|
-
itemLabel: "wrappers"
|
|
142
|
+
force: forceInstall,
|
|
143
|
+
spinner,
|
|
144
|
+
itemLabel: "wrapper"
|
|
69
145
|
});
|
|
70
|
-
|
|
146
|
+
const npmDependencies = new Set();
|
|
147
|
+
dependenciesResult.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
148
|
+
wrappersResult.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
149
|
+
spinner?.start("Updating lockfile...");
|
|
71
150
|
await saveLockfile(cwd, lockfile);
|
|
72
|
-
|
|
73
|
-
|
|
151
|
+
spinner?.succeed("Lockfile updated");
|
|
152
|
+
const combinedResult = {
|
|
153
|
+
entries: wrappersResult,
|
|
154
|
+
dependencies: dependenciesResult,
|
|
155
|
+
npmDependencies,
|
|
156
|
+
conflicts: analysis.conflicts
|
|
157
|
+
};
|
|
158
|
+
if (npmDependencies.size > 0 && !options.skipDeps) {
|
|
159
|
+
const shouldInstallDeps = shouldPrompt
|
|
160
|
+
? await confirmDependencyInstallation(npmDependencies)
|
|
161
|
+
: true;
|
|
162
|
+
if (shouldInstallDeps) {
|
|
163
|
+
await installNpmDependencies({
|
|
164
|
+
cwd,
|
|
165
|
+
dependencies: npmDependencies,
|
|
166
|
+
spinner
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (shouldLog) {
|
|
171
|
+
await displayManualInstallInstructions(npmDependencies, cwd);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
74
174
|
}
|
|
75
|
-
if (
|
|
76
|
-
|
|
175
|
+
else if (npmDependencies.size > 0 && shouldLog) {
|
|
176
|
+
await displayManualInstallInstructions(npmDependencies, cwd);
|
|
77
177
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
178
|
+
if (shouldLog) {
|
|
179
|
+
displayResults(combinedResult, { ...options, force: forceInstall }, WRAPPER_LABELS);
|
|
80
180
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (npmDependencies.size) {
|
|
85
|
-
console.log(`\nInstall dependencies:`);
|
|
86
|
-
console.log(`npm install ${[...npmDependencies].join(" ")}`);
|
|
181
|
+
if (wrappersResult.failed.length > 0 || dependenciesResult.failed.length > 0) {
|
|
182
|
+
process.exit(1);
|
|
183
|
+
return;
|
|
87
184
|
}
|
|
88
185
|
}
|
|
89
186
|
catch (error) {
|
|
90
|
-
|
|
187
|
+
spinner?.fail("Installation failed");
|
|
188
|
+
logger.error(error.message);
|
|
189
|
+
if (process.env.DEBUG) {
|
|
190
|
+
console.error(error);
|
|
191
|
+
}
|
|
91
192
|
process.exit(1);
|
|
193
|
+
return;
|
|
92
194
|
}
|
|
93
195
|
});
|
|
94
196
|
//# sourceMappingURL=add-wrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-wrapper.js","sourceRoot":"","sources":["../../src/commands/add-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"add-wrapper.js","sourceRoot":"","sources":["../../src/commands/add-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,GAAiB,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,cAAc,EACd,mBAAmB,EAEnB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EACL,6BA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G,CAAC,CAAA;gBAC9D,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;YACjD,MAAM,gCAAgC,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;QAC9D,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,cAAc,CACZ,cAAc,EACd,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EACnC,cAAc,CACf,CAAA;QACH,CAAC;QAED,IAAI,cAAc,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACf,OAAM;QACR,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;QACpC,MAAM,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC,CAAA;QACtC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACf,OAAM;IACR,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Ora } from "ora";
|
|
2
|
+
import type { Lockfile, LockfileComponent } from "../../lib/lockfile.js";
|
|
3
|
+
import type { RegistryIndex, RegistryItem } from "../../lib/registry.js";
|
|
4
|
+
import type { AddConfig, AddOptions } from "../add/types.js";
|
|
5
|
+
export interface EntryValidation {
|
|
6
|
+
valid: string[];
|
|
7
|
+
invalid: string[];
|
|
8
|
+
suggestions: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface EntryDependencyAnalysis {
|
|
11
|
+
entries: string[];
|
|
12
|
+
componentDependencies: string[];
|
|
13
|
+
npmDependencies: Set<string>;
|
|
14
|
+
conflicts: string[];
|
|
15
|
+
totalTargets: number;
|
|
16
|
+
totalToInstall: number;
|
|
17
|
+
}
|
|
18
|
+
export interface EntryInstallResult {
|
|
19
|
+
installed: string[];
|
|
20
|
+
skipped: string[];
|
|
21
|
+
failed: string[];
|
|
22
|
+
npmDependencies: Set<string>;
|
|
23
|
+
}
|
|
24
|
+
export interface CollectionInstallResult {
|
|
25
|
+
entries: EntryInstallResult;
|
|
26
|
+
dependencies: EntryInstallResult;
|
|
27
|
+
npmDependencies: Set<string>;
|
|
28
|
+
conflicts: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface EntryLabels {
|
|
31
|
+
entrySingular: string;
|
|
32
|
+
entryPlural: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function normalizeEntryNames(names: string[]): string[];
|
|
35
|
+
export declare function getEntryNames(entries: RegistryItem[]): string[];
|
|
36
|
+
export declare function createEntryMap(entries: RegistryItem[]): Map<string, RegistryItem>;
|
|
37
|
+
export declare function validateEntries(names: string[], entries: RegistryItem[]): EntryValidation;
|
|
38
|
+
export declare function analyzeEntryDependencies(names: string[], entries: RegistryItem[], registry: RegistryIndex, lockfile: Lockfile, lockKey: "sections" | "wrappers"): EntryDependencyAnalysis;
|
|
39
|
+
export declare function confirmOverwrite(entryPlural: string): Promise<boolean>;
|
|
40
|
+
export declare function displayInstallationPlan(analysis: EntryDependencyAnalysis, options: AddOptions, labels: EntryLabels): void;
|
|
41
|
+
export declare function displayResults(result: CollectionInstallResult, options: AddOptions, labels: EntryLabels): void;
|
|
42
|
+
export declare function installEntries(entries: RegistryItem[], names: string[], lockEntries: Record<string, LockfileComponent>, options: {
|
|
43
|
+
cwd: string;
|
|
44
|
+
config: AddConfig;
|
|
45
|
+
force: boolean;
|
|
46
|
+
spinner: Ora | null;
|
|
47
|
+
itemLabel: string;
|
|
48
|
+
}): Promise<EntryInstallResult>;
|
|
49
|
+
export declare function createEmptyResult(): EntryInstallResult;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
import { installRegistryEntries } from "../../lib/install.js";
|
|
4
|
+
import { logger } from "../../lib/logger.js";
|
|
5
|
+
import { analyzeDependencies } from "../add/analysis.js";
|
|
6
|
+
function capitalize(value) {
|
|
7
|
+
if (value.length === 0) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
11
|
+
}
|
|
12
|
+
export function normalizeEntryNames(names) {
|
|
13
|
+
const unique = new Set();
|
|
14
|
+
const normalized = [];
|
|
15
|
+
for (const name of names) {
|
|
16
|
+
const trimmed = name.trim();
|
|
17
|
+
if (!trimmed || unique.has(trimmed)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
unique.add(trimmed);
|
|
21
|
+
normalized.push(trimmed);
|
|
22
|
+
}
|
|
23
|
+
return normalized;
|
|
24
|
+
}
|
|
25
|
+
export function getEntryNames(entries) {
|
|
26
|
+
return entries.map((entry) => entry.name);
|
|
27
|
+
}
|
|
28
|
+
export function createEntryMap(entries) {
|
|
29
|
+
return new Map(entries.map((entry) => [entry.name, entry]));
|
|
30
|
+
}
|
|
31
|
+
export function validateEntries(names, entries) {
|
|
32
|
+
const valid = [];
|
|
33
|
+
const invalid = [];
|
|
34
|
+
const suggestions = [];
|
|
35
|
+
const entryMap = createEntryMap(entries);
|
|
36
|
+
const available = getEntryNames(entries);
|
|
37
|
+
for (const name of names) {
|
|
38
|
+
const trimmed = name.trim();
|
|
39
|
+
if (!trimmed) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (entryMap.has(trimmed)) {
|
|
43
|
+
valid.push(trimmed);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
invalid.push(trimmed);
|
|
47
|
+
const lower = trimmed.toLowerCase();
|
|
48
|
+
const similar = available.filter((entryName) => {
|
|
49
|
+
const candidate = entryName.toLowerCase();
|
|
50
|
+
return candidate.includes(lower) || lower.includes(candidate);
|
|
51
|
+
});
|
|
52
|
+
suggestions.push(...similar);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
valid,
|
|
56
|
+
invalid,
|
|
57
|
+
suggestions: [...new Set(suggestions)]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function analyzeEntryDependencies(names, entries, registry, lockfile, lockKey) {
|
|
61
|
+
const entryMap = createEntryMap(entries);
|
|
62
|
+
const componentDependencies = new Set();
|
|
63
|
+
const npmDependencies = new Set();
|
|
64
|
+
for (const entryName of names) {
|
|
65
|
+
const entry = entryMap.get(entryName);
|
|
66
|
+
entry?.dependencies?.local?.forEach((dep) => componentDependencies.add(dep));
|
|
67
|
+
entry?.dependencies?.npm?.forEach((dep) => npmDependencies.add(dep));
|
|
68
|
+
}
|
|
69
|
+
const componentDependencyList = Array.from(componentDependencies);
|
|
70
|
+
const componentAnalysis = componentDependencyList.length > 0
|
|
71
|
+
? analyzeDependencies(componentDependencyList, registry, lockfile)
|
|
72
|
+
: {
|
|
73
|
+
components: [],
|
|
74
|
+
dependencies: new Set(),
|
|
75
|
+
npmDependencies: new Set(),
|
|
76
|
+
conflicts: [],
|
|
77
|
+
totalToInstall: 0
|
|
78
|
+
};
|
|
79
|
+
componentAnalysis.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
80
|
+
const entryConflicts = names.filter((entryName) => lockfile[lockKey][entryName]);
|
|
81
|
+
const componentConflicts = componentAnalysis.conflicts;
|
|
82
|
+
const conflicts = new Set([
|
|
83
|
+
...entryConflicts,
|
|
84
|
+
...componentConflicts
|
|
85
|
+
]);
|
|
86
|
+
const totalTargets = names.length + componentAnalysis.components.length;
|
|
87
|
+
const totalToInstall = Math.max(0, totalTargets - conflicts.size);
|
|
88
|
+
return {
|
|
89
|
+
entries: names,
|
|
90
|
+
componentDependencies: componentAnalysis.components,
|
|
91
|
+
npmDependencies,
|
|
92
|
+
conflicts: Array.from(conflicts),
|
|
93
|
+
totalTargets,
|
|
94
|
+
totalToInstall
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export async function confirmOverwrite(entryPlural) {
|
|
98
|
+
const { overwrite } = await prompts({
|
|
99
|
+
type: "confirm",
|
|
100
|
+
name: "overwrite",
|
|
101
|
+
message: `Overwrite existing ${entryPlural}?`,
|
|
102
|
+
initial: false
|
|
103
|
+
});
|
|
104
|
+
return overwrite;
|
|
105
|
+
}
|
|
106
|
+
export function displayInstallationPlan(analysis, options, labels) {
|
|
107
|
+
const entryLabel = capitalize(labels.entryPlural);
|
|
108
|
+
console.log("\n" + chalk.bold("Installation Plan:"));
|
|
109
|
+
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
110
|
+
console.log(`${chalk.cyan(`${entryLabel} to install:`)} ${chalk.white(analysis.entries.length)}`);
|
|
111
|
+
if (analysis.componentDependencies.length > 0) {
|
|
112
|
+
console.log(`${chalk.cyan("Component dependencies:")} ${chalk.white(analysis.componentDependencies.length)}`);
|
|
113
|
+
console.log(chalk.gray(` ${analysis.componentDependencies.join(", ")}`));
|
|
114
|
+
}
|
|
115
|
+
if (analysis.npmDependencies.size > 0) {
|
|
116
|
+
console.log(`${chalk.cyan("NPM packages required:")} ${chalk.white(analysis.npmDependencies.size)}`);
|
|
117
|
+
console.log(chalk.gray(` ${Array.from(analysis.npmDependencies).join(", ")}`));
|
|
118
|
+
}
|
|
119
|
+
if (analysis.conflicts.length > 0 && !options.force) {
|
|
120
|
+
console.log(`${chalk.yellow("Conflicts detected:")} ${chalk.white(analysis.conflicts.length)}`);
|
|
121
|
+
console.log(chalk.gray(` ${analysis.conflicts.join(", ")}`));
|
|
122
|
+
}
|
|
123
|
+
console.log(chalk.gray("\u00c4".repeat(50)) + "\n");
|
|
124
|
+
}
|
|
125
|
+
export function displayResults(result, options, labels) {
|
|
126
|
+
const { dependencies, entries } = result;
|
|
127
|
+
console.log("\n" + chalk.bold("Installation Results:"));
|
|
128
|
+
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
129
|
+
if (dependencies.installed.length > 0) {
|
|
130
|
+
console.log(chalk.green(`\u00fb Installed component dependencies (${dependencies.installed.length}):`));
|
|
131
|
+
dependencies.installed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
132
|
+
}
|
|
133
|
+
if (dependencies.skipped.length > 0 && !options.force) {
|
|
134
|
+
console.log(chalk.yellow(`? Skipped component dependencies (${dependencies.skipped.length}):`));
|
|
135
|
+
dependencies.skipped.forEach((name) => console.log(chalk.gray(` \u0007 ${name} (already exists)`)));
|
|
136
|
+
}
|
|
137
|
+
if (dependencies.failed.length > 0) {
|
|
138
|
+
console.log(chalk.red(`? Failed component dependencies (${dependencies.failed.length}):`));
|
|
139
|
+
dependencies.failed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
140
|
+
}
|
|
141
|
+
if (entries.installed.length > 0) {
|
|
142
|
+
console.log(chalk.green(`\u00fb Installed ${labels.entryPlural} (${entries.installed.length}):`));
|
|
143
|
+
entries.installed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
144
|
+
}
|
|
145
|
+
if (entries.skipped.length > 0 && !options.force) {
|
|
146
|
+
console.log(chalk.yellow(`? Skipped ${labels.entryPlural} (${entries.skipped.length}):`));
|
|
147
|
+
entries.skipped.forEach((name) => console.log(chalk.gray(` \u0007 ${name} (already exists)`)));
|
|
148
|
+
}
|
|
149
|
+
if (entries.failed.length > 0) {
|
|
150
|
+
console.log(chalk.red(`? Failed ${labels.entryPlural} (${entries.failed.length}):`));
|
|
151
|
+
entries.failed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
152
|
+
}
|
|
153
|
+
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
154
|
+
if (entries.installed.length > 0) {
|
|
155
|
+
const label = entries.installed.length === 1 ? labels.entrySingular : labels.entryPlural;
|
|
156
|
+
console.log(chalk.green.bold(`\n\u00fb Successfully installed ${entries.installed.length} ${label}!`));
|
|
157
|
+
}
|
|
158
|
+
console.log();
|
|
159
|
+
}
|
|
160
|
+
export async function installEntries(entries, names, lockEntries, options) {
|
|
161
|
+
const installed = [];
|
|
162
|
+
const skipped = [];
|
|
163
|
+
const failed = [];
|
|
164
|
+
const npmDependencies = new Set();
|
|
165
|
+
let currentIndex = 0;
|
|
166
|
+
const total = names.length;
|
|
167
|
+
for (const name of names) {
|
|
168
|
+
currentIndex += 1;
|
|
169
|
+
try {
|
|
170
|
+
if (options.spinner) {
|
|
171
|
+
options.spinner.text = `Installing ${name} (${currentIndex}/${total})...`;
|
|
172
|
+
}
|
|
173
|
+
const result = await installRegistryEntries({
|
|
174
|
+
cwd: options.cwd,
|
|
175
|
+
config: options.config,
|
|
176
|
+
entries,
|
|
177
|
+
names: [name],
|
|
178
|
+
lockEntries,
|
|
179
|
+
force: options.force,
|
|
180
|
+
itemLabel: options.itemLabel
|
|
181
|
+
});
|
|
182
|
+
if (result.installed.length > 0) {
|
|
183
|
+
installed.push(...result.installed);
|
|
184
|
+
}
|
|
185
|
+
if (result.skipped.length > 0) {
|
|
186
|
+
skipped.push(...result.skipped);
|
|
187
|
+
}
|
|
188
|
+
result.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
failed.push(name);
|
|
192
|
+
logger.error(`Failed to install ${options.itemLabel} ${name}: ${error.message}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
installed,
|
|
197
|
+
skipped,
|
|
198
|
+
failed,
|
|
199
|
+
npmDependencies
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export function createEmptyResult() {
|
|
203
|
+
return {
|
|
204
|
+
installed: [],
|
|
205
|
+
skipped: [],
|
|
206
|
+
failed: [],
|
|
207
|
+
npmDependencies: new Set()
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=add-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-collection.js","sourceRoot":"","sources":["../../../src/commands/shared/add-collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAG5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAqCxD,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACvD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;IAChC,MAAM,UAAU,GAAa,EAAE,CAAA;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;QAC3B,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,SAAQ;QACV,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACnB,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAuB;IACnD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAC3C,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M,UAAU,iBAAiB;IAC/B,OAAO;QACL,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;QACV,eAAe,EAAE,IAAI,GAAG,EAAU;KACnC,CAAA;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { addCommand } from "./commands/add.js";
|
|
5
|
+
import { addSectionCommand } from "./commands/add-section.js";
|
|
5
6
|
import { initCommand } from "./commands/init.js";
|
|
6
7
|
const require = createRequire(import.meta.url);
|
|
7
8
|
const packageJson = require("../package.json");
|
|
@@ -13,7 +14,7 @@ const program = new Command()
|
|
|
13
14
|
.version(packageJson.version ?? "0.0.0", "-v, --version", "display version");
|
|
14
15
|
program.addCommand(initCommand);
|
|
15
16
|
program.addCommand(addCommand);
|
|
16
|
-
|
|
17
|
+
program.addCommand(addSectionCommand);
|
|
17
18
|
// program.addCommand(addWrapperCommand)
|
|
18
19
|
// program.addCommand(buildCommand)
|
|
19
20
|
// program.addCommand(removeCommand)
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;A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