@adep/cli 0.5.4 → 0.5.5
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/README.md +1 -1
- package/dist/index.js +211 -18
- package/dist/vite.js +134 -11
- package/dist/worker-entry.js +20 -8
- package/package.json +6 -10
package/README.md
CHANGED
|
@@ -276,7 +276,7 @@ adep serve --public-url https://api.example.com # 对外地址(横幅与签
|
|
|
276
276
|
adep serve --parity # 严格同形:沙箱不注入 process、越根引用报错
|
|
277
277
|
```
|
|
278
278
|
|
|
279
|
-
- **存量表缺列检测**(sqlite 模式 + `--schema`):`CREATE TABLE IF NOT EXISTS` 对已存在的表是空操作,schema.sql 给存量表新增列不会生效——启动时把 schema.sql 声明的列面与每张存量表实际列面比对(与 `adep db migrate` 同一份解析实现),缺列逐列响亮警告(日志 + 启动横幅),**不阻断启动**。`--schema-fix` 自动 `ADD COLUMN`:`PRIMARY KEY` / 无默认值的 `NOT NULL` 与 `RENAME` / 删列 / 改类型仍只警告并给手工迁移提示。sim 模式不做检测,启动日志显式注明。
|
|
279
|
+
- **存量表缺列检测**(sqlite 模式 + `--schema`):`CREATE TABLE IF NOT EXISTS` 对已存在的表是空操作,schema.sql 给存量表新增列不会生效——启动时把 schema.sql 声明的列面与每张存量表实际列面比对(与 `adep db migrate` 同一份解析实现),缺列逐列响亮警告(日志 + 启动横幅),**不阻断启动**。`--schema-fix` 自动 `ADD COLUMN`:`PRIMARY KEY` / 无默认值的 `NOT NULL` 与 `RENAME` / 删列 / 改类型仍只警告并给手工迁移提示。schema.sql 的 `ALTER TABLE … ADD COLUMN` 自带幂等预检(CLI-108):列已存在自动跳过(`PRAGMA table_info`,大小写不敏感),重复启动不报 `duplicate column`;表不存在原样执行不掩盖真错。sim 模式不做检测,启动日志显式注明。
|
|
280
280
|
|
|
281
281
|
- **对外地址**(`--public-url`,env `ADEP_PUBLIC_URL` 同名生效、旗标优先):设置后启动横幅与存储签名 URL 的基址统一取该值。绑定 `0.0.0.0`(容器 / 局域网自托管)或对外 HTTPS 退出时必设,否则推导出 `http://0.0.0.0:…` 不可达 URL;`--port 0` 取监听确立后的真实端口;非法值(缺协议 / 非 http(s))启动即报错。`adep doctor` 会提示该风险。
|
|
282
282
|
|
package/dist/index.js
CHANGED
|
@@ -3393,6 +3393,11 @@ function resolveSignedUrlTtl(ttlSeconds, options) {
|
|
|
3393
3393
|
`\u7B7E\u540D URL \u6709\u6548\u671F\u6700\u957F ${MAX_SIGNED_URL_TTL_SECONDS / 86400} \u5929\uFF08\u6536\u5230 ${ttlSeconds} \u79D2\uFF09\u3002\u9700\u8981\u957F\u671F\u7A33\u5B9A\u7684\u94FE\u63A5\u8BF7\u628A\u6587\u4EF6\u4E0A\u4F20\u4E3A visibility: 'public' \u5E76\u7528 getUrl() \u53D6\u76F4\u94FE\uFF1B\u786E\u9700\u8D85\u957F\u79C1\u6709\u94FE\u63A5\u8BF7\u663E\u5F0F\u4F20 { force: true }\uFF08\u8FC7\u671F\u524D\u94FE\u63A5\u6CC4\u6F0F\u5373\u957F\u671F\u53EF\u8BFB\uFF09\u3002`
|
|
3394
3394
|
);
|
|
3395
3395
|
}
|
|
3396
|
+
if (ttlSeconds > DEFAULT_SIGN_TTL_SECONDS && options?.force !== true) {
|
|
3397
|
+
console.warn(
|
|
3398
|
+
`[deprecation] \u79C1\u6709\u7B7E\u540D URL \u4F7F\u7528\u4E86\u8D85\u8FC7\u7F3A\u7701 15 \u5206\u949F\u7684\u957F TTL\uFF08${String(ttlSeconds)}s\uFF09\uFF1A\u957F TTL \u79C1\u6709\u94FE\u63A5\u5C06\u5728\u4E0A\u9650\u6536\u7A84\u65F6\u5931\u6548\uFF0C\u957F\u671F\u5C55\u793A\u8BF7\u8FC1\u79FB visibility: 'public' + getUrl() \u53D6\u76F4\u94FE\u3002`
|
|
3399
|
+
);
|
|
3400
|
+
}
|
|
3396
3401
|
return ttlSeconds;
|
|
3397
3402
|
}
|
|
3398
3403
|
function sign(secret, projectId, path, expires) {
|
|
@@ -4080,6 +4085,43 @@ function parsePlainIdent(raw) {
|
|
|
4080
4085
|
}
|
|
4081
4086
|
return /^[A-Za-z_][A-Za-z0-9_$]*$/.test(text) ? text : null;
|
|
4082
4087
|
}
|
|
4088
|
+
function takeIdent(text) {
|
|
4089
|
+
const trimmed = text.trimStart();
|
|
4090
|
+
const first = trimmed[0];
|
|
4091
|
+
if (first === '"' || first === "`" || first === "'") {
|
|
4092
|
+
let i = 1;
|
|
4093
|
+
while (i < trimmed.length) {
|
|
4094
|
+
if (trimmed[i] === first) {
|
|
4095
|
+
if (trimmed[i + 1] === first) {
|
|
4096
|
+
i += 2;
|
|
4097
|
+
continue;
|
|
4098
|
+
}
|
|
4099
|
+
return { name: unquoteIdent(trimmed.slice(0, i + 1)), rest: trimmed.slice(i + 1) };
|
|
4100
|
+
}
|
|
4101
|
+
i += 1;
|
|
4102
|
+
}
|
|
4103
|
+
return null;
|
|
4104
|
+
}
|
|
4105
|
+
if (first === "[") {
|
|
4106
|
+
const close = trimmed.indexOf("]");
|
|
4107
|
+
if (close === -1) return null;
|
|
4108
|
+
return { name: unquoteIdent(trimmed.slice(0, close + 1)), rest: trimmed.slice(close + 1) };
|
|
4109
|
+
}
|
|
4110
|
+
const bare = /^[A-Za-z_][A-Za-z0-9_$]*/.exec(trimmed);
|
|
4111
|
+
if (bare === null) return null;
|
|
4112
|
+
return { name: bare[0], rest: trimmed.slice(bare[0].length) };
|
|
4113
|
+
}
|
|
4114
|
+
function parseAlterAddColumn(sql) {
|
|
4115
|
+
const head = /^ALTER\s+TABLE\s+/i.exec(sql.trim());
|
|
4116
|
+
if (head === null) return null;
|
|
4117
|
+
const table = takeIdent(sql.trim().slice(head[0].length));
|
|
4118
|
+
if (table === null) return null;
|
|
4119
|
+
const add = /^\s+ADD\s+(?:COLUMN\s+)?/i.exec(table.rest);
|
|
4120
|
+
if (add === null) return null;
|
|
4121
|
+
const column = takeIdent(table.rest.slice(add[0].length));
|
|
4122
|
+
if (column === null) return null;
|
|
4123
|
+
return { table: table.name, column: column.name };
|
|
4124
|
+
}
|
|
4083
4125
|
function splitTopLevel2(body) {
|
|
4084
4126
|
const parts = [];
|
|
4085
4127
|
let depth = 0;
|
|
@@ -4892,6 +4934,22 @@ async function applyLocalSchema(driver, options) {
|
|
|
4892
4934
|
let applied = 0;
|
|
4893
4935
|
let skipped = 0;
|
|
4894
4936
|
for (const [index, statement] of statements.entries()) {
|
|
4937
|
+
if (mode === "sqlite") {
|
|
4938
|
+
const addColumn = parseAlterAddColumn(statement);
|
|
4939
|
+
if (addColumn !== null) {
|
|
4940
|
+
const rows = await driver.all(`SELECT name FROM pragma_table_info(?)`, [addColumn.table]);
|
|
4941
|
+
const exists = rows.some(
|
|
4942
|
+
(row) => String(row["name"] ?? "").toLowerCase() === addColumn.column.toLowerCase()
|
|
4943
|
+
);
|
|
4944
|
+
if (exists) {
|
|
4945
|
+
skipped += 1;
|
|
4946
|
+
log(
|
|
4947
|
+
`[${tag}] \u8DF3\u8FC7\u5DF2\u5B58\u5728\u7684\u5217\uFF08--schema \u5E42\u7B49\u9884\u68C0\uFF09\uFF1A${addColumn.table}.${addColumn.column}`
|
|
4948
|
+
);
|
|
4949
|
+
continue;
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
}
|
|
4895
4953
|
try {
|
|
4896
4954
|
await driver.run(statement);
|
|
4897
4955
|
applied += 1;
|
|
@@ -6219,12 +6277,23 @@ function errorLineIn(stack, path) {
|
|
|
6219
6277
|
if (own2 !== null) return own2[1];
|
|
6220
6278
|
return /(?:^|\n):(\d+)(?:\n|$)/.exec(stack)?.[1];
|
|
6221
6279
|
}
|
|
6222
|
-
function
|
|
6280
|
+
function isDynamicImportRejection(error62) {
|
|
6281
|
+
const code = error62.code;
|
|
6282
|
+
if (code === "ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING") return true;
|
|
6283
|
+
const message = error62 instanceof Error ? error62.message : String(error62);
|
|
6284
|
+
return /dynamic import callback/i.test(message);
|
|
6285
|
+
}
|
|
6286
|
+
function containsDynamicImport(source) {
|
|
6287
|
+
return /(^|[^\w$.])import\s*\(/.test(source);
|
|
6288
|
+
}
|
|
6289
|
+
function syntaxErrorWithLocation(error62, path, source) {
|
|
6223
6290
|
const rawMessage = error62 instanceof Error ? error62.message : String(error62);
|
|
6224
6291
|
const stack = error62.stack;
|
|
6225
6292
|
const line = typeof stack === "string" ? errorLineIn(stack, path) : void 0;
|
|
6226
6293
|
const location = line === void 0 ? path : `${path}:${line}`;
|
|
6227
|
-
const
|
|
6294
|
+
const hint = containsDynamicImport(source) ? `
|
|
6295
|
+
${DYNAMIC_IMPORT_HINT}` : "";
|
|
6296
|
+
const wrapped = new Error(`\u6E90\u7801\u8BED\u6CD5\u9519\u8BEF\uFF08${location}\uFF09\uFF1A${rawMessage}${hint}`, { cause: error62 });
|
|
6228
6297
|
const code = error62.code;
|
|
6229
6298
|
if (typeof code === "string") wrapped.code = code;
|
|
6230
6299
|
return wrapped;
|
|
@@ -6269,7 +6338,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
6269
6338
|
try {
|
|
6270
6339
|
transformed = transformExports(transpile(source));
|
|
6271
6340
|
} catch (error62) {
|
|
6272
|
-
throw syntaxErrorWithLocation(error62, path);
|
|
6341
|
+
throw syntaxErrorWithLocation(error62, path, source);
|
|
6273
6342
|
}
|
|
6274
6343
|
const context = createSandboxContext(sandboxGlobals);
|
|
6275
6344
|
let wrapper;
|
|
@@ -6281,7 +6350,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
6281
6350
|
{ filename: path }
|
|
6282
6351
|
);
|
|
6283
6352
|
} catch (error62) {
|
|
6284
|
-
throw syntaxErrorWithLocation(error62, path);
|
|
6353
|
+
throw syntaxErrorWithLocation(error62, path, source);
|
|
6285
6354
|
}
|
|
6286
6355
|
wrapper(module, exports, require2);
|
|
6287
6356
|
if (module.default !== void 0 && exports["default"] === void 0) {
|
|
@@ -6307,7 +6376,7 @@ function loadFunctionModule(files, entry, sandboxGlobals, resolveBare, strictPat
|
|
|
6307
6376
|
}
|
|
6308
6377
|
return { handler };
|
|
6309
6378
|
}
|
|
6310
|
-
var bunTranspiler, SANDBOX_BUILTIN_REJECTED, REALM_VALUE_KEY;
|
|
6379
|
+
var bunTranspiler, SANDBOX_BUILTIN_REJECTED, REALM_VALUE_KEY, DYNAMIC_IMPORT_HINT;
|
|
6311
6380
|
var init_sandbox = __esm({
|
|
6312
6381
|
"packages/runtime/src/functions/runtime/sandbox.ts"() {
|
|
6313
6382
|
"use strict";
|
|
@@ -6315,6 +6384,7 @@ var init_sandbox = __esm({
|
|
|
6315
6384
|
init_regexp();
|
|
6316
6385
|
SANDBOX_BUILTIN_REJECTED = "FN_SANDBOX_BUILTIN_BLOCKED";
|
|
6317
6386
|
REALM_VALUE_KEY = "__adepRealmValue";
|
|
6387
|
+
DYNAMIC_IMPORT_HINT = "\u63D0\u793A\uFF1AM1 \u6C99\u7BB1\u4E0D\u652F\u6301\u52A8\u6001 import\uFF0C\u6539\u9759\u6001 import";
|
|
6318
6388
|
}
|
|
6319
6389
|
});
|
|
6320
6390
|
|
|
@@ -7000,10 +7070,10 @@ function firstUserFrame(stack, files) {
|
|
|
7000
7070
|
function errorMessageWithLocation(error62, files) {
|
|
7001
7071
|
const message = errorMessageOf2(error62);
|
|
7002
7072
|
const stack = error62.stack;
|
|
7003
|
-
|
|
7004
|
-
const
|
|
7005
|
-
|
|
7006
|
-
|
|
7073
|
+
const frame = typeof stack === "string" ? firstUserFrame(stack, files) : void 0;
|
|
7074
|
+
const located = frame === void 0 || message.includes(`\uFF08${frame}\uFF09`) ? message : `${message}\uFF08${frame}\uFF09`;
|
|
7075
|
+
return isDynamicImportRejection(error62) ? `${located}
|
|
7076
|
+
${DYNAMIC_IMPORT_HINT}` : located;
|
|
7007
7077
|
}
|
|
7008
7078
|
function createBareResolver(deps) {
|
|
7009
7079
|
const platformRequire = createRequire(import.meta.url);
|
|
@@ -7358,6 +7428,49 @@ function createBearerUserResolver(issuer) {
|
|
|
7358
7428
|
}
|
|
7359
7429
|
};
|
|
7360
7430
|
}
|
|
7431
|
+
function parseSimUserJson(raw) {
|
|
7432
|
+
let parsed;
|
|
7433
|
+
try {
|
|
7434
|
+
parsed = JSON.parse(raw);
|
|
7435
|
+
} catch {
|
|
7436
|
+
return { ok: false, reason: "\u4E0D\u662F\u5408\u6CD5 JSON" };
|
|
7437
|
+
}
|
|
7438
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
7439
|
+
return { ok: false, reason: `\u5FC5\u987B\u662F\u5BF9\u8C61\uFF08{"id":"u1","name":"\u5192\u70DF"}\uFF09` };
|
|
7440
|
+
}
|
|
7441
|
+
const record2 = parsed;
|
|
7442
|
+
if (typeof record2["id"] !== "string" || record2["id"].length === 0) {
|
|
7443
|
+
return { ok: false, reason: `\u7F3A\u5C11\u975E\u7A7A\u5B57\u7B26\u4E32 id \u5B57\u6BB5\uFF08{"id":"u1","name":"\u5192\u70DF"}\uFF09` };
|
|
7444
|
+
}
|
|
7445
|
+
for (const key of ["name", "email"]) {
|
|
7446
|
+
const value = record2[key];
|
|
7447
|
+
if (value !== void 0 && typeof value !== "string") {
|
|
7448
|
+
return { ok: false, reason: `${key} \u5B57\u6BB5\u5FC5\u987B\u662F\u5B57\u7B26\u4E32` };
|
|
7449
|
+
}
|
|
7450
|
+
}
|
|
7451
|
+
const name = record2["name"];
|
|
7452
|
+
const email3 = record2["email"];
|
|
7453
|
+
return {
|
|
7454
|
+
ok: true,
|
|
7455
|
+
user: {
|
|
7456
|
+
id: record2["id"],
|
|
7457
|
+
...typeof name === "string" && name !== "" ? { name } : {},
|
|
7458
|
+
...typeof email3 === "string" && email3 !== "" ? { email: email3 } : {}
|
|
7459
|
+
}
|
|
7460
|
+
};
|
|
7461
|
+
}
|
|
7462
|
+
function simUserResolverFromEnv(fileEnv = {}) {
|
|
7463
|
+
const raw = firstNonEmpty(process.env[SIM_USER_ENV_KEY], fileEnv[SIM_USER_ENV_KEY]);
|
|
7464
|
+
if (raw === void 0) return { resolver: void 0, warning: void 0 };
|
|
7465
|
+
const parsed = parseSimUserJson(raw);
|
|
7466
|
+
if (!parsed.ok) {
|
|
7467
|
+
return {
|
|
7468
|
+
resolver: void 0,
|
|
7469
|
+
warning: `${SIM_USER_ENV_KEY}=${raw} \u89E3\u6790\u5931\u8D25\uFF08${parsed.reason}\uFF09\uFF1A\u5DF2\u8DF3\u8FC7\u6A21\u62DF\u767B\u5F55\u6001\u6CE8\u5165\uFF0C\u767B\u5F55\u6001\u94FE\u8DEF\u8D70\u539F\u8DEF\u5F84`
|
|
7470
|
+
};
|
|
7471
|
+
}
|
|
7472
|
+
return { resolver: async () => parsed.user, warning: void 0 };
|
|
7473
|
+
}
|
|
7361
7474
|
function isRuntimeSource(name) {
|
|
7362
7475
|
return (name.endsWith(".ts") || name.endsWith(".js")) && !name.endsWith(".d.ts") && !name.endsWith(".test.ts");
|
|
7363
7476
|
}
|
|
@@ -7461,7 +7574,7 @@ async function requestInput(url2, req, readBody) {
|
|
|
7461
7574
|
...parsed?.files === void 0 ? {} : { files: parsed.files }
|
|
7462
7575
|
};
|
|
7463
7576
|
}
|
|
7464
|
-
var BEARER_TOKEN_RE, ISSUER_PATH_SUFFIX;
|
|
7577
|
+
var BEARER_TOKEN_RE, ISSUER_PATH_SUFFIX, SIM_USER_ENV_KEY;
|
|
7465
7578
|
var init_dev_shared = __esm({
|
|
7466
7579
|
"packages/cli/src/dev-shared.ts"() {
|
|
7467
7580
|
"use strict";
|
|
@@ -7472,6 +7585,7 @@ var init_dev_shared = __esm({
|
|
|
7472
7585
|
init_invoke();
|
|
7473
7586
|
BEARER_TOKEN_RE = /^Bearer\s+(.+)$/i;
|
|
7474
7587
|
ISSUER_PATH_SUFFIX = "/api";
|
|
7588
|
+
SIM_USER_ENV_KEY = "ADEP_SIM_USER";
|
|
7475
7589
|
}
|
|
7476
7590
|
});
|
|
7477
7591
|
|
|
@@ -7553,7 +7667,9 @@ async function startDevServer(options) {
|
|
|
7553
7667
|
...options.dbFile === void 0 ? {} : { dbFile: options.dbFile }
|
|
7554
7668
|
});
|
|
7555
7669
|
const simEnv = await loadSimEnv(cwd).catch(() => ({}));
|
|
7556
|
-
let
|
|
7670
|
+
let simUser = simUserResolverFromEnv(simEnv);
|
|
7671
|
+
if (simUser.warning !== void 0) log(`[adep] ${simUser.warning}`);
|
|
7672
|
+
let bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(simEnv);
|
|
7557
7673
|
const fetchConfig = resolveLocalFetchConfig(simEnv);
|
|
7558
7674
|
const executor = new WorkerFunctionExecutor({
|
|
7559
7675
|
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS },
|
|
@@ -7667,7 +7783,10 @@ async function startDevServer(options) {
|
|
|
7667
7783
|
]);
|
|
7668
7784
|
files = nextFiles;
|
|
7669
7785
|
env = { ...config2.environment, ...parseEnvFile(envText2) };
|
|
7670
|
-
|
|
7786
|
+
const nextEnv = await loadSimEnv(cwd).catch(() => ({}));
|
|
7787
|
+
simUser = simUserResolverFromEnv(nextEnv);
|
|
7788
|
+
if (simUser.warning !== void 0) log(`[adep] ${simUser.warning}`);
|
|
7789
|
+
bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(nextEnv);
|
|
7671
7790
|
};
|
|
7672
7791
|
const envText = await readFile9(join13(cwd, ".env.local"), "utf8").catch(() => "");
|
|
7673
7792
|
env = { ...config2.environment, ...parseEnvFile(envText) };
|
|
@@ -7836,7 +7955,11 @@ async function startDevServer(options) {
|
|
|
7836
7955
|
);
|
|
7837
7956
|
log(`[adep] curl \u793A\u4F8B\uFF1Acurl ${baseUrl}${curlPath}`);
|
|
7838
7957
|
printBoundaries(log);
|
|
7839
|
-
if (
|
|
7958
|
+
if (simUser.resolver !== void 0) {
|
|
7959
|
+
log(
|
|
7960
|
+
`[adep] \u26A0\uFE0F \u6A21\u62DF\u767B\u5F55\u6001\uFF1AADEP_SIM_USER \u5DF2\u914D\u7F6E\uFF0C\u6240\u6709\u8BF7\u6C42\u7684 ctx.user \u5C06\u6CE8\u5165\u6A21\u62DF\u7528\u6237\uFF08\u4EC5\u672C\u5730 sim\uFF1B\u5E73\u53F0\u90E8\u7F72\u4E0D\u8BFB\u8BE5\u53D8\u91CF\uFF09`
|
|
7961
|
+
);
|
|
7962
|
+
} else if (bearerUser !== void 0) {
|
|
7840
7963
|
log(
|
|
7841
7964
|
`[adep] \u767B\u5F55\u5373\u670D\u52A1\uFF1AADEP_AUTH_ISSUER \u5DF2\u914D\u7F6E\uFF0CBearer token \u5C06\u89E3\u6790\u4E3A\u7528\u6237\u8EAB\u4EFD\uFF08userinfo \u7AEF\u70B9\uFF09`
|
|
7842
7965
|
);
|
|
@@ -8771,7 +8894,9 @@ async function startServeServer(options) {
|
|
|
8771
8894
|
let env = parseEnvFile(envText);
|
|
8772
8895
|
let envViews = await loadSimEnvViews(cwd);
|
|
8773
8896
|
let simEnv = envViews.merged;
|
|
8774
|
-
let
|
|
8897
|
+
let simUser = simUserResolverFromEnv(simEnv);
|
|
8898
|
+
if (simUser.warning !== void 0) log(`[serve] ${simUser.warning}`);
|
|
8899
|
+
let bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(simEnv);
|
|
8775
8900
|
const dotenvFile = await readDotenvFile(cwd, ".env");
|
|
8776
8901
|
let templateEnv;
|
|
8777
8902
|
try {
|
|
@@ -8845,7 +8970,9 @@ async function startServeServer(options) {
|
|
|
8845
8970
|
env = parseEnvFile(envLocalText);
|
|
8846
8971
|
envViews = await loadSimEnvViews(cwd);
|
|
8847
8972
|
simEnv = envViews.merged;
|
|
8848
|
-
|
|
8973
|
+
simUser = simUserResolverFromEnv(simEnv);
|
|
8974
|
+
if (simUser.warning !== void 0) log(`[serve] ${simUser.warning}`);
|
|
8975
|
+
bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(simEnv);
|
|
8849
8976
|
invokeHandler = createSimInvokeHandler({ executor, files });
|
|
8850
8977
|
functionNames = listFunctionNames(files);
|
|
8851
8978
|
log(`[serve] \u70ED\u91CD\u8F7D\uFF1A\u68C0\u6D4B\u5230\u53D8\u66F4\uFF0C\u5DF2\u91CD\u65B0\u52A0\u8F7D ${functionNames.length} \u4E2A\u51FD\u6570`);
|
|
@@ -9173,7 +9300,11 @@ async function startServeServer(options) {
|
|
|
9173
9300
|
if (options.watch === true) {
|
|
9174
9301
|
log(`[serve] \u70ED\u91CD\u8F7D\u5DF2\u5F00\u542F\uFF1A\u6539 functions/ \u4E0E .env* \u5373\u751F\u6548\uFF0C\u51FD\u6570 console \u8F93\u51FA\u76F4\u8FBE\u7EC8\u7AEF\uFF08--watch\uFF09`);
|
|
9175
9302
|
}
|
|
9176
|
-
if (
|
|
9303
|
+
if (simUser.resolver !== void 0) {
|
|
9304
|
+
log(
|
|
9305
|
+
`[serve] \u26A0\uFE0F \u6A21\u62DF\u767B\u5F55\u6001\uFF1AADEP_SIM_USER \u5DF2\u914D\u7F6E\uFF0C\u6240\u6709\u8BF7\u6C42\u7684 ctx.user \u5C06\u6CE8\u5165\u6A21\u62DF\u7528\u6237\uFF08\u4EC5\u672C\u5730 sim\uFF1B\u5E73\u53F0\u90E8\u7F72\u4E0D\u8BFB\u8BE5\u53D8\u91CF\uFF09`
|
|
9306
|
+
);
|
|
9307
|
+
} else if (bearerUser !== void 0) {
|
|
9177
9308
|
log(
|
|
9178
9309
|
`[serve] \u767B\u5F55\u5373\u670D\u52A1\uFF1AADEP_AUTH_ISSUER \u5DF2\u914D\u7F6E\uFF0CBearer token \u5C06\u89E3\u6790\u4E3A\u7528\u6237\u8EAB\u4EFD\uFF08userinfo \u7AEF\u70B9\uFF09`
|
|
9179
9310
|
);
|
|
@@ -10850,7 +10981,7 @@ var init_version = __esm({
|
|
|
10850
10981
|
manifest = requireJson("../package.json");
|
|
10851
10982
|
CLI_VERSION = typeof manifest.version === "string" && manifest.version.length > 0 ? manifest.version : "0.0.0";
|
|
10852
10983
|
RELEASE_TASKS = Array.isArray(manifest.adep?.releaseTasks) ? manifest.adep.releaseTasks.filter((item) => typeof item === "string") : [];
|
|
10853
|
-
BUILD_COMMIT = "
|
|
10984
|
+
BUILD_COMMIT = "8e63db96".trim() !== "" ? "8e63db96".trim() : null;
|
|
10854
10985
|
}
|
|
10855
10986
|
});
|
|
10856
10987
|
|
|
@@ -10859,8 +10990,11 @@ var doctor_exports = {};
|
|
|
10859
10990
|
__export(doctor_exports, {
|
|
10860
10991
|
detectSupplyChainPolicy: () => detectSupplyChainPolicy,
|
|
10861
10992
|
formatDoctorReport: () => formatDoctorReport,
|
|
10993
|
+
parseChangelogBreaking: () => parseChangelogBreaking,
|
|
10994
|
+
pickBreakingNotices: () => pickBreakingNotices,
|
|
10862
10995
|
runDoctor: () => runDoctor
|
|
10863
10996
|
});
|
|
10997
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
10864
10998
|
import { readFile as readFile32, stat as stat18 } from "node:fs/promises";
|
|
10865
10999
|
import { homedir } from "node:os";
|
|
10866
11000
|
import { join as join39 } from "node:path";
|
|
@@ -10973,9 +11107,16 @@ async function runDoctor(paths, cwd = process.cwd()) {
|
|
|
10973
11107
|
const projectEnv = await inspectProjectEnv(cwd);
|
|
10974
11108
|
const supplyChain = await detectSupplyChainPolicy(cwd);
|
|
10975
11109
|
const cliRelease = await checkCliRelease(CLI_VERSION, RELEASE_TASKS);
|
|
11110
|
+
const changelog = await readOwnChangelog();
|
|
11111
|
+
const breaking = changelog === null ? [] : pickBreakingNotices(
|
|
11112
|
+
parseChangelogBreaking(changelog),
|
|
11113
|
+
cliRelease.status,
|
|
11114
|
+
CLI_VERSION,
|
|
11115
|
+
cliRelease.newerVersions
|
|
11116
|
+
);
|
|
10976
11117
|
const report = {
|
|
10977
11118
|
server,
|
|
10978
|
-
cli: { version: CLI_VERSION, buildCommit: BUILD_COMMIT, ...cliRelease },
|
|
11119
|
+
cli: { version: CLI_VERSION, buildCommit: BUILD_COMMIT, breaking, ...cliRelease },
|
|
10979
11120
|
credentials: {
|
|
10980
11121
|
file: credentialsFile,
|
|
10981
11122
|
present: credentials !== null,
|
|
@@ -11057,6 +11198,43 @@ async function inspectProjectEnv(cwd) {
|
|
|
11057
11198
|
fetchAllowlist: fetch2
|
|
11058
11199
|
};
|
|
11059
11200
|
}
|
|
11201
|
+
function parseChangelogBreaking(text) {
|
|
11202
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
11203
|
+
const versionHeading = /^#{1,6}\s+v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:\s*[((]|$)/;
|
|
11204
|
+
const breakingLine = /^\s*-\s+\*\*breaking(?:\(([^)]*)\))?:?\*\*\s*(.*)$/i;
|
|
11205
|
+
let currentVersion = null;
|
|
11206
|
+
for (const rawLine of text.split("\n")) {
|
|
11207
|
+
const heading = versionHeading.exec(rawLine);
|
|
11208
|
+
if (heading !== null) {
|
|
11209
|
+
currentVersion = heading[1] ?? null;
|
|
11210
|
+
continue;
|
|
11211
|
+
}
|
|
11212
|
+
if (currentVersion === null) continue;
|
|
11213
|
+
const marker = breakingLine.exec(rawLine);
|
|
11214
|
+
if (marker === null) continue;
|
|
11215
|
+
const scope = (marker[1] ?? "").trim();
|
|
11216
|
+
const list = map2.get(currentVersion) ?? [];
|
|
11217
|
+
list.push({
|
|
11218
|
+
version: currentVersion,
|
|
11219
|
+
packages: scope === "" ? ["cli"] : [scope],
|
|
11220
|
+
summary: (marker[2] ?? "").trim()
|
|
11221
|
+
});
|
|
11222
|
+
map2.set(currentVersion, list);
|
|
11223
|
+
}
|
|
11224
|
+
return map2;
|
|
11225
|
+
}
|
|
11226
|
+
function pickBreakingNotices(parsed, status, version2, newerVersions) {
|
|
11227
|
+
if (status === "behind") return newerVersions.flatMap((item) => parsed.get(item) ?? []);
|
|
11228
|
+
if (status === "current") return [...parsed.get(version2) ?? []];
|
|
11229
|
+
return [];
|
|
11230
|
+
}
|
|
11231
|
+
async function readOwnChangelog() {
|
|
11232
|
+
try {
|
|
11233
|
+
return await readFile32(createRequire3(import.meta.url).resolve("../CHANGELOG.md"), "utf8");
|
|
11234
|
+
} catch {
|
|
11235
|
+
return null;
|
|
11236
|
+
}
|
|
11237
|
+
}
|
|
11060
11238
|
function cliVersionSection(cli) {
|
|
11061
11239
|
const versionText = cli.buildCommit === null ? `${cli.version}\uFF08source\uFF09` : `${cli.version}\uFF08commit ${cli.buildCommit}\uFF09`;
|
|
11062
11240
|
const lines = [];
|
|
@@ -11066,6 +11244,11 @@ function cliVersionSection(cli) {
|
|
|
11066
11244
|
}
|
|
11067
11245
|
if (cli.status === "current") {
|
|
11068
11246
|
lines.push(` \u2713 adep ${versionText} \xB7 registry latest ${cli.latest}`);
|
|
11247
|
+
for (const notice of cli.breaking) {
|
|
11248
|
+
lines.push(
|
|
11249
|
+
` \u26A0\uFE0F \u672C\u7248 ${notice.version} \u542B breaking\uFF08${notice.packages.join("/")}\uFF09\uFF1A${notice.summary}`
|
|
11250
|
+
);
|
|
11251
|
+
}
|
|
11069
11252
|
return lines;
|
|
11070
11253
|
}
|
|
11071
11254
|
if (cli.status === "behind") {
|
|
@@ -11074,6 +11257,16 @@ function cliVersionSection(cli) {
|
|
|
11074
11257
|
lines.push(
|
|
11075
11258
|
cli.missingTasks.length > 0 ? ` \u7F3A\u5931\u6539\u52A8\uFF1A${cli.missingTasks.join("\u3001")}` : " \u7F3A\u5931\u6539\u52A8\uFF1Aregistry \u672A\u767B\u8BB0\u4EFB\u52A1\u53F7\uFF08\u4EC5 0.5.3 \u8D77\u7684\u7248\u672C\u5E26 adep.releaseTasks\uFF09"
|
|
11076
11259
|
);
|
|
11260
|
+
for (const notice of cli.breaking) {
|
|
11261
|
+
lines.push(
|
|
11262
|
+
` \u26A0\uFE0F ${notice.version} \u542B breaking\uFF08${notice.packages.join("/")}\uFF09\uFF1A${notice.summary}`
|
|
11263
|
+
);
|
|
11264
|
+
}
|
|
11265
|
+
if (cli.breaking.length > 0) {
|
|
11266
|
+
lines.push(
|
|
11267
|
+
" \u63D0\u793A\uFF1A\u5347\u7EA7\u524D\u5BF9\u8D26 CHANGELOG \u7684 breaking \u6761\u76EE\uFF08\u6807\u6CE8\u7EA6\u5B9A\u89C1 docs/npm-publishing.md\uFF09"
|
|
11268
|
+
);
|
|
11269
|
+
}
|
|
11077
11270
|
lines.push(" \u63D0\u793A\uFF1Anpm i -g @adep/cli@latest \u540E\u91CD\u8DD1 adep doctor");
|
|
11078
11271
|
return lines;
|
|
11079
11272
|
}
|
package/dist/vite.js
CHANGED
|
@@ -2377,6 +2377,11 @@ function resolveSignedUrlTtl(ttlSeconds, options) {
|
|
|
2377
2377
|
`\u7B7E\u540D URL \u6709\u6548\u671F\u6700\u957F ${MAX_SIGNED_URL_TTL_SECONDS / 86400} \u5929\uFF08\u6536\u5230 ${ttlSeconds} \u79D2\uFF09\u3002\u9700\u8981\u957F\u671F\u7A33\u5B9A\u7684\u94FE\u63A5\u8BF7\u628A\u6587\u4EF6\u4E0A\u4F20\u4E3A visibility: 'public' \u5E76\u7528 getUrl() \u53D6\u76F4\u94FE\uFF1B\u786E\u9700\u8D85\u957F\u79C1\u6709\u94FE\u63A5\u8BF7\u663E\u5F0F\u4F20 { force: true }\uFF08\u8FC7\u671F\u524D\u94FE\u63A5\u6CC4\u6F0F\u5373\u957F\u671F\u53EF\u8BFB\uFF09\u3002`
|
|
2378
2378
|
);
|
|
2379
2379
|
}
|
|
2380
|
+
if (ttlSeconds > DEFAULT_SIGN_TTL_SECONDS && options?.force !== true) {
|
|
2381
|
+
console.warn(
|
|
2382
|
+
`[deprecation] \u79C1\u6709\u7B7E\u540D URL \u4F7F\u7528\u4E86\u8D85\u8FC7\u7F3A\u7701 15 \u5206\u949F\u7684\u957F TTL\uFF08${String(ttlSeconds)}s\uFF09\uFF1A\u957F TTL \u79C1\u6709\u94FE\u63A5\u5C06\u5728\u4E0A\u9650\u6536\u7A84\u65F6\u5931\u6548\uFF0C\u957F\u671F\u5C55\u793A\u8BF7\u8FC1\u79FB visibility: 'public' + getUrl() \u53D6\u76F4\u94FE\u3002`
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2380
2385
|
return ttlSeconds;
|
|
2381
2386
|
}
|
|
2382
2387
|
function sign(secret, projectId, path, expires) {
|
|
@@ -2985,6 +2990,43 @@ function parsePlainIdent(raw) {
|
|
|
2985
2990
|
}
|
|
2986
2991
|
return /^[A-Za-z_][A-Za-z0-9_$]*$/.test(text) ? text : null;
|
|
2987
2992
|
}
|
|
2993
|
+
function takeIdent(text) {
|
|
2994
|
+
const trimmed = text.trimStart();
|
|
2995
|
+
const first = trimmed[0];
|
|
2996
|
+
if (first === '"' || first === "`" || first === "'") {
|
|
2997
|
+
let i = 1;
|
|
2998
|
+
while (i < trimmed.length) {
|
|
2999
|
+
if (trimmed[i] === first) {
|
|
3000
|
+
if (trimmed[i + 1] === first) {
|
|
3001
|
+
i += 2;
|
|
3002
|
+
continue;
|
|
3003
|
+
}
|
|
3004
|
+
return { name: unquoteIdent(trimmed.slice(0, i + 1)), rest: trimmed.slice(i + 1) };
|
|
3005
|
+
}
|
|
3006
|
+
i += 1;
|
|
3007
|
+
}
|
|
3008
|
+
return null;
|
|
3009
|
+
}
|
|
3010
|
+
if (first === "[") {
|
|
3011
|
+
const close = trimmed.indexOf("]");
|
|
3012
|
+
if (close === -1) return null;
|
|
3013
|
+
return { name: unquoteIdent(trimmed.slice(0, close + 1)), rest: trimmed.slice(close + 1) };
|
|
3014
|
+
}
|
|
3015
|
+
const bare = /^[A-Za-z_][A-Za-z0-9_$]*/.exec(trimmed);
|
|
3016
|
+
if (bare === null) return null;
|
|
3017
|
+
return { name: bare[0], rest: trimmed.slice(bare[0].length) };
|
|
3018
|
+
}
|
|
3019
|
+
function parseAlterAddColumn(sql) {
|
|
3020
|
+
const head = /^ALTER\s+TABLE\s+/i.exec(sql.trim());
|
|
3021
|
+
if (head === null) return null;
|
|
3022
|
+
const table = takeIdent(sql.trim().slice(head[0].length));
|
|
3023
|
+
if (table === null) return null;
|
|
3024
|
+
const add = /^\s+ADD\s+(?:COLUMN\s+)?/i.exec(table.rest);
|
|
3025
|
+
if (add === null) return null;
|
|
3026
|
+
const column = takeIdent(table.rest.slice(add[0].length));
|
|
3027
|
+
if (column === null) return null;
|
|
3028
|
+
return { table: table.name, column: column.name };
|
|
3029
|
+
}
|
|
2988
3030
|
function splitTopLevel2(body) {
|
|
2989
3031
|
const parts = [];
|
|
2990
3032
|
let depth = 0;
|
|
@@ -3390,6 +3432,22 @@ async function applyLocalSchema(driver, options) {
|
|
|
3390
3432
|
let applied = 0;
|
|
3391
3433
|
let skipped = 0;
|
|
3392
3434
|
for (const [index, statement] of statements.entries()) {
|
|
3435
|
+
if (mode === "sqlite") {
|
|
3436
|
+
const addColumn = parseAlterAddColumn(statement);
|
|
3437
|
+
if (addColumn !== null) {
|
|
3438
|
+
const rows = await driver.all(`SELECT name FROM pragma_table_info(?)`, [addColumn.table]);
|
|
3439
|
+
const exists = rows.some(
|
|
3440
|
+
(row) => String(row["name"] ?? "").toLowerCase() === addColumn.column.toLowerCase()
|
|
3441
|
+
);
|
|
3442
|
+
if (exists) {
|
|
3443
|
+
skipped += 1;
|
|
3444
|
+
log(
|
|
3445
|
+
`[${tag}] \u8DF3\u8FC7\u5DF2\u5B58\u5728\u7684\u5217\uFF08--schema \u5E42\u7B49\u9884\u68C0\uFF09\uFF1A${addColumn.table}.${addColumn.column}`
|
|
3446
|
+
);
|
|
3447
|
+
continue;
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3393
3451
|
try {
|
|
3394
3452
|
await driver.run(statement);
|
|
3395
3453
|
applied += 1;
|
|
@@ -4809,12 +4867,24 @@ function errorLineIn(stack, path) {
|
|
|
4809
4867
|
if (own !== null) return own[1];
|
|
4810
4868
|
return /(?:^|\n):(\d+)(?:\n|$)/.exec(stack)?.[1];
|
|
4811
4869
|
}
|
|
4812
|
-
|
|
4870
|
+
var DYNAMIC_IMPORT_HINT = "\u63D0\u793A\uFF1AM1 \u6C99\u7BB1\u4E0D\u652F\u6301\u52A8\u6001 import\uFF0C\u6539\u9759\u6001 import";
|
|
4871
|
+
function isDynamicImportRejection(error) {
|
|
4872
|
+
const code = error.code;
|
|
4873
|
+
if (code === "ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING") return true;
|
|
4874
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4875
|
+
return /dynamic import callback/i.test(message);
|
|
4876
|
+
}
|
|
4877
|
+
function containsDynamicImport(source) {
|
|
4878
|
+
return /(^|[^\w$.])import\s*\(/.test(source);
|
|
4879
|
+
}
|
|
4880
|
+
function syntaxErrorWithLocation(error, path, source) {
|
|
4813
4881
|
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
4814
4882
|
const stack = error.stack;
|
|
4815
4883
|
const line = typeof stack === "string" ? errorLineIn(stack, path) : void 0;
|
|
4816
4884
|
const location = line === void 0 ? path : `${path}:${line}`;
|
|
4817
|
-
const
|
|
4885
|
+
const hint = containsDynamicImport(source) ? `
|
|
4886
|
+
${DYNAMIC_IMPORT_HINT}` : "";
|
|
4887
|
+
const wrapped = new Error(`\u6E90\u7801\u8BED\u6CD5\u9519\u8BEF\uFF08${location}\uFF09\uFF1A${rawMessage}${hint}`, { cause: error });
|
|
4818
4888
|
const code = error.code;
|
|
4819
4889
|
if (typeof code === "string") wrapped.code = code;
|
|
4820
4890
|
return wrapped;
|
|
@@ -4859,7 +4929,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
4859
4929
|
try {
|
|
4860
4930
|
transformed = transformExports(transpile(source));
|
|
4861
4931
|
} catch (error) {
|
|
4862
|
-
throw syntaxErrorWithLocation(error, path);
|
|
4932
|
+
throw syntaxErrorWithLocation(error, path, source);
|
|
4863
4933
|
}
|
|
4864
4934
|
const context = createSandboxContext(sandboxGlobals);
|
|
4865
4935
|
let wrapper;
|
|
@@ -4871,7 +4941,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
4871
4941
|
{ filename: path }
|
|
4872
4942
|
);
|
|
4873
4943
|
} catch (error) {
|
|
4874
|
-
throw syntaxErrorWithLocation(error, path);
|
|
4944
|
+
throw syntaxErrorWithLocation(error, path, source);
|
|
4875
4945
|
}
|
|
4876
4946
|
wrapper(module, exports, require2);
|
|
4877
4947
|
if (module.default !== void 0 && exports["default"] === void 0) {
|
|
@@ -5518,10 +5588,10 @@ function firstUserFrame(stack, files) {
|
|
|
5518
5588
|
function errorMessageWithLocation(error, files) {
|
|
5519
5589
|
const message = errorMessageOf2(error);
|
|
5520
5590
|
const stack = error.stack;
|
|
5521
|
-
|
|
5522
|
-
const
|
|
5523
|
-
|
|
5524
|
-
|
|
5591
|
+
const frame = typeof stack === "string" ? firstUserFrame(stack, files) : void 0;
|
|
5592
|
+
const located = frame === void 0 || message.includes(`\uFF08${frame}\uFF09`) ? message : `${message}\uFF08${frame}\uFF09`;
|
|
5593
|
+
return isDynamicImportRejection(error) ? `${located}
|
|
5594
|
+
${DYNAMIC_IMPORT_HINT}` : located;
|
|
5525
5595
|
}
|
|
5526
5596
|
function createBareResolver(deps) {
|
|
5527
5597
|
const platformRequire = createRequire(import.meta.url);
|
|
@@ -5845,6 +5915,50 @@ function createBearerUserResolver(issuer) {
|
|
|
5845
5915
|
}
|
|
5846
5916
|
};
|
|
5847
5917
|
}
|
|
5918
|
+
var SIM_USER_ENV_KEY = "ADEP_SIM_USER";
|
|
5919
|
+
function parseSimUserJson(raw) {
|
|
5920
|
+
let parsed;
|
|
5921
|
+
try {
|
|
5922
|
+
parsed = JSON.parse(raw);
|
|
5923
|
+
} catch {
|
|
5924
|
+
return { ok: false, reason: "\u4E0D\u662F\u5408\u6CD5 JSON" };
|
|
5925
|
+
}
|
|
5926
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
5927
|
+
return { ok: false, reason: `\u5FC5\u987B\u662F\u5BF9\u8C61\uFF08{"id":"u1","name":"\u5192\u70DF"}\uFF09` };
|
|
5928
|
+
}
|
|
5929
|
+
const record = parsed;
|
|
5930
|
+
if (typeof record["id"] !== "string" || record["id"].length === 0) {
|
|
5931
|
+
return { ok: false, reason: `\u7F3A\u5C11\u975E\u7A7A\u5B57\u7B26\u4E32 id \u5B57\u6BB5\uFF08{"id":"u1","name":"\u5192\u70DF"}\uFF09` };
|
|
5932
|
+
}
|
|
5933
|
+
for (const key of ["name", "email"]) {
|
|
5934
|
+
const value = record[key];
|
|
5935
|
+
if (value !== void 0 && typeof value !== "string") {
|
|
5936
|
+
return { ok: false, reason: `${key} \u5B57\u6BB5\u5FC5\u987B\u662F\u5B57\u7B26\u4E32` };
|
|
5937
|
+
}
|
|
5938
|
+
}
|
|
5939
|
+
const name = record["name"];
|
|
5940
|
+
const email = record["email"];
|
|
5941
|
+
return {
|
|
5942
|
+
ok: true,
|
|
5943
|
+
user: {
|
|
5944
|
+
id: record["id"],
|
|
5945
|
+
...typeof name === "string" && name !== "" ? { name } : {},
|
|
5946
|
+
...typeof email === "string" && email !== "" ? { email } : {}
|
|
5947
|
+
}
|
|
5948
|
+
};
|
|
5949
|
+
}
|
|
5950
|
+
function simUserResolverFromEnv(fileEnv = {}) {
|
|
5951
|
+
const raw = firstNonEmpty(process.env[SIM_USER_ENV_KEY], fileEnv[SIM_USER_ENV_KEY]);
|
|
5952
|
+
if (raw === void 0) return { resolver: void 0, warning: void 0 };
|
|
5953
|
+
const parsed = parseSimUserJson(raw);
|
|
5954
|
+
if (!parsed.ok) {
|
|
5955
|
+
return {
|
|
5956
|
+
resolver: void 0,
|
|
5957
|
+
warning: `${SIM_USER_ENV_KEY}=${raw} \u89E3\u6790\u5931\u8D25\uFF08${parsed.reason}\uFF09\uFF1A\u5DF2\u8DF3\u8FC7\u6A21\u62DF\u767B\u5F55\u6001\u6CE8\u5165\uFF0C\u767B\u5F55\u6001\u94FE\u8DEF\u8D70\u539F\u8DEF\u5F84`
|
|
5958
|
+
};
|
|
5959
|
+
}
|
|
5960
|
+
return { resolver: async () => parsed.user, warning: void 0 };
|
|
5961
|
+
}
|
|
5848
5962
|
function isRuntimeSource(name) {
|
|
5849
5963
|
return (name.endsWith(".ts") || name.endsWith(".js")) && !name.endsWith(".d.ts") && !name.endsWith(".test.ts");
|
|
5850
5964
|
}
|
|
@@ -6017,7 +6131,9 @@ async function startDevServer(options) {
|
|
|
6017
6131
|
...options.dbFile === void 0 ? {} : { dbFile: options.dbFile }
|
|
6018
6132
|
});
|
|
6019
6133
|
const simEnv = await loadSimEnv(cwd).catch(() => ({}));
|
|
6020
|
-
let
|
|
6134
|
+
let simUser = simUserResolverFromEnv(simEnv);
|
|
6135
|
+
if (simUser.warning !== void 0) log(`[adep] ${simUser.warning}`);
|
|
6136
|
+
let bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(simEnv);
|
|
6021
6137
|
const fetchConfig = resolveLocalFetchConfig(simEnv);
|
|
6022
6138
|
const executor = new WorkerFunctionExecutor({
|
|
6023
6139
|
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS },
|
|
@@ -6131,7 +6247,10 @@ async function startDevServer(options) {
|
|
|
6131
6247
|
]);
|
|
6132
6248
|
files = nextFiles;
|
|
6133
6249
|
env = { ...config.environment, ...parseEnvFile(envText2) };
|
|
6134
|
-
|
|
6250
|
+
const nextEnv = await loadSimEnv(cwd).catch(() => ({}));
|
|
6251
|
+
simUser = simUserResolverFromEnv(nextEnv);
|
|
6252
|
+
if (simUser.warning !== void 0) log(`[adep] ${simUser.warning}`);
|
|
6253
|
+
bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(nextEnv);
|
|
6135
6254
|
};
|
|
6136
6255
|
const envText = await readFile7(join10(cwd, ".env.local"), "utf8").catch(() => "");
|
|
6137
6256
|
env = { ...config.environment, ...parseEnvFile(envText) };
|
|
@@ -6300,7 +6419,11 @@ async function startDevServer(options) {
|
|
|
6300
6419
|
);
|
|
6301
6420
|
log(`[adep] curl \u793A\u4F8B\uFF1Acurl ${baseUrl}${curlPath}`);
|
|
6302
6421
|
printBoundaries(log);
|
|
6303
|
-
if (
|
|
6422
|
+
if (simUser.resolver !== void 0) {
|
|
6423
|
+
log(
|
|
6424
|
+
`[adep] \u26A0\uFE0F \u6A21\u62DF\u767B\u5F55\u6001\uFF1AADEP_SIM_USER \u5DF2\u914D\u7F6E\uFF0C\u6240\u6709\u8BF7\u6C42\u7684 ctx.user \u5C06\u6CE8\u5165\u6A21\u62DF\u7528\u6237\uFF08\u4EC5\u672C\u5730 sim\uFF1B\u5E73\u53F0\u90E8\u7F72\u4E0D\u8BFB\u8BE5\u53D8\u91CF\uFF09`
|
|
6425
|
+
);
|
|
6426
|
+
} else if (bearerUser !== void 0) {
|
|
6304
6427
|
log(
|
|
6305
6428
|
`[adep] \u767B\u5F55\u5373\u670D\u52A1\uFF1AADEP_AUTH_ISSUER \u5DF2\u914D\u7F6E\uFF0CBearer token \u5C06\u89E3\u6790\u4E3A\u7528\u6237\u8EAB\u4EFD\uFF08userinfo \u7AEF\u70B9\uFF09`
|
|
6306
6429
|
);
|
package/dist/worker-entry.js
CHANGED
|
@@ -467,12 +467,24 @@ function errorLineIn(stack, path) {
|
|
|
467
467
|
if (own !== null) return own[1];
|
|
468
468
|
return /(?:^|\n):(\d+)(?:\n|$)/.exec(stack)?.[1];
|
|
469
469
|
}
|
|
470
|
-
|
|
470
|
+
var DYNAMIC_IMPORT_HINT = "\u63D0\u793A\uFF1AM1 \u6C99\u7BB1\u4E0D\u652F\u6301\u52A8\u6001 import\uFF0C\u6539\u9759\u6001 import";
|
|
471
|
+
function isDynamicImportRejection(error) {
|
|
472
|
+
const code = error.code;
|
|
473
|
+
if (code === "ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING") return true;
|
|
474
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
475
|
+
return /dynamic import callback/i.test(message);
|
|
476
|
+
}
|
|
477
|
+
function containsDynamicImport(source) {
|
|
478
|
+
return /(^|[^\w$.])import\s*\(/.test(source);
|
|
479
|
+
}
|
|
480
|
+
function syntaxErrorWithLocation(error, path, source) {
|
|
471
481
|
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
472
482
|
const stack = error.stack;
|
|
473
483
|
const line = typeof stack === "string" ? errorLineIn(stack, path) : void 0;
|
|
474
484
|
const location = line === void 0 ? path : `${path}:${line}`;
|
|
475
|
-
const
|
|
485
|
+
const hint = containsDynamicImport(source) ? `
|
|
486
|
+
${DYNAMIC_IMPORT_HINT}` : "";
|
|
487
|
+
const wrapped = new Error(`\u6E90\u7801\u8BED\u6CD5\u9519\u8BEF\uFF08${location}\uFF09\uFF1A${rawMessage}${hint}`, { cause: error });
|
|
476
488
|
const code = error.code;
|
|
477
489
|
if (typeof code === "string") wrapped.code = code;
|
|
478
490
|
return wrapped;
|
|
@@ -517,7 +529,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
517
529
|
try {
|
|
518
530
|
transformed = transformExports(transpile(source));
|
|
519
531
|
} catch (error) {
|
|
520
|
-
throw syntaxErrorWithLocation(error, path);
|
|
532
|
+
throw syntaxErrorWithLocation(error, path, source);
|
|
521
533
|
}
|
|
522
534
|
const context = createSandboxContext(sandboxGlobals);
|
|
523
535
|
let wrapper;
|
|
@@ -529,7 +541,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
529
541
|
{ filename: path }
|
|
530
542
|
);
|
|
531
543
|
} catch (error) {
|
|
532
|
-
throw syntaxErrorWithLocation(error, path);
|
|
544
|
+
throw syntaxErrorWithLocation(error, path, source);
|
|
533
545
|
}
|
|
534
546
|
wrapper(module, exports, require2);
|
|
535
547
|
if (module.default !== void 0 && exports["default"] === void 0) {
|
|
@@ -1124,10 +1136,10 @@ function firstUserFrame(stack, files) {
|
|
|
1124
1136
|
function errorMessageWithLocation(error, files) {
|
|
1125
1137
|
const message = errorMessageOf2(error);
|
|
1126
1138
|
const stack = error.stack;
|
|
1127
|
-
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
|
|
1139
|
+
const frame = typeof stack === "string" ? firstUserFrame(stack, files) : void 0;
|
|
1140
|
+
const located = frame === void 0 || message.includes(`\uFF08${frame}\uFF09`) ? message : `${message}\uFF08${frame}\uFF09`;
|
|
1141
|
+
return isDynamicImportRejection(error) ? `${located}
|
|
1142
|
+
${DYNAMIC_IMPORT_HINT}` : located;
|
|
1131
1143
|
}
|
|
1132
1144
|
function createBareResolver(deps) {
|
|
1133
1145
|
const platformRequire = createRequire(import.meta.url);
|
package/package.json
CHANGED
|
@@ -7,16 +7,12 @@
|
|
|
7
7
|
},
|
|
8
8
|
"homepage": "https://adep.top",
|
|
9
9
|
"bugs": "https://gitcode.com/yunqiang_wu/ai-yunke/issues",
|
|
10
|
-
"version": "0.5.
|
|
10
|
+
"version": "0.5.5",
|
|
11
11
|
"adep": {
|
|
12
12
|
"releaseTasks": [
|
|
13
|
-
"CLI-
|
|
14
|
-
"
|
|
15
|
-
"CLI-
|
|
16
|
-
"CLI-101",
|
|
17
|
-
"CLI-102",
|
|
18
|
-
"CLI-103",
|
|
19
|
-
"CLI-104"
|
|
13
|
+
"CLI-105",
|
|
14
|
+
"CLI-106",
|
|
15
|
+
"CLI-108"
|
|
20
16
|
]
|
|
21
17
|
},
|
|
22
18
|
"type": "module",
|
|
@@ -44,8 +40,8 @@
|
|
|
44
40
|
"@adep/app-runtime": "0.1.1",
|
|
45
41
|
"@adep/cf-compat": "0.1.4",
|
|
46
42
|
"@adep/crypto": "0.1.1",
|
|
47
|
-
"@adep/
|
|
48
|
-
"@adep/
|
|
43
|
+
"@adep/runtime": "0.3.11",
|
|
44
|
+
"@adep/vite-plugin": "0.1.13"
|
|
49
45
|
},
|
|
50
46
|
"devDependencies": {
|
|
51
47
|
"@adep/types": "0.4.3"
|