everything-dev 1.30.0 → 1.31.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/cli/init.cjs +1 -0
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +1 -1
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +1 -1
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +1 -0
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/sync.cjs +3 -1
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +3 -1
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +1 -1
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +1 -1
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/cli.cjs +31 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +31 -0
- package/dist/cli.mjs.map +1 -1
- package/dist/contract.cjs +32 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +80 -1
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +80 -1
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.meta.cjs +18 -1
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +33 -0
- package/dist/contract.meta.d.mts +33 -0
- package/dist/contract.meta.mjs +18 -1
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +31 -2
- package/dist/contract.mjs.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/merge.cjs +1 -0
- package/dist/merge.cjs.map +1 -1
- package/dist/merge.d.cts +1 -1
- package/dist/merge.d.cts.map +1 -1
- package/dist/merge.d.mts +1 -1
- package/dist/merge.d.mts.map +1 -1
- package/dist/merge.mjs +1 -0
- package/dist/merge.mjs.map +1 -1
- package/dist/mf.cjs +1 -0
- package/dist/mf.cjs.map +1 -1
- package/dist/mf.d.cts.map +1 -1
- package/dist/mf.d.mts.map +1 -1
- package/dist/mf.mjs +1 -0
- package/dist/mf.mjs.map +1 -1
- package/dist/plugin.cjs +216 -76
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +43 -0
- package/dist/plugin.d.mts +43 -0
- package/dist/plugin.mjs +216 -76
- package/dist/plugin.mjs.map +1 -1
- package/dist/types.cjs +7 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +17 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +17 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +6 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
package/dist/plugin.mjs
CHANGED
|
@@ -248,8 +248,9 @@ async function buildEverythingDevQuietly(cwd) {
|
|
|
248
248
|
async function fetchPublishedConfig(accountId, gatewayId) {
|
|
249
249
|
try {
|
|
250
250
|
return await fetchBosConfigFromFastKv(`bos://${accountId}/${gatewayId}`);
|
|
251
|
-
} catch {
|
|
252
|
-
return null;
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (error instanceof Error && error.message.startsWith("No config found")) return null;
|
|
253
|
+
throw error;
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
function selectWorkspaceTargets(packages, bosConfig) {
|
|
@@ -610,20 +611,31 @@ var plugin_default = createPlugin({
|
|
|
610
611
|
phase: "config",
|
|
611
612
|
status: "running"
|
|
612
613
|
});
|
|
614
|
+
const bosEnv = input.env ?? (process.env.BOS_ENV === "staging" ? "staging" : "production");
|
|
613
615
|
const account = input.account ?? process.env.BOS_ACCOUNT;
|
|
614
616
|
const domain = input.domain ?? process.env.BOS_GATEWAY;
|
|
615
617
|
let config = null;
|
|
616
618
|
let remoteConfig = null;
|
|
617
|
-
if (account && domain) {
|
|
619
|
+
if (account && domain) try {
|
|
618
620
|
remoteConfig = await fetchPublishedConfig(account, domain);
|
|
619
621
|
if (remoteConfig) config = remoteConfig;
|
|
620
|
-
else
|
|
622
|
+
else return {
|
|
623
|
+
status: "error",
|
|
624
|
+
url: "",
|
|
625
|
+
error: `No config found at bos://${account}/${domain}. Verify the account and gateway are correct and the config has been published.\nExpected URL: ${buildRegistryConfigUrl(account, domain)}`
|
|
626
|
+
};
|
|
627
|
+
} catch (error) {
|
|
628
|
+
return {
|
|
629
|
+
status: "error",
|
|
630
|
+
url: "",
|
|
631
|
+
error: `Failed to fetch config for bos://${account}/${domain}: ${error instanceof Error ? error.message : "Unknown error"}\nExpected URL: ${buildRegistryConfigUrl(account, domain)}`
|
|
632
|
+
};
|
|
621
633
|
}
|
|
622
|
-
|
|
634
|
+
else config = deps.bosConfig;
|
|
623
635
|
if (!config) return {
|
|
624
636
|
status: "error",
|
|
625
637
|
url: "",
|
|
626
|
-
error: "No configuration found.
|
|
638
|
+
error: "No configuration found. Provide --account and --gateway flags, or create a local bos.config.json."
|
|
627
639
|
};
|
|
628
640
|
if (account) config = {
|
|
629
641
|
...config,
|
|
@@ -634,7 +646,7 @@ var plugin_default = createPlugin({
|
|
|
634
646
|
domain
|
|
635
647
|
};
|
|
636
648
|
const port = input.port ?? getHostDevelopmentPort(config.app.host.development);
|
|
637
|
-
const isStaging =
|
|
649
|
+
const isStaging = bosEnv === "staging";
|
|
638
650
|
const runtimePlugins = await buildRuntimePluginsForConfig(config, deps.configDir, "production");
|
|
639
651
|
suppressWarnings();
|
|
640
652
|
const runtimeConfig = buildRuntimeConfig(config, {
|
|
@@ -647,6 +659,8 @@ var plugin_default = createPlugin({
|
|
|
647
659
|
});
|
|
648
660
|
drainConfigWarnings();
|
|
649
661
|
resumeWarnings();
|
|
662
|
+
if (isStaging && config.staging?.domain) runtimeConfig.domain = config.staging.domain;
|
|
663
|
+
if (isStaging) runtimeConfig.env = "staging";
|
|
650
664
|
syncGeneratedInfra(deps.configDir, runtimeConfig);
|
|
651
665
|
if (!existsSync(join(deps.configDir, ".env"))) {
|
|
652
666
|
ensureEnvFile(deps.configDir);
|
|
@@ -667,12 +681,13 @@ var plugin_default = createPlugin({
|
|
|
667
681
|
const productionEnv = {};
|
|
668
682
|
const warnings = [];
|
|
669
683
|
if (!process.env.CORS_ORIGIN && config.domain) {
|
|
670
|
-
const defaultOrigin = `https://${config.domain}`;
|
|
684
|
+
const defaultOrigin = `https://${isStaging ? config.staging?.domain ?? config.domain : config.domain}`;
|
|
671
685
|
productionEnv.CORS_ORIGIN = defaultOrigin;
|
|
672
686
|
warnings.push(`CORS_ORIGIN defaulting to ${defaultOrigin}`);
|
|
673
687
|
}
|
|
674
688
|
const requiredSecrets = /* @__PURE__ */ new Set();
|
|
675
689
|
const missingSecrets = [];
|
|
690
|
+
if (runtimeConfig.host.secrets) for (const s of runtimeConfig.host.secrets) requiredSecrets.add(s);
|
|
676
691
|
if (runtimeConfig.auth?.secrets) for (const s of runtimeConfig.auth.secrets) requiredSecrets.add(s);
|
|
677
692
|
if (runtimeConfig.api?.secrets) for (const s of runtimeConfig.api.secrets) requiredSecrets.add(s);
|
|
678
693
|
for (const plugin of Object.values(runtimeConfig.plugins ?? {})) if (plugin.secrets) for (const s of plugin.secrets) requiredSecrets.add(s);
|
|
@@ -775,89 +790,120 @@ var plugin_default = createPlugin({
|
|
|
775
790
|
registryUrl: "",
|
|
776
791
|
error: "No bos.config.json found"
|
|
777
792
|
};
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
|
|
793
|
+
const result = await publishToFastKv({
|
|
794
|
+
bosConfig: deps.bosConfig,
|
|
795
|
+
runtimeConfig: deps.runtimeConfig,
|
|
796
|
+
configDir: deps.configDir,
|
|
797
|
+
env: input.env,
|
|
798
|
+
build: input.deploy,
|
|
799
|
+
dryRun: input.dryRun,
|
|
800
|
+
packages: input.packages,
|
|
801
|
+
network: input.network,
|
|
802
|
+
privateKey: input.privateKey
|
|
803
|
+
});
|
|
804
|
+
if (result.publishConfig) {
|
|
805
|
+
const refreshed = await loadResolvedConfig({ cwd: deps.configDir });
|
|
806
|
+
if (refreshed?.config) {
|
|
807
|
+
deps.bosConfig = refreshed.config;
|
|
808
|
+
deps.runtimeConfig = refreshed.runtime;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return {
|
|
812
|
+
status: result.status,
|
|
813
|
+
registryUrl: result.registryUrl,
|
|
814
|
+
txHash: result.txHash,
|
|
815
|
+
error: result.error,
|
|
816
|
+
built: result.built,
|
|
817
|
+
skipped: result.skipped
|
|
818
|
+
};
|
|
819
|
+
}),
|
|
820
|
+
deploy: builder.deploy.handler(async ({ input }) => {
|
|
821
|
+
if (!deps.bosConfig) return {
|
|
781
822
|
status: "error",
|
|
782
823
|
registryUrl: "",
|
|
783
|
-
|
|
824
|
+
redeployed: false,
|
|
825
|
+
error: "No bos.config.json found"
|
|
784
826
|
};
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
827
|
+
const result = await publishToFastKv({
|
|
828
|
+
bosConfig: deps.bosConfig,
|
|
829
|
+
runtimeConfig: deps.runtimeConfig,
|
|
830
|
+
configDir: deps.configDir,
|
|
831
|
+
env: input.env,
|
|
832
|
+
build: input.build,
|
|
833
|
+
dryRun: input.dryRun,
|
|
834
|
+
packages: input.packages,
|
|
835
|
+
network: input.network,
|
|
836
|
+
privateKey: input.privateKey
|
|
837
|
+
});
|
|
838
|
+
if (result.status === "error") return {
|
|
839
|
+
status: "error",
|
|
840
|
+
registryUrl: result.registryUrl,
|
|
841
|
+
txHash: result.txHash,
|
|
842
|
+
built: result.built,
|
|
843
|
+
skipped: result.skipped,
|
|
844
|
+
redeployed: false,
|
|
845
|
+
error: result.error
|
|
846
|
+
};
|
|
847
|
+
if (result.status === "dry-run") return {
|
|
793
848
|
status: "dry-run",
|
|
794
|
-
registryUrl,
|
|
795
|
-
built,
|
|
796
|
-
skipped
|
|
849
|
+
registryUrl: result.registryUrl,
|
|
850
|
+
built: result.built,
|
|
851
|
+
skipped: result.skipped,
|
|
852
|
+
redeployed: false
|
|
797
853
|
};
|
|
798
|
-
if (
|
|
799
|
-
await generateCodeArtifacts(deps.configDir, deps.bosConfig, {
|
|
800
|
-
env: "production",
|
|
801
|
-
runtimeConfig: deps.runtimeConfig ?? void 0
|
|
802
|
-
});
|
|
803
|
-
const result = await buildWorkspaceTargets({
|
|
804
|
-
configDir: deps.configDir,
|
|
805
|
-
bosConfig: deps.bosConfig,
|
|
806
|
-
runtimeConfig: deps.runtimeConfig,
|
|
807
|
-
targets,
|
|
808
|
-
deploy: true
|
|
809
|
-
});
|
|
810
|
-
built = result.built;
|
|
811
|
-
skipped = result.skipped;
|
|
854
|
+
if (result.publishConfig) {
|
|
812
855
|
const refreshed = await loadResolvedConfig({ cwd: deps.configDir });
|
|
813
856
|
if (refreshed?.config) {
|
|
814
857
|
deps.bosConfig = refreshed.config;
|
|
815
858
|
deps.runtimeConfig = refreshed.runtime;
|
|
816
|
-
publishConfig = refreshed.config;
|
|
817
859
|
}
|
|
818
860
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
861
|
+
let redeployed = false;
|
|
862
|
+
let service;
|
|
863
|
+
if (process.env.RAILWAY_TOKEN) {
|
|
864
|
+
const railwayService = input.service ?? deps.bosConfig.ci?.railway?.service;
|
|
865
|
+
if (!railwayService) return {
|
|
866
|
+
status: "published",
|
|
867
|
+
registryUrl: result.registryUrl,
|
|
868
|
+
txHash: result.txHash,
|
|
869
|
+
built: result.built,
|
|
870
|
+
skipped: result.skipped,
|
|
871
|
+
redeployed: false,
|
|
872
|
+
error: "Config published but Railway redeploy failed: ci.railway.service is not configured in bos.config.json"
|
|
873
|
+
};
|
|
874
|
+
service = railwayService;
|
|
826
875
|
try {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
gas: "300Tgas",
|
|
835
|
-
deposit: "0NEAR"
|
|
836
|
-
}))).txHash;
|
|
876
|
+
await run("railway", [
|
|
877
|
+
"redeploy",
|
|
878
|
+
"--service",
|
|
879
|
+
railwayService,
|
|
880
|
+
"--yes"
|
|
881
|
+
]);
|
|
882
|
+
redeployed = true;
|
|
837
883
|
} catch (error) {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
884
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
885
|
+
const railError = message.includes("not found") || message.includes("ENOENT") ? "Railway CLI not found. Install it: npm i -g @railway/cli" : `Railway redeploy failed: ${message}`;
|
|
886
|
+
return {
|
|
887
|
+
status: "published",
|
|
888
|
+
registryUrl: result.registryUrl,
|
|
889
|
+
txHash: result.txHash,
|
|
890
|
+
built: result.built,
|
|
891
|
+
skipped: result.skipped,
|
|
892
|
+
redeployed: false,
|
|
893
|
+
service,
|
|
894
|
+
error: `Config published but ${railError}`
|
|
895
|
+
};
|
|
844
896
|
}
|
|
845
|
-
return {
|
|
846
|
-
status: "published",
|
|
847
|
-
registryUrl,
|
|
848
|
-
txHash,
|
|
849
|
-
built,
|
|
850
|
-
skipped
|
|
851
|
-
};
|
|
852
|
-
} catch (error) {
|
|
853
|
-
return {
|
|
854
|
-
status: "error",
|
|
855
|
-
registryUrl,
|
|
856
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
857
|
-
built,
|
|
858
|
-
skipped
|
|
859
|
-
};
|
|
860
897
|
}
|
|
898
|
+
return {
|
|
899
|
+
status: "deployed",
|
|
900
|
+
registryUrl: result.registryUrl,
|
|
901
|
+
txHash: result.txHash,
|
|
902
|
+
built: result.built,
|
|
903
|
+
skipped: result.skipped,
|
|
904
|
+
redeployed,
|
|
905
|
+
service
|
|
906
|
+
};
|
|
861
907
|
}),
|
|
862
908
|
keyPublish: builder.keyPublish.handler(async ({ input }) => {
|
|
863
909
|
if (!deps.bosConfig) return {
|
|
@@ -1210,6 +1256,100 @@ var plugin_default = createPlugin({
|
|
|
1210
1256
|
})
|
|
1211
1257
|
})
|
|
1212
1258
|
});
|
|
1259
|
+
async function publishToFastKv(input) {
|
|
1260
|
+
const { env, dryRun, configDir } = input;
|
|
1261
|
+
let bosConfig = input.bosConfig;
|
|
1262
|
+
const runtimeConfig = input.runtimeConfig;
|
|
1263
|
+
const isStaging = env === "staging";
|
|
1264
|
+
const account = bosConfig.account;
|
|
1265
|
+
const gateway = isStaging ? bosConfig.staging?.domain ?? bosConfig.domain : bosConfig.domain;
|
|
1266
|
+
if (!gateway) return {
|
|
1267
|
+
status: "error",
|
|
1268
|
+
registryUrl: "",
|
|
1269
|
+
error: "bos.config.json must define domain to publish"
|
|
1270
|
+
};
|
|
1271
|
+
const network = input.network ?? getNetworkIdForAccount(account);
|
|
1272
|
+
const registryUrl = buildRegistryConfigUrlForNetwork(network, account, gateway);
|
|
1273
|
+
const targets = selectWorkspaceTargets(input.packages, bosConfig);
|
|
1274
|
+
let publishConfig = isStaging ? {
|
|
1275
|
+
...bosConfig,
|
|
1276
|
+
domain: gateway
|
|
1277
|
+
} : bosConfig;
|
|
1278
|
+
let built;
|
|
1279
|
+
let skipped;
|
|
1280
|
+
if (dryRun) return {
|
|
1281
|
+
status: "dry-run",
|
|
1282
|
+
registryUrl,
|
|
1283
|
+
built,
|
|
1284
|
+
skipped
|
|
1285
|
+
};
|
|
1286
|
+
if (input.build) {
|
|
1287
|
+
await generateCodeArtifacts(configDir, bosConfig, {
|
|
1288
|
+
env: "production",
|
|
1289
|
+
runtimeConfig: runtimeConfig ?? void 0
|
|
1290
|
+
});
|
|
1291
|
+
const result = await buildWorkspaceTargets({
|
|
1292
|
+
configDir,
|
|
1293
|
+
bosConfig,
|
|
1294
|
+
runtimeConfig,
|
|
1295
|
+
targets,
|
|
1296
|
+
deploy: true
|
|
1297
|
+
});
|
|
1298
|
+
built = result.built;
|
|
1299
|
+
skipped = result.skipped;
|
|
1300
|
+
const refreshed = await loadResolvedConfig({ cwd: configDir });
|
|
1301
|
+
if (refreshed?.config) {
|
|
1302
|
+
bosConfig = refreshed.config;
|
|
1303
|
+
publishConfig = isStaging ? {
|
|
1304
|
+
...refreshed.config,
|
|
1305
|
+
domain: gateway
|
|
1306
|
+
} : refreshed.config;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
const registryEntries = { [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig) };
|
|
1310
|
+
const payload = JSON.stringify(registryEntries);
|
|
1311
|
+
const argsBase64 = Buffer.from(payload).toString("base64");
|
|
1312
|
+
const privateKey = input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;
|
|
1313
|
+
try {
|
|
1314
|
+
await Effect.runPromise(ensureNearCli);
|
|
1315
|
+
let txHash;
|
|
1316
|
+
try {
|
|
1317
|
+
txHash = (await Effect.runPromise(executeTransaction({
|
|
1318
|
+
account,
|
|
1319
|
+
contract: getRegistryNamespaceForNetwork(network),
|
|
1320
|
+
method: "__fastdata_kv",
|
|
1321
|
+
argsBase64,
|
|
1322
|
+
network,
|
|
1323
|
+
privateKey,
|
|
1324
|
+
gas: "300Tgas",
|
|
1325
|
+
deposit: "0NEAR"
|
|
1326
|
+
}))).txHash;
|
|
1327
|
+
} catch (error) {
|
|
1328
|
+
txHash = extractTransactionHash(error);
|
|
1329
|
+
if (!txHash) throw error;
|
|
1330
|
+
try {
|
|
1331
|
+
const verifiedConfig = await fetchBosConfigFromFastKv(`bos://${account}/${gateway}`);
|
|
1332
|
+
if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) throw error;
|
|
1333
|
+
} catch {}
|
|
1334
|
+
}
|
|
1335
|
+
return {
|
|
1336
|
+
status: "published",
|
|
1337
|
+
registryUrl,
|
|
1338
|
+
txHash,
|
|
1339
|
+
built,
|
|
1340
|
+
skipped,
|
|
1341
|
+
publishConfig
|
|
1342
|
+
};
|
|
1343
|
+
} catch (error) {
|
|
1344
|
+
return {
|
|
1345
|
+
status: "error",
|
|
1346
|
+
registryUrl,
|
|
1347
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
1348
|
+
built,
|
|
1349
|
+
skipped
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1213
1353
|
function extractTransactionHash(error) {
|
|
1214
1354
|
return (error instanceof Error ? error.message : String(error)).match(/Transaction ID:\s*([A-Za-z0-9]+)/i)?.[1];
|
|
1215
1355
|
}
|