everything-dev 1.29.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/api-contract.cjs +109 -49
- package/dist/api-contract.cjs.map +1 -1
- package/dist/api-contract.mjs +109 -49
- package/dist/api-contract.mjs.map +1 -1
- package/dist/cli/init.cjs +3 -2
- 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 +3 -2
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/parse.cjs +7 -7
- package/dist/cli/parse.cjs.map +1 -1
- package/dist/cli/parse.mjs +7 -7
- package/dist/cli/parse.mjs.map +1 -1
- package/dist/cli/sync.cjs +3 -2
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +3 -2
- 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 +33 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +33 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/config.cjs +2 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +32 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +82 -3
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +82 -3
- 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 +7 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/merge.cjs +1 -0
- package/dist/merge.cjs.map +1 -1
- package/dist/merge.d.cts +5 -2
- package/dist/merge.d.cts.map +1 -1
- package/dist/merge.d.mts +5 -2
- 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 +243 -96
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +44 -1
- package/dist/plugin.d.mts +44 -1
- package/dist/plugin.mjs +243 -96
- package/dist/plugin.mjs.map +1 -1
- package/dist/types.cjs +14 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +24 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +24 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +12 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
- package/skills/extends-config/SKILL.md +19 -10
- package/skills/init-upgrade/SKILL.md +23 -16
- package/skills/publish-sync/SKILL.md +14 -0
- package/skills/super-app/SKILL.md +32 -24
package/dist/plugin.cjs
CHANGED
|
@@ -200,7 +200,8 @@ async function generateCodeArtifacts(configDir, config, opts) {
|
|
|
200
200
|
return {
|
|
201
201
|
sidebarPath: (0, node_path.join)(configDir, "ui/src/lib/plugin-sidebar.gen.ts"),
|
|
202
202
|
resolvedConfigPath: opts?.env ? (0, node_path.join)(configDir, ".bos/bos.resolved-config.json") : void 0,
|
|
203
|
-
contractBridgePath: bridge.bridgePath
|
|
203
|
+
contractBridgePath: bridge.bridgePath,
|
|
204
|
+
contractStatus: bridge.status
|
|
204
205
|
};
|
|
205
206
|
}
|
|
206
207
|
function extractPublishedUrl(output) {
|
|
@@ -251,8 +252,9 @@ async function buildEverythingDevQuietly(cwd) {
|
|
|
251
252
|
async function fetchPublishedConfig(accountId, gatewayId) {
|
|
252
253
|
try {
|
|
253
254
|
return await require_fastkv.fetchBosConfigFromFastKv(`bos://${accountId}/${gatewayId}`);
|
|
254
|
-
} catch {
|
|
255
|
-
return null;
|
|
255
|
+
} catch (error) {
|
|
256
|
+
if (error instanceof Error && error.message.startsWith("No config found")) return null;
|
|
257
|
+
throw error;
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
260
|
function selectWorkspaceTargets(packages, bosConfig) {
|
|
@@ -613,20 +615,31 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
613
615
|
phase: "config",
|
|
614
616
|
status: "running"
|
|
615
617
|
});
|
|
618
|
+
const bosEnv = input.env ?? (node_process.default.env.BOS_ENV === "staging" ? "staging" : "production");
|
|
616
619
|
const account = input.account ?? node_process.default.env.BOS_ACCOUNT;
|
|
617
620
|
const domain = input.domain ?? node_process.default.env.BOS_GATEWAY;
|
|
618
621
|
let config = null;
|
|
619
622
|
let remoteConfig = null;
|
|
620
|
-
if (account && domain) {
|
|
623
|
+
if (account && domain) try {
|
|
621
624
|
remoteConfig = await fetchPublishedConfig(account, domain);
|
|
622
625
|
if (remoteConfig) config = remoteConfig;
|
|
623
|
-
else
|
|
626
|
+
else return {
|
|
627
|
+
status: "error",
|
|
628
|
+
url: "",
|
|
629
|
+
error: `No config found at bos://${account}/${domain}. Verify the account and gateway are correct and the config has been published.\nExpected URL: ${require_fastkv.buildRegistryConfigUrl(account, domain)}`
|
|
630
|
+
};
|
|
631
|
+
} catch (error) {
|
|
632
|
+
return {
|
|
633
|
+
status: "error",
|
|
634
|
+
url: "",
|
|
635
|
+
error: `Failed to fetch config for bos://${account}/${domain}: ${error instanceof Error ? error.message : "Unknown error"}\nExpected URL: ${require_fastkv.buildRegistryConfigUrl(account, domain)}`
|
|
636
|
+
};
|
|
624
637
|
}
|
|
625
|
-
|
|
638
|
+
else config = deps.bosConfig;
|
|
626
639
|
if (!config) return {
|
|
627
640
|
status: "error",
|
|
628
641
|
url: "",
|
|
629
|
-
error: "No configuration found.
|
|
642
|
+
error: "No configuration found. Provide --account and --gateway flags, or create a local bos.config.json."
|
|
630
643
|
};
|
|
631
644
|
if (account) config = {
|
|
632
645
|
...config,
|
|
@@ -637,7 +650,7 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
637
650
|
domain
|
|
638
651
|
};
|
|
639
652
|
const port = input.port ?? require_config.getHostDevelopmentPort(config.app.host.development);
|
|
640
|
-
const isStaging =
|
|
653
|
+
const isStaging = bosEnv === "staging";
|
|
641
654
|
const runtimePlugins = await require_config.buildRuntimePluginsForConfig(config, deps.configDir, "production");
|
|
642
655
|
require_config.suppressWarnings();
|
|
643
656
|
const runtimeConfig = require_app.buildRuntimeConfig(config, {
|
|
@@ -650,6 +663,8 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
650
663
|
});
|
|
651
664
|
require_config.drainConfigWarnings();
|
|
652
665
|
require_config.resumeWarnings();
|
|
666
|
+
if (isStaging && config.staging?.domain) runtimeConfig.domain = config.staging.domain;
|
|
667
|
+
if (isStaging) runtimeConfig.env = "staging";
|
|
653
668
|
require_infra.syncGeneratedInfra(deps.configDir, runtimeConfig);
|
|
654
669
|
if (!(0, node_fs.existsSync)((0, node_path.join)(deps.configDir, ".env"))) {
|
|
655
670
|
require_infra.ensureEnvFile(deps.configDir);
|
|
@@ -670,12 +685,13 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
670
685
|
const productionEnv = {};
|
|
671
686
|
const warnings = [];
|
|
672
687
|
if (!node_process.default.env.CORS_ORIGIN && config.domain) {
|
|
673
|
-
const defaultOrigin = `https://${config.domain}`;
|
|
688
|
+
const defaultOrigin = `https://${isStaging ? config.staging?.domain ?? config.domain : config.domain}`;
|
|
674
689
|
productionEnv.CORS_ORIGIN = defaultOrigin;
|
|
675
690
|
warnings.push(`CORS_ORIGIN defaulting to ${defaultOrigin}`);
|
|
676
691
|
}
|
|
677
692
|
const requiredSecrets = /* @__PURE__ */ new Set();
|
|
678
693
|
const missingSecrets = [];
|
|
694
|
+
if (runtimeConfig.host.secrets) for (const s of runtimeConfig.host.secrets) requiredSecrets.add(s);
|
|
679
695
|
if (runtimeConfig.auth?.secrets) for (const s of runtimeConfig.auth.secrets) requiredSecrets.add(s);
|
|
680
696
|
if (runtimeConfig.api?.secrets) for (const s of runtimeConfig.api.secrets) requiredSecrets.add(s);
|
|
681
697
|
for (const plugin of Object.values(runtimeConfig.plugins ?? {})) if (plugin.secrets) for (const s of plugin.secrets) requiredSecrets.add(s);
|
|
@@ -778,89 +794,120 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
778
794
|
registryUrl: "",
|
|
779
795
|
error: "No bos.config.json found"
|
|
780
796
|
};
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
|
|
797
|
+
const result = await publishToFastKv({
|
|
798
|
+
bosConfig: deps.bosConfig,
|
|
799
|
+
runtimeConfig: deps.runtimeConfig,
|
|
800
|
+
configDir: deps.configDir,
|
|
801
|
+
env: input.env,
|
|
802
|
+
build: input.deploy,
|
|
803
|
+
dryRun: input.dryRun,
|
|
804
|
+
packages: input.packages,
|
|
805
|
+
network: input.network,
|
|
806
|
+
privateKey: input.privateKey
|
|
807
|
+
});
|
|
808
|
+
if (result.publishConfig) {
|
|
809
|
+
const refreshed = await require_config.loadResolvedConfig({ cwd: deps.configDir });
|
|
810
|
+
if (refreshed?.config) {
|
|
811
|
+
deps.bosConfig = refreshed.config;
|
|
812
|
+
deps.runtimeConfig = refreshed.runtime;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
status: result.status,
|
|
817
|
+
registryUrl: result.registryUrl,
|
|
818
|
+
txHash: result.txHash,
|
|
819
|
+
error: result.error,
|
|
820
|
+
built: result.built,
|
|
821
|
+
skipped: result.skipped
|
|
822
|
+
};
|
|
823
|
+
}),
|
|
824
|
+
deploy: builder.deploy.handler(async ({ input }) => {
|
|
825
|
+
if (!deps.bosConfig) return {
|
|
784
826
|
status: "error",
|
|
785
827
|
registryUrl: "",
|
|
786
|
-
|
|
828
|
+
redeployed: false,
|
|
829
|
+
error: "No bos.config.json found"
|
|
787
830
|
};
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
831
|
+
const result = await publishToFastKv({
|
|
832
|
+
bosConfig: deps.bosConfig,
|
|
833
|
+
runtimeConfig: deps.runtimeConfig,
|
|
834
|
+
configDir: deps.configDir,
|
|
835
|
+
env: input.env,
|
|
836
|
+
build: input.build,
|
|
837
|
+
dryRun: input.dryRun,
|
|
838
|
+
packages: input.packages,
|
|
839
|
+
network: input.network,
|
|
840
|
+
privateKey: input.privateKey
|
|
841
|
+
});
|
|
842
|
+
if (result.status === "error") return {
|
|
843
|
+
status: "error",
|
|
844
|
+
registryUrl: result.registryUrl,
|
|
845
|
+
txHash: result.txHash,
|
|
846
|
+
built: result.built,
|
|
847
|
+
skipped: result.skipped,
|
|
848
|
+
redeployed: false,
|
|
849
|
+
error: result.error
|
|
850
|
+
};
|
|
851
|
+
if (result.status === "dry-run") return {
|
|
796
852
|
status: "dry-run",
|
|
797
|
-
registryUrl,
|
|
798
|
-
built,
|
|
799
|
-
skipped
|
|
853
|
+
registryUrl: result.registryUrl,
|
|
854
|
+
built: result.built,
|
|
855
|
+
skipped: result.skipped,
|
|
856
|
+
redeployed: false
|
|
800
857
|
};
|
|
801
|
-
if (
|
|
802
|
-
await generateCodeArtifacts(deps.configDir, deps.bosConfig, {
|
|
803
|
-
env: "production",
|
|
804
|
-
runtimeConfig: deps.runtimeConfig ?? void 0
|
|
805
|
-
});
|
|
806
|
-
const result = await buildWorkspaceTargets({
|
|
807
|
-
configDir: deps.configDir,
|
|
808
|
-
bosConfig: deps.bosConfig,
|
|
809
|
-
runtimeConfig: deps.runtimeConfig,
|
|
810
|
-
targets,
|
|
811
|
-
deploy: true
|
|
812
|
-
});
|
|
813
|
-
built = result.built;
|
|
814
|
-
skipped = result.skipped;
|
|
858
|
+
if (result.publishConfig) {
|
|
815
859
|
const refreshed = await require_config.loadResolvedConfig({ cwd: deps.configDir });
|
|
816
860
|
if (refreshed?.config) {
|
|
817
861
|
deps.bosConfig = refreshed.config;
|
|
818
862
|
deps.runtimeConfig = refreshed.runtime;
|
|
819
|
-
publishConfig = refreshed.config;
|
|
820
863
|
}
|
|
821
864
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
865
|
+
let redeployed = false;
|
|
866
|
+
let service;
|
|
867
|
+
if (node_process.default.env.RAILWAY_TOKEN) {
|
|
868
|
+
const railwayService = input.service ?? deps.bosConfig.ci?.railway?.service;
|
|
869
|
+
if (!railwayService) return {
|
|
870
|
+
status: "published",
|
|
871
|
+
registryUrl: result.registryUrl,
|
|
872
|
+
txHash: result.txHash,
|
|
873
|
+
built: result.built,
|
|
874
|
+
skipped: result.skipped,
|
|
875
|
+
redeployed: false,
|
|
876
|
+
error: "Config published but Railway redeploy failed: ci.railway.service is not configured in bos.config.json"
|
|
877
|
+
};
|
|
878
|
+
service = railwayService;
|
|
829
879
|
try {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
gas: "300Tgas",
|
|
838
|
-
deposit: "0NEAR"
|
|
839
|
-
}))).txHash;
|
|
880
|
+
await require_run.run("railway", [
|
|
881
|
+
"redeploy",
|
|
882
|
+
"--service",
|
|
883
|
+
railwayService,
|
|
884
|
+
"--yes"
|
|
885
|
+
]);
|
|
886
|
+
redeployed = true;
|
|
840
887
|
} catch (error) {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
888
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
889
|
+
const railError = message.includes("not found") || message.includes("ENOENT") ? "Railway CLI not found. Install it: npm i -g @railway/cli" : `Railway redeploy failed: ${message}`;
|
|
890
|
+
return {
|
|
891
|
+
status: "published",
|
|
892
|
+
registryUrl: result.registryUrl,
|
|
893
|
+
txHash: result.txHash,
|
|
894
|
+
built: result.built,
|
|
895
|
+
skipped: result.skipped,
|
|
896
|
+
redeployed: false,
|
|
897
|
+
service,
|
|
898
|
+
error: `Config published but ${railError}`
|
|
899
|
+
};
|
|
847
900
|
}
|
|
848
|
-
return {
|
|
849
|
-
status: "published",
|
|
850
|
-
registryUrl,
|
|
851
|
-
txHash,
|
|
852
|
-
built,
|
|
853
|
-
skipped
|
|
854
|
-
};
|
|
855
|
-
} catch (error) {
|
|
856
|
-
return {
|
|
857
|
-
status: "error",
|
|
858
|
-
registryUrl,
|
|
859
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
860
|
-
built,
|
|
861
|
-
skipped
|
|
862
|
-
};
|
|
863
901
|
}
|
|
902
|
+
return {
|
|
903
|
+
status: "deployed",
|
|
904
|
+
registryUrl: result.registryUrl,
|
|
905
|
+
txHash: result.txHash,
|
|
906
|
+
built: result.built,
|
|
907
|
+
skipped: result.skipped,
|
|
908
|
+
redeployed,
|
|
909
|
+
service
|
|
910
|
+
};
|
|
864
911
|
}),
|
|
865
912
|
keyPublish: builder.keyPublish.handler(async ({ input }) => {
|
|
866
913
|
if (!deps.bosConfig) return {
|
|
@@ -1136,18 +1183,16 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1136
1183
|
const pluginEntries = Object.entries(refreshed.runtime.plugins ?? {});
|
|
1137
1184
|
const fetched = [];
|
|
1138
1185
|
const skipped = [];
|
|
1139
|
-
|
|
1186
|
+
const hasLocalApiWorkspace = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "api", "src"));
|
|
1187
|
+
if (refreshed.runtime.api.source !== "local") fetched.push(`api (${refreshed.runtime.api.url})`);
|
|
1140
1188
|
else skipped.push("api (local)");
|
|
1141
|
-
if (refreshed.runtime.auth) if (refreshed.runtime.auth.source !== "local") fetched.push(refreshed.runtime.auth.url);
|
|
1189
|
+
if (refreshed.runtime.auth) if (refreshed.runtime.auth.source !== "local") fetched.push(`auth (${refreshed.runtime.auth.url})`);
|
|
1142
1190
|
else skipped.push("auth (local)");
|
|
1143
|
-
for (const [key, plugin] of pluginEntries) if (plugin.url && plugin.source !== "local") fetched.push(plugin.url);
|
|
1191
|
+
for (const [key, plugin] of pluginEntries) if (plugin.url && plugin.source !== "local") fetched.push(`${key} (${plugin.url})`);
|
|
1144
1192
|
else if (plugin.localPath) skipped.push(`${key} (local)`);
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
"api/src/lib/plugins-types.gen.ts",
|
|
1149
|
-
"api/src/lib/auth-types.gen.ts"
|
|
1150
|
-
];
|
|
1193
|
+
else skipped.push(`${key} (no URL resolved)`);
|
|
1194
|
+
const generated = ["ui/src/lib/api-types.gen.ts", "ui/src/lib/auth-types.gen.ts"];
|
|
1195
|
+
if (hasLocalApiWorkspace) generated.push("api/src/lib/plugins-types.gen.ts", "api/src/lib/auth-types.gen.ts");
|
|
1151
1196
|
if ((0, node_fs.existsSync)((0, node_path.join)(projectDir, "host", "src"))) generated.push("host/src/lib/auth-types.gen.ts");
|
|
1152
1197
|
return {
|
|
1153
1198
|
status: "success",
|
|
@@ -1158,21 +1203,29 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1158
1203
|
source: refreshed.runtime.api.source
|
|
1159
1204
|
};
|
|
1160
1205
|
}
|
|
1161
|
-
await generateCodeArtifacts(projectDir, refreshed.config, { runtimeConfig: refreshed.runtime });
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
"api/src/lib/plugins-types.gen.ts",
|
|
1166
|
-
"api/src/lib/auth-types.gen.ts"
|
|
1167
|
-
];
|
|
1206
|
+
const artifacts = await generateCodeArtifacts(projectDir, refreshed.config, { runtimeConfig: refreshed.runtime });
|
|
1207
|
+
const hasLocalApiWorkspace = (0, node_fs.existsSync)((0, node_path.join)(projectDir, "api", "src"));
|
|
1208
|
+
const generated = ["ui/src/lib/plugin-sidebar.gen.ts", "ui/src/lib/api-types.gen.ts"];
|
|
1209
|
+
if (hasLocalApiWorkspace) generated.push("api/src/lib/plugins-types.gen.ts", "api/src/lib/auth-types.gen.ts");
|
|
1168
1210
|
if (refreshed.runtime.auth && (refreshed.runtime.auth.source !== "local" || refreshed.runtime.auth.localPath)) generated.push("ui/src/lib/auth-types.gen.ts");
|
|
1169
1211
|
if ((0, node_fs.existsSync)((0, node_path.join)(projectDir, "host", "src"))) generated.push("host/src/lib/auth-types.gen.ts");
|
|
1212
|
+
const contractStatus = artifacts?.contractStatus ?? [];
|
|
1213
|
+
const fetched = [];
|
|
1214
|
+
const skipped = [];
|
|
1215
|
+
const failed = [];
|
|
1216
|
+
for (const entry of contractStatus) if (entry.source === "remote") fetched.push(entry.url ? `${entry.key} (${entry.url})` : entry.key);
|
|
1217
|
+
else if (entry.source === "local") skipped.push(`${entry.key} (local)`);
|
|
1218
|
+
else if (entry.source === "skipped") skipped.push(`${entry.key} (no URL resolved)`);
|
|
1219
|
+
else if (entry.source === "failed") {
|
|
1220
|
+
const detail = entry.error ? `: ${entry.error}` : "";
|
|
1221
|
+
failed.push(`${entry.key}${detail}`);
|
|
1222
|
+
}
|
|
1170
1223
|
return {
|
|
1171
1224
|
status: "success",
|
|
1172
1225
|
generated,
|
|
1173
|
-
fetched
|
|
1174
|
-
skipped
|
|
1175
|
-
failed
|
|
1226
|
+
fetched,
|
|
1227
|
+
skipped,
|
|
1228
|
+
failed,
|
|
1176
1229
|
source: refreshed.runtime.api.source
|
|
1177
1230
|
};
|
|
1178
1231
|
} catch (error) {
|
|
@@ -1207,6 +1260,100 @@ var plugin_default = (0, every_plugin.createPlugin)({
|
|
|
1207
1260
|
})
|
|
1208
1261
|
})
|
|
1209
1262
|
});
|
|
1263
|
+
async function publishToFastKv(input) {
|
|
1264
|
+
const { env, dryRun, configDir } = input;
|
|
1265
|
+
let bosConfig = input.bosConfig;
|
|
1266
|
+
const runtimeConfig = input.runtimeConfig;
|
|
1267
|
+
const isStaging = env === "staging";
|
|
1268
|
+
const account = bosConfig.account;
|
|
1269
|
+
const gateway = isStaging ? bosConfig.staging?.domain ?? bosConfig.domain : bosConfig.domain;
|
|
1270
|
+
if (!gateway) return {
|
|
1271
|
+
status: "error",
|
|
1272
|
+
registryUrl: "",
|
|
1273
|
+
error: "bos.config.json must define domain to publish"
|
|
1274
|
+
};
|
|
1275
|
+
const network = input.network ?? require_network.getNetworkIdForAccount(account);
|
|
1276
|
+
const registryUrl = require_fastkv.buildRegistryConfigUrlForNetwork(network, account, gateway);
|
|
1277
|
+
const targets = selectWorkspaceTargets(input.packages, bosConfig);
|
|
1278
|
+
let publishConfig = isStaging ? {
|
|
1279
|
+
...bosConfig,
|
|
1280
|
+
domain: gateway
|
|
1281
|
+
} : bosConfig;
|
|
1282
|
+
let built;
|
|
1283
|
+
let skipped;
|
|
1284
|
+
if (dryRun) return {
|
|
1285
|
+
status: "dry-run",
|
|
1286
|
+
registryUrl,
|
|
1287
|
+
built,
|
|
1288
|
+
skipped
|
|
1289
|
+
};
|
|
1290
|
+
if (input.build) {
|
|
1291
|
+
await generateCodeArtifacts(configDir, bosConfig, {
|
|
1292
|
+
env: "production",
|
|
1293
|
+
runtimeConfig: runtimeConfig ?? void 0
|
|
1294
|
+
});
|
|
1295
|
+
const result = await buildWorkspaceTargets({
|
|
1296
|
+
configDir,
|
|
1297
|
+
bosConfig,
|
|
1298
|
+
runtimeConfig,
|
|
1299
|
+
targets,
|
|
1300
|
+
deploy: true
|
|
1301
|
+
});
|
|
1302
|
+
built = result.built;
|
|
1303
|
+
skipped = result.skipped;
|
|
1304
|
+
const refreshed = await require_config.loadResolvedConfig({ cwd: configDir });
|
|
1305
|
+
if (refreshed?.config) {
|
|
1306
|
+
bosConfig = refreshed.config;
|
|
1307
|
+
publishConfig = isStaging ? {
|
|
1308
|
+
...refreshed.config,
|
|
1309
|
+
domain: gateway
|
|
1310
|
+
} : refreshed.config;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
const registryEntries = { [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig) };
|
|
1314
|
+
const payload = JSON.stringify(registryEntries);
|
|
1315
|
+
const argsBase64 = Buffer.from(payload).toString("base64");
|
|
1316
|
+
const privateKey = input.privateKey || node_process.default.env.NEAR_PRIVATE_KEY || node_process.default.env.BOS_NEAR_PRIVATE_KEY;
|
|
1317
|
+
try {
|
|
1318
|
+
await effect.Effect.runPromise(require_near_cli.ensureNearCli);
|
|
1319
|
+
let txHash;
|
|
1320
|
+
try {
|
|
1321
|
+
txHash = (await effect.Effect.runPromise(require_near_cli.executeTransaction({
|
|
1322
|
+
account,
|
|
1323
|
+
contract: require_fastkv.getRegistryNamespaceForNetwork(network),
|
|
1324
|
+
method: "__fastdata_kv",
|
|
1325
|
+
argsBase64,
|
|
1326
|
+
network,
|
|
1327
|
+
privateKey,
|
|
1328
|
+
gas: "300Tgas",
|
|
1329
|
+
deposit: "0NEAR"
|
|
1330
|
+
}))).txHash;
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
txHash = extractTransactionHash(error);
|
|
1333
|
+
if (!txHash) throw error;
|
|
1334
|
+
try {
|
|
1335
|
+
const verifiedConfig = await require_fastkv.fetchBosConfigFromFastKv(`bos://${account}/${gateway}`);
|
|
1336
|
+
if (JSON.stringify(verifiedConfig) !== JSON.stringify(publishConfig)) throw error;
|
|
1337
|
+
} catch {}
|
|
1338
|
+
}
|
|
1339
|
+
return {
|
|
1340
|
+
status: "published",
|
|
1341
|
+
registryUrl,
|
|
1342
|
+
txHash,
|
|
1343
|
+
built,
|
|
1344
|
+
skipped,
|
|
1345
|
+
publishConfig
|
|
1346
|
+
};
|
|
1347
|
+
} catch (error) {
|
|
1348
|
+
return {
|
|
1349
|
+
status: "error",
|
|
1350
|
+
registryUrl,
|
|
1351
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
1352
|
+
built,
|
|
1353
|
+
skipped
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1210
1357
|
function extractTransactionHash(error) {
|
|
1211
1358
|
return (error instanceof Error ? error.message : String(error)).match(/Transaction ID:\s*([A-Za-z0-9]+)/i)?.[1];
|
|
1212
1359
|
}
|