everything-dev 1.45.0 → 1.46.0
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/build.cjs +328 -0
- package/dist/build.cjs.map +1 -0
- package/dist/build.mjs +320 -0
- package/dist/build.mjs.map +1 -0
- package/dist/cli/init.cjs +1 -1
- package/dist/cli/init.mjs +1 -1
- package/dist/cli/sync.cjs +1 -1
- package/dist/cli/sync.mjs +1 -1
- package/dist/cli/upgrade.cjs +2 -2
- package/dist/cli/upgrade.mjs +2 -2
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/code-artifacts.cjs +25 -0
- package/dist/code-artifacts.cjs.map +1 -0
- package/dist/code-artifacts.mjs +24 -0
- package/dist/code-artifacts.mjs.map +1 -0
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +22 -21
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +22 -21
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/integrity.cjs +18 -55
- package/dist/integrity.cjs.map +1 -1
- package/dist/integrity.d.cts +3 -7
- package/dist/integrity.d.cts.map +1 -1
- package/dist/integrity.d.mts +3 -7
- package/dist/integrity.d.mts.map +1 -1
- package/dist/integrity.mjs +18 -53
- package/dist/integrity.mjs.map +1 -1
- package/dist/plugin.cjs +37 -571
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +9 -16
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +9 -16
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +23 -556
- package/dist/plugin.mjs.map +1 -1
- package/dist/publish.cjs +220 -0
- package/dist/publish.cjs.map +1 -0
- package/dist/publish.mjs +217 -0
- package/dist/publish.mjs.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/utils/run.cjs +21 -3
- package/dist/utils/run.cjs.map +1 -1
- package/dist/utils/run.mjs +21 -3
- package/dist/utils/run.mjs.map +1 -1
- package/dist/utils/string.cjs +9 -0
- package/dist/utils/string.cjs.map +1 -0
- package/dist/utils/string.mjs +8 -0
- package/dist/utils/string.mjs.map +1 -0
- package/package.json +1 -1
package/dist/plugin.mjs
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { buildRegistryConfigUrl,
|
|
1
|
+
import { buildRegistryConfigUrl, fetchBosConfigFromFastKv, fetchRemotePluginManifest, getRegistryNamespaceForAccount, parseBosUrl } from "./fastkv.mjs";
|
|
2
2
|
import { mergeBosConfigWithExtends, resolveExtendsRef } from "./merge.mjs";
|
|
3
3
|
import { getNetworkIdForAccount } from "./network.mjs";
|
|
4
4
|
import { BosConfigSchema } from "./types.mjs";
|
|
5
|
-
import { buildRuntimePluginsForConfig, drainConfigWarnings, findConfigPath, getHostDevelopmentPort, getProjectRoot, loadLocalConfig, loadResolvedConfig, resolveConfigComposableEntries,
|
|
5
|
+
import { buildRuntimePluginsForConfig, drainConfigWarnings, findConfigPath, getHostDevelopmentPort, getProjectRoot, loadLocalConfig, loadResolvedConfig, resolveConfigComposableEntries, resumeWarnings, suppressWarnings } from "./config.mjs";
|
|
6
6
|
import { createPlugin, z } from "./sdk.mjs";
|
|
7
7
|
import { bosContract } from "./contract.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { syncApiContractBridge } from "./api-contract.mjs";
|
|
8
|
+
import { computeSriHashForUrl, parseDeployLines } from "./integrity.mjs";
|
|
10
9
|
import { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from "./app.mjs";
|
|
10
|
+
import { syncResolvedSharedDeps } from "./shared-deps.mjs";
|
|
11
|
+
import { run } from "./utils/run.mjs";
|
|
12
|
+
import { colors } from "./utils/theme.mjs";
|
|
13
|
+
import { buildEveryPluginQuietly, buildEverythingDevQuietly, buildWorkspaceTargets, fileExists, getPluginRef, readJsonFile, selectWorkspaceTargets } from "./build.mjs";
|
|
11
14
|
import { ensureEnvFile, loadProjectEnv, syncGeneratedInfra, writeGeneratedInfra } from "./cli/infra.mjs";
|
|
12
15
|
import { saveBosConfig } from "./utils/save-config.mjs";
|
|
13
16
|
import { buildInitPatterns, copyFilteredFiles, detectGitRemoteUrl, fetchParentConfig, generateDatabaseMigrations, personalizeAgentsMd, personalizeConfig, removeInitLockfile, resolveSourceDir, runBunInstall, runTypesGen, scaffoldMinimalProject, stripOrphanedWorkspacesFromLockfile, writeInitSnapshot } from "./cli/init.mjs";
|
|
14
17
|
import { getStatus } from "./cli/status.mjs";
|
|
15
|
-
import { syncResolvedSharedDeps } from "./shared-deps.mjs";
|
|
16
18
|
import { syncTemplate } from "./cli/sync.mjs";
|
|
17
19
|
import { upgradeTemplate } from "./cli/upgrade.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import { addFunctionCallAccessKey, ensureNearCli
|
|
20
|
+
import { generateCodeArtifacts } from "./code-artifacts.mjs";
|
|
21
|
+
import { addFunctionCallAccessKey, ensureNearCli } from "./near-cli.mjs";
|
|
22
|
+
import { extractPublishedUrl, publishToFastKv } from "./publish.mjs";
|
|
20
23
|
import { buildDescription, buildServiceDescriptorMap } from "./service-descriptor.mjs";
|
|
21
|
-
import {
|
|
22
|
-
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
24
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
23
25
|
import { basename, dirname, join, resolve } from "node:path";
|
|
24
26
|
import { Effect } from "effect";
|
|
25
27
|
import { EventEmitter } from "node:events";
|
|
26
|
-
import { access, readFile } from "node:fs/promises";
|
|
27
28
|
import process from "node:process";
|
|
28
29
|
|
|
29
30
|
//#region src/plugin.ts
|
|
@@ -68,25 +69,7 @@ async function timePhase(timings, name, fn) {
|
|
|
68
69
|
throw error;
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
|
-
const buildCommands = {
|
|
72
|
-
host: {
|
|
73
|
-
cmd: "bun",
|
|
74
|
-
args: ["run", "build"]
|
|
75
|
-
},
|
|
76
|
-
ui: {
|
|
77
|
-
cmd: "bun",
|
|
78
|
-
args: ["run", "build"]
|
|
79
|
-
},
|
|
80
|
-
api: {
|
|
81
|
-
cmd: "bun",
|
|
82
|
-
args: ["run", "build"]
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
72
|
const PUBLISH_FUNCTION_NAMES = ["__fastdata_kv"];
|
|
86
|
-
function getPluginRef(entry) {
|
|
87
|
-
if (!entry || typeof entry === "string") return null;
|
|
88
|
-
return entry;
|
|
89
|
-
}
|
|
90
73
|
function parseSourceMode(value, defaultValue) {
|
|
91
74
|
if (value === "local" || value === "remote") return value;
|
|
92
75
|
return defaultValue;
|
|
@@ -101,40 +84,6 @@ function buildConfigResult(bosConfig, full = false) {
|
|
|
101
84
|
full
|
|
102
85
|
};
|
|
103
86
|
}
|
|
104
|
-
async function fileExists(path) {
|
|
105
|
-
try {
|
|
106
|
-
await access(path);
|
|
107
|
-
return true;
|
|
108
|
-
} catch {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function readJsonFile(path) {
|
|
113
|
-
return JSON.parse(await readFile(path, "utf8"));
|
|
114
|
-
}
|
|
115
|
-
function resolveWorkspaceTarget(key, bosConfig, runtimeConfig, configDir) {
|
|
116
|
-
if (bosConfig?.app && key in bosConfig.app) {
|
|
117
|
-
const appEntry = bosConfig.app[key];
|
|
118
|
-
const devPath = resolveLocalDevelopmentPath(appEntry?.development, configDir);
|
|
119
|
-
if (devPath) return {
|
|
120
|
-
key,
|
|
121
|
-
kind: "app",
|
|
122
|
-
path: devPath
|
|
123
|
-
};
|
|
124
|
-
return {
|
|
125
|
-
key,
|
|
126
|
-
kind: "app",
|
|
127
|
-
path: `${configDir}/${key}`
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const pluginPath = (runtimeConfig?.plugins?.[key])?.localPath ?? resolveLocalDevelopmentPath(getPluginRef(bosConfig?.plugins?.[key])?.development, configDir);
|
|
131
|
-
if (pluginPath) return {
|
|
132
|
-
key,
|
|
133
|
-
kind: "plugin",
|
|
134
|
-
path: pluginPath
|
|
135
|
-
};
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
87
|
function isValidProxyUrl(url) {
|
|
139
88
|
try {
|
|
140
89
|
const parsed = new URL(url);
|
|
@@ -185,82 +134,6 @@ function listPluginAttachments(config) {
|
|
|
185
134
|
};
|
|
186
135
|
}).sort((a, b) => a.key.localeCompare(b.key));
|
|
187
136
|
}
|
|
188
|
-
async function generateCodeArtifacts(configDir, config, opts) {
|
|
189
|
-
if (opts?.env) writeResolvedConfig(configDir, config, opts.env, opts.extendsChain);
|
|
190
|
-
const runtimeConfig = opts?.runtimeConfig ?? (await loadResolvedConfig({ cwd: configDir }))?.runtime;
|
|
191
|
-
if (!runtimeConfig) return null;
|
|
192
|
-
const bridge = await syncApiContractBridge({
|
|
193
|
-
configDir,
|
|
194
|
-
runtimeConfig,
|
|
195
|
-
apiBaseUrl: runtimeConfig.api.url
|
|
196
|
-
});
|
|
197
|
-
return {
|
|
198
|
-
resolvedConfigPath: opts?.env ? join(configDir, ".bos/bos.resolved-config.json") : void 0,
|
|
199
|
-
contractBridgePath: bridge.bridgePath,
|
|
200
|
-
contractStatus: bridge.status
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
function extractPublishedUrl(output) {
|
|
204
|
-
const match = output.match(/https?:\/\/[^\s"'<>]+/g);
|
|
205
|
-
if (!match || match.length === 0) return null;
|
|
206
|
-
return match[match.length - 1] ?? null;
|
|
207
|
-
}
|
|
208
|
-
function sleep(ms) {
|
|
209
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
210
|
-
}
|
|
211
|
-
async function waitForPublishedConfig(opts) {
|
|
212
|
-
const envTimeoutMs = Number(process.env.BOS_PUBLISH_CONFIRMATION_TIMEOUT_MS);
|
|
213
|
-
const envIntervalMs = Number(process.env.BOS_PUBLISH_CONFIRMATION_INTERVAL_MS);
|
|
214
|
-
const timeoutMs = opts.timeoutMs ?? (Number.isFinite(envTimeoutMs) ? envTimeoutMs : void 0) ?? 12e4;
|
|
215
|
-
const intervalMs = opts.intervalMs ?? (Number.isFinite(envIntervalMs) ? envIntervalMs : void 0) ?? 3e3;
|
|
216
|
-
const startedAt = Date.now();
|
|
217
|
-
let lastError;
|
|
218
|
-
while (Date.now() - startedAt < timeoutMs) {
|
|
219
|
-
try {
|
|
220
|
-
const verifiedConfig = await fetchBosConfigFromFastKv(`bos://${opts.account}/${opts.gateway}`);
|
|
221
|
-
if (JSON.stringify(verifiedConfig) === JSON.stringify(opts.publishConfig)) return;
|
|
222
|
-
} catch (error) {
|
|
223
|
-
lastError = error;
|
|
224
|
-
}
|
|
225
|
-
await sleep(intervalMs);
|
|
226
|
-
}
|
|
227
|
-
const reason = lastError instanceof Error ? ` Last error: ${lastError.message}` : "";
|
|
228
|
-
throw new Error(`Timed out waiting for publish confirmation at bos://${opts.account}/${opts.gateway}.${reason}`);
|
|
229
|
-
}
|
|
230
|
-
async function buildEveryPluginQuietly(cwd, force = false) {
|
|
231
|
-
if (!await fileExists(`${`${cwd}/packages/every-plugin`}/package.json`)) return;
|
|
232
|
-
if (await fileExists(`${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`) && !force) return;
|
|
233
|
-
const result = await run("bun", [
|
|
234
|
-
"run",
|
|
235
|
-
"--cwd",
|
|
236
|
-
"packages/every-plugin",
|
|
237
|
-
"build"
|
|
238
|
-
], {
|
|
239
|
-
cwd,
|
|
240
|
-
capture: true
|
|
241
|
-
});
|
|
242
|
-
if (result.exitCode === 0) return;
|
|
243
|
-
if (result.stdout.trim()) process.stdout.write(result.stdout);
|
|
244
|
-
if (result.stderr.trim()) process.stderr.write(result.stderr);
|
|
245
|
-
throw new Error(`bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`);
|
|
246
|
-
}
|
|
247
|
-
async function buildEverythingDevQuietly(cwd, force = false) {
|
|
248
|
-
if (!await fileExists(`${`${cwd}/packages/everything-dev`}/package.json`)) return;
|
|
249
|
-
if (await fileExists(`${cwd}/packages/everything-dev/dist/index.mjs`) && !force) return;
|
|
250
|
-
const result = await run("bun", [
|
|
251
|
-
"run",
|
|
252
|
-
"--cwd",
|
|
253
|
-
"packages/everything-dev",
|
|
254
|
-
"build"
|
|
255
|
-
], {
|
|
256
|
-
cwd,
|
|
257
|
-
capture: true
|
|
258
|
-
});
|
|
259
|
-
if (result.exitCode === 0) return;
|
|
260
|
-
if (result.stdout.trim()) process.stdout.write(result.stdout);
|
|
261
|
-
if (result.stderr.trim()) process.stderr.write(result.stderr);
|
|
262
|
-
throw new Error(`bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`);
|
|
263
|
-
}
|
|
264
137
|
async function resolveRemoteConfigChain(accountId, gatewayId, visited) {
|
|
265
138
|
const selfRef = `bos://${accountId}/${gatewayId}`;
|
|
266
139
|
if (visited.has(selfRef)) throw new Error(`Circular extends detected: ${selfRef}`);
|
|
@@ -284,251 +157,6 @@ async function fetchPublishedConfig(accountId, gatewayId) {
|
|
|
284
157
|
throw error;
|
|
285
158
|
}
|
|
286
159
|
}
|
|
287
|
-
function selectWorkspaceTargets(packages, bosConfig) {
|
|
288
|
-
const allPackages = [...Object.keys(bosConfig?.app ?? {}), ...Object.keys(bosConfig?.plugins ?? {})];
|
|
289
|
-
if (packages === "all") return allPackages;
|
|
290
|
-
return packages.split(",").map((pkg) => pkg.trim()).filter((pkg) => allPackages.includes(pkg));
|
|
291
|
-
}
|
|
292
|
-
function padRight(str, len) {
|
|
293
|
-
return str.length >= len ? str : str + " ".repeat(len - str.length);
|
|
294
|
-
}
|
|
295
|
-
function formatDuration(ms) {
|
|
296
|
-
if (ms < 1e3) return `${ms}ms`;
|
|
297
|
-
return `${(ms / 1e3).toFixed(1)}s`;
|
|
298
|
-
}
|
|
299
|
-
async function runBuildAttempt(cmd, args, cwd, env, verbose, wsKey, resultBaseDir) {
|
|
300
|
-
if (verbose) try {
|
|
301
|
-
await run(cmd, args, {
|
|
302
|
-
cwd,
|
|
303
|
-
env,
|
|
304
|
-
capture: false
|
|
305
|
-
});
|
|
306
|
-
if (resultBaseDir) {
|
|
307
|
-
const results = readDeployResults(join(resultBaseDir, wsKey));
|
|
308
|
-
if (results.length > 0) return {
|
|
309
|
-
success: true,
|
|
310
|
-
url: results[0]?.url,
|
|
311
|
-
exitCode: 0,
|
|
312
|
-
output: ""
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
return {
|
|
316
|
-
success: true,
|
|
317
|
-
exitCode: 0,
|
|
318
|
-
output: ""
|
|
319
|
-
};
|
|
320
|
-
} catch (err) {
|
|
321
|
-
return {
|
|
322
|
-
success: false,
|
|
323
|
-
error: err instanceof Error ? err.message : String(err),
|
|
324
|
-
exitCode: 1,
|
|
325
|
-
output: ""
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
const result = await run(cmd, args, {
|
|
329
|
-
cwd,
|
|
330
|
-
env,
|
|
331
|
-
capture: true
|
|
332
|
-
});
|
|
333
|
-
const stdout = result?.stdout ?? "";
|
|
334
|
-
const stderr = result?.stderr ?? "";
|
|
335
|
-
const exitCode = result?.exitCode ?? 0;
|
|
336
|
-
const output = `${stdout}\n${stderr}`;
|
|
337
|
-
if (exitCode !== 0) return {
|
|
338
|
-
success: false,
|
|
339
|
-
error: `Build failed (exit code ${exitCode})\n${output.trim().split("\n").slice(-5).join("\n")}`,
|
|
340
|
-
exitCode,
|
|
341
|
-
output
|
|
342
|
-
};
|
|
343
|
-
const zeMatch = output.match(/ZE\d+/);
|
|
344
|
-
if (zeMatch) return {
|
|
345
|
-
success: false,
|
|
346
|
-
error: `Zephyr upload failed (${zeMatch[0]})`,
|
|
347
|
-
exitCode: 0,
|
|
348
|
-
output
|
|
349
|
-
};
|
|
350
|
-
if (resultBaseDir) {
|
|
351
|
-
const results = readDeployResults(join(resultBaseDir, wsKey));
|
|
352
|
-
if (results.length > 0) return {
|
|
353
|
-
success: true,
|
|
354
|
-
url: results[0]?.url,
|
|
355
|
-
exitCode: 0,
|
|
356
|
-
output
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
const deployMatch = output.match(/🚀.*Deployed:\s*(https?:\S+)/);
|
|
360
|
-
if (deployMatch) return {
|
|
361
|
-
success: true,
|
|
362
|
-
url: deployMatch[1],
|
|
363
|
-
exitCode: 0,
|
|
364
|
-
output
|
|
365
|
-
};
|
|
366
|
-
if (env.DEPLOY === "true") return {
|
|
367
|
-
success: false,
|
|
368
|
-
error: "No deploy URL found (Zephyr may have failed)",
|
|
369
|
-
exitCode: 0,
|
|
370
|
-
output
|
|
371
|
-
};
|
|
372
|
-
return {
|
|
373
|
-
success: true,
|
|
374
|
-
exitCode: 0,
|
|
375
|
-
output
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
async function buildOneWorkspace(ws, env, opts, resultBaseDir) {
|
|
379
|
-
const pkgJson = await readJsonFile(`${ws.path}/package.json`);
|
|
380
|
-
const buildConfig = opts.deploy && pkgJson.scripts?.deploy ? {
|
|
381
|
-
cmd: "bun",
|
|
382
|
-
args: ["run", "deploy"]
|
|
383
|
-
} : buildCommands[ws.key] ?? {
|
|
384
|
-
cmd: "bun",
|
|
385
|
-
args: ["run", "build"]
|
|
386
|
-
};
|
|
387
|
-
const wsEnv = { ...env };
|
|
388
|
-
if (resultBaseDir) wsEnv.BOS_DEPLOY_RESULT_DIR = join(resultBaseDir, ws.key);
|
|
389
|
-
const startTime = Date.now();
|
|
390
|
-
let attempt = await runBuildAttempt(buildConfig.cmd, buildConfig.args, ws.path, wsEnv, opts.verbose ?? false, ws.key, resultBaseDir);
|
|
391
|
-
let retried = false;
|
|
392
|
-
if (!attempt.success && attempt.exitCode === 0 && opts.deploy) {
|
|
393
|
-
if (!opts.verbose) console.log(` ${colors.yellow("↻")} ${padRight(ws.key, 28)} retrying...`);
|
|
394
|
-
if (resultBaseDir) {
|
|
395
|
-
const wsResultDir = join(resultBaseDir, ws.key);
|
|
396
|
-
if (existsSync(wsResultDir)) rmSync(wsResultDir, {
|
|
397
|
-
recursive: true,
|
|
398
|
-
force: true
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
retried = true;
|
|
402
|
-
attempt = await runBuildAttempt(buildConfig.cmd, buildConfig.args, ws.path, wsEnv, opts.verbose ?? false, ws.key, resultBaseDir);
|
|
403
|
-
}
|
|
404
|
-
const durationMs = Date.now() - startTime;
|
|
405
|
-
const result = {
|
|
406
|
-
key: ws.key,
|
|
407
|
-
kind: ws.kind,
|
|
408
|
-
success: attempt.success,
|
|
409
|
-
url: attempt.url,
|
|
410
|
-
error: attempt.error,
|
|
411
|
-
durationMs,
|
|
412
|
-
retried: retried ? true : void 0
|
|
413
|
-
};
|
|
414
|
-
if (!opts.verbose) {
|
|
415
|
-
const name = padRight(ws.key, 28);
|
|
416
|
-
if (result.success) {
|
|
417
|
-
const duration = formatDuration(durationMs);
|
|
418
|
-
const retryTag = retried ? " (retried)" : "";
|
|
419
|
-
console.log(` ${colors.green(icons.ok)} ${name} ${colors.dim(duration + retryTag)}`);
|
|
420
|
-
} else {
|
|
421
|
-
const errorLine = (result.error ?? "Failed").split("\n")[0];
|
|
422
|
-
console.log(` ${colors.error(icons.err)} ${name} ${errorLine}`);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
return result;
|
|
426
|
-
}
|
|
427
|
-
async function buildWorkspaceTargets(opts) {
|
|
428
|
-
const existing = [];
|
|
429
|
-
const skipped = [];
|
|
430
|
-
for (const target of opts.targets) {
|
|
431
|
-
const resolved = resolveWorkspaceTarget(target, opts.bosConfig, opts.runtimeConfig, opts.configDir);
|
|
432
|
-
if (!resolved) {
|
|
433
|
-
skipped.push(target);
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
if (await fileExists(`${resolved.path}/package.json`)) existing.push(resolved);
|
|
437
|
-
else skipped.push(target);
|
|
438
|
-
}
|
|
439
|
-
if (existing.length === 0) return {
|
|
440
|
-
built: [],
|
|
441
|
-
skipped
|
|
442
|
-
};
|
|
443
|
-
if ((await syncResolvedSharedDeps({
|
|
444
|
-
configDir: opts.configDir,
|
|
445
|
-
hostMode: "local",
|
|
446
|
-
bosConfig: opts.bosConfig ?? void 0,
|
|
447
|
-
extendsChain: []
|
|
448
|
-
})).catalogChanged) await run("bun", ["install"], { cwd: opts.configDir });
|
|
449
|
-
const shouldBuildPlugin = existing.some((entry) => entry.key === "api");
|
|
450
|
-
const forceRebuild = opts.deploy;
|
|
451
|
-
const buildTasks = [buildEverythingDevQuietly(opts.configDir, forceRebuild)];
|
|
452
|
-
if (shouldBuildPlugin) buildTasks.push(buildEveryPluginQuietly(opts.configDir, forceRebuild));
|
|
453
|
-
await Promise.all(buildTasks);
|
|
454
|
-
const env = {
|
|
455
|
-
...process.env,
|
|
456
|
-
NODE_ENV: opts.deploy ? "production" : "development"
|
|
457
|
-
};
|
|
458
|
-
if (opts.deploy) env.DEPLOY = "true";
|
|
459
|
-
else delete env.DEPLOY;
|
|
460
|
-
const resultBaseDir = opts.deploy ? join(opts.configDir, ".bos", "deploy-results") : void 0;
|
|
461
|
-
if (resultBaseDir) cleanDeployResultDir(resultBaseDir);
|
|
462
|
-
const bosConfigPath = join(opts.configDir, "bos.config.json");
|
|
463
|
-
let configSnapshot;
|
|
464
|
-
if (opts.deploy && existsSync(bosConfigPath)) configSnapshot = readFileSync(bosConfigPath, "utf-8");
|
|
465
|
-
const orderedExisting = opts.deploy ? [
|
|
466
|
-
...existing.filter((entry) => entry.kind === "app" && entry.key !== "host"),
|
|
467
|
-
...existing.filter((entry) => entry.kind === "plugin"),
|
|
468
|
-
...existing.filter((entry) => entry.kind === "app" && entry.key === "host")
|
|
469
|
-
] : existing;
|
|
470
|
-
const parallelGroup = opts.deploy ? orderedExisting.filter((e) => e.key !== "host") : orderedExisting;
|
|
471
|
-
const sequentialGroup = opts.deploy ? orderedExisting.filter((e) => e.key === "host") : [];
|
|
472
|
-
const built = [];
|
|
473
|
-
const deployResults = [];
|
|
474
|
-
if (opts.deploy && parallelGroup.length > 0) {
|
|
475
|
-
const total = parallelGroup.length + sequentialGroup.length;
|
|
476
|
-
console.log();
|
|
477
|
-
console.log(` Building ${total} workspace${total > 1 ? "s" : ""}...`);
|
|
478
|
-
console.log();
|
|
479
|
-
const results = await Promise.allSettled(parallelGroup.map((ws) => buildOneWorkspace(ws, env, opts, resultBaseDir)));
|
|
480
|
-
for (let i = 0; i < parallelGroup.length; i++) {
|
|
481
|
-
const ws = parallelGroup[i];
|
|
482
|
-
const result = results[i];
|
|
483
|
-
if (result.status === "fulfilled") {
|
|
484
|
-
if (result.value.success) built.push(ws.key);
|
|
485
|
-
deployResults.push(result.value);
|
|
486
|
-
} else deployResults.push({
|
|
487
|
-
key: ws.key,
|
|
488
|
-
kind: ws.kind,
|
|
489
|
-
success: false,
|
|
490
|
-
error: result.reason?.message ?? "Unknown error"
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
if (resultBaseDir && configSnapshot) {
|
|
494
|
-
const allResults = readAllDeployResults(resultBaseDir);
|
|
495
|
-
if (allResults.length > 0) {
|
|
496
|
-
const merged = applyDeployResults(JSON.parse(configSnapshot), allResults);
|
|
497
|
-
writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\n`);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
for (const ws of sequentialGroup) {
|
|
501
|
-
const result = await buildOneWorkspace(ws, env, opts, resultBaseDir);
|
|
502
|
-
if (result.success) built.push(ws.key);
|
|
503
|
-
deployResults.push(result);
|
|
504
|
-
}
|
|
505
|
-
if (resultBaseDir && existsSync(bosConfigPath)) {
|
|
506
|
-
const allResults = readAllDeployResults(resultBaseDir);
|
|
507
|
-
const currentConfig = JSON.parse(readFileSync(bosConfigPath, "utf-8"));
|
|
508
|
-
const hostResults = allResults.filter((r) => r.urlField.startsWith("app.host"));
|
|
509
|
-
if (hostResults.length > 0) {
|
|
510
|
-
const merged = applyDeployResults(currentConfig, hostResults);
|
|
511
|
-
writeFileSync(bosConfigPath, `${JSON.stringify(merged, null, 2)}\n`);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
console.log();
|
|
515
|
-
} else for (const resolved of orderedExisting) {
|
|
516
|
-
const buildConfig = buildCommands[resolved.key] ?? {
|
|
517
|
-
cmd: "bun",
|
|
518
|
-
args: ["run", "build"]
|
|
519
|
-
};
|
|
520
|
-
await run(buildConfig.cmd, buildConfig.args, {
|
|
521
|
-
cwd: resolved.path,
|
|
522
|
-
env
|
|
523
|
-
});
|
|
524
|
-
built.push(resolved.key);
|
|
525
|
-
}
|
|
526
|
-
return {
|
|
527
|
-
built,
|
|
528
|
-
skipped,
|
|
529
|
-
deployResults: opts.deploy ? deployResults : void 0
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
160
|
var plugin_default = createPlugin({
|
|
533
161
|
variables: z.object({ configPath: z.string().optional() }),
|
|
534
162
|
secrets: z.object({}),
|
|
@@ -661,14 +289,23 @@ var plugin_default = createPlugin({
|
|
|
661
289
|
}
|
|
662
290
|
if (stdout.trim()) process.stdout.write(stdout);
|
|
663
291
|
if (stderr.trim()) process.stderr.write(stderr);
|
|
664
|
-
|
|
292
|
+
const output = `${stdout}\n${stderr}`;
|
|
293
|
+
const deployEntry = parseDeployLines(output).find((e) => e.urlField === `plugins.${input.key}.production`);
|
|
294
|
+
let publishedUrl;
|
|
295
|
+
let integrity;
|
|
296
|
+
if (deployEntry) {
|
|
297
|
+
publishedUrl = deployEntry.url;
|
|
298
|
+
integrity = deployEntry.integrity;
|
|
299
|
+
} else {
|
|
300
|
+
publishedUrl = extractPublishedUrl(output) ?? void 0;
|
|
301
|
+
integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) ?? void 0 : void 0;
|
|
302
|
+
}
|
|
665
303
|
let manifest = null;
|
|
666
304
|
if (publishedUrl) manifest = await fetchRemotePluginManifest(publishedUrl);
|
|
667
305
|
else if (attachmentRef?.production) {
|
|
668
306
|
manifest = await fetchRemotePluginManifest(attachmentRef.production);
|
|
669
307
|
if (manifest) publishedUrl = attachmentRef.production;
|
|
670
308
|
}
|
|
671
|
-
const integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) : null;
|
|
672
309
|
const version = manifest?.plugin.version ?? pkgJson.version;
|
|
673
310
|
if (publishedUrl) {
|
|
674
311
|
const rootConfigPath = join(deps.configDir, "bos.config.json");
|
|
@@ -1540,176 +1177,6 @@ var plugin_default = createPlugin({
|
|
|
1540
1177
|
})
|
|
1541
1178
|
})
|
|
1542
1179
|
});
|
|
1543
|
-
async function publishToFastKv(input) {
|
|
1544
|
-
const { env, dryRun, configDir } = input;
|
|
1545
|
-
let bosConfig = input.bosConfig;
|
|
1546
|
-
const runtimeConfig = input.runtimeConfig;
|
|
1547
|
-
const isStaging = env === "staging";
|
|
1548
|
-
const account = bosConfig.account;
|
|
1549
|
-
const gateway = isStaging ? bosConfig.staging?.domain ?? bosConfig.domain : bosConfig.domain;
|
|
1550
|
-
if (!gateway) return {
|
|
1551
|
-
status: "error",
|
|
1552
|
-
registryUrl: "",
|
|
1553
|
-
error: "bos.config.json must define domain to publish"
|
|
1554
|
-
};
|
|
1555
|
-
const network = input.network ?? getNetworkIdForAccount(account);
|
|
1556
|
-
const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);
|
|
1557
|
-
const targets = selectWorkspaceTargets(input.packages, bosConfig);
|
|
1558
|
-
let built;
|
|
1559
|
-
let skipped;
|
|
1560
|
-
let deployResults;
|
|
1561
|
-
if (dryRun) return {
|
|
1562
|
-
status: "dry-run",
|
|
1563
|
-
registryUrl,
|
|
1564
|
-
built,
|
|
1565
|
-
skipped
|
|
1566
|
-
};
|
|
1567
|
-
const privateKey = input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;
|
|
1568
|
-
let signingMode;
|
|
1569
|
-
try {
|
|
1570
|
-
signingMode = resolveNearSigningMode(privateKey);
|
|
1571
|
-
} catch (error) {
|
|
1572
|
-
return {
|
|
1573
|
-
status: "error",
|
|
1574
|
-
registryUrl,
|
|
1575
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
1576
|
-
};
|
|
1577
|
-
}
|
|
1578
|
-
if (input.build) {
|
|
1579
|
-
console.log(" Ensuring NEAR CLI...");
|
|
1580
|
-
await Effect.runPromise(ensureNearCli);
|
|
1581
|
-
console.log(" NEAR CLI ready");
|
|
1582
|
-
await generateCodeArtifacts(configDir, bosConfig, {
|
|
1583
|
-
env: "production",
|
|
1584
|
-
runtimeConfig: runtimeConfig ?? void 0
|
|
1585
|
-
});
|
|
1586
|
-
const result = await buildWorkspaceTargets({
|
|
1587
|
-
configDir,
|
|
1588
|
-
bosConfig,
|
|
1589
|
-
runtimeConfig,
|
|
1590
|
-
targets,
|
|
1591
|
-
deploy: true,
|
|
1592
|
-
verbose: input.verbose
|
|
1593
|
-
});
|
|
1594
|
-
built = result.built;
|
|
1595
|
-
skipped = result.skipped;
|
|
1596
|
-
deployResults = result.deployResults;
|
|
1597
|
-
if (deployResults) {
|
|
1598
|
-
const failures = deployResults.filter((r) => !r.success);
|
|
1599
|
-
if (failures.length > 0) {
|
|
1600
|
-
const total = deployResults.length;
|
|
1601
|
-
console.log();
|
|
1602
|
-
console.log(colors.error(` ${icons.err} Deploy failed — ${failures.length} of ${total} workspace${total > 1 ? "s" : ""} failed`));
|
|
1603
|
-
console.log();
|
|
1604
|
-
for (const f of failures) {
|
|
1605
|
-
const errorLine = (f.error ?? "Failed").split("\n")[0];
|
|
1606
|
-
console.log(` ${colors.error(icons.err)} ${padRight(f.key, 28)} ${errorLine}`);
|
|
1607
|
-
}
|
|
1608
|
-
console.log();
|
|
1609
|
-
if (!input.verbose) {
|
|
1610
|
-
console.log(colors.dim(" Run with --verbose for full build output."));
|
|
1611
|
-
console.log();
|
|
1612
|
-
}
|
|
1613
|
-
return {
|
|
1614
|
-
status: "error",
|
|
1615
|
-
registryUrl,
|
|
1616
|
-
built,
|
|
1617
|
-
skipped,
|
|
1618
|
-
deployResults,
|
|
1619
|
-
error: `${failures.length} of ${total} workspaces failed to deploy`
|
|
1620
|
-
};
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
const refreshed = await loadResolvedConfig({ cwd: configDir });
|
|
1624
|
-
if (!refreshed?.config) return {
|
|
1625
|
-
status: "error",
|
|
1626
|
-
registryUrl,
|
|
1627
|
-
built,
|
|
1628
|
-
skipped,
|
|
1629
|
-
deployResults,
|
|
1630
|
-
error: "Failed to reload bos.config.json after build"
|
|
1631
|
-
};
|
|
1632
|
-
bosConfig = refreshed.config;
|
|
1633
|
-
}
|
|
1634
|
-
const rawConfigPath = join(configDir, "bos.config.json");
|
|
1635
|
-
const rawConfig = JSON.parse(readFileSync(rawConfigPath, "utf-8"));
|
|
1636
|
-
const publishPayload = isStaging ? {
|
|
1637
|
-
...rawConfig,
|
|
1638
|
-
domain: gateway
|
|
1639
|
-
} : rawConfig;
|
|
1640
|
-
const registryEntries = { [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishPayload) };
|
|
1641
|
-
const payload = JSON.stringify(registryEntries);
|
|
1642
|
-
const argsBase64 = Buffer.from(payload).toString("base64");
|
|
1643
|
-
console.log();
|
|
1644
|
-
console.log(" Publishing to:");
|
|
1645
|
-
console.log(` ${colors.cyan(registryUrl)}`);
|
|
1646
|
-
try {
|
|
1647
|
-
let txHash;
|
|
1648
|
-
console.log(` Submitting transaction on ${network}...`);
|
|
1649
|
-
try {
|
|
1650
|
-
const tx = await Effect.runPromise(executeTransaction({
|
|
1651
|
-
account,
|
|
1652
|
-
contract: getRegistryNamespaceForNetwork(network),
|
|
1653
|
-
method: "__fastdata_kv",
|
|
1654
|
-
argsBase64,
|
|
1655
|
-
network,
|
|
1656
|
-
privateKey: signingMode._tag === "privateKey" ? signingMode.privateKey : void 0,
|
|
1657
|
-
gas: "300Tgas",
|
|
1658
|
-
deposit: "0NEAR",
|
|
1659
|
-
verbose: input.verbose
|
|
1660
|
-
}, signingMode));
|
|
1661
|
-
txHash = tx.txHash;
|
|
1662
|
-
if (txHash && !tx.output?.includes("CodeDoesNotExist")) console.log(` Transaction submitted: ${colors.dim(txHash)}`);
|
|
1663
|
-
} catch (error) {
|
|
1664
|
-
console.log(colors.dim(" Transaction reported an error — verifying publish..."));
|
|
1665
|
-
try {
|
|
1666
|
-
await waitForPublishedConfig({
|
|
1667
|
-
account,
|
|
1668
|
-
gateway,
|
|
1669
|
-
publishConfig: publishPayload,
|
|
1670
|
-
timeoutMs: 3e4,
|
|
1671
|
-
intervalMs: 2e3
|
|
1672
|
-
});
|
|
1673
|
-
txHash = extractTransactionHash(error);
|
|
1674
|
-
} catch {
|
|
1675
|
-
throw error;
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
console.log(" Waiting for publish confirmation...");
|
|
1679
|
-
await waitForPublishedConfig({
|
|
1680
|
-
account,
|
|
1681
|
-
gateway,
|
|
1682
|
-
publishConfig: publishPayload
|
|
1683
|
-
});
|
|
1684
|
-
return {
|
|
1685
|
-
status: "published",
|
|
1686
|
-
registryUrl,
|
|
1687
|
-
txHash,
|
|
1688
|
-
built,
|
|
1689
|
-
skipped,
|
|
1690
|
-
deployResults,
|
|
1691
|
-
publishConfig: publishPayload
|
|
1692
|
-
};
|
|
1693
|
-
} catch (error) {
|
|
1694
|
-
return {
|
|
1695
|
-
status: "error",
|
|
1696
|
-
registryUrl,
|
|
1697
|
-
error: formatNearError(error),
|
|
1698
|
-
built,
|
|
1699
|
-
skipped,
|
|
1700
|
-
deployResults
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
function formatNearError(error) {
|
|
1705
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1706
|
-
if (message.includes("exceeded gas") || message.includes("GasLimitExceeded")) return `Transaction exceeded gas limit.\n Original: ${message}`;
|
|
1707
|
-
if (message.includes("timeout") || message.includes("Timeout")) return `Transaction timed out. Check NEAR network status.\n Original: ${message}`;
|
|
1708
|
-
return message;
|
|
1709
|
-
}
|
|
1710
|
-
function extractTransactionHash(error) {
|
|
1711
|
-
return (error instanceof Error ? error.message : String(error)).match(/Transaction ID:\s*([A-Za-z0-9]+)/i)?.[1];
|
|
1712
|
-
}
|
|
1713
1180
|
function computeAllowedWorkspaces(overrides, plugins) {
|
|
1714
1181
|
const workspaces = [];
|
|
1715
1182
|
for (const section of overrides) {
|
|
@@ -1722,5 +1189,5 @@ function computeAllowedWorkspaces(overrides, plugins) {
|
|
|
1722
1189
|
}
|
|
1723
1190
|
|
|
1724
1191
|
//#endregion
|
|
1725
|
-
export { consumeDevSession, plugin_default as default, pluginEvents, resolveRemoteConfigChain
|
|
1192
|
+
export { consumeDevSession, plugin_default as default, pluginEvents, resolveRemoteConfigChain };
|
|
1726
1193
|
//# sourceMappingURL=plugin.mjs.map
|