fix: installer copies default framework files (AGENTS.md) to mosaicHome (#363)
Some checks failed
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/publish Pipeline failed

This commit was merged in pull request #363.
This commit is contained in:
2026-04-03 02:34:43 +00:00
parent 70a51ba711
commit d4c5797a65
4 changed files with 30 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env node
import { resolve } from 'node:path';
import { existsSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Command } from 'commander';
@@ -49,7 +50,14 @@ program
.action(async (opts: Record<string, string | boolean | undefined>) => {
try {
const mosaicHome = (opts['mosaicHome'] as string) ?? DEFAULT_MOSAIC_HOME;
const sourceDir = (opts['sourceDir'] as string | undefined) ?? mosaicHome;
// Default source to the framework/ dir bundled in this npm package.
// This ensures syncFramework copies AGENTS.md, STANDARDS.md, guides/, etc.
// Falls back to mosaicHome if the bundled dir doesn't exist (shouldn't happen).
const pkgRoot = dirname(fileURLToPath(import.meta.url));
const bundledFramework = resolve(pkgRoot, '..', 'framework');
const sourceDir =
(opts['sourceDir'] as string | undefined) ??
(existsSync(bundledFramework) ? bundledFramework : mosaicHome);
const prompter = opts['nonInteractive'] ? new HeadlessPrompter() : new ClackPrompter();