everything-dev 1.28.4 → 1.28.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/init.cjs +78 -73
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +7 -1
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +7 -1
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +78 -74
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/sync.cjs +13 -2
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +13 -2
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +105 -1
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +106 -2
- package/dist/cli/upgrade.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli/init.mjs
CHANGED
|
@@ -243,6 +243,38 @@ function stripProductionFields(entry) {
|
|
|
243
243
|
delete entry.ssr;
|
|
244
244
|
delete entry.ssrIntegrity;
|
|
245
245
|
}
|
|
246
|
+
function buildRootTypecheckScript(sections) {
|
|
247
|
+
const commands = ["bun run types:gen"];
|
|
248
|
+
if (sections.ui) commands.push("if [ -d ui ]; then bun run --cwd ui typecheck; fi");
|
|
249
|
+
if (sections.api) commands.push("if [ -d api ]; then bun run --cwd api typecheck; fi");
|
|
250
|
+
if (sections.host) commands.push("if [ -d host ]; then bun run --cwd host typecheck; fi");
|
|
251
|
+
if (sections.plugins) commands.push("if [ -d plugins ]; then for dir in plugins/*; do if [ -f \"$dir/package.json\" ]; then bun run --cwd \"$dir\" typecheck; fi; done; fi");
|
|
252
|
+
return commands.join(" && ");
|
|
253
|
+
}
|
|
254
|
+
function buildChildRootScripts(sections) {
|
|
255
|
+
const scripts = {
|
|
256
|
+
dev: "node_modules/.bin/bos dev --host remote",
|
|
257
|
+
"dev:proxy": "node_modules/.bin/bos dev --proxy",
|
|
258
|
+
build: "node_modules/.bin/bos build",
|
|
259
|
+
deploy: "node_modules/.bin/bos build --deploy",
|
|
260
|
+
publish: "node_modules/.bin/bos publish",
|
|
261
|
+
start: "node_modules/.bin/bos start",
|
|
262
|
+
typecheck: buildRootTypecheckScript(sections),
|
|
263
|
+
lint: "biome check .",
|
|
264
|
+
"lint:fix": "biome check --write .",
|
|
265
|
+
format: "biome format --write .",
|
|
266
|
+
"format:check": "biome format .",
|
|
267
|
+
changeset: "changeset",
|
|
268
|
+
version: "changeset version",
|
|
269
|
+
release: "echo 'Packages versioned - app release handled by workflow'",
|
|
270
|
+
postinstall: "node_modules/.bin/bos types gen || true",
|
|
271
|
+
"types:gen": "node_modules/.bin/bos types gen",
|
|
272
|
+
bos: "node_modules/.bin/bos"
|
|
273
|
+
};
|
|
274
|
+
if (sections.ui) scripts["dev:ui"] = "node_modules/.bin/bos dev --ui local --api remote";
|
|
275
|
+
if (sections.api) scripts["dev:api"] = "node_modules/.bin/bos dev --ui remote --api local";
|
|
276
|
+
return scripts;
|
|
277
|
+
}
|
|
246
278
|
async function personalizeConfig(destination, opts) {
|
|
247
279
|
const has = (section) => opts.overrides.includes(section);
|
|
248
280
|
const explicitRootKeys = new Set(Object.entries(opts).filter(([key, value]) => value !== void 0 && ![
|
|
@@ -323,6 +355,17 @@ async function personalizeConfig(destination, opts) {
|
|
|
323
355
|
const pkgPath = join(destination, "package.json");
|
|
324
356
|
if (existsSync(pkgPath)) {
|
|
325
357
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
358
|
+
const childScripts = buildChildRootScripts({
|
|
359
|
+
ui: has("ui"),
|
|
360
|
+
api: has("api"),
|
|
361
|
+
host: has("host"),
|
|
362
|
+
plugins: has("plugins")
|
|
363
|
+
});
|
|
364
|
+
pkg.name = opts.domain || opts.extendsGateway;
|
|
365
|
+
pkg.private = true;
|
|
366
|
+
pkg.type = "module";
|
|
367
|
+
delete pkg.module;
|
|
368
|
+
delete pkg.peerDependencies;
|
|
326
369
|
if (pkg.workspaces && typeof pkg.workspaces === "object") {
|
|
327
370
|
const ws = pkg.workspaces;
|
|
328
371
|
if (Array.isArray(ws.packages)) {
|
|
@@ -337,31 +380,26 @@ async function personalizeConfig(destination, opts) {
|
|
|
337
380
|
}
|
|
338
381
|
}
|
|
339
382
|
}
|
|
340
|
-
if (pkg.scripts
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (!has("ui")) scripts.typecheck = scripts.typecheck.replace(/bun run --cwd ui tsc --noEmit & ?/, "");
|
|
361
|
-
if (!has("api")) scripts.typecheck = scripts.typecheck.replace(/bun run --cwd api tsc --noEmit & ?/, "");
|
|
362
|
-
if (!has("host")) scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, "");
|
|
363
|
-
}
|
|
364
|
-
}
|
|
383
|
+
if (!pkg.scripts || typeof pkg.scripts !== "object") pkg.scripts = {};
|
|
384
|
+
const scripts = pkg.scripts;
|
|
385
|
+
for (const [key, value] of Object.entries(childScripts)) scripts[key] = value;
|
|
386
|
+
for (const obsoleteScript of [
|
|
387
|
+
"init",
|
|
388
|
+
"sync-catalog",
|
|
389
|
+
"db:push",
|
|
390
|
+
"db:studio",
|
|
391
|
+
"db:generate",
|
|
392
|
+
"db:migrate",
|
|
393
|
+
"test",
|
|
394
|
+
"test:api",
|
|
395
|
+
"test:integration",
|
|
396
|
+
"test:e2e",
|
|
397
|
+
"dev:postgres",
|
|
398
|
+
"dev:postgres:down",
|
|
399
|
+
"dev:postgres:reset",
|
|
400
|
+
"dev:ui",
|
|
401
|
+
"dev:api"
|
|
402
|
+
]) if (!(obsoleteScript in childScripts)) delete scripts[obsoleteScript];
|
|
365
403
|
if (pkg.devDependencies && typeof pkg.devDependencies === "object") {
|
|
366
404
|
const deps = pkg.devDependencies;
|
|
367
405
|
delete deps["every-plugin"];
|
|
@@ -422,6 +460,14 @@ async function personalizeConfig(destination, opts) {
|
|
|
422
460
|
mkdirSync(dirname(authTypesGenPath), { recursive: true });
|
|
423
461
|
writeFileSync(authTypesGenPath, authTypesContent);
|
|
424
462
|
}
|
|
463
|
+
if (has("plugins")) for (const plugin of opts.plugins ?? []) {
|
|
464
|
+
const pluginSrcDir = join(destination, "plugins", plugin, "src");
|
|
465
|
+
const pluginIndexPath = join(pluginSrcDir, "index.ts");
|
|
466
|
+
const pluginClientGenPath = join(pluginSrcDir, "plugins-client.gen.ts");
|
|
467
|
+
if (!existsSync(pluginIndexPath) || existsSync(pluginClientGenPath)) continue;
|
|
468
|
+
if (!readFileSync(pluginIndexPath, "utf-8").includes("./plugins-client.gen")) continue;
|
|
469
|
+
writeFileSync(pluginClientGenPath, "export type PluginsClient = Record<string, never>;\n");
|
|
470
|
+
}
|
|
425
471
|
}
|
|
426
472
|
function generateAuthTypesTemplate() {
|
|
427
473
|
return `import type { Auth } from "better-auth";
|
|
@@ -484,17 +530,6 @@ async function runTypesGen(destination, spinner) {
|
|
|
484
530
|
await runWithProgress("node_modules/.bin/bos", ["types", "gen"], destination, spinner, "Generating types");
|
|
485
531
|
return;
|
|
486
532
|
}
|
|
487
|
-
if (existsSync(join(destination, "packages", "everything-dev", "src", "cli.ts"))) {
|
|
488
|
-
await runWithProgress("bun", [
|
|
489
|
-
"run",
|
|
490
|
-
"--cwd",
|
|
491
|
-
"packages/everything-dev",
|
|
492
|
-
"src/cli.ts",
|
|
493
|
-
"types",
|
|
494
|
-
"gen"
|
|
495
|
-
], destination, spinner, "Generating types");
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
533
|
throw new Error("Unable to locate bos CLI for types generation");
|
|
499
534
|
}
|
|
500
535
|
async function runDockerComposeUp(destination) {
|
|
@@ -551,10 +586,6 @@ function removeInitLockfile(lockfilePath) {
|
|
|
551
586
|
if (!existsSync(lockfilePath)) return;
|
|
552
587
|
rmSync(lockfilePath, { force: true });
|
|
553
588
|
}
|
|
554
|
-
const WORKSPACE_LOCAL_PATHS = {
|
|
555
|
-
"everything-dev": "packages/everything-dev",
|
|
556
|
-
"every-plugin": "packages/every-plugin"
|
|
557
|
-
};
|
|
558
589
|
function readJsonFile(filePath) {
|
|
559
590
|
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
560
591
|
}
|
|
@@ -651,19 +682,12 @@ async function scaffoldMinimalProject(destination, parentConfig, opts) {
|
|
|
651
682
|
name: opts.domain || opts.extendsGateway,
|
|
652
683
|
private: true,
|
|
653
684
|
type: "module",
|
|
654
|
-
scripts: {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
publish: "node_modules/.bin/bos publish",
|
|
661
|
-
start: "node_modules/.bin/bos start",
|
|
662
|
-
typecheck: "node_modules/.bin/bos types gen && tsc --noEmit",
|
|
663
|
-
postinstall: "node_modules/.bin/bos types gen || true",
|
|
664
|
-
"types:gen": "node_modules/.bin/bos types gen",
|
|
665
|
-
bos: "node_modules/.bin/bos"
|
|
666
|
-
},
|
|
685
|
+
scripts: buildChildRootScripts({
|
|
686
|
+
ui: has("ui"),
|
|
687
|
+
api: has("api"),
|
|
688
|
+
host: has("host"),
|
|
689
|
+
plugins: has("plugins")
|
|
690
|
+
}),
|
|
667
691
|
dependencies: {
|
|
668
692
|
"everything-dev": "catalog:",
|
|
669
693
|
"every-plugin": "catalog:"
|
|
@@ -688,26 +712,6 @@ async function resolveWorkspaceRefs(destination, options) {
|
|
|
688
712
|
preserveCatalogRefs: true,
|
|
689
713
|
removeWorkspaceDeps: ["host"]
|
|
690
714
|
});
|
|
691
|
-
if (options?.localOverrides && options.sourceDir) {
|
|
692
|
-
const rootPkgPath = join(destination, "package.json");
|
|
693
|
-
if (existsSync(rootPkgPath)) {
|
|
694
|
-
const pkg = JSON.parse(readFileSync(rootPkgPath, "utf-8"));
|
|
695
|
-
if (!pkg.overrides) pkg.overrides = {};
|
|
696
|
-
const overrides = pkg.overrides;
|
|
697
|
-
const rootWorkspaces = (pkg.workspaces?.packages ?? []).filter(Boolean);
|
|
698
|
-
for (const [name, relPath] of Object.entries(WORKSPACE_LOCAL_PATHS)) if (!rootWorkspaces.some((ws) => ws === relPath || ws === `plugins/${name}`)) {
|
|
699
|
-
if (existsSync(join(options.sourceDir, relPath, "package.json"))) {
|
|
700
|
-
overrides[name] = `file:${relPath}`;
|
|
701
|
-
rootWorkspaces.push(relPath);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
if (rootWorkspaces.length > 0) {
|
|
705
|
-
if (!pkg.workspaces) pkg.workspaces = {};
|
|
706
|
-
pkg.workspaces.packages = rootWorkspaces;
|
|
707
|
-
}
|
|
708
|
-
writeFileSync(rootPkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
715
|
}
|
|
712
716
|
async function writeInitSnapshot(destination, extendsAccount, extendsGateway, sourceDir, patterns, _options) {
|
|
713
717
|
const allFiles = /* @__PURE__ */ new Set();
|
|
@@ -816,5 +820,5 @@ dist/
|
|
|
816
820
|
}
|
|
817
821
|
|
|
818
822
|
//#endregion
|
|
819
|
-
export { INIT_ROOT_PATTERNS, buildInitPatterns, copyFilteredFiles, detectGitRemoteUrl, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, removeInitLockfile, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runBunInstallForUpgrade, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, sourcePathToDestinationPath, stripOrphanedWorkspacesFromLockfile, writeInitSnapshot };
|
|
823
|
+
export { INIT_ROOT_PATTERNS, buildChildRootScripts, buildInitPatterns, copyFilteredFiles, detectGitRemoteUrl, downloadTarball, execCommand, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, removeInitLockfile, resolveRepositoryViaExtendsChain, resolveSourceDir, runBunInstall, runBunInstallForUpgrade, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, sourcePathToDestinationPath, stripOrphanedWorkspacesFromLockfile, writeInitSnapshot };
|
|
820
824
|
//# sourceMappingURL=init.mjs.map
|
package/dist/cli/init.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.mjs","names":[],"sources":["../../src/cli/init.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n createWriteStream,\n existsSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { execa } from \"execa\";\nimport { glob } from \"glob\";\nimport type { OverrideSection } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport {\n loadManifestNormalizationSpec,\n normalizePackageManifestsInTree,\n} from \"../internal/manifest-normalizer\";\nimport type { BosConfig, BosConfigInput } from \"../types\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst require = createRequire(import.meta.url);\n\nexport const INIT_ROOT_PATTERNS = [\n \"bos.config.json\",\n \"package.json\",\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bunfig.toml\",\n \"Dockerfile\",\n \"railway.json\",\n \".agent/**\",\n \"AGENTS.md\",\n \".opencode/skills/everything-dev/**\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \"README.md\",\n \"CONTRIBUTING.md\",\n \".github/templates/**\",\n] as const;\n\nconst FRAMEWORK_PACKAGES = [\"every-plugin\", \"everything-dev\"] as const;\n\nconst OVERRIDE_WORKSPACE_MAP: Record<OverrideSection, string[]> = {\n ui: [\"ui\"],\n api: [\"api\"],\n host: [\"host\"],\n plugins: [],\n};\n\ninterface SourceResult {\n sourceDir: string;\n parentConfig: BosConfig;\n cleanup: () => Promise<void>;\n}\n\nexport async function resolveSourceDir(opts: {\n extendsAccount: string;\n extendsGateway: string;\n source?: string;\n}): Promise<SourceResult> {\n if (opts.source) {\n const sourceDir = resolve(opts.source);\n if (!existsSync(join(sourceDir, \"bos.config.json\"))) {\n throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);\n }\n const parentConfig = JSON.parse(\n readFileSync(join(sourceDir, \"bos.config.json\"), \"utf-8\"),\n ) as BosConfig;\n return { sourceDir, parentConfig, cleanup: async () => {} };\n }\n\n const parentConfig = await fetchParentConfig(opts.extendsAccount, opts.extendsGateway);\n\n if (parentConfig.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);\n return { sourceDir, parentConfig, cleanup };\n }\n\n const chainResult = await resolveRepositoryViaExtendsChain(\n opts.extendsAccount,\n opts.extendsGateway,\n );\n if (chainResult?.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(chainResult.repository);\n return { sourceDir, parentConfig: chainResult.config, cleanup };\n }\n\n return {\n sourceDir: \"\",\n parentConfig,\n cleanup: async () => {},\n };\n}\n\nexport function buildInitPatterns(overrides: OverrideSection[], plugins?: string[]): string[] {\n const has = (section: OverrideSection) => overrides.includes(section);\n const patterns: string[] = [...INIT_ROOT_PATTERNS];\n\n if (has(\"ui\")) patterns.push(\"ui/**\");\n if (has(\"api\")) patterns.push(\"api/**\");\n if (has(\"host\")) patterns.push(\"host/**\");\n if (has(\"plugins\")) {\n for (const plugin of plugins ?? []) {\n patterns.push(`plugins/${plugin}/**`);\n }\n }\n\n return patterns;\n}\n\nexport function sourcePathToDestinationPath(filePath: string): string {\n return filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath;\n}\n\nexport async function fetchParentConfig(\n extendsAccount: string,\n extendsGateway: string,\n): Promise<BosConfig> {\n const bosUrl = `bos://${extendsAccount}/${extendsGateway}`;\n return fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n}\n\nexport async function resolveRepositoryViaExtendsChain(\n extendsAccount: string,\n extendsGateway: string,\n visited = new Set<string>(),\n): Promise<{ repository: string; config: BosConfig } | null> {\n const key = `bos://${extendsAccount}/${extendsGateway}`;\n if (visited.has(key)) return null;\n visited.add(key);\n\n try {\n const config = await fetchParentConfig(extendsAccount, extendsGateway);\n if (config.repository) {\n return { repository: config.repository, config };\n }\n\n const extendsRef = config.extends;\n if (extendsRef && typeof extendsRef === \"string\") {\n const normalized = extendsRef.startsWith(\"bos://\") ? extendsRef : `bos://${extendsRef}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (match) {\n const result = await resolveRepositoryViaExtendsChain(match[1], match[2], visited);\n if (result) return result;\n }\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\nexport async function detectGitRemoteUrl(directory: string): Promise<string | undefined> {\n try {\n const { stdout } = await execa(\"git\", [\"remote\", \"get-url\", \"origin\"], {\n cwd: directory,\n stdio: \"pipe\",\n });\n const url = stdout.trim();\n if (!url) return undefined;\n return normalizeGitUrl(url);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeGitUrl(url: string): string | undefined {\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return `https://github.com/${sshMatch[1]}/${sshMatch[2]}`;\n }\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return `https://github.com/${httpsMatch[1]}/${httpsMatch[2]}`;\n }\n return url.endsWith(\".git\") ? url.slice(0, -4) : url;\n}\n\nexport async function downloadTarball(\n repoUrl: string,\n): Promise<{ dir: string; cleanup: () => Promise<void> }> {\n const parsed = parseGitHubUrl(repoUrl);\n if (!parsed) {\n throw new Error(`Cannot parse repository URL: ${repoUrl}`);\n }\n\n const { owner, repo, branch } = parsed;\n const tarballUrl = `https://api.github.com/repos/${owner}/${repo}/tarball/${branch}`;\n\n const tmpDir = mkTmpDir(\"bos-init-tarball-\");\n const tarballPath = join(tmpDir, \"source.tar.gz\");\n\n const response = await fetch(tarballUrl, {\n headers: { \"User-Agent\": \"everything-dev\" },\n redirect: \"follow\",\n });\n\n if (!response.ok) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(`GitHub tarball download failed: ${response.status} ${response.statusText}`);\n }\n\n if (!response.body) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(\"GitHub tarball download returned empty body\");\n }\n\n const fileStream = createWriteStream(tarballPath);\n const reader = response.body as unknown as NodeJS.ReadableStream;\n await pipeline(reader, fileStream);\n\n const extractDir = mkTmpDir(\"bos-init-extract-\");\n try {\n const tar = require(\"tar\") as {\n extract: (opts: { cwd: string; file: string; strip: number }) => Promise<void>;\n };\n await tar.extract({ cwd: extractDir, file: tarballPath, strip: 1 });\n } catch {\n await execCommand(\"tar\", [\"-xzf\", tarballPath, \"--strip-components=1\", \"-C\", extractDir]);\n }\n\n rmSync(tmpDir, { recursive: true, force: true });\n\n return {\n dir: extractDir,\n cleanup: async () => {\n rmSync(extractDir, { recursive: true, force: true });\n },\n };\n}\n\nfunction parseGitHubUrl(url: string): { owner: string; repo: string; branch: string } | null {\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return { owner: httpsMatch[1], repo: httpsMatch[2], branch: \"main\" };\n }\n\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return { owner: sshMatch[1], repo: sshMatch[2], branch: \"main\" };\n }\n\n return null;\n}\n\nexport async function copyFilteredFiles(\n sourceDir: string,\n destination: string,\n patterns: string[],\n _options: {\n overrides: OverrideSection[];\n plugins?: string[];\n },\n): Promise<number> {\n if (patterns.length === 0) {\n return 0;\n }\n\n const allFiles = new Set<string>();\n for (const pattern of patterns) {\n const matches = await glob(pattern, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n ignore: [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \"**/.bos/**\"],\n });\n for (const match of matches) {\n allFiles.add(match);\n }\n }\n\n mkdirSync(destination, { recursive: true });\n\n let count = 0;\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n\n const destPath = sourcePathToDestinationPath(filePath);\n const dest = join(destination, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n const content = readFileSync(src);\n writeFileSync(dest, content);\n count++;\n }\n\n return count;\n}\n\nfunction stripProductionFields(entry: Record<string, unknown>): void {\n delete entry.production;\n delete entry.integrity;\n delete entry.ssr;\n delete entry.ssrIntegrity;\n}\n\nexport async function personalizeConfig(\n destination: string,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides: OverrideSection[];\n pluginRoutes?: Record<string, string[]>;\n workspaceOpts?: { localOverrides?: boolean; sourceDir?: string };\n mode?: \"init\" | \"sync\";\n existingConfig?: Record<string, unknown>;\n repository?: string;\n title?: string;\n description?: string;\n testnet?: string;\n staging?: unknown;\n },\n): Promise<void> {\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\n const explicitRootKeys = new Set(\n Object.entries(opts)\n .filter(\n ([key, value]) =>\n value !== undefined &&\n ![\n \"extendsAccount\",\n \"extendsGateway\",\n \"plugins\",\n \"overrides\",\n \"pluginRoutes\",\n \"workspaceOpts\",\n \"mode\",\n \"existingConfig\",\n ].includes(key),\n )\n .map(([key]) => key),\n );\n\n const configPath = join(destination, \"bos.config.json\");\n if (existsSync(configPath)) {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n config.extends = `bos://${opts.extendsAccount}/${opts.extendsGateway}`;\n\n if (opts.account) {\n config.account = opts.account;\n }\n if (opts.domain) {\n config.domain = opts.domain;\n }\n if (opts.repository) {\n config.repository = opts.repository;\n } else {\n delete config.repository;\n }\n\n const inheritableFields = [\"title\", \"description\", \"testnet\", \"staging\"] as const;\n for (const field of inheritableFields) {\n if (!(field in opts)) {\n delete config[field];\n }\n }\n\n if (config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n\n for (const entryKey of Object.keys(app)) {\n if (\n !has(entryKey as OverrideSection) &&\n (entryKey === \"host\" || entryKey === \"ui\" || entryKey === \"api\" || entryKey === \"auth\")\n ) {\n delete app[entryKey];\n continue;\n }\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n stripProductionFields(entry as Record<string, unknown>);\n }\n }\n }\n\n if (has(\"plugins\")) {\n if (config.plugins && typeof config.plugins === \"object\") {\n const plugins = config.plugins as Record<string, unknown>;\n\n if (opts.plugins !== undefined) {\n for (const pluginKey of Object.keys(plugins)) {\n if (!opts.plugins.includes(pluginKey)) {\n delete plugins[pluginKey];\n }\n }\n }\n\n for (const pluginKey of Object.keys(plugins)) {\n const plugin = plugins[pluginKey];\n let pluginObj: Record<string, unknown>;\n\n if (typeof plugin === \"string\") {\n pluginObj = { extends: plugin };\n plugins[pluginKey] = pluginObj;\n } else if (plugin && typeof plugin === \"object\") {\n pluginObj = { ...(plugin as Record<string, unknown>) };\n plugins[pluginKey] = pluginObj;\n } else {\n continue;\n }\n\n stripProductionFields(pluginObj);\n }\n\n if (Object.keys(plugins).length === 0) {\n delete config.plugins;\n }\n }\n } else {\n delete config.plugins;\n }\n\n if (opts.mode === \"sync\" && opts.existingConfig) {\n const managedRootKeys = new Set([\"extends\", \"account\", \"domain\", \"app\", \"plugins\", \"shared\"]);\n const preservedRootKeys = new Set([\n ...managedRootKeys,\n ...Object.keys(opts.existingConfig),\n ...explicitRootKeys,\n ]);\n\n for (const key of Object.keys(config)) {\n if (!preservedRootKeys.has(key)) {\n delete config[key];\n }\n }\n\n for (const [key, value] of Object.entries(opts.existingConfig)) {\n if (!(key in config) && !managedRootKeys.has(key) && !explicitRootKeys.has(key)) {\n config[key] = value;\n }\n }\n }\n\n await saveBosConfig(destination, config);\n }\n\n const pkgPath = join(destination, \"package.json\");\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n\n if (pkg.workspaces && typeof pkg.workspaces === \"object\") {\n const ws = pkg.workspaces as { packages?: string[] };\n if (Array.isArray(ws.packages)) {\n ws.packages = ws.packages.filter((p: string) => {\n if (p.startsWith(\"packages/\")) return false;\n if (p === \"host\") return has(\"host\");\n if (p.startsWith(\"plugins/\")) return false;\n return true;\n });\n\n if (has(\"plugins\")) {\n if (!ws.packages.includes(\"plugins/*\")) {\n ws.packages.push(\"plugins/*\");\n }\n }\n }\n }\n\n if (pkg.scripts && typeof pkg.scripts === \"object\") {\n const scripts = pkg.scripts as Record<string, string>;\n const FROM = \"bun packages/everything-dev/src/cli.ts\";\n const TO = \"node_modules/.bin/bos\";\n const rewrite = (key: string) => {\n if (scripts[key]?.includes(FROM)) {\n scripts[key] = scripts[key].replaceAll(FROM, TO);\n }\n };\n rewrite(\"dev\");\n rewrite(\"dev:ui\");\n rewrite(\"dev:api\");\n rewrite(\"dev:proxy\");\n rewrite(\"build\");\n rewrite(\"deploy\");\n rewrite(\"publish\");\n rewrite(\"start\");\n rewrite(\"bos\");\n scripts.postinstall = \"node_modules/.bin/bos types gen || true\";\n scripts[\"types:gen\"] = \"node_modules/.bin/bos types gen\";\n if (scripts.typecheck) {\n scripts.typecheck = scripts.typecheck\n .replace(\"bun run types:gen && \", \"\")\n .replace(/bun run --cwd packages\\/everything-dev typecheck & ?/, \"\");\n if (!has(\"ui\")) {\n scripts.typecheck = scripts.typecheck.replace(/bun run --cwd ui tsc --noEmit & ?/, \"\");\n }\n if (!has(\"api\")) {\n scripts.typecheck = scripts.typecheck.replace(/bun run --cwd api tsc --noEmit & ?/, \"\");\n }\n if (!has(\"host\")) {\n scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, \"\");\n }\n }\n }\n\n if (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n const deps = pkg.devDependencies as Record<string, string>;\n delete deps[\"every-plugin\"];\n delete deps[\"everything-dev\"];\n }\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n }\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n }\n\n if (!pkg.dependencies) pkg.dependencies = {};\n const deps = pkg.dependencies as Record<string, string>;\n const spec = opts.workspaceOpts?.sourceDir\n ? loadManifestNormalizationSpec(opts.workspaceOpts.sourceDir)\n : null;\n if (spec) {\n workspaces.catalog[\"everything-dev\"] = spec.rootCatalog[\"everything-dev\"];\n workspaces.catalog[\"every-plugin\"] = spec.rootCatalog[\"every-plugin\"];\n }\n const frameworkCatalog = resolveFrameworkCatalog();\n for (const [name, version] of Object.entries(frameworkCatalog)) {\n workspaces.catalog[name] = version;\n }\n if (!deps[\"everything-dev\"]) deps[\"everything-dev\"] = \"catalog:\";\n if (!deps[\"every-plugin\"]) deps[\"every-plugin\"] = \"catalog:\";\n\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n const apiTsConfigPath = join(destination, \"api\", \"tsconfig.json\");\n if (existsSync(apiTsConfigPath)) {\n const apiTsConfig = JSON.parse(readFileSync(apiTsConfigPath, \"utf-8\")) as {\n files?: string[];\n [key: string]: unknown;\n };\n if (apiTsConfig.files) {\n const validFiles = apiTsConfig.files.filter((f) => existsSync(join(destination, \"api\", f)));\n if (validFiles.length !== apiTsConfig.files.length) {\n if (validFiles.length === 0) {\n delete apiTsConfig.files;\n } else {\n apiTsConfig.files = validFiles;\n }\n writeFileSync(apiTsConfigPath, `${JSON.stringify(apiTsConfig, null, 2)}\\n`);\n }\n }\n }\n\n await resolveWorkspaceRefs(destination, opts.workspaceOpts);\n\n if (has(\"ui\")) {\n const genContractPath = join(destination, \"ui\", \"src\", \"lib\", \"api-types.gen.ts\");\n if (!existsSync(genContractPath)) {\n mkdirSync(dirname(genContractPath), { recursive: true });\n writeFileSync(genContractPath, `export type ApiContract = Record<string, never>;\\n`);\n }\n }\n\n if (has(\"api\")) {\n const pluginsClientGenPath = join(destination, \"api\", \"src\", \"lib\", \"plugins-types.gen.ts\");\n if (!existsSync(pluginsClientGenPath)) {\n mkdirSync(dirname(pluginsClientGenPath), { recursive: true });\n writeFileSync(\n pluginsClientGenPath,\n `import type { ContractRouterClient, AnyContractRouter } from \"@orpc/contract\";\\ntype ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;\\nexport type PluginsClient = Record<string, never>;\\n`,\n );\n }\n }\n\n const authTypesContent = generateAuthTypesTemplate();\n const authTypesPaths: string[] = [];\n if (has(\"ui\")) {\n authTypesPaths.push(join(destination, \"ui\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"api\")) {\n authTypesPaths.push(join(destination, \"api\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"host\") && existsSync(join(destination, \"host\", \"src\"))) {\n authTypesPaths.push(join(destination, \"host\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n for (const authTypesGenPath of authTypesPaths) {\n if (!existsSync(authTypesGenPath)) {\n mkdirSync(dirname(authTypesGenPath), { recursive: true });\n writeFileSync(authTypesGenPath, authTypesContent);\n }\n }\n}\n\nfunction generateAuthTypesTemplate(): string {\n return `import type { Auth } from \"better-auth\";\nexport type { Auth } from \"better-auth\";\nexport type AuthSessionUser = NonNullable<Auth[\"$Infer\"][\"Session\"][\"user\"]> & {\n role?: string | null;\n isAnonymous?: boolean | null;\n walletAddress?: string | null;\n banned?: boolean | null;\n};\nexport type AuthSessionData = NonNullable<Auth[\"$Infer\"][\"Session\"][\"session\"]> & {\n activeOrganizationId?: string | null;\n};\nexport type AuthSession = {\n user: AuthSessionUser | null;\n session: AuthSessionData | null;\n};\nexport interface AuthOrganizationContext {\n activeOrganizationId: string | null;\n organization: { id: string; name: string; slug: string; logo?: string | null; metadata?: Record<string, unknown> } | null;\n member: { id: string; role: string } | null;\n isPersonal: boolean;\n hasOrganization: boolean;\n}\nexport interface AuthRequestContext {\n user: AuthSessionUser | null;\n userId: string | null;\n isAuthenticated: boolean;\n authMethod: \"session\" | \"apiKey\" | \"anonymous\" | \"none\";\n near: {\n primaryAccountId: string | null;\n linkedAccounts: Array<{ accountId: string; network: string; publicKey: string; isPrimary: boolean }>;\n hasNearAccount: boolean;\n };\n organization: AuthOrganizationContext;\n organizations?: Array<{ id: string; role: string; name?: string; slug?: string }>;\n}\nexport type AuthActiveMember = { id: string | null; role: string | null; organizationId: string | null };\nexport type AuthOrganization = NonNullable<AuthOrganizationContext[\"organization\"]>;\nexport type AuthOrganizationMember = NonNullable<AuthOrganizationContext[\"member\"]>;\nexport type AuthOrganizationSummary = NonNullable<AuthRequestContext[\"organizations\"]>[number];\nexport type AuthBaseSession = Auth[\"$Infer\"][\"Session\"];\nexport type createAuthInstance = never;\nexport interface AuthServices {\n auth: Auth;\n db: unknown;\n driver: { close(): Promise<void> };\n handler: (req: Request) => Promise<Response>;\n}\n`;\n}\n\nexport async function runBunInstall(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"bun\",\n [\"install\", \"--ignore-scripts\"],\n destination,\n spinner,\n \"Installing dependencies\",\n );\n}\n\nexport async function runBunInstallForUpgrade(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"bun\",\n [\"install\", \"--force\"],\n destination,\n spinner,\n \"Installing dependencies\",\n );\n}\n\nexport async function runTypesGen(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n const localBosBin = join(destination, \"node_modules\", \".bin\", \"bos\");\n if (existsSync(localBosBin)) {\n await runWithProgress(\n \"node_modules/.bin/bos\",\n [\"types\", \"gen\"],\n destination,\n spinner,\n \"Generating types\",\n );\n return;\n }\n\n const localCli = join(destination, \"packages\", \"everything-dev\", \"src\", \"cli.ts\");\n if (existsSync(localCli)) {\n await runWithProgress(\n \"bun\",\n [\"run\", \"--cwd\", \"packages/everything-dev\", \"src/cli.ts\", \"types\", \"gen\"],\n destination,\n spinner,\n \"Generating types\",\n );\n return;\n }\n\n throw new Error(\"Unable to locate bos CLI for types generation\");\n}\n\nexport async function runDockerComposeUp(destination: string): Promise<void> {\n await execCommand(\"docker\", [\"compose\", \"up\", \"-d\", \"--wait\"], destination, { stdio: \"inherit\" });\n}\n\nasync function runWithProgress(\n command: string,\n args: string[],\n cwd: string,\n spinner: { message: (msg: string) => void } | undefined,\n label: string,\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n const child = execa(command, args, { cwd, stdio: \"inherit\", timeout });\n\n if (spinner) {\n const start = Date.now();\n const interval = setInterval(() => {\n const elapsed = Math.round((Date.now() - start) / 1000);\n spinner.message(`${label}... (${elapsed}s)`);\n }, 2000);\n try {\n await child;\n } finally {\n clearInterval(interval);\n }\n } else {\n await child;\n }\n}\n\nexport function stripOrphanedWorkspacesFromLockfile(\n lockfilePath: string,\n allowedWorkspaces: string[],\n): void {\n if (!existsSync(lockfilePath)) return;\n\n const content = readFileSync(lockfilePath, \"utf-8\");\n let lockfile: Record<string, unknown>;\n try {\n lockfile = JSON.parse(content) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const workspaces = lockfile.workspaces;\n if (!workspaces || typeof workspaces !== \"object\") return;\n\n const workspaceMap = workspaces as Record<string, unknown>;\n const allowed = new Set([\"\", ...allowedWorkspaces]);\n\n const keys = Object.keys(workspaceMap);\n let changed = false;\n for (const key of keys) {\n if (allowed.has(key)) continue;\n if (\n allowedWorkspaces.some(\n (pattern) => pattern.endsWith(\"/*\") && key.startsWith(pattern.slice(0, -1)),\n )\n )\n continue;\n delete workspaceMap[key];\n changed = true;\n }\n\n if (changed) {\n writeFileSync(lockfilePath, `${JSON.stringify(lockfile, null, 2)}\\n`);\n }\n}\n\nexport function removeInitLockfile(lockfilePath: string): void {\n if (!existsSync(lockfilePath)) return;\n rmSync(lockfilePath, { force: true });\n}\n\nconst WORKSPACE_LOCAL_PATHS: Record<string, string> = {\n \"everything-dev\": \"packages/everything-dev\",\n \"every-plugin\": \"packages/every-plugin\",\n};\n\nfunction readJsonFile<T>(filePath: string): T {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as T;\n}\n\nfunction tryResolvePackageJson(packageName: string): string | null {\n try {\n return require.resolve(`${packageName}/package.json`);\n } catch {\n return null;\n }\n}\n\nfunction resolveFrameworkCatalog(): Record<string, string> {\n const catalog: Record<string, string> = {};\n const everythingDevPackageJson = tryResolvePackageJson(\"everything-dev\");\n\n if (everythingDevPackageJson) {\n try {\n const selfPkgDir = dirname(everythingDevPackageJson);\n const monorepoPkgPath = join(selfPkgDir, \"..\", \"..\", \"package.json\");\n if (existsSync(monorepoPkgPath)) {\n const monorepoPkg = readJsonFile<{\n workspaces?: { catalog?: Record<string, string> };\n }>(monorepoPkgPath);\n const sourceCatalog = monorepoPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\") {\n catalog[name] = version;\n }\n }\n }\n }\n } catch {}\n\n try {\n const selfPkg = readJsonFile<{\n version?: string;\n workspaces?: { catalog?: Record<string, string> };\n }>(everythingDevPackageJson);\n if (selfPkg.version && !catalog[\"everything-dev\"]) {\n catalog[\"everything-dev\"] = `^${selfPkg.version}`;\n }\n const sourceCatalog = selfPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\" && !catalog[name]) {\n catalog[name] = version;\n }\n }\n }\n } catch {}\n }\n\n for (const packageName of FRAMEWORK_PACKAGES) {\n const resolved = tryResolvePackageJson(packageName);\n if (!resolved) continue;\n\n try {\n const pkg = readJsonFile<{ version?: string }>(resolved);\n if (pkg.version) {\n catalog[packageName] = `^${pkg.version}`;\n }\n } catch {}\n }\n\n return catalog;\n}\n\nexport async function scaffoldMinimalProject(\n destination: string,\n parentConfig: BosConfigInput,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides: OverrideSection[];\n repository?: string;\n title?: string;\n description?: string;\n },\n): Promise<number> {\n mkdirSync(destination, { recursive: true });\n\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\n const config: Record<string, unknown> = {\n extends: `bos://${opts.extendsAccount}/${opts.extendsGateway}`,\n account: opts.account || opts.extendsAccount,\n ...(opts.domain ? { domain: opts.domain } : {}),\n ...(opts.repository ? { repository: opts.repository } : {}),\n ...(opts.title ? { title: opts.title } : {}),\n ...(opts.description ? { description: opts.description } : {}),\n };\n\n if (parentConfig.app && typeof parentConfig.app === \"object\") {\n const app: Record<string, unknown> = {};\n const parentApp = parentConfig.app as Record<string, Record<string, unknown>>;\n\n if (has(\"host\") && parentApp.host) {\n app.host = { ...parentApp.host };\n stripProductionFields(app.host as Record<string, unknown>);\n }\n\n if (has(\"ui\") && parentApp.ui) {\n app.ui = { ...parentApp.ui };\n stripProductionFields(app.ui as Record<string, unknown>);\n }\n\n if (has(\"api\") && parentApp.api) {\n app.api = { ...parentApp.api };\n stripProductionFields(app.api as Record<string, unknown>);\n }\n\n if (has(\"plugins\") && parentApp.auth) {\n app.auth = { ...parentApp.auth };\n stripProductionFields(app.auth as Record<string, unknown>);\n }\n\n if (Object.keys(app).length > 0) {\n config.app = app;\n }\n }\n\n if (has(\"plugins\") && opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {\n const plugins: Record<string, unknown> = {};\n for (const key of opts.plugins) {\n const parentPlugin = (parentConfig.plugins as Record<string, unknown>)?.[key];\n if (parentPlugin) {\n if (typeof parentPlugin === \"string\") {\n plugins[key] = { extends: parentPlugin };\n } else {\n const pluginCopy = { ...(parentPlugin as Record<string, unknown>) };\n stripProductionFields(pluginCopy);\n plugins[key] = pluginCopy;\n }\n }\n }\n config.plugins = plugins;\n }\n\n await saveBosConfig(destination, config);\n\n const workspacePackages: string[] = [];\n for (const section of opts.overrides) {\n workspacePackages.push(...OVERRIDE_WORKSPACE_MAP[section]);\n }\n if (has(\"plugins\")) {\n workspacePackages.push(\"plugins/*\");\n }\n\n const catalog = resolveFrameworkCatalog();\n\n const pkg: Record<string, unknown> = {\n name: opts.domain || opts.extendsGateway,\n private: true,\n type: \"module\",\n scripts: {\n dev: \"node_modules/.bin/bos dev --host remote\",\n \"dev:ui\": \"node_modules/.bin/bos dev --ui local --api remote\",\n \"dev:api\": \"node_modules/.bin/bos dev --ui remote --api local\",\n build: \"node_modules/.bin/bos build\",\n deploy: \"node_modules/.bin/bos build --deploy\",\n publish: \"node_modules/.bin/bos publish\",\n start: \"node_modules/.bin/bos start\",\n typecheck: \"node_modules/.bin/bos types gen && tsc --noEmit\",\n postinstall: \"node_modules/.bin/bos types gen || true\",\n \"types:gen\": \"node_modules/.bin/bos types gen\",\n bos: \"node_modules/.bin/bos\",\n },\n dependencies: {\n \"everything-dev\": \"catalog:\",\n \"every-plugin\": \"catalog:\",\n },\n devDependencies: {},\n workspaces: {\n packages: workspacePackages,\n catalog,\n },\n };\n writeFileSync(join(destination, \"package.json\"), `${JSON.stringify(pkg, null, 2)}\\n`);\n\n const envExample = generateEnvExample(parentConfig, opts.overrides);\n if (envExample) {\n writeFileSync(join(destination, \".env.example\"), envExample);\n }\n\n writeFileSync(join(destination, \".gitignore\"), generateGitignore());\n\n return 4;\n}\n\nasync function resolveWorkspaceRefs(\n destination: string,\n options?: { localOverrides?: boolean; sourceDir?: string },\n): Promise<void> {\n await normalizePackageManifestsInTree({\n sourceRootDir: options?.sourceDir ?? destination,\n targetDir: destination,\n resolveCatalogRefs: false,\n preserveCatalogRefs: true,\n removeWorkspaceDeps: [\"host\"],\n });\n\n if (options?.localOverrides && options.sourceDir) {\n const rootPkgPath = join(destination, \"package.json\");\n if (existsSync(rootPkgPath)) {\n const pkg = JSON.parse(readFileSync(rootPkgPath, \"utf-8\")) as Record<string, unknown>;\n if (!pkg.overrides) pkg.overrides = {};\n const overrides = pkg.overrides as Record<string, string>;\n\n const rootWorkspaces = ((pkg.workspaces as Record<string, string[]>)?.packages ?? []).filter(\n Boolean,\n );\n\n for (const [name, relPath] of Object.entries(WORKSPACE_LOCAL_PATHS)) {\n if (!rootWorkspaces.some((ws) => ws === relPath || ws === `plugins/${name}`)) {\n const srcPkgPath = join(options.sourceDir, relPath, \"package.json\");\n if (existsSync(srcPkgPath)) {\n overrides[name] = `file:${relPath}`;\n rootWorkspaces.push(relPath);\n }\n }\n }\n\n if (rootWorkspaces.length > 0) {\n if (!pkg.workspaces) pkg.workspaces = {};\n (pkg.workspaces as Record<string, string[]>).packages = rootWorkspaces;\n }\n\n writeFileSync(rootPkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n }\n}\n\nexport async function writeInitSnapshot(\n destination: string,\n extendsAccount: string,\n extendsGateway: string,\n sourceDir: string,\n patterns: string[],\n _options: {\n overrides: OverrideSection[];\n plugins?: string[];\n },\n): Promise<void> {\n const allFiles = new Set<string>();\n for (const pattern of patterns) {\n const matches = await glob(pattern, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n ignore: [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \"**/.bos/**\"],\n });\n for (const match of matches) {\n allFiles.add(match);\n }\n }\n\n const fileHashes: Record<string, string> = {};\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n const content = readFileSync(src);\n const destPath = sourcePathToDestinationPath(filePath);\n fileHashes[destPath] = computeHash(content);\n }\n\n await writeSnapshot(destination, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: fileHashes,\n });\n}\n\nfunction computeHash(data: Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\").substring(0, 16);\n}\n\nfunction mkTmpDir(prefix: string): string {\n return mkdtempSync(join(tmpdir(), `${prefix}-`));\n}\n\nexport async function generateDatabaseMigrations(destination: string): Promise<void> {\n const drizzleConfigs = await glob(\"**/drizzle.config.ts\", {\n cwd: destination,\n nodir: true,\n dot: false,\n absolute: false,\n ignore: [\"**/node_modules/**\"],\n });\n\n for (const configPath of drizzleConfigs) {\n const workspaceDir = dirname(configPath);\n const pkgPath = join(destination, workspaceDir, \"package.json\");\n if (!existsSync(pkgPath)) continue;\n\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n const scripts = pkg.scripts as Record<string, string> | undefined;\n if (!scripts?.[\"db:generate\"]) continue;\n\n const cwd = join(destination, workspaceDir);\n await execCommand(\"bun\", [\"run\", \"db:generate\"], cwd);\n }\n}\n\nconst COMMAND_TIMEOUTS: Record<string, number> = {\n bun: 5 * 60_000,\n docker: 5 * 60_000,\n node_modules: 2 * 60_000,\n tar: 60_000,\n};\n\nexport async function execCommand(\n command: string,\n args: string[],\n cwd?: string,\n options?: { stdio?: \"pipe\" | \"inherit\" },\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n await execa(command, args, { cwd, stdio: options?.stdio ?? \"pipe\", timeout });\n}\n\nfunction generateEnvExample(config: BosConfigInput, overrides: OverrideSection[]): string {\n const has = (section: OverrideSection) => overrides.includes(section);\n\n const lines: string[] = [\"# Environment variables\"];\n const collectSecrets = (\n obj: Record<string, unknown>,\n includeSection: boolean,\n prefix = \"\",\n ): void => {\n for (const [key, value] of Object.entries(obj)) {\n if (!includeSection) continue;\n if (key === \"secrets\" && Array.isArray(value)) {\n for (const secret of value) {\n if (typeof secret === \"string\") {\n lines.push(`${secret}=`);\n }\n }\n } else if (key === \"variables\" && isPlainObject(value)) {\n for (const [varKey, varVal] of Object.entries(value as Record<string, unknown>)) {\n if (typeof varVal === \"string\") {\n lines.push(`${varKey}=${varVal}`);\n }\n }\n } else if (isPlainObject(value) && key !== \"extends\") {\n collectSecrets(value as Record<string, unknown>, includeSection, `${prefix}${key}.`);\n }\n }\n };\n\n if (config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n collectSecrets(app, has(\"host\"), \"host.\");\n collectSecrets(app, has(\"ui\"), \"ui.\");\n collectSecrets(app, has(\"api\"), \"api.\");\n collectSecrets(app, has(\"plugins\"), \"auth.\");\n }\n if (has(\"plugins\") && config.plugins && typeof config.plugins === \"object\") {\n for (const [pluginKey, pluginVal] of Object.entries(\n config.plugins as Record<string, unknown>,\n )) {\n if (isPlainObject(pluginVal)) {\n collectSecrets(pluginVal as Record<string, unknown>, true);\n } else if (typeof pluginVal === \"string\") {\n lines.push(`# Plugin '${pluginKey}' extends ${pluginVal}`);\n }\n }\n }\n\n lines.push(\"BETTER_AUTH_SECRET=generate-a-secret-here\");\n return `${lines.join(\"\\n\")}\\n`;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction generateGitignore(): string {\n return `node_modules/\ndist/\n.env\n.bos/\n*.gen.ts\n*.gen.tsx\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAqB,CAAC,gBAAgB,iBAAiB;AAE7D,MAAM,yBAA4D;CAChE,IAAI,CAAC,KAAK;CACV,KAAK,CAAC,MAAM;CACZ,MAAM,CAAC,OAAO;CACd,SAAS,EAAE;CACZ;AAQD,eAAsB,iBAAiB,MAIb;AACxB,KAAI,KAAK,QAAQ;EACf,M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AG5B,cAAc,MAAM,IAAI,QAAQ,UACzC,gBAAe,OAAkC,gBAAgB,GAAG,SAAS,IAAI,GAAG;;;AAK1F,KAAI,OAAO,OAAO,OAAO,OAAO,QAAQ,UAAU;EAChD,MAAM,MAAM,OAAO;AACnB,iBAAe,KAAK,IAAI,OAAO,EAAE,QAAQ;AACzC,iBAAe,KAAK,IAAI,KAAK,EAAE,MAAM;AACrC,iBAAe,KAAK,IAAI,MAAM,EAAE,OAAO;AACvC,iBAAe,KAAK,IAAI,UAAU,EAAE,QAAQ;;AAE9C,KAAI,IAAI,UAAU,IAAI,OAAO,WAAW,OAAO,OAAO,YAAY,UAChE;OAAK,MAAM,CAAC,WAAW,cAAc,OAAO,QAC1C,OAAO,QACR,CACC,KAAI,cAAc,UAAU,CAC1B,gBAAe,WAAsC,KAAK;WACjD,OAAO,cAAc,SAC9B,OAAM,KAAK,aAAa,UAAU,YAAY,YAAY;;AAKhE,OAAM,KAAK,4CAA4C;AACvD,QAAO,GAAG,MAAM,KAAK,KAAK,CAAC;;AAG7B,SAAS,cAAc,OAAkD;AACvE,QAAO,QAAQ,MAAM,IAAI,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAS,oBAA4B;AACnC,QAAO"}
|
|
1
|
+
{"version":3,"file":"init.mjs","names":[],"sources":["../../src/cli/init.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n createWriteStream,\n existsSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { execa } from \"execa\";\nimport { glob } from \"glob\";\nimport type { OverrideSection } from \"../contract\";\nimport { fetchBosConfigFromFastKv } from \"../fastkv\";\nimport {\n loadManifestNormalizationSpec,\n normalizePackageManifestsInTree,\n} from \"../internal/manifest-normalizer\";\nimport type { BosConfig, BosConfigInput } from \"../types\";\nimport { saveBosConfig } from \"../utils/save-config\";\nimport { writeSnapshot } from \"./snapshot\";\n\nconst require = createRequire(import.meta.url);\n\nexport const INIT_ROOT_PATTERNS = [\n \"bos.config.json\",\n \"package.json\",\n \".env.example\",\n \".gitignore\",\n \"biome.json\",\n \"bunfig.toml\",\n \"Dockerfile\",\n \"railway.json\",\n \".agent/**\",\n \"AGENTS.md\",\n \".opencode/skills/everything-dev/**\",\n \".changeset/config.json\",\n \".changeset/README.md\",\n \"README.md\",\n \"CONTRIBUTING.md\",\n \".github/templates/**\",\n] as const;\n\nconst FRAMEWORK_PACKAGES = [\"every-plugin\", \"everything-dev\"] as const;\n\nconst OVERRIDE_WORKSPACE_MAP: Record<OverrideSection, string[]> = {\n ui: [\"ui\"],\n api: [\"api\"],\n host: [\"host\"],\n plugins: [],\n};\n\ninterface SourceResult {\n sourceDir: string;\n parentConfig: BosConfig;\n cleanup: () => Promise<void>;\n}\n\nexport async function resolveSourceDir(opts: {\n extendsAccount: string;\n extendsGateway: string;\n source?: string;\n}): Promise<SourceResult> {\n if (opts.source) {\n const sourceDir = resolve(opts.source);\n if (!existsSync(join(sourceDir, \"bos.config.json\"))) {\n throw new Error(`No bos.config.json found in source directory: ${sourceDir}`);\n }\n const parentConfig = JSON.parse(\n readFileSync(join(sourceDir, \"bos.config.json\"), \"utf-8\"),\n ) as BosConfig;\n return { sourceDir, parentConfig, cleanup: async () => {} };\n }\n\n const parentConfig = await fetchParentConfig(opts.extendsAccount, opts.extendsGateway);\n\n if (parentConfig.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(parentConfig.repository);\n return { sourceDir, parentConfig, cleanup };\n }\n\n const chainResult = await resolveRepositoryViaExtendsChain(\n opts.extendsAccount,\n opts.extendsGateway,\n );\n if (chainResult?.repository) {\n const { dir: sourceDir, cleanup } = await downloadTarball(chainResult.repository);\n return { sourceDir, parentConfig: chainResult.config, cleanup };\n }\n\n return {\n sourceDir: \"\",\n parentConfig,\n cleanup: async () => {},\n };\n}\n\nexport function buildInitPatterns(overrides: OverrideSection[], plugins?: string[]): string[] {\n const has = (section: OverrideSection) => overrides.includes(section);\n const patterns: string[] = [...INIT_ROOT_PATTERNS];\n\n if (has(\"ui\")) patterns.push(\"ui/**\");\n if (has(\"api\")) patterns.push(\"api/**\");\n if (has(\"host\")) patterns.push(\"host/**\");\n if (has(\"plugins\")) {\n for (const plugin of plugins ?? []) {\n patterns.push(`plugins/${plugin}/**`);\n }\n }\n\n return patterns;\n}\n\nexport function sourcePathToDestinationPath(filePath: string): string {\n return filePath.startsWith(\".github/templates/\")\n ? filePath.replace(/^\\.github\\/templates\\//, \".github/\")\n : filePath;\n}\n\nexport async function fetchParentConfig(\n extendsAccount: string,\n extendsGateway: string,\n): Promise<BosConfig> {\n const bosUrl = `bos://${extendsAccount}/${extendsGateway}`;\n return fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n}\n\nexport async function resolveRepositoryViaExtendsChain(\n extendsAccount: string,\n extendsGateway: string,\n visited = new Set<string>(),\n): Promise<{ repository: string; config: BosConfig } | null> {\n const key = `bos://${extendsAccount}/${extendsGateway}`;\n if (visited.has(key)) return null;\n visited.add(key);\n\n try {\n const config = await fetchParentConfig(extendsAccount, extendsGateway);\n if (config.repository) {\n return { repository: config.repository, config };\n }\n\n const extendsRef = config.extends;\n if (extendsRef && typeof extendsRef === \"string\") {\n const normalized = extendsRef.startsWith(\"bos://\") ? extendsRef : `bos://${extendsRef}`;\n const match = normalized.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (match) {\n const result = await resolveRepositoryViaExtendsChain(match[1], match[2], visited);\n if (result) return result;\n }\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\nexport async function detectGitRemoteUrl(directory: string): Promise<string | undefined> {\n try {\n const { stdout } = await execa(\"git\", [\"remote\", \"get-url\", \"origin\"], {\n cwd: directory,\n stdio: \"pipe\",\n });\n const url = stdout.trim();\n if (!url) return undefined;\n return normalizeGitUrl(url);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeGitUrl(url: string): string | undefined {\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return `https://github.com/${sshMatch[1]}/${sshMatch[2]}`;\n }\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return `https://github.com/${httpsMatch[1]}/${httpsMatch[2]}`;\n }\n return url.endsWith(\".git\") ? url.slice(0, -4) : url;\n}\n\nexport async function downloadTarball(\n repoUrl: string,\n): Promise<{ dir: string; cleanup: () => Promise<void> }> {\n const parsed = parseGitHubUrl(repoUrl);\n if (!parsed) {\n throw new Error(`Cannot parse repository URL: ${repoUrl}`);\n }\n\n const { owner, repo, branch } = parsed;\n const tarballUrl = `https://api.github.com/repos/${owner}/${repo}/tarball/${branch}`;\n\n const tmpDir = mkTmpDir(\"bos-init-tarball-\");\n const tarballPath = join(tmpDir, \"source.tar.gz\");\n\n const response = await fetch(tarballUrl, {\n headers: { \"User-Agent\": \"everything-dev\" },\n redirect: \"follow\",\n });\n\n if (!response.ok) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(`GitHub tarball download failed: ${response.status} ${response.statusText}`);\n }\n\n if (!response.body) {\n rmSync(tmpDir, { recursive: true, force: true });\n throw new Error(\"GitHub tarball download returned empty body\");\n }\n\n const fileStream = createWriteStream(tarballPath);\n const reader = response.body as unknown as NodeJS.ReadableStream;\n await pipeline(reader, fileStream);\n\n const extractDir = mkTmpDir(\"bos-init-extract-\");\n try {\n const tar = require(\"tar\") as {\n extract: (opts: { cwd: string; file: string; strip: number }) => Promise<void>;\n };\n await tar.extract({ cwd: extractDir, file: tarballPath, strip: 1 });\n } catch {\n await execCommand(\"tar\", [\"-xzf\", tarballPath, \"--strip-components=1\", \"-C\", extractDir]);\n }\n\n rmSync(tmpDir, { recursive: true, force: true });\n\n return {\n dir: extractDir,\n cleanup: async () => {\n rmSync(extractDir, { recursive: true, force: true });\n },\n };\n}\n\nfunction parseGitHubUrl(url: string): { owner: string; repo: string; branch: string } | null {\n const httpsMatch = url.match(/^https?:\\/\\/github\\.com\\/([^/]+)\\/([^/]+?)(?:\\.git)?(?:\\/.*)?$/);\n if (httpsMatch) {\n return { owner: httpsMatch[1], repo: httpsMatch[2], branch: \"main\" };\n }\n\n const sshMatch = url.match(/^git@github\\.com:([^/]+)\\/([^/]+?)(?:\\.git)?$/);\n if (sshMatch) {\n return { owner: sshMatch[1], repo: sshMatch[2], branch: \"main\" };\n }\n\n return null;\n}\n\nexport async function copyFilteredFiles(\n sourceDir: string,\n destination: string,\n patterns: string[],\n _options: {\n overrides: OverrideSection[];\n plugins?: string[];\n },\n): Promise<number> {\n if (patterns.length === 0) {\n return 0;\n }\n\n const allFiles = new Set<string>();\n for (const pattern of patterns) {\n const matches = await glob(pattern, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n ignore: [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \"**/.bos/**\"],\n });\n for (const match of matches) {\n allFiles.add(match);\n }\n }\n\n mkdirSync(destination, { recursive: true });\n\n let count = 0;\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n\n const destPath = sourcePathToDestinationPath(filePath);\n const dest = join(destination, destPath);\n mkdirSync(dirname(dest), { recursive: true });\n const content = readFileSync(src);\n writeFileSync(dest, content);\n count++;\n }\n\n return count;\n}\n\nfunction stripProductionFields(entry: Record<string, unknown>): void {\n delete entry.production;\n delete entry.integrity;\n delete entry.ssr;\n delete entry.ssrIntegrity;\n}\n\nfunction buildRootTypecheckScript(sections: {\n ui: boolean;\n api: boolean;\n host: boolean;\n plugins: boolean;\n}): string {\n const commands = [\"bun run types:gen\"];\n\n if (sections.ui) {\n commands.push(\"if [ -d ui ]; then bun run --cwd ui typecheck; fi\");\n }\n if (sections.api) {\n commands.push(\"if [ -d api ]; then bun run --cwd api typecheck; fi\");\n }\n if (sections.host) {\n commands.push(\"if [ -d host ]; then bun run --cwd host typecheck; fi\");\n }\n if (sections.plugins) {\n commands.push(\n 'if [ -d plugins ]; then for dir in plugins/*; do if [ -f \"$dir/package.json\" ]; then bun run --cwd \"$dir\" typecheck; fi; done; fi',\n );\n }\n\n return commands.join(\" && \");\n}\n\nexport function buildChildRootScripts(sections: {\n ui: boolean;\n api: boolean;\n host: boolean;\n plugins: boolean;\n}): Record<string, string> {\n const scripts: Record<string, string> = {\n dev: \"node_modules/.bin/bos dev --host remote\",\n \"dev:proxy\": \"node_modules/.bin/bos dev --proxy\",\n build: \"node_modules/.bin/bos build\",\n deploy: \"node_modules/.bin/bos build --deploy\",\n publish: \"node_modules/.bin/bos publish\",\n start: \"node_modules/.bin/bos start\",\n typecheck: buildRootTypecheckScript(sections),\n lint: \"biome check .\",\n \"lint:fix\": \"biome check --write .\",\n format: \"biome format --write .\",\n \"format:check\": \"biome format .\",\n changeset: \"changeset\",\n version: \"changeset version\",\n release: \"echo 'Packages versioned - app release handled by workflow'\",\n postinstall: \"node_modules/.bin/bos types gen || true\",\n \"types:gen\": \"node_modules/.bin/bos types gen\",\n bos: \"node_modules/.bin/bos\",\n };\n\n if (sections.ui) {\n scripts[\"dev:ui\"] = \"node_modules/.bin/bos dev --ui local --api remote\";\n }\n if (sections.api) {\n scripts[\"dev:api\"] = \"node_modules/.bin/bos dev --ui remote --api local\";\n }\n\n return scripts;\n}\n\nexport async function personalizeConfig(\n destination: string,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides: OverrideSection[];\n pluginRoutes?: Record<string, string[]>;\n workspaceOpts?: { localOverrides?: boolean; sourceDir?: string };\n mode?: \"init\" | \"sync\";\n existingConfig?: Record<string, unknown>;\n repository?: string;\n title?: string;\n description?: string;\n testnet?: string;\n staging?: unknown;\n },\n): Promise<void> {\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\n const explicitRootKeys = new Set(\n Object.entries(opts)\n .filter(\n ([key, value]) =>\n value !== undefined &&\n ![\n \"extendsAccount\",\n \"extendsGateway\",\n \"plugins\",\n \"overrides\",\n \"pluginRoutes\",\n \"workspaceOpts\",\n \"mode\",\n \"existingConfig\",\n ].includes(key),\n )\n .map(([key]) => key),\n );\n\n const configPath = join(destination, \"bos.config.json\");\n if (existsSync(configPath)) {\n const config = JSON.parse(readFileSync(configPath, \"utf-8\")) as Record<string, unknown>;\n\n config.extends = `bos://${opts.extendsAccount}/${opts.extendsGateway}`;\n\n if (opts.account) {\n config.account = opts.account;\n }\n if (opts.domain) {\n config.domain = opts.domain;\n }\n if (opts.repository) {\n config.repository = opts.repository;\n } else {\n delete config.repository;\n }\n\n const inheritableFields = [\"title\", \"description\", \"testnet\", \"staging\"] as const;\n for (const field of inheritableFields) {\n if (!(field in opts)) {\n delete config[field];\n }\n }\n\n if (config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n\n for (const entryKey of Object.keys(app)) {\n if (\n !has(entryKey as OverrideSection) &&\n (entryKey === \"host\" || entryKey === \"ui\" || entryKey === \"api\" || entryKey === \"auth\")\n ) {\n delete app[entryKey];\n continue;\n }\n const entry = app[entryKey];\n if (entry && typeof entry === \"object\") {\n stripProductionFields(entry as Record<string, unknown>);\n }\n }\n }\n\n if (has(\"plugins\")) {\n if (config.plugins && typeof config.plugins === \"object\") {\n const plugins = config.plugins as Record<string, unknown>;\n\n if (opts.plugins !== undefined) {\n for (const pluginKey of Object.keys(plugins)) {\n if (!opts.plugins.includes(pluginKey)) {\n delete plugins[pluginKey];\n }\n }\n }\n\n for (const pluginKey of Object.keys(plugins)) {\n const plugin = plugins[pluginKey];\n let pluginObj: Record<string, unknown>;\n\n if (typeof plugin === \"string\") {\n pluginObj = { extends: plugin };\n plugins[pluginKey] = pluginObj;\n } else if (plugin && typeof plugin === \"object\") {\n pluginObj = { ...(plugin as Record<string, unknown>) };\n plugins[pluginKey] = pluginObj;\n } else {\n continue;\n }\n\n stripProductionFields(pluginObj);\n }\n\n if (Object.keys(plugins).length === 0) {\n delete config.plugins;\n }\n }\n } else {\n delete config.plugins;\n }\n\n if (opts.mode === \"sync\" && opts.existingConfig) {\n const managedRootKeys = new Set([\"extends\", \"account\", \"domain\", \"app\", \"plugins\", \"shared\"]);\n const preservedRootKeys = new Set([\n ...managedRootKeys,\n ...Object.keys(opts.existingConfig),\n ...explicitRootKeys,\n ]);\n\n for (const key of Object.keys(config)) {\n if (!preservedRootKeys.has(key)) {\n delete config[key];\n }\n }\n\n for (const [key, value] of Object.entries(opts.existingConfig)) {\n if (!(key in config) && !managedRootKeys.has(key) && !explicitRootKeys.has(key)) {\n config[key] = value;\n }\n }\n }\n\n await saveBosConfig(destination, config);\n }\n\n const pkgPath = join(destination, \"package.json\");\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n const childScripts = buildChildRootScripts({\n ui: has(\"ui\"),\n api: has(\"api\"),\n host: has(\"host\"),\n plugins: has(\"plugins\"),\n });\n\n pkg.name = opts.domain || opts.extendsGateway;\n pkg.private = true;\n pkg.type = \"module\";\n delete pkg.module;\n delete pkg.peerDependencies;\n\n if (pkg.workspaces && typeof pkg.workspaces === \"object\") {\n const ws = pkg.workspaces as { packages?: string[] };\n if (Array.isArray(ws.packages)) {\n ws.packages = ws.packages.filter((p: string) => {\n if (p.startsWith(\"packages/\")) return false;\n if (p === \"host\") return has(\"host\");\n if (p.startsWith(\"plugins/\")) return false;\n return true;\n });\n\n if (has(\"plugins\")) {\n if (!ws.packages.includes(\"plugins/*\")) {\n ws.packages.push(\"plugins/*\");\n }\n }\n }\n }\n\n if (!pkg.scripts || typeof pkg.scripts !== \"object\") {\n pkg.scripts = {};\n }\n const scripts = pkg.scripts as Record<string, string>;\n for (const [key, value] of Object.entries(childScripts)) {\n scripts[key] = value;\n }\n for (const obsoleteScript of [\n \"init\",\n \"sync-catalog\",\n \"db:push\",\n \"db:studio\",\n \"db:generate\",\n \"db:migrate\",\n \"test\",\n \"test:api\",\n \"test:integration\",\n \"test:e2e\",\n \"dev:postgres\",\n \"dev:postgres:down\",\n \"dev:postgres:reset\",\n \"dev:ui\",\n \"dev:api\",\n ]) {\n if (!(obsoleteScript in childScripts)) {\n delete scripts[obsoleteScript];\n }\n }\n\n if (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n const deps = pkg.devDependencies as Record<string, string>;\n delete deps[\"every-plugin\"];\n delete deps[\"everything-dev\"];\n }\n\n if (!pkg.workspaces || typeof pkg.workspaces !== \"object\") {\n pkg.workspaces = { packages: [], catalog: {} };\n }\n const workspaces = pkg.workspaces as { packages?: string[]; catalog?: Record<string, string> };\n if (!workspaces.catalog || typeof workspaces.catalog !== \"object\") {\n workspaces.catalog = {};\n }\n\n if (!pkg.dependencies) pkg.dependencies = {};\n const deps = pkg.dependencies as Record<string, string>;\n const spec = opts.workspaceOpts?.sourceDir\n ? loadManifestNormalizationSpec(opts.workspaceOpts.sourceDir)\n : null;\n if (spec) {\n workspaces.catalog[\"everything-dev\"] = spec.rootCatalog[\"everything-dev\"];\n workspaces.catalog[\"every-plugin\"] = spec.rootCatalog[\"every-plugin\"];\n }\n const frameworkCatalog = resolveFrameworkCatalog();\n for (const [name, version] of Object.entries(frameworkCatalog)) {\n workspaces.catalog[name] = version;\n }\n if (!deps[\"everything-dev\"]) deps[\"everything-dev\"] = \"catalog:\";\n if (!deps[\"every-plugin\"]) deps[\"every-plugin\"] = \"catalog:\";\n\n writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\\n`);\n }\n\n const apiTsConfigPath = join(destination, \"api\", \"tsconfig.json\");\n if (existsSync(apiTsConfigPath)) {\n const apiTsConfig = JSON.parse(readFileSync(apiTsConfigPath, \"utf-8\")) as {\n files?: string[];\n [key: string]: unknown;\n };\n if (apiTsConfig.files) {\n const validFiles = apiTsConfig.files.filter((f) => existsSync(join(destination, \"api\", f)));\n if (validFiles.length !== apiTsConfig.files.length) {\n if (validFiles.length === 0) {\n delete apiTsConfig.files;\n } else {\n apiTsConfig.files = validFiles;\n }\n writeFileSync(apiTsConfigPath, `${JSON.stringify(apiTsConfig, null, 2)}\\n`);\n }\n }\n }\n\n await resolveWorkspaceRefs(destination, opts.workspaceOpts);\n\n if (has(\"ui\")) {\n const genContractPath = join(destination, \"ui\", \"src\", \"lib\", \"api-types.gen.ts\");\n if (!existsSync(genContractPath)) {\n mkdirSync(dirname(genContractPath), { recursive: true });\n writeFileSync(genContractPath, `export type ApiContract = Record<string, never>;\\n`);\n }\n }\n\n if (has(\"api\")) {\n const pluginsClientGenPath = join(destination, \"api\", \"src\", \"lib\", \"plugins-types.gen.ts\");\n if (!existsSync(pluginsClientGenPath)) {\n mkdirSync(dirname(pluginsClientGenPath), { recursive: true });\n writeFileSync(\n pluginsClientGenPath,\n `import type { ContractRouterClient, AnyContractRouter } from \"@orpc/contract\";\\ntype ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;\\nexport type PluginsClient = Record<string, never>;\\n`,\n );\n }\n }\n\n const authTypesContent = generateAuthTypesTemplate();\n const authTypesPaths: string[] = [];\n if (has(\"ui\")) {\n authTypesPaths.push(join(destination, \"ui\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"api\")) {\n authTypesPaths.push(join(destination, \"api\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n if (has(\"host\") && existsSync(join(destination, \"host\", \"src\"))) {\n authTypesPaths.push(join(destination, \"host\", \"src\", \"lib\", \"auth-types.gen.ts\"));\n }\n for (const authTypesGenPath of authTypesPaths) {\n if (!existsSync(authTypesGenPath)) {\n mkdirSync(dirname(authTypesGenPath), { recursive: true });\n writeFileSync(authTypesGenPath, authTypesContent);\n }\n }\n\n if (has(\"plugins\")) {\n for (const plugin of opts.plugins ?? []) {\n const pluginSrcDir = join(destination, \"plugins\", plugin, \"src\");\n const pluginIndexPath = join(pluginSrcDir, \"index.ts\");\n const pluginClientGenPath = join(pluginSrcDir, \"plugins-client.gen.ts\");\n if (!existsSync(pluginIndexPath) || existsSync(pluginClientGenPath)) {\n continue;\n }\n const pluginIndex = readFileSync(pluginIndexPath, \"utf-8\");\n if (!pluginIndex.includes(\"./plugins-client.gen\")) {\n continue;\n }\n writeFileSync(pluginClientGenPath, \"export type PluginsClient = Record<string, never>;\\n\");\n }\n }\n}\n\nfunction generateAuthTypesTemplate(): string {\n return `import type { Auth } from \"better-auth\";\nexport type { Auth } from \"better-auth\";\nexport type AuthSessionUser = NonNullable<Auth[\"$Infer\"][\"Session\"][\"user\"]> & {\n role?: string | null;\n isAnonymous?: boolean | null;\n walletAddress?: string | null;\n banned?: boolean | null;\n};\nexport type AuthSessionData = NonNullable<Auth[\"$Infer\"][\"Session\"][\"session\"]> & {\n activeOrganizationId?: string | null;\n};\nexport type AuthSession = {\n user: AuthSessionUser | null;\n session: AuthSessionData | null;\n};\nexport interface AuthOrganizationContext {\n activeOrganizationId: string | null;\n organization: { id: string; name: string; slug: string; logo?: string | null; metadata?: Record<string, unknown> } | null;\n member: { id: string; role: string } | null;\n isPersonal: boolean;\n hasOrganization: boolean;\n}\nexport interface AuthRequestContext {\n user: AuthSessionUser | null;\n userId: string | null;\n isAuthenticated: boolean;\n authMethod: \"session\" | \"apiKey\" | \"anonymous\" | \"none\";\n near: {\n primaryAccountId: string | null;\n linkedAccounts: Array<{ accountId: string; network: string; publicKey: string; isPrimary: boolean }>;\n hasNearAccount: boolean;\n };\n organization: AuthOrganizationContext;\n organizations?: Array<{ id: string; role: string; name?: string; slug?: string }>;\n}\nexport type AuthActiveMember = { id: string | null; role: string | null; organizationId: string | null };\nexport type AuthOrganization = NonNullable<AuthOrganizationContext[\"organization\"]>;\nexport type AuthOrganizationMember = NonNullable<AuthOrganizationContext[\"member\"]>;\nexport type AuthOrganizationSummary = NonNullable<AuthRequestContext[\"organizations\"]>[number];\nexport type AuthBaseSession = Auth[\"$Infer\"][\"Session\"];\nexport type createAuthInstance = never;\nexport interface AuthServices {\n auth: Auth;\n db: unknown;\n driver: { close(): Promise<void> };\n handler: (req: Request) => Promise<Response>;\n}\n`;\n}\n\nexport async function runBunInstall(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"bun\",\n [\"install\", \"--ignore-scripts\"],\n destination,\n spinner,\n \"Installing dependencies\",\n );\n}\n\nexport async function runBunInstallForUpgrade(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n await runWithProgress(\n \"bun\",\n [\"install\", \"--force\"],\n destination,\n spinner,\n \"Installing dependencies\",\n );\n}\n\nexport async function runTypesGen(\n destination: string,\n spinner?: { message: (msg: string) => void },\n): Promise<void> {\n const localBosBin = join(destination, \"node_modules\", \".bin\", \"bos\");\n if (existsSync(localBosBin)) {\n await runWithProgress(\n \"node_modules/.bin/bos\",\n [\"types\", \"gen\"],\n destination,\n spinner,\n \"Generating types\",\n );\n return;\n }\n\n throw new Error(\"Unable to locate bos CLI for types generation\");\n}\n\nexport async function runDockerComposeUp(destination: string): Promise<void> {\n await execCommand(\"docker\", [\"compose\", \"up\", \"-d\", \"--wait\"], destination, { stdio: \"inherit\" });\n}\n\nasync function runWithProgress(\n command: string,\n args: string[],\n cwd: string,\n spinner: { message: (msg: string) => void } | undefined,\n label: string,\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n const child = execa(command, args, { cwd, stdio: \"inherit\", timeout });\n\n if (spinner) {\n const start = Date.now();\n const interval = setInterval(() => {\n const elapsed = Math.round((Date.now() - start) / 1000);\n spinner.message(`${label}... (${elapsed}s)`);\n }, 2000);\n try {\n await child;\n } finally {\n clearInterval(interval);\n }\n } else {\n await child;\n }\n}\n\nexport function stripOrphanedWorkspacesFromLockfile(\n lockfilePath: string,\n allowedWorkspaces: string[],\n): void {\n if (!existsSync(lockfilePath)) return;\n\n const content = readFileSync(lockfilePath, \"utf-8\");\n let lockfile: Record<string, unknown>;\n try {\n lockfile = JSON.parse(content) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const workspaces = lockfile.workspaces;\n if (!workspaces || typeof workspaces !== \"object\") return;\n\n const workspaceMap = workspaces as Record<string, unknown>;\n const allowed = new Set([\"\", ...allowedWorkspaces]);\n\n const keys = Object.keys(workspaceMap);\n let changed = false;\n for (const key of keys) {\n if (allowed.has(key)) continue;\n if (\n allowedWorkspaces.some(\n (pattern) => pattern.endsWith(\"/*\") && key.startsWith(pattern.slice(0, -1)),\n )\n )\n continue;\n delete workspaceMap[key];\n changed = true;\n }\n\n if (changed) {\n writeFileSync(lockfilePath, `${JSON.stringify(lockfile, null, 2)}\\n`);\n }\n}\n\nexport function removeInitLockfile(lockfilePath: string): void {\n if (!existsSync(lockfilePath)) return;\n rmSync(lockfilePath, { force: true });\n}\n\nfunction readJsonFile<T>(filePath: string): T {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as T;\n}\n\nfunction tryResolvePackageJson(packageName: string): string | null {\n try {\n return require.resolve(`${packageName}/package.json`);\n } catch {\n return null;\n }\n}\n\nfunction resolveFrameworkCatalog(): Record<string, string> {\n const catalog: Record<string, string> = {};\n const everythingDevPackageJson = tryResolvePackageJson(\"everything-dev\");\n\n if (everythingDevPackageJson) {\n try {\n const selfPkgDir = dirname(everythingDevPackageJson);\n const monorepoPkgPath = join(selfPkgDir, \"..\", \"..\", \"package.json\");\n if (existsSync(monorepoPkgPath)) {\n const monorepoPkg = readJsonFile<{\n workspaces?: { catalog?: Record<string, string> };\n }>(monorepoPkgPath);\n const sourceCatalog = monorepoPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\") {\n catalog[name] = version;\n }\n }\n }\n }\n } catch {}\n\n try {\n const selfPkg = readJsonFile<{\n version?: string;\n workspaces?: { catalog?: Record<string, string> };\n }>(everythingDevPackageJson);\n if (selfPkg.version && !catalog[\"everything-dev\"]) {\n catalog[\"everything-dev\"] = `^${selfPkg.version}`;\n }\n const sourceCatalog = selfPkg.workspaces?.catalog;\n if (sourceCatalog && typeof sourceCatalog === \"object\") {\n for (const [name, version] of Object.entries(sourceCatalog)) {\n if (typeof version === \"string\" && !catalog[name]) {\n catalog[name] = version;\n }\n }\n }\n } catch {}\n }\n\n for (const packageName of FRAMEWORK_PACKAGES) {\n const resolved = tryResolvePackageJson(packageName);\n if (!resolved) continue;\n\n try {\n const pkg = readJsonFile<{ version?: string }>(resolved);\n if (pkg.version) {\n catalog[packageName] = `^${pkg.version}`;\n }\n } catch {}\n }\n\n return catalog;\n}\n\nexport async function scaffoldMinimalProject(\n destination: string,\n parentConfig: BosConfigInput,\n opts: {\n extendsAccount: string;\n extendsGateway: string;\n account?: string;\n domain?: string;\n plugins?: string[];\n overrides: OverrideSection[];\n repository?: string;\n title?: string;\n description?: string;\n },\n): Promise<number> {\n mkdirSync(destination, { recursive: true });\n\n const has = (section: OverrideSection) => opts.overrides.includes(section);\n\n const config: Record<string, unknown> = {\n extends: `bos://${opts.extendsAccount}/${opts.extendsGateway}`,\n account: opts.account || opts.extendsAccount,\n ...(opts.domain ? { domain: opts.domain } : {}),\n ...(opts.repository ? { repository: opts.repository } : {}),\n ...(opts.title ? { title: opts.title } : {}),\n ...(opts.description ? { description: opts.description } : {}),\n };\n\n if (parentConfig.app && typeof parentConfig.app === \"object\") {\n const app: Record<string, unknown> = {};\n const parentApp = parentConfig.app as Record<string, Record<string, unknown>>;\n\n if (has(\"host\") && parentApp.host) {\n app.host = { ...parentApp.host };\n stripProductionFields(app.host as Record<string, unknown>);\n }\n\n if (has(\"ui\") && parentApp.ui) {\n app.ui = { ...parentApp.ui };\n stripProductionFields(app.ui as Record<string, unknown>);\n }\n\n if (has(\"api\") && parentApp.api) {\n app.api = { ...parentApp.api };\n stripProductionFields(app.api as Record<string, unknown>);\n }\n\n if (has(\"plugins\") && parentApp.auth) {\n app.auth = { ...parentApp.auth };\n stripProductionFields(app.auth as Record<string, unknown>);\n }\n\n if (Object.keys(app).length > 0) {\n config.app = app;\n }\n }\n\n if (has(\"plugins\") && opts.plugins && opts.plugins.length > 0 && parentConfig.plugins) {\n const plugins: Record<string, unknown> = {};\n for (const key of opts.plugins) {\n const parentPlugin = (parentConfig.plugins as Record<string, unknown>)?.[key];\n if (parentPlugin) {\n if (typeof parentPlugin === \"string\") {\n plugins[key] = { extends: parentPlugin };\n } else {\n const pluginCopy = { ...(parentPlugin as Record<string, unknown>) };\n stripProductionFields(pluginCopy);\n plugins[key] = pluginCopy;\n }\n }\n }\n config.plugins = plugins;\n }\n\n await saveBosConfig(destination, config);\n\n const workspacePackages: string[] = [];\n for (const section of opts.overrides) {\n workspacePackages.push(...OVERRIDE_WORKSPACE_MAP[section]);\n }\n if (has(\"plugins\")) {\n workspacePackages.push(\"plugins/*\");\n }\n\n const catalog = resolveFrameworkCatalog();\n\n const pkg: Record<string, unknown> = {\n name: opts.domain || opts.extendsGateway,\n private: true,\n type: \"module\",\n scripts: buildChildRootScripts({\n ui: has(\"ui\"),\n api: has(\"api\"),\n host: has(\"host\"),\n plugins: has(\"plugins\"),\n }),\n dependencies: {\n \"everything-dev\": \"catalog:\",\n \"every-plugin\": \"catalog:\",\n },\n devDependencies: {},\n workspaces: {\n packages: workspacePackages,\n catalog,\n },\n };\n writeFileSync(join(destination, \"package.json\"), `${JSON.stringify(pkg, null, 2)}\\n`);\n\n const envExample = generateEnvExample(parentConfig, opts.overrides);\n if (envExample) {\n writeFileSync(join(destination, \".env.example\"), envExample);\n }\n\n writeFileSync(join(destination, \".gitignore\"), generateGitignore());\n\n return 4;\n}\n\nasync function resolveWorkspaceRefs(\n destination: string,\n options?: { localOverrides?: boolean; sourceDir?: string },\n): Promise<void> {\n await normalizePackageManifestsInTree({\n sourceRootDir: options?.sourceDir ?? destination,\n targetDir: destination,\n resolveCatalogRefs: false,\n preserveCatalogRefs: true,\n removeWorkspaceDeps: [\"host\"],\n });\n}\n\nexport async function writeInitSnapshot(\n destination: string,\n extendsAccount: string,\n extendsGateway: string,\n sourceDir: string,\n patterns: string[],\n _options: {\n overrides: OverrideSection[];\n plugins?: string[];\n },\n): Promise<void> {\n const allFiles = new Set<string>();\n for (const pattern of patterns) {\n const matches = await glob(pattern, {\n cwd: sourceDir,\n nodir: true,\n dot: true,\n absolute: false,\n ignore: [\"**/node_modules/**\", \"**/.git/**\", \"**/dist/**\", \"**/.bos/**\"],\n });\n for (const match of matches) {\n allFiles.add(match);\n }\n }\n\n const fileHashes: Record<string, string> = {};\n for (const filePath of allFiles) {\n const src = join(sourceDir, filePath);\n const stat = lstatSync(src);\n if (!stat.isFile()) continue;\n const content = readFileSync(src);\n const destPath = sourcePathToDestinationPath(filePath);\n fileHashes[destPath] = computeHash(content);\n }\n\n await writeSnapshot(destination, {\n parentRef: `bos://${extendsAccount}/${extendsGateway}`,\n files: fileHashes,\n });\n}\n\nfunction computeHash(data: Uint8Array): string {\n return createHash(\"sha256\").update(data).digest(\"hex\").substring(0, 16);\n}\n\nfunction mkTmpDir(prefix: string): string {\n return mkdtempSync(join(tmpdir(), `${prefix}-`));\n}\n\nexport async function generateDatabaseMigrations(destination: string): Promise<void> {\n const drizzleConfigs = await glob(\"**/drizzle.config.ts\", {\n cwd: destination,\n nodir: true,\n dot: false,\n absolute: false,\n ignore: [\"**/node_modules/**\"],\n });\n\n for (const configPath of drizzleConfigs) {\n const workspaceDir = dirname(configPath);\n const pkgPath = join(destination, workspaceDir, \"package.json\");\n if (!existsSync(pkgPath)) continue;\n\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as Record<string, unknown>;\n const scripts = pkg.scripts as Record<string, string> | undefined;\n if (!scripts?.[\"db:generate\"]) continue;\n\n const cwd = join(destination, workspaceDir);\n await execCommand(\"bun\", [\"run\", \"db:generate\"], cwd);\n }\n}\n\nconst COMMAND_TIMEOUTS: Record<string, number> = {\n bun: 5 * 60_000,\n docker: 5 * 60_000,\n node_modules: 2 * 60_000,\n tar: 60_000,\n};\n\nexport async function execCommand(\n command: string,\n args: string[],\n cwd?: string,\n options?: { stdio?: \"pipe\" | \"inherit\" },\n): Promise<void> {\n const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;\n await execa(command, args, { cwd, stdio: options?.stdio ?? \"pipe\", timeout });\n}\n\nfunction generateEnvExample(config: BosConfigInput, overrides: OverrideSection[]): string {\n const has = (section: OverrideSection) => overrides.includes(section);\n\n const lines: string[] = [\"# Environment variables\"];\n const collectSecrets = (\n obj: Record<string, unknown>,\n includeSection: boolean,\n prefix = \"\",\n ): void => {\n for (const [key, value] of Object.entries(obj)) {\n if (!includeSection) continue;\n if (key === \"secrets\" && Array.isArray(value)) {\n for (const secret of value) {\n if (typeof secret === \"string\") {\n lines.push(`${secret}=`);\n }\n }\n } else if (key === \"variables\" && isPlainObject(value)) {\n for (const [varKey, varVal] of Object.entries(value as Record<string, unknown>)) {\n if (typeof varVal === \"string\") {\n lines.push(`${varKey}=${varVal}`);\n }\n }\n } else if (isPlainObject(value) && key !== \"extends\") {\n collectSecrets(value as Record<string, unknown>, includeSection, `${prefix}${key}.`);\n }\n }\n };\n\n if (config.app && typeof config.app === \"object\") {\n const app = config.app as Record<string, unknown>;\n collectSecrets(app, has(\"host\"), \"host.\");\n collectSecrets(app, has(\"ui\"), \"ui.\");\n collectSecrets(app, has(\"api\"), \"api.\");\n collectSecrets(app, has(\"plugins\"), \"auth.\");\n }\n if (has(\"plugins\") && config.plugins && typeof config.plugins === \"object\") {\n for (const [pluginKey, pluginVal] of Object.entries(\n config.plugins as Record<string, unknown>,\n )) {\n if (isPlainObject(pluginVal)) {\n collectSecrets(pluginVal as Record<string, unknown>, true);\n } else if (typeof pluginVal === \"string\") {\n lines.push(`# Plugin '${pluginKey}' extends ${pluginVal}`);\n }\n }\n }\n\n lines.push(\"BETTER_AUTH_SECRET=generate-a-secret-here\");\n return `${lines.join(\"\\n\")}\\n`;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction generateGitignore(): string {\n return `node_modules/\ndist/\n.env\n.bos/\n*.gen.ts\n*.gen.tsx\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,qBAAqB,CAAC,gBAAgB,iBAAiB;AAE7D,MAAM,yBAA4D;CAChE,IAAI,CAAC,KAAK;CACV,KAAK,CAAC,MAAM;CACZ,MAAM,CAAC,OAAO;CACd,SAAS,EAAE;CACZ;AAQD,eAAsB,iBAAiB,MAIb;AACxB,KAAI,KAAK,QAAQ;EACf,MAAM,YAAY,QAAQ,KAAK,OAAO;AACtC,MAAI,CAAC,WAAW,KAAK,WAAW,kBAAkB,CAAC,CACjD,OAAM,IAAI,MAAM,iDAAiD,YAAY;AAK/E,SAAO;GAAE;GAAW,cAHC,KAAK,MACxB,aAAa,KAAK,WAAW,kBAAkB,EAAE,QAAQ,CAE3B;GAAE,SAAS,YAAY;GAAI;;CAG7D,MAAM,eAAe,MAAM,kBAAkB,KAAK,gBAAgB,KAAK,eAAe;AAEtF,KAAI,aAAa,YAAY;EAC3B,MAAM,EAAE,KAAK,WAAW,YAAY,MAAM,gBAAgB,aAAa,WAAW;AAClF,SAAO;GAAE;GAAW;GAAc;GAAS;;CAG7C,MAAM,cAAc,MAAM,iCACxB,KAAK,gBACL,KAAK,eACN;AACD,KAAI,aAAa,YAAY;EAC3B,MAAM,EAAE,KAAK,WAAW,YAAY,MAAM,gBAAgB,YAAY,WAAW;AACjF,SAAO;GAAE;GAAW,cAAc,YAAY;GAAQ;GAAS;;AAGjE,QAAO;EACL,WAAW;EACX;EACA,SAA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|
21
21
|
"package.json",
|
|
22
22
|
".changeset/config.json",
|
|
23
23
|
".changeset/README.md",
|
|
24
|
-
".github/renovate.json",
|
|
25
24
|
".github/workflows/ci.yml",
|
|
25
|
+
".github/workflows/packages-release.yml",
|
|
26
26
|
".github/workflows/release.yml",
|
|
27
27
|
".opencode/skills/everything-dev/SKILL.md",
|
|
28
28
|
"ui/package.json",
|
|
@@ -200,6 +200,16 @@ async function getSelectedChildPlugins(projectDir, localConfig) {
|
|
|
200
200
|
}
|
|
201
201
|
return selected;
|
|
202
202
|
}
|
|
203
|
+
function hasPluginsWorkspace(projectDir) {
|
|
204
|
+
const packageJsonPath = (0, node_path.join)(projectDir, "package.json");
|
|
205
|
+
if (!(0, node_fs.existsSync)(packageJsonPath)) return false;
|
|
206
|
+
try {
|
|
207
|
+
const workspaces = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8")).workspaces;
|
|
208
|
+
return (Array.isArray(workspaces) ? workspaces : Array.isArray(workspaces?.packages) ? workspaces.packages : []).includes("plugins/*");
|
|
209
|
+
} catch {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
203
213
|
async function syncTemplate(projectDir, options) {
|
|
204
214
|
const localConfig = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(projectDir, "bos.config.json"), "utf-8"));
|
|
205
215
|
let extendsRef;
|
|
@@ -231,6 +241,7 @@ async function syncTemplate(projectDir, options) {
|
|
|
231
241
|
const withUi = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "ui", "package.json"));
|
|
232
242
|
const withApi = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "api", "package.json"));
|
|
233
243
|
const withHost = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "host", "package.json"));
|
|
244
|
+
const withPlugins = childPlugins.length > 0 || hasPluginsWorkspace(projectDir);
|
|
234
245
|
const filteredFiles = /* @__PURE__ */ new Set();
|
|
235
246
|
const destToSource = /* @__PURE__ */ new Map();
|
|
236
247
|
for (const destPath of FRAMEWORK_OWNED_SYNC_FILES) {
|
|
@@ -281,7 +292,7 @@ async function syncTemplate(projectDir, options) {
|
|
|
281
292
|
if (withUi) overrides.push("ui");
|
|
282
293
|
if (withApi) overrides.push("api");
|
|
283
294
|
if (withHost) overrides.push("host");
|
|
284
|
-
if (
|
|
295
|
+
if (withPlugins) overrides.push("plugins");
|
|
285
296
|
await require_cli_init.personalizeConfig(projectDir, {
|
|
286
297
|
extendsAccount,
|
|
287
298
|
extendsGateway,
|