everything-dev 1.44.1 → 1.45.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.
Files changed (49) hide show
  1. package/dist/cli/sync.cjs +6 -0
  2. package/dist/cli/sync.cjs.map +1 -1
  3. package/dist/cli/sync.mjs +6 -0
  4. package/dist/cli/sync.mjs.map +1 -1
  5. package/dist/cli.cjs +34 -0
  6. package/dist/cli.cjs.map +1 -1
  7. package/dist/cli.mjs +34 -0
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/contract.cjs +16 -2
  10. package/dist/contract.cjs.map +1 -1
  11. package/dist/contract.d.cts +68 -3
  12. package/dist/contract.d.cts.map +1 -1
  13. package/dist/contract.d.mts +68 -3
  14. package/dist/contract.d.mts.map +1 -1
  15. package/dist/contract.meta.cjs +2 -0
  16. package/dist/contract.meta.cjs.map +1 -1
  17. package/dist/contract.meta.d.cts +6 -0
  18. package/dist/contract.meta.d.mts +6 -0
  19. package/dist/contract.meta.mjs +2 -0
  20. package/dist/contract.meta.mjs.map +1 -1
  21. package/dist/contract.mjs +16 -3
  22. package/dist/contract.mjs.map +1 -1
  23. package/dist/index.cjs +1 -0
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.mts +2 -2
  26. package/dist/index.mjs +2 -2
  27. package/dist/integrity.cjs +116 -0
  28. package/dist/integrity.cjs.map +1 -1
  29. package/dist/integrity.d.cts +21 -1
  30. package/dist/integrity.d.cts.map +1 -1
  31. package/dist/integrity.d.mts +21 -1
  32. package/dist/integrity.d.mts.map +1 -1
  33. package/dist/integrity.mjs +111 -1
  34. package/dist/integrity.mjs.map +1 -1
  35. package/dist/near-cli.cjs +12 -15
  36. package/dist/near-cli.cjs.map +1 -1
  37. package/dist/near-cli.mjs +12 -15
  38. package/dist/near-cli.mjs.map +1 -1
  39. package/dist/plugin.cjs +281 -47
  40. package/dist/plugin.cjs.map +1 -1
  41. package/dist/plugin.d.cts +28 -2
  42. package/dist/plugin.d.cts.map +1 -1
  43. package/dist/plugin.d.mts +28 -2
  44. package/dist/plugin.d.mts.map +1 -1
  45. package/dist/plugin.mjs +284 -50
  46. package/dist/plugin.mjs.map +1 -1
  47. package/dist/types.d.cts +2 -2
  48. package/dist/types.d.mts +2 -2
  49. package/package.json +1 -1
package/dist/plugin.cjs CHANGED
@@ -231,9 +231,9 @@ async function waitForPublishedConfig(opts) {
231
231
  const reason = lastError instanceof Error ? ` Last error: ${lastError.message}` : "";
232
232
  throw new Error(`Timed out waiting for publish confirmation at bos://${opts.account}/${opts.gateway}.${reason}`);
233
233
  }
234
- async function buildEveryPluginQuietly(cwd) {
234
+ async function buildEveryPluginQuietly(cwd, force = false) {
235
235
  if (!await fileExists(`${`${cwd}/packages/every-plugin`}/package.json`)) return;
236
- if (await fileExists(`${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`)) return;
236
+ if (await fileExists(`${cwd}/packages/every-plugin/dist/build/rspack/plugin.mjs`) && !force) return;
237
237
  const result = await require_run.run("bun", [
238
238
  "run",
239
239
  "--cwd",
@@ -243,17 +243,14 @@ async function buildEveryPluginQuietly(cwd) {
243
243
  cwd,
244
244
  capture: true
245
245
  });
246
- if (result.exitCode === 0) {
247
- console.log("[build:ssr] build succeeded");
248
- return;
249
- }
246
+ if (result.exitCode === 0) return;
250
247
  if (result.stdout.trim()) node_process.default.stdout.write(result.stdout);
251
248
  if (result.stderr.trim()) node_process.default.stderr.write(result.stderr);
252
249
  throw new Error(`bun run --cwd packages/every-plugin build failed with exit code ${result.exitCode}`);
253
250
  }
254
- async function buildEverythingDevQuietly(cwd) {
251
+ async function buildEverythingDevQuietly(cwd, force = false) {
255
252
  if (!await fileExists(`${`${cwd}/packages/everything-dev`}/package.json`)) return;
256
- if (await fileExists(`${cwd}/packages/everything-dev/dist/index.mjs`)) return;
253
+ if (await fileExists(`${cwd}/packages/everything-dev/dist/index.mjs`) && !force) return;
257
254
  const result = await require_run.run("bun", [
258
255
  "run",
259
256
  "--cwd",
@@ -263,10 +260,7 @@ async function buildEverythingDevQuietly(cwd) {
263
260
  cwd,
264
261
  capture: true
265
262
  });
266
- if (result.exitCode === 0) {
267
- console.log("[everything-dev] build succeeded");
268
- return;
269
- }
263
+ if (result.exitCode === 0) return;
270
264
  if (result.stdout.trim()) node_process.default.stdout.write(result.stdout);
271
265
  if (result.stderr.trim()) node_process.default.stderr.write(result.stderr);
272
266
  throw new Error(`bun run --cwd packages/everything-dev build failed with exit code ${result.exitCode}`);
@@ -299,6 +293,141 @@ function selectWorkspaceTargets(packages, bosConfig) {
299
293
  if (packages === "all") return allPackages;
300
294
  return packages.split(",").map((pkg) => pkg.trim()).filter((pkg) => allPackages.includes(pkg));
301
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
+ }
302
431
  async function buildWorkspaceTargets(opts) {
303
432
  const existing = [];
304
433
  const skipped = [];
@@ -322,8 +451,9 @@ async function buildWorkspaceTargets(opts) {
322
451
  extendsChain: []
323
452
  })).catalogChanged) await require_run.run("bun", ["install"], { cwd: opts.configDir });
324
453
  const shouldBuildPlugin = existing.some((entry) => entry.key === "api");
325
- const buildTasks = [buildEverythingDevQuietly(opts.configDir)];
326
- if (shouldBuildPlugin) buildTasks.push(buildEveryPluginQuietly(opts.configDir));
454
+ const forceRebuild = opts.deploy;
455
+ const buildTasks = [buildEverythingDevQuietly(opts.configDir, forceRebuild)];
456
+ if (shouldBuildPlugin) buildTasks.push(buildEveryPluginQuietly(opts.configDir, forceRebuild));
327
457
  await Promise.all(buildTasks);
328
458
  const env = {
329
459
  ...node_process.default.env,
@@ -331,18 +461,63 @@ async function buildWorkspaceTargets(opts) {
331
461
  };
332
462
  if (opts.deploy) env.DEPLOY = "true";
333
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");
334
469
  const orderedExisting = opts.deploy ? [
335
470
  ...existing.filter((entry) => entry.kind === "app" && entry.key !== "host"),
336
471
  ...existing.filter((entry) => entry.kind === "plugin"),
337
472
  ...existing.filter((entry) => entry.kind === "app" && entry.key === "host")
338
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") : [];
339
476
  const built = [];
340
- for (const resolved of orderedExisting) {
341
- const pkgJson = await readJsonFile(`${resolved.path}/package.json`);
342
- const buildConfig = opts.deploy && pkgJson.scripts?.deploy ? {
343
- cmd: "bun",
344
- args: ["run", "deploy"]
345
- } : buildCommands[resolved.key] ?? {
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] ?? {
346
521
  cmd: "bun",
347
522
  args: ["run", "build"]
348
523
  };
@@ -354,7 +529,8 @@ async function buildWorkspaceTargets(opts) {
354
529
  }
355
530
  return {
356
531
  built,
357
- skipped
532
+ skipped,
533
+ deployResults: opts.deploy ? deployResults : void 0
358
534
  };
359
535
  }
360
536
  var plugin_default = (0, every_plugin.createPlugin)({
@@ -826,6 +1002,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
826
1002
  env: input.env,
827
1003
  build: input.deploy,
828
1004
  dryRun: input.dryRun,
1005
+ verbose: input.verbose,
829
1006
  packages: input.packages,
830
1007
  network: input.network,
831
1008
  privateKey: input.privateKey
@@ -843,7 +1020,8 @@ var plugin_default = (0, every_plugin.createPlugin)({
843
1020
  txHash: result.txHash,
844
1021
  error: result.error,
845
1022
  built: result.built,
846
- skipped: result.skipped
1023
+ skipped: result.skipped,
1024
+ deployResults: result.deployResults
847
1025
  };
848
1026
  }),
849
1027
  deploy: builder.deploy.handler(async ({ input }) => {
@@ -860,6 +1038,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
860
1038
  env: input.env,
861
1039
  build: input.build,
862
1040
  dryRun: input.dryRun,
1041
+ verbose: input.verbose,
863
1042
  packages: input.packages,
864
1043
  network: input.network,
865
1044
  privateKey: input.privateKey
@@ -871,7 +1050,8 @@ var plugin_default = (0, every_plugin.createPlugin)({
871
1050
  built: result.built,
872
1051
  skipped: result.skipped,
873
1052
  redeployed: false,
874
- error: result.error
1053
+ error: result.error,
1054
+ deployResults: result.deployResults
875
1055
  };
876
1056
  if (result.status === "dry-run") return {
877
1057
  status: "dry-run",
@@ -901,6 +1081,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
901
1081
  built: result.built,
902
1082
  skipped: result.skipped,
903
1083
  redeployed: false,
1084
+ deployResults: result.deployResults,
904
1085
  error: "Config published but Railway redeploy failed: ci.railway.service is not configured in bos.config.json"
905
1086
  };
906
1087
  }
@@ -931,6 +1112,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
931
1112
  skipped: result.skipped,
932
1113
  redeployed: false,
933
1114
  service,
1115
+ deployResults: result.deployResults,
934
1116
  error: `Config published but ${railError}`
935
1117
  };
936
1118
  }
@@ -945,7 +1127,8 @@ var plugin_default = (0, every_plugin.createPlugin)({
945
1127
  built: result.built,
946
1128
  skipped: result.skipped,
947
1129
  redeployed,
948
- service
1130
+ service,
1131
+ deployResults: result.deployResults
949
1132
  };
950
1133
  }),
951
1134
  keyPublish: builder.keyPublish.handler(async ({ input }) => {
@@ -1378,13 +1561,28 @@ async function publishToFastKv(input) {
1378
1561
  const targets = selectWorkspaceTargets(input.packages, bosConfig);
1379
1562
  let built;
1380
1563
  let skipped;
1564
+ let deployResults;
1381
1565
  if (dryRun) return {
1382
1566
  status: "dry-run",
1383
1567
  registryUrl,
1384
1568
  built,
1385
1569
  skipped
1386
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
+ }
1387
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");
1388
1586
  await generateCodeArtifacts(configDir, bosConfig, {
1389
1587
  env: "production",
1390
1588
  runtimeConfig: runtimeConfig ?? void 0
@@ -1394,16 +1592,45 @@ async function publishToFastKv(input) {
1394
1592
  bosConfig,
1395
1593
  runtimeConfig,
1396
1594
  targets,
1397
- deploy: true
1595
+ deploy: true,
1596
+ verbose: input.verbose
1398
1597
  });
1399
1598
  built = result.built;
1400
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
+ }
1401
1627
  const refreshed = await require_config.loadResolvedConfig({ cwd: configDir });
1402
1628
  if (!refreshed?.config) return {
1403
1629
  status: "error",
1404
1630
  registryUrl,
1405
1631
  built,
1406
1632
  skipped,
1633
+ deployResults,
1407
1634
  error: "Failed to reload bos.config.json after build"
1408
1635
  };
1409
1636
  bosConfig = refreshed.config;
@@ -1417,28 +1644,14 @@ async function publishToFastKv(input) {
1417
1644
  const registryEntries = { [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishPayload) };
1418
1645
  const payload = JSON.stringify(registryEntries);
1419
1646
  const argsBase64 = Buffer.from(payload).toString("base64");
1420
- const privateKey = input.privateKey || node_process.default.env.NEAR_PRIVATE_KEY || node_process.default.env.BOS_NEAR_PRIVATE_KEY;
1421
- let signingMode;
1422
- try {
1423
- signingMode = require_near_cli.resolveNearSigningMode(privateKey);
1424
- } catch (error) {
1425
- return {
1426
- status: "error",
1427
- registryUrl,
1428
- error: error instanceof Error ? error.message : "Unknown error"
1429
- };
1430
- }
1431
1647
  console.log();
1432
1648
  console.log(" Publishing to:");
1433
1649
  console.log(` ${require_theme.colors.cyan(registryUrl)}`);
1434
1650
  try {
1435
- console.log(" Ensuring NEAR CLI...");
1436
- await effect.Effect.runPromise(require_near_cli.ensureNearCli);
1437
- console.log(" NEAR CLI ready");
1438
1651
  let txHash;
1439
1652
  console.log(` Submitting transaction on ${network}...`);
1440
1653
  try {
1441
- txHash = (await effect.Effect.runPromise(require_near_cli.executeTransaction({
1654
+ const tx = await effect.Effect.runPromise(require_near_cli.executeTransaction({
1442
1655
  account,
1443
1656
  contract: require_fastkv.getRegistryNamespaceForNetwork(network),
1444
1657
  method: "__fastdata_kv",
@@ -1446,12 +1659,25 @@ async function publishToFastKv(input) {
1446
1659
  network,
1447
1660
  privateKey: signingMode._tag === "privateKey" ? signingMode.privateKey : void 0,
1448
1661
  gas: "300Tgas",
1449
- deposit: "0NEAR"
1450
- }, signingMode))).txHash;
1451
- if (txHash) console.log(` Transaction submitted: ${require_theme.colors.dim(txHash)}`);
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)}`);
1452
1667
  } catch (error) {
1453
- txHash = extractTransactionHash(error);
1454
- if (!txHash) throw 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
+ }
1455
1681
  }
1456
1682
  console.log(" Waiting for publish confirmation...");
1457
1683
  await waitForPublishedConfig({
@@ -1465,18 +1691,26 @@ async function publishToFastKv(input) {
1465
1691
  txHash,
1466
1692
  built,
1467
1693
  skipped,
1694
+ deployResults,
1468
1695
  publishConfig: publishPayload
1469
1696
  };
1470
1697
  } catch (error) {
1471
1698
  return {
1472
1699
  status: "error",
1473
1700
  registryUrl,
1474
- error: error instanceof Error ? error.message : "Unknown error",
1701
+ error: formatNearError(error),
1475
1702
  built,
1476
- skipped
1703
+ skipped,
1704
+ deployResults
1477
1705
  };
1478
1706
  }
1479
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
+ }
1480
1714
  function extractTransactionHash(error) {
1481
1715
  return (error instanceof Error ? error.message : String(error)).match(/Transaction ID:\s*([A-Za-z0-9]+)/i)?.[1];
1482
1716
  }