@ibm-cloud/cd-tools 1.15.0 → 1.15.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/cmd/utils/utils.js +10 -1
  2. package/package.json +1 -1
@@ -206,12 +206,21 @@ export function getRandChars(size) {
206
206
  };
207
207
 
208
208
  export function normalizeName(str) {
209
- const specialChars = `-<>()*#{}[]|@_ .%'",&`;
209
+ const specialChars = `-–—<>()*#{}[]|@_ .%'",&`; // turn these special chars into underscores
210
+ const whitelistRegex = /[^_\-\p{L}0-9]+/ug // this regex matches anything that is not (unicode, numbers, underscores, and hyphens)
211
+
210
212
  let newStr = str;
211
213
 
212
214
  for (const char of specialChars) {
213
215
  newStr = newStr.replaceAll(char, '_');
214
216
  }
215
217
 
218
+ newStr = newStr.replaceAll(whitelistRegex, '');
219
+
220
+ // terraform resource names must start with a letter
221
+ if (!newStr.slice(0,1).match(/[A-Za-z]/)) {
222
+ newStr = `x_${newStr}`;
223
+ }
224
+
216
225
  return newStr.toLowerCase();
217
226
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibm-cloud/cd-tools",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
4
4
  "description": "Tools and utilities for the IBM Cloud Continuous Delivery service and resources",
5
5
  "repository": {
6
6
  "type": "git",