@qawolf/cli 2.0.0 → 2.1.0
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/cli.js +439 -53
- package/dist/runner-sdk.js +13 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -8569,6 +8569,18 @@ var authMessages = {
|
|
|
8569
8569
|
success: "Logged out successfully.",
|
|
8570
8570
|
cancelled: "Logout cancelled."
|
|
8571
8571
|
},
|
|
8572
|
+
gitHelper: {
|
|
8573
|
+
added: (file) => `Git now uses your QA Wolf sign-in. Added to ${file ?? "your global Git config"}:`,
|
|
8574
|
+
unchanged: "Git already uses your QA Wolf sign-in.",
|
|
8575
|
+
gitMissing: "Git is not installed, so Git setup was skipped.",
|
|
8576
|
+
temporaryInstall: "Git setup was skipped because this CLI runs from a temporary install. Install the CLI globally to clone with your QA Wolf sign-in.",
|
|
8577
|
+
teamApiKeySkipped: "Git setup was skipped because Git cannot use a team API key. Sign in with your browser or a user API key to clone with your QA Wolf sign-in.",
|
|
8578
|
+
failed: (detail) => `Could not set up Git: ${detail}`,
|
|
8579
|
+
removed: (file) => `Removed the QA Wolf Git helper from ${file ?? "your global Git config"}:`,
|
|
8580
|
+
removalFailed: (detail) => `Could not remove the QA Wolf Git helper: ${detail}`,
|
|
8581
|
+
signedOut: "qawolf: run 'qawolf auth login' to use your QA Wolf sign-in with Git.",
|
|
8582
|
+
teamApiKey: "qawolf: Git needs a browser sign-in or a user API key. Run 'qawolf auth login' to use one."
|
|
8583
|
+
},
|
|
8572
8584
|
errors: authErrorMessages,
|
|
8573
8585
|
whoami: whoamiMessages
|
|
8574
8586
|
};
|
|
@@ -23570,7 +23582,7 @@ function startUpdateCheck(deps) {
|
|
|
23570
23582
|
// package.json
|
|
23571
23583
|
var package_default = {
|
|
23572
23584
|
name: "@qawolf/cli",
|
|
23573
|
-
version: "2.
|
|
23585
|
+
version: "2.1.0",
|
|
23574
23586
|
description: "Run and manage QA Wolf flows from the terminal, CI, or an AI agent",
|
|
23575
23587
|
keywords: [
|
|
23576
23588
|
"automation",
|
|
@@ -24358,6 +24370,399 @@ function registerAgentCommand(program, signals) {
|
|
|
24358
24370
|
registerAgentGetCommand(agent, signals);
|
|
24359
24371
|
}
|
|
24360
24372
|
|
|
24373
|
+
// src/commands/auth/gitCredential.ts
|
|
24374
|
+
import { text as text2 } from "node:stream/consumers";
|
|
24375
|
+
|
|
24376
|
+
// src/domains/gitCredential/credentialKind.ts
|
|
24377
|
+
var teamApiKeyPrefix = "qawolf_";
|
|
24378
|
+
function isTeamApiKey(credential) {
|
|
24379
|
+
return credential.key.startsWith(teamApiKeyPrefix);
|
|
24380
|
+
}
|
|
24381
|
+
|
|
24382
|
+
// src/domains/gitCredential/answerCredentialRequest.ts
|
|
24383
|
+
var gitUsername = "qawolf";
|
|
24384
|
+
var millisecondsPerSecond = 1000;
|
|
24385
|
+
function readAttributes(input) {
|
|
24386
|
+
return new Map(input.split(`
|
|
24387
|
+
`).filter((line) => line.includes("=")).map((line) => [
|
|
24388
|
+
line.slice(0, line.indexOf("=")),
|
|
24389
|
+
line.slice(line.indexOf("=") + 1)
|
|
24390
|
+
]));
|
|
24391
|
+
}
|
|
24392
|
+
function isRequestForHost({
|
|
24393
|
+
attributes,
|
|
24394
|
+
hostUrl
|
|
24395
|
+
}) {
|
|
24396
|
+
const host = new URL(hostUrl);
|
|
24397
|
+
return attributes.get("protocol") === host.protocol.replace(/:$/, "") && attributes.get("host") === host.host;
|
|
24398
|
+
}
|
|
24399
|
+
async function answerCredentialRequest({
|
|
24400
|
+
hostUrl,
|
|
24401
|
+
operation,
|
|
24402
|
+
readRequest,
|
|
24403
|
+
resolveCredential
|
|
24404
|
+
}) {
|
|
24405
|
+
if (operation !== "get")
|
|
24406
|
+
return { status: "not-a-lookup" };
|
|
24407
|
+
const attributes = readAttributes(await readRequest());
|
|
24408
|
+
if (!isRequestForHost({ attributes, hostUrl })) {
|
|
24409
|
+
return { status: "other-host" };
|
|
24410
|
+
}
|
|
24411
|
+
const credential = await resolveCredential();
|
|
24412
|
+
if (!credential)
|
|
24413
|
+
return { status: "signed-out" };
|
|
24414
|
+
if (isTeamApiKey(credential)) {
|
|
24415
|
+
return { status: "team-api-key" };
|
|
24416
|
+
}
|
|
24417
|
+
const expiresAtMs = credential.source === "browser" ? readAccessTokenExpiry(credential.key) : undefined;
|
|
24418
|
+
const lines = [
|
|
24419
|
+
`username=${gitUsername}`,
|
|
24420
|
+
`password=${credential.key}`,
|
|
24421
|
+
...expiresAtMs === undefined ? [] : [
|
|
24422
|
+
`password_expiry_utc=${Math.floor(expiresAtMs / millisecondsPerSecond)}`
|
|
24423
|
+
]
|
|
24424
|
+
];
|
|
24425
|
+
return {
|
|
24426
|
+
output: lines.map((line) => `${line}
|
|
24427
|
+
`).join(""),
|
|
24428
|
+
status: "answered"
|
|
24429
|
+
};
|
|
24430
|
+
}
|
|
24431
|
+
// src/domains/gitCredential/helperCommand.ts
|
|
24432
|
+
var helperSubcommand = "auth git-credential";
|
|
24433
|
+
var temporaryInstallPath = /[\\/](?:_npx|bunx-[^\\/]*)[\\/]/;
|
|
24434
|
+
function quoteForShell(value) {
|
|
24435
|
+
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
24436
|
+
}
|
|
24437
|
+
function resolveHelperCommand(invocation) {
|
|
24438
|
+
if (invocation.compiled) {
|
|
24439
|
+
return {
|
|
24440
|
+
command: `!${quoteForShell(invocation.execPath)} ${helperSubcommand}`,
|
|
24441
|
+
status: "ready"
|
|
24442
|
+
};
|
|
24443
|
+
}
|
|
24444
|
+
const { scriptPath } = invocation;
|
|
24445
|
+
if (scriptPath === undefined || temporaryInstallPath.test(scriptPath)) {
|
|
24446
|
+
return { status: "temporary-install" };
|
|
24447
|
+
}
|
|
24448
|
+
return {
|
|
24449
|
+
command: `!${quoteForShell(invocation.execPath)} ${quoteForShell(scriptPath)} ${helperSubcommand}`,
|
|
24450
|
+
status: "ready"
|
|
24451
|
+
};
|
|
24452
|
+
}
|
|
24453
|
+
function isCliHelperEntry(entry) {
|
|
24454
|
+
return entry.startsWith("!") && entry.endsWith(` ${helperSubcommand}`);
|
|
24455
|
+
}
|
|
24456
|
+
function defaultCliInvocation() {
|
|
24457
|
+
return {
|
|
24458
|
+
compiled: process.env.QAWOLF_COMPILED === "true",
|
|
24459
|
+
execPath: process.execPath,
|
|
24460
|
+
scriptPath: process.argv[1]
|
|
24461
|
+
};
|
|
24462
|
+
}
|
|
24463
|
+
|
|
24464
|
+
// src/domains/gitCredential/helperEntries.ts
|
|
24465
|
+
var keyNotFoundExitCode = 1;
|
|
24466
|
+
var valueNotFoundExitCode = 5;
|
|
24467
|
+
var cliEntryPattern = "^(!.* auth git-credential)?$";
|
|
24468
|
+
var helperListReset = "";
|
|
24469
|
+
function isCliEntry(entry) {
|
|
24470
|
+
return entry === helperListReset || isCliHelperEntry(entry);
|
|
24471
|
+
}
|
|
24472
|
+
function helperKey(hostUrl) {
|
|
24473
|
+
return `credential.${hostUrl}.helper`;
|
|
24474
|
+
}
|
|
24475
|
+
function failure(result) {
|
|
24476
|
+
return {
|
|
24477
|
+
detail: result.stderr.trim() || `git exited with ${result.exitCode}`,
|
|
24478
|
+
status: "failed"
|
|
24479
|
+
};
|
|
24480
|
+
}
|
|
24481
|
+
function runGitConfig({
|
|
24482
|
+
args,
|
|
24483
|
+
deps
|
|
24484
|
+
}) {
|
|
24485
|
+
return deps.spawn("git", ["config", "--global", ...args], {
|
|
24486
|
+
platform: deps.platform
|
|
24487
|
+
});
|
|
24488
|
+
}
|
|
24489
|
+
async function readHelperEntries({
|
|
24490
|
+
deps,
|
|
24491
|
+
hostUrl
|
|
24492
|
+
}) {
|
|
24493
|
+
const result = await runGitConfig({
|
|
24494
|
+
args: ["--show-origin", "--null", "--get-all", helperKey(hostUrl)],
|
|
24495
|
+
deps
|
|
24496
|
+
});
|
|
24497
|
+
if (result.exitCode < 0)
|
|
24498
|
+
return { status: "git-missing" };
|
|
24499
|
+
if (result.exitCode === keyNotFoundExitCode) {
|
|
24500
|
+
return { entries: [], file: undefined, status: "read" };
|
|
24501
|
+
}
|
|
24502
|
+
if (result.exitCode !== 0)
|
|
24503
|
+
return failure(result);
|
|
24504
|
+
const fields = result.stdout.split("\x00");
|
|
24505
|
+
const origins = fields.filter((_field, index) => index % 2 === 0);
|
|
24506
|
+
const values = fields.filter((_field, index) => index % 2 === 1);
|
|
24507
|
+
const [firstOrigin] = origins;
|
|
24508
|
+
return {
|
|
24509
|
+
entries: values,
|
|
24510
|
+
file: firstOrigin?.replace(/^file:/, ""),
|
|
24511
|
+
status: "read"
|
|
24512
|
+
};
|
|
24513
|
+
}
|
|
24514
|
+
async function addEntry({
|
|
24515
|
+
deps,
|
|
24516
|
+
entry,
|
|
24517
|
+
hostUrl
|
|
24518
|
+
}) {
|
|
24519
|
+
const result = await runGitConfig({
|
|
24520
|
+
args: ["--add", helperKey(hostUrl), entry],
|
|
24521
|
+
deps
|
|
24522
|
+
});
|
|
24523
|
+
return result.exitCode === 0 ? undefined : failure(result);
|
|
24524
|
+
}
|
|
24525
|
+
async function unsetCliEntries({
|
|
24526
|
+
deps,
|
|
24527
|
+
hostUrl
|
|
24528
|
+
}) {
|
|
24529
|
+
const result = await runGitConfig({
|
|
24530
|
+
args: ["--unset-all", helperKey(hostUrl), cliEntryPattern],
|
|
24531
|
+
deps
|
|
24532
|
+
});
|
|
24533
|
+
if (result.exitCode === 0 || result.exitCode === valueNotFoundExitCode) {
|
|
24534
|
+
return;
|
|
24535
|
+
}
|
|
24536
|
+
return failure(result);
|
|
24537
|
+
}
|
|
24538
|
+
|
|
24539
|
+
// src/domains/gitCredential/gitConfig.ts
|
|
24540
|
+
function describeLines({
|
|
24541
|
+
entries,
|
|
24542
|
+
hostUrl
|
|
24543
|
+
}) {
|
|
24544
|
+
return [
|
|
24545
|
+
`[credential "${hostUrl}"]`,
|
|
24546
|
+
...entries.map((entry) => ` helper = ${entry}`)
|
|
24547
|
+
].join(`
|
|
24548
|
+
`);
|
|
24549
|
+
}
|
|
24550
|
+
function hasSameEntries({
|
|
24551
|
+
actual,
|
|
24552
|
+
expected
|
|
24553
|
+
}) {
|
|
24554
|
+
return actual.length === expected.length && actual.every((entry, index) => entry === expected[index]);
|
|
24555
|
+
}
|
|
24556
|
+
function isInPlace({
|
|
24557
|
+
cliEntries,
|
|
24558
|
+
entries
|
|
24559
|
+
}) {
|
|
24560
|
+
return hasSameEntries({
|
|
24561
|
+
actual: entries.filter(isCliEntry),
|
|
24562
|
+
expected: cliEntries
|
|
24563
|
+
}) && hasSameEntries({
|
|
24564
|
+
actual: entries.slice(-cliEntries.length),
|
|
24565
|
+
expected: cliEntries
|
|
24566
|
+
});
|
|
24567
|
+
}
|
|
24568
|
+
async function setUpGitCredentialHelper({
|
|
24569
|
+
credential,
|
|
24570
|
+
deps,
|
|
24571
|
+
helperCommand,
|
|
24572
|
+
hostUrl
|
|
24573
|
+
}) {
|
|
24574
|
+
if (isTeamApiKey(credential)) {
|
|
24575
|
+
return {
|
|
24576
|
+
removal: await removeGitCredentialHelper({ deps, hostUrl }),
|
|
24577
|
+
status: "team-api-key"
|
|
24578
|
+
};
|
|
24579
|
+
}
|
|
24580
|
+
if (helperCommand.status === "temporary-install")
|
|
24581
|
+
return helperCommand;
|
|
24582
|
+
const current = await readHelperEntries({ deps, hostUrl });
|
|
24583
|
+
if (current.status !== "read")
|
|
24584
|
+
return current;
|
|
24585
|
+
const cliEntries = [helperListReset, helperCommand.command];
|
|
24586
|
+
const lines = describeLines({ entries: cliEntries, hostUrl });
|
|
24587
|
+
if (isInPlace({ cliEntries, entries: current.entries })) {
|
|
24588
|
+
return { file: current.file, lines, status: "unchanged" };
|
|
24589
|
+
}
|
|
24590
|
+
const writeFailure = await unsetCliEntries({ deps, hostUrl }) ?? await addEntry({ deps, entry: helperListReset, hostUrl }) ?? await addEntry({ deps, entry: helperCommand.command, hostUrl });
|
|
24591
|
+
if (writeFailure)
|
|
24592
|
+
return writeFailure;
|
|
24593
|
+
const after = await readHelperEntries({ deps, hostUrl });
|
|
24594
|
+
return {
|
|
24595
|
+
file: after.status === "read" ? after.file : undefined,
|
|
24596
|
+
lines,
|
|
24597
|
+
status: "added"
|
|
24598
|
+
};
|
|
24599
|
+
}
|
|
24600
|
+
async function removeGitCredentialHelper({
|
|
24601
|
+
deps,
|
|
24602
|
+
hostUrl
|
|
24603
|
+
}) {
|
|
24604
|
+
const current = await readHelperEntries({ deps, hostUrl });
|
|
24605
|
+
if (current.status !== "read")
|
|
24606
|
+
return current;
|
|
24607
|
+
if (!current.entries.some(isCliHelperEntry))
|
|
24608
|
+
return { status: "none" };
|
|
24609
|
+
const unsetFailure = await unsetCliEntries({ deps, hostUrl });
|
|
24610
|
+
if (unsetFailure)
|
|
24611
|
+
return unsetFailure;
|
|
24612
|
+
return {
|
|
24613
|
+
file: current.file,
|
|
24614
|
+
lines: describeLines({
|
|
24615
|
+
entries: current.entries.filter(isCliEntry),
|
|
24616
|
+
hostUrl
|
|
24617
|
+
}),
|
|
24618
|
+
status: "removed"
|
|
24619
|
+
};
|
|
24620
|
+
}
|
|
24621
|
+
// src/commands/auth/gitCredential.ts
|
|
24622
|
+
function defaultGitCredentialDeps() {
|
|
24623
|
+
return {
|
|
24624
|
+
hostUrl: resolveHostUrl(process.env),
|
|
24625
|
+
readRequest: () => text2(process.stdin),
|
|
24626
|
+
resolveCredential: () => resolveApiKey(getConfigDir(), makeDefaultFs()),
|
|
24627
|
+
writeError: (message) => process.stderr.write(message),
|
|
24628
|
+
writeOutput: (output) => process.stdout.write(output)
|
|
24629
|
+
};
|
|
24630
|
+
}
|
|
24631
|
+
async function handleGitCredential({
|
|
24632
|
+
deps,
|
|
24633
|
+
operation
|
|
24634
|
+
}) {
|
|
24635
|
+
const answer = await answerCredentialRequest({
|
|
24636
|
+
hostUrl: deps.hostUrl,
|
|
24637
|
+
operation,
|
|
24638
|
+
readRequest: deps.readRequest,
|
|
24639
|
+
resolveCredential: deps.resolveCredential
|
|
24640
|
+
});
|
|
24641
|
+
if (answer.status === "answered")
|
|
24642
|
+
deps.writeOutput(answer.output);
|
|
24643
|
+
if (answer.status === "signed-out") {
|
|
24644
|
+
deps.writeError(`${authMessages.gitHelper.signedOut}
|
|
24645
|
+
`);
|
|
24646
|
+
}
|
|
24647
|
+
if (answer.status === "team-api-key") {
|
|
24648
|
+
deps.writeError(`${authMessages.gitHelper.teamApiKey}
|
|
24649
|
+
`);
|
|
24650
|
+
}
|
|
24651
|
+
}
|
|
24652
|
+
|
|
24653
|
+
// src/shell/spawn.ts
|
|
24654
|
+
import { spawn } from "node:child_process";
|
|
24655
|
+
|
|
24656
|
+
// src/core/cmdEscape.ts
|
|
24657
|
+
var metaChars = /([()\][%!^"`<>&|;, *?])/g;
|
|
24658
|
+
function escapeCommand(command) {
|
|
24659
|
+
return command.replace(metaChars, "^$1");
|
|
24660
|
+
}
|
|
24661
|
+
function escapeArgument(arg) {
|
|
24662
|
+
const escaped = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"").replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
24663
|
+
return `"${escaped}"`.replace(metaChars, "^$1").replace(metaChars, "^$1");
|
|
24664
|
+
}
|
|
24665
|
+
|
|
24666
|
+
// src/shell/spawn.ts
|
|
24667
|
+
function buildSpawnCommand(cmd, args, platform, env) {
|
|
24668
|
+
const options = {};
|
|
24669
|
+
if (env)
|
|
24670
|
+
options.env = env;
|
|
24671
|
+
if (platform !== "win32" || !/\.(cmd|bat)$/i.test(cmd)) {
|
|
24672
|
+
return { cmd, args, options };
|
|
24673
|
+
}
|
|
24674
|
+
const line = [escapeCommand(cmd), ...args.map(escapeArgument)].join(" ");
|
|
24675
|
+
return {
|
|
24676
|
+
cmd: process.env["ComSpec"] ?? "cmd.exe",
|
|
24677
|
+
args: ["/d", "/s", "/c", `"${line}"`],
|
|
24678
|
+
options: { ...options, windowsVerbatimArguments: true }
|
|
24679
|
+
};
|
|
24680
|
+
}
|
|
24681
|
+
var defaultSpawn = (cmd, args, opts) => new Promise((resolve) => {
|
|
24682
|
+
const env = opts.env ? { ...process.env, ...opts.env } : undefined;
|
|
24683
|
+
const built = buildSpawnCommand(cmd, args, opts.platform, env);
|
|
24684
|
+
const child = spawn(built.cmd, built.args, built.options);
|
|
24685
|
+
let stdout = "";
|
|
24686
|
+
let stderr = "";
|
|
24687
|
+
child.stdout?.on("data", (chunk) => {
|
|
24688
|
+
stdout += String(chunk);
|
|
24689
|
+
});
|
|
24690
|
+
child.stderr?.on("data", (chunk) => {
|
|
24691
|
+
stderr += String(chunk);
|
|
24692
|
+
});
|
|
24693
|
+
if (opts?.stdin !== undefined) {
|
|
24694
|
+
child.stdin?.write(opts.stdin);
|
|
24695
|
+
child.stdin?.end();
|
|
24696
|
+
}
|
|
24697
|
+
child.on("error", (err) => resolve({ exitCode: -1, stdout, stderr: stderr || err.message }));
|
|
24698
|
+
child.on("close", (code) => resolve({ exitCode: code ?? -1, stdout, stderr }));
|
|
24699
|
+
});
|
|
24700
|
+
|
|
24701
|
+
// src/commands/auth/gitHelperSetup.ts
|
|
24702
|
+
var defaultGitConfigDeps = {
|
|
24703
|
+
platform: process.platform,
|
|
24704
|
+
spawn: defaultSpawn
|
|
24705
|
+
};
|
|
24706
|
+
function reportSetup({ result, ui }) {
|
|
24707
|
+
switch (result.status) {
|
|
24708
|
+
case "added":
|
|
24709
|
+
ui.info(authMessages.gitHelper.added(result.file));
|
|
24710
|
+
ui.note(result.lines);
|
|
24711
|
+
return;
|
|
24712
|
+
case "unchanged":
|
|
24713
|
+
ui.info(authMessages.gitHelper.unchanged);
|
|
24714
|
+
return;
|
|
24715
|
+
case "git-missing":
|
|
24716
|
+
ui.info(authMessages.gitHelper.gitMissing);
|
|
24717
|
+
return;
|
|
24718
|
+
case "temporary-install":
|
|
24719
|
+
ui.warn(authMessages.gitHelper.temporaryInstall);
|
|
24720
|
+
return;
|
|
24721
|
+
case "team-api-key":
|
|
24722
|
+
ui.warn(authMessages.gitHelper.teamApiKeySkipped);
|
|
24723
|
+
reportRemoval({ result: result.removal, ui });
|
|
24724
|
+
return;
|
|
24725
|
+
case "failed":
|
|
24726
|
+
ui.warn(authMessages.gitHelper.failed(result.detail));
|
|
24727
|
+
return;
|
|
24728
|
+
}
|
|
24729
|
+
}
|
|
24730
|
+
function reportRemoval({
|
|
24731
|
+
result,
|
|
24732
|
+
ui
|
|
24733
|
+
}) {
|
|
24734
|
+
if (result.status === "removed") {
|
|
24735
|
+
ui.info(authMessages.gitHelper.removed(result.file));
|
|
24736
|
+
ui.note(result.lines);
|
|
24737
|
+
}
|
|
24738
|
+
if (result.status === "failed") {
|
|
24739
|
+
ui.warn(authMessages.gitHelper.removalFailed(result.detail));
|
|
24740
|
+
}
|
|
24741
|
+
}
|
|
24742
|
+
async function configureGitCredentialHelper({
|
|
24743
|
+
credential,
|
|
24744
|
+
ctx
|
|
24745
|
+
}) {
|
|
24746
|
+
reportSetup({
|
|
24747
|
+
result: await setUpGitCredentialHelper({
|
|
24748
|
+
credential,
|
|
24749
|
+
deps: defaultGitConfigDeps,
|
|
24750
|
+
helperCommand: resolveHelperCommand(defaultCliInvocation()),
|
|
24751
|
+
hostUrl: ctx.apiBaseUrl
|
|
24752
|
+
}),
|
|
24753
|
+
ui: ctx.ui
|
|
24754
|
+
});
|
|
24755
|
+
}
|
|
24756
|
+
async function unconfigureGitCredentialHelper(ctx) {
|
|
24757
|
+
reportRemoval({
|
|
24758
|
+
result: await removeGitCredentialHelper({
|
|
24759
|
+
deps: defaultGitConfigDeps,
|
|
24760
|
+
hostUrl: ctx.apiBaseUrl
|
|
24761
|
+
}),
|
|
24762
|
+
ui: ctx.ui
|
|
24763
|
+
});
|
|
24764
|
+
}
|
|
24765
|
+
|
|
24361
24766
|
// src/commands/auth/loginApiKey.ts
|
|
24362
24767
|
async function loginWithApiKey(ctx) {
|
|
24363
24768
|
const result = await ctx.ui.password(authMessages.promptApiKey, "Set QAWOLF_API_KEY to authenticate in non-interactive environments.");
|
|
@@ -24503,54 +24908,6 @@ async function openBrowser(url, deps) {
|
|
|
24503
24908
|
return Promise.race([launched, deps.sleep(launchTimeoutMs).then(() => true)]);
|
|
24504
24909
|
}
|
|
24505
24910
|
|
|
24506
|
-
// src/shell/spawn.ts
|
|
24507
|
-
import { spawn } from "node:child_process";
|
|
24508
|
-
|
|
24509
|
-
// src/core/cmdEscape.ts
|
|
24510
|
-
var metaChars = /([()\][%!^"`<>&|;, *?])/g;
|
|
24511
|
-
function escapeCommand(command) {
|
|
24512
|
-
return command.replace(metaChars, "^$1");
|
|
24513
|
-
}
|
|
24514
|
-
function escapeArgument(arg) {
|
|
24515
|
-
const escaped = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"").replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
24516
|
-
return `"${escaped}"`.replace(metaChars, "^$1").replace(metaChars, "^$1");
|
|
24517
|
-
}
|
|
24518
|
-
|
|
24519
|
-
// src/shell/spawn.ts
|
|
24520
|
-
function buildSpawnCommand(cmd, args, platform, env) {
|
|
24521
|
-
const options = {};
|
|
24522
|
-
if (env)
|
|
24523
|
-
options.env = env;
|
|
24524
|
-
if (platform !== "win32" || !/\.(cmd|bat)$/i.test(cmd)) {
|
|
24525
|
-
return { cmd, args, options };
|
|
24526
|
-
}
|
|
24527
|
-
const line = [escapeCommand(cmd), ...args.map(escapeArgument)].join(" ");
|
|
24528
|
-
return {
|
|
24529
|
-
cmd: process.env["ComSpec"] ?? "cmd.exe",
|
|
24530
|
-
args: ["/d", "/s", "/c", `"${line}"`],
|
|
24531
|
-
options: { ...options, windowsVerbatimArguments: true }
|
|
24532
|
-
};
|
|
24533
|
-
}
|
|
24534
|
-
var defaultSpawn = (cmd, args, opts) => new Promise((resolve) => {
|
|
24535
|
-
const env = opts.env ? { ...process.env, ...opts.env } : undefined;
|
|
24536
|
-
const built = buildSpawnCommand(cmd, args, opts.platform, env);
|
|
24537
|
-
const child = spawn(built.cmd, built.args, built.options);
|
|
24538
|
-
let stdout = "";
|
|
24539
|
-
let stderr = "";
|
|
24540
|
-
child.stdout?.on("data", (chunk) => {
|
|
24541
|
-
stdout += String(chunk);
|
|
24542
|
-
});
|
|
24543
|
-
child.stderr?.on("data", (chunk) => {
|
|
24544
|
-
stderr += String(chunk);
|
|
24545
|
-
});
|
|
24546
|
-
if (opts?.stdin !== undefined) {
|
|
24547
|
-
child.stdin?.write(opts.stdin);
|
|
24548
|
-
child.stdin?.end();
|
|
24549
|
-
}
|
|
24550
|
-
child.on("error", (err) => resolve({ exitCode: -1, stdout, stderr: stderr || err.message }));
|
|
24551
|
-
child.on("close", (code) => resolve({ exitCode: code ?? -1, stdout, stderr }));
|
|
24552
|
-
});
|
|
24553
|
-
|
|
24554
24911
|
// src/shell/platform/getAuthConfig.ts
|
|
24555
24912
|
var timeoutMs5 = 1e4;
|
|
24556
24913
|
var authConfigBody = object({
|
|
@@ -24936,6 +25293,18 @@ async function loginWithDevice(ctx, deps = {}) {
|
|
|
24936
25293
|
|
|
24937
25294
|
// src/commands/auth/login.ts
|
|
24938
25295
|
var browserMethod = "browser";
|
|
25296
|
+
async function configureGitAfterSignIn({
|
|
25297
|
+
ctx,
|
|
25298
|
+
deps,
|
|
25299
|
+
result
|
|
25300
|
+
}) {
|
|
25301
|
+
const resolveApiKey2 = deps.resolveApiKey ?? resolveApiKey;
|
|
25302
|
+
const credential = result === undefined ? await resolveApiKey2(ctx.configDir, ctx.fs) : undefined;
|
|
25303
|
+
if (credential) {
|
|
25304
|
+
await (deps.configureGitCredentialHelper ?? configureGitCredentialHelper)({ credential, ctx });
|
|
25305
|
+
}
|
|
25306
|
+
return result;
|
|
25307
|
+
}
|
|
24939
25308
|
async function handleLogin(ctx, deps = {}) {
|
|
24940
25309
|
if (ctx.ui.mode !== "human") {
|
|
24941
25310
|
ctx.ui.error(authMessages.login.nonInteractive);
|
|
@@ -24947,7 +25316,7 @@ async function handleLogin(ctx, deps = {}) {
|
|
|
24947
25316
|
const reauth = await ctx.ui.confirm(authMessages.login.reAuthPrompt);
|
|
24948
25317
|
if (!reauth.ok || !reauth.value) {
|
|
24949
25318
|
ctx.ui.info(authMessages.alreadyConfigured);
|
|
24950
|
-
return;
|
|
25319
|
+
return configureGitAfterSignIn({ ctx, deps, result: undefined });
|
|
24951
25320
|
}
|
|
24952
25321
|
}
|
|
24953
25322
|
ctx.ui.gap();
|
|
@@ -24969,12 +25338,20 @@ async function handleLogin(ctx, deps = {}) {
|
|
|
24969
25338
|
return;
|
|
24970
25339
|
}
|
|
24971
25340
|
if (method.value !== browserMethod) {
|
|
24972
|
-
return (
|
|
25341
|
+
return configureGitAfterSignIn({
|
|
25342
|
+
ctx,
|
|
25343
|
+
deps,
|
|
25344
|
+
result: await (deps.loginWithApiKey ?? loginWithApiKey)(ctx)
|
|
25345
|
+
});
|
|
24973
25346
|
}
|
|
24974
25347
|
if (existing && existing.source !== "browser") {
|
|
24975
25348
|
ctx.ui.warn(existing.source === "env" ? authMessages.login.apiKeyPrecedence.env : authMessages.login.apiKeyPrecedence.stored);
|
|
24976
25349
|
}
|
|
24977
|
-
return (
|
|
25350
|
+
return configureGitAfterSignIn({
|
|
25351
|
+
ctx,
|
|
25352
|
+
deps,
|
|
25353
|
+
result: await (deps.loginWithDevice ?? loginWithDevice)(ctx)
|
|
25354
|
+
});
|
|
24978
25355
|
}
|
|
24979
25356
|
|
|
24980
25357
|
// src/domains/auth/store/deleteTokens.ts
|
|
@@ -25011,11 +25388,13 @@ async function handleLogout(ctx, deps = {}) {
|
|
|
25011
25388
|
const hasStoredCredentials2 = deps.hasStoredCredentials ?? hasStoredCredentials;
|
|
25012
25389
|
const deleteApiKey2 = deps.deleteApiKey ?? deleteApiKey;
|
|
25013
25390
|
const deleteTokens2 = deps.deleteTokens ?? deleteTokens;
|
|
25391
|
+
const unconfigureGitCredentialHelper2 = deps.unconfigureGitCredentialHelper ?? unconfigureGitCredentialHelper;
|
|
25014
25392
|
const env = deps.env ?? process.env;
|
|
25015
25393
|
const envKey = env["QAWOLF_API_KEY"]?.trim();
|
|
25016
25394
|
const stored = await hasStoredCredentials2(ctx.configDir, ctx.fs);
|
|
25017
25395
|
if (!envKey && !stored) {
|
|
25018
25396
|
ctx.ui.info(authMessages.logout.notAuthenticated);
|
|
25397
|
+
await unconfigureGitCredentialHelper2(ctx);
|
|
25019
25398
|
return;
|
|
25020
25399
|
}
|
|
25021
25400
|
if (envKey) {
|
|
@@ -25041,6 +25420,7 @@ async function handleLogout(ctx, deps = {}) {
|
|
|
25041
25420
|
}
|
|
25042
25421
|
}
|
|
25043
25422
|
], () => authMessages.logout.credentialsRemoved);
|
|
25423
|
+
await unconfigureGitCredentialHelper2(ctx);
|
|
25044
25424
|
if (ctx.ui.mode === "human") {
|
|
25045
25425
|
ctx.ui.outro(authMessages.logout.success);
|
|
25046
25426
|
} else {
|
|
@@ -25212,6 +25592,12 @@ function registerAuthCommand(program, signals) {
|
|
|
25212
25592
|
declareCommandKind(auth.command("logout"), "local").description("Remove stored credentials").action(withContext(signals, handleLogout));
|
|
25213
25593
|
declareCommandKind(auth.command("switch"), "local").description("Choose which workspace to work in").action(withContext(signals, handleSwitchWorkspace));
|
|
25214
25594
|
declareCommandKind(auth.command("whoami"), "read").description("Show authentication status").action(withContext(signals, handleWhoami));
|
|
25595
|
+
declareCommandKind(auth.command("git-credential", { hidden: true }).argument("<operation>"), "read").description("Answer a Git credential request for the QA Wolf host").action(async (operation) => {
|
|
25596
|
+
await handleGitCredential({
|
|
25597
|
+
deps: defaultGitCredentialDeps(),
|
|
25598
|
+
operation
|
|
25599
|
+
});
|
|
25600
|
+
});
|
|
25215
25601
|
}
|
|
25216
25602
|
|
|
25217
25603
|
// node_modules/@qawolf/flow-targets/dist/presets/android/androidPixel2Android14.js
|
|
@@ -41401,4 +41787,4 @@ createProgram({ signals }).parseAsync().catch(() => {
|
|
|
41401
41787
|
process.exitCode = 1;
|
|
41402
41788
|
}).finally(() => exitWhenIdle(typeof process.exitCode === "number" ? process.exitCode : 0));
|
|
41403
41789
|
|
|
41404
|
-
//# debugId=
|
|
41790
|
+
//# debugId=FFFD1A9214AB797D64756E2164756E21
|
package/dist/runner-sdk.js
CHANGED
|
@@ -11536,6 +11536,18 @@ var authMessages = {
|
|
|
11536
11536
|
success: "Logged out successfully.",
|
|
11537
11537
|
cancelled: "Logout cancelled."
|
|
11538
11538
|
},
|
|
11539
|
+
gitHelper: {
|
|
11540
|
+
added: (file) => `Git now uses your QA Wolf sign-in. Added to ${file ?? "your global Git config"}:`,
|
|
11541
|
+
unchanged: "Git already uses your QA Wolf sign-in.",
|
|
11542
|
+
gitMissing: "Git is not installed, so Git setup was skipped.",
|
|
11543
|
+
temporaryInstall: "Git setup was skipped because this CLI runs from a temporary install. Install the CLI globally to clone with your QA Wolf sign-in.",
|
|
11544
|
+
teamApiKeySkipped: "Git setup was skipped because Git cannot use a team API key. Sign in with your browser or a user API key to clone with your QA Wolf sign-in.",
|
|
11545
|
+
failed: (detail) => `Could not set up Git: ${detail}`,
|
|
11546
|
+
removed: (file) => `Removed the QA Wolf Git helper from ${file ?? "your global Git config"}:`,
|
|
11547
|
+
removalFailed: (detail) => `Could not remove the QA Wolf Git helper: ${detail}`,
|
|
11548
|
+
signedOut: "qawolf: run 'qawolf auth login' to use your QA Wolf sign-in with Git.",
|
|
11549
|
+
teamApiKey: "qawolf: Git needs a browser sign-in or a user API key. Run 'qawolf auth login' to use one."
|
|
11550
|
+
},
|
|
11539
11551
|
errors: authErrorMessages,
|
|
11540
11552
|
whoami: whoamiMessages
|
|
11541
11553
|
};
|
|
@@ -16020,4 +16032,4 @@ export {
|
|
|
16020
16032
|
createRunnerSdk
|
|
16021
16033
|
};
|
|
16022
16034
|
|
|
16023
|
-
//# debugId=
|
|
16035
|
+
//# debugId=991A751E681DB2D264756E2164756E21
|