@catladder/cli 1.148.1 → 1.149.1

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/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  }
53
53
  ],
54
54
  "license": "MIT",
55
- "version": "1.148.1",
55
+ "version": "1.149.1",
56
56
  "scripts": {
57
57
  "lint": "eslint \"src/**/*.ts\"",
58
58
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -28,14 +28,32 @@ const upsertGcloudServiceAccount = async (
28
28
  const { projectId, name, displayName, roles, description } = account;
29
29
 
30
30
  // name has limit of 30
31
- const namePrefix = `${name}-`;
32
- const nameSuffix = `-${context.environment.shortName}-${context.componentName}`;
33
- const nameMiddleLength = 30 - namePrefix.length - nameSuffix.length;
34
- const nameMiddle = `${context.fullConfig.customerName}-${context.fullConfig.appName}`;
35
-
36
- const middle = hashIfNessecary(nameMiddle, nameMiddleLength);
31
+ const namePrefix = `${name}`;
32
+ const nameSuffixRaw = `${context.environment.shortName}-${context.componentName}`;
33
+ const nameMiddleRaw = `${context.fullConfig.customerName}-${context.fullConfig.appName}`;
34
+ const MAX_LENGTH = 30;
35
+ const NUM_SEPARATORS = 2;
36
+
37
+ // we want to first hash middle, then suffix
38
+ // if for middle we have at least 1 char left, its ok, so we don't hash nameSuffix, otherwise we need to hash that as well
39
+
40
+ const middleMaxLength =
41
+ MAX_LENGTH - namePrefix.length - nameSuffixRaw.length - NUM_SEPARATORS;
42
+
43
+ let nameMiddle: string;
44
+ let nameSuffix: string;
45
+ if (middleMaxLength < 1) {
46
+ nameMiddle = hashIfNessecary(nameMiddleRaw, 1);
47
+ nameSuffix = hashIfNessecary(
48
+ nameSuffixRaw,
49
+ MAX_LENGTH - namePrefix.length - 1 - NUM_SEPARATORS,
50
+ );
51
+ } else {
52
+ nameMiddle = hashIfNessecary(nameMiddleRaw, middleMaxLength);
53
+ nameSuffix = nameSuffixRaw;
54
+ }
37
55
 
38
- const fullName = `${namePrefix}${middle}${nameSuffix}`;
56
+ const fullName = `${namePrefix}-${nameMiddle}-${nameSuffix}`;
39
57
 
40
58
  const fullDisplayName = `${context.fullConfig.customerName}-${context.fullConfig.appName} ${context.environment.shortName}:${context.componentName} | ${displayName}`;
41
59