everything-dev 1.3.2 → 1.3.4

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.
@@ -0,0 +1,138 @@
1
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, relative } from "node:path";
3
+ import { glob } from "glob";
4
+
5
+ //#region src/internal/manifest-normalizer.ts
6
+ const FRAMEWORK_PACKAGES = ["every-plugin", "everything-dev"];
7
+ function readJson(filePath) {
8
+ return JSON.parse(readFileSync(filePath, "utf-8"));
9
+ }
10
+ function extractExactVersion(input) {
11
+ if (!input) return null;
12
+ const match = input.match(/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?/);
13
+ return match ? match[0] : null;
14
+ }
15
+ function writeJson(filePath, value) {
16
+ writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
17
+ }
18
+ function loadManifestNormalizationSpec(sourceRootDir) {
19
+ const rootCatalog = { ...readJson(join(sourceRootDir, "package.json")).workspaces?.catalog ?? {} };
20
+ const frameworkVersions = {};
21
+ for (const packageName of FRAMEWORK_PACKAGES) {
22
+ const sourcePackagePath = join(sourceRootDir, "packages", packageName, "package.json");
23
+ const localPackagePath = join(import.meta.dirname, "..", "..", packageName, "package.json");
24
+ const packageVersion = existsSync(sourcePackagePath) ? readJson(sourcePackagePath).version : existsSync(localPackagePath) ? readJson(localPackagePath).version : extractExactVersion(rootCatalog[packageName]);
25
+ if (!packageVersion) throw new Error(`Could not resolve version for ${packageName}`);
26
+ frameworkVersions[packageName] = packageVersion;
27
+ rootCatalog[packageName] = `^${packageVersion}`;
28
+ }
29
+ return {
30
+ rootCatalog,
31
+ frameworkVersions
32
+ };
33
+ }
34
+ function normalizeDependencyMap(map, spec, options) {
35
+ let modified = false;
36
+ for (const [name, version] of Object.entries(map)) {
37
+ if (version === "workspace:*") {
38
+ const frameworkVersion = spec.frameworkVersions[name];
39
+ if (frameworkVersion) {
40
+ map[name] = `^${frameworkVersion}`;
41
+ modified = true;
42
+ continue;
43
+ }
44
+ if (options.removeWorkspaceDeps?.includes(name)) {
45
+ delete map[name];
46
+ modified = true;
47
+ }
48
+ continue;
49
+ }
50
+ if (options.resolveCatalogRefs && version.startsWith("catalog:")) {
51
+ const resolved = spec.rootCatalog[name];
52
+ if (resolved) {
53
+ map[name] = resolved;
54
+ modified = true;
55
+ }
56
+ }
57
+ }
58
+ return modified;
59
+ }
60
+ function normalizePackageManifest(pkg, spec, options) {
61
+ let modified = false;
62
+ for (const depField of [
63
+ "dependencies",
64
+ "devDependencies",
65
+ "peerDependencies"
66
+ ]) {
67
+ const deps = pkg[depField];
68
+ if (!deps || typeof deps !== "object") continue;
69
+ if (normalizeDependencyMap(deps, spec, options)) modified = true;
70
+ }
71
+ if (pkg.workspaces && typeof pkg.workspaces === "object") {
72
+ const workspaces = pkg.workspaces;
73
+ if (options.excludeFrameworkWorkspaces && Array.isArray(workspaces.packages)) {
74
+ const nextPackages = workspaces.packages.filter((entry) => !FRAMEWORK_PACKAGES.some((name) => entry === `packages/${name}`));
75
+ if (nextPackages.length !== workspaces.packages.length) {
76
+ workspaces.packages = nextPackages;
77
+ modified = true;
78
+ }
79
+ }
80
+ if (workspaces.catalog && typeof workspaces.catalog === "object") for (const [name, version] of Object.entries(workspaces.catalog)) {
81
+ const resolved = spec.rootCatalog[name];
82
+ if (resolved && resolved !== version) {
83
+ workspaces.catalog[name] = resolved;
84
+ modified = true;
85
+ continue;
86
+ }
87
+ if (version === "workspace:*" && spec.frameworkVersions[name]) {
88
+ workspaces.catalog[name] = `^${spec.frameworkVersions[name]}`;
89
+ modified = true;
90
+ }
91
+ }
92
+ }
93
+ if (options.removeWorkspaces && "workspaces" in pkg) {
94
+ delete pkg.workspaces;
95
+ modified = true;
96
+ }
97
+ if (options.removePublishScripts && pkg.scripts && typeof pkg.scripts === "object") {
98
+ const scripts = pkg.scripts;
99
+ let scriptsModified = false;
100
+ for (const key of [
101
+ "prepublishOnly",
102
+ "prepack",
103
+ "prepare",
104
+ "postpack"
105
+ ]) if (key in scripts) {
106
+ delete scripts[key];
107
+ scriptsModified = true;
108
+ }
109
+ if (scriptsModified) {
110
+ modified = true;
111
+ if (Object.keys(scripts).length === 0) delete pkg.scripts;
112
+ }
113
+ }
114
+ return modified;
115
+ }
116
+ async function normalizePackageManifestsInTree(opts) {
117
+ const spec = loadManifestNormalizationSpec(opts.sourceRootDir);
118
+ const files = await glob("**/package.json", {
119
+ cwd: opts.targetDir,
120
+ nodir: true,
121
+ dot: false,
122
+ absolute: true,
123
+ ignore: ["**/node_modules/**"]
124
+ });
125
+ const updatedFiles = [];
126
+ for (const filePath of files) {
127
+ const pkg = readJson(filePath);
128
+ if (normalizePackageManifest(pkg, spec, opts)) {
129
+ writeJson(filePath, pkg);
130
+ updatedFiles.push(filePath);
131
+ }
132
+ }
133
+ return updatedFiles;
134
+ }
135
+
136
+ //#endregion
137
+ export { loadManifestNormalizationSpec, normalizePackageManifestsInTree };
138
+ //# sourceMappingURL=manifest-normalizer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-normalizer.mjs","names":[],"sources":["../../src/internal/manifest-normalizer.ts"],"sourcesContent":["import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative, sep } from \"node:path\";\nimport { glob } from \"glob\";\n\nconst FRAMEWORK_PACKAGES = [\"every-plugin\", \"everything-dev\"] as const;\n\ntype PackageJson = Record<string, unknown>;\n\ntype NormalizationSpec = {\n rootCatalog: Record<string, string>;\n frameworkVersions: Record<string, string>;\n};\n\ntype NormalizeManifestOptions = {\n resolveCatalogRefs: boolean;\n excludeFrameworkWorkspaces?: boolean;\n removeWorkspaceDeps?: string[];\n removeWorkspaces?: boolean;\n removePublishScripts?: boolean;\n};\n\nexport type NormalizeTreeOptions = NormalizeManifestOptions & {\n sourceRootDir: string;\n targetDir: string;\n};\n\nfunction readJson<T>(filePath: string): T {\n return JSON.parse(readFileSync(filePath, \"utf-8\")) as T;\n}\n\nfunction extractExactVersion(input: string | undefined): string | null {\n if (!input) return null;\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : null;\n}\n\nfunction writeJson(filePath: string, value: PackageJson) {\n writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\\n`);\n}\n\nexport function loadManifestNormalizationSpec(sourceRootDir: string): NormalizationSpec {\n const rootPackage = readJson<PackageJson>(join(sourceRootDir, \"package.json\"));\n const rootCatalog = {\n ...(((rootPackage.workspaces as { catalog?: Record<string, string> } | undefined)?.catalog ??\n {}) as Record<string, string>),\n };\n const frameworkVersions: Record<string, string> = {};\n\n for (const packageName of FRAMEWORK_PACKAGES) {\n const sourcePackagePath = join(sourceRootDir, \"packages\", packageName, \"package.json\");\n const localPackagePath = join(import.meta.dirname, \"..\", \"..\", packageName, \"package.json\");\n const packageVersion = existsSync(sourcePackagePath)\n ? readJson<{ version: string }>(sourcePackagePath).version\n : existsSync(localPackagePath)\n ? readJson<{ version: string }>(localPackagePath).version\n : extractExactVersion(rootCatalog[packageName]);\n\n if (!packageVersion) {\n throw new Error(`Could not resolve version for ${packageName}`);\n }\n\n frameworkVersions[packageName] = packageVersion;\n rootCatalog[packageName] = `^${packageVersion}`;\n }\n\n return { rootCatalog, frameworkVersions };\n}\n\nfunction normalizeDependencyMap(\n map: Record<string, string>,\n spec: NormalizationSpec,\n options: NormalizeManifestOptions,\n) {\n let modified = false;\n\n for (const [name, version] of Object.entries(map)) {\n if (version === \"workspace:*\") {\n const frameworkVersion = spec.frameworkVersions[name];\n if (frameworkVersion) {\n map[name] = `^${frameworkVersion}`;\n modified = true;\n continue;\n }\n\n if (options.removeWorkspaceDeps?.includes(name)) {\n delete map[name];\n modified = true;\n }\n continue;\n }\n\n if (options.resolveCatalogRefs && version.startsWith(\"catalog:\")) {\n const resolved = spec.rootCatalog[name];\n if (resolved) {\n map[name] = resolved;\n modified = true;\n }\n }\n }\n\n return modified;\n}\n\nexport function normalizePackageManifest(\n pkg: PackageJson,\n spec: NormalizationSpec,\n options: NormalizeManifestOptions,\n) {\n let modified = false;\n\n for (const depField of [\"dependencies\", \"devDependencies\", \"peerDependencies\"]) {\n const deps = pkg[depField];\n if (!deps || typeof deps !== \"object\") continue;\n if (normalizeDependencyMap(deps as Record<string, string>, spec, options)) {\n modified = true;\n }\n }\n\n if (pkg.workspaces && typeof pkg.workspaces === \"object\") {\n const workspaces = pkg.workspaces as {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n\n if (options.excludeFrameworkWorkspaces && Array.isArray(workspaces.packages)) {\n const nextPackages = workspaces.packages.filter(\n (entry) => !FRAMEWORK_PACKAGES.some((name) => entry === `packages/${name}`),\n );\n if (nextPackages.length !== workspaces.packages.length) {\n workspaces.packages = nextPackages;\n modified = true;\n }\n }\n\n if (workspaces.catalog && typeof workspaces.catalog === \"object\") {\n for (const [name, version] of Object.entries(workspaces.catalog)) {\n const resolved = spec.rootCatalog[name];\n if (resolved && resolved !== version) {\n workspaces.catalog[name] = resolved;\n modified = true;\n continue;\n }\n\n if (version === \"workspace:*\" && spec.frameworkVersions[name]) {\n workspaces.catalog[name] = `^${spec.frameworkVersions[name]}`;\n modified = true;\n }\n }\n }\n }\n\n if (options.removeWorkspaces && \"workspaces\" in pkg) {\n delete pkg.workspaces;\n modified = true;\n }\n\n if (options.removePublishScripts && pkg.scripts && typeof pkg.scripts === \"object\") {\n const scripts = pkg.scripts as Record<string, string>;\n let scriptsModified = false;\n for (const key of [\"prepublishOnly\", \"prepack\", \"prepare\", \"postpack\"]) {\n if (key in scripts) {\n delete scripts[key];\n scriptsModified = true;\n }\n }\n if (scriptsModified) {\n modified = true;\n if (Object.keys(scripts).length === 0) {\n delete pkg.scripts;\n }\n }\n }\n\n return modified;\n}\n\nexport async function normalizePackageManifestsInTree(opts: NormalizeTreeOptions) {\n const spec = loadManifestNormalizationSpec(opts.sourceRootDir);\n const files = await glob(\"**/package.json\", {\n cwd: opts.targetDir,\n nodir: true,\n dot: false,\n absolute: true,\n ignore: [\"**/node_modules/**\"],\n });\n\n const updatedFiles: string[] = [];\n\n for (const filePath of files) {\n const pkg = readJson<PackageJson>(filePath);\n if (normalizePackageManifest(pkg, spec, opts)) {\n writeJson(filePath, pkg);\n updatedFiles.push(filePath);\n }\n }\n\n return updatedFiles;\n}\n\nfunction shouldCopyPackageFile(sourceDir: string, filePath: string) {\n const relPath = relative(sourceDir, filePath);\n if (!relPath) return true;\n const segments = relPath.split(sep);\n return !segments.includes(\"node_modules\") && !segments.includes(\"tests\");\n}\n\nexport function stageReleasePackage(opts: {\n repoRoot: string;\n packageName: string;\n outDir: string;\n}) {\n const sourceDir = join(opts.repoRoot, \"packages\", opts.packageName);\n\n rmSync(opts.outDir, { recursive: true, force: true });\n mkdirSync(dirname(opts.outDir), { recursive: true });\n cpSync(sourceDir, opts.outDir, {\n recursive: true,\n filter: (filePath) => shouldCopyPackageFile(sourceDir, filePath),\n });\n rmSync(join(opts.outDir, \"tests\"), { recursive: true, force: true });\n\n const packageJsonPath = join(opts.outDir, \"package.json\");\n const spec = loadManifestNormalizationSpec(opts.repoRoot);\n const pkg = readJson<PackageJson>(packageJsonPath);\n\n normalizePackageManifest(pkg, spec, {\n resolveCatalogRefs: true,\n removeWorkspaces: true,\n removePublishScripts: true,\n });\n\n writeJson(packageJsonPath, pkg);\n}\n\nexport function stageReleasePackages(opts: {\n repoRoot: string;\n outDir: string;\n packageNames?: string[];\n}) {\n const packageNames = opts.packageNames ?? [...FRAMEWORK_PACKAGES];\n rmSync(opts.outDir, { recursive: true, force: true });\n mkdirSync(opts.outDir, { recursive: true });\n\n for (const packageName of packageNames) {\n stageReleasePackage({\n repoRoot: opts.repoRoot,\n packageName,\n outDir: join(opts.outDir, packageName),\n });\n }\n}\n"],"mappings":";;;;;AAIA,MAAM,qBAAqB,CAAC,gBAAgB,iBAAiB;AAsB7D,SAAS,SAAY,UAAqB;AACxC,QAAO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;AACf,qBAAkB;;AAGtB,MAAI,iBAAiB;AACnB,cAAW;AACX,OAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,EAClC,QAAO,IAAI;;;AAKjB,QAAO;;AAGT,eAAsB,gCAAgC,MAA4B;CAChF,MAAM,OAAO,8BAA8B,KAAK,cAAc;CAC9D,MAAM,QAAQ,MAAM,KAAK,mBAAmB;EAC1C,KAAK,KAAK;EACV,OAAO;EACP,KAAK;EACL,UAAU;EACV,QAAQ,CAAC,qBAAqB;EAC/B,CAAC;CAEF,MAAM,eAAyB,EAAE;AAEjC,MAAK,MAAM,YAAY,OAAO;EAC5B,MAAM,MAAM,SAAsB,SAAS;AAC3C,MAAI,yBAAyB,KAAK,MAAM,KAAK,EAAE;AAC7C,aAAU,UAAU,IAAI;AACxB,gBAAa,KAAK,SAAS;;;AAI/B,QAAO"}
package/dist/plugin.cjs CHANGED
@@ -189,6 +189,8 @@ async function buildEnvVars(config, bosConfig) {
189
189
  return env;
190
190
  }
191
191
  async function buildEveryPluginQuietly(cwd) {
192
+ const packageDir = `${cwd}/packages/every-plugin`;
193
+ if (!await Bun.file(`${packageDir}/package.json`).exists()) return;
192
194
  const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;
193
195
  if (await Bun.file(distPath).exists()) return;
194
196
  const result = await require_run.run("bun", [
@@ -209,6 +211,8 @@ async function buildEveryPluginQuietly(cwd) {
209
211
  throw new Error(`bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`);
210
212
  }
211
213
  async function buildEverythingDevQuietly(cwd) {
214
+ const packageDir = `${cwd}/packages/everything-dev`;
215
+ if (!await Bun.file(`${packageDir}/package.json`).exists()) return;
212
216
  const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;
213
217
  if (await Bun.file(distPath).exists()) return;
214
218
  const result = await require_run.run("bun", [
@@ -783,7 +787,8 @@ var plugin_default = (0, every_plugin.createPlugin)({
783
787
  parentAccount: account,
784
788
  parentGateway: gateway,
785
789
  name: name || account,
786
- domain: domain || gateway
790
+ domain: domain || gateway,
791
+ workspaceOpts: { sourceDir }
787
792
  });
788
793
  if (!input.noInstall) await require_cli_init.runBunInstall(destination);
789
794
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":["resolveLocalDevelopmentPath","loadConfig","syncApiContractBridge","run","fetchBosConfigFromFastKv","syncAndGenerateSharedUi","z","bosContract","Effect","getProjectRoot","detectLocalPackages","getHostDevelopmentPort","prepareDevelopmentRuntimeConfig","buildRuntimeConfig","parsePort","buildRuntimePluginsForConfig","resolveDevelopmentHostUrl","getNetworkIdForAccount","buildRegistryConfigUrlForNetwork","ensureNearCli","executeTransaction","getRegistryNamespaceForNetwork","getRegistryNamespaceForAccount","addFunctionCallAccessKey","promptInitOptions","resolveSourceDir","readTemplatekeep","copyFilteredFiles","personalizeConfig","runBunInstall"],"sources":["../src/plugin.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, join, resolve } from \"node:path\";\nimport { Effect } from \"effect\";\nimport { syncApiContractBridge } from \"./api-contract\";\nimport { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from \"./app\";\nimport {\n copyFilteredFiles,\n personalizeConfig,\n readTemplatekeep,\n resolveSourceDir,\n runBunInstall,\n} from \"./cli/init\";\nimport { promptInitOptions } from \"./cli/prompts\";\nimport {\n buildRuntimePluginsForConfig,\n getHostDevelopmentPort,\n getProjectRoot,\n loadConfig,\n parsePort,\n resolveDevelopmentHostUrl,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport {\n type BosConfigResult,\n type BuildOptions,\n bosContract,\n type DevOptions,\n type InitOptions,\n type KeyPublishOptions,\n type PluginAddOptions,\n type PluginListResult,\n type PluginPublishOptions,\n type PluginRemoveOptions,\n type PublishOptions,\n type StartOptions,\n} from \"./contract\";\nimport { type AppConfig, type AppOrchestrator, startApp } from \"./dev-session\";\nimport {\n buildRegistryConfigUrlForNetwork,\n fetchBosConfigFromFastKv,\n getRegistryNamespaceForAccount,\n getRegistryNamespaceForNetwork,\n} from \"./fastkv\";\nimport { addFunctionCallAccessKey, ensureNearCli, executeTransaction } from \"./near-cli\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport { createPlugin, z } from \"./sdk\";\nimport { syncAndGenerateSharedUi } from \"./shared\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\nimport { run } from \"./utils/run\";\n\nconst DEFAULT_DEV_CONFIG: AppConfig = {\n host: \"local\",\n ui: \"local\",\n api: \"local\",\n ssr: false,\n};\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\n};\n\nconst PUBLISH_FUNCTION_NAMES = [\"__fastdata_kv\"];\n\ntype BosDeps = {\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n configDir: string;\n};\n\ntype PluginAttachmentConfig = NonNullable<BosConfig[\"plugins\"]>[string];\n\nfunction parseSourceMode(value: string | undefined, defaultValue: SourceMode): SourceMode {\n if (value === \"local\" || value === \"remote\") return value;\n return defaultValue;\n}\n\nfunction buildAppConfig(options: {\n host?: string;\n ui?: string;\n api?: string;\n proxy?: boolean;\n ssr?: boolean;\n}): AppConfig {\n return {\n host: parseSourceMode(options.host, DEFAULT_DEV_CONFIG.host),\n ui: parseSourceMode(options.ui, DEFAULT_DEV_CONFIG.ui),\n api: parseSourceMode(options.api, DEFAULT_DEV_CONFIG.api),\n proxy: options.proxy,\n ssr: options.ssr ?? DEFAULT_DEV_CONFIG.ssr,\n };\n}\n\nfunction buildDescription(config: AppConfig): string {\n if (config.host === \"local\" && config.ui === \"local\" && config.api === \"local\" && !config.proxy) {\n return \"Full Local Development\";\n }\n\n const parts: string[] = [];\n parts.push(config.host === \"remote\" ? \"Remote Host\" : \"Local Host\");\n if (config.ui === \"remote\") parts.push(\"Remote UI\");\n if (config.proxy) parts.push(\"Proxy API → Production\");\n else if (config.api === \"remote\") parts.push(\"Remote API\");\n return parts.join(\" + \");\n}\n\nfunction buildConfigResult(bosConfig: BosConfig | null): BosConfigResult {\n const packages = bosConfig ? Object.keys(bosConfig.app) : [];\n const remotes = packages.filter((name) => name !== \"host\");\n\n return {\n config: bosConfig,\n packages,\n remotes,\n };\n}\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.plugins?.[key]?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\n}\n\nfunction determineProcesses(\n config: AppConfig,\n localPackages: string[],\n runtimeConfig?: RuntimeConfig | null,\n): string[] {\n const processes: string[] = [];\n if (config.ssr && config.ui === \"local\") processes.push(\"ui-ssr\");\n if (config.ui === \"local\") processes.push(\"ui\");\n if (config.api === \"local\" && !config.proxy) processes.push(\"api\");\n for (const pkg of localPackages) {\n if (pkg.startsWith(\"plugin:\")) {\n const pluginId = pkg.slice(\"plugin:\".length);\n if (runtimeConfig?.plugins?.[pluginId]?.source === \"local\") {\n processes.push(pkg);\n }\n }\n }\n processes.push(\"host\");\n return processes;\n}\n\nfunction isValidProxyUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n\nfunction resolveProxyUrl(bosConfig: BosConfig | null): string | null {\n if (!bosConfig) return null;\n const apiConfig = bosConfig.app.api;\n if (!apiConfig) return null;\n if (apiConfig.proxy && isValidProxyUrl(apiConfig.proxy)) return apiConfig.proxy;\n if (apiConfig.production && isValidProxyUrl(apiConfig.production)) return apiConfig.production;\n return null;\n}\n\nfunction sanitizePluginKey(value: string): string {\n return value\n .replace(/[^A-Za-z0-9/_-]/g, \"-\")\n .replace(/\\/+/g, \"/\")\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, \"-\"))\n .join(\"/\")\n .replace(/^\\/+|\\/+$/g, \"\");\n}\n\nfunction defaultPluginKey(source: string): string {\n const normalized = source.replace(/^local:/, \"\").replace(/\\/$/, \"\");\n if (source.startsWith(\"local:\")) {\n return sanitizePluginKey(basename(normalized)) || \"plugin\";\n }\n\n try {\n const url = new URL(source);\n return sanitizePluginKey(basename(url.pathname) || url.hostname) || \"plugin\";\n } catch {\n return sanitizePluginKey(source) || \"plugin\";\n }\n}\n\nfunction pluginLocalPath(configDir: string, attachment: PluginAttachmentConfig): string | null {\n const source = attachment.development ?? attachment.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nasync function saveBosConfig(configDir: string, config: BosConfig): Promise<void> {\n const filePath = join(configDir, \"bos.config.json\");\n const next = `${JSON.stringify(config, null, 2)}\\n`;\n try {\n if (readFileSync(filePath, \"utf8\") === next) return;\n } catch {\n // file does not exist yet\n }\n\n writeFileSync(filePath, next);\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => ({\n key,\n development: attachment.development,\n production: attachment.production,\n localPath: attachment.development?.startsWith(\"local:\")\n ? attachment.development.slice(\"local:\".length)\n : undefined,\n source: attachment.development?.startsWith(\"local:\")\n ? (\"local\" as const)\n : (\"remote\" as const),\n }))\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n\nasync function refreshApiContractBridge(configDir: string): Promise<void> {\n const refreshed = await loadConfig({ cwd: configDir, env: \"development\" });\n if (!refreshed) return;\n\n await syncApiContractBridge({\n configDir,\n runtimeConfig: refreshed.runtime,\n apiBaseUrl: refreshed.runtime.api.url,\n });\n}\n\nfunction extractPublishedUrl(output: string): string | null {\n const match = output.match(/https?:\\/\\/[^\\s\"'<>]+/g);\n if (!match || match.length === 0) return null;\n return match[match.length - 1] ?? null;\n}\n\nasync function buildEnvVars(\n config: AppConfig,\n bosConfig?: BosConfig | null,\n): Promise<Record<string, string>> {\n const env: Record<string, string> = {\n HOST_SOURCE: config.host,\n UI_SOURCE: config.ui,\n API_SOURCE: config.api,\n };\n\n if (config.host === \"remote\") {\n const remoteUrl = bosConfig?.app.host.production;\n if (remoteUrl) env.HOST_REMOTE_URL = remoteUrl;\n }\n\n if (config.ui === \"remote\") {\n const remoteUrl = bosConfig?.app.ui.production;\n if (remoteUrl) env.UI_REMOTE_URL = remoteUrl;\n }\n\n if (config.api === \"remote\") {\n const remoteUrl = bosConfig?.app.api.production;\n if (remoteUrl) env.API_REMOTE_URL = remoteUrl;\n }\n\n if (config.proxy && bosConfig) {\n const proxyUrl = resolveProxyUrl(bosConfig);\n if (proxyUrl) env.API_PROXY = proxyUrl;\n }\n\n return env;\n}\n\nasync function buildEveryPluginQuietly(cwd: string) {\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[build:ssr] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function buildEverythingDevQuietly(cwd: string) {\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[everything-dev] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function fetchPublishedConfig(\n accountId: string,\n gatewayId: string,\n): Promise<BosConfig | null> {\n try {\n return await fetchBosConfigFromFastKv<BosConfig>(`bos://${accountId}/${gatewayId}`);\n } catch {\n return null;\n }\n}\n\nfunction selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\nasync function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n}): Promise<{ built: string[]; skipped: string[] }> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await Bun.file(`${resolved.path}/package.json`).exists();\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n if (existing.some((entry) => entry.key === \"api\")) {\n await buildEveryPluginQuietly(opts.configDir);\n }\n\n await buildEverythingDevQuietly(opts.configDir);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n const built: string[] = [];\n\n for (const resolved of orderedExisting) {\n const pkgJson = JSON.parse(await Bun.file(`${resolved.path}/package.json`).text()) as {\n scripts?: Record<string, string>;\n };\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[resolved.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n\n return { built, skipped };\n}\n\nexport default createPlugin({\n variables: z.object({\n configPath: z.string().optional(),\n }),\n secrets: z.object({}),\n contract: bosContract,\n initialize: (config: any) =>\n Effect.promise(async () => {\n const configResult = await loadConfig({ path: config.variables.configPath });\n return {\n bosConfig: configResult?.config ?? null,\n runtimeConfig: configResult?.runtime ?? null,\n configDir: getProjectRoot(),\n } satisfies BosDeps;\n }),\n shutdown: () => Effect.void,\n createRouter: (deps: BosDeps, builder: any) => ({\n config: builder.config.handler(async () => buildConfigResult(deps.bosConfig)),\n\n pluginAdd: builder.pluginAdd.handler(async ({ input }: { input: PluginAddOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: \"No bos.config.json found\",\n };\n }\n\n const key = sanitizePluginKey(input.as ?? defaultPluginKey(input.source));\n const existing = deps.bosConfig.plugins?.[key];\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n\n nextPlugins[key] = input.source.startsWith(\"local:\")\n ? {\n ...(existing ?? {}),\n development: input.source,\n production: input.production ?? existing?.production,\n }\n : {\n ...(existing ?? {}),\n production: input.production ?? input.source,\n };\n\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: nextPlugins,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"added\" as const,\n key,\n development: deps.bosConfig.plugins?.[key]?.development,\n production: deps.bosConfig.plugins?.[key]?.production,\n };\n }),\n\n pluginRemove: builder.pluginRemove.handler(\n async ({ input }: { input: PluginRemoveOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: \"No bos.config.json found\",\n };\n }\n\n if (!deps.bosConfig.plugins?.[input.key]) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n delete nextPlugins[input.key];\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : undefined,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\n },\n ),\n\n pluginList: builder.pluginList.handler(async () => {\n const plugins: PluginListResult[\"plugins\"] = listPluginAttachments(deps.bosConfig);\n return {\n status: \"listed\" as const,\n plugins,\n };\n }),\n\n pluginPublish: builder.pluginPublish.handler(\n async ({ input }: { input: PluginPublishOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: \"No bos.config.json found\",\n };\n }\n\n const attachment = deps.bosConfig.plugins?.[input.key];\n if (!attachment) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const localPath = pluginLocalPath(deps.configDir, attachment);\n if (!localPath) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' does not have a local development path`,\n };\n }\n\n const pkgPath = join(localPath, \"package.json\");\n if (!(await Bun.file(pkgPath).exists())) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Missing package.json at ${localPath}`,\n };\n }\n\n const pkgJson = (await Bun.file(pkgPath).json()) as { scripts?: Record<string, string> };\n const script = pkgJson.scripts?.deploy ? \"deploy\" : \"build\";\n\n const { stdout, stderr, exitCode } = (await run(\"bun\", [\"run\", script], {\n cwd: localPath,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (exitCode !== 0) {\n if (stdout.trim()) process.stdout.write(stdout);\n if (stderr.trim()) process.stderr.write(stderr);\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Publish failed with exit code ${exitCode}`,\n };\n }\n\n if (stdout.trim()) process.stdout.write(stdout);\n if (stderr.trim()) process.stderr.write(stderr);\n\n const publishedUrl = extractPublishedUrl(`${stdout}\\n${stderr}`);\n if (publishedUrl) {\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: {\n ...(deps.bosConfig.plugins ?? {}),\n [input.key]: {\n ...(deps.bosConfig.plugins?.[input.key] ?? {}),\n production: publishedUrl,\n },\n },\n };\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n script,\n production: publishedUrl ?? attachment.production,\n };\n },\n ),\n\n dev: builder.dev.handler(async ({ input }: { input: DevOptions }) => {\n const localPackages = detectLocalPackages(\n deps.bosConfig ?? undefined,\n deps.runtimeConfig ?? undefined,\n );\n\n const appConfig = buildAppConfig({\n host: localPackages.includes(\"host\") ? (input.host as string) : \"remote\",\n ui: localPackages.includes(\"ui\") ? (input.ui as string) : \"remote\",\n api: localPackages.includes(\"api\") ? (input.api as string) : \"remote\",\n proxy: input.proxy,\n ssr: input.ssr,\n });\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: deps.configDir,\n hostMode: appConfig.host,\n bosConfig: deps.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: deps.configDir });\n }\n if (\n (appConfig.api === \"local\" && !appConfig.proxy) ||\n localPackages.some((pkg) => pkg.startsWith(\"plugin:\"))\n ) {\n await buildEveryPluginQuietly(deps.configDir);\n }\n\n await buildEverythingDevQuietly(deps.configDir);\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n deps.bosConfig = refreshed?.config ?? deps.bosConfig;\n deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;\n\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n description: \"No bos.config.json found\",\n processes: [],\n };\n }\n\n if (appConfig.proxy && !resolveProxyUrl(deps.bosConfig)) {\n return {\n status: \"error\" as const,\n description: \"No valid proxy URL configured in bos.config.json\",\n processes: [],\n };\n }\n\n const refreshedLocalPackages = detectLocalPackages(\n deps.bosConfig ?? undefined,\n deps.runtimeConfig ?? undefined,\n );\n const processes = determineProcesses(appConfig, refreshedLocalPackages, deps.runtimeConfig);\n const env = await buildEnvVars(appConfig, deps.bosConfig);\n const hostPort = input.port ?? getHostDevelopmentPort(deps.bosConfig.app.host.development);\n const developmentRuntime = buildRuntimeConfig(deps.bosConfig, {\n uiSource: appConfig.ui,\n apiSource: appConfig.api,\n hostUrl: `http://localhost:${hostPort}`,\n proxy: env.API_PROXY,\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n const runtimeConfig = await prepareDevelopmentRuntimeConfig(developmentRuntime, {\n hostPort,\n ssr: appConfig.ssr,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const orchestrator: AppOrchestrator = {\n packages: processes,\n env,\n description: buildDescription(appConfig),\n appConfig,\n bosConfig: deps.bosConfig,\n runtimeConfig,\n port: parsePort(runtimeConfig.hostUrl),\n interactive: input.interactive,\n };\n\n startApp(orchestrator);\n\n return {\n status: \"started\" as const,\n description: orchestrator.description,\n processes,\n };\n }),\n\n start: builder.start.handler(async ({ input }: { input: StartOptions }) => {\n let remoteConfig: BosConfig | null = null;\n\n if (input.account && input.domain) {\n remoteConfig = await fetchPublishedConfig(input.account, input.domain);\n if (!remoteConfig) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n }\n\n const config = remoteConfig || deps.bosConfig;\n if (!config) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n\n const port = input.port ?? getHostDevelopmentPort(config.app.host.development);\n const appConfig: AppConfig = { host: \"remote\", ui: \"remote\", api: \"remote\" };\n const env = await buildEnvVars(appConfig, config);\n const isStaging = input.env === \"staging\";\n const runtimePlugins = remoteConfig\n ? await buildRuntimePluginsForConfig(config, deps.configDir, \"production\")\n : deps.runtimeConfig?.plugins;\n const runtimeConfig = buildRuntimeConfig(config, {\n uiSource: \"remote\",\n apiSource: \"remote\",\n hostUrl: `http://localhost:${port}`,\n env: \"production\",\n plugins: runtimePlugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const stagingEnvVars: Record<string, string> = isStaging\n ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? \"\" }\n : {};\n\n const orchestrator: AppOrchestrator = {\n packages: [\"host\"],\n env: {\n NODE_ENV: \"production\",\n ...env,\n ...stagingEnvVars,\n },\n description: `${isStaging ? \"Staging\" : \"Production\"} Mode (${config.account})`,\n appConfig,\n bosConfig: config,\n runtimeConfig,\n port,\n interactive: input.interactive,\n noLogs: true,\n };\n\n startApp(orchestrator);\n return {\n status: \"running\" as const,\n url: `http://localhost:${port}`,\n };\n }),\n\n build: builder.build.handler(async ({ input }: { input: BuildOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\n\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n if (targets.length === 0) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\n\n const runtimeConfig = buildRuntimeConfig(deps.bosConfig, {\n uiSource: deps.bosConfig.app.ui?.development ? \"local\" : \"remote\",\n apiSource: deps.bosConfig.app.api?.development ? \"local\" : \"remote\",\n hostUrl: resolveDevelopmentHostUrl(deps.bosConfig.app.host.development),\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const { built, skipped } = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: runtimeConfig,\n targets,\n deploy: input.deploy,\n });\n\n if (built.length === 0) {\n return {\n status: \"error\" as const,\n built: [],\n skipped,\n };\n }\n\n return {\n status: \"success\" as const,\n built,\n skipped,\n deployed: input.deploy,\n };\n }),\n\n publish: builder.publish.handler(async ({ input }: { input: PublishOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"No bos.config.json found\",\n };\n }\n\n const account = deps.bosConfig.account;\n const gateway = deps.bosConfig.domain;\n if (!gateway) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"bos.config.json must define domain to publish\",\n };\n }\n\n const network = input.network ?? getNetworkIdForAccount(account);\n const bosUrl = `bos://${account}/${gateway}`;\n const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n\n let publishConfig = deps.bosConfig;\n let built: string[] | undefined;\n let skipped: string[] | undefined;\n\n if (input.dryRun) {\n return {\n status: \"dry-run\" as const,\n registryUrl,\n built,\n skipped,\n };\n }\n\n if (input.deploy) {\n const result = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n targets,\n deploy: true,\n });\n built = result.built;\n skipped = result.skipped;\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n publishConfig = refreshed.config;\n }\n }\n\n const payload = JSON.stringify({\n [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig),\n });\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey =\n input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n try {\n await Effect.runPromise(ensureNearCli);\n let txHash: string | undefined;\n\n try {\n const tx = await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"300Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n txHash = tx.txHash;\n } catch (error) {\n txHash = extractTransactionHash(error);\n\n if (!txHash) {\n throw error;\n }\n\n const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {\n throw error;\n }\n }\n\n return {\n status: \"published\" as const,\n registryUrl,\n txHash,\n built,\n skipped,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl,\n error: error instanceof Error ? error.message : \"Unknown error\",\n built,\n skipped,\n };\n }\n }),\n\n keyPublish: builder.keyPublish.handler(async ({ input }: { input: KeyPublishOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n account: \"\",\n network: \"mainnet\" as const,\n contract: \"\",\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n error: \"No bos.config.json found\",\n };\n }\n\n const account = deps.bosConfig.account;\n const network = getNetworkIdForAccount(account);\n const contract = getRegistryNamespaceForAccount(account);\n try {\n await Effect.runPromise(ensureNearCli);\n const keyPair = await addFunctionCallAccessKey({\n account,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n network,\n });\n\n return {\n status: \"published\" as const,\n account,\n network,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n publicKey: keyPair.publicKey,\n privateKey: keyPair.privateKey,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n account,\n network,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n init: builder.init.handler(async ({ input }: { input: InitOptions }) => {\n try {\n let account = input.account;\n let gateway = input.gateway;\n let destination = input.destination;\n let name = input.name;\n let domain = input.domain;\n let withHost = input.withHost;\n\n if (!account || !gateway) {\n if (input.noInteractive) {\n return {\n status: \"error\" as const,\n destination: \"\",\n parentAccount: account ?? \"\",\n parentGateway: gateway ?? \"\",\n name: input.name,\n domain: input.domain,\n extends: account && gateway ? `bos://${account}/${gateway}` : \"\",\n filesCopied: 0,\n error:\n \"account and gateway are required (use --no-interactive to skip prompts and provide them as positional args)\",\n };\n }\n\n const prompted = await promptInitOptions({\n account,\n gateway,\n destination,\n name,\n domain,\n withHost,\n });\n account = prompted.account;\n gateway = prompted.gateway;\n destination = prompted.destination;\n name = prompted.name;\n domain = prompted.domain;\n withHost = prompted.withHost;\n }\n\n destination = destination || gateway;\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n account,\n gateway,\n source: input.source,\n });\n\n try {\n const patterns = await readTemplatekeep(sourceDir);\n if (patterns.length === 0) {\n return {\n status: \"error\" as const,\n destination,\n parentAccount: account,\n parentGateway: gateway,\n name,\n domain,\n extends: `bos://${account}/${gateway}`,\n filesCopied: 0,\n error: \"No .templatekeep found in template source\",\n };\n }\n\n const filesCopied = await copyFilteredFiles(sourceDir, destination, patterns, {\n withHost,\n });\n\n await personalizeConfig(destination, {\n parentAccount: account,\n parentGateway: gateway,\n name: name || account,\n domain: domain || gateway,\n });\n\n if (!input.noInstall) {\n await runBunInstall(destination);\n }\n\n return {\n status: \"initialized\" as const,\n destination: resolve(destination),\n parentAccount: account,\n parentGateway: gateway,\n name,\n domain,\n extends: `bos://${account}/${gateway}`,\n filesCopied,\n };\n } finally {\n await cleanup();\n }\n } catch (error) {\n return {\n status: \"error\" as const,\n destination: input.destination ?? input.gateway ?? \"\",\n parentAccount: input.account ?? \"\",\n parentGateway: input.gateway ?? \"\",\n name: input.name,\n domain: input.domain,\n extends: input.account && input.gateway ? `bos://${input.account}/${input.gateway}` : \"\",\n filesCopied: 0,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n }),\n});\n\nfunction extractTransactionHash(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n const match =\n message.match(/Transaction ID:\\s*([A-Za-z0-9]+)/i) ||\n message.match(/([A-HJ-NP-Za-km-z1-9]{43,44})/);\n\n return match?.[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,qBAAgC;CACpC,MAAM;CACN,IAAI;CACJ,KAAK;CACL,KAAK;CACN;AAED,MAAM,gBAAiE;CACrE,MAAM;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C,IAAI;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC1C,KAAK;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C;AAED,MAAM,yBAAyB,CAAC,gBAAgB;AAUhD,SAAS,gBAAgB,OAA2B,cAAsC;AACxF,KAAI,UAAU,WAAW,UAAU,SAAU,QAAO;AACpD,QAAO;;AAGT,SAAS,eAAe,SAMV;AACZ,QAAO;EACL,MAAM,gBAAgB,QAAQ,MAAM,mBAAmB,KAAK;EAC5D,IAAI,gBAAgB,QAAQ,IAAI,mBAAm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C,eAAe;MACf,eAAe;MACf,MAAM,QAAQ;MACd,QAAQ,UAAU;MACnB,CAAC;AAEF,SAAI,CAAC,MAAM,UACT,OAAMC,+BAAc,YAAY;AAGlC,YAAO;MACL,QAAQ;MACR,oCAAqB,YAAY;MACjC,eAAe;MACf,eAAe;MACf;MACA;MACA,SAAS,SAAS,QAAQ,GAAG;MAC7B;MACD;cACO;AACR,WAAM,SAAS;;YAEV,OAAO;AACd,WAAO;KACL,QAAQ;KACR,aAAa,MAAM,eAAe,MAAM,WAAW;KACnD,eAAe,MAAM,WAAW;KAChC,eAAe,MAAM,WAAW;KAChC,MAAM,MAAM;KACZ,QAAQ,MAAM;KACd,SAAS,MAAM,WAAW,MAAM,UAAU,SAAS,MAAM,QAAQ,GAAG,MAAM,YAAY;KACtF,aAAa;KACb,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EACH;CACF,CAAC;AAEF,SAAS,uBAAuB,OAAgB;CAC9C,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAKtE,SAHE,QAAQ,MAAM,oCAAoC,IAClD,QAAQ,MAAM,gCAAgC,IAEjC"}
1
+ {"version":3,"file":"plugin.cjs","names":["resolveLocalDevelopmentPath","loadConfig","syncApiContractBridge","run","fetchBosConfigFromFastKv","syncAndGenerateSharedUi","z","bosContract","Effect","getProjectRoot","detectLocalPackages","getHostDevelopmentPort","prepareDevelopmentRuntimeConfig","buildRuntimeConfig","parsePort","buildRuntimePluginsForConfig","resolveDevelopmentHostUrl","getNetworkIdForAccount","buildRegistryConfigUrlForNetwork","ensureNearCli","executeTransaction","getRegistryNamespaceForNetwork","getRegistryNamespaceForAccount","addFunctionCallAccessKey","promptInitOptions","resolveSourceDir","readTemplatekeep","copyFilteredFiles","personalizeConfig","runBunInstall"],"sources":["../src/plugin.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, join, resolve } from \"node:path\";\nimport { Effect } from \"effect\";\nimport { syncApiContractBridge } from \"./api-contract\";\nimport { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from \"./app\";\nimport {\n copyFilteredFiles,\n personalizeConfig,\n readTemplatekeep,\n resolveSourceDir,\n runBunInstall,\n} from \"./cli/init\";\nimport { promptInitOptions } from \"./cli/prompts\";\nimport {\n buildRuntimePluginsForConfig,\n getHostDevelopmentPort,\n getProjectRoot,\n loadConfig,\n parsePort,\n resolveDevelopmentHostUrl,\n resolveLocalDevelopmentPath,\n} from \"./config\";\nimport {\n type BosConfigResult,\n type BuildOptions,\n bosContract,\n type DevOptions,\n type InitOptions,\n type KeyPublishOptions,\n type PluginAddOptions,\n type PluginListResult,\n type PluginPublishOptions,\n type PluginRemoveOptions,\n type PublishOptions,\n type StartOptions,\n} from \"./contract\";\nimport { type AppConfig, type AppOrchestrator, startApp } from \"./dev-session\";\nimport {\n buildRegistryConfigUrlForNetwork,\n fetchBosConfigFromFastKv,\n getRegistryNamespaceForAccount,\n getRegistryNamespaceForNetwork,\n} from \"./fastkv\";\nimport { addFunctionCallAccessKey, ensureNearCli, executeTransaction } from \"./near-cli\";\nimport { getNetworkIdForAccount } from \"./network\";\nimport { createPlugin, z } from \"./sdk\";\nimport { syncAndGenerateSharedUi } from \"./shared\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\nimport { run } from \"./utils/run\";\n\nconst DEFAULT_DEV_CONFIG: AppConfig = {\n host: \"local\",\n ui: \"local\",\n api: \"local\",\n ssr: false,\n};\n\nconst buildCommands: Record<string, { cmd: string; args: string[] }> = {\n host: { cmd: \"bun\", args: [\"run\", \"build\"] },\n ui: { cmd: \"bun\", args: [\"run\", \"build\"] },\n api: { cmd: \"bun\", args: [\"run\", \"build\"] },\n};\n\nconst PUBLISH_FUNCTION_NAMES = [\"__fastdata_kv\"];\n\ntype BosDeps = {\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n configDir: string;\n};\n\ntype PluginAttachmentConfig = NonNullable<BosConfig[\"plugins\"]>[string];\n\nfunction parseSourceMode(value: string | undefined, defaultValue: SourceMode): SourceMode {\n if (value === \"local\" || value === \"remote\") return value;\n return defaultValue;\n}\n\nfunction buildAppConfig(options: {\n host?: string;\n ui?: string;\n api?: string;\n proxy?: boolean;\n ssr?: boolean;\n}): AppConfig {\n return {\n host: parseSourceMode(options.host, DEFAULT_DEV_CONFIG.host),\n ui: parseSourceMode(options.ui, DEFAULT_DEV_CONFIG.ui),\n api: parseSourceMode(options.api, DEFAULT_DEV_CONFIG.api),\n proxy: options.proxy,\n ssr: options.ssr ?? DEFAULT_DEV_CONFIG.ssr,\n };\n}\n\nfunction buildDescription(config: AppConfig): string {\n if (config.host === \"local\" && config.ui === \"local\" && config.api === \"local\" && !config.proxy) {\n return \"Full Local Development\";\n }\n\n const parts: string[] = [];\n parts.push(config.host === \"remote\" ? \"Remote Host\" : \"Local Host\");\n if (config.ui === \"remote\") parts.push(\"Remote UI\");\n if (config.proxy) parts.push(\"Proxy API → Production\");\n else if (config.api === \"remote\") parts.push(\"Remote API\");\n return parts.join(\" + \");\n}\n\nfunction buildConfigResult(bosConfig: BosConfig | null): BosConfigResult {\n const packages = bosConfig ? Object.keys(bosConfig.app) : [];\n const remotes = packages.filter((name) => name !== \"host\");\n\n return {\n config: bosConfig,\n packages,\n remotes,\n };\n}\n\ntype WorkspaceTarget = {\n key: string;\n kind: \"app\" | \"plugin\";\n path: string;\n};\n\nfunction resolveWorkspaceTarget(\n key: string,\n bosConfig: BosConfig | null,\n runtimeConfig: RuntimeConfig | null,\n configDir: string,\n): WorkspaceTarget | null {\n if (bosConfig?.app && key in bosConfig.app) {\n return {\n key,\n kind: \"app\",\n path: `${configDir}/${key}`,\n };\n }\n\n const runtimePlugin = runtimeConfig?.plugins?.[key];\n const pluginPath =\n runtimePlugin?.localPath ??\n resolveLocalDevelopmentPath(bosConfig?.plugins?.[key]?.development, configDir);\n if (pluginPath) {\n return {\n key,\n kind: \"plugin\",\n path: pluginPath,\n };\n }\n\n return null;\n}\n\nfunction determineProcesses(\n config: AppConfig,\n localPackages: string[],\n runtimeConfig?: RuntimeConfig | null,\n): string[] {\n const processes: string[] = [];\n if (config.ssr && config.ui === \"local\") processes.push(\"ui-ssr\");\n if (config.ui === \"local\") processes.push(\"ui\");\n if (config.api === \"local\" && !config.proxy) processes.push(\"api\");\n for (const pkg of localPackages) {\n if (pkg.startsWith(\"plugin:\")) {\n const pluginId = pkg.slice(\"plugin:\".length);\n if (runtimeConfig?.plugins?.[pluginId]?.source === \"local\") {\n processes.push(pkg);\n }\n }\n }\n processes.push(\"host\");\n return processes;\n}\n\nfunction isValidProxyUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n\nfunction resolveProxyUrl(bosConfig: BosConfig | null): string | null {\n if (!bosConfig) return null;\n const apiConfig = bosConfig.app.api;\n if (!apiConfig) return null;\n if (apiConfig.proxy && isValidProxyUrl(apiConfig.proxy)) return apiConfig.proxy;\n if (apiConfig.production && isValidProxyUrl(apiConfig.production)) return apiConfig.production;\n return null;\n}\n\nfunction sanitizePluginKey(value: string): string {\n return value\n .replace(/[^A-Za-z0-9/_-]/g, \"-\")\n .replace(/\\/+/g, \"/\")\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => segment.replace(/[^A-Za-z0-9_-]/g, \"-\"))\n .join(\"/\")\n .replace(/^\\/+|\\/+$/g, \"\");\n}\n\nfunction defaultPluginKey(source: string): string {\n const normalized = source.replace(/^local:/, \"\").replace(/\\/$/, \"\");\n if (source.startsWith(\"local:\")) {\n return sanitizePluginKey(basename(normalized)) || \"plugin\";\n }\n\n try {\n const url = new URL(source);\n return sanitizePluginKey(basename(url.pathname) || url.hostname) || \"plugin\";\n } catch {\n return sanitizePluginKey(source) || \"plugin\";\n }\n}\n\nfunction pluginLocalPath(configDir: string, attachment: PluginAttachmentConfig): string | null {\n const source = attachment.development ?? attachment.production;\n if (!source?.startsWith(\"local:\")) {\n return null;\n }\n\n return join(configDir, source.slice(\"local:\".length));\n}\n\nasync function saveBosConfig(configDir: string, config: BosConfig): Promise<void> {\n const filePath = join(configDir, \"bos.config.json\");\n const next = `${JSON.stringify(config, null, 2)}\\n`;\n try {\n if (readFileSync(filePath, \"utf8\") === next) return;\n } catch {\n // file does not exist yet\n }\n\n writeFileSync(filePath, next);\n}\n\nfunction listPluginAttachments(config: BosConfig | null) {\n return (Object.entries(config?.plugins ?? {}) as Array<[string, PluginAttachmentConfig]>)\n .map(([key, attachment]) => ({\n key,\n development: attachment.development,\n production: attachment.production,\n localPath: attachment.development?.startsWith(\"local:\")\n ? attachment.development.slice(\"local:\".length)\n : undefined,\n source: attachment.development?.startsWith(\"local:\")\n ? (\"local\" as const)\n : (\"remote\" as const),\n }))\n .sort((a, b) => a.key.localeCompare(b.key));\n}\n\nasync function refreshApiContractBridge(configDir: string): Promise<void> {\n const refreshed = await loadConfig({ cwd: configDir, env: \"development\" });\n if (!refreshed) return;\n\n await syncApiContractBridge({\n configDir,\n runtimeConfig: refreshed.runtime,\n apiBaseUrl: refreshed.runtime.api.url,\n });\n}\n\nfunction extractPublishedUrl(output: string): string | null {\n const match = output.match(/https?:\\/\\/[^\\s\"'<>]+/g);\n if (!match || match.length === 0) return null;\n return match[match.length - 1] ?? null;\n}\n\nasync function buildEnvVars(\n config: AppConfig,\n bosConfig?: BosConfig | null,\n): Promise<Record<string, string>> {\n const env: Record<string, string> = {\n HOST_SOURCE: config.host,\n UI_SOURCE: config.ui,\n API_SOURCE: config.api,\n };\n\n if (config.host === \"remote\") {\n const remoteUrl = bosConfig?.app.host.production;\n if (remoteUrl) env.HOST_REMOTE_URL = remoteUrl;\n }\n\n if (config.ui === \"remote\") {\n const remoteUrl = bosConfig?.app.ui.production;\n if (remoteUrl) env.UI_REMOTE_URL = remoteUrl;\n }\n\n if (config.api === \"remote\") {\n const remoteUrl = bosConfig?.app.api.production;\n if (remoteUrl) env.API_REMOTE_URL = remoteUrl;\n }\n\n if (config.proxy && bosConfig) {\n const proxyUrl = resolveProxyUrl(bosConfig);\n if (proxyUrl) env.API_PROXY = proxyUrl;\n }\n\n return env;\n}\n\nasync function buildEveryPluginQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/every-plugin`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/every-plugin\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[build:ssr] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function buildEverythingDevQuietly(cwd: string) {\n const packageDir = `${cwd}/packages/everything-dev`;\n const packageExists = await Bun.file(`${packageDir}/package.json`).exists();\n if (!packageExists) {\n return;\n }\n\n const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;\n const distExists = await Bun.file(distPath).exists();\n\n if (distExists) {\n return;\n }\n\n const result = (await run(\"bun\", [\"run\", \"--cwd\", \"packages/everything-dev\", \"build\"], {\n cwd,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (result.exitCode === 0) {\n console.log(\"[everything-dev] build succeeded\");\n return;\n }\n\n if (result.stdout.trim()) {\n process.stdout.write(result.stdout);\n }\n\n if (result.stderr.trim()) {\n process.stderr.write(result.stderr);\n }\n\n throw new Error(\n `bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`,\n );\n}\n\nasync function fetchPublishedConfig(\n accountId: string,\n gatewayId: string,\n): Promise<BosConfig | null> {\n try {\n return await fetchBosConfigFromFastKv<BosConfig>(`bos://${accountId}/${gatewayId}`);\n } catch {\n return null;\n }\n}\n\nfunction selectWorkspaceTargets(packages: string, bosConfig: BosConfig | null): string[] {\n const allPackages = [\n ...Object.keys(bosConfig?.app ?? {}),\n ...Object.keys(bosConfig?.plugins ?? {}),\n ];\n if (packages === \"all\") {\n return allPackages;\n }\n\n return packages\n .split(\",\")\n .map((pkg) => pkg.trim())\n .filter((pkg) => allPackages.includes(pkg));\n}\n\nasync function buildWorkspaceTargets(opts: {\n configDir: string;\n bosConfig: BosConfig | null;\n runtimeConfig: RuntimeConfig | null;\n targets: string[];\n deploy: boolean;\n}): Promise<{ built: string[]; skipped: string[] }> {\n const existing: WorkspaceTarget[] = [];\n const skipped: string[] = [];\n\n for (const target of opts.targets) {\n const resolved = resolveWorkspaceTarget(\n target,\n opts.bosConfig,\n opts.runtimeConfig,\n opts.configDir,\n );\n if (!resolved) {\n skipped.push(target);\n continue;\n }\n\n const exists = await Bun.file(`${resolved.path}/package.json`).exists();\n if (exists) existing.push(resolved);\n else skipped.push(target);\n }\n\n if (existing.length === 0) {\n return { built: [], skipped };\n }\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: opts.configDir,\n hostMode: \"local\",\n bosConfig: opts.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: opts.configDir });\n }\n\n if (existing.some((entry) => entry.key === \"api\")) {\n await buildEveryPluginQuietly(opts.configDir);\n }\n\n await buildEverythingDevQuietly(opts.configDir);\n\n const env: Record<string, string> = {\n ...process.env,\n NODE_ENV: opts.deploy ? \"production\" : \"development\",\n };\n if (opts.deploy) {\n env.DEPLOY = \"true\";\n } else {\n delete env.DEPLOY;\n }\n\n const orderedExisting = opts.deploy\n ? [\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key !== \"host\"),\n ...existing.filter((entry) => entry.kind === \"plugin\"),\n ...existing.filter((entry) => entry.kind === \"app\" && entry.key === \"host\"),\n ]\n : existing;\n const built: string[] = [];\n\n for (const resolved of orderedExisting) {\n const pkgJson = JSON.parse(await Bun.file(`${resolved.path}/package.json`).text()) as {\n scripts?: Record<string, string>;\n };\n const shouldDeployScript = opts.deploy && pkgJson.scripts?.deploy;\n const buildConfig = shouldDeployScript\n ? { cmd: \"bun\", args: [\"run\", \"deploy\"] }\n : (buildCommands[resolved.key] ?? { cmd: \"bun\", args: [\"run\", \"build\"] });\n\n await run(buildConfig.cmd, buildConfig.args, {\n cwd: resolved.path,\n env,\n });\n built.push(resolved.key);\n }\n\n return { built, skipped };\n}\n\nexport default createPlugin({\n variables: z.object({\n configPath: z.string().optional(),\n }),\n secrets: z.object({}),\n contract: bosContract,\n initialize: (config: any) =>\n Effect.promise(async () => {\n const configResult = await loadConfig({ path: config.variables.configPath });\n return {\n bosConfig: configResult?.config ?? null,\n runtimeConfig: configResult?.runtime ?? null,\n configDir: getProjectRoot(),\n } satisfies BosDeps;\n }),\n shutdown: () => Effect.void,\n createRouter: (deps: BosDeps, builder: any) => ({\n config: builder.config.handler(async () => buildConfigResult(deps.bosConfig)),\n\n pluginAdd: builder.pluginAdd.handler(async ({ input }: { input: PluginAddOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: \"\",\n error: \"No bos.config.json found\",\n };\n }\n\n const key = sanitizePluginKey(input.as ?? defaultPluginKey(input.source));\n const existing = deps.bosConfig.plugins?.[key];\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n\n nextPlugins[key] = input.source.startsWith(\"local:\")\n ? {\n ...(existing ?? {}),\n development: input.source,\n production: input.production ?? existing?.production,\n }\n : {\n ...(existing ?? {}),\n production: input.production ?? input.source,\n };\n\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: nextPlugins,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"added\" as const,\n key,\n development: deps.bosConfig.plugins?.[key]?.development,\n production: deps.bosConfig.plugins?.[key]?.production,\n };\n }),\n\n pluginRemove: builder.pluginRemove.handler(\n async ({ input }: { input: PluginRemoveOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: \"No bos.config.json found\",\n };\n }\n\n if (!deps.bosConfig.plugins?.[input.key]) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const nextPlugins = { ...(deps.bosConfig.plugins ?? {}) };\n delete nextPlugins[input.key];\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : undefined,\n };\n\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n\n return {\n status: \"removed\" as const,\n key: input.key,\n };\n },\n ),\n\n pluginList: builder.pluginList.handler(async () => {\n const plugins: PluginListResult[\"plugins\"] = listPluginAttachments(deps.bosConfig);\n return {\n status: \"listed\" as const,\n plugins,\n };\n }),\n\n pluginPublish: builder.pluginPublish.handler(\n async ({ input }: { input: PluginPublishOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: \"No bos.config.json found\",\n };\n }\n\n const attachment = deps.bosConfig.plugins?.[input.key];\n if (!attachment) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' is not configured`,\n };\n }\n\n const localPath = pluginLocalPath(deps.configDir, attachment);\n if (!localPath) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Plugin '${input.key}' does not have a local development path`,\n };\n }\n\n const pkgPath = join(localPath, \"package.json\");\n if (!(await Bun.file(pkgPath).exists())) {\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Missing package.json at ${localPath}`,\n };\n }\n\n const pkgJson = (await Bun.file(pkgPath).json()) as { scripts?: Record<string, string> };\n const script = pkgJson.scripts?.deploy ? \"deploy\" : \"build\";\n\n const { stdout, stderr, exitCode } = (await run(\"bun\", [\"run\", script], {\n cwd: localPath,\n capture: true,\n })) as { stdout: string; stderr: string; exitCode: number };\n\n if (exitCode !== 0) {\n if (stdout.trim()) process.stdout.write(stdout);\n if (stderr.trim()) process.stderr.write(stderr);\n return {\n status: \"error\" as const,\n key: input.key,\n error: `Publish failed with exit code ${exitCode}`,\n };\n }\n\n if (stdout.trim()) process.stdout.write(stdout);\n if (stderr.trim()) process.stderr.write(stderr);\n\n const publishedUrl = extractPublishedUrl(`${stdout}\\n${stderr}`);\n if (publishedUrl) {\n deps.bosConfig = {\n ...deps.bosConfig,\n plugins: {\n ...(deps.bosConfig.plugins ?? {}),\n [input.key]: {\n ...(deps.bosConfig.plugins?.[input.key] ?? {}),\n production: publishedUrl,\n },\n },\n };\n await saveBosConfig(deps.configDir, deps.bosConfig);\n await refreshApiContractBridge(deps.configDir);\n }\n\n return {\n status: \"published\" as const,\n key: input.key,\n path: localPath,\n script,\n production: publishedUrl ?? attachment.production,\n };\n },\n ),\n\n dev: builder.dev.handler(async ({ input }: { input: DevOptions }) => {\n const localPackages = detectLocalPackages(\n deps.bosConfig ?? undefined,\n deps.runtimeConfig ?? undefined,\n );\n\n const appConfig = buildAppConfig({\n host: localPackages.includes(\"host\") ? (input.host as string) : \"remote\",\n ui: localPackages.includes(\"ui\") ? (input.ui as string) : \"remote\",\n api: localPackages.includes(\"api\") ? (input.api as string) : \"remote\",\n proxy: input.proxy,\n ssr: input.ssr,\n });\n\n const sharedSync = await syncAndGenerateSharedUi({\n configDir: deps.configDir,\n hostMode: appConfig.host,\n bosConfig: deps.bosConfig ?? undefined,\n });\n if (sharedSync.catalogChanged) {\n await run(\"bun\", [\"install\"], { cwd: deps.configDir });\n }\n if (\n (appConfig.api === \"local\" && !appConfig.proxy) ||\n localPackages.some((pkg) => pkg.startsWith(\"plugin:\"))\n ) {\n await buildEveryPluginQuietly(deps.configDir);\n }\n\n await buildEverythingDevQuietly(deps.configDir);\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n deps.bosConfig = refreshed?.config ?? deps.bosConfig;\n deps.runtimeConfig = refreshed?.runtime ?? deps.runtimeConfig;\n\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n description: \"No bos.config.json found\",\n processes: [],\n };\n }\n\n if (appConfig.proxy && !resolveProxyUrl(deps.bosConfig)) {\n return {\n status: \"error\" as const,\n description: \"No valid proxy URL configured in bos.config.json\",\n processes: [],\n };\n }\n\n const refreshedLocalPackages = detectLocalPackages(\n deps.bosConfig ?? undefined,\n deps.runtimeConfig ?? undefined,\n );\n const processes = determineProcesses(appConfig, refreshedLocalPackages, deps.runtimeConfig);\n const env = await buildEnvVars(appConfig, deps.bosConfig);\n const hostPort = input.port ?? getHostDevelopmentPort(deps.bosConfig.app.host.development);\n const developmentRuntime = buildRuntimeConfig(deps.bosConfig, {\n uiSource: appConfig.ui,\n apiSource: appConfig.api,\n hostUrl: `http://localhost:${hostPort}`,\n proxy: env.API_PROXY,\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n const runtimeConfig = await prepareDevelopmentRuntimeConfig(developmentRuntime, {\n hostPort,\n ssr: appConfig.ssr,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const orchestrator: AppOrchestrator = {\n packages: processes,\n env,\n description: buildDescription(appConfig),\n appConfig,\n bosConfig: deps.bosConfig,\n runtimeConfig,\n port: parsePort(runtimeConfig.hostUrl),\n interactive: input.interactive,\n };\n\n startApp(orchestrator);\n\n return {\n status: \"started\" as const,\n description: orchestrator.description,\n processes,\n };\n }),\n\n start: builder.start.handler(async ({ input }: { input: StartOptions }) => {\n let remoteConfig: BosConfig | null = null;\n\n if (input.account && input.domain) {\n remoteConfig = await fetchPublishedConfig(input.account, input.domain);\n if (!remoteConfig) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n }\n\n const config = remoteConfig || deps.bosConfig;\n if (!config) {\n return {\n status: \"error\" as const,\n url: \"\",\n };\n }\n\n const port = input.port ?? getHostDevelopmentPort(config.app.host.development);\n const appConfig: AppConfig = { host: \"remote\", ui: \"remote\", api: \"remote\" };\n const env = await buildEnvVars(appConfig, config);\n const isStaging = input.env === \"staging\";\n const runtimePlugins = remoteConfig\n ? await buildRuntimePluginsForConfig(config, deps.configDir, \"production\")\n : deps.runtimeConfig?.plugins;\n const runtimeConfig = buildRuntimeConfig(config, {\n uiSource: \"remote\",\n apiSource: \"remote\",\n hostUrl: `http://localhost:${port}`,\n env: \"production\",\n plugins: runtimePlugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig: runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const stagingEnvVars: Record<string, string> = isStaging\n ? { GATEWAY_DOMAIN: config.staging?.domain ?? config.domain ?? \"\" }\n : {};\n\n const orchestrator: AppOrchestrator = {\n packages: [\"host\"],\n env: {\n NODE_ENV: \"production\",\n ...env,\n ...stagingEnvVars,\n },\n description: `${isStaging ? \"Staging\" : \"Production\"} Mode (${config.account})`,\n appConfig,\n bosConfig: config,\n runtimeConfig,\n port,\n interactive: input.interactive,\n noLogs: true,\n };\n\n startApp(orchestrator);\n return {\n status: \"running\" as const,\n url: `http://localhost:${port}`,\n };\n }),\n\n build: builder.build.handler(async ({ input }: { input: BuildOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\n\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n if (targets.length === 0) {\n return {\n status: \"error\" as const,\n built: [],\n skipped: [],\n };\n }\n\n const runtimeConfig = buildRuntimeConfig(deps.bosConfig, {\n uiSource: deps.bosConfig.app.ui?.development ? \"local\" : \"remote\",\n apiSource: deps.bosConfig.app.api?.development ? \"local\" : \"remote\",\n hostUrl: resolveDevelopmentHostUrl(deps.bosConfig.app.host.development),\n env: \"development\",\n plugins: deps.runtimeConfig?.plugins,\n });\n\n await syncApiContractBridge({\n configDir: deps.configDir,\n runtimeConfig,\n apiBaseUrl: runtimeConfig.api.url,\n });\n\n const { built, skipped } = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: runtimeConfig,\n targets,\n deploy: input.deploy,\n });\n\n if (built.length === 0) {\n return {\n status: \"error\" as const,\n built: [],\n skipped,\n };\n }\n\n return {\n status: \"success\" as const,\n built,\n skipped,\n deployed: input.deploy,\n };\n }),\n\n publish: builder.publish.handler(async ({ input }: { input: PublishOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"No bos.config.json found\",\n };\n }\n\n const account = deps.bosConfig.account;\n const gateway = deps.bosConfig.domain;\n if (!gateway) {\n return {\n status: \"error\" as const,\n registryUrl: \"\",\n error: \"bos.config.json must define domain to publish\",\n };\n }\n\n const network = input.network ?? getNetworkIdForAccount(account);\n const bosUrl = `bos://${account}/${gateway}`;\n const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);\n const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);\n\n let publishConfig = deps.bosConfig;\n let built: string[] | undefined;\n let skipped: string[] | undefined;\n\n if (input.dryRun) {\n return {\n status: \"dry-run\" as const,\n registryUrl,\n built,\n skipped,\n };\n }\n\n if (input.deploy) {\n const result = await buildWorkspaceTargets({\n configDir: deps.configDir,\n bosConfig: deps.bosConfig,\n runtimeConfig: deps.runtimeConfig,\n targets,\n deploy: true,\n });\n built = result.built;\n skipped = result.skipped;\n\n const refreshed = await loadConfig({ cwd: deps.configDir });\n if (refreshed?.config) {\n deps.bosConfig = refreshed.config;\n deps.runtimeConfig = refreshed.runtime;\n publishConfig = refreshed.config;\n }\n }\n\n const payload = JSON.stringify({\n [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig),\n });\n const argsBase64 = Buffer.from(payload).toString(\"base64\");\n const privateKey =\n input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;\n\n try {\n await Effect.runPromise(ensureNearCli);\n let txHash: string | undefined;\n\n try {\n const tx = await Effect.runPromise(\n executeTransaction({\n account,\n contract: getRegistryNamespaceForNetwork(network),\n method: \"__fastdata_kv\",\n argsBase64,\n network,\n privateKey,\n gas: \"300Tgas\",\n deposit: \"0NEAR\",\n }),\n );\n txHash = tx.txHash;\n } catch (error) {\n txHash = extractTransactionHash(error);\n\n if (!txHash) {\n throw error;\n }\n\n const verifiedConfig = await fetchBosConfigFromFastKv<BosConfig>(bosUrl);\n if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) {\n throw error;\n }\n }\n\n return {\n status: \"published\" as const,\n registryUrl,\n txHash,\n built,\n skipped,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n registryUrl,\n error: error instanceof Error ? error.message : \"Unknown error\",\n built,\n skipped,\n };\n }\n }),\n\n keyPublish: builder.keyPublish.handler(async ({ input }: { input: KeyPublishOptions }) => {\n if (!deps.bosConfig) {\n return {\n status: \"error\" as const,\n account: \"\",\n network: \"mainnet\" as const,\n contract: \"\",\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n error: \"No bos.config.json found\",\n };\n }\n\n const account = deps.bosConfig.account;\n const network = getNetworkIdForAccount(account);\n const contract = getRegistryNamespaceForAccount(account);\n try {\n await Effect.runPromise(ensureNearCli);\n const keyPair = await addFunctionCallAccessKey({\n account,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n network,\n });\n\n return {\n status: \"published\" as const,\n account,\n network,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n publicKey: keyPair.publicKey,\n privateKey: keyPair.privateKey,\n };\n } catch (error) {\n return {\n status: \"error\" as const,\n account,\n network,\n contract,\n allowance: input.allowance,\n functionNames: PUBLISH_FUNCTION_NAMES,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n\n init: builder.init.handler(async ({ input }: { input: InitOptions }) => {\n try {\n let account = input.account;\n let gateway = input.gateway;\n let destination = input.destination;\n let name = input.name;\n let domain = input.domain;\n let withHost = input.withHost;\n\n if (!account || !gateway) {\n if (input.noInteractive) {\n return {\n status: \"error\" as const,\n destination: \"\",\n parentAccount: account ?? \"\",\n parentGateway: gateway ?? \"\",\n name: input.name,\n domain: input.domain,\n extends: account && gateway ? `bos://${account}/${gateway}` : \"\",\n filesCopied: 0,\n error:\n \"account and gateway are required (use --no-interactive to skip prompts and provide them as positional args)\",\n };\n }\n\n const prompted = await promptInitOptions({\n account,\n gateway,\n destination,\n name,\n domain,\n withHost,\n });\n account = prompted.account;\n gateway = prompted.gateway;\n destination = prompted.destination;\n name = prompted.name;\n domain = prompted.domain;\n withHost = prompted.withHost;\n }\n\n destination = destination || gateway;\n\n const { sourceDir, cleanup } = await resolveSourceDir({\n account,\n gateway,\n source: input.source,\n });\n\n try {\n const patterns = await readTemplatekeep(sourceDir);\n if (patterns.length === 0) {\n return {\n status: \"error\" as const,\n destination,\n parentAccount: account,\n parentGateway: gateway,\n name,\n domain,\n extends: `bos://${account}/${gateway}`,\n filesCopied: 0,\n error: \"No .templatekeep found in template source\",\n };\n }\n\n const filesCopied = await copyFilteredFiles(sourceDir, destination, patterns, {\n withHost,\n });\n\n await personalizeConfig(destination, {\n parentAccount: account,\n parentGateway: gateway,\n name: name || account,\n domain: domain || gateway,\n workspaceOpts: { sourceDir },\n });\n\n if (!input.noInstall) {\n await runBunInstall(destination);\n }\n\n return {\n status: \"initialized\" as const,\n destination: resolve(destination),\n parentAccount: account,\n parentGateway: gateway,\n name,\n domain,\n extends: `bos://${account}/${gateway}`,\n filesCopied,\n };\n } finally {\n await cleanup();\n }\n } catch (error) {\n return {\n status: \"error\" as const,\n destination: input.destination ?? input.gateway ?? \"\",\n parentAccount: input.account ?? \"\",\n parentGateway: input.gateway ?? \"\",\n name: input.name,\n domain: input.domain,\n extends: input.account && input.gateway ? `bos://${input.account}/${input.gateway}` : \"\",\n filesCopied: 0,\n error: error instanceof Error ? error.message : \"Unknown error\",\n };\n }\n }),\n }),\n});\n\nfunction extractTransactionHash(error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n const match =\n message.match(/Transaction ID:\\s*([A-Za-z0-9]+)/i) ||\n message.match(/([A-HJ-NP-Za-km-z1-9]{43,44})/);\n\n return match?.[1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,qBAAgC;CACpC,MAAM;CACN,IAAI;CACJ,KAAK;CACL,KAAK;CACN;AAED,MAAM,gBAAiE;CACrE,MAAM;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C,IAAI;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC1C,KAAK;EAAE,KAAK;EAAO,MAAM,CAAC,OAAO,QAAQ;EAAE;CAC5C;AAED,MAAM,yBAAyB,CAAC,gBAAgB;AAUhD,SAAS,gBAAgB,OAA2B,cAAsC;AACxF,KAAI,UAAU,WAAW,UAAU,SAAU,QAAO;AACpD,QAAO;;AAGT,SAAS,eAAe,SAMV;AACZ,QAAO;EACL,MAAM,gBAAgB,QAAQ,MAAM,mBAAmB,KAAK;EAC5D,IAAI,gBAAgB,QAAQ,IAAI,mBAAmB,GAAG;EACtD,KAAK,gBAAgB,QAAQ,KAAK,mBAAmB,IAAI;EACzD,OAAO,QAAQ;EACf,KAAK,QAAQ,OAAO,mBAAmB;EACxC;;AAGH,SAAS,iBAAiB,QAA2B;AACnD,KAAI,OAAO,SAAS,WAAW,OAAO,OAAO,WAAW,OAAO,QAAQ,WAAW,CAAC,OAAO,MACxF,QAAO;CAGT,MAAM,QAAkB,EAAE;AAC1B,OAAM,KAAK,OAAO,SAAS,WAAW,gBAAgB,aAAa;AACnE,KAAI,OAAO,OAAO,SAAU,OAAM,KAAK,YAAY;AACnD,KAAI,OAAO,MAAO,OAAM,KAAK,yBAAyB;UAC7C,OAAO,QAAQ,SAAU,OAAM,KAAK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SAAS,QAAQ,GAAG;MAC7B;MACD;cACO;AACR,WAAM,SAAS;;YAEV,OAAO;AACd,WAAO;KACL,QAAQ;KACR,aAAa,MAAM,eAAe,MAAM,WAAW;KACnD,eAAe,MAAM,WAAW;KAChC,eAAe,MAAM,WAAW;KAChC,MAAM,MAAM;KACZ,QAAQ,MAAM;KACd,SAAS,MAAM,WAAW,MAAM,UAAU,SAAS,MAAM,QAAQ,GAAG,MAAM,YAAY;KACtF,aAAa;KACb,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KACjD;;IAEH;EACH;CACF,CAAC;AAEF,SAAS,uBAAuB,OAAgB;CAC9C,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AAKtE,SAHE,QAAQ,MAAM,oCAAoC,IAClD,QAAQ,MAAM,gCAAgC,IAEjC"}
package/dist/plugin.d.cts CHANGED
@@ -23,8 +23,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
23
23
  interactive: z.ZodOptional<z.ZodBoolean>;
24
24
  }, z.core.$strip>, z.ZodObject<{
25
25
  status: z.ZodEnum<{
26
- error: "error";
27
26
  started: "started";
27
+ error: "error";
28
28
  }>;
29
29
  description: z.ZodString;
30
30
  processes: z.ZodArray<z.ZodString>;
package/dist/plugin.d.mts CHANGED
@@ -23,8 +23,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
23
23
  interactive: z.ZodOptional<z.ZodBoolean>;
24
24
  }, z.core.$strip>, z.ZodObject<{
25
25
  status: z.ZodEnum<{
26
- error: "error";
27
26
  started: "started";
27
+ error: "error";
28
28
  }>;
29
29
  description: z.ZodString;
30
30
  processes: z.ZodArray<z.ZodString>;
package/dist/plugin.mjs CHANGED
@@ -186,6 +186,8 @@ async function buildEnvVars(config, bosConfig) {
186
186
  return env;
187
187
  }
188
188
  async function buildEveryPluginQuietly(cwd) {
189
+ const packageDir = `${cwd}/packages/every-plugin`;
190
+ if (!await Bun.file(`${packageDir}/package.json`).exists()) return;
189
191
  const distPath = `${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`;
190
192
  if (await Bun.file(distPath).exists()) return;
191
193
  const result = await run("bun", [
@@ -206,6 +208,8 @@ async function buildEveryPluginQuietly(cwd) {
206
208
  throw new Error(`bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`);
207
209
  }
208
210
  async function buildEverythingDevQuietly(cwd) {
211
+ const packageDir = `${cwd}/packages/everything-dev`;
212
+ if (!await Bun.file(`${packageDir}/package.json`).exists()) return;
209
213
  const distPath = `${cwd}/packages/everything-dev/dist/index.mjs`;
210
214
  if (await Bun.file(distPath).exists()) return;
211
215
  const result = await run("bun", [
@@ -780,7 +784,8 @@ var plugin_default = createPlugin({
780
784
  parentAccount: account,
781
785
  parentGateway: gateway,
782
786
  name: name || account,
783
- domain: domain || gateway
787
+ domain: domain || gateway,
788
+ workspaceOpts: { sourceDir }
784
789
  });
785
790
  if (!input.noInstall) await runBunInstall(destination);
786
791
  return {