trix-ui 0.2.8 → 0.2.10
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/__tests__/contracts/registry.test.d.ts +1 -0
- package/dist/__tests__/contracts/registry.test.js +42 -0
- package/dist/__tests__/contracts/registry.test.js.map +1 -0
- package/dist/__tests__/e2e/cli.test.d.ts +1 -0
- package/dist/__tests__/e2e/cli.test.js +67 -0
- package/dist/__tests__/e2e/cli.test.js.map +1 -0
- package/dist/__tests__/helpers/fs.d.ts +5 -0
- package/dist/__tests__/helpers/fs.js +26 -0
- package/dist/__tests__/helpers/fs.js.map +1 -0
- package/dist/__tests__/integration/commands.integration.test.d.ts +1 -0
- package/dist/__tests__/integration/commands.integration.test.js +184 -0
- package/dist/__tests__/integration/commands.integration.test.js.map +1 -0
- package/dist/commands/__tests__/add-composite.test.d.ts +2 -0
- package/dist/commands/__tests__/add-composite.test.js +171 -0
- package/dist/commands/__tests__/add-composite.test.js.map +1 -0
- package/dist/commands/__tests__/add-entry.mocks.d.ts +23 -0
- package/dist/commands/__tests__/add-entry.mocks.js +64 -0
- package/dist/commands/__tests__/add-entry.mocks.js.map +1 -0
- package/dist/commands/__tests__/add-section.test.d.ts +2 -0
- package/dist/commands/__tests__/add-section.test.js +191 -0
- package/dist/commands/__tests__/add-section.test.js.map +1 -0
- package/dist/commands/__tests__/add-wrapper.test.d.ts +2 -0
- package/dist/commands/__tests__/add-wrapper.test.js +171 -0
- package/dist/commands/__tests__/add-wrapper.test.js.map +1 -0
- package/dist/commands/__tests__/cli-mocks.d.ts +1 -0
- package/dist/commands/__tests__/cli-mocks.js +24 -0
- package/dist/commands/__tests__/cli-mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.mocks.d.ts +6 -0
- package/dist/commands/__tests__/doctor.mocks.js +20 -0
- package/dist/commands/__tests__/doctor.mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.test.d.ts +2 -0
- package/dist/commands/__tests__/doctor.test.js +80 -0
- package/dist/commands/__tests__/doctor.test.js.map +1 -0
- package/dist/commands/__tests__/list.mocks.d.ts +8 -0
- package/dist/commands/__tests__/list.mocks.js +20 -0
- package/dist/commands/__tests__/list.mocks.js.map +1 -0
- package/dist/commands/__tests__/list.test.d.ts +2 -0
- package/dist/commands/__tests__/list.test.js +60 -0
- package/dist/commands/__tests__/list.test.js.map +1 -0
- package/dist/commands/__tests__/remove.mocks.d.ts +9 -0
- package/dist/commands/__tests__/remove.mocks.js +26 -0
- package/dist/commands/__tests__/remove.mocks.js.map +1 -0
- package/dist/commands/__tests__/remove.test.d.ts +2 -0
- package/dist/commands/__tests__/remove.test.js +116 -0
- package/dist/commands/__tests__/remove.test.js.map +1 -0
- package/dist/commands/add/__tests__/add.mocks.d.ts +19 -19
- package/dist/commands/add/__tests__/add.mocks.js +59 -59
- package/dist/commands/add/__tests__/add.test.d.ts +2 -2
- package/dist/commands/add/__tests__/add.test.js +140 -140
- package/dist/commands/add/analysis.d.ts +4 -4
- package/dist/commands/add/analysis.js +56 -56
- package/dist/commands/add/command.d.ts +2 -2
- package/dist/commands/add/command.js +202 -202
- package/dist/commands/add/config.d.ts +2 -2
- package/dist/commands/add/config.js +11 -11
- package/dist/commands/add/install.d.ts +27 -27
- package/dist/commands/add/install.js +80 -80
- package/dist/commands/add/package-manager.d.ts +1 -1
- package/dist/commands/add/package-manager.js +4 -4
- package/dist/commands/add/project-files.d.ts +2 -2
- package/dist/commands/add/project-files.js +17 -17
- package/dist/commands/add/prompts.d.ts +3 -3
- package/dist/commands/add/prompts.js +28 -28
- package/dist/commands/add/registry.d.ts +4 -4
- package/dist/commands/add/registry.js +6 -6
- package/dist/commands/add/types.d.ts +33 -33
- package/dist/commands/add/types.js +1 -1
- package/dist/commands/add/ui.d.ts +4 -4
- package/dist/commands/add/ui.js +55 -55
- package/dist/commands/add/validation.d.ts +3 -3
- package/dist/commands/add/validation.js +30 -30
- package/dist/commands/add-collection.d.ts +1 -1
- package/dist/commands/add-collection.js +1 -1
- package/dist/commands/add-composite.d.ts +2 -2
- package/dist/commands/add-composite.js +201 -201
- package/dist/commands/add-section.d.ts +2 -2
- package/dist/commands/add-section.js +201 -201
- package/dist/commands/add-wrapper.d.ts +2 -2
- package/dist/commands/add-wrapper.js +201 -201
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/build.d.ts +2 -2
- package/dist/commands/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +67 -67
- package/dist/commands/init/__tests__/init.mocks.d.ts +24 -0
- package/dist/commands/init/__tests__/init.mocks.js +84 -0
- package/dist/commands/init/__tests__/init.mocks.js.map +1 -0
- package/dist/commands/init/__tests__/init.test.d.ts +2 -0
- package/dist/commands/init/__tests__/init.test.js +283 -0
- package/dist/commands/init/__tests__/init.test.js.map +1 -0
- package/dist/commands/init/__tests__/tailwind.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tailwind.test.js +56 -0
- package/dist/commands/init/__tests__/tailwind.test.js.map +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.js +108 -0
- package/dist/commands/init/__tests__/tsconfig.test.js.map +1 -0
- package/dist/commands/init/__tests__/vite.test.d.ts +1 -0
- package/dist/commands/init/__tests__/vite.test.js +66 -0
- package/dist/commands/init/__tests__/vite.test.js.map +1 -0
- package/dist/commands/init/command.d.ts +2 -2
- package/dist/commands/init/command.js +114 -114
- package/dist/commands/init/config.d.ts +2 -2
- package/dist/commands/init/config.js +25 -25
- package/dist/commands/init/constants.d.ts +3 -3
- package/dist/commands/init/constants.js +105 -105
- package/dist/commands/init/dependencies.d.ts +5 -5
- package/dist/commands/init/dependencies.js +52 -52
- package/dist/commands/init/filesystem.d.ts +1 -1
- package/dist/commands/init/filesystem.js +10 -10
- package/dist/commands/init/lockfile.d.ts +1 -1
- package/dist/commands/init/lockfile.js +1 -1
- package/dist/commands/init/package-json.d.ts +6 -6
- package/dist/commands/init/package-json.js +18 -18
- package/dist/commands/init/project-files.d.ts +8 -0
- package/dist/commands/init/project-files.js +37 -0
- package/dist/commands/init/project-files.js.map +1 -0
- package/dist/commands/init/project.d.ts +3 -3
- package/dist/commands/init/project.js +97 -97
- package/dist/commands/init/style-imports.d.ts +9 -0
- package/dist/commands/init/style-imports.js +218 -0
- package/dist/commands/init/style-imports.js.map +1 -0
- package/dist/commands/init/tailwind.d.ts +3 -3
- package/dist/commands/init/tailwind.js +34 -34
- package/dist/commands/init/templates.d.ts +3 -3
- package/dist/commands/init/templates.js +15 -15
- package/dist/commands/init/tsconfig.d.ts +2 -2
- package/dist/commands/init/tsconfig.js +273 -273
- package/dist/commands/init/types.d.ts +33 -33
- package/dist/commands/init/types.js +1 -1
- package/dist/commands/init/ui.d.ts +3 -3
- package/dist/commands/init/ui.js +33 -33
- package/dist/commands/init/vite.d.ts +23 -0
- package/dist/commands/init/vite.js +347 -0
- package/dist/commands/init/vite.js.map +1 -0
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/list.d.ts +2 -2
- package/dist/commands/list.js +62 -62
- package/dist/commands/remove.d.ts +2 -2
- package/dist/commands/remove.js +93 -93
- package/dist/commands/shared/add-collection.d.ts +50 -50
- package/dist/commands/shared/add-collection.js +206 -206
- package/dist/commands/shared/list-entries.d.ts +6 -6
- package/dist/commands/shared/list-entries.js +12 -12
- package/dist/commands/shared/name-utils.d.ts +1 -1
- package/dist/commands/shared/name-utils.js +13 -13
- package/dist/commands/shared/remove-entries.d.ts +16 -16
- package/dist/commands/shared/remove-entries.js +41 -41
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/libraries.d.ts +37 -37
- package/dist/icons/libraries.js +34 -34
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -30
- package/dist/lib/__tests__/config.test.d.ts +1 -0
- package/dist/lib/__tests__/config.test.js +49 -0
- package/dist/lib/__tests__/config.test.js.map +1 -0
- package/dist/lib/__tests__/install.test.d.ts +1 -0
- package/dist/lib/__tests__/install.test.js +149 -0
- package/dist/lib/__tests__/install.test.js.map +1 -0
- package/dist/lib/__tests__/lockfile.test.d.ts +1 -0
- package/dist/lib/__tests__/lockfile.test.js +89 -0
- package/dist/lib/__tests__/lockfile.test.js.map +1 -0
- package/dist/lib/__tests__/paths.test.d.ts +1 -0
- package/dist/lib/__tests__/paths.test.js +39 -0
- package/dist/lib/__tests__/paths.test.js.map +1 -0
- package/dist/lib/__tests__/registry.test.d.ts +1 -0
- package/dist/lib/__tests__/registry.test.js +76 -0
- package/dist/lib/__tests__/registry.test.js.map +1 -0
- package/dist/lib/config.d.ts +45 -45
- package/dist/lib/config.js +97 -97
- package/dist/lib/fs.d.ts +76 -76
- package/dist/lib/fs.js +302 -302
- package/dist/lib/highlighter.d.ts +6 -6
- package/dist/lib/highlighter.js +7 -7
- package/dist/lib/install.d.ts +19 -19
- package/dist/lib/install.js +55 -55
- package/dist/lib/lockfile.d.ts +63 -63
- package/dist/lib/lockfile.js +173 -173
- package/dist/lib/logger.d.ts +8 -8
- package/dist/lib/logger.js +41 -41
- package/dist/lib/paths.d.ts +14 -14
- package/dist/lib/paths.js +31 -31
- package/dist/lib/registry.d.ts +35 -35
- package/dist/lib/registry.js +180 -180
- package/dist/schema/index.d.ts +1128 -1128
- package/dist/schema/index.js +238 -238
- package/dist/styles/create-style-map.d.ts +4 -4
- package/dist/styles/create-style-map.js +68 -68
- package/dist/styles/transform-style-map.d.ts +3 -3
- package/dist/styles/transform-style-map.js +428 -428
- package/dist/styles/transform.d.ts +10 -10
- package/dist/styles/transform.js +15 -15
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/index.js +5 -5
- package/dist/utils/transformers/transform-icons.d.ts +2 -2
- package/dist/utils/transformers/transform-icons.js +164 -164
- package/dist/utils/transformers/transform-menu.d.ts +2 -2
- package/dist/utils/transformers/transform-menu.js +39 -39
- package/dist/utils/transformers/transform-render.d.ts +2 -2
- package/dist/utils/transformers/transform-render.js +97 -97
- package/dist/utils/transformers/types.d.ts +14 -14
- package/dist/utils/transformers/types.js +1 -1
- package/package.json +1 -1
|
@@ -1,207 +1,207 @@
|
|
|
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
|
-
import { normalizeNames } from "./name-utils.js";
|
|
7
|
-
function capitalize(value) {
|
|
8
|
-
if (value.length === 0) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
12
|
-
}
|
|
13
|
-
export function normalizeEntryNames(names) {
|
|
14
|
-
return normalizeNames(names);
|
|
15
|
-
}
|
|
16
|
-
export function getEntryNames(entries) {
|
|
17
|
-
return entries.map((entry) => entry.name);
|
|
18
|
-
}
|
|
19
|
-
export function createEntryMap(entries) {
|
|
20
|
-
return new Map(entries.map((entry) => [entry.name, entry]));
|
|
21
|
-
}
|
|
22
|
-
export function validateEntries(names, entries) {
|
|
23
|
-
const valid = [];
|
|
24
|
-
const invalid = [];
|
|
25
|
-
const suggestions = [];
|
|
26
|
-
const entryMap = createEntryMap(entries);
|
|
27
|
-
const available = getEntryNames(entries);
|
|
28
|
-
for (const name of names) {
|
|
29
|
-
const trimmed = name.trim();
|
|
30
|
-
if (!trimmed) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (entryMap.has(trimmed)) {
|
|
34
|
-
valid.push(trimmed);
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
invalid.push(trimmed);
|
|
38
|
-
const lower = trimmed.toLowerCase();
|
|
39
|
-
const similar = available.filter((entryName) => {
|
|
40
|
-
const candidate = entryName.toLowerCase();
|
|
41
|
-
return candidate.includes(lower) || lower.includes(candidate);
|
|
42
|
-
});
|
|
43
|
-
suggestions.push(...similar);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
valid,
|
|
47
|
-
invalid,
|
|
48
|
-
suggestions: [...new Set(suggestions)]
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export function analyzeEntryDependencies(names, entries, registry, lockfile, lockKey) {
|
|
52
|
-
const entryMap = createEntryMap(entries);
|
|
53
|
-
const componentDependencies = new Set();
|
|
54
|
-
const npmDependencies = new Set();
|
|
55
|
-
for (const entryName of names) {
|
|
56
|
-
const entry = entryMap.get(entryName);
|
|
57
|
-
entry?.dependencies?.local?.forEach((dep) => componentDependencies.add(dep));
|
|
58
|
-
entry?.dependencies?.npm?.forEach((dep) => npmDependencies.add(dep));
|
|
59
|
-
}
|
|
60
|
-
const componentDependencyList = Array.from(componentDependencies);
|
|
61
|
-
const componentAnalysis = componentDependencyList.length > 0
|
|
62
|
-
? analyzeDependencies(componentDependencyList, registry, lockfile)
|
|
63
|
-
: {
|
|
64
|
-
components: [],
|
|
65
|
-
dependencies: new Set(),
|
|
66
|
-
npmDependencies: new Set(),
|
|
67
|
-
conflicts: [],
|
|
68
|
-
totalToInstall: 0,
|
|
69
|
-
missingDependencies: []
|
|
70
|
-
};
|
|
71
|
-
componentAnalysis.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
72
|
-
const entryConflicts = names.filter((entryName) => lockfile[lockKey][entryName]);
|
|
73
|
-
const componentConflicts = componentAnalysis.conflicts;
|
|
74
|
-
const conflicts = new Set([
|
|
75
|
-
...entryConflicts,
|
|
76
|
-
...componentConflicts
|
|
77
|
-
]);
|
|
78
|
-
const totalTargets = names.length + componentAnalysis.components.length;
|
|
79
|
-
const totalToInstall = Math.max(0, totalTargets - conflicts.size);
|
|
80
|
-
return {
|
|
81
|
-
entries: names,
|
|
82
|
-
componentDependencies: componentAnalysis.components,
|
|
83
|
-
npmDependencies,
|
|
84
|
-
conflicts: Array.from(conflicts),
|
|
85
|
-
totalTargets,
|
|
86
|
-
totalToInstall,
|
|
87
|
-
missingDependencies: componentAnalysis.missingDependencies
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export async function confirmOverwrite(entryPlural) {
|
|
91
|
-
const { overwrite } = await prompts({
|
|
92
|
-
type: "confirm",
|
|
93
|
-
name: "overwrite",
|
|
94
|
-
message: `Overwrite existing ${entryPlural}?`,
|
|
95
|
-
initial: false
|
|
96
|
-
});
|
|
97
|
-
return overwrite;
|
|
98
|
-
}
|
|
99
|
-
export function displayInstallationPlan(analysis, options, labels) {
|
|
100
|
-
const entryLabel = capitalize(labels.entryPlural);
|
|
101
|
-
console.log("\n" + chalk.bold("Installation Plan:"));
|
|
102
|
-
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
103
|
-
console.log(`${chalk.cyan(`${entryLabel} to install:`)} ${chalk.white(analysis.entries.length)}`);
|
|
104
|
-
if (analysis.componentDependencies.length > 0) {
|
|
105
|
-
console.log(`${chalk.cyan("Component dependencies:")} ${chalk.white(analysis.componentDependencies.length)}`);
|
|
106
|
-
console.log(chalk.gray(` ${analysis.componentDependencies.join(", ")}`));
|
|
107
|
-
}
|
|
108
|
-
if (analysis.npmDependencies.size > 0) {
|
|
109
|
-
console.log(`${chalk.cyan("NPM packages required:")} ${chalk.white(analysis.npmDependencies.size)}`);
|
|
110
|
-
console.log(chalk.gray(` ${Array.from(analysis.npmDependencies).join(", ")}`));
|
|
111
|
-
}
|
|
112
|
-
if (analysis.missingDependencies.length > 0) {
|
|
113
|
-
console.log(`${chalk.red("Missing registry dependencies:")} ${chalk.white(analysis.missingDependencies.length)}`);
|
|
114
|
-
console.log(chalk.gray(` ${analysis.missingDependencies.join(", ")}`));
|
|
115
|
-
}
|
|
116
|
-
if (analysis.conflicts.length > 0 && !options.force) {
|
|
117
|
-
console.log(`${chalk.yellow("Conflicts detected:")} ${chalk.white(analysis.conflicts.length)}`);
|
|
118
|
-
console.log(chalk.gray(` ${analysis.conflicts.join(", ")}`));
|
|
119
|
-
}
|
|
120
|
-
console.log(chalk.gray("\u00c4".repeat(50)) + "\n");
|
|
121
|
-
}
|
|
122
|
-
export function displayResults(result, options, labels) {
|
|
123
|
-
const { dependencies, entries } = result;
|
|
124
|
-
console.log("\n" + chalk.bold("Installation Results:"));
|
|
125
|
-
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
126
|
-
if (dependencies.installed.length > 0) {
|
|
127
|
-
console.log(chalk.green(`\u00fb Installed component dependencies (${dependencies.installed.length}):`));
|
|
128
|
-
dependencies.installed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
129
|
-
}
|
|
130
|
-
if (dependencies.skipped.length > 0 && !options.force) {
|
|
131
|
-
console.log(chalk.yellow(`? Skipped component dependencies (${dependencies.skipped.length}):`));
|
|
132
|
-
dependencies.skipped.forEach((name) => console.log(chalk.gray(` \u0007 ${name} (already exists)`)));
|
|
133
|
-
}
|
|
134
|
-
if (dependencies.failed.length > 0) {
|
|
135
|
-
console.log(chalk.red(`? Failed component dependencies (${dependencies.failed.length}):`));
|
|
136
|
-
dependencies.failed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
137
|
-
}
|
|
138
|
-
if (entries.installed.length > 0) {
|
|
139
|
-
console.log(chalk.green(`\u00fb Installed ${labels.entryPlural} (${entries.installed.length}):`));
|
|
140
|
-
entries.installed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
141
|
-
}
|
|
142
|
-
if (entries.skipped.length > 0 && !options.force) {
|
|
143
|
-
console.log(chalk.yellow(`? Skipped ${labels.entryPlural} (${entries.skipped.length}):`));
|
|
144
|
-
entries.skipped.forEach((name) => console.log(chalk.gray(` \u0007 ${name} (already exists)`)));
|
|
145
|
-
}
|
|
146
|
-
if (entries.failed.length > 0) {
|
|
147
|
-
console.log(chalk.red(`? Failed ${labels.entryPlural} (${entries.failed.length}):`));
|
|
148
|
-
entries.failed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
149
|
-
}
|
|
150
|
-
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
151
|
-
if (entries.installed.length > 0) {
|
|
152
|
-
const label = entries.installed.length === 1 ? labels.entrySingular : labels.entryPlural;
|
|
153
|
-
console.log(chalk.green.bold(`\n\u00fb Successfully installed ${entries.installed.length} ${label}!`));
|
|
154
|
-
}
|
|
155
|
-
console.log();
|
|
156
|
-
}
|
|
157
|
-
export async function installEntries(entries, names, lockEntries, options) {
|
|
158
|
-
const installed = [];
|
|
159
|
-
const skipped = [];
|
|
160
|
-
const failed = [];
|
|
161
|
-
const npmDependencies = new Set();
|
|
162
|
-
let currentIndex = 0;
|
|
163
|
-
const total = names.length;
|
|
164
|
-
for (const name of names) {
|
|
165
|
-
currentIndex += 1;
|
|
166
|
-
try {
|
|
167
|
-
if (options.spinner) {
|
|
168
|
-
options.spinner.text = `Installing ${name} (${currentIndex}/${total})...`;
|
|
169
|
-
}
|
|
170
|
-
const result = await installRegistryEntries({
|
|
171
|
-
cwd: options.cwd,
|
|
172
|
-
config: options.config,
|
|
173
|
-
entries,
|
|
174
|
-
names: [name],
|
|
175
|
-
lockEntries,
|
|
176
|
-
force: options.force,
|
|
177
|
-
itemLabel: options.itemLabel
|
|
178
|
-
});
|
|
179
|
-
if (result.installed.length > 0) {
|
|
180
|
-
installed.push(...result.installed);
|
|
181
|
-
}
|
|
182
|
-
if (result.skipped.length > 0) {
|
|
183
|
-
skipped.push(...result.skipped);
|
|
184
|
-
}
|
|
185
|
-
result.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
failed.push(name);
|
|
189
|
-
logger.error(`Failed to install ${options.itemLabel} ${name}: ${error.message}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return {
|
|
193
|
-
installed,
|
|
194
|
-
skipped,
|
|
195
|
-
failed,
|
|
196
|
-
npmDependencies
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
export function createEmptyResult() {
|
|
200
|
-
return {
|
|
201
|
-
installed: [],
|
|
202
|
-
skipped: [],
|
|
203
|
-
failed: [],
|
|
204
|
-
npmDependencies: new Set()
|
|
205
|
-
};
|
|
206
|
-
}
|
|
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
|
+
import { normalizeNames } from "./name-utils.js";
|
|
7
|
+
function capitalize(value) {
|
|
8
|
+
if (value.length === 0) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
12
|
+
}
|
|
13
|
+
export function normalizeEntryNames(names) {
|
|
14
|
+
return normalizeNames(names);
|
|
15
|
+
}
|
|
16
|
+
export function getEntryNames(entries) {
|
|
17
|
+
return entries.map((entry) => entry.name);
|
|
18
|
+
}
|
|
19
|
+
export function createEntryMap(entries) {
|
|
20
|
+
return new Map(entries.map((entry) => [entry.name, entry]));
|
|
21
|
+
}
|
|
22
|
+
export function validateEntries(names, entries) {
|
|
23
|
+
const valid = [];
|
|
24
|
+
const invalid = [];
|
|
25
|
+
const suggestions = [];
|
|
26
|
+
const entryMap = createEntryMap(entries);
|
|
27
|
+
const available = getEntryNames(entries);
|
|
28
|
+
for (const name of names) {
|
|
29
|
+
const trimmed = name.trim();
|
|
30
|
+
if (!trimmed) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (entryMap.has(trimmed)) {
|
|
34
|
+
valid.push(trimmed);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
invalid.push(trimmed);
|
|
38
|
+
const lower = trimmed.toLowerCase();
|
|
39
|
+
const similar = available.filter((entryName) => {
|
|
40
|
+
const candidate = entryName.toLowerCase();
|
|
41
|
+
return candidate.includes(lower) || lower.includes(candidate);
|
|
42
|
+
});
|
|
43
|
+
suggestions.push(...similar);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
valid,
|
|
47
|
+
invalid,
|
|
48
|
+
suggestions: [...new Set(suggestions)]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function analyzeEntryDependencies(names, entries, registry, lockfile, lockKey) {
|
|
52
|
+
const entryMap = createEntryMap(entries);
|
|
53
|
+
const componentDependencies = new Set();
|
|
54
|
+
const npmDependencies = new Set();
|
|
55
|
+
for (const entryName of names) {
|
|
56
|
+
const entry = entryMap.get(entryName);
|
|
57
|
+
entry?.dependencies?.local?.forEach((dep) => componentDependencies.add(dep));
|
|
58
|
+
entry?.dependencies?.npm?.forEach((dep) => npmDependencies.add(dep));
|
|
59
|
+
}
|
|
60
|
+
const componentDependencyList = Array.from(componentDependencies);
|
|
61
|
+
const componentAnalysis = componentDependencyList.length > 0
|
|
62
|
+
? analyzeDependencies(componentDependencyList, registry, lockfile)
|
|
63
|
+
: {
|
|
64
|
+
components: [],
|
|
65
|
+
dependencies: new Set(),
|
|
66
|
+
npmDependencies: new Set(),
|
|
67
|
+
conflicts: [],
|
|
68
|
+
totalToInstall: 0,
|
|
69
|
+
missingDependencies: []
|
|
70
|
+
};
|
|
71
|
+
componentAnalysis.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
72
|
+
const entryConflicts = names.filter((entryName) => lockfile[lockKey][entryName]);
|
|
73
|
+
const componentConflicts = componentAnalysis.conflicts;
|
|
74
|
+
const conflicts = new Set([
|
|
75
|
+
...entryConflicts,
|
|
76
|
+
...componentConflicts
|
|
77
|
+
]);
|
|
78
|
+
const totalTargets = names.length + componentAnalysis.components.length;
|
|
79
|
+
const totalToInstall = Math.max(0, totalTargets - conflicts.size);
|
|
80
|
+
return {
|
|
81
|
+
entries: names,
|
|
82
|
+
componentDependencies: componentAnalysis.components,
|
|
83
|
+
npmDependencies,
|
|
84
|
+
conflicts: Array.from(conflicts),
|
|
85
|
+
totalTargets,
|
|
86
|
+
totalToInstall,
|
|
87
|
+
missingDependencies: componentAnalysis.missingDependencies
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export async function confirmOverwrite(entryPlural) {
|
|
91
|
+
const { overwrite } = await prompts({
|
|
92
|
+
type: "confirm",
|
|
93
|
+
name: "overwrite",
|
|
94
|
+
message: `Overwrite existing ${entryPlural}?`,
|
|
95
|
+
initial: false
|
|
96
|
+
});
|
|
97
|
+
return overwrite;
|
|
98
|
+
}
|
|
99
|
+
export function displayInstallationPlan(analysis, options, labels) {
|
|
100
|
+
const entryLabel = capitalize(labels.entryPlural);
|
|
101
|
+
console.log("\n" + chalk.bold("Installation Plan:"));
|
|
102
|
+
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
103
|
+
console.log(`${chalk.cyan(`${entryLabel} to install:`)} ${chalk.white(analysis.entries.length)}`);
|
|
104
|
+
if (analysis.componentDependencies.length > 0) {
|
|
105
|
+
console.log(`${chalk.cyan("Component dependencies:")} ${chalk.white(analysis.componentDependencies.length)}`);
|
|
106
|
+
console.log(chalk.gray(` ${analysis.componentDependencies.join(", ")}`));
|
|
107
|
+
}
|
|
108
|
+
if (analysis.npmDependencies.size > 0) {
|
|
109
|
+
console.log(`${chalk.cyan("NPM packages required:")} ${chalk.white(analysis.npmDependencies.size)}`);
|
|
110
|
+
console.log(chalk.gray(` ${Array.from(analysis.npmDependencies).join(", ")}`));
|
|
111
|
+
}
|
|
112
|
+
if (analysis.missingDependencies.length > 0) {
|
|
113
|
+
console.log(`${chalk.red("Missing registry dependencies:")} ${chalk.white(analysis.missingDependencies.length)}`);
|
|
114
|
+
console.log(chalk.gray(` ${analysis.missingDependencies.join(", ")}`));
|
|
115
|
+
}
|
|
116
|
+
if (analysis.conflicts.length > 0 && !options.force) {
|
|
117
|
+
console.log(`${chalk.yellow("Conflicts detected:")} ${chalk.white(analysis.conflicts.length)}`);
|
|
118
|
+
console.log(chalk.gray(` ${analysis.conflicts.join(", ")}`));
|
|
119
|
+
}
|
|
120
|
+
console.log(chalk.gray("\u00c4".repeat(50)) + "\n");
|
|
121
|
+
}
|
|
122
|
+
export function displayResults(result, options, labels) {
|
|
123
|
+
const { dependencies, entries } = result;
|
|
124
|
+
console.log("\n" + chalk.bold("Installation Results:"));
|
|
125
|
+
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
126
|
+
if (dependencies.installed.length > 0) {
|
|
127
|
+
console.log(chalk.green(`\u00fb Installed component dependencies (${dependencies.installed.length}):`));
|
|
128
|
+
dependencies.installed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
129
|
+
}
|
|
130
|
+
if (dependencies.skipped.length > 0 && !options.force) {
|
|
131
|
+
console.log(chalk.yellow(`? Skipped component dependencies (${dependencies.skipped.length}):`));
|
|
132
|
+
dependencies.skipped.forEach((name) => console.log(chalk.gray(` \u0007 ${name} (already exists)`)));
|
|
133
|
+
}
|
|
134
|
+
if (dependencies.failed.length > 0) {
|
|
135
|
+
console.log(chalk.red(`? Failed component dependencies (${dependencies.failed.length}):`));
|
|
136
|
+
dependencies.failed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
137
|
+
}
|
|
138
|
+
if (entries.installed.length > 0) {
|
|
139
|
+
console.log(chalk.green(`\u00fb Installed ${labels.entryPlural} (${entries.installed.length}):`));
|
|
140
|
+
entries.installed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
141
|
+
}
|
|
142
|
+
if (entries.skipped.length > 0 && !options.force) {
|
|
143
|
+
console.log(chalk.yellow(`? Skipped ${labels.entryPlural} (${entries.skipped.length}):`));
|
|
144
|
+
entries.skipped.forEach((name) => console.log(chalk.gray(` \u0007 ${name} (already exists)`)));
|
|
145
|
+
}
|
|
146
|
+
if (entries.failed.length > 0) {
|
|
147
|
+
console.log(chalk.red(`? Failed ${labels.entryPlural} (${entries.failed.length}):`));
|
|
148
|
+
entries.failed.forEach((name) => console.log(chalk.gray(` \u0007 ${name}`)));
|
|
149
|
+
}
|
|
150
|
+
console.log(chalk.gray("\u00c4".repeat(50)));
|
|
151
|
+
if (entries.installed.length > 0) {
|
|
152
|
+
const label = entries.installed.length === 1 ? labels.entrySingular : labels.entryPlural;
|
|
153
|
+
console.log(chalk.green.bold(`\n\u00fb Successfully installed ${entries.installed.length} ${label}!`));
|
|
154
|
+
}
|
|
155
|
+
console.log();
|
|
156
|
+
}
|
|
157
|
+
export async function installEntries(entries, names, lockEntries, options) {
|
|
158
|
+
const installed = [];
|
|
159
|
+
const skipped = [];
|
|
160
|
+
const failed = [];
|
|
161
|
+
const npmDependencies = new Set();
|
|
162
|
+
let currentIndex = 0;
|
|
163
|
+
const total = names.length;
|
|
164
|
+
for (const name of names) {
|
|
165
|
+
currentIndex += 1;
|
|
166
|
+
try {
|
|
167
|
+
if (options.spinner) {
|
|
168
|
+
options.spinner.text = `Installing ${name} (${currentIndex}/${total})...`;
|
|
169
|
+
}
|
|
170
|
+
const result = await installRegistryEntries({
|
|
171
|
+
cwd: options.cwd,
|
|
172
|
+
config: options.config,
|
|
173
|
+
entries,
|
|
174
|
+
names: [name],
|
|
175
|
+
lockEntries,
|
|
176
|
+
force: options.force,
|
|
177
|
+
itemLabel: options.itemLabel
|
|
178
|
+
});
|
|
179
|
+
if (result.installed.length > 0) {
|
|
180
|
+
installed.push(...result.installed);
|
|
181
|
+
}
|
|
182
|
+
if (result.skipped.length > 0) {
|
|
183
|
+
skipped.push(...result.skipped);
|
|
184
|
+
}
|
|
185
|
+
result.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
failed.push(name);
|
|
189
|
+
logger.error(`Failed to install ${options.itemLabel} ${name}: ${error.message}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
installed,
|
|
194
|
+
skipped,
|
|
195
|
+
failed,
|
|
196
|
+
npmDependencies
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export function createEmptyResult() {
|
|
200
|
+
return {
|
|
201
|
+
installed: [],
|
|
202
|
+
skipped: [],
|
|
203
|
+
failed: [],
|
|
204
|
+
npmDependencies: new Set()
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
207
|
//# sourceMappingURL=add-collection.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RegistryItem } from "../../lib/registry.js";
|
|
2
|
-
export interface ListEntriesOptions {
|
|
3
|
-
entries: RegistryItem[];
|
|
4
|
-
emptyMessage?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function listEntries(options: ListEntriesOptions): void;
|
|
1
|
+
import type { RegistryItem } from "../../lib/registry.js";
|
|
2
|
+
export interface ListEntriesOptions {
|
|
3
|
+
entries: RegistryItem[];
|
|
4
|
+
emptyMessage?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function listEntries(options: ListEntriesOptions): void;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export function listEntries(options) {
|
|
2
|
-
const { entries, emptyMessage } = options;
|
|
3
|
-
if (entries.length === 0) {
|
|
4
|
-
if (emptyMessage) {
|
|
5
|
-
console.log(emptyMessage);
|
|
6
|
-
}
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
for (const entry of entries) {
|
|
10
|
-
console.log(`${entry.name} - ${entry.description}`);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
export function listEntries(options) {
|
|
2
|
+
const { entries, emptyMessage } = options;
|
|
3
|
+
if (entries.length === 0) {
|
|
4
|
+
if (emptyMessage) {
|
|
5
|
+
console.log(emptyMessage);
|
|
6
|
+
}
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
for (const entry of entries) {
|
|
10
|
+
console.log(`${entry.name} - ${entry.description}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=list-entries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function normalizeNames(names: string[]): string[];
|
|
1
|
+
export declare function normalizeNames(names: string[]): string[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export function normalizeNames(names) {
|
|
2
|
-
const unique = new Set();
|
|
3
|
-
const normalized = [];
|
|
4
|
-
for (const name of names) {
|
|
5
|
-
const trimmed = name.trim();
|
|
6
|
-
if (!trimmed || unique.has(trimmed)) {
|
|
7
|
-
continue;
|
|
8
|
-
}
|
|
9
|
-
unique.add(trimmed);
|
|
10
|
-
normalized.push(trimmed);
|
|
11
|
-
}
|
|
12
|
-
return normalized;
|
|
13
|
-
}
|
|
1
|
+
export function normalizeNames(names) {
|
|
2
|
+
const unique = new Set();
|
|
3
|
+
const normalized = [];
|
|
4
|
+
for (const name of names) {
|
|
5
|
+
const trimmed = name.trim();
|
|
6
|
+
if (!trimmed || unique.has(trimmed)) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
unique.add(trimmed);
|
|
10
|
+
normalized.push(trimmed);
|
|
11
|
+
}
|
|
12
|
+
return normalized;
|
|
13
|
+
}
|
|
14
14
|
//# sourceMappingURL=name-utils.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { TrixUIConfig } from "../../lib/config.js";
|
|
2
|
-
import type { LockfileComponent } from "../../lib/lockfile.js";
|
|
3
|
-
import type { RegistryItem } from "../../lib/registry.js";
|
|
4
|
-
export interface RemoveEntriesOptions {
|
|
5
|
-
cwd: string;
|
|
6
|
-
config: TrixUIConfig;
|
|
7
|
-
registryEntries: RegistryItem[];
|
|
8
|
-
lockEntries: Record<string, LockfileComponent>;
|
|
9
|
-
names: string[];
|
|
10
|
-
force: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface RemoveEntriesResult {
|
|
13
|
-
removed: string[];
|
|
14
|
-
skipped: string[];
|
|
15
|
-
}
|
|
16
|
-
export declare function removeEntries(options: RemoveEntriesOptions): Promise<RemoveEntriesResult>;
|
|
1
|
+
import type { TrixUIConfig } from "../../lib/config.js";
|
|
2
|
+
import type { LockfileComponent } from "../../lib/lockfile.js";
|
|
3
|
+
import type { RegistryItem } from "../../lib/registry.js";
|
|
4
|
+
export interface RemoveEntriesOptions {
|
|
5
|
+
cwd: string;
|
|
6
|
+
config: TrixUIConfig;
|
|
7
|
+
registryEntries: RegistryItem[];
|
|
8
|
+
lockEntries: Record<string, LockfileComponent>;
|
|
9
|
+
names: string[];
|
|
10
|
+
force: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface RemoveEntriesResult {
|
|
13
|
+
removed: string[];
|
|
14
|
+
skipped: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function removeEntries(options: RemoveEntriesOptions): Promise<RemoveEntriesResult>;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { deleteFile } from "../../lib/fs.js";
|
|
3
|
-
import { fromPosix, resolveTargetPath } from "../../lib/paths.js";
|
|
4
|
-
import { normalizeNames } from "./name-utils.js";
|
|
5
|
-
export async function removeEntries(options) {
|
|
6
|
-
const { cwd, config, registryEntries, lockEntries, names, force } = options;
|
|
7
|
-
const registryMap = new Map(registryEntries.map((entry) => [entry.name, entry]));
|
|
8
|
-
const uniqueNames = normalizeNames(names);
|
|
9
|
-
const removed = [];
|
|
10
|
-
const skipped = [];
|
|
11
|
-
for (const name of uniqueNames) {
|
|
12
|
-
const locked = lockEntries[name];
|
|
13
|
-
let files = [];
|
|
14
|
-
if (locked) {
|
|
15
|
-
files = locked.files.map((file) => path.resolve(cwd, fromPosix(file)));
|
|
16
|
-
}
|
|
17
|
-
else if (force) {
|
|
18
|
-
const entry = registryMap.get(name);
|
|
19
|
-
if (!entry) {
|
|
20
|
-
skipped.push(name);
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
files = entry.files.map((file) => resolveTargetPath(cwd, file.target, config.paths));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
skipped.push(name);
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
for (const file of files) {
|
|
30
|
-
await deleteFile(file);
|
|
31
|
-
}
|
|
32
|
-
if (lockEntries[name]) {
|
|
33
|
-
delete lockEntries[name];
|
|
34
|
-
}
|
|
35
|
-
removed.push(name);
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
removed,
|
|
39
|
-
skipped
|
|
40
|
-
};
|
|
41
|
-
}
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { deleteFile } from "../../lib/fs.js";
|
|
3
|
+
import { fromPosix, resolveTargetPath } from "../../lib/paths.js";
|
|
4
|
+
import { normalizeNames } from "./name-utils.js";
|
|
5
|
+
export async function removeEntries(options) {
|
|
6
|
+
const { cwd, config, registryEntries, lockEntries, names, force } = options;
|
|
7
|
+
const registryMap = new Map(registryEntries.map((entry) => [entry.name, entry]));
|
|
8
|
+
const uniqueNames = normalizeNames(names);
|
|
9
|
+
const removed = [];
|
|
10
|
+
const skipped = [];
|
|
11
|
+
for (const name of uniqueNames) {
|
|
12
|
+
const locked = lockEntries[name];
|
|
13
|
+
let files = [];
|
|
14
|
+
if (locked) {
|
|
15
|
+
files = locked.files.map((file) => path.resolve(cwd, fromPosix(file)));
|
|
16
|
+
}
|
|
17
|
+
else if (force) {
|
|
18
|
+
const entry = registryMap.get(name);
|
|
19
|
+
if (!entry) {
|
|
20
|
+
skipped.push(name);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
files = entry.files.map((file) => resolveTargetPath(cwd, file.target, config.paths));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
skipped.push(name);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
await deleteFile(file);
|
|
31
|
+
}
|
|
32
|
+
if (lockEntries[name]) {
|
|
33
|
+
delete lockEntries[name];
|
|
34
|
+
}
|
|
35
|
+
removed.push(name);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
removed,
|
|
39
|
+
skipped
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
42
|
//# sourceMappingURL=remove-entries.js.map
|
package/dist/icons/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./libraries.js";
|
|
1
|
+
export * from "./libraries.js";
|
package/dist/icons/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./libraries.js";
|
|
1
|
+
export * from "./libraries.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|