trix-ui 0.2.7 → 0.2.9
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 +68 -68
- package/templates/lib/utils.js +7 -0
- package/templates/styles/globals.css +85 -67
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { addCommand } from "../../add.js";
|
|
3
|
-
import "./__mocks__/cli-mocks.js";
|
|
4
|
-
import "./add.mocks.js";
|
|
5
|
-
import { analyzeDependencies, directoryExists, getComponentNames, installComponents, loadConfig, loadLockfile, loadRegistry, validateComponents } from "./add.mocks.js";
|
|
6
|
-
describe("add command", () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
vi.resetAllMocks();
|
|
9
|
-
});
|
|
10
|
-
it("exits if directory does not exist", async () => {
|
|
11
|
-
directoryExists.mockResolvedValue(false);
|
|
12
|
-
await addCommand.parseAsync(["node", "cli", "add", "button"]);
|
|
13
|
-
expect(process.exit).toHaveBeenCalledWith(1);
|
|
14
|
-
});
|
|
15
|
-
it("exits if component does not exist", async () => {
|
|
16
|
-
directoryExists.mockResolvedValue(true);
|
|
17
|
-
loadConfig.mockResolvedValue({});
|
|
18
|
-
loadRegistry.mockResolvedValue({});
|
|
19
|
-
loadLockfile.mockResolvedValue({});
|
|
20
|
-
validateComponents.mockReturnValue({
|
|
21
|
-
valid: [],
|
|
22
|
-
invalid: ["button"],
|
|
23
|
-
suggestions: []
|
|
24
|
-
});
|
|
25
|
-
await addCommand.parseAsync(["node", "cli", "add", "button"]);
|
|
26
|
-
expect(process.exit).toHaveBeenCalledWith(1);
|
|
27
|
-
});
|
|
28
|
-
it("installs a valid component successfully", async () => {
|
|
29
|
-
directoryExists.mockResolvedValue(true);
|
|
30
|
-
loadConfig.mockResolvedValue({ barrel: false });
|
|
31
|
-
loadRegistry.mockResolvedValue({});
|
|
32
|
-
loadLockfile.mockResolvedValue({});
|
|
33
|
-
validateComponents.mockReturnValue({
|
|
34
|
-
valid: ["button"],
|
|
35
|
-
invalid: [],
|
|
36
|
-
suggestions: []
|
|
37
|
-
});
|
|
38
|
-
analyzeDependencies.mockReturnValue({
|
|
39
|
-
components: ["button"],
|
|
40
|
-
dependencies: new Set(),
|
|
41
|
-
npmDependencies: new Set(),
|
|
42
|
-
conflicts: [],
|
|
43
|
-
totalToInstall: 1,
|
|
44
|
-
missingDependencies: []
|
|
45
|
-
});
|
|
46
|
-
installComponents.mockResolvedValue({
|
|
47
|
-
installed: ["button"],
|
|
48
|
-
failed: [],
|
|
49
|
-
npmDependencies: new Set()
|
|
50
|
-
});
|
|
51
|
-
await addCommand.parseAsync(["node", "cli", "add", "button", "--yes"]);
|
|
52
|
-
expect(installComponents).toHaveBeenCalled();
|
|
53
|
-
});
|
|
54
|
-
it("installs all components when 'all' is used", async () => {
|
|
55
|
-
directoryExists.mockResolvedValue(true);
|
|
56
|
-
loadConfig.mockResolvedValue({});
|
|
57
|
-
loadRegistry.mockResolvedValue({});
|
|
58
|
-
loadLockfile.mockResolvedValue({});
|
|
59
|
-
getComponentNames.mockReturnValue(["button", "card"]);
|
|
60
|
-
validateComponents.mockReturnValue({
|
|
61
|
-
valid: ["button", "card"],
|
|
62
|
-
invalid: [],
|
|
63
|
-
suggestions: []
|
|
64
|
-
});
|
|
65
|
-
analyzeDependencies.mockReturnValue({
|
|
66
|
-
components: ["button", "card"],
|
|
67
|
-
dependencies: new Set(),
|
|
68
|
-
npmDependencies: new Set(),
|
|
69
|
-
conflicts: [],
|
|
70
|
-
totalToInstall: 2,
|
|
71
|
-
missingDependencies: []
|
|
72
|
-
});
|
|
73
|
-
installComponents.mockResolvedValue({
|
|
74
|
-
installed: ["button", "card"],
|
|
75
|
-
failed: [],
|
|
76
|
-
npmDependencies: new Set()
|
|
77
|
-
});
|
|
78
|
-
await addCommand.parseAsync(["node", "cli", "add", "all", "--yes"]);
|
|
79
|
-
expect(installComponents).toHaveBeenCalled();
|
|
80
|
-
});
|
|
81
|
-
it("forces overwrite when --force is passed", async () => {
|
|
82
|
-
directoryExists.mockResolvedValue(true);
|
|
83
|
-
loadConfig.mockResolvedValue({});
|
|
84
|
-
loadRegistry.mockResolvedValue({});
|
|
85
|
-
loadLockfile.mockResolvedValue({});
|
|
86
|
-
validateComponents.mockReturnValue({
|
|
87
|
-
valid: ["button"],
|
|
88
|
-
invalid: [],
|
|
89
|
-
suggestions: []
|
|
90
|
-
});
|
|
91
|
-
analyzeDependencies.mockReturnValue({
|
|
92
|
-
components: ["button"],
|
|
93
|
-
dependencies: new Set(),
|
|
94
|
-
npmDependencies: new Set(),
|
|
95
|
-
conflicts: ["button"],
|
|
96
|
-
totalToInstall: 0,
|
|
97
|
-
missingDependencies: []
|
|
98
|
-
});
|
|
99
|
-
installComponents.mockResolvedValue({
|
|
100
|
-
installed: ["button"],
|
|
101
|
-
failed: [],
|
|
102
|
-
npmDependencies: new Set()
|
|
103
|
-
});
|
|
104
|
-
await addCommand.parseAsync([
|
|
105
|
-
"node",
|
|
106
|
-
"cli",
|
|
107
|
-
"add",
|
|
108
|
-
"button",
|
|
109
|
-
"--force",
|
|
110
|
-
"--yes"
|
|
111
|
-
]);
|
|
112
|
-
expect(installComponents).toHaveBeenCalled();
|
|
113
|
-
});
|
|
114
|
-
it("exits with failure if install fails", async () => {
|
|
115
|
-
directoryExists.mockResolvedValue(true);
|
|
116
|
-
loadConfig.mockResolvedValue({});
|
|
117
|
-
loadRegistry.mockResolvedValue({});
|
|
118
|
-
loadLockfile.mockResolvedValue({});
|
|
119
|
-
validateComponents.mockReturnValue({
|
|
120
|
-
valid: ["button"],
|
|
121
|
-
invalid: [],
|
|
122
|
-
suggestions: []
|
|
123
|
-
});
|
|
124
|
-
analyzeDependencies.mockReturnValue({
|
|
125
|
-
components: ["hbutton"],
|
|
126
|
-
dependencies: new Set(),
|
|
127
|
-
npmDependencies: new Set(),
|
|
128
|
-
conflicts: [],
|
|
129
|
-
totalToInstall: 1,
|
|
130
|
-
missingDependencies: []
|
|
131
|
-
});
|
|
132
|
-
installComponents.mockResolvedValue({
|
|
133
|
-
installed: [],
|
|
134
|
-
failed: ["button"],
|
|
135
|
-
npmDependencies: new Set()
|
|
136
|
-
});
|
|
137
|
-
await addCommand.parseAsync(["node", "cli", "add", "button", "--yes"]);
|
|
138
|
-
expect(process.exit).toHaveBeenCalledWith(1);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import { addCommand } from "../../add.js";
|
|
3
|
+
import "./__mocks__/cli-mocks.js";
|
|
4
|
+
import "./add.mocks.js";
|
|
5
|
+
import { analyzeDependencies, directoryExists, getComponentNames, installComponents, loadConfig, loadLockfile, loadRegistry, validateComponents } from "./add.mocks.js";
|
|
6
|
+
describe("add command", () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
vi.resetAllMocks();
|
|
9
|
+
});
|
|
10
|
+
it("exits if directory does not exist", async () => {
|
|
11
|
+
directoryExists.mockResolvedValue(false);
|
|
12
|
+
await addCommand.parseAsync(["node", "cli", "add", "button"]);
|
|
13
|
+
expect(process.exit).toHaveBeenCalledWith(1);
|
|
14
|
+
});
|
|
15
|
+
it("exits if component does not exist", async () => {
|
|
16
|
+
directoryExists.mockResolvedValue(true);
|
|
17
|
+
loadConfig.mockResolvedValue({});
|
|
18
|
+
loadRegistry.mockResolvedValue({});
|
|
19
|
+
loadLockfile.mockResolvedValue({});
|
|
20
|
+
validateComponents.mockReturnValue({
|
|
21
|
+
valid: [],
|
|
22
|
+
invalid: ["button"],
|
|
23
|
+
suggestions: []
|
|
24
|
+
});
|
|
25
|
+
await addCommand.parseAsync(["node", "cli", "add", "button"]);
|
|
26
|
+
expect(process.exit).toHaveBeenCalledWith(1);
|
|
27
|
+
});
|
|
28
|
+
it("installs a valid component successfully", async () => {
|
|
29
|
+
directoryExists.mockResolvedValue(true);
|
|
30
|
+
loadConfig.mockResolvedValue({ barrel: false });
|
|
31
|
+
loadRegistry.mockResolvedValue({});
|
|
32
|
+
loadLockfile.mockResolvedValue({});
|
|
33
|
+
validateComponents.mockReturnValue({
|
|
34
|
+
valid: ["button"],
|
|
35
|
+
invalid: [],
|
|
36
|
+
suggestions: []
|
|
37
|
+
});
|
|
38
|
+
analyzeDependencies.mockReturnValue({
|
|
39
|
+
components: ["button"],
|
|
40
|
+
dependencies: new Set(),
|
|
41
|
+
npmDependencies: new Set(),
|
|
42
|
+
conflicts: [],
|
|
43
|
+
totalToInstall: 1,
|
|
44
|
+
missingDependencies: []
|
|
45
|
+
});
|
|
46
|
+
installComponents.mockResolvedValue({
|
|
47
|
+
installed: ["button"],
|
|
48
|
+
failed: [],
|
|
49
|
+
npmDependencies: new Set()
|
|
50
|
+
});
|
|
51
|
+
await addCommand.parseAsync(["node", "cli", "add", "button", "--yes"]);
|
|
52
|
+
expect(installComponents).toHaveBeenCalled();
|
|
53
|
+
});
|
|
54
|
+
it("installs all components when 'all' is used", async () => {
|
|
55
|
+
directoryExists.mockResolvedValue(true);
|
|
56
|
+
loadConfig.mockResolvedValue({});
|
|
57
|
+
loadRegistry.mockResolvedValue({});
|
|
58
|
+
loadLockfile.mockResolvedValue({});
|
|
59
|
+
getComponentNames.mockReturnValue(["button", "card"]);
|
|
60
|
+
validateComponents.mockReturnValue({
|
|
61
|
+
valid: ["button", "card"],
|
|
62
|
+
invalid: [],
|
|
63
|
+
suggestions: []
|
|
64
|
+
});
|
|
65
|
+
analyzeDependencies.mockReturnValue({
|
|
66
|
+
components: ["button", "card"],
|
|
67
|
+
dependencies: new Set(),
|
|
68
|
+
npmDependencies: new Set(),
|
|
69
|
+
conflicts: [],
|
|
70
|
+
totalToInstall: 2,
|
|
71
|
+
missingDependencies: []
|
|
72
|
+
});
|
|
73
|
+
installComponents.mockResolvedValue({
|
|
74
|
+
installed: ["button", "card"],
|
|
75
|
+
failed: [],
|
|
76
|
+
npmDependencies: new Set()
|
|
77
|
+
});
|
|
78
|
+
await addCommand.parseAsync(["node", "cli", "add", "all", "--yes"]);
|
|
79
|
+
expect(installComponents).toHaveBeenCalled();
|
|
80
|
+
});
|
|
81
|
+
it("forces overwrite when --force is passed", async () => {
|
|
82
|
+
directoryExists.mockResolvedValue(true);
|
|
83
|
+
loadConfig.mockResolvedValue({});
|
|
84
|
+
loadRegistry.mockResolvedValue({});
|
|
85
|
+
loadLockfile.mockResolvedValue({});
|
|
86
|
+
validateComponents.mockReturnValue({
|
|
87
|
+
valid: ["button"],
|
|
88
|
+
invalid: [],
|
|
89
|
+
suggestions: []
|
|
90
|
+
});
|
|
91
|
+
analyzeDependencies.mockReturnValue({
|
|
92
|
+
components: ["button"],
|
|
93
|
+
dependencies: new Set(),
|
|
94
|
+
npmDependencies: new Set(),
|
|
95
|
+
conflicts: ["button"],
|
|
96
|
+
totalToInstall: 0,
|
|
97
|
+
missingDependencies: []
|
|
98
|
+
});
|
|
99
|
+
installComponents.mockResolvedValue({
|
|
100
|
+
installed: ["button"],
|
|
101
|
+
failed: [],
|
|
102
|
+
npmDependencies: new Set()
|
|
103
|
+
});
|
|
104
|
+
await addCommand.parseAsync([
|
|
105
|
+
"node",
|
|
106
|
+
"cli",
|
|
107
|
+
"add",
|
|
108
|
+
"button",
|
|
109
|
+
"--force",
|
|
110
|
+
"--yes"
|
|
111
|
+
]);
|
|
112
|
+
expect(installComponents).toHaveBeenCalled();
|
|
113
|
+
});
|
|
114
|
+
it("exits with failure if install fails", async () => {
|
|
115
|
+
directoryExists.mockResolvedValue(true);
|
|
116
|
+
loadConfig.mockResolvedValue({});
|
|
117
|
+
loadRegistry.mockResolvedValue({});
|
|
118
|
+
loadLockfile.mockResolvedValue({});
|
|
119
|
+
validateComponents.mockReturnValue({
|
|
120
|
+
valid: ["button"],
|
|
121
|
+
invalid: [],
|
|
122
|
+
suggestions: []
|
|
123
|
+
});
|
|
124
|
+
analyzeDependencies.mockReturnValue({
|
|
125
|
+
components: ["hbutton"],
|
|
126
|
+
dependencies: new Set(),
|
|
127
|
+
npmDependencies: new Set(),
|
|
128
|
+
conflicts: [],
|
|
129
|
+
totalToInstall: 1,
|
|
130
|
+
missingDependencies: []
|
|
131
|
+
});
|
|
132
|
+
installComponents.mockResolvedValue({
|
|
133
|
+
installed: [],
|
|
134
|
+
failed: ["button"],
|
|
135
|
+
npmDependencies: new Set()
|
|
136
|
+
});
|
|
137
|
+
await addCommand.parseAsync(["node", "cli", "add", "button", "--yes"]);
|
|
138
|
+
expect(process.exit).toHaveBeenCalledWith(1);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
141
|
//# sourceMappingURL=add.test.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Lockfile } from "../../lib/lockfile.js";
|
|
2
|
-
import type { RegistryIndex } from "../../lib/registry.js";
|
|
3
|
-
import type { DependencyAnalysis } from "./types.js";
|
|
4
|
-
export declare function analyzeDependencies(components: string[], registry: RegistryIndex, lockfile: Lockfile): DependencyAnalysis;
|
|
1
|
+
import type { Lockfile } from "../../lib/lockfile.js";
|
|
2
|
+
import type { RegistryIndex } from "../../lib/registry.js";
|
|
3
|
+
import type { DependencyAnalysis } from "./types.js";
|
|
4
|
+
export declare function analyzeDependencies(components: string[], registry: RegistryIndex, lockfile: Lockfile): DependencyAnalysis;
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { createComponentMap } from "./registry.js";
|
|
2
|
-
function collectLocalDependencies(entry) {
|
|
3
|
-
return entry.dependencies?.local ?? [];
|
|
4
|
-
}
|
|
5
|
-
function collectNpmDependencies(entry) {
|
|
6
|
-
return entry.dependencies?.npm ?? [];
|
|
7
|
-
}
|
|
8
|
-
export function analyzeDependencies(components, registry, lockfile) {
|
|
9
|
-
const componentMap = createComponentMap(registry);
|
|
10
|
-
const allComponents = new Set(components);
|
|
11
|
-
const dependencies = new Set();
|
|
12
|
-
const npmDependencies = new Set();
|
|
13
|
-
const missingDependencies = new Set();
|
|
14
|
-
const visited = new Set();
|
|
15
|
-
const resolveDependencies = (componentName) => {
|
|
16
|
-
if (visited.has(componentName)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
visited.add(componentName);
|
|
20
|
-
const entry = componentMap.get(componentName);
|
|
21
|
-
if (!entry) {
|
|
22
|
-
missingDependencies.add(componentName);
|
|
23
|
-
allComponents.delete(componentName);
|
|
24
|
-
dependencies.delete(componentName);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
for (const dep of collectLocalDependencies(entry)) {
|
|
28
|
-
if (!allComponents.has(dep)) {
|
|
29
|
-
allComponents.add(dep);
|
|
30
|
-
dependencies.add(dep);
|
|
31
|
-
}
|
|
32
|
-
resolveDependencies(dep);
|
|
33
|
-
}
|
|
34
|
-
for (const dep of collectNpmDependencies(entry)) {
|
|
35
|
-
npmDependencies.add(dep);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
for (const component of components) {
|
|
39
|
-
resolveDependencies(component);
|
|
40
|
-
}
|
|
41
|
-
const conflicts = [];
|
|
42
|
-
for (const component of allComponents) {
|
|
43
|
-
if (lockfile.components[component]) {
|
|
44
|
-
conflicts.push(component);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const totalToInstall = Math.max(0, allComponents.size - conflicts.length);
|
|
48
|
-
return {
|
|
49
|
-
components: Array.from(allComponents),
|
|
50
|
-
dependencies,
|
|
51
|
-
npmDependencies,
|
|
52
|
-
conflicts,
|
|
53
|
-
totalToInstall,
|
|
54
|
-
missingDependencies: Array.from(missingDependencies).sort()
|
|
55
|
-
};
|
|
56
|
-
}
|
|
1
|
+
import { createComponentMap } from "./registry.js";
|
|
2
|
+
function collectLocalDependencies(entry) {
|
|
3
|
+
return entry.dependencies?.local ?? [];
|
|
4
|
+
}
|
|
5
|
+
function collectNpmDependencies(entry) {
|
|
6
|
+
return entry.dependencies?.npm ?? [];
|
|
7
|
+
}
|
|
8
|
+
export function analyzeDependencies(components, registry, lockfile) {
|
|
9
|
+
const componentMap = createComponentMap(registry);
|
|
10
|
+
const allComponents = new Set(components);
|
|
11
|
+
const dependencies = new Set();
|
|
12
|
+
const npmDependencies = new Set();
|
|
13
|
+
const missingDependencies = new Set();
|
|
14
|
+
const visited = new Set();
|
|
15
|
+
const resolveDependencies = (componentName) => {
|
|
16
|
+
if (visited.has(componentName)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
visited.add(componentName);
|
|
20
|
+
const entry = componentMap.get(componentName);
|
|
21
|
+
if (!entry) {
|
|
22
|
+
missingDependencies.add(componentName);
|
|
23
|
+
allComponents.delete(componentName);
|
|
24
|
+
dependencies.delete(componentName);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const dep of collectLocalDependencies(entry)) {
|
|
28
|
+
if (!allComponents.has(dep)) {
|
|
29
|
+
allComponents.add(dep);
|
|
30
|
+
dependencies.add(dep);
|
|
31
|
+
}
|
|
32
|
+
resolveDependencies(dep);
|
|
33
|
+
}
|
|
34
|
+
for (const dep of collectNpmDependencies(entry)) {
|
|
35
|
+
npmDependencies.add(dep);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
for (const component of components) {
|
|
39
|
+
resolveDependencies(component);
|
|
40
|
+
}
|
|
41
|
+
const conflicts = [];
|
|
42
|
+
for (const component of allComponents) {
|
|
43
|
+
if (lockfile.components[component]) {
|
|
44
|
+
conflicts.push(component);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const totalToInstall = Math.max(0, allComponents.size - conflicts.length);
|
|
48
|
+
return {
|
|
49
|
+
components: Array.from(allComponents),
|
|
50
|
+
dependencies,
|
|
51
|
+
npmDependencies,
|
|
52
|
+
conflicts,
|
|
53
|
+
totalToInstall,
|
|
54
|
+
missingDependencies: Array.from(missingDependencies).sort()
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
57
|
//# sourceMappingURL=analysis.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
export declare const addCommand: Command;
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
export declare const addCommand: Command;
|