@lark-apaas/fullstack-cli 1.1.40-alpha.1 → 1.1.40-alpha.3
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/index.js +21 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3107,19 +3107,21 @@ async function run3(options = {}) {
|
|
|
3107
3107
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
3108
3108
|
|
|
3109
3109
|
// src/utils/grayscale/config.ts
|
|
3110
|
-
function getGrayscaleConfig() {
|
|
3111
|
-
const raw = process.env.GRAYSCALE_CONFIG;
|
|
3110
|
+
function getGrayscaleConfig(configJson) {
|
|
3111
|
+
const raw = configJson || process.env.GRAYSCALE_CONFIG;
|
|
3112
3112
|
if (!raw) {
|
|
3113
3113
|
return null;
|
|
3114
3114
|
}
|
|
3115
3115
|
try {
|
|
3116
|
-
const
|
|
3116
|
+
const parsed = JSON.parse(raw);
|
|
3117
|
+
const config = parsed.config || parsed;
|
|
3118
|
+
const tenantId = parsed.tenant_id != null ? String(parsed.tenant_id) : void 0;
|
|
3117
3119
|
if (!config.enabled) {
|
|
3118
3120
|
return null;
|
|
3119
3121
|
}
|
|
3120
|
-
return config;
|
|
3122
|
+
return { config, tenantId };
|
|
3121
3123
|
} catch {
|
|
3122
|
-
console.warn("[grayscale] Failed to parse
|
|
3124
|
+
console.warn("[grayscale] Failed to parse grayscale config");
|
|
3123
3125
|
return null;
|
|
3124
3126
|
}
|
|
3125
3127
|
}
|
|
@@ -3224,14 +3226,12 @@ function readProjectIdentity(cwd) {
|
|
|
3224
3226
|
}
|
|
3225
3227
|
|
|
3226
3228
|
// src/utils/grayscale/rules.ts
|
|
3227
|
-
|
|
3228
|
-
function isInPercentage(key, percentage) {
|
|
3229
|
+
function isInPercentage(tenantId, percentage) {
|
|
3229
3230
|
if (percentage <= 0) return false;
|
|
3230
3231
|
if (percentage >= 100) return true;
|
|
3231
|
-
const
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
return value < threshold;
|
|
3232
|
+
const id = parseInt(tenantId, 10);
|
|
3233
|
+
if (isNaN(id)) return false;
|
|
3234
|
+
return id % 100 < percentage;
|
|
3235
3235
|
}
|
|
3236
3236
|
function matchConditions(rule, identity) {
|
|
3237
3237
|
const { conditions } = rule;
|
|
@@ -3246,9 +3246,8 @@ function matchConditions(rule, identity) {
|
|
|
3246
3246
|
}
|
|
3247
3247
|
}
|
|
3248
3248
|
if (conditions.percentage != null && conditions.percentage > 0) {
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
if (hashValue && isInPercentage(hashValue, conditions.percentage)) {
|
|
3249
|
+
if (conditions.percentage >= 100) return true;
|
|
3250
|
+
if (identity.tenantId && isInPercentage(identity.tenantId, conditions.percentage)) {
|
|
3252
3251
|
return true;
|
|
3253
3252
|
}
|
|
3254
3253
|
}
|
|
@@ -3294,16 +3293,16 @@ function resolveTargetVersions(config, identity) {
|
|
|
3294
3293
|
}
|
|
3295
3294
|
|
|
3296
3295
|
// src/utils/grayscale/index.ts
|
|
3297
|
-
function resolveGrayscaleVersions(cwd) {
|
|
3298
|
-
const
|
|
3299
|
-
if (!
|
|
3296
|
+
function resolveGrayscaleVersions(cwd, configJson) {
|
|
3297
|
+
const result = getGrayscaleConfig(configJson);
|
|
3298
|
+
if (!result) {
|
|
3300
3299
|
console.log("[grayscale] Config not available, skipping grayscale");
|
|
3301
3300
|
return null;
|
|
3302
3301
|
}
|
|
3302
|
+
const { config, tenantId: payloadTenantId } = result;
|
|
3303
3303
|
const identity = readProjectIdentity(cwd);
|
|
3304
|
-
if (
|
|
3305
|
-
|
|
3306
|
-
return null;
|
|
3304
|
+
if (payloadTenantId) {
|
|
3305
|
+
identity.tenantId = payloadTenantId;
|
|
3307
3306
|
}
|
|
3308
3307
|
console.log(`[grayscale] Project identity: appId=${identity.appId || "N/A"}, tenantId=${identity.tenantId || "N/A"}`);
|
|
3309
3308
|
const versions = resolveTargetVersions(config, identity);
|
|
@@ -3418,7 +3417,7 @@ async function run4(options = {}) {
|
|
|
3418
3417
|
if (!options.skipGrayscale && !options.version) {
|
|
3419
3418
|
console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
|
|
3420
3419
|
try {
|
|
3421
|
-
const grayscaleVersions = resolveGrayscaleVersions(cwd);
|
|
3420
|
+
const grayscaleVersions = resolveGrayscaleVersions(cwd, options.grayscaleConfig);
|
|
3422
3421
|
if (grayscaleVersions) {
|
|
3423
3422
|
console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
|
|
3424
3423
|
installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun);
|
|
@@ -3459,7 +3458,7 @@ var depsCommand = {
|
|
|
3459
3458
|
name: "deps",
|
|
3460
3459
|
description: "Upgrade @lark-apaas dependencies",
|
|
3461
3460
|
register(parentCommand) {
|
|
3462
|
-
parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").option("--skip-grayscale", "Skip grayscale version check").option("--dry-run", "Show upgrade plan without executing").action(async (options) => {
|
|
3461
|
+
parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").option("--skip-grayscale", "Skip grayscale version check").option("--grayscale-config <json>", "Grayscale config JSON (injected by sandbox_console)").option("--dry-run", "Show upgrade plan without executing").action(async (options) => {
|
|
3463
3462
|
await run4(options);
|
|
3464
3463
|
});
|
|
3465
3464
|
}
|