everything-dev 1.21.0 → 1.23.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 +87 -8
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +11 -4
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +11 -4
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +87 -9
- package/dist/cli/init.mjs.map +1 -1
- package/dist/contract.d.cts +11 -11
- package/dist/contract.d.mts +11 -11
- package/dist/fastkv.cjs +4 -1
- package/dist/fastkv.cjs.map +1 -1
- package/dist/fastkv.mjs +4 -1
- package/dist/fastkv.mjs.map +1 -1
- package/dist/plugin.cjs +36 -12
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +6 -6
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +6 -6
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +37 -13
- 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 +160 -8
- package/src/fastkv.ts +6 -1
- package/src/plugin.ts +48 -2
package/dist/types.d.mts
CHANGED
|
@@ -397,9 +397,9 @@ declare const BosConfigSchema: z.ZodObject<{
|
|
|
397
397
|
type BosConfig = z.infer<typeof BosConfigSchema>;
|
|
398
398
|
declare const RuntimeConfigSchema: z.ZodObject<{
|
|
399
399
|
env: z.ZodEnum<{
|
|
400
|
+
development: "development";
|
|
400
401
|
production: "production";
|
|
401
402
|
staging: "staging";
|
|
402
|
-
development: "development";
|
|
403
403
|
}>;
|
|
404
404
|
account: z.ZodString;
|
|
405
405
|
domain: z.ZodOptional<z.ZodString>;
|
|
@@ -539,9 +539,9 @@ type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
|
|
|
539
539
|
declare const ClientRuntimeConfigSchema: z.ZodObject<{
|
|
540
540
|
cspNonce: z.ZodOptional<z.ZodString>;
|
|
541
541
|
env: z.ZodEnum<{
|
|
542
|
+
development: "development";
|
|
542
543
|
production: "production";
|
|
543
544
|
staging: "staging";
|
|
544
|
-
development: "development";
|
|
545
545
|
}>;
|
|
546
546
|
account: z.ZodString;
|
|
547
547
|
networkId: z.ZodEnum<{
|
package/package.json
CHANGED
package/src/cli/init.ts
CHANGED
|
@@ -28,6 +28,8 @@ import { writeSnapshot } from "./snapshot";
|
|
|
28
28
|
|
|
29
29
|
const require = createRequire(import.meta.url);
|
|
30
30
|
|
|
31
|
+
const FRAMEWORK_PACKAGES = ["every-plugin", "everything-dev"] as const;
|
|
32
|
+
|
|
31
33
|
const _DEFAULT_OVERRIDES: OverrideSection[] = ["ui", "api"];
|
|
32
34
|
|
|
33
35
|
const OVERRIDE_WORKSPACE_MAP: Record<OverrideSection, string[]> = {
|
|
@@ -628,16 +630,94 @@ export interface AuthServices {
|
|
|
628
630
|
`;
|
|
629
631
|
}
|
|
630
632
|
|
|
631
|
-
export async function runBunInstall(
|
|
632
|
-
|
|
633
|
+
export async function runBunInstall(
|
|
634
|
+
destination: string,
|
|
635
|
+
spinner?: { message: (msg: string) => void },
|
|
636
|
+
): Promise<void> {
|
|
637
|
+
await runWithProgress(
|
|
638
|
+
"bun",
|
|
639
|
+
["install", "--ignore-scripts"],
|
|
640
|
+
destination,
|
|
641
|
+
spinner,
|
|
642
|
+
"Installing dependencies",
|
|
643
|
+
);
|
|
633
644
|
}
|
|
634
645
|
|
|
635
|
-
export async function runTypesGen(
|
|
636
|
-
|
|
646
|
+
export async function runTypesGen(
|
|
647
|
+
destination: string,
|
|
648
|
+
spinner?: { message: (msg: string) => void },
|
|
649
|
+
): Promise<void> {
|
|
650
|
+
await runWithProgress(
|
|
651
|
+
"node_modules/.bin/bos",
|
|
652
|
+
["types", "gen"],
|
|
653
|
+
destination,
|
|
654
|
+
spinner,
|
|
655
|
+
"Generating types",
|
|
656
|
+
);
|
|
637
657
|
}
|
|
638
658
|
|
|
639
659
|
export async function runDockerComposeUp(destination: string): Promise<void> {
|
|
640
|
-
await execCommand("docker", ["compose", "up", "-d", "--wait"], destination);
|
|
660
|
+
await execCommand("docker", ["compose", "up", "-d", "--wait"], destination, { stdio: "inherit" });
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
async function runWithProgress(
|
|
664
|
+
command: string,
|
|
665
|
+
args: string[],
|
|
666
|
+
cwd: string,
|
|
667
|
+
spinner: { message: (msg: string) => void } | undefined,
|
|
668
|
+
label: string,
|
|
669
|
+
): Promise<void> {
|
|
670
|
+
const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;
|
|
671
|
+
const child = execa(command, args, { cwd, stdio: "inherit", timeout });
|
|
672
|
+
|
|
673
|
+
if (spinner) {
|
|
674
|
+
const start = Date.now();
|
|
675
|
+
const interval = setInterval(() => {
|
|
676
|
+
const elapsed = Math.round((Date.now() - start) / 1000);
|
|
677
|
+
spinner.message(`${label}... (${elapsed}s)`);
|
|
678
|
+
}, 2000);
|
|
679
|
+
try {
|
|
680
|
+
await child;
|
|
681
|
+
} finally {
|
|
682
|
+
clearInterval(interval);
|
|
683
|
+
}
|
|
684
|
+
} else {
|
|
685
|
+
await child;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export function stripOrphanedWorkspacesFromLockfile(
|
|
690
|
+
lockfilePath: string,
|
|
691
|
+
allowedWorkspaces: string[],
|
|
692
|
+
): void {
|
|
693
|
+
if (!existsSync(lockfilePath)) return;
|
|
694
|
+
|
|
695
|
+
const content = readFileSync(lockfilePath, "utf-8");
|
|
696
|
+
let lockfile: Record<string, unknown>;
|
|
697
|
+
try {
|
|
698
|
+
lockfile = JSON.parse(content) as Record<string, unknown>;
|
|
699
|
+
} catch {
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const workspaces = lockfile.workspaces;
|
|
704
|
+
if (!workspaces || typeof workspaces !== "object") return;
|
|
705
|
+
|
|
706
|
+
const workspaceMap = workspaces as Record<string, unknown>;
|
|
707
|
+
const allowed = new Set(["", ...allowedWorkspaces]);
|
|
708
|
+
|
|
709
|
+
const keys = Object.keys(workspaceMap);
|
|
710
|
+
let changed = false;
|
|
711
|
+
for (const key of keys) {
|
|
712
|
+
if (!allowed.has(key)) {
|
|
713
|
+
delete workspaceMap[key];
|
|
714
|
+
changed = true;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (changed) {
|
|
719
|
+
writeFileSync(lockfilePath, `${JSON.stringify(lockfile, null, 2)}\n`);
|
|
720
|
+
}
|
|
641
721
|
}
|
|
642
722
|
|
|
643
723
|
const WORKSPACE_LOCAL_PATHS: Record<string, string> = {
|
|
@@ -645,6 +725,63 @@ const WORKSPACE_LOCAL_PATHS: Record<string, string> = {
|
|
|
645
725
|
"every-plugin": "packages/every-plugin",
|
|
646
726
|
};
|
|
647
727
|
|
|
728
|
+
function resolveFrameworkCatalog(): Record<string, string> {
|
|
729
|
+
const catalog: Record<string, string> = {};
|
|
730
|
+
|
|
731
|
+
try {
|
|
732
|
+
const selfPkgPath = require.resolve("everything-dev/package.json");
|
|
733
|
+
const selfPkgDir = dirname(selfPkgPath);
|
|
734
|
+
const monorepoPkgPath = join(selfPkgDir, "..", "..", "package.json");
|
|
735
|
+
if (existsSync(monorepoPkgPath)) {
|
|
736
|
+
const monorepoPkg = JSON.parse(readFileSync(monorepoPkgPath, "utf-8")) as {
|
|
737
|
+
workspaces?: { catalog?: Record<string, string> };
|
|
738
|
+
};
|
|
739
|
+
const sourceCatalog = monorepoPkg.workspaces?.catalog;
|
|
740
|
+
if (sourceCatalog && typeof sourceCatalog === "object") {
|
|
741
|
+
for (const [name, version] of Object.entries(sourceCatalog)) {
|
|
742
|
+
if (typeof version === "string") {
|
|
743
|
+
catalog[name] = version;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
} catch {}
|
|
749
|
+
|
|
750
|
+
try {
|
|
751
|
+
const selfPkgPath = require.resolve("everything-dev/package.json");
|
|
752
|
+
const selfPkg = JSON.parse(readFileSync(selfPkgPath, "utf-8")) as {
|
|
753
|
+
version?: string;
|
|
754
|
+
workspaces?: { catalog?: Record<string, string> };
|
|
755
|
+
};
|
|
756
|
+
if (selfPkg.version && !catalog["everything-dev"]) {
|
|
757
|
+
catalog["everything-dev"] = `^${selfPkg.version}`;
|
|
758
|
+
}
|
|
759
|
+
const sourceCatalog = selfPkg.workspaces?.catalog;
|
|
760
|
+
if (sourceCatalog && typeof sourceCatalog === "object") {
|
|
761
|
+
for (const [name, version] of Object.entries(sourceCatalog)) {
|
|
762
|
+
if (typeof version === "string" && !catalog[name]) {
|
|
763
|
+
catalog[name] = version;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
} catch {}
|
|
768
|
+
|
|
769
|
+
if (Object.keys(catalog).length > 0) {
|
|
770
|
+
return catalog;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
for (const packageName of FRAMEWORK_PACKAGES) {
|
|
774
|
+
try {
|
|
775
|
+
const resolved = require.resolve(`${packageName}/package.json`);
|
|
776
|
+
const pkg = JSON.parse(readFileSync(resolved, "utf-8")) as { version?: string };
|
|
777
|
+
if (pkg.version) {
|
|
778
|
+
catalog[packageName] = `^${pkg.version}`;
|
|
779
|
+
}
|
|
780
|
+
} catch {}
|
|
781
|
+
}
|
|
782
|
+
return catalog;
|
|
783
|
+
}
|
|
784
|
+
|
|
648
785
|
export async function scaffoldMinimalProject(
|
|
649
786
|
destination: string,
|
|
650
787
|
parentConfig: BosConfigInput,
|
|
@@ -727,6 +864,8 @@ export async function scaffoldMinimalProject(
|
|
|
727
864
|
}
|
|
728
865
|
}
|
|
729
866
|
|
|
867
|
+
const catalog = resolveFrameworkCatalog();
|
|
868
|
+
|
|
730
869
|
const pkg: Record<string, unknown> = {
|
|
731
870
|
name: opts.domain || opts.extendsGateway,
|
|
732
871
|
private: true,
|
|
@@ -750,7 +889,7 @@ export async function scaffoldMinimalProject(
|
|
|
750
889
|
devDependencies: {},
|
|
751
890
|
workspaces: {
|
|
752
891
|
packages: workspacePackages,
|
|
753
|
-
catalog
|
|
892
|
+
catalog,
|
|
754
893
|
},
|
|
755
894
|
};
|
|
756
895
|
writeFileSync(join(destination, "package.json"), `${JSON.stringify(pkg, null, 2)}\n`);
|
|
@@ -920,8 +1059,21 @@ export async function generateDatabaseMigrations(destination: string): Promise<v
|
|
|
920
1059
|
}
|
|
921
1060
|
}
|
|
922
1061
|
|
|
923
|
-
|
|
924
|
-
|
|
1062
|
+
const COMMAND_TIMEOUTS: Record<string, number> = {
|
|
1063
|
+
bun: 5 * 60_000,
|
|
1064
|
+
docker: 5 * 60_000,
|
|
1065
|
+
node_modules: 2 * 60_000,
|
|
1066
|
+
tar: 60_000,
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1069
|
+
export async function execCommand(
|
|
1070
|
+
command: string,
|
|
1071
|
+
args: string[],
|
|
1072
|
+
cwd?: string,
|
|
1073
|
+
options?: { stdio?: "pipe" | "inherit" },
|
|
1074
|
+
): Promise<void> {
|
|
1075
|
+
const timeout = COMMAND_TIMEOUTS[command] ?? 2 * 60_000;
|
|
1076
|
+
await execa(command, args, { cwd, stdio: options?.stdio ?? "pipe", timeout });
|
|
925
1077
|
}
|
|
926
1078
|
|
|
927
1079
|
function generateEnvExample(config: BosConfigInput, overrides: OverrideSection[]): string {
|
package/src/fastkv.ts
CHANGED
|
@@ -141,8 +141,13 @@ export interface PluginManifest {
|
|
|
141
141
|
|
|
142
142
|
export async function fetchRemotePluginManifest(cdnUrl: string): Promise<PluginManifest | null> {
|
|
143
143
|
try {
|
|
144
|
+
const controller = new AbortController();
|
|
145
|
+
const timeout = setTimeout(() => controller.abort(), FASTKV_TIMEOUT_MS);
|
|
144
146
|
const baseUrl = cdnUrl.replace(/\/$/, "");
|
|
145
|
-
const response = await fetch(`${baseUrl}/plugin.manifest.json
|
|
147
|
+
const response = await fetch(`${baseUrl}/plugin.manifest.json`, {
|
|
148
|
+
signal: controller.signal,
|
|
149
|
+
});
|
|
150
|
+
clearTimeout(timeout);
|
|
146
151
|
if (!response.ok) return null;
|
|
147
152
|
return (await response.json()) as PluginManifest;
|
|
148
153
|
} catch {
|
package/src/plugin.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
runDockerComposeUp,
|
|
18
18
|
runTypesGen,
|
|
19
19
|
scaffoldMinimalProject,
|
|
20
|
+
stripOrphanedWorkspacesFromLockfile,
|
|
20
21
|
writeInitSnapshot,
|
|
21
22
|
} from "./cli/init";
|
|
22
23
|
import { promptInitOptions } from "./cli/prompts";
|
|
@@ -1336,6 +1337,23 @@ export default createPlugin({
|
|
|
1336
1337
|
}),
|
|
1337
1338
|
s,
|
|
1338
1339
|
);
|
|
1340
|
+
|
|
1341
|
+
await timePhase(
|
|
1342
|
+
timings,
|
|
1343
|
+
"personalize config",
|
|
1344
|
+
() =>
|
|
1345
|
+
personalizeConfig(targetDir, {
|
|
1346
|
+
extendsAccount,
|
|
1347
|
+
extendsGateway,
|
|
1348
|
+
account: account || extendsAccount,
|
|
1349
|
+
domain: domain || extendsGateway,
|
|
1350
|
+
plugins,
|
|
1351
|
+
overrides,
|
|
1352
|
+
mode: "init",
|
|
1353
|
+
repository,
|
|
1354
|
+
}),
|
|
1355
|
+
s,
|
|
1356
|
+
);
|
|
1339
1357
|
} else {
|
|
1340
1358
|
const patterns = await readTemplatekeep(sourceDir);
|
|
1341
1359
|
if (patterns.length === 0) {
|
|
@@ -1411,6 +1429,10 @@ export default createPlugin({
|
|
|
1411
1429
|
);
|
|
1412
1430
|
}
|
|
1413
1431
|
|
|
1432
|
+
const lockfilePath = join(targetDir, "bun.lock");
|
|
1433
|
+
const allowedWorkspaces = computeAllowedWorkspaces(overrides, plugins);
|
|
1434
|
+
stripOrphanedWorkspacesFromLockfile(lockfilePath, allowedWorkspaces);
|
|
1435
|
+
|
|
1414
1436
|
const initConfig = await timePhase(
|
|
1415
1437
|
timings,
|
|
1416
1438
|
"resolve config",
|
|
@@ -1437,8 +1459,12 @@ export default createPlugin({
|
|
|
1437
1459
|
);
|
|
1438
1460
|
|
|
1439
1461
|
if (!input.noInstall) {
|
|
1440
|
-
await timePhase(timings, "install dependencies", () =>
|
|
1441
|
-
|
|
1462
|
+
await timePhase(timings, "install dependencies", () =>
|
|
1463
|
+
runBunInstall(targetDir, s ?? undefined),
|
|
1464
|
+
);
|
|
1465
|
+
await timePhase(timings, "generate types", () =>
|
|
1466
|
+
runTypesGen(targetDir, s ?? undefined),
|
|
1467
|
+
);
|
|
1442
1468
|
await timePhase(
|
|
1443
1469
|
timings,
|
|
1444
1470
|
"generate migrations",
|
|
@@ -1721,3 +1747,23 @@ function extractTransactionHash(error: unknown) {
|
|
|
1721
1747
|
const match = message.match(/Transaction ID:\s*([A-Za-z0-9]+)/i);
|
|
1722
1748
|
return match?.[1];
|
|
1723
1749
|
}
|
|
1750
|
+
|
|
1751
|
+
const OVERRIDE_WORKSPACE_MAP: Record<string, string[]> = {
|
|
1752
|
+
ui: ["ui"],
|
|
1753
|
+
api: ["api"],
|
|
1754
|
+
host: ["host"],
|
|
1755
|
+
plugins: [],
|
|
1756
|
+
};
|
|
1757
|
+
|
|
1758
|
+
function computeAllowedWorkspaces(overrides: string[], plugins?: string[]): string[] {
|
|
1759
|
+
const workspaces: string[] = [];
|
|
1760
|
+
for (const section of overrides) {
|
|
1761
|
+
workspaces.push(...(OVERRIDE_WORKSPACE_MAP[section] ?? []));
|
|
1762
|
+
}
|
|
1763
|
+
if (plugins) {
|
|
1764
|
+
for (const plugin of plugins) {
|
|
1765
|
+
workspaces.push(`plugins/${plugin}`);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return workspaces;
|
|
1769
|
+
}
|