everything-dev 0.3.2 → 0.3.3

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/src/plugin.ts CHANGED
@@ -15,7 +15,11 @@ import {
15
15
  resolvePackages,
16
16
  type SourceMode,
17
17
  } from "./config";
18
- import { bosContract } from "./contract";
18
+ import {
19
+ type BuildOptions,
20
+ bosContract,
21
+ type PublishOptions,
22
+ } from "./contract";
19
23
  import {
20
24
  getBuildEnv,
21
25
  hasZephyrConfig,
@@ -370,7 +374,7 @@ export default createPlugin({
370
374
  };
371
375
  }),
372
376
 
373
- start: builder.start.handler(async (input) => {
377
+ start: builder.start.handler(async ({ input }) => {
374
378
  let remoteConfig: BosConfigType | null = null;
375
379
 
376
380
  if (input.account && input.domain) {
@@ -469,7 +473,7 @@ export default createPlugin({
469
473
  };
470
474
  }),
471
475
 
472
- serve: builder.serve.handler(async (input) => {
476
+ serve: builder.serve.handler(async ({ input }) => {
473
477
  const port = input.port;
474
478
 
475
479
  return {
@@ -482,14 +486,14 @@ export default createPlugin({
482
486
  };
483
487
  }),
484
488
 
485
- build: builder.build.handler(async (input: buildInput) => {
489
+ build: builder.build.handler(async ({ input }: { input: BuildOptions }) => {
486
490
  const allPackages = deps.bosConfig ? Object.keys(deps.bosConfig.app) : [];
487
491
  const { configDir } = deps;
488
492
 
489
493
  const targets =
490
- buildInput.packages === "all"
494
+ input.packages === "all"
491
495
  ? allPackages
492
- : buildInput.packages
496
+ : input.packages
493
497
  .split(",")
494
498
  .map((p) => p.trim())
495
499
  .filter((p) => allPackages.includes(p));
@@ -542,7 +546,7 @@ export default createPlugin({
542
546
  const bosEnv = yield* loadBosEnv;
543
547
  const env = getBuildEnv(bosEnv);
544
548
 
545
- if (!buildInput.deploy) {
549
+ if (!input.deploy) {
546
550
  env.NODE_ENV = "development";
547
551
  } else {
548
552
  env.NODE_ENV = "production";
@@ -580,106 +584,109 @@ export default createPlugin({
580
584
  status: "success" as const,
581
585
  built,
582
586
  skipped: missing,
583
- deployed: buildInput.deploy,
587
+ deployed: input.deploy,
584
588
  };
585
589
  }),
586
590
 
587
- publish: builder.publish.handler(async (input: publishInput) => {
588
- const { bosConfig, nearPrivateKey } = deps;
589
-
590
- if (!bosConfig) {
591
- return {
592
- status: "error" as const,
593
- txHash: "",
594
- registryUrl: "",
595
- error: "No bos.config.json found. Run from a BOS project directory.",
596
- };
597
- }
598
-
599
- const network = publishInput.network;
600
-
601
- try {
602
- const account = getAccountForNetwork(bosConfig, network);
603
- const gatewayDomain = getGatewayDomain(bosConfig);
604
- const socialContract = getSocialContract(network);
605
- const socialPath = `${account}/bos/gateways/${gatewayDomain}/bos.config.json`;
591
+ publish: builder.publish.handler(
592
+ async ({ input }: { input: PublishOptions }) => {
593
+ const { bosConfig, nearPrivateKey } = deps;
606
594
 
607
- const publishEffect = Effect.gen(function* () {
608
- yield* ensureNearCli;
595
+ if (!bosConfig) {
596
+ return {
597
+ status: "error" as const,
598
+ txHash: "",
599
+ registryUrl: "",
600
+ error:
601
+ "No bos.config.json found. Run from a BOS project directory.",
602
+ };
603
+ }
609
604
 
610
- const bosEnv = yield* loadBosEnv;
611
- const privateKey = nearPrivateKey || bosEnv.NEAR_PRIVATE_KEY;
605
+ const network = input.network;
612
606
 
613
- const socialArgs = buildSocialSetArgs(
614
- account,
615
- gatewayDomain,
616
- bosConfig,
617
- ) as {
618
- data: Record<string, Record<string, unknown>>;
619
- };
620
- const argsBase64 = Buffer.from(JSON.stringify(socialArgs)).toString(
621
- "base64",
622
- );
607
+ try {
608
+ const account = getAccountForNetwork(bosConfig, network);
609
+ const gatewayDomain = getGatewayDomain(bosConfig);
610
+ const socialContract = getSocialContract(network);
611
+ const socialPath = `${account}/bos/gateways/${gatewayDomain}/bos.config.json`;
612
+
613
+ const publishEffect = Effect.gen(function* () {
614
+ yield* ensureNearCli;
615
+
616
+ const bosEnv = yield* loadBosEnv;
617
+ const privateKey = nearPrivateKey || bosEnv.NEAR_PRIVATE_KEY;
618
+
619
+ const socialArgs = buildSocialSetArgs(
620
+ account,
621
+ gatewayDomain,
622
+ bosConfig,
623
+ ) as {
624
+ data: Record<string, Record<string, unknown>>;
625
+ };
626
+ const argsBase64 = Buffer.from(JSON.stringify(socialArgs)).toString(
627
+ "base64",
628
+ );
623
629
 
624
- const graph = new Graph({
625
- network,
626
- contractId: socialContract,
627
- });
628
- const storageBalance = yield* Effect.tryPromise({
629
- try: () => graph.storageBalanceOf(account),
630
- catch: () => new Error("Failed to fetch storage balance"),
631
- });
630
+ const graph = new Graph({
631
+ network,
632
+ contractId: socialContract,
633
+ });
634
+ const storageBalance = yield* Effect.tryPromise({
635
+ try: () => graph.storageBalanceOf(account),
636
+ catch: () => new Error("Failed to fetch storage balance"),
637
+ });
638
+
639
+ const requiredDeposit = calculateRequiredDeposit({
640
+ data: socialArgs.data,
641
+ storageBalance: storageBalance
642
+ ? {
643
+ available: BigInt(storageBalance.available),
644
+ total: BigInt(storageBalance.total),
645
+ }
646
+ : null,
647
+ });
648
+ const depositAmount = requiredDeposit.toFixed();
649
+
650
+ if (input.dryRun) {
651
+ return {
652
+ status: "dry-run" as const,
653
+ txHash: "",
654
+ registryUrl: getSocialExplorerUrl(network, socialPath),
655
+ };
656
+ }
632
657
 
633
- const requiredDeposit = calculateRequiredDeposit({
634
- data: socialArgs.data,
635
- storageBalance: storageBalance
636
- ? {
637
- available: BigInt(storageBalance.available),
638
- total: BigInt(storageBalance.total),
639
- }
640
- : null,
641
- });
642
- const depositAmount = requiredDeposit.toFixed();
658
+ const result = yield* executeTransaction({
659
+ account,
660
+ contract: socialContract,
661
+ method: "set",
662
+ argsBase64,
663
+ network,
664
+ privateKey,
665
+ gas: "300Tgas",
666
+ deposit:
667
+ depositAmount === "0"
668
+ ? "1yoctoNEAR"
669
+ : `${depositAmount}yoctoNEAR`,
670
+ });
643
671
 
644
- if (publishInput.dryRun) {
645
672
  return {
646
- status: "dry-run" as const,
647
- txHash: "",
673
+ status: "published" as const,
674
+ txHash: result.txHash || "unknown",
648
675
  registryUrl: getSocialExplorerUrl(network, socialPath),
649
676
  };
650
- }
651
-
652
- const result = yield* executeTransaction({
653
- account,
654
- contract: socialContract,
655
- method: "set",
656
- argsBase64,
657
- network,
658
- privateKey,
659
- gas: "300Tgas",
660
- deposit:
661
- depositAmount === "0"
662
- ? "1yoctoNEAR"
663
- : `${depositAmount}yoctoNEAR`,
664
677
  });
665
678
 
679
+ return await Effect.runPromise(publishEffect);
680
+ } catch (error) {
666
681
  return {
667
- status: "published" as const,
668
- txHash: result.txHash || "unknown",
669
- registryUrl: getSocialExplorerUrl(network, socialPath),
682
+ status: "error" as const,
683
+ txHash: "",
684
+ registryUrl: "",
685
+ error: error instanceof Error ? error.message : "Unknown error",
670
686
  };
671
- });
672
-
673
- return await Effect.runPromise(publishEffect);
674
- } catch (error) {
675
- return {
676
- status: "error" as const,
677
- txHash: "",
678
- registryUrl: "",
679
- error: error instanceof Error ? error.message : "Unknown error",
680
- };
681
- }
682
- }),
687
+ }
688
+ },
689
+ ),
683
690
 
684
691
  create: builder.create.handler(async ({ input }) => {
685
692
  const { join } = await import("path");
@@ -1051,7 +1058,7 @@ export default createPlugin({
1051
1058
  };
1052
1059
  }),
1053
1060
 
1054
- status: builder.status.handler(async (input) => {
1061
+ status: builder.status.handler(async ({ input }) => {
1055
1062
  const config = deps.bosConfig;
1056
1063
 
1057
1064
  if (!config) {
@@ -1146,7 +1153,7 @@ export default createPlugin({
1146
1153
  };
1147
1154
  }),
1148
1155
 
1149
- register: builder.register.handler(async (input) => {
1156
+ register: builder.register.handler(async ({ input }) => {
1150
1157
  const { bosConfig } = deps;
1151
1158
 
1152
1159
  if (!bosConfig) {
@@ -1210,7 +1217,7 @@ export default createPlugin({
1210
1217
  }
1211
1218
  }),
1212
1219
 
1213
- secretsSync: builder.secretsSync.handler(async (input) => {
1220
+ secretsSync: builder.secretsSync.handler(async ({ input }) => {
1214
1221
  const { bosConfig } = deps;
1215
1222
 
1216
1223
  if (!bosConfig) {
@@ -1252,7 +1259,7 @@ export default createPlugin({
1252
1259
  }
1253
1260
  }),
1254
1261
 
1255
- secretsSet: builder.secretsSet.handler(async (input) => {
1262
+ secretsSet: builder.secretsSet.handler(async ({ input }) => {
1256
1263
  const { bosConfig } = deps;
1257
1264
 
1258
1265
  if (!bosConfig) {
@@ -1332,7 +1339,7 @@ export default createPlugin({
1332
1339
  }
1333
1340
  }),
1334
1341
 
1335
- secretsDelete: builder.secretsDelete.handler(async (input) => {
1342
+ secretsDelete: builder.secretsDelete.handler(async ({ input }) => {
1336
1343
  const { bosConfig } = deps;
1337
1344
 
1338
1345
  if (!bosConfig) {
@@ -1377,7 +1384,7 @@ export default createPlugin({
1377
1384
  }
1378
1385
  }),
1379
1386
 
1380
- login: builder.login.handler(async (input) => {
1387
+ login: builder.login.handler(async ({ input }) => {
1381
1388
  const loginEffect = Effect.gen(function* () {
1382
1389
  const { token, accountId } = input;
1383
1390
 
@@ -1475,7 +1482,7 @@ export default createPlugin({
1475
1482
  }
1476
1483
  }),
1477
1484
 
1478
- gatewayDeploy: builder.gatewayDeploy.handler(async (input) => {
1485
+ gatewayDeploy: builder.gatewayDeploy.handler(async ({ input }) => {
1479
1486
  const { configDir, bosConfig } = deps;
1480
1487
 
1481
1488
  if (!bosConfig) {
@@ -1571,7 +1578,7 @@ export default createPlugin({
1571
1578
  }
1572
1579
  }),
1573
1580
 
1574
- depsUpdate: builder.depsUpdate.handler(async (input) => {
1581
+ depsUpdate: builder.depsUpdate.handler(async ({ input }) => {
1575
1582
  const { configDir, bosConfig } = deps;
1576
1583
 
1577
1584
  if (!bosConfig) {
@@ -1706,7 +1713,7 @@ export default createPlugin({
1706
1713
  }
1707
1714
  }),
1708
1715
 
1709
- filesSync: builder.filesSync.handler(async (input) => {
1716
+ filesSync: builder.filesSync.handler(async ({ input }) => {
1710
1717
  const { configDir, bosConfig } = deps;
1711
1718
 
1712
1719
  if (!bosConfig) {
@@ -1739,7 +1746,7 @@ export default createPlugin({
1739
1746
  };
1740
1747
  }),
1741
1748
 
1742
- update: builder.update.handler(async (input) => {
1749
+ update: builder.update.handler(async ({ input }) => {
1743
1750
  const { configDir, bosConfig } = deps;
1744
1751
 
1745
1752
  const DEFAULT_ACCOUNT = "every.near";
@@ -1969,7 +1976,7 @@ export default createPlugin({
1969
1976
  }
1970
1977
  }),
1971
1978
 
1972
- kill: builder.kill.handler(async (input) => {
1979
+ kill: builder.kill.handler(async ({ input }) => {
1973
1980
  const killEffect = Effect.gen(function* () {
1974
1981
  const registry = yield* createProcessRegistry();
1975
1982
  const result = yield* registry.killAll(input.force);
@@ -2013,7 +2020,7 @@ export default createPlugin({
2013
2020
  }
2014
2021
  }),
2015
2022
 
2016
- dockerBuild: builder.dockerBuild.handler(async (input) => {
2023
+ dockerBuild: builder.dockerBuild.handler(async ({ input }) => {
2017
2024
  const { configDir, bosConfig } = deps;
2018
2025
 
2019
2026
  const dockerEffect = Effect.gen(function* () {
@@ -2063,7 +2070,7 @@ export default createPlugin({
2063
2070
  }
2064
2071
  }),
2065
2072
 
2066
- dockerRun: builder.dockerRun.handler(async (input) => {
2073
+ dockerRun: builder.dockerRun.handler(async ({ input }) => {
2067
2074
  const { bosConfig } = deps;
2068
2075
 
2069
2076
  const dockerEffect = Effect.gen(function* () {
@@ -2148,7 +2155,7 @@ export default createPlugin({
2148
2155
  }
2149
2156
  }),
2150
2157
 
2151
- dockerStop: builder.dockerStop.handler(async (input) => {
2158
+ dockerStop: builder.dockerStop.handler(async ({ input }) => {
2152
2159
  const { bosConfig } = deps;
2153
2160
 
2154
2161
  const dockerEffect = Effect.gen(function* () {
@@ -2211,7 +2218,7 @@ export default createPlugin({
2211
2218
  }
2212
2219
  }),
2213
2220
 
2214
- monitor: builder.monitor.handler(async (input) => {
2221
+ monitor: builder.monitor.handler(async ({ input }) => {
2215
2222
  try {
2216
2223
  if (input.json) {
2217
2224
  const snapshot = await runWithInfo(
@@ -2251,7 +2258,7 @@ export default createPlugin({
2251
2258
  }
2252
2259
  }),
2253
2260
 
2254
- session: builder.session.handler(async (input) => {
2261
+ session: builder.session.handler(async ({ input }) => {
2255
2262
  const sessionEffect = Effect.gen(function* () {
2256
2263
  const recorder = yield* SessionRecorder.create({
2257
2264
  ports: [3000],