@adep/cli 0.5.3 → 0.5.4

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.
Files changed (4) hide show
  1. package/README.md +18 -5
  2. package/dist/index.js +1030 -190
  3. package/dist/vite.js +285 -29
  4. package/package.json +12 -13
package/dist/vite.js CHANGED
@@ -2137,9 +2137,20 @@ var StorageError = class extends Error {
2137
2137
  var STORAGE_CODES = {
2138
2138
  invalidPath: "STORAGE_INVALID_PATH",
2139
2139
  invalidData: "STORAGE_INVALID_DATA",
2140
+ invalidVisibility: "STORAGE_INVALID_VISIBILITY",
2141
+ invalidSignedUrlTtl: "STORAGE_SIGNED_URL_TTL_INVALID",
2142
+ signedUrlTtlExceeded: "STORAGE_SIGNED_URL_TTL_EXCEEDED",
2140
2143
  notFound: "STORAGE_NOT_FOUND",
2141
2144
  quotaExceeded: "STORAGE_QUOTA_EXCEEDED"
2142
2145
  };
2146
+ function assertFileVisibility(value) {
2147
+ if (value === "public" || value === "private") return value;
2148
+ throw new StorageError(
2149
+ 400,
2150
+ STORAGE_CODES.invalidVisibility,
2151
+ `\u975E\u6CD5\u7684\u6587\u4EF6\u53EF\u89C1\u6027 ${JSON.stringify(value)}\uFF08\u53EA\u652F\u6301 'public' / 'private'\uFF09`
2152
+ );
2153
+ }
2143
2154
  function assertSafeStoragePath(path) {
2144
2155
  if (typeof path !== "string" || path.length === 0) {
2145
2156
  throw new StorageError(400, STORAGE_CODES.invalidPath, "\u5B58\u50A8\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
@@ -2347,17 +2358,46 @@ function hmacSha256Hex(key, message) {
2347
2358
 
2348
2359
  // packages/runtime/src/storage/signature.ts
2349
2360
  var DEFAULT_SIGN_TTL_SECONDS = 15 * 60;
2361
+ var MAX_SIGNED_URL_TTL_SECONDS = 7 * 24 * 60 * 60;
2350
2362
  var SIGN_EXPIRES_KEY = "x-expires";
2351
2363
  var SIGN_SIGNATURE_KEY = "x-signature";
2364
+ function resolveSignedUrlTtl(ttlSeconds, options) {
2365
+ if (ttlSeconds === void 0) return DEFAULT_SIGN_TTL_SECONDS;
2366
+ if (!Number.isInteger(ttlSeconds) || ttlSeconds <= 0) {
2367
+ throw new StorageError(
2368
+ 400,
2369
+ STORAGE_CODES.invalidSignedUrlTtl,
2370
+ `\u7B7E\u540D\u6709\u6548\u671F\u5FC5\u987B\u662F\u6B63\u6574\u6570\u79D2\uFF08\u6536\u5230 ${ttlSeconds}\uFF09`
2371
+ );
2372
+ }
2373
+ if (ttlSeconds > MAX_SIGNED_URL_TTL_SECONDS && options?.force !== true) {
2374
+ throw new StorageError(
2375
+ 400,
2376
+ STORAGE_CODES.signedUrlTtlExceeded,
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
+ );
2379
+ }
2380
+ return ttlSeconds;
2381
+ }
2352
2382
  function sign(secret, projectId, path, expires) {
2353
2383
  const payload = `${projectId}|${path}|${expires}`;
2354
2384
  return hmacSha256Hex(secret, payload);
2355
2385
  }
2356
- function signDownloadUrl(config, projectId, path, ttlSeconds = DEFAULT_SIGN_TTL_SECONDS) {
2357
- const expires = Math.floor(Date.now() / 1e3) + ttlSeconds;
2358
- const base = `${config.baseUrl}/api/v1/projects/${encodeURIComponent(projectId)}/files/${encodeURIComponent(path)}`;
2386
+ function publicDownloadUrl(config, projectId, path) {
2387
+ return `${config.baseUrl}/api/v1/projects/${encodeURIComponent(projectId)}/files/${encodeURIComponent(path)}`;
2388
+ }
2389
+ function signDownloadUrlWithExpiry(config, projectId, path, ttlSeconds = DEFAULT_SIGN_TTL_SECONDS, options) {
2390
+ const ttl = resolveSignedUrlTtl(ttlSeconds, options);
2391
+ const expires = Math.floor(Date.now() / 1e3) + ttl;
2392
+ const base = publicDownloadUrl(config, projectId, path);
2359
2393
  const signature = sign(config.secret, projectId, path, expires);
2360
- return `${base}?${SIGN_EXPIRES_KEY}=${expires}&${SIGN_SIGNATURE_KEY}=${signature}`;
2394
+ return {
2395
+ url: `${base}?${SIGN_EXPIRES_KEY}=${expires}&${SIGN_SIGNATURE_KEY}=${signature}`,
2396
+ expires
2397
+ };
2398
+ }
2399
+ function signDownloadUrl(config, projectId, path, ttlSeconds = DEFAULT_SIGN_TTL_SECONDS, options) {
2400
+ return signDownloadUrlWithExpiry(config, projectId, path, ttlSeconds, options).url;
2361
2401
  }
2362
2402
 
2363
2403
  // packages/runtime/src/storage/cloud.ts
@@ -2406,9 +2446,10 @@ function createStorageCapability(driver, signer, projectId) {
2406
2446
  switch (method) {
2407
2447
  case "upload": {
2408
2448
  const [path, data, options] = args;
2449
+ const visibility = assertFileVisibility(options?.visibility ?? DEFAULT_VISIBILITY);
2409
2450
  return toStoredFile(
2410
2451
  await driver.put(projectId, path, asBytes(data), {
2411
- visibility: DEFAULT_VISIBILITY,
2452
+ visibility,
2412
2453
  ...options?.contentType === void 0 ? {} : { contentType: options.contentType }
2413
2454
  })
2414
2455
  );
@@ -2426,9 +2467,26 @@ function createStorageCapability(driver, signer, projectId) {
2426
2467
  const [prefix] = args;
2427
2468
  return (await driver.list(projectId, prefix)).map(toStoredFile);
2428
2469
  }
2470
+ case "getUrl": {
2471
+ const [path] = args;
2472
+ const meta = await driver.getMeta(projectId, path);
2473
+ if (meta.visibility === "public") {
2474
+ const result2 = {
2475
+ url: publicDownloadUrl(signer, projectId, path),
2476
+ expiresAt: null
2477
+ };
2478
+ return result2;
2479
+ }
2480
+ const signed = signDownloadUrlWithExpiry(signer, projectId, path);
2481
+ const result = {
2482
+ url: signed.url,
2483
+ expiresAt: new Date(signed.expires * 1e3).toISOString()
2484
+ };
2485
+ return result;
2486
+ }
2429
2487
  case "getSignedUrl": {
2430
- const [path, ttlSeconds] = args;
2431
- return signDownloadUrl(signer, projectId, path, ttlSeconds);
2488
+ const [path, ttlSeconds, options] = args;
2489
+ return signDownloadUrl(signer, projectId, path, ttlSeconds, options);
2432
2490
  }
2433
2491
  default:
2434
2492
  throw new StorageError(
@@ -2917,6 +2975,16 @@ function unquoteIdent(raw) {
2917
2975
  }
2918
2976
  return text;
2919
2977
  }
2978
+ function parsePlainIdent(raw) {
2979
+ const text = raw.trim();
2980
+ if (text.length === 0) return null;
2981
+ const first = text[0];
2982
+ if (first === '"' || first === "`" || first === "[" || first === "'") {
2983
+ const unquoted = unquoteIdent(text);
2984
+ return unquoted === text.trim() ? null : unquoted;
2985
+ }
2986
+ return /^[A-Za-z_][A-Za-z0-9_$]*$/.test(text) ? text : null;
2987
+ }
2920
2988
  function splitTopLevel2(body) {
2921
2989
  const parts = [];
2922
2990
  let depth = 0;
@@ -3010,19 +3078,47 @@ function parseColumn(part) {
3010
3078
  }
3011
3079
  const type = rest.slice(0, typeEnd).trim();
3012
3080
  rest = rest.slice(typeEnd).trim();
3013
- const notNull = /\bNOT\s+NULL\b/i.test(rest);
3014
- const primaryKey = /\bPRIMARY\s+KEY\b/i.test(rest);
3015
3081
  const defaultMatch = /\bDEFAULT\s+(.+?)(?=\s+(?:NOT|PRIMARY|UNIQUE|CHECK|REFERENCES|COLLATE|GENERATED|AS|AUTOINCREMENT|CONSTRAINT)\b|$)/i.exec(
3016
3082
  rest
3017
3083
  );
3084
+ const constraintText = defaultMatch === null ? rest : rest.replace(defaultMatch[0], " ");
3085
+ const declarationText = stripNonNullabilityClauses(constraintText);
3086
+ const notNull = /\bNOT\s+NULL\b/i.test(declarationText);
3087
+ const explicitNullable = !notNull && /\bNULL\b/i.test(declarationText);
3088
+ const primaryKey = /\bPRIMARY\s+KEY\b/i.test(declarationText);
3089
+ const unique = /\bUNIQUE\b/i.test(declarationText);
3018
3090
  return {
3019
3091
  name,
3020
3092
  type,
3021
3093
  notNull,
3094
+ explicitNullable,
3022
3095
  primaryKey,
3096
+ unique,
3023
3097
  defaultValue: defaultMatch === null ? null : defaultMatch[1].trim()
3024
3098
  };
3025
3099
  }
3100
+ function stripNonNullabilityClauses(text) {
3101
+ return text.replace(
3102
+ /\bREFERENCES\s+\S+(?:\s*\([^)]*\))?(?:\s+ON\s+(?:DELETE|UPDATE)\s+(?:CASCADE|RESTRICT|SET\s+NULL|SET\s+DEFAULT|NO\s+ACTION))*/gi,
3103
+ " "
3104
+ ).replace(/\bCHECK\s*\([^)]*\)/gi, " ").replace(/\bGENERATED\s+ALWAYS\s+AS\s*\([^)]*\)(?:\s+STORED|\s+VIRTUAL)?/gi, " ");
3105
+ }
3106
+ function parseTableUnique(part) {
3107
+ const trimmed = part.trim();
3108
+ const match = /^(?:CONSTRAINT\s+(?:"(?:[^"]|"")*"|`(?:[^`]|``)*`|\[[^\]]*\]|[A-Za-z_][A-Za-z0-9_$]*)\s+)?UNIQUE\s*\(/i.exec(
3109
+ trimmed
3110
+ );
3111
+ if (match === null) return null;
3112
+ const body = findTableBody(trimmed, match[0].lastIndexOf("("));
3113
+ if (body === null) return null;
3114
+ const columns = [];
3115
+ for (const entry of splitTopLevel2(body)) {
3116
+ const column = parsePlainIdent(entry);
3117
+ if (column === null) return null;
3118
+ columns.push(column);
3119
+ }
3120
+ return columns.length === 0 ? null : columns;
3121
+ }
3026
3122
  function parseSchemaTables(sql) {
3027
3123
  const tables = [];
3028
3124
  const pattern = /CREATE\s+(?:TEMP|TEMPORARY\s+)?TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?("(?:[^"]|"")*"|`(?:[^`]|``)*`|\[[^\]]*\]|'[^']*'|[A-Za-z_][A-Za-z0-9_$.]*)\s*\(/gi;
@@ -3036,11 +3132,14 @@ function parseSchemaTables(sql) {
3036
3132
  const rawName = match[1];
3037
3133
  const name = unquoteIdent(rawName.split(".").pop() ?? rawName);
3038
3134
  const columns = [];
3135
+ const uniqueConstraints = [];
3039
3136
  for (const part of splitTopLevel2(body)) {
3137
+ const unique = parseTableUnique(part);
3138
+ if (unique !== null) uniqueConstraints.push(unique);
3040
3139
  const column = parseColumn(part);
3041
3140
  if (column !== null) columns.push(column);
3042
3141
  }
3043
- tables.push({ name, columns, statement: statement.trim() });
3142
+ tables.push({ name, columns, uniqueConstraints, statement: statement.trim() });
3044
3143
  }
3045
3144
  return tables;
3046
3145
  }
@@ -3063,6 +3162,18 @@ function planMissingColumn(table, column) {
3063
3162
  };
3064
3163
  }
3065
3164
 
3165
+ // packages/cli/src/auth.ts
3166
+ var CliError = class extends Error {
3167
+ constructor(code, message, exitCode = 1) {
3168
+ super(message);
3169
+ this.code = code;
3170
+ this.exitCode = exitCode;
3171
+ this.name = "CliError";
3172
+ }
3173
+ code;
3174
+ exitCode;
3175
+ };
3176
+
3066
3177
  // packages/cli/src/serve/sqlite-driver.ts
3067
3178
  import { mkdir as mkdir3 } from "node:fs/promises";
3068
3179
  import { dirname as dirname4, resolve as resolve2 } from "node:path";
@@ -3403,6 +3514,13 @@ function isFetchBlockedPort(port) {
3403
3514
 
3404
3515
  // packages/cli/src/serve/fetch-safe-port.ts
3405
3516
  var MAX_FETCH_SAFE_LISTEN_ATTEMPTS = 8;
3517
+ var DEFAULT_PORT_FALLBACK_SPAN = 12;
3518
+ var PortFallbackExhaustedError = class extends Error {
3519
+ constructor(message) {
3520
+ super(message);
3521
+ this.name = "PortFallbackExhaustedError";
3522
+ }
3523
+ };
3406
3524
  function listenOnce(server, port, host) {
3407
3525
  return new Promise((resolve6, reject) => {
3408
3526
  const onError = (error) => {
@@ -3444,6 +3562,21 @@ function buildExhaustedMessage(input) {
3444
3562
  "\u53EF\u80FD\u539F\u56E0\uFF1A\u7CFB\u7EDF\u4E34\u65F6\u7AEF\u53E3\u8D77\u59CB\u503C\u88AB\u8C03\u4F4E\uFF08Windows \u7528 netsh int ipv4 show dynamicport tcp \u6838\u5BF9\uFF0CHyper-V / \u5BB9\u5668\u7F51\u7EDC\u4F1A\u6539\u5B83\uFF09\u3002\u53EF\u7528 --port \u6307\u5B9A\u4E00\u4E2A\u672A\u5360\u7528\u7684\u7AEF\u53E3\u7ED5\u8FC7\u3002"
3445
3563
  ].join("\n");
3446
3564
  }
3565
+ function isAddrInUseCode(error) {
3566
+ return error?.code === "EADDRINUSE";
3567
+ }
3568
+ function formatFallbackNotice(info) {
3569
+ return `[adep] \u7AEF\u53E3 ${info.requested} \u5DF2\u88AB\u5360\u7528\uFF0C\u5DF2\u6539\u7528 ${info.actual}\uFF08\u7F3A\u7701\u7AEF\u53E3\u81EA\u52A8\u987A\u5EF6\uFF1B\u663E\u5F0F\u6307\u5B9A\u7684\u7AEF\u53E3\u4E0D\u6362\u53F7\uFF09`;
3570
+ }
3571
+ function buildFallbackExhaustedMessage(input) {
3572
+ const first = input.requested + 1;
3573
+ const last = input.requested + input.span;
3574
+ return [
3575
+ `[adep] \u7AEF\u53E3 ${input.requested} \u5DF2\u88AB\u5360\u7528\uFF0C\u5176\u540E ${input.span} \u4E2A\u5019\u9009\u7AEF\u53E3\uFF08${first}~${last}\uFF09\u4E5F\u4E0D\u53EF\u7528\uFF0C\u5DF2\u653E\u5F03\u542F\u52A8\u3002`,
3576
+ "\u7F3A\u7701\u7AEF\u53E3\u81EA\u52A8\u987A\u5EF6\u53EA\u8986\u76D6\u8FD9\u4E00\u5C0F\u6BB5\uFF1B\u8BF7\u7528 --port \u6307\u5B9A\u4E00\u4E2A\u7A7A\u95F2\u7AEF\u53E3\uFF08\u663E\u5F0F\u7AEF\u53E3\u4E0D\u4F1A\u81EA\u52A8\u6362\u53F7\uFF09\u3002",
3577
+ `\u5360\u7528\u8005\u6392\u67E5\uFF1Alsof -nP -iTCP:${input.requested} -sTCP:LISTEN\uFF08Windows\uFF1Anetstat -ano | findstr :${input.requested}\uFF09`
3578
+ ].join("\n");
3579
+ }
3447
3580
  async function listenOnFetchSafePort(server, options) {
3448
3581
  const isBlocked = options.isBlocked ?? isFetchBlockedPort;
3449
3582
  const warn = options.warn ?? (() => {
@@ -3454,12 +3587,46 @@ async function listenOnFetchSafePort(server, options) {
3454
3587
  } catch {
3455
3588
  }
3456
3589
  };
3457
- if (options.port !== 0) {
3590
+ const requestedPort = options.port;
3591
+ if (requestedPort !== 0) {
3458
3592
  try {
3459
- await listenOnce(server, options.port, options.host);
3593
+ await listenOnce(server, requestedPort, options.host);
3460
3594
  } catch (error) {
3461
- await notifyListenError(error);
3462
- throw error;
3595
+ const fallback = options.fallbackOnInUse;
3596
+ if (fallback === void 0 || !isAddrInUseCode(error)) {
3597
+ await notifyListenError(error);
3598
+ throw error;
3599
+ }
3600
+ const span = fallback.span ?? DEFAULT_PORT_FALLBACK_SPAN;
3601
+ if (!Number.isInteger(span) || span < 1) {
3602
+ await notifyListenError(error);
3603
+ throw new Error(`[adep] fallbackOnInUse.span \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF08\u6536\u5230 ${String(span)}\uFF09\u3002`, {
3604
+ cause: error
3605
+ });
3606
+ }
3607
+ let lastError = error;
3608
+ for (let offset = 1; offset <= span; offset += 1) {
3609
+ const candidate = requestedPort + offset;
3610
+ if (candidate > 65535) break;
3611
+ if (isBlocked(candidate)) continue;
3612
+ try {
3613
+ await listenOnce(server, candidate, options.host);
3614
+ } catch (candidateError) {
3615
+ if (isAddrInUseCode(candidateError)) {
3616
+ lastError = candidateError;
3617
+ continue;
3618
+ }
3619
+ await notifyListenError(candidateError);
3620
+ throw candidateError;
3621
+ }
3622
+ const report = options.onFallback ?? ((info) => warn(formatFallbackNotice(info)));
3623
+ report({ requested: requestedPort, actual: candidate });
3624
+ return candidate;
3625
+ }
3626
+ await notifyListenError(lastError);
3627
+ throw new PortFallbackExhaustedError(
3628
+ buildFallbackExhaustedMessage({ requested: requestedPort, span })
3629
+ );
3463
3630
  }
3464
3631
  const actual = readTcpPort(server, options.host);
3465
3632
  if (isBlocked(actual)) {
@@ -3492,6 +3659,79 @@ async function listenOnFetchSafePort(server, options) {
3492
3659
  throw new Error(buildExhaustedMessage({ host: options.host, hits, maxAttempts }));
3493
3660
  }
3494
3661
 
3662
+ // packages/cli/src/serve/port-in-use.ts
3663
+ import { execFile } from "node:child_process";
3664
+ function parsePortOccupier(stdout) {
3665
+ for (const line of stdout.split(/\r?\n/)) {
3666
+ const trimmed = line.trim();
3667
+ if (trimmed.length === 0 || trimmed.startsWith("COMMAND")) continue;
3668
+ const [command, pid] = trimmed.split(/\s+/);
3669
+ if (command === void 0 || pid === void 0 || !/^\d+$/u.test(pid)) return null;
3670
+ return `${command} ${pid}`;
3671
+ }
3672
+ return null;
3673
+ }
3674
+ function runLsof(port) {
3675
+ return new Promise((resolve6, reject) => {
3676
+ execFile(
3677
+ "lsof",
3678
+ ["-nP", `-iTCP:${port}`, "-sTCP:LISTEN"],
3679
+ { timeout: 2e3, windowsHide: true },
3680
+ (error, stdout) => {
3681
+ if (error !== null) {
3682
+ reject(error);
3683
+ return;
3684
+ }
3685
+ resolve6(stdout);
3686
+ }
3687
+ );
3688
+ });
3689
+ }
3690
+ async function lookupPortOccupier(port, options = {}) {
3691
+ if (process.platform === "win32") return null;
3692
+ const execute = options.execute ?? runLsof;
3693
+ try {
3694
+ return parsePortOccupier(await execute(port));
3695
+ } catch {
3696
+ return null;
3697
+ }
3698
+ }
3699
+ async function describePortInUse(options) {
3700
+ const occupier = await (options.lookup ?? lookupPortOccupier)(options.port);
3701
+ const nextPort = options.port < 65535 ? options.port + 1 : options.port - 1;
3702
+ const command = `adep ${options.scope}`;
3703
+ return [
3704
+ `[adep] \u7AEF\u53E3 ${options.port} \u5DF2\u88AB\u5360\u7528\uFF08EADDRINUSE\uFF09\uFF1B\u8BE5\u7AEF\u53E3\u662F\u663E\u5F0F\u6307\u5B9A\u7684\uFF08--port / PORT\uFF09\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u6539\u7528\u5176\u5B83\u7AEF\u53E3\u3002`,
3705
+ occupier === null ? `\u5360\u7528\u8005\uFF1A\u65E0\u6CD5\u5B9A\u4F4D\u3002\u624B\u52A8\u68C0\u67E5\uFF1Alsof -nP -iTCP:${options.port} -sTCP:LISTEN\uFF08Windows\uFF1Anetstat -ano | findstr :${options.port}\uFF09` : `\u5360\u7528\u8005\uFF1A${occupier}\uFF08\u590D\u6838\u547D\u4EE4\uFF1Alsof -nP -iTCP:${options.port} -sTCP:LISTEN\uFF09`,
3706
+ `\u5904\u7F6E\uFF1A\u6539\u7528\u5176\u5B83\u7AEF\u53E3\uFF08${command} --port ${nextPort}\uFF09\uFF0C\u6216\u5148\u505C\u6B62\u5360\u7528\u8BE5\u7AEF\u53E3\u7684\u8FDB\u7A0B\u3002`
3707
+ ].join("\n");
3708
+ }
3709
+ function isAddrInUse(error) {
3710
+ return error?.code === "EADDRINUSE";
3711
+ }
3712
+ async function toPortCliError(error, context) {
3713
+ if (isAddrInUse(error)) {
3714
+ return new CliError(
3715
+ "PORT_IN_USE",
3716
+ await describePortInUse({ port: context.port, scope: context.scope })
3717
+ );
3718
+ }
3719
+ if (error instanceof PortFallbackExhaustedError) {
3720
+ return new CliError("PORT_FALLBACK_EXHAUSTED", error.message);
3721
+ }
3722
+ return null;
3723
+ }
3724
+ function isPortConflictError(error) {
3725
+ if (isAddrInUse(error)) return true;
3726
+ return error instanceof CliError && error.code === "PORT_IN_USE";
3727
+ }
3728
+ function toAddrInUseError(error) {
3729
+ const message = error instanceof Error ? error.message : String(error);
3730
+ const wrapped = new Error(message, { cause: error });
3731
+ wrapped.code = "EADDRINUSE";
3732
+ return wrapped;
3733
+ }
3734
+
3495
3735
  // packages/cli/src/sim/env.ts
3496
3736
  import { readFile as readFile4 } from "node:fs/promises";
3497
3737
  import { join as join6 } from "node:path";
@@ -6035,13 +6275,22 @@ async function startDevServer(options) {
6035
6275
  } catch {
6036
6276
  }
6037
6277
  };
6038
- const actualPort = await listenOnFetchSafePort(server, {
6039
- port,
6040
- host: "127.0.0.1",
6041
- warn: log,
6042
- onListenError: disposeAfterListenError
6043
- });
6278
+ let actualPort;
6279
+ try {
6280
+ actualPort = await listenOnFetchSafePort(server, {
6281
+ port,
6282
+ host: "127.0.0.1",
6283
+ warn: log,
6284
+ ...options.port === void 0 ? { fallbackOnInUse: {} } : {},
6285
+ onListenError: disposeAfterListenError
6286
+ });
6287
+ } catch (error) {
6288
+ const portError = await toPortCliError(error, { port, scope: "dev" });
6289
+ if (portError !== null) throw portError;
6290
+ throw error;
6291
+ }
6044
6292
  const baseUrl = `http://127.0.0.1:${actualPort}`;
6293
+ runtime.storage.signer.baseUrl = baseUrl;
6045
6294
  const coldStartMs = Date.now() - coldStartAt;
6046
6295
  const curlPath = config.functionsPrefix.length === 0 ? "/hello" : `/${config.functionsPrefix}/hello`;
6047
6296
  const dbLabel = db.mode === "sqlite" ? `SQLite \u771F\u5B9E\u5E93${db.module === null ? "" : `\uFF08${db.module}\uFF09`}` : "sim \u5F15\u64CE\uFF08\u5185\u7F6E\u6A21\u62DF\uFF09";
@@ -6080,17 +6329,24 @@ import {
6080
6329
  FN_FETCH_INTERCEPTOR_SCRIPT,
6081
6330
  injectAutomationScriptTag,
6082
6331
  injectFnProxyScriptTag,
6083
- isAddrInUse,
6332
+ isAddrInUse as isAddrInUse2,
6084
6333
  normalizeFunctionPrefix,
6085
6334
  PREVIEW_AUTOMATION_SCRIPT
6086
6335
  } from "@adep/vite-plugin";
6087
- var createDevServer = (opts) => startDevServer({
6088
- cwd: opts.cwd,
6089
- port: opts.port,
6090
- prefix: opts.prefix,
6091
- log: opts.log,
6092
- ...opts.schemaFile === void 0 ? {} : { schemaFile: opts.schemaFile }
6093
- });
6336
+ var createDevServer = async (opts) => {
6337
+ try {
6338
+ return await startDevServer({
6339
+ cwd: opts.cwd,
6340
+ port: opts.port,
6341
+ prefix: opts.prefix,
6342
+ log: opts.log,
6343
+ ...opts.schemaFile === void 0 ? {} : { schemaFile: opts.schemaFile }
6344
+ });
6345
+ } catch (error) {
6346
+ if (isPortConflictError(error)) throw toAddrInUseError(error);
6347
+ throw error;
6348
+ }
6349
+ };
6094
6350
  var loadConfig2 = (cwd) => loadAdepConfigModule(cwd);
6095
6351
  function resolveLocalSchemaFile(cwd, configured) {
6096
6352
  if (configured === false) return void 0;
@@ -6118,7 +6374,7 @@ export {
6118
6374
  vite_default as default,
6119
6375
  injectAutomationScriptTag,
6120
6376
  injectFnProxyScriptTag,
6121
- isAddrInUse,
6377
+ isAddrInUse2 as isAddrInUse,
6122
6378
  normalizeFunctionPrefix,
6123
6379
  resolveLocalSchemaFile
6124
6380
  };
package/package.json CHANGED
@@ -7,17 +7,16 @@
7
7
  },
8
8
  "homepage": "https://adep.top",
9
9
  "bugs": "https://gitcode.com/yunqiang_wu/ai-yunke/issues",
10
- "version": "0.5.3",
10
+ "version": "0.5.4",
11
11
  "adep": {
12
12
  "releaseTasks": [
13
- "DB-024",
14
- "FE-169",
15
- "CLI-051",
16
- "CLI-052",
17
- "CLI-053",
18
- "CLI-054",
19
- "CLI-055",
20
- "CLI-056"
13
+ "CLI-057",
14
+ "DB-025",
15
+ "CLI-100",
16
+ "CLI-101",
17
+ "CLI-102",
18
+ "CLI-103",
19
+ "CLI-104"
21
20
  ]
22
21
  },
23
22
  "type": "module",
@@ -42,14 +41,14 @@
42
41
  "esbuild": "0.25.12",
43
42
  "yaml": "2.9.1",
44
43
  "zod": "^4.6.6",
45
- "@adep/vite-plugin": "0.1.12",
46
44
  "@adep/app-runtime": "0.1.1",
47
- "@adep/crypto": "0.1.1",
48
45
  "@adep/cf-compat": "0.1.4",
49
- "@adep/runtime": "0.3.9"
46
+ "@adep/crypto": "0.1.1",
47
+ "@adep/vite-plugin": "0.1.13",
48
+ "@adep/runtime": "0.3.10"
50
49
  },
51
50
  "devDependencies": {
52
- "@adep/types": "0.4.2"
51
+ "@adep/types": "0.4.3"
53
52
  },
54
53
  "scripts": {
55
54
  "test": "vitest run",