git-drive 0.1.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 (56) 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 +95 -0
  12. package/docker-compose.yml +48 -0
  13. package/package.json +25 -0
  14. package/packages/cli/Dockerfile +26 -0
  15. package/packages/cli/package.json +57 -0
  16. package/packages/cli/src/commands/archive.ts +39 -0
  17. package/packages/cli/src/commands/init.ts +34 -0
  18. package/packages/cli/src/commands/link.ts +115 -0
  19. package/packages/cli/src/commands/list.ts +94 -0
  20. package/packages/cli/src/commands/push.ts +64 -0
  21. package/packages/cli/src/commands/restore.ts +36 -0
  22. package/packages/cli/src/commands/status.ts +127 -0
  23. package/packages/cli/src/config.ts +73 -0
  24. package/packages/cli/src/errors.ts +23 -0
  25. package/packages/cli/src/git.ts +55 -0
  26. package/packages/cli/src/index.ts +97 -0
  27. package/packages/cli/src/server.ts +514 -0
  28. package/packages/cli/tsconfig.json +13 -0
  29. package/packages/cli/ui/assets/index-Cc2q1t5k.js +17 -0
  30. package/packages/cli/ui/assets/index-DrL7ojPA.css +1 -0
  31. package/packages/cli/ui/index.html +14 -0
  32. package/packages/cli/ui/vite.svg +1 -0
  33. package/packages/git-drive-docker/package.json +15 -0
  34. package/packages/server/package.json +44 -0
  35. package/packages/server/src/index.ts +569 -0
  36. package/packages/server/tsconfig.json +9 -0
  37. package/packages/ui/README.md +73 -0
  38. package/packages/ui/eslint.config.js +23 -0
  39. package/packages/ui/index.html +13 -0
  40. package/packages/ui/package.json +42 -0
  41. package/packages/ui/postcss.config.js +6 -0
  42. package/packages/ui/public/vite.svg +1 -0
  43. package/packages/ui/src/App.css +23 -0
  44. package/packages/ui/src/App.tsx +726 -0
  45. package/packages/ui/src/assets/react.svg +8 -0
  46. package/packages/ui/src/assets/vite.svg +3 -0
  47. package/packages/ui/src/index.css +37 -0
  48. package/packages/ui/src/main.tsx +14 -0
  49. package/packages/ui/tailwind.config.js +11 -0
  50. package/packages/ui/tsconfig.app.json +28 -0
  51. package/packages/ui/tsconfig.json +26 -0
  52. package/packages/ui/tsconfig.node.json +12 -0
  53. package/packages/ui/vite.config.ts +7 -0
  54. package/pnpm-workspace.yaml +4 -0
  55. package/rewrite_app.js +731 -0
  56. package/tsconfig.json +14 -0
@@ -0,0 +1,77 @@
1
+ # Technology Stack
2
+
3
+ **Analysis Date:** 2026-01-22
4
+
5
+ ## Languages
6
+
7
+ **Primary:**
8
+ - TypeScript 5.9.3 - All source code
9
+
10
+ **Runtime:**
11
+ - Node.js 14.17+ (from TypeScript compiler requirement)
12
+
13
+ ## Runtime
14
+
15
+ **Environment:**
16
+ - Node.js (ES2022 target)
17
+
18
+ **Package Manager:**
19
+ - npm - Lockfile: `package-lock.json` (present)
20
+
21
+ ## Frameworks
22
+
23
+ **Core:**
24
+ - None - Native Node.js modules only
25
+ - Uses built-in modules: `child_process`, `fs`, `path`, `os`
26
+
27
+ **Build/Dev:**
28
+ - TypeScript 5.9.3 - Compilation from `src/` to `dist/`
29
+ - Module system: Node16 ESM
30
+
31
+ ## Key Dependencies
32
+
33
+ **Development Only:**
34
+ - `typescript` 5.9.3 - TypeScript compiler
35
+ - `@types/node` 22.19.7 - Type definitions for Node.js built-in modules
36
+
37
+ **Runtime Dependencies:**
38
+ - None - Zero runtime dependencies
39
+
40
+ ## Configuration
41
+
42
+ **Environment:**
43
+ - Configuration directory: `~/.config/git-drive/config.json`
44
+ - Stores single configuration: `drivePath` (external drive path)
45
+ - Configuration persisted as JSON
46
+
47
+ **Build:**
48
+ - TypeScript compiler config: `tsconfig.json`
49
+ - Target: ES2022
50
+ - Module resolution: Node16 (ESM)
51
+ - Output: `./dist` directory
52
+ - Input: `./src` directory
53
+
54
+ ## Compiler Options
55
+
56
+ **Settings:**
57
+ - `strict: true` - Strict type checking enabled
58
+ - `esModuleInterop: true` - CommonJS compatibility for imports
59
+ - `declaration: false` - No `.d.ts` generation
60
+ - `sourceMap: false` - No source maps
61
+ - `moduleResolution: Node16` - Node.js ESM module resolution
62
+
63
+ ## Project Metadata
64
+
65
+ **Type:** Command-line tool (bin entry point)
66
+
67
+ **Entry Point:**
68
+ - Executable: `dist/index.js`
69
+ - Command: `git-drive` (registered via package.json bin)
70
+
71
+ **Build Scripts:**
72
+ - `npm run build` - Compile TypeScript to `dist/`
73
+ - `npm run dev` - Watch mode compilation
74
+
75
+ ---
76
+
77
+ *Stack analysis: 2026-01-22*
@@ -0,0 +1,157 @@
1
+ # Codebase Structure
2
+
3
+ **Analysis Date:** 2026-01-22
4
+
5
+ ## Directory Layout
6
+
7
+ ```
8
+ git-drive/
9
+ ├── src/ # TypeScript source code
10
+ │ ├── commands/ # Command handlers (6 modules)
11
+ │ │ ├── init.ts
12
+ │ │ ├── push.ts
13
+ │ │ ├── archive.ts
14
+ │ │ ├── restore.ts
15
+ │ │ ├── list.ts
16
+ │ │ └── status.ts
17
+ │ ├── index.ts # CLI entry point with command dispatch
18
+ │ ├── config.ts # Configuration management
19
+ │ ├── git.ts # Git command abstraction layer
20
+ │ └── errors.ts # Error types and formatting
21
+ ├── dist/ # Compiled JavaScript (generated)
22
+ │ └── commands/
23
+ ├── .planning/ # Planning documents (generated)
24
+ │ └── codebase/
25
+ ├── package.json # npm configuration and dependencies
26
+ ├── tsconfig.json # TypeScript compiler options
27
+ └── .gitignore # Git ignore patterns
28
+ ```
29
+
30
+ ## Directory Purposes
31
+
32
+ **src/ (Source Code):**
33
+ - Purpose: All TypeScript source files for the application
34
+ - Contains: Entry point, command implementations, utilities, error definitions
35
+ - Key files: `index.ts` (entry), `commands/` (all command logic)
36
+
37
+ **src/commands/ (Command Implementations):**
38
+ - Purpose: Individual command handler modules, each implementing one CLI command
39
+ - Contains: init, push, archive, restore, list, status command logic
40
+ - Key files: Each file exports a function matching (args: string[]) => void signature
41
+
42
+ **dist/ (Compiled Output):**
43
+ - Purpose: Generated JavaScript output from TypeScript compilation
44
+ - Contains: Transpiled .js files mirroring src/ structure
45
+ - Generated: Yes
46
+ - Committed: No (in .gitignore)
47
+
48
+ **.planning/codebase/ (Analysis Documents):**
49
+ - Purpose: GSD codebase documentation for code generation planning
50
+ - Contains: ARCHITECTURE.md, STRUCTURE.md, CONVENTIONS.md, TESTING.md (when written)
51
+ - Generated: Yes (by orchestrator)
52
+ - Committed: Yes (version controlled for reference)
53
+
54
+ ## Key File Locations
55
+
56
+ **Entry Points:**
57
+ - `src/index.ts`: Main CLI entry point; shebang executable; imports all commands and dispatches by name
58
+
59
+ **Configuration:**
60
+ - `src/config.ts`: Config loading/saving; configuration file location: ~/.config/git-drive/config.json
61
+ - `tsconfig.json`: TypeScript compilation target ES2022, Node16 modules, strict mode enabled
62
+
63
+ **Core Logic:**
64
+ - `src/git.ts`: git command wrapper; Repository queries (root, project name, remotes)
65
+ - `src/errors.ts`: GitDriveError type; handleError() formatter for console output
66
+ - `src/commands/*.ts`: Six command modules; each handles one CLI operation
67
+
68
+ **Testing:**
69
+ - Not applicable (no test files present)
70
+
71
+ ## Naming Conventions
72
+
73
+ **Files:**
74
+ - `camelCase.ts` for source files: index.ts, config.ts, git.ts, errors.ts
75
+ - Command files match command names: init.ts, push.ts, archive.ts, restore.ts, list.ts, status.ts
76
+ - Compiled output: `camelCase.js` in dist/ directory
77
+
78
+ **Directories:**
79
+ - `lowercase/` for directory names: src, dist, commands, .planning
80
+ - Domain-specific grouping: commands/ contains all CLI command handlers
81
+
82
+ **Functions:**
83
+ - camelCase for all functions: init(), push(), archive(), restore(), list(), status(), git(), loadConfig(), saveConfig(), etc.
84
+ - Handler functions export command function: export function {command}(args: string[])
85
+ - Utility functions use descriptive names: getRepoRoot(), getProjectName(), getDriveStorePath(), assertDriveMounted()
86
+
87
+ **Types/Interfaces:**
88
+ - PascalCase for types: GitDriveError, Config
89
+ - Config interface has required properties in camelCase: drivePath
90
+
91
+ **Variables:**
92
+ - camelCase for all variables and parameters: args, config, drivePath, projectName, storePath, bareRepoPath, etc.
93
+
94
+ ## Where to Add New Code
95
+
96
+ **New Command:**
97
+ 1. Create new file in `src/commands/{command-name}.ts`
98
+ 2. Export function matching signature: `export function {command-name}(args: string[]): void`
99
+ 3. Import in `src/index.ts` at top: `import { {command-name} } from "./commands/{command-name}.js"`
100
+ 4. Add to commands record: `{command-name},` in commands object
101
+ 5. Add help text to printUsage() function
102
+ 6. Implementation pattern: validate args → load config → assert prerequisites → perform operation → console.log() result
103
+
104
+ **New Utility Module:**
105
+ 1. Create file at `src/{utility-name}.ts` (e.g., src/cache.ts, src/validate.ts)
106
+ 2. Export functions with clear names
107
+ 3. Import in commands that need them
108
+ 4. Follow error handling pattern: throw GitDriveError for application errors
109
+
110
+ **Config Changes:**
111
+ 1. Update Config interface in `src/config.ts` (add new property)
112
+ 2. Update loadConfig() and saveConfig() JSON serialization (happens automatically)
113
+ 3. Update requireConfig() validation if new field is required
114
+ 4. Update all dependent code to access new property
115
+
116
+ **Git Operations:**
117
+ 1. Add new helper function in `src/git.ts`
118
+ 2. Follow pattern: use git() wrapper, return trimmed output or null on error
119
+ 3. Add try-catch for git() calls that might fail gracefully
120
+ 4. Import and use in commands
121
+
122
+ **Error Handling:**
123
+ 1. Throw GitDriveError with descriptive message for user-facing errors
124
+ 2. Let system errors propagate; main handler extracts stderr from execSync
125
+ 3. Messages should be actionable: "... Run: git drive init <path>"
126
+
127
+ ## Special Directories
128
+
129
+ **dist/ (Build Output):**
130
+ - Purpose: Generated JavaScript from TypeScript compilation via `npm run build`
131
+ - Generated: Yes
132
+ - Committed: No
133
+
134
+ **.planning/codebase/ (Documentation):**
135
+ - Purpose: Store GSD analysis documents for code generation planning
136
+ - Generated: Yes (orchestrator writes these)
137
+ - Committed: Yes (version controlled)
138
+
139
+ **.claude/ (Context Storage):**
140
+ - Purpose: Agent context and state (auto-generated by Claude agent)
141
+ - Generated: Yes
142
+ - Committed: No
143
+
144
+ ## Import Patterns
145
+
146
+ **External Modules:**
147
+ - Node.js built-ins only: fs, child_process, path, os
148
+ - No npm dependencies (dev-only: typescript, @types/node)
149
+
150
+ **Internal Imports:**
151
+ - Use .js extensions in import statements (for ES Module compatibility): `import { init } from "./commands/init.js"`
152
+ - Relative imports: `../config.js`, `../errors.js`, `../git.js`
153
+ - Path aliases: Not used; relative imports preferred
154
+
155
+ ---
156
+
157
+ *Structure analysis: 2026-01-22*
@@ -0,0 +1,156 @@
1
+ # Testing Patterns
2
+
3
+ **Analysis Date:** 2026-01-22
4
+
5
+ ## Test Framework
6
+
7
+ **Runner:**
8
+ - Not detected
9
+ - No testing framework configured (no jest.config.*, vitest.config.*, package.json test script)
10
+
11
+ **Assertion Library:**
12
+ - Not applicable - no tests present
13
+
14
+ **Run Commands:**
15
+ - No test commands defined in `package.json`
16
+ - Current package.json scripts:
17
+ ```json
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "dev": "tsc --watch"
21
+ }
22
+ ```
23
+
24
+ ## Test File Organization
25
+
26
+ **Location:**
27
+ - No test files detected in codebase
28
+ - No `__tests__` directory
29
+ - No `.test.ts` or `.spec.ts` files
30
+
31
+ **Naming:**
32
+ - No test naming convention established
33
+
34
+ **Structure:**
35
+ - Not applicable - no tests present
36
+
37
+ ## Test Structure
38
+
39
+ **Suite Organization:**
40
+ - Not applicable - no tests present
41
+
42
+ **Patterns:**
43
+ - Not applicable - no tests present
44
+
45
+ ## Mocking
46
+
47
+ **Framework:**
48
+ - Not detected - no mocking library configured
49
+
50
+ **Patterns:**
51
+ - Not applicable - no mocks present
52
+
53
+ **What to Mock:**
54
+ - If tests were to be added, candidates for mocking:
55
+ - File system operations (`fs` module): `readFileSync`, `writeFileSync`, `mkdirSync`, `existsSync`, `readdirSync`, `statSync`, `rmSync`
56
+ - Child process execution (`child_process.execSync`): Would need mocking to avoid running real git commands
57
+ - Environment paths: `homedir()`, `process.argv`, `process.cwd()`, `process.chdir()`
58
+
59
+ **What NOT to Mock:**
60
+ - If tests were to be added, avoid mocking:
61
+ - Error classes (`GitDriveError`) - should use real instances
62
+ - Type interfaces (`Config`) - used for type checking only
63
+ - Custom utility functions - better to test with real implementations
64
+
65
+ ## Fixtures and Factories
66
+
67
+ **Test Data:**
68
+ - Not applicable - no test fixtures present
69
+
70
+ **Location:**
71
+ - If needed, should be created in: `src/__fixtures__/` or `src/__testdata__/`
72
+
73
+ ## Coverage
74
+
75
+ **Requirements:**
76
+ - No coverage requirements enforced
77
+ - No coverage configuration present
78
+
79
+ **View Coverage:**
80
+ - Not applicable - no test runner configured
81
+
82
+ ## Test Types
83
+
84
+ **Unit Tests:**
85
+ - Not present
86
+ - Candidates for unit testing:
87
+ - `src/config.ts` functions: `loadConfig()`, `saveConfig()`, `requireConfig()`, `assertDriveMounted()`, `getDriveStorePath()`
88
+ - `src/git.ts` functions: `git()`, `getRepoRoot()`, `getProjectName()`, `getRemoteUrl()`, `isGitRepo()`
89
+ - `src/errors.ts`: `GitDriveError` class and `handleError()` function
90
+
91
+ **Integration Tests:**
92
+ - Not present
93
+ - Candidates for integration testing:
94
+ - `src/commands/init.ts`: Configuration setup and drive initialization
95
+ - `src/commands/push.ts`: Bare repository creation and remote configuration
96
+ - `src/commands/archive.ts`: Multi-step archival process (push + delete)
97
+ - `src/commands/restore.ts`: Repository cloning and remote renaming
98
+
99
+ **E2E Tests:**
100
+ - Not present
101
+ - Could be valuable for validating complete workflows with actual filesystem and git operations
102
+
103
+ ## Common Patterns
104
+
105
+ **Async Testing:**
106
+ - Not applicable - codebase is synchronous
107
+ - All operations use `execSync` and synchronous file I/O
108
+
109
+ **Error Testing:**
110
+ - Not applicable - no tests present
111
+ - Current error handling in `src/errors.ts` shows pattern for testing:
112
+ - Custom error instances: `instanceof GitDriveError`
113
+ - Standard Error instances: `instanceof Error`
114
+ - Unknown errors: catch-all with fallback message
115
+
116
+ ## Current Testing Strategy
117
+
118
+ **Status:** No automated tests currently in place.
119
+
120
+ **Testing Approach:**
121
+ - Manual testing via CLI commands
122
+ - Commands throw `GitDriveError` on validation failures
123
+ - Exit codes used: `0` for success, `1` for failure
124
+ - User-facing error messages output to `console.error()`
125
+
126
+ **Why Manual Now:**
127
+ - Simple CLI tool with small codebase (374 lines total)
128
+ - Requires filesystem and git operations that are environment-dependent
129
+ - Suitable for expansion as test infrastructure is added
130
+
131
+ ## Recommended Testing Structure
132
+
133
+ If tests are to be added, follow this structure:
134
+
135
+ **Test Files Location:**
136
+ ```
137
+ src/
138
+ ├── commands/
139
+ │ ├── init.ts
140
+ │ └── init.test.ts # Co-located tests
141
+ ├── config.ts
142
+ ├── config.test.ts
143
+ ├── git.ts
144
+ ├── git.test.ts
145
+ ├── errors.ts
146
+ └── errors.test.ts
147
+ ```
148
+
149
+ **Test Dependencies Needed:**
150
+ - Jest or Vitest as test runner
151
+ - Mock library for fs and child_process (built-in to Jest/Vitest)
152
+ - Temporary directory library (e.g., `fs-extra` or native `fs.mkdtempSync`)
153
+
154
+ ---
155
+
156
+ *Testing analysis: 2026-01-22*
package/Dockerfile.cli ADDED
@@ -0,0 +1,30 @@
1
+ # Use a Node.js base image that includes git and common utilities
2
+ FROM node:20-alpine
3
+
4
+ # Install git and util-linux (for lsblk)
5
+ RUN apk add --no-cache git util-linux
6
+
7
+ # Set working directory
8
+ WORKDIR /app
9
+
10
+ # Install pnpm
11
+ RUN npm install -g pnpm
12
+
13
+ # Copy package.json and pnpm-lock.yaml for dependency installation
14
+ COPY package.json pnpm-lock.yaml ./
15
+ COPY packages/cli/package.json ./packages/cli/
16
+ COPY packages/server/package.json ./packages/server/ # Copy server's package.json too for root pnpm install
17
+ COPY packages/ui/package.json ./packages/ui/ # Copy ui's package.json too for root pnpm install
18
+
19
+ # Install dependencies for all workspaces
20
+ RUN pnpm install --frozen-lockfile
21
+
22
+ # Copy source code
23
+ COPY . .
24
+
25
+ # Build cli
26
+ RUN pnpm build:cli
27
+
28
+ # Entrypoint to run the git-drive CLI
29
+ # This will allow 'docker run git-drive-cli <command> <args>'
30
+ ENTRYPOINT ["pnpm", "--filter=@git-drive/cli", "start"]
@@ -0,0 +1,32 @@
1
+ # Use a Node.js base image that includes git and common utilities for node-disk-info (lsblk for linux)
2
+ FROM node:20-alpine
3
+
4
+ # Install git and util-linux (for lsblk)
5
+ RUN apk add --no-cache git util-linux
6
+
7
+ # Set working directory
8
+ WORKDIR /app
9
+
10
+ # Install pnpm
11
+ RUN npm install -g pnpm
12
+
13
+ # Copy package.json and pnpm-lock.yaml for dependency installation
14
+ COPY package.json pnpm-lock.yaml ./
15
+ COPY packages/server/package.json ./packages/server/
16
+ COPY packages/ui/package.json ./packages/ui/
17
+ COPY packages/cli/package.json ./packages/cli/ # Copy cli's package.json too for root pnpm install
18
+
19
+ # Install dependencies for all workspaces
20
+ RUN pnpm install --frozen-lockfile
21
+
22
+ # Copy source code
23
+ COPY . .
24
+
25
+ # Build server and UI
26
+ RUN pnpm build:server && pnpm build:ui
27
+
28
+ # Expose the port the server runs on
29
+ EXPOSE 4483
30
+
31
+ # Command to run the server
32
+ CMD ["pnpm", "--filter=@git-drive/server", "start"]
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # GIT-DRIVE
2
+
3
+ Git drive is an app that can turn any connected storage volume into another git remote repo you can use to backup your code.
4
+
5
+ ## Installation
6
+
7
+ ### npm
8
+
9
+ ```bash
10
+ npm install -g git-drive
11
+ ```
12
+
13
+ ### pnpm
14
+
15
+ ```bash
16
+ pnpm add -g git-drive
17
+ ```
18
+
19
+ ### yarn
20
+
21
+ ```bash
22
+ yarn global add git-drive
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ Once installed, you can use the `git-drive` command:
28
+
29
+ ```bash
30
+ # Link current repo to a drive
31
+ git-drive link
32
+
33
+ # Push current repo to drive
34
+ git-drive push
35
+
36
+ # Show projects on drive
37
+ git-drive list
38
+
39
+ # Check drive and repo state
40
+ git-drive status
41
+ ```
42
+
43
+ ## How it works
44
+
45
+ Run the git-drive (available as a docker container). In the web ui (localhost:4483) just select the drive you want to use (this will create a `.git-drive/` directory in that drive if it doesnt already have it). Here you can see a list of existing repos in this drive (`.git-drive/*`) or add new ones so you can push your code to.
46
+
47
+ Installing git-drive also installs a git-drive cli which can do all of the same things as the web ui. Users can link their current codebase to any connected drive with `git-drive link` this should create the repo in git-drive if it doesnt already exist. Then add a new remote (`git remote add git-drive .........`) and pushing to that new remote "git-drive".
48
+
49
+ Git-drive can handle scenarios where multiple git-drive volumes are connected.
50
+
51
+ ## Docker
52
+
53
+ You can also run git-drive via Docker:
54
+
55
+ ```bash
56
+ # Build the Docker image
57
+ docker compose build
58
+
59
+ # Run the container
60
+ docker compose up -d
61
+
62
+ # Use the CLI through Docker
63
+ docker compose run git-drive-cli <command>
64
+ ```
65
+
66
+ ## Development
67
+
68
+ ```bash
69
+ # Clone the repository
70
+ git clone https://github.com/josmanvis/git-drive.git
71
+ cd git-drive
72
+
73
+ # Install dependencies
74
+ pnpm install
75
+
76
+ # Build all packages
77
+ pnpm build
78
+
79
+ # Run in development mode
80
+ pnpm dev
81
+ ```
82
+
83
+ ## Publishing (Maintainers)
84
+
85
+ The project uses GitHub Actions for automated publishing to npm. To publish a new version:
86
+
87
+ 1. Update the version in `packages/cli/package.json`
88
+ 2. Create a new git tag and push to main
89
+ 3. The CI will automatically build and publish to npm
90
+
91
+ Make sure to set the `NPM_TOKEN` secret in your GitHub repository settings.
92
+
93
+ ## License
94
+
95
+ MIT
@@ -0,0 +1,48 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ git-drive-server:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile.server
8
+ ports:
9
+ - "4483:4483"
10
+ volumes:
11
+ - git-drive-config:/root/.config/git-drive
12
+ # USER: Add your external drive mounts here. For example:
13
+ # For macOS:
14
+ # - /Volumes/MyExternalDrive:/mnt/MyExternalDrive
15
+ # For Linux:
16
+ # - /media/youruser/MyExternalDrive:/mnt/MyExternalDrive
17
+ # These paths are illustrative; you will need to adjust them to your actual drive mount points.
18
+ environment:
19
+ SERVER_URL: "http://localhost:4483" # Or the public URL if exposed
20
+ restart: unless-stopped
21
+
22
+ git-drive-cli:
23
+ build:
24
+ context: .
25
+ dockerfile: Dockerfile.cli
26
+ volumes:
27
+ - git-drive-config:/root/.config/git-drive
28
+ # USER: Add your external drive mounts here, same as for server.
29
+ # For example, to make a host repo available to the CLI:
30
+ # - ./my-local-repo:/app/my-local-repo
31
+ # And also any external drives you want the CLI to interact with:
32
+ # For macOS:
33
+ # - /Volumes/MyExternalDrive:/mnt/MyExternalDrive
34
+ # For Linux:
35
+ # - /media/youruser/MyExternalDrive:/mnt/MyExternalDrive
36
+ # These paths are illustrative; you will need to adjust them to your actual drive mount points.
37
+ depends_on:
38
+ - git-drive-server # Ensures config volume is initialized by server if needed.
39
+ # The 'git-drive-cli' service is designed to be used via `docker compose run` or `docker compose exec`.
40
+ # To use the CLI, you would typically run:
41
+ # docker compose run git-drive-cli <cli-command> <args>
42
+ # Or to execute a command in a running container:
43
+ # docker compose exec git-drive-cli <cli-command> <args>
44
+ # For keeping the container running in the background for exec:
45
+ command: ["tail", "-f", "/dev/null"]
46
+
47
+ volumes:
48
+ git-drive-config: # For persistent git-drive configs like links.json
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "git-drive",
3
+ "version": "0.1.0",
4
+ "description": "Use an external drive as a git bare repository remote",
5
+ "workspaces": [
6
+ "packages/*"
7
+ ],
8
+ "scripts": {
9
+ "build": "pnpm build:cli && pnpm build:ui && pnpm build:server",
10
+ "build:cli": "tsc -p packages/cli/tsconfig.json",
11
+ "build:ui": "cd packages/ui && pnpm run build",
12
+ "build:server": "tsc -p packages/server/tsconfig.json",
13
+ "dev": "tsc --watch"
14
+ },
15
+ "devDependencies": {
16
+ "@types/node": "^22.0.0",
17
+ "typescript": "^5.7.0"
18
+ },
19
+ "pnpm": {
20
+ "onlyBuiltDependencies": [
21
+ "drivelist",
22
+ "esbuild"
23
+ ]
24
+ }
25
+ }
@@ -0,0 +1,26 @@
1
+ # Git Drive - Docker Image
2
+ # Includes CLI, server, and web UI
3
+
4
+ FROM node:20-alpine
5
+
6
+ # Install git and util-linux (for lsblk)
7
+ RUN apk add --no-cache git util-linux
8
+
9
+ WORKDIR /app
10
+
11
+ # Copy package files
12
+ COPY package.json ./
13
+ COPY dist ./dist/
14
+ COPY ui ./ui/
15
+
16
+ # Install production dependencies only
17
+ RUN npm install --omit=dev
18
+
19
+ # Expose the web UI port
20
+ EXPOSE 4483
21
+
22
+ # Set environment
23
+ ENV GIT_DRIVE_PORT=4483
24
+
25
+ # Default command starts the server
26
+ CMD ["node", "dist/server.js"]