@fantasticit/sumi 0.14.0 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents.js +2 -1
- package/dist/agents.js.map +1 -1
- package/dist/cli.js +14 -1
- package/dist/cli.js.map +1 -1
- package/dist/constraint-list.js +2 -1
- package/dist/constraint-list.js.map +1 -1
- package/dist/hook-routing.js +19 -3
- package/dist/hook-routing.js.map +1 -1
- package/dist/launcher.cjs +350 -158
- package/dist/launcher.js +13 -2
- package/dist/launcher.js.map +1 -1
- package/node_modules/@sumi/create/package.json +2 -2
- package/node_modules/@sumi/kernel/dist/config.d.ts +6 -0
- package/node_modules/@sumi/kernel/dist/config.js +49 -15
- package/node_modules/@sumi/kernel/dist/config.js.map +1 -1
- package/node_modules/@sumi/kernel/package.json +6 -2
- package/node_modules/@sumi/plugin-sdk/package.json +1 -1
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js +23 -23
- package/node_modules/@sumi/plugins-core/dist/plugins/test-affected.js.map +1 -1
- package/node_modules/@sumi/plugins-core/package.json +2 -2
- package/node_modules/@sumi/plugins-core/sumi-plugins.yaml +1 -1
- package/node_modules/@sumi/plugins-governance/assets/hook-bootstrap.cjs +44 -16
- package/node_modules/@sumi/plugins-governance/dist/checkout.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/checkout.js +6 -2
- package/node_modules/@sumi/plugins-governance/dist/checkout.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js +11 -5
- package/node_modules/@sumi/plugins-governance/dist/commands/gate.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/config-recovery.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/config-recovery.js +15 -0
- package/node_modules/@sumi/plugins-governance/dist/config-recovery.js.map +1 -0
- package/node_modules/@sumi/plugins-governance/dist/context-provider.js +7 -0
- package/node_modules/@sumi/plugins-governance/dist/context-provider.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/index.d.ts +2 -0
- package/node_modules/@sumi/plugins-governance/dist/index.js +2 -0
- package/node_modules/@sumi/plugins-governance/dist/index.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/preflight.d.ts +4 -0
- package/node_modules/@sumi/plugins-governance/dist/preflight.js +12 -2
- package/node_modules/@sumi/plugins-governance/dist/preflight.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/dist/upgrade-command.js +0 -4
- package/node_modules/@sumi/plugins-governance/dist/upgrade-command.js.map +1 -1
- package/node_modules/@sumi/plugins-governance/instructions/push.md +1 -1
- package/node_modules/@sumi/plugins-governance/package.json +4 -4
- package/node_modules/@sumi/plugins-openspec/package.json +4 -4
- package/node_modules/@sumi/plugins-precedent/package.json +3 -3
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js +3 -1
- package/node_modules/@sumi/plugins-review/dist/plugins/independent-recheck.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/preflight.d.ts +13 -0
- package/node_modules/@sumi/plugins-review/dist/preflight.js +10 -8
- package/node_modules/@sumi/plugins-review/dist/preflight.js.map +1 -1
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js +12 -3
- package/node_modules/@sumi/plugins-review/dist/validation-receipt.js.map +1 -1
- package/node_modules/@sumi/plugins-review/package.json +6 -6
- package/package.json +10 -10
package/dist/launcher.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/* global process, console, Buffer, __filename, atob, btoa, queueMicrotask */
|
|
2
3
|
"use strict";
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
@@ -56,7 +57,7 @@ var require_identity = __commonJS({
|
|
|
56
57
|
}
|
|
57
58
|
return false;
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function isNode2(node) {
|
|
60
61
|
if (node && typeof node === "object")
|
|
61
62
|
switch (node[NODE_TYPE]) {
|
|
62
63
|
case ALIAS:
|
|
@@ -80,7 +81,7 @@ var require_identity = __commonJS({
|
|
|
80
81
|
exports2.isCollection = isCollection;
|
|
81
82
|
exports2.isDocument = isDocument;
|
|
82
83
|
exports2.isMap = isMap;
|
|
83
|
-
exports2.isNode =
|
|
84
|
+
exports2.isNode = isNode2;
|
|
84
85
|
exports2.isPair = isPair;
|
|
85
86
|
exports2.isScalar = isScalar;
|
|
86
87
|
exports2.isSeq = isSeq;
|
|
@@ -3484,7 +3485,7 @@ var require_Document = __commonJS({
|
|
|
3484
3485
|
createAlias(node, name) {
|
|
3485
3486
|
if (!node.anchor) {
|
|
3486
3487
|
const prev = anchors.anchorNames(this);
|
|
3487
|
-
node.anchor =
|
|
3488
|
+
node.anchor =
|
|
3488
3489
|
!name || prev.has(name) ? anchors.findNewAnchor(name || "a", prev) : name;
|
|
3489
3490
|
}
|
|
3490
3491
|
return new Alias.Alias(node.anchor);
|
|
@@ -3507,7 +3508,7 @@ var require_Document = __commonJS({
|
|
|
3507
3508
|
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options ?? {};
|
|
3508
3509
|
const { onAnchor, setAnchors, sourceObjects } = anchors.createNodeAnchors(
|
|
3509
3510
|
this,
|
|
3510
|
-
|
|
3511
|
+
|
|
3511
3512
|
anchorPrefix || "a"
|
|
3512
3513
|
);
|
|
3513
3514
|
const ctx = {
|
|
@@ -6310,7 +6311,7 @@ var require_lexer = __commonJS({
|
|
|
6310
6311
|
var require_line_counter = __commonJS({
|
|
6311
6312
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/line-counter.js"(exports2) {
|
|
6312
6313
|
"use strict";
|
|
6313
|
-
var
|
|
6314
|
+
var LineCounter2 = class {
|
|
6314
6315
|
constructor() {
|
|
6315
6316
|
this.lineStarts = [];
|
|
6316
6317
|
this.addNewLine = (offset) => this.lineStarts.push(offset);
|
|
@@ -6333,7 +6334,7 @@ var require_line_counter = __commonJS({
|
|
|
6333
6334
|
};
|
|
6334
6335
|
}
|
|
6335
6336
|
};
|
|
6336
|
-
exports2.LineCounter =
|
|
6337
|
+
exports2.LineCounter = LineCounter2;
|
|
6337
6338
|
}
|
|
6338
6339
|
});
|
|
6339
6340
|
|
|
@@ -7241,7 +7242,7 @@ var require_public_api = __commonJS({
|
|
|
7241
7242
|
return docs;
|
|
7242
7243
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
7243
7244
|
}
|
|
7244
|
-
function
|
|
7245
|
+
function parseDocument2(source, options = {}) {
|
|
7245
7246
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
7246
7247
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
7247
7248
|
const composer$1 = new composer.Composer(options);
|
|
@@ -7260,14 +7261,14 @@ var require_public_api = __commonJS({
|
|
|
7260
7261
|
}
|
|
7261
7262
|
return doc;
|
|
7262
7263
|
}
|
|
7263
|
-
function
|
|
7264
|
+
function parse(src, reviver, options) {
|
|
7264
7265
|
let _reviver = void 0;
|
|
7265
7266
|
if (typeof reviver === "function") {
|
|
7266
7267
|
_reviver = reviver;
|
|
7267
7268
|
} else if (options === void 0 && reviver && typeof reviver === "object") {
|
|
7268
7269
|
options = reviver;
|
|
7269
7270
|
}
|
|
7270
|
-
const doc =
|
|
7271
|
+
const doc = parseDocument2(src, options);
|
|
7271
7272
|
if (!doc)
|
|
7272
7273
|
return null;
|
|
7273
7274
|
doc.warnings.forEach((warning) => log.warn(doc.options.logLevel, warning));
|
|
@@ -7301,9 +7302,9 @@ var require_public_api = __commonJS({
|
|
|
7301
7302
|
return value.toString(options);
|
|
7302
7303
|
return new Document.Document(value, _replacer, options).toString(options);
|
|
7303
7304
|
}
|
|
7304
|
-
exports2.parse =
|
|
7305
|
+
exports2.parse = parse;
|
|
7305
7306
|
exports2.parseAllDocuments = parseAllDocuments;
|
|
7306
|
-
exports2.parseDocument =
|
|
7307
|
+
exports2.parseDocument = parseDocument2;
|
|
7307
7308
|
exports2.stringify = stringify;
|
|
7308
7309
|
}
|
|
7309
7310
|
});
|
|
@@ -7363,8 +7364,8 @@ var require_dist = __commonJS({
|
|
|
7363
7364
|
// src/launcher.ts
|
|
7364
7365
|
var import_node_child_process = require("node:child_process");
|
|
7365
7366
|
var import_node_crypto4 = require("node:crypto");
|
|
7366
|
-
var
|
|
7367
|
-
var
|
|
7367
|
+
var import_node_fs12 = require("node:fs");
|
|
7368
|
+
var import_node_path15 = require("node:path");
|
|
7368
7369
|
|
|
7369
7370
|
// ../plugin-sdk/dist/project.js
|
|
7370
7371
|
var import_node_fs = require("node:fs");
|
|
@@ -7375,22 +7376,206 @@ function configFile(root) {
|
|
|
7375
7376
|
}
|
|
7376
7377
|
var PUBLISHED_CLI_PACKAGE = "@fantasticit/sumi";
|
|
7377
7378
|
var CLI_PACKAGE_NAMES = ["@sumi/cli", PUBLISHED_CLI_PACKAGE];
|
|
7379
|
+
var isCliPackageName = (name) => typeof name === "string" && CLI_PACKAGE_NAMES.includes(name);
|
|
7380
|
+
function satisfies(version, range) {
|
|
7381
|
+
const parse = (v3) => v3.replace(/^v/, "").split("-")[0].split(".").map((n) => Number(n) || 0);
|
|
7382
|
+
const cmp = (a, b2) => {
|
|
7383
|
+
for (let i = 0; i < 3; i++)
|
|
7384
|
+
if ((a[i] ?? 0) !== (b2[i] ?? 0))
|
|
7385
|
+
return (a[i] ?? 0) - (b2[i] ?? 0);
|
|
7386
|
+
return 0;
|
|
7387
|
+
};
|
|
7388
|
+
const v2 = parse(version);
|
|
7389
|
+
return range.trim().split(/\s+/).every((part) => {
|
|
7390
|
+
const m2 = /^(>=|<=|>|<|=|\^|~)?(.+)$/.exec(part);
|
|
7391
|
+
if (!m2)
|
|
7392
|
+
return false;
|
|
7393
|
+
const target = parse(m2[2]);
|
|
7394
|
+
const c = cmp(v2, target);
|
|
7395
|
+
switch (m2[1]) {
|
|
7396
|
+
case ">=":
|
|
7397
|
+
return c >= 0;
|
|
7398
|
+
case ">":
|
|
7399
|
+
return c > 0;
|
|
7400
|
+
case "<=":
|
|
7401
|
+
return c <= 0;
|
|
7402
|
+
case "<":
|
|
7403
|
+
return c < 0;
|
|
7404
|
+
case "^": {
|
|
7405
|
+
const upper = target[0] > 0 ? [target[0] + 1, 0, 0] : target[1] > 0 ? [0, target[1] + 1, 0] : [0, 0, target[2] + 1];
|
|
7406
|
+
return c >= 0 && cmp(v2, upper) < 0;
|
|
7407
|
+
}
|
|
7408
|
+
case "~":
|
|
7409
|
+
return c >= 0 && cmp(v2, [target[0], target[1] + 1, 0]) < 0;
|
|
7410
|
+
default:
|
|
7411
|
+
return c === 0;
|
|
7412
|
+
}
|
|
7413
|
+
});
|
|
7414
|
+
}
|
|
7378
7415
|
|
|
7379
|
-
//
|
|
7416
|
+
// ../kernel/dist/config.js
|
|
7417
|
+
var import_node_fs2 = require("node:fs");
|
|
7418
|
+
var import_node_path2 = require("node:path");
|
|
7380
7419
|
var import_yaml = __toESM(require_dist(), 1);
|
|
7381
7420
|
|
|
7421
|
+
// ../kernel/dist/errors.js
|
|
7422
|
+
var KernelError = class extends Error {
|
|
7423
|
+
exitCode = 3;
|
|
7424
|
+
constructor(message) {
|
|
7425
|
+
super(message);
|
|
7426
|
+
this.name = "KernelError";
|
|
7427
|
+
}
|
|
7428
|
+
};
|
|
7429
|
+
|
|
7430
|
+
// ../kernel/dist/config.js
|
|
7431
|
+
var CONFIG_FILE = CONFIG_FILES[0];
|
|
7432
|
+
var cliVersion;
|
|
7433
|
+
var cliBuild;
|
|
7434
|
+
var identityHint = "\u8BF7\u4ECE\u9879\u76EE\u58F0\u660E\u7684 CLI \u5165\u53E3\u91CD\u65B0\u542F\u52A8";
|
|
7435
|
+
var DEFAULTS = {
|
|
7436
|
+
tiers: ["delta", "runtime", "full"],
|
|
7437
|
+
zones: {},
|
|
7438
|
+
neutral: [],
|
|
7439
|
+
pathHints: {},
|
|
7440
|
+
exclude: [],
|
|
7441
|
+
upgrade: [],
|
|
7442
|
+
packages: [],
|
|
7443
|
+
plugins: [],
|
|
7444
|
+
groups: {},
|
|
7445
|
+
flows: "control/flows",
|
|
7446
|
+
brief: { maxLines: 40, maxFindings: 10 },
|
|
7447
|
+
loop: { threshold: 3 },
|
|
7448
|
+
runs: { keepLast: 100, keepDays: 14 },
|
|
7449
|
+
sourceCheck: { intervalMs: 5e3 }
|
|
7450
|
+
};
|
|
7451
|
+
var isStringArray = (v2) => Array.isArray(v2) && v2.every((x) => typeof x === "string");
|
|
7452
|
+
var RuntimeIdentityError = class extends KernelError {
|
|
7453
|
+
config;
|
|
7454
|
+
constructor(message, config) {
|
|
7455
|
+
super(message);
|
|
7456
|
+
this.config = config;
|
|
7457
|
+
this.name = "RuntimeIdentityError";
|
|
7458
|
+
}
|
|
7459
|
+
};
|
|
7460
|
+
var ProjectConfigError = class extends KernelError {
|
|
7461
|
+
file;
|
|
7462
|
+
line;
|
|
7463
|
+
constructor(file, reason, line) {
|
|
7464
|
+
const location = line === void 0 ? file : `${file}:${line}`;
|
|
7465
|
+
super(`\u9879\u76EE\u914D\u7F6E\u4E0D\u5408\u6CD5\uFF08${location}\uFF1A${reason.replace(/[\r\n]+/g, " ")}\uFF09\uFF0C\u5148\u4FEE\u590D\u8BE5\u6587\u4EF6\u6216\u7528 git checkout -- ${file} \u6062\u590D`);
|
|
7466
|
+
this.file = file;
|
|
7467
|
+
this.line = line;
|
|
7468
|
+
this.name = "ProjectConfigError";
|
|
7469
|
+
}
|
|
7470
|
+
};
|
|
7471
|
+
function readProjectConfig(root) {
|
|
7472
|
+
const file = configFile(root);
|
|
7473
|
+
if (!file)
|
|
7474
|
+
throw new KernelError(`\u7F3A\u5C11\u9879\u76EE\u914D\u7F6E\uFF1A${(0, import_node_path2.join)(root, CONFIG_FILE)}\uFF08\u6216\u65E7\u4F4D\u7F6E ${(0, import_node_path2.join)(root, CONFIG_FILES[1])}\uFF09`);
|
|
7475
|
+
const source = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(root, file), "utf8");
|
|
7476
|
+
const lines = new import_yaml.LineCounter();
|
|
7477
|
+
const document = (0, import_yaml.parseDocument)(source, { lineCounter: lines });
|
|
7478
|
+
const error = document.errors[0];
|
|
7479
|
+
if (error) {
|
|
7480
|
+
const reason = error.message.split("\n")[0].replace(/ at line \d+, column \d+:$/, "");
|
|
7481
|
+
throw new ProjectConfigError(file, reason, lines.linePos(error.pos[0]).line);
|
|
7482
|
+
}
|
|
7483
|
+
let raw;
|
|
7484
|
+
try {
|
|
7485
|
+
raw = document.toJS() ?? {};
|
|
7486
|
+
} catch (error2) {
|
|
7487
|
+
throw new ProjectConfigError(file, error2.message.split("\n")[0]);
|
|
7488
|
+
}
|
|
7489
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
7490
|
+
throw new ProjectConfigError(file, "\u9879\u76EE\u914D\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61", 1);
|
|
7491
|
+
const lineFor = (key) => {
|
|
7492
|
+
const node = document.getIn(key.split("."), true);
|
|
7493
|
+
return (0, import_yaml.isNode)(node) && node.range ? lines.linePos(node.range[0]).line : void 0;
|
|
7494
|
+
};
|
|
7495
|
+
return { file, raw, lineFor };
|
|
7496
|
+
}
|
|
7497
|
+
function loadConfig(root) {
|
|
7498
|
+
const { file, raw, lineFor } = readProjectConfig(root);
|
|
7499
|
+
const config = { ...DEFAULTS, ...raw };
|
|
7500
|
+
config.brief = { ...DEFAULTS.brief, ...raw.brief };
|
|
7501
|
+
config.loop = { ...DEFAULTS.loop, ...raw.loop };
|
|
7502
|
+
config.runs = { ...DEFAULTS.runs, ...raw.runs };
|
|
7503
|
+
config.sourceCheck = { ...DEFAULTS.sourceCheck, ...raw.sourceCheck };
|
|
7504
|
+
const errors = [];
|
|
7505
|
+
const sourceCheck = raw.sourceCheck;
|
|
7506
|
+
if (sourceCheck !== void 0 && (!sourceCheck || typeof sourceCheck !== "object" || Array.isArray(sourceCheck)))
|
|
7507
|
+
errors.push("sourceCheck \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
7508
|
+
if (!Number.isSafeInteger(config.sourceCheck.intervalMs) || config.sourceCheck.intervalMs < 0)
|
|
7509
|
+
errors.push("sourceCheck.intervalMs \u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570");
|
|
7510
|
+
if (!isStringArray(config.tiers) || config.tiers.length === 0)
|
|
7511
|
+
errors.push("tiers \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u6570\u7EC4");
|
|
7512
|
+
for (const key of ["keepLast", "keepDays"])
|
|
7513
|
+
if (!Number.isSafeInteger(config.runs[key]) || config.runs[key] < 0)
|
|
7514
|
+
errors.push(`runs.${key} \u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570`);
|
|
7515
|
+
for (const key of ["neutral", "exclude", "packages", "plugins"]) {
|
|
7516
|
+
if (!isStringArray(config[key]))
|
|
7517
|
+
errors.push(`${key} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4`);
|
|
7518
|
+
}
|
|
7519
|
+
for (const [zone, globs] of Object.entries(config.zones ?? {})) {
|
|
7520
|
+
if (!isStringArray(globs))
|
|
7521
|
+
errors.push(`zones.${zone} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4`);
|
|
7522
|
+
}
|
|
7523
|
+
for (const [group, ids] of Object.entries(config.groups ?? {})) {
|
|
7524
|
+
if (!isStringArray(ids))
|
|
7525
|
+
errors.push(`groups.${group} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4`);
|
|
7526
|
+
}
|
|
7527
|
+
if (!config.pathHints || typeof config.pathHints !== "object" || Array.isArray(config.pathHints))
|
|
7528
|
+
errors.push("pathHints \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
7529
|
+
else
|
|
7530
|
+
for (const [name, change] of Object.entries(config.pathHints)) {
|
|
7531
|
+
if (!change || typeof change !== "object" || Array.isArray(change) || Object.keys(change).some((key) => key !== "add" && key !== "remove")) {
|
|
7532
|
+
errors.push(`pathHints.${name} \u5FC5\u987B\u662F { add?, remove? } \u5BF9\u8C61`);
|
|
7533
|
+
continue;
|
|
7534
|
+
}
|
|
7535
|
+
for (const key of ["add", "remove"])
|
|
7536
|
+
if (change[key] !== void 0 && !isStringArray(change[key]))
|
|
7537
|
+
errors.push(`pathHints.${name}.${key} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6570\u7EC4`);
|
|
7538
|
+
}
|
|
7539
|
+
if (!Array.isArray(config.upgrade))
|
|
7540
|
+
errors.push("upgrade \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
7541
|
+
else
|
|
7542
|
+
for (const rule of config.upgrade) {
|
|
7543
|
+
const validTier = isStringArray(config.tiers) && config.tiers.includes(rule?.tier);
|
|
7544
|
+
if (!rule || !isStringArray(rule.paths) || !validTier)
|
|
7545
|
+
errors.push("upgrade \u89C4\u5219\u975E\u6CD5");
|
|
7546
|
+
}
|
|
7547
|
+
if (config.sumiBuild !== void 0 && (typeof config.sumiBuild !== "string" || !/^sha256:[0-9a-f]{64}$/.test(config.sumiBuild))) {
|
|
7548
|
+
errors.push("sumiBuild \u5FC5\u987B\u662F sha256:<64 \u4F4D\u5C0F\u5199\u5341\u516D\u8FDB\u5236>");
|
|
7549
|
+
}
|
|
7550
|
+
if (config.sumiPackage !== void 0 && !isCliPackageName(config.sumiPackage)) {
|
|
7551
|
+
errors.push(`sumiPackage \u5FC5\u987B\u662F ${CLI_PACKAGE_NAMES.join(" \u6216 ")}`);
|
|
7552
|
+
}
|
|
7553
|
+
if (errors.length) {
|
|
7554
|
+
const reason = errors[0];
|
|
7555
|
+
throw new ProjectConfigError(file, reason, lineFor(reason.split(" ")[0]));
|
|
7556
|
+
}
|
|
7557
|
+
if (config.sumi && cliVersion && !satisfies(cliVersion, config.sumi)) {
|
|
7558
|
+
throw new RuntimeIdentityError(`\u5F53\u524D sumi ${cliVersion} \u4E0D\u6EE1\u8DB3\u9879\u76EE\u8981\u6C42\u7684 ${config.sumi}\uFF0C${identityHint}`, config);
|
|
7559
|
+
}
|
|
7560
|
+
if (config.sumiBuild && config.sumiBuild !== cliBuild) {
|
|
7561
|
+
const current = cliBuild ?? "unknown";
|
|
7562
|
+
throw new RuntimeIdentityError(`\u5F53\u524D sumi \u6784\u5EFA ${current} \u4E0D\u6EE1\u8DB3\u9879\u76EE\u8981\u6C42\u7684 ${config.sumiBuild}\uFF0C${identityHint}`, config);
|
|
7563
|
+
}
|
|
7564
|
+
return config;
|
|
7565
|
+
}
|
|
7566
|
+
|
|
7382
7567
|
// src/runtime-manifest.ts
|
|
7383
7568
|
var import_node_crypto2 = require("node:crypto");
|
|
7384
|
-
var
|
|
7385
|
-
var
|
|
7569
|
+
var import_node_fs4 = require("node:fs");
|
|
7570
|
+
var import_node_path4 = require("node:path");
|
|
7386
7571
|
|
|
7387
7572
|
// src/build-identity.ts
|
|
7388
7573
|
var import_node_crypto = require("node:crypto");
|
|
7389
|
-
var
|
|
7390
|
-
var
|
|
7574
|
+
var import_node_fs3 = require("node:fs");
|
|
7575
|
+
var import_node_path3 = require("node:path");
|
|
7391
7576
|
var BUILD_ID_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
7392
7577
|
function payload(path, relative) {
|
|
7393
|
-
const content = (0,
|
|
7578
|
+
const content = (0, import_node_fs3.readFileSync)(path);
|
|
7394
7579
|
if (relative !== "package.json") return content;
|
|
7395
7580
|
const manifest = JSON.parse(content.toString("utf8"));
|
|
7396
7581
|
delete manifest.sumiBuild;
|
|
@@ -7401,9 +7586,9 @@ function buildIdentity(root) {
|
|
|
7401
7586
|
const hash = (0, import_node_crypto.createHash)("sha256");
|
|
7402
7587
|
const entries = [];
|
|
7403
7588
|
const walk = (dir, prefix = "") => {
|
|
7404
|
-
for (const entry of (0,
|
|
7589
|
+
for (const entry of (0, import_node_fs3.readdirSync)(dir, { withFileTypes: true })) {
|
|
7405
7590
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
7406
|
-
const path = (0,
|
|
7591
|
+
const path = (0, import_node_path3.join)(dir, entry.name);
|
|
7407
7592
|
if (entry.isDirectory() && entry.name === ".bin" && (prefix === "node_modules" || prefix.endsWith("/node_modules"))) continue;
|
|
7408
7593
|
if (entry.isDirectory()) walk(path, relative);
|
|
7409
7594
|
else entries.push(relative);
|
|
@@ -7412,10 +7597,10 @@ function buildIdentity(root) {
|
|
|
7412
7597
|
walk(root);
|
|
7413
7598
|
entries.sort();
|
|
7414
7599
|
for (const relative of entries) {
|
|
7415
|
-
const path = (0,
|
|
7416
|
-
const stat = (0,
|
|
7600
|
+
const path = (0, import_node_path3.join)(root, ...relative.split("/"));
|
|
7601
|
+
const stat = (0, import_node_fs3.lstatSync)(path);
|
|
7417
7602
|
if (stat.isSymbolicLink()) {
|
|
7418
|
-
const target = Buffer.from((0,
|
|
7603
|
+
const target = Buffer.from((0, import_node_fs3.readlinkSync)(path));
|
|
7419
7604
|
hash.update(`link\0${relative}\0${target.length}\0`);
|
|
7420
7605
|
hash.update(target);
|
|
7421
7606
|
} else if (stat.isFile()) {
|
|
@@ -7436,7 +7621,7 @@ var RUNTIME_MANIFEST = `${VENDOR_DIR}/sumi-runtime.json`;
|
|
|
7436
7621
|
var SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
|
7437
7622
|
var ARCHIVE_PATTERN = /^control\/vendor\/sumi-cli-[^/\\]+\.tgz$/;
|
|
7438
7623
|
function fileSha256(path) {
|
|
7439
|
-
return (0, import_node_crypto2.createHash)("sha256").update((0,
|
|
7624
|
+
return (0, import_node_crypto2.createHash)("sha256").update((0, import_node_fs4.readFileSync)(path)).digest("hex");
|
|
7440
7625
|
}
|
|
7441
7626
|
function parseRuntimeManifest(value, repo) {
|
|
7442
7627
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("runtime \u6E05\u5355\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
@@ -7457,12 +7642,12 @@ function parseRuntimeManifest(value, repo) {
|
|
|
7457
7642
|
archiveSha256: typeof input.archiveSha256 === "string" ? input.archiveSha256 : "",
|
|
7458
7643
|
...identity
|
|
7459
7644
|
};
|
|
7460
|
-
if (!ARCHIVE_PATTERN.test(manifest.archive) || (0,
|
|
7645
|
+
if (!ARCHIVE_PATTERN.test(manifest.archive) || (0, import_node_path4.isAbsolute)(manifest.archive) || manifest.archive.split("/").includes("..")) {
|
|
7461
7646
|
throw new Error(`runtime \u5B89\u88C5\u5305\u8DEF\u5F84\u65E0\u6548\uFF1A${manifest.archive || "(\u7F3A\u5931)"}`);
|
|
7462
7647
|
}
|
|
7463
7648
|
if (!SHA256_PATTERN.test(manifest.archiveSha256)) throw new Error("runtime \u5B89\u88C5\u5305 SHA-256 \u65E0\u6548\u6216\u7F3A\u5931");
|
|
7464
|
-
const archive = (0,
|
|
7465
|
-
const vendor = (0,
|
|
7649
|
+
const archive = (0, import_node_path4.resolve)(repo, ...manifest.archive.split("/"));
|
|
7650
|
+
const vendor = (0, import_node_path4.resolve)(repo, "control/vendor");
|
|
7466
7651
|
if (archive !== vendor && !archive.startsWith(`${vendor}/`) && !archive.startsWith(`${vendor}\\`)) {
|
|
7467
7652
|
throw new Error(`runtime \u5B89\u88C5\u5305\u8D8A\u754C\uFF1A${manifest.archive}`);
|
|
7468
7653
|
}
|
|
@@ -7478,13 +7663,13 @@ function safeArchiveEntry(path) {
|
|
|
7478
7663
|
function safeLinkTarget(entryPath, target) {
|
|
7479
7664
|
const normalized = target.replaceAll("\\", "/");
|
|
7480
7665
|
if (!normalized || normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized)) return false;
|
|
7481
|
-
const resolved =
|
|
7666
|
+
const resolved = import_node_path4.posix.normalize(import_node_path4.posix.join(import_node_path4.posix.dirname(entryPath.replaceAll("\\", "/")), normalized));
|
|
7482
7667
|
return resolved === "package" || resolved.startsWith("package/");
|
|
7483
7668
|
}
|
|
7484
7669
|
|
|
7485
7670
|
// src/runtime-package.ts
|
|
7486
|
-
var
|
|
7487
|
-
var
|
|
7671
|
+
var import_node_fs11 = require("node:fs");
|
|
7672
|
+
var import_node_path14 = require("node:path");
|
|
7488
7673
|
|
|
7489
7674
|
// ../../node_modules/.pnpm/tar@7.5.22/node_modules/tar/dist/esm/index.min.js
|
|
7490
7675
|
var import_events = __toESM(require("events"), 1);
|
|
@@ -7492,35 +7677,35 @@ var import_fs = __toESM(require("fs"), 1);
|
|
|
7492
7677
|
var import_node_events = require("node:events");
|
|
7493
7678
|
var import_node_stream = __toESM(require("node:stream"), 1);
|
|
7494
7679
|
var import_node_string_decoder = require("node:string_decoder");
|
|
7495
|
-
var
|
|
7496
|
-
var
|
|
7680
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
7681
|
+
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
7497
7682
|
var import_path = require("path");
|
|
7498
7683
|
var import_events2 = require("events");
|
|
7499
7684
|
var import_assert = __toESM(require("assert"), 1);
|
|
7500
7685
|
var import_buffer = require("buffer");
|
|
7501
7686
|
var Ps = __toESM(require("zlib"), 1);
|
|
7502
7687
|
var import_zlib = __toESM(require("zlib"), 1);
|
|
7503
|
-
var import_node_path5 = require("node:path");
|
|
7504
7688
|
var import_node_path6 = require("node:path");
|
|
7689
|
+
var import_node_path7 = require("node:path");
|
|
7505
7690
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
7506
7691
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
7507
7692
|
var import_path2 = __toESM(require("path"), 1);
|
|
7508
|
-
var
|
|
7693
|
+
var import_node_path8 = require("node:path");
|
|
7509
7694
|
var import_path3 = __toESM(require("path"), 1);
|
|
7510
|
-
var
|
|
7695
|
+
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
7511
7696
|
var import_node_assert = __toESM(require("node:assert"), 1);
|
|
7512
7697
|
var import_node_crypto3 = require("node:crypto");
|
|
7513
|
-
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
7514
|
-
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
7515
|
-
var import_fs4 = __toESM(require("fs"), 1);
|
|
7516
7698
|
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
7517
7699
|
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
7700
|
+
var import_fs4 = __toESM(require("fs"), 1);
|
|
7518
7701
|
var import_node_fs8 = __toESM(require("node:fs"), 1);
|
|
7519
|
-
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
7520
7702
|
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
7521
|
-
var import_node_path11 = require("node:path");
|
|
7522
7703
|
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
7523
|
-
var
|
|
7704
|
+
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
7705
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
7706
|
+
var import_node_path12 = require("node:path");
|
|
7707
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
7708
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
7524
7709
|
var zr = Object.defineProperty;
|
|
7525
7710
|
var Ur = (s3, t) => {
|
|
7526
7711
|
for (var e in t) zr(s3, e, { get: t[e], enumerable: true });
|
|
@@ -8414,12 +8599,12 @@ var F = class {
|
|
|
8414
8599
|
}
|
|
8415
8600
|
};
|
|
8416
8601
|
var mn = (s3, t) => {
|
|
8417
|
-
let i = s3, r = "", n, o =
|
|
8602
|
+
let i = s3, r = "", n, o = import_node_path6.posix.parse(s3).root || ".";
|
|
8418
8603
|
if (Buffer.byteLength(i) < 100) n = [i, r, false];
|
|
8419
8604
|
else {
|
|
8420
|
-
r =
|
|
8605
|
+
r = import_node_path6.posix.dirname(i), i = import_node_path6.posix.basename(i);
|
|
8421
8606
|
do
|
|
8422
|
-
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i =
|
|
8607
|
+
Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t ? n = [i.slice(0, 99), r, true] : (i = import_node_path6.posix.join(import_node_path6.posix.basename(r), i), r = import_node_path6.posix.dirname(r));
|
|
8423
8608
|
while (r !== o && n === void 0);
|
|
8424
8609
|
n || (n = [s3.slice(0, 99), "", true]);
|
|
8425
8610
|
}
|
|
@@ -8465,7 +8650,7 @@ var ft = class s {
|
|
|
8465
8650
|
if (t === "") return Buffer.allocUnsafe(0);
|
|
8466
8651
|
let e = Buffer.byteLength(t), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
|
|
8467
8652
|
for (let n = 0; n < 512; n++) r[n] = 0;
|
|
8468
|
-
new F({ path: ("PaxHeader/" + (0,
|
|
8653
|
+
new F({ path: ("PaxHeader/" + (0, import_node_path7.basename)(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t, 512, e, "utf8");
|
|
8469
8654
|
for (let n = e + 512; n < r.length; n++) r[n] = 0;
|
|
8470
8655
|
return r;
|
|
8471
8656
|
}
|
|
@@ -8891,15 +9076,15 @@ var Qi = (s3, t) => {
|
|
|
8891
9076
|
var Mn = (s3) => {
|
|
8892
9077
|
let t = new rt(s3), e = s3.file, i;
|
|
8893
9078
|
try {
|
|
8894
|
-
i =
|
|
8895
|
-
let r =
|
|
9079
|
+
i = import_node_fs5.default.openSync(e, "r");
|
|
9080
|
+
let r = import_node_fs5.default.fstatSync(i), n = s3.maxReadSize || 16 * 1024 * 1024;
|
|
8896
9081
|
if (r.size < n) {
|
|
8897
|
-
let o = Buffer.allocUnsafe(r.size), h =
|
|
9082
|
+
let o = Buffer.allocUnsafe(r.size), h = import_node_fs5.default.readSync(i, o, 0, r.size, 0);
|
|
8898
9083
|
t.end(h === o.byteLength ? o : o.subarray(0, h));
|
|
8899
9084
|
} else {
|
|
8900
9085
|
let o = 0, h = Buffer.allocUnsafe(n);
|
|
8901
9086
|
for (; o < r.size; ) {
|
|
8902
|
-
let a =
|
|
9087
|
+
let a = import_node_fs5.default.readSync(i, h, 0, n, o);
|
|
8903
9088
|
if (a === 0) break;
|
|
8904
9089
|
o += a, t.write(h.subarray(0, a));
|
|
8905
9090
|
}
|
|
@@ -8907,7 +9092,7 @@ var Mn = (s3) => {
|
|
|
8907
9092
|
}
|
|
8908
9093
|
} finally {
|
|
8909
9094
|
if (typeof i == "number") try {
|
|
8910
|
-
|
|
9095
|
+
import_node_fs5.default.closeSync(i);
|
|
8911
9096
|
} catch {
|
|
8912
9097
|
}
|
|
8913
9098
|
}
|
|
@@ -8915,7 +9100,7 @@ var Mn = (s3) => {
|
|
|
8915
9100
|
var Bn = (s3, t) => {
|
|
8916
9101
|
let e = new rt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
|
|
8917
9102
|
return new Promise((o, h) => {
|
|
8918
|
-
e.on("error", h), e.on("end", o),
|
|
9103
|
+
e.on("error", h), e.on("end", o), import_node_fs5.default.stat(r, (a, l) => {
|
|
8919
9104
|
if (a) h(a);
|
|
8920
9105
|
else {
|
|
8921
9106
|
let c = new _t(r, { readSize: i, size: l.size });
|
|
@@ -8928,7 +9113,7 @@ var Ct = K(Mn, Bn, (s3) => new rt(s3), (s3) => new rt(s3), (s3, t) => {
|
|
|
8928
9113
|
t?.length && Qi(s3, t), s3.noResume || vn(s3);
|
|
8929
9114
|
});
|
|
8930
9115
|
var Ji = (s3, t, e) => (s3 &= 4095, e && (s3 = (s3 | 384) & -19), t && (s3 & 256 && (s3 |= 64), s3 & 32 && (s3 |= 8), s3 & 4 && (s3 |= 1)), s3);
|
|
8931
|
-
var { isAbsolute: zn, parse: qs } =
|
|
9116
|
+
var { isAbsolute: zn, parse: qs } = import_node_path8.win32;
|
|
8932
9117
|
var ce = (s3) => {
|
|
8933
9118
|
let t = "", e = qs(s3);
|
|
8934
9119
|
for (; zn(s3) || e.root; ) {
|
|
@@ -9637,11 +9822,11 @@ var $n = (s3, t) => {
|
|
|
9637
9822
|
};
|
|
9638
9823
|
var fr = (s3, t) => {
|
|
9639
9824
|
t.forEach((e) => {
|
|
9640
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
9825
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path5.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
9641
9826
|
}), s3.end();
|
|
9642
9827
|
};
|
|
9643
9828
|
var dr = async (s3, t) => {
|
|
9644
|
-
for (let e of t) e.charAt(0) === "@" ? await Ct({ file:
|
|
9829
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path5.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
|
|
9645
9830
|
s3.add(i);
|
|
9646
9831
|
} }) : s3.add(e);
|
|
9647
9832
|
s3.end();
|
|
@@ -9668,29 +9853,29 @@ var mr = !Er && typeof ur == "number" ? ur | Sr | wr | yr : null;
|
|
|
9668
9853
|
var ms = mr !== null ? () => mr : jn ? (s3) => s3 < to ? eo : "w" : () => "w";
|
|
9669
9854
|
var ps = (s3, t, e) => {
|
|
9670
9855
|
try {
|
|
9671
|
-
return
|
|
9856
|
+
return import_node_fs8.default.lchownSync(s3, t, e);
|
|
9672
9857
|
} catch (i) {
|
|
9673
9858
|
if (i?.code !== "ENOENT") throw i;
|
|
9674
9859
|
}
|
|
9675
9860
|
};
|
|
9676
9861
|
var Ei = (s3, t, e, i) => {
|
|
9677
|
-
|
|
9862
|
+
import_node_fs8.default.lchown(s3, t, e, (r) => {
|
|
9678
9863
|
i(r && r?.code !== "ENOENT" ? r : null);
|
|
9679
9864
|
});
|
|
9680
9865
|
};
|
|
9681
9866
|
var io = (s3, t, e, i, r) => {
|
|
9682
|
-
if (t.isDirectory()) Es(
|
|
9867
|
+
if (t.isDirectory()) Es(import_node_path10.default.resolve(s3, t.name), e, i, (n) => {
|
|
9683
9868
|
if (n) return r(n);
|
|
9684
|
-
let o =
|
|
9869
|
+
let o = import_node_path10.default.resolve(s3, t.name);
|
|
9685
9870
|
Ei(o, e, i, r);
|
|
9686
9871
|
});
|
|
9687
9872
|
else {
|
|
9688
|
-
let n =
|
|
9873
|
+
let n = import_node_path10.default.resolve(s3, t.name);
|
|
9689
9874
|
Ei(n, e, i, r);
|
|
9690
9875
|
}
|
|
9691
9876
|
};
|
|
9692
9877
|
var Es = (s3, t, e, i) => {
|
|
9693
|
-
|
|
9878
|
+
import_node_fs8.default.readdir(s3, { withFileTypes: true }, (r, n) => {
|
|
9694
9879
|
if (r) {
|
|
9695
9880
|
if (r.code === "ENOENT") return i();
|
|
9696
9881
|
if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
|
|
@@ -9706,12 +9891,12 @@ var Es = (s3, t, e, i) => {
|
|
|
9706
9891
|
});
|
|
9707
9892
|
};
|
|
9708
9893
|
var so = (s3, t, e, i) => {
|
|
9709
|
-
t.isDirectory() && ws(
|
|
9894
|
+
t.isDirectory() && ws(import_node_path10.default.resolve(s3, t.name), e, i), ps(import_node_path10.default.resolve(s3, t.name), e, i);
|
|
9710
9895
|
};
|
|
9711
9896
|
var ws = (s3, t, e) => {
|
|
9712
9897
|
let i;
|
|
9713
9898
|
try {
|
|
9714
|
-
i =
|
|
9899
|
+
i = import_node_fs8.default.readdirSync(s3, { withFileTypes: true });
|
|
9715
9900
|
} catch (r) {
|
|
9716
9901
|
let n = r;
|
|
9717
9902
|
if (n?.code === "ENOENT") return;
|
|
@@ -9745,32 +9930,32 @@ var St = class extends Error {
|
|
|
9745
9930
|
}
|
|
9746
9931
|
};
|
|
9747
9932
|
var no = (s3, t) => {
|
|
9748
|
-
|
|
9933
|
+
import_node_fs9.default.stat(s3, (e, i) => {
|
|
9749
9934
|
(e || !i.isDirectory()) && (e = new Se(s3, e?.code || "ENOTDIR")), t(e);
|
|
9750
9935
|
});
|
|
9751
9936
|
};
|
|
9752
9937
|
var gr = (s3, t, e) => {
|
|
9753
9938
|
s3 = f(s3);
|
|
9754
9939
|
let i = t.umask ?? 18, r = t.mode | 448, n = (r & i) !== 0, o = t.uid, h = t.gid, a = typeof o == "number" && typeof h == "number" && (o !== t.processUid || h !== t.processGid), l = t.preserve, c = t.unlink, d = f(t.cwd), y = (E, x) => {
|
|
9755
|
-
E ? e(E) : x && a ? Es(x, o, h, (Le) => y(Le)) : n ?
|
|
9940
|
+
E ? e(E) : x && a ? Es(x, o, h, (Le) => y(Le)) : n ? import_node_fs9.default.chmod(s3, r, e) : e();
|
|
9756
9941
|
};
|
|
9757
9942
|
if (s3 === d) return no(s3, y);
|
|
9758
9943
|
if (l) return import_promises.default.mkdir(s3, { mode: r, recursive: true }).then((E) => y(null, E ?? void 0), y);
|
|
9759
|
-
let D = f(
|
|
9944
|
+
let D = f(import_node_path11.default.relative(d, s3)).split("/");
|
|
9760
9945
|
Ss(d, D, r, c, d, void 0, y);
|
|
9761
9946
|
};
|
|
9762
9947
|
var Ss = (s3, t, e, i, r, n, o) => {
|
|
9763
9948
|
if (t.length === 0) return o(null, n);
|
|
9764
|
-
let h = t.shift(), a = f(
|
|
9765
|
-
|
|
9949
|
+
let h = t.shift(), a = f(import_node_path11.default.resolve(s3 + "/" + h));
|
|
9950
|
+
import_node_fs9.default.mkdir(a, e, br(a, t, e, i, r, n, o));
|
|
9766
9951
|
};
|
|
9767
9952
|
var br = (s3, t, e, i, r, n, o) => (h) => {
|
|
9768
|
-
h ?
|
|
9953
|
+
h ? import_node_fs9.default.lstat(s3, (a, l) => {
|
|
9769
9954
|
if (a) a.path = a.path && f(a.path), o(a);
|
|
9770
9955
|
else if (l.isDirectory()) Ss(s3, t, e, i, r, n, o);
|
|
9771
|
-
else if (i)
|
|
9956
|
+
else if (i) import_node_fs9.default.unlink(s3, (c) => {
|
|
9772
9957
|
if (c) return o(c);
|
|
9773
|
-
|
|
9958
|
+
import_node_fs9.default.mkdir(s3, e, br(s3, t, e, i, r, n, o));
|
|
9774
9959
|
});
|
|
9775
9960
|
else {
|
|
9776
9961
|
if (l.isSymbolicLink()) return o(new St(s3, s3 + "/" + t.join("/")));
|
|
@@ -9781,7 +9966,7 @@ var br = (s3, t, e, i, r, n, o) => (h) => {
|
|
|
9781
9966
|
var oo = (s3) => {
|
|
9782
9967
|
let t = false, e;
|
|
9783
9968
|
try {
|
|
9784
|
-
t =
|
|
9969
|
+
t = import_node_fs9.default.statSync(s3).isDirectory();
|
|
9785
9970
|
} catch (i) {
|
|
9786
9971
|
e = i?.code;
|
|
9787
9972
|
} finally {
|
|
@@ -9791,20 +9976,20 @@ var oo = (s3) => {
|
|
|
9791
9976
|
var _r = (s3, t) => {
|
|
9792
9977
|
s3 = f(s3);
|
|
9793
9978
|
let e = t.umask ?? 18, i = t.mode | 448, r = (i & e) !== 0, n = t.uid, o = t.gid, h = typeof n == "number" && typeof o == "number" && (n !== t.processUid || o !== t.processGid), a = t.preserve, l = t.unlink, c = f(t.cwd), d = (E) => {
|
|
9794
|
-
E && h && ws(E, n, o), r &&
|
|
9979
|
+
E && h && ws(E, n, o), r && import_node_fs9.default.chmodSync(s3, i);
|
|
9795
9980
|
};
|
|
9796
9981
|
if (s3 === c) return oo(c), d();
|
|
9797
|
-
if (a) return d(
|
|
9798
|
-
let T = f(
|
|
9982
|
+
if (a) return d(import_node_fs9.default.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
|
|
9983
|
+
let T = f(import_node_path11.default.relative(c, s3)).split("/"), D;
|
|
9799
9984
|
for (let E = T.shift(), x = c; E && (x += "/" + E); E = T.shift()) {
|
|
9800
|
-
x = f(
|
|
9985
|
+
x = f(import_node_path11.default.resolve(x));
|
|
9801
9986
|
try {
|
|
9802
|
-
|
|
9987
|
+
import_node_fs9.default.mkdirSync(x, i), D = D || x;
|
|
9803
9988
|
} catch {
|
|
9804
|
-
let Le =
|
|
9989
|
+
let Le = import_node_fs9.default.lstatSync(x);
|
|
9805
9990
|
if (Le.isDirectory()) continue;
|
|
9806
9991
|
if (l) {
|
|
9807
|
-
|
|
9992
|
+
import_node_fs9.default.unlinkSync(x), import_node_fs9.default.mkdirSync(x, i), D = D || x;
|
|
9808
9993
|
continue;
|
|
9809
9994
|
} else if (Le.isSymbolicLink()) return new St(x, x + "/" + T.join("/"));
|
|
9810
9995
|
}
|
|
@@ -9826,14 +10011,14 @@ var ho = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
|
9826
10011
|
var ao = ho === "win32";
|
|
9827
10012
|
var lo = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
|
|
9828
10013
|
let r = e.at(-1);
|
|
9829
|
-
return r !== void 0 && (i = (0,
|
|
10014
|
+
return r !== void 0 && (i = (0, import_node_path12.join)(r, i)), e.push(i || "/"), e;
|
|
9830
10015
|
}, []);
|
|
9831
10016
|
var yi = class {
|
|
9832
10017
|
#t = /* @__PURE__ */ new Map();
|
|
9833
10018
|
#i = /* @__PURE__ */ new Map();
|
|
9834
10019
|
#s = /* @__PURE__ */ new Set();
|
|
9835
10020
|
reserve(t, e) {
|
|
9836
|
-
t = ao ? ["win32 parallelization disabled"] : t.map((r) => mt((0,
|
|
10021
|
+
t = ao ? ["win32 parallelization disabled"] : t.map((r) => mt((0, import_node_path12.join)(Tr(r))));
|
|
9837
10022
|
let i = new Set(t.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
|
|
9838
10023
|
this.#i.set(e, { dirs: i, paths: t });
|
|
9839
10024
|
for (let r of t) {
|
|
@@ -9923,17 +10108,17 @@ var fo = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
|
|
|
9923
10108
|
var Te = fo === "win32";
|
|
9924
10109
|
var uo = 1024;
|
|
9925
10110
|
var mo = (s3, t) => {
|
|
9926
|
-
if (!Te) return
|
|
10111
|
+
if (!Te) return import_node_fs7.default.unlink(s3, t);
|
|
9927
10112
|
let e = s3 + ".DELETE." + (0, import_node_crypto3.randomBytes)(16).toString("hex");
|
|
9928
|
-
|
|
10113
|
+
import_node_fs7.default.rename(s3, e, (i) => {
|
|
9929
10114
|
if (i) return t(i);
|
|
9930
|
-
|
|
10115
|
+
import_node_fs7.default.unlink(e, t);
|
|
9931
10116
|
});
|
|
9932
10117
|
};
|
|
9933
10118
|
var po = (s3) => {
|
|
9934
|
-
if (!Te) return
|
|
10119
|
+
if (!Te) return import_node_fs7.default.unlinkSync(s3);
|
|
9935
10120
|
let t = s3 + ".DELETE." + (0, import_node_crypto3.randomBytes)(16).toString("hex");
|
|
9936
|
-
|
|
10121
|
+
import_node_fs7.default.renameSync(s3, t), import_node_fs7.default.unlinkSync(t);
|
|
9937
10122
|
};
|
|
9938
10123
|
var vr = (s3, t, e) => s3 !== void 0 && s3 === s3 >>> 0 ? s3 : t !== void 0 && t === t >>> 0 ? t : e;
|
|
9939
10124
|
var Xt = class extends rt {
|
|
@@ -9973,7 +10158,7 @@ var Xt = class extends rt {
|
|
|
9973
10158
|
if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
|
|
9974
10159
|
this.uid = t.uid, this.gid = t.gid, this.setOwner = true;
|
|
9975
10160
|
} else this.uid = void 0, this.gid = void 0, this.setOwner = false;
|
|
9976
|
-
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : uo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(
|
|
10161
|
+
this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : uo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(import_node_path9.default.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Lr() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
|
|
9977
10162
|
}
|
|
9978
10163
|
warn(t, e, i = {}) {
|
|
9979
10164
|
return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = false), super.warn(t, e, i);
|
|
@@ -9987,7 +10172,7 @@ var Xt = class extends rt {
|
|
|
9987
10172
|
let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
|
|
9988
10173
|
if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
|
|
9989
10174
|
if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t, [e]: i }), false;
|
|
9990
|
-
let a =
|
|
10175
|
+
let a = import_node_path9.default.posix.dirname(t.path), l = import_node_path9.default.posix.normalize(import_node_path9.default.posix.join(a, h.join("/")));
|
|
9991
10176
|
if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t, [e]: i }), false;
|
|
9992
10177
|
}
|
|
9993
10178
|
return n && (t[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t, [e]: i })), true;
|
|
@@ -10005,12 +10190,12 @@ var Xt = class extends rt {
|
|
|
10005
10190
|
}
|
|
10006
10191
|
if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
|
|
10007
10192
|
if (!this[Rs](t, "path") || !this[Rs](t, "linkpath")) return false;
|
|
10008
|
-
if (t.absolute =
|
|
10193
|
+
if (t.absolute = import_node_path9.default.isAbsolute(t.path) ? f(import_node_path9.default.resolve(t.path)) : f(import_node_path9.default.resolve(this.cwd, t.path)), !this.preservePaths && typeof t.absolute == "string" && t.absolute.indexOf(this.cwd + "/") !== 0 && t.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t, path: f(t.path), resolvedPath: t.absolute, cwd: this.cwd }), false;
|
|
10009
10194
|
if (t.absolute === this.cwd && t.type !== "Directory" && t.type !== "GNUDumpDir") return false;
|
|
10010
10195
|
if (this.win32) {
|
|
10011
|
-
let { root: r } =
|
|
10196
|
+
let { root: r } = import_node_path9.default.win32.parse(String(t.absolute));
|
|
10012
10197
|
t.absolute = r + ts(String(t.absolute).slice(r.length));
|
|
10013
|
-
let { root: n } =
|
|
10198
|
+
let { root: n } = import_node_path9.default.win32.parse(t.path);
|
|
10014
10199
|
t.path = n + ts(t.path.slice(n.length));
|
|
10015
10200
|
}
|
|
10016
10201
|
return true;
|
|
@@ -10049,16 +10234,16 @@ var Xt = class extends rt {
|
|
|
10049
10234
|
[Ts](t, e) {
|
|
10050
10235
|
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new et(String(t.absolute), { flags: ms(t.size), mode: i, autoClose: false });
|
|
10051
10236
|
r.on("error", (a) => {
|
|
10052
|
-
r.fd &&
|
|
10237
|
+
r.fd && import_node_fs7.default.close(r.fd, () => {
|
|
10053
10238
|
}), r.write = () => true, this[O](a, t), e();
|
|
10054
10239
|
});
|
|
10055
10240
|
let n = 1, o = (a) => {
|
|
10056
10241
|
if (a) {
|
|
10057
|
-
r.fd &&
|
|
10242
|
+
r.fd && import_node_fs7.default.close(r.fd, () => {
|
|
10058
10243
|
}), this[O](a, t), e();
|
|
10059
10244
|
return;
|
|
10060
10245
|
}
|
|
10061
|
-
--n === 0 && r.fd !== void 0 &&
|
|
10246
|
+
--n === 0 && r.fd !== void 0 && import_node_fs7.default.close(r.fd, (l) => {
|
|
10062
10247
|
l ? this[O](l, t) : this[$t](), e();
|
|
10063
10248
|
});
|
|
10064
10249
|
};
|
|
@@ -10067,12 +10252,12 @@ var Xt = class extends rt {
|
|
|
10067
10252
|
if (typeof l == "number" && t.mtime && !this.noMtime) {
|
|
10068
10253
|
n++;
|
|
10069
10254
|
let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
|
|
10070
|
-
|
|
10255
|
+
import_node_fs7.default.futimes(l, c, d, (y) => y ? import_node_fs7.default.utimes(a, c, d, (T) => o(T && y)) : o());
|
|
10071
10256
|
}
|
|
10072
10257
|
if (typeof l == "number" && this[ge](t)) {
|
|
10073
10258
|
n++;
|
|
10074
10259
|
let c = this[be](t), d = this[_e](t);
|
|
10075
|
-
typeof c == "number" && typeof d == "number" &&
|
|
10260
|
+
typeof c == "number" && typeof d == "number" && import_node_fs7.default.fchown(l, c, d, (y) => y ? import_node_fs7.default.chown(a, c, d, (T) => o(T && y)) : o());
|
|
10076
10261
|
}
|
|
10077
10262
|
o();
|
|
10078
10263
|
});
|
|
@@ -10091,20 +10276,20 @@ var Xt = class extends rt {
|
|
|
10091
10276
|
let n = 1, o = () => {
|
|
10092
10277
|
--n === 0 && (e(), this[$t](), t.resume());
|
|
10093
10278
|
};
|
|
10094
|
-
t.mtime && !this.noMtime && (n++,
|
|
10279
|
+
t.mtime && !this.noMtime && (n++, import_node_fs7.default.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[ge](t) && (n++, import_node_fs7.default.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
|
|
10095
10280
|
});
|
|
10096
10281
|
}
|
|
10097
10282
|
[Cr](t) {
|
|
10098
10283
|
t.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t.type}`, { entry: t }), t.resume();
|
|
10099
10284
|
}
|
|
10100
10285
|
[Ar](t, e) {
|
|
10101
|
-
let i = f(
|
|
10286
|
+
let i = f(import_node_path9.default.relative(this.cwd, import_node_path9.default.resolve(import_node_path9.default.dirname(String(t.absolute)), String(t.linkpath)))).split("/");
|
|
10102
10287
|
this[Re](t, this.cwd, i, () => this[gi](t, String(t.linkpath), "symlink", e), (r) => {
|
|
10103
10288
|
this[O](r, t), e();
|
|
10104
10289
|
});
|
|
10105
10290
|
}
|
|
10106
10291
|
[Ir](t, e) {
|
|
10107
|
-
let i = f(
|
|
10292
|
+
let i = f(import_node_path9.default.resolve(this.cwd, String(t.linkpath))), r = f(String(t.linkpath)).split("/");
|
|
10108
10293
|
this[Re](t, this.cwd, r, () => this[gi](t, i, "link", e), (n) => {
|
|
10109
10294
|
this[O](n, t), e();
|
|
10110
10295
|
});
|
|
@@ -10112,10 +10297,10 @@ var Xt = class extends rt {
|
|
|
10112
10297
|
[Re](t, e, i, r, n) {
|
|
10113
10298
|
let o = i.shift();
|
|
10114
10299
|
if (this.preservePaths || o === void 0) return r();
|
|
10115
|
-
let h =
|
|
10116
|
-
|
|
10300
|
+
let h = import_node_path9.default.resolve(e, o);
|
|
10301
|
+
import_node_fs7.default.lstat(h, (a, l) => {
|
|
10117
10302
|
if (a) return r();
|
|
10118
|
-
if (l?.isSymbolicLink()) return n(new St(h,
|
|
10303
|
+
if (l?.isSymbolicLink()) return n(new St(h, import_node_path9.default.resolve(h, i.join("/"))));
|
|
10119
10304
|
this[Re](t, h, i, r, n);
|
|
10120
10305
|
});
|
|
10121
10306
|
}
|
|
@@ -10149,7 +10334,7 @@ var Xt = class extends rt {
|
|
|
10149
10334
|
});
|
|
10150
10335
|
}, n = () => {
|
|
10151
10336
|
if (t.absolute !== this.cwd) {
|
|
10152
|
-
let h = f(
|
|
10337
|
+
let h = f(import_node_path9.default.dirname(String(t.absolute)));
|
|
10153
10338
|
if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
|
|
10154
10339
|
if (a) {
|
|
10155
10340
|
this[O](a, t), i();
|
|
@@ -10160,7 +10345,7 @@ var Xt = class extends rt {
|
|
|
10160
10345
|
}
|
|
10161
10346
|
o();
|
|
10162
10347
|
}, o = () => {
|
|
10163
|
-
|
|
10348
|
+
import_node_fs7.default.lstat(String(t.absolute), (h, a) => {
|
|
10164
10349
|
if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
|
|
10165
10350
|
this[Ls](t), i();
|
|
10166
10351
|
return;
|
|
@@ -10169,9 +10354,9 @@ var Xt = class extends rt {
|
|
|
10169
10354
|
if (a.isDirectory()) {
|
|
10170
10355
|
if (t.type === "Directory") {
|
|
10171
10356
|
let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
|
|
10172
|
-
return l ?
|
|
10357
|
+
return l ? import_node_fs7.default.chmod(String(t.absolute), Number(t.mode), c) : c();
|
|
10173
10358
|
}
|
|
10174
|
-
if (t.absolute !== this.cwd) return
|
|
10359
|
+
if (t.absolute !== this.cwd) return import_node_fs7.default.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
10175
10360
|
}
|
|
10176
10361
|
if (t.absolute === this.cwd) return this[P](null, t, i);
|
|
10177
10362
|
mo(String(t.absolute), (l) => this[P](l ?? null, t, i));
|
|
@@ -10199,7 +10384,7 @@ var Xt = class extends rt {
|
|
|
10199
10384
|
}
|
|
10200
10385
|
}
|
|
10201
10386
|
[gi](t, e, i, r) {
|
|
10202
|
-
|
|
10387
|
+
import_node_fs7.default[i](e, String(t.absolute), (n) => {
|
|
10203
10388
|
n ? this[O](n, t) : (this[$t](), t.resume()), r();
|
|
10204
10389
|
});
|
|
10205
10390
|
}
|
|
@@ -10224,23 +10409,23 @@ var xe = class extends Xt {
|
|
|
10224
10409
|
this[Oe] = true;
|
|
10225
10410
|
}
|
|
10226
10411
|
if (t.absolute !== this.cwd) {
|
|
10227
|
-
let n = f(
|
|
10412
|
+
let n = f(import_node_path9.default.dirname(String(t.absolute)));
|
|
10228
10413
|
if (n !== this.cwd) {
|
|
10229
10414
|
let o = this[yt](n, this.dmode);
|
|
10230
10415
|
if (o) return this[O](o, t);
|
|
10231
10416
|
}
|
|
10232
10417
|
}
|
|
10233
|
-
let [e, i] = ye(() =>
|
|
10418
|
+
let [e, i] = ye(() => import_node_fs7.default.lstatSync(String(t.absolute)));
|
|
10234
10419
|
if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ls](t);
|
|
10235
10420
|
if (e || this[Os](t, i)) return this[P](null, t);
|
|
10236
10421
|
if (i.isDirectory()) {
|
|
10237
10422
|
if (t.type === "Directory") {
|
|
10238
10423
|
let o = this.chmod && t.mode && (i.mode & 4095) !== t.mode, [h] = o ? ye(() => {
|
|
10239
|
-
|
|
10424
|
+
import_node_fs7.default.chmodSync(String(t.absolute), Number(t.mode));
|
|
10240
10425
|
}) : [];
|
|
10241
10426
|
return this[P](h, t);
|
|
10242
10427
|
}
|
|
10243
|
-
let [n] = ye(() =>
|
|
10428
|
+
let [n] = ye(() => import_node_fs7.default.rmdirSync(String(t.absolute)));
|
|
10244
10429
|
this[P](n, t);
|
|
10245
10430
|
}
|
|
10246
10431
|
let [r] = t.absolute === this.cwd ? [] : ye(() => po(String(t.absolute)));
|
|
@@ -10250,21 +10435,21 @@ var xe = class extends Xt {
|
|
|
10250
10435
|
let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
|
|
10251
10436
|
let a;
|
|
10252
10437
|
try {
|
|
10253
|
-
|
|
10438
|
+
import_node_fs7.default.closeSync(n);
|
|
10254
10439
|
} catch (l) {
|
|
10255
10440
|
a = l;
|
|
10256
10441
|
}
|
|
10257
10442
|
(h || a) && this[O](h || a, t), e();
|
|
10258
10443
|
}, n;
|
|
10259
10444
|
try {
|
|
10260
|
-
n =
|
|
10445
|
+
n = import_node_fs7.default.openSync(String(t.absolute), ms(t.size), i);
|
|
10261
10446
|
} catch (h) {
|
|
10262
10447
|
return r(h);
|
|
10263
10448
|
}
|
|
10264
10449
|
let o = this.transform && this.transform(t) || t;
|
|
10265
10450
|
o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
|
|
10266
10451
|
try {
|
|
10267
|
-
|
|
10452
|
+
import_node_fs7.default.writeSync(n, h, 0, h.length);
|
|
10268
10453
|
} catch (a) {
|
|
10269
10454
|
r(a);
|
|
10270
10455
|
}
|
|
@@ -10273,10 +10458,10 @@ var xe = class extends Xt {
|
|
|
10273
10458
|
if (t.mtime && !this.noMtime) {
|
|
10274
10459
|
let a = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
|
|
10275
10460
|
try {
|
|
10276
|
-
|
|
10461
|
+
import_node_fs7.default.futimesSync(n, a, l);
|
|
10277
10462
|
} catch (c) {
|
|
10278
10463
|
try {
|
|
10279
|
-
|
|
10464
|
+
import_node_fs7.default.utimesSync(String(t.absolute), a, l);
|
|
10280
10465
|
} catch {
|
|
10281
10466
|
h = c;
|
|
10282
10467
|
}
|
|
@@ -10285,10 +10470,10 @@ var xe = class extends Xt {
|
|
|
10285
10470
|
if (this[ge](t)) {
|
|
10286
10471
|
let a = this[be](t), l = this[_e](t);
|
|
10287
10472
|
try {
|
|
10288
|
-
|
|
10473
|
+
import_node_fs7.default.fchownSync(n, Number(a), Number(l));
|
|
10289
10474
|
} catch (c) {
|
|
10290
10475
|
try {
|
|
10291
|
-
|
|
10476
|
+
import_node_fs7.default.chownSync(String(t.absolute), Number(a), Number(l));
|
|
10292
10477
|
} catch {
|
|
10293
10478
|
h = h || c;
|
|
10294
10479
|
}
|
|
@@ -10304,11 +10489,11 @@ var xe = class extends Xt {
|
|
|
10304
10489
|
return;
|
|
10305
10490
|
}
|
|
10306
10491
|
if (t.mtime && !this.noMtime) try {
|
|
10307
|
-
|
|
10492
|
+
import_node_fs7.default.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
|
|
10308
10493
|
} catch {
|
|
10309
10494
|
}
|
|
10310
10495
|
if (this[ge](t)) try {
|
|
10311
|
-
|
|
10496
|
+
import_node_fs7.default.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
|
|
10312
10497
|
} catch {
|
|
10313
10498
|
}
|
|
10314
10499
|
e(), t.resume();
|
|
@@ -10324,30 +10509,30 @@ var xe = class extends Xt {
|
|
|
10324
10509
|
if (this.preservePaths || i.length === 0) return r();
|
|
10325
10510
|
let o = e;
|
|
10326
10511
|
for (let h of i) {
|
|
10327
|
-
o =
|
|
10328
|
-
let [a, l] = ye(() =>
|
|
10512
|
+
o = import_node_path9.default.resolve(o, h);
|
|
10513
|
+
let [a, l] = ye(() => import_node_fs7.default.lstatSync(o));
|
|
10329
10514
|
if (a) return r();
|
|
10330
|
-
if (l.isSymbolicLink()) return n(new St(o,
|
|
10515
|
+
if (l.isSymbolicLink()) return n(new St(o, import_node_path9.default.resolve(e, i.join("/"))));
|
|
10331
10516
|
}
|
|
10332
10517
|
r();
|
|
10333
10518
|
}
|
|
10334
10519
|
[gi](t, e, i, r) {
|
|
10335
10520
|
let n = `${i}Sync`;
|
|
10336
10521
|
try {
|
|
10337
|
-
|
|
10522
|
+
import_node_fs7.default[n](e, String(t.absolute)), r(), t.resume();
|
|
10338
10523
|
} catch (o) {
|
|
10339
10524
|
return this[O](o, t);
|
|
10340
10525
|
}
|
|
10341
10526
|
}
|
|
10342
10527
|
};
|
|
10343
10528
|
var Eo = (s3) => {
|
|
10344
|
-
let t = new xe(s3), e = s3.file, i =
|
|
10529
|
+
let t = new xe(s3), e = s3.file, i = import_node_fs6.default.statSync(e), r = s3.maxReadSize || 16 * 1024 * 1024;
|
|
10345
10530
|
new Be(e, { readSize: r, size: i.size }).pipe(t);
|
|
10346
10531
|
};
|
|
10347
10532
|
var wo = (s3, t) => {
|
|
10348
10533
|
let e = new Xt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
|
|
10349
10534
|
return new Promise((o, h) => {
|
|
10350
|
-
e.on("error", h), e.on("close", o),
|
|
10535
|
+
e.on("error", h), e.on("close", o), import_node_fs6.default.stat(r, (a, l) => {
|
|
10351
10536
|
if (a) h(a);
|
|
10352
10537
|
else {
|
|
10353
10538
|
let c = new _t(r, { readSize: i, size: l.size });
|
|
@@ -10363,15 +10548,15 @@ var yo = (s3, t) => {
|
|
|
10363
10548
|
let e = new kt(s3), i = true, r, n;
|
|
10364
10549
|
try {
|
|
10365
10550
|
try {
|
|
10366
|
-
r =
|
|
10551
|
+
r = import_node_fs10.default.openSync(s3.file, "r+");
|
|
10367
10552
|
} catch (a) {
|
|
10368
|
-
if (a?.code === "ENOENT") r =
|
|
10553
|
+
if (a?.code === "ENOENT") r = import_node_fs10.default.openSync(s3.file, "w+");
|
|
10369
10554
|
else throw a;
|
|
10370
10555
|
}
|
|
10371
|
-
let o =
|
|
10556
|
+
let o = import_node_fs10.default.fstatSync(r), h = Buffer.alloc(512);
|
|
10372
10557
|
t: for (n = 0; n < o.size; n += 512) {
|
|
10373
10558
|
for (let c = 0, d = 0; c < 512; c += d) {
|
|
10374
|
-
if (d =
|
|
10559
|
+
if (d = import_node_fs10.default.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
|
|
10375
10560
|
if (!d) break t;
|
|
10376
10561
|
}
|
|
10377
10562
|
let a = new F(h);
|
|
@@ -10383,7 +10568,7 @@ var yo = (s3, t) => {
|
|
|
10383
10568
|
i = false, Ro(s3, e, n, r, t);
|
|
10384
10569
|
} finally {
|
|
10385
10570
|
if (i) try {
|
|
10386
|
-
|
|
10571
|
+
import_node_fs10.default.closeSync(r);
|
|
10387
10572
|
} catch {
|
|
10388
10573
|
}
|
|
10389
10574
|
}
|
|
@@ -10396,29 +10581,29 @@ var go = (s3, t) => {
|
|
|
10396
10581
|
t = Array.from(t);
|
|
10397
10582
|
let e = new wt(s3), i = (n, o, h) => {
|
|
10398
10583
|
let a = (T, D) => {
|
|
10399
|
-
T ?
|
|
10584
|
+
T ? import_node_fs10.default.close(n, (E) => h(T)) : h(null, D);
|
|
10400
10585
|
}, l = 0;
|
|
10401
10586
|
if (o === 0) return a(null, 0);
|
|
10402
10587
|
let c = 0, d = Buffer.alloc(512), y = (T, D) => {
|
|
10403
10588
|
if (T || D === void 0) return a(T);
|
|
10404
|
-
if (c += D, c < 512 && D) return
|
|
10589
|
+
if (c += D, c < 512 && D) return import_node_fs10.default.read(n, d, c, d.length - c, l + c, y);
|
|
10405
10590
|
if (l === 0 && d[0] === 31 && d[1] === 139) return a(new Error("cannot append to compressed archives"));
|
|
10406
10591
|
if (c < 512) return a(null, l);
|
|
10407
10592
|
let E = new F(d);
|
|
10408
10593
|
if (!E.cksumValid) return a(null, l);
|
|
10409
10594
|
let x = 512 * Math.ceil((E.size ?? 0) / 512);
|
|
10410
10595
|
if (l + x + 512 > o || (l += x + 512, l >= o)) return a(null, l);
|
|
10411
|
-
s3.mtimeCache && E.mtime && s3.mtimeCache.set(String(E.path), E.mtime), c = 0,
|
|
10596
|
+
s3.mtimeCache && E.mtime && s3.mtimeCache.set(String(E.path), E.mtime), c = 0, import_node_fs10.default.read(n, d, 0, 512, l, y);
|
|
10412
10597
|
};
|
|
10413
|
-
|
|
10598
|
+
import_node_fs10.default.read(n, d, 0, 512, l, y);
|
|
10414
10599
|
};
|
|
10415
10600
|
return new Promise((n, o) => {
|
|
10416
10601
|
e.on("error", o);
|
|
10417
10602
|
let h = "r+", a = (l, c) => {
|
|
10418
|
-
if (l && l.code === "ENOENT" && h === "r+") return h = "w+",
|
|
10603
|
+
if (l && l.code === "ENOENT" && h === "r+") return h = "w+", import_node_fs10.default.open(s3.file, h, a);
|
|
10419
10604
|
if (l || !c) return o(l);
|
|
10420
|
-
|
|
10421
|
-
if (d) return
|
|
10605
|
+
import_node_fs10.default.fstat(c, (d, y) => {
|
|
10606
|
+
if (d) return import_node_fs10.default.close(c, () => o(d));
|
|
10422
10607
|
i(c, y.size, (T, D) => {
|
|
10423
10608
|
if (T) return o(T);
|
|
10424
10609
|
let E = new et(s3.file, { fd: c, start: D });
|
|
@@ -10426,16 +10611,16 @@ var go = (s3, t) => {
|
|
|
10426
10611
|
});
|
|
10427
10612
|
});
|
|
10428
10613
|
};
|
|
10429
|
-
|
|
10614
|
+
import_node_fs10.default.open(s3.file, h, a);
|
|
10430
10615
|
});
|
|
10431
10616
|
};
|
|
10432
10617
|
var bo = (s3, t) => {
|
|
10433
10618
|
t.forEach((e) => {
|
|
10434
|
-
e.charAt(0) === "@" ? Ct({ file:
|
|
10619
|
+
e.charAt(0) === "@" ? Ct({ file: import_node_path13.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
10435
10620
|
}), s3.end();
|
|
10436
10621
|
};
|
|
10437
10622
|
var _o = async (s3, t) => {
|
|
10438
|
-
for (let e of t) e.charAt(0) === "@" ? await Ct({ file:
|
|
10623
|
+
for (let e of t) e.charAt(0) === "@" ? await Ct({ file: import_node_path13.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
|
|
10439
10624
|
s3.end();
|
|
10440
10625
|
};
|
|
10441
10626
|
var vt = K(yo, go, () => {
|
|
@@ -10487,7 +10672,7 @@ async function extractRuntimePackage(archive, destination) {
|
|
|
10487
10672
|
if (violation) throw violation;
|
|
10488
10673
|
}
|
|
10489
10674
|
function validateRuntimeTree(root, expected) {
|
|
10490
|
-
const pkg = JSON.parse((0,
|
|
10675
|
+
const pkg = JSON.parse((0, import_node_fs11.readFileSync)((0, import_node_path14.join)(root, "package.json"), "utf8"));
|
|
10491
10676
|
if (!CLI_PACKAGE_NAMES.includes(pkg.name ?? "") || !pkg.version || !pkg.sumiBuild || !BUILD_ID_PATTERN.test(pkg.sumiBuild)) {
|
|
10492
10677
|
throw new Error("\u9700\u8981\u542B\u6784\u5EFA\u8EAB\u4EFD\u7684 pnpm pack:cli \u4EA7\u7269");
|
|
10493
10678
|
}
|
|
@@ -10501,20 +10686,27 @@ function validateRuntimeTree(root, expected) {
|
|
|
10501
10686
|
|
|
10502
10687
|
// src/launcher.ts
|
|
10503
10688
|
function projectRoot(scriptPath) {
|
|
10504
|
-
return (0,
|
|
10689
|
+
return (0, import_node_path15.resolve)((0, import_node_path15.dirname)(scriptPath), "../..");
|
|
10505
10690
|
}
|
|
10506
10691
|
function readManifest(repo) {
|
|
10507
|
-
const path = (0,
|
|
10692
|
+
const path = (0, import_node_path15.join)(repo, RUNTIME_MANIFEST);
|
|
10508
10693
|
let value;
|
|
10509
10694
|
try {
|
|
10510
|
-
value = JSON.parse((0,
|
|
10695
|
+
value = JSON.parse((0, import_node_fs12.readFileSync)(path, "utf8"));
|
|
10511
10696
|
} catch (error) {
|
|
10512
10697
|
throw new Error(`\u65E0\u6CD5\u8BFB\u53D6 runtime \u6E05\u5355 ${RUNTIME_MANIFEST}\uFF1A${error.message}`);
|
|
10513
10698
|
}
|
|
10514
10699
|
const manifest = parseRuntimeManifest(value, repo);
|
|
10515
10700
|
const configPath = configFile(repo);
|
|
10516
10701
|
if (!configPath) throw new Error(`\u7F3A\u5C11\u9879\u76EE\u914D\u7F6E ${CONFIG_FILES[0]}`);
|
|
10517
|
-
|
|
10702
|
+
let config;
|
|
10703
|
+
try {
|
|
10704
|
+
config = loadConfig(repo);
|
|
10705
|
+
} catch (error) {
|
|
10706
|
+
if (error instanceof ProjectConfigError) return manifest;
|
|
10707
|
+
if (!(error instanceof RuntimeIdentityError)) throw error;
|
|
10708
|
+
config = error.config;
|
|
10709
|
+
}
|
|
10518
10710
|
if (config.sumi !== manifest.version || config.sumiBuild !== manifest.build) {
|
|
10519
10711
|
throw new Error(`runtime \u6E05\u5355\u4E0E ${configPath} \u4E0D\u4E00\u81F4\uFF1A${manifest.version}\uFF08${manifest.build}\uFF09`);
|
|
10520
10712
|
}
|
|
@@ -10523,38 +10715,38 @@ function readManifest(repo) {
|
|
|
10523
10715
|
function validRuntime(root, manifest) {
|
|
10524
10716
|
try {
|
|
10525
10717
|
validateRuntimeTree(root, { version: manifest.version, build: manifest.build });
|
|
10526
|
-
return (0,
|
|
10718
|
+
return (0, import_node_fs12.existsSync)((0, import_node_path15.join)(root, "dist/bin.js"));
|
|
10527
10719
|
} catch {
|
|
10528
10720
|
return false;
|
|
10529
10721
|
}
|
|
10530
10722
|
}
|
|
10531
10723
|
async function prepareRuntime(repo, manifest = readManifest(repo)) {
|
|
10532
|
-
const archive = (0,
|
|
10533
|
-
if (!(0,
|
|
10724
|
+
const archive = (0, import_node_path15.resolve)(repo, ...manifest.archive.split("/"));
|
|
10725
|
+
if (!(0, import_node_fs12.existsSync)(archive)) throw new Error(`\u627E\u4E0D\u5230\u9879\u76EE Sumi \u5B89\u88C5\u5305\uFF1A${manifest.archive}`);
|
|
10534
10726
|
const archiveSha = fileSha256(archive);
|
|
10535
10727
|
if (archiveSha !== manifest.archiveSha256) {
|
|
10536
10728
|
throw new Error(`\u9879\u76EE Sumi \u5B89\u88C5\u5305 SHA-256 \u4E0D\u5339\u914D\uFF1A\u58F0\u660E ${manifest.archiveSha256}\uFF0C\u5B9E\u9645 ${archiveSha}`);
|
|
10537
10729
|
}
|
|
10538
10730
|
const hex = manifest.build.slice("sha256:".length);
|
|
10539
|
-
const runtimeRoot = (0,
|
|
10540
|
-
const final = (0,
|
|
10731
|
+
const runtimeRoot = (0, import_node_path15.join)(repo, ".sumi/runtime");
|
|
10732
|
+
const final = (0, import_node_path15.join)(runtimeRoot, hex);
|
|
10541
10733
|
if (validRuntime(final, manifest)) return final;
|
|
10542
|
-
(0,
|
|
10543
|
-
(0,
|
|
10544
|
-
const temporary = (0,
|
|
10734
|
+
(0, import_node_fs12.rmSync)(final, { recursive: true, force: true });
|
|
10735
|
+
(0, import_node_fs12.mkdirSync)(runtimeRoot, { recursive: true });
|
|
10736
|
+
const temporary = (0, import_node_fs12.mkdtempSync)((0, import_node_path15.join)(runtimeRoot, `.tmp-${hex}-${process.pid}-${(0, import_node_crypto4.randomBytes)(3).toString("hex")}-`));
|
|
10545
10737
|
try {
|
|
10546
10738
|
await extractRuntimePackage(archive, temporary);
|
|
10547
|
-
const extracted = (0,
|
|
10739
|
+
const extracted = (0, import_node_path15.join)(temporary, "package");
|
|
10548
10740
|
if (!validRuntime(extracted, manifest)) throw new Error("\u89E3\u5305\u540E\u7684 Sumi runtime \u7248\u672C\u6216\u6784\u5EFA\u8EAB\u4EFD\u65E0\u6548");
|
|
10549
10741
|
try {
|
|
10550
|
-
(0,
|
|
10742
|
+
(0, import_node_fs12.renameSync)(extracted, final);
|
|
10551
10743
|
} catch (error) {
|
|
10552
10744
|
if (!validRuntime(final, manifest)) throw error;
|
|
10553
10745
|
}
|
|
10554
10746
|
if (!validRuntime(final, manifest)) throw new Error("Sumi runtime \u539F\u5B50\u5B89\u88C5\u540E\u6821\u9A8C\u5931\u8D25");
|
|
10555
10747
|
return final;
|
|
10556
10748
|
} finally {
|
|
10557
|
-
(0,
|
|
10749
|
+
(0, import_node_fs12.rmSync)(temporary, { recursive: true, force: true });
|
|
10558
10750
|
}
|
|
10559
10751
|
}
|
|
10560
10752
|
function exitCode(code, signal) {
|
|
@@ -10565,7 +10757,7 @@ function exitCode(code, signal) {
|
|
|
10565
10757
|
async function runLauncher(args = process.argv.slice(2), scriptPath = __filename) {
|
|
10566
10758
|
const repo = projectRoot(scriptPath);
|
|
10567
10759
|
const runtime = await prepareRuntime(repo);
|
|
10568
|
-
const child = (0, import_node_child_process.spawn)(process.execPath, [(0,
|
|
10760
|
+
const child = (0, import_node_child_process.spawn)(process.execPath, [(0, import_node_path15.join)(runtime, "dist/bin.js"), ...args], {
|
|
10569
10761
|
cwd: process.cwd(),
|
|
10570
10762
|
stdio: "inherit",
|
|
10571
10763
|
windowsHide: true
|