bpmax-cli 0.1.44-beta.0 → 0.1.44-beta.1
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/bin.js +47 -2
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -372,7 +372,7 @@ function normalizePath2(path9) {
|
|
|
372
372
|
// package.json
|
|
373
373
|
var package_default = {
|
|
374
374
|
name: "bpmax-cli",
|
|
375
|
-
version: "0.1.44-beta.
|
|
375
|
+
version: "0.1.44-beta.1",
|
|
376
376
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
377
377
|
type: "module",
|
|
378
378
|
bin: {
|
|
@@ -4556,6 +4556,7 @@ import { promisify } from "util";
|
|
|
4556
4556
|
import { password, text } from "@clack/prompts";
|
|
4557
4557
|
import axios5 from "axios";
|
|
4558
4558
|
var execFileAsync = promisify(execFile);
|
|
4559
|
+
var PLATFORM_SYSCONFIG_BRANCH = "master";
|
|
4559
4560
|
async function ensureConfigCapability2(profile, capability) {
|
|
4560
4561
|
if (capabilityEnabled(profile.config.capabilities_cache, capability)) {
|
|
4561
4562
|
return;
|
|
@@ -4749,6 +4750,44 @@ async function withTransientGitCredentials(credentials, operation) {
|
|
|
4749
4750
|
await rm2(askpassPath, { force: true });
|
|
4750
4751
|
}
|
|
4751
4752
|
}
|
|
4753
|
+
async function runGitWithTransientCredentials(args, workspaceDir, credentials) {
|
|
4754
|
+
await withTransientGitCredentials(
|
|
4755
|
+
credentials,
|
|
4756
|
+
(envVars) => execFileAsync("git", args, {
|
|
4757
|
+
cwd: workspaceDir,
|
|
4758
|
+
...envVars ? { env: envVars } : {}
|
|
4759
|
+
})
|
|
4760
|
+
);
|
|
4761
|
+
}
|
|
4762
|
+
async function gitRefExists(workspaceDir, ref) {
|
|
4763
|
+
try {
|
|
4764
|
+
await execFileAsync("git", ["rev-parse", "--verify", ref], { cwd: workspaceDir });
|
|
4765
|
+
return true;
|
|
4766
|
+
} catch {
|
|
4767
|
+
return false;
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
async function ensurePlatformSysconfigBranch(workspaceDir, credentials, remote = "origin", branch = PLATFORM_SYSCONFIG_BRANCH) {
|
|
4771
|
+
try {
|
|
4772
|
+
await runGitWithTransientCredentials(["fetch", remote, branch], workspaceDir, credentials);
|
|
4773
|
+
} catch {
|
|
4774
|
+
}
|
|
4775
|
+
if (await gitRefExists(workspaceDir, `${remote}/${branch}`)) {
|
|
4776
|
+
if (await gitRefExists(workspaceDir, branch)) {
|
|
4777
|
+
await execFileAsync("git", ["switch", branch], { cwd: workspaceDir });
|
|
4778
|
+
} else {
|
|
4779
|
+
await execFileAsync("git", ["switch", "--track", "-c", branch, `${remote}/${branch}`], { cwd: workspaceDir });
|
|
4780
|
+
}
|
|
4781
|
+
await execFileAsync("git", ["branch", "--set-upstream-to", `${remote}/${branch}`, branch], { cwd: workspaceDir });
|
|
4782
|
+
return;
|
|
4783
|
+
}
|
|
4784
|
+
if (await gitRefExists(workspaceDir, branch)) {
|
|
4785
|
+
await execFileAsync("git", ["switch", branch], { cwd: workspaceDir });
|
|
4786
|
+
} else {
|
|
4787
|
+
await execFileAsync("git", ["switch", "-C", branch], { cwd: workspaceDir });
|
|
4788
|
+
}
|
|
4789
|
+
await runGitWithTransientCredentials(["push", "-u", remote, branch], workspaceDir, credentials);
|
|
4790
|
+
}
|
|
4752
4791
|
function sanitizeConfigRepositoryValue(value) {
|
|
4753
4792
|
const redacted = redactAuditValue(value);
|
|
4754
4793
|
return sanitizeGitUrls(redacted);
|
|
@@ -4824,6 +4863,7 @@ async function collectEnvironment(env, profile, existed, options = {}) {
|
|
|
4824
4863
|
`/Users/you/sysconfig-${env}`
|
|
4825
4864
|
),
|
|
4826
4865
|
git_remote: options.gitRemote || existed?.git_remote || "origin",
|
|
4866
|
+
git_branch: options.gitBranch || existed?.git_branch || PLATFORM_SYSCONFIG_BRANCH,
|
|
4827
4867
|
username: await promptValue(options.username || existed?.username, "sysconfigdiff username"),
|
|
4828
4868
|
password: await promptSecret(options.password || existed?.password, "sysconfigdiff password or token"),
|
|
4829
4869
|
extra_headers: existed?.extra_headers || {}
|
|
@@ -5009,6 +5049,7 @@ async function initConfigWorkspaceFromPlatform(env, options) {
|
|
|
5009
5049
|
} else {
|
|
5010
5050
|
await assertExistingGitWorkspace(workspaceDir, gitUrl, options.force);
|
|
5011
5051
|
}
|
|
5052
|
+
await ensurePlatformSysconfigBranch(workspaceDir, credentials);
|
|
5012
5053
|
const latestConfig = await loadConfig();
|
|
5013
5054
|
latestConfig.profiles[profile.name].config_environments = {
|
|
5014
5055
|
...latestConfig.profiles[profile.name].config_environments || {},
|
|
@@ -5019,6 +5060,7 @@ async function initConfigWorkspaceFromPlatform(env, options) {
|
|
|
5019
5060
|
sysconfigdiff_base_url: sysconfigdiffBaseUrlFromEnvironment(platformEnv),
|
|
5020
5061
|
sysconfig_repo_path: workspaceDir,
|
|
5021
5062
|
git_remote: "origin",
|
|
5063
|
+
git_branch: PLATFORM_SYSCONFIG_BRANCH,
|
|
5022
5064
|
extra_headers: {}
|
|
5023
5065
|
}
|
|
5024
5066
|
};
|
|
@@ -5036,6 +5078,7 @@ async function initConfigWorkspaceFromPlatform(env, options) {
|
|
|
5036
5078
|
workspace_dir: workspaceDir,
|
|
5037
5079
|
cloned: !existed,
|
|
5038
5080
|
profile_saved: true,
|
|
5081
|
+
git_branch: PLATFORM_SYSCONFIG_BRANCH,
|
|
5039
5082
|
agents_file: guide.path,
|
|
5040
5083
|
next_commands: {
|
|
5041
5084
|
latest_pull: `${commandPrefix2()} config latest pull ${env} --profile ${profile.name} --format json`
|
|
@@ -5061,9 +5104,11 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
5061
5104
|
for (const step of ["pullcommit", "extract", "pushcommit"]) {
|
|
5062
5105
|
steps[step] = String(redactAuditValue(await callPlatformSysconfigStep(platformEnvironment, env, step)));
|
|
5063
5106
|
}
|
|
5107
|
+
const gitRemote = environment.git_remote || "origin";
|
|
5108
|
+
const gitBranch = environment.git_branch || PLATFORM_SYSCONFIG_BRANCH;
|
|
5064
5109
|
const pull = await withTransientGitCredentials(
|
|
5065
5110
|
gitCredentials,
|
|
5066
|
-
(envVars) => execFileAsync("git", ["pull", "--ff-only",
|
|
5111
|
+
(envVars) => execFileAsync("git", ["pull", "--ff-only", gitRemote, gitBranch], {
|
|
5067
5112
|
cwd: repo,
|
|
5068
5113
|
...envVars ? { env: envVars } : {}
|
|
5069
5114
|
})
|