pushwork 2.0.0-a.sub.0 → 2.0.0-preview

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 (251) hide show
  1. package/dist/branches.d.ts +19 -0
  2. package/dist/branches.d.ts.map +1 -0
  3. package/dist/branches.js +111 -0
  4. package/dist/branches.js.map +1 -0
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +238 -272
  8. package/dist/cli.js.map +1 -1
  9. package/dist/config.d.ts +17 -0
  10. package/dist/config.d.ts.map +1 -0
  11. package/dist/config.js +84 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/fs-tree.d.ts +6 -0
  14. package/dist/fs-tree.d.ts.map +1 -0
  15. package/dist/fs-tree.js +99 -0
  16. package/dist/fs-tree.js.map +1 -0
  17. package/dist/ignore.d.ts +6 -0
  18. package/dist/ignore.d.ts.map +1 -0
  19. package/dist/ignore.js +74 -0
  20. package/dist/ignore.js.map +1 -0
  21. package/dist/index.d.ts +8 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +34 -4
  24. package/dist/index.js.map +1 -1
  25. package/dist/log.d.ts +3 -0
  26. package/dist/log.d.ts.map +1 -0
  27. package/dist/log.js +14 -0
  28. package/dist/log.js.map +1 -0
  29. package/dist/pushwork.d.ts +115 -0
  30. package/dist/pushwork.d.ts.map +1 -0
  31. package/dist/pushwork.js +918 -0
  32. package/dist/pushwork.js.map +1 -0
  33. package/dist/repo.d.ts +14 -0
  34. package/dist/repo.d.ts.map +1 -0
  35. package/dist/repo.js +60 -0
  36. package/dist/repo.js.map +1 -0
  37. package/dist/shapes/custom.d.ts +3 -0
  38. package/dist/shapes/custom.d.ts.map +1 -0
  39. package/dist/shapes/custom.js +57 -0
  40. package/dist/shapes/custom.js.map +1 -0
  41. package/dist/shapes/file.d.ts +20 -0
  42. package/dist/shapes/file.d.ts.map +1 -0
  43. package/dist/shapes/file.js +140 -0
  44. package/dist/shapes/file.js.map +1 -0
  45. package/dist/shapes/index.d.ts +10 -0
  46. package/dist/shapes/index.d.ts.map +1 -0
  47. package/dist/shapes/index.js +35 -0
  48. package/dist/shapes/index.js.map +1 -0
  49. package/dist/shapes/patchwork-folder.d.ts +3 -0
  50. package/dist/shapes/patchwork-folder.d.ts.map +1 -0
  51. package/dist/shapes/patchwork-folder.js +160 -0
  52. package/dist/shapes/patchwork-folder.js.map +1 -0
  53. package/dist/shapes/types.d.ts +37 -0
  54. package/dist/shapes/types.d.ts.map +1 -0
  55. package/dist/shapes/types.js +52 -0
  56. package/dist/shapes/types.js.map +1 -0
  57. package/dist/shapes/vfs.d.ts +3 -0
  58. package/dist/shapes/vfs.d.ts.map +1 -0
  59. package/dist/shapes/vfs.js +88 -0
  60. package/dist/shapes/vfs.js.map +1 -0
  61. package/dist/stash.d.ts +23 -0
  62. package/dist/stash.d.ts.map +1 -0
  63. package/dist/stash.js +118 -0
  64. package/dist/stash.js.map +1 -0
  65. package/flake.lock +128 -0
  66. package/flake.nix +66 -0
  67. package/package.json +15 -48
  68. package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +26 -0
  69. package/pnpm-workspace.yaml +5 -0
  70. package/src/branches.ts +93 -0
  71. package/src/cli.ts +258 -408
  72. package/src/config.ts +64 -0
  73. package/src/fs-tree.ts +70 -0
  74. package/src/ignore.ts +33 -0
  75. package/src/index.ts +38 -4
  76. package/src/log.ts +8 -0
  77. package/src/pushwork.ts +1055 -0
  78. package/src/repo.ts +76 -0
  79. package/src/shapes/custom.ts +29 -0
  80. package/src/shapes/file.ts +115 -0
  81. package/src/shapes/index.ts +19 -0
  82. package/src/shapes/patchwork-folder.ts +156 -0
  83. package/src/shapes/types.ts +79 -0
  84. package/src/shapes/vfs.ts +93 -0
  85. package/src/stash.ts +106 -0
  86. package/test/integration/branches.test.ts +389 -0
  87. package/test/integration/pushwork.test.ts +547 -0
  88. package/test/setup.ts +29 -0
  89. package/test/unit/doc-shape.test.ts +612 -0
  90. package/tsconfig.json +2 -3
  91. package/vitest.config.ts +14 -0
  92. package/ARCHITECTURE-ACCORDING-TO-CLAUDE.md +0 -248
  93. package/CLAUDE.md +0 -141
  94. package/README.md +0 -221
  95. package/babel.config.js +0 -5
  96. package/dist/cli/commands.d.ts +0 -71
  97. package/dist/cli/commands.d.ts.map +0 -1
  98. package/dist/cli/commands.js +0 -794
  99. package/dist/cli/commands.js.map +0 -1
  100. package/dist/cli/index.d.ts +0 -2
  101. package/dist/cli/index.d.ts.map +0 -1
  102. package/dist/cli/index.js +0 -19
  103. package/dist/cli/index.js.map +0 -1
  104. package/dist/commands.d.ts +0 -61
  105. package/dist/commands.d.ts.map +0 -1
  106. package/dist/commands.js +0 -861
  107. package/dist/commands.js.map +0 -1
  108. package/dist/config/index.d.ts +0 -71
  109. package/dist/config/index.d.ts.map +0 -1
  110. package/dist/config/index.js +0 -314
  111. package/dist/config/index.js.map +0 -1
  112. package/dist/core/change-detection.d.ts +0 -80
  113. package/dist/core/change-detection.d.ts.map +0 -1
  114. package/dist/core/change-detection.js +0 -523
  115. package/dist/core/change-detection.js.map +0 -1
  116. package/dist/core/config.d.ts +0 -81
  117. package/dist/core/config.d.ts.map +0 -1
  118. package/dist/core/config.js +0 -258
  119. package/dist/core/config.js.map +0 -1
  120. package/dist/core/index.d.ts +0 -6
  121. package/dist/core/index.d.ts.map +0 -1
  122. package/dist/core/index.js +0 -6
  123. package/dist/core/index.js.map +0 -1
  124. package/dist/core/move-detection.d.ts +0 -34
  125. package/dist/core/move-detection.d.ts.map +0 -1
  126. package/dist/core/move-detection.js +0 -121
  127. package/dist/core/move-detection.js.map +0 -1
  128. package/dist/core/snapshot.d.ts +0 -105
  129. package/dist/core/snapshot.d.ts.map +0 -1
  130. package/dist/core/snapshot.js +0 -217
  131. package/dist/core/snapshot.js.map +0 -1
  132. package/dist/core/sync-engine.d.ts +0 -151
  133. package/dist/core/sync-engine.d.ts.map +0 -1
  134. package/dist/core/sync-engine.js +0 -1346
  135. package/dist/core/sync-engine.js.map +0 -1
  136. package/dist/types/config.d.ts +0 -99
  137. package/dist/types/config.d.ts.map +0 -1
  138. package/dist/types/config.js +0 -5
  139. package/dist/types/config.js.map +0 -1
  140. package/dist/types/documents.d.ts +0 -88
  141. package/dist/types/documents.d.ts.map +0 -1
  142. package/dist/types/documents.js +0 -20
  143. package/dist/types/documents.js.map +0 -1
  144. package/dist/types/index.d.ts +0 -4
  145. package/dist/types/index.d.ts.map +0 -1
  146. package/dist/types/index.js +0 -4
  147. package/dist/types/index.js.map +0 -1
  148. package/dist/types/snapshot.d.ts +0 -64
  149. package/dist/types/snapshot.d.ts.map +0 -1
  150. package/dist/types/snapshot.js +0 -2
  151. package/dist/types/snapshot.js.map +0 -1
  152. package/dist/utils/content-similarity.d.ts +0 -53
  153. package/dist/utils/content-similarity.d.ts.map +0 -1
  154. package/dist/utils/content-similarity.js +0 -155
  155. package/dist/utils/content-similarity.js.map +0 -1
  156. package/dist/utils/content.d.ts +0 -10
  157. package/dist/utils/content.d.ts.map +0 -1
  158. package/dist/utils/content.js +0 -31
  159. package/dist/utils/content.js.map +0 -1
  160. package/dist/utils/directory.d.ts +0 -24
  161. package/dist/utils/directory.d.ts.map +0 -1
  162. package/dist/utils/directory.js +0 -52
  163. package/dist/utils/directory.js.map +0 -1
  164. package/dist/utils/fs.d.ts +0 -74
  165. package/dist/utils/fs.d.ts.map +0 -1
  166. package/dist/utils/fs.js +0 -248
  167. package/dist/utils/fs.js.map +0 -1
  168. package/dist/utils/index.d.ts +0 -5
  169. package/dist/utils/index.d.ts.map +0 -1
  170. package/dist/utils/index.js +0 -5
  171. package/dist/utils/index.js.map +0 -1
  172. package/dist/utils/mime-types.d.ts +0 -13
  173. package/dist/utils/mime-types.d.ts.map +0 -1
  174. package/dist/utils/mime-types.js +0 -209
  175. package/dist/utils/mime-types.js.map +0 -1
  176. package/dist/utils/network-sync.d.ts +0 -36
  177. package/dist/utils/network-sync.d.ts.map +0 -1
  178. package/dist/utils/network-sync.js +0 -250
  179. package/dist/utils/network-sync.js.map +0 -1
  180. package/dist/utils/node-polyfills.d.ts +0 -9
  181. package/dist/utils/node-polyfills.d.ts.map +0 -1
  182. package/dist/utils/node-polyfills.js +0 -9
  183. package/dist/utils/node-polyfills.js.map +0 -1
  184. package/dist/utils/output.d.ts +0 -129
  185. package/dist/utils/output.d.ts.map +0 -1
  186. package/dist/utils/output.js +0 -368
  187. package/dist/utils/output.js.map +0 -1
  188. package/dist/utils/repo-factory.d.ts +0 -13
  189. package/dist/utils/repo-factory.d.ts.map +0 -1
  190. package/dist/utils/repo-factory.js +0 -46
  191. package/dist/utils/repo-factory.js.map +0 -1
  192. package/dist/utils/string-similarity.d.ts +0 -14
  193. package/dist/utils/string-similarity.d.ts.map +0 -1
  194. package/dist/utils/string-similarity.js +0 -39
  195. package/dist/utils/string-similarity.js.map +0 -1
  196. package/dist/utils/text-diff.d.ts +0 -37
  197. package/dist/utils/text-diff.d.ts.map +0 -1
  198. package/dist/utils/text-diff.js +0 -93
  199. package/dist/utils/text-diff.js.map +0 -1
  200. package/dist/utils/trace.d.ts +0 -19
  201. package/dist/utils/trace.d.ts.map +0 -1
  202. package/dist/utils/trace.js +0 -63
  203. package/dist/utils/trace.js.map +0 -1
  204. package/src/commands.ts +0 -1134
  205. package/src/core/change-detection.ts +0 -712
  206. package/src/core/config.ts +0 -313
  207. package/src/core/index.ts +0 -5
  208. package/src/core/move-detection.ts +0 -169
  209. package/src/core/snapshot.ts +0 -275
  210. package/src/core/sync-engine.ts +0 -1758
  211. package/src/types/config.ts +0 -111
  212. package/src/types/documents.ts +0 -91
  213. package/src/types/index.ts +0 -3
  214. package/src/types/snapshot.ts +0 -67
  215. package/src/utils/content.ts +0 -34
  216. package/src/utils/directory.ts +0 -73
  217. package/src/utils/fs.ts +0 -297
  218. package/src/utils/index.ts +0 -4
  219. package/src/utils/mime-types.ts +0 -244
  220. package/src/utils/network-sync.ts +0 -319
  221. package/src/utils/node-polyfills.ts +0 -8
  222. package/src/utils/output.ts +0 -450
  223. package/src/utils/repo-factory.ts +0 -73
  224. package/src/utils/string-similarity.ts +0 -54
  225. package/src/utils/text-diff.ts +0 -101
  226. package/src/utils/trace.ts +0 -70
  227. package/test/integration/README.md +0 -328
  228. package/test/integration/clone-test.sh +0 -310
  229. package/test/integration/conflict-resolution-test.sh +0 -309
  230. package/test/integration/debug-both-nested.sh +0 -74
  231. package/test/integration/debug-concurrent-nested.sh +0 -87
  232. package/test/integration/debug-nested.sh +0 -73
  233. package/test/integration/deletion-behavior-test.sh +0 -487
  234. package/test/integration/deletion-sync-test-simple.sh +0 -193
  235. package/test/integration/deletion-sync-test.sh +0 -297
  236. package/test/integration/exclude-patterns.test.ts +0 -144
  237. package/test/integration/full-integration-test.sh +0 -363
  238. package/test/integration/fuzzer.test.ts +0 -818
  239. package/test/integration/in-memory-sync.test.ts +0 -830
  240. package/test/integration/init-sync.test.ts +0 -89
  241. package/test/integration/manual-sync-test.sh +0 -84
  242. package/test/integration/sync-deletion.test.ts +0 -280
  243. package/test/integration/sync-flow.test.ts +0 -291
  244. package/test/jest.setup.ts +0 -34
  245. package/test/run-tests.sh +0 -225
  246. package/test/unit/deletion-behavior.test.ts +0 -249
  247. package/test/unit/enhanced-mime-detection.test.ts +0 -244
  248. package/test/unit/snapshot.test.ts +0 -404
  249. package/test/unit/sync-convergence.test.ts +0 -298
  250. package/test/unit/sync-timing.test.ts +0 -134
  251. package/test/unit/utils.test.ts +0 -366
@@ -1,291 +0,0 @@
1
- import * as fs from "fs/promises";
2
- import * as path from "path";
3
- import * as tmp from "tmp";
4
- import { ConfigManager } from "../../src/core";
5
- import { DirectoryConfig } from "../../src/types";
6
-
7
- describe("Sync Flow Integration", () => {
8
- let tmpDir: string;
9
- let cleanup: () => void;
10
-
11
- beforeEach(() => {
12
- const tmpObj = tmp.dirSync({ unsafeCleanup: true });
13
- tmpDir = tmpObj.name;
14
- cleanup = tmpObj.removeCallback;
15
- });
16
-
17
- afterEach(() => {
18
- cleanup();
19
- });
20
-
21
- describe("Configuration Management", () => {
22
- it("should create and load configuration", async () => {
23
- const configManager = new ConfigManager(tmpDir);
24
-
25
- // Create test config
26
- const testConfig: DirectoryConfig = {
27
- sync_server: "wss://test.server.com",
28
- sync_enabled: true,
29
- exclude_patterns: [".git", "*.tmp"],
30
- artifact_directories: ["dist"],
31
- sync: {
32
- move_detection_threshold: 0.8,
33
- },
34
- };
35
-
36
- await configManager.save(testConfig);
37
-
38
- const loadedConfig = await configManager.load();
39
- expect(loadedConfig).toEqual(testConfig);
40
- });
41
-
42
- it("should merge global and local configurations", async () => {
43
- const configManager = new ConfigManager(tmpDir);
44
-
45
- // Create default global config
46
- await configManager.createDefaultGlobal();
47
-
48
- // Test directory config
49
- const localConfig: DirectoryConfig = {
50
- sync_server: "wss://local.server.com",
51
- sync_enabled: true,
52
- exclude_patterns: [".git", "*.tmp"],
53
- artifact_directories: ["dist"],
54
- sync: {
55
- move_detection_threshold: 0.9,
56
- },
57
- };
58
-
59
- await configManager.save(localConfig);
60
-
61
- // Verify merged config
62
- const mergedConfig = await configManager.getMerged();
63
- expect(mergedConfig.sync_server).toBe("wss://local.server.com");
64
- expect(mergedConfig.exclude_patterns).toContain(".git");
65
- expect(mergedConfig.sync?.move_detection_threshold).toBe(0.9);
66
- });
67
- });
68
-
69
- describe("File System Operations", () => {
70
- it("should handle file creation and modification", async () => {
71
- // Create initial file structure
72
- await fs.mkdir(path.join(tmpDir, "subdir"));
73
- await fs.writeFile(path.join(tmpDir, "file1.txt"), "Initial content");
74
- await fs.writeFile(
75
- path.join(tmpDir, "subdir", "file2.txt"),
76
- "Nested content"
77
- );
78
-
79
- // Modify files
80
- await fs.writeFile(path.join(tmpDir, "file1.txt"), "Modified content");
81
- await fs.writeFile(path.join(tmpDir, "new-file.txt"), "New file content");
82
-
83
- // Delete file
84
- await fs.unlink(path.join(tmpDir, "subdir", "file2.txt"));
85
-
86
- // Verify final state
87
- const file1Content = await fs.readFile(
88
- path.join(tmpDir, "file1.txt"),
89
- "utf8"
90
- );
91
- expect(file1Content).toBe("Modified content");
92
-
93
- const newFileContent = await fs.readFile(
94
- path.join(tmpDir, "new-file.txt"),
95
- "utf8"
96
- );
97
- expect(newFileContent).toBe("New file content");
98
-
99
- try {
100
- await fs.access(path.join(tmpDir, "subdir", "file2.txt"));
101
- throw new Error("Deleted file should not exist");
102
- } catch (error: any) {
103
- // Expected - file should not exist
104
- expect(error.code).toBe("ENOENT");
105
- }
106
- });
107
-
108
- it("should handle binary files", async () => {
109
- const binaryData = new Uint8Array([
110
- 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
111
- ]); // PNG header
112
-
113
- await fs.writeFile(path.join(tmpDir, "image.png"), binaryData);
114
-
115
- const readData = await fs.readFile(path.join(tmpDir, "image.png"));
116
- expect(Array.from(readData)).toEqual(Array.from(binaryData));
117
- });
118
- });
119
-
120
- describe("Directory Structure Scenarios", () => {
121
- it("should handle complex directory structures", async () => {
122
- const structure = {
123
- src: {
124
- components: {
125
- "Button.tsx": "export const Button = () => <button />",
126
- "Input.tsx": "export const Input = () => <input />",
127
- },
128
- utils: {
129
- "helpers.ts": "export const helper = () => {}",
130
- "constants.ts": 'export const API_URL = "http://localhost"',
131
- },
132
- "index.ts": 'export * from "./components"',
133
- },
134
- "package.json": '{"name": "test-project", "version": "1.0.0"}',
135
- "README.md": "# Test Project\n\nThis is a test project.",
136
- };
137
-
138
- await createDirectoryStructure(tmpDir, structure);
139
-
140
- // Verify structure was created
141
- const srcExists = await pathExists(path.join(tmpDir, "src"));
142
- expect(srcExists).toBe(true);
143
-
144
- const buttonExists = await pathExists(
145
- path.join(tmpDir, "src", "components", "Button.tsx")
146
- );
147
- expect(buttonExists).toBe(true);
148
-
149
- const packageContent = await fs.readFile(
150
- path.join(tmpDir, "package.json"),
151
- "utf8"
152
- );
153
- expect(JSON.parse(packageContent).name).toBe("test-project");
154
- });
155
-
156
- it("should handle file moves and renames", async () => {
157
- // Create initial files
158
- await fs.writeFile(path.join(tmpDir, "old-name.txt"), "File content");
159
- await fs.mkdir(path.join(tmpDir, "new-dir"));
160
-
161
- // Simulate move operation
162
- await fs.rename(
163
- path.join(tmpDir, "old-name.txt"),
164
- path.join(tmpDir, "new-dir", "new-name.txt")
165
- );
166
-
167
- // Verify move
168
- const movedFileExists = await pathExists(
169
- path.join(tmpDir, "new-dir", "new-name.txt")
170
- );
171
- expect(movedFileExists).toBe(true);
172
-
173
- const oldFileExists = await pathExists(path.join(tmpDir, "old-name.txt"));
174
- expect(oldFileExists).toBe(false);
175
-
176
- const content = await fs.readFile(
177
- path.join(tmpDir, "new-dir", "new-name.txt"),
178
- "utf8"
179
- );
180
- expect(content).toBe("File content");
181
- });
182
- });
183
-
184
- describe("Error Handling", () => {
185
- it("should handle permission errors gracefully", async () => {
186
- // Create a file
187
- const filePath = path.join(tmpDir, "restricted.txt");
188
- await fs.writeFile(filePath, "content");
189
-
190
- // Make it read-only (if supported by filesystem)
191
- try {
192
- await fs.chmod(filePath, 0o444);
193
-
194
- // Try to write - should handle error gracefully
195
- try {
196
- await fs.writeFile(filePath, "new content");
197
- // If this succeeds, the filesystem doesn't enforce permissions
198
- } catch (error) {
199
- expect(error).toBeDefined();
200
- // This is expected behavior
201
- }
202
- } catch {
203
- // chmod may not be supported on all filesystems
204
- console.log(
205
- "Permission test skipped - filesystem does not support chmod"
206
- );
207
- }
208
- });
209
-
210
- it("should handle corrupted snapshot files", async () => {
211
- const configManager = new ConfigManager(tmpDir);
212
-
213
- // Create .pushwork directory
214
- const syncToolDir = path.join(tmpDir, ".pushwork");
215
- await fs.mkdir(syncToolDir);
216
-
217
- // Write corrupted snapshot
218
- const snapshotPath = path.join(syncToolDir, "snapshot.json");
219
- await fs.writeFile(snapshotPath, '{"invalid": json}');
220
-
221
- // Should handle gracefully
222
- const config = await configManager.load();
223
- expect(config).toBeNull();
224
- });
225
- });
226
-
227
- describe("Performance Scenarios", () => {
228
- it("should handle many small files", async () => {
229
- const fileCount = 100;
230
- const promises: Promise<void>[] = [];
231
-
232
- for (let i = 0; i < fileCount; i++) {
233
- const filePath = path.join(tmpDir, `file-${i}.txt`);
234
- promises.push(fs.writeFile(filePath, `Content of file ${i}`));
235
- }
236
-
237
- await Promise.all(promises);
238
-
239
- // Verify all files were created
240
- const files = await fs.readdir(tmpDir);
241
- const textFiles = files.filter((f) => f.endsWith(".txt"));
242
- expect(textFiles.length).toBe(fileCount);
243
- });
244
-
245
- it("should handle large files efficiently", async () => {
246
- const largeContent = "x".repeat(1024 * 1024); // 1MB of data
247
- const filePath = path.join(tmpDir, "large-file.txt");
248
-
249
- const startTime = Date.now();
250
- await fs.writeFile(filePath, largeContent);
251
- const writeTime = Date.now() - startTime;
252
-
253
- const readStartTime = Date.now();
254
- const readContent = await fs.readFile(filePath, "utf8");
255
- const readTime = Date.now() - readStartTime;
256
-
257
- expect(readContent.length).toBe(largeContent.length);
258
- expect(writeTime).toBeLessThan(5000); // Should complete within 5 seconds
259
- expect(readTime).toBeLessThan(5000); // Should complete within 5 seconds
260
- }, 10000); // 10 second timeout
261
- });
262
- });
263
-
264
- // Helper functions
265
-
266
- async function pathExists(filePath: string): Promise<boolean> {
267
- try {
268
- await fs.access(filePath);
269
- return true;
270
- } catch {
271
- return false;
272
- }
273
- }
274
-
275
- async function createDirectoryStructure(
276
- basePath: string,
277
- structure: any
278
- ): Promise<void> {
279
- for (const [name, content] of Object.entries(structure)) {
280
- const fullPath = path.join(basePath, name);
281
-
282
- if (typeof content === "string") {
283
- // It's a file
284
- await fs.writeFile(fullPath, content);
285
- } else {
286
- // It's a directory
287
- await fs.mkdir(fullPath, { recursive: true });
288
- await createDirectoryStructure(fullPath, content);
289
- }
290
- }
291
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Jest setup file to mock ESM modules that don't work well with Jest
3
- */
4
-
5
- // Mock chalk (ESM-only module)
6
- jest.mock("chalk", () => ({
7
- __esModule: true,
8
- default: new Proxy(
9
- {},
10
- {
11
- get: (target, prop) => {
12
- if (prop === "default") return target;
13
- // Return a function that returns the input string unchanged
14
- return (str: string) => str;
15
- },
16
- }
17
- ),
18
- }));
19
-
20
- // Mock ora (ESM-only module)
21
- jest.mock("ora", () => ({
22
- __esModule: true,
23
- default: jest.fn(() => ({
24
- start: jest.fn().mockReturnThis(),
25
- stop: jest.fn().mockReturnThis(),
26
- succeed: jest.fn().mockReturnThis(),
27
- fail: jest.fn().mockReturnThis(),
28
- warn: jest.fn().mockReturnThis(),
29
- info: jest.fn().mockReturnThis(),
30
- clear: jest.fn().mockReturnThis(),
31
- text: "",
32
- })),
33
- }));
34
-
package/test/run-tests.sh DELETED
@@ -1,225 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Pushwork Test Runner
4
- # Provides options to run different test suites
5
-
6
- set -e
7
-
8
- # Colors for output
9
- RED='\033[0;31m'
10
- GREEN='\033[0;32m'
11
- YELLOW='\033[1;33m'
12
- BLUE='\033[0;34m'
13
- NC='\033[0m'
14
-
15
- # Helper functions
16
- log_info() {
17
- echo -e "${BLUE}[INFO]${NC} $1"
18
- }
19
-
20
- log_success() {
21
- echo -e "${GREEN}[SUCCESS]${NC} $1"
22
- }
23
-
24
- log_error() {
25
- echo -e "${RED}[ERROR]${NC} $1"
26
- }
27
-
28
- log_warning() {
29
- echo -e "${YELLOW}[WARNING]${NC} $1"
30
- }
31
-
32
- # Show usage
33
- show_usage() {
34
- echo "Pushwork Test Runner"
35
- echo ""
36
- echo "Usage: $0 [test-type]"
37
- echo ""
38
- echo "Test Types:"
39
- echo " full Run comprehensive integration tests (default)"
40
- echo " clone Run focused clone functionality tests"
41
- echo " conflict Run CRDT conflict resolution tests"
42
- echo " deletion Run deletion sync behavior tests"
43
- echo " deletion-behavior Run comprehensive deletion behavior tests"
44
- echo " unit Run unit tests"
45
- echo " help Show this help message"
46
- echo ""
47
- echo "Examples:"
48
- echo " $0 # Run full integration tests"
49
- echo " $0 full # Run full integration tests"
50
- echo " $0 clone # Run clone-specific tests"
51
- echo " $0 conflict # Run CRDT conflict resolution tests"
52
- echo " $0 unit # Run unit tests"
53
- echo ""
54
- }
55
-
56
- # Check dependencies
57
- check_dependencies() {
58
- log_info "Checking dependencies..."
59
-
60
- # Check if Node.js is available
61
- if ! command -v node &> /dev/null; then
62
- log_error "Node.js is not installed"
63
- echo "Please install Node.js from https://nodejs.org/"
64
- exit 1
65
- fi
66
-
67
- # Check if npm is available
68
- if ! command -v npm &> /dev/null; then
69
- log_error "npm is not installed"
70
- echo "Please install npm"
71
- exit 1
72
- fi
73
-
74
- # Check if jq is available (optional for some tests)
75
- if ! command -v jq &> /dev/null; then
76
- log_warning "jq is not installed - some configuration tests may be skipped"
77
- echo "To install jq (optional):"
78
- echo " macOS: brew install jq"
79
- echo " Ubuntu/Debian: apt-get install jq"
80
- echo " Other: https://stedolan.github.io/jq/download/"
81
- echo ""
82
- fi
83
-
84
- log_success "Dependencies check complete"
85
- }
86
-
87
- # Run unit tests
88
- run_unit_tests() {
89
- log_info "Running unit tests..."
90
-
91
- if [ -f "package.json" ] && grep -q "\"test\":" package.json; then
92
- npm test
93
- else
94
- log_warning "No unit tests configured in package.json"
95
-
96
- # Check for individual test files
97
- if ls test/unit/*.test.* 1> /dev/null 2>&1; then
98
- log_info "Found unit test files, running with jest/vitest..."
99
- if command -v jest &> /dev/null; then
100
- jest test/unit/
101
- elif command -v vitest &> /dev/null; then
102
- vitest run test/unit/
103
- else
104
- log_error "No test runner found (jest/vitest)"
105
- exit 1
106
- fi
107
- else
108
- log_warning "No unit test files found"
109
- fi
110
- fi
111
- }
112
-
113
- # Run clone tests
114
- run_clone_tests() {
115
- log_info "Running clone functionality tests..."
116
-
117
- if [ -f "test/integration/clone-test.sh" ]; then
118
- ./test/integration/clone-test.sh
119
- else
120
- log_error "Clone test script not found"
121
- exit 1
122
- fi
123
- }
124
-
125
- # Run conflict resolution tests
126
- run_conflict_tests() {
127
- log_info "Running conflict resolution tests..."
128
-
129
- if [ -f "test/integration/conflict-resolution-test.sh" ]; then
130
- ./test/integration/conflict-resolution-test.sh
131
- else
132
- log_error "Conflict resolution test script not found"
133
- exit 1
134
- fi
135
- }
136
-
137
- # Run deletion sync tests
138
- run_deletion_tests() {
139
- log_info "Running deletion sync behavior tests..."
140
-
141
- if [ -f "test/integration/deletion-sync-test-simple.sh" ]; then
142
- ./test/integration/deletion-sync-test-simple.sh
143
- else
144
- log_error "Deletion sync test script not found"
145
- exit 1
146
- fi
147
- }
148
-
149
- # Run comprehensive deletion behavior tests
150
- run_deletion_behavior_tests() {
151
- log_info "Running comprehensive deletion behavior tests..."
152
-
153
- if [ -f "test/integration/deletion-behavior-test.sh" ]; then
154
- ./test/integration/deletion-behavior-test.sh
155
- else
156
- log_error "Deletion behavior test script not found"
157
- exit 1
158
- fi
159
- }
160
-
161
- # Run full integration tests
162
- run_full_tests() {
163
- log_info "Running full integration tests..."
164
-
165
- if [ -f "test/integration/full-integration-test.sh" ]; then
166
- ./test/integration/full-integration-test.sh
167
- else
168
- log_error "Full integration test script not found"
169
- exit 1
170
- fi
171
- }
172
-
173
- # Main function
174
- main() {
175
- local test_type="${1:-full}"
176
-
177
- echo "======================================"
178
- echo "Pushwork Test Runner"
179
- echo "======================================"
180
-
181
- # Change to project directory if not already there
182
- if [ ! -f "package.json" ]; then
183
- log_error "Not in project directory (package.json not found)"
184
- echo "Please run this script from the project root directory"
185
- exit 1
186
- fi
187
-
188
- check_dependencies
189
-
190
- case "$test_type" in
191
- "help"|"-h"|"--help")
192
- show_usage
193
- exit 0
194
- ;;
195
- "unit")
196
- run_unit_tests
197
- ;;
198
- "clone")
199
- run_clone_tests
200
- ;;
201
- "conflict")
202
- run_conflict_tests
203
- ;;
204
- "deletion")
205
- run_deletion_tests
206
- ;;
207
- "deletion-behavior")
208
- run_deletion_behavior_tests
209
- ;;
210
- "full")
211
- run_full_tests
212
- ;;
213
- *)
214
- log_error "Unknown test type: $test_type"
215
- echo ""
216
- show_usage
217
- exit 1
218
- ;;
219
- esac
220
-
221
- log_success "Test run complete!"
222
- }
223
-
224
- # Run main function with all arguments
225
- main "$@"