A CLI tool for managing alignerr project submissions with automatic git tracking and organized file structure.
- π Automatic directory structure creation with date-based organization
- π Git commit tracking for submissions
- π UUID-based task identification
- βοΈ Configurable base path via environment variables
- π― Interactive prompts for missing parameters
- β Full TypeScript support with type safety
- π§ͺ Comprehensive test coverage
- Clone the repository:
git clone <repository-url>
cd alignerr-cli- Install dependencies:
npm install- Create your environment configuration:
cp .env.example .env- Edit
.envto set your base path (optional):
ALIGNERR_BASE_PATH=~/Documents/projects/alignerr- Build the project:
npm run build- Link the CLI globally for local testing:
npm linknpm install -g alignerrInitialize a new submission:
npx alignerr submission --init --file=<filename>.tar --uuid=<uuid> --source=<path-to-source-folder> --cleanFinalize a submission:
npx alignerr submission --final --source=<path-to-source-folder>Initialization Examples:
- With all parameters provided:
npx alignerr submission --init --file=my-submission.tar --uuid=123e4567-e89b-12d3-a456-426614174000 --source=/path/to/project- With clean flag to start fresh:
npx alignerr submission --init --uuid=abc123 --source=/path/to/project --clean
# This will delete any existing submissions for today's date before creating new ones- With interactive prompts (no parameters):
npx alignerr submission --initThe CLI will prompt you for:
- Filename (if not provided)
- UUID (if not provided)
- With partial parameters:
npx alignerr submission --init --file=submission.tar
# Will prompt only for UUID- Using source from environment variable:
# Set ALIGNERR_SOURCE_PATH in .env, then run:
npx alignerr submission --init --file=submission.tar --uuid=abc123
# Will use source path from .envFinalization Examples:
- Finalize with explicit source path:
npx alignerr submission --final --source=/path/to/project- Finalize using source from environment variable:
# Set ALIGNERR_SOURCE_PATH in .env, then run:
npx alignerr submission --final
# Will use source path from .env- Finalize using current directory:
# From your project directory:
cd /path/to/project
npx alignerr submission --finalThe --source parameter determines where git commands will be executed. The priority order is:
- Command line parameter (
--sourceflag) - highest priority - Environment variable (
ALIGNERR_SOURCE_PATHin.env) - Current working directory - default fallback
This allows you to track git commits from different project directories while creating submissions.
When you run the initialization command (--init), the CLI will:
-
Create organized directory structure:
~/Documents/projects/alignerr/submissions/YYYY-MM-DD/ -
Create the tar file:
~/Documents/projects/alignerr/submissions/YYYY-MM-DD/<filename>.tar -
Capture current git commit:
- Runs
git rev-parse HEAD - Prints the commit hash to console
- Saves to:
initial-hash.<hash>
- Runs
-
Save task UUID:
- Prints UUID to console
- Saves to:
uuid.<uuid>
When you run the finalization command (--final), the CLI will:
-
Read initialization data:
- Reads commit hash from
initial-hash.<hash>file - Reads UUID from
uuid.<uuid>file - If either file is missing, shows error and explains that
--initmust be run first
- Reads commit hash from
-
Extract tar file:
- Extracts the tar file created during init to verify contents
-
Stage all changes:
- Runs
git add -Ato ensure new files are included in the diff
- Runs
-
Create diff file:
- Runs
git diff <commit_hash> > ~/<uuid>_final.diff - Creates the diff file in your home directory
- Diff shows all changes from the initial commit to current state
- Runs
-
Validate changes:
- Applies the diff to the extracted files using
git apply - Shows success message if changes apply cleanly
- Shows error message with details if changes fail to apply
- Helps verify that your changes are compatible with the initial submission
- Applies the diff to the extracted files using
-
Cleanup:
- Removes the extracted directory
- Maintains only the original tar file
The CLI can be configured via the .env file:
# Base path for submissions storage
ALIGNERR_BASE_PATH=~/Documents/projects/alignerr
# Source folder path where git commands will be executed (optional)
# If not set, git commands will run in the current directory
ALIGNERR_SOURCE_PATH=/path/to/your/projectConfiguration options:
ALIGNERR_BASE_PATH: Base directory for storing submissions (defaults to~/Documents/projects/alignerr)ALIGNERR_SOURCE_PATH: Default source directory for git operations (optional, defaults to current directory)
npm run dev -- submission --initnpm run build# Run tests once
npm test
# Run tests in watch mode
npm test -- --watch
# Run tests with coverage
npm run test:coveragealignerr-cli/
βββ src/
β βββ commands/
β β βββ submission.ts # Submission command definition
β βββ services/
β β βββ submissionService.ts # Core submission logic
β βββ utils/
β β βββ config.ts # Configuration and path utilities
β β βββ git.ts # Git operations
β β βββ prompts.ts # Interactive prompts
β βββ tests/
β β βββ config.test.ts # Config tests
β β βββ git.test.ts # Git tests
β β βββ prompts.test.ts # Prompts tests
β βββ index.ts # CLI entry point
βββ .env.example # Environment configuration template
βββ .gitignore
βββ package.json
βββ tsconfig.json
βββ vitest.config.ts
βββ README.md
- Node.js >= 18.0.0
- Git installed and accessible via command line
- TypeScript >= 5.0.0 (dev dependency)
npm run build- Compile TypeScript to JavaScriptnpm run dev- Run in development mode with tsxnpm test- Run tests with vitestnpm run test:coverage- Run tests with coverage report
The CLI includes comprehensive error handling:
- Validates required inputs
- Checks for git availability
- Creates directories recursively if they don't exist
- Provides clear error messages for troubleshooting
Init Command:
π Initializing alignerr submission...
β Created directory: /Users/user/Documents/projects/alignerr/submissions/2026-01-08
β Created tar file: /Users/user/Documents/projects/alignerr/submissions/2026-01-08/submission.tar
β Current commit: abc123def456789...
β Saved commit hash to: /Users/user/Documents/projects/alignerr/submissions/2026-01-08/initial-hash.abc123def456789...
β Task UUID: 123e4567-e89b-12d3-a456-426614174000
β Saved UUID to: /Users/user/Documents/projects/alignerr/submissions/2026-01-08/uuid.123e4567-e89b-12d3-a456-426614174000
β
Submission initialized successfully!
Final Command:
π Finalizing alignerr submission...
β Found initial commit hash: abc123def456789...
β Found task UUID: 123e4567-e89b-12d3-a456-426614174000
π¦ Extracting tar file...
β Extracted to: /Users/user/Documents/projects/alignerr/submissions/2026-01-08/project-name
π¦ Adding all files to git...
β Executed: git add -A in /path/to/project
π Creating diff...
β Created diff file: /Users/user/123e4567-e89b-12d3-a456-426614174000_final.diff
π§ Applying diff to extracted files...
β
Diff applied successfully!
β
All changes are compatible with the initial submission.
π§Ή Cleaning up extracted files...
β Removed: /Users/user/Documents/projects/alignerr/submissions/2026-01-08/project-name
β
Submission finalized successfully!
Final Command (with errors):
π Finalizing alignerr submission...
β Found initial commit hash: abc123def456789...
β Found task UUID: 123e4567-e89b-12d3-a456-426614174000
π¦ Extracting tar file...
β Extracted to: /Users/user/Documents/projects/alignerr/submissions/2026-01-08/project-name
π¦ Adding all files to git...
β Executed: git add -A in /path/to/project
π Creating diff...
β Created diff file: /Users/user/123e4567-e89b-12d3-a456-426614174000_final.diff
π§ Applying diff to extracted files...
β Failed to apply diff.
Reason:
error: patch failed: src/file.ts:10
error: src/file.ts: patch does not apply
β οΈ This might indicate conflicts or incompatible changes.
π§Ή Cleaning up extracted files...
β Removed: /Users/user/Documents/projects/alignerr/submissions/2026-01-08/project-name
β
Submission finalized successfully!
MIT
Contributions are welcome! Please feel free to submit a Pull Request.