pantheon-cli 0.2.21 → 0.2.25
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/pantheon.mjs +92 -40
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -2986,7 +2986,7 @@ var require_compile = __commonJS({
|
|
|
2986
2986
|
const schOrFunc = root.refs[ref];
|
|
2987
2987
|
if (schOrFunc)
|
|
2988
2988
|
return schOrFunc;
|
|
2989
|
-
let _sch =
|
|
2989
|
+
let _sch = resolve3.call(this, root, ref);
|
|
2990
2990
|
if (_sch === void 0) {
|
|
2991
2991
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
2992
2992
|
const { schemaId } = this.opts;
|
|
@@ -3013,7 +3013,7 @@ var require_compile = __commonJS({
|
|
|
3013
3013
|
function sameSchemaEnv(s1, s2) {
|
|
3014
3014
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3015
3015
|
}
|
|
3016
|
-
function
|
|
3016
|
+
function resolve3(root, ref) {
|
|
3017
3017
|
let sch;
|
|
3018
3018
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3019
3019
|
ref = sch;
|
|
@@ -3640,11 +3640,11 @@ var require_fast_uri = __commonJS({
|
|
|
3640
3640
|
normalizeString(uri, options);
|
|
3641
3641
|
} else if (typeof uri === "object") {
|
|
3642
3642
|
uri = /** @type {T} */
|
|
3643
|
-
|
|
3643
|
+
parse4(serialize2(uri, options), options);
|
|
3644
3644
|
}
|
|
3645
3645
|
return uri;
|
|
3646
3646
|
}
|
|
3647
|
-
function
|
|
3647
|
+
function resolve3(baseURI, relativeURI, options) {
|
|
3648
3648
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3649
3649
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
|
|
3650
3650
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -3658,8 +3658,8 @@ var require_fast_uri = __commonJS({
|
|
|
3658
3658
|
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
3659
3659
|
const target = {};
|
|
3660
3660
|
if (!skipNormalization) {
|
|
3661
|
-
base =
|
|
3662
|
-
relative2 =
|
|
3661
|
+
base = parse4(serialize2(base, options), options);
|
|
3662
|
+
relative2 = parse4(serialize2(relative2, options), options);
|
|
3663
3663
|
}
|
|
3664
3664
|
options = options || {};
|
|
3665
3665
|
if (!options.tolerant && relative2.scheme) {
|
|
@@ -3903,7 +3903,7 @@ var require_fast_uri = __commonJS({
|
|
|
3903
3903
|
}
|
|
3904
3904
|
return { parsed, malformedAuthorityOrPort };
|
|
3905
3905
|
}
|
|
3906
|
-
function
|
|
3906
|
+
function parse4(uri, opts) {
|
|
3907
3907
|
return parseWithStatus(uri, opts).parsed;
|
|
3908
3908
|
}
|
|
3909
3909
|
function normalizeString(uri, opts) {
|
|
@@ -3928,11 +3928,11 @@ var require_fast_uri = __commonJS({
|
|
|
3928
3928
|
var fastUri = {
|
|
3929
3929
|
SCHEMES,
|
|
3930
3930
|
normalize,
|
|
3931
|
-
resolve:
|
|
3931
|
+
resolve: resolve3,
|
|
3932
3932
|
resolveComponent,
|
|
3933
3933
|
equal,
|
|
3934
3934
|
serialize: serialize2,
|
|
3935
|
-
parse:
|
|
3935
|
+
parse: parse4
|
|
3936
3936
|
};
|
|
3937
3937
|
module.exports = fastUri;
|
|
3938
3938
|
module.exports.default = fastUri;
|
|
@@ -6928,7 +6928,7 @@ var require_content_type = __commonJS({
|
|
|
6928
6928
|
var QUOTE_REGEXP = /([\\"])/g;
|
|
6929
6929
|
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
6930
6930
|
exports.format = format;
|
|
6931
|
-
exports.parse =
|
|
6931
|
+
exports.parse = parse4;
|
|
6932
6932
|
function format(obj) {
|
|
6933
6933
|
if (!obj || typeof obj !== "object") {
|
|
6934
6934
|
throw new TypeError("argument obj is required");
|
|
@@ -6952,7 +6952,7 @@ var require_content_type = __commonJS({
|
|
|
6952
6952
|
}
|
|
6953
6953
|
return string3;
|
|
6954
6954
|
}
|
|
6955
|
-
function
|
|
6955
|
+
function parse4(string3) {
|
|
6956
6956
|
if (!string3) {
|
|
6957
6957
|
throw new TypeError("argument string is required");
|
|
6958
6958
|
}
|
|
@@ -19128,7 +19128,7 @@ var Protocol = class {
|
|
|
19128
19128
|
return;
|
|
19129
19129
|
}
|
|
19130
19130
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
19131
|
-
await new Promise((
|
|
19131
|
+
await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
|
|
19132
19132
|
options?.signal?.throwIfAborted();
|
|
19133
19133
|
}
|
|
19134
19134
|
} catch (error2) {
|
|
@@ -19145,7 +19145,7 @@ var Protocol = class {
|
|
|
19145
19145
|
*/
|
|
19146
19146
|
request(request, resultSchema, options) {
|
|
19147
19147
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
19148
|
-
return new Promise((
|
|
19148
|
+
return new Promise((resolve3, reject) => {
|
|
19149
19149
|
const earlyReject = (error2) => {
|
|
19150
19150
|
reject(error2);
|
|
19151
19151
|
};
|
|
@@ -19223,7 +19223,7 @@ var Protocol = class {
|
|
|
19223
19223
|
if (!parseResult.success) {
|
|
19224
19224
|
reject(parseResult.error);
|
|
19225
19225
|
} else {
|
|
19226
|
-
|
|
19226
|
+
resolve3(parseResult.data);
|
|
19227
19227
|
}
|
|
19228
19228
|
} catch (error2) {
|
|
19229
19229
|
reject(error2);
|
|
@@ -19484,12 +19484,12 @@ var Protocol = class {
|
|
|
19484
19484
|
}
|
|
19485
19485
|
} catch {
|
|
19486
19486
|
}
|
|
19487
|
-
return new Promise((
|
|
19487
|
+
return new Promise((resolve3, reject) => {
|
|
19488
19488
|
if (signal.aborted) {
|
|
19489
19489
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
19490
19490
|
return;
|
|
19491
19491
|
}
|
|
19492
|
-
const timeoutId = setTimeout(
|
|
19492
|
+
const timeoutId = setTimeout(resolve3, interval);
|
|
19493
19493
|
signal.addEventListener("abort", () => {
|
|
19494
19494
|
clearTimeout(timeoutId);
|
|
19495
19495
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -20580,7 +20580,7 @@ var McpServer = class {
|
|
|
20580
20580
|
let task = createTaskResult.task;
|
|
20581
20581
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
20582
20582
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
20583
|
-
await new Promise((
|
|
20583
|
+
await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
|
|
20584
20584
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
20585
20585
|
if (!updatedTask) {
|
|
20586
20586
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -21244,12 +21244,12 @@ var StdioServerTransport = class {
|
|
|
21244
21244
|
this.onclose?.();
|
|
21245
21245
|
}
|
|
21246
21246
|
send(message) {
|
|
21247
|
-
return new Promise((
|
|
21247
|
+
return new Promise((resolve3) => {
|
|
21248
21248
|
const json = serializeMessage(message);
|
|
21249
21249
|
if (this._stdout.write(json)) {
|
|
21250
|
-
|
|
21250
|
+
resolve3();
|
|
21251
21251
|
} else {
|
|
21252
|
-
this._stdout.once("drain",
|
|
21252
|
+
this._stdout.once("drain", resolve3);
|
|
21253
21253
|
}
|
|
21254
21254
|
});
|
|
21255
21255
|
}
|
|
@@ -22011,6 +22011,15 @@ function dirsIn(root) {
|
|
|
22011
22011
|
if (!existsSync3(root)) return [];
|
|
22012
22012
|
return readdirSync3(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => ({ name: entry.name, dir: join3(root, entry.name) }));
|
|
22013
22013
|
}
|
|
22014
|
+
function hasContent(dir) {
|
|
22015
|
+
try {
|
|
22016
|
+
return readdirSync3(dir, { withFileTypes: true }).some(
|
|
22017
|
+
(entry) => entry.isDirectory() ? hasContent(join3(dir, entry.name)) : true
|
|
22018
|
+
);
|
|
22019
|
+
} catch {
|
|
22020
|
+
return false;
|
|
22021
|
+
}
|
|
22022
|
+
}
|
|
22014
22023
|
function sharedMatches(home, slug) {
|
|
22015
22024
|
return dirsIn(sharedHome(home)).map((owner) => ({ owner: owner.name, root: join3(owner.dir, slug) })).filter((match) => existsSync3(match.root));
|
|
22016
22025
|
}
|
|
@@ -22933,11 +22942,9 @@ function summarise(dir, slug, name, extra = {}) {
|
|
|
22933
22942
|
};
|
|
22934
22943
|
}
|
|
22935
22944
|
function listSpaces(home) {
|
|
22936
|
-
const own = dirsIn(join3(resolve(home), "spaces")).map(
|
|
22937
|
-
(entry) => summarise(entry.dir, entry.name, entry.name)
|
|
22938
|
-
);
|
|
22945
|
+
const own = dirsIn(join3(resolve(home), "spaces")).filter((entry) => hasContent(entry.dir)).map((entry) => summarise(entry.dir, entry.name, entry.name));
|
|
22939
22946
|
const shared = dirsIn(sharedHome(home)).flatMap(
|
|
22940
|
-
(owner) => dirsIn(owner.dir).map(
|
|
22947
|
+
(owner) => dirsIn(owner.dir).filter((space) => hasContent(space.dir)).map(
|
|
22941
22948
|
(space) => summarise(space.dir, `${owner.name}/${space.name}`, space.name, {
|
|
22942
22949
|
owner: owner.name,
|
|
22943
22950
|
shared: true
|
|
@@ -23192,7 +23199,7 @@ function saveMachineConfig(config2, credentials) {
|
|
|
23192
23199
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
23193
23200
|
import { existsSync as existsSync5, mkdirSync as mkdirSync4, unlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
23194
23201
|
import { homedir as homedir4, tmpdir } from "node:os";
|
|
23195
|
-
import { dirname, join as join5 } from "node:path";
|
|
23202
|
+
import { dirname, join as join5, resolve as resolve2 } from "node:path";
|
|
23196
23203
|
function gitEnv(extra = {}) {
|
|
23197
23204
|
return {
|
|
23198
23205
|
...process.env,
|
|
@@ -23268,12 +23275,29 @@ esac
|
|
|
23268
23275
|
}
|
|
23269
23276
|
}
|
|
23270
23277
|
}
|
|
23278
|
+
function boundElsewhere(home) {
|
|
23279
|
+
try {
|
|
23280
|
+
const stored = loadMachineConfig();
|
|
23281
|
+
if (!stored?.config.cloneUrl) return null;
|
|
23282
|
+
if (resolve2(stored.config.home) !== resolve2(home)) return null;
|
|
23283
|
+
const origin = git(home, ["remote", "get-url", "origin"]);
|
|
23284
|
+
if (origin === stored.config.cloneUrl) return null;
|
|
23285
|
+
return `This vault pushes to ${origin}, but this machine is connected to ${stored.config.repo}. Run pantheon connect <code> to switch it over \u2014 that sets the current vault aside instead of rewriting it.`;
|
|
23286
|
+
} catch {
|
|
23287
|
+
return null;
|
|
23288
|
+
}
|
|
23289
|
+
}
|
|
23271
23290
|
function syncVaultWithToken(home, token, opts = {}) {
|
|
23272
23291
|
const result = { ok: false, committed: false, pulled: false, pushed: false };
|
|
23273
23292
|
if (!existsSync5(join5(home, ".git"))) {
|
|
23274
23293
|
result.error = "Vault is not a git repo.";
|
|
23275
23294
|
return result;
|
|
23276
23295
|
}
|
|
23296
|
+
const bound = boundElsewhere(home);
|
|
23297
|
+
if (bound) {
|
|
23298
|
+
result.error = bound;
|
|
23299
|
+
return result;
|
|
23300
|
+
}
|
|
23277
23301
|
try {
|
|
23278
23302
|
return withGitAuth(token, (env) => {
|
|
23279
23303
|
const auth = [
|
|
@@ -24375,17 +24399,17 @@ async function connect(opts) {
|
|
|
24375
24399
|
{ machineSecret: body.machineSecret }
|
|
24376
24400
|
);
|
|
24377
24401
|
mkdirSync6(home, { recursive: true });
|
|
24378
|
-
const
|
|
24402
|
+
const auth = authArgs();
|
|
24379
24403
|
const quiet = { stdio: ["ignore", "pipe", "pipe"] };
|
|
24380
24404
|
const fresh = !existsSync7(join7(home, ".git"));
|
|
24381
24405
|
let archived = "";
|
|
24382
24406
|
if (fresh) {
|
|
24383
24407
|
process.stdout.write(" Cloning the vault\u2026\n");
|
|
24384
|
-
execFileSync3("git", [
|
|
24408
|
+
execFileSync3("git", [...auth, "clone", body.cloneUrl, home], quiet);
|
|
24385
24409
|
} else {
|
|
24386
|
-
archived = syncVault2(home, body.cloneUrl,
|
|
24410
|
+
archived = syncVault2(home, body.cloneUrl, auth, quiet);
|
|
24387
24411
|
}
|
|
24388
|
-
|
|
24412
|
+
claimCredentials(home, quiet);
|
|
24389
24413
|
execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
|
|
24390
24414
|
execFileSync3("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
|
|
24391
24415
|
let written = [];
|
|
@@ -24418,8 +24442,9 @@ async function connect(opts) {
|
|
|
24418
24442
|
)
|
|
24419
24443
|
);
|
|
24420
24444
|
}
|
|
24421
|
-
function syncVault2(home, cloneUrl,
|
|
24422
|
-
const git2 = (...args) => execFileSync3("git", [
|
|
24445
|
+
function syncVault2(home, cloneUrl, auth, quiet) {
|
|
24446
|
+
const git2 = (...args) => execFileSync3("git", [...auth, "-C", home, ...args], quiet);
|
|
24447
|
+
retarget(home, cloneUrl, quiet);
|
|
24423
24448
|
try {
|
|
24424
24449
|
git2("pull", "--ff-only");
|
|
24425
24450
|
return "";
|
|
@@ -24433,11 +24458,18 @@ function syncVault2(home, cloneUrl, helper, quiet) {
|
|
|
24433
24458
|
}
|
|
24434
24459
|
const stamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
24435
24460
|
const archive = `${home}-${stamp2}`;
|
|
24436
|
-
process.stdout.write(" Vault belongs to a
|
|
24461
|
+
process.stdout.write(" Vault belongs to a different repo; setting it aside\u2026\n");
|
|
24437
24462
|
renameSync2(home, archive);
|
|
24438
|
-
execFileSync3("git", [
|
|
24463
|
+
execFileSync3("git", [...auth, "clone", cloneUrl, home], quiet);
|
|
24439
24464
|
return archive;
|
|
24440
24465
|
}
|
|
24466
|
+
function retarget(home, cloneUrl, quiet) {
|
|
24467
|
+
try {
|
|
24468
|
+
execFileSync3("git", ["-C", home, "remote", "set-url", "origin", cloneUrl], quiet);
|
|
24469
|
+
} catch {
|
|
24470
|
+
execFileSync3("git", ["-C", home, "remote", "add", "origin", cloneUrl], quiet);
|
|
24471
|
+
}
|
|
24472
|
+
}
|
|
24441
24473
|
function sharesHistory(home) {
|
|
24442
24474
|
try {
|
|
24443
24475
|
const upstream = execFileSync3("git", ["-C", home, "rev-parse", "@{u}"], {
|
|
@@ -24459,6 +24491,17 @@ function vaultNote(fresh, archived) {
|
|
|
24459
24491
|
function credentialHelperCommand() {
|
|
24460
24492
|
return "!pantheon git-credential";
|
|
24461
24493
|
}
|
|
24494
|
+
function authArgs() {
|
|
24495
|
+
return ["-c", "credential.helper=", "-c", `credential.helper=${credentialHelperCommand()}`];
|
|
24496
|
+
}
|
|
24497
|
+
function claimCredentials(home, quiet) {
|
|
24498
|
+
execFileSync3("git", ["-C", home, "config", "--replace-all", "credential.helper", ""], quiet);
|
|
24499
|
+
execFileSync3(
|
|
24500
|
+
"git",
|
|
24501
|
+
["-C", home, "config", "--add", "credential.helper", credentialHelperCommand()],
|
|
24502
|
+
quiet
|
|
24503
|
+
);
|
|
24504
|
+
}
|
|
24462
24505
|
|
|
24463
24506
|
// src/bootstrap.ts
|
|
24464
24507
|
function log(message) {
|
|
@@ -24526,9 +24569,10 @@ async function bootstrapFromToken(token, opts = {}) {
|
|
|
24526
24569
|
}
|
|
24527
24570
|
|
|
24528
24571
|
// src/credential.ts
|
|
24529
|
-
async function handleGitCredential() {
|
|
24530
|
-
|
|
24531
|
-
|
|
24572
|
+
async function handleGitCredential(operation) {
|
|
24573
|
+
if (operation !== "get") return;
|
|
24574
|
+
const request = parse3(await readStdin());
|
|
24575
|
+
if (request.host && request.host !== "github.com") return;
|
|
24532
24576
|
const stored = loadMachineConfig();
|
|
24533
24577
|
if (!stored) return;
|
|
24534
24578
|
const res = await fetch(`${stored.config.apiUrl}/api/cli/token`, {
|
|
@@ -24543,15 +24587,23 @@ async function handleGitCredential() {
|
|
|
24543
24587
|
password=${body.token}
|
|
24544
24588
|
`);
|
|
24545
24589
|
}
|
|
24590
|
+
function parse3(input) {
|
|
24591
|
+
const fields = {};
|
|
24592
|
+
for (const line of input.split("\n")) {
|
|
24593
|
+
const eq = line.indexOf("=");
|
|
24594
|
+
if (eq > 0) fields[line.slice(0, eq).trim()] = line.slice(eq + 1).trim();
|
|
24595
|
+
}
|
|
24596
|
+
return fields;
|
|
24597
|
+
}
|
|
24546
24598
|
function readStdin() {
|
|
24547
|
-
return new Promise((
|
|
24599
|
+
return new Promise((resolve3) => {
|
|
24548
24600
|
let data = "";
|
|
24549
24601
|
process.stdin.setEncoding("utf8");
|
|
24550
24602
|
process.stdin.on("data", (chunk) => {
|
|
24551
24603
|
data += chunk;
|
|
24552
24604
|
});
|
|
24553
|
-
process.stdin.on("end", () =>
|
|
24554
|
-
setTimeout(() =>
|
|
24605
|
+
process.stdin.on("end", () => resolve3(data));
|
|
24606
|
+
setTimeout(() => resolve3(data), 50);
|
|
24555
24607
|
});
|
|
24556
24608
|
}
|
|
24557
24609
|
|
|
@@ -24771,7 +24823,7 @@ async function main() {
|
|
|
24771
24823
|
return;
|
|
24772
24824
|
}
|
|
24773
24825
|
if (cmd === "git-credential") {
|
|
24774
|
-
await handleGitCredential();
|
|
24826
|
+
await handleGitCredential(rest[0]);
|
|
24775
24827
|
return;
|
|
24776
24828
|
}
|
|
24777
24829
|
printError(new Error(`Unknown command: ${cmd}. Run pantheon help.`));
|
package/package.json
CHANGED