@lark-apaas/fullstack-cli 1.1.40-alpha.4 → 1.1.40-alpha.6
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 +24 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3240,74 +3240,53 @@ function isInPercentage(tenantId, percentage) {
|
|
|
3240
3240
|
return id % 100 < percentage;
|
|
3241
3241
|
}
|
|
3242
3242
|
function matchRule(rule, identity) {
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
if (!identity.tenantId || !rule.tenant_ids.includes(identity.tenantId)) {
|
|
3247
|
-
return false;
|
|
3243
|
+
switch (rule.type) {
|
|
3244
|
+
case "tenant_id": {
|
|
3245
|
+
return !!identity.tenantId && rule.values.includes(identity.tenantId);
|
|
3248
3246
|
}
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
hasAnyCondition = true;
|
|
3252
|
-
if (!identity.appId || !rule.app_ids.includes(identity.appId)) {
|
|
3253
|
-
return false;
|
|
3247
|
+
case "app_id": {
|
|
3248
|
+
return !!identity.appId && rule.values.includes(identity.appId);
|
|
3254
3249
|
}
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
hasAnyCondition = true;
|
|
3258
|
-
if (rule.percentage < 100) {
|
|
3259
|
-
if (!identity.tenantId || !isInPercentage(identity.tenantId, rule.percentage)) {
|
|
3260
|
-
return false;
|
|
3261
|
-
}
|
|
3250
|
+
case "canary": {
|
|
3251
|
+
return identity.xTtEnv === rule.value;
|
|
3262
3252
|
}
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
return
|
|
3253
|
+
case "percentage": {
|
|
3254
|
+
if (rule.value >= 100) return true;
|
|
3255
|
+
if (rule.value <= 0) return false;
|
|
3256
|
+
if (!identity.tenantId) return false;
|
|
3257
|
+
return isInPercentage(identity.tenantId, rule.value);
|
|
3268
3258
|
}
|
|
3259
|
+
default:
|
|
3260
|
+
return false;
|
|
3269
3261
|
}
|
|
3270
|
-
return hasAnyCondition;
|
|
3271
|
-
}
|
|
3272
|
-
function matchChannel(channel, identity) {
|
|
3273
|
-
if (!channel.rules || channel.rules.length === 0) return false;
|
|
3274
|
-
return channel.rules.some((rule) => matchRule(rule, identity));
|
|
3275
3262
|
}
|
|
3276
|
-
function isBlocked(
|
|
3277
|
-
if (identity.tenantId &&
|
|
3263
|
+
function isBlocked(channel, identity) {
|
|
3264
|
+
if (identity.tenantId && channel.blocklist?.tenant_ids?.includes(identity.tenantId)) {
|
|
3278
3265
|
return true;
|
|
3279
3266
|
}
|
|
3280
|
-
if (identity.appId &&
|
|
3267
|
+
if (identity.appId && channel.blocklist?.app_ids?.includes(identity.appId)) {
|
|
3281
3268
|
return true;
|
|
3282
3269
|
}
|
|
3283
3270
|
return false;
|
|
3284
3271
|
}
|
|
3272
|
+
function matchChannel(channel, identity) {
|
|
3273
|
+
if (isBlocked(channel, identity)) return false;
|
|
3274
|
+
if (!channel.rules || channel.rules.length === 0) return false;
|
|
3275
|
+
return channel.rules.some((rule) => matchRule(rule, identity));
|
|
3276
|
+
}
|
|
3285
3277
|
function resolveTargetVersions(config, identity) {
|
|
3286
3278
|
const stableVersions = config.stable?.versions || {};
|
|
3287
|
-
|
|
3288
|
-
if (isBlocked(config, identity)) {
|
|
3289
|
-
console.log("[grayscale] Tenant/app is in blocklist, use stable");
|
|
3290
|
-
} else {
|
|
3291
|
-
matchedChannel = (config.channels || []).find((ch) => matchChannel(ch, identity));
|
|
3292
|
-
}
|
|
3279
|
+
const matchedChannel = (config.channels || []).find((ch) => matchChannel(ch, identity));
|
|
3293
3280
|
const merged = /* @__PURE__ */ new Map();
|
|
3294
3281
|
for (const [pkg2, version] of Object.entries(stableVersions)) {
|
|
3295
|
-
if (config.blocked_versions?.includes(version)) {
|
|
3296
|
-
console.warn(`[grayscale] stable version ${version} of ${pkg2} is blocked, skipping`);
|
|
3297
|
-
continue;
|
|
3298
|
-
}
|
|
3299
3282
|
merged.set(pkg2, version);
|
|
3300
3283
|
}
|
|
3301
3284
|
if (matchedChannel) {
|
|
3302
3285
|
console.log(`[grayscale] Matched channel: ${matchedChannel.name}`);
|
|
3303
3286
|
for (const [pkg2, version] of Object.entries(matchedChannel.versions || {})) {
|
|
3304
|
-
if (config.blocked_versions?.includes(version)) {
|
|
3305
|
-
console.warn(`[grayscale] channel version ${version} of ${pkg2} is blocked, skipping`);
|
|
3306
|
-
continue;
|
|
3307
|
-
}
|
|
3308
3287
|
merged.set(pkg2, version);
|
|
3309
3288
|
}
|
|
3310
|
-
} else
|
|
3289
|
+
} else {
|
|
3311
3290
|
console.log("[grayscale] No channel matched, use stable");
|
|
3312
3291
|
}
|
|
3313
3292
|
return merged.size > 0 ? merged : null;
|