bpmax-cli 0.1.44-beta.17 → 0.1.44-beta.19
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
CHANGED
|
@@ -449,7 +449,7 @@ function normalizePath2(path11) {
|
|
|
449
449
|
// package.json
|
|
450
450
|
var package_default = {
|
|
451
451
|
name: "bpmax-cli",
|
|
452
|
-
version: "0.1.44-beta.
|
|
452
|
+
version: "0.1.44-beta.19",
|
|
453
453
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
454
454
|
type: "module",
|
|
455
455
|
bin: {
|
|
@@ -6591,6 +6591,8 @@ import { password, text } from "@clack/prompts";
|
|
|
6591
6591
|
import axios5 from "axios";
|
|
6592
6592
|
var execFileAsync = promisify(execFile);
|
|
6593
6593
|
var PLATFORM_SYSCONFIG_BRANCH = "master";
|
|
6594
|
+
var LATEST_EXEC_MAX_BUFFER = 64 * 1024 * 1024;
|
|
6595
|
+
var LATEST_OUTPUT_PREVIEW_CHARS = 4e3;
|
|
6594
6596
|
async function ensureConfigCapability2(profile, capability) {
|
|
6595
6597
|
if (capabilityEnabled(profile.config.capabilities_cache, capability)) {
|
|
6596
6598
|
return;
|
|
@@ -6826,6 +6828,31 @@ function sanitizeConfigRepositoryValue(value) {
|
|
|
6826
6828
|
const redacted = redactAuditValue(value);
|
|
6827
6829
|
return sanitizeGitUrls(redacted);
|
|
6828
6830
|
}
|
|
6831
|
+
function outputText(value) {
|
|
6832
|
+
if (typeof value === "string") {
|
|
6833
|
+
return value;
|
|
6834
|
+
}
|
|
6835
|
+
try {
|
|
6836
|
+
return JSON.stringify(value) ?? String(value);
|
|
6837
|
+
} catch {
|
|
6838
|
+
return String(value);
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
function redactLatestOutputText(value) {
|
|
6842
|
+
return value.replace(/\b(https?:\/\/)([^/\s:@]+):([^/\s@]+)@/gi, "$1[REDACTED]@").replace(/authorization\s*:?\s*bearer\s+[^\s,;]+/gi, "Authorization Bearer [REDACTED]").replace(/authorization\s*:?\s*basic\s+[^\s,;]+/gi, "Authorization Basic [REDACTED]").replace(/\b(cookie|set-cookie|x-api-key)\s*[:=]\s*[^\n\r]+/gi, "$1 [REDACTED]").replace(/(sk-|npm_)[A-Za-z0-9_-]{8,}/g, "$1[REDACTED]").replace(/\b1[3-9]\d{9}\b/g, "[REDACTED_PHONE]").replace(/\b(password|passwd|pwd|token|secret|credential|api[-_]?key|x[-_]?api[-_]?key|access[-_]?token|refresh[-_]?token|client[-_]?secret|session[-_]?id)\s*[:= ]\s*[^\s,;]+/gi, "$1 [REDACTED]").replace(/("(?:[^"]*(?:authorization|auth|api[-_]?key|x[-_]?api[-_]?key|access[-_]?token|refresh[-_]?token|token|password|passwd|pwd|secret|credential|cookie|set[-_]?cookie|session|phone|mobile|device[-_]?code|verification[-_]?code|sms[-_]?code|captcha|手机号|验证码)[^"]*)"\s*:\s*")([^"]*)(")/gi, "$1[REDACTED]$3");
|
|
6843
|
+
}
|
|
6844
|
+
function summarizeLatestOutput(value) {
|
|
6845
|
+
const rawText = outputText(value);
|
|
6846
|
+
const textValue = typeof value === "string" ? redactLatestOutputText(rawText) : outputText(sanitizeConfigRepositoryValue(value));
|
|
6847
|
+
const preview = textValue.slice(0, LATEST_OUTPUT_PREVIEW_CHARS);
|
|
6848
|
+
return {
|
|
6849
|
+
ok: true,
|
|
6850
|
+
bytes: Buffer.byteLength(rawText),
|
|
6851
|
+
lines: rawText ? rawText.split(/\r?\n/).length : 0,
|
|
6852
|
+
truncated: textValue.length > LATEST_OUTPUT_PREVIEW_CHARS,
|
|
6853
|
+
preview
|
|
6854
|
+
};
|
|
6855
|
+
}
|
|
6829
6856
|
function sanitizeGitUrls(value) {
|
|
6830
6857
|
if (Array.isArray(value)) {
|
|
6831
6858
|
return value.map((item) => sanitizeGitUrls(item));
|
|
@@ -7129,14 +7156,20 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
7129
7156
|
}
|
|
7130
7157
|
const platformEnvironment = await fetchPlatformConfigRepositoryEnvironment(profile, env);
|
|
7131
7158
|
const gitCredentials = platformGitCredentials(platformEnvironment);
|
|
7132
|
-
const before = (await execFileAsync("git", ["rev-parse", "HEAD"], {
|
|
7133
|
-
|
|
7159
|
+
const before = (await execFileAsync("git", ["rev-parse", "HEAD"], {
|
|
7160
|
+
cwd: repo,
|
|
7161
|
+
maxBuffer: LATEST_EXEC_MAX_BUFFER
|
|
7162
|
+
})).stdout.trim();
|
|
7163
|
+
const dirty = (await execFileAsync("git", ["status", "--porcelain"], {
|
|
7164
|
+
cwd: repo,
|
|
7165
|
+
maxBuffer: LATEST_EXEC_MAX_BUFFER
|
|
7166
|
+
})).stdout.trim();
|
|
7134
7167
|
if (dirty && !options.allowDirty && hasBlockingDirtyStatus(dirty)) {
|
|
7135
7168
|
throw new Error("Working tree is not clean. Re-run with --allow-dirty only if you accept local changes.");
|
|
7136
7169
|
}
|
|
7137
7170
|
const steps = {};
|
|
7138
7171
|
for (const step of ["pullcommit", "extract", "pushcommit"]) {
|
|
7139
|
-
steps[step] =
|
|
7172
|
+
steps[step] = summarizeLatestOutput(await callPlatformSysconfigStep(platformEnvironment, env, step));
|
|
7140
7173
|
}
|
|
7141
7174
|
const gitRemote = environment.git_remote || "origin";
|
|
7142
7175
|
const gitBranch = environment.git_branch || PLATFORM_SYSCONFIG_BRANCH;
|
|
@@ -7144,12 +7177,22 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
7144
7177
|
gitCredentials,
|
|
7145
7178
|
(envVars) => execFileAsync("git", ["pull", "--ff-only", gitRemote, gitBranch], {
|
|
7146
7179
|
cwd: repo,
|
|
7180
|
+
maxBuffer: LATEST_EXEC_MAX_BUFFER,
|
|
7147
7181
|
...envVars ? { env: envVars } : {}
|
|
7148
7182
|
})
|
|
7149
7183
|
);
|
|
7150
|
-
const after = (await execFileAsync("git", ["rev-parse", "HEAD"], {
|
|
7151
|
-
|
|
7152
|
-
|
|
7184
|
+
const after = (await execFileAsync("git", ["rev-parse", "HEAD"], {
|
|
7185
|
+
cwd: repo,
|
|
7186
|
+
maxBuffer: LATEST_EXEC_MAX_BUFFER
|
|
7187
|
+
})).stdout.trim();
|
|
7188
|
+
const changedFiles = before === after ? "" : (await execFileAsync("git", ["diff", "--name-status", before, after], {
|
|
7189
|
+
cwd: repo,
|
|
7190
|
+
maxBuffer: LATEST_EXEC_MAX_BUFFER
|
|
7191
|
+
})).stdout;
|
|
7192
|
+
const numstat = before === after ? "" : (await execFileAsync("git", ["diff", "--numstat", before, after], {
|
|
7193
|
+
cwd: repo,
|
|
7194
|
+
maxBuffer: LATEST_EXEC_MAX_BUFFER
|
|
7195
|
+
})).stdout;
|
|
7153
7196
|
return {
|
|
7154
7197
|
profile: profile.name,
|
|
7155
7198
|
env,
|
|
@@ -7158,7 +7201,7 @@ async function pullLatestConfigEnvironment(env, options) {
|
|
|
7158
7201
|
after,
|
|
7159
7202
|
changed: before !== after,
|
|
7160
7203
|
steps,
|
|
7161
|
-
git_pull:
|
|
7204
|
+
git_pull: summarizeLatestOutput(pull.stdout || pull.stderr),
|
|
7162
7205
|
changed_files: changedFiles.trim(),
|
|
7163
7206
|
numstat: numstat.trim(),
|
|
7164
7207
|
graph_refresh: options.withGraph && !options.fast ? "requested_external_step" : "skipped"
|
|
@@ -11218,6 +11261,10 @@ var URL_RE = /https?:\/\/|\/w:[^\s,,;;]+|\/project\?|\/project_detail\/|\/pr
|
|
|
11218
11261
|
var SHA_RE = /^[0-9a-f]{40}$/;
|
|
11219
11262
|
var CONFIG_BASIS_REASON_RE = /(依据|覆盖|校验|验证|对应|因为|reason=|why=|=>|->)/;
|
|
11220
11263
|
var PREP_TOKEN_RE = /(账号|入口|样本|准备操作|预期|主数据|权限|自动化|依赖流程|清理策略|绑定解析|定位规则|模拟用户)=/g;
|
|
11264
|
+
var TEST_DATA_TOKEN_RE = /(业务场景|业务逻辑|样本数据|合理性|客户口径|数据约束)=/g;
|
|
11265
|
+
var GENERIC_SAMPLE_VALUE_RE = /(^|[=,;,\s])(sample|test|mock|demo|xxx|todo|tbd|placeholder|随便|假数据|占位|待补)(?=$|[,;,\s])/i;
|
|
11266
|
+
var SENSITIVE_TEST_DATA_RE = /authorization|bearer\s+[A-Za-z0-9._-]+|cookie|set-cookie|api[-_]?key|token|password|passwd|pwd|secret|session|验证码|手机号|\b1[3-9]\d{9}\b/i;
|
|
11267
|
+
var RAW_PAYLOAD_TEST_DATA_RE = /(^|[;;]\s*)(payload|完整payload|request|请求体|headers?)\s*=/i;
|
|
11221
11268
|
var PLACEHOLDER_RE = /<[^>]+>/;
|
|
11222
11269
|
var IMAGE_RE = /!\[[^\]]*]\(([^)]+)\)/g;
|
|
11223
11270
|
var YBS_NONZERO_DETAIL_RE = /https:\/\/yaditest\.yitaiyitai\.com\/w:ybs\/project_detail\/(?!0\/)\d+\//;
|
|
@@ -11350,7 +11397,14 @@ async function validateConfigBasis(filePath, caseId, configBasis) {
|
|
|
11350
11397
|
if (missing.length > 0) fail(`${filePath}:${caseId}: \`config_basis\` references missing config location(s): ${missing.join(", ")}`);
|
|
11351
11398
|
}
|
|
11352
11399
|
function parsePrepData(value) {
|
|
11353
|
-
|
|
11400
|
+
return parseStructuredTokens(value, PREP_TOKEN_RE);
|
|
11401
|
+
}
|
|
11402
|
+
function parseTestData(value) {
|
|
11403
|
+
return parseStructuredTokens(value, TEST_DATA_TOKEN_RE);
|
|
11404
|
+
}
|
|
11405
|
+
function parseStructuredTokens(value, tokenPattern) {
|
|
11406
|
+
tokenPattern.lastIndex = 0;
|
|
11407
|
+
const matches = [...value.matchAll(tokenPattern)];
|
|
11354
11408
|
const tokens = {};
|
|
11355
11409
|
matches.forEach((match, index) => {
|
|
11356
11410
|
const start = (match.index ?? 0) + match[0].length;
|
|
@@ -11359,6 +11413,39 @@ function parsePrepData(value) {
|
|
|
11359
11413
|
});
|
|
11360
11414
|
return tokens;
|
|
11361
11415
|
}
|
|
11416
|
+
function validateBusinessTestData(filePath, caseId, row) {
|
|
11417
|
+
const testData = row.test_data.trim();
|
|
11418
|
+
if (!testData) fail(`${filePath}:${caseId}: \`test_data\` is required`);
|
|
11419
|
+
if (SENSITIVE_TEST_DATA_RE.test(testData) || RAW_PAYLOAD_TEST_DATA_RE.test(testData)) {
|
|
11420
|
+
fail(`${filePath}:${caseId}: \`test_data\` must not include token, cookie, phone number, password, Authorization, or raw payload content`);
|
|
11421
|
+
}
|
|
11422
|
+
const requiredTokens = ["\u4E1A\u52A1\u573A\u666F", "\u4E1A\u52A1\u903B\u8F91", "\u6837\u672C\u6570\u636E", "\u5408\u7406\u6027"];
|
|
11423
|
+
const tokens = parseTestData(testData);
|
|
11424
|
+
const missingTokens = requiredTokens.filter((token) => !tokens[token]);
|
|
11425
|
+
if (missingTokens.length > 0) {
|
|
11426
|
+
fail(`${filePath}:${caseId}: \`test_data\` must include ${requiredTokens.map((token) => `${token}=`).join(", ")}`);
|
|
11427
|
+
}
|
|
11428
|
+
for (const chunk of testData.split(";")) {
|
|
11429
|
+
if (chunk.trim() && !chunk.includes("=")) fail(`${filePath}:${caseId}: every \`test_data\` segment must be key=value`);
|
|
11430
|
+
}
|
|
11431
|
+
if (GENERIC_SAMPLE_VALUE_RE.test(tokens["\u6837\u672C\u6570\u636E"])) {
|
|
11432
|
+
fail(`${filePath}:${caseId}: \`test_data\` token \`\u6837\u672C\u6570\u636E=\` must describe customer-realistic business data, not sample/test/mock/placeholder values`);
|
|
11433
|
+
}
|
|
11434
|
+
for (const token of requiredTokens) {
|
|
11435
|
+
if (tokens[token].trim().length < 6) {
|
|
11436
|
+
fail(`${filePath}:${caseId}: \`test_data\` token \`${token}=\` must explain the customer business scenario and logic`);
|
|
11437
|
+
}
|
|
11438
|
+
}
|
|
11439
|
+
const businessContext = [row.title, row.preconditions, row.prep_data, row.steps, row.expected_result].join(" ");
|
|
11440
|
+
const businessScenarioTerms = tokens["\u4E1A\u52A1\u573A\u666F"].split(/[、,,\s]+/).flatMap((word) => {
|
|
11441
|
+
const trimmed = word.trim();
|
|
11442
|
+
if (trimmed.length >= 4) return [trimmed, trimmed.slice(0, 4)];
|
|
11443
|
+
return [trimmed];
|
|
11444
|
+
});
|
|
11445
|
+
if (!businessScenarioTerms.some((word) => word.length >= 2 && businessContext.includes(word))) {
|
|
11446
|
+
fail(`${filePath}:${caseId}: \`test_data\` token \`\u4E1A\u52A1\u573A\u666F=\` must align with the case title, preconditions, steps, or expected result`);
|
|
11447
|
+
}
|
|
11448
|
+
}
|
|
11362
11449
|
async function validateCase(filePath, row, seen) {
|
|
11363
11450
|
const caseId = row.case_id.trim();
|
|
11364
11451
|
if (!caseId) fail(`${filePath}: case_id is required`);
|
|
@@ -11407,6 +11494,7 @@ async function validateCase(filePath, row, seen) {
|
|
|
11407
11494
|
if (UUID_RE.test(browserText)) fail(`${filePath}:${caseId}: browser-executed cases must not use UUID as the execution entrypoint`);
|
|
11408
11495
|
if (YBS_NONZERO_DETAIL_RE.test(browserText)) fail(`${filePath}:${caseId}: YBS detail URLs must use /w:ybs/project_detail/0/<project_id> unless verified otherwise`);
|
|
11409
11496
|
if (YBS_PC_CREATE_WRONG_RE.test(browserText)) fail(`${filePath}:${caseId}: YBS PC create URLs must use /w:ybs/project/create?flow_type=<flow_type>`);
|
|
11497
|
+
validateBusinessTestData(filePath, caseId, row);
|
|
11410
11498
|
}
|
|
11411
11499
|
async function scenarioDirs(root) {
|
|
11412
11500
|
if (!await exists2(root)) return [];
|