@lark-apaas/fullstack-cli 1.1.40-alpha.4 → 1.1.40-alpha.5

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 +17 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3240,44 +3240,34 @@ function isInPercentage(tenantId, percentage) {
3240
3240
  return id % 100 < percentage;
3241
3241
  }
3242
3242
  function matchRule(rule, identity) {
3243
- let hasAnyCondition = false;
3244
- if (rule.tenant_ids && rule.tenant_ids.length > 0) {
3245
- hasAnyCondition = true;
3246
- if (!identity.tenantId || !rule.tenant_ids.includes(identity.tenantId)) {
3247
- return false;
3243
+ switch (rule.type) {
3244
+ case "whitelist": {
3245
+ const tenantMatch = rule.tenant_ids && rule.tenant_ids.length > 0 ? !!identity.tenantId && rule.tenant_ids.includes(identity.tenantId) : false;
3246
+ const appMatch = rule.app_ids && rule.app_ids.length > 0 ? !!identity.appId && rule.app_ids.includes(identity.appId) : false;
3247
+ return tenantMatch || appMatch;
3248
3248
  }
3249
- }
3250
- if (rule.app_ids && rule.app_ids.length > 0) {
3251
- hasAnyCondition = true;
3252
- if (!identity.appId || !rule.app_ids.includes(identity.appId)) {
3253
- return false;
3249
+ case "header": {
3250
+ return identity.xTtEnv === rule["x-tt-env"];
3254
3251
  }
3255
- }
3256
- if (rule.percentage != null && rule.percentage > 0) {
3257
- hasAnyCondition = true;
3258
- if (rule.percentage < 100) {
3259
- if (!identity.tenantId || !isInPercentage(identity.tenantId, rule.percentage)) {
3260
- return false;
3261
- }
3252
+ case "percentage": {
3253
+ if (rule.value >= 100) return true;
3254
+ if (rule.value <= 0) return false;
3255
+ if (!identity.tenantId) return false;
3256
+ return isInPercentage(identity.tenantId, rule.value);
3262
3257
  }
3263
- }
3264
- if (rule.x_tt_env) {
3265
- hasAnyCondition = true;
3266
- if (identity.xTtEnv !== rule.x_tt_env) {
3258
+ default:
3267
3259
  return false;
3268
- }
3269
3260
  }
3270
- return hasAnyCondition;
3271
3261
  }
3272
3262
  function matchChannel(channel, identity) {
3273
3263
  if (!channel.rules || channel.rules.length === 0) return false;
3274
3264
  return channel.rules.some((rule) => matchRule(rule, identity));
3275
3265
  }
3276
3266
  function isBlocked(config, identity) {
3277
- if (identity.tenantId && config.blocked_tenant_ids?.includes(identity.tenantId)) {
3267
+ if (identity.tenantId && config.blocklist?.tenant_ids?.includes(identity.tenantId)) {
3278
3268
  return true;
3279
3269
  }
3280
- if (identity.appId && config.blocked_app_ids?.includes(identity.appId)) {
3270
+ if (identity.appId && config.blocklist?.app_ids?.includes(identity.appId)) {
3281
3271
  return true;
3282
3272
  }
3283
3273
  return false;
@@ -3292,7 +3282,7 @@ function resolveTargetVersions(config, identity) {
3292
3282
  }
3293
3283
  const merged = /* @__PURE__ */ new Map();
3294
3284
  for (const [pkg2, version] of Object.entries(stableVersions)) {
3295
- if (config.blocked_versions?.includes(version)) {
3285
+ if (config.blocklist?.versions?.includes(version)) {
3296
3286
  console.warn(`[grayscale] stable version ${version} of ${pkg2} is blocked, skipping`);
3297
3287
  continue;
3298
3288
  }
@@ -3301,7 +3291,7 @@ function resolveTargetVersions(config, identity) {
3301
3291
  if (matchedChannel) {
3302
3292
  console.log(`[grayscale] Matched channel: ${matchedChannel.name}`);
3303
3293
  for (const [pkg2, version] of Object.entries(matchedChannel.versions || {})) {
3304
- if (config.blocked_versions?.includes(version)) {
3294
+ if (config.blocklist?.versions?.includes(version)) {
3305
3295
  console.warn(`[grayscale] channel version ${version} of ${pkg2} is blocked, skipping`);
3306
3296
  continue;
3307
3297
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.40-alpha.4",
3
+ "version": "1.1.40-alpha.5",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",