@adep/cli 0.5.3 → 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 +19 -6
- package/dist/index.js +1240 -207
- package/dist/vite.js +419 -40
- package/dist/worker-entry.js +20 -8
- package/package.json +8 -13
package/dist/index.js
CHANGED
|
@@ -3123,6 +3123,14 @@ var init_kv = __esm({
|
|
|
3123
3123
|
});
|
|
3124
3124
|
|
|
3125
3125
|
// packages/runtime/src/storage/driver.ts
|
|
3126
|
+
function assertFileVisibility(value) {
|
|
3127
|
+
if (value === "public" || value === "private") return value;
|
|
3128
|
+
throw new StorageError(
|
|
3129
|
+
400,
|
|
3130
|
+
STORAGE_CODES.invalidVisibility,
|
|
3131
|
+
`\u975E\u6CD5\u7684\u6587\u4EF6\u53EF\u89C1\u6027 ${JSON.stringify(value)}\uFF08\u53EA\u652F\u6301 'public' / 'private'\uFF09`
|
|
3132
|
+
);
|
|
3133
|
+
}
|
|
3126
3134
|
function assertSafeStoragePath(path) {
|
|
3127
3135
|
if (typeof path !== "string" || path.length === 0) {
|
|
3128
3136
|
throw new StorageError(400, STORAGE_CODES.invalidPath, "\u5B58\u50A8\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
|
|
@@ -3183,6 +3191,9 @@ var init_driver = __esm({
|
|
|
3183
3191
|
STORAGE_CODES = {
|
|
3184
3192
|
invalidPath: "STORAGE_INVALID_PATH",
|
|
3185
3193
|
invalidData: "STORAGE_INVALID_DATA",
|
|
3194
|
+
invalidVisibility: "STORAGE_INVALID_VISIBILITY",
|
|
3195
|
+
invalidSignedUrlTtl: "STORAGE_SIGNED_URL_TTL_INVALID",
|
|
3196
|
+
signedUrlTtlExceeded: "STORAGE_SIGNED_URL_TTL_EXCEEDED",
|
|
3186
3197
|
notFound: "STORAGE_NOT_FOUND",
|
|
3187
3198
|
quotaExceeded: "STORAGE_QUOTA_EXCEEDED"
|
|
3188
3199
|
};
|
|
@@ -3366,15 +3377,48 @@ var init_hmac_sha256 = __esm({
|
|
|
3366
3377
|
});
|
|
3367
3378
|
|
|
3368
3379
|
// packages/runtime/src/storage/signature.ts
|
|
3380
|
+
function resolveSignedUrlTtl(ttlSeconds, options) {
|
|
3381
|
+
if (ttlSeconds === void 0) return DEFAULT_SIGN_TTL_SECONDS;
|
|
3382
|
+
if (!Number.isInteger(ttlSeconds) || ttlSeconds <= 0) {
|
|
3383
|
+
throw new StorageError(
|
|
3384
|
+
400,
|
|
3385
|
+
STORAGE_CODES.invalidSignedUrlTtl,
|
|
3386
|
+
`\u7B7E\u540D\u6709\u6548\u671F\u5FC5\u987B\u662F\u6B63\u6574\u6570\u79D2\uFF08\u6536\u5230 ${ttlSeconds}\uFF09`
|
|
3387
|
+
);
|
|
3388
|
+
}
|
|
3389
|
+
if (ttlSeconds > MAX_SIGNED_URL_TTL_SECONDS && options?.force !== true) {
|
|
3390
|
+
throw new StorageError(
|
|
3391
|
+
400,
|
|
3392
|
+
STORAGE_CODES.signedUrlTtlExceeded,
|
|
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
|
+
);
|
|
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
|
+
}
|
|
3401
|
+
return ttlSeconds;
|
|
3402
|
+
}
|
|
3369
3403
|
function sign(secret, projectId, path, expires) {
|
|
3370
3404
|
const payload = `${projectId}|${path}|${expires}`;
|
|
3371
3405
|
return hmacSha256Hex(secret, payload);
|
|
3372
3406
|
}
|
|
3373
|
-
function
|
|
3374
|
-
|
|
3375
|
-
|
|
3407
|
+
function publicDownloadUrl(config2, projectId, path) {
|
|
3408
|
+
return `${config2.baseUrl}/api/v1/projects/${encodeURIComponent(projectId)}/files/${encodeURIComponent(path)}`;
|
|
3409
|
+
}
|
|
3410
|
+
function signDownloadUrlWithExpiry(config2, projectId, path, ttlSeconds = DEFAULT_SIGN_TTL_SECONDS, options) {
|
|
3411
|
+
const ttl = resolveSignedUrlTtl(ttlSeconds, options);
|
|
3412
|
+
const expires = Math.floor(Date.now() / 1e3) + ttl;
|
|
3413
|
+
const base = publicDownloadUrl(config2, projectId, path);
|
|
3376
3414
|
const signature = sign(config2.secret, projectId, path, expires);
|
|
3377
|
-
return
|
|
3415
|
+
return {
|
|
3416
|
+
url: `${base}?${SIGN_EXPIRES_KEY}=${expires}&${SIGN_SIGNATURE_KEY}=${signature}`,
|
|
3417
|
+
expires
|
|
3418
|
+
};
|
|
3419
|
+
}
|
|
3420
|
+
function signDownloadUrl(config2, projectId, path, ttlSeconds = DEFAULT_SIGN_TTL_SECONDS, options) {
|
|
3421
|
+
return signDownloadUrlWithExpiry(config2, projectId, path, ttlSeconds, options).url;
|
|
3378
3422
|
}
|
|
3379
3423
|
function verifyDownloadSignature(config2, projectId, path, query, nowSeconds2 = Math.floor(Date.now() / 1e3)) {
|
|
3380
3424
|
const expiresRaw = query.expires;
|
|
@@ -3392,12 +3436,14 @@ function verifyDownloadSignature(config2, projectId, path, query, nowSeconds2 =
|
|
|
3392
3436
|
}
|
|
3393
3437
|
return { ok: true };
|
|
3394
3438
|
}
|
|
3395
|
-
var DEFAULT_SIGN_TTL_SECONDS, SIGN_EXPIRES_KEY, SIGN_SIGNATURE_KEY;
|
|
3439
|
+
var DEFAULT_SIGN_TTL_SECONDS, MAX_SIGNED_URL_TTL_SECONDS, SIGN_EXPIRES_KEY, SIGN_SIGNATURE_KEY;
|
|
3396
3440
|
var init_signature = __esm({
|
|
3397
3441
|
"packages/runtime/src/storage/signature.ts"() {
|
|
3398
3442
|
"use strict";
|
|
3399
3443
|
init_hmac_sha256();
|
|
3444
|
+
init_driver();
|
|
3400
3445
|
DEFAULT_SIGN_TTL_SECONDS = 15 * 60;
|
|
3446
|
+
MAX_SIGNED_URL_TTL_SECONDS = 7 * 24 * 60 * 60;
|
|
3401
3447
|
SIGN_EXPIRES_KEY = "x-expires";
|
|
3402
3448
|
SIGN_SIGNATURE_KEY = "x-signature";
|
|
3403
3449
|
}
|
|
@@ -3448,9 +3494,10 @@ function createStorageCapability(driver, signer, projectId) {
|
|
|
3448
3494
|
switch (method) {
|
|
3449
3495
|
case "upload": {
|
|
3450
3496
|
const [path, data, options] = args;
|
|
3497
|
+
const visibility = assertFileVisibility(options?.visibility ?? DEFAULT_VISIBILITY);
|
|
3451
3498
|
return toStoredFile(
|
|
3452
3499
|
await driver.put(projectId, path, asBytes(data), {
|
|
3453
|
-
visibility
|
|
3500
|
+
visibility,
|
|
3454
3501
|
...options?.contentType === void 0 ? {} : { contentType: options.contentType }
|
|
3455
3502
|
})
|
|
3456
3503
|
);
|
|
@@ -3468,9 +3515,26 @@ function createStorageCapability(driver, signer, projectId) {
|
|
|
3468
3515
|
const [prefix] = args;
|
|
3469
3516
|
return (await driver.list(projectId, prefix)).map(toStoredFile);
|
|
3470
3517
|
}
|
|
3518
|
+
case "getUrl": {
|
|
3519
|
+
const [path] = args;
|
|
3520
|
+
const meta3 = await driver.getMeta(projectId, path);
|
|
3521
|
+
if (meta3.visibility === "public") {
|
|
3522
|
+
const result2 = {
|
|
3523
|
+
url: publicDownloadUrl(signer, projectId, path),
|
|
3524
|
+
expiresAt: null
|
|
3525
|
+
};
|
|
3526
|
+
return result2;
|
|
3527
|
+
}
|
|
3528
|
+
const signed = signDownloadUrlWithExpiry(signer, projectId, path);
|
|
3529
|
+
const result = {
|
|
3530
|
+
url: signed.url,
|
|
3531
|
+
expiresAt: new Date(signed.expires * 1e3).toISOString()
|
|
3532
|
+
};
|
|
3533
|
+
return result;
|
|
3534
|
+
}
|
|
3471
3535
|
case "getSignedUrl": {
|
|
3472
|
-
const [path, ttlSeconds] = args;
|
|
3473
|
-
return signDownloadUrl(signer, projectId, path, ttlSeconds);
|
|
3536
|
+
const [path, ttlSeconds, options] = args;
|
|
3537
|
+
return signDownloadUrl(signer, projectId, path, ttlSeconds, options);
|
|
3474
3538
|
}
|
|
3475
3539
|
default:
|
|
3476
3540
|
throw new StorageError(
|
|
@@ -4011,6 +4075,53 @@ function unquoteIdent(raw) {
|
|
|
4011
4075
|
}
|
|
4012
4076
|
return text;
|
|
4013
4077
|
}
|
|
4078
|
+
function parsePlainIdent(raw) {
|
|
4079
|
+
const text = raw.trim();
|
|
4080
|
+
if (text.length === 0) return null;
|
|
4081
|
+
const first = text[0];
|
|
4082
|
+
if (first === '"' || first === "`" || first === "[" || first === "'") {
|
|
4083
|
+
const unquoted = unquoteIdent(text);
|
|
4084
|
+
return unquoted === text.trim() ? null : unquoted;
|
|
4085
|
+
}
|
|
4086
|
+
return /^[A-Za-z_][A-Za-z0-9_$]*$/.test(text) ? text : null;
|
|
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
|
+
}
|
|
4014
4125
|
function splitTopLevel2(body) {
|
|
4015
4126
|
const parts = [];
|
|
4016
4127
|
let depth = 0;
|
|
@@ -4089,19 +4200,47 @@ function parseColumn(part) {
|
|
|
4089
4200
|
}
|
|
4090
4201
|
const type = rest.slice(0, typeEnd).trim();
|
|
4091
4202
|
rest = rest.slice(typeEnd).trim();
|
|
4092
|
-
const notNull = /\bNOT\s+NULL\b/i.test(rest);
|
|
4093
|
-
const primaryKey = /\bPRIMARY\s+KEY\b/i.test(rest);
|
|
4094
4203
|
const defaultMatch = /\bDEFAULT\s+(.+?)(?=\s+(?:NOT|PRIMARY|UNIQUE|CHECK|REFERENCES|COLLATE|GENERATED|AS|AUTOINCREMENT|CONSTRAINT)\b|$)/i.exec(
|
|
4095
4204
|
rest
|
|
4096
4205
|
);
|
|
4206
|
+
const constraintText = defaultMatch === null ? rest : rest.replace(defaultMatch[0], " ");
|
|
4207
|
+
const declarationText = stripNonNullabilityClauses(constraintText);
|
|
4208
|
+
const notNull = /\bNOT\s+NULL\b/i.test(declarationText);
|
|
4209
|
+
const explicitNullable = !notNull && /\bNULL\b/i.test(declarationText);
|
|
4210
|
+
const primaryKey = /\bPRIMARY\s+KEY\b/i.test(declarationText);
|
|
4211
|
+
const unique = /\bUNIQUE\b/i.test(declarationText);
|
|
4097
4212
|
return {
|
|
4098
4213
|
name,
|
|
4099
4214
|
type,
|
|
4100
4215
|
notNull,
|
|
4216
|
+
explicitNullable,
|
|
4101
4217
|
primaryKey,
|
|
4218
|
+
unique,
|
|
4102
4219
|
defaultValue: defaultMatch === null ? null : defaultMatch[1].trim()
|
|
4103
4220
|
};
|
|
4104
4221
|
}
|
|
4222
|
+
function stripNonNullabilityClauses(text) {
|
|
4223
|
+
return text.replace(
|
|
4224
|
+
/\bREFERENCES\s+\S+(?:\s*\([^)]*\))?(?:\s+ON\s+(?:DELETE|UPDATE)\s+(?:CASCADE|RESTRICT|SET\s+NULL|SET\s+DEFAULT|NO\s+ACTION))*/gi,
|
|
4225
|
+
" "
|
|
4226
|
+
).replace(/\bCHECK\s*\([^)]*\)/gi, " ").replace(/\bGENERATED\s+ALWAYS\s+AS\s*\([^)]*\)(?:\s+STORED|\s+VIRTUAL)?/gi, " ");
|
|
4227
|
+
}
|
|
4228
|
+
function parseTableUnique(part) {
|
|
4229
|
+
const trimmed = part.trim();
|
|
4230
|
+
const match = /^(?:CONSTRAINT\s+(?:"(?:[^"]|"")*"|`(?:[^`]|``)*`|\[[^\]]*\]|[A-Za-z_][A-Za-z0-9_$]*)\s+)?UNIQUE\s*\(/i.exec(
|
|
4231
|
+
trimmed
|
|
4232
|
+
);
|
|
4233
|
+
if (match === null) return null;
|
|
4234
|
+
const body = findTableBody(trimmed, match[0].lastIndexOf("("));
|
|
4235
|
+
if (body === null) return null;
|
|
4236
|
+
const columns = [];
|
|
4237
|
+
for (const entry of splitTopLevel2(body)) {
|
|
4238
|
+
const column = parsePlainIdent(entry);
|
|
4239
|
+
if (column === null) return null;
|
|
4240
|
+
columns.push(column);
|
|
4241
|
+
}
|
|
4242
|
+
return columns.length === 0 ? null : columns;
|
|
4243
|
+
}
|
|
4105
4244
|
function parseSchemaTables(sql) {
|
|
4106
4245
|
const tables = [];
|
|
4107
4246
|
const pattern = /CREATE\s+(?:TEMP|TEMPORARY\s+)?TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?("(?:[^"]|"")*"|`(?:[^`]|``)*`|\[[^\]]*\]|'[^']*'|[A-Za-z_][A-Za-z0-9_$.]*)\s*\(/gi;
|
|
@@ -4115,11 +4254,14 @@ function parseSchemaTables(sql) {
|
|
|
4115
4254
|
const rawName = match[1];
|
|
4116
4255
|
const name = unquoteIdent(rawName.split(".").pop() ?? rawName);
|
|
4117
4256
|
const columns = [];
|
|
4257
|
+
const uniqueConstraints = [];
|
|
4118
4258
|
for (const part of splitTopLevel2(body)) {
|
|
4259
|
+
const unique = parseTableUnique(part);
|
|
4260
|
+
if (unique !== null) uniqueConstraints.push(unique);
|
|
4119
4261
|
const column = parseColumn(part);
|
|
4120
4262
|
if (column !== null) columns.push(column);
|
|
4121
4263
|
}
|
|
4122
|
-
tables.push({ name, columns, statement: statement.trim() });
|
|
4264
|
+
tables.push({ name, columns, uniqueConstraints, statement: statement.trim() });
|
|
4123
4265
|
}
|
|
4124
4266
|
return tables;
|
|
4125
4267
|
}
|
|
@@ -4412,7 +4554,28 @@ async function dbExecBatch(paths, options) {
|
|
|
4412
4554
|
"SQL_EXEC_FAILED"
|
|
4413
4555
|
);
|
|
4414
4556
|
}
|
|
4557
|
+
function assertProductionMigrateConfirm(project2, files, confirmDb) {
|
|
4558
|
+
const fileArgs = files.join(" ");
|
|
4559
|
+
const runExample = `adep db migrate ${fileArgs} --confirm-db ${project2}`;
|
|
4560
|
+
if (confirmDb === void 0 || confirmDb.trim() === "") {
|
|
4561
|
+
throw new CliError(
|
|
4562
|
+
"MIGRATE_CONFIRM_REQUIRED",
|
|
4563
|
+
`\u751F\u4EA7\u5E93\u8FC1\u79FB\u9700\u8981\u4E8C\u6B21\u786E\u8BA4\uFF1A\u547D\u4EE4\u4F1A\u4F5C\u7528\u5230\u9879\u76EE\u300C${project2}\u300D\u7684\u751F\u4EA7\u5E93\u3002\u5148\u770B\u8BA1\u5212\uFF1Aadep db migrate ${fileArgs} --plan\uFF1B\u786E\u8BA4\u540E\u6267\u884C\uFF1A${runExample}`
|
|
4564
|
+
);
|
|
4565
|
+
}
|
|
4566
|
+
if (confirmDb.trim() !== project2) {
|
|
4567
|
+
throw new CliError(
|
|
4568
|
+
"MIGRATE_CONFIRM_MISMATCH",
|
|
4569
|
+
`--confirm-db \u7684\u503C\u300C${confirmDb}\u300D\u4E0E\u76EE\u6807\u9879\u76EE slug\u300C${project2}\u300D\u4E0D\u4E00\u81F4\u3002\u786E\u8BA4\u503C\u5FC5\u987B\u4E0E\u76EE\u6807\u9879\u76EE slug \u5B8C\u5168\u4E00\u81F4\uFF08\u533A\u5206\u5927\u5C0F\u5199\uFF09\uFF1A${runExample}`
|
|
4570
|
+
);
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4415
4573
|
async function dbMigrate(paths, options) {
|
|
4574
|
+
const environment = options.environment ?? "prod";
|
|
4575
|
+
const project2 = await resolveSlug(resolve3(options.cwd), options.slug);
|
|
4576
|
+
if (options.plan !== true && environment === "prod") {
|
|
4577
|
+
assertProductionMigrateConfirm(project2, options.files, options.confirmDb);
|
|
4578
|
+
}
|
|
4416
4579
|
const queue = [];
|
|
4417
4580
|
for (const file2 of options.files) {
|
|
4418
4581
|
const source = await readFile4(resolve3(file2), "utf8");
|
|
@@ -4422,7 +4585,7 @@ async function dbMigrate(paths, options) {
|
|
|
4422
4585
|
}
|
|
4423
4586
|
queue.push({ file: file2, sql: source });
|
|
4424
4587
|
}
|
|
4425
|
-
|
|
4588
|
+
await open2(paths, { cwd: options.cwd, slug: project2 });
|
|
4426
4589
|
const applied = [];
|
|
4427
4590
|
const changes = [];
|
|
4428
4591
|
let createdTables = 0;
|
|
@@ -4440,10 +4603,15 @@ async function dbMigrate(paths, options) {
|
|
|
4440
4603
|
missingTables: [...drift.missingTables, ...next.missingTables],
|
|
4441
4604
|
missingColumns: [...drift.missingColumns, ...next.missingColumns],
|
|
4442
4605
|
typeMismatches: [...drift.typeMismatches, ...next.typeMismatches],
|
|
4606
|
+
// 兼容旧服务端响应(缺字段按空处理):CLI 与平台版本允许滚动差。
|
|
4607
|
+
missingIndexes: [...drift.missingIndexes ?? [], ...next.missingIndexes ?? []],
|
|
4608
|
+
uniqueDiff: [...drift.uniqueDiff ?? [], ...next.uniqueDiff ?? []],
|
|
4609
|
+
defaultDiff: [...drift.defaultDiff ?? [], ...next.defaultDiff ?? []],
|
|
4610
|
+
nullabilityDiff: [...drift.nullabilityDiff ?? [], ...next.nullabilityDiff ?? []],
|
|
4611
|
+
blocking: drift.blocking === void 0 && next.blocking === void 0 ? void 0 : (drift.blocking ?? false) || (next.blocking ?? false),
|
|
4443
4612
|
extraTables: [.../* @__PURE__ */ new Set([...drift.extraTables, ...next.extraTables])],
|
|
4444
4613
|
extraColumns: [...drift.extraColumns, ...next.extraColumns],
|
|
4445
4614
|
destructiveStatements: [...drift.destructiveStatements, ...next.destructiveStatements],
|
|
4446
|
-
// 兼容旧服务端响应(缺字段按空处理):CLI 与平台版本允许滚动差。
|
|
4447
4615
|
dataStatements: [...drift.dataStatements ?? [], ...next.dataStatements ?? []],
|
|
4448
4616
|
applicable: drift.applicable && next.applicable
|
|
4449
4617
|
};
|
|
@@ -4454,8 +4622,8 @@ async function dbMigrate(paths, options) {
|
|
|
4454
4622
|
const next = await dbSchemaDiff(paths, {
|
|
4455
4623
|
cwd: options.cwd,
|
|
4456
4624
|
sql,
|
|
4457
|
-
|
|
4458
|
-
|
|
4625
|
+
slug: project2,
|
|
4626
|
+
environment
|
|
4459
4627
|
});
|
|
4460
4628
|
mergeDrift(next);
|
|
4461
4629
|
} catch (error62) {
|
|
@@ -4482,12 +4650,21 @@ async function dbMigrate(paths, options) {
|
|
|
4482
4650
|
}
|
|
4483
4651
|
for (const { file: file2, sql } of queue) {
|
|
4484
4652
|
try {
|
|
4653
|
+
if (environment === "prod" && options.onPlan !== void 0) {
|
|
4654
|
+
const planned = await dbSchemaDiff(paths, {
|
|
4655
|
+
cwd: options.cwd,
|
|
4656
|
+
sql,
|
|
4657
|
+
slug: project2,
|
|
4658
|
+
environment
|
|
4659
|
+
});
|
|
4660
|
+
options.onPlan(planned, file2);
|
|
4661
|
+
}
|
|
4485
4662
|
const result = await dbSchemaMigrate(paths, {
|
|
4486
4663
|
cwd: options.cwd,
|
|
4487
4664
|
sql,
|
|
4488
|
-
|
|
4665
|
+
slug: project2,
|
|
4489
4666
|
// 环境必须一路透传:漏掉这一步,`--env dev` 的迁移会落到生产库。
|
|
4490
|
-
|
|
4667
|
+
environment
|
|
4491
4668
|
});
|
|
4492
4669
|
applied.push(...result.applied);
|
|
4493
4670
|
changes.push(...result.applied.map(() => 0));
|
|
@@ -4757,6 +4934,22 @@ async function applyLocalSchema(driver, options) {
|
|
|
4757
4934
|
let applied = 0;
|
|
4758
4935
|
let skipped = 0;
|
|
4759
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
|
+
}
|
|
4760
4953
|
try {
|
|
4761
4954
|
await driver.run(statement);
|
|
4762
4955
|
applied += 1;
|
|
@@ -4940,6 +5133,21 @@ function buildExhaustedMessage(input2) {
|
|
|
4940
5133
|
"\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"
|
|
4941
5134
|
].join("\n");
|
|
4942
5135
|
}
|
|
5136
|
+
function isAddrInUseCode(error62) {
|
|
5137
|
+
return error62?.code === "EADDRINUSE";
|
|
5138
|
+
}
|
|
5139
|
+
function formatFallbackNotice(info) {
|
|
5140
|
+
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`;
|
|
5141
|
+
}
|
|
5142
|
+
function buildFallbackExhaustedMessage(input2) {
|
|
5143
|
+
const first = input2.requested + 1;
|
|
5144
|
+
const last = input2.requested + input2.span;
|
|
5145
|
+
return [
|
|
5146
|
+
`[adep] \u7AEF\u53E3 ${input2.requested} \u5DF2\u88AB\u5360\u7528\uFF0C\u5176\u540E ${input2.span} \u4E2A\u5019\u9009\u7AEF\u53E3\uFF08${first}~${last}\uFF09\u4E5F\u4E0D\u53EF\u7528\uFF0C\u5DF2\u653E\u5F03\u542F\u52A8\u3002`,
|
|
5147
|
+
"\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",
|
|
5148
|
+
`\u5360\u7528\u8005\u6392\u67E5\uFF1Alsof -nP -iTCP:${input2.requested} -sTCP:LISTEN\uFF08Windows\uFF1Anetstat -ano | findstr :${input2.requested}\uFF09`
|
|
5149
|
+
].join("\n");
|
|
5150
|
+
}
|
|
4943
5151
|
async function listenOnFetchSafePort(server, options) {
|
|
4944
5152
|
const isBlocked = options.isBlocked ?? isFetchBlockedPort;
|
|
4945
5153
|
const warn = options.warn ?? (() => {
|
|
@@ -4950,12 +5158,46 @@ async function listenOnFetchSafePort(server, options) {
|
|
|
4950
5158
|
} catch {
|
|
4951
5159
|
}
|
|
4952
5160
|
};
|
|
4953
|
-
|
|
5161
|
+
const requestedPort = options.port;
|
|
5162
|
+
if (requestedPort !== 0) {
|
|
4954
5163
|
try {
|
|
4955
|
-
await listenOnce(server,
|
|
5164
|
+
await listenOnce(server, requestedPort, options.host);
|
|
4956
5165
|
} catch (error62) {
|
|
4957
|
-
|
|
4958
|
-
|
|
5166
|
+
const fallback = options.fallbackOnInUse;
|
|
5167
|
+
if (fallback === void 0 || !isAddrInUseCode(error62)) {
|
|
5168
|
+
await notifyListenError(error62);
|
|
5169
|
+
throw error62;
|
|
5170
|
+
}
|
|
5171
|
+
const span = fallback.span ?? DEFAULT_PORT_FALLBACK_SPAN;
|
|
5172
|
+
if (!Number.isInteger(span) || span < 1) {
|
|
5173
|
+
await notifyListenError(error62);
|
|
5174
|
+
throw new Error(`[adep] fallbackOnInUse.span \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF08\u6536\u5230 ${String(span)}\uFF09\u3002`, {
|
|
5175
|
+
cause: error62
|
|
5176
|
+
});
|
|
5177
|
+
}
|
|
5178
|
+
let lastError = error62;
|
|
5179
|
+
for (let offset = 1; offset <= span; offset += 1) {
|
|
5180
|
+
const candidate = requestedPort + offset;
|
|
5181
|
+
if (candidate > 65535) break;
|
|
5182
|
+
if (isBlocked(candidate)) continue;
|
|
5183
|
+
try {
|
|
5184
|
+
await listenOnce(server, candidate, options.host);
|
|
5185
|
+
} catch (candidateError) {
|
|
5186
|
+
if (isAddrInUseCode(candidateError)) {
|
|
5187
|
+
lastError = candidateError;
|
|
5188
|
+
continue;
|
|
5189
|
+
}
|
|
5190
|
+
await notifyListenError(candidateError);
|
|
5191
|
+
throw candidateError;
|
|
5192
|
+
}
|
|
5193
|
+
const report = options.onFallback ?? ((info) => warn(formatFallbackNotice(info)));
|
|
5194
|
+
report({ requested: requestedPort, actual: candidate });
|
|
5195
|
+
return candidate;
|
|
5196
|
+
}
|
|
5197
|
+
await notifyListenError(lastError);
|
|
5198
|
+
throw new PortFallbackExhaustedError(
|
|
5199
|
+
buildFallbackExhaustedMessage({ requested: requestedPort, span })
|
|
5200
|
+
);
|
|
4959
5201
|
}
|
|
4960
5202
|
const actual = readTcpPort(server, options.host);
|
|
4961
5203
|
if (isBlocked(actual)) {
|
|
@@ -4987,12 +5229,89 @@ async function listenOnFetchSafePort(server, options) {
|
|
|
4987
5229
|
}
|
|
4988
5230
|
throw new Error(buildExhaustedMessage({ host: options.host, hits, maxAttempts }));
|
|
4989
5231
|
}
|
|
4990
|
-
var MAX_FETCH_SAFE_LISTEN_ATTEMPTS;
|
|
5232
|
+
var MAX_FETCH_SAFE_LISTEN_ATTEMPTS, DEFAULT_PORT_FALLBACK_SPAN, PortFallbackExhaustedError;
|
|
4991
5233
|
var init_fetch_safe_port = __esm({
|
|
4992
5234
|
"packages/cli/src/serve/fetch-safe-port.ts"() {
|
|
4993
5235
|
"use strict";
|
|
4994
5236
|
init_fetch_blocked_ports();
|
|
4995
5237
|
MAX_FETCH_SAFE_LISTEN_ATTEMPTS = 8;
|
|
5238
|
+
DEFAULT_PORT_FALLBACK_SPAN = 12;
|
|
5239
|
+
PortFallbackExhaustedError = class extends Error {
|
|
5240
|
+
constructor(message) {
|
|
5241
|
+
super(message);
|
|
5242
|
+
this.name = "PortFallbackExhaustedError";
|
|
5243
|
+
}
|
|
5244
|
+
};
|
|
5245
|
+
}
|
|
5246
|
+
});
|
|
5247
|
+
|
|
5248
|
+
// packages/cli/src/serve/port-in-use.ts
|
|
5249
|
+
import { execFile } from "node:child_process";
|
|
5250
|
+
function parsePortOccupier(stdout) {
|
|
5251
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
5252
|
+
const trimmed = line.trim();
|
|
5253
|
+
if (trimmed.length === 0 || trimmed.startsWith("COMMAND")) continue;
|
|
5254
|
+
const [command, pid] = trimmed.split(/\s+/);
|
|
5255
|
+
if (command === void 0 || pid === void 0 || !/^\d+$/u.test(pid)) return null;
|
|
5256
|
+
return `${command} ${pid}`;
|
|
5257
|
+
}
|
|
5258
|
+
return null;
|
|
5259
|
+
}
|
|
5260
|
+
function runLsof(port) {
|
|
5261
|
+
return new Promise((resolve22, reject) => {
|
|
5262
|
+
execFile(
|
|
5263
|
+
"lsof",
|
|
5264
|
+
["-nP", `-iTCP:${port}`, "-sTCP:LISTEN"],
|
|
5265
|
+
{ timeout: 2e3, windowsHide: true },
|
|
5266
|
+
(error62, stdout) => {
|
|
5267
|
+
if (error62 !== null) {
|
|
5268
|
+
reject(error62);
|
|
5269
|
+
return;
|
|
5270
|
+
}
|
|
5271
|
+
resolve22(stdout);
|
|
5272
|
+
}
|
|
5273
|
+
);
|
|
5274
|
+
});
|
|
5275
|
+
}
|
|
5276
|
+
async function lookupPortOccupier(port, options = {}) {
|
|
5277
|
+
if (process.platform === "win32") return null;
|
|
5278
|
+
const execute = options.execute ?? runLsof;
|
|
5279
|
+
try {
|
|
5280
|
+
return parsePortOccupier(await execute(port));
|
|
5281
|
+
} catch {
|
|
5282
|
+
return null;
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
async function describePortInUse(options) {
|
|
5286
|
+
const occupier = await (options.lookup ?? lookupPortOccupier)(options.port);
|
|
5287
|
+
const nextPort = options.port < 65535 ? options.port + 1 : options.port - 1;
|
|
5288
|
+
const command = `adep ${options.scope}`;
|
|
5289
|
+
return [
|
|
5290
|
+
`[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`,
|
|
5291
|
+
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`,
|
|
5292
|
+
`\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`
|
|
5293
|
+
].join("\n");
|
|
5294
|
+
}
|
|
5295
|
+
function isAddrInUse(error62) {
|
|
5296
|
+
return error62?.code === "EADDRINUSE";
|
|
5297
|
+
}
|
|
5298
|
+
async function toPortCliError(error62, context) {
|
|
5299
|
+
if (isAddrInUse(error62)) {
|
|
5300
|
+
return new CliError(
|
|
5301
|
+
"PORT_IN_USE",
|
|
5302
|
+
await describePortInUse({ port: context.port, scope: context.scope })
|
|
5303
|
+
);
|
|
5304
|
+
}
|
|
5305
|
+
if (error62 instanceof PortFallbackExhaustedError) {
|
|
5306
|
+
return new CliError("PORT_FALLBACK_EXHAUSTED", error62.message);
|
|
5307
|
+
}
|
|
5308
|
+
return null;
|
|
5309
|
+
}
|
|
5310
|
+
var init_port_in_use = __esm({
|
|
5311
|
+
"packages/cli/src/serve/port-in-use.ts"() {
|
|
5312
|
+
"use strict";
|
|
5313
|
+
init_auth();
|
|
5314
|
+
init_fetch_safe_port();
|
|
4996
5315
|
}
|
|
4997
5316
|
});
|
|
4998
5317
|
|
|
@@ -5958,12 +6277,23 @@ function errorLineIn(stack, path) {
|
|
|
5958
6277
|
if (own2 !== null) return own2[1];
|
|
5959
6278
|
return /(?:^|\n):(\d+)(?:\n|$)/.exec(stack)?.[1];
|
|
5960
6279
|
}
|
|
5961
|
-
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) {
|
|
5962
6290
|
const rawMessage = error62 instanceof Error ? error62.message : String(error62);
|
|
5963
6291
|
const stack = error62.stack;
|
|
5964
6292
|
const line = typeof stack === "string" ? errorLineIn(stack, path) : void 0;
|
|
5965
6293
|
const location = line === void 0 ? path : `${path}:${line}`;
|
|
5966
|
-
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 });
|
|
5967
6297
|
const code = error62.code;
|
|
5968
6298
|
if (typeof code === "string") wrapped.code = code;
|
|
5969
6299
|
return wrapped;
|
|
@@ -6008,7 +6338,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
6008
6338
|
try {
|
|
6009
6339
|
transformed = transformExports(transpile(source));
|
|
6010
6340
|
} catch (error62) {
|
|
6011
|
-
throw syntaxErrorWithLocation(error62, path);
|
|
6341
|
+
throw syntaxErrorWithLocation(error62, path, source);
|
|
6012
6342
|
}
|
|
6013
6343
|
const context = createSandboxContext(sandboxGlobals);
|
|
6014
6344
|
let wrapper;
|
|
@@ -6020,7 +6350,7 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache,
|
|
|
6020
6350
|
{ filename: path }
|
|
6021
6351
|
);
|
|
6022
6352
|
} catch (error62) {
|
|
6023
|
-
throw syntaxErrorWithLocation(error62, path);
|
|
6353
|
+
throw syntaxErrorWithLocation(error62, path, source);
|
|
6024
6354
|
}
|
|
6025
6355
|
wrapper(module, exports, require2);
|
|
6026
6356
|
if (module.default !== void 0 && exports["default"] === void 0) {
|
|
@@ -6046,7 +6376,7 @@ function loadFunctionModule(files, entry, sandboxGlobals, resolveBare, strictPat
|
|
|
6046
6376
|
}
|
|
6047
6377
|
return { handler };
|
|
6048
6378
|
}
|
|
6049
|
-
var bunTranspiler, SANDBOX_BUILTIN_REJECTED, REALM_VALUE_KEY;
|
|
6379
|
+
var bunTranspiler, SANDBOX_BUILTIN_REJECTED, REALM_VALUE_KEY, DYNAMIC_IMPORT_HINT;
|
|
6050
6380
|
var init_sandbox = __esm({
|
|
6051
6381
|
"packages/runtime/src/functions/runtime/sandbox.ts"() {
|
|
6052
6382
|
"use strict";
|
|
@@ -6054,6 +6384,7 @@ var init_sandbox = __esm({
|
|
|
6054
6384
|
init_regexp();
|
|
6055
6385
|
SANDBOX_BUILTIN_REJECTED = "FN_SANDBOX_BUILTIN_BLOCKED";
|
|
6056
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";
|
|
6057
6388
|
}
|
|
6058
6389
|
});
|
|
6059
6390
|
|
|
@@ -6739,10 +7070,10 @@ function firstUserFrame(stack, files) {
|
|
|
6739
7070
|
function errorMessageWithLocation(error62, files) {
|
|
6740
7071
|
const message = errorMessageOf2(error62);
|
|
6741
7072
|
const stack = error62.stack;
|
|
6742
|
-
|
|
6743
|
-
const
|
|
6744
|
-
|
|
6745
|
-
|
|
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;
|
|
6746
7077
|
}
|
|
6747
7078
|
function createBareResolver(deps) {
|
|
6748
7079
|
const platformRequire = createRequire(import.meta.url);
|
|
@@ -7097,6 +7428,49 @@ function createBearerUserResolver(issuer) {
|
|
|
7097
7428
|
}
|
|
7098
7429
|
};
|
|
7099
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
|
+
}
|
|
7100
7474
|
function isRuntimeSource(name) {
|
|
7101
7475
|
return (name.endsWith(".ts") || name.endsWith(".js")) && !name.endsWith(".d.ts") && !name.endsWith(".test.ts");
|
|
7102
7476
|
}
|
|
@@ -7200,7 +7574,7 @@ async function requestInput(url2, req, readBody) {
|
|
|
7200
7574
|
...parsed?.files === void 0 ? {} : { files: parsed.files }
|
|
7201
7575
|
};
|
|
7202
7576
|
}
|
|
7203
|
-
var BEARER_TOKEN_RE, ISSUER_PATH_SUFFIX;
|
|
7577
|
+
var BEARER_TOKEN_RE, ISSUER_PATH_SUFFIX, SIM_USER_ENV_KEY;
|
|
7204
7578
|
var init_dev_shared = __esm({
|
|
7205
7579
|
"packages/cli/src/dev-shared.ts"() {
|
|
7206
7580
|
"use strict";
|
|
@@ -7211,6 +7585,7 @@ var init_dev_shared = __esm({
|
|
|
7211
7585
|
init_invoke();
|
|
7212
7586
|
BEARER_TOKEN_RE = /^Bearer\s+(.+)$/i;
|
|
7213
7587
|
ISSUER_PATH_SUFFIX = "/api";
|
|
7588
|
+
SIM_USER_ENV_KEY = "ADEP_SIM_USER";
|
|
7214
7589
|
}
|
|
7215
7590
|
});
|
|
7216
7591
|
|
|
@@ -7292,7 +7667,9 @@ async function startDevServer(options) {
|
|
|
7292
7667
|
...options.dbFile === void 0 ? {} : { dbFile: options.dbFile }
|
|
7293
7668
|
});
|
|
7294
7669
|
const simEnv = await loadSimEnv(cwd).catch(() => ({}));
|
|
7295
|
-
let
|
|
7670
|
+
let simUser = simUserResolverFromEnv(simEnv);
|
|
7671
|
+
if (simUser.warning !== void 0) log(`[adep] ${simUser.warning}`);
|
|
7672
|
+
let bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(simEnv);
|
|
7296
7673
|
const fetchConfig = resolveLocalFetchConfig(simEnv);
|
|
7297
7674
|
const executor = new WorkerFunctionExecutor({
|
|
7298
7675
|
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS },
|
|
@@ -7406,7 +7783,10 @@ async function startDevServer(options) {
|
|
|
7406
7783
|
]);
|
|
7407
7784
|
files = nextFiles;
|
|
7408
7785
|
env = { ...config2.environment, ...parseEnvFile(envText2) };
|
|
7409
|
-
|
|
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);
|
|
7410
7790
|
};
|
|
7411
7791
|
const envText = await readFile9(join13(cwd, ".env.local"), "utf8").catch(() => "");
|
|
7412
7792
|
env = { ...config2.environment, ...parseEnvFile(envText) };
|
|
@@ -7550,13 +7930,22 @@ async function startDevServer(options) {
|
|
|
7550
7930
|
} catch {
|
|
7551
7931
|
}
|
|
7552
7932
|
};
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7933
|
+
let actualPort;
|
|
7934
|
+
try {
|
|
7935
|
+
actualPort = await listenOnFetchSafePort(server, {
|
|
7936
|
+
port,
|
|
7937
|
+
host: "127.0.0.1",
|
|
7938
|
+
warn: log,
|
|
7939
|
+
...options.port === void 0 ? { fallbackOnInUse: {} } : {},
|
|
7940
|
+
onListenError: disposeAfterListenError
|
|
7941
|
+
});
|
|
7942
|
+
} catch (error62) {
|
|
7943
|
+
const portError = await toPortCliError(error62, { port, scope: "dev" });
|
|
7944
|
+
if (portError !== null) throw portError;
|
|
7945
|
+
throw error62;
|
|
7946
|
+
}
|
|
7559
7947
|
const baseUrl = `http://127.0.0.1:${actualPort}`;
|
|
7948
|
+
runtime.storage.signer.baseUrl = baseUrl;
|
|
7560
7949
|
const coldStartMs = Date.now() - coldStartAt;
|
|
7561
7950
|
const curlPath = config2.functionsPrefix.length === 0 ? "/hello" : `/${config2.functionsPrefix}/hello`;
|
|
7562
7951
|
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";
|
|
@@ -7566,7 +7955,11 @@ async function startDevServer(options) {
|
|
|
7566
7955
|
);
|
|
7567
7956
|
log(`[adep] curl \u793A\u4F8B\uFF1Acurl ${baseUrl}${curlPath}`);
|
|
7568
7957
|
printBoundaries(log);
|
|
7569
|
-
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) {
|
|
7570
7963
|
log(
|
|
7571
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`
|
|
7572
7965
|
);
|
|
@@ -7596,6 +7989,7 @@ var init_dev = __esm({
|
|
|
7596
7989
|
init_runtime();
|
|
7597
7990
|
init_db_mode();
|
|
7598
7991
|
init_fetch_safe_port();
|
|
7992
|
+
init_port_in_use();
|
|
7599
7993
|
init_env();
|
|
7600
7994
|
init_fetch_config();
|
|
7601
7995
|
init_invoke();
|
|
@@ -8472,6 +8866,7 @@ async function startServeServer(options) {
|
|
|
8472
8866
|
`));
|
|
8473
8867
|
const host = options.host ?? envString("HOST") ?? "127.0.0.1";
|
|
8474
8868
|
const port = resolveServePort(options.port);
|
|
8869
|
+
const portFromBuiltinDefault = options.port === void 0 && envNumber("PORT") === void 0;
|
|
8475
8870
|
const publicUrl = resolvePublicUrl(
|
|
8476
8871
|
options.publicUrl !== void 0 ? options.publicUrl : envString("ADEP_PUBLIC_URL")
|
|
8477
8872
|
);
|
|
@@ -8499,7 +8894,9 @@ async function startServeServer(options) {
|
|
|
8499
8894
|
let env = parseEnvFile(envText);
|
|
8500
8895
|
let envViews = await loadSimEnvViews(cwd);
|
|
8501
8896
|
let simEnv = envViews.merged;
|
|
8502
|
-
let
|
|
8897
|
+
let simUser = simUserResolverFromEnv(simEnv);
|
|
8898
|
+
if (simUser.warning !== void 0) log(`[serve] ${simUser.warning}`);
|
|
8899
|
+
let bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(simEnv);
|
|
8503
8900
|
const dotenvFile = await readDotenvFile(cwd, ".env");
|
|
8504
8901
|
let templateEnv;
|
|
8505
8902
|
try {
|
|
@@ -8573,7 +8970,9 @@ async function startServeServer(options) {
|
|
|
8573
8970
|
env = parseEnvFile(envLocalText);
|
|
8574
8971
|
envViews = await loadSimEnvViews(cwd);
|
|
8575
8972
|
simEnv = envViews.merged;
|
|
8576
|
-
|
|
8973
|
+
simUser = simUserResolverFromEnv(simEnv);
|
|
8974
|
+
if (simUser.warning !== void 0) log(`[serve] ${simUser.warning}`);
|
|
8975
|
+
bearerUser = simUser.resolver ?? bearerUserResolverFromEnv(simEnv);
|
|
8577
8976
|
invokeHandler = createSimInvokeHandler({ executor, files });
|
|
8578
8977
|
functionNames = listFunctionNames(files);
|
|
8579
8978
|
log(`[serve] \u70ED\u91CD\u8F7D\uFF1A\u68C0\u6D4B\u5230\u53D8\u66F4\uFF0C\u5DF2\u91CD\u65B0\u52A0\u8F7D ${functionNames.length} \u4E2A\u51FD\u6570`);
|
|
@@ -8829,7 +9228,31 @@ async function startServeServer(options) {
|
|
|
8829
9228
|
}
|
|
8830
9229
|
});
|
|
8831
9230
|
});
|
|
8832
|
-
const
|
|
9231
|
+
const disposeAfterListenError = async () => {
|
|
9232
|
+
stopWatch?.();
|
|
9233
|
+
try {
|
|
9234
|
+
await executor.dispose();
|
|
9235
|
+
} catch {
|
|
9236
|
+
}
|
|
9237
|
+
try {
|
|
9238
|
+
await runtime.dispose();
|
|
9239
|
+
} catch {
|
|
9240
|
+
}
|
|
9241
|
+
};
|
|
9242
|
+
let actualPort;
|
|
9243
|
+
try {
|
|
9244
|
+
actualPort = await listenOnFetchSafePort(server, {
|
|
9245
|
+
port,
|
|
9246
|
+
host,
|
|
9247
|
+
warn: log,
|
|
9248
|
+
...portFromBuiltinDefault ? { fallbackOnInUse: {} } : {},
|
|
9249
|
+
onListenError: disposeAfterListenError
|
|
9250
|
+
});
|
|
9251
|
+
} catch (error62) {
|
|
9252
|
+
const portError = await toPortCliError(error62, { port, scope: "serve" });
|
|
9253
|
+
if (portError !== null) throw portError;
|
|
9254
|
+
throw error62;
|
|
9255
|
+
}
|
|
8833
9256
|
runtime.storage.signer.baseUrl = publicUrl ?? `http://${host}:${actualPort}`;
|
|
8834
9257
|
const drift = schemaReport?.drift ?? null;
|
|
8835
9258
|
const schemaDrift = drift === null || drift.missing.length === 0 ? void 0 : drift.missing.map((plan) => {
|
|
@@ -8864,7 +9287,9 @@ async function startServeServer(options) {
|
|
|
8864
9287
|
});
|
|
8865
9288
|
log(banner);
|
|
8866
9289
|
if (options.parity === true) {
|
|
8867
|
-
log(
|
|
9290
|
+
log(
|
|
9291
|
+
"[serve] --parity \u4E25\u683C\u6A21\u5F0F\uFF1A\u6C99\u7BB1\u4E0D\u6CE8\u5165 process\uFF08env \u8D70 ctx.env\uFF09\u3001../ \u8D8A\u6839\u5F15\u7528\u62A5\u9519\u2014\u2014\u4E0E\u5E73\u53F0\u6C99\u7BB1\u540C\u5F62"
|
|
9292
|
+
);
|
|
8868
9293
|
}
|
|
8869
9294
|
if (templateEnv !== null) {
|
|
8870
9295
|
const currentKeys = Object.keys(templateEnv.values());
|
|
@@ -8875,7 +9300,11 @@ async function startServeServer(options) {
|
|
|
8875
9300
|
if (options.watch === true) {
|
|
8876
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`);
|
|
8877
9302
|
}
|
|
8878
|
-
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) {
|
|
8879
9308
|
log(
|
|
8880
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`
|
|
8881
9310
|
);
|
|
@@ -8912,6 +9341,7 @@ var init_server = __esm({
|
|
|
8912
9341
|
init_dev();
|
|
8913
9342
|
init_banner();
|
|
8914
9343
|
init_fetch_safe_port();
|
|
9344
|
+
init_port_in_use();
|
|
8915
9345
|
init_staleness();
|
|
8916
9346
|
init_template_params2();
|
|
8917
9347
|
init_adep_env_inject();
|
|
@@ -9369,11 +9799,15 @@ var init_deploy = __esm({
|
|
|
9369
9799
|
});
|
|
9370
9800
|
|
|
9371
9801
|
// shared/frontend-draft.ts
|
|
9372
|
-
|
|
9802
|
+
function hasFrontendEntry(files) {
|
|
9803
|
+
return Object.hasOwn(files, FRONTEND_DRAFT_ENTRY_PATH);
|
|
9804
|
+
}
|
|
9805
|
+
var FRONTEND_DRAFT_FILE_PATH_PATTERN, FRONTEND_DRAFT_ENTRY_PATH, FRONTEND_DRAFT_MAX_TOTAL_SOURCE_BYTES, FRONTEND_DRAFT_MAX_FILES, FRONTEND_TRANSFORM_EXTENSIONS;
|
|
9373
9806
|
var init_frontend_draft = __esm({
|
|
9374
9807
|
"shared/frontend-draft.ts"() {
|
|
9375
9808
|
"use strict";
|
|
9376
9809
|
FRONTEND_DRAFT_FILE_PATH_PATTERN = /^[a-zA-Z0-9._][a-zA-Z0-9._/-]*$/;
|
|
9810
|
+
FRONTEND_DRAFT_ENTRY_PATH = "web/index.html";
|
|
9377
9811
|
FRONTEND_DRAFT_MAX_TOTAL_SOURCE_BYTES = 512 * 1024;
|
|
9378
9812
|
FRONTEND_DRAFT_MAX_FILES = 100;
|
|
9379
9813
|
FRONTEND_TRANSFORM_EXTENSIONS = [
|
|
@@ -9396,8 +9830,10 @@ __export(frontend_exports, {
|
|
|
9396
9830
|
detectCanonicalFrontendLayout: () => detectCanonicalFrontendLayout,
|
|
9397
9831
|
frontendSync: () => frontendSync,
|
|
9398
9832
|
isStaticFrontendDir: () => isStaticFrontendDir,
|
|
9833
|
+
prepareFrontendDraft: () => prepareFrontendDraft,
|
|
9399
9834
|
readPackageDistDir: () => readPackageDistDir,
|
|
9400
|
-
resolveSiteOutputDir: () => resolveSiteOutputDir
|
|
9835
|
+
resolveSiteOutputDir: () => resolveSiteOutputDir,
|
|
9836
|
+
syncPreparedFrontend: () => syncPreparedFrontend
|
|
9401
9837
|
});
|
|
9402
9838
|
import { readdir as readdir10, readFile as readFile23, stat as stat13 } from "node:fs/promises";
|
|
9403
9839
|
import { join as join31, relative as relative6, resolve as resolve14, sep as sep2 } from "node:path";
|
|
@@ -9434,15 +9870,12 @@ async function collectFiles(root, dir) {
|
|
|
9434
9870
|
}
|
|
9435
9871
|
return { files, skipped };
|
|
9436
9872
|
}
|
|
9437
|
-
async function
|
|
9438
|
-
const log = options.silent === true ? () => void 0 : options.log ?? ((line) => process.stdout.write(`${line}
|
|
9439
|
-
`));
|
|
9440
|
-
const webDir = options.dir ?? join31(options.cwd, "web");
|
|
9873
|
+
async function prepareFrontendDraft(webDir) {
|
|
9441
9874
|
const rootStat = await stat13(webDir).catch(() => null);
|
|
9442
9875
|
if (rootStat === null || !rootStat.isDirectory()) {
|
|
9443
9876
|
throw new CliError(
|
|
9444
9877
|
"FRONTEND_DIR_MISSING",
|
|
9445
|
-
`\u672C\u5730\u524D\u7AEF\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${webDir}\
|
|
9878
|
+
`\u672C\u5730\u524D\u7AEF\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${webDir}\uFF08\u671F\u671B ${webDir}/ \u4E0B\u662F Vite \u5DE5\u7A0B\uFF09`
|
|
9446
9879
|
);
|
|
9447
9880
|
}
|
|
9448
9881
|
const { files, skipped } = await collectFiles(webDir, webDir);
|
|
@@ -9471,18 +9904,40 @@ async function frontendSync(paths, options) {
|
|
|
9471
9904
|
`\u6E90\u7801\u603B\u91CF ${totalBytes} \u5B57\u8282\u8D85\u8FC7\u4E0A\u9650\uFF08${MAX_TOTAL_SOURCE_BYTES2} \u5B57\u8282\uFF09`
|
|
9472
9905
|
);
|
|
9473
9906
|
}
|
|
9907
|
+
return { drafts, skipped, totalBytes };
|
|
9908
|
+
}
|
|
9909
|
+
async function syncPreparedFrontend(paths, options) {
|
|
9910
|
+
const log = options.silent === true ? () => void 0 : options.log ?? ((line) => process.stdout.write(`${line}
|
|
9911
|
+
`));
|
|
9912
|
+
const { prepared } = options;
|
|
9913
|
+
const uploaded = Object.keys(prepared.drafts).length;
|
|
9474
9914
|
const client = await createClient(paths);
|
|
9475
9915
|
const project2 = await resolveProjectId(client, options.cwd, options.slug);
|
|
9476
|
-
log(`[adep] \u540C\u6B65\u672C\u5730 web/ \u8349\u7A3F\u5230\u5E73\u53F0\uFF08\u9879\u76EE ${project2.slug}\uFF0C${
|
|
9916
|
+
log(`[adep] \u540C\u6B65\u672C\u5730 web/ \u8349\u7A3F\u5230\u5E73\u53F0\uFF08\u9879\u76EE ${project2.slug}\uFF0C${uploaded} \u4E2A\u6587\u4EF6\uFF09\u2026`);
|
|
9477
9917
|
await client.request(
|
|
9478
9918
|
`/api/v1/projects/${project2.id}/frontend/files`,
|
|
9479
|
-
{ method: "PUT", body: { files: drafts } },
|
|
9919
|
+
{ method: "PUT", body: { files: prepared.drafts } },
|
|
9480
9920
|
"FRONTEND_SYNC_FAILED"
|
|
9481
9921
|
);
|
|
9482
|
-
if (skipped.length > 0) {
|
|
9483
|
-
log(`[adep] \u8DF3\u8FC7\u975E\u6587\u672C\u6587\u4EF6\uFF08\u8349\u7A3F\u901A\u9053\u4E0D\u652F\u6301\u4E8C\u8FDB\u5236\uFF09\uFF1A${skipped.join(", ")}`);
|
|
9922
|
+
if (prepared.skipped.length > 0) {
|
|
9923
|
+
log(`[adep] \u8DF3\u8FC7\u975E\u6587\u672C\u6587\u4EF6\uFF08\u8349\u7A3F\u901A\u9053\u4E0D\u652F\u6301\u4E8C\u8FDB\u5236\uFF09\uFF1A${prepared.skipped.join(", ")}`);
|
|
9484
9924
|
}
|
|
9485
|
-
return {
|
|
9925
|
+
return {
|
|
9926
|
+
projectId: project2.id,
|
|
9927
|
+
uploaded,
|
|
9928
|
+
skipped: prepared.skipped,
|
|
9929
|
+
totalBytes: prepared.totalBytes
|
|
9930
|
+
};
|
|
9931
|
+
}
|
|
9932
|
+
async function frontendSync(paths, options) {
|
|
9933
|
+
const prepared = await prepareFrontendDraft(options.dir ?? join31(options.cwd, "web"));
|
|
9934
|
+
return syncPreparedFrontend(paths, {
|
|
9935
|
+
cwd: options.cwd,
|
|
9936
|
+
...options.slug === void 0 ? {} : { slug: options.slug },
|
|
9937
|
+
...options.silent === void 0 ? {} : { silent: options.silent },
|
|
9938
|
+
...options.log === void 0 ? {} : { log: options.log },
|
|
9939
|
+
prepared
|
|
9940
|
+
});
|
|
9486
9941
|
}
|
|
9487
9942
|
function declaresBuildScript(pkgJson) {
|
|
9488
9943
|
if (pkgJson === void 0) return false;
|
|
@@ -10526,18 +10981,93 @@ var init_version = __esm({
|
|
|
10526
10981
|
manifest = requireJson("../package.json");
|
|
10527
10982
|
CLI_VERSION = typeof manifest.version === "string" && manifest.version.length > 0 ? manifest.version : "0.0.0";
|
|
10528
10983
|
RELEASE_TASKS = Array.isArray(manifest.adep?.releaseTasks) ? manifest.adep.releaseTasks.filter((item) => typeof item === "string") : [];
|
|
10529
|
-
BUILD_COMMIT = "
|
|
10984
|
+
BUILD_COMMIT = "8e63db96".trim() !== "" ? "8e63db96".trim() : null;
|
|
10530
10985
|
}
|
|
10531
10986
|
});
|
|
10532
10987
|
|
|
10533
10988
|
// packages/cli/src/doctor.ts
|
|
10534
10989
|
var doctor_exports = {};
|
|
10535
10990
|
__export(doctor_exports, {
|
|
10991
|
+
detectSupplyChainPolicy: () => detectSupplyChainPolicy,
|
|
10536
10992
|
formatDoctorReport: () => formatDoctorReport,
|
|
10993
|
+
parseChangelogBreaking: () => parseChangelogBreaking,
|
|
10994
|
+
pickBreakingNotices: () => pickBreakingNotices,
|
|
10537
10995
|
runDoctor: () => runDoctor
|
|
10538
10996
|
});
|
|
10539
|
-
import {
|
|
10997
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
10998
|
+
import { readFile as readFile32, stat as stat18 } from "node:fs/promises";
|
|
10999
|
+
import { homedir } from "node:os";
|
|
10540
11000
|
import { join as join39 } from "node:path";
|
|
11001
|
+
import { parse as parseYaml } from "yaml";
|
|
11002
|
+
function minimumReleaseAgeMinutes(raw) {
|
|
11003
|
+
const text = raw.trim();
|
|
11004
|
+
return /^\d+$/u.test(text) ? Number(text) : null;
|
|
11005
|
+
}
|
|
11006
|
+
function hitFromRaw(raw, source) {
|
|
11007
|
+
const minutes = minimumReleaseAgeMinutes(raw);
|
|
11008
|
+
return {
|
|
11009
|
+
minutes,
|
|
11010
|
+
raw,
|
|
11011
|
+
warning: minutes === null ? `minimumReleaseAge \u7684\u503C\u300C${raw}\u300D\u4E0D\u662F\u975E\u8D1F\u6574\u6570\uFF08\u5206\u949F\uFF09\uFF0Cpnpm \u4F1A\u62D2\u7EDD\u8BE5\u914D\u7F6E` : null,
|
|
11012
|
+
source
|
|
11013
|
+
};
|
|
11014
|
+
}
|
|
11015
|
+
function hitFromEnvironment(env) {
|
|
11016
|
+
for (const [key, value] of Object.entries(env)) {
|
|
11017
|
+
if (value === void 0 || !MINIMUM_RELEASE_AGE_ENV.test(key)) continue;
|
|
11018
|
+
return hitFromRaw(value, `\u73AF\u5883\u53D8\u91CF ${key}`);
|
|
11019
|
+
}
|
|
11020
|
+
return null;
|
|
11021
|
+
}
|
|
11022
|
+
async function readTextOrNull(file2) {
|
|
11023
|
+
try {
|
|
11024
|
+
return await readFile32(file2, "utf8");
|
|
11025
|
+
} catch {
|
|
11026
|
+
return null;
|
|
11027
|
+
}
|
|
11028
|
+
}
|
|
11029
|
+
async function hitFromYamlConfig(file2, label) {
|
|
11030
|
+
const text = await readTextOrNull(file2);
|
|
11031
|
+
if (text === null) return null;
|
|
11032
|
+
let data;
|
|
11033
|
+
try {
|
|
11034
|
+
data = parseYaml(text);
|
|
11035
|
+
} catch (error62) {
|
|
11036
|
+
return {
|
|
11037
|
+
minutes: null,
|
|
11038
|
+
raw: null,
|
|
11039
|
+
warning: `${label} \u65E0\u6CD5\u89E3\u6790\uFF1A${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
11040
|
+
source: label
|
|
11041
|
+
};
|
|
11042
|
+
}
|
|
11043
|
+
if (data === null || typeof data !== "object") return null;
|
|
11044
|
+
const value = data["minimumReleaseAge"];
|
|
11045
|
+
if (value === void 0) return null;
|
|
11046
|
+
return hitFromRaw(String(value), label);
|
|
11047
|
+
}
|
|
11048
|
+
async function hitFromNpmrc(file2, label) {
|
|
11049
|
+
const text = await readTextOrNull(file2);
|
|
11050
|
+
if (text === null) return null;
|
|
11051
|
+
let found = null;
|
|
11052
|
+
for (const line of text.split(/\r?\n/u)) {
|
|
11053
|
+
const trimmed = line.trim();
|
|
11054
|
+
if (trimmed === "" || trimmed.startsWith("#") || trimmed.startsWith(";")) continue;
|
|
11055
|
+
const equal = trimmed.indexOf("=");
|
|
11056
|
+
if (equal < 0) continue;
|
|
11057
|
+
const key = trimmed.slice(0, equal).trim().toLowerCase().replaceAll("-", "").replaceAll("_", "");
|
|
11058
|
+
if (key !== "minimumreleaseage") continue;
|
|
11059
|
+
found = trimmed.slice(equal + 1).trim();
|
|
11060
|
+
}
|
|
11061
|
+
return found === null ? null : hitFromRaw(found, label);
|
|
11062
|
+
}
|
|
11063
|
+
async function detectSupplyChainPolicy(cwd, env = process.env, home = homedir()) {
|
|
11064
|
+
const xdg = env["XDG_CONFIG_HOME"]?.trim();
|
|
11065
|
+
const globalConfig2 = xdg !== void 0 && xdg !== "" ? join39(xdg, "pnpm", "config.yaml") : join39(home, ".config", "pnpm", "config.yaml");
|
|
11066
|
+
const hit = hitFromEnvironment(env) ?? await hitFromYamlConfig(join39(cwd, "pnpm-workspace.yaml"), "pnpm-workspace.yaml") ?? await hitFromNpmrc(join39(cwd, ".npmrc"), ".npmrc") ?? await hitFromYamlConfig(globalConfig2, "~/.config/pnpm/config.yaml") ?? await hitFromNpmrc(join39(home, ".npmrc"), "~/.npmrc");
|
|
11067
|
+
return {
|
|
11068
|
+
minimumReleaseAge: hit === null ? { minutes: null, source: null, raw: null, warning: null } : { minutes: hit.minutes, source: hit.source, raw: hit.raw, warning: hit.warning }
|
|
11069
|
+
};
|
|
11070
|
+
}
|
|
10541
11071
|
function isWildcardBind(host) {
|
|
10542
11072
|
return host === "0.0.0.0" || host === "::" || host === "[::]";
|
|
10543
11073
|
}
|
|
@@ -10575,10 +11105,18 @@ async function runDoctor(paths, cwd = process.cwd()) {
|
|
|
10575
11105
|
const session = credentials === null ? null : await checkSession(credentials);
|
|
10576
11106
|
const sandbox = await scanSandbox(cwd);
|
|
10577
11107
|
const projectEnv = await inspectProjectEnv(cwd);
|
|
11108
|
+
const supplyChain = await detectSupplyChainPolicy(cwd);
|
|
10578
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
|
+
);
|
|
10579
11117
|
const report = {
|
|
10580
11118
|
server,
|
|
10581
|
-
cli: { version: CLI_VERSION, buildCommit: BUILD_COMMIT, ...cliRelease },
|
|
11119
|
+
cli: { version: CLI_VERSION, buildCommit: BUILD_COMMIT, breaking, ...cliRelease },
|
|
10582
11120
|
credentials: {
|
|
10583
11121
|
file: credentialsFile,
|
|
10584
11122
|
present: credentials !== null,
|
|
@@ -10594,7 +11132,8 @@ async function runDoctor(paths, cwd = process.cwd()) {
|
|
|
10594
11132
|
env: process.env["ADEP_PUBLIC_URL"]?.trim() || null,
|
|
10595
11133
|
hostEnv: process.env["HOST"]?.trim() || null
|
|
10596
11134
|
},
|
|
10597
|
-
projectEnv
|
|
11135
|
+
projectEnv,
|
|
11136
|
+
supplyChain
|
|
10598
11137
|
};
|
|
10599
11138
|
if (credentials !== null) report.credentials.email = credentials.email;
|
|
10600
11139
|
if (mode !== void 0 && mode !== "600") {
|
|
@@ -10659,6 +11198,43 @@ async function inspectProjectEnv(cwd) {
|
|
|
10659
11198
|
fetchAllowlist: fetch2
|
|
10660
11199
|
};
|
|
10661
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
|
+
}
|
|
10662
11238
|
function cliVersionSection(cli) {
|
|
10663
11239
|
const versionText = cli.buildCommit === null ? `${cli.version}\uFF08source\uFF09` : `${cli.version}\uFF08commit ${cli.buildCommit}\uFF09`;
|
|
10664
11240
|
const lines = [];
|
|
@@ -10668,6 +11244,11 @@ function cliVersionSection(cli) {
|
|
|
10668
11244
|
}
|
|
10669
11245
|
if (cli.status === "current") {
|
|
10670
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
|
+
}
|
|
10671
11252
|
return lines;
|
|
10672
11253
|
}
|
|
10673
11254
|
if (cli.status === "behind") {
|
|
@@ -10676,6 +11257,16 @@ function cliVersionSection(cli) {
|
|
|
10676
11257
|
lines.push(
|
|
10677
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"
|
|
10678
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
|
+
}
|
|
10679
11270
|
lines.push(" \u63D0\u793A\uFF1Anpm i -g @adep/cli@latest \u540E\u91CD\u8DD1 adep doctor");
|
|
10680
11271
|
return lines;
|
|
10681
11272
|
}
|
|
@@ -10686,10 +11277,34 @@ function cliVersionSection(cli) {
|
|
|
10686
11277
|
lines.push(" \u63D0\u793A\uFF1A\u6309 docs/npm-publishing.md \u53D1\u5305\uFF08pnpm run release:check \u53EF\u67E5\u5F85\u53D1\u6E05\u5355\uFF09");
|
|
10687
11278
|
return lines;
|
|
10688
11279
|
}
|
|
11280
|
+
function supplyChainSection(policy) {
|
|
11281
|
+
const { minutes, source, warning } = policy.minimumReleaseAge;
|
|
11282
|
+
if (source === null) {
|
|
11283
|
+
return [" \xB7 \u672A\u68C0\u6D4B\u5230 minimumReleaseAge \u4F9B\u5E94\u94FE\u7B56\u7565\uFF08pnpm \u4E0D\u9650\u5236\u4F9D\u8D56\u53D1\u5E03\u5E74\u9F84\uFF09"];
|
|
11284
|
+
}
|
|
11285
|
+
if (warning !== null) {
|
|
11286
|
+
return [
|
|
11287
|
+
` ! ${warning}\uFF08\u6765\u6E90 ${source}\uFF09`,
|
|
11288
|
+
" \u63D0\u793A\uFF1A\u5148\u4FEE\u6B63\u8BE5\u914D\u7F6E\uFF0Cpnpm \u7684\u5B89\u88C5\u4E0E exec \u624D\u80FD\u6B63\u5E38\u6267\u884C"
|
|
11289
|
+
];
|
|
11290
|
+
}
|
|
11291
|
+
if (minutes === 0) {
|
|
11292
|
+
return [` \xB7 minimumReleaseAge=0\uFF08\u6765\u6E90 ${source}\uFF09\uFF1A\u7B56\u7565\u5DF2\u663E\u5F0F\u5173\u95ED`];
|
|
11293
|
+
}
|
|
11294
|
+
return [
|
|
11295
|
+
` ! minimumReleaseAge=${minutes} \u5206\u949F\uFF08\u6765\u6E90 ${source}\uFF09\uFF1Apnpm \u4F1A\u62D2\u7EDD\u53D1\u5E03\u65F6\u95F4\u4E0D\u8DB3 ${minutes} \u5206\u949F\u7684\u65B0\u7248\u672C`,
|
|
11296
|
+
" \u4EE5\u4E0B\u8F93\u51FA\u5C5E\u4E8E pnpm \u7684\u524D\u7F6E\u5B89\u88C5\u7B56\u7565\uFF0C\u4E0D\u662F adep \u5931\u8D25\uFF08\u4EE5 adep \u547D\u4EE4\u81EA\u8EAB\u7684\u9000\u51FA\u7801\u4E0E\u7ED3\u679C\u4E3A\u51C6\uFF09\uFF1A",
|
|
11297
|
+
" Lockfile failed supply-chain policy check / ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION",
|
|
11298
|
+
" \u4EC5\u672C\u6B21\u7ED5\u8FC7\uFF08pnpm \u53C2\u6570\uFF0C\u4E0D\u662F adep \u7684\uFF09\uFF1Apnpm --config.minimumReleaseAge=0 exec adep <\u547D\u4EE4>",
|
|
11299
|
+
" \u957F\u671F\u7B56\u7565\uFF08canary/next \u5148\u53D1\u3001latest \u5EF6\u540E\uFF09\u89C1\u6587\u6863\u300C\u4E25\u683C\u4F9B\u5E94\u94FE\u7B56\u7565\u73AF\u5883\u300D"
|
|
11300
|
+
];
|
|
11301
|
+
}
|
|
10689
11302
|
function formatDoctorReport(report) {
|
|
10690
11303
|
const lines = ["adep doctor \xB7 \u73AF\u5883\u81EA\u68C0", ""];
|
|
10691
11304
|
lines.push("CLI \u7248\u672C\u4E0E\u53D1\u7248");
|
|
10692
11305
|
lines.push(...cliVersionSection(report.cli));
|
|
11306
|
+
lines.push("", "\u4F9B\u5E94\u94FE\u7B56\u7565\uFF08\u73AF\u5883\uFF09");
|
|
11307
|
+
lines.push(...supplyChainSection(report.supplyChain));
|
|
10693
11308
|
lines.push("", "\u51ED\u636E\u4E0E\u8EAB\u4EFD");
|
|
10694
11309
|
if (report.credentials.present) {
|
|
10695
11310
|
const email3 = report.credentials.email ?? "(\u672A\u77E5\u90AE\u7BB1)";
|
|
@@ -10797,7 +11412,7 @@ function formatDoctorReport(report) {
|
|
|
10797
11412
|
}
|
|
10798
11413
|
return lines;
|
|
10799
11414
|
}
|
|
10800
|
-
var SERVER_PROBE_TIMEOUT_MS, OFFLINE_COMMANDS;
|
|
11415
|
+
var SERVER_PROBE_TIMEOUT_MS, OFFLINE_COMMANDS, MINIMUM_RELEASE_AGE_ENV;
|
|
10801
11416
|
var init_doctor = __esm({
|
|
10802
11417
|
"packages/cli/src/doctor.ts"() {
|
|
10803
11418
|
"use strict";
|
|
@@ -10821,6 +11436,7 @@ var init_doctor = __esm({
|
|
|
10821
11436
|
"adep db\uFF08\u672C\u5730\u6A21\u62DF\uFF09",
|
|
10822
11437
|
"adep doctor"
|
|
10823
11438
|
];
|
|
11439
|
+
MINIMUM_RELEASE_AGE_ENV = /^(?:npm_config_|pnpm_config_)minimum[_-]release[_-]age$/i;
|
|
10824
11440
|
}
|
|
10825
11441
|
});
|
|
10826
11442
|
|
|
@@ -11275,7 +11891,14 @@ var GENERATED_TEMPLATES = {
|
|
|
11275
11891
|
description: "\u6A21\u677F code"
|
|
11276
11892
|
}
|
|
11277
11893
|
],
|
|
11278
|
-
sharedAssets: [
|
|
11894
|
+
sharedAssets: [
|
|
11895
|
+
"packageJson",
|
|
11896
|
+
"adepConfig",
|
|
11897
|
+
"adepEnv",
|
|
11898
|
+
"gitignore",
|
|
11899
|
+
"dockerAssets",
|
|
11900
|
+
"pnpmWorkspace"
|
|
11901
|
+
]
|
|
11279
11902
|
},
|
|
11280
11903
|
files: [
|
|
11281
11904
|
{
|
|
@@ -11308,7 +11931,8 @@ var GENERATED_TEMPLATES = {
|
|
|
11308
11931
|
"helloFunction",
|
|
11309
11932
|
"functionIndex",
|
|
11310
11933
|
"gitignore",
|
|
11311
|
-
"dockerAssets"
|
|
11934
|
+
"dockerAssets",
|
|
11935
|
+
"pnpmWorkspace"
|
|
11312
11936
|
]
|
|
11313
11937
|
},
|
|
11314
11938
|
files: []
|
|
@@ -11341,7 +11965,8 @@ var GENERATED_TEMPLATES = {
|
|
|
11341
11965
|
"indexHtml",
|
|
11342
11966
|
"webSrc",
|
|
11343
11967
|
"gitignore",
|
|
11344
|
-
"dockerAssets"
|
|
11968
|
+
"dockerAssets",
|
|
11969
|
+
"pnpmWorkspace"
|
|
11345
11970
|
]
|
|
11346
11971
|
},
|
|
11347
11972
|
files: []
|
|
@@ -11370,14 +11995,15 @@ var GENERATED_TEMPLATES = {
|
|
|
11370
11995
|
"indexHtml",
|
|
11371
11996
|
"viteConfig",
|
|
11372
11997
|
"gitignore",
|
|
11373
|
-
"dockerAssets"
|
|
11998
|
+
"dockerAssets",
|
|
11999
|
+
"pnpmWorkspace"
|
|
11374
12000
|
],
|
|
11375
12001
|
source: "\u672C\u76EE\u5F55\u5373\u771F\u76F8\u6E90\uFF08\u539F apps/countdown \u5DF2\u79FB\u51FA\u4ED3\u5E93\uFF0C\u72EC\u7ACB\u7EF4\u62A4\u4E8E git.a.jajabjbj.top:6602/a/countdown-adep.git\uFF09"
|
|
11376
12002
|
},
|
|
11377
12003
|
files: [
|
|
11378
12004
|
{
|
|
11379
12005
|
path: "README.md",
|
|
11380
|
-
content:
|
|
12006
|
+
content: '# {{name}}\n\n\u5012\u6570\u65E5 / \u7EAA\u5FF5\u65E5\uFF08countdown \u6A21\u677F\uFF09\u2014\u2014\u7531\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u300C\u5012\u6570\u65E5\u300D\u79FB\u690D\u7684 adep \u5168\u6808\u5E94\u7528\uFF1A\n`functions/` \u4E91\u51FD\u6570\uFF08auth / events + `_shared/` \u5171\u4EAB\u6A21\u5757\uFF09+ `web/src/` \u524D\u7AEF\u6E90\u7801\uFF08Vue 3 + Vite\uFF0C\nHome / Edit / Profile \u4E09\u9875 + OIDC \u56DE\u8C03\u9875\u3001\u81EA\u5B9A\u4E49 TabBar + \u5DE6\u6ED1\u5220\u9664 / \u957F\u6309\u7F6E\u9876 / \u4E0B\u62C9\u5237\u65B0\uFF0C\n\u754C\u9762\u4E0E\u5C0F\u7A0B\u5E8F\u5BF9\u9F50\uFF09\u3002vite \u5DE5\u7A0B\u6839\u5728**\u9879\u76EE\u6839**\uFF08`index.html` + `vite.config.ts` + \u6839 `package.json`\uFF09\u3002\n\n> \u672C\u6A21\u677F\u76EE\u5F55\u662F\u81EA\u5305\u542B\u771F\u76F8\u6E90\uFF08`scripts/build-templates.mjs` \u7531\u6B64\u751F\u6210 `generated.ts` \u5FEB\u7167\uFF0C\n> \u6539\u6A21\u677F\u540E\u91CD\u8DD1\u811A\u672C\uFF09\u3002**\u5B8C\u6574\u7248**\u5012\u6570\u65E5\uFF089 \u51FD\u6570\u57DF + \u4F1A\u5458/\u88C2\u53D8/\u519C\u5386/\u63D0\u9192 + 102 \u9879\u6D4B\u8BD5\uFF09\u89C1\u72EC\u7ACB\u4ED3\u5E93 [a/countdown-adep](https://git.a.jajabjbj.top:6602/a/countdown-adep)\uFF0C\u53EF\u88AB\u5E73\u53F0\u76F4\u63A5 from-git \u5BFC\u5165\u3002\n\n## \u5FEB\u901F\u5F00\u59CB\n\n```bash\nnpm install # \u5355\u4E00\u5DE5\u7A0B\u6839\uFF1A@adep/cli + \u524D\u7AEF\u4F9D\u8D56\uFF08vue / vue-router / @adep/auth-client\uFF09+ \u6784\u5EFA\u94FE\nnpm run dev # \u5168\u6808\u5F00\u53D1\uFF1Avite \u8FDB\u7A0B\u5185\u542F\u52A8 adep dev + /api \u4EE3\u7406\uFF0C\u524D\u7AEF HMR + \u51FD\u6570\u70ED\u91CD\u8F7D\nnpm test # \u51FD\u6570/\u5DE5\u5177\u5171\u4EAB\u903B\u8F91\u5355\u5143\u6D4B\u8BD5\uFF08vitest\uFF09\nnpm run build # \u6784\u5EFA\u524D\u7AEF \u2192 site/\nnpm run start # \u72EC\u7ACB\u8FD0\u884C\uFF08\u672C\u5730\u6A21\u62DF\u8FD0\u884C\u65F6 + \u9759\u6001\u6258\u7BA1 + --schema \u81EA\u52A8\u5EFA\u8868\uFF09\uFF0C\u6D4F\u89C8\u5668\u5F00 http://127.0.0.1:8787\n```\n\n## pnpm \u4E0E\u4F9D\u8D56\u6784\u5EFA\u811A\u672C\uFF08pnpm 10 \u8D77\u9ED8\u8BA4\u4E0D\u8DD1\uFF09\n\n\u9879\u76EE\u6839\u7684 `pnpm-workspace.yaml` \u5DF2\u653E\u884C `esbuild` \u7684\u6784\u5EFA\u811A\u672C\uFF08`onlyBuiltDependencies` \u4E0E\n`allowBuilds` \u53CC\u5199\uFF1Apnpm 10 \u8BFB\u524D\u8005\uFF0Cpnpm 11+ \u8BFB\u540E\u8005\uFF09\u3002pnpm 10 \u8D77**\u9ED8\u8BA4\u4E0D\u6267\u884C\u4F9D\u8D56\u7684\n\u6784\u5EFA\u811A\u672C**\uFF0C\u5220\u6389\u8FD9\u4EFD\u914D\u7F6E\u540E `pnpm install` \u4F1A\u4EE5 `ERR_PNPM_IGNORED_BUILDS` \u62A5\u9519\uFF08vite \u4F9D\u8D56\u7684\nesbuild \u539F\u751F\u4E8C\u8FDB\u5236\u6CA1\u51C6\u5907\u597D\uFF0C\u6784\u5EFA\u53EF\u80FD\u5931\u8D25\uFF09\uFF1B\u7528 npm \u5B89\u88C5\u4E0D\u53D7\u8FD9\u6761\u7B56\u7565\u5F71\u54CD\u3002\u4ECD\u7528 pnpm 9 \u65F6\n\u7B49\u4EF7\u5199\u6CD5\u662F\u5728 `package.json` \u91CC\u5199 `"pnpm": { "onlyBuiltDependencies": ["esbuild"] }`\u3002\n\n## \u90E8\u7F72\u5230 adep \u5E73\u53F0\n\n```bash\nadep login # \u767B\u5F55\uFF08\u5199 ~/.adep/credentials\uFF09\nnpm run deploy # \u53D1\u5E03\u4E91\u51FD\u6570\uFF08\u542B _shared/ \u5171\u4EAB\u6E90\u7801\uFF09\nadep publish --only frontend # \u672C\u5730\u6784\u5EFA\uFF08npm run build\uFF09\u2192 \u4E0A\u4F20 site/ \u5230\u5E73\u53F0\u9759\u6001\u6258\u7BA1\uFF08\u5F00 SPA \u56DE\u9000\uFF09\n# \u7B49\u4EF7\u7684\u663E\u5F0F\u4E24\u6B65\uFF1Anpm run build && npm run site:deploy\n```\n\n\u53D1\u5E03\u540E\u8BBF\u95EE `https://{project-slug}.adep.localhost:3001`\uFF08\u672C\u5730 dev \u5E73\u53F0\uFF09\u6216\u7EBF\u4E0A\u7AD9\u70B9\u5730\u5740\u3002\n\n> `adep publish --only frontend` \u5BF9 canonical \u5E03\u5C40\uFF08\u6839 `index.html` + \u6839 `scripts.build`\uFF0C\n> `web/` \u53EA\u653E\u6E90\u7801\uFF09\u4F1A\u81EA\u52A8\u6267\u884C\u672C\u5730\u6784\u5EFA\u518D\u76F4\u901A\u9759\u6001\u6258\u7BA1\u2014\u2014\u5E73\u53F0\u300C\u524D\u7AEF\u8349\u7A3F\u6784\u5EFA\u300D\u7684\u5165\u53E3\n> `web/index.html` \u5728\u672C\u5E03\u5C40\u4E0B\u4E0D\u5B58\u5728\uFF0C\u6240\u4EE5\u8D70\u524D\u8005\u800C\u4E0D\u662F\u7F3A\u7701\u5168\u6808\u53D1\u5E03\u3002\n\n## \u72EC\u7ACB\u90E8\u7F72\uFF08\u4E0D\u4F9D\u8D56 adep \u5E73\u53F0\uFF09\n\n`npm run build && npm run start` \u5373\u53EF\u672C\u5730\u72EC\u7ACB\u8DD1\uFF08adep serve \u4E0E\u5E73\u53F0\u540C\u6E90\u6267\u884C\u5668\uFF09\u3002\n\u5BB9\u5668\u5316\u90E8\u7F72\u53C2\u8003\u72EC\u7ACB\u4ED3\u5E93 a/countdown-adep \u7684 `Dockerfile` + `compose.yaml`\uFF08\u5355\u5BB9\u5668 =\nserve \u627F\u8F7D /api/* + \u9759\u6001\u6258\u7BA1 site/ + .adep/sim/ \u6570\u636E\u5377\uFF09\u3002\n\n## \u76EE\u5F55\u7ED3\u6784\n\n- `adep.config.ts`\uFF1A\u9879\u76EE\u914D\u7F6E\uFF08name / template / functionsDir / functions_prefix \u9ED8\u8BA4 /api\uFF09\n- `index.html` / `vite.config.ts`\uFF1Avite \u5165\u53E3\u4E0E\u914D\u7F6E\uFF08\u5DE5\u7A0B\u6839 = \u9879\u76EE\u6839\uFF0C`adep()` \u63D2\u4EF6\u4EE3\u7406 /api/*\uFF0Cbuild \u8F93\u51FA `site/`\uFF09\n- `pnpm-workspace.yaml`\uFF1Apnpm 10+ \u7684\u4F9D\u8D56\u6784\u5EFA\u811A\u672C\u767D\u540D\u5355\uFF08\u653E\u884C esbuild\uFF0C\u89C1\u4E0A\u8282\uFF09\n- `functions/`\uFF1A\u4E91\u51FD\u6570\u76EE\u5F55\u2014\u2014`auth.ts`\uFF08\u767B\u5F55/\u4F1A\u8BDD\uFF1AOIDC \u8EAB\u4EFD\u4F18\u5148\u3001device \u8EAB\u4EFD\u517C\u5BB9\uFF09\u3001`events.ts`\n \uFF08\u4E8B\u4EF6 CRUD + \u7F6E\u9876\u6392\u5E8F\uFF09\u3001`_shared/`\uFF08auth / store / date / response / route \u5171\u4EAB\u6A21\u5757\uFF0C\n \u5BF9\u5E94 vitest \u5355\u6D4B\uFF0C\u5168\u9879\u76EE\u5355\u4EFD\uFF09\n- `database/schema.sql`\uFF1A\u6570\u636E\u5E93\u7ED3\u6784\uFF08users / events \u8868\uFF1B`adep db migrate database/schema.sql` \u5E94\u7528\uFF09\n- `web/src/`\uFF1A\u524D\u7AEF\u6E90\u7801\u2014\u2014`web/src/views/`\uFF08Home / Edit / Profile + `OidcCallbackView.vue`\uFF09\u3001\n `web/src/ui/`\uFF08TabBar / UiHost \u590D\u523B wx.showToast \u7B49\uFF09\u3001`web/src/lib/`\n \uFF08request / auth / config / date / events / oidc\uFF09\n- `web/src/lib/request.ts`\uFF1Afetch \u5C01\u88C5\uFF08\u4E1A\u52A1\u4FE1\u5C01 + 40001 \u81EA\u52A8\u5237\u65B0\u91CD\u8BD5\uFF09\n- `site/`\uFF1A`npm run build` \u7684\u524D\u7AEF\u6784\u5EFA\u4EA7\u7269\uFF08\u7AD9\u70B9\u6258\u7BA1\u76EE\u5F55\uFF0C\u5DF2 gitignore\uFF09\n- `tsconfig.json` / `adep.d.ts`\uFF1ATypeScript \u914D\u7F6E\u4E0E\u4E91\u51FD\u6570\u4E0A\u4E0B\u6587\u7C7B\u578B\u58F0\u660E\n\n## \u7528\u6237\u4F53\u7CFB\u8BF4\u660E\uFF08\u767B\u5F55\u94FE\u8DEF\uFF09\n\n- **OIDC \u767B\u5F55\uFF08\u767B\u5F55\u5373\u670D\u52A1\uFF0C\u4E3B\u94FE\u8DEF\uFF09**\uFF1A`web/src/lib/oidc.ts` \u63A5\u5165\u5E73\u53F0\u4E09\u65B9\u767B\u5F55\uFF08\u6388\u6743\u7801 +\n PKCE S256\uFF0C\u4F1A\u8BDD\u81EA\u7BA1 localStorage\uFF0Caccess token \u8FC7\u671F\u81EA\u52A8\u5237\u65B0\uFF09\uFF0C`OidcCallbackView.vue`\n \u5904\u7406\u6388\u6743\u56DE\u8C03\uFF1B`functions/_shared/auth.ts` \u628A\u7F51\u5173\u89E3\u6790\u7684 `ctx.user`\uFF08\u5E73\u53F0\u7528\u6237\uFF09\u4EE5\n `oidc:<\u5E73\u53F0\u7528\u6237 id>` \u5173\u8054\u672C\u5730 users \u8868\uFF08\u96F6\u8FC1\u79FB\uFF0C\u7F3A\u884C\u5373\u5EFA\uFF09\u3002\u672A\u767B\u5F55\u65F6\u6570\u636E\u5B58 localStorage\n \uFF08`lib/events.ts`\uFF09\uFF0C\u767B\u5F55\u540E\u540C\u6B65\u4E91\u7AEF\u3002\n- **\u8BBE\u5907\u8EAB\u4EFD\uFF08\u517C\u5BB9\u65E7\u5BA2\u6237\u7AEF / API \u8C03\u7528\uFF0C\u515C\u5E95\uFF09**\uFF1A`POST /auth/login` \u6362\u53D6 device_id \u4F5C\n Bearer \u51ED\u636E\uFF08\u7B49\u4EF7 API Key\uFF09\uFF1Bweb \u524D\u7AEF\u5DF2\u8FC1\u79FB OIDC\uFF0C\u4E0D\u518D\u8D70\u8BBE\u5907\u767B\u5F55\u3002\u672A\u767B\u5F55/\u5931\u6548\u8FD4\u56DE\n \u4E1A\u52A1\u7801 40001\uFF0C`request.ts` \u636E\u6B64\u6E05\u4F1A\u8BDD\u3001\u6709 OIDC \u4F1A\u8BDD\u5219\u5F3A\u5236\u5237\u65B0\u91CD\u8BD5\u4E00\u6B21\u3002\n\n## \u66F4\u591A\n\n- \u79FB\u690D\u7ECF\u9A8C\u4E0E\u9010\u9879\u5BF9\u9F50\u8BF4\u660E\uFF1Aadep \u6587\u6863\u7AD9\u300C\u5B9E\u6218\uFF1A\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u79FB\u690D\u5012\u6570\u65E5\u300D\uFF08tutorial-countdown.md\uFF09\n- \u72EC\u7ACB\u90E8\u7F72\u5BB9\u5668\u914D\u7F6E\u89C1\u72EC\u7ACB\u4ED3\u5E93 a/countdown-adep\uFF08Dockerfile / compose.yaml\uFF09\n'
|
|
11381
12007
|
},
|
|
11382
12008
|
{
|
|
11383
12009
|
path: "database/schema.sql",
|
|
@@ -13718,14 +14344,18 @@ onMounted(() => {
|
|
|
13718
14344
|
}
|
|
13719
14345
|
};
|
|
13720
14346
|
|
|
13721
|
-
// shared/sdk/adep-env.ts
|
|
14347
|
+
// shared/sdk/adep-env.generated.ts
|
|
13722
14348
|
var ADEP_ENV_DTS = `/**
|
|
13723
14349
|
* AgentDeploy \u4E91\u51FD\u6570\u5F00\u53D1\u73AF\u5883\u7C7B\u578B\u58F0\u660E\uFF08\u90E8\u7F72\u5305 / adep init \u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u6539\uFF09\u3002
|
|
13724
14350
|
*
|
|
13725
|
-
* \u672C\u6587\u4EF6\
|
|
13726
|
-
* headers/body/files/user \u4E0E cloud.db / cloud.
|
|
13727
|
-
* \u5168\u5C40 ctx \u4E0E AdepContext \u662F\u5F00\u53D1\u671F\u4E0A\u4E0B\u6587
|
|
13728
|
-
* \
|
|
14351
|
+
* \u672C\u6587\u4EF6\u7531\u300Cpnpm run generate:contracts\u300D\u4ECE @adep/types \u751F\u6210\uFF1A\u4E3A\u51FD\u6570\u6E90\u7801\u91CC\u7684 ctx \u63D0\u4F9B
|
|
14352
|
+
* method/path/query/headers/body/files/user/env \u4E0E cloud.db / cloud.kv / cloud.storage /
|
|
14353
|
+
* cloud.fetch / cloud.realtime \u7684\u5B8C\u6574\u8865\u5168\u3002\u5168\u5C40 ctx \u4E0E AdepContext \u662F\u5F00\u53D1\u671F\u4E0A\u4E0B\u6587
|
|
14354
|
+
* \uFF08\u7F16\u8F91\u5668\u8865\u5168\u7528\uFF09\uFF1B\u51FD\u6570\u8FD0\u884C\u671F\u7ECF\u53C2\u6570\u6CE8\u5165\uFF0C\u4E0D\u8BFB\u53D6\u5168\u5C40\u3002
|
|
14355
|
+
*
|
|
14356
|
+
* \u5951\u7EA6\u552F\u4E00\u771F\u76F8\u6E90 = packages/types/src/\uFF1B\u540C\u6E90\u4EA7\u7269\u8FD8\u6709 Web IDE \u955C\u50CF
|
|
14357
|
+
* \uFF08app/components/ide/adep.d.ts\uFF0C\u540C\u4E00\u4EFD\u751F\u6210\u5668\u8F93\u51FA + \u6D4F\u89C8\u5668\u6D4B\u8BD5\u5168\u5C40\uFF09\u3002
|
|
14358
|
+
* \u6F02\u79FB\u95E8 = scripts/lib/__tests__/contract-mirrors.test.ts\u3002
|
|
13729
14359
|
*/
|
|
13730
14360
|
|
|
13731
14361
|
/* ---------- HTTP \u89E6\u53D1\u4E0A\u4E0B\u6587\uFF08FunctionContext \u955C\u50CF\uFF09 ---------- */
|
|
@@ -13734,44 +14364,145 @@ type AdepHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OP
|
|
|
13734
14364
|
|
|
13735
14365
|
/* ---------- \u6587\u4EF6\u4E0E\u5B58\u50A8\uFF08CloudStorage \u955C\u50CF\uFF09 ---------- */
|
|
13736
14366
|
|
|
13737
|
-
/**
|
|
14367
|
+
/** \u51FD\u6570 HTTP \u89E6\u53D1\u65F6 ctx.files \u91CC\u7684\u5355\u4E2A\u4E0A\u4F20\u6587\u4EF6\uFF08multipart \u89E3\u6790\u4EA7\u7269\uFF09\u3002 */
|
|
13738
14368
|
interface AdepFunctionFile {
|
|
13739
14369
|
/** \u5BA2\u6237\u7AEF\u63D0\u4F9B\u7684\u6587\u4EF6\u540D\uFF08\u542B\u6269\u5C55\u540D\uFF09\u3002 */
|
|
13740
|
-
name: string
|
|
14370
|
+
readonly name: string
|
|
13741
14371
|
/** MIME \u7C7B\u578B\u3002 */
|
|
13742
|
-
type: string
|
|
14372
|
+
readonly type: string
|
|
13743
14373
|
/** \u5B57\u8282\u6570\u3002 */
|
|
13744
|
-
size: number
|
|
13745
|
-
data: Uint8Array
|
|
14374
|
+
readonly size: number
|
|
14375
|
+
readonly data: Uint8Array
|
|
13746
14376
|
}
|
|
13747
14377
|
|
|
13748
|
-
/** \u4E0A\u4F20\u6570\u636E\uFF1A\u6587\u672C\u3001\u4E8C\u8FDB\u5236\u3001\u6216\u76F4\u63A5\u900F\u4F20\u8BF7\u6C42\u91CC\u7684\u6587\u4EF6\u5BF9\u8C61\u3002 */
|
|
14378
|
+
/** \u4E0A\u4F20\u6570\u636E\uFF1A\u6587\u672C\u3001\u4E8C\u8FDB\u5236\u3001\u6216\u76F4\u63A5\u900F\u4F20\u8BF7\u6C42\u91CC\u7684\u6587\u4EF6\u5BF9\u8C61\uFF08PRD \xA72.1.3 \u793A\u4F8B\u7684\u7528\u6CD5\uFF09\u3002 */
|
|
13749
14379
|
type AdepStorageUploadData = string | Uint8Array | ArrayBuffer | AdepFunctionFile
|
|
13750
14380
|
|
|
13751
14381
|
type AdepFileVisibility = 'public' | 'private'
|
|
13752
14382
|
|
|
14383
|
+
/** \u4E0A\u4F20\u9009\u9879\u3002 */
|
|
14384
|
+
interface AdepStorageUploadOptions {
|
|
14385
|
+
/** \u53EF\u9009 MIME\uFF08R2 \u8FC1\u79FB\u7ECF httpMetadata \u6620\u5C04\uFF1B\u9A71\u52A8\u4FA7\u6301\u4E45\u5316\uFF09\u3002 */
|
|
14386
|
+
contentType?: string
|
|
14387
|
+
/**
|
|
14388
|
+
* \u53EF\u89C1\u6027\uFF0C\u7F3A\u7701 private\u3002
|
|
14389
|
+
*
|
|
14390
|
+
* public \u8868\u793A\u300C\u62FF\u5230 URL \u7684\u4EFB\u4F55\u4EBA\u6C38\u4E45\u53EF\u8BFB\u300D\uFF08\u9879\u76EE\u6587\u4EF6\u76F4\u8FDE\u8DEF\u7531\u8DF3\u8FC7\u7B7E\u540D\uFF09\uFF0C
|
|
14391
|
+
* \u9700\u8981\u957F\u671F\u7A33\u5B9A\u7684\u5916\u94FE\uFF08getUrl\uFF09\u624D\u663E\u5F0F\u4F20\uFF1B\u5176\u4F59\u60C5\u51B5\u4FDD\u6301 private\u3002
|
|
14392
|
+
*/
|
|
14393
|
+
visibility?: AdepFileVisibility
|
|
14394
|
+
}
|
|
14395
|
+
|
|
14396
|
+
/** getUrl \u7684\u8FD4\u56DE\uFF1A\u7A33\u5B9A\u8BBF\u95EE\u5730\u5740 + \u8FC7\u671F\u8BED\u4E49\u3002 */
|
|
14397
|
+
interface AdepStorageFileUrl {
|
|
14398
|
+
/**
|
|
14399
|
+
* \u8BBF\u95EE\u5730\u5740\uFF1A
|
|
14400
|
+
* - public \u6587\u4EF6 \u2192 \u65E0\u7B7E\u540D\u7684\u7A33\u5B9A\u76F4\u94FE\uFF08expiresAt: null\uFF09\uFF1B
|
|
14401
|
+
* - private \u6587\u4EF6 \u2192 \u5E26\u7B7E\u540D URL\uFF08expiresAt \u7ED9\u51FA\u771F\u5B9E\u8FC7\u671F\u65F6\u95F4\uFF0C**\u4E0D\u8981**\u628A\u5B83\u5F53\u6C38\u4E45\u94FE\u63A5\u5B58\u5E93\uFF09\u3002
|
|
14402
|
+
*/
|
|
14403
|
+
readonly url: string
|
|
14404
|
+
/** ISO 8601 \u8FC7\u671F\u65F6\u95F4\uFF1Bnull = \u4E0D\u8FC7\u671F\uFF08public \u76F4\u94FE\uFF09\u3002 */
|
|
14405
|
+
readonly expiresAt: string | null
|
|
14406
|
+
}
|
|
14407
|
+
|
|
14408
|
+
/** getSignedUrl \u9009\u9879\u3002 */
|
|
14409
|
+
interface AdepStorageSignedUrlOptions {
|
|
14410
|
+
/**
|
|
14411
|
+
* \u663E\u5F0F\u5141\u8BB8\u8D85\u8FC7 7 \u5929\u4E0A\u9650\u7684\u79C1\u6709\u7B7E\u540D URL\u3002
|
|
14412
|
+
*
|
|
14413
|
+
* \u79C1\u6709\u7B7E\u540D\u94FE\u63A5\u7684\u8BED\u4E49\u662F\u300C\u4E34\u65F6\u8BBF\u95EE\u300D\uFF1A\u8FC7\u671F\u524D\u6CC4\u6F0F\u5373\u957F\u671F\u53EF\u8BFB\u3002\u8D85\u957F TTL \u5FC5\u987B\u663E\u5F0F\u627F\u62C5\u98CE\u9669\uFF1B
|
|
14414
|
+
* \u957F\u671F\u5C55\u793A\u8BF7\u6539\u7528 visibility: 'public' + getUrl()\u3002
|
|
14415
|
+
*/
|
|
14416
|
+
force?: boolean
|
|
14417
|
+
}
|
|
14418
|
+
|
|
13753
14419
|
/** \u4E0A\u4F20 / \u5217\u4E3E\u8FD4\u56DE\u7684\u6587\u4EF6\u5143\u6570\u636E\uFF08\u4E0D\u542B\u5185\u5BB9\uFF09\u3002 */
|
|
13754
14420
|
interface AdepStoredFile {
|
|
13755
14421
|
/** \u6876\u5185\u76F8\u5BF9\u8DEF\u5F84\uFF0C\u5982 avatars/avatar.png\u3002 */
|
|
13756
|
-
path: string
|
|
13757
|
-
size: number
|
|
13758
|
-
contentType?: string
|
|
13759
|
-
visibility: AdepFileVisibility
|
|
14422
|
+
readonly path: string
|
|
14423
|
+
readonly size: number
|
|
14424
|
+
readonly contentType?: string
|
|
14425
|
+
readonly visibility: AdepFileVisibility
|
|
13760
14426
|
/** ISO 8601 \u65F6\u95F4\u6233\u3002 */
|
|
13761
|
-
updatedAt?: string
|
|
14427
|
+
readonly updatedAt?: string
|
|
13762
14428
|
}
|
|
13763
14429
|
|
|
13764
14430
|
interface AdepCloudStorage {
|
|
13765
|
-
/**
|
|
13766
|
-
|
|
14431
|
+
/**
|
|
14432
|
+
* \u4E0A\u4F20 / \u8986\u76D6\u6587\u4EF6\uFF1B\u8DEF\u5F84\u975E\u6CD5\uFF08\u7A7F\u8D8A\u3001\u8D85\u9650\uFF09\u7531\u5B9E\u73B0\u629B\u9519\u3002
|
|
14433
|
+
* options.contentType\uFF1A\u53EF\u9009 MIME\uFF08R2 \u8FC1\u79FB\u7ECF httpMetadata \u6620\u5C04\uFF1B\u9A71\u52A8\u4FA7\u6301\u4E45\u5316\uFF09\u3002
|
|
14434
|
+
* options.visibility\uFF1A\u7F3A\u7701 private\uFF1Bpublic \u624D\u80FD\u7528 getUrl \u62FF\u4E0D\u8FC7\u671F\u7684\u7A33\u5B9A\u76F4\u94FE\u3002
|
|
14435
|
+
*/
|
|
14436
|
+
upload(
|
|
14437
|
+
path: string,
|
|
14438
|
+
data: AdepStorageUploadData,
|
|
14439
|
+
options?: AdepStorageUploadOptions
|
|
14440
|
+
): Promise<AdepStoredFile>
|
|
13767
14441
|
/** \u8BFB\u53D6\u6587\u4EF6\u5185\u5BB9\uFF1B\u4E0D\u5B58\u5728\u65F6\u629B STORAGE_NOT_FOUND\u3002 */
|
|
13768
14442
|
get(path: string): Promise<Uint8Array>
|
|
13769
14443
|
/** \u5220\u9664\u6587\u4EF6\uFF1B\u4E0D\u5B58\u5728\u65F6\u629B STORAGE_NOT_FOUND\u3002 */
|
|
13770
14444
|
remove(path: string): Promise<void>
|
|
13771
14445
|
/** \u6309\u524D\u7F00\u5217\u4E3E\uFF08\u7F3A\u7701\u5168\u6876\uFF09\u3002 */
|
|
13772
14446
|
list(prefix?: string): Promise<AdepStoredFile[]>
|
|
13773
|
-
/**
|
|
13774
|
-
|
|
14447
|
+
/**
|
|
14448
|
+
* \u7A33\u5B9A\u8BBF\u95EE\u5730\u5740\uFF08\u4E0E SDK \u901A\u9053 getFileUrl \u540C\u8BED\u4E49\uFF09\uFF1A
|
|
14449
|
+
* public \u2192 \u65E0\u7B7E\u540D\u3001\u4E0D\u8FC7\u671F\uFF1Bprivate \u2192 \u5E26\u7B7E\u540D\u5E76\u7ED9\u51FA expiresAt\uFF08\u663E\u5F0F\u533A\u5206\uFF0C\u4E0D\u8FD4\u56DE\u4F1A 403 \u7684\u88F8\u94FE\u63A5\uFF09\u3002
|
|
14450
|
+
*/
|
|
14451
|
+
getUrl(path: string): Promise<AdepStorageFileUrl>
|
|
14452
|
+
/** \u751F\u6210\u7B7E\u540D URL\uFF08private \u6587\u4EF6\u7684\u5916\u53D1\u901A\u9053\uFF09\uFF1B\u7F3A\u7701 TTL \u7531\u5B9E\u73B0\u5B9A\uFF08M1\uFF1A15 \u5206\u949F\uFF09\uFF0C\u4E0A\u9650 7 \u5929\u3002 */
|
|
14453
|
+
getSignedUrl(
|
|
14454
|
+
path: string,
|
|
14455
|
+
ttlSeconds?: number,
|
|
14456
|
+
options?: AdepStorageSignedUrlOptions
|
|
14457
|
+
): Promise<string>
|
|
14458
|
+
}
|
|
14459
|
+
|
|
14460
|
+
/* ---------- KV \u5B58\u50A8\uFF08CloudKv \u955C\u50CF\uFF09 ---------- */
|
|
14461
|
+
|
|
14462
|
+
/**
|
|
14463
|
+
* cloud.kv \u5951\u7EA6\uFF08ADR-0024 / CF-012\uFF09\uFF1A\u9879\u76EE\u7EA7 KV \u5B58\u50A8\u80FD\u529B\u3002
|
|
14464
|
+
*
|
|
14465
|
+
* \u5B9A\u4F4D\uFF1AWorkers KV \u7684 adep \u539F\u751F\u5BF9\u5E94\u7269\u2014\u2014@adep/cf-compat \u7684 KVNamespace shim
|
|
14466
|
+
* \u5728\u5176\u4E0A\u63D0\u4F9B Workers \u98CE\u683C API\uFF08text/json/arrayBuffer\u3001TTL\u3001list\uFF09\u3002\u539F\u751F\u51FD\u6570\u4E5F\u53EF
|
|
14467
|
+
* \u76F4\u63A5 cloud.kv \u4F7F\u7528\u3002
|
|
14468
|
+
*
|
|
14469
|
+
* \u5951\u7EA6\u8981\u70B9\uFF1A
|
|
14470
|
+
* - \u503C\u4E3A string\uFF08\u4E8C\u8FDB\u5236\u7531 shim \u5C42 base64 \u7F16\u89E3\u7801\u540E\u5B58\u53D6\uFF0C\u80FD\u529B\u672C\u4F53\u4FDD\u6301\u7B80\u5355\uFF09\uFF1B
|
|
14471
|
+
* - TTL \u4EE5\u300C\u79D2\u300D\u4E3A\u5355\u4F4D\uFF08Workers expirationTtl \u540C\u8BED\u4E49\uFF09\uFF1B\u672A\u8BBE TTL \u6C38\u4E0D\u8FC7\u671F\uFF1B
|
|
14472
|
+
* - list \u8FD4\u56DE\u952E + \u8FC7\u671F\u65F6\u95F4\uFF08unix \u79D2\uFF09\uFF0Cprefix \u8FC7\u6EE4\u5728\u5B9E\u73B0\u5185\u5B8C\u6210\uFF1B
|
|
14473
|
+
* - \u5B9E\u73B0\u843D\u70B9\uFF1A\u9879\u76EE\u5E93 _adep_kv \u4FDD\u7559\u8868\uFF08_ \u5E73\u53F0\u4FDD\u7559\u6BB5\uFF0C\u63A7\u5236\u53F0/db.list_tables
|
|
14474
|
+
* \u81EA\u52A8\u6392\u9664\uFF09\uFF0CSQL \u4E25\u683C\u4FDD\u6301\u5728 sim \u5F15\u64CE\u5B50\u96C6\u5185\uFF08CF-012\uFF09\u3002
|
|
14475
|
+
*/
|
|
14476
|
+
interface AdepCloudKvEntry {
|
|
14477
|
+
/** \u952E\u540D\u3002 */
|
|
14478
|
+
readonly name: string
|
|
14479
|
+
/** \u8FC7\u671F\u65F6\u95F4\uFF08unix \u79D2\uFF09\uFF1Bnull = \u6C38\u4E0D\u8FC7\u671F\u3002 */
|
|
14480
|
+
readonly expiration: number | null
|
|
14481
|
+
}
|
|
14482
|
+
|
|
14483
|
+
interface AdepCloudKvListOptions {
|
|
14484
|
+
/** \u524D\u7F00\u8FC7\u6EE4\u3002 */
|
|
14485
|
+
readonly prefix?: string
|
|
14486
|
+
/** \u8FD4\u56DE\u6761\u6570\u4E0A\u9650\uFF08\u7F3A\u7701\u5B9E\u73B0\u9ED8\u8BA4\uFF0C\u5982 100\uFF09\u3002 */
|
|
14487
|
+
readonly limit?: number
|
|
14488
|
+
}
|
|
14489
|
+
|
|
14490
|
+
interface AdepCloudKv {
|
|
14491
|
+
/** \u8BFB\u952E\uFF1B\u4E0D\u5B58\u5728\u6216\u5DF2\u8FC7\u671F\u8FD4\u56DE null\u3002 */
|
|
14492
|
+
get(key: string): Promise<string | null>
|
|
14493
|
+
/**
|
|
14494
|
+
* \u5199\u952E\uFF1BexpirationTtlSeconds \u4E3A\u5B58\u6D3B\u79D2\u6570\uFF08\u5230\u671F\u540E\u8BFB\u53D6\u8FD4\u56DE null\uFF09\u3002
|
|
14495
|
+
* \u8986\u76D6\u5199\u4E0D\u62A5\u9519\uFF08Workers KV \u540C\u8BED\u4E49\uFF09\u3002
|
|
14496
|
+
*/
|
|
14497
|
+
put(
|
|
14498
|
+
key: string,
|
|
14499
|
+
value: string,
|
|
14500
|
+
options?: { readonly expirationTtlSeconds?: number }
|
|
14501
|
+
): Promise<void>
|
|
14502
|
+
/** \u5220\u952E\uFF1B\u4E0D\u5B58\u5728\u4E0D\u62A5\u9519\uFF08\u5E42\u7B49\uFF09\u3002 */
|
|
14503
|
+
delete(key: string): Promise<void>
|
|
14504
|
+
/** \u6309\u524D\u7F00\u5217\u4E3E\u952E\uFF08\u672A\u8FC7\u671F\u7684\uFF09\uFF1B\u987A\u5E8F\u4E0E\u5206\u9875\u7531\u5B9E\u73B0\u5B9A\u4E49\u3002 */
|
|
14505
|
+
list(options?: AdepCloudKvListOptions): Promise<AdepCloudKvEntry[]>
|
|
13775
14506
|
}
|
|
13776
14507
|
|
|
13777
14508
|
/* ---------- \u6570\u636E\u5E93\uFF08CloudDb \u955C\u50CF\uFF09 ---------- */
|
|
@@ -13816,14 +14547,16 @@ interface AdepChangeQuery {
|
|
|
13816
14547
|
}
|
|
13817
14548
|
|
|
13818
14549
|
/**
|
|
13819
|
-
* \u5355\u8868\u94FE\u5F0F Builder\u3002\u6240\u6709\u94FE\u5F0F\u65B9\u6CD5\u8FD4\u56DE\u65B0 Builder\uFF08\u4E0D\u53EF\u53D8\uFF09\uFF0C\u7EC8\u503C\u65B9\u6CD5
|
|
13820
|
-
* \
|
|
13821
|
-
* \u5B9E\u4F8B\u6D3E\u751F\u591A\u4E2A\u67E5\u8BE2\u662F\u5B89\u5168\u7684\uFF08\u5B9E\u73B0\u4E0D\u5F97\u6709\u5171\u4EAB\u53EF\u53D8\u72B6\u6001\uFF09\u3002
|
|
14550
|
+
* \u5355\u8868\u94FE\u5F0F Builder\u3002\u6240\u6709\u94FE\u5F0F\u65B9\u6CD5\u8FD4\u56DE\u65B0 Builder\uFF08\u4E0D\u53EF\u53D8\uFF09\uFF0C\u7EC8\u503C\u65B9\u6CD5\uFF08get/first/count/insert/update/delete\uFF09
|
|
14551
|
+
* \u8FD4\u56DE Promise\u3002\u590D\u7528\u540C\u4E00 Builder \u5B9E\u4F8B\u6D3E\u751F\u591A\u4E2A\u67E5\u8BE2\u662F\u5B89\u5168\u7684\uFF08\u5B9E\u73B0\u4E0D\u5F97\u6709\u5171\u4EAB\u53EF\u53D8\u72B6\u6001\uFF09\u3002
|
|
13822
14552
|
*/
|
|
13823
14553
|
interface AdepCloudDbTable {
|
|
13824
14554
|
/** \u9650\u5B9A\u8FD4\u56DE\u5217\uFF1B\u4E0D\u8C03\u5373 select *\u3002 */
|
|
13825
14555
|
select(...columns: string[]): AdepCloudDbTable
|
|
13826
|
-
/**
|
|
14556
|
+
/**
|
|
14557
|
+
* \u58F0\u660E\u4E3A owned \u8868\uFF08DB-006\uFF09\uFF1A\u5199\u5165\u81EA\u52A8\u751F\u6210 ULID \u4E3B\u952E + \u8FFD\u52A0 __changes \u53D8\u66F4\u6D41\u3002
|
|
14558
|
+
* \u8868\u987B\u5DF2\u58F0\u660E owned\uFF08\u5B58\u5728 _adep_changes_<table> \u53D8\u66F4\u6D41\u8868\uFF09\uFF0C\u5426\u5219\u629B DB_UNSAFE_OP\u3002
|
|
14559
|
+
*/
|
|
13827
14560
|
owned(): AdepCloudDbTable
|
|
13828
14561
|
/** \u7B49\u503C\u8FC7\u6EE4\uFF1Awhere('status', 'active')\u3002 */
|
|
13829
14562
|
where(column: string, value: AdepSqlValue): AdepCloudDbTable
|
|
@@ -13842,7 +14575,7 @@ interface AdepCloudDbTable {
|
|
|
13842
14575
|
first(): Promise<AdepRow | null>
|
|
13843
14576
|
/** \u884C\u6570\uFF08\u5FFD\u7565 select/orderBy\uFF09\u3002 */
|
|
13844
14577
|
count(): Promise<number>
|
|
13845
|
-
/** \u63D2\u5165\u4E00\u884C\uFF1Bwhere \u5BF9\u63D2\u5165\u65E0\u610F\u4E49\u3002 */
|
|
14578
|
+
/** \u63D2\u5165\u4E00\u884C\uFF1Bwhere \u5BF9\u63D2\u5165\u65E0\u610F\u4E49\uFF0C\u5B9E\u73B0\u5E94\u5FFD\u7565\u6216\u62D2\u7EDD\u3002 */
|
|
13846
14579
|
insert(row: Record<string, AdepSqlValue>): Promise<void>
|
|
13847
14580
|
/** \u6279\u91CF\u63D2\u5165\u3002 */
|
|
13848
14581
|
insertMany(rows: ReadonlyArray<Record<string, AdepSqlValue>>): Promise<void>
|
|
@@ -13852,15 +14585,38 @@ interface AdepCloudDbTable {
|
|
|
13852
14585
|
delete(): Promise<number>
|
|
13853
14586
|
}
|
|
13854
14587
|
|
|
13855
|
-
/**
|
|
14588
|
+
/**
|
|
14589
|
+
* \u9879\u76EE\u6570\u636E\u5E93\u53E5\u67C4\u3002\u53E5\u67C4\u5FC5\u987B\u95ED\u5305\u5C01\u88C5\uFF1A\u4E0D\u5F97\u66B4\u9732\u8FDE\u63A5\u4E32\u3001schema \u540D\uFF08\xA74.5 \u786C\u89C4\u5219 4\uFF09\u3002
|
|
14590
|
+
*/
|
|
13856
14591
|
interface AdepCloudDb {
|
|
13857
|
-
/** \u6253\u5F00\u5355\u8868 Builder\u3002\u8868\u540D\u7531\u8FD0\u884C\u65F6\u767D\u540D\u5355\u6821\u9A8C\u3002 */
|
|
14592
|
+
/** \u6253\u5F00\u5355\u8868 Builder\u3002\u8868\u540D\u7531\u8FD0\u884C\u65F6\u767D\u540D\u5355\u6821\u9A8C\uFF08^[a-zA-Z_][a-zA-Z0-9_]{0,62}$\uFF09\u3002 */
|
|
13858
14593
|
table(name: string): AdepCloudDbTable
|
|
13859
|
-
/**
|
|
14594
|
+
/**
|
|
14595
|
+
* \u4E8B\u52A1\uFF1Afn \u6536\u5230\u540C\u5F62\u72B6\u7684\u53D7\u63A7\u4E8B\u52A1\u53E5\u67C4\uFF1B\u629B\u9519\u5373\u6574\u4F53\u56DE\u6EDA\u3002
|
|
14596
|
+
* \u4E8B\u52A1\u5185\u7981\u6B62 await \u4E8B\u52A1\u5916\u7684\u672C\u5E93\u64CD\u4F5C\uFF08\u5B9E\u73B0\u53EF\u68C0\u6D4B\u5E76\u62D2\u7EDD\uFF09\u3002
|
|
14597
|
+
*/
|
|
13860
14598
|
transaction<T>(fn: (tx: AdepCloudDb) => Promise<T>): Promise<T>
|
|
13861
14599
|
/** \u53D7\u63A7\u88F8 SQL\uFF1Bparams \u5FC5\u586B\uFF08\u65E0\u53C2\u4F20 []\uFF09\uFF0C\u5355\u8BED\u53E5\uFF0C\u7981\u591A\u8BED\u53E5\u5806\u53E0\u3002 */
|
|
13862
14600
|
query(sql: string, params: readonly AdepSqlValue[]): Promise<AdepRow[]>
|
|
13863
|
-
/**
|
|
14601
|
+
/**
|
|
14602
|
+
* \u53D7\u63A7\u88F8 DML\uFF08ADR-0024 / CF-013\uFF09\uFF1A\u5355\u6761 INSERT / UPDATE / DELETE\uFF0C
|
|
14603
|
+
* \u53C2\u6570\u5316\u7ED1\u5B9A\uFF0C\u8FD4\u56DE\u503C = \u53D7\u5F71\u54CD\u884C\u6570\u3002DDL\uFF08CREATE/DROP/ALTER\uFF09\u62D2\u7EDD\uFF08\u8D70\u63A7\u5236\u53F0\u5BA1\u8BA1\u8DEF\u5F84\uFF09\u3002
|
|
14604
|
+
* \u8FB9\u754C\uFF1A\u672C\u5730\u6A21\u62DF\u5F15\u64CE\u8981\u6C42 UPDATE/DELETE \u5FC5\u987B\u5E26 WHERE\uFF08\u4E0E\u7EBF\u4E0A\u884C\u4E3A\u5206\u53C9\u65F6\u4EE5 sim \u5F15\u64CE
|
|
14605
|
+
* \u7EA6\u675F\u4E3A\u51C6\uFF0CD1 shim \u4E1A\u52A1\u4EE3\u7801\u901A\u5E38\u5929\u7136\u5E26 WHERE\uFF09\u3002
|
|
14606
|
+
*/
|
|
14607
|
+
writeQuery(sql: string, params: readonly AdepSqlValue[]): Promise<{ changes: number }>
|
|
14608
|
+
/**
|
|
14609
|
+
* \u901A\u7528\u6267\u884C\uFF082026-10-14\uFF0CBUG-4\uFF09\uFF1Aquery \u53EA\u8BFB\u3001writeQuery \u4EC5 DML \u7684\u5386\u53F2 split \u8BA9
|
|
14610
|
+
* \u300CDDL \u8BE5\u8D70\u54EA\u300D\u6210\u4E3A\u6A21\u578B\u7684\u5FC5\u9519\u9898\uFF08\u5B9E\u6D4B db.execute \u76F4\u63A5 500\uFF09\u3002execute \u6536\u53E3\u4E3A
|
|
14611
|
+
* \u300Cquery \u222A writeQuery \u222A \u5355\u6761 DDL\u300D\u7684\u7EDF\u4E00\u5165\u53E3\uFF1A\u8BFB\u8BED\u53E5\u8F6C\u53D1 query \u8BED\u4E49\u3001\u5199\u8BED\u53E5\u8F6C\u53D1
|
|
14612
|
+
* writeQuery \u8BED\u4E49\u3001CREATE/ALTER \u7B49\u5355\u6761 DDL \u76F4\u653E\uFF08\u591A\u8BED\u53E5\u4ECD\u7136\u62D2\u7EDD\uFF09\u3002\u8FD4\u56DE\u53D7\u5F71\u54CD\u884C\u6570\uFF1B
|
|
14613
|
+
* SELECT \u7ECF\u5B83\u6267\u884C\u65F6\u8FD4\u56DE 0\uFF08\u8981\u884C\u96C6\u8BF7\u7528 query\uFF09\u3002
|
|
14614
|
+
*/
|
|
14615
|
+
execute(sql: string, params?: readonly AdepSqlValue[]): Promise<{ changes: number }>
|
|
14616
|
+
/**
|
|
14617
|
+
* \u8BFB\u53D6 owned \u8868 __changes \u53D8\u66F4\u6D41\uFF08\u6309 seq \u5347\u5E8F\uFF0C\u53EF\u91CD\u653E\uFF09\u3002\u8868\u975E owned \u2192 DB_UNSAFE_OP\u3002
|
|
14618
|
+
* afterSeq / ownerKey / limit \u8FC7\u6EE4\u6761\u4EF6\u53C2\u6570\u5316\u7ED1\u5B9A\u3002
|
|
14619
|
+
*/
|
|
13864
14620
|
changes(table: string, query?: AdepChangeQuery): Promise<AdepChangeRecord[]>
|
|
13865
14621
|
}
|
|
13866
14622
|
|
|
@@ -13891,9 +14647,12 @@ interface AdepCloudFetchResponse {
|
|
|
13891
14647
|
/** cloud.fetch\uFF1A\u53D7\u63A7\u7684 HTTPS \u8BF7\u6C42\u3002URL \u4E3B\u673A\u4E0D\u5728\u767D\u540D\u5355\u5219\u629B FN_FETCH_FORBIDDEN\u3002 */
|
|
13892
14648
|
type AdepCloudFetch = (url: string, init?: AdepCloudFetchInit) => Promise<AdepCloudFetchResponse>
|
|
13893
14649
|
|
|
13894
|
-
/* ---------- \u5B9E\u65F6\u901A\u9053\uFF08CloudRealtime \u955C\u50CF\uFF09 ---------- */
|
|
14650
|
+
/* ---------- \u5B9E\u65F6\u901A\u9053\uFF08CloudRealtime \u955C\u50CF\uFF0CFN-020\uFF09 ---------- */
|
|
13895
14651
|
|
|
13896
|
-
/**
|
|
14652
|
+
/**
|
|
14653
|
+
* \u4E00\u6761\u5DF2\u6295\u9012\u7684 channel \u6D88\u606F\uFF08RT-003 \u7684\u6D3E\u53D1\u961F\u5217\u8F93\u51FA\uFF09\u3002
|
|
14654
|
+
* seq \u4E3A\u670D\u52A1\u7AEF\u5728\u8BE5 channel \u5185\u7684\u5355\u8C03\u9012\u589E\u5E8F\u53F7\uFF08PRD \xA73.2.9 \u6BCF channel \u4E32\u884C\u4FDD\u5E8F\uFF09\u3002
|
|
14655
|
+
*/
|
|
13897
14656
|
interface AdepRealtimeChannelMessage {
|
|
13898
14657
|
channel: string
|
|
13899
14658
|
seq: number
|
|
@@ -13907,37 +14666,60 @@ interface AdepCloudRealtimeReceipt {
|
|
|
13907
14666
|
delivered: number
|
|
13908
14667
|
}
|
|
13909
14668
|
|
|
13910
|
-
/** subscribe \u56DE\u6267\uFF1Asubscription \u662F\u540E\u7EED receive / unsubscribe \u7684\u53E5\u67C4\u3002 */
|
|
14669
|
+
/** subscribe \u56DE\u6267\uFF1Asubscription \u662F\u540E\u7EED receive / unsubscribe \u7684\u53E5\u67C4\uFF08\u4E0D\u900F\u660E\u5B57\u7B26\u4E32\uFF09\u3002 */
|
|
13911
14670
|
interface AdepCloudRealtimeSubscription {
|
|
13912
14671
|
subscription: string
|
|
13913
14672
|
channel: string
|
|
13914
14673
|
}
|
|
13915
14674
|
|
|
13916
|
-
/**
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
|
|
14675
|
+
/** \u9000\u8BA2\u56DE\u6267\uFF08\u4E0E\u672C\u5730 sim \u540C\u5F62\uFF1A\u53EA\u62A5\u300C\u5DF2\u79FB\u9664\u300D\uFF0C\u4E0D\u62A5\u5269\u4F59\u7F13\u51B2\u91CF\uFF09\u3002 */
|
|
14676
|
+
interface AdepCloudRealtimeUnsubscribeReceipt {
|
|
14677
|
+
removed: true
|
|
14678
|
+
}
|
|
14679
|
+
|
|
14680
|
+
/** \u51FD\u6570\u5185\u53EF\u7528\u7684\u5B9E\u65F6\u901A\u9053\u80FD\u529B\uFF08PRD \xA72.12 / \xA72.14.2\uFF09\u3002 */
|
|
13920
14681
|
interface AdepCloudRealtime {
|
|
13921
|
-
/**
|
|
14682
|
+
/**
|
|
14683
|
+
* \u5411 channel \u6295\u9012\u4E00\u6761\u6D88\u606F\uFF08\u540C\u6B65\u8BED\u4E49\uFF1A\u4E0D\u7B49\u8BA2\u9605\u8005\u786E\u8BA4\uFF0C\xA72.12.3\uFF09\u3002
|
|
14684
|
+
* except \u4E3A\u300C\u4E0D\u56DE\u53D1\u7ED9\u8BE5\u8FDE\u63A5\u300D\u7684\u8FDE\u63A5\u6807\u8BC6\u2014\u2014**\u7EBF\u4E0A\u652F\u6301\u3001\u672C\u5730 fail loud**
|
|
14685
|
+
* \uFF08\u5355\u8FDB\u7A0B\u5185\u5B58\u5E7F\u64AD\u6CA1\u6709\u8FDE\u63A5\u8EAB\u4EFD\u53EF\u6BD4\u8F83\uFF0C\u89C1 sim/boundary.ts\uFF09\u3002
|
|
14686
|
+
*/
|
|
13922
14687
|
publish(channel: string, data: unknown, except?: string): Promise<AdepCloudRealtimeReceipt>
|
|
14688
|
+
/** \u8BA2\u9605 channel\uFF0C\u53D6\u5F97\u4E00\u4E2A\u8F6E\u8BE2\u53E5\u67C4\uFF1B\u547D\u4E2D\u672C\u8BA2\u9605\u7684\u6D88\u606F\u7559\u5728\u5BBF\u4E3B\u7F13\u51B2\u3002 */
|
|
13923
14689
|
subscribe(channel: string): Promise<AdepCloudRealtimeSubscription>
|
|
14690
|
+
/** \u53D6\u56DE\u5E76\u6E05\u7A7A\u8BE5\u53E5\u67C4\u7684\u7F13\u51B2\uFF08\u975E\u963B\u585E\uFF1B\u65E0\u6D88\u606F\u8FD4\u56DE\u7A7A\u6570\u7EC4\uFF09\u3002 */
|
|
13924
14691
|
receive(subscription: string): Promise<AdepRealtimeChannelMessage[]>
|
|
13925
|
-
|
|
14692
|
+
/** \u9000\u8BA2\u5E76\u4E22\u5F03\u7F13\u51B2\u3002 */
|
|
14693
|
+
unsubscribe(subscription: string): Promise<AdepCloudRealtimeUnsubscribeReceipt>
|
|
13926
14694
|
}
|
|
13927
14695
|
|
|
13928
14696
|
/* ---------- \u80FD\u529B\u6302\u8F7D\u70B9\uFF08Cloud / CapabilityRegistry \u955C\u50CF\uFF09 ---------- */
|
|
13929
14697
|
|
|
13930
|
-
/** \u5DF2\u6CE8\u518C\u80FD\u529B\u540D \u2192 \u5B9E\u73B0\u5951\u7EA6\u7684\u6620\u5C04\
|
|
14698
|
+
/** \u5DF2\u6CE8\u518C\u80FD\u529B\u540D \u2192 \u5B9E\u73B0\u5951\u7EA6\u7684\u6620\u5C04\uFF08\u80FD\u529B\u540D\u7684\u552F\u4E00\u767B\u8BB0\u5904\uFF0C\u89C4\u8303 \xA74.5\uFF09\u3002 */
|
|
13931
14699
|
interface AdepCapabilityRegistry {
|
|
13932
14700
|
db: AdepCloudDb
|
|
13933
14701
|
storage: AdepCloudStorage
|
|
13934
|
-
/**
|
|
13935
|
-
|
|
13936
|
-
|
|
14702
|
+
/**
|
|
14703
|
+
* \u5B9E\u65F6\u901A\u9053\uFF08FN-020\uFF09\uFF1A\u9879\u76EE\u88C5\u914D\u4E86 realtime \u57DF\u5373\u6CE8\u5165\uFF1B\u65B9\u6CD5\u9762\u4E0E\u672C\u5730 sim \u540C\u6E90
|
|
14704
|
+
* \uFF08\u5951\u7EA6\u89C1 cloud-realtime.ts \u7684\u8F6E\u8BE2\u8BED\u4E49\u8B66\u793A\uFF09\u3002
|
|
14705
|
+
*/
|
|
13937
14706
|
realtime: AdepCloudRealtime
|
|
14707
|
+
/**
|
|
14708
|
+
* \u6C99\u7BB1\u53D7\u63A7\u7F51\u7EDC\uFF08GAME-007\uFF09\uFF1A\u672A\u914D\u7F6E FUNCTIONS_FETCH_ALLOWLIST \u65F6\u4E0D\u6CE8\u5165\uFF08\u65E0\u7F51\u7EDC\u5B89\u5168\u9ED8\u8BA4\uFF09\u3002
|
|
14709
|
+
* \u6CE8\u5165\u65F6\u4EC5\u53EF\u8BBF\u95EE\u767D\u540D\u5355\u4E3B\u673A\uFF0C\u53D7\u8D85\u65F6\u4E0E\u54CD\u5E94\u4F53\u4E0A\u9650\u7EA6\u675F\u3002
|
|
14710
|
+
*/
|
|
14711
|
+
fetch: AdepCloudFetch
|
|
14712
|
+
/**
|
|
14713
|
+
* \u9879\u76EE\u7EA7 KV \u5B58\u50A8\uFF08ADR-0024 / CF-012\uFF09\uFF1Abacked by \u9879\u76EE\u5E93 _adep_kv \u4FDD\u7559\u8868\uFF1B
|
|
14714
|
+
* @adep/cf-compat \u7684 KVNamespace shim \u5728\u5176\u4E0A\u63D0\u4F9B Workers \u98CE\u683C API\u3002
|
|
14715
|
+
*/
|
|
14716
|
+
kv: AdepCloudKv
|
|
13938
14717
|
}
|
|
13939
14718
|
|
|
13940
|
-
/**
|
|
14719
|
+
/**
|
|
14720
|
+
* \u7528\u6237\u51FD\u6570\u4FA7\u7684 ctx.cloud\uFF1A\u53EA\u80FD**\u8BBF\u95EE**\u80FD\u529B\uFF0C\u4E0D\u80FD\u6CE8\u518C/\u6CE8\u9500\uFF08\u90A3\u662F Provider/Consumer \u7684\u7279\u6743\uFF09\u3002
|
|
14721
|
+
* \u5DF2\u77E5\u80FD\u529B\u6709\u7CBE\u786E\u7C7B\u578B\u8865\u5168\uFF1B\u81EA\u5B9A\u4E49\u80FD\u529B\u7ECF\u7D22\u5F15\u7B7E\u540D\u8BBF\u95EE\uFF08\u8FD0\u884C\u65F6\u672A\u6CE8\u518C\u5373\u629B\u9519\uFF09\u3002
|
|
14722
|
+
*/
|
|
13941
14723
|
type AdepCloud = {
|
|
13942
14724
|
readonly [K in keyof AdepCapabilityRegistry]: AdepCapabilityRegistry[K]
|
|
13943
14725
|
} & {
|
|
@@ -13947,7 +14729,11 @@ type AdepCloud = {
|
|
|
13947
14729
|
|
|
13948
14730
|
/* ---------- \u8C03\u7528\u8005\u8EAB\u4EFD\uFF08ExecutorUser \u955C\u50CF\uFF09 ---------- */
|
|
13949
14731
|
|
|
13950
|
-
/**
|
|
14732
|
+
/**
|
|
14733
|
+
* \u6267\u884C\u8005\u8EAB\u4EFD\u6295\u5F71\uFF08FN-010 auth-in-function\uFF09\uFF1A\u7F51\u5173\u89E3\u6790\u4F1A\u8BDD\u540E\u6CE8\u5165\u8C03\u7528\u8005\u8EAB\u4EFD\u3002
|
|
14734
|
+
* \u7F3A\u7701 / \u533F\u540D / \u672A\u63A5\u89E3\u6790\u5668\u65F6\uFF0CExecutorRequest.user \u4E3A null\u2014\u2014
|
|
14735
|
+
* \u8EAB\u4EFD\u662F**\u900F\u4F20\u4FE1\u606F**\uFF08\u4F9B\u51FD\u6570\u81EA\u884C\u505A\u6743\u9650\u5224\u65AD\uFF09\uFF0C\u4E0D\u662F\u5F3A\u5236\u95E8\uFF0C\u7F3A\u8EAB\u4EFD\u4E0D\u963B\u585E\u6267\u884C\u3002
|
|
14736
|
+
*/
|
|
13951
14737
|
interface AdepExecutorUser {
|
|
13952
14738
|
/** \u5E73\u53F0\u7528\u6237 id\uFF08= better-auth session.user.id\uFF09\u3002 */
|
|
13953
14739
|
id: string
|
|
@@ -13966,19 +14752,30 @@ interface AdepContext {
|
|
|
13966
14752
|
readonly query: Readonly<Record<string, string | readonly string[]>>
|
|
13967
14753
|
/** \u8BF7\u6C42\u5934\uFF08\u952E\u4E3A\u5C0F\u5199\uFF09\u3002 */
|
|
13968
14754
|
readonly headers: Readonly<Record<string, string>>
|
|
13969
|
-
/** \u8BF7\u6C42\u4F53\uFF1B\u5F62\u72B6\u7531\u7528\u6237\u7528\u7C7B\u578B\u65AD\u8A00\u6536\u7A84\
|
|
14755
|
+
/** \u8BF7\u6C42\u4F53\uFF1B\u5F62\u72B6\u7531\u7528\u6237\u7528\u7C7B\u578B\u65AD\u8A00\u6536\u7A84\uFF08PRD \xA72.1.3 \u793A\u4F8B\u5373 ctx.body as {...}\uFF09\u3002 */
|
|
13970
14756
|
readonly body: unknown
|
|
13971
14757
|
/** multipart \u4E0A\u4F20\u7684\u6587\u4EF6\uFF08\u65E0\u6587\u4EF6\u65F6\u4E3A\u7A7A\u6570\u7EC4\uFF09\u3002 */
|
|
13972
14758
|
readonly files: readonly AdepFunctionFile[]
|
|
13973
|
-
/** \u5E73\u53F0\u80FD\u529B\u6302\u8F7D\u70B9\uFF1Acloud.db / cloud.storage
|
|
14759
|
+
/** \u5E73\u53F0\u80FD\u529B\u6302\u8F7D\u70B9\uFF1Acloud.db / cloud.storage\uFF08M3 \u8D77 cloud.realtime\uFF09\u3002 */
|
|
13974
14760
|
readonly cloud: AdepCloud
|
|
13975
|
-
/**
|
|
14761
|
+
/**
|
|
14762
|
+
* \u51FD\u6570\u73AF\u5883\u53D8\u91CF\uFF08CF-015\uFF09\uFF1A\u90E8\u7F72/\u672C\u5730\u6CE8\u5165\u7684\u9879\u76EE\u73AF\u5883\uFF08wrangler vars \u8FC1\u79FB\u4EA7\u7269\uFF09\u3002
|
|
14763
|
+
* \u4F9B @adep/cf-compat \u7684 cfEnv \u7EC4\u88C5 Workers \u98CE\u683C env\uFF08cf-compat \u7ECF\u771F\u5B9E\u6A21\u5757\u7CFB\u7EDF\u52A0\u8F7D\uFF0C
|
|
14764
|
+
* \u8BFB\u4E0D\u5230 vm \u6C99\u7BB1\u7684 process.env\uFF0C\u6545\u7ECF ctx \u900F\u4F20\uFF09\uFF1B\u7F3A\u7701 undefined\uFF08\u672A\u914D\u7F6E\uFF09\u3002
|
|
14765
|
+
*/
|
|
14766
|
+
readonly env?: Readonly<Record<string, string>>
|
|
14767
|
+
/**
|
|
14768
|
+
* \u8C03\u7528\u8005\u8EAB\u4EFD\u6295\u5F71\uFF08FN-010\uFF09\uFF1A\u7F51\u5173\u89E3\u6790\u4F1A\u8BDD\u540E\u6CE8\u5165\uFF1Bnull = \u533F\u540D / \u672A\u6CE8\u5165\u3002
|
|
14769
|
+
* \u51FD\u6570\u636E\u6B64\u81EA\u884C\u505A\u6210\u5458 / \u6743\u9650\u5224\u65AD\uFF08\u8EAB\u4EFD\u662F\u900F\u4F20\u4FE1\u606F\uFF0C\u4E0D\u662F\u5F3A\u5236\u95E8\uFF09\u3002
|
|
14770
|
+
*/
|
|
13976
14771
|
readonly user: AdepExecutorUser | null
|
|
13977
14772
|
}
|
|
13978
14773
|
|
|
13979
14774
|
/** \u5168\u5C40\u5F00\u53D1\u671F\u4E0A\u4E0B\u6587\uFF08\u7F16\u8F91\u5668\u8865\u5168\u7528\uFF1B\u51FD\u6570\u8FD0\u884C\u671F\u7ECF\u53C2\u6570\u6CE8\u5165\uFF0C\u4E0D\u8BFB\u53D6\u5168\u5C40\uFF09\u3002 */
|
|
13980
14775
|
declare const ctx: AdepContext
|
|
13981
14776
|
`;
|
|
14777
|
+
|
|
14778
|
+
// shared/sdk/adep-env.ts
|
|
13982
14779
|
var ADEP_TSCONFIG_JSON = `{
|
|
13983
14780
|
"compilerOptions": {
|
|
13984
14781
|
"target": "ES2021",
|
|
@@ -14394,6 +15191,14 @@ AgentDeploy \u5168\u6808\u9879\u76EE\uFF08\u6A21\u677F\uFF1A${template}\uFF09\u3
|
|
|
14394
15191
|
- \`pnpm deploy\`\uFF08= \`adep publish --only functions\`\uFF09\uFF1A\u589E\u91CF\u90E8\u7F72\u4E91\u51FD\u6570\uFF08\u5BF9\u6BD4\u8FDC\u7AEF\u54C8\u5E0C \u2192 \u4EC5\u4E0A\u4F20\u53D8\u66F4 \u2192 \u53D1\u5E03 \u2192 \u8F93\u51FA\u8BBF\u95EE\u57DF\u540D\uFF09
|
|
14395
15192
|
- \`pnpm doctor\`\uFF08= \`adep doctor\`\uFF09\uFF1A\u672C\u5730\u73AF\u5883\u79BB\u7EBF\u8BCA\u65AD
|
|
14396
15193
|
|
|
15194
|
+
## pnpm \u4E0E\u4F9D\u8D56\u6784\u5EFA\u811A\u672C\uFF08pnpm 10 \u8D77\u9ED8\u8BA4\u4E0D\u8DD1\uFF09
|
|
15195
|
+
|
|
15196
|
+
\u9879\u76EE\u6839\u7684 \`pnpm-workspace.yaml\` \u5DF2\u653E\u884C \`esbuild\` \u7684\u6784\u5EFA\u811A\u672C\uFF08\`onlyBuiltDependencies\` \u4E0E
|
|
15197
|
+
\`allowBuilds\` \u53CC\u5199\uFF1Apnpm 10 \u8BFB\u524D\u8005\uFF0Cpnpm 11+ \u8BFB\u540E\u8005\uFF09\u3002pnpm 10 \u8D77**\u9ED8\u8BA4\u4E0D\u6267\u884C\u4F9D\u8D56\u7684
|
|
15198
|
+
\u6784\u5EFA\u811A\u672C**\uFF0C\u5220\u6389\u8FD9\u4EFD\u914D\u7F6E\u540E \`pnpm install\` \u4F1A\u4EE5 \`ERR_PNPM_IGNORED_BUILDS\` \u62A5\u9519
|
|
15199
|
+
\uFF08vite \u4F9D\u8D56\u7684 esbuild \u539F\u751F\u4E8C\u8FDB\u5236\u6CA1\u51C6\u5907\u597D\uFF0C\u6784\u5EFA\u53EF\u80FD\u5931\u8D25\uFF09\u3002\u4ECD\u7528 pnpm 9 \u65F6\u7B49\u4EF7\u5199\u6CD5\u662F\u5728
|
|
15200
|
+
\`package.json\` \u91CC\u5199 \`"pnpm": { "onlyBuiltDependencies": ["esbuild"] }\`\u3002
|
|
15201
|
+
|
|
14397
15202
|
${DOCKER_README_SECTION()}
|
|
14398
15203
|
|
|
14399
15204
|
## \u76EE\u5F55\u7ED3\u6784
|
|
@@ -14534,6 +15339,19 @@ export default defineConfig({
|
|
|
14534
15339
|
})
|
|
14535
15340
|
`;
|
|
14536
15341
|
var GITIGNORE = "node_modules/\ndata/\n.adep/\nsite/\n";
|
|
15342
|
+
var PNPM_WORKSPACE_YAML = `# pnpm \u914D\u7F6E\uFF08pnpm 10 \u8D77\u4ECE\u8FD9\u91CC\u8BFB\u53D6\uFF1Bpackage.json \u7684 pnpm \u5B57\u6BB5\u53EA\u5BF9 pnpm 9 \u53CA\u66F4\u65E9\u751F\u6548\uFF09
|
|
15343
|
+
#
|
|
15344
|
+
# pnpm 10+ \u9ED8\u8BA4\u4E0D\u6267\u884C\u4F9D\u8D56\u7684\u6784\u5EFA\u811A\u672C\uFF08\u4F9B\u5E94\u94FE\u5B89\u5168\u9ED8\u8BA4\uFF09\u3002esbuild \u662F vite / @adep/cli \u7684
|
|
15345
|
+
# \u4F20\u9012\u4F9D\u8D56\uFF0C\u9700\u8981\u51C6\u5907\u539F\u751F\u4E8C\u8FDB\u5236\uFF1B\u4E0D\u653E\u884C\u4F1A\u5728 pnpm install \u672B\u5C3E\u62A5
|
|
15346
|
+
# Error: ERR_PNPM_IGNORED_BUILDS ... Ignored build scripts: esbuild
|
|
15347
|
+
# pnpm 10 \u8BFB onlyBuiltDependencies\uFF0Cpnpm 11+ \u6539\u540D\u4E3A allowBuilds\uFF08\u65E7\u952E\u88AB\u9759\u9ED8\u5FFD\u7565\uFF09\uFF0C
|
|
15348
|
+
# \u4E24\u4EFD\u5E76\u5199\u4EE5\u540C\u65F6\u8986\u76D6\u4E24\u4E2A major\u3002
|
|
15349
|
+
onlyBuiltDependencies:
|
|
15350
|
+
- esbuild
|
|
15351
|
+
|
|
15352
|
+
allowBuilds:
|
|
15353
|
+
esbuild: true
|
|
15354
|
+
`;
|
|
14537
15355
|
var SHARED_ASSETS = {
|
|
14538
15356
|
packageJson: (ctx) => [
|
|
14539
15357
|
{
|
|
@@ -14563,7 +15381,8 @@ var SHARED_ASSETS = {
|
|
|
14563
15381
|
viteConfig: () => [{ path: "vite.config.ts", content: VITE_CONFIG }],
|
|
14564
15382
|
indexHtml: () => [{ path: "index.html", content: INDEX_HTML }],
|
|
14565
15383
|
gitignore: () => [{ path: ".gitignore", content: GITIGNORE }],
|
|
14566
|
-
dockerAssets: (ctx) => DOCKER_ASSETS(ctx.name)
|
|
15384
|
+
dockerAssets: (ctx) => DOCKER_ASSETS(ctx.name),
|
|
15385
|
+
pnpmWorkspace: () => [{ path: "pnpm-workspace.yaml", content: PNPM_WORKSPACE_YAML }]
|
|
14567
15386
|
};
|
|
14568
15387
|
|
|
14569
15388
|
// packages/cli/src/templates/template-render.ts
|
|
@@ -38555,7 +39374,7 @@ function registerImport(program2, ctx) {
|
|
|
38555
39374
|
|
|
38556
39375
|
// packages/cli/src/commands/dev.ts
|
|
38557
39376
|
function registerDevServers(program2, ctx) {
|
|
38558
|
-
program2.command("dev").description("\u672C\u5730\u8C03\u8BD5\uFF1A\u76D1\u542C functions/ \u70ED\u91CD\u8F7D\uFF0Chttp://localhost:<port>/<fnName>").option("-p, --port <port>", "\u76D1\u542C\u7AEF\u53E3\uFF08\u7F3A\u7701 8787\uFF09"
|
|
39377
|
+
program2.command("dev").description("\u672C\u5730\u8C03\u8BD5\uFF1A\u76D1\u542C functions/ \u70ED\u91CD\u8F7D\uFF0Chttp://localhost:<port>/<fnName>").option("-p, --port <port>", "\u76D1\u542C\u7AEF\u53E3\uFF08\u7F3A\u7701 8787\uFF1B\u5185\u7F6E\u7F3A\u7701\u88AB\u5360\u7528\u65F6\u81EA\u52A8\u987A\u5EF6\u5230 8788 \u8D77\uFF09").option(
|
|
38559
39378
|
"--db <mode>",
|
|
38560
39379
|
"\u6570\u636E\u5E93\u6A21\u5F0F\uFF1Asqlite\uFF08\u7F3A\u7701\uFF0C\u771F\u5B9E SQLite \u5E93\u6587\u4EF6\uFF0C\u9700 Bun \u6216 Node \u2265 22.5\uFF1B\u8FD0\u884C\u65F6\u4E0D\u652F\u6301\u6216\u6253\u5F00\u5931\u8D25\u65F6\u81EA\u52A8\u964D\u7EA7 sim\uFF09| sim\uFF08\u5185\u7F6E\u6A21\u62DF\u5F15\u64CE + .adep/sim/db.json\uFF09"
|
|
38561
39380
|
).option(
|
|
@@ -38570,7 +39389,8 @@ function registerDevServers(program2, ctx) {
|
|
|
38570
39389
|
const { startDevServer: startDevServer2 } = await Promise.resolve().then(() => (init_dev(), dev_exports));
|
|
38571
39390
|
const started = await startDevServer2({
|
|
38572
39391
|
cwd: ctx.cwd,
|
|
38573
|
-
|
|
39392
|
+
// 不传就交给 startDevServer 定档(内置缺省 8787,被占用时顺延);传了就是显式意图,不换号。
|
|
39393
|
+
...flags.port === void 0 ? {} : { port: Number(flags.port) },
|
|
38574
39394
|
// 缺省值一律交给 startDevServer 定档(旗标 > ADEP_SERVE_DB > 内置缺省),
|
|
38575
39395
|
// 与 `adep serve` 同一条纪律:commander 的缺省值不该盖掉环境变量。
|
|
38576
39396
|
...flags.db === void 0 ? {} : { db: flags.db },
|
|
@@ -38583,7 +39403,10 @@ function registerDevServers(program2, ctx) {
|
|
|
38583
39403
|
});
|
|
38584
39404
|
program2.command("serve").description(
|
|
38585
39405
|
"\u5F00\u53D1\u6001\u670D\u52A1\u5668\uFF1A\u51FD\u6570 /api/{fn} + /healthz + \u9759\u6001\u6258\u7BA1 + \u7EC4\u4EF6\u9884\u89C8\uFF08\u9ED8\u8BA4\u4EC5\u56DE\u73AF\uFF0C\u4E0D\u662F\u751F\u4EA7\u670D\u52A1\u5668\uFF09"
|
|
38586
|
-
).option(
|
|
39406
|
+
).option(
|
|
39407
|
+
"-p, --port <port>",
|
|
39408
|
+
"\u76D1\u542C\u7AEF\u53E3\uFF08\u7F3A\u7701\u53D6 PORT \u73AF\u5883\u53D8\u91CF\uFF0C\u518D\u7F3A\u7701 8787\uFF1B\u4EC5\u5185\u7F6E\u7F3A\u7701 8787 \u88AB\u5360\u7528\u65F6\u81EA\u52A8\u987A\u5EF6\uFF0C\u663E\u5F0F\u7AEF\u53E3/PORT \u4E0D\u6362\u53F7\uFF09"
|
|
39409
|
+
).option(
|
|
38587
39410
|
"-H, --host <host>",
|
|
38588
39411
|
"\u76D1\u542C\u5730\u5740\uFF08\u7F3A\u7701\u53D6 HOST \u73AF\u5883\u53D8\u91CF\uFF0C\u518D\u7F3A\u7701 127.0.0.1\uFF1B\u7ED1\u5B9A\u975E\u56DE\u73AF\u65F6\u7ED9\u51FA\u5BF9\u5916\u66B4\u9732\u8B66\u544A\uFF09"
|
|
38589
39412
|
).option(
|
|
@@ -38643,6 +39466,7 @@ init_auth();
|
|
|
38643
39466
|
init_client();
|
|
38644
39467
|
init_deploy();
|
|
38645
39468
|
init_frontend();
|
|
39469
|
+
init_frontend_draft();
|
|
38646
39470
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
38647
39471
|
import { readFile as readFile26, stat as stat16 } from "node:fs/promises";
|
|
38648
39472
|
import { join as join34, resolve as resolve17 } from "node:path";
|
|
@@ -38683,6 +39507,30 @@ async function frontendNoPageGuidance(cwd, message) {
|
|
|
38683
39507
|
);
|
|
38684
39508
|
return lines.join("\n");
|
|
38685
39509
|
}
|
|
39510
|
+
async function assertDraftPublishable(cwd, prepared) {
|
|
39511
|
+
if (hasFrontendEntry(prepared.drafts)) return;
|
|
39512
|
+
const fileCount = Object.keys(prepared.drafts).length;
|
|
39513
|
+
throw new CliError(
|
|
39514
|
+
"FE_NO_PAGE",
|
|
39515
|
+
await frontendNoPageGuidance(
|
|
39516
|
+
cwd,
|
|
39517
|
+
`\u672C\u5730 web/ \u7F3A\u5C11\u7AD9\u70B9\u5165\u53E3 web/index.html\uFF08\u73B0\u6709 ${fileCount} \u4E2A\u6587\u4EF6\u90FD\u4E0D\u662F\u5165\u53E3\uFF09\uFF1A\u5E73\u53F0\u6784\u7AD9\u95E8\u540C\u6837\u8981\u6C42\u8BE5\u6587\u4EF6\uFF0C\u53D1\u5E03\u5FC5\u7136\u5931\u8D25\u3002
|
|
39518
|
+
\u5DF2\u5728\u540C\u6B65\u4E4B\u524D\u963B\u65AD\u2014\u2014\u672C\u6B21\u672A\u5411\u5E73\u53F0\u5199\u5165\u4EFB\u4F55\u8349\u7A3F\uFF0C\u5E73\u53F0\u8349\u7A3F\u4FDD\u6301\u539F\u6837\u3002
|
|
39519
|
+
\u5728 web/ \u4E0B\u8865 index.html \u540E\u518D\u6267\u884C adep publish --only frontend\u3002`
|
|
39520
|
+
)
|
|
39521
|
+
);
|
|
39522
|
+
}
|
|
39523
|
+
function withDraftReplacedNote(error62, prepared) {
|
|
39524
|
+
if (!(error62 instanceof CliError)) return error62;
|
|
39525
|
+
const fileCount = Object.keys(prepared.drafts).length;
|
|
39526
|
+
return new CliError(
|
|
39527
|
+
error62.code,
|
|
39528
|
+
`${error62.message}
|
|
39529
|
+
|
|
39530
|
+
\u6CE8\u610F\uFF1A\u672C\u6B21\u53D1\u5E03\u524D\u5DF2\u628A\u672C\u5730 web/ \u7684 ${fileCount} \u4E2A\u6587\u4EF6\u6574\u7EC4\u5199\u5165\u5E73\u53F0\u8349\u7A3F\uFF08\u539F\u8349\u7A3F\u5DF2\u88AB\u66FF\u6362\uFF0C\u5F53\u524D\u5E73\u53F0\u8349\u7A3F = \u672C\u5730\u6E90\u7801\uFF09\uFF1B\u4FEE\u590D\u540E\u91CD\u8BD5\u4F1A\u518D\u6B21\u6574\u7EC4\u8986\u76D6\u3002`,
|
|
39531
|
+
error62.exitCode
|
|
39532
|
+
);
|
|
39533
|
+
}
|
|
38686
39534
|
async function publishFrontend(paths, options) {
|
|
38687
39535
|
const log = options.silent === true ? () => void 0 : options.log ?? ((line) => process.stdout.write(`${line}
|
|
38688
39536
|
`));
|
|
@@ -38852,7 +39700,7 @@ async function checkSchemaDrift(paths, options) {
|
|
|
38852
39700
|
const schemaStat = await stat16(schemaFile).catch(() => null);
|
|
38853
39701
|
if (schemaStat === null || !schemaStat.isFile()) {
|
|
38854
39702
|
options.log("[adep] \u672A\u627E\u5230 database/schema.sql\uFF0C\u8DF3\u8FC7 schema \u6F02\u79FB\u68C0\u67E5");
|
|
38855
|
-
return
|
|
39703
|
+
return { status: "skipped", reason: "no-schema" };
|
|
38856
39704
|
}
|
|
38857
39705
|
const sql = await readFile26(schemaFile, "utf8");
|
|
38858
39706
|
const { dbSchemaDiff: dbSchemaDiff2 } = await Promise.resolve().then(() => (init_db2(), db_exports));
|
|
@@ -38867,25 +39715,61 @@ async function checkSchemaDrift(paths, options) {
|
|
|
38867
39715
|
} catch (error62) {
|
|
38868
39716
|
if (error62 instanceof CliError && (error62.code === "DB_NOT_PROVISIONED" || error62.code === "DB_NOT_FOUND")) {
|
|
38869
39717
|
options.log("[adep] \u6570\u636E\u5E93\u5C1A\u672A\u542F\u52A8\uFF0C\u8DF3\u8FC7 schema \u6F02\u79FB\u68C0\u67E5\uFF08\u5148 adep db start \u540E\u53D1\u5E03\u53EF\u542F\u7528\uFF09");
|
|
38870
|
-
return
|
|
39718
|
+
return { status: "skipped", reason: "db-not-provisioned" };
|
|
38871
39719
|
}
|
|
38872
39720
|
throw error62;
|
|
38873
39721
|
}
|
|
38874
|
-
const
|
|
39722
|
+
const missingIndexes = drift.missingIndexes ?? [];
|
|
39723
|
+
const uniqueDiff = drift.uniqueDiff ?? [];
|
|
39724
|
+
const defaultDiff = drift.defaultDiff ?? [];
|
|
39725
|
+
const nullabilityDiff = drift.nullabilityDiff ?? [];
|
|
39726
|
+
const missingPlainIndexes = missingIndexes.filter((index) => !index.unique);
|
|
39727
|
+
const blockingNullability = nullabilityDiff.filter(
|
|
39728
|
+
(item) => item.expected === "not-null" && item.actual === "nullable"
|
|
39729
|
+
);
|
|
39730
|
+
const warningNullability = nullabilityDiff.filter(
|
|
39731
|
+
(item) => item.expected === "nullable" && item.actual === "not-null"
|
|
39732
|
+
);
|
|
39733
|
+
const fallbackBlocking = drift.missingTables.length > 0 || drift.missingColumns.length > 0 || drift.typeMismatches.length > 0 || uniqueDiff.length > 0 || blockingNullability.length > 0;
|
|
39734
|
+
const blocking = drift.blocking ?? fallbackBlocking;
|
|
38875
39735
|
if (drift.destructiveStatements.length > 0) {
|
|
38876
39736
|
options.log(
|
|
38877
39737
|
`[adep] \u26A0 schema.sql \u542B\u7834\u574F\u6027\u8BED\u53E5\uFF08\u4E0D\u4F1A\u88AB\u81EA\u52A8\u6267\u884C\uFF09\uFF1A${drift.destructiveStatements.join(" \xB7 ")}`
|
|
38878
39738
|
);
|
|
38879
39739
|
}
|
|
39740
|
+
const warningCount = missingPlainIndexes.length + defaultDiff.length + warningNullability.length;
|
|
39741
|
+
const hasWarnings = warningCount > 0;
|
|
39742
|
+
if (missingPlainIndexes.length > 0) {
|
|
39743
|
+
options.log(
|
|
39744
|
+
`[adep] \u26A0 \u7EBF\u4E0A\u7F3A\u5C11 ${missingPlainIndexes.length} \u4E2A\u7D22\u5F15\uFF08\u4E0D\u963B\u65AD\u53D1\u5E03\uFF1Badep db migrate \u53EF\u8865\u5EFA\uFF09\uFF1A${missingPlainIndexes.map((index) => index.name).join(" \xB7 ")}`
|
|
39745
|
+
);
|
|
39746
|
+
}
|
|
39747
|
+
if (defaultDiff.length > 0) {
|
|
39748
|
+
options.log(
|
|
39749
|
+
`[adep] \u26A0 \u9ED8\u8BA4\u503C\u6F02\u79FB ${defaultDiff.length} \u5904\uFF08\u4E0D\u963B\u65AD\u53D1\u5E03\uFF1B\u8BF7\u6838\u5BF9 schema \u4E0E\u7EBF\u4E0A\uFF09\uFF1A${defaultDiff.map((item) => `${item.table}.${item.column}`).join(" \xB7 ")}`
|
|
39750
|
+
);
|
|
39751
|
+
}
|
|
39752
|
+
if (warningNullability.length > 0) {
|
|
39753
|
+
options.log(
|
|
39754
|
+
`[adep] \u26A0 \u7EBF\u4E0A\u5217\u6BD4 schema \u66F4\u4E25\u683C\uFF08NOT NULL\uFF09${warningNullability.length} \u5904\uFF08\u4E0D\u963B\u65AD\uFF09\uFF1A${warningNullability.map((item) => `${item.table}.${item.column}`).join(" \xB7 ")}`
|
|
39755
|
+
);
|
|
39756
|
+
}
|
|
38880
39757
|
if (!blocking) {
|
|
38881
|
-
options.log(
|
|
38882
|
-
|
|
39758
|
+
options.log(
|
|
39759
|
+
hasWarnings ? "[adep] \u2713 schema \u65E0\u963B\u65AD\u6F02\u79FB\uFF08\u5B58\u5728\u4E0A\u8FF0\u8B66\u544A\uFF09" : "[adep] \u2713 schema \u65E0\u6F02\u79FB"
|
|
39760
|
+
);
|
|
39761
|
+
return { status: "clean", warnings: warningCount };
|
|
38883
39762
|
}
|
|
39763
|
+
const blockingCount = drift.missingTables.length + drift.missingColumns.length + drift.typeMismatches.length + uniqueDiff.length + blockingNullability.length;
|
|
38884
39764
|
if (options.allowDrift === true) {
|
|
38885
|
-
options.log(
|
|
38886
|
-
|
|
39765
|
+
options.log(
|
|
39766
|
+
"[adep] \u26A0 schema \u6F02\u79FB\u88AB --allow-drift \u653E\u884C\uFF1A\u7EBF\u4E0A\u51FD\u6570\u53EF\u80FD no such column / \u4EA7\u751F\u91CD\u590D\u6570\u636E"
|
|
39767
|
+
);
|
|
39768
|
+
return { status: "allowed", blocking: blockingCount };
|
|
38887
39769
|
}
|
|
38888
|
-
const lines = [
|
|
39770
|
+
const lines = [
|
|
39771
|
+
"\u68C0\u6D4B\u5230 schema \u6F02\u79FB\uFF0C\u53D1\u5E03\u5DF2\u963B\u65AD\uFF08\u4E91\u51FD\u6570\u4F1A\u76F4\u63A5 no such column / \u552F\u4E00\u7EA6\u675F\u7F3A\u5931\u4F1A\u4EA7\u751F\u91CD\u590D\u6570\u636E\uFF09\uFF1A"
|
|
39772
|
+
];
|
|
38889
39773
|
for (const item of drift.missingTables) lines.push(` +table ${item.table}`);
|
|
38890
39774
|
for (const item of drift.missingColumns) {
|
|
38891
39775
|
lines.push(` +column ${item.table}.${item.column.name}`);
|
|
@@ -38895,6 +39779,14 @@ async function checkSchemaDrift(paths, options) {
|
|
|
38895
39779
|
` !type ${item.table}.${item.column}\uFF08\u671F\u671B ${item.expected}\uFF0C\u7EBF\u4E0A ${item.actual}\uFF09`
|
|
38896
39780
|
);
|
|
38897
39781
|
}
|
|
39782
|
+
for (const item of uniqueDiff) {
|
|
39783
|
+
lines.push(
|
|
39784
|
+
` !unique ${item.table}(${item.columns.join(", ")})` + (item.fixable ? "\uFF08adep db migrate \u53EF\u8865\u5EFA\u552F\u4E00\u7D22\u5F15\uFF09" : "\uFF08\u9700\u91CD\u5EFA\u8868\u8865\u552F\u4E00\u7EA6\u675F\uFF09")
|
|
39785
|
+
);
|
|
39786
|
+
}
|
|
39787
|
+
for (const item of blockingNullability) {
|
|
39788
|
+
lines.push(` !null ${item.table}.${item.column}\uFF08schema NOT NULL\uFF0C\u7EBF\u4E0A\u53EF\u7A7A\uFF09`);
|
|
39789
|
+
}
|
|
38898
39790
|
lines.push("\u4E0B\u4E00\u6B65\uFF1Aadep db migrate database/schema.sql");
|
|
38899
39791
|
lines.push(" \u67E5\u770B\u8BA1\u5212\uFF1Aadep db migrate database/schema.sql --plan");
|
|
38900
39792
|
lines.push(" \u5168\u5E93\u6F02\u79FB\u62A5\u544A\uFF1Aadep db doctor");
|
|
@@ -38910,8 +39802,9 @@ async function runPublish(paths, io, cwd, flags) {
|
|
|
38910
39802
|
const wantFrontend = scope === "fullstack" || scope === "frontend";
|
|
38911
39803
|
const environment = flags.environment;
|
|
38912
39804
|
const result = { scope };
|
|
39805
|
+
let schemaGate;
|
|
38913
39806
|
if (wantFunctions) {
|
|
38914
|
-
await checkSchemaDrift(paths, {
|
|
39807
|
+
schemaGate = await checkSchemaDrift(paths, {
|
|
38915
39808
|
cwd,
|
|
38916
39809
|
...flags.project === void 0 ? {} : { slug: flags.project },
|
|
38917
39810
|
log: io.json ? () => void 0 : (line) => io.line(line),
|
|
@@ -38949,19 +39842,26 @@ async function runPublish(paths, io, cwd, flags) {
|
|
|
38949
39842
|
log: (line) => io.line(line)
|
|
38950
39843
|
});
|
|
38951
39844
|
} else {
|
|
38952
|
-
await
|
|
38953
|
-
|
|
38954
|
-
|
|
38955
|
-
silent: io.json,
|
|
38956
|
-
log: (line) => io.line(line)
|
|
38957
|
-
});
|
|
38958
|
-
result.frontend = await publishFrontend(paths, {
|
|
39845
|
+
const prepared = await prepareFrontendDraft(webDir);
|
|
39846
|
+
await assertDraftPublishable(cwd, prepared);
|
|
39847
|
+
await syncPreparedFrontend(paths, {
|
|
38959
39848
|
cwd,
|
|
38960
|
-
...environment === void 0 ? {} : { environment },
|
|
38961
39849
|
...flags.project === void 0 ? {} : { slug: flags.project },
|
|
38962
39850
|
silent: io.json,
|
|
38963
|
-
log: (line) => io.line(line)
|
|
39851
|
+
log: (line) => io.line(line),
|
|
39852
|
+
prepared
|
|
38964
39853
|
});
|
|
39854
|
+
try {
|
|
39855
|
+
result.frontend = await publishFrontend(paths, {
|
|
39856
|
+
cwd,
|
|
39857
|
+
...environment === void 0 ? {} : { environment },
|
|
39858
|
+
...flags.project === void 0 ? {} : { slug: flags.project },
|
|
39859
|
+
silent: io.json,
|
|
39860
|
+
log: (line) => io.line(line)
|
|
39861
|
+
});
|
|
39862
|
+
} catch (error62) {
|
|
39863
|
+
throw withDraftReplacedNote(error62, prepared);
|
|
39864
|
+
}
|
|
38965
39865
|
}
|
|
38966
39866
|
} else {
|
|
38967
39867
|
result.frontend = await publishFrontend(paths, {
|
|
@@ -38974,9 +39874,60 @@ async function runPublish(paths, io, cwd, flags) {
|
|
|
38974
39874
|
}
|
|
38975
39875
|
}
|
|
38976
39876
|
}
|
|
38977
|
-
return result;
|
|
39877
|
+
return schemaGate === void 0 ? { result } : { result, schemaGate };
|
|
39878
|
+
}
|
|
39879
|
+
function namedList(functions) {
|
|
39880
|
+
return functions.length === 0 ? "" : `\uFF08${functions.map((fn) => fn.name).join("\u3001")}\uFF09`;
|
|
39881
|
+
}
|
|
39882
|
+
function classifyFunctionPublish(functions) {
|
|
39883
|
+
if (functions.length === 0) return "unknown";
|
|
39884
|
+
if (functions.some((fn) => fn.action !== "create")) return "repeat";
|
|
39885
|
+
return functions.every((fn) => fn.version === 1) ? "first" : "unknown";
|
|
39886
|
+
}
|
|
39887
|
+
function describeFrontendPublish(fe) {
|
|
39888
|
+
if (fe.mode === "static") {
|
|
39889
|
+
const via = fe.built === true ? `\u672C\u5730\u6784\u5EFA ${fe.distDir ?? "\u4EA7\u7269"}/ \u2192 \u9759\u6001\u76F4\u901A` : "\u9759\u6001\u76F4\u901A";
|
|
39890
|
+
const files = fe.uploaded === void 0 ? "\u6587\u4EF6\u6570\u672A\u8FD4\u56DE" : `${fe.uploaded} \u4E2A\u6587\u4EF6`;
|
|
39891
|
+
let spa = "\u672A\u8FD4\u56DE";
|
|
39892
|
+
if (fe.spaMode !== void 0) spa = fe.spaMode ? "\u5F00" : "\u5173";
|
|
39893
|
+
return `\u524D\u7AEF\uFF1A${via}\uFF08${files}\uFF0CSPA \u56DE\u9000 ${spa}\uFF09 \xB7 \u7248\u672C/reused \u672A\u8FD4\u56DE\uFF08\u8BE5\u901A\u9053\u4E0D\u4EA7\u751F\u7248\u672C\u53F7\uFF09 \xB7 ${fe.siteUrl}`;
|
|
39894
|
+
}
|
|
39895
|
+
let channel = "\u524D\u7AEF\u53D1\u5E03";
|
|
39896
|
+
if (fe.reused === true) channel = "\u590D\u7528";
|
|
39897
|
+
else if (fe.reused === false) channel = "\u6784\u5EFA\u53D1\u5E03";
|
|
39898
|
+
const version2 = fe.version === void 0 ? "\u7248\u672C\u672A\u8FD4\u56DE" : `v${fe.version}`;
|
|
39899
|
+
const reused = fe.reused === void 0 ? "reused \u672A\u8FD4\u56DE" : `reused=${fe.reused}`;
|
|
39900
|
+
return `\u524D\u7AEF\uFF1A${channel} ${version2}\uFF08${reused}\uFF09 \xB7 ${fe.siteUrl}`;
|
|
38978
39901
|
}
|
|
38979
|
-
function
|
|
39902
|
+
function describeSchemaGate(gate) {
|
|
39903
|
+
switch (gate.status) {
|
|
39904
|
+
case "skipped":
|
|
39905
|
+
return gate.reason === "no-schema" ? "\u6570\u636E\u5E93\uFF1A\u672A\u68C0\u67E5\uFF08\u672A\u627E\u5230 database/schema.sql\uFF09" : "\u6570\u636E\u5E93\uFF1A\u672A\u68C0\u67E5\uFF08\u6570\u636E\u5E93\u5C1A\u672A\u542F\u52A8\uFF09";
|
|
39906
|
+
case "clean":
|
|
39907
|
+
return gate.warnings === 0 ? "\u6570\u636E\u5E93\uFF1A\u65E0\u6F02\u79FB" : `\u6570\u636E\u5E93\uFF1A\u65E0\u963B\u65AD\u6F02\u79FB\uFF08\u8B66\u544A ${gate.warnings} \u5904\uFF09`;
|
|
39908
|
+
case "allowed":
|
|
39909
|
+
return `\u6570\u636E\u5E93\uFF1A\u6F02\u79FB\u5DF2\u7531 --allow-drift \u653E\u884C\uFF08\u963B\u65AD ${gate.blocking} \u5904\uFF09`;
|
|
39910
|
+
}
|
|
39911
|
+
}
|
|
39912
|
+
function renderPublishSummary(result, context) {
|
|
39913
|
+
const lines = [];
|
|
39914
|
+
if (result.functions !== void 0) {
|
|
39915
|
+
const created = result.functions.functions.filter((fn) => fn.action === "create");
|
|
39916
|
+
const updated = result.functions.functions.filter((fn) => fn.action === "publish");
|
|
39917
|
+
const unchanged = result.functions.functions.filter((fn) => fn.action === "none");
|
|
39918
|
+
lines.push(
|
|
39919
|
+
` \u51FD\u6570\uFF1A\u65B0\u589E ${created.length}${namedList(created)} \xB7 \u66F4\u65B0 ${updated.length}${namedList(updated)} \xB7 \u672A\u53D8 ${unchanged.length} \xB7 \u7F51\u5173 ${result.functions.baseUrl}`
|
|
39920
|
+
);
|
|
39921
|
+
}
|
|
39922
|
+
if (result.frontend !== void 0) {
|
|
39923
|
+
lines.push(` ${describeFrontendPublish(result.frontend)}`);
|
|
39924
|
+
}
|
|
39925
|
+
if (context.schemaGate !== void 0) {
|
|
39926
|
+
lines.push(` ${describeSchemaGate(context.schemaGate)}`);
|
|
39927
|
+
}
|
|
39928
|
+
return lines.length === 0 ? [] : ["\u672C\u6B21\u53D1\u5E03\u6458\u8981\uFF1A", ...lines];
|
|
39929
|
+
}
|
|
39930
|
+
function renderPublish(data, context = {}) {
|
|
38980
39931
|
const result = data;
|
|
38981
39932
|
const lines = [];
|
|
38982
39933
|
if (result.functions !== void 0) {
|
|
@@ -39005,14 +39956,26 @@ function renderPublish(data) {
|
|
|
39005
39956
|
lines.push(`\u2713 frontend built ${status} \xB7 ${fe.siteUrl}`);
|
|
39006
39957
|
}
|
|
39007
39958
|
}
|
|
39959
|
+
const summary = renderPublishSummary(result, context);
|
|
39960
|
+
if (summary.length > 0) {
|
|
39961
|
+
lines.push("");
|
|
39962
|
+
lines.push(...summary);
|
|
39963
|
+
}
|
|
39008
39964
|
if (result.functions !== void 0) {
|
|
39965
|
+
const kind = classifyFunctionPublish(result.functions.functions);
|
|
39009
39966
|
lines.push("");
|
|
39010
|
-
|
|
39011
|
-
|
|
39012
|
-
|
|
39013
|
-
|
|
39014
|
-
|
|
39015
|
-
|
|
39967
|
+
if (kind === "first") {
|
|
39968
|
+
lines.push("\u53D1\u5E03\u540E\u4E09\u6B65\uFF08\u9996\u6B21\u53D1\u5E03\u5FC5\u505A\uFF09\uFF1A");
|
|
39969
|
+
lines.push(" 1. adep db start # \u542F\u52A8\u9879\u76EE\u6570\u636E\u5E93\uFF08\u82E5\u5DF2\u542F\u52A8\u8DF3\u8FC7\uFF09");
|
|
39970
|
+
lines.push(
|
|
39971
|
+
" 2. adep db migrate <schema.sql> # \u5EFA\u8868 + \u6267\u884C\u6587\u4EF6\u5185\u5176\u4F59\u8BED\u53E5\uFF08\u7D22\u5F15/\u79CD\u5B50\uFF1B\u91CD\u8DD1\u4F1A\u518D\u6267\u884C\uFF09"
|
|
39972
|
+
);
|
|
39973
|
+
lines.push(" 3. adep db migrate <seed.sql> # \u79CD\u5B50\u5355\u72EC\u6210\u6587\u4EF6\u65F6\uFF08\u53EF\u9009\uFF1B\u79CD\u5B50\u8BF7\u5199\u6210\u5E42\u7B49\u8BED\u53E5\uFF09");
|
|
39974
|
+
} else if (kind === "repeat") {
|
|
39975
|
+
lines.push("\u975E\u9996\u6B21\u53D1\u5E03\uFF08\u670D\u52A1\u7AEF\u8FD4\u56DE\u65E2\u6709\u7248\u672C\uFF09\uFF0C\u8DF3\u8FC7\u300C\u53D1\u5E03\u540E\u4E09\u6B65\u300D\u9996\u6B21\u6E05\u5355\u3002");
|
|
39976
|
+
} else {
|
|
39977
|
+
lines.push("\u65E0\u6CD5\u786E\u8BA4\u662F\u5426\u9996\u6B21\u53D1\u5E03\uFF08\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u81EA\u6D3D\u7684\u7248\u672C\u5B57\u6BB5\uFF09\uFF0C\u8DF3\u8FC7\u300C\u53D1\u5E03\u540E\u4E09\u6B65\u300D\u9996\u6B21\u6E05\u5355\u3002");
|
|
39978
|
+
}
|
|
39016
39979
|
}
|
|
39017
39980
|
return lines;
|
|
39018
39981
|
}
|
|
@@ -39031,7 +39994,7 @@ function registerPublish(program2, ctx) {
|
|
|
39031
39994
|
const command = ctx.io("publish");
|
|
39032
39995
|
await command.run(async () => {
|
|
39033
39996
|
const { environment, source } = await ctx.env();
|
|
39034
|
-
const
|
|
39997
|
+
const run = await runPublish(ctx.paths, command, ctx.cwd, {
|
|
39035
39998
|
...flags,
|
|
39036
39999
|
...source === "default" ? {} : { environment }
|
|
39037
40000
|
});
|
|
@@ -39040,7 +40003,10 @@ function registerPublish(program2, ctx) {
|
|
|
39040
40003
|
`\u73AF\u5883\uFF1Adev\uFF08${describeEnvironmentSource(source)}\uFF09\u2014\u2014 \u524D\u7AEF\u53D1\u5230\u5F00\u53D1\u7AD9\u70B9\uFF1B\u4E91\u51FD\u6570\u90E8\u7F72\u4E0D\u53D7\u5F71\u54CD\uFF08\u7EBF\u4E0A\u51FD\u6570\u6052\u8BFB\u751F\u4EA7\u5E93\uFF09`
|
|
39041
40004
|
);
|
|
39042
40005
|
}
|
|
39043
|
-
command.ok(
|
|
40006
|
+
command.ok(
|
|
40007
|
+
run.result,
|
|
40008
|
+
(data) => renderPublish(data, run.schemaGate === void 0 ? {} : { schemaGate: run.schemaGate })
|
|
40009
|
+
);
|
|
39044
40010
|
});
|
|
39045
40011
|
}
|
|
39046
40012
|
);
|
|
@@ -39276,8 +40242,13 @@ function registerExport(program2, ctx) {
|
|
|
39276
40242
|
import { readFile as readFile29 } from "node:fs/promises";
|
|
39277
40243
|
import { resolve as resolve19 } from "node:path";
|
|
39278
40244
|
init_db2();
|
|
39279
|
-
function renderDrift(diff) {
|
|
40245
|
+
function renderDrift(diff, options = {}) {
|
|
39280
40246
|
const lines = [];
|
|
40247
|
+
const missingIndexes = diff.missingIndexes ?? [];
|
|
40248
|
+
const uniqueDiff = diff.uniqueDiff ?? [];
|
|
40249
|
+
const defaultDiff = diff.defaultDiff ?? [];
|
|
40250
|
+
const nullabilityDiff = diff.nullabilityDiff ?? [];
|
|
40251
|
+
const dataStatements = diff.dataStatements ?? [];
|
|
39281
40252
|
for (const table of diff.missingTables) lines.push(`+table ${table.table}`);
|
|
39282
40253
|
for (const column of diff.missingColumns) {
|
|
39283
40254
|
lines.push(
|
|
@@ -39289,6 +40260,30 @@ function renderDrift(diff) {
|
|
|
39289
40260
|
`!type ${mismatch.table}.${mismatch.column} \u7EBF\u4E0A ${mismatch.actual || "(\u65E0\u7C7B\u578B)"} \u2192 schema ${mismatch.expected}`
|
|
39290
40261
|
);
|
|
39291
40262
|
}
|
|
40263
|
+
for (const unique of uniqueDiff) {
|
|
40264
|
+
const columns = unique.columns.length === 0 ? "(\u5217\u672A\u77E5)" : unique.columns.join(", ");
|
|
40265
|
+
const source = unique.source === "index" ? unique.fixable ? "\u552F\u4E00\u7D22\u5F15\u672A\u5EFA\uFF0Cadep db migrate \u53EF\u8865\u5EFA" : "\u540C\u5217\u7D22\u5F15\u5B58\u5728\u4F46\u4E0D\u662F UNIQUE\uFF0C\u9700\u91CD\u5EFA" : "UNIQUE \u7EA6\u675F\u672A\u751F\u6548\uFF0C\u9700\u91CD\u5EFA\u8868\u8865\u7EA6\u675F";
|
|
40266
|
+
lines.push(`!unique ${unique.table}(${columns}) ${source}`);
|
|
40267
|
+
}
|
|
40268
|
+
for (const item of defaultDiff) {
|
|
40269
|
+
lines.push(
|
|
40270
|
+
`!default ${item.table}.${item.column} \u7EBF\u4E0A ${item.actual === null ? "(\u65E0\u9ED8\u8BA4\u503C)" : item.actual} \u2192 schema ${item.expected}\uFF08\u53EA\u8B66\u544A\uFF0C\u4E0D\u963B\u65AD\uFF09`
|
|
40271
|
+
);
|
|
40272
|
+
}
|
|
40273
|
+
for (const item of nullabilityDiff) {
|
|
40274
|
+
const blocking = item.expected === "not-null" && item.actual === "nullable";
|
|
40275
|
+
lines.push(
|
|
40276
|
+
`!null ${item.table}.${item.column} schema ${item.expected === "not-null" ? "NOT NULL" : "\u663E\u5F0F NULL"}\uFF0C\u7EBF\u4E0A ${item.actual === "not-null" ? "NOT NULL" : "\u53EF\u7A7A"}` + (blocking ? "\uFF08\u963B\u65AD\uFF1A\u9700\u91CD\u5EFA\u8868\uFF09" : "\uFF08\u53EA\u8B66\u544A\uFF09")
|
|
40277
|
+
);
|
|
40278
|
+
}
|
|
40279
|
+
for (const index of missingIndexes) {
|
|
40280
|
+
if (index.unique) continue;
|
|
40281
|
+
const columns = index.columns.length === 0 ? "(\u5217\u672A\u77E5)" : index.columns.join(", ");
|
|
40282
|
+
lines.push(`+index ${index.name} ON ${index.table}(${columns})`);
|
|
40283
|
+
if (options.indexStatements === true && index.statement !== void 0) {
|
|
40284
|
+
lines.push(` ${index.statement.replace(/\s+/g, " ").slice(0, 160)}`);
|
|
40285
|
+
}
|
|
40286
|
+
}
|
|
39292
40287
|
for (const table of diff.extraTables)
|
|
39293
40288
|
lines.push(`-table ${table}\uFF08\u7EBF\u4E0A\u6709\u3001schema \u672A\u58F0\u660E\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u5220\u9664\uFF09`);
|
|
39294
40289
|
for (const column of diff.extraColumns) {
|
|
@@ -39297,12 +40292,17 @@ function renderDrift(diff) {
|
|
|
39297
40292
|
for (const statement of diff.destructiveStatements) {
|
|
39298
40293
|
lines.push(`!ddl ${statement.replace(/\s+/g, " ").slice(0, 120)}`);
|
|
39299
40294
|
}
|
|
39300
|
-
const
|
|
39301
|
-
|
|
40295
|
+
const missingIndexStatements = new Set(
|
|
40296
|
+
missingIndexes.map((index) => (index.statement ?? "").trim()).filter((statement) => statement !== "")
|
|
40297
|
+
);
|
|
40298
|
+
const visibleDataStatements = dataStatements.filter(
|
|
40299
|
+
(statement) => !missingIndexStatements.has(statement.trim())
|
|
40300
|
+
);
|
|
40301
|
+
for (const statement of visibleDataStatements) {
|
|
39302
40302
|
lines.push(`!dml ${statement.replace(/\s+/g, " ").slice(0, 120)}`);
|
|
39303
40303
|
}
|
|
39304
40304
|
if (lines.length === 0) return ["\u2713 schema \u4E0E\u7EBF\u4E0A\u4E00\u81F4\uFF0C\u65E0\u6F02\u79FB"];
|
|
39305
|
-
if (
|
|
40305
|
+
if (visibleDataStatements.length > 0) {
|
|
39306
40306
|
lines.push(
|
|
39307
40307
|
"",
|
|
39308
40308
|
"\u63D0\u793A\uFF1A!dml \u8BED\u53E5\uFF08\u7D22\u5F15 / \u79CD\u5B50\u7B49\uFF09\u4F1A\u6309\u58F0\u660E\u987A\u5E8F\u539F\u6837\u6267\u884C\uFF1B\u91CD\u590D\u6267\u884C\u540C\u4E00\u6587\u4EF6\u65F6\u4F1A\u518D\u6B21\u6267\u884C\uFF0C\u79CD\u5B50\u8BF7\u5199\u6210\u5E42\u7B49\u8BED\u53E5\uFF08WHERE NOT EXISTS / INSERT OR IGNORE\uFF09\u3002"
|
|
@@ -39313,6 +40313,25 @@ function renderDrift(diff) {
|
|
|
39313
40313
|
}
|
|
39314
40314
|
return lines;
|
|
39315
40315
|
}
|
|
40316
|
+
function renderTableSchema(schema) {
|
|
40317
|
+
const lines = [`\u8868 ${schema.name}`];
|
|
40318
|
+
for (const col of schema.columns) {
|
|
40319
|
+
lines.push(
|
|
40320
|
+
` ${col.name} ${col.type}${col.primaryKey ? " PRIMARY KEY" : ""}${col.nullable ? "" : " NOT NULL"}`
|
|
40321
|
+
);
|
|
40322
|
+
}
|
|
40323
|
+
if (schema.indexes.length === 0) {
|
|
40324
|
+
lines.push("", "\u7D22\u5F15\uFF1A\uFF08\u65E0\uFF09");
|
|
40325
|
+
} else {
|
|
40326
|
+
lines.push("", "\u7D22\u5F15\uFF1A");
|
|
40327
|
+
for (const index of schema.indexes) {
|
|
40328
|
+
const columns = index.columns.length === 0 ? "(\u5217\u89C1 DDL)" : `(${index.columns.join(", ")})`;
|
|
40329
|
+
lines.push(` ${index.name} ${columns}${index.unique ? " UNIQUE" : ""}`);
|
|
40330
|
+
}
|
|
40331
|
+
}
|
|
40332
|
+
if (schema.ddl !== null) lines.push("", schema.ddl);
|
|
40333
|
+
return lines;
|
|
40334
|
+
}
|
|
39316
40335
|
function registerDb(program2, ctx) {
|
|
39317
40336
|
const db = program2.command("db").description("\u9879\u76EE\u6570\u636E\u5E93\u7EF4\u62A4\uFF1A\u542F\u52A8 / \u72B6\u6001 / \u505C\u6B62 / SQL / \u5FEB\u7167 / \u56DE\u6EDA");
|
|
39318
40337
|
db.command("start").description("\u542F\u52A8\u9879\u76EE\u6570\u636E\u5E93\uFF08\u5DF2\u5B58\u5728\u5219\u91CD\u65B0\u6FC0\u6D3B\uFF0C\u4E0D\u91CD\u5EFA\u6570\u636E\uFF09").option("-p, --project <slug>", "\u76EE\u6807\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").action(async (flags) => {
|
|
@@ -39438,14 +40457,7 @@ function registerDb(program2, ctx) {
|
|
|
39438
40457
|
command.ok(result, (data) => {
|
|
39439
40458
|
const r = data;
|
|
39440
40459
|
if ("columns" in r) {
|
|
39441
|
-
|
|
39442
|
-
for (const col of r.columns) {
|
|
39443
|
-
lines.push(
|
|
39444
|
-
` ${col.name} ${col.type}${col.primaryKey ? " PRIMARY KEY" : ""}${col.nullable ? "" : " NOT NULL"}`
|
|
39445
|
-
);
|
|
39446
|
-
}
|
|
39447
|
-
if (r.ddl !== null) lines.push("", r.ddl);
|
|
39448
|
-
return lines;
|
|
40460
|
+
return renderTableSchema(r);
|
|
39449
40461
|
}
|
|
39450
40462
|
if (r.tables.length === 0) {
|
|
39451
40463
|
return `\uFF08${environment} \u5E93\u91CC\u6CA1\u6709\u8868\uFF09`;
|
|
@@ -39458,53 +40470,73 @@ function registerDb(program2, ctx) {
|
|
|
39458
40470
|
});
|
|
39459
40471
|
});
|
|
39460
40472
|
db.command("migrate").description(
|
|
39461
|
-
"\u6267\u884C SQL \u8FC1\u79FB\u6587\u4EF6\uFF08\u589E\u91CF\u8BED\u4E49\uFF09\uFF1A\u7F3A\u8868\u5EFA\u8868\u3001\u65E2\u6709\u8868\u7F3A\u5217\u81EA\u52A8 ADD COLUMN\uFF1BINDEX / INSERT / UPDATE \u7B49\u5176\u4F59\u8BED\u53E5\u6309\u58F0\u660E\u987A\u5E8F\u539F\u6837\u6267\u884C\uFF08\u6BCF\u6B21\u90FD\u4F1A\u91CD\u8DD1\uFF0C\u79CD\u5B50\u8BF7\u5199\u6210\u5E42\u7B49\u8BED\u53E5\uFF09\uFF1B\u5220\u5217/\u6539\u7C7B\u578B/\u91CD\u547D\u540D\u62D2\u7EDD\u81EA\u52A8\u6267\u884C\u3002\u53EF\u591A\u4E2A\u6587\u4EF6\uFF0C\u6309\u58F0\u660E\u987A\u5E8F\u6267\u884C\uFF0C\u5931\u8D25\u5373\u505C"
|
|
39462
|
-
).argument("<files...>", "\u8FC1\u79FB SQL \u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u5F53\u524D\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u6309\u58F0\u660E\u987A\u5E8F\u6267\u884C\uFF09").option("-p, --project <slug>", "\u76EE\u6807\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").option(
|
|
39463
|
-
|
|
39464
|
-
|
|
39465
|
-
|
|
39466
|
-
|
|
39467
|
-
|
|
39468
|
-
|
|
39469
|
-
|
|
39470
|
-
|
|
39471
|
-
|
|
39472
|
-
|
|
39473
|
-
|
|
39474
|
-
|
|
39475
|
-
|
|
39476
|
-
);
|
|
39477
|
-
if (result.failed !== void 0) {
|
|
39478
|
-
const f = result.failed;
|
|
39479
|
-
const nextStep = f.code === "DB_NOT_PROVISIONED" ? "\n\u4E0B\u4E00\u6B65\uFF1Aadep db start\uFF08\u542F\u52A8\u9879\u76EE\u6570\u636E\u5E93\uFF1B--env dev \u9700\u5148\u89E6\u53D1\u4E00\u6B21\u51FD\u6570\u8C03\u8BD5\u4EE5\u521D\u59CB\u5316\u5F00\u53D1\u5E93\uFF09" : "";
|
|
39480
|
-
command.fail(f.code, `\u6587\u4EF6 ${f.file} \u8FC1\u79FB\u5931\u8D25\uFF1A${f.message}${nextStep}`);
|
|
39481
|
-
return;
|
|
39482
|
-
}
|
|
39483
|
-
command.ok(result, (data) => {
|
|
39484
|
-
const r = data;
|
|
39485
|
-
const lines = renderDrift(
|
|
39486
|
-
r.drift ?? {
|
|
39487
|
-
missingTables: [],
|
|
39488
|
-
missingColumns: [],
|
|
39489
|
-
typeMismatches: [],
|
|
39490
|
-
extraTables: [],
|
|
39491
|
-
extraColumns: [],
|
|
39492
|
-
destructiveStatements: [],
|
|
39493
|
-
dataStatements: [],
|
|
39494
|
-
applicable: true
|
|
39495
|
-
}
|
|
39496
|
-
);
|
|
39497
|
-
if (flags.plan === true) return lines;
|
|
39498
|
-
lines.push(
|
|
39499
|
-
`\u2713 \u8FC1\u79FB\u5B8C\u6210\uFF1A\u65B0\u5EFA\u8868 ${r.createdTables}\uFF0C\u65B0\u589E\u5217 ${r.addedColumns}\uFF0C\u5DF2\u5B58\u5728\u8DF3\u8FC7 ${r.skippedTables}\uFF08\u5171\u6267\u884C ${r.applied.length} \u6761\u8BED\u53E5\uFF09`
|
|
40473
|
+
"\u6267\u884C SQL \u8FC1\u79FB\u6587\u4EF6\uFF08\u589E\u91CF\u8BED\u4E49\uFF09\uFF1A\u7F3A\u8868\u5EFA\u8868\u3001\u65E2\u6709\u8868\u7F3A\u5217\u81EA\u52A8 ADD COLUMN\uFF1BINDEX / INSERT / UPDATE \u7B49\u5176\u4F59\u8BED\u53E5\u6309\u58F0\u660E\u987A\u5E8F\u539F\u6837\u6267\u884C\uFF08\u6BCF\u6B21\u90FD\u4F1A\u91CD\u8DD1\uFF0C\u79CD\u5B50\u8BF7\u5199\u6210\u5E42\u7B49\u8BED\u53E5\uFF09\uFF1B\u5220\u5217/\u6539\u7C7B\u578B/\u91CD\u547D\u540D\u62D2\u7EDD\u81EA\u52A8\u6267\u884C\u3002\u53EF\u591A\u4E2A\u6587\u4EF6\uFF0C\u6309\u58F0\u660E\u987A\u5E8F\u6267\u884C\uFF0C\u5931\u8D25\u5373\u505C\u3002\u751F\u4EA7\u5E93\uFF08\u542B\u7F3A\u7701\u73AF\u5883\uFF09\u6267\u884C\u9700 --confirm-db <project-slug> \u4E8C\u6B21\u786E\u8BA4\u2014\u2014\u5148 --plan \u770B\u5BF9\u8C61\u6E05\u5355"
|
|
40474
|
+
).argument("<files...>", "\u8FC1\u79FB SQL \u6587\u4EF6\u8DEF\u5F84\uFF08\u76F8\u5BF9\u5F53\u524D\u76EE\u5F55\u6216\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u6309\u58F0\u660E\u987A\u5E8F\u6267\u884C\uFF09").option("-p, --project <slug>", "\u76EE\u6807\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").option(
|
|
40475
|
+
"--plan",
|
|
40476
|
+
"\u53EA\u8F93\u51FA\u8BA1\u5212\uFF08+table / +column / !type / +index / !unique / !default / !null / !dml\uFF09\uFF0C\u4E0D\u6267\u884C\u4EFB\u4F55\u8BED\u53E5"
|
|
40477
|
+
).option(
|
|
40478
|
+
"--confirm-db <project-slug>",
|
|
40479
|
+
"\u751F\u4EA7\u8FC1\u79FB\u4E8C\u6B21\u786E\u8BA4\uFF1A\u503C\u5FC5\u987B\u4E0E\u76EE\u6807\u9879\u76EE slug \u5B8C\u5168\u4E00\u81F4\uFF08dev \u4E0E --plan \u4E0D\u9700\u8981\uFF09"
|
|
40480
|
+
).action(
|
|
40481
|
+
async (files, flags) => {
|
|
40482
|
+
const command = ctx.io("db migrate");
|
|
40483
|
+
await command.run(async () => {
|
|
40484
|
+
const { environment, source } = await ctx.env();
|
|
40485
|
+
const { dbMigrate: dbMigrate2 } = await Promise.resolve().then(() => (init_db2(), db_exports));
|
|
40486
|
+
command.line(
|
|
40487
|
+
`\u73AF\u5883\uFF1A${environment}\uFF08${describeEnvironmentSource(source)}\uFF09\u2014\u2014 \u8FC1\u79FB\u5C06\u4F5C\u7528\u5230${environment === "dev" ? "\u5F00\u53D1\u5E93" : "\u751F\u4EA7\u5E93"}`
|
|
39500
40488
|
);
|
|
39501
|
-
|
|
40489
|
+
const printsPreflight = flags.plan !== true && environment === "prod" && !command.json;
|
|
40490
|
+
const result = await dbMigrate2(ctx.paths, {
|
|
40491
|
+
cwd: ctx.cwd,
|
|
40492
|
+
files,
|
|
40493
|
+
environment,
|
|
40494
|
+
...flags.project === void 0 ? {} : { slug: flags.project },
|
|
40495
|
+
...flags.plan === true ? { plan: true } : {},
|
|
40496
|
+
...flags.confirmDb === void 0 ? {} : { confirmDb: flags.confirmDb },
|
|
40497
|
+
...printsPreflight ? {
|
|
40498
|
+
onPlan: (diff, file2) => {
|
|
40499
|
+
command.line(`\u5C06\u8981\u6267\u884C\u7684\u5BF9\u8C61\uFF08${file2}\uFF09\uFF1A`);
|
|
40500
|
+
for (const line of renderDrift(diff, { indexStatements: true }))
|
|
40501
|
+
command.line(line);
|
|
40502
|
+
}
|
|
40503
|
+
} : {}
|
|
40504
|
+
});
|
|
40505
|
+
if (result.failed !== void 0) {
|
|
40506
|
+
const f = result.failed;
|
|
40507
|
+
const nextStep = f.code === "DB_NOT_PROVISIONED" ? "\n\u4E0B\u4E00\u6B65\uFF1Aadep db start\uFF08\u542F\u52A8\u9879\u76EE\u6570\u636E\u5E93\uFF1B--env dev \u9700\u5148\u89E6\u53D1\u4E00\u6B21\u51FD\u6570\u8C03\u8BD5\u4EE5\u521D\u59CB\u5316\u5F00\u53D1\u5E93\uFF09" : "";
|
|
40508
|
+
command.fail(f.code, `\u6587\u4EF6 ${f.file} \u8FC1\u79FB\u5931\u8D25\uFF1A${f.message}${nextStep}`);
|
|
40509
|
+
return;
|
|
40510
|
+
}
|
|
40511
|
+
command.ok(result, (data) => {
|
|
40512
|
+
const r = data;
|
|
40513
|
+
const summary = `\u2713 \u8FC1\u79FB\u5B8C\u6210\uFF1A\u65B0\u5EFA\u8868 ${r.createdTables}\uFF0C\u65B0\u589E\u5217 ${r.addedColumns}\uFF0C\u5DF2\u5B58\u5728\u8DF3\u8FC7 ${r.skippedTables}\uFF08\u5171\u6267\u884C ${r.applied.length} \u6761\u8BED\u53E5\uFF09`;
|
|
40514
|
+
if (printsPreflight) return [summary];
|
|
40515
|
+
const lines = renderDrift(
|
|
40516
|
+
r.drift ?? {
|
|
40517
|
+
dbEnvironment: environment,
|
|
40518
|
+
missingTables: [],
|
|
40519
|
+
missingColumns: [],
|
|
40520
|
+
typeMismatches: [],
|
|
40521
|
+
extraTables: [],
|
|
40522
|
+
extraColumns: [],
|
|
40523
|
+
destructiveStatements: [],
|
|
40524
|
+
dataStatements: [],
|
|
40525
|
+
applicable: true
|
|
40526
|
+
},
|
|
40527
|
+
// 计划必须与「实际会执行的索引语句」对得上:缺失索引逐条列出并附语句原文。
|
|
40528
|
+
{ indexStatements: true }
|
|
40529
|
+
);
|
|
40530
|
+
if (flags.plan === true) return lines;
|
|
40531
|
+
lines.push(summary);
|
|
40532
|
+
return lines;
|
|
40533
|
+
});
|
|
39502
40534
|
});
|
|
39503
|
-
}
|
|
39504
|
-
|
|
40535
|
+
}
|
|
40536
|
+
);
|
|
39505
40537
|
db.command("doctor").description(
|
|
39506
|
-
"\u5168\u5E93 schema \u6F02\u79FB\u62A5\u544A\uFF1A\u5BF9\u6BD4 schema.sql \u4E0E\u7EBF\u4E0A\u76EE\u5F55\uFF08\u7F3A\u8868 / \u7F3A\u5217 / \u7C7B\u578B\
|
|
39507
|
-
).argument("[schema]", "schema.sql \u8DEF\u5F84", "database/schema.sql").option("-p, --project <slug>", "\u76EE\u6807\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").action(async (schema, flags) => {
|
|
40538
|
+
"\u5168\u5E93 schema \u6F02\u79FB\u62A5\u544A\uFF1A\u5BF9\u6BD4 schema.sql \u4E0E\u7EBF\u4E0A\u76EE\u5F55\uFF08\u7F3A\u8868 / \u7F3A\u5217 / \u7C7B\u578B / \u552F\u4E00\u7EA6\u675F / \u9ED8\u8BA4\u503C / \u53EF\u7A7A\u6027 / \u7D22\u5F15\uFF09\u3002\u53D7\u5168\u5C40 --env \u5F71\u54CD\uFF1B\u5B58\u5728\u963B\u65AD\u9879\u65F6\u9000\u51FA\u7801\u975E 0"
|
|
40539
|
+
).argument("[schema]", "schema.sql \u8DEF\u5F84", "database/schema.sql").option("-p, --project <slug>", "\u76EE\u6807\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").option("--verbose", "\u7D22\u5F15\u5C42\u660E\u7EC6\uFF1A\u7F3A\u5931\u7D22\u5F15\u9644\u5B8C\u6574 CREATE INDEX \u8BED\u53E5").action(async (schema, flags) => {
|
|
39508
40540
|
const command = ctx.io("db doctor");
|
|
39509
40541
|
await command.run(async () => {
|
|
39510
40542
|
const { environment, source } = await ctx.env();
|
|
@@ -39519,15 +40551,16 @@ function registerDb(program2, ctx) {
|
|
|
39519
40551
|
command.line(
|
|
39520
40552
|
`\u73AF\u5883\uFF1A${environment}\uFF08${describeEnvironmentSource(source)}\uFF09\u2014\u2014 \u68C0\u67E5\u7684\u662F${environment === "dev" ? "\u5F00\u53D1\u5E93" : "\u751F\u4EA7\u5E93"}`
|
|
39521
40553
|
);
|
|
39522
|
-
|
|
40554
|
+
const blocking = diff.blocking === true || !diff.applicable;
|
|
40555
|
+
if (blocking) {
|
|
39523
40556
|
command.fail(
|
|
39524
40557
|
"SCHEMA_DRIFT",
|
|
39525
|
-
`\u68C0\u6D4B\u5230\
|
|
39526
|
-
${renderDrift(diff).join("\n")}`
|
|
40558
|
+
`\u68C0\u6D4B\u5230\u963B\u65AD\u53D1\u5E03\u7684\u6F02\u79FB\uFF08${schema}\uFF09\uFF1A
|
|
40559
|
+
${renderDrift(diff, { indexStatements: true }).join("\n")}`
|
|
39527
40560
|
);
|
|
39528
40561
|
return;
|
|
39529
40562
|
}
|
|
39530
|
-
command.ok(diff, () => renderDrift(diff));
|
|
40563
|
+
command.ok(diff, () => renderDrift(diff, { indexStatements: flags.verbose === true }));
|
|
39531
40564
|
});
|
|
39532
40565
|
});
|
|
39533
40566
|
const snapshot = db.command("snapshot").description("\u6570\u636E\u5E93\u5FEB\u7167\uFF08\u4ED8\u8D39\u6863\u4F4D\uFF09\uFF1A\u5217\u51FA\uFF08\u7F3A\u7701\uFF09/ \u521B\u5EFA / \u8FD8\u539F");
|