git-drive 0.1.2 → 0.1.5

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 (83) hide show
  1. package/.github/workflows/ci.yml +77 -0
  2. package/.planning/codebase/ARCHITECTURE.md +151 -0
  3. package/.planning/codebase/CONCERNS.md +191 -0
  4. package/.planning/codebase/CONVENTIONS.md +169 -0
  5. package/.planning/codebase/INTEGRATIONS.md +94 -0
  6. package/.planning/codebase/STACK.md +77 -0
  7. package/.planning/codebase/STRUCTURE.md +157 -0
  8. package/.planning/codebase/TESTING.md +156 -0
  9. package/Dockerfile.cli +30 -0
  10. package/Dockerfile.server +32 -0
  11. package/README.md +121 -0
  12. package/docker-compose.yml +48 -0
  13. package/package.json +19 -46
  14. package/packages/cli/Dockerfile +26 -0
  15. package/packages/cli/jest.config.js +26 -0
  16. package/packages/cli/package.json +65 -0
  17. package/packages/cli/src/__tests__/commands/init.test.ts +154 -0
  18. package/packages/cli/src/__tests__/commands/list.test.ts +118 -0
  19. package/packages/cli/src/__tests__/commands/push.test.ts +155 -0
  20. package/packages/cli/src/__tests__/commands/restore.test.ts +134 -0
  21. package/packages/cli/src/__tests__/commands/status.test.ts +195 -0
  22. package/packages/cli/src/__tests__/config.test.ts +198 -0
  23. package/packages/cli/src/__tests__/e2e.test.ts +125 -0
  24. package/packages/cli/src/__tests__/errors.test.ts +66 -0
  25. package/packages/cli/src/__tests__/git.test.ts +226 -0
  26. package/packages/cli/src/__tests__/server.test.ts +368 -0
  27. package/packages/cli/src/commands/archive.ts +39 -0
  28. package/packages/cli/src/commands/init.ts +64 -0
  29. package/packages/cli/src/commands/link.ts +151 -0
  30. package/packages/cli/src/commands/list.ts +94 -0
  31. package/packages/cli/src/commands/push.ts +77 -0
  32. package/packages/cli/src/commands/restore.ts +36 -0
  33. package/packages/cli/src/commands/status.ts +127 -0
  34. package/packages/cli/src/config.ts +73 -0
  35. package/packages/cli/src/errors.ts +23 -0
  36. package/packages/cli/src/git.ts +55 -0
  37. package/packages/cli/src/index.ts +122 -0
  38. package/packages/cli/src/server.ts +573 -0
  39. package/packages/cli/tsconfig.json +13 -0
  40. package/packages/cli/ui/assets/index-Br8xQbJz.js +17 -0
  41. package/{ui → packages/cli/ui}/index.html +1 -1
  42. package/packages/git-drive-docker/package.json +15 -0
  43. package/packages/server/package.json +44 -0
  44. package/packages/server/src/index.ts +569 -0
  45. package/packages/server/tsconfig.json +9 -0
  46. package/packages/ui/README.md +73 -0
  47. package/packages/ui/eslint.config.js +23 -0
  48. package/packages/ui/index.html +13 -0
  49. package/packages/ui/package.json +52 -0
  50. package/packages/ui/postcss.config.js +6 -0
  51. package/packages/ui/public/vite.svg +1 -0
  52. package/packages/ui/src/App.css +23 -0
  53. package/packages/ui/src/App.test.tsx +242 -0
  54. package/packages/ui/src/App.tsx +755 -0
  55. package/packages/ui/src/assets/react.svg +8 -0
  56. package/packages/ui/src/assets/vite.svg +3 -0
  57. package/packages/ui/src/index.css +37 -0
  58. package/packages/ui/src/main.tsx +14 -0
  59. package/packages/ui/src/test/setup.ts +1 -0
  60. package/packages/ui/tailwind.config.js +11 -0
  61. package/packages/ui/tsconfig.app.json +28 -0
  62. package/packages/ui/tsconfig.json +26 -0
  63. package/packages/ui/tsconfig.node.json +12 -0
  64. package/packages/ui/vite.config.ts +7 -0
  65. package/packages/ui/vitest.config.ts +20 -0
  66. package/pnpm-workspace.yaml +4 -0
  67. package/rewrite_app.js +731 -0
  68. package/tsconfig.json +14 -0
  69. package/dist/commands/archive.js +0 -32
  70. package/dist/commands/init.js +0 -55
  71. package/dist/commands/link.js +0 -139
  72. package/dist/commands/list.js +0 -83
  73. package/dist/commands/push.js +0 -99
  74. package/dist/commands/restore.js +0 -30
  75. package/dist/commands/status.js +0 -116
  76. package/dist/config.js +0 -62
  77. package/dist/errors.js +0 -30
  78. package/dist/git.js +0 -60
  79. package/dist/index.js +0 -100
  80. package/dist/server.js +0 -526
  81. /package/{ui → packages/cli/ui}/assets/index-Cc2q1t5k.js +0 -0
  82. /package/{ui → packages/cli/ui}/assets/index-DrL7ojPA.css +0 -0
  83. /package/{ui → packages/cli/ui}/vite.svg +0 -0
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```
@@ -0,0 +1,23 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+ import { defineConfig, globalIgnores } from 'eslint/config'
7
+
8
+ export default defineConfig([
9
+ globalIgnores(['dist']),
10
+ {
11
+ files: ['**/*.{ts,tsx}'],
12
+ extends: [
13
+ js.configs.recommended,
14
+ tseslint.configs.recommended,
15
+ reactHooks.configs.flat.recommended,
16
+ reactRefresh.configs.vite,
17
+ ],
18
+ languageOptions: {
19
+ ecmaVersion: 2020,
20
+ globals: globals.browser,
21
+ },
22
+ },
23
+ ])
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + React + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "git-drive-ui",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "lint": "eslint .",
10
+ "preview": "vite preview",
11
+ "test": "vitest",
12
+ "test:watch": "vitest watch",
13
+ "test:coverage": "vitest run --coverage"
14
+ },
15
+ "dependencies": {
16
+ "@radix-ui/react-icons": "^1.3.2",
17
+ "@radix-ui/react-slot": "^1.2.4",
18
+ "@radix-ui/react-tooltip": "^1.2.8",
19
+ "autoprefixer": "^10.4.25",
20
+ "axios": "^1.13.5",
21
+ "class-variance-authority": "^0.7.1",
22
+ "clsx": "^2.1.1",
23
+ "fuse.js": "^7.1.0",
24
+ "lucide-react": "^0.575.0",
25
+ "postcss": "^8.5.6",
26
+ "react": "^19.2.4",
27
+ "react-dom": "^19.2.4",
28
+ "react-query": "^3.39.3",
29
+ "react-router-dom": "^7.13.1",
30
+ "tailwind-merge": "^3.5.0",
31
+ "tailwindcss": "^3.4.19",
32
+ "valibot": "^1.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@eslint/js": "^10.0.1",
36
+ "@testing-library/jest-dom": "^6.6.3",
37
+ "@testing-library/react": "^16.2.0",
38
+ "@testing-library/user-event": "^14.6.1",
39
+ "@types/react": "^19.2.14",
40
+ "@types/react-dom": "^19.2.3",
41
+ "@vitejs/plugin-react": "^5.1.4",
42
+ "eslint": "^10.0.2",
43
+ "eslint-plugin-react-hooks": "^7.0.1",
44
+ "eslint-plugin-react-refresh": "^0.5.2",
45
+ "globals": "^17.3.0",
46
+ "jsdom": "^26.0.0",
47
+ "msw": "^2.7.3",
48
+ "typescript-eslint": "^8.56.1",
49
+ "vite": "^7.3.1",
50
+ "vitest": "^3.0.8"
51
+ }
52
+ }
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,23 @@
1
+ .App {
2
+ text-align: center;
3
+ }
4
+
5
+ .App-logo {
6
+ animation: App-logo-spin infinite 20s linear;
7
+ height: 40vmin;
8
+ pointer-events: none;
9
+ }
10
+
11
+ @media (prefers-reduced-motion: no-preference) {
12
+ a:nth-of-type(2).logo:hover {
13
+ filter: drop-shadow(0 0 2em #61dafbaa);
14
+ }
15
+ }
16
+
17
+ .card {
18
+ padding: 2em;
19
+ }
20
+
21
+ .read-the-docs {
22
+ color: #888;
23
+ }
@@ -0,0 +1,242 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import App from './App';
5
+
6
+ // Mock axios
7
+ vi.mock('axios', () => ({
8
+ default: {
9
+ get: vi.fn(),
10
+ post: vi.fn(),
11
+ delete: vi.fn(),
12
+ },
13
+ }));
14
+
15
+ import axios from 'axios';
16
+
17
+ const mockAxios = vi.mocked(axios);
18
+
19
+ // Helper to render with router
20
+ const renderWithRouter = (initialRoute = '/') => {
21
+ return render(
22
+ <MemoryRouter initialEntries={[initialRoute]}>
23
+ <App />
24
+ </MemoryRouter>
25
+ );
26
+ };
27
+
28
+ describe('App', () => {
29
+ beforeEach(() => {
30
+ vi.clearAllMocks();
31
+ });
32
+
33
+ it('should render the header with title', () => {
34
+ renderWithRouter();
35
+ expect(screen.getByText('Git Drive')).toBeInTheDocument();
36
+ expect(screen.getByText('Turn any drive into a git remote.')).toBeInTheDocument();
37
+ });
38
+
39
+ it('should render drive list on home route', () => {
40
+ renderWithRouter();
41
+ expect(screen.getByText('Connected Drives')).toBeInTheDocument();
42
+ });
43
+ });
44
+
45
+ describe('DriveList', () => {
46
+ beforeEach(() => {
47
+ vi.clearAllMocks();
48
+ });
49
+
50
+ it('should display loading state initially', () => {
51
+ mockAxios.get.mockImplementation(() => new Promise(() => {})); // Never resolves
52
+
53
+ renderWithRouter();
54
+
55
+ // Check for loading state (skeleton or loading text)
56
+ expect(screen.getByText('Connected Drives')).toBeInTheDocument();
57
+ });
58
+
59
+ it('should display drives after loading', async () => {
60
+ mockAxios.get.mockResolvedValue({
61
+ data: [
62
+ {
63
+ device: 'TestDrive',
64
+ description: '/Volumes/TestDrive',
65
+ size: 32000000000,
66
+ isRemovable: true,
67
+ isSystem: false,
68
+ mountpoints: ['/Volumes/TestDrive'],
69
+ hasGitDrive: true,
70
+ },
71
+ ],
72
+ });
73
+
74
+ renderWithRouter();
75
+
76
+ await waitFor(() => {
77
+ expect(screen.getByText('/Volumes/TestDrive')).toBeInTheDocument();
78
+ });
79
+ });
80
+
81
+ it('should display unconfigured drive with initialize button', async () => {
82
+ mockAxios.get.mockResolvedValue({
83
+ data: [
84
+ {
85
+ device: 'NewDrive',
86
+ description: '/Volumes/NewDrive',
87
+ size: 64000000000,
88
+ isRemovable: true,
89
+ isSystem: false,
90
+ mountpoints: ['/Volumes/NewDrive'],
91
+ hasGitDrive: false,
92
+ },
93
+ ],
94
+ });
95
+
96
+ renderWithRouter();
97
+
98
+ await waitFor(() => {
99
+ expect(screen.getByText('Initialize Git Drive')).toBeInTheDocument();
100
+ });
101
+ });
102
+
103
+ it('should initialize drive when button clicked', async () => {
104
+ mockAxios.get.mockResolvedValue({
105
+ data: [
106
+ {
107
+ device: 'NewDrive',
108
+ description: '/Volumes/NewDrive',
109
+ size: 64000000000,
110
+ isRemovable: true,
111
+ isSystem: false,
112
+ mountpoints: ['/Volumes/NewDrive'],
113
+ hasGitDrive: false,
114
+ },
115
+ ],
116
+ });
117
+
118
+ mockAxios.post.mockResolvedValue({ data: { message: 'Initialized' } });
119
+
120
+ renderWithRouter();
121
+
122
+ await waitFor(() => {
123
+ expect(screen.getByText('Initialize Git Drive')).toBeInTheDocument();
124
+ });
125
+
126
+ fireEvent.click(screen.getByText('Initialize Git Drive'));
127
+
128
+ await waitFor(() => {
129
+ expect(mockAxios.post).toHaveBeenCalledWith(
130
+ expect.stringContaining('/init')
131
+ );
132
+ });
133
+ });
134
+ });
135
+
136
+ describe('RepoList', () => {
137
+ beforeEach(() => {
138
+ vi.clearAllMocks();
139
+ });
140
+
141
+ it('should display repos for a drive', async () => {
142
+ mockAxios.get.mockResolvedValue({
143
+ data: {
144
+ mountpoint: '/Volumes/TestDrive',
145
+ gitDrivePath: '/Volumes/TestDrive/.git-drive',
146
+ initialized: true,
147
+ repos: [
148
+ {
149
+ name: 'my-project',
150
+ path: '/Volumes/TestDrive/.git-drive/my-project.git',
151
+ lastModified: '2024-01-01T00:00:00.000Z',
152
+ },
153
+ ],
154
+ },
155
+ });
156
+
157
+ renderWithRouter('/drives/%2FVolumes%2FTestDrive');
158
+
159
+ await waitFor(() => {
160
+ expect(screen.getByText('my-project')).toBeInTheDocument();
161
+ });
162
+ });
163
+
164
+ it('should display empty state when no repos', async () => {
165
+ mockAxios.get.mockResolvedValue({
166
+ data: {
167
+ mountpoint: '/Volumes/TestDrive',
168
+ gitDrivePath: '/Volumes/TestDrive/.git-drive',
169
+ initialized: true,
170
+ repos: [],
171
+ },
172
+ });
173
+
174
+ renderWithRouter('/drives/%2FVolumes%2FTestDrive');
175
+
176
+ await waitFor(() => {
177
+ expect(screen.getByText('No repositories yet')).toBeInTheDocument();
178
+ });
179
+ });
180
+
181
+ it('should filter repos with search', async () => {
182
+ mockAxios.get.mockResolvedValue({
183
+ data: {
184
+ mountpoint: '/Volumes/TestDrive',
185
+ gitDrivePath: '/Volumes/TestDrive/.git-drive',
186
+ initialized: true,
187
+ repos: [
188
+ { name: 'project-alpha', path: '/a', lastModified: '2024-01-01' },
189
+ { name: 'project-beta', path: '/b', lastModified: '2024-01-02' },
190
+ ],
191
+ },
192
+ });
193
+
194
+ renderWithRouter('/drives/%2FVolumes%2FTestDrive');
195
+
196
+ await waitFor(() => {
197
+ expect(screen.getByText('project-alpha')).toBeInTheDocument();
198
+ expect(screen.getByText('project-beta')).toBeInTheDocument();
199
+ });
200
+
201
+ const searchInput = screen.getByPlaceholderText('Filter repositories...');
202
+ fireEvent.change(searchInput, { target: { value: 'alpha' } });
203
+
204
+ await waitFor(() => {
205
+ expect(screen.getByText('project-alpha')).toBeInTheDocument();
206
+ expect(screen.queryByText('project-beta')).not.toBeInTheDocument();
207
+ });
208
+ });
209
+
210
+ it('should create a new repo', async () => {
211
+ mockAxios.get.mockResolvedValue({
212
+ data: {
213
+ mountpoint: '/Volumes/TestDrive',
214
+ gitDrivePath: '/Volumes/TestDrive/.git-drive',
215
+ initialized: true,
216
+ repos: [],
217
+ },
218
+ });
219
+
220
+ mockAxios.post.mockResolvedValue({
221
+ data: { name: 'new-repo', path: '/path/to/new-repo.git' },
222
+ });
223
+
224
+ // Mock prompt
225
+ vi.spyOn(window, 'prompt').mockReturnValue('new-repo');
226
+
227
+ renderWithRouter('/drives/%2FVolumes%2FTestDrive');
228
+
229
+ await waitFor(() => {
230
+ expect(screen.getByText('New Repository')).toBeInTheDocument();
231
+ });
232
+
233
+ fireEvent.click(screen.getByText('New Repository'));
234
+
235
+ await waitFor(() => {
236
+ expect(mockAxios.post).toHaveBeenCalledWith(
237
+ expect.stringContaining('/repos'),
238
+ { name: 'new-repo' }
239
+ );
240
+ });
241
+ });
242
+ });