@awsless/awsless 0.0.512 → 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
|
});
|
|
@@ -6061,6 +6060,9 @@ var imageFeature = defineFeature({
|
|
|
6061
6060
|
resourceType: "image",
|
|
6062
6061
|
resourceName: shortId(`cache-${id}-${ctx.appId}`)
|
|
6063
6062
|
}),
|
|
6063
|
+
tags: {
|
|
6064
|
+
cache: "true"
|
|
6065
|
+
},
|
|
6064
6066
|
forceDestroy: true
|
|
6065
6067
|
});
|
|
6066
6068
|
const sharpLayerId = formatGlobalResourceName({
|
|
@@ -6298,8 +6300,7 @@ var iconFeature = defineFeature({
|
|
|
6298
6300
|
appName: ctx.app.name,
|
|
6299
6301
|
stackName: ctx.stack.name,
|
|
6300
6302
|
resourceType: "icon",
|
|
6301
|
-
resourceName: id
|
|
6302
|
-
postfix: ctx.appId
|
|
6303
|
+
resourceName: shortId(`${id}-${ctx.appId}`)
|
|
6303
6304
|
}),
|
|
6304
6305
|
forceDestroy: true
|
|
6305
6306
|
});
|
|
@@ -6311,6 +6312,9 @@ var iconFeature = defineFeature({
|
|
|
6311
6312
|
resourceType: "icon",
|
|
6312
6313
|
resourceName: shortId(`cache-${id}-${ctx.appId}`)
|
|
6313
6314
|
}),
|
|
6315
|
+
tags: {
|
|
6316
|
+
cache: "true"
|
|
6317
|
+
},
|
|
6314
6318
|
forceDestroy: true
|
|
6315
6319
|
});
|
|
6316
6320
|
const serverLambda = createPrebuildLambdaFunction(group, ctx, "icon", id, {
|
|
@@ -6360,8 +6364,7 @@ var iconFeature = defineFeature({
|
|
|
6360
6364
|
"ICON_CONFIG",
|
|
6361
6365
|
JSON.stringify({
|
|
6362
6366
|
preserveId: props.preserveId,
|
|
6363
|
-
symbols: props.symbols
|
|
6364
|
-
version: props.version
|
|
6367
|
+
symbols: props.symbols
|
|
6365
6368
|
})
|
|
6366
6369
|
);
|
|
6367
6370
|
serverLambda.setEnvironment("ICON_CACHE_BUCKET", cacheBucket.bucket);
|
|
@@ -8481,6 +8484,7 @@ var parseJsonLog = (message) => {
|
|
|
8481
8484
|
import { CloudFrontClient as CloudFrontClient2, CreateInvalidationCommand as CreateInvalidationCommand2 } from "@aws-sdk/client-cloudfront";
|
|
8482
8485
|
import { DeleteObjectsCommand, ListObjectsV2Command, S3Client as S3Client3 } from "@aws-sdk/client-s3";
|
|
8483
8486
|
import { Cancelled as Cancelled2, log as log23, prompt as prompt10 } from "@awsless/clui";
|
|
8487
|
+
import { randomUUID } from "crypto";
|
|
8484
8488
|
var clearCache = (program2) => {
|
|
8485
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) => {
|
|
8486
8490
|
await layout("image cache-clear", async ({ appConfig, stackConfigs }) => {
|
|
@@ -8496,7 +8500,7 @@ var clearCache = (program2) => {
|
|
|
8496
8500
|
return;
|
|
8497
8501
|
});
|
|
8498
8502
|
stack = await prompt10.select({
|
|
8499
|
-
message: "Select the
|
|
8503
|
+
message: "Select the stack:",
|
|
8500
8504
|
options: imageStacks.map((stack2) => ({
|
|
8501
8505
|
label: stack2.name,
|
|
8502
8506
|
value: stack2.name
|
|
@@ -8510,10 +8514,10 @@ var clearCache = (program2) => {
|
|
|
8510
8514
|
}
|
|
8511
8515
|
const names = Object.keys(stackConfig.images ?? {});
|
|
8512
8516
|
if (!names) {
|
|
8513
|
-
throw new ExpectedError(`No
|
|
8517
|
+
throw new ExpectedError(`No image resources are defined in stack "${stack}".`);
|
|
8514
8518
|
}
|
|
8515
8519
|
name = await prompt10.select({
|
|
8516
|
-
message: "Select the image:",
|
|
8520
|
+
message: "Select the image resource:",
|
|
8517
8521
|
options: names.map((name2) => ({
|
|
8518
8522
|
label: name2,
|
|
8519
8523
|
value: name2
|
|
@@ -8540,59 +8544,65 @@ var clearCache = (program2) => {
|
|
|
8540
8544
|
distributionId = await shared.entry("image", "distribution-id", name);
|
|
8541
8545
|
cacheBucket = await shared.entry("image", "cache-bucket", name);
|
|
8542
8546
|
} catch (_) {
|
|
8543
|
-
throw new ExpectedError(`The image
|
|
8547
|
+
throw new ExpectedError(`The image resource hasn't been deployed yet.`);
|
|
8544
8548
|
}
|
|
8545
8549
|
const s3Client2 = new S3Client3({
|
|
8546
8550
|
credentials,
|
|
8547
8551
|
region
|
|
8548
8552
|
});
|
|
8549
|
-
let continuationToken;
|
|
8550
|
-
let totalDeleted = 0;
|
|
8551
|
-
let hasMore = true;
|
|
8552
|
-
while (hasMore) {
|
|
8553
|
-
const result = await s3Client2.send(
|
|
8554
|
-
new ListObjectsV2Command({
|
|
8555
|
-
Bucket: cacheBucket,
|
|
8556
|
-
ContinuationToken: continuationToken,
|
|
8557
|
-
MaxKeys: 1e3
|
|
8558
|
-
// Maximum allowed per request
|
|
8559
|
-
})
|
|
8560
|
-
);
|
|
8561
|
-
if (result.Contents && result.Contents.length > 0) {
|
|
8562
|
-
await s3Client2.send(
|
|
8563
|
-
new DeleteObjectsCommand({
|
|
8564
|
-
Bucket: cacheBucket,
|
|
8565
|
-
Delete: {
|
|
8566
|
-
Objects: result.Contents.map((obj) => ({
|
|
8567
|
-
Key: obj.Key
|
|
8568
|
-
})),
|
|
8569
|
-
Quiet: true
|
|
8570
|
-
}
|
|
8571
|
-
})
|
|
8572
|
-
);
|
|
8573
|
-
totalDeleted += result.Contents.length;
|
|
8574
|
-
log23.info(`${result.Contents.length} objects deleted from cache.`);
|
|
8575
|
-
}
|
|
8576
|
-
continuationToken = result.NextContinuationToken;
|
|
8577
|
-
hasMore = !!continuationToken;
|
|
8578
|
-
}
|
|
8579
8553
|
const cloudFrontClient = new CloudFrontClient2({
|
|
8580
8554
|
credentials,
|
|
8581
8555
|
region: "us-east-1"
|
|
8582
8556
|
});
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
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;
|
|
8591
8589
|
}
|
|
8592
8590
|
}
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
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.`;
|
|
8596
8606
|
});
|
|
8597
8607
|
});
|
|
8598
8608
|
};
|
|
@@ -8608,6 +8618,7 @@ var image = (program2) => {
|
|
|
8608
8618
|
import { CloudFrontClient as CloudFrontClient3, CreateInvalidationCommand as CreateInvalidationCommand3 } from "@aws-sdk/client-cloudfront";
|
|
8609
8619
|
import { DeleteObjectsCommand as DeleteObjectsCommand2, ListObjectsV2Command as ListObjectsV2Command2, S3Client as S3Client4 } from "@aws-sdk/client-s3";
|
|
8610
8620
|
import { Cancelled as Cancelled3, log as log24, prompt as prompt11 } from "@awsless/clui";
|
|
8621
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
8611
8622
|
var clearCache2 = (program2) => {
|
|
8612
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) => {
|
|
8613
8624
|
await layout("icon cache-clear", async ({ appConfig, stackConfigs }) => {
|
|
@@ -8623,7 +8634,7 @@ var clearCache2 = (program2) => {
|
|
|
8623
8634
|
return;
|
|
8624
8635
|
});
|
|
8625
8636
|
stack = await prompt11.select({
|
|
8626
|
-
message: "Select the
|
|
8637
|
+
message: "Select the stack:",
|
|
8627
8638
|
options: iconStacks.map((stack2) => ({
|
|
8628
8639
|
label: stack2.name,
|
|
8629
8640
|
value: stack2.name
|
|
@@ -8637,10 +8648,10 @@ var clearCache2 = (program2) => {
|
|
|
8637
8648
|
}
|
|
8638
8649
|
const names = Object.keys(stackConfig.icons ?? {});
|
|
8639
8650
|
if (!names) {
|
|
8640
|
-
throw new ExpectedError(`No
|
|
8651
|
+
throw new ExpectedError(`No icon resources are defined in stack "${stack}".`);
|
|
8641
8652
|
}
|
|
8642
8653
|
name = await prompt11.select({
|
|
8643
|
-
message: "Select the icon:",
|
|
8654
|
+
message: "Select the icon resource:",
|
|
8644
8655
|
options: names.map((name2) => ({
|
|
8645
8656
|
label: name2,
|
|
8646
8657
|
value: name2
|
|
@@ -8667,59 +8678,65 @@ var clearCache2 = (program2) => {
|
|
|
8667
8678
|
distributionId = await shared.entry("icon", "distribution-id", name);
|
|
8668
8679
|
cacheBucket = await shared.entry("icon", "cache-bucket", name);
|
|
8669
8680
|
} catch (_) {
|
|
8670
|
-
throw new ExpectedError(`The icon
|
|
8681
|
+
throw new ExpectedError(`The icon resource hasn't been deployed yet.`);
|
|
8671
8682
|
}
|
|
8672
8683
|
const s3Client2 = new S3Client4({
|
|
8673
8684
|
credentials,
|
|
8674
8685
|
region
|
|
8675
8686
|
});
|
|
8676
|
-
let continuationToken;
|
|
8677
|
-
let totalDeleted = 0;
|
|
8678
|
-
let hasMore = true;
|
|
8679
|
-
while (hasMore) {
|
|
8680
|
-
const result = await s3Client2.send(
|
|
8681
|
-
new ListObjectsV2Command2({
|
|
8682
|
-
Bucket: cacheBucket,
|
|
8683
|
-
ContinuationToken: continuationToken,
|
|
8684
|
-
MaxKeys: 1e3
|
|
8685
|
-
// Maximum allowed per request
|
|
8686
|
-
})
|
|
8687
|
-
);
|
|
8688
|
-
if (result.Contents && result.Contents.length > 0) {
|
|
8689
|
-
await s3Client2.send(
|
|
8690
|
-
new DeleteObjectsCommand2({
|
|
8691
|
-
Bucket: cacheBucket,
|
|
8692
|
-
Delete: {
|
|
8693
|
-
Objects: result.Contents.map((obj) => ({
|
|
8694
|
-
Key: obj.Key
|
|
8695
|
-
})),
|
|
8696
|
-
Quiet: true
|
|
8697
|
-
}
|
|
8698
|
-
})
|
|
8699
|
-
);
|
|
8700
|
-
totalDeleted += result.Contents.length;
|
|
8701
|
-
log24.info(`${result.Contents.length} objects deleted from cache.`);
|
|
8702
|
-
}
|
|
8703
|
-
continuationToken = result.NextContinuationToken;
|
|
8704
|
-
hasMore = !!continuationToken;
|
|
8705
|
-
}
|
|
8706
8687
|
const cloudFrontClient = new CloudFrontClient3({
|
|
8707
8688
|
credentials,
|
|
8708
8689
|
region: "us-east-1"
|
|
8709
8690
|
});
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
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;
|
|
8718
8723
|
}
|
|
8719
8724
|
}
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
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.`;
|
|
8723
8740
|
});
|
|
8724
8741
|
});
|
|
8725
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
|