pantheon-cli 0.2.23 → 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 +63 -30
- package/package.json +1 -1
package/dist/pantheon.mjs
CHANGED
|
@@ -3640,7 +3640,7 @@ 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
|
}
|
|
@@ -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) {
|
|
@@ -3932,7 +3932,7 @@ var require_fast_uri = __commonJS({
|
|
|
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
|
}
|
|
@@ -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
|
|
@@ -23268,14 +23275,16 @@ esac
|
|
|
23268
23275
|
}
|
|
23269
23276
|
}
|
|
23270
23277
|
}
|
|
23271
|
-
function
|
|
23278
|
+
function boundElsewhere(home) {
|
|
23272
23279
|
try {
|
|
23273
23280
|
const stored = loadMachineConfig();
|
|
23274
|
-
if (!stored?.config.cloneUrl) return;
|
|
23275
|
-
if (resolve2(stored.config.home) !== resolve2(home)) return;
|
|
23276
|
-
|
|
23277
|
-
|
|
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.`;
|
|
23278
23286
|
} catch {
|
|
23287
|
+
return null;
|
|
23279
23288
|
}
|
|
23280
23289
|
}
|
|
23281
23290
|
function syncVaultWithToken(home, token, opts = {}) {
|
|
@@ -23284,7 +23293,11 @@ function syncVaultWithToken(home, token, opts = {}) {
|
|
|
23284
23293
|
result.error = "Vault is not a git repo.";
|
|
23285
23294
|
return result;
|
|
23286
23295
|
}
|
|
23287
|
-
|
|
23296
|
+
const bound = boundElsewhere(home);
|
|
23297
|
+
if (bound) {
|
|
23298
|
+
result.error = bound;
|
|
23299
|
+
return result;
|
|
23300
|
+
}
|
|
23288
23301
|
try {
|
|
23289
23302
|
return withGitAuth(token, (env) => {
|
|
23290
23303
|
const auth = [
|
|
@@ -24386,17 +24399,17 @@ async function connect(opts) {
|
|
|
24386
24399
|
{ machineSecret: body.machineSecret }
|
|
24387
24400
|
);
|
|
24388
24401
|
mkdirSync6(home, { recursive: true });
|
|
24389
|
-
const
|
|
24402
|
+
const auth = authArgs();
|
|
24390
24403
|
const quiet = { stdio: ["ignore", "pipe", "pipe"] };
|
|
24391
24404
|
const fresh = !existsSync7(join7(home, ".git"));
|
|
24392
24405
|
let archived = "";
|
|
24393
24406
|
if (fresh) {
|
|
24394
24407
|
process.stdout.write(" Cloning the vault\u2026\n");
|
|
24395
|
-
execFileSync3("git", [
|
|
24408
|
+
execFileSync3("git", [...auth, "clone", body.cloneUrl, home], quiet);
|
|
24396
24409
|
} else {
|
|
24397
|
-
archived = syncVault2(home, body.cloneUrl,
|
|
24410
|
+
archived = syncVault2(home, body.cloneUrl, auth, quiet);
|
|
24398
24411
|
}
|
|
24399
|
-
|
|
24412
|
+
claimCredentials(home, quiet);
|
|
24400
24413
|
execFileSync3("git", ["-C", home, "config", "user.name", "Pantheon"], quiet);
|
|
24401
24414
|
execFileSync3("git", ["-C", home, "config", "user.email", "pantheon@users.noreply.github.com"], quiet);
|
|
24402
24415
|
let written = [];
|
|
@@ -24429,9 +24442,9 @@ async function connect(opts) {
|
|
|
24429
24442
|
)
|
|
24430
24443
|
);
|
|
24431
24444
|
}
|
|
24432
|
-
function syncVault2(home, cloneUrl,
|
|
24433
|
-
const git2 = (...args) => execFileSync3("git", [
|
|
24434
|
-
|
|
24445
|
+
function syncVault2(home, cloneUrl, auth, quiet) {
|
|
24446
|
+
const git2 = (...args) => execFileSync3("git", [...auth, "-C", home, ...args], quiet);
|
|
24447
|
+
retarget(home, cloneUrl, quiet);
|
|
24435
24448
|
try {
|
|
24436
24449
|
git2("pull", "--ff-only");
|
|
24437
24450
|
return "";
|
|
@@ -24447,10 +24460,10 @@ function syncVault2(home, cloneUrl, helper, quiet) {
|
|
|
24447
24460
|
const archive = `${home}-${stamp2}`;
|
|
24448
24461
|
process.stdout.write(" Vault belongs to a different repo; setting it aside\u2026\n");
|
|
24449
24462
|
renameSync2(home, archive);
|
|
24450
|
-
execFileSync3("git", [
|
|
24463
|
+
execFileSync3("git", [...auth, "clone", cloneUrl, home], quiet);
|
|
24451
24464
|
return archive;
|
|
24452
24465
|
}
|
|
24453
|
-
function
|
|
24466
|
+
function retarget(home, cloneUrl, quiet) {
|
|
24454
24467
|
try {
|
|
24455
24468
|
execFileSync3("git", ["-C", home, "remote", "set-url", "origin", cloneUrl], quiet);
|
|
24456
24469
|
} catch {
|
|
@@ -24478,6 +24491,17 @@ function vaultNote(fresh, archived) {
|
|
|
24478
24491
|
function credentialHelperCommand() {
|
|
24479
24492
|
return "!pantheon git-credential";
|
|
24480
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
|
+
}
|
|
24481
24505
|
|
|
24482
24506
|
// src/bootstrap.ts
|
|
24483
24507
|
function log(message) {
|
|
@@ -24545,9 +24569,10 @@ async function bootstrapFromToken(token, opts = {}) {
|
|
|
24545
24569
|
}
|
|
24546
24570
|
|
|
24547
24571
|
// src/credential.ts
|
|
24548
|
-
async function handleGitCredential() {
|
|
24549
|
-
|
|
24550
|
-
|
|
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;
|
|
24551
24576
|
const stored = loadMachineConfig();
|
|
24552
24577
|
if (!stored) return;
|
|
24553
24578
|
const res = await fetch(`${stored.config.apiUrl}/api/cli/token`, {
|
|
@@ -24562,6 +24587,14 @@ async function handleGitCredential() {
|
|
|
24562
24587
|
password=${body.token}
|
|
24563
24588
|
`);
|
|
24564
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
|
+
}
|
|
24565
24598
|
function readStdin() {
|
|
24566
24599
|
return new Promise((resolve3) => {
|
|
24567
24600
|
let data = "";
|
|
@@ -24790,7 +24823,7 @@ async function main() {
|
|
|
24790
24823
|
return;
|
|
24791
24824
|
}
|
|
24792
24825
|
if (cmd === "git-credential") {
|
|
24793
|
-
await handleGitCredential();
|
|
24826
|
+
await handleGitCredential(rest[0]);
|
|
24794
24827
|
return;
|
|
24795
24828
|
}
|
|
24796
24829
|
printError(new Error(`Unknown command: ${cmd}. Run pantheon help.`));
|
package/package.json
CHANGED