@go-to-k/cdkd 0.91.5 → 0.93.0
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/README.md +43 -2
- package/dist/cli.js +201 -63
- package/dist/cli.js.map +4 -4
- package/dist/go-to-k-cdkd-0.93.0.tgz +0 -0
- package/dist/index.js +24 -6
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/go-to-k-cdkd-0.91.5.tgz +0 -0
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -442,10 +442,20 @@ function withStackName(stackName, fn) {
|
|
|
442
442
|
function getCurrentStackName() {
|
|
443
443
|
return stackNameStore.getStore();
|
|
444
444
|
}
|
|
445
|
+
var skipPrefixStore = new AsyncLocalStorage();
|
|
446
|
+
function getCurrentSkipPrefix() {
|
|
447
|
+
return skipPrefixStore.getStore() ?? false;
|
|
448
|
+
}
|
|
445
449
|
function generateResourceName(name, options) {
|
|
446
|
-
const {
|
|
450
|
+
const {
|
|
451
|
+
maxLength,
|
|
452
|
+
lowercase = false,
|
|
453
|
+
allowedPattern = /[^a-zA-Z0-9-]/g,
|
|
454
|
+
userSupplied = false
|
|
455
|
+
} = options;
|
|
447
456
|
const currentStackName = stackNameStore.getStore();
|
|
448
|
-
const
|
|
457
|
+
const shouldPrefix = currentStackName && !(userSupplied && getCurrentSkipPrefix());
|
|
458
|
+
const fullName = shouldPrefix ? `${currentStackName}-${name}` : name;
|
|
449
459
|
let sanitized = lowercase ? fullName.toLowerCase() : fullName;
|
|
450
460
|
sanitized = sanitized.replace(allowedPattern, "-");
|
|
451
461
|
sanitized = sanitized.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -457,6 +467,12 @@ function generateResourceName(name, options) {
|
|
|
457
467
|
const prefix = sanitized.substring(0, maxPrefixLength).replace(/-+$/, "");
|
|
458
468
|
return `${prefix}-${hash}`;
|
|
459
469
|
}
|
|
470
|
+
function generateResourceNameWithFallback(userSuppliedName, logicalId, options) {
|
|
471
|
+
if (userSuppliedName !== void 0 && userSuppliedName !== "") {
|
|
472
|
+
return generateResourceName(userSuppliedName, { ...options, userSupplied: true });
|
|
473
|
+
}
|
|
474
|
+
return generateResourceName(logicalId, { ...options, userSupplied: false });
|
|
475
|
+
}
|
|
460
476
|
var FALLBACK_NAME_RULES = {
|
|
461
477
|
"AWS::S3::Bucket": { nameProperty: "BucketName", options: { maxLength: 63, lowercase: true } },
|
|
462
478
|
"AWS::SQS::Queue": { nameProperty: "QueueName", options: { maxLength: 80 } },
|
|
@@ -7865,8 +7881,9 @@ var IAMRoleProvider = class {
|
|
|
7865
7881
|
*/
|
|
7866
7882
|
async create(logicalId, resourceType, properties) {
|
|
7867
7883
|
this.logger.debug(`Creating IAM role ${logicalId}`);
|
|
7868
|
-
const roleName =
|
|
7869
|
-
properties["RoleName"]
|
|
7884
|
+
const roleName = generateResourceNameWithFallback(
|
|
7885
|
+
properties["RoleName"],
|
|
7886
|
+
logicalId,
|
|
7870
7887
|
{ maxLength: 64 }
|
|
7871
7888
|
);
|
|
7872
7889
|
const assumeRolePolicyDocument = properties["AssumeRolePolicyDocument"];
|
|
@@ -7958,8 +7975,9 @@ var IAMRoleProvider = class {
|
|
|
7958
7975
|
*/
|
|
7959
7976
|
async update(logicalId, physicalId, resourceType, properties, previousProperties) {
|
|
7960
7977
|
this.logger.debug(`Updating IAM role ${logicalId}: ${physicalId}`);
|
|
7961
|
-
const newRoleName =
|
|
7962
|
-
properties["RoleName"]
|
|
7978
|
+
const newRoleName = generateResourceNameWithFallback(
|
|
7979
|
+
properties["RoleName"],
|
|
7980
|
+
logicalId,
|
|
7963
7981
|
{ maxLength: 64 }
|
|
7964
7982
|
);
|
|
7965
7983
|
const newPath = properties["Path"] || "/";
|