@adep/cli 0.4.5 → 0.4.6
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/index.js +595 -518
- package/dist/vite.js +38 -2
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1001,6 +1001,9 @@ function depsKeyOf(dependencies) {
|
|
|
1001
1001
|
const canonical = Object.entries(dependencies).map(([name, version2]) => `${name}@${version2}`).toSorted().join("\n");
|
|
1002
1002
|
return createHash("sha256").update(canonical).digest("hex").slice(0, 16);
|
|
1003
1003
|
}
|
|
1004
|
+
function parseNameList(value) {
|
|
1005
|
+
return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
1006
|
+
}
|
|
1004
1007
|
var PACKAGE_NAME_PATTERN, COMPARATOR_PATTERN, MANIFEST_MAX_DEPS;
|
|
1005
1008
|
var init_manifest = __esm({
|
|
1006
1009
|
"packages/runtime/src/functions/deps/manifest.ts"() {
|
|
@@ -4247,6 +4250,32 @@ var init_env = __esm({
|
|
|
4247
4250
|
}
|
|
4248
4251
|
});
|
|
4249
4252
|
|
|
4253
|
+
// packages/cli/src/sim/fetch-config.ts
|
|
4254
|
+
function resolveLocalFetchConfig(simEnv) {
|
|
4255
|
+
const rawAllowlist = simEnv.FUNCTIONS_FETCH_ALLOWLIST;
|
|
4256
|
+
if (rawAllowlist === void 0) return void 0;
|
|
4257
|
+
const rawTimeout = simEnv.FUNCTIONS_FETCH_TIMEOUT_MS;
|
|
4258
|
+
let timeoutMs = LOCAL_FETCH_TIMEOUT_MS_DEFAULT;
|
|
4259
|
+
if (rawTimeout !== void 0 && rawTimeout.trim() !== "") {
|
|
4260
|
+
const parsed = Number(rawTimeout);
|
|
4261
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
4262
|
+
throw new Error(
|
|
4263
|
+
`[adep] FUNCTIONS_FETCH_TIMEOUT_MS \u975E\u6CD5\uFF1A"${rawTimeout}"\uFF08\u987B\u4E3A\u6B63\u6574\u6570\u6BEB\u79D2\u6570\uFF1B\u4E0D\u914D\u5219\u7F3A\u7701 ${LOCAL_FETCH_TIMEOUT_MS_DEFAULT}\uFF09`
|
|
4264
|
+
);
|
|
4265
|
+
}
|
|
4266
|
+
timeoutMs = parsed;
|
|
4267
|
+
}
|
|
4268
|
+
return { allowlist: parseNameList(rawAllowlist), timeoutMs };
|
|
4269
|
+
}
|
|
4270
|
+
var LOCAL_FETCH_TIMEOUT_MS_DEFAULT;
|
|
4271
|
+
var init_fetch_config = __esm({
|
|
4272
|
+
"packages/cli/src/sim/fetch-config.ts"() {
|
|
4273
|
+
"use strict";
|
|
4274
|
+
init_manifest();
|
|
4275
|
+
LOCAL_FETCH_TIMEOUT_MS_DEFAULT = 1e4;
|
|
4276
|
+
}
|
|
4277
|
+
});
|
|
4278
|
+
|
|
4250
4279
|
// packages/cli/src/sim/invoke.ts
|
|
4251
4280
|
function resolveFunctionEntry(files, fnName) {
|
|
4252
4281
|
const flat = `${fnName}.ts`;
|
|
@@ -4376,6 +4405,11 @@ var init_boundary = __esm({
|
|
|
4376
4405
|
kind: "diff",
|
|
4377
4406
|
title: "\u4E0D\u8BA1\u91CF",
|
|
4378
4407
|
detail: "\u672C\u6A21\u62DF\u8FD0\u884C\u65F6\u4E0D\u4EA7\u51FA\u8BA1\u91CF\u4E8B\u4EF6\uFF0C\u4E5F\u4E0D\u5199 billing\uFF1B\u79BB\u7EBF\u5F00\u53D1\u4E0D\u8BA1\u8D39\u3002"
|
|
4408
|
+
},
|
|
4409
|
+
{
|
|
4410
|
+
kind: "diff",
|
|
4411
|
+
title: "\u51FA\u7F51\u7531\u767D\u540D\u5355\u63A7\u5236",
|
|
4412
|
+
detail: "cloud.fetch \u9ED8\u8BA4\u65E0\u7F51\u7EDC\uFF08\u672A\u914D\u7F6E\u65F6\u8C03\u7528\u629B FN_FETCH_DISABLED\uFF09\uFF1B.env \u914D FUNCTIONS_FETCH_ALLOWLIST\uFF08\u9017\u53F7\u5206\u9694\u4E3B\u673A\uFF0C*. \u901A\u914D\uFF1BFUNCTIONS_FETCH_TIMEOUT_MS \u7F3A\u7701 10s\uFF09\u540E\u91CD\u542F\u6CE8\u5165\u53D7\u63A7 fetch\u2014\u2014\u95E8\u7981\u4E0E\u7EBF\u4E0A\u4E00\u81F4\uFF08\u767D\u540D\u5355 / \u8D85\u65F6 / \u91CD\u5B9A\u5411\u9010\u8DF3\u590D\u68C0\uFF09\uFF0C\u4F46\u672C\u5730\u7531\u5F00\u53D1\u673A\u7F51\u7EDC\u6808\u76F4\u8FDE\uFF0C\u65E0\u5E73\u53F0\u51FA\u7F51\u4E2D\u7EE7\u4E0E\u5BA1\u8BA1\u3002"
|
|
4379
4413
|
}
|
|
4380
4414
|
];
|
|
4381
4415
|
}
|
|
@@ -6198,9 +6232,18 @@ async function startDevServer(options) {
|
|
|
6198
6232
|
...options.dbFile === void 0 ? {} : { dbFile: options.dbFile }
|
|
6199
6233
|
});
|
|
6200
6234
|
const bearerUser = bearerUserResolverFromEnv();
|
|
6235
|
+
const simEnv = await loadSimEnv(cwd).catch(() => ({}));
|
|
6236
|
+
const fetchConfig = resolveLocalFetchConfig(simEnv);
|
|
6201
6237
|
const executor = new WorkerFunctionExecutor({
|
|
6202
|
-
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS }
|
|
6238
|
+
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS },
|
|
6239
|
+
// GAME-007 本地接线:配置白名单才注入受控 fetch,语义与线上逐字一致。
|
|
6240
|
+
...fetchConfig === void 0 ? {} : { fetch: fetchConfig }
|
|
6203
6241
|
});
|
|
6242
|
+
if (fetchConfig !== void 0) {
|
|
6243
|
+
log(
|
|
6244
|
+
`[adep] \u53D7\u63A7 fetch \u5DF2\u6CE8\u5165\uFF08FUNCTIONS_FETCH_ALLOWLIST\uFF09\uFF1A\u767D\u540D\u5355 ${fetchConfig.allowlist.length} \u9879\uFF0C\u8D85\u65F6 ${fetchConfig.timeoutMs}ms`
|
|
6245
|
+
);
|
|
6246
|
+
}
|
|
6204
6247
|
await mkdir6(functionsDir, { recursive: true });
|
|
6205
6248
|
const db = await openLocalDbDriver(dbTarget, { cwd, tag: "adep", log });
|
|
6206
6249
|
const runtime = await createSimRuntime({
|
|
@@ -6223,7 +6266,7 @@ async function startDevServer(options) {
|
|
|
6223
6266
|
let files = mergeSharedIntoFunctions(await collectFunctions(functionsDir));
|
|
6224
6267
|
let env = {
|
|
6225
6268
|
...config2.environment,
|
|
6226
|
-
...
|
|
6269
|
+
...simEnv
|
|
6227
6270
|
};
|
|
6228
6271
|
const dbBundle = runtime.bundle;
|
|
6229
6272
|
const invokeHandler = createSimInvokeHandler({ executor, files });
|
|
@@ -6496,6 +6539,7 @@ var init_dev = __esm({
|
|
|
6496
6539
|
init_runtime();
|
|
6497
6540
|
init_db_mode();
|
|
6498
6541
|
init_env();
|
|
6542
|
+
init_fetch_config();
|
|
6499
6543
|
init_invoke();
|
|
6500
6544
|
init_builtin_deps2();
|
|
6501
6545
|
init_boundary();
|
|
@@ -6549,6 +6593,75 @@ var init_prompt = __esm({
|
|
|
6549
6593
|
}
|
|
6550
6594
|
});
|
|
6551
6595
|
|
|
6596
|
+
// packages/cli/src/export/client.ts
|
|
6597
|
+
var client_exports2 = {};
|
|
6598
|
+
__export(client_exports2, {
|
|
6599
|
+
createExportApiClient: () => createExportApiClient
|
|
6600
|
+
});
|
|
6601
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
6602
|
+
function toExportJob(view) {
|
|
6603
|
+
return {
|
|
6604
|
+
id: view.id,
|
|
6605
|
+
status: view.status,
|
|
6606
|
+
progress: view.progress,
|
|
6607
|
+
createdAt: view.createdAt,
|
|
6608
|
+
...view.stage === void 0 ? {} : { stage: view.stage },
|
|
6609
|
+
...view.error === void 0 ? {} : { error: view.error },
|
|
6610
|
+
...view.downloadUrl === void 0 ? {} : { downloadUrl: view.downloadUrl },
|
|
6611
|
+
...view.bundleSize === void 0 ? {} : { bundleSize: view.bundleSize },
|
|
6612
|
+
...view.completedAt === void 0 ? {} : { completedAt: view.completedAt }
|
|
6613
|
+
};
|
|
6614
|
+
}
|
|
6615
|
+
async function createExportApiClient(paths) {
|
|
6616
|
+
const client = await createClient(paths);
|
|
6617
|
+
return {
|
|
6618
|
+
async triggerExport(projectId, options) {
|
|
6619
|
+
const view = await client.request(
|
|
6620
|
+
`/api/v1/projects/${encodeURIComponent(projectId)}/export`,
|
|
6621
|
+
{
|
|
6622
|
+
method: "POST",
|
|
6623
|
+
body: {
|
|
6624
|
+
withData: options.withData,
|
|
6625
|
+
withSource: options.withSource,
|
|
6626
|
+
...options.withoutSource === true ? { withoutSource: true } : {}
|
|
6627
|
+
}
|
|
6628
|
+
},
|
|
6629
|
+
"EXPORT_TRIGGER_FAILED"
|
|
6630
|
+
);
|
|
6631
|
+
return toExportJob(view);
|
|
6632
|
+
},
|
|
6633
|
+
async getJobStatus(jobId) {
|
|
6634
|
+
const view = await client.request(
|
|
6635
|
+
`/api/v1/exports/${encodeURIComponent(jobId)}`,
|
|
6636
|
+
{},
|
|
6637
|
+
"EXPORT_STATUS_FAILED"
|
|
6638
|
+
);
|
|
6639
|
+
return toExportJob(view);
|
|
6640
|
+
},
|
|
6641
|
+
async downloadBundle(jobId, outputPath) {
|
|
6642
|
+
const download = await client.request(
|
|
6643
|
+
`/api/v1/exports/${encodeURIComponent(jobId)}/download`,
|
|
6644
|
+
{},
|
|
6645
|
+
"EXPORT_DOWNLOAD_FAILED"
|
|
6646
|
+
);
|
|
6647
|
+
if (download.downloadUrl.length === 0) {
|
|
6648
|
+
throw new CliError("EXPORT_BUNDLE_UNAVAILABLE", "\u5BFC\u51FA\u4EA7\u7269\u4E0B\u8F7D URL \u4E3A\u7A7A\uFF0C\u4EA7\u7269\u53EF\u80FD\u5C1A\u4E0D\u53EF\u7528");
|
|
6649
|
+
}
|
|
6650
|
+
const response = await client.download(download.downloadUrl, "EXPORT_DOWNLOAD_FAILED");
|
|
6651
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
6652
|
+
await writeFile7(outputPath, bytes);
|
|
6653
|
+
return { path: outputPath, size: bytes.length };
|
|
6654
|
+
}
|
|
6655
|
+
};
|
|
6656
|
+
}
|
|
6657
|
+
var init_client2 = __esm({
|
|
6658
|
+
"packages/cli/src/export/client.ts"() {
|
|
6659
|
+
"use strict";
|
|
6660
|
+
init_auth();
|
|
6661
|
+
init_client();
|
|
6662
|
+
}
|
|
6663
|
+
});
|
|
6664
|
+
|
|
6552
6665
|
// shared/deploy-bundle/manifest.ts
|
|
6553
6666
|
var CURRENT_SCHEMA_VERSION, BundleContentKind, ALLOWED_CONTENT_KINDS;
|
|
6554
6667
|
var init_manifest2 = __esm({
|
|
@@ -6892,75 +7005,6 @@ var init_zip = __esm({
|
|
|
6892
7005
|
}
|
|
6893
7006
|
});
|
|
6894
7007
|
|
|
6895
|
-
// packages/cli/src/export/client.ts
|
|
6896
|
-
var client_exports2 = {};
|
|
6897
|
-
__export(client_exports2, {
|
|
6898
|
-
createExportApiClient: () => createExportApiClient
|
|
6899
|
-
});
|
|
6900
|
-
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
6901
|
-
function toExportJob(view) {
|
|
6902
|
-
return {
|
|
6903
|
-
id: view.id,
|
|
6904
|
-
status: view.status,
|
|
6905
|
-
progress: view.progress,
|
|
6906
|
-
createdAt: view.createdAt,
|
|
6907
|
-
...view.stage === void 0 ? {} : { stage: view.stage },
|
|
6908
|
-
...view.error === void 0 ? {} : { error: view.error },
|
|
6909
|
-
...view.downloadUrl === void 0 ? {} : { downloadUrl: view.downloadUrl },
|
|
6910
|
-
...view.bundleSize === void 0 ? {} : { bundleSize: view.bundleSize },
|
|
6911
|
-
...view.completedAt === void 0 ? {} : { completedAt: view.completedAt }
|
|
6912
|
-
};
|
|
6913
|
-
}
|
|
6914
|
-
async function createExportApiClient(paths) {
|
|
6915
|
-
const client = await createClient(paths);
|
|
6916
|
-
return {
|
|
6917
|
-
async triggerExport(projectId, options) {
|
|
6918
|
-
const view = await client.request(
|
|
6919
|
-
`/api/v1/projects/${encodeURIComponent(projectId)}/export`,
|
|
6920
|
-
{
|
|
6921
|
-
method: "POST",
|
|
6922
|
-
body: {
|
|
6923
|
-
withData: options.withData,
|
|
6924
|
-
withSource: options.withSource,
|
|
6925
|
-
...options.withoutSource === true ? { withoutSource: true } : {}
|
|
6926
|
-
}
|
|
6927
|
-
},
|
|
6928
|
-
"EXPORT_TRIGGER_FAILED"
|
|
6929
|
-
);
|
|
6930
|
-
return toExportJob(view);
|
|
6931
|
-
},
|
|
6932
|
-
async getJobStatus(jobId) {
|
|
6933
|
-
const view = await client.request(
|
|
6934
|
-
`/api/v1/exports/${encodeURIComponent(jobId)}`,
|
|
6935
|
-
{},
|
|
6936
|
-
"EXPORT_STATUS_FAILED"
|
|
6937
|
-
);
|
|
6938
|
-
return toExportJob(view);
|
|
6939
|
-
},
|
|
6940
|
-
async downloadBundle(jobId, outputPath) {
|
|
6941
|
-
const download = await client.request(
|
|
6942
|
-
`/api/v1/exports/${encodeURIComponent(jobId)}/download`,
|
|
6943
|
-
{},
|
|
6944
|
-
"EXPORT_DOWNLOAD_FAILED"
|
|
6945
|
-
);
|
|
6946
|
-
if (download.downloadUrl.length === 0) {
|
|
6947
|
-
throw new CliError("EXPORT_BUNDLE_UNAVAILABLE", "\u5BFC\u51FA\u4EA7\u7269\u4E0B\u8F7D URL \u4E3A\u7A7A\uFF0C\u4EA7\u7269\u53EF\u80FD\u5C1A\u4E0D\u53EF\u7528");
|
|
6948
|
-
}
|
|
6949
|
-
const response = await client.download(download.downloadUrl, "EXPORT_DOWNLOAD_FAILED");
|
|
6950
|
-
const bytes = Buffer.from(await response.arrayBuffer());
|
|
6951
|
-
await writeFile7(outputPath, bytes);
|
|
6952
|
-
return { path: outputPath, size: bytes.length };
|
|
6953
|
-
}
|
|
6954
|
-
};
|
|
6955
|
-
}
|
|
6956
|
-
var init_client2 = __esm({
|
|
6957
|
-
"packages/cli/src/export/client.ts"() {
|
|
6958
|
-
"use strict";
|
|
6959
|
-
init_auth();
|
|
6960
|
-
init_client();
|
|
6961
|
-
}
|
|
6962
|
-
});
|
|
6963
|
-
|
|
6964
7008
|
// packages/cli/src/serve/banner.ts
|
|
6965
7009
|
function isLoopback(host) {
|
|
6966
7010
|
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]";
|
|
@@ -7155,8 +7199,8 @@ var init_template_params = __esm({
|
|
|
7155
7199
|
});
|
|
7156
7200
|
|
|
7157
7201
|
// packages/cli/src/serve/template-params.ts
|
|
7158
|
-
import { readFile as
|
|
7159
|
-
import { join as
|
|
7202
|
+
import { readFile as readFile20 } from "node:fs/promises";
|
|
7203
|
+
import { join as join27 } from "node:path";
|
|
7160
7204
|
import { parse as parse3 } from "yaml";
|
|
7161
7205
|
function mergeTemplateEnvSource(source) {
|
|
7162
7206
|
return { ...source.processEnv, ...source.dotenv, ...source.dotenvLocal };
|
|
@@ -7164,7 +7208,7 @@ function mergeTemplateEnvSource(source) {
|
|
|
7164
7208
|
async function loadTemplateFields(cwd) {
|
|
7165
7209
|
let text;
|
|
7166
7210
|
try {
|
|
7167
|
-
text = await
|
|
7211
|
+
text = await readFile20(join27(cwd, TEMPLATE_PARAMS_FILE), "utf8");
|
|
7168
7212
|
} catch {
|
|
7169
7213
|
return null;
|
|
7170
7214
|
}
|
|
@@ -7180,7 +7224,7 @@ async function loadTemplateFields(cwd) {
|
|
|
7180
7224
|
return extractTemplateFields(root);
|
|
7181
7225
|
}
|
|
7182
7226
|
async function readDotenvFile(cwd, name) {
|
|
7183
|
-
const text = await
|
|
7227
|
+
const text = await readFile20(join27(cwd, name), "utf8").catch(() => "");
|
|
7184
7228
|
if (text === "") return {};
|
|
7185
7229
|
return parseEnvFile(text);
|
|
7186
7230
|
}
|
|
@@ -7235,8 +7279,8 @@ __export(server_exports, {
|
|
|
7235
7279
|
});
|
|
7236
7280
|
import { createServer as createServer2 } from "node:http";
|
|
7237
7281
|
import { watch as watch2 } from "node:fs";
|
|
7238
|
-
import { mkdir as
|
|
7239
|
-
import { extname, join as
|
|
7282
|
+
import { mkdir as mkdir14, readFile as readFile21, stat as stat12 } from "node:fs/promises";
|
|
7283
|
+
import { extname, join as join28, relative as relative4, resolve as resolve12 } from "node:path";
|
|
7240
7284
|
function envNumber(name) {
|
|
7241
7285
|
const raw = process.env[name];
|
|
7242
7286
|
if (raw === void 0 || raw.trim() === "") return void 0;
|
|
@@ -7269,7 +7313,7 @@ async function startServeServer(options) {
|
|
|
7269
7313
|
...options.dbFile === void 0 ? {} : { dbFile: options.dbFile }
|
|
7270
7314
|
});
|
|
7271
7315
|
const config2 = await loadConfig(cwd);
|
|
7272
|
-
const functionsDir =
|
|
7316
|
+
const functionsDir = join28(cwd, config2.functionsDir);
|
|
7273
7317
|
const bearerUser = bearerUserResolverFromEnv();
|
|
7274
7318
|
let hasStatic = false;
|
|
7275
7319
|
try {
|
|
@@ -7281,7 +7325,7 @@ async function startServeServer(options) {
|
|
|
7281
7325
|
const loadFunctionFiles = async () => mergeSharedIntoFunctions(await collectFunctions(functionsDir));
|
|
7282
7326
|
let files = await loadFunctionFiles();
|
|
7283
7327
|
let functionNames = listFunctionNames(files);
|
|
7284
|
-
const envText = await
|
|
7328
|
+
const envText = await readFile21(join28(cwd, ".env.local"), "utf8").catch(() => "");
|
|
7285
7329
|
let env = parseEnvFile(envText);
|
|
7286
7330
|
let simEnv = await loadSimEnv(cwd).catch(() => ({}));
|
|
7287
7331
|
const dotenvFile = await readDotenvFile(cwd, ".env");
|
|
@@ -7322,9 +7366,16 @@ async function startServeServer(options) {
|
|
|
7322
7366
|
log
|
|
7323
7367
|
});
|
|
7324
7368
|
}
|
|
7369
|
+
const fetchConfig = resolveLocalFetchConfig(simEnv);
|
|
7325
7370
|
const executor = new WorkerFunctionExecutor({
|
|
7326
|
-
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS }
|
|
7371
|
+
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS },
|
|
7372
|
+
...fetchConfig === void 0 ? {} : { fetch: fetchConfig }
|
|
7327
7373
|
});
|
|
7374
|
+
if (fetchConfig !== void 0) {
|
|
7375
|
+
log(
|
|
7376
|
+
`[adep] \u53D7\u63A7 fetch \u5DF2\u6CE8\u5165\uFF08FUNCTIONS_FETCH_ALLOWLIST\uFF09\uFF1A\u767D\u540D\u5355 ${fetchConfig.allowlist.length} \u9879\uFF0C\u8D85\u65F6 ${fetchConfig.timeoutMs}ms`
|
|
7377
|
+
);
|
|
7378
|
+
}
|
|
7328
7379
|
const dbBundle = runtime.bundle;
|
|
7329
7380
|
let invokeHandler = createSimInvokeHandler({ executor, files });
|
|
7330
7381
|
let stopWatch;
|
|
@@ -7332,7 +7383,7 @@ async function startServeServer(options) {
|
|
|
7332
7383
|
const reload = async () => {
|
|
7333
7384
|
const [nextFiles, envLocalText] = await Promise.all([
|
|
7334
7385
|
loadFunctionFiles(),
|
|
7335
|
-
|
|
7386
|
+
readFile21(join28(cwd, ".env.local"), "utf8").catch(() => "")
|
|
7336
7387
|
]);
|
|
7337
7388
|
files = nextFiles;
|
|
7338
7389
|
env = parseEnvFile(envLocalText);
|
|
@@ -7349,7 +7400,7 @@ async function startServeServer(options) {
|
|
|
7349
7400
|
void reload();
|
|
7350
7401
|
}, 120);
|
|
7351
7402
|
};
|
|
7352
|
-
await
|
|
7403
|
+
await mkdir14(functionsDir, { recursive: true }).catch(() => void 0);
|
|
7353
7404
|
try {
|
|
7354
7405
|
watchers.push(watch2(functionsDir, { recursive: true }, scheduleReload));
|
|
7355
7406
|
} catch {
|
|
@@ -7404,31 +7455,31 @@ async function startServeServer(options) {
|
|
|
7404
7455
|
const serveStatic = async (pathname, res) => {
|
|
7405
7456
|
if (!hasStatic) return false;
|
|
7406
7457
|
const safePath = pathname.replace(/\.\.\//g, "").replace(/^\//, "");
|
|
7407
|
-
const filePath =
|
|
7408
|
-
const resolvedPath = safePath === "" || safePath === "/" ?
|
|
7458
|
+
const filePath = join28(staticDir, safePath);
|
|
7459
|
+
const resolvedPath = safePath === "" || safePath === "/" ? join28(filePath, "index.html") : filePath;
|
|
7409
7460
|
try {
|
|
7410
7461
|
const fileStat = await stat12(resolvedPath);
|
|
7411
7462
|
if (fileStat.isDirectory()) {
|
|
7412
|
-
const indexPath =
|
|
7463
|
+
const indexPath = join28(resolvedPath, "index.html");
|
|
7413
7464
|
try {
|
|
7414
7465
|
const indexStat = await stat12(indexPath);
|
|
7415
7466
|
if (indexStat.isFile()) {
|
|
7416
|
-
sendStaticFile(res, indexPath, await
|
|
7467
|
+
sendStaticFile(res, indexPath, await readFile21(indexPath));
|
|
7417
7468
|
return true;
|
|
7418
7469
|
}
|
|
7419
7470
|
} catch {
|
|
7420
7471
|
}
|
|
7421
7472
|
return false;
|
|
7422
7473
|
}
|
|
7423
|
-
sendStaticFile(res, resolvedPath, await
|
|
7474
|
+
sendStaticFile(res, resolvedPath, await readFile21(resolvedPath));
|
|
7424
7475
|
return true;
|
|
7425
7476
|
} catch {
|
|
7426
7477
|
if (options.spaFallback === true) {
|
|
7427
7478
|
const ext = extname(pathname);
|
|
7428
7479
|
if (ext === "" || ext === ".html") {
|
|
7429
7480
|
try {
|
|
7430
|
-
const indexContent = await
|
|
7431
|
-
sendStaticFile(res,
|
|
7481
|
+
const indexContent = await readFile21(join28(staticDir, "index.html"));
|
|
7482
|
+
sendStaticFile(res, join28(staticDir, "index.html"), indexContent);
|
|
7432
7483
|
return true;
|
|
7433
7484
|
} catch {
|
|
7434
7485
|
}
|
|
@@ -7656,6 +7707,7 @@ var init_server = __esm({
|
|
|
7656
7707
|
init_runtime();
|
|
7657
7708
|
init_storage();
|
|
7658
7709
|
init_env();
|
|
7710
|
+
init_fetch_config();
|
|
7659
7711
|
init_invoke();
|
|
7660
7712
|
init_dev();
|
|
7661
7713
|
init_banner();
|
|
@@ -7697,8 +7749,8 @@ __export(deploy_exports, {
|
|
|
7697
7749
|
deploy: () => deploy
|
|
7698
7750
|
});
|
|
7699
7751
|
import { createHash as createHash4 } from "node:crypto";
|
|
7700
|
-
import { readdir as
|
|
7701
|
-
import { join as
|
|
7752
|
+
import { readdir as readdir9, readFile as readFile22 } from "node:fs/promises";
|
|
7753
|
+
import { join as join29, resolve as resolve13, basename as basename4, relative as relative5, sep } from "node:path";
|
|
7702
7754
|
function functionUrlBase(prefix) {
|
|
7703
7755
|
const raw = (prefix ?? "/api").trim();
|
|
7704
7756
|
const normalized = raw === "/" ? "/" : raw.replace(/\/+$/, "");
|
|
@@ -7710,7 +7762,7 @@ function isRuntimeSource2(name) {
|
|
|
7710
7762
|
async function collectFunctionFiles(functionsDir) {
|
|
7711
7763
|
let dirents;
|
|
7712
7764
|
try {
|
|
7713
|
-
dirents = await
|
|
7765
|
+
dirents = await readdir9(functionsDir, { withFileTypes: true });
|
|
7714
7766
|
} catch {
|
|
7715
7767
|
return {};
|
|
7716
7768
|
}
|
|
@@ -7724,10 +7776,10 @@ async function collectFunctionFiles(functionsDir) {
|
|
|
7724
7776
|
if (conflicting.length > 0) throw new AmbiguousFunctionError(functionsDir, conflicting);
|
|
7725
7777
|
const out = {};
|
|
7726
7778
|
for (const name of flatNames) {
|
|
7727
|
-
out[name] = { [`${name}.ts`]: await
|
|
7779
|
+
out[name] = { [`${name}.ts`]: await readFile22(join29(functionsDir, `${name}.ts`), "utf8") };
|
|
7728
7780
|
}
|
|
7729
7781
|
for (const name of dirNames) {
|
|
7730
|
-
const files = await collectFunctionDir(
|
|
7782
|
+
const files = await collectFunctionDir(join29(functionsDir, name));
|
|
7731
7783
|
if (files["index.ts"] === void 0) continue;
|
|
7732
7784
|
out[name] = files;
|
|
7733
7785
|
}
|
|
@@ -7738,7 +7790,7 @@ async function collectFunctionDir(absDir) {
|
|
|
7738
7790
|
const walk = async (dir, prefix) => {
|
|
7739
7791
|
let entries;
|
|
7740
7792
|
try {
|
|
7741
|
-
entries = await
|
|
7793
|
+
entries = await readdir9(dir, { withFileTypes: true });
|
|
7742
7794
|
} catch {
|
|
7743
7795
|
return;
|
|
7744
7796
|
}
|
|
@@ -7746,11 +7798,11 @@ async function collectFunctionDir(absDir) {
|
|
|
7746
7798
|
const rel = prefix === "" ? entry.name : `${prefix}/${entry.name}`;
|
|
7747
7799
|
if (entry.isDirectory()) {
|
|
7748
7800
|
if (entry.name === "__tests__" || IGNORED_DIRS.has(entry.name)) continue;
|
|
7749
|
-
await walk(
|
|
7801
|
+
await walk(join29(dir, entry.name), rel);
|
|
7750
7802
|
continue;
|
|
7751
7803
|
}
|
|
7752
7804
|
if (!isRuntimeSource2(entry.name)) continue;
|
|
7753
|
-
files[rel] = await
|
|
7805
|
+
files[rel] = await readFile22(join29(dir, entry.name), "utf8");
|
|
7754
7806
|
}
|
|
7755
7807
|
};
|
|
7756
7808
|
await walk(absDir, "");
|
|
@@ -7760,25 +7812,25 @@ function sha256Hex(content) {
|
|
|
7760
7812
|
return createHash4("sha256").update(content).digest("hex");
|
|
7761
7813
|
}
|
|
7762
7814
|
async function collectShared(functionsDir) {
|
|
7763
|
-
const sharedDir =
|
|
7815
|
+
const sharedDir = join29(functionsDir, FUNCTION_SHARED_DIR);
|
|
7764
7816
|
const files = {};
|
|
7765
7817
|
const walk = async (dir) => {
|
|
7766
7818
|
let entries;
|
|
7767
7819
|
try {
|
|
7768
|
-
entries = await
|
|
7820
|
+
entries = await readdir9(dir, { withFileTypes: true });
|
|
7769
7821
|
} catch {
|
|
7770
7822
|
return;
|
|
7771
7823
|
}
|
|
7772
7824
|
for (const entry of entries) {
|
|
7773
7825
|
if (entry.isDirectory()) {
|
|
7774
7826
|
if (entry.name === "__tests__" || entry.name === "node_modules") continue;
|
|
7775
|
-
await walk(
|
|
7827
|
+
await walk(join29(dir, entry.name));
|
|
7776
7828
|
continue;
|
|
7777
7829
|
}
|
|
7778
7830
|
if (!isRuntimeSource2(entry.name)) continue;
|
|
7779
|
-
const full =
|
|
7831
|
+
const full = join29(dir, entry.name);
|
|
7780
7832
|
const rel = relative5(sharedDir, full).split(sep).join("/");
|
|
7781
|
-
files[`${SHARED_SOURCE_ROOT}${rel}`] = await
|
|
7833
|
+
files[`${SHARED_SOURCE_ROOT}${rel}`] = await readFile22(full, "utf8");
|
|
7782
7834
|
}
|
|
7783
7835
|
};
|
|
7784
7836
|
await walk(sharedDir);
|
|
@@ -7790,7 +7842,7 @@ async function deploy(paths, options) {
|
|
|
7790
7842
|
const cwd = resolve13(options.cwd);
|
|
7791
7843
|
const config2 = await loadConfig(cwd);
|
|
7792
7844
|
const slug = options.slug ?? config2.name;
|
|
7793
|
-
const functionsDir = options.functionsDir === void 0 ?
|
|
7845
|
+
const functionsDir = options.functionsDir === void 0 ? join29(cwd, config2.functionsDir) : resolve13(cwd, options.functionsDir);
|
|
7794
7846
|
const local = await collectFunctionFiles(functionsDir);
|
|
7795
7847
|
if (Object.keys(local).length === 0) {
|
|
7796
7848
|
throw new CliError("NO_FUNCTIONS", `${functionsDir} \u4E0B\u6CA1\u6709\u51FD\u6570\u6587\u4EF6`);
|
|
@@ -7921,8 +7973,8 @@ __export(storage_exports, {
|
|
|
7921
7973
|
storageRemove: () => storageRemove,
|
|
7922
7974
|
storageUpload: () => storageUpload
|
|
7923
7975
|
});
|
|
7924
|
-
import { mkdir as
|
|
7925
|
-
import { basename as basename5, dirname as dirname13, extname as extname2, join as
|
|
7976
|
+
import { mkdir as mkdir15, readFile as readFile23, stat as stat13, writeFile as writeFile14 } from "node:fs/promises";
|
|
7977
|
+
import { basename as basename5, dirname as dirname13, extname as extname2, join as join30, resolve as resolve14 } from "node:path";
|
|
7926
7978
|
function envQuery2(options) {
|
|
7927
7979
|
return options.environment === void 0 ? "" : `?environment=${options.environment}`;
|
|
7928
7980
|
}
|
|
@@ -7967,7 +8019,7 @@ async function storageUpload(paths, options) {
|
|
|
7967
8019
|
throw new CliError("FILE_NOT_FOUND", `\u672C\u5730\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${local}`);
|
|
7968
8020
|
}
|
|
7969
8021
|
const visibility = options.visibility ?? "private";
|
|
7970
|
-
const bytes = await
|
|
8022
|
+
const bytes = await readFile23(local);
|
|
7971
8023
|
const form = new FormData();
|
|
7972
8024
|
form.set("path", options.path);
|
|
7973
8025
|
form.set("visibility", visibility);
|
|
@@ -8014,9 +8066,9 @@ async function storageDownload(paths, options) {
|
|
|
8014
8066
|
const url2 = await resolveDownloadUrl(client, project2, options.path, options.environment);
|
|
8015
8067
|
const response = await client.download(url2, "STORAGE_DOWNLOAD_FAILED");
|
|
8016
8068
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
8017
|
-
const output2 = resolve14(options.output ??
|
|
8018
|
-
await
|
|
8019
|
-
await
|
|
8069
|
+
const output2 = resolve14(options.output ?? join30(resolve14(options.cwd), basename5(options.path)));
|
|
8070
|
+
await mkdir15(dirname13(output2), { recursive: true });
|
|
8071
|
+
await writeFile14(output2, bytes);
|
|
8020
8072
|
return { path: options.path, output: output2, size: bytes.length };
|
|
8021
8073
|
}
|
|
8022
8074
|
async function storageRemove(paths, options) {
|
|
@@ -8042,8 +8094,8 @@ __export(hosting_exports, {
|
|
|
8042
8094
|
hostingInfo: () => hostingInfo,
|
|
8043
8095
|
hostingPull: () => hostingPull
|
|
8044
8096
|
});
|
|
8045
|
-
import { readdir as
|
|
8046
|
-
import { dirname as dirname14, join as
|
|
8097
|
+
import { readdir as readdir10, readFile as readFile24, stat as stat14 } from "node:fs/promises";
|
|
8098
|
+
import { dirname as dirname14, join as join31, relative as relative6, resolve as resolve15, sep as sep2 } from "node:path";
|
|
8047
8099
|
async function open5(paths, options) {
|
|
8048
8100
|
const client = await createClient(paths);
|
|
8049
8101
|
const project2 = await resolveSlug(resolve15(options.cwd), options.slug);
|
|
@@ -8064,12 +8116,12 @@ async function collectSiteFiles(dir) {
|
|
|
8064
8116
|
const walk = async (sub) => {
|
|
8065
8117
|
let entries;
|
|
8066
8118
|
try {
|
|
8067
|
-
entries = await
|
|
8119
|
+
entries = await readdir10(sub, { withFileTypes: true });
|
|
8068
8120
|
} catch {
|
|
8069
8121
|
return;
|
|
8070
8122
|
}
|
|
8071
8123
|
for (const entry of entries) {
|
|
8072
|
-
const full =
|
|
8124
|
+
const full = join31(sub, entry.name);
|
|
8073
8125
|
if (entry.isDirectory()) {
|
|
8074
8126
|
await walk(full);
|
|
8075
8127
|
} else if (entry.isFile()) {
|
|
@@ -8093,7 +8145,7 @@ async function hostingDeploy(paths, options) {
|
|
|
8093
8145
|
for (const [rel, full] of files) {
|
|
8094
8146
|
log(`[adep] \u4E0A\u4F20 site/${rel}`);
|
|
8095
8147
|
const info2 = await stat14(full);
|
|
8096
|
-
const bytes = await
|
|
8148
|
+
const bytes = await readFile24(full);
|
|
8097
8149
|
const form = new FormData();
|
|
8098
8150
|
form.set("path", `site/${rel}`);
|
|
8099
8151
|
form.set("visibility", "public");
|
|
@@ -8121,7 +8173,7 @@ async function hostingPull(paths, options) {
|
|
|
8121
8173
|
`));
|
|
8122
8174
|
const info = await hostingInfo(paths, options);
|
|
8123
8175
|
const outputDir = resolve15(options.output ?? resolve15(options.cwd));
|
|
8124
|
-
const { mkdir:
|
|
8176
|
+
const { mkdir: mkdir17, writeFile: writeFile16 } = await import("node:fs/promises");
|
|
8125
8177
|
const files = [];
|
|
8126
8178
|
for (const entry of info.files) {
|
|
8127
8179
|
if (entry.visibility !== "public" || entry.path === HOSTING_CONFIG_PATH) continue;
|
|
@@ -8131,9 +8183,9 @@ async function hostingPull(paths, options) {
|
|
|
8131
8183
|
const response = await client.download(url2, "HOSTING_DOWNLOAD_FAILED");
|
|
8132
8184
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
8133
8185
|
const rel = entry.path.replace(/^site\//, "");
|
|
8134
|
-
const target =
|
|
8135
|
-
await
|
|
8136
|
-
await
|
|
8186
|
+
const target = join31(outputDir, ...rel.split("/"));
|
|
8187
|
+
await mkdir17(dirname14(target), { recursive: true });
|
|
8188
|
+
await writeFile16(target, bytes);
|
|
8137
8189
|
files.push({ path: entry.path, size: bytes.length });
|
|
8138
8190
|
}
|
|
8139
8191
|
return { siteUrl: info.siteUrl, outputDir, files };
|
|
@@ -8187,22 +8239,22 @@ __export(frontend_exports, {
|
|
|
8187
8239
|
frontendSync: () => frontendSync,
|
|
8188
8240
|
isStaticFrontendDir: () => isStaticFrontendDir
|
|
8189
8241
|
});
|
|
8190
|
-
import { readdir as
|
|
8191
|
-
import { join as
|
|
8242
|
+
import { readdir as readdir11, readFile as readFile25, stat as stat15 } from "node:fs/promises";
|
|
8243
|
+
import { join as join32, relative as relative7, sep as sep3 } from "node:path";
|
|
8192
8244
|
async function collectFiles(root, dir) {
|
|
8193
8245
|
const files = /* @__PURE__ */ new Map();
|
|
8194
8246
|
const skipped = [];
|
|
8195
|
-
const entries = await
|
|
8247
|
+
const entries = await readdir11(dir, { withFileTypes: true });
|
|
8196
8248
|
for (const entry of entries) {
|
|
8197
8249
|
if (entry.isDirectory()) {
|
|
8198
8250
|
if (IGNORED_DIRS2.has(entry.name)) continue;
|
|
8199
|
-
const nested = await collectFiles(root,
|
|
8251
|
+
const nested = await collectFiles(root, join32(dir, entry.name));
|
|
8200
8252
|
for (const [path, content] of nested.files) files.set(path, content);
|
|
8201
8253
|
skipped.push(...nested.skipped);
|
|
8202
8254
|
continue;
|
|
8203
8255
|
}
|
|
8204
8256
|
if (IGNORED_FILES.has(entry.name)) continue;
|
|
8205
|
-
const full =
|
|
8257
|
+
const full = join32(dir, entry.name);
|
|
8206
8258
|
const rel = relative7(root, full).split(sep3).join("/");
|
|
8207
8259
|
const info = await stat15(full);
|
|
8208
8260
|
if (info.size > 1024 * 1024) {
|
|
@@ -8210,7 +8262,7 @@ async function collectFiles(root, dir) {
|
|
|
8210
8262
|
continue;
|
|
8211
8263
|
}
|
|
8212
8264
|
try {
|
|
8213
|
-
const content = await
|
|
8265
|
+
const content = await readFile25(full, "utf8");
|
|
8214
8266
|
if (content.includes("\0")) {
|
|
8215
8267
|
skipped.push(rel);
|
|
8216
8268
|
continue;
|
|
@@ -8225,7 +8277,7 @@ async function collectFiles(root, dir) {
|
|
|
8225
8277
|
async function frontendSync(paths, options) {
|
|
8226
8278
|
const log = options.silent === true ? () => void 0 : options.log ?? ((line) => process.stdout.write(`${line}
|
|
8227
8279
|
`));
|
|
8228
|
-
const webDir = options.dir ??
|
|
8280
|
+
const webDir = options.dir ?? join32(options.cwd, "web");
|
|
8229
8281
|
const rootStat = await stat15(webDir).catch(() => null);
|
|
8230
8282
|
if (rootStat === null || !rootStat.isDirectory()) {
|
|
8231
8283
|
throw new CliError(
|
|
@@ -8285,14 +8337,14 @@ function declaresBuildScript(pkgJson) {
|
|
|
8285
8337
|
return typeof build === "string" && build.trim().length > 0;
|
|
8286
8338
|
}
|
|
8287
8339
|
async function isStaticFrontendDir(dir) {
|
|
8288
|
-
const pkg = await
|
|
8340
|
+
const pkg = await readFile25(join32(dir, "package.json"), "utf8").catch(() => void 0);
|
|
8289
8341
|
if (declaresBuildScript(pkg)) return false;
|
|
8290
8342
|
const walk = async (sub) => {
|
|
8291
|
-
const entries = await
|
|
8343
|
+
const entries = await readdir11(sub, { withFileTypes: true });
|
|
8292
8344
|
for (const entry of entries) {
|
|
8293
8345
|
if (entry.isDirectory()) {
|
|
8294
8346
|
if (IGNORED_DIRS2.has(entry.name)) continue;
|
|
8295
|
-
if (!await walk(
|
|
8347
|
+
if (!await walk(join32(sub, entry.name))) return false;
|
|
8296
8348
|
continue;
|
|
8297
8349
|
}
|
|
8298
8350
|
if (FRONTEND_TRANSFORM_EXTENSIONS.some((ext) => entry.name.endsWith(ext))) return false;
|
|
@@ -8328,12 +8380,12 @@ var fs_exports = {};
|
|
|
8328
8380
|
__export(fs_exports, {
|
|
8329
8381
|
createExportFileSystem: () => createExportFileSystem
|
|
8330
8382
|
});
|
|
8331
|
-
import { mkdir as
|
|
8332
|
-
import { dirname as dirname15, join as
|
|
8383
|
+
import { mkdir as mkdir16, readFile as readFile27, rm as rm5, stat as stat17, writeFile as writeFile15 } from "node:fs/promises";
|
|
8384
|
+
import { dirname as dirname15, join as join35 } from "node:path";
|
|
8333
8385
|
function createExportFileSystem() {
|
|
8334
8386
|
return {
|
|
8335
|
-
readFile: (path) =>
|
|
8336
|
-
writeFile: (path, content) =>
|
|
8387
|
+
readFile: (path) => readFile27(path),
|
|
8388
|
+
writeFile: (path, content) => writeFile15(path, content),
|
|
8337
8389
|
// 同时用于清理解压临时目录(${zip}.tmp 是个目录)——递归强制删除,缺失不报错。
|
|
8338
8390
|
deleteFile: async (path) => {
|
|
8339
8391
|
await rm5(path, { recursive: true, force: true });
|
|
@@ -8347,14 +8399,14 @@ function createExportFileSystem() {
|
|
|
8347
8399
|
}
|
|
8348
8400
|
},
|
|
8349
8401
|
mkdir: async (path) => {
|
|
8350
|
-
await
|
|
8402
|
+
await mkdir16(path, { recursive: true });
|
|
8351
8403
|
},
|
|
8352
8404
|
unzip: async (zipPath, targetDir) => {
|
|
8353
|
-
const entries = zipRead(await
|
|
8405
|
+
const entries = zipRead(await readFile27(zipPath));
|
|
8354
8406
|
for (const [name, data] of entries) {
|
|
8355
|
-
const dest =
|
|
8356
|
-
await
|
|
8357
|
-
await
|
|
8407
|
+
const dest = join35(targetDir, name);
|
|
8408
|
+
await mkdir16(dirname15(dest), { recursive: true });
|
|
8409
|
+
await writeFile15(dest, data);
|
|
8358
8410
|
}
|
|
8359
8411
|
}
|
|
8360
8412
|
};
|
|
@@ -8598,8 +8650,8 @@ ${detail}`);
|
|
|
8598
8650
|
});
|
|
8599
8651
|
|
|
8600
8652
|
// packages/cli/src/sandbox-scan.ts
|
|
8601
|
-
import { readdir as
|
|
8602
|
-
import { join as
|
|
8653
|
+
import { readdir as readdir13, readFile as readFile28 } from "node:fs/promises";
|
|
8654
|
+
import { join as join36, relative as relative9, sep as sep5 } from "node:path";
|
|
8603
8655
|
function extractSpecifiers(line) {
|
|
8604
8656
|
const out = [];
|
|
8605
8657
|
const patterns = [
|
|
@@ -8643,17 +8695,17 @@ function classify(specifier) {
|
|
|
8643
8695
|
return null;
|
|
8644
8696
|
}
|
|
8645
8697
|
async function scanFunctionSources(rootDir, functionsDir) {
|
|
8646
|
-
const base =
|
|
8698
|
+
const base = join36(rootDir, functionsDir);
|
|
8647
8699
|
const findings = [];
|
|
8648
8700
|
async function walk(current) {
|
|
8649
8701
|
let entries;
|
|
8650
8702
|
try {
|
|
8651
|
-
entries = await
|
|
8703
|
+
entries = await readdir13(current, { withFileTypes: true });
|
|
8652
8704
|
} catch {
|
|
8653
8705
|
return;
|
|
8654
8706
|
}
|
|
8655
8707
|
for (const entry of entries) {
|
|
8656
|
-
const abs =
|
|
8708
|
+
const abs = join36(current, entry.name);
|
|
8657
8709
|
if (entry.isDirectory()) {
|
|
8658
8710
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
8659
8711
|
await walk(abs);
|
|
@@ -8664,7 +8716,7 @@ async function scanFunctionSources(rootDir, functionsDir) {
|
|
|
8664
8716
|
if (entry.name.endsWith(".d.ts")) continue;
|
|
8665
8717
|
let content;
|
|
8666
8718
|
try {
|
|
8667
|
-
content = await
|
|
8719
|
+
content = await readFile28(abs, "utf8");
|
|
8668
8720
|
} catch {
|
|
8669
8721
|
continue;
|
|
8670
8722
|
}
|
|
@@ -13289,15 +13341,150 @@ function registerTemplates(program2, ctx) {
|
|
|
13289
13341
|
import { resolve as resolve10 } from "node:path";
|
|
13290
13342
|
|
|
13291
13343
|
// packages/cli/src/app-build.ts
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
import {
|
|
13297
|
-
import {
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
import {
|
|
13344
|
+
import { mkdir as mkdir11, writeFile as writeFile11 } from "node:fs/promises";
|
|
13345
|
+
import { join as join21, resolve as resolve8 } from "node:path";
|
|
13346
|
+
|
|
13347
|
+
// packages/cli/src/app-init.ts
|
|
13348
|
+
import { cp, mkdir as mkdir8, readdir as readdir5, stat as stat7, writeFile as writeFile6 } from "node:fs/promises";
|
|
13349
|
+
import { dirname as dirname9, join as join15, resolve as resolve7 } from "node:path";
|
|
13350
|
+
|
|
13351
|
+
// packages/cli/src/app-template.ts
|
|
13352
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
13353
|
+
import { readdir as readdir4, readFile as readFile11, stat as stat6 } from "node:fs/promises";
|
|
13354
|
+
import { dirname as dirname8, join as join14 } from "node:path";
|
|
13355
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
13356
|
+
var TEMPLATE_VAR_ALLOWLIST = {
|
|
13357
|
+
"app-desktop": /* @__PURE__ */ new Set(["projectSlug", "appName", "appId", "platformUrl"]),
|
|
13358
|
+
"app-mobile": /* @__PURE__ */ new Set([
|
|
13359
|
+
"projectSlug",
|
|
13360
|
+
"appName",
|
|
13361
|
+
"platformUrl",
|
|
13362
|
+
"iosBundleId",
|
|
13363
|
+
"androidPackageId"
|
|
13364
|
+
]),
|
|
13365
|
+
// xtool 只做 iOS ⇒ 没有 androidPackageId。少这一个变量是**刻意的**:
|
|
13366
|
+
// 模板里若写了它,渲染期会 fail loud(而不是渲染出一个没有 Android 目标的空值)。
|
|
13367
|
+
"app-mobile-xtool": /* @__PURE__ */ new Set(["projectSlug", "appName", "platformUrl", "iosBundleId"])
|
|
13368
|
+
};
|
|
13369
|
+
function shellTemplateForPlatform(platform) {
|
|
13370
|
+
return platform === "mobile" ? "app-mobile" : "app-desktop";
|
|
13371
|
+
}
|
|
13372
|
+
function normalizeToolchain(input2) {
|
|
13373
|
+
if (input2 === void 0 || input2.length === 0) return "capacitor";
|
|
13374
|
+
if (input2 === "capacitor" || input2 === "xtool") return input2;
|
|
13375
|
+
throw new InitError(
|
|
13376
|
+
"INVALID_TOOLCHAIN",
|
|
13377
|
+
`--toolchain \u987B\u4E3A capacitor | xtool\uFF0C\u6536\u5230 "${input2}"\uFF08\u7F3A\u7701 capacitor\uFF09`
|
|
13378
|
+
);
|
|
13379
|
+
}
|
|
13380
|
+
function shellTemplateFor(platform, toolchain) {
|
|
13381
|
+
if (toolchain === "xtool") {
|
|
13382
|
+
if (platform !== "mobile") {
|
|
13383
|
+
throw new InitError(
|
|
13384
|
+
"INVALID_TOOLCHAIN",
|
|
13385
|
+
`--toolchain xtool \u53EA\u652F\u6301 --platform mobile\uFF08xtool \u4EA7\u51FA iOS \u539F\u751F app\uFF09\uFF0C\u6536\u5230 --platform ${platform}`
|
|
13386
|
+
);
|
|
13387
|
+
}
|
|
13388
|
+
return "app-mobile-xtool";
|
|
13389
|
+
}
|
|
13390
|
+
return shellTemplateForPlatform(platform);
|
|
13391
|
+
}
|
|
13392
|
+
var XTOOL_SHELL_REUSED_FROM_MOBILE = [
|
|
13393
|
+
{ from: "plugins/adep-bridge", to: "plugins/adep-bridge" },
|
|
13394
|
+
{ from: "web/adep-bridge.js", to: "web/adep-bridge.js" },
|
|
13395
|
+
{ from: "web/offline-runtime.js", to: "web/offline-runtime.js" }
|
|
13396
|
+
];
|
|
13397
|
+
var TEMPLATE_MANIFEST_FILES = /* @__PURE__ */ new Set(["template.json"]);
|
|
13398
|
+
async function collectRelPaths(dir, base) {
|
|
13399
|
+
const entries = await readdir4(dir, { withFileTypes: true });
|
|
13400
|
+
const nested = await Promise.all(
|
|
13401
|
+
entries.filter((entry) => entry.name !== ".DS_Store" && !TEMPLATE_MANIFEST_FILES.has(entry.name)).toSorted((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((entry) => {
|
|
13402
|
+
const abs = join14(dir, entry.name);
|
|
13403
|
+
return entry.isDirectory() ? (
|
|
13404
|
+
// 递归时 base 必须带上子目录前缀,否则深层文件相对路径会丢目录段
|
|
13405
|
+
// (app-mobile 是嵌套目录结构:bridge/gate.mjs、plugins/adep-bridge/...)。
|
|
13406
|
+
collectRelPaths(abs, join14(base, entry.name))
|
|
13407
|
+
) : Promise.resolve([join14(base, entry.name).split("\\").join("/")]);
|
|
13408
|
+
})
|
|
13409
|
+
);
|
|
13410
|
+
return nested.flat();
|
|
13411
|
+
}
|
|
13412
|
+
async function findCliPackageRoot() {
|
|
13413
|
+
let dir = dirname8(fileURLToPath3(import.meta.url));
|
|
13414
|
+
for (; ; ) {
|
|
13415
|
+
let raw;
|
|
13416
|
+
try {
|
|
13417
|
+
raw = readFileSync3(join14(dir, "package.json"), "utf8");
|
|
13418
|
+
} catch {
|
|
13419
|
+
raw = "";
|
|
13420
|
+
}
|
|
13421
|
+
try {
|
|
13422
|
+
const pkg = JSON.parse(raw);
|
|
13423
|
+
if (pkg.name === "@adep/cli") return dir;
|
|
13424
|
+
} catch {
|
|
13425
|
+
}
|
|
13426
|
+
const parent = dirname8(dir);
|
|
13427
|
+
if (parent === dir) {
|
|
13428
|
+
throw new InitError(
|
|
13429
|
+
"SHELL_TEMPLATE_MISSING",
|
|
13430
|
+
"\u627E\u4E0D\u5230 @adep/cli \u7684 package.json\uFF08\u5DF2\u904D\u5386\u5230\u6587\u4EF6\u7CFB\u7EDF\u6839\uFF09"
|
|
13431
|
+
);
|
|
13432
|
+
}
|
|
13433
|
+
dir = parent;
|
|
13434
|
+
}
|
|
13435
|
+
}
|
|
13436
|
+
async function appShellTemplateDir(code = "app-desktop") {
|
|
13437
|
+
const dir = join14(await findCliPackageRoot(), "templates", code);
|
|
13438
|
+
try {
|
|
13439
|
+
await stat6(dir);
|
|
13440
|
+
} catch {
|
|
13441
|
+
throw new InitError(
|
|
13442
|
+
"SHELL_TEMPLATE_MISSING",
|
|
13443
|
+
`\u58F3\u6A21\u677F\u76EE\u5F55\u7F3A\u5931\uFF1A${dir}\uFF08\u5B89\u88C5\u4EA7\u7269\u5E94\u5305\u542B templates/\uFF0C\u68C0\u67E5 package.json \u7684 files \u5B57\u6BB5\uFF09`
|
|
13444
|
+
);
|
|
13445
|
+
}
|
|
13446
|
+
return dir;
|
|
13447
|
+
}
|
|
13448
|
+
async function renderAppShellTemplate(vars, code = "app-desktop") {
|
|
13449
|
+
const templateDir = await appShellTemplateDir(code);
|
|
13450
|
+
const rels = await collectRelPaths(templateDir, ".");
|
|
13451
|
+
const allowed = TEMPLATE_VAR_ALLOWLIST[code];
|
|
13452
|
+
const values = {
|
|
13453
|
+
projectSlug: vars.projectSlug,
|
|
13454
|
+
appName: vars.appName,
|
|
13455
|
+
platformUrl: vars.platformUrl,
|
|
13456
|
+
// ⚠️ 判据是「desktop 与 mobile 族」而不是「是不是 app-mobile」——`app-mobile-xtool`
|
|
13457
|
+
// 同样要 iosBundleId。原来写成 `code === 'app-mobile' ? ... : { appId }` 时,
|
|
13458
|
+
// 新 code 会落进 else 分支:`{{iosBundleId}}` 取到 `undefined → ''`,
|
|
13459
|
+
// 渲染出一个 **bundle id 为空** 的工程(SwiftPM/xtool 都在更晚的环节才报错)。
|
|
13460
|
+
...code === "app-desktop" ? { appId: vars.appId ?? "" } : {
|
|
13461
|
+
iosBundleId: vars.iosBundleId ?? "",
|
|
13462
|
+
androidPackageId: vars.androidPackageId ?? ""
|
|
13463
|
+
}
|
|
13464
|
+
};
|
|
13465
|
+
return Promise.all(
|
|
13466
|
+
rels.map(async (rel) => {
|
|
13467
|
+
const raw = await readFile11(join14(templateDir, rel), "utf8");
|
|
13468
|
+
const content = raw.replace(/\{\{\s*([A-Za-z0-9_-]+)\s*\}\}/g, (whole, name) => {
|
|
13469
|
+
if (!allowed.has(name)) {
|
|
13470
|
+
throw new InitError(
|
|
13471
|
+
"SHELL_TEMPLATE_INVALID",
|
|
13472
|
+
`\u58F3\u6A21\u677F ${code} \u7684\u6587\u4EF6 ${rel} \u4F7F\u7528\u4E86\u672A\u652F\u6301\u53D8\u91CF "${whole}"\uFF1A\u5141\u8BB8 ${[...allowed].join(" | ")}`
|
|
13473
|
+
);
|
|
13474
|
+
}
|
|
13475
|
+
return values[name] ?? "";
|
|
13476
|
+
});
|
|
13477
|
+
const leftover = /\{\{\s*[A-Za-z0-9_-]+\s*\}\}/.exec(content);
|
|
13478
|
+
if (leftover !== null) {
|
|
13479
|
+
throw new InitError(
|
|
13480
|
+
"SHELL_TEMPLATE_INVALID",
|
|
13481
|
+
`\u58F3\u6A21\u677F ${code} \u7684\u6587\u4EF6 ${rel} \u6E32\u67D3\u540E\u4ECD\u6709\u672A\u66FF\u6362\u5360\u4F4D\u7B26 "${leftover[0]}"`
|
|
13482
|
+
);
|
|
13483
|
+
}
|
|
13484
|
+
return { path: rel, content };
|
|
13485
|
+
})
|
|
13486
|
+
);
|
|
13487
|
+
}
|
|
13301
13488
|
|
|
13302
13489
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
|
|
13303
13490
|
var external_exports = {};
|
|
@@ -33050,148 +33237,6 @@ function parseAdepAppConfig(input2) {
|
|
|
33050
33237
|
return parsed.data;
|
|
33051
33238
|
}
|
|
33052
33239
|
|
|
33053
|
-
// packages/cli/src/app-init.ts
|
|
33054
|
-
import { cp, mkdir as mkdir8, readdir as readdir5, stat as stat7, writeFile as writeFile6 } from "node:fs/promises";
|
|
33055
|
-
import { dirname as dirname9, join as join15, resolve as resolve7 } from "node:path";
|
|
33056
|
-
|
|
33057
|
-
// packages/cli/src/app-template.ts
|
|
33058
|
-
import { readFileSync as readFileSync3 } from "node:fs";
|
|
33059
|
-
import { readdir as readdir4, readFile as readFile11, stat as stat6 } from "node:fs/promises";
|
|
33060
|
-
import { dirname as dirname8, join as join14 } from "node:path";
|
|
33061
|
-
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
33062
|
-
var TEMPLATE_VAR_ALLOWLIST = {
|
|
33063
|
-
"app-desktop": /* @__PURE__ */ new Set(["projectSlug", "appName", "appId", "platformUrl"]),
|
|
33064
|
-
"app-mobile": /* @__PURE__ */ new Set([
|
|
33065
|
-
"projectSlug",
|
|
33066
|
-
"appName",
|
|
33067
|
-
"platformUrl",
|
|
33068
|
-
"iosBundleId",
|
|
33069
|
-
"androidPackageId"
|
|
33070
|
-
]),
|
|
33071
|
-
// xtool 只做 iOS ⇒ 没有 androidPackageId。少这一个变量是**刻意的**:
|
|
33072
|
-
// 模板里若写了它,渲染期会 fail loud(而不是渲染出一个没有 Android 目标的空值)。
|
|
33073
|
-
"app-mobile-xtool": /* @__PURE__ */ new Set(["projectSlug", "appName", "platformUrl", "iosBundleId"])
|
|
33074
|
-
};
|
|
33075
|
-
function shellTemplateForPlatform(platform) {
|
|
33076
|
-
return platform === "mobile" ? "app-mobile" : "app-desktop";
|
|
33077
|
-
}
|
|
33078
|
-
function normalizeToolchain(input2) {
|
|
33079
|
-
if (input2 === void 0 || input2.length === 0) return "capacitor";
|
|
33080
|
-
if (input2 === "capacitor" || input2 === "xtool") return input2;
|
|
33081
|
-
throw new InitError(
|
|
33082
|
-
"INVALID_TOOLCHAIN",
|
|
33083
|
-
`--toolchain \u987B\u4E3A capacitor | xtool\uFF0C\u6536\u5230 "${input2}"\uFF08\u7F3A\u7701 capacitor\uFF09`
|
|
33084
|
-
);
|
|
33085
|
-
}
|
|
33086
|
-
function shellTemplateFor(platform, toolchain) {
|
|
33087
|
-
if (toolchain === "xtool") {
|
|
33088
|
-
if (platform !== "mobile") {
|
|
33089
|
-
throw new InitError(
|
|
33090
|
-
"INVALID_TOOLCHAIN",
|
|
33091
|
-
`--toolchain xtool \u53EA\u652F\u6301 --platform mobile\uFF08xtool \u4EA7\u51FA iOS \u539F\u751F app\uFF09\uFF0C\u6536\u5230 --platform ${platform}`
|
|
33092
|
-
);
|
|
33093
|
-
}
|
|
33094
|
-
return "app-mobile-xtool";
|
|
33095
|
-
}
|
|
33096
|
-
return shellTemplateForPlatform(platform);
|
|
33097
|
-
}
|
|
33098
|
-
var XTOOL_SHELL_REUSED_FROM_MOBILE = [
|
|
33099
|
-
{ from: "plugins/adep-bridge", to: "plugins/adep-bridge" },
|
|
33100
|
-
{ from: "web/adep-bridge.js", to: "web/adep-bridge.js" },
|
|
33101
|
-
{ from: "web/offline-runtime.js", to: "web/offline-runtime.js" }
|
|
33102
|
-
];
|
|
33103
|
-
var TEMPLATE_MANIFEST_FILES = /* @__PURE__ */ new Set(["template.json"]);
|
|
33104
|
-
async function collectRelPaths(dir, base) {
|
|
33105
|
-
const entries = await readdir4(dir, { withFileTypes: true });
|
|
33106
|
-
const nested = await Promise.all(
|
|
33107
|
-
entries.filter((entry) => entry.name !== ".DS_Store" && !TEMPLATE_MANIFEST_FILES.has(entry.name)).toSorted((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0).map((entry) => {
|
|
33108
|
-
const abs = join14(dir, entry.name);
|
|
33109
|
-
return entry.isDirectory() ? (
|
|
33110
|
-
// 递归时 base 必须带上子目录前缀,否则深层文件相对路径会丢目录段
|
|
33111
|
-
// (app-mobile 是嵌套目录结构:bridge/gate.mjs、plugins/adep-bridge/...)。
|
|
33112
|
-
collectRelPaths(abs, join14(base, entry.name))
|
|
33113
|
-
) : Promise.resolve([join14(base, entry.name).split("\\").join("/")]);
|
|
33114
|
-
})
|
|
33115
|
-
);
|
|
33116
|
-
return nested.flat();
|
|
33117
|
-
}
|
|
33118
|
-
async function findCliPackageRoot() {
|
|
33119
|
-
let dir = dirname8(fileURLToPath3(import.meta.url));
|
|
33120
|
-
for (; ; ) {
|
|
33121
|
-
let raw;
|
|
33122
|
-
try {
|
|
33123
|
-
raw = readFileSync3(join14(dir, "package.json"), "utf8");
|
|
33124
|
-
} catch {
|
|
33125
|
-
raw = "";
|
|
33126
|
-
}
|
|
33127
|
-
try {
|
|
33128
|
-
const pkg = JSON.parse(raw);
|
|
33129
|
-
if (pkg.name === "@adep/cli") return dir;
|
|
33130
|
-
} catch {
|
|
33131
|
-
}
|
|
33132
|
-
const parent = dirname8(dir);
|
|
33133
|
-
if (parent === dir) {
|
|
33134
|
-
throw new InitError(
|
|
33135
|
-
"SHELL_TEMPLATE_MISSING",
|
|
33136
|
-
"\u627E\u4E0D\u5230 @adep/cli \u7684 package.json\uFF08\u5DF2\u904D\u5386\u5230\u6587\u4EF6\u7CFB\u7EDF\u6839\uFF09"
|
|
33137
|
-
);
|
|
33138
|
-
}
|
|
33139
|
-
dir = parent;
|
|
33140
|
-
}
|
|
33141
|
-
}
|
|
33142
|
-
async function appShellTemplateDir(code = "app-desktop") {
|
|
33143
|
-
const dir = join14(await findCliPackageRoot(), "templates", code);
|
|
33144
|
-
try {
|
|
33145
|
-
await stat6(dir);
|
|
33146
|
-
} catch {
|
|
33147
|
-
throw new InitError(
|
|
33148
|
-
"SHELL_TEMPLATE_MISSING",
|
|
33149
|
-
`\u58F3\u6A21\u677F\u76EE\u5F55\u7F3A\u5931\uFF1A${dir}\uFF08\u5B89\u88C5\u4EA7\u7269\u5E94\u5305\u542B templates/\uFF0C\u68C0\u67E5 package.json \u7684 files \u5B57\u6BB5\uFF09`
|
|
33150
|
-
);
|
|
33151
|
-
}
|
|
33152
|
-
return dir;
|
|
33153
|
-
}
|
|
33154
|
-
async function renderAppShellTemplate(vars, code = "app-desktop") {
|
|
33155
|
-
const templateDir = await appShellTemplateDir(code);
|
|
33156
|
-
const rels = await collectRelPaths(templateDir, ".");
|
|
33157
|
-
const allowed = TEMPLATE_VAR_ALLOWLIST[code];
|
|
33158
|
-
const values = {
|
|
33159
|
-
projectSlug: vars.projectSlug,
|
|
33160
|
-
appName: vars.appName,
|
|
33161
|
-
platformUrl: vars.platformUrl,
|
|
33162
|
-
// ⚠️ 判据是「desktop 与 mobile 族」而不是「是不是 app-mobile」——`app-mobile-xtool`
|
|
33163
|
-
// 同样要 iosBundleId。原来写成 `code === 'app-mobile' ? ... : { appId }` 时,
|
|
33164
|
-
// 新 code 会落进 else 分支:`{{iosBundleId}}` 取到 `undefined → ''`,
|
|
33165
|
-
// 渲染出一个 **bundle id 为空** 的工程(SwiftPM/xtool 都在更晚的环节才报错)。
|
|
33166
|
-
...code === "app-desktop" ? { appId: vars.appId ?? "" } : {
|
|
33167
|
-
iosBundleId: vars.iosBundleId ?? "",
|
|
33168
|
-
androidPackageId: vars.androidPackageId ?? ""
|
|
33169
|
-
}
|
|
33170
|
-
};
|
|
33171
|
-
return Promise.all(
|
|
33172
|
-
rels.map(async (rel) => {
|
|
33173
|
-
const raw = await readFile11(join14(templateDir, rel), "utf8");
|
|
33174
|
-
const content = raw.replace(/\{\{\s*([A-Za-z0-9_-]+)\s*\}\}/g, (whole, name) => {
|
|
33175
|
-
if (!allowed.has(name)) {
|
|
33176
|
-
throw new InitError(
|
|
33177
|
-
"SHELL_TEMPLATE_INVALID",
|
|
33178
|
-
`\u58F3\u6A21\u677F ${code} \u7684\u6587\u4EF6 ${rel} \u4F7F\u7528\u4E86\u672A\u652F\u6301\u53D8\u91CF "${whole}"\uFF1A\u5141\u8BB8 ${[...allowed].join(" | ")}`
|
|
33179
|
-
);
|
|
33180
|
-
}
|
|
33181
|
-
return values[name] ?? "";
|
|
33182
|
-
});
|
|
33183
|
-
const leftover = /\{\{\s*[A-Za-z0-9_-]+\s*\}\}/.exec(content);
|
|
33184
|
-
if (leftover !== null) {
|
|
33185
|
-
throw new InitError(
|
|
33186
|
-
"SHELL_TEMPLATE_INVALID",
|
|
33187
|
-
`\u58F3\u6A21\u677F ${code} \u7684\u6587\u4EF6 ${rel} \u6E32\u67D3\u540E\u4ECD\u6709\u672A\u66FF\u6362\u5360\u4F4D\u7B26 "${leftover[0]}"`
|
|
33188
|
-
);
|
|
33189
|
-
}
|
|
33190
|
-
return { path: rel, content };
|
|
33191
|
-
})
|
|
33192
|
-
);
|
|
33193
|
-
}
|
|
33194
|
-
|
|
33195
33240
|
// packages/cli/src/app-init.ts
|
|
33196
33241
|
function appIdForSlug(slug) {
|
|
33197
33242
|
return `top.adep.${slug}`;
|
|
@@ -33312,8 +33357,10 @@ async function listFiles(path, base) {
|
|
|
33312
33357
|
|
|
33313
33358
|
// packages/cli/src/app-build.ts
|
|
33314
33359
|
init_client();
|
|
33315
|
-
init_config();
|
|
33316
33360
|
init_client2();
|
|
33361
|
+
|
|
33362
|
+
// packages/cli/src/app-build/shared.ts
|
|
33363
|
+
import { stat as stat8 } from "node:fs/promises";
|
|
33317
33364
|
var SITE_PREFIX = "site/";
|
|
33318
33365
|
var SHELL_SITE_DIR = "app/site";
|
|
33319
33366
|
var MOBILE_SITE_ASSET_FILES = {
|
|
@@ -33370,30 +33417,15 @@ async function pathExists(path) {
|
|
|
33370
33417
|
return false;
|
|
33371
33418
|
}
|
|
33372
33419
|
}
|
|
33373
|
-
|
|
33374
|
-
|
|
33375
|
-
|
|
33376
|
-
|
|
33377
|
-
|
|
33378
|
-
|
|
33379
|
-
|
|
33380
|
-
|
|
33381
|
-
|
|
33382
|
-
);
|
|
33383
|
-
}
|
|
33384
|
-
let parsed;
|
|
33385
|
-
try {
|
|
33386
|
-
parsed = JSON.parse(text);
|
|
33387
|
-
} catch (error62) {
|
|
33388
|
-
throw new InitError(
|
|
33389
|
-
"APP_CONFIG_INVALID",
|
|
33390
|
-
`adep.app.json \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${error62 instanceof Error ? error62.message : String(error62)}`
|
|
33391
|
-
);
|
|
33392
|
-
}
|
|
33393
|
-
const config2 = parseAdepAppConfig(parsed);
|
|
33394
|
-
const raw = parsed ?? {};
|
|
33395
|
-
return { raw, config: config2 };
|
|
33396
|
-
}
|
|
33420
|
+
|
|
33421
|
+
// packages/cli/src/app-build/bundle.ts
|
|
33422
|
+
init_shared_source();
|
|
33423
|
+
init_validate();
|
|
33424
|
+
init_zip();
|
|
33425
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
33426
|
+
import { mkdir as mkdir9, mkdtemp, readFile as readFile12, rm as rm3, writeFile as writeFile8 } from "node:fs/promises";
|
|
33427
|
+
import { tmpdir } from "node:os";
|
|
33428
|
+
import { dirname as dirname10, join as join16, posix } from "node:path";
|
|
33397
33429
|
function computeBundleVersion(manifest) {
|
|
33398
33430
|
const siteEntries = manifest.contents.filter((content) => content.path.startsWith(SITE_PREFIX)).toSorted((left, right) => compareByCodeUnit(left.path, right.path));
|
|
33399
33431
|
const fingerprint = createHash2("sha256").update(siteEntries.map((content) => `${content.path}:${content.sha256}`).join("\n")).digest("hex").slice(0, 12);
|
|
@@ -33495,11 +33527,6 @@ async function writeSiteTree(shellDir, site) {
|
|
|
33495
33527
|
}
|
|
33496
33528
|
return written;
|
|
33497
33529
|
}
|
|
33498
|
-
async function bindVersion(shellDir, raw, binding) {
|
|
33499
|
-
const next = { ...raw, build: binding };
|
|
33500
|
-
await writeFile8(join16(shellDir, "adep.app.json"), `${JSON.stringify(next, null, 2)}
|
|
33501
|
-
`);
|
|
33502
|
-
}
|
|
33503
33530
|
async function waitForExport(api, jobId, pollIntervalMs, maxPollAttempts) {
|
|
33504
33531
|
let attempts = 0;
|
|
33505
33532
|
for (; ; ) {
|
|
@@ -33515,6 +33542,113 @@ async function waitForExport(api, jobId, pollIntervalMs, maxPollAttempts) {
|
|
|
33515
33542
|
await new Promise((resolvePromise) => setTimeout(resolvePromise, pollIntervalMs));
|
|
33516
33543
|
}
|
|
33517
33544
|
}
|
|
33545
|
+
async function fetchAndInjectSite(input2) {
|
|
33546
|
+
const workDir = await mkdtemp(join16(tmpdir(), "adep-app-build-"));
|
|
33547
|
+
try {
|
|
33548
|
+
const zipPath = join16(workDir, "bundle.zip");
|
|
33549
|
+
await input2.api.downloadBundle(input2.jobId, zipPath);
|
|
33550
|
+
const entries = zipRead(await readFile12(zipPath));
|
|
33551
|
+
const manifest = readManifest(entries);
|
|
33552
|
+
verifySiteContents(manifest, entries);
|
|
33553
|
+
const site = collectSiteEntries(entries);
|
|
33554
|
+
if (site.size === 0) {
|
|
33555
|
+
throw new InitError(
|
|
33556
|
+
"APP_NO_PUBLISHED_FRONTEND",
|
|
33557
|
+
`\u9879\u76EE "${input2.projectSlug}" \u6CA1\u6709\u5DF2\u53D1\u5E03\u7684\u9875\u9762\u4EA7\u7269\uFF08\u5BFC\u51FA\u5305\u5185\u6CA1\u6709 ${SITE_PREFIX}\uFF09\uFF1A\u8BF7\u5148\u6267\u884C adep publish --only frontend --project ${input2.projectSlug}`
|
|
33558
|
+
);
|
|
33559
|
+
}
|
|
33560
|
+
return { manifest, written: await writeSiteTree(input2.shellDir, site) };
|
|
33561
|
+
} finally {
|
|
33562
|
+
await rm3(workDir, { recursive: true, force: true });
|
|
33563
|
+
}
|
|
33564
|
+
}
|
|
33565
|
+
|
|
33566
|
+
// packages/cli/src/app-build/shell.ts
|
|
33567
|
+
import { readFile as readFile13, writeFile as writeFile9 } from "node:fs/promises";
|
|
33568
|
+
import { join as join17 } from "node:path";
|
|
33569
|
+
async function readShellConfig(shellDir) {
|
|
33570
|
+
const configPath = join17(shellDir, "adep.app.json");
|
|
33571
|
+
let text;
|
|
33572
|
+
try {
|
|
33573
|
+
text = await readFile13(configPath, "utf8");
|
|
33574
|
+
} catch {
|
|
33575
|
+
throw new InitError(
|
|
33576
|
+
"APP_CONFIG_NOT_FOUND",
|
|
33577
|
+
`\u672A\u627E\u5230 ${configPath}\uFF1A\u8BE5\u76EE\u5F55\u4E0D\u662F\u684C\u9762\u58F3\u5DE5\u7A0B\uFF0C\u6216\u5C1A\u672A\u6267\u884C adep app init --dir ${shellDir}`
|
|
33578
|
+
);
|
|
33579
|
+
}
|
|
33580
|
+
let parsed;
|
|
33581
|
+
try {
|
|
33582
|
+
parsed = JSON.parse(text);
|
|
33583
|
+
} catch (error62) {
|
|
33584
|
+
throw new InitError(
|
|
33585
|
+
"APP_CONFIG_INVALID",
|
|
33586
|
+
`adep.app.json \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${error62 instanceof Error ? error62.message : String(error62)}`
|
|
33587
|
+
);
|
|
33588
|
+
}
|
|
33589
|
+
const config2 = parseAdepAppConfig(parsed);
|
|
33590
|
+
const raw = parsed ?? {};
|
|
33591
|
+
return { raw, config: config2 };
|
|
33592
|
+
}
|
|
33593
|
+
async function bindVersion(shellDir, raw, binding) {
|
|
33594
|
+
const next = { ...raw, build: binding };
|
|
33595
|
+
await writeFile9(join17(shellDir, "adep.app.json"), `${JSON.stringify(next, null, 2)}
|
|
33596
|
+
`);
|
|
33597
|
+
}
|
|
33598
|
+
|
|
33599
|
+
// packages/cli/src/app-build/site.ts
|
|
33600
|
+
import { copyFile, readFile as readFile14, writeFile as writeFile10 } from "node:fs/promises";
|
|
33601
|
+
import { join as join18 } from "node:path";
|
|
33602
|
+
async function readEntryPage(indexPath) {
|
|
33603
|
+
try {
|
|
33604
|
+
return await readFile14(indexPath, "utf8");
|
|
33605
|
+
} catch (error62) {
|
|
33606
|
+
const code = typeof error62 === "object" && error62 !== null ? error62.code : void 0;
|
|
33607
|
+
if (code === "ENOENT") {
|
|
33608
|
+
throw new InitError(
|
|
33609
|
+
"APP_SITE_MISSING",
|
|
33610
|
+
`\u7AD9\u70B9\u4EA7\u7269\u7F3A\u5165\u53E3\u9875\uFF1A${indexPath} \u4E0D\u5B58\u5728\u3002\u79FB\u52A8\u58F3\u7684 WebView \u6052\u52A0\u8F7D index.html\uFF0C\u7F3A\u4E86\u88C5\u673A\u5C31\u662F\u767D\u5C4F\u2014\u2014\u8BF7\u786E\u8BA4\u7AD9\u70B9\u5DF2\u53D1\u5E03\u4E14\u5165\u53E3\u9875\u662F**\u6839\u7EA7** index.html\uFF08\`adep publish --only frontend\`\uFF09\uFF0C\u518D\u91CD\u8DD1 adep app build`
|
|
33611
|
+
);
|
|
33612
|
+
}
|
|
33613
|
+
throw new InitError(
|
|
33614
|
+
"APP_SITE_UNREADABLE",
|
|
33615
|
+
`\u7AD9\u70B9\u5165\u53E3\u9875\u8BFB\u4E0D\u51FA\u6765\uFF1A${indexPath}\uFF08${error62 instanceof Error ? error62.message : String(error62)}\uFF09`
|
|
33616
|
+
);
|
|
33617
|
+
}
|
|
33618
|
+
}
|
|
33619
|
+
async function injectMobileShellAssets(input2) {
|
|
33620
|
+
const siteRoot = join18(input2.shellDir, SHELL_SITE_DIR);
|
|
33621
|
+
const indexPath = join18(siteRoot, "index.html");
|
|
33622
|
+
const html = await readEntryPage(indexPath);
|
|
33623
|
+
const permissionsJson = `${JSON.stringify(
|
|
33624
|
+
{ schemaVersion: 1, permissions: sortPermissions(input2.permissions) },
|
|
33625
|
+
null,
|
|
33626
|
+
2
|
|
33627
|
+
)}
|
|
33628
|
+
`;
|
|
33629
|
+
await writeFile10(join18(siteRoot, MOBILE_SITE_ASSET_FILES.permissions), permissionsJson);
|
|
33630
|
+
await copyFile(
|
|
33631
|
+
join18(input2.shellDir, "web", "adep-bridge.js"),
|
|
33632
|
+
join18(siteRoot, MOBILE_SITE_ASSET_FILES.bridge)
|
|
33633
|
+
);
|
|
33634
|
+
await copyFile(
|
|
33635
|
+
join18(input2.shellDir, "adep.app.json"),
|
|
33636
|
+
join18(siteRoot, MOBILE_SITE_ASSET_FILES.config)
|
|
33637
|
+
);
|
|
33638
|
+
if (html.includes("adep-bridge.js")) return;
|
|
33639
|
+
const tag = '<script src="/adep-bridge.js"></script>';
|
|
33640
|
+
const next = html.includes("</head>") ? html.replace("</head>", `${tag}
|
|
33641
|
+
</head>`) : `${tag}
|
|
33642
|
+
${html}`;
|
|
33643
|
+
await writeFile10(indexPath, next);
|
|
33644
|
+
}
|
|
33645
|
+
|
|
33646
|
+
// packages/cli/src/app-build/toolchain.ts
|
|
33647
|
+
init_config();
|
|
33648
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
33649
|
+
import { closeSync, openSync } from "node:fs";
|
|
33650
|
+
import { copyFile as copyFile2, mkdir as mkdir10, readdir as readdir6 } from "node:fs/promises";
|
|
33651
|
+
import { basename as basename2, join as join19 } from "node:path";
|
|
33518
33652
|
function platformArgs(platform) {
|
|
33519
33653
|
if (platform === "darwin") return ["--mac"];
|
|
33520
33654
|
if (platform === "win32") return ["--win"];
|
|
@@ -33522,7 +33656,7 @@ function platformArgs(platform) {
|
|
|
33522
33656
|
}
|
|
33523
33657
|
function resolvePackagerBinary(shellDir) {
|
|
33524
33658
|
const name = process.platform === "win32" ? "electron-builder.cmd" : "electron-builder";
|
|
33525
|
-
return
|
|
33659
|
+
return join19(shellDir, "node_modules", ".bin", name);
|
|
33526
33660
|
}
|
|
33527
33661
|
function missingDepsError(shellDir) {
|
|
33528
33662
|
return new InitError(
|
|
@@ -33534,17 +33668,17 @@ function missingMobileDepsError(shellDir, platform) {
|
|
|
33534
33668
|
if (platform === "ios") {
|
|
33535
33669
|
return new InitError(
|
|
33536
33670
|
"APP_SHELL_DEPS_MISSING",
|
|
33537
|
-
`\u672A\u627E\u5230 iOS \u539F\u751F\u5DE5\u7A0B\uFF08${
|
|
33671
|
+
`\u672A\u627E\u5230 iOS \u539F\u751F\u5DE5\u7A0B\uFF08${join19(shellDir, "ios", "App")}\uFF09\uFF1A\u8BF7\u5148\u5728 ${shellDir} \u6267\u884C npx cap add ios && npx cap sync`
|
|
33538
33672
|
);
|
|
33539
33673
|
}
|
|
33540
33674
|
return new InitError(
|
|
33541
33675
|
"APP_SHELL_DEPS_MISSING",
|
|
33542
|
-
`\u672A\u627E\u5230 Android \u539F\u751F\u5DE5\u7A0B\uFF08${
|
|
33676
|
+
`\u672A\u627E\u5230 Android \u539F\u751F\u5DE5\u7A0B\uFF08${join19(shellDir, "android", "gradlew")}\uFF09\uFF1A\u8BF7\u5148\u5728 ${shellDir} \u6267\u884C npx cap add android && npx cap sync`
|
|
33543
33677
|
);
|
|
33544
33678
|
}
|
|
33545
33679
|
function resolveCapBinary(shellDir) {
|
|
33546
33680
|
const name = process.platform === "win32" ? "cap.cmd" : "cap";
|
|
33547
|
-
return
|
|
33681
|
+
return join19(shellDir, "node_modules", ".bin", name);
|
|
33548
33682
|
}
|
|
33549
33683
|
async function syncCapacitorAssets(input2) {
|
|
33550
33684
|
const capBin = resolveCapBinary(input2.shellDir);
|
|
@@ -33567,11 +33701,11 @@ async function assertShellPackagerReady(shellDir, platform, prepareOnly, toolcha
|
|
|
33567
33701
|
return;
|
|
33568
33702
|
}
|
|
33569
33703
|
if (platform === "ios") {
|
|
33570
|
-
if (!await pathExists(
|
|
33571
|
-
if (await pathExists(
|
|
33704
|
+
if (!await pathExists(join19(shellDir, "ios", "App"))) {
|
|
33705
|
+
if (await pathExists(join19(shellDir, "xtool.yml"))) {
|
|
33572
33706
|
throw new InitError(
|
|
33573
33707
|
"APP_SHELL_DEPS_MISSING",
|
|
33574
|
-
`\u672A\u627E\u5230 Capacitor \u7684 iOS \u539F\u751F\u5DE5\u7A0B\uFF08${
|
|
33708
|
+
`\u672A\u627E\u5230 Capacitor \u7684 iOS \u539F\u751F\u5DE5\u7A0B\uFF08${join19(shellDir, "ios", "App")}\uFF09\uFF1B\u4F46\u68C0\u6D4B\u5230\u8BE5\u76EE\u5F55\u662F xtool \u58F3\u5DE5\u7A0B\uFF08\u6709 xtool.yml\uFF09\u2014\u2014\u672C\u6B21\u8BF7\u52A0 --toolchain xtool`
|
|
33575
33709
|
);
|
|
33576
33710
|
}
|
|
33577
33711
|
throw missingMobileDepsError(shellDir, "ios");
|
|
@@ -33587,16 +33721,16 @@ async function assertShellPackagerReady(shellDir, platform, prepareOnly, toolcha
|
|
|
33587
33721
|
if (!await pathExists(resolvePackagerBinary(shellDir))) throw missingDepsError(shellDir);
|
|
33588
33722
|
}
|
|
33589
33723
|
async function assertXtoolShellReady(shellDir) {
|
|
33590
|
-
if (!await pathExists(
|
|
33724
|
+
if (!await pathExists(join19(shellDir, "xtool.yml")) || !await pathExists(join19(shellDir, "Package.swift"))) {
|
|
33591
33725
|
throw new InitError(
|
|
33592
33726
|
"APP_SHELL_DEPS_MISSING",
|
|
33593
|
-
`\u672A\u627E\u5230 xtool \u58F3\u5DE5\u7A0B\uFF08\u9700\u8981 ${
|
|
33727
|
+
`\u672A\u627E\u5230 xtool \u58F3\u5DE5\u7A0B\uFF08\u9700\u8981 ${join19(shellDir, "xtool.yml")} \u4E0E ${join19(shellDir, "Package.swift")}\uFF09\uFF1A\u8BF7\u7528 adep app init --platform mobile --toolchain xtool \u751F\u6210`
|
|
33594
33728
|
);
|
|
33595
33729
|
}
|
|
33596
|
-
if (!await pathExists(
|
|
33730
|
+
if (!await pathExists(join19(shellDir, "plugins", "adep-bridge", "Package.swift"))) {
|
|
33597
33731
|
throw new InitError(
|
|
33598
33732
|
"APP_SHELL_DEPS_MISSING",
|
|
33599
|
-
`xtool \u58F3\u7F3A\u5C11\u539F\u751F\u6865\u63D2\u4EF6\u6E90\u7801\uFF08${
|
|
33733
|
+
`xtool \u58F3\u7F3A\u5C11\u539F\u751F\u6865\u63D2\u4EF6\u6E90\u7801\uFF08${join19(shellDir, "plugins", "adep-bridge", "Package.swift")}\uFF09\uFF1A\u58F3\u7684 Package.swift \u4EE5 .package(path:) \u786C\u4F9D\u8D56\u5B83\uFF0C\u7F3A\u5931\u65F6**\u89E3\u6790\u6E05\u5355\u5373\u5931\u8D25**\uFF08\u4E0D\u662F\u8FD0\u884C\u671F\u5C11\u4E2A\u529F\u80FD\uFF09\u3002\u8BF7\u91CD\u65B0 adep app init --platform mobile --toolchain xtool\uFF0C\u6216\u624B\u5DE5\u8865\u8BE5\u76EE\u5F55`
|
|
33600
33734
|
);
|
|
33601
33735
|
}
|
|
33602
33736
|
}
|
|
@@ -33623,8 +33757,8 @@ function probeCommand(command, args) {
|
|
|
33623
33757
|
});
|
|
33624
33758
|
}
|
|
33625
33759
|
function xcodebuildArgs(shellDir, outDir) {
|
|
33626
|
-
const appDir =
|
|
33627
|
-
const project2 =
|
|
33760
|
+
const appDir = join19(shellDir, "ios", "App");
|
|
33761
|
+
const project2 = join19(appDir, "App.xcodeproj");
|
|
33628
33762
|
const args = [
|
|
33629
33763
|
// 有 workspace(pod install 后)用 workspace;否则退到 xcodeproj(无插件的最小工程)。
|
|
33630
33764
|
"-project",
|
|
@@ -33635,7 +33769,7 @@ function xcodebuildArgs(shellDir, outDir) {
|
|
|
33635
33769
|
"Release",
|
|
33636
33770
|
"archive",
|
|
33637
33771
|
"-archivePath",
|
|
33638
|
-
|
|
33772
|
+
join19(outDir, `${basename2(shellDir)}.xcarchive`),
|
|
33639
33773
|
// unsigned:平台不出具任何签名(PRD §2.11.6「平台不出具签名」)。
|
|
33640
33774
|
// 显式 CODE_SIGNING_ALLOWED=NO——不带任何签名身份(CODE_SIGN_IDENTITY / PROVISIONING_PROFILE)。
|
|
33641
33775
|
"CODE_SIGNING_ALLOWED=NO",
|
|
@@ -33644,8 +33778,8 @@ function xcodebuildArgs(shellDir, outDir) {
|
|
|
33644
33778
|
return args;
|
|
33645
33779
|
}
|
|
33646
33780
|
async function runXcodebuild(input2) {
|
|
33647
|
-
const workspace =
|
|
33648
|
-
const project2 =
|
|
33781
|
+
const workspace = join19(input2.shellDir, "ios", "App", "App.xcworkspace");
|
|
33782
|
+
const project2 = join19(input2.shellDir, "ios", "App", "App.xcodeproj");
|
|
33649
33783
|
if (!await pathExists(workspace) && !await pathExists(project2)) {
|
|
33650
33784
|
throw missingMobileDepsError(input2.shellDir, "ios");
|
|
33651
33785
|
}
|
|
@@ -33662,7 +33796,7 @@ async function assertUnsignedIosArchive(archivePath) {
|
|
|
33662
33796
|
if (!await pathExists(archivePath)) {
|
|
33663
33797
|
throw new InitError("APP_ARCHIVE_INCOMPLETE", `iOS archive \u4E0D\u5B58\u5728\uFF1A${archivePath}`);
|
|
33664
33798
|
}
|
|
33665
|
-
const applicationsDir =
|
|
33799
|
+
const applicationsDir = join19(archivePath, "Products", "Applications");
|
|
33666
33800
|
let hasAppBundle = false;
|
|
33667
33801
|
try {
|
|
33668
33802
|
const entries = await readdir6(applicationsDir, { withFileTypes: true });
|
|
@@ -33692,7 +33826,7 @@ async function assertUnsignedIosArchive(archivePath) {
|
|
|
33692
33826
|
continue;
|
|
33693
33827
|
}
|
|
33694
33828
|
if (entry.isDirectory()) {
|
|
33695
|
-
await walk(
|
|
33829
|
+
await walk(join19(dir, entry.name), childRel, depth + 1);
|
|
33696
33830
|
}
|
|
33697
33831
|
}
|
|
33698
33832
|
};
|
|
@@ -33705,10 +33839,10 @@ async function assertUnsignedIosArchive(archivePath) {
|
|
|
33705
33839
|
}
|
|
33706
33840
|
}
|
|
33707
33841
|
function resolveGradlew(shellDir) {
|
|
33708
|
-
return process.platform === "win32" ?
|
|
33842
|
+
return process.platform === "win32" ? join19(shellDir, "android", "gradlew.bat") : join19(shellDir, "android", "gradlew");
|
|
33709
33843
|
}
|
|
33710
33844
|
async function copyGradleApkToOutDir(shellDir, outDir) {
|
|
33711
|
-
const outputsRoot =
|
|
33845
|
+
const outputsRoot = join19(shellDir, "android", "app", "build", "outputs", "apk");
|
|
33712
33846
|
const copied = [];
|
|
33713
33847
|
const walk = async (dir, depth) => {
|
|
33714
33848
|
if (depth > 2) return;
|
|
@@ -33719,9 +33853,9 @@ async function copyGradleApkToOutDir(shellDir, outDir) {
|
|
|
33719
33853
|
return;
|
|
33720
33854
|
}
|
|
33721
33855
|
for (const entry of entries) {
|
|
33722
|
-
const full =
|
|
33856
|
+
const full = join19(dir, entry.name);
|
|
33723
33857
|
if (entry.isFile() && entry.name.endsWith(".apk")) {
|
|
33724
|
-
await
|
|
33858
|
+
await copyFile2(full, join19(outDir, entry.name));
|
|
33725
33859
|
copied.push(entry.name);
|
|
33726
33860
|
continue;
|
|
33727
33861
|
}
|
|
@@ -33737,7 +33871,7 @@ async function runGradle(input2) {
|
|
|
33737
33871
|
const gradlew = resolveGradlew(input2.shellDir);
|
|
33738
33872
|
if (!await pathExists(gradlew)) throw missingMobileDepsError(input2.shellDir, "android");
|
|
33739
33873
|
if (process.platform === "win32") {
|
|
33740
|
-
await spawnChild(
|
|
33874
|
+
await spawnChild(join19(input2.shellDir, "android"), "cmd.exe", [
|
|
33741
33875
|
"/d",
|
|
33742
33876
|
"/s",
|
|
33743
33877
|
"/c",
|
|
@@ -33745,14 +33879,14 @@ async function runGradle(input2) {
|
|
|
33745
33879
|
"assembleRelease"
|
|
33746
33880
|
]);
|
|
33747
33881
|
} else {
|
|
33748
|
-
await spawnChild(
|
|
33882
|
+
await spawnChild(join19(input2.shellDir, "android"), gradlew, ["assembleRelease"]);
|
|
33749
33883
|
}
|
|
33750
|
-
await
|
|
33884
|
+
await mkdir10(input2.outDir, { recursive: true });
|
|
33751
33885
|
const copied = await copyGradleApkToOutDir(input2.shellDir, input2.outDir);
|
|
33752
33886
|
if (copied.length === 0) {
|
|
33753
33887
|
throw new InitError(
|
|
33754
33888
|
"APP_ARTIFACT_MISSING",
|
|
33755
|
-
`gradle \u5DF2\u6210\u529F\u4F46 ${
|
|
33889
|
+
`gradle \u5DF2\u6210\u529F\u4F46 ${join19(input2.shellDir, "android", "app", "build", "outputs", "apk")} \u4E0B\u6CA1\u6709 .apk\uFF1AassembleRelease \u53EF\u80FD\u88AB\u964D\u7EA7\u6210\u522B\u7684\u53D8\u4F53\uFF0C\u8BF7\u68C0\u67E5 android \u5DE5\u7A0B\u7684\u6784\u5EFA\u53D8\u4F53\u914D\u7F6E`
|
|
33756
33890
|
);
|
|
33757
33891
|
}
|
|
33758
33892
|
}
|
|
@@ -33818,6 +33952,10 @@ async function runElectronBuilder(input2) {
|
|
|
33818
33952
|
}
|
|
33819
33953
|
await spawnChild(input2.shellDir, binary, args, void 0, env);
|
|
33820
33954
|
}
|
|
33955
|
+
|
|
33956
|
+
// packages/cli/src/app-build/artifacts.ts
|
|
33957
|
+
import { readFile as readFile15, readdir as readdir7 } from "node:fs/promises";
|
|
33958
|
+
import { join as join20, relative as relative2 } from "node:path";
|
|
33821
33959
|
function isArtifact(name, isDirectory, platform, toolchain) {
|
|
33822
33960
|
if (toolchain === "xtool") return !isDirectory && name.endsWith(".ipa");
|
|
33823
33961
|
if (platform === "ios") return isDirectory && name.endsWith(".xcarchive");
|
|
@@ -33830,17 +33968,17 @@ function isArtifact(name, isDirectory, platform, toolchain) {
|
|
|
33830
33968
|
}
|
|
33831
33969
|
async function findArtifacts(shellDir, outDir, platform, toolchain = "capacitor") {
|
|
33832
33970
|
const found = [];
|
|
33833
|
-
const scanRoot = toolchain === "xtool" ?
|
|
33971
|
+
const scanRoot = toolchain === "xtool" ? join20(shellDir, XTOOL_ARTIFACT_DIR) : outDir;
|
|
33834
33972
|
const walk = async (dir, depth) => {
|
|
33835
33973
|
if (depth > 3) return;
|
|
33836
33974
|
let entries;
|
|
33837
33975
|
try {
|
|
33838
|
-
entries = await
|
|
33976
|
+
entries = await readdir7(dir, { withFileTypes: true });
|
|
33839
33977
|
} catch {
|
|
33840
33978
|
return;
|
|
33841
33979
|
}
|
|
33842
33980
|
for (const entry of entries) {
|
|
33843
|
-
const full =
|
|
33981
|
+
const full = join20(dir, entry.name);
|
|
33844
33982
|
if (isArtifact(entry.name, entry.isDirectory(), platform, toolchain)) {
|
|
33845
33983
|
found.push(relative2(shellDir, full).split(/[\\/]/u).join("/"));
|
|
33846
33984
|
continue;
|
|
@@ -33891,7 +34029,7 @@ function linuxTargetSkips(declared, artifacts) {
|
|
|
33891
34029
|
}
|
|
33892
34030
|
async function readLinuxDeclaredTargets(shellDir) {
|
|
33893
34031
|
try {
|
|
33894
|
-
const raw = await
|
|
34032
|
+
const raw = await readFile15(join20(shellDir, "package.json"), "utf8");
|
|
33895
34033
|
const parsed = JSON.parse(raw);
|
|
33896
34034
|
const target = parsed.build?.linux?.target;
|
|
33897
34035
|
if (typeof target === "string") return [target];
|
|
@@ -33902,69 +34040,8 @@ async function readLinuxDeclaredTargets(shellDir) {
|
|
|
33902
34040
|
return [];
|
|
33903
34041
|
}
|
|
33904
34042
|
}
|
|
33905
|
-
|
|
33906
|
-
|
|
33907
|
-
try {
|
|
33908
|
-
const zipPath = join16(workDir, "bundle.zip");
|
|
33909
|
-
await input2.api.downloadBundle(input2.jobId, zipPath);
|
|
33910
|
-
const entries = zipRead(await readFile12(zipPath));
|
|
33911
|
-
const manifest = readManifest(entries);
|
|
33912
|
-
verifySiteContents(manifest, entries);
|
|
33913
|
-
const site = collectSiteEntries(entries);
|
|
33914
|
-
if (site.size === 0) {
|
|
33915
|
-
throw new InitError(
|
|
33916
|
-
"APP_NO_PUBLISHED_FRONTEND",
|
|
33917
|
-
`\u9879\u76EE "${input2.projectSlug}" \u6CA1\u6709\u5DF2\u53D1\u5E03\u7684\u9875\u9762\u4EA7\u7269\uFF08\u5BFC\u51FA\u5305\u5185\u6CA1\u6709 ${SITE_PREFIX}\uFF09\uFF1A\u8BF7\u5148\u6267\u884C adep publish --only frontend --project ${input2.projectSlug}`
|
|
33918
|
-
);
|
|
33919
|
-
}
|
|
33920
|
-
return { manifest, written: await writeSiteTree(input2.shellDir, site) };
|
|
33921
|
-
} finally {
|
|
33922
|
-
await rm3(workDir, { recursive: true, force: true });
|
|
33923
|
-
}
|
|
33924
|
-
}
|
|
33925
|
-
async function readEntryPage(indexPath) {
|
|
33926
|
-
try {
|
|
33927
|
-
return await readFile12(indexPath, "utf8");
|
|
33928
|
-
} catch (error62) {
|
|
33929
|
-
const code = typeof error62 === "object" && error62 !== null ? error62.code : void 0;
|
|
33930
|
-
if (code === "ENOENT") {
|
|
33931
|
-
throw new InitError(
|
|
33932
|
-
"APP_SITE_MISSING",
|
|
33933
|
-
`\u7AD9\u70B9\u4EA7\u7269\u7F3A\u5165\u53E3\u9875\uFF1A${indexPath} \u4E0D\u5B58\u5728\u3002\u79FB\u52A8\u58F3\u7684 WebView \u6052\u52A0\u8F7D index.html\uFF0C\u7F3A\u4E86\u88C5\u673A\u5C31\u662F\u767D\u5C4F\u2014\u2014\u8BF7\u786E\u8BA4\u7AD9\u70B9\u5DF2\u53D1\u5E03\u4E14\u5165\u53E3\u9875\u662F**\u6839\u7EA7** index.html\uFF08\`adep publish --only frontend\`\uFF09\uFF0C\u518D\u91CD\u8DD1 adep app build`
|
|
33934
|
-
);
|
|
33935
|
-
}
|
|
33936
|
-
throw new InitError(
|
|
33937
|
-
"APP_SITE_UNREADABLE",
|
|
33938
|
-
`\u7AD9\u70B9\u5165\u53E3\u9875\u8BFB\u4E0D\u51FA\u6765\uFF1A${indexPath}\uFF08${error62 instanceof Error ? error62.message : String(error62)}\uFF09`
|
|
33939
|
-
);
|
|
33940
|
-
}
|
|
33941
|
-
}
|
|
33942
|
-
async function injectMobileShellAssets(input2) {
|
|
33943
|
-
const siteRoot = join16(input2.shellDir, SHELL_SITE_DIR);
|
|
33944
|
-
const indexPath = join16(siteRoot, "index.html");
|
|
33945
|
-
const html = await readEntryPage(indexPath);
|
|
33946
|
-
const permissionsJson = `${JSON.stringify(
|
|
33947
|
-
{ schemaVersion: 1, permissions: sortPermissions(input2.permissions) },
|
|
33948
|
-
null,
|
|
33949
|
-
2
|
|
33950
|
-
)}
|
|
33951
|
-
`;
|
|
33952
|
-
await writeFile8(join16(siteRoot, MOBILE_SITE_ASSET_FILES.permissions), permissionsJson);
|
|
33953
|
-
await copyFile(
|
|
33954
|
-
join16(input2.shellDir, "web", "adep-bridge.js"),
|
|
33955
|
-
join16(siteRoot, MOBILE_SITE_ASSET_FILES.bridge)
|
|
33956
|
-
);
|
|
33957
|
-
await copyFile(
|
|
33958
|
-
join16(input2.shellDir, "adep.app.json"),
|
|
33959
|
-
join16(siteRoot, MOBILE_SITE_ASSET_FILES.config)
|
|
33960
|
-
);
|
|
33961
|
-
if (html.includes("adep-bridge.js")) return;
|
|
33962
|
-
const tag = '<script src="/adep-bridge.js"></script>';
|
|
33963
|
-
const next = html.includes("</head>") ? html.replace("</head>", `${tag}
|
|
33964
|
-
</head>`) : `${tag}
|
|
33965
|
-
${html}`;
|
|
33966
|
-
await writeFile8(indexPath, next);
|
|
33967
|
-
}
|
|
34043
|
+
|
|
34044
|
+
// packages/cli/src/app-build.ts
|
|
33968
34045
|
async function buildDesktopApp(options, deps) {
|
|
33969
34046
|
const shellDir = resolve8(options.dir);
|
|
33970
34047
|
const platform = normalizePlatform(options.platform);
|
|
@@ -33972,7 +34049,7 @@ async function buildDesktopApp(options, deps) {
|
|
|
33972
34049
|
const toolchain = normalizeToolchain(options.toolchain);
|
|
33973
34050
|
const prepareOnly = options.prepareOnly === true;
|
|
33974
34051
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
33975
|
-
const outDir =
|
|
34052
|
+
const outDir = join21(shellDir, SHELL_OUT_DIR);
|
|
33976
34053
|
if (isMobilePlatform(platform) && target === "dir") {
|
|
33977
34054
|
throw new InitError(
|
|
33978
34055
|
"INVALID_TARGET",
|
|
@@ -34033,7 +34110,7 @@ async function buildDesktopApp(options, deps) {
|
|
|
34033
34110
|
if (toolchain === "capacitor" && (platform === "ios" || platform === "android")) {
|
|
34034
34111
|
await (deps.runCapSync ?? syncCapacitorAssets)({ shellDir, platform });
|
|
34035
34112
|
}
|
|
34036
|
-
await
|
|
34113
|
+
await mkdir11(outDir, { recursive: true });
|
|
34037
34114
|
await (deps.runPackager ?? runPlatformPackager)({
|
|
34038
34115
|
shellDir,
|
|
34039
34116
|
platform,
|
|
@@ -34044,7 +34121,7 @@ async function buildDesktopApp(options, deps) {
|
|
|
34044
34121
|
});
|
|
34045
34122
|
artifacts = await findArtifacts(shellDir, outDir, platform, toolchain);
|
|
34046
34123
|
if (artifacts.length === 0) {
|
|
34047
|
-
const scanned = toolchain === "xtool" ?
|
|
34124
|
+
const scanned = toolchain === "xtool" ? join21(shellDir, XTOOL_ARTIFACT_DIR) : outDir;
|
|
34048
34125
|
const hint = toolchain === "xtool" ? "`xtool dev build --ipa` \u7684\u4EA7\u7269\u5E94\u5728 xtool/<product>.ipa\uFF08\u65E0\u8F93\u51FA\u4F4D\u53C2\u6570\uFF09\uFF1B\u8BF7\u68C0\u67E5 xtool \u662F\u5426\u771F\u7684\u8DD1\u5230\u4E86\u6253\u5305\uFF08\u800C\u4E0D\u662F\u5728\u7F16\u8BD1\u9636\u6BB5\u9000\u51FA\uFF09" : "\u8BF7\u68C0\u67E5\u58F3\u5DE5\u7A0B\u7684\u539F\u751F\u5DE5\u7A0B / build \u914D\u7F6E";
|
|
34049
34126
|
throw new InitError(
|
|
34050
34127
|
"APP_ARTIFACT_MISSING",
|
|
@@ -34053,7 +34130,7 @@ async function buildDesktopApp(options, deps) {
|
|
|
34053
34130
|
}
|
|
34054
34131
|
if (platform === "ios" && toolchain === "capacitor") {
|
|
34055
34132
|
for (const artifact of artifacts) {
|
|
34056
|
-
await assertUnsignedIosArchive(
|
|
34133
|
+
await assertUnsignedIosArchive(join21(shellDir, artifact));
|
|
34057
34134
|
}
|
|
34058
34135
|
}
|
|
34059
34136
|
if (platform === "linux" && target === "installer") {
|
|
@@ -34086,9 +34163,9 @@ async function buildDesktopApp(options, deps) {
|
|
|
34086
34163
|
artifacts,
|
|
34087
34164
|
warnings
|
|
34088
34165
|
};
|
|
34089
|
-
await
|
|
34090
|
-
const reportPath =
|
|
34091
|
-
await
|
|
34166
|
+
await mkdir11(outDir, { recursive: true });
|
|
34167
|
+
const reportPath = join21(outDir, REPORT_FILE);
|
|
34168
|
+
await writeFile11(reportPath, `${JSON.stringify(report, null, 2)}
|
|
34092
34169
|
`);
|
|
34093
34170
|
return {
|
|
34094
34171
|
appPath: shellDir,
|
|
@@ -34132,17 +34209,17 @@ async function createAppBuildApi(paths, cwd) {
|
|
|
34132
34209
|
}
|
|
34133
34210
|
|
|
34134
34211
|
// packages/cli/src/app-doctor.ts
|
|
34135
|
-
import { readFile as
|
|
34136
|
-
import { join as
|
|
34212
|
+
import { readFile as readFile17, stat as stat9 } from "node:fs/promises";
|
|
34213
|
+
import { join as join23 } from "node:path";
|
|
34137
34214
|
|
|
34138
34215
|
// packages/cli/src/app-offline-build.ts
|
|
34139
34216
|
init_zip();
|
|
34140
34217
|
init_auth();
|
|
34141
34218
|
import { createHash as createHash3 } from "node:crypto";
|
|
34142
|
-
import { access, copyFile as
|
|
34219
|
+
import { access, copyFile as copyFile3, mkdir as mkdir12, mkdtemp as mkdtemp2, readFile as readFile16, rm as rm4, writeFile as writeFile12 } from "node:fs/promises";
|
|
34143
34220
|
import { spawn as spawn3 } from "node:child_process";
|
|
34144
34221
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
34145
|
-
import { dirname as dirname11, join as
|
|
34222
|
+
import { dirname as dirname11, join as join22, posix as posix2, resolve as resolve9 } from "node:path";
|
|
34146
34223
|
init_client();
|
|
34147
34224
|
var SHELL_OFFLINE_DIR = "app/offline";
|
|
34148
34225
|
var SHELL_SITE_OFFLINE_DIR = "app/site/offline";
|
|
@@ -34184,15 +34261,15 @@ function collectOfflineEntries(entries) {
|
|
|
34184
34261
|
return collected;
|
|
34185
34262
|
}
|
|
34186
34263
|
async function writeOfflineTree(shellDir, collected, targetRel) {
|
|
34187
|
-
const targetRoot =
|
|
34264
|
+
const targetRoot = join22(shellDir, targetRel);
|
|
34188
34265
|
await rm4(targetRoot, { recursive: true, force: true });
|
|
34189
|
-
await
|
|
34266
|
+
await mkdir12(targetRoot, { recursive: true });
|
|
34190
34267
|
const written = [];
|
|
34191
34268
|
for (const [rel, bytes] of collected) {
|
|
34192
34269
|
if (rel.length === 0 || rel.endsWith("/")) continue;
|
|
34193
|
-
const dest =
|
|
34194
|
-
await
|
|
34195
|
-
await
|
|
34270
|
+
const dest = join22(targetRoot, ...rel.split("/"));
|
|
34271
|
+
await mkdir12(dirname11(dest), { recursive: true });
|
|
34272
|
+
await writeFile12(dest, bytes);
|
|
34196
34273
|
written.push({ path: `${targetRel}/${rel}`, size: bytes.length });
|
|
34197
34274
|
}
|
|
34198
34275
|
return written;
|
|
@@ -34286,14 +34363,14 @@ async function buildOfflineApp(options, deps) {
|
|
|
34286
34363
|
);
|
|
34287
34364
|
}
|
|
34288
34365
|
if (mobileOffline) {
|
|
34289
|
-
const entry =
|
|
34366
|
+
const entry = join22(shellDir, "app", "site", "index.html");
|
|
34290
34367
|
if (!await fileExists(entry)) {
|
|
34291
34368
|
throw new InitError(
|
|
34292
34369
|
"APP_SITE_MISSING",
|
|
34293
34370
|
`\u79BB\u7EBF\u5305\u7F3A\u9875\u9762\u4EA7\u7269\uFF1A${entry} \u4E0D\u5B58\u5728\u3002\u8BF7\u5148\u6267\u884C ` + (toolchain === "xtool" ? "`adep app build --platform ios --toolchain xtool`\uFF08\u62C9\u53D6\u9875\u9762\u4EA7\u7269\u5E76\u6CE8\u5165\u9875\u9762\u6865 / \u58F3\u914D\u7F6E\uFF09\uFF0C" : "`adep app build --platform android`\uFF08\u62C9\u53D6\u9875\u9762\u4EA7\u7269\u5E76\u6CE8\u5165\u9875\u9762\u6865 / \u58F3\u914D\u7F6E\uFF09\uFF0C") + "\u518D\u6267\u884C\u79BB\u7EBF\u6784\u5EFA\u2014\u2014\u79BB\u7EBF\u6784\u5EFA\u53EA\u8FFD\u52A0 site/offline/ \u5B50\u6811\uFF0C\u4E0D\u4EA7\u751F\u9875\u9762\u672C\u4F53"
|
|
34294
34371
|
);
|
|
34295
34372
|
}
|
|
34296
|
-
const loaderSource =
|
|
34373
|
+
const loaderSource = join22(shellDir, MOBILE_OFFLINE_LOADER.source);
|
|
34297
34374
|
if (!await fileExists(loaderSource)) {
|
|
34298
34375
|
throw new InitError(
|
|
34299
34376
|
"OFFLINE_LOADER_MISSING",
|
|
@@ -34318,11 +34395,11 @@ ${finished.error ?? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B\u539F\u56E0"}
|
|
|
34318
34395
|
\uFF08\u8FD9\u4E9B\u51FD\u6570\u4E0D\u53EF\u79FB\u690D\u5230\u8BBE\u5907\u7AEF\uFF1B\u4ECE\u6253\u5305\u914D\u7F6E\u7684\u79BB\u7EBF\u767D\u540D\u5355\u79FB\u9664\u540E\u91CD\u65B0\u4FDD\u5B58\uFF0C\u5373\u53EF\u7EE7\u7EED\u6784\u5EFA\uFF09`
|
|
34319
34396
|
);
|
|
34320
34397
|
}
|
|
34321
|
-
const workDir = await mkdtemp2(
|
|
34398
|
+
const workDir = await mkdtemp2(join22(tmpdir2(), "adep-app-offline-build-"));
|
|
34322
34399
|
try {
|
|
34323
|
-
const bundlePath =
|
|
34400
|
+
const bundlePath = join22(workDir, "bundle.adepack");
|
|
34324
34401
|
await deps.api.downloadBundle(project2.id, finished.id, bundlePath);
|
|
34325
|
-
const entries = zipRead(await
|
|
34402
|
+
const entries = zipRead(await readFile16(bundlePath));
|
|
34326
34403
|
const manifest = readManifest(entries, { allowOfflinePortZero: true });
|
|
34327
34404
|
const collected = collectOfflineEntries(entries);
|
|
34328
34405
|
const functionEntries = readFunctionsIndex(collected);
|
|
@@ -34331,9 +34408,9 @@ ${finished.error ?? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B\u539F\u56E0"}
|
|
|
34331
34408
|
if (mobileOffline) {
|
|
34332
34409
|
const permissions = sortPermissions(await deps.api.getPackagingPermissions(project2.id));
|
|
34333
34410
|
await injectMobileShellAssets({ shellDir, permissions });
|
|
34334
|
-
await
|
|
34335
|
-
|
|
34336
|
-
|
|
34411
|
+
await copyFile3(
|
|
34412
|
+
join22(shellDir, MOBILE_OFFLINE_LOADER.source),
|
|
34413
|
+
join22(shellDir, MOBILE_OFFLINE_LOADER.dest)
|
|
34337
34414
|
);
|
|
34338
34415
|
}
|
|
34339
34416
|
const builtAt = now().toISOString();
|
|
@@ -34349,13 +34426,13 @@ ${finished.error ?? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B\u539F\u56E0"}
|
|
|
34349
34426
|
platform: "ios",
|
|
34350
34427
|
target: "installer",
|
|
34351
34428
|
toolchain: "xtool",
|
|
34352
|
-
outDir:
|
|
34429
|
+
outDir: join22(shellDir, "dist")
|
|
34353
34430
|
});
|
|
34354
|
-
artifacts = await findArtifacts(shellDir,
|
|
34431
|
+
artifacts = await findArtifacts(shellDir, join22(shellDir, "dist"), "ios", "xtool");
|
|
34355
34432
|
} else if (androidOffline) {
|
|
34356
34433
|
await (deps.runCapSync ?? syncCapacitorAssets)({ shellDir, platform: "android" });
|
|
34357
|
-
const outDir2 =
|
|
34358
|
-
await
|
|
34434
|
+
const outDir2 = join22(shellDir, "dist");
|
|
34435
|
+
await mkdir12(outDir2, { recursive: true });
|
|
34359
34436
|
await runner({
|
|
34360
34437
|
shellDir,
|
|
34361
34438
|
platform: "android",
|
|
@@ -34366,8 +34443,8 @@ ${finished.error ?? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B\u539F\u56E0"}
|
|
|
34366
34443
|
artifacts = await findArtifacts(shellDir, outDir2, "android");
|
|
34367
34444
|
} else {
|
|
34368
34445
|
const platform = resolveOfflinePlatform();
|
|
34369
|
-
const outDir2 =
|
|
34370
|
-
await
|
|
34446
|
+
const outDir2 = join22(shellDir, "dist");
|
|
34447
|
+
await mkdir12(outDir2, { recursive: true });
|
|
34371
34448
|
await runner({
|
|
34372
34449
|
shellDir,
|
|
34373
34450
|
platform,
|
|
@@ -34380,7 +34457,7 @@ ${finished.error ?? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B\u539F\u56E0"}
|
|
|
34380
34457
|
if (artifacts.length === 0) {
|
|
34381
34458
|
throw new InitError(
|
|
34382
34459
|
"APP_ARTIFACT_MISSING",
|
|
34383
|
-
toolchain === "xtool" ? `\u6253\u5305\u5668\u5DF2\u6267\u884C\u4F46 ${
|
|
34460
|
+
toolchain === "xtool" ? `\u6253\u5305\u5668\u5DF2\u6267\u884C\u4F46 ${join22(shellDir, "xtool")} \u4E0B\u6CA1\u6709 ios \u4EA7\u7269\uFF1A\`xtool dev build --ipa\` \u7684\u4EA7\u7269\u5E94\u5728 xtool/<product>.ipa\uFF08\u65E0\u8F93\u51FA\u4F4D\u53C2\u6570\uFF09\uFF1B\u8BF7\u68C0\u67E5 xtool \u662F\u5426\u771F\u7684\u8DD1\u5230\u4E86\u6253\u5305\uFF08\u800C\u4E0D\u662F\u5728\u7F16\u8BD1\u9636\u6BB5\u9000\u51FA\uFF09` : androidOffline ? `\u6253\u5305\u5668\u5DF2\u6267\u884C\u4F46 ${join22(shellDir, "dist")} \u4E0B\u6CA1\u6709 android \u4EA7\u7269\uFF1Agradle assembleRelease \u7684 APK \u5E94\u5DF2\u88AB\u590D\u5236\u8FDB dist/\uFF08\u89C1 copyGradleApkToOutDir\uFF09\uFF1B\u8BF7\u68C0\u67E5 android \u5DE5\u7A0B\u7684\u6784\u5EFA\u53D8\u4F53\u914D\u7F6E` : `electron-builder \u5DF2\u6267\u884C\u4F46 ${join22(shellDir, "dist")} \u4E0B\u6CA1\u6709\u4EA7\u7269\uFF1A\u8BF7\u68C0\u67E5\u58F3\u5DE5\u7A0B build \u914D\u7F6E\u7684 target`
|
|
34384
34461
|
);
|
|
34385
34462
|
}
|
|
34386
34463
|
}
|
|
@@ -34408,10 +34485,10 @@ ${finished.error ?? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B\u539F\u56E0"}
|
|
|
34408
34485
|
},
|
|
34409
34486
|
artifacts
|
|
34410
34487
|
};
|
|
34411
|
-
const outDir =
|
|
34412
|
-
await
|
|
34413
|
-
const reportPath =
|
|
34414
|
-
await
|
|
34488
|
+
const outDir = join22(shellDir, "dist");
|
|
34489
|
+
await mkdir12(outDir, { recursive: true });
|
|
34490
|
+
const reportPath = join22(outDir, "build-report.json");
|
|
34491
|
+
await writeFile12(reportPath, `${JSON.stringify(report, null, 2)}
|
|
34415
34492
|
`);
|
|
34416
34493
|
return {
|
|
34417
34494
|
appPath: shellDir,
|
|
@@ -34472,7 +34549,7 @@ async function createAppOfflineBuildApi(paths, cwd) {
|
|
|
34472
34549
|
}
|
|
34473
34550
|
const response = await client.download(downloadUrl, "APP_OFFLINE_BUILD_DOWNLOAD_FAILED");
|
|
34474
34551
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
34475
|
-
await
|
|
34552
|
+
await writeFile12(outputPath, bytes);
|
|
34476
34553
|
return { path: outputPath, size: bytes.length };
|
|
34477
34554
|
},
|
|
34478
34555
|
// 与在线构建 `AppBuildDeps.getPackagingPermissions` 同一端点同一读法(app-build.ts 同款)。
|
|
@@ -34510,7 +34587,7 @@ async function pathExists2(path) {
|
|
|
34510
34587
|
}
|
|
34511
34588
|
async function missingEntries(root, rels) {
|
|
34512
34589
|
const probed = await Promise.all(
|
|
34513
|
-
rels.map(async (rel) => ({ rel, exists: await pathExists2(
|
|
34590
|
+
rels.map(async (rel) => ({ rel, exists: await pathExists2(join23(root, ...rel.split("/"))) }))
|
|
34514
34591
|
);
|
|
34515
34592
|
return probed.filter((entry) => !entry.exists).map((entry) => entry.rel);
|
|
34516
34593
|
}
|
|
@@ -34524,10 +34601,10 @@ async function resolveTargets(shellDir, template, platform) {
|
|
|
34524
34601
|
if (template === "app-mobile-xtool") return [{ platform: "ios", toolchain: "xtool" }];
|
|
34525
34602
|
if (template === "app-mobile") {
|
|
34526
34603
|
const targets = [];
|
|
34527
|
-
if (await pathExists2(
|
|
34604
|
+
if (await pathExists2(join23(shellDir, "ios", "App"))) {
|
|
34528
34605
|
targets.push({ platform: "ios", toolchain: "capacitor" });
|
|
34529
34606
|
}
|
|
34530
|
-
if (await pathExists2(
|
|
34607
|
+
if (await pathExists2(join23(shellDir, "android", "gradlew"))) {
|
|
34531
34608
|
targets.push({ platform: "android", toolchain: "capacitor" });
|
|
34532
34609
|
}
|
|
34533
34610
|
return targets;
|
|
@@ -34535,10 +34612,10 @@ async function resolveTargets(shellDir, template, platform) {
|
|
|
34535
34612
|
return [];
|
|
34536
34613
|
}
|
|
34537
34614
|
async function checkConfigDrift(shellDir, config2) {
|
|
34538
|
-
const siteConfigPath =
|
|
34615
|
+
const siteConfigPath = join23(shellDir, SHELL_SITE_DIR, MOBILE_SITE_ASSET_FILES.config);
|
|
34539
34616
|
let text;
|
|
34540
34617
|
try {
|
|
34541
|
-
text = await
|
|
34618
|
+
text = await readFile17(siteConfigPath, "utf8");
|
|
34542
34619
|
} catch {
|
|
34543
34620
|
return {
|
|
34544
34621
|
id: "configDrift",
|
|
@@ -34579,8 +34656,8 @@ async function checkConfigDrift(shellDir, config2) {
|
|
|
34579
34656
|
};
|
|
34580
34657
|
}
|
|
34581
34658
|
async function checkOffline(shellDir) {
|
|
34582
|
-
const desktopRoot =
|
|
34583
|
-
const siteRoot =
|
|
34659
|
+
const desktopRoot = join23(shellDir, SHELL_OFFLINE_DIR);
|
|
34660
|
+
const siteRoot = join23(shellDir, SHELL_SITE_OFFLINE_DIR);
|
|
34584
34661
|
const hasDesktop = await pathExists2(desktopRoot);
|
|
34585
34662
|
const hasSite = await pathExists2(siteRoot);
|
|
34586
34663
|
if (!hasDesktop && !hasSite) {
|
|
@@ -34613,7 +34690,7 @@ async function checkOffline(shellDir) {
|
|
|
34613
34690
|
let functions = [];
|
|
34614
34691
|
try {
|
|
34615
34692
|
const index = JSON.parse(
|
|
34616
|
-
await
|
|
34693
|
+
await readFile17(join23(root, ...OFFLINE_BUNDLE_PATHS.functionsIndex.split("/")), "utf8")
|
|
34617
34694
|
);
|
|
34618
34695
|
functions = index.functions ?? [];
|
|
34619
34696
|
} catch (error62) {
|
|
@@ -34626,7 +34703,7 @@ async function checkOffline(shellDir) {
|
|
|
34626
34703
|
};
|
|
34627
34704
|
}
|
|
34628
34705
|
const missingSources = (await missingEntries(
|
|
34629
|
-
|
|
34706
|
+
join23(root, "functions"),
|
|
34630
34707
|
functions.map((entry) => typeof entry.name === "string" ? entry.name : "").filter((name) => name !== "").map((name) => `${name}.mjs`)
|
|
34631
34708
|
)).map((rel) => rel.slice(0, -".mjs".length));
|
|
34632
34709
|
if (missingSources.length > 0) {
|
|
@@ -34654,10 +34731,10 @@ async function checkIdentity(shellDir, desktopShaped) {
|
|
|
34654
34731
|
detail: "\u79FB\u52A8\u58F3\u5F62\u6001\uFF1A\u8EAB\u4EFD\u5728 Keychain / Keystore\uFF08\u672C\u9879\u53EA\u8BFB\u684C\u9762\u58F3\u7684\u72B6\u6001\u6587\u4EF6\uFF09"
|
|
34655
34732
|
};
|
|
34656
34733
|
}
|
|
34657
|
-
const file2 =
|
|
34734
|
+
const file2 = join23(shellDir, IDENTITY_STATUS_REL);
|
|
34658
34735
|
let text;
|
|
34659
34736
|
try {
|
|
34660
|
-
text = await
|
|
34737
|
+
text = await readFile17(file2, "utf8");
|
|
34661
34738
|
} catch {
|
|
34662
34739
|
return {
|
|
34663
34740
|
id: "identity",
|
|
@@ -34792,7 +34869,7 @@ async function runShellDoctor(shellDir, deps = {}) {
|
|
|
34792
34869
|
}
|
|
34793
34870
|
let html;
|
|
34794
34871
|
try {
|
|
34795
|
-
html = await readEntryPage(
|
|
34872
|
+
html = await readEntryPage(join23(shellDir, SHELL_SITE_DIR, "index.html"));
|
|
34796
34873
|
checks.push({
|
|
34797
34874
|
id: "siteEntry",
|
|
34798
34875
|
status: "ok",
|
|
@@ -34810,7 +34887,7 @@ async function runShellDoctor(shellDir, deps = {}) {
|
|
|
34810
34887
|
}
|
|
34811
34888
|
const desktopShaped = config2.template === "app-desktop";
|
|
34812
34889
|
if (desktopShaped) {
|
|
34813
|
-
if (await pathExists2(
|
|
34890
|
+
if (await pathExists2(join23(shellDir, "preload.cjs"))) {
|
|
34814
34891
|
checks.push({
|
|
34815
34892
|
id: "bridgeTag",
|
|
34816
34893
|
status: "ok",
|
|
@@ -34855,7 +34932,7 @@ async function runShellDoctor(shellDir, deps = {}) {
|
|
|
34855
34932
|
});
|
|
34856
34933
|
} else {
|
|
34857
34934
|
const missingAssets = await missingEntries(
|
|
34858
|
-
|
|
34935
|
+
join23(shellDir, SHELL_SITE_DIR),
|
|
34859
34936
|
Object.values(MOBILE_SITE_ASSET_FILES)
|
|
34860
34937
|
);
|
|
34861
34938
|
if (missingAssets.length === 0) {
|
|
@@ -34924,8 +35001,8 @@ function formatShellDoctorReport(report) {
|
|
|
34924
35001
|
}
|
|
34925
35002
|
|
|
34926
35003
|
// packages/cli/src/app-sync.ts
|
|
34927
|
-
import { readFile as
|
|
34928
|
-
import { join as
|
|
35004
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
35005
|
+
import { join as join24 } from "node:path";
|
|
34929
35006
|
|
|
34930
35007
|
// packages/app-runtime/src/device-sqlite.ts
|
|
34931
35008
|
function createDeviceSqliteDriver(sqlite) {
|
|
@@ -35361,7 +35438,7 @@ var APP_SYNC_CODES = {
|
|
|
35361
35438
|
/** 当前运行时无 SQLite 内建模块(需要 Bun 或 Node ≥ 22.5)。 */
|
|
35362
35439
|
runtimeUnsupported: "APP_SYNC_RUNTIME_UNSUPPORTED"
|
|
35363
35440
|
};
|
|
35364
|
-
var LOCAL_DB_REL =
|
|
35441
|
+
var LOCAL_DB_REL = join24("data", "offline.sqlite");
|
|
35365
35442
|
function resolveOwnerKey(explicit) {
|
|
35366
35443
|
const fromEnv = process.env["ADEP_OWNER_KEY"];
|
|
35367
35444
|
const value = (explicit ?? fromEnv ?? "").trim();
|
|
@@ -35436,9 +35513,9 @@ async function runAppSync(options) {
|
|
|
35436
35513
|
);
|
|
35437
35514
|
}
|
|
35438
35515
|
const ownerKey = resolveOwnerKey(options.ownerKey);
|
|
35439
|
-
const localDb =
|
|
35516
|
+
const localDb = join24(shellDir, LOCAL_DB_REL);
|
|
35440
35517
|
try {
|
|
35441
|
-
await
|
|
35518
|
+
await readFile18(localDb);
|
|
35442
35519
|
} catch (error62) {
|
|
35443
35520
|
const code = error62.code;
|
|
35444
35521
|
if (code === "ENOENT" || code === "EISDIR") {
|
|
@@ -35499,14 +35576,14 @@ function formatAppSyncReport(report) {
|
|
|
35499
35576
|
// packages/cli/src/app-open.ts
|
|
35500
35577
|
import { spawn as spawn4 } from "node:child_process";
|
|
35501
35578
|
import { stat as stat10 } from "node:fs/promises";
|
|
35502
|
-
import { join as
|
|
35579
|
+
import { join as join25 } from "node:path";
|
|
35503
35580
|
var OPEN_UNSUPPORTED_HINT = {
|
|
35504
35581
|
"app-mobile": "\u79FB\u52A8\u58F3\u6CA1\u6709\u5F00\u53D1\u9884\u89C8\u8DEF\u5F84\uFF1A\u4E0B\u4E00\u6B65\u662F npm install && npx cap add ios / android\uFF08\u539F\u751F\u5DE5\u7A0B\u7531 Capacitor \u751F\u6210\uFF09\uFF0C\u968F\u540E\u5728 Xcode / Android Studio \u91CC\u8FD0\u884C",
|
|
35505
35582
|
"app-mobile-xtool": "xtool \u79FB\u52A8\u58F3\u6CA1\u6709\u5F00\u53D1\u9884\u89C8\u8DEF\u5F84\uFF1A\u5728\u8BE5\u76EE\u5F55\u6267\u884C xtool dev\uFF08\u9009\u8BBE\u5907\uFF09\u2014\u2014\u4E0D\u9700\u8981 npm start"
|
|
35506
35583
|
};
|
|
35507
35584
|
function resolveDevBinary(shellDir) {
|
|
35508
35585
|
const name = process.platform === "win32" ? "electron.cmd" : "electron";
|
|
35509
|
-
return
|
|
35586
|
+
return join25(shellDir, "node_modules", ".bin", name);
|
|
35510
35587
|
}
|
|
35511
35588
|
function defaultSpawnDev(command, args, options) {
|
|
35512
35589
|
return spawn4(command, args, { cwd: options.cwd, stdio: "inherit" });
|
|
@@ -35792,8 +35869,8 @@ function registerApp(program2, ctx) {
|
|
|
35792
35869
|
// packages/cli/src/import-cf.ts
|
|
35793
35870
|
init_adep_config();
|
|
35794
35871
|
init_regexp();
|
|
35795
|
-
import { copyFile as
|
|
35796
|
-
import { basename as basename3, dirname as dirname12, join as
|
|
35872
|
+
import { copyFile as copyFile4, mkdir as mkdir13, readFile as readFile19, readdir as readdir8, stat as stat11, writeFile as writeFile13 } from "node:fs/promises";
|
|
35873
|
+
import { basename as basename3, dirname as dirname12, join as join26, relative as relative3, resolve as resolve11 } from "node:path";
|
|
35797
35874
|
var TomlSyntaxError = class extends Error {
|
|
35798
35875
|
constructor(message) {
|
|
35799
35876
|
super(message);
|
|
@@ -36047,13 +36124,13 @@ var SKIP_COPY_NAMES = /* @__PURE__ */ new Set([
|
|
|
36047
36124
|
async function copyWorkerDir(sourceDir, targetDir, mainFile) {
|
|
36048
36125
|
const copied = [];
|
|
36049
36126
|
const renamedIndex = [];
|
|
36050
|
-
const entries = await
|
|
36127
|
+
const entries = await readdir8(sourceDir, { withFileTypes: true });
|
|
36051
36128
|
for (const entry of entries) {
|
|
36052
|
-
const from =
|
|
36053
|
-
const to =
|
|
36129
|
+
const from = join26(sourceDir, entry.name);
|
|
36130
|
+
const to = join26(targetDir, entry.name);
|
|
36054
36131
|
if (SKIP_COPY_NAMES.has(entry.name)) continue;
|
|
36055
36132
|
if (entry.isDirectory()) {
|
|
36056
|
-
await
|
|
36133
|
+
await mkdir13(to, { recursive: true });
|
|
36057
36134
|
const sub = await copyWorkerDir(from, to, "");
|
|
36058
36135
|
copied.push(...sub.copied);
|
|
36059
36136
|
renamedIndex.push(...sub.renamedIndex);
|
|
@@ -36061,18 +36138,18 @@ async function copyWorkerDir(sourceDir, targetDir, mainFile) {
|
|
|
36061
36138
|
}
|
|
36062
36139
|
if (from === mainFile) continue;
|
|
36063
36140
|
if (entry.name === "index.ts") {
|
|
36064
|
-
await
|
|
36141
|
+
await copyFile4(from, join26(targetDir, "_index.ts"));
|
|
36065
36142
|
renamedIndex.push("_index.ts");
|
|
36066
36143
|
continue;
|
|
36067
36144
|
}
|
|
36068
|
-
await
|
|
36145
|
+
await copyFile4(from, to);
|
|
36069
36146
|
copied.push(relative3(targetDir, to));
|
|
36070
36147
|
}
|
|
36071
36148
|
return { copied, renamedIndex };
|
|
36072
36149
|
}
|
|
36073
36150
|
async function readDevVars(sourceDir) {
|
|
36074
36151
|
try {
|
|
36075
|
-
const text = await
|
|
36152
|
+
const text = await readFile19(join26(sourceDir, ".dev.vars"), "utf8");
|
|
36076
36153
|
const vars = {};
|
|
36077
36154
|
for (const line of text.split(/\r?\n/)) {
|
|
36078
36155
|
const trimmed = line.trim();
|
|
@@ -36090,19 +36167,19 @@ async function readDevVars(sourceDir) {
|
|
|
36090
36167
|
async function copyAssetsToWeb(sourceDir, assetsDir, outDir) {
|
|
36091
36168
|
const files = [];
|
|
36092
36169
|
const from = resolve11(sourceDir, assetsDir);
|
|
36093
|
-
const target =
|
|
36094
|
-
await
|
|
36095
|
-
const entries = await
|
|
36170
|
+
const target = join26(outDir, "web");
|
|
36171
|
+
await mkdir13(target, { recursive: true });
|
|
36172
|
+
const entries = await readdir8(from, { withFileTypes: true });
|
|
36096
36173
|
for (const entry of entries) {
|
|
36097
|
-
const src =
|
|
36098
|
-
const dst =
|
|
36174
|
+
const src = join26(from, entry.name);
|
|
36175
|
+
const dst = join26(target, entry.name);
|
|
36099
36176
|
if (entry.isDirectory()) {
|
|
36100
|
-
await
|
|
36177
|
+
await mkdir13(dst, { recursive: true });
|
|
36101
36178
|
const sub = await copyAssetsToWeb(src, ".", outDir);
|
|
36102
36179
|
files.push(...sub);
|
|
36103
36180
|
continue;
|
|
36104
36181
|
}
|
|
36105
|
-
await
|
|
36182
|
+
await copyFile4(src, dst);
|
|
36106
36183
|
files.push(relative3(outDir, dst));
|
|
36107
36184
|
}
|
|
36108
36185
|
return files;
|
|
@@ -36351,11 +36428,11 @@ function renderImportPackageJson(name) {
|
|
|
36351
36428
|
async function importCfProject(cwd, sourceDir, options = {}) {
|
|
36352
36429
|
let tomlText;
|
|
36353
36430
|
try {
|
|
36354
|
-
tomlText = await
|
|
36431
|
+
tomlText = await readFile19(join26(sourceDir, "wrangler.toml"), "utf8");
|
|
36355
36432
|
} catch {
|
|
36356
36433
|
throw new ImportCfError(
|
|
36357
36434
|
"NO_WRANGLER",
|
|
36358
|
-
`\u627E\u4E0D\u5230 ${
|
|
36435
|
+
`\u627E\u4E0D\u5230 ${join26(sourceDir, "wrangler.toml")}\uFF1A\u9700\u5728 Cloudflare \u9879\u76EE\u6839\u6267\u884C\u5BFC\u5165`
|
|
36359
36436
|
);
|
|
36360
36437
|
}
|
|
36361
36438
|
let config2;
|
|
@@ -36390,10 +36467,10 @@ async function importCfProject(cwd, sourceDir, options = {}) {
|
|
|
36390
36467
|
const configText = renderAdepConfig(adepConfig, {
|
|
36391
36468
|
header: "// \u7531 adep import cf \u751F\u6210\uFF08CF-015\uFF09\uFF1A\u7ED1\u5B9A\u58F0\u660E\u4E0E wrangler.toml \u5BF9\u5E94"
|
|
36392
36469
|
});
|
|
36393
|
-
await
|
|
36394
|
-
await
|
|
36470
|
+
await mkdir13(outDir, { recursive: true });
|
|
36471
|
+
await writeFile13(join26(outDir, "adep.config.ts"), configText, "utf8");
|
|
36395
36472
|
files.push("adep.config.ts");
|
|
36396
|
-
await
|
|
36473
|
+
await writeFile13(join26(outDir, "package.json"), renderImportPackageJson(workerName), "utf8");
|
|
36397
36474
|
files.push("package.json");
|
|
36398
36475
|
let mainCopied = false;
|
|
36399
36476
|
if (config2.main !== void 0) {
|
|
@@ -36407,9 +36484,9 @@ async function importCfProject(cwd, sourceDir, options = {}) {
|
|
|
36407
36484
|
if (!mainStat.isFile()) {
|
|
36408
36485
|
throw new ImportCfError("MAIN_NOT_FILE", `main \u4E0D\u662F\u6587\u4EF6\uFF1A${config2.main}`);
|
|
36409
36486
|
}
|
|
36410
|
-
const fnDir =
|
|
36411
|
-
await
|
|
36412
|
-
await
|
|
36487
|
+
const fnDir = join26(outDir, "functions", workerName);
|
|
36488
|
+
await mkdir13(fnDir, { recursive: true });
|
|
36489
|
+
await copyFile4(mainAbs, join26(fnDir, "worker.ts"));
|
|
36413
36490
|
files.push(`functions/${workerName}/worker.ts`);
|
|
36414
36491
|
mainCopied = true;
|
|
36415
36492
|
const mainDir = dirname12(mainAbs);
|
|
@@ -36423,7 +36500,7 @@ async function importCfProject(cwd, sourceDir, options = {}) {
|
|
|
36423
36500
|
if (copied.length > 0) {
|
|
36424
36501
|
warnings.push(`\u5DF2\u590D\u5236\u540C\u76EE\u5F55\u4F9D\u8D56\u6A21\u5757 ${copied.length} \u4E2A\uFF08\u4FDD\u6301\u76F8\u5BF9 import\uFF09`);
|
|
36425
36502
|
}
|
|
36426
|
-
await
|
|
36503
|
+
await writeFile13(join26(fnDir, "index.ts"), renderFunctionEntry("worker", cfBindings), "utf8");
|
|
36427
36504
|
files.push(`functions/${workerName}/index.ts`);
|
|
36428
36505
|
}
|
|
36429
36506
|
let dosMigrated = 0;
|
|
@@ -36438,20 +36515,20 @@ async function importCfProject(cwd, sourceDir, options = {}) {
|
|
|
36438
36515
|
);
|
|
36439
36516
|
}
|
|
36440
36517
|
if (doBindings.length > 0) {
|
|
36441
|
-
const fnDir =
|
|
36442
|
-
const workerPath =
|
|
36443
|
-
const workerText = await
|
|
36518
|
+
const fnDir = join26(outDir, "functions", workerName);
|
|
36519
|
+
const workerPath = join26(fnDir, "worker.ts");
|
|
36520
|
+
const workerText = await readFile19(workerPath, "utf8");
|
|
36444
36521
|
const { text: stripped, removed } = stripDurableObjectClasses(
|
|
36445
36522
|
workerText,
|
|
36446
36523
|
doBindings.map((b) => b.className)
|
|
36447
36524
|
);
|
|
36448
|
-
await
|
|
36525
|
+
await writeFile13(workerPath, stripped, "utf8");
|
|
36449
36526
|
if (removed.length > 0) {
|
|
36450
|
-
await
|
|
36527
|
+
await mkdir13(join26(fnDir, "durable-objects"), { recursive: true });
|
|
36451
36528
|
await Promise.all(
|
|
36452
36529
|
removed.map(async (r) => {
|
|
36453
|
-
await
|
|
36454
|
-
|
|
36530
|
+
await writeFile13(
|
|
36531
|
+
join26(fnDir, "durable-objects", `${r.className}.ts`),
|
|
36455
36532
|
`${r.source}
|
|
36456
36533
|
`,
|
|
36457
36534
|
"utf8"
|
|
@@ -36461,8 +36538,8 @@ async function importCfProject(cwd, sourceDir, options = {}) {
|
|
|
36461
36538
|
);
|
|
36462
36539
|
}
|
|
36463
36540
|
if (removed.length > 0) {
|
|
36464
|
-
await
|
|
36465
|
-
|
|
36541
|
+
await writeFile13(
|
|
36542
|
+
join26(fnDir, "state-objects.ts"),
|
|
36466
36543
|
renderStateObjectDeclaration(doBindings, removed),
|
|
36467
36544
|
"utf8"
|
|
36468
36545
|
);
|
|
@@ -36507,7 +36584,7 @@ async function importCfProject(cwd, sourceDir, options = {}) {
|
|
|
36507
36584
|
unsupported,
|
|
36508
36585
|
warnings
|
|
36509
36586
|
});
|
|
36510
|
-
await
|
|
36587
|
+
await writeFile13(join26(outDir, "MIGRATION.md"), migration, "utf8");
|
|
36511
36588
|
files.push("MIGRATION.md");
|
|
36512
36589
|
if (!mainCopied) {
|
|
36513
36590
|
warnings.push("wrangler.toml \u672A\u58F0\u660E main\uFF1A\u672A\u751F\u6210\u51FD\u6570\uFF0C\u4EC5\u751F\u6210\u914D\u7F6E\u4E0E\u62A5\u544A");
|
|
@@ -36628,7 +36705,7 @@ init_auth();
|
|
|
36628
36705
|
init_client();
|
|
36629
36706
|
init_deploy();
|
|
36630
36707
|
import { stat as stat16 } from "node:fs/promises";
|
|
36631
|
-
import { join as
|
|
36708
|
+
import { join as join33, resolve as resolve16 } from "node:path";
|
|
36632
36709
|
async function resolveProjectId2(client, cwd, slug) {
|
|
36633
36710
|
const resolvedSlug = await resolveSlug(resolve16(cwd), slug);
|
|
36634
36711
|
const listed = await client.request("/api/v1/projects", {}, "PROJECT_LIST_FAILED");
|
|
@@ -36675,8 +36752,8 @@ async function publishStaticFrontend(paths, options) {
|
|
|
36675
36752
|
"\u7EAF\u9759\u6001\u7AD9\u6682\u4E0D\u652F\u6301\u53D1\u5230\u5F00\u53D1\u7AD9\u70B9\uFF1A\u8BE5\u901A\u9053\u76F4\u63A5\u4E0A\u4F20 site/\uFF0C\u4F1A\u8986\u76D6\u7EBF\u4E0A\u7AD9\u70B9\u3002\u8BF7\u6539\u7528\u5E73\u53F0\u6784\u5EFA\u901A\u9053\uFF08\u5728 web/ \u58F0\u660E scripts.build\uFF09\uFF0C\u6216\u7528 --only functions \u4E4B\u5916\u7684\u5176\u5B83\u65B9\u5F0F\u9A8C\u8BC1\u3002"
|
|
36676
36753
|
);
|
|
36677
36754
|
}
|
|
36678
|
-
const webDir =
|
|
36679
|
-
const indexStat = await stat16(
|
|
36755
|
+
const webDir = join33(options.cwd, "web");
|
|
36756
|
+
const indexStat = await stat16(join33(webDir, "index.html")).catch(() => null);
|
|
36680
36757
|
if (indexStat === null || !indexStat.isFile()) {
|
|
36681
36758
|
throw new CliError(
|
|
36682
36759
|
"FRONTEND_NO_PAGE",
|
|
@@ -36729,7 +36806,7 @@ async function runPublish(paths, io, cwd, flags) {
|
|
|
36729
36806
|
});
|
|
36730
36807
|
}
|
|
36731
36808
|
if (wantFrontend) {
|
|
36732
|
-
const webDir =
|
|
36809
|
+
const webDir = join33(cwd, "web");
|
|
36733
36810
|
const webStat = await stat16(webDir).catch(() => null);
|
|
36734
36811
|
if (webStat !== null && webStat.isDirectory()) {
|
|
36735
36812
|
const { isStaticFrontendDir: isStaticFrontendDir2 } = await Promise.resolve().then(() => (init_frontend(), frontend_exports));
|
|
@@ -36830,8 +36907,8 @@ init_auth();
|
|
|
36830
36907
|
// packages/cli/src/deploy-worker.ts
|
|
36831
36908
|
init_auth();
|
|
36832
36909
|
init_client();
|
|
36833
|
-
import { readdir as
|
|
36834
|
-
import { join as
|
|
36910
|
+
import { readdir as readdir12, readFile as readFile26 } from "node:fs/promises";
|
|
36911
|
+
import { join as join34, relative as relative8, resolve as resolve17, sep as sep4 } from "node:path";
|
|
36835
36912
|
async function collectWranglerFiles(dir) {
|
|
36836
36913
|
const root = resolve17(dir);
|
|
36837
36914
|
const out = {};
|
|
@@ -36839,7 +36916,7 @@ async function collectWranglerFiles(dir) {
|
|
|
36839
36916
|
const walk = async (sub) => {
|
|
36840
36917
|
let entries;
|
|
36841
36918
|
try {
|
|
36842
|
-
entries = await
|
|
36919
|
+
entries = await readdir12(sub, { withFileTypes: true });
|
|
36843
36920
|
} catch (error62) {
|
|
36844
36921
|
throw new CliError(
|
|
36845
36922
|
"WORKER_DIR_UNREADABLE",
|
|
@@ -36848,11 +36925,11 @@ async function collectWranglerFiles(dir) {
|
|
|
36848
36925
|
}
|
|
36849
36926
|
for (const entry of entries) {
|
|
36850
36927
|
if (entry.isDirectory() && skip.has(entry.name)) continue;
|
|
36851
|
-
const full =
|
|
36928
|
+
const full = join34(sub, entry.name);
|
|
36852
36929
|
if (entry.isDirectory()) {
|
|
36853
36930
|
await walk(full);
|
|
36854
36931
|
} else if (entry.isFile()) {
|
|
36855
|
-
const buf = await
|
|
36932
|
+
const buf = await readFile26(full).catch(() => null);
|
|
36856
36933
|
if (buf === null) continue;
|
|
36857
36934
|
if (buf.includes(0)) continue;
|
|
36858
36935
|
out[relative8(root, full).split(sep4).join("/")] = buf.toString("utf8");
|