- GitHub repository created
- Dependencies installed
- Folder structure created
- Files initialized
- TypeScript configured
- Initial commit pushed
npm install @actions/core @actions/github commander simple-git chalk yaml axios ora promptsnpm install -D typescript @types/node @types/prompts jest @types/jest ts-jest eslint @typescript-eslint/eslint-plugin @typescript-eslint/parserFor Windows CMD:
mkdir src\cli\commands
mkdir src\cli\utils
mkdir src\core
mkdir src\action
mkdir src\types
mkdir tests
mkdir templates
mkdir .github\workflowsFor PowerShell:
New-Item -ItemType Directory -Force -Path src\cli\commands
New-Item -ItemType Directory -Force -Path src\cli\utils
New-Item -ItemType Directory -Force -Path src\core
New-Item -ItemType Directory -Force -Path src\action
New-Item -ItemType Directory -Force -Path src\types
New-Item -ItemType Directory -Force -Path tests
New-Item -ItemType Directory -Force -Path templates
New-Item -ItemType Directory -Force -Path .github\workflowsFor Windows CMD:
type nul > src\types\config.ts
type nul > src\core\git-operations.ts
type nul > src\core\conflict-detector.ts
type nul > src\core\branch-sync.ts
type nul > src\core\notifications.ts
type nul > src\cli\index.ts
type nul > src\cli\commands\init.ts
type nul > src\cli\commands\sync.ts
type nul > src\cli\commands\status.ts
type nul > src\cli\utils\config.ts
type nul > src\cli\utils\logger.ts
type nul > src\action\index.ts
type nul > templates\.gitflow-autopilot.yml
type nul > action.yml
type nul > .npmignoreFor PowerShell:
New-Item -ItemType File -Path src\types\config.ts
New-Item -ItemType File -Path src\core\git-operations.ts
New-Item -ItemType File -Path src\core\conflict-detector.ts
New-Item -ItemType File -Path src\core\branch-sync.ts
New-Item -ItemType File -Path src\core\notifications.ts
New-Item -ItemType File -Path src\cli\index.ts
New-Item -ItemType File -Path src\cli\commands\init.ts
New-Item -ItemType File -Path src\cli\commands\sync.ts
New-Item -ItemType File -Path src\cli\commands\status.ts
New-Item -ItemType File -Path src\cli\utils\config.ts
New-Item -ItemType File -Path src\cli\utils\logger.ts
New-Item -ItemType File -Path src\action\index.ts
New-Item -ItemType File -Path templates\.gitflow-autopilot.yml
New-Item -ItemType File -Path action.yml
New-Item -ItemType File -Path .npmignoreReplace the content of package.json with:
{
"name": "gitflow-autopilot",
"version": "0.1.0",
"description": "Git branch syncing on autopilot",
"main": "dist/index.js",
"bin": {
"gitflow-autopilot": "dist/cli/index.js"
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"test": "jest",
"lint": "eslint src/**/*.ts"
},
"keywords": [
"git",
"gitflow",
"branch-sync",
"automation",
"devops",
"ci-cd"
],
"author": "Your Name",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/24andup/gitflow-autopilot.git"
},
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"axios": "^1.6.0",
"chalk": "^4.1.2",
"commander": "^11.1.0",
"ora": "^5.4.1",
"prompts": "^2.4.2",
"simple-git": "^3.20.0",
"yaml": "^2.3.4"
},
"devDependencies": {
"@types/jest": "^29.5.8",
"@types/node": "^20.9.0",
"@types/prompts": "^2.4.9",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint": "^8.54.0",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
}
}node_modules/
dist/
*.log
.env
.DS_Store
coverage/
.vscode/
*.tsbuildinfo
src/
tests/
*.test.ts
*.spec.ts
tsconfig.json
.eslintrc.js
.gitignore
.github/
coverage/
*.md
!README.md
Replace the content of tsconfig.json with:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"moduleResolution": "node"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "tests"]
}Create .eslintrc.js:
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
},
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
};Create jest.config.js:
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/tests'],
testMatch: ['**/*.test.ts'],
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts'
]
};npm run buildShould compile successfully (even with empty files).
git add .
git commit -m "chore: initial project setup - Day 1 complete"
git push origin mainTime spent: ~60 minutes
What's ready: Project structure, dependencies, configuration files
- Type interfaces created
- Build successful
- No TypeScript errors
File: src/types/config.ts
/**
* Configuration structure for GitFlow Autopilot
*/
export interface GitFlowConfig {
branches: {
main: string;
develop: string;
};
sync: {
enabled: boolean;
auto_sync: boolean;
skip_patterns: string[];
conflict_strategy: 'notify' | 'auto-resolve' | 'skip';
};
notifications: {
slack?: {
enabled: boolean;
webhook_url: string;
channel?: string;
mention_users?: string[];
};
email?: {
enabled: boolean;
recipients: string[];
smtp_config?: {
host: string;
port: number;
username: string;
password: string;
};
};
};
conflict_detection: {
enabled: boolean;
file_patterns?: string[];
ignore_patterns?: string[];
};
github_action?: {
run_on_schedule?: boolean;
schedule_cron?: string;
};
}
/**
* Result of a sync operation
*/
export interface SyncResult {
success: boolean;
message: string;
sourceBranch: string;
targetBranch: string;
conflictFiles?: string[];
skipped: boolean;
skipReason?: string;
timestamp: Date;
commitHash?: string;
}
/**
* Information about detected conflicts
*/
export interface ConflictInfo {
hasConflicts: boolean;
conflicts: Array<{
file: string;
type: 'content' | 'deletion' | 'modification';
severity: 'low' | 'medium' | 'high';
}>;
riskScore: number; // 0-100
recommendation: 'safe' | 'caution' | 'manual-review-required';
}
/**
* Branch status information
*/
export interface BranchStatus {
name: string;
exists: boolean;
ahead: number;
behind: number;
lastCommit?: {
hash: string;
message: string;
author: string;
date: Date;
};
}
/**
* Notification payload
*/
export interface NotificationPayload {
type: 'conflict' | 'success' | 'error' | 'skip';
title: string;
message: string;
details?: Record<string, unknown>;
severity: 'info' | 'warning' | 'error';
timestamp: Date;
}
/**
* CLI command options
*/
export interface CLIOptions {
source?: string;
target?: string;
configPath?: string;
dryRun?: boolean;
verbose?: boolean;
force?: boolean;
}
/**
* GitHub Action inputs
*/
export interface ActionInputs {
githubToken: string;
configPath: string;
slackWebhook?: string;
dryRun: boolean;
}
/**
* Default configuration template
*/
export const DEFAULT_CONFIG: GitFlowConfig = {
branches: {
main: 'main',
develop: 'dev'
},
sync: {
enabled: true,
auto_sync: true,
skip_patterns: [
'*[skip ci]*',
'*[no sync]*',
'*WIP*'
],
conflict_strategy: 'notify'
},
notifications: {
slack: {
enabled: false,
webhook_url: ''
}
},
conflict_detection: {
enabled: true,
ignore_patterns: [
'package-lock.json',
'yarn.lock',
'pnpm-lock.yaml'
]
}
};npm run buildExpected output:
- No TypeScript errors
dist/folder createddist/types/config.jsexistsdist/types/config.d.tsexists
Verify files:
dir dist\typesShould show:
config.js
config.d.ts
config.js.map
Create a test file to verify types work:
File: tests/types.test.ts
import { GitFlowConfig, SyncResult, DEFAULT_CONFIG } from '../src/types/config';
describe('Type Definitions', () => {
it('should use default config', () => {
const config: GitFlowConfig = DEFAULT_CONFIG;
expect(config.branches.main).toBe('main');
expect(config.branches.develop).toBe('dev');
expect(config.sync.enabled).toBe(true);
});
it('should create sync result', () => {
const result: SyncResult = {
success: true,
message: 'Sync completed',
sourceBranch: 'main',
targetBranch: 'dev',
skipped: false,
timestamp: new Date()
};
expect(result.success).toBe(true);
});
});Run test:
npm testgit add .
git commit -m "feat: add core type definitions - Day 2 complete"
git push origin mainTime spent: ~60 minutes
What's ready: Complete type system with interfaces for all core functionality
- ✅ Complete project structure
- ✅ All dependencies installed
- ✅ TypeScript configured and working
- ✅ Type definitions for entire application
- ✅ Build system functional
- ✅ Testing framework ready
- Day 3: Git Operations Module
- Day 4: Conflict Detection
- Day 5: Branch Sync Service
You now have a solid foundation! The hardest setup work is done. Days 3-5 will implement the core logic using these types.
npm run build # Compile TypeScript
npm run dev # Watch mode
npm test # Run tests
npm run lint # Check code stylegitflow-autopilot/
├── src/
│ ├── types/ ✅ DONE
│ ├── core/ → Next
│ ├── cli/ → Week 2
│ └── action/ → Week 2
├── tests/ ✅ Setup done
├── dist/ ✅ Generated on build
└── package.json ✅ DONE
You've completed the foundation in just 2 hours! This is the boring part - it gets more fun from here as you implement actual Git logic and see things work.
Keep going! 💪