ui-thing 0.2.8 → 0.3.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/.claude/settings.local.json +5 -0
- package/.prettierrc +1 -1
- package/CHANGELOG.md +58 -0
- package/bun.lock +978 -0
- package/package.json +29 -27
- package/src/commands/add.ts +9 -5
- package/src/commands/block.ts +5 -3
- package/src/commands/list.ts +48 -0
- package/src/commands/prose.ts +7 -3
- package/src/commands/remove.ts +109 -0
- package/src/commands/theme.ts +5 -14
- package/src/commands/update.ts +81 -0
- package/src/index.ts +6 -0
- package/src/templates/css.ts +5 -0
- package/src/templates/vs-code.ts +0 -8
- package/src/utils/config.ts +11 -17
- package/src/utils/constants.ts +1 -0
- package/src/utils/fetchBlockCategories.ts +13 -11
- package/src/utils/fetchBlocks.ts +13 -11
- package/src/utils/fetchComponents.ts +13 -11
- package/src/utils/fetchProseComponents.ts +13 -11
- package/src/utils/installPackages.ts +30 -4
- package/src/utils/installValidator.ts +3 -3
- package/src/utils/logger.ts +9 -0
- package/src/utils/uiConfigPrompt.ts +3 -6
- package/tests/commands/list.test.ts +111 -0
- package/tests/commands/remove.test.ts +151 -0
- package/tests/commands/update.test.ts +127 -0
- package/tests/utils/fetchBlockCategories.test.ts +14 -2
- package/tests/utils/fetchBlocks.test.ts +14 -2
- package/tests/utils/fetchComponents.test.ts +10 -4
- package/tests/utils/fetchProseComponents.test.ts +14 -2
- package/tests/utils/installPackages.test.ts +36 -3
- package/tsup.config.ts +5 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1343
- package/dist/index.js.map +0 -1
|
@@ -69,16 +69,22 @@ describe("utils/fetchComponents", () => {
|
|
|
69
69
|
delete process.env.COMPONENTS_API;
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
it("should
|
|
72
|
+
it("should call process.exit(1) on API error", async () => {
|
|
73
|
+
const exitSpy = vi.spyOn(process, "exit").mockImplementation((() => {}) as any);
|
|
73
74
|
mockAxios.onGet("https://uithing.com/api/components").reply(500);
|
|
74
75
|
|
|
75
|
-
await
|
|
76
|
+
await fetchComponents();
|
|
77
|
+
|
|
78
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
76
79
|
});
|
|
77
80
|
|
|
78
|
-
it("should
|
|
81
|
+
it("should call process.exit(1) on network error", async () => {
|
|
82
|
+
const exitSpy = vi.spyOn(process, "exit").mockImplementation((() => {}) as any);
|
|
79
83
|
mockAxios.onGet("https://uithing.com/api/components").networkError();
|
|
80
84
|
|
|
81
|
-
await
|
|
85
|
+
await fetchComponents();
|
|
86
|
+
|
|
87
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
82
88
|
});
|
|
83
89
|
|
|
84
90
|
it("should return empty array when API returns no data", async () => {
|
|
@@ -54,9 +54,21 @@ describe("utils/fetchProseComponents", () => {
|
|
|
54
54
|
delete process.env.PROSE_COMPONENTS_API;
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
it("should
|
|
57
|
+
it("should call process.exit(1) on API error", async () => {
|
|
58
|
+
const exitSpy = vi.spyOn(process, "exit").mockImplementation((() => {}) as any);
|
|
58
59
|
mockAxios.onGet("https://uithing.com/api/prose").reply(500);
|
|
59
60
|
|
|
60
|
-
await
|
|
61
|
+
await fetchProseComponents();
|
|
62
|
+
|
|
63
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("should call process.exit(1) on network error", async () => {
|
|
67
|
+
const exitSpy = vi.spyOn(process, "exit").mockImplementation((() => {}) as any);
|
|
68
|
+
mockAxios.onGet("https://uithing.com/api/prose").networkError();
|
|
69
|
+
|
|
70
|
+
await fetchProseComponents();
|
|
71
|
+
|
|
72
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
61
73
|
});
|
|
62
74
|
});
|
|
@@ -79,15 +79,48 @@ describe("utils/installPackages", () => {
|
|
|
79
79
|
expect(mockExeca).toHaveBeenCalledWith("npm", ["install", "-D", "typescript"]);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
it("should
|
|
82
|
+
it("should use pnpm add instead of install", async () => {
|
|
83
83
|
const { execa } = await import("execa");
|
|
84
84
|
const mockExeca = vi.mocked(execa);
|
|
85
85
|
mockExeca.mockResolvedValue({} as any);
|
|
86
86
|
|
|
87
87
|
await installPackages("pnpm", ["vue"], ["typescript"]);
|
|
88
88
|
|
|
89
|
-
expect(mockExeca).toHaveBeenCalledWith("pnpm", ["
|
|
90
|
-
expect(mockExeca).toHaveBeenCalledWith("pnpm", ["
|
|
89
|
+
expect(mockExeca).toHaveBeenCalledWith("pnpm", ["add", "vue"]);
|
|
90
|
+
expect(mockExeca).toHaveBeenCalledWith("pnpm", ["add", "-D", "typescript"]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("should use bun add instead of install", async () => {
|
|
94
|
+
const { execa } = await import("execa");
|
|
95
|
+
const mockExeca = vi.mocked(execa);
|
|
96
|
+
mockExeca.mockResolvedValue({} as any);
|
|
97
|
+
|
|
98
|
+
await installPackages("bun", ["vue"], ["typescript"]);
|
|
99
|
+
|
|
100
|
+
expect(mockExeca).toHaveBeenCalledWith("bun", ["add", "vue"]);
|
|
101
|
+
expect(mockExeca).toHaveBeenCalledWith("bun", ["add", "-D", "typescript"]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("should use deno add with npm: prefix", async () => {
|
|
105
|
+
const { execa } = await import("execa");
|
|
106
|
+
const mockExeca = vi.mocked(execa);
|
|
107
|
+
mockExeca.mockResolvedValue({} as any);
|
|
108
|
+
|
|
109
|
+
await installPackages("deno", ["vue"], ["typescript"]);
|
|
110
|
+
|
|
111
|
+
expect(mockExeca).toHaveBeenCalledWith("deno", ["add", "npm:vue"]);
|
|
112
|
+
expect(mockExeca).toHaveBeenCalledWith("deno", ["add", "--dev", "npm:typescript"]);
|
|
113
|
+
expect(mockExeca).toHaveBeenCalledWith("deno", ["run", "-A", "npm:nuxt", "prepare"]);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("should not double-prefix packages already starting with npm:", async () => {
|
|
117
|
+
const { execa } = await import("execa");
|
|
118
|
+
const mockExeca = vi.mocked(execa);
|
|
119
|
+
mockExeca.mockResolvedValue({} as any);
|
|
120
|
+
|
|
121
|
+
await installPackages("deno", ["npm:vue"]);
|
|
122
|
+
|
|
123
|
+
expect(mockExeca).toHaveBeenCalledWith("deno", ["add", "npm:vue"]);
|
|
91
124
|
});
|
|
92
125
|
|
|
93
126
|
it("should run nuxt prepare after installation", async () => {
|
package/tsup.config.ts
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|