@lark-apaas/fullstack-cli 1.1.40-alpha.1 → 1.1.40-alpha.2

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.
Files changed (2) hide show
  1. package/dist/index.js +12 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3107,8 +3107,8 @@ 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
  }
@@ -3119,7 +3119,7 @@ function getGrayscaleConfig() {
3119
3119
  }
3120
3120
  return config;
3121
3121
  } catch {
3122
- console.warn("[grayscale] Failed to parse GRAYSCALE_CONFIG env");
3122
+ console.warn("[grayscale] Failed to parse grayscale config");
3123
3123
  return null;
3124
3124
  }
3125
3125
  }
@@ -3224,14 +3224,12 @@ function readProjectIdentity(cwd) {
3224
3224
  }
3225
3225
 
3226
3226
  // src/utils/grayscale/rules.ts
3227
- import { createHash } from "crypto";
3228
- function isInPercentage(key, percentage) {
3227
+ function isInPercentage(tenantId, percentage) {
3229
3228
  if (percentage <= 0) return false;
3230
3229
  if (percentage >= 100) return true;
3231
- const hash = createHash("md5").update(`grayscale:${key}`).digest("hex");
3232
- const value = parseInt(hash.substring(0, 8), 16) % 1e4;
3233
- const threshold = Math.floor(percentage * 100);
3234
- return value < threshold;
3230
+ const id = parseInt(tenantId, 10);
3231
+ if (isNaN(id)) return false;
3232
+ return id % 100 < percentage;
3235
3233
  }
3236
3234
  function matchConditions(rule, identity) {
3237
3235
  const { conditions } = rule;
@@ -3246,9 +3244,7 @@ function matchConditions(rule, identity) {
3246
3244
  }
3247
3245
  }
3248
3246
  if (conditions.percentage != null && conditions.percentage > 0) {
3249
- const hashKey = conditions.hash_key || "app_id";
3250
- const hashValue = hashKey === "tenant_id" ? identity.tenantId : identity.appId;
3251
- if (hashValue && isInPercentage(hashValue, conditions.percentage)) {
3247
+ if (identity.tenantId && isInPercentage(identity.tenantId, conditions.percentage)) {
3252
3248
  return true;
3253
3249
  }
3254
3250
  }
@@ -3294,8 +3290,8 @@ function resolveTargetVersions(config, identity) {
3294
3290
  }
3295
3291
 
3296
3292
  // src/utils/grayscale/index.ts
3297
- function resolveGrayscaleVersions(cwd) {
3298
- const config = getGrayscaleConfig();
3293
+ function resolveGrayscaleVersions(cwd, configJson) {
3294
+ const config = getGrayscaleConfig(configJson);
3299
3295
  if (!config) {
3300
3296
  console.log("[grayscale] Config not available, skipping grayscale");
3301
3297
  return null;
@@ -3418,7 +3414,7 @@ async function run4(options = {}) {
3418
3414
  if (!options.skipGrayscale && !options.version) {
3419
3415
  console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
3420
3416
  try {
3421
- const grayscaleVersions = resolveGrayscaleVersions(cwd);
3417
+ const grayscaleVersions = resolveGrayscaleVersions(cwd, options.grayscaleConfig);
3422
3418
  if (grayscaleVersions) {
3423
3419
  console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
3424
3420
  installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun);
@@ -3459,7 +3455,7 @@ var depsCommand = {
3459
3455
  name: "deps",
3460
3456
  description: "Upgrade @lark-apaas dependencies",
3461
3457
  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) => {
3458
+ 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
3459
  await run4(options);
3464
3460
  });
3465
3461
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.40-alpha.1",
3
+ "version": "1.1.40-alpha.2",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",