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.cjs
CHANGED
|
@@ -7,24 +7,25 @@ const require_types = require('./types.cjs');
|
|
|
7
7
|
const require_config = require('./config.cjs');
|
|
8
8
|
const require_contract = require('./contract.cjs');
|
|
9
9
|
const require_integrity = require('./integrity.cjs');
|
|
10
|
-
const require_api_contract = require('./api-contract.cjs');
|
|
11
10
|
const require_app = require('./app.cjs');
|
|
11
|
+
const require_shared_deps = require('./shared-deps.cjs');
|
|
12
|
+
const require_run = require('./utils/run.cjs');
|
|
13
|
+
const require_theme = require('./utils/theme.cjs');
|
|
14
|
+
const require_build = require('./build.cjs');
|
|
12
15
|
const require_infra = require('./cli/infra.cjs');
|
|
13
16
|
const require_save_config = require('./utils/save-config.cjs');
|
|
14
17
|
const require_cli_init = require('./cli/init.cjs');
|
|
15
18
|
const require_status = require('./cli/status.cjs');
|
|
16
|
-
const require_shared_deps = require('./shared-deps.cjs');
|
|
17
19
|
const require_sync = require('./cli/sync.cjs');
|
|
18
20
|
const require_upgrade = require('./cli/upgrade.cjs');
|
|
19
|
-
const
|
|
21
|
+
const require_code_artifacts = require('./code-artifacts.cjs');
|
|
20
22
|
const require_near_cli = require('./near-cli.cjs');
|
|
23
|
+
const require_publish = require('./publish.cjs');
|
|
21
24
|
const require_service_descriptor = require('./service-descriptor.cjs');
|
|
22
|
-
const require_run = require('./utils/run.cjs');
|
|
23
25
|
let node_fs = require("node:fs");
|
|
24
26
|
let node_path = require("node:path");
|
|
25
27
|
let effect = require("effect");
|
|
26
28
|
let node_events = require("node:events");
|
|
27
|
-
let node_fs_promises = require("node:fs/promises");
|
|
28
29
|
let node_process = require("node:process");
|
|
29
30
|
node_process = require_runtime.__toESM(node_process, 1);
|
|
30
31
|
let every_plugin = require("every-plugin");
|
|
@@ -72,25 +73,7 @@ async function timePhase(timings, name, fn) {
|
|
|
72
73
|
throw error;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
const buildCommands = {
|
|
76
|
-
host: {
|
|
77
|
-
cmd: "bun",
|
|
78
|
-
args: ["run", "build"]
|
|
79
|
-
},
|
|
80
|
-
ui: {
|
|
81
|
-
cmd: "bun",
|
|
82
|
-
args: ["run", "build"]
|
|
83
|
-
},
|
|
84
|
-
api: {
|
|
85
|
-
cmd: "bun",
|
|
86
|
-
args: ["run", "build"]
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
76
|
const PUBLISH_FUNCTION_NAMES = ["__fastdata_kv"];
|
|
90
|
-
function getPluginRef(entry) {
|
|
91
|
-
if (!entry || typeof entry === "string") return null;
|
|
92
|
-
return entry;
|
|
93
|
-
}
|
|
94
77
|
function parseSourceMode(value, defaultValue) {
|
|
95
78
|
if (value === "local" || value === "remote") return value;
|
|
96
79
|
return defaultValue;
|
|
@@ -105,40 +88,6 @@ function buildConfigResult(bosConfig, full = false) {
|
|
|
105
88
|
full
|
|
106
89
|
};
|
|
107
90
|
}
|
|
108
|
-
async function fileExists(path) {
|
|
109
|
-
try {
|
|
110
|
-
await (0, node_fs_promises.access)(path);
|
|
111
|
-
return true;
|
|
112
|
-
} catch {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async function readJsonFile(path) {
|
|
117
|
-
return JSON.parse(await (0, node_fs_promises.readFile)(path, "utf8"));
|
|
118
|
-
}
|
|
119
|
-
function resolveWorkspaceTarget(key, bosConfig, runtimeConfig, configDir) {
|
|
120
|
-
if (bosConfig?.app && key in bosConfig.app) {
|
|
121
|
-
const appEntry = bosConfig.app[key];
|
|
122
|
-
const devPath = require_config.resolveLocalDevelopmentPath(appEntry?.development, configDir);
|
|
123
|
-
if (devPath) return {
|
|
124
|
-
key,
|
|
125
|
-
kind: "app",
|
|
126
|
-
path: devPath
|
|
127
|
-
};
|
|
128
|
-
return {
|
|
129
|
-
key,
|
|
130
|
-
kind: "app",
|
|
131
|
-
path: `${configDir}/${key}`
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const pluginPath = (runtimeConfig?.plugins?.[key])?.localPath ?? require_config.resolveLocalDevelopmentPath(getPluginRef(bosConfig?.plugins?.[key])?.development, configDir);
|
|
135
|
-
if (pluginPath) return {
|
|
136
|
-
key,
|
|
137
|
-
kind: "plugin",
|
|
138
|
-
path: pluginPath
|
|
139
|
-
};
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
91
|
function isValidProxyUrl(url) {
|
|
143
92
|
try {
|
|
144
93
|
const parsed = new URL(url);
|
|
@@ -169,14 +118,14 @@ function defaultPluginKey(source) {
|
|
|
169
118
|
}
|
|
170
119
|
}
|
|
171
120
|
function pluginLocalPath(configDir, attachment) {
|
|
172
|
-
const ref = getPluginRef(attachment);
|
|
121
|
+
const ref = require_build.getPluginRef(attachment);
|
|
173
122
|
const source = ref?.development ?? ref?.production;
|
|
174
123
|
if (!source?.startsWith("local:")) return null;
|
|
175
124
|
return (0, node_path.join)(configDir, source.slice(6));
|
|
176
125
|
}
|
|
177
126
|
function listPluginAttachments(config) {
|
|
178
127
|
return Object.entries(config?.plugins ?? {}).map(([key, attachment]) => {
|
|
179
|
-
const ref = getPluginRef(attachment);
|
|
128
|
+
const ref = require_build.getPluginRef(attachment);
|
|
180
129
|
return {
|
|
181
130
|
key,
|
|
182
131
|
development: ref?.development,
|
|
@@ -189,82 +138,6 @@ function listPluginAttachments(config) {
|
|
|
189
138
|
};
|
|
190
139
|
}).sort((a, b) => a.key.localeCompare(b.key));
|
|
191
140
|
}
|
|
192
|
-
async function generateCodeArtifacts(configDir, config, opts) {
|
|
193
|
-
if (opts?.env) require_config.writeResolvedConfig(configDir, config, opts.env, opts.extendsChain);
|
|
194
|
-
const runtimeConfig = opts?.runtimeConfig ?? (await require_config.loadResolvedConfig({ cwd: configDir }))?.runtime;
|
|
195
|
-
if (!runtimeConfig) return null;
|
|
196
|
-
const bridge = await require_api_contract.syncApiContractBridge({
|
|
197
|
-
configDir,
|
|
198
|
-
runtimeConfig,
|
|
199
|
-
apiBaseUrl: runtimeConfig.api.url
|
|
200
|
-
});
|
|
201
|
-
return {
|
|
202
|
-
resolvedConfigPath: opts?.env ? (0, node_path.join)(configDir, ".bos/bos.resolved-config.json") : void 0,
|
|
203
|
-
contractBridgePath: bridge.bridgePath,
|
|
204
|
-
contractStatus: bridge.status
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function extractPublishedUrl(output) {
|
|
208
|
-
const match = output.match(/https?:\/\/[^\s"'<>]+/g);
|
|
209
|
-
if (!match || match.length === 0) return null;
|
|
210
|
-
return match[match.length - 1] ?? null;
|
|
211
|
-
}
|
|
212
|
-
function sleep(ms) {
|
|
213
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
214
|
-
}
|
|
215
|
-
async function waitForPublishedConfig(opts) {
|
|
216
|
-
const envTimeoutMs = Number(node_process.default.env.BOS_PUBLISH_CONFIRMATION_TIMEOUT_MS);
|
|
217
|
-
const envIntervalMs = Number(node_process.default.env.BOS_PUBLISH_CONFIRMATION_INTERVAL_MS);
|
|
218
|
-
const timeoutMs = opts.timeoutMs ?? (Number.isFinite(envTimeoutMs) ? envTimeoutMs : void 0) ?? 12e4;
|
|
219
|
-
const intervalMs = opts.intervalMs ?? (Number.isFinite(envIntervalMs) ? envIntervalMs : void 0) ?? 3e3;
|
|
220
|
-
const startedAt = Date.now();
|
|
221
|
-
let lastError;
|
|
222
|
-
while (Date.now() - startedAt < timeoutMs) {
|
|
223
|
-
try {
|
|
224
|
-
const verifiedConfig = await require_fastkv.fetchBosConfigFromFastKv(`bos://${opts.account}/${opts.gateway}`);
|
|
225
|
-
if (JSON.stringify(verifiedConfig) === JSON.stringify(opts.publishConfig)) return;
|
|
226
|
-
} catch (error) {
|
|
227
|
-
lastError = error;
|
|
228
|
-
}
|
|
229
|
-
await sleep(intervalMs);
|
|
230
|
-
}
|
|
231
|
-
const reason = lastError instanceof Error ? ` Last error: ${lastError.message}` : "";
|
|
232
|
-
throw new Error(`Timed out waiting for publish confirmation at bos://${opts.account}/${opts.gateway}.${reason}`);
|
|
233
|
-
}
|
|
234
|
-
async function buildEveryPluginQuietly(cwd, force = false) {
|
|
235
|
-
if (!await fileExists(`${`${cwd}/packages/every-plugin`}/package.json`)) return;
|
|
236
|
-
if (await fileExists(`${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`) && !force) return;
|
|
237
|
-
const result = await require_run.run("bun", [
|
|
238
|
-
"run",
|
|
239
|
-
"--cwd",
|
|
240
|
-
"packages/every-plugin",
|
|
241
|
-
"build"
|
|
242
|
-
], {
|
|
243
|
-
cwd,
|
|
244
|
-
capture: true
|
|
245
|
-
});
|
|
246
|
-
if (result.exitCode === 0) return;
|
|
247
|
-
if (result.stdout.trim()) node_process.default.stdout.write(result.stdout);
|
|
248
|
-
if (result.stderr.trim()) node_process.default.stderr.write(result.stderr);
|
|
249
|
-
throw new Error(`bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`);
|
|
250
|
-
}
|
|
251
|
-
async function buildEverythingDevQuietly(cwd, force = false) {
|
|
252
|
-
if (!await fileExists(`${`${cwd}/packages/everything-dev`}/package.json`)) return;
|
|
253
|
-
if (await fileExists(`${cwd}/packages/everything-dev/dist/index.mjs`) && !force) return;
|
|
254
|
-
const result = await require_run.run("bun", [
|
|
255
|
-
"run",
|
|
256
|
-
"--cwd",
|
|
257
|
-
"packages/everything-dev",
|
|
258
|
-
"build"
|
|
259
|
-
], {
|
|
260
|
-
cwd,
|
|
261
|
-
capture: true
|
|
262
|
-
});
|
|
263
|
-
if (result.exitCode === 0) return;
|
|
264
|
-
if (result.stdout.trim()) node_process.default.stdout.write(result.stdout);
|
|
265
|
-
if (result.stderr.trim()) node_process.default.stderr.write(result.stderr);
|
|
266
|
-
throw new Error(`bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`);
|
|
267
|
-
}
|
|
268
141
|
async function resolveRemoteConfigChain(accountId, gatewayId, visited) {
|
|
269
142
|
const selfRef = `bos://${accountId}/${gatewayId}`;
|
|
270
143
|
if (visited.has(selfRef)) throw new Error(`Circular extends detected: ${selfRef}`);
|
|
@@ -288,251 +161,6 @@ async function fetchPublishedConfig(accountId, gatewayId) {
|
|
|
288
161
|
throw error;
|
|
289
162
|
}
|
|
290
163
|
}
|
|
291
|
-
function selectWorkspaceTargets(packages, bosConfig) {
|
|
292
|
-
const allPackages = [...Object.keys(bosConfig?.app ?? {}), ...Object.keys(bosConfig?.plugins ?? {})];
|
|
293
|
-
if (packages === "all") return allPackages;
|
|
294
|
-
return packages.split(",").map((pkg) => pkg.trim()).filter((pkg) => allPackages.includes(pkg));
|
|
295
|
-
}
|
|
296
|
-
function padRight(str, len) {
|
|
297
|
-
return str.length >= len ? str : str + " ".repeat(len - str.length);
|
|
298
|
-
}
|
|
299
|
-
function formatDuration(ms) {
|
|
300
|
-
if (ms < 1e3) return `${ms}ms`;
|
|
301
|
-
return `${(ms / 1e3).toFixed(1)}s`;
|
|
302
|
-
}
|
|
303
|
-
async function runBuildAttempt(cmd, args, cwd, env, verbose, wsKey, resultBaseDir) {
|
|
304
|
-
if (verbose) try {
|
|
305
|
-
await require_run.run(cmd, args, {
|
|
306
|
-
cwd,
|
|
307
|
-
env,
|
|
308
|
-
capture: false
|
|
309
|
-
});
|
|
310
|
-
if (resultBaseDir) {
|
|
311
|
-
const results = require_integrity.readDeployResults((0, node_path.join)(resultBaseDir, wsKey));
|
|
312
|
-
if (results.length > 0) return {
|
|
313
|
-
success: true,
|
|
314
|
-
url: results[0]?.url,
|
|
315
|
-
exitCode: 0,
|
|
316
|
-
output: ""
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
return {
|
|
320
|
-
success: true,
|
|
321
|
-
exitCode: 0,
|
|
322
|
-
output: ""
|
|
323
|
-
};
|
|
324
|
-
} catch (err) {
|
|
325
|
-
return {
|
|
326
|
-
success: false,
|
|
327
|
-
error: err instanceof Error ? err.message : String(err),
|
|
328
|
-
exitCode: 1,
|
|
329
|
-
output: ""
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
const result = await require_run.run(cmd, args, {
|
|
333
|
-
cwd,
|
|
334
|
-
env,
|
|
335
|
-
capture: true
|
|
336
|
-
});
|
|
337
|
-
const stdout = result?.stdout ?? "";
|
|
338
|
-
const stderr = result?.stderr ?? "";
|
|
339
|
-
const exitCode = result?.exitCode ?? 0;
|
|
340
|
-
const output = `${stdout}\n${stderr}`;
|
|
341
|
-
if (exitCode !== 0) return {
|
|
342
|
-
success: false,
|
|
343
|
-
error: `Build failed (exit code ${exitCode})\n${output.trim().split("\n").slice(-5).join("\n")}`,
|
|
344
|
-
exitCode,
|
|
345
|
-
output
|
|
346
|
-
};
|
|
347
|
-
const zeMatch = output.match(/ZE\d+/);
|
|
348
|
-
if (zeMatch) return {
|
|
349
|
-
success: false,
|
|
350
|
-
error: `Zephyr upload failed (${zeMatch[0]})`,
|
|
351
|
-
exitCode: 0,
|
|
352
|
-
output
|
|
353
|
-
};
|
|
354
|
-
if (resultBaseDir) {
|
|
355
|
-
const results = require_integrity.readDeployResults((0, node_path.join)(resultBaseDir, wsKey));
|
|
356
|
-
if (results.length > 0) return {
|
|
357
|
-
success: true,
|
|
358
|
-
url: results[0]?.url,
|
|
359
|
-
exitCode: 0,
|
|
360
|
-
output
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
const deployMatch = output.match(/🚀.*Deployed:\s*(https?:\S+)/);
|
|
364
|
-
if (deployMatch) return {
|
|
365
|
-
success: true,
|
|
366
|
-
url: deployMatch[1],
|
|
367
|
-
exitCode: 0,
|
|
368
|
-
output
|
|
369
|
-
};
|
|
370
|
-
if (env.DEPLOY === "true") return {
|
|
371
|
-
success: false,
|
|
372
|
-
error: "No deploy URL found (Zephyr may have failed)",
|
|
373
|
-
exitCode: 0,
|
|
374
|
-
output
|
|
375
|
-
};
|
|
376
|
-
return {
|
|
377
|
-
success: true,
|
|
378
|
-
exitCode: 0,
|
|
379
|
-
output
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
async function buildOneWorkspace(ws, env, opts, resultBaseDir) {
|
|
383
|
-
const pkgJson = await readJsonFile(`${ws.path}/package.json`);
|
|
384
|
-
const buildConfig = opts.deploy && pkgJson.scripts?.deploy ? {
|
|
385
|
-
cmd: "bun",
|
|
386
|
-
args: ["run", "deploy"]
|
|
387
|
-
} : buildCommands[ws.key] ?? {
|
|
388
|
-
cmd: "bun",
|
|
389
|
-
args: ["run", "build"]
|
|
390
|
-
};
|
|
391
|
-
const wsEnv = { ...env };
|
|
392
|
-
if (resultBaseDir) wsEnv.BOS_DEPLOY_RESULT_DIR = (0, node_path.join)(resultBaseDir, ws.key);
|
|
393
|
-
const startTime = Date.now();
|
|
394
|
-
let attempt = await runBuildAttempt(buildConfig.cmd, buildConfig.args, ws.path, wsEnv, opts.verbose ?? false, ws.key, resultBaseDir);
|
|
395
|
-
let retried = false;
|
|
396
|
-
if (!attempt.success && attempt.exitCode === 0 && opts.deploy) {
|
|
397
|
-
if (!opts.verbose) console.log(` ${require_theme.colors.yellow("↻")} ${padRight(ws.key, 28)} retrying...`);
|
|
398
|
-
if (resultBaseDir) {
|
|
399
|
-
const wsResultDir = (0, node_path.join)(resultBaseDir, ws.key);
|
|
400
|
-
if ((0, node_fs.existsSync)(wsResultDir)) (0, node_fs.rmSync)(wsResultDir, {
|
|
401
|
-
recursive: true,
|
|
402
|
-
force: true
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
retried = true;
|
|
406
|
-
attempt = await runBuildAttempt(buildConfig.cmd, buildConfig.args, ws.path, wsEnv, opts.verbose ?? false, ws.key, resultBaseDir);
|
|
407
|
-
}
|
|
408
|
-
const durationMs = Date.now() - startTime;
|
|
409
|
-
const result = {
|
|
410
|
-
key: ws.key,
|
|
411
|
-
kind: ws.kind,
|
|
412
|
-
success: attempt.success,
|
|
413
|
-
url: attempt.url,
|
|
414
|
-
error: attempt.error,
|
|
415
|
-
durationMs,
|
|
416
|
-
retried: retried ? true : void 0
|
|
417
|
-
};
|
|
418
|
-
if (!opts.verbose) {
|
|
419
|
-
const name = padRight(ws.key, 28);
|
|
420
|
-
if (result.success) {
|
|
421
|
-
const duration = formatDuration(durationMs);
|
|
422
|
-
const retryTag = retried ? " (retried)" : "";
|
|
423
|
-
console.log(` ${require_theme.colors.green(require_theme.icons.ok)} ${name} ${require_theme.colors.dim(duration + retryTag)}`);
|
|
424
|
-
} else {
|
|
425
|
-
const errorLine = (result.error ?? "Failed").split("\n")[0];
|
|
426
|
-
console.log(` ${require_theme.colors.error(require_theme.icons.err)} ${name} ${errorLine}`);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return result;
|
|
430
|
-
}
|
|
431
|
-
async function buildWorkspaceTargets(opts) {
|
|
432
|
-
const existing = [];
|
|
433
|
-
const skipped = [];
|
|
434
|
-
for (const target of opts.targets) {
|
|
435
|
-
const resolved = resolveWorkspaceTarget(target, opts.bosConfig, opts.runtimeConfig, opts.configDir);
|
|
436
|
-
if (!resolved) {
|
|
437
|
-
skipped.push(target);
|
|
438
|
-
continue;
|
|
439
|
-
}
|
|
440
|
-
if (await fileExists(`${resolved.path}/package.json`)) existing.push(resolved);
|
|
441
|
-
else skipped.push(target);
|
|
442
|
-
}
|
|
443
|
-
if (existing.length === 0) return {
|
|
444
|
-
built: [],
|
|
445
|
-
skipped
|
|
446
|
-
};
|
|
447
|
-
if ((await require_shared_deps.syncResolvedSharedDeps({
|
|
448
|
-
configDir: opts.configDir,
|
|
449
|
-
hostMode: "local",
|
|
450
|
-
bosConfig: opts.bosConfig ?? void 0,
|
|
451
|
-
extendsChain: []
|
|
452
|
-
})).catalogChanged) await require_run.run("bun", ["install"], { cwd: opts.configDir });
|
|
453
|
-
const shouldBuildPlugin = existing.some((entry) => entry.key === "api");
|
|
454
|
-
const forceRebuild = opts.deploy;
|
|
455
|
-
const buildTasks = [buildEverythingDevQuietly(opts.configDir, forceRebuild)];
|
|
456
|
-
if (shouldBuildPlugin) buildTasks.push(buildEveryPluginQuietly(opts.configDir, forceRebuild));
|
|
457
|
-
await Promise.all(buildTasks);
|
|
458
|
-
const env = {
|
|
459
|
-
...node_process.default.env,
|
|
460
|
-
NODE_ENV: opts.deploy ? "production" : "development"
|
|
461
|
-
};
|
|
462
|
-
if (opts.deploy) env.DEPLOY = "true";
|
|
463
|
-
else delete env.DEPLOY;
|
|
464
|
-
const resultBaseDir = opts.deploy ? (0, node_path.join)(opts.configDir, ".bos", "deploy-results") : void 0;
|
|
465
|
-
if (resultBaseDir) require_integrity.cleanDeployResultDir(resultBaseDir);
|
|
466
|
-
const bosConfigPath = (0, node_path.join)(opts.configDir, "bos.config.json");
|
|
467
|
-
let configSnapshot;
|
|
468
|
-
if (opts.deploy && (0, node_fs.existsSync)(bosConfigPath)) configSnapshot = (0, node_fs.readFileSync)(bosConfigPath, "utf-8");
|
|
469
|
-
const orderedExisting = opts.deploy ? [
|
|
470
|
-
...existing.filter((entry) => entry.kind === "app" && entry.key !== "host"),
|
|
471
|
-
...existing.filter((entry) => entry.kind === "plugin"),
|
|
472
|
-
...existing.filter((entry) => entry.kind === "app" && entry.key === "host")
|
|
473
|
-
] : existing;
|
|
474
|
-
const parallelGroup = opts.deploy ? orderedExisting.filter((e) => e.key !== "host") : orderedExisting;
|
|
475
|
-
const sequentialGroup = opts.deploy ? orderedExisting.filter((e) => e.key === "host") : [];
|
|
476
|
-
const built = [];
|
|
477
|
-
const deployResults = [];
|
|
478
|
-
if (opts.deploy && parallelGroup.length > 0) {
|
|
479
|
-
const total = parallelGroup.length + sequentialGroup.length;
|
|
480
|
-
console.log();
|
|
481
|
-
console.log(` Building ${total} workspace${total > 1 ? "s" : ""}...`);
|
|
482
|
-
console.log();
|
|
483
|
-
const results = await Promise.allSettled(parallelGroup.map((ws) => buildOneWorkspace(ws, env, opts, resultBaseDir)));
|
|
484
|
-
for (let i = 0; i < parallelGroup.length; i++) {
|
|
485
|
-
const ws = parallelGroup[i];
|
|
486
|
-
const result = results[i];
|
|
487
|
-
if (result.status === "fulfilled") {
|
|
488
|
-
if (result.value.success) built.push(ws.key);
|
|
489
|
-
deployResults.push(result.value);
|
|
490
|
-
} else deployResults.push({
|
|
491
|
-
key: ws.key,
|
|
492
|
-
kind: ws.kind,
|
|
493
|
-
success: false,
|
|
494
|
-
error: result.reason?.message ?? "Unknown error"
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
if (resultBaseDir && configSnapshot) {
|
|
498
|
-
const allResults = require_integrity.readAllDeployResults(resultBaseDir);
|
|
499
|
-
if (allResults.length > 0) {
|
|
500
|
-
const merged = require_integrity.applyDeployResults(JSON.parse(configSnapshot), allResults);
|
|
501
|
-
(0, node_fs.writeFileSync)(bosConfigPath, `${JSON.stringify(merged, null, 2)}\n`);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
for (const ws of sequentialGroup) {
|
|
505
|
-
const result = await buildOneWorkspace(ws, env, opts, resultBaseDir);
|
|
506
|
-
if (result.success) built.push(ws.key);
|
|
507
|
-
deployResults.push(result);
|
|
508
|
-
}
|
|
509
|
-
if (resultBaseDir && (0, node_fs.existsSync)(bosConfigPath)) {
|
|
510
|
-
const allResults = require_integrity.readAllDeployResults(resultBaseDir);
|
|
511
|
-
const currentConfig = JSON.parse((0, node_fs.readFileSync)(bosConfigPath, "utf-8"));
|
|
512
|
-
const hostResults = allResults.filter((r) => r.urlField.startsWith("app.host"));
|
|
513
|
-
if (hostResults.length > 0) {
|
|
514
|
-
const merged = require_integrity.applyDeployResults(currentConfig, hostResults);
|
|
515
|
-
(0, node_fs.writeFileSync)(bosConfigPath, `${JSON.stringify(merged, null, 2)}\n`);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
console.log();
|
|
519
|
-
} else for (const resolved of orderedExisting) {
|
|
520
|
-
const buildConfig = buildCommands[resolved.key] ?? {
|
|
521
|
-
cmd: "bun",
|
|
522
|
-
args: ["run", "build"]
|
|
523
|
-
};
|
|
524
|
-
await require_run.run(buildConfig.cmd, buildConfig.args, {
|
|
525
|
-
cwd: resolved.path,
|
|
526
|
-
env
|
|
527
|
-
});
|
|
528
|
-
built.push(resolved.key);
|
|
529
|
-
}
|
|
530
|
-
return {
|
|
531
|
-
built,
|
|
532
|
-
skipped,
|
|
533
|
-
deployResults: opts.deploy ? deployResults : void 0
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
164
|
var plugin_default = (0, every_plugin.createPlugin)({
|
|
537
165
|
variables: zod.z.object({ configPath: zod.z.string().optional() }),
|
|
538
166
|
secrets: zod.z.object({}),
|
|
@@ -581,7 +209,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
581
209
|
plugins: nextPlugins
|
|
582
210
|
};
|
|
583
211
|
await require_save_config.saveBosConfig(deps.configDir, deps.bosConfig);
|
|
584
|
-
await generateCodeArtifacts(deps.configDir, deps.bosConfig);
|
|
212
|
+
await require_code_artifacts.generateCodeArtifacts(deps.configDir, deps.bosConfig);
|
|
585
213
|
const stored = deps.bosConfig.plugins?.[key];
|
|
586
214
|
const storedObj = stored && typeof stored === "object" ? stored : {};
|
|
587
215
|
return {
|
|
@@ -611,7 +239,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
611
239
|
plugins: Object.keys(nextPlugins).length > 0 ? nextPlugins : void 0
|
|
612
240
|
};
|
|
613
241
|
await require_save_config.saveBosConfig(deps.configDir, deps.bosConfig);
|
|
614
|
-
await generateCodeArtifacts(deps.configDir, deps.bosConfig);
|
|
242
|
+
await require_code_artifacts.generateCodeArtifacts(deps.configDir, deps.bosConfig);
|
|
615
243
|
return {
|
|
616
244
|
status: "removed",
|
|
617
245
|
key: input.key
|
|
@@ -635,7 +263,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
635
263
|
key: input.key,
|
|
636
264
|
error: `Plugin '${input.key}' is not configured`
|
|
637
265
|
};
|
|
638
|
-
const attachmentRef = getPluginRef(attachment);
|
|
266
|
+
const attachmentRef = require_build.getPluginRef(attachment);
|
|
639
267
|
const localPath = pluginLocalPath(deps.configDir, attachment);
|
|
640
268
|
if (!localPath) return {
|
|
641
269
|
status: "error",
|
|
@@ -643,12 +271,12 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
643
271
|
error: `Plugin '${input.key}' does not have a local development path`
|
|
644
272
|
};
|
|
645
273
|
const pkgPath = (0, node_path.join)(localPath, "package.json");
|
|
646
|
-
if (!await fileExists(pkgPath)) return {
|
|
274
|
+
if (!await require_build.fileExists(pkgPath)) return {
|
|
647
275
|
status: "error",
|
|
648
276
|
key: input.key,
|
|
649
277
|
error: `Missing package.json at ${localPath}`
|
|
650
278
|
};
|
|
651
|
-
const pkgJson = await readJsonFile(pkgPath);
|
|
279
|
+
const pkgJson = await require_build.readJsonFile(pkgPath);
|
|
652
280
|
const script = pkgJson.scripts?.deploy ? "deploy" : "build";
|
|
653
281
|
const { stdout, stderr, exitCode } = await require_run.run("bun", ["run", script], {
|
|
654
282
|
cwd: localPath,
|
|
@@ -665,14 +293,23 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
665
293
|
}
|
|
666
294
|
if (stdout.trim()) node_process.default.stdout.write(stdout);
|
|
667
295
|
if (stderr.trim()) node_process.default.stderr.write(stderr);
|
|
668
|
-
|
|
296
|
+
const output = `${stdout}\n${stderr}`;
|
|
297
|
+
const deployEntry = require_integrity.parseDeployLines(output).find((e) => e.urlField === `plugins.${input.key}.production`);
|
|
298
|
+
let publishedUrl;
|
|
299
|
+
let integrity;
|
|
300
|
+
if (deployEntry) {
|
|
301
|
+
publishedUrl = deployEntry.url;
|
|
302
|
+
integrity = deployEntry.integrity;
|
|
303
|
+
} else {
|
|
304
|
+
publishedUrl = require_publish.extractPublishedUrl(output) ?? void 0;
|
|
305
|
+
integrity = publishedUrl ? await require_integrity.computeSriHashForUrl(publishedUrl) ?? void 0 : void 0;
|
|
306
|
+
}
|
|
669
307
|
let manifest = null;
|
|
670
308
|
if (publishedUrl) manifest = await require_fastkv.fetchRemotePluginManifest(publishedUrl);
|
|
671
309
|
else if (attachmentRef?.production) {
|
|
672
310
|
manifest = await require_fastkv.fetchRemotePluginManifest(attachmentRef.production);
|
|
673
311
|
if (manifest) publishedUrl = attachmentRef.production;
|
|
674
312
|
}
|
|
675
|
-
const integrity = publishedUrl ? await require_integrity.computeSriHashForUrl(publishedUrl) : null;
|
|
676
313
|
const version = manifest?.plugin.version ?? pkgJson.version;
|
|
677
314
|
if (publishedUrl) {
|
|
678
315
|
const rootConfigPath = (0, node_path.join)(deps.configDir, "bos.config.json");
|
|
@@ -690,7 +327,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
690
327
|
} catch (err) {
|
|
691
328
|
console.error(` ❌ Failed to update bos.config.json:`, err instanceof Error ? err.message : err);
|
|
692
329
|
}
|
|
693
|
-
await generateCodeArtifacts(deps.configDir, deps.bosConfig);
|
|
330
|
+
await require_code_artifacts.generateCodeArtifacts(deps.configDir, deps.bosConfig);
|
|
694
331
|
}
|
|
695
332
|
return {
|
|
696
333
|
status: "published",
|
|
@@ -726,8 +363,8 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
726
363
|
}
|
|
727
364
|
const shouldBuildPlugin = apiSource === "local" && !proxy || localPackages.some((pkg) => pkg.startsWith("plugin:"));
|
|
728
365
|
await timePhase(devTimings, "build", async () => {
|
|
729
|
-
const buildTasks = [buildEverythingDevQuietly(deps.configDir)];
|
|
730
|
-
if (shouldBuildPlugin) buildTasks.push(buildEveryPluginQuietly(deps.configDir));
|
|
366
|
+
const buildTasks = [require_build.buildEverythingDevQuietly(deps.configDir)];
|
|
367
|
+
if (shouldBuildPlugin) buildTasks.push(require_build.buildEveryPluginQuietly(deps.configDir));
|
|
731
368
|
await Promise.all(buildTasks);
|
|
732
369
|
});
|
|
733
370
|
let devExtendsChain;
|
|
@@ -771,7 +408,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
771
408
|
require_infra.syncGeneratedInfra(deps.configDir, runtimeConfig);
|
|
772
409
|
require_infra.ensureEnvFile(deps.configDir);
|
|
773
410
|
require_infra.loadProjectEnv(deps.configDir);
|
|
774
|
-
await timePhase(devTimings, "generate artifacts", () => generateCodeArtifacts(deps.configDir, deps.bosConfig, {
|
|
411
|
+
await timePhase(devTimings, "generate artifacts", () => require_code_artifacts.generateCodeArtifacts(deps.configDir, deps.bosConfig, {
|
|
775
412
|
env: "development",
|
|
776
413
|
extendsChain: devExtendsChain,
|
|
777
414
|
runtimeConfig
|
|
@@ -875,7 +512,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
875
512
|
phase: "generate artifacts",
|
|
876
513
|
status: "running"
|
|
877
514
|
});
|
|
878
|
-
await generateCodeArtifacts(deps.configDir, config, {
|
|
515
|
+
await require_code_artifacts.generateCodeArtifacts(deps.configDir, config, {
|
|
879
516
|
env: "production",
|
|
880
517
|
runtimeConfig
|
|
881
518
|
});
|
|
@@ -949,7 +586,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
949
586
|
skipped: []
|
|
950
587
|
};
|
|
951
588
|
const buildEnv = input.deploy ? "production" : "development";
|
|
952
|
-
const targets = selectWorkspaceTargets(input.packages, deps.bosConfig);
|
|
589
|
+
const targets = require_build.selectWorkspaceTargets(input.packages, deps.bosConfig);
|
|
953
590
|
if (targets.length === 0) return {
|
|
954
591
|
status: "error",
|
|
955
592
|
built: [],
|
|
@@ -966,11 +603,11 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
966
603
|
});
|
|
967
604
|
require_config.drainConfigWarnings();
|
|
968
605
|
require_config.resumeWarnings();
|
|
969
|
-
await generateCodeArtifacts(deps.configDir, deps.bosConfig, {
|
|
606
|
+
await require_code_artifacts.generateCodeArtifacts(deps.configDir, deps.bosConfig, {
|
|
970
607
|
env: buildEnv,
|
|
971
608
|
runtimeConfig
|
|
972
609
|
});
|
|
973
|
-
const { built, skipped } = await buildWorkspaceTargets({
|
|
610
|
+
const { built, skipped } = await require_build.buildWorkspaceTargets({
|
|
974
611
|
configDir: deps.configDir,
|
|
975
612
|
bosConfig: deps.bosConfig,
|
|
976
613
|
runtimeConfig,
|
|
@@ -995,7 +632,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
995
632
|
registryUrl: "",
|
|
996
633
|
error: "No bos.config.json found"
|
|
997
634
|
};
|
|
998
|
-
const result = await publishToFastKv({
|
|
635
|
+
const result = await require_publish.publishToFastKv({
|
|
999
636
|
bosConfig: deps.bosConfig,
|
|
1000
637
|
runtimeConfig: deps.runtimeConfig,
|
|
1001
638
|
configDir: deps.configDir,
|
|
@@ -1031,7 +668,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1031
668
|
redeployed: false,
|
|
1032
669
|
error: "No bos.config.json found"
|
|
1033
670
|
};
|
|
1034
|
-
const result = await publishToFastKv({
|
|
671
|
+
const result = await require_publish.publishToFastKv({
|
|
1035
672
|
bosConfig: deps.bosConfig,
|
|
1036
673
|
runtimeConfig: deps.runtimeConfig,
|
|
1037
674
|
configDir: deps.configDir,
|
|
@@ -1320,7 +957,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1320
957
|
await timePhase(timings, "generate types", () => require_cli_init.runTypesGen(targetDir));
|
|
1321
958
|
await timePhase(timings, "generate migrations", () => require_cli_init.generateDatabaseMigrations(targetDir));
|
|
1322
959
|
}
|
|
1323
|
-
if (input.noInstall && initConfig?.config) await timePhase(timings, "generate code artifacts", () => generateCodeArtifacts(targetDir, initConfig.config));
|
|
960
|
+
if (input.noInstall && initConfig?.config) await timePhase(timings, "generate code artifacts", () => require_code_artifacts.generateCodeArtifacts(targetDir, initConfig.config));
|
|
1324
961
|
return {
|
|
1325
962
|
status: "initialized",
|
|
1326
963
|
directory,
|
|
@@ -1368,7 +1005,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1368
1005
|
const result = await require_sync.syncTemplate(projectDir, input);
|
|
1369
1006
|
if (result.status === "synced" || result.status === "dry-run") {
|
|
1370
1007
|
const syncedConfig = await require_config.loadResolvedConfig({ cwd: projectDir });
|
|
1371
|
-
if (syncedConfig?.config) await generateCodeArtifacts(projectDir, syncedConfig.config);
|
|
1008
|
+
if (syncedConfig?.config) await require_code_artifacts.generateCodeArtifacts(projectDir, syncedConfig.config);
|
|
1372
1009
|
}
|
|
1373
1010
|
return result;
|
|
1374
1011
|
} catch (error) {
|
|
@@ -1446,7 +1083,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1446
1083
|
source: refreshed.runtime.api.source
|
|
1447
1084
|
};
|
|
1448
1085
|
}
|
|
1449
|
-
const artifacts = await generateCodeArtifacts(projectDir, refreshed.config, { runtimeConfig: refreshed.runtime });
|
|
1086
|
+
const artifacts = await require_code_artifacts.generateCodeArtifacts(projectDir, refreshed.config, { runtimeConfig: refreshed.runtime });
|
|
1450
1087
|
const hasLocalApiWorkspace = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "api", "src"));
|
|
1451
1088
|
const generated = ["ui/src/lib/api-types.gen.ts"];
|
|
1452
1089
|
if (hasLocalApiWorkspace) generated.push("api/src/lib/plugins-types.gen.ts", "api/src/lib/auth-types.gen.ts");
|
|
@@ -1544,176 +1181,6 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1544
1181
|
})
|
|
1545
1182
|
})
|
|
1546
1183
|
});
|
|
1547
|
-
async function publishToFastKv(input) {
|
|
1548
|
-
const { env, dryRun, configDir } = input;
|
|
1549
|
-
let bosConfig = input.bosConfig;
|
|
1550
|
-
const runtimeConfig = input.runtimeConfig;
|
|
1551
|
-
const isStaging = env === "staging";
|
|
1552
|
-
const account = bosConfig.account;
|
|
1553
|
-
const gateway = isStaging ? bosConfig.staging?.domain ?? bosConfig.domain : bosConfig.domain;
|
|
1554
|
-
if (!gateway) return {
|
|
1555
|
-
status: "error",
|
|
1556
|
-
registryUrl: "",
|
|
1557
|
-
error: "bos.config.json must define domain to publish"
|
|
1558
|
-
};
|
|
1559
|
-
const network = input.network ?? require_network.getNetworkIdForAccount(account);
|
|
1560
|
-
const registryUrl = require_fastkv.buildRegistryConfigUrlForNetwork(network, account, gateway);
|
|
1561
|
-
const targets = selectWorkspaceTargets(input.packages, bosConfig);
|
|
1562
|
-
let built;
|
|
1563
|
-
let skipped;
|
|
1564
|
-
let deployResults;
|
|
1565
|
-
if (dryRun) return {
|
|
1566
|
-
status: "dry-run",
|
|
1567
|
-
registryUrl,
|
|
1568
|
-
built,
|
|
1569
|
-
skipped
|
|
1570
|
-
};
|
|
1571
|
-
const privateKey = input.privateKey || node_process.default.env.NEAR_PRIVATE_KEY || node_process.default.env.BOS_NEAR_PRIVATE_KEY;
|
|
1572
|
-
let signingMode;
|
|
1573
|
-
try {
|
|
1574
|
-
signingMode = require_near_cli.resolveNearSigningMode(privateKey);
|
|
1575
|
-
} catch (error) {
|
|
1576
|
-
return {
|
|
1577
|
-
status: "error",
|
|
1578
|
-
registryUrl,
|
|
1579
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
if (input.build) {
|
|
1583
|
-
console.log(" Ensuring NEAR CLI...");
|
|
1584
|
-
await effect.Effect.runPromise(require_near_cli.ensureNearCli);
|
|
1585
|
-
console.log(" NEAR CLI ready");
|
|
1586
|
-
await generateCodeArtifacts(configDir, bosConfig, {
|
|
1587
|
-
env: "production",
|
|
1588
|
-
runtimeConfig: runtimeConfig ?? void 0
|
|
1589
|
-
});
|
|
1590
|
-
const result = await buildWorkspaceTargets({
|
|
1591
|
-
configDir,
|
|
1592
|
-
bosConfig,
|
|
1593
|
-
runtimeConfig,
|
|
1594
|
-
targets,
|
|
1595
|
-
deploy: true,
|
|
1596
|
-
verbose: input.verbose
|
|
1597
|
-
});
|
|
1598
|
-
built = result.built;
|
|
1599
|
-
skipped = result.skipped;
|
|
1600
|
-
deployResults = result.deployResults;
|
|
1601
|
-
if (deployResults) {
|
|
1602
|
-
const failures = deployResults.filter((r) => !r.success);
|
|
1603
|
-
if (failures.length > 0) {
|
|
1604
|
-
const total = deployResults.length;
|
|
1605
|
-
console.log();
|
|
1606
|
-
console.log(require_theme.colors.error(` ${require_theme.icons.err} Deploy failed — ${failures.length} of ${total} workspace${total > 1 ? "s" : ""} failed`));
|
|
1607
|
-
console.log();
|
|
1608
|
-
for (const f of failures) {
|
|
1609
|
-
const errorLine = (f.error ?? "Failed").split("\n")[0];
|
|
1610
|
-
console.log(` ${require_theme.colors.error(require_theme.icons.err)} ${padRight(f.key, 28)} ${errorLine}`);
|
|
1611
|
-
}
|
|
1612
|
-
console.log();
|
|
1613
|
-
if (!input.verbose) {
|
|
1614
|
-
console.log(require_theme.colors.dim(" Run with --verbose for full build output."));
|
|
1615
|
-
console.log();
|
|
1616
|
-
}
|
|
1617
|
-
return {
|
|
1618
|
-
status: "error",
|
|
1619
|
-
registryUrl,
|
|
1620
|
-
built,
|
|
1621
|
-
skipped,
|
|
1622
|
-
deployResults,
|
|
1623
|
-
error: `${failures.length} of ${total} workspaces failed to deploy`
|
|
1624
|
-
};
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
const refreshed = await require_config.loadResolvedConfig({ cwd: configDir });
|
|
1628
|
-
if (!refreshed?.config) return {
|
|
1629
|
-
status: "error",
|
|
1630
|
-
registryUrl,
|
|
1631
|
-
built,
|
|
1632
|
-
skipped,
|
|
1633
|
-
deployResults,
|
|
1634
|
-
error: "Failed to reload bos.config.json after build"
|
|
1635
|
-
};
|
|
1636
|
-
bosConfig = refreshed.config;
|
|
1637
|
-
}
|
|
1638
|
-
const rawConfigPath = (0, node_path.join)(configDir, "bos.config.json");
|
|
1639
|
-
const rawConfig = JSON.parse((0, node_fs.readFileSync)(rawConfigPath, "utf-8"));
|
|
1640
|
-
const publishPayload = isStaging ? {
|
|
1641
|
-
...rawConfig,
|
|
1642
|
-
domain: gateway
|
|
1643
|
-
} : rawConfig;
|
|
1644
|
-
const registryEntries = { [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishPayload) };
|
|
1645
|
-
const payload = JSON.stringify(registryEntries);
|
|
1646
|
-
const argsBase64 = Buffer.from(payload).toString("base64");
|
|
1647
|
-
console.log();
|
|
1648
|
-
console.log(" Publishing to:");
|
|
1649
|
-
console.log(` ${require_theme.colors.cyan(registryUrl)}`);
|
|
1650
|
-
try {
|
|
1651
|
-
let txHash;
|
|
1652
|
-
console.log(` Submitting transaction on ${network}...`);
|
|
1653
|
-
try {
|
|
1654
|
-
const tx = await effect.Effect.runPromise(require_near_cli.executeTransaction({
|
|
1655
|
-
account,
|
|
1656
|
-
contract: require_fastkv.getRegistryNamespaceForNetwork(network),
|
|
1657
|
-
method: "__fastdata_kv",
|
|
1658
|
-
argsBase64,
|
|
1659
|
-
network,
|
|
1660
|
-
privateKey: signingMode._tag === "privateKey" ? signingMode.privateKey : void 0,
|
|
1661
|
-
gas: "300Tgas",
|
|
1662
|
-
deposit: "0NEAR",
|
|
1663
|
-
verbose: input.verbose
|
|
1664
|
-
}, signingMode));
|
|
1665
|
-
txHash = tx.txHash;
|
|
1666
|
-
if (txHash && !tx.output?.includes("CodeDoesNotExist")) console.log(` Transaction submitted: ${require_theme.colors.dim(txHash)}`);
|
|
1667
|
-
} catch (error) {
|
|
1668
|
-
console.log(require_theme.colors.dim(" Transaction reported an error — verifying publish..."));
|
|
1669
|
-
try {
|
|
1670
|
-
await waitForPublishedConfig({
|
|
1671
|
-
account,
|
|
1672
|
-
gateway,
|
|
1673
|
-
publishConfig: publishPayload,
|
|
1674
|
-
timeoutMs: 3e4,
|
|
1675
|
-
intervalMs: 2e3
|
|
1676
|
-
});
|
|
1677
|
-
txHash = extractTransactionHash(error);
|
|
1678
|
-
} catch {
|
|
1679
|
-
throw error;
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
console.log(" Waiting for publish confirmation...");
|
|
1683
|
-
await waitForPublishedConfig({
|
|
1684
|
-
account,
|
|
1685
|
-
gateway,
|
|
1686
|
-
publishConfig: publishPayload
|
|
1687
|
-
});
|
|
1688
|
-
return {
|
|
1689
|
-
status: "published",
|
|
1690
|
-
registryUrl,
|
|
1691
|
-
txHash,
|
|
1692
|
-
built,
|
|
1693
|
-
skipped,
|
|
1694
|
-
deployResults,
|
|
1695
|
-
publishConfig: publishPayload
|
|
1696
|
-
};
|
|
1697
|
-
} catch (error) {
|
|
1698
|
-
return {
|
|
1699
|
-
status: "error",
|
|
1700
|
-
registryUrl,
|
|
1701
|
-
error: formatNearError(error),
|
|
1702
|
-
built,
|
|
1703
|
-
skipped,
|
|
1704
|
-
deployResults
|
|
1705
|
-
};
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
function formatNearError(error) {
|
|
1709
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1710
|
-
if (message.includes("exceeded gas") || message.includes("GasLimitExceeded")) return `Transaction exceeded gas limit.\n Original: ${message}`;
|
|
1711
|
-
if (message.includes("timeout") || message.includes("Timeout")) return `Transaction timed out. Check NEAR network status.\n Original: ${message}`;
|
|
1712
|
-
return message;
|
|
1713
|
-
}
|
|
1714
|
-
function extractTransactionHash(error) {
|
|
1715
|
-
return (error instanceof Error ? error.message : String(error)).match(/Transaction ID:\s*([A-Za-z0-9]+)/i)?.[1];
|
|
1716
|
-
}
|
|
1717
1184
|
function computeAllowedWorkspaces(overrides, plugins) {
|
|
1718
1185
|
const workspaces = [];
|
|
1719
1186
|
for (const section of overrides) {
|
|
@@ -1730,5 +1197,4 @@ exports.consumeDevSession = consumeDevSession;
|
|
|
1730
1197
|
exports.default = plugin_default;
|
|
1731
1198
|
exports.pluginEvents = pluginEvents;
|
|
1732
1199
|
exports.resolveRemoteConfigChain = resolveRemoteConfigChain;
|
|
1733
|
-
exports.waitForPublishedConfig = waitForPublishedConfig;
|
|
1734
1200
|
//# sourceMappingURL=plugin.cjs.map
|