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.
@@ -69,16 +69,22 @@ describe("utils/fetchComponents", () => {
69
69
  delete process.env.COMPONENTS_API;
70
70
  });
71
71
 
72
- it("should handle API errors gracefully", async () => {
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 expect(fetchComponents()).rejects.toThrow();
76
+ await fetchComponents();
77
+
78
+ expect(exitSpy).toHaveBeenCalledWith(1);
76
79
  });
77
80
 
78
- it("should handle network errors", async () => {
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 expect(fetchComponents()).rejects.toThrow();
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 handle API errors", async () => {
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 expect(fetchProseComponents()).rejects.toThrow();
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 work with pnpm", async () => {
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", ["install", "vue"]);
90
- expect(mockExeca).toHaveBeenCalledWith("pnpm", ["install", "-D", "typescript"]);
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
@@ -3,7 +3,11 @@ import { defineConfig } from "tsup";
3
3
  export default defineConfig({
4
4
  sourcemap: true,
5
5
  entry: ["src/index.ts"],
6
- dts: true,
6
+ dts: {
7
+ compilerOptions: {
8
+ ignoreDeprecations: "6.0",
9
+ },
10
+ },
7
11
  clean: true,
8
12
  format: ["esm"],
9
13
  minify: true,
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node