@awsless/awsless 0.0.511 → 0.0.513
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/bin.js
CHANGED
|
@@ -1688,8 +1688,8 @@ var IconsSchema = z34.record(
|
|
|
1688
1688
|
})
|
|
1689
1689
|
]).describe(
|
|
1690
1690
|
"Image transformation will be applied from a base image. Base images orginates from a local directory that will be uploaded to S3 or from a lambda function."
|
|
1691
|
-
)
|
|
1692
|
-
version:
|
|
1691
|
+
)
|
|
1692
|
+
// version: z.number().int().min(1).optional().describe('Version of the icon configuration.'),
|
|
1693
1693
|
})
|
|
1694
1694
|
).optional().describe("Define an icon proxy in your stack. Store, optimize, and deliver icons at scale.");
|
|
1695
1695
|
|
|
@@ -6048,8 +6048,7 @@ var imageFeature = defineFeature({
|
|
|
6048
6048
|
appName: ctx.app.name,
|
|
6049
6049
|
stackName: ctx.stack.name,
|
|
6050
6050
|
resourceType: "image",
|
|
6051
|
-
resourceName: id
|
|
6052
|
-
postfix: ctx.appId
|
|
6051
|
+
resourceName: shortId(`${id}-${ctx.appId}`)
|
|
6053
6052
|
}),
|
|
6054
6053
|
forceDestroy: true
|
|
6055
6054
|
});
|
|
@@ -6059,9 +6058,11 @@ var imageFeature = defineFeature({
|
|
|
6059
6058
|
appName: ctx.app.name,
|
|
6060
6059
|
stackName: ctx.stack.name,
|
|
6061
6060
|
resourceType: "image",
|
|
6062
|
-
resourceName: `cache-${id}`
|
|
6063
|
-
// postfix: ctx.appId,
|
|
6061
|
+
resourceName: shortId(`cache-${id}-${ctx.appId}`)
|
|
6064
6062
|
}),
|
|
6063
|
+
tags: {
|
|
6064
|
+
cache: "true"
|
|
6065
|
+
},
|
|
6065
6066
|
forceDestroy: true
|
|
6066
6067
|
});
|
|
6067
6068
|
const sharpLayerId = formatGlobalResourceName({
|
|
@@ -6299,8 +6300,7 @@ var iconFeature = defineFeature({
|
|
|
6299
6300
|
appName: ctx.app.name,
|
|
6300
6301
|
stackName: ctx.stack.name,
|
|
6301
6302
|
resourceType: "icon",
|
|
6302
|
-
resourceName: id
|
|
6303
|
-
postfix: ctx.appId
|
|
6303
|
+
resourceName: shortId(`${id}-${ctx.appId}`)
|
|
6304
6304
|
}),
|
|
6305
6305
|
forceDestroy: true
|
|
6306
6306
|
});
|
|
@@ -6310,9 +6310,11 @@ var iconFeature = defineFeature({
|
|
|
6310
6310
|
appName: ctx.app.name,
|
|
6311
6311
|
stackName: ctx.stack.name,
|
|
6312
6312
|
resourceType: "icon",
|
|
6313
|
-
resourceName: `cache-${id}`
|
|
6314
|
-
// postfix: ctx.appId,
|
|
6313
|
+
resourceName: shortId(`cache-${id}-${ctx.appId}`)
|
|
6315
6314
|
}),
|
|
6315
|
+
tags: {
|
|
6316
|
+
cache: "true"
|
|
6317
|
+
},
|
|
6316
6318
|
forceDestroy: true
|
|
6317
6319
|
});
|
|
6318
6320
|
const serverLambda = createPrebuildLambdaFunction(group, ctx, "icon", id, {
|
|
@@ -6362,8 +6364,7 @@ var iconFeature = defineFeature({
|
|
|
6362
6364
|
"ICON_CONFIG",
|
|
6363
6365
|
JSON.stringify({
|
|
6364
6366
|
preserveId: props.preserveId,
|
|
6365
|
-
symbols: props.symbols
|
|
6366
|
-
version: props.version
|
|
6367
|
+
symbols: props.symbols
|
|
6367
6368
|
})
|
|
6368
6369
|
);
|
|
6369
6370
|
serverLambda.setEnvironment("ICON_CACHE_BUCKET", cacheBucket.bucket);
|
|
@@ -8483,6 +8484,7 @@ var parseJsonLog = (message) => {
|
|
|
8483
8484
|
import { CloudFrontClient as CloudFrontClient2, CreateInvalidationCommand as CreateInvalidationCommand2 } from "@aws-sdk/client-cloudfront";
|
|
8484
8485
|
import { DeleteObjectsCommand, ListObjectsV2Command, S3Client as S3Client3 } from "@aws-sdk/client-s3";
|
|
8485
8486
|
import { Cancelled as Cancelled2, log as log23, prompt as prompt10 } from "@awsless/clui";
|
|
8487
|
+
import { randomUUID } from "crypto";
|
|
8486
8488
|
var clearCache = (program2) => {
|
|
8487
8489
|
program2.command("cache-clear").argument("[stack]", "The stack name of the image proxy").argument("[name]", "The name of the image proxy").description("Clears the cache of the image proxy").action(async (stack, name) => {
|
|
8488
8490
|
await layout("image cache-clear", async ({ appConfig, stackConfigs }) => {
|
|
@@ -8498,7 +8500,7 @@ var clearCache = (program2) => {
|
|
|
8498
8500
|
return;
|
|
8499
8501
|
});
|
|
8500
8502
|
stack = await prompt10.select({
|
|
8501
|
-
message: "Select the
|
|
8503
|
+
message: "Select the stack:",
|
|
8502
8504
|
options: imageStacks.map((stack2) => ({
|
|
8503
8505
|
label: stack2.name,
|
|
8504
8506
|
value: stack2.name
|
|
@@ -8512,10 +8514,10 @@ var clearCache = (program2) => {
|
|
|
8512
8514
|
}
|
|
8513
8515
|
const names = Object.keys(stackConfig.images ?? {});
|
|
8514
8516
|
if (!names) {
|
|
8515
|
-
throw new ExpectedError(`No
|
|
8517
|
+
throw new ExpectedError(`No image resources are defined in stack "${stack}".`);
|
|
8516
8518
|
}
|
|
8517
8519
|
name = await prompt10.select({
|
|
8518
|
-
message: "Select the image:",
|
|
8520
|
+
message: "Select the image resource:",
|
|
8519
8521
|
options: names.map((name2) => ({
|
|
8520
8522
|
label: name2,
|
|
8521
8523
|
value: name2
|
|
@@ -8542,59 +8544,65 @@ var clearCache = (program2) => {
|
|
|
8542
8544
|
distributionId = await shared.entry("image", "distribution-id", name);
|
|
8543
8545
|
cacheBucket = await shared.entry("image", "cache-bucket", name);
|
|
8544
8546
|
} catch (_) {
|
|
8545
|
-
throw new ExpectedError(`The image
|
|
8547
|
+
throw new ExpectedError(`The image resource hasn't been deployed yet.`);
|
|
8546
8548
|
}
|
|
8547
8549
|
const s3Client2 = new S3Client3({
|
|
8548
8550
|
credentials,
|
|
8549
8551
|
region
|
|
8550
8552
|
});
|
|
8551
|
-
let continuationToken;
|
|
8552
|
-
let totalDeleted = 0;
|
|
8553
|
-
let hasMore = true;
|
|
8554
|
-
while (hasMore) {
|
|
8555
|
-
const result = await s3Client2.send(
|
|
8556
|
-
new ListObjectsV2Command({
|
|
8557
|
-
Bucket: cacheBucket,
|
|
8558
|
-
ContinuationToken: continuationToken,
|
|
8559
|
-
MaxKeys: 1e3
|
|
8560
|
-
// Maximum allowed per request
|
|
8561
|
-
})
|
|
8562
|
-
);
|
|
8563
|
-
if (result.Contents && result.Contents.length > 0) {
|
|
8564
|
-
await s3Client2.send(
|
|
8565
|
-
new DeleteObjectsCommand({
|
|
8566
|
-
Bucket: cacheBucket,
|
|
8567
|
-
Delete: {
|
|
8568
|
-
Objects: result.Contents.map((obj) => ({
|
|
8569
|
-
Key: obj.Key
|
|
8570
|
-
})),
|
|
8571
|
-
Quiet: true
|
|
8572
|
-
}
|
|
8573
|
-
})
|
|
8574
|
-
);
|
|
8575
|
-
totalDeleted += result.Contents.length;
|
|
8576
|
-
log23.info(`${result.Contents.length} objects deleted from cache.`);
|
|
8577
|
-
}
|
|
8578
|
-
continuationToken = result.NextContinuationToken;
|
|
8579
|
-
hasMore = !!continuationToken;
|
|
8580
|
-
}
|
|
8581
8553
|
const cloudFrontClient = new CloudFrontClient2({
|
|
8582
8554
|
credentials,
|
|
8583
8555
|
region: "us-east-1"
|
|
8584
8556
|
});
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8557
|
+
let totalDeleted = 0;
|
|
8558
|
+
await log23.task({
|
|
8559
|
+
initialMessage: "Clearing cache...",
|
|
8560
|
+
successMessage: "Cache successfully cleared.",
|
|
8561
|
+
task: async () => {
|
|
8562
|
+
let continuationToken;
|
|
8563
|
+
while (true) {
|
|
8564
|
+
const result = await s3Client2.send(
|
|
8565
|
+
new ListObjectsV2Command({
|
|
8566
|
+
Bucket: cacheBucket,
|
|
8567
|
+
ContinuationToken: continuationToken,
|
|
8568
|
+
MaxKeys: 1e3
|
|
8569
|
+
// Maximum allowed per request
|
|
8570
|
+
})
|
|
8571
|
+
);
|
|
8572
|
+
if (result.Contents && result.Contents.length > 0) {
|
|
8573
|
+
await s3Client2.send(
|
|
8574
|
+
new DeleteObjectsCommand({
|
|
8575
|
+
Bucket: cacheBucket,
|
|
8576
|
+
Delete: {
|
|
8577
|
+
Objects: result.Contents.map((obj) => ({
|
|
8578
|
+
Key: obj.Key
|
|
8579
|
+
})),
|
|
8580
|
+
Quiet: true
|
|
8581
|
+
}
|
|
8582
|
+
})
|
|
8583
|
+
);
|
|
8584
|
+
totalDeleted += result.Contents.length;
|
|
8585
|
+
}
|
|
8586
|
+
continuationToken = result.NextContinuationToken;
|
|
8587
|
+
if (!continuationToken) {
|
|
8588
|
+
break;
|
|
8593
8589
|
}
|
|
8594
8590
|
}
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8591
|
+
await cloudFrontClient.send(
|
|
8592
|
+
new CreateInvalidationCommand2({
|
|
8593
|
+
DistributionId: distributionId,
|
|
8594
|
+
InvalidationBatch: {
|
|
8595
|
+
CallerReference: randomUUID(),
|
|
8596
|
+
Paths: {
|
|
8597
|
+
Quantity: 1,
|
|
8598
|
+
Items: ["/*"]
|
|
8599
|
+
}
|
|
8600
|
+
}
|
|
8601
|
+
})
|
|
8602
|
+
);
|
|
8603
|
+
}
|
|
8604
|
+
});
|
|
8605
|
+
return `${totalDeleted} objects deleted from cache.`;
|
|
8598
8606
|
});
|
|
8599
8607
|
});
|
|
8600
8608
|
};
|
|
@@ -8610,6 +8618,7 @@ var image = (program2) => {
|
|
|
8610
8618
|
import { CloudFrontClient as CloudFrontClient3, CreateInvalidationCommand as CreateInvalidationCommand3 } from "@aws-sdk/client-cloudfront";
|
|
8611
8619
|
import { DeleteObjectsCommand as DeleteObjectsCommand2, ListObjectsV2Command as ListObjectsV2Command2, S3Client as S3Client4 } from "@aws-sdk/client-s3";
|
|
8612
8620
|
import { Cancelled as Cancelled3, log as log24, prompt as prompt11 } from "@awsless/clui";
|
|
8621
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
8613
8622
|
var clearCache2 = (program2) => {
|
|
8614
8623
|
program2.command("cache-clear").argument("[stack]", "The stack name of the icon proxy").argument("[name]", "The name of the icon proxy").description("Clears the cache of the icon proxy").action(async (stack, name) => {
|
|
8615
8624
|
await layout("icon cache-clear", async ({ appConfig, stackConfigs }) => {
|
|
@@ -8625,7 +8634,7 @@ var clearCache2 = (program2) => {
|
|
|
8625
8634
|
return;
|
|
8626
8635
|
});
|
|
8627
8636
|
stack = await prompt11.select({
|
|
8628
|
-
message: "Select the
|
|
8637
|
+
message: "Select the stack:",
|
|
8629
8638
|
options: iconStacks.map((stack2) => ({
|
|
8630
8639
|
label: stack2.name,
|
|
8631
8640
|
value: stack2.name
|
|
@@ -8639,10 +8648,10 @@ var clearCache2 = (program2) => {
|
|
|
8639
8648
|
}
|
|
8640
8649
|
const names = Object.keys(stackConfig.icons ?? {});
|
|
8641
8650
|
if (!names) {
|
|
8642
|
-
throw new ExpectedError(`No
|
|
8651
|
+
throw new ExpectedError(`No icon resources are defined in stack "${stack}".`);
|
|
8643
8652
|
}
|
|
8644
8653
|
name = await prompt11.select({
|
|
8645
|
-
message: "Select the icon:",
|
|
8654
|
+
message: "Select the icon resource:",
|
|
8646
8655
|
options: names.map((name2) => ({
|
|
8647
8656
|
label: name2,
|
|
8648
8657
|
value: name2
|
|
@@ -8669,59 +8678,65 @@ var clearCache2 = (program2) => {
|
|
|
8669
8678
|
distributionId = await shared.entry("icon", "distribution-id", name);
|
|
8670
8679
|
cacheBucket = await shared.entry("icon", "cache-bucket", name);
|
|
8671
8680
|
} catch (_) {
|
|
8672
|
-
throw new ExpectedError(`The icon
|
|
8681
|
+
throw new ExpectedError(`The icon resource hasn't been deployed yet.`);
|
|
8673
8682
|
}
|
|
8674
8683
|
const s3Client2 = new S3Client4({
|
|
8675
8684
|
credentials,
|
|
8676
8685
|
region
|
|
8677
8686
|
});
|
|
8678
|
-
let continuationToken;
|
|
8679
|
-
let totalDeleted = 0;
|
|
8680
|
-
let hasMore = true;
|
|
8681
|
-
while (hasMore) {
|
|
8682
|
-
const result = await s3Client2.send(
|
|
8683
|
-
new ListObjectsV2Command2({
|
|
8684
|
-
Bucket: cacheBucket,
|
|
8685
|
-
ContinuationToken: continuationToken,
|
|
8686
|
-
MaxKeys: 1e3
|
|
8687
|
-
// Maximum allowed per request
|
|
8688
|
-
})
|
|
8689
|
-
);
|
|
8690
|
-
if (result.Contents && result.Contents.length > 0) {
|
|
8691
|
-
await s3Client2.send(
|
|
8692
|
-
new DeleteObjectsCommand2({
|
|
8693
|
-
Bucket: cacheBucket,
|
|
8694
|
-
Delete: {
|
|
8695
|
-
Objects: result.Contents.map((obj) => ({
|
|
8696
|
-
Key: obj.Key
|
|
8697
|
-
})),
|
|
8698
|
-
Quiet: true
|
|
8699
|
-
}
|
|
8700
|
-
})
|
|
8701
|
-
);
|
|
8702
|
-
totalDeleted += result.Contents.length;
|
|
8703
|
-
log24.info(`${result.Contents.length} objects deleted from cache.`);
|
|
8704
|
-
}
|
|
8705
|
-
continuationToken = result.NextContinuationToken;
|
|
8706
|
-
hasMore = !!continuationToken;
|
|
8707
|
-
}
|
|
8708
8687
|
const cloudFrontClient = new CloudFrontClient3({
|
|
8709
8688
|
credentials,
|
|
8710
8689
|
region: "us-east-1"
|
|
8711
8690
|
});
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8691
|
+
let totalDeleted = 0;
|
|
8692
|
+
await log24.task({
|
|
8693
|
+
initialMessage: "Clearing cache...",
|
|
8694
|
+
successMessage: "Cache successfully cleared.",
|
|
8695
|
+
task: async () => {
|
|
8696
|
+
let continuationToken;
|
|
8697
|
+
while (true) {
|
|
8698
|
+
const result = await s3Client2.send(
|
|
8699
|
+
new ListObjectsV2Command2({
|
|
8700
|
+
Bucket: cacheBucket,
|
|
8701
|
+
ContinuationToken: continuationToken,
|
|
8702
|
+
MaxKeys: 1e3
|
|
8703
|
+
// Maximum allowed per request
|
|
8704
|
+
})
|
|
8705
|
+
);
|
|
8706
|
+
if (result.Contents && result.Contents.length > 0) {
|
|
8707
|
+
await s3Client2.send(
|
|
8708
|
+
new DeleteObjectsCommand2({
|
|
8709
|
+
Bucket: cacheBucket,
|
|
8710
|
+
Delete: {
|
|
8711
|
+
Objects: result.Contents.map((obj) => ({
|
|
8712
|
+
Key: obj.Key
|
|
8713
|
+
})),
|
|
8714
|
+
Quiet: true
|
|
8715
|
+
}
|
|
8716
|
+
})
|
|
8717
|
+
);
|
|
8718
|
+
totalDeleted += result.Contents.length;
|
|
8719
|
+
}
|
|
8720
|
+
continuationToken = result.NextContinuationToken;
|
|
8721
|
+
if (!continuationToken) {
|
|
8722
|
+
break;
|
|
8720
8723
|
}
|
|
8721
8724
|
}
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
+
await cloudFrontClient.send(
|
|
8726
|
+
new CreateInvalidationCommand3({
|
|
8727
|
+
DistributionId: distributionId,
|
|
8728
|
+
InvalidationBatch: {
|
|
8729
|
+
CallerReference: randomUUID2(),
|
|
8730
|
+
Paths: {
|
|
8731
|
+
Quantity: 1,
|
|
8732
|
+
Items: ["/*"]
|
|
8733
|
+
}
|
|
8734
|
+
}
|
|
8735
|
+
})
|
|
8736
|
+
);
|
|
8737
|
+
}
|
|
8738
|
+
});
|
|
8739
|
+
return `${totalDeleted} objects deleted from cache.`;
|
|
8725
8740
|
});
|
|
8726
8741
|
});
|
|
8727
8742
|
};
|
|
@@ -1090,8 +1090,8 @@ var IconsSchema = z31.record(
|
|
|
1090
1090
|
})
|
|
1091
1091
|
]).describe(
|
|
1092
1092
|
"Image transformation will be applied from a base image. Base images orginates from a local directory that will be uploaded to S3 or from a lambda function."
|
|
1093
|
-
)
|
|
1094
|
-
version:
|
|
1093
|
+
)
|
|
1094
|
+
// version: z.number().int().min(1).optional().describe('Version of the icon configuration.'),
|
|
1095
1095
|
})
|
|
1096
1096
|
).optional().describe("Define an icon proxy in your stack. Store, optimize, and deliver icons at scale.");
|
|
1097
1097
|
|
package/dist/prebuild/icon/HASH
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
335545401eb807d040031352ed637833c4aba83e
|
|
Binary file
|
|
Binary file
|
|
Binary file
|