everything-dev 1.17.0 → 1.19.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/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 +6 -12
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +6 -12
- 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 +64 -106
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +4 -7
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +4 -7
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +65 -107
- package/dist/plugin.mjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +1 -1
- package/src/cli/init.ts +224 -162
- package/src/cli/prompts.ts +17 -22
- package/src/cli/upgrade.ts +173 -56
- package/src/contract.meta.ts +6 -8
- package/src/contract.ts +1 -4
- package/src/plugin.ts +118 -187
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,18 +775,18 @@ 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";
|
|
@@ -849,9 +799,7 @@ var plugin_default = createPlugin({
|
|
|
849
799
|
} catch {}
|
|
850
800
|
if (!input.noInteractive) {
|
|
851
801
|
const prompted = await promptInitOptions({
|
|
852
|
-
extendsAccount
|
|
853
|
-
extendsGateway,
|
|
854
|
-
extends: input.extends,
|
|
802
|
+
extends: `bos://${extendsAccount}/${extendsGateway}`,
|
|
855
803
|
directory,
|
|
856
804
|
account,
|
|
857
805
|
domain,
|
|
@@ -870,21 +818,21 @@ var plugin_default = createPlugin({
|
|
|
870
818
|
directory = directory || domain || extendsGateway;
|
|
871
819
|
const targetDir = resolve(directory);
|
|
872
820
|
plugins = plugins ?? [];
|
|
821
|
+
const extendsRef = `bos://${extendsAccount}/${extendsGateway}`;
|
|
873
822
|
if (!parentConfig) try {
|
|
874
823
|
parentConfig = await timePhase(timings, "parent config", () => fetchParentConfig(extendsAccount, extendsGateway));
|
|
875
824
|
} catch {
|
|
876
825
|
return {
|
|
877
826
|
status: "error",
|
|
878
827
|
directory,
|
|
879
|
-
|
|
880
|
-
extendsGateway,
|
|
828
|
+
extendsRef,
|
|
881
829
|
account,
|
|
882
830
|
domain,
|
|
883
|
-
extends:
|
|
831
|
+
extends: extendsRef,
|
|
884
832
|
plugins: plugins ?? [],
|
|
885
833
|
filesCopied: 0,
|
|
886
834
|
timings,
|
|
887
|
-
error: `No config found at
|
|
835
|
+
error: `No config found at ${extendsRef} — are you sure this is the right parent?`
|
|
888
836
|
};
|
|
889
837
|
}
|
|
890
838
|
const { sourceDir, parentConfig: resolvedParentConfig, cleanup } = await timePhase(timings, "template source", () => resolveSourceDir({
|
|
@@ -893,45 +841,56 @@ var plugin_default = createPlugin({
|
|
|
893
841
|
source: input.source
|
|
894
842
|
}));
|
|
895
843
|
parentConfig = resolvedParentConfig;
|
|
844
|
+
const isMinimalScaffold = sourceDir === "";
|
|
896
845
|
try {
|
|
897
|
-
const patterns = await readTemplatekeep(sourceDir);
|
|
898
|
-
if (patterns.length === 0) return {
|
|
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
846
|
const s = p.spinner();
|
|
914
847
|
s.start("Setting up project");
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
plugins,
|
|
918
|
-
pluginRoutes
|
|
919
|
-
}));
|
|
920
|
-
await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
|
|
848
|
+
let filesCopied;
|
|
849
|
+
if (isMinimalScaffold) filesCopied = await timePhase(timings, "scaffold project", () => scaffoldMinimalProject(targetDir, parentConfig, {
|
|
921
850
|
extendsAccount,
|
|
922
851
|
extendsGateway,
|
|
923
852
|
account: account || extendsAccount,
|
|
924
|
-
domain
|
|
853
|
+
domain,
|
|
925
854
|
plugins,
|
|
926
|
-
pluginRoutes,
|
|
927
|
-
workspaceOpts: { sourceDir },
|
|
928
855
|
withHost
|
|
929
856
|
}));
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
857
|
+
else {
|
|
858
|
+
const patterns = await readTemplatekeep(sourceDir);
|
|
859
|
+
if (patterns.length === 0) return {
|
|
860
|
+
status: "error",
|
|
861
|
+
directory,
|
|
862
|
+
extendsRef,
|
|
863
|
+
account,
|
|
864
|
+
domain,
|
|
865
|
+
extends: extendsRef,
|
|
866
|
+
plugins: plugins ?? [],
|
|
867
|
+
filesCopied: 0,
|
|
868
|
+
error: "No .templatekeep found in template source"
|
|
869
|
+
};
|
|
870
|
+
const pluginRoutes = {};
|
|
871
|
+
const parentRuntimePlugins = await buildRuntimePluginsForConfig(parentConfig, sourceDir, "production");
|
|
872
|
+
for (const [key, plugin] of Object.entries(parentRuntimePlugins ?? {})) if (plugin.routes && plugin.routes.length > 0) pluginRoutes[key] = plugin.routes;
|
|
873
|
+
filesCopied = await timePhase(timings, "copy files", () => copyFilteredFiles(sourceDir, targetDir, patterns, {
|
|
874
|
+
withHost,
|
|
875
|
+
plugins,
|
|
876
|
+
pluginRoutes
|
|
877
|
+
}));
|
|
878
|
+
await timePhase(timings, "personalize config", () => personalizeConfig(targetDir, {
|
|
879
|
+
extendsAccount,
|
|
880
|
+
extendsGateway,
|
|
881
|
+
account: account || extendsAccount,
|
|
882
|
+
domain: domain || extendsGateway,
|
|
883
|
+
plugins,
|
|
884
|
+
pluginRoutes,
|
|
885
|
+
workspaceOpts: { sourceDir },
|
|
886
|
+
withHost
|
|
887
|
+
}));
|
|
888
|
+
await timePhase(timings, "write snapshot", () => writeInitSnapshot(targetDir, extendsAccount, extendsGateway, sourceDir, patterns, {
|
|
889
|
+
withHost,
|
|
890
|
+
plugins,
|
|
891
|
+
pluginRoutes
|
|
892
|
+
}));
|
|
893
|
+
}
|
|
935
894
|
const initConfig = await timePhase(timings, "resolve config", () => loadConfig({ cwd: targetDir }));
|
|
936
895
|
if (initConfig?.runtime) await timePhase(timings, "generate env/docker", async () => {
|
|
937
896
|
writeGeneratedInfra(targetDir, initConfig.runtime);
|
|
@@ -965,11 +924,10 @@ var plugin_default = createPlugin({
|
|
|
965
924
|
return {
|
|
966
925
|
status: "initialized",
|
|
967
926
|
directory,
|
|
968
|
-
|
|
969
|
-
extendsGateway,
|
|
927
|
+
extendsRef,
|
|
970
928
|
account,
|
|
971
929
|
domain,
|
|
972
|
-
extends:
|
|
930
|
+
extends: extendsRef,
|
|
973
931
|
plugins,
|
|
974
932
|
filesCopied,
|
|
975
933
|
timings
|
|
@@ -978,14 +936,14 @@ var plugin_default = createPlugin({
|
|
|
978
936
|
await cleanup();
|
|
979
937
|
}
|
|
980
938
|
} catch (error) {
|
|
939
|
+
const extendsRef = input.extends ? input.extends.startsWith("bos://") ? input.extends : `bos://${input.extends}` : "bos://dev.everything.near/everything.dev";
|
|
981
940
|
return {
|
|
982
941
|
status: "error",
|
|
983
942
|
directory: input.directory ?? "",
|
|
984
|
-
|
|
985
|
-
extendsGateway: input.extendsGateway ?? "",
|
|
943
|
+
extendsRef,
|
|
986
944
|
account: input.account,
|
|
987
945
|
domain: input.domain,
|
|
988
|
-
extends:
|
|
946
|
+
extends: extendsRef,
|
|
989
947
|
plugins: input.plugins ?? [],
|
|
990
948
|
filesCopied: 0,
|
|
991
949
|
timings: [],
|