feat(KB-503): merge kb/kb-503

- feat(KB-503): complete Step 5 other command project support
- fix(KB-503): align task resolution with shared project context
- fix(KB-503): preserve local task command fallback
- test(KB-503): complete Step 4 task command coverage
- test(KB-503): harden Step 3 CLI parser coverage
- fix(KB-503): keep settings set scope explicit
- fix(KB-503): allow implicit project resolution for project settings
- fix(KB-503): enforce explicit settings scope rules
- fix(KB-503): restore shared settings resolution behavior
- fix(KB-503): align settings scope and project flag behavior
- feat(KB-503): complete Step 5 — add project-aware settings, git, and backup behavior
- fix(KB-503): enforce settings scope for global and project modes
- fix(KB-503): preserve project-scoped settings and cwd-aware git helpers
- fix(KB-503): add scoped settings behavior and git project tests
- feat(KB-503): complete Step 5 — add project-aware git and backup coverage
- test(KB-503): cover remaining project-aware task command paths
- fix(KB-503): use shared resolution flow for all task commands
- fix(KB-503): restore legacy task fallback and correct task mocks
- fix(KB-503): align task resolution order and kb storage paths
- fix(KB-503): restore local task store fallback without project flag
- test(KB-503): cover remaining project-aware task handlers
- fix(KB-503): preserve branch naming and avoid duplicate log resolution
- test(KB-503): expand project-aware task command coverage
- fix(KB-503): restore cwd fallback for path-based task commands
- fix(KB-503): add project-aware task output and tests
- fix(KB-503): harden project command output and coverage
- fix(KB-503): preserve legacy task resolution without project flag
- test(KB-503): add bin routing coverage for project flag parsing
- feat(KB-503): complete Step 3 — CLI argument parsing updates
- fix(KB-503): add defaultProjectId to GlobalSettings type and fix TypeScript errors
- test(KB-503): fix resolveProject mock in task tests for runTaskLogs follow mode
- docs(KB-503): add multi-project CLI documentation and changeset
- test(KB-503): add project-context mock to task tests
- test(KB-503): update git tests for new cwd parameter
- feat(KB-503): Step 3 — CLI argument parsing updates with --project flag support
- feat(KB-503): Steps 1-2 — project context utilities and project subcommands
This commit is contained in:
gsxdsm
2026-04-01 15:06:58 -07:00
parent c6acedb432
commit 07adb42d64
37 changed files with 2500 additions and 5763 deletions

View File

@@ -1,7 +1,7 @@
import { writeFile } from "node:fs/promises";
import { existsSync } from "node:fs";
import { resolve, join } from "node:path";
import { TaskStore, exportSettings, generateExportFilename } from "@fusion/core";
import { resolveProject } from "../project-context.js";
/**
* Run settings export command.
@@ -9,40 +9,37 @@ import { TaskStore, exportSettings, generateExportFilename } from "@fusion/core"
*
* @param options.output - Custom output file path (optional, auto-generates if not provided)
* @param options.scope - Which settings to export: 'global', 'project', or 'both' (default: 'both')
* @param options.projectName - Optional project name for project-scoped export
*/
export async function runSettingsExport(options: {
output?: string;
scope?: "global" | "project" | "both";
projectName?: string;
} = {}): Promise<void> {
const store = new TaskStore(process.cwd());
await store.init();
const scope = options.scope ?? "both";
const project = options.projectName ? await resolveProject(options.projectName) : undefined;
const store = new TaskStore(project?.projectPath ?? process.cwd());
await store.init();
const outputPath = options.output;
try {
// Export settings
const exportData = await exportSettings(store, { scope });
// Determine output file path
let targetPath: string;
if (outputPath) {
targetPath = resolve(outputPath);
} else {
// Generate timestamped filename in current directory
const filename = generateExportFilename();
targetPath = join(process.cwd(), filename);
}
// Write to file with pretty-printed JSON
const jsonContent = JSON.stringify(exportData, null, 2);
await writeFile(targetPath, jsonContent);
// Output success message
console.log();
console.log(` ✓ Settings exported to ${targetPath}`);
// Show what was exported
const parts: string[] = [];
if (exportData.global) {
const globalKeys = Object.keys(exportData.global).filter(
@@ -60,12 +57,12 @@ export async function runSettingsExport(options: {
parts.push(`${projectKeys.length} project setting(s)`);
}
}
if (parts.length > 0) {
console.log(` Exported: ${parts.join(", ")}`);
}
console.log();
process.exit(0);
} catch (err) {
console.error(`Error: ${(err as Error).message}`);