-
Notifications
You must be signed in to change notification settings - Fork 0
feat: update init.ts to write YAML config (GIT-90) #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { existsSync, readFileSync, writeFileSync, appendFileSync, mkdirSync } fr | |
| import { execFileSync } from 'child_process'; | ||
| import { join } from 'path'; | ||
| import prompts from 'prompts'; | ||
| import { parse as parseYaml, stringify as stringifyYaml } from 'yaml'; | ||
| import type { ILogger } from '../domain/interfaces/ILogger'; | ||
| import { | ||
| getSettingsPath, | ||
|
|
@@ -24,6 +25,7 @@ import { installPostCommitHook, uninstallPostCommitHook } from '../hooks/post-co | |
| import { installCommitMsgHook, uninstallCommitMsgHook } from '../hooks/commit-msg'; | ||
| import { createContainer } from '../infrastructure/di'; | ||
| import { createStderrProgressHandler } from './progress'; | ||
| import { getConfigPath, getConfigDir } from '../hooks/utils/config'; | ||
|
|
||
| interface IInitCommandOptions { | ||
| yes?: boolean; | ||
|
|
@@ -245,14 +247,26 @@ export async function initCommand(options: IInitCommandOptions, logger?: ILogger | |
| writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n'); | ||
| console.log(`✓ Created ${settingsPath}`); | ||
|
|
||
| // .git-mem.json | ||
| const gitMemConfigPath = join(cwd, '.git-mem.json'); | ||
| const existingGitMemConfig = existsSync(gitMemConfigPath) | ||
| ? (() => { try { return JSON.parse(readFileSync(gitMemConfigPath, 'utf8')) as Record<string, unknown>; } catch { return {}; } })() | ||
| : {}; | ||
| // .git-mem/.git-mem.yaml | ||
| const configDir = getConfigDir(cwd); | ||
| const configPath = getConfigPath(cwd); | ||
| if (!existsSync(configDir)) { | ||
| mkdirSync(configDir, { recursive: true }); | ||
| } | ||
| const existingGitMemConfig = (() => { | ||
| if (!existsSync(configPath)) return {}; | ||
| try { | ||
| const parsed = parseYaml(readFileSync(configPath, 'utf8')); | ||
| return parsed && typeof parsed === 'object' && !Array.isArray(parsed) | ||
| ? (parsed as Record<string, unknown>) | ||
| : {}; | ||
| } catch { | ||
| return {}; | ||
| } | ||
| })(); | ||
| const mergedGitMemConfig = deepMergeGitMemConfig(existingGitMemConfig, buildGitMemConfig()); | ||
| writeFileSync(gitMemConfigPath, JSON.stringify(mergedGitMemConfig, null, 2) + '\n'); | ||
| console.log('✓ Created .git-mem.json'); | ||
| writeFileSync(configPath, stringifyYaml(mergedGitMemConfig)); | ||
| console.log('✓ Created .git-mem/.git-mem.yaml'); | ||
| } | ||
|
|
||
| // ── Git hooks (prepare-commit-msg, commit-msg, post-commit) ───── | ||
|
|
@@ -295,7 +309,7 @@ export async function initCommand(options: IInitCommandOptions, logger?: ILogger | |
| } | ||
|
|
||
| // ── .gitignore ───────────────────────────────────────────────── | ||
| ensureGitignoreEntries(cwd, ['.env', '.git-mem.json']); | ||
| ensureGitignoreEntries(cwd, ['.env', '.git-mem/']); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Search for .git-mem.json references in the codebase
rg -n "\.git-mem\.json" src/ --type ts
# Search for migration-related code and comments
rg -n "migrat|backward|compat" src/ --type ts -i
# Check the config loading mechanism mentioned in learnings
cat -n src/hooks/utils/config.tsRepository: TonyCasey/git-mem Length of output: 4911 🏁 Script executed: # Search for documentation about config changes
find . -maxdepth 2 -type f \( -name "README.md" -o -name "CHANGELOG.md" -o -name "CHANGES.md" \) -exec cat -n {} +
# Also check the init.ts file to see full context around line 312
cat -n src/commands/init.ts | sed -n '300,330p'Repository: TonyCasey/git-mem Length of output: 6917 🏁 Script executed: # Check for any test files that test migration scenarios
fd -e test.ts -e spec.ts | xargs rg -l "migration|git-mem\.json|backward" 2>/dev/null || echo "No migration tests found"
# Check the full init.ts to understand the broader context
wc -l src/commands/init.tsRepository: TonyCasey/git-mem Length of output: 222 🏁 Script executed: # Check if init.ts calls init-hooks.ts and understand the config architecture
sed -n '1,50p' src/commands/init.ts
sed -n '250,320p' src/commands/init.ts
# Check what init-hooks.ts is for (hook configuration vs general config)
head -30 src/commands/init-hooks.ts
# Check the IHookConfig interface to understand purpose
cat -n src/domain/interfaces/IHookConfig.tsRepository: TonyCasey/git-mem Length of output: 8058 🏁 Script executed: # Search for any migration logic in init.ts specifically
rg -n "migration|migrate|\.git-mem\.json|backward" src/commands/init.ts -C 3
# Check if there's any logic that references both .git-mem.json and .git-mem.yaml
rg -n "\.git-mem\.yaml|CONFIG_FILE|CONFIG_DIR" src/commands/init.ts -C 2Repository: TonyCasey/git-mem Length of output: 485 🏁 Script executed: # Confirm: does init-hooks.ts create .git-mem.json and is it being ignored?
grep -n "\.git-mem\.json" src/commands/init-hooks.ts | head -20
# Check what files are typically ignored in similar projects (user config files)
# Look at the comment/context around line 312
sed -n '305,320p' src/commands/init.ts
# Verify: .git-mem.json contains what kind of data
grep -A 5 "buildGitMemConfig\|buildHooksConfig" src/commands/init-hooks.ts | head -20Repository: TonyCasey/git-mem Length of output: 1692 🏁 Script executed: # Search for any gitignore related to .git-mem.json
rg -n "gitignore.*git-mem" src/ --type ts -i -C 2Repository: TonyCasey/git-mem Length of output: 897 Add The Update the ensureGitignoreEntries call to: (Note: The two configuration files— 🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a false positive. The purpose of this PR series is to migrate from
The only remaining reference to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 8718
Looking at the code:
My review comment was indeed a false positive. I apologize for the confusion. As you mentioned, there are still references to In the git-mem project, configuration migrated from 🧬 Code Graph Analysis Results
🧠 Learnings used
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The stacked PR approach is clean and keeps each change focused. I appreciate you explaining the roadmap! ✏️ Learnings added
⛔ Learnings removed🧠 Learnings used |
||
| console.log('✓ Updated .gitignore'); | ||
|
|
||
| // ── .env placeholder ────────────────────────────────────────── | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.