everything-dev 1.17.0 → 1.20.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 +165 -84
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +14 -2
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +14 -2
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +164 -85
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/prompts.cjs +12 -14
- package/dist/cli/prompts.cjs.map +1 -1
- package/dist/cli/prompts.mjs +12 -14
- package/dist/cli/prompts.mjs.map +1 -1
- package/dist/cli/timing.cjs +21 -1
- package/dist/cli/timing.cjs.map +1 -1
- package/dist/cli/timing.mjs +21 -1
- package/dist/cli/timing.mjs.map +1 -1
- package/dist/cli/upgrade.cjs +114 -49
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +114 -49
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/contract.cjs +1 -4
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +4 -10
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +4 -10
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.meta.cjs +5 -5
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +9 -9
- package/dist/contract.meta.d.mts +9 -9
- package/dist/contract.meta.mjs +5 -5
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +1 -4
- package/dist/contract.mjs.map +1 -1
- package/dist/plugin.cjs +83 -119
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +3 -6
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +3 -6
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +84 -120
- package/dist/plugin.mjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +5 -5
- package/src/cli/init.ts +224 -162
- package/src/cli/prompts.ts +17 -22
- package/src/cli/timing.ts +27 -0
- package/src/cli/upgrade.ts +173 -56
- package/src/contract.meta.ts +6 -8
- package/src/contract.ts +1 -4
- package/src/plugin.ts +189 -209
package/dist/plugin.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { syncApiContractBridge } from "./api-contract.mjs";
|
|
|
7
7
|
import { buildRuntimeConfig, detectLocalPackages, prepareDevelopmentRuntimeConfig } from "./app.mjs";
|
|
8
8
|
import { ensureEnvFile, writeGeneratedInfra } from "./cli/infra.mjs";
|
|
9
9
|
import { saveBosConfig } from "./utils/save-config.mjs";
|
|
10
|
-
import { copyFilteredFiles, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, writeInitSnapshot } from "./cli/init.mjs";
|
|
10
|
+
import { copyFilteredFiles, fetchParentConfig, generateDatabaseMigrations, personalizeConfig, readTemplatekeep, resolveSourceDir, runBunInstall, runDockerComposeUp, runTypesGen, scaffoldMinimalProject, writeInitSnapshot } from "./cli/init.mjs";
|
|
11
11
|
import { promptInitOptions } from "./cli/prompts.mjs";
|
|
12
12
|
import { getStatus } from "./cli/status.mjs";
|
|
13
13
|
import { syncTemplate } from "./cli/sync.mjs";
|
|
@@ -405,58 +405,20 @@ var plugin_default = createPlugin({
|
|
|
405
405
|
const integrity = publishedUrl ? await computeSriHashForUrl(publishedUrl) : null;
|
|
406
406
|
const version = manifest?.plugin.version ?? pkgJson.version;
|
|
407
407
|
if (publishedUrl) {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
if (!
|
|
412
|
-
const plugins =
|
|
408
|
+
const rootConfigPath = join(deps.configDir, "bos.config.json");
|
|
409
|
+
try {
|
|
410
|
+
const rootConfig = JSON.parse(readFileSync(rootConfigPath, "utf-8"));
|
|
411
|
+
if (!rootConfig.plugins || typeof rootConfig.plugins !== "object") rootConfig.plugins = {};
|
|
412
|
+
const plugins = rootConfig.plugins;
|
|
413
413
|
if (!plugins[input.key] || typeof plugins[input.key] !== "object") plugins[input.key] = {};
|
|
414
414
|
const entry = plugins[input.key];
|
|
415
415
|
entry.production = publishedUrl;
|
|
416
416
|
if (integrity) entry.integrity = integrity;
|
|
417
417
|
else delete entry.integrity;
|
|
418
|
-
writeFileSync(
|
|
419
|
-
console.log(` ✅ Updated
|
|
418
|
+
writeFileSync(rootConfigPath, `${JSON.stringify(rootConfig, null, 2)}\n`);
|
|
419
|
+
console.log(` ✅ Updated bos.config.json: plugins.${input.key}.production`);
|
|
420
420
|
} catch (err) {
|
|
421
|
-
console.error(` ❌ Failed to update
|
|
422
|
-
}
|
|
423
|
-
const account = deps.bosConfig.account;
|
|
424
|
-
const network = getNetworkIdForAccount(account);
|
|
425
|
-
let pluginDomain;
|
|
426
|
-
if (existsSync(pluginConfigPath)) try {
|
|
427
|
-
const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
|
|
428
|
-
if (typeof pluginConfig.domain === "string") pluginDomain = pluginConfig.domain;
|
|
429
|
-
} catch {}
|
|
430
|
-
if (!pluginDomain) pluginDomain = `${input.key}.${deps.bosConfig.domain ?? "everything.dev"}`;
|
|
431
|
-
try {
|
|
432
|
-
const registryEntries = {};
|
|
433
|
-
if (existsSync(pluginConfigPath)) try {
|
|
434
|
-
const publishedPluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
|
|
435
|
-
delete publishedPluginConfig.development;
|
|
436
|
-
registryEntries[`apps/${account}/${pluginDomain}/bos.config.json`] = JSON.stringify(publishedPluginConfig);
|
|
437
|
-
} catch {}
|
|
438
|
-
if (Object.keys(registryEntries).length > 0) {
|
|
439
|
-
const payload = JSON.stringify(registryEntries);
|
|
440
|
-
const argsBase64 = Buffer.from(payload).toString("base64");
|
|
441
|
-
const privateKey = process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;
|
|
442
|
-
await Effect.runPromise(ensureNearCli);
|
|
443
|
-
try {
|
|
444
|
-
await Effect.runPromise(executeTransaction({
|
|
445
|
-
account,
|
|
446
|
-
contract: getRegistryNamespaceForNetwork(network),
|
|
447
|
-
method: "__fastdata_kv",
|
|
448
|
-
argsBase64,
|
|
449
|
-
network,
|
|
450
|
-
privateKey,
|
|
451
|
-
gas: "50Tgas",
|
|
452
|
-
deposit: "0NEAR"
|
|
453
|
-
}));
|
|
454
|
-
} catch (registryError) {
|
|
455
|
-
if (!extractTransactionHash(registryError)) console.warn(`[publish] Plugin registry write failed: ${registryError instanceof Error ? registryError.message : registryError}`);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
} catch (registryError) {
|
|
459
|
-
console.warn(`[publish] Plugin registry write skipped: ${registryError instanceof Error ? registryError.message : registryError}`);
|
|
421
|
+
console.error(` ❌ Failed to update bos.config.json:`, err instanceof Error ? err.message : err);
|
|
460
422
|
}
|
|
461
423
|
await generateCodeArtifacts(deps.configDir, deps.bosConfig);
|
|
462
424
|
}
|
|
@@ -724,18 +686,6 @@ var plugin_default = createPlugin({
|
|
|
724
686
|
}
|
|
725
687
|
}
|
|
726
688
|
const registryEntries = { [`apps/${account}/${gateway}/bos.config.json`]: JSON.stringify(publishConfig) };
|
|
727
|
-
for (const [pluginKey, pluginEntry] of Object.entries(publishConfig.plugins ?? {})) {
|
|
728
|
-
const pluginRef = getPluginRef(pluginEntry);
|
|
729
|
-
if (!pluginRef?.development?.startsWith("local:")) continue;
|
|
730
|
-
const pluginConfigPath = join(join(deps.configDir, pluginRef.development.slice(6)), "bos.config.json");
|
|
731
|
-
if (!existsSync(pluginConfigPath)) continue;
|
|
732
|
-
try {
|
|
733
|
-
const pluginConfig = JSON.parse(readFileSync(pluginConfigPath, "utf-8"));
|
|
734
|
-
const pluginDomain = typeof pluginConfig.domain === "string" ? pluginConfig.domain : `${pluginKey}.${gateway}`;
|
|
735
|
-
delete pluginConfig.development;
|
|
736
|
-
registryEntries[`apps/${account}/${pluginDomain}/bos.config.json`] = JSON.stringify(pluginConfig);
|
|
737
|
-
} catch {}
|
|
738
|
-
}
|
|
739
689
|
const payload = JSON.stringify(registryEntries);
|
|
740
690
|
const argsBase64 = Buffer.from(payload).toString("base64");
|
|
741
691
|
const privateKey = input.privateKey || process.env.NEAR_PRIVATE_KEY || process.env.BOS_NEAR_PRIVATE_KEY;
|
|
@@ -825,33 +775,34 @@ var plugin_default = createPlugin({
|
|
|
825
775
|
init: builder.init.handler(async ({ input }) => {
|
|
826
776
|
try {
|
|
827
777
|
const timings = [];
|
|
828
|
-
let extendsAccount =
|
|
829
|
-
let extendsGateway =
|
|
778
|
+
let extendsAccount = "";
|
|
779
|
+
let extendsGateway = "";
|
|
830
780
|
let directory = input.directory;
|
|
831
781
|
let account = input.account;
|
|
832
782
|
let domain = input.domain;
|
|
833
783
|
let withHost = input.withHost;
|
|
834
784
|
let plugins = input.plugins;
|
|
835
785
|
if (input.extends) {
|
|
836
|
-
const match = input.extends.match(/^
|
|
786
|
+
const match = (input.extends.startsWith("bos://") ? input.extends : `bos://${input.extends}`).match(/^bos:\/\/([^/]+)\/(.+)$/);
|
|
837
787
|
if (match) {
|
|
838
|
-
|
|
839
|
-
|
|
788
|
+
extendsAccount = match[1];
|
|
789
|
+
extendsGateway = match[2];
|
|
840
790
|
}
|
|
841
791
|
}
|
|
842
792
|
extendsAccount = extendsAccount || "dev.everything.near";
|
|
843
793
|
extendsGateway = extendsGateway || "everything.dev";
|
|
794
|
+
const s = p.spinner();
|
|
795
|
+
s.start("Initializing project");
|
|
844
796
|
let parentPluginKeys = [];
|
|
845
797
|
let parentConfig = null;
|
|
846
798
|
try {
|
|
847
|
-
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway));
|
|
799
|
+
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway), s);
|
|
848
800
|
if (parentConfig?.plugins && typeof parentConfig.plugins === "object") parentPluginKeys = Object.keys(parentConfig.plugins);
|
|
849
801
|
} catch {}
|
|
850
802
|
if (!input.noInteractive) {
|
|
803
|
+
s.stop("Config fetched");
|
|
851
804
|
const prompted = await promptInitOptions({
|
|
852
|
-
extendsAccount
|
|
853
|
-
extendsGateway,
|
|
854
|
-
extends: input.extends,
|
|
805
|
+
extends: `bos://${extendsAccount}/${extendsGateway}`,
|
|
855
806
|
directory,
|
|
856
807
|
account,
|
|
857
808
|
domain,
|
|
@@ -866,85 +817,99 @@ var plugin_default = createPlugin({
|
|
|
866
817
|
domain = prompted.domain;
|
|
867
818
|
withHost = prompted.withHost;
|
|
868
819
|
plugins = prompted.plugins;
|
|
820
|
+
s.start("Setting up project");
|
|
869
821
|
}
|
|
870
822
|
directory = directory || domain || extendsGateway;
|
|
871
823
|
const targetDir = resolve(directory);
|
|
872
824
|
plugins = plugins ?? [];
|
|
825
|
+
const extendsRef = `bos://${extendsAccount}/${extendsGateway}`;
|
|
873
826
|
if (!parentConfig) try {
|
|
874
|
-
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway));
|
|
827
|
+
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway), s);
|
|
875
828
|
} catch {
|
|
829
|
+
s.stop("Failed");
|
|
876
830
|
return {
|
|
877
831
|
status: "error",
|
|
878
832
|
directory,
|
|
879
|
-
|
|
880
|
-
extendsGateway,
|
|
833
|
+
extendsRef,
|
|
881
834
|
account,
|
|
882
835
|
domain,
|
|
883
|
-
extends:
|
|
836
|
+
extends: extendsRef,
|
|
884
837
|
plugins: plugins ?? [],
|
|
885
838
|
filesCopied: 0,
|
|
886
839
|
timings,
|
|
887
|
-
error: `No config found at
|
|
840
|
+
error: `No config found at ${extendsRef} — are you sure this is the right parent?`
|
|
888
841
|
};
|
|
889
842
|
}
|
|
890
843
|
const { sourceDir, parentConfig: resolvedParentConfig, cleanup } = await timePhase(timings, "template source", () => resolveSourceDir({
|
|
891
844
|
extendsAccount,
|
|
892
845
|
extendsGateway,
|
|
893
846
|
source: input.source
|
|
894
|
-
}));
|
|
847
|
+
}), s);
|
|
895
848
|
parentConfig = resolvedParentConfig;
|
|
849
|
+
const isMinimalScaffold = sourceDir === "";
|
|
896
850
|
try {
|
|
897
|
-
|
|
898
|
-
if (
|
|
899
|
-
status: "error",
|
|
900
|
-
directory,
|
|
901
|
-
extendsAccount,
|
|
902
|
-
extendsGateway,
|
|
903
|
-
account,
|
|
904
|
-
domain,
|
|
905
|
-
extends: `bos://${extendsAccount}/${extendsGateway}`,
|
|
906
|
-
plugins: plugins ?? [],
|
|
907
|
-
filesCopied: 0,
|
|
908
|
-
error: "No .templatekeep found in template source"
|
|
909
|
-
};
|
|
910
|
-
const pluginRoutes = {};
|
|
911
|
-
const parentRuntimePlugins = await buildRuntimePluginsForConfig(parentConfig, sourceDir, "production");
|
|
912
|
-
for (const [key, plugin] of Object.entries(parentRuntimePlugins ?? {})) if (plugin.routes && plugin.routes.length > 0) pluginRoutes[key] = plugin.routes;
|
|
913
|
-
const s = p.spinner();
|
|
914
|
-
s.start("Setting up project");
|
|
915
|
-
const filesCopied = await timePhase(timings, "copy files", () => copyFilteredFiles(sourceDir, targetDir, patterns, {
|
|
916
|
-
withHost,
|
|
917
|
-
plugins,
|
|
918
|
-
pluginRoutes
|
|
919
|
-
}));
|
|
920
|
-
await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
|
|
851
|
+
let filesCopied;
|
|
852
|
+
if (isMinimalScaffold) filesCopied = await timePhase(timings, "scaffold project", () => scaffoldMinimalProject(targetDir, parentConfig, {
|
|
921
853
|
extendsAccount,
|
|
922
854
|
extendsGateway,
|
|
923
855
|
account: account || extendsAccount,
|
|
924
|
-
domain
|
|
856
|
+
domain,
|
|
925
857
|
plugins,
|
|
926
|
-
pluginRoutes,
|
|
927
|
-
workspaceOpts: { sourceDir },
|
|
928
858
|
withHost
|
|
929
|
-
}));
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
859
|
+
}), s);
|
|
860
|
+
else {
|
|
861
|
+
const patterns = await readTemplatekeep(sourceDir);
|
|
862
|
+
if (patterns.length === 0) {
|
|
863
|
+
s.stop("Failed");
|
|
864
|
+
return {
|
|
865
|
+
status: "error",
|
|
866
|
+
directory,
|
|
867
|
+
extendsRef,
|
|
868
|
+
account,
|
|
869
|
+
domain,
|
|
870
|
+
extends: extendsRef,
|
|
871
|
+
plugins: plugins ?? [],
|
|
872
|
+
filesCopied: 0,
|
|
873
|
+
error: "No .templatekeep found in template source"
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
const pluginRoutes = {};
|
|
877
|
+
const parentRuntimePlugins = await buildRuntimePluginsForConfig(parentConfig, sourceDir, "production");
|
|
878
|
+
for (const [key, plugin] of Object.entries(parentRuntimePlugins ?? {})) if (plugin.routes && plugin.routes.length > 0) pluginRoutes[key] = plugin.routes;
|
|
879
|
+
filesCopied = await timePhase(timings, "copy files", () => copyFilteredFiles(sourceDir, targetDir, patterns, {
|
|
880
|
+
withHost,
|
|
881
|
+
plugins,
|
|
882
|
+
pluginRoutes
|
|
883
|
+
}), s);
|
|
884
|
+
await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
|
|
885
|
+
extendsAccount,
|
|
886
|
+
extendsGateway,
|
|
887
|
+
account: account || extendsAccount,
|
|
888
|
+
domain: domain || extendsGateway,
|
|
889
|
+
plugins,
|
|
890
|
+
pluginRoutes,
|
|
891
|
+
workspaceOpts: { sourceDir },
|
|
892
|
+
withHost
|
|
893
|
+
}), s);
|
|
894
|
+
await timePhase(timings, "write snapshot", () => writeInitSnapshot(targetDir, extendsAccount, extendsGateway, sourceDir, patterns, {
|
|
895
|
+
withHost,
|
|
896
|
+
plugins,
|
|
897
|
+
pluginRoutes
|
|
898
|
+
}), s);
|
|
899
|
+
}
|
|
900
|
+
const initConfig = await timePhase(timings, "resolve config", () => loadConfig({ cwd: targetDir }), s);
|
|
936
901
|
if (initConfig?.runtime) await timePhase(timings, "generate env/docker", async () => {
|
|
937
902
|
writeGeneratedInfra(targetDir, initConfig.runtime);
|
|
938
|
-
});
|
|
903
|
+
}, s);
|
|
939
904
|
await timePhase(timings, "create env file", async () => {
|
|
940
905
|
ensureEnvFile(targetDir);
|
|
941
|
-
});
|
|
906
|
+
}, s);
|
|
942
907
|
if (!input.noInstall) {
|
|
943
|
-
await timePhase(timings, "install dependencies", () => runBunInstall(targetDir));
|
|
944
|
-
await timePhase(timings, "generate types", () => runTypesGen(targetDir));
|
|
945
|
-
await timePhase(timings, "generate migrations", () => generateDatabaseMigrations(targetDir));
|
|
908
|
+
await timePhase(timings, "install dependencies", () => runBunInstall(targetDir), s);
|
|
909
|
+
await timePhase(timings, "generate types", () => runTypesGen(targetDir), s);
|
|
910
|
+
await timePhase(timings, "generate migrations", () => generateDatabaseMigrations(targetDir), s);
|
|
946
911
|
}
|
|
947
|
-
if (input.noInstall && initConfig?.config) await timePhase(timings, "generate code artifacts", () => generateCodeArtifacts(targetDir, initConfig.config));
|
|
912
|
+
if (input.noInstall && initConfig?.config) await timePhase(timings, "generate code artifacts", () => generateCodeArtifacts(targetDir, initConfig.config), s);
|
|
948
913
|
s.stop("Project initialized");
|
|
949
914
|
if (!input.noInteractive) {
|
|
950
915
|
if (await p.confirm({
|
|
@@ -965,11 +930,10 @@ var plugin_default = createPlugin({
|
|
|
965
930
|
return {
|
|
966
931
|
status: "initialized",
|
|
967
932
|
directory,
|
|
968
|
-
|
|
969
|
-
extendsGateway,
|
|
933
|
+
extendsRef,
|
|
970
934
|
account,
|
|
971
935
|
domain,
|
|
972
|
-
extends:
|
|
936
|
+
extends: extendsRef,
|
|
973
937
|
plugins,
|
|
974
938
|
filesCopied,
|
|
975
939
|
timings
|
|
@@ -978,14 +942,14 @@ var plugin_default = createPlugin({
|
|
|
978
942
|
await cleanup();
|
|
979
943
|
}
|
|
980
944
|
} catch (error) {
|
|
945
|
+
const extendsRef = input.extends ? input.extends.startsWith("bos://") ? input.extends : `bos://${input.extends}` : "bos://dev.everything.near/everything.dev";
|
|
981
946
|
return {
|
|
982
947
|
status: "error",
|
|
983
948
|
directory: input.directory ?? "",
|
|
984
|
-
|
|
985
|
-
extendsGateway: input.extendsGateway ?? "",
|
|
949
|
+
extendsRef,
|
|
986
950
|
account: input.account,
|
|
987
951
|
domain: input.domain,
|
|
988
|
-
extends:
|
|
952
|
+
extends: extendsRef,
|
|
989
953
|
plugins: input.plugins ?? [],
|
|
990
954
|
filesCopied: 0,
|
|
991
955
|
timings: [],
|