@adep/cli 0.5.4 → 0.5.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/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
- function syntaxErrorWithLocation(error, path) {
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 wrapped = new Error(`\u6E90\u7801\u8BED\u6CD5\u9519\u8BEF\uFF08${location}\uFF09\uFF1A${rawMessage}`, { cause: error });
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
- if (typeof stack !== "string") return message;
5522
- const frame = firstUserFrame(stack, files);
5523
- if (frame === void 0 || message.includes(`\uFF08${frame}\uFF09`)) return message;
5524
- return `${message}\uFF08${frame}\uFF09`;
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 bearerUser = bearerUserResolverFromEnv(simEnv);
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
- bearerUser = bearerUserResolverFromEnv(await loadSimEnv(cwd).catch(() => ({})));
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 (bearerUser !== void 0) {
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
  );
@@ -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
- function syntaxErrorWithLocation(error, path) {
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 wrapped = new Error(`\u6E90\u7801\u8BED\u6CD5\u9519\u8BEF\uFF08${location}\uFF09\uFF1A${rawMessage}`, { cause: error });
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
- if (typeof stack !== "string") return message;
1128
- const frame = firstUserFrame(stack, files);
1129
- if (frame === void 0 || message.includes(`\uFF08${frame}\uFF09`)) return message;
1130
- return `${message}\uFF08${frame}\uFF09`;
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,10 @@
7
7
  },
8
8
  "homepage": "https://adep.top",
9
9
  "bugs": "https://gitcode.com/yunqiang_wu/ai-yunke/issues",
10
- "version": "0.5.4",
10
+ "version": "0.5.6",
11
11
  "adep": {
12
12
  "releaseTasks": [
13
- "CLI-057",
14
- "DB-025",
15
- "CLI-100",
16
- "CLI-101",
17
- "CLI-102",
18
- "CLI-103",
19
- "CLI-104"
13
+ "CORE-193"
20
14
  ]
21
15
  },
22
16
  "type": "module",
@@ -37,15 +31,15 @@
37
31
  "templates"
38
32
  ],
39
33
  "dependencies": {
40
- "commander": "14.0.2",
41
- "esbuild": "0.25.12",
34
+ "commander": "15.1.0",
35
+ "esbuild": "0.28.2",
42
36
  "yaml": "2.9.1",
43
37
  "zod": "^4.6.6",
44
38
  "@adep/app-runtime": "0.1.1",
45
39
  "@adep/cf-compat": "0.1.4",
46
40
  "@adep/crypto": "0.1.1",
47
41
  "@adep/vite-plugin": "0.1.13",
48
- "@adep/runtime": "0.3.10"
42
+ "@adep/runtime": "0.3.11"
49
43
  },
50
44
  "devDependencies": {
51
45
  "@adep/types": "0.4.3"