claudekit-cli 1.4.1 → 1.5.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.
Files changed (47) hide show
  1. package/bin/ck-darwin-arm64 +0 -0
  2. package/bin/ck-darwin-x64 +0 -0
  3. package/bin/ck-linux-x64 +0 -0
  4. package/bin/ck-win32-x64.exe +0 -0
  5. package/package.json +8 -2
  6. package/scripts/postinstall.js +74 -0
  7. package/.github/workflows/ci.yml +0 -45
  8. package/.github/workflows/claude-code-review.yml +0 -57
  9. package/.github/workflows/claude.yml +0 -50
  10. package/.github/workflows/release.yml +0 -102
  11. package/.releaserc.json +0 -17
  12. package/.repomixignore +0 -15
  13. package/AGENTS.md +0 -217
  14. package/CHANGELOG.md +0 -95
  15. package/CLAUDE.md +0 -34
  16. package/biome.json +0 -28
  17. package/bun.lock +0 -863
  18. package/dist/index.js +0 -22511
  19. package/src/commands/new.ts +0 -185
  20. package/src/commands/update.ts +0 -174
  21. package/src/commands/version.ts +0 -135
  22. package/src/index.ts +0 -102
  23. package/src/lib/auth.ts +0 -157
  24. package/src/lib/download.ts +0 -689
  25. package/src/lib/github.ts +0 -230
  26. package/src/lib/merge.ts +0 -119
  27. package/src/lib/prompts.ts +0 -114
  28. package/src/types.ts +0 -178
  29. package/src/utils/config.ts +0 -87
  30. package/src/utils/file-scanner.ts +0 -134
  31. package/src/utils/logger.ts +0 -124
  32. package/src/utils/safe-prompts.ts +0 -44
  33. package/src/utils/safe-spinner.ts +0 -38
  34. package/src/version.json +0 -3
  35. package/tests/commands/version.test.ts +0 -297
  36. package/tests/integration/cli.test.ts +0 -252
  37. package/tests/lib/auth.test.ts +0 -116
  38. package/tests/lib/download.test.ts +0 -292
  39. package/tests/lib/github-download-priority.test.ts +0 -432
  40. package/tests/lib/github.test.ts +0 -52
  41. package/tests/lib/merge.test.ts +0 -267
  42. package/tests/lib/prompts.test.ts +0 -66
  43. package/tests/types.test.ts +0 -337
  44. package/tests/utils/config.test.ts +0 -263
  45. package/tests/utils/file-scanner.test.ts +0 -202
  46. package/tests/utils/logger.test.ts +0 -239
  47. package/tsconfig.json +0 -30
@@ -1,292 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2
- import { existsSync } from "node:fs";
3
- import { mkdir, rm, writeFile } from "node:fs/promises";
4
- import { join } from "node:path";
5
- import { DownloadManager } from "../../src/lib/download.js";
6
- import { DownloadError, ExtractionError } from "../../src/types.js";
7
-
8
- describe("DownloadManager", () => {
9
- let manager: DownloadManager;
10
- let testDir: string;
11
-
12
- beforeEach(async () => {
13
- manager = new DownloadManager();
14
- testDir = join(process.cwd(), "test-temp", `test-${Date.now()}`);
15
- await mkdir(testDir, { recursive: true });
16
- });
17
-
18
- afterEach(async () => {
19
- if (existsSync(testDir)) {
20
- await rm(testDir, { recursive: true, force: true });
21
- }
22
- });
23
-
24
- describe("constructor", () => {
25
- test("should create DownloadManager instance", () => {
26
- expect(manager).toBeInstanceOf(DownloadManager);
27
- });
28
- });
29
-
30
- describe("createTempDir", () => {
31
- test("should create temporary directory", async () => {
32
- const tempDir = await manager.createTempDir();
33
-
34
- expect(tempDir).toBeDefined();
35
- expect(typeof tempDir).toBe("string");
36
- expect(tempDir).toContain("claudekit-");
37
- expect(existsSync(tempDir)).toBe(true);
38
-
39
- // Cleanup
40
- await rm(tempDir, { recursive: true, force: true });
41
- });
42
-
43
- test("should create unique directories", async () => {
44
- const tempDir1 = await manager.createTempDir();
45
-
46
- // Wait 1ms to ensure different timestamps
47
- await new Promise((resolve) => setTimeout(resolve, 1));
48
-
49
- const tempDir2 = await manager.createTempDir();
50
-
51
- expect(tempDir1).not.toBe(tempDir2);
52
-
53
- // Cleanup
54
- await rm(tempDir1, { recursive: true, force: true });
55
- await rm(tempDir2, { recursive: true, force: true });
56
- });
57
- });
58
-
59
- describe("validateExtraction", () => {
60
- test("should throw error for empty directory", async () => {
61
- const emptyDir = join(testDir, "empty");
62
- await mkdir(emptyDir, { recursive: true });
63
-
64
- await expect(manager.validateExtraction(emptyDir)).rejects.toThrow(ExtractionError);
65
- await expect(manager.validateExtraction(emptyDir)).rejects.toThrow(
66
- "Extraction resulted in no files",
67
- );
68
- });
69
-
70
- test("should pass validation for directory with .claude and CLAUDE.md", async () => {
71
- const validDir = join(testDir, "valid");
72
- await mkdir(join(validDir, ".claude"), { recursive: true });
73
- await writeFile(join(validDir, ".claude", "config.json"), "{}");
74
- await writeFile(join(validDir, "CLAUDE.md"), "# Test");
75
-
76
- // Should not throw
77
- await manager.validateExtraction(validDir);
78
- });
79
-
80
- test("should warn but not fail for directory with files but missing critical paths", async () => {
81
- const partialDir = join(testDir, "partial");
82
- await mkdir(partialDir, { recursive: true });
83
- await writeFile(join(partialDir, "README.md"), "# Test");
84
-
85
- // Should not throw but will log warnings
86
- await manager.validateExtraction(partialDir);
87
- });
88
-
89
- test("should throw error for non-existent directory", async () => {
90
- const nonExistentDir = join(testDir, "does-not-exist");
91
-
92
- await expect(manager.validateExtraction(nonExistentDir)).rejects.toThrow();
93
- });
94
- });
95
-
96
- describe("wrapper directory detection", () => {
97
- test("should detect version wrapper with v prefix", () => {
98
- // Access private method via any type casting for testing
99
- const isWrapper = (manager as any).isWrapperDirectory("project-v1.0.0");
100
- expect(isWrapper).toBe(true);
101
- });
102
-
103
- test("should detect version wrapper without v prefix", () => {
104
- const isWrapper = (manager as any).isWrapperDirectory("project-1.0.0");
105
- expect(isWrapper).toBe(true);
106
- });
107
-
108
- test("should detect commit hash wrapper", () => {
109
- const isWrapper = (manager as any).isWrapperDirectory("project-abc1234");
110
- expect(isWrapper).toBe(true);
111
- });
112
-
113
- test("should detect prerelease version wrapper", () => {
114
- const isWrapper = (manager as any).isWrapperDirectory("project-v1.0.0-alpha");
115
- expect(isWrapper).toBe(true);
116
- });
117
-
118
- test("should detect beta version wrapper", () => {
119
- const isWrapper = (manager as any).isWrapperDirectory("project-v2.0.0-beta.1");
120
- expect(isWrapper).toBe(true);
121
- });
122
-
123
- test("should detect rc version wrapper", () => {
124
- const isWrapper = (manager as any).isWrapperDirectory("repo-v3.0.0-rc.5");
125
- expect(isWrapper).toBe(true);
126
- });
127
-
128
- test("should not detect .claude as wrapper", () => {
129
- const isWrapper = (manager as any).isWrapperDirectory(".claude");
130
- expect(isWrapper).toBe(false);
131
- });
132
-
133
- test("should not detect src as wrapper", () => {
134
- const isWrapper = (manager as any).isWrapperDirectory("src");
135
- expect(isWrapper).toBe(false);
136
- });
137
-
138
- test("should not detect docs as wrapper", () => {
139
- const isWrapper = (manager as any).isWrapperDirectory("docs");
140
- expect(isWrapper).toBe(false);
141
- });
142
-
143
- test("should not detect node_modules as wrapper", () => {
144
- const isWrapper = (manager as any).isWrapperDirectory("node_modules");
145
- expect(isWrapper).toBe(false);
146
- });
147
- });
148
-
149
- describe("path safety validation", () => {
150
- test("should allow safe relative paths", () => {
151
- const basePath = join(testDir, "base");
152
- const targetPath = join(testDir, "base", "subdir", "file.txt");
153
- const isSafe = (manager as any).isPathSafe(basePath, targetPath);
154
- expect(isSafe).toBe(true);
155
- });
156
-
157
- test("should block path traversal attempts with ..", () => {
158
- const basePath = join(testDir, "base");
159
- const targetPath = join(testDir, "outside", "file.txt");
160
- const isSafe = (manager as any).isPathSafe(basePath, targetPath);
161
- expect(isSafe).toBe(false);
162
- });
163
-
164
- test("should block absolute path attempts", () => {
165
- const basePath = join(testDir, "base");
166
- const targetPath = "/etc/passwd";
167
- const isSafe = (manager as any).isPathSafe(basePath, targetPath);
168
- expect(isSafe).toBe(false);
169
- });
170
-
171
- test("should allow same directory", () => {
172
- const basePath = join(testDir, "base");
173
- const targetPath = join(testDir, "base");
174
- const isSafe = (manager as any).isPathSafe(basePath, targetPath);
175
- expect(isSafe).toBe(true);
176
- });
177
- });
178
-
179
- describe("archive bomb protection", () => {
180
- test("should track extraction size", () => {
181
- const manager = new DownloadManager();
182
-
183
- // Add some file sizes
184
- (manager as any).checkExtractionSize(100 * 1024 * 1024); // 100MB
185
- expect((manager as any).totalExtractedSize).toBe(100 * 1024 * 1024);
186
-
187
- (manager as any).checkExtractionSize(200 * 1024 * 1024); // 200MB more
188
- expect((manager as any).totalExtractedSize).toBe(300 * 1024 * 1024);
189
- });
190
-
191
- test("should throw error when size exceeds limit", () => {
192
- const manager = new DownloadManager();
193
-
194
- expect(() => {
195
- (manager as any).checkExtractionSize(600 * 1024 * 1024); // 600MB
196
- }).toThrow(ExtractionError);
197
-
198
- expect(() => {
199
- (manager as any).checkExtractionSize(600 * 1024 * 1024); // 600MB
200
- }).toThrow("Archive exceeds maximum extraction size");
201
- });
202
-
203
- test("should allow extraction within limit", () => {
204
- const manager = new DownloadManager();
205
-
206
- expect(() => {
207
- (manager as any).checkExtractionSize(400 * 1024 * 1024); // 400MB
208
- }).not.toThrow();
209
- });
210
-
211
- test("should reset extraction size", () => {
212
- const manager = new DownloadManager();
213
-
214
- (manager as any).checkExtractionSize(300 * 1024 * 1024); // 300MB
215
- expect((manager as any).totalExtractedSize).toBe(300 * 1024 * 1024);
216
-
217
- (manager as any).resetExtractionSize();
218
- expect((manager as any).totalExtractedSize).toBe(0);
219
- });
220
- });
221
-
222
- describe("file exclusion", () => {
223
- test("should exclude .git directory", () => {
224
- const shouldExclude = (manager as any).shouldExclude(".git");
225
- expect(shouldExclude).toBe(true);
226
- });
227
-
228
- test("should exclude .git/** files", () => {
229
- const shouldExclude = (manager as any).shouldExclude(".git/config");
230
- expect(shouldExclude).toBe(true);
231
- });
232
-
233
- test("should exclude node_modules", () => {
234
- const shouldExclude = (manager as any).shouldExclude("node_modules");
235
- expect(shouldExclude).toBe(true);
236
- });
237
-
238
- test("should exclude .DS_Store", () => {
239
- const shouldExclude = (manager as any).shouldExclude(".DS_Store");
240
- expect(shouldExclude).toBe(true);
241
- });
242
-
243
- test("should not exclude normal files", () => {
244
- const shouldExclude = (manager as any).shouldExclude("src/index.ts");
245
- expect(shouldExclude).toBe(false);
246
- });
247
-
248
- test("should not exclude .claude directory", () => {
249
- const shouldExclude = (manager as any).shouldExclude(".claude");
250
- expect(shouldExclude).toBe(false);
251
- });
252
- });
253
-
254
- describe("archive type detection", () => {
255
- test("should detect .tar.gz archive", () => {
256
- const type = (manager as any).detectArchiveType("project-v1.0.0.tar.gz");
257
- expect(type).toBe("tar.gz");
258
- });
259
-
260
- test("should detect .tgz archive", () => {
261
- const type = (manager as any).detectArchiveType("project-v1.0.0.tgz");
262
- expect(type).toBe("tar.gz");
263
- });
264
-
265
- test("should detect .zip archive", () => {
266
- const type = (manager as any).detectArchiveType("project-v1.0.0.zip");
267
- expect(type).toBe("zip");
268
- });
269
-
270
- test("should throw error for unknown archive type", () => {
271
- expect(() => {
272
- (manager as any).detectArchiveType("project-v1.0.0.rar");
273
- }).toThrow(ExtractionError);
274
- });
275
- });
276
-
277
- describe("error classes", () => {
278
- test("DownloadError should store message", () => {
279
- const error = new DownloadError("Download failed");
280
- expect(error.message).toBe("Download failed");
281
- expect(error.code).toBe("DOWNLOAD_ERROR");
282
- expect(error.name).toBe("DownloadError");
283
- });
284
-
285
- test("ExtractionError should store message", () => {
286
- const error = new ExtractionError("Extraction failed");
287
- expect(error.message).toBe("Extraction failed");
288
- expect(error.code).toBe("EXTRACTION_ERROR");
289
- expect(error.name).toBe("ExtractionError");
290
- });
291
- });
292
- });