everything-dev 1.27.0 → 1.28.1
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/infra.cjs +1 -1
- package/dist/cli/infra.mjs +1 -1
- package/dist/cli/init.cjs +34 -9
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +2 -1
- package/dist/cli/init.d.cts.map +1 -1
- package/dist/cli/init.d.mts +2 -1
- package/dist/cli/init.d.mts.map +1 -1
- package/dist/cli/init.mjs +34 -9
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/prompts.cjs +28 -24
- package/dist/cli/prompts.cjs.map +1 -1
- package/dist/cli/prompts.mjs +27 -24
- package/dist/cli/prompts.mjs.map +1 -1
- package/dist/cli/sync.cjs +40 -3
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +40 -3
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli.cjs +187 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +186 -11
- package/dist/cli.mjs.map +1 -1
- package/dist/config.cjs +1 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +1 -0
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +1 -1
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +38 -34
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +38 -34
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.mjs +1 -0
- package/dist/contract.mjs.map +1 -1
- package/dist/dev-session.cjs +0 -1
- package/dist/dev-session.mjs +1 -1
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +0 -1
- package/dist/near-cli.cjs +1 -1
- package/dist/near-cli.mjs +1 -1
- package/dist/orchestrator.cjs +1 -1
- package/dist/orchestrator.mjs +1 -1
- package/dist/plugin.cjs +183 -151
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +67 -34
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +66 -34
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +173 -142
- package/dist/plugin.mjs.map +1 -1
- package/dist/service-descriptor.d.cts +34 -0
- package/dist/service-descriptor.d.cts.map +1 -0
- package/dist/service-descriptor.d.mts +36 -0
- package/dist/service-descriptor.d.mts.map +1 -0
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/utils/run.cjs +9 -20
- package/dist/utils/run.cjs.map +1 -1
- package/dist/utils/run.mjs +9 -20
- package/dist/utils/run.mjs.map +1 -1
- package/package.json +2 -2
- package/src/api-contract.ts +0 -623
- package/src/app.ts +0 -193
- package/src/cli/catalog.ts +0 -49
- package/src/cli/framework-version.ts +0 -61
- package/src/cli/help.ts +0 -13
- package/src/cli/infra.ts +0 -190
- package/src/cli/init.ts +0 -1145
- package/src/cli/parse.ts +0 -147
- package/src/cli/prompts.ts +0 -135
- package/src/cli/snapshot.ts +0 -46
- package/src/cli/status.ts +0 -99
- package/src/cli/sync.ts +0 -429
- package/src/cli/timing.ts +0 -63
- package/src/cli/upgrade.ts +0 -869
- package/src/cli.ts +0 -516
- package/src/components/dev-view.tsx +0 -352
- package/src/components/streaming-view.ts +0 -177
- package/src/config.ts +0 -893
- package/src/contract.meta.ts +0 -140
- package/src/contract.ts +0 -326
- package/src/dev-logs.ts +0 -92
- package/src/dev-session.ts +0 -283
- package/src/fastkv.ts +0 -181
- package/src/index.ts +0 -8
- package/src/integrity.ts +0 -138
- package/src/internal/manifest-normalizer.ts +0 -290
- package/src/merge.ts +0 -187
- package/src/mf.ts +0 -147
- package/src/near-cli.ts +0 -259
- package/src/network.ts +0 -3
- package/src/orchestrator.ts +0 -493
- package/src/plugin.ts +0 -1799
- package/src/sdk.ts +0 -14
- package/src/service-descriptor.ts +0 -281
- package/src/shared.ts +0 -249
- package/src/sidebar.ts +0 -140
- package/src/types.ts +0 -330
- package/src/ui/head.ts +0 -83
- package/src/ui/index.ts +0 -5
- package/src/ui/metadata.ts +0 -95
- package/src/ui/router.ts +0 -88
- package/src/ui/runtime.ts +0 -42
- package/src/ui/types.ts +0 -65
- package/src/utils/banner.ts +0 -21
- package/src/utils/linkify.ts +0 -11
- package/src/utils/path-match.ts +0 -16
- package/src/utils/run.ts +0 -31
- package/src/utils/save-config.ts +0 -20
- package/src/utils/theme.ts +0 -39
package/src/cli/parse.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import type { CommandDescriptor } from "./catalog";
|
|
2
|
-
|
|
3
|
-
type SchemaLike = {
|
|
4
|
-
_def?: {
|
|
5
|
-
type?: string;
|
|
6
|
-
innerType?: SchemaLike;
|
|
7
|
-
shape?: Record<string, SchemaLike>;
|
|
8
|
-
values?: Record<string, string> | string[];
|
|
9
|
-
};
|
|
10
|
-
parse: (value: unknown) => unknown;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function unwrap(schema: SchemaLike): SchemaLike {
|
|
14
|
-
let current = schema;
|
|
15
|
-
while (true) {
|
|
16
|
-
const type = current._def?.type;
|
|
17
|
-
if (type === "default" || type === "optional" || type === "nullable" || type === "nullish") {
|
|
18
|
-
const inner = current._def?.innerType;
|
|
19
|
-
if (!inner) break;
|
|
20
|
-
current = inner;
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
return current;
|
|
24
|
-
}
|
|
25
|
-
return current;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function isBooleanSchema(schema: SchemaLike): boolean {
|
|
29
|
-
return unwrap(schema)._def?.type === "boolean";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function isArraySchema(schema: SchemaLike): boolean {
|
|
33
|
-
return unwrap(schema)._def?.type === "array";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function coerceValue(raw: string, schema: SchemaLike): unknown {
|
|
37
|
-
const inner = unwrap(schema);
|
|
38
|
-
switch (inner._def?.type) {
|
|
39
|
-
case "boolean":
|
|
40
|
-
return raw === "true" || raw === "1" || raw === "yes";
|
|
41
|
-
case "number": {
|
|
42
|
-
const value = Number(raw);
|
|
43
|
-
if (Number.isNaN(value)) throw new Error(`Invalid number: ${raw}`);
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
case "enum":
|
|
47
|
-
return raw;
|
|
48
|
-
default:
|
|
49
|
-
return raw;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function toFlagName(field: string): string {
|
|
54
|
-
return `--${field.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getShape(schema: SchemaLike): Record<string, SchemaLike> {
|
|
58
|
-
const inner = unwrap(schema);
|
|
59
|
-
const shape = inner._def?.shape;
|
|
60
|
-
if (!shape) return {};
|
|
61
|
-
return shape;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function parseCommandInput(descriptor: CommandDescriptor, argv: string[]): unknown {
|
|
65
|
-
const schema = (descriptor.procedure as any)["~orpc"]?.inputSchema as SchemaLike | undefined;
|
|
66
|
-
if (!schema) return {};
|
|
67
|
-
|
|
68
|
-
const shape = getShape(schema);
|
|
69
|
-
const fields = Object.entries(shape);
|
|
70
|
-
const fieldByFlag = new Map<string, string>();
|
|
71
|
-
const positionalFields: string[] = [];
|
|
72
|
-
|
|
73
|
-
for (const [fieldName] of fields) {
|
|
74
|
-
fieldByFlag.set(toFlagName(fieldName), fieldName);
|
|
75
|
-
if (descriptor.meta.fields?.[fieldName]?.positional) {
|
|
76
|
-
positionalFields.push(fieldName);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const input: Record<string, unknown> = {};
|
|
81
|
-
const positionals: string[] = [];
|
|
82
|
-
|
|
83
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
84
|
-
const token = argv[i];
|
|
85
|
-
if (!token) continue;
|
|
86
|
-
|
|
87
|
-
if (token.startsWith("--no-")) {
|
|
88
|
-
const flagName = `--${token.slice(5)}`;
|
|
89
|
-
const fieldName = fieldByFlag.get(flagName);
|
|
90
|
-
if (!fieldName) throw new Error(`Unknown flag: ${token}`);
|
|
91
|
-
input[fieldName] = false;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (token.startsWith("--")) {
|
|
96
|
-
const [flag, inline] = token.split("=", 2);
|
|
97
|
-
const fieldName = fieldByFlag.get(flag);
|
|
98
|
-
if (!fieldName) throw new Error(`Unknown flag: ${token}`);
|
|
99
|
-
|
|
100
|
-
const fieldSchema = shape[fieldName];
|
|
101
|
-
if (isBooleanSchema(fieldSchema)) {
|
|
102
|
-
input[fieldName] = inline ? coerceValue(inline, fieldSchema) : true;
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const next = inline ?? argv[i + 1];
|
|
107
|
-
|
|
108
|
-
if (isArraySchema(fieldSchema)) {
|
|
109
|
-
if (next === undefined || next.startsWith("--")) {
|
|
110
|
-
throw new Error(`Missing value for ${flag}`);
|
|
111
|
-
}
|
|
112
|
-
input[fieldName] = next
|
|
113
|
-
.split(",")
|
|
114
|
-
.map((s: string) => s.trim())
|
|
115
|
-
.filter(Boolean);
|
|
116
|
-
if (!inline) i += 1;
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (next === undefined || next.startsWith("--")) {
|
|
121
|
-
throw new Error(`Missing value for ${flag}`);
|
|
122
|
-
}
|
|
123
|
-
input[fieldName] = coerceValue(next, fieldSchema);
|
|
124
|
-
if (!inline) i += 1;
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
positionals.push(token);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (positionalFields.length > 0) {
|
|
132
|
-
positionalFields.forEach((fieldName, index) => {
|
|
133
|
-
const raw = positionals[index];
|
|
134
|
-
if (raw !== undefined) {
|
|
135
|
-
input[fieldName] = coerceValue(raw, shape[fieldName]);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
} else if (positionals.length > 0) {
|
|
139
|
-
const candidate = fields.find(([, fieldSchema]) => !isBooleanSchema(fieldSchema));
|
|
140
|
-
if (candidate) {
|
|
141
|
-
const [fieldName, fieldSchema] = candidate;
|
|
142
|
-
input[fieldName] = coerceValue(positionals[0], fieldSchema);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return schema.parse(input);
|
|
147
|
-
}
|
package/src/cli/prompts.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import * as p from "@clack/prompts";
|
|
3
|
-
import type { OverrideSection } from "../contract";
|
|
4
|
-
|
|
5
|
-
function parseExtendsRef(ref: string): { account: string; gateway: string } | null {
|
|
6
|
-
const normalized = ref.startsWith("bos://") ? ref : `bos://${ref}`;
|
|
7
|
-
const match = normalized.match(/^bos:\/\/([^/]+)\/(.+)$/);
|
|
8
|
-
if (!match) return null;
|
|
9
|
-
return { account: match[1], gateway: match[2] };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function deriveAccountFromExtends(domain: string, extendsAccount: string): string {
|
|
13
|
-
const firstSegment = domain.split(".")[0];
|
|
14
|
-
if (!firstSegment) return "";
|
|
15
|
-
const suffix = extendsAccount.includes(".")
|
|
16
|
-
? extendsAccount.substring(extendsAccount.indexOf(".") + 1)
|
|
17
|
-
: extendsAccount;
|
|
18
|
-
return `${firstSegment}.${suffix}`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const OVERRIDE_OPTIONS: { value: OverrideSection; label: string; hint: string }[] = [
|
|
22
|
-
{ value: "ui", label: "ui", hint: "Override UI with local source" },
|
|
23
|
-
{ value: "api", label: "api", hint: "Override API with local source" },
|
|
24
|
-
{ value: "host", label: "host", hint: "Override host with local source" },
|
|
25
|
-
{ value: "plugins", label: "plugins", hint: "Override selected plugins with local source" },
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
export async function promptInitOptions(input: {
|
|
29
|
-
extends?: string;
|
|
30
|
-
directory?: string;
|
|
31
|
-
account?: string;
|
|
32
|
-
domain?: string;
|
|
33
|
-
plugins?: string[];
|
|
34
|
-
overrides?: OverrideSection[];
|
|
35
|
-
parentPluginKeys?: string[];
|
|
36
|
-
}): Promise<{
|
|
37
|
-
extendsAccount: string;
|
|
38
|
-
extendsGateway: string;
|
|
39
|
-
directory: string;
|
|
40
|
-
account?: string;
|
|
41
|
-
domain?: string;
|
|
42
|
-
plugins: string[];
|
|
43
|
-
overrides: OverrideSection[];
|
|
44
|
-
}> {
|
|
45
|
-
p.intro("Let's build an app...");
|
|
46
|
-
|
|
47
|
-
const extendsInput =
|
|
48
|
-
input.extends ??
|
|
49
|
-
((await p.text({
|
|
50
|
-
message: "Extending an existing app?",
|
|
51
|
-
placeholder: "bos://dev.everything.near/everything.dev",
|
|
52
|
-
})) as string);
|
|
53
|
-
|
|
54
|
-
if (p.isCancel(extendsInput)) process.exit(0);
|
|
55
|
-
|
|
56
|
-
let extendsAccount = "dev.everything.near";
|
|
57
|
-
let extendsGateway = "everything.dev";
|
|
58
|
-
|
|
59
|
-
if (extendsInput) {
|
|
60
|
-
const parsed = parseExtendsRef(extendsInput);
|
|
61
|
-
if (parsed) {
|
|
62
|
-
extendsAccount = parsed.account;
|
|
63
|
-
extendsGateway = parsed.gateway;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const domain =
|
|
68
|
-
input.domain ??
|
|
69
|
-
((await p.text({
|
|
70
|
-
message: "Starting with a domain?",
|
|
71
|
-
placeholder: "no",
|
|
72
|
-
})) as string);
|
|
73
|
-
|
|
74
|
-
if (p.isCancel(domain)) process.exit(0);
|
|
75
|
-
|
|
76
|
-
const accountDefault = domain ? deriveAccountFromExtends(domain, extendsAccount) : "";
|
|
77
|
-
const account =
|
|
78
|
-
input.account ??
|
|
79
|
-
((await p.text({
|
|
80
|
-
message: "What NEAR account will you publish from?",
|
|
81
|
-
placeholder: accountDefault || "skip",
|
|
82
|
-
defaultValue: accountDefault,
|
|
83
|
-
})) as string);
|
|
84
|
-
|
|
85
|
-
if (p.isCancel(account)) process.exit(0);
|
|
86
|
-
|
|
87
|
-
const directory = input.directory || domain || extendsGateway;
|
|
88
|
-
|
|
89
|
-
const overrides =
|
|
90
|
-
input.overrides ??
|
|
91
|
-
((await p.multiselect({
|
|
92
|
-
message: "What do you want to customize?",
|
|
93
|
-
options: OVERRIDE_OPTIONS,
|
|
94
|
-
initialValues: ["ui", "api"] as OverrideSection[],
|
|
95
|
-
required: false,
|
|
96
|
-
})) as OverrideSection[]);
|
|
97
|
-
|
|
98
|
-
if (p.isCancel(overrides)) process.exit(0);
|
|
99
|
-
|
|
100
|
-
let plugins: string[] = [];
|
|
101
|
-
if (overrides.includes("plugins")) {
|
|
102
|
-
const parentPlugins = input.parentPluginKeys ?? [];
|
|
103
|
-
const pluginOptions =
|
|
104
|
-
parentPlugins.length > 0 ? parentPlugins.map((key) => ({ value: key, label: key })) : [];
|
|
105
|
-
|
|
106
|
-
plugins =
|
|
107
|
-
input.plugins ??
|
|
108
|
-
(pluginOptions.length > 0
|
|
109
|
-
? ((await p.multiselect({
|
|
110
|
-
message: "Select plugins to include:",
|
|
111
|
-
options: pluginOptions,
|
|
112
|
-
required: false,
|
|
113
|
-
})) as string[])
|
|
114
|
-
: []);
|
|
115
|
-
|
|
116
|
-
if (p.isCancel(plugins)) process.exit(0);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const go = await p.confirm({
|
|
120
|
-
message: "GO!",
|
|
121
|
-
initialValue: true,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
if (p.isCancel(go) || !go) process.exit(0);
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
extendsAccount,
|
|
128
|
-
extendsGateway,
|
|
129
|
-
directory,
|
|
130
|
-
account: account || undefined,
|
|
131
|
-
domain: domain || undefined,
|
|
132
|
-
plugins,
|
|
133
|
-
overrides,
|
|
134
|
-
};
|
|
135
|
-
}
|
package/src/cli/snapshot.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
|
|
4
|
-
export interface SyncSnapshot {
|
|
5
|
-
parentRef: string;
|
|
6
|
-
timestamp: string;
|
|
7
|
-
files: Record<string, string>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const SNAPSHOT_DIR = ".bos";
|
|
11
|
-
const SNAPSHOT_FILE = "sync-snapshot.json";
|
|
12
|
-
|
|
13
|
-
function snapshotPath(projectDir: string): string {
|
|
14
|
-
return join(projectDir, SNAPSHOT_DIR, SNAPSHOT_FILE);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function readSnapshot(projectDir: string): Promise<SyncSnapshot | null> {
|
|
18
|
-
const path = snapshotPath(projectDir);
|
|
19
|
-
if (!existsSync(path)) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const content = readFileSync(path, "utf-8");
|
|
24
|
-
return JSON.parse(content) as SyncSnapshot;
|
|
25
|
-
} catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function writeSnapshot(
|
|
31
|
-
projectDir: string,
|
|
32
|
-
data: { parentRef: string; files: Record<string, string> },
|
|
33
|
-
): Promise<void> {
|
|
34
|
-
const dir = join(projectDir, SNAPSHOT_DIR);
|
|
35
|
-
if (!existsSync(dir)) {
|
|
36
|
-
mkdirSync(dir, { recursive: true });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const snapshot: SyncSnapshot = {
|
|
40
|
-
parentRef: data.parentRef,
|
|
41
|
-
timestamp: new Date().toISOString(),
|
|
42
|
-
files: data.files,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
writeFileSync(snapshotPath(projectDir), `${JSON.stringify(snapshot, null, 2)}\n`);
|
|
46
|
-
}
|
package/src/cli/status.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import type { StatusResult } from "../contract";
|
|
4
|
-
import { fetchBosConfigFromFastKv } from "../fastkv";
|
|
5
|
-
import { readInstalledFrameworkVersion } from "./framework-version";
|
|
6
|
-
import { readSnapshot } from "./snapshot";
|
|
7
|
-
|
|
8
|
-
const FRAMEWORK_PACKAGES = ["everything-dev", "every-plugin"];
|
|
9
|
-
|
|
10
|
-
const CATALOG_TOOL_PACKAGES = [
|
|
11
|
-
"@rspack/core",
|
|
12
|
-
"@rspack/cli",
|
|
13
|
-
"@rsbuild/core",
|
|
14
|
-
"@rsbuild/plugin-react",
|
|
15
|
-
"@module-federation/enhanced",
|
|
16
|
-
"@module-federation/node",
|
|
17
|
-
"@module-federation/rsbuild-plugin",
|
|
18
|
-
"@module-federation/runtime-core",
|
|
19
|
-
"@module-federation/sdk",
|
|
20
|
-
"@module-federation/dts-plugin",
|
|
21
|
-
] as const;
|
|
22
|
-
|
|
23
|
-
async function fetchLatestNpmVersion(packageName: string): Promise<string | null> {
|
|
24
|
-
try {
|
|
25
|
-
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
|
|
26
|
-
headers: { Accept: "application/json" },
|
|
27
|
-
signal: AbortSignal.timeout(10_000),
|
|
28
|
-
});
|
|
29
|
-
if (!response.ok) return null;
|
|
30
|
-
const data = (await response.json()) as { version: string };
|
|
31
|
-
return data.version;
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function readInstalledVersion(projectDir: string, packageName: string): string | undefined {
|
|
38
|
-
return readInstalledFrameworkVersion(projectDir, packageName);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function checkEnvFile(projectDir: string): "found" | "missing" | "example-only" {
|
|
42
|
-
if (existsSync(join(projectDir, ".env"))) return "found";
|
|
43
|
-
if (existsSync(join(projectDir, ".env.example"))) return "example-only";
|
|
44
|
-
return "missing";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function checkParentReachable(extendsRef: string | undefined): Promise<boolean | undefined> {
|
|
48
|
-
if (!extendsRef?.startsWith("bos://")) return undefined;
|
|
49
|
-
try {
|
|
50
|
-
const config = await fetchBosConfigFromFastKv(extendsRef);
|
|
51
|
-
return config !== null;
|
|
52
|
-
} catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function getStatus(projectDir: string): Promise<StatusResult> {
|
|
58
|
-
const configPath = join(projectDir, "bos.config.json");
|
|
59
|
-
if (!existsSync(configPath)) {
|
|
60
|
-
return {
|
|
61
|
-
status: "error",
|
|
62
|
-
error: "No bos.config.json found in current directory",
|
|
63
|
-
packages: [],
|
|
64
|
-
envFile: "missing",
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const config = JSON.parse(readFileSync(configPath, "utf-8")) as Record<string, unknown>;
|
|
69
|
-
|
|
70
|
-
const packages = [];
|
|
71
|
-
for (const name of FRAMEWORK_PACKAGES) {
|
|
72
|
-
const installed = readInstalledVersion(projectDir, name);
|
|
73
|
-
const latest = await fetchLatestNpmVersion(name);
|
|
74
|
-
packages.push({ name, installed, latest: latest ?? undefined });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
for (const name of CATALOG_TOOL_PACKAGES) {
|
|
78
|
-
const installed = readInstalledVersion(projectDir, name);
|
|
79
|
-
if (!installed) continue;
|
|
80
|
-
const latest = await fetchLatestNpmVersion(name);
|
|
81
|
-
packages.push({ name, installed, latest: latest ?? undefined });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const snapshot = await readSnapshot(projectDir);
|
|
85
|
-
|
|
86
|
-
const extendsRef = config.extends as string | undefined;
|
|
87
|
-
const parentReachable = await checkParentReachable(extendsRef);
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
status: "ok",
|
|
91
|
-
extends: extendsRef,
|
|
92
|
-
account: config.account as string | undefined,
|
|
93
|
-
domain: config.domain as string | undefined,
|
|
94
|
-
packages,
|
|
95
|
-
lastSync: snapshot?.timestamp,
|
|
96
|
-
envFile: checkEnvFile(projectDir),
|
|
97
|
-
parentReachable,
|
|
98
|
-
};
|
|
99
|
-
}
|