carlin 1.36.13 → 1.36.15
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/index.js +69 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -197,6 +197,8 @@ var BASE_STACK_NAME = `${pascalCaseName}BaseStack`;
|
|
|
197
197
|
var BASE_STACK_BUCKET_TEMPLATES_FOLDER = "cloudformation-templates";
|
|
198
198
|
var BASE_STACK_BUCKET_LOGICAL_NAME = `${pascalCaseName}Bucket`;
|
|
199
199
|
var BASE_STACK_BUCKET_NAME_EXPORTED_NAME = `${pascalCaseName}BucketNameExportedName`;
|
|
200
|
+
var BASE_STACK_CLOUDFRONT_FUNCTION_APPEND_INDEX_HTML_LOGICAL_NAME = `${pascalCaseName}CloudFrontFunctionAppendIndexHtml`;
|
|
201
|
+
var BASE_STACK_CLOUDFRONT_FUNCTION_APPEND_INDEX_HTML_EXPORTED_NAME = `${pascalCaseName}CloudFrontFunctionAppendIndexHtmlExportedName`;
|
|
200
202
|
var BASE_STACK_LAMBDA_IMAGE_BUILDER_LOGICAL_NAME = `${pascalCaseName}LambdaImageBuilder`;
|
|
201
203
|
var BASE_STACK_LAMBDA_IMAGE_BUILDER_EXPORTED_NAME = `${pascalCaseName}LambdaImageBuilderExportedName`;
|
|
202
204
|
var BASE_STACK_LAMBDA_LAYER_BUILDER_LOGICAL_NAME = `${pascalCaseName}LambdaLayerBuilder`;
|
|
@@ -869,6 +871,47 @@ var getBucketTemplate = () => {
|
|
|
869
871
|
}
|
|
870
872
|
};
|
|
871
873
|
};
|
|
874
|
+
|
|
875
|
+
// src/deploy/baseStack/getCloudFrontTemplate.ts
|
|
876
|
+
var functionCode = `function handler(event) {
|
|
877
|
+
var request = event.request;
|
|
878
|
+
var uri = request.uri;
|
|
879
|
+
if (uri.endsWith('/')) {
|
|
880
|
+
request.uri += 'index.html';
|
|
881
|
+
} else if (!uri.includes('.')) {
|
|
882
|
+
request.uri += '/index.html';
|
|
883
|
+
}
|
|
884
|
+
return request;
|
|
885
|
+
}`;
|
|
886
|
+
var getCloudFrontTemplate = () => {
|
|
887
|
+
return {
|
|
888
|
+
AWSTemplateFormatVersion: "2010-09-09",
|
|
889
|
+
Resources: {
|
|
890
|
+
[BASE_STACK_CLOUDFRONT_FUNCTION_APPEND_INDEX_HTML_LOGICAL_NAME]: {
|
|
891
|
+
Type: "AWS::CloudFront::Function",
|
|
892
|
+
Properties: {
|
|
893
|
+
Name: "AppendIndexDotHtml",
|
|
894
|
+
FunctionConfig: {
|
|
895
|
+
Comment: "Append index.html to the request URI",
|
|
896
|
+
Runtime: "cloudfront-js-2.0"
|
|
897
|
+
},
|
|
898
|
+
FunctionCode: functionCode,
|
|
899
|
+
AutoPublish: true
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
Outputs: {
|
|
904
|
+
[BASE_STACK_CLOUDFRONT_FUNCTION_APPEND_INDEX_HTML_LOGICAL_NAME]: {
|
|
905
|
+
Value: {
|
|
906
|
+
Ref: BASE_STACK_CLOUDFRONT_FUNCTION_APPEND_INDEX_HTML_LOGICAL_NAME
|
|
907
|
+
},
|
|
908
|
+
Export: {
|
|
909
|
+
Name: BASE_STACK_CLOUDFRONT_FUNCTION_APPEND_INDEX_HTML_EXPORTED_NAME
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
};
|
|
872
915
|
var getLambdaImageBuilderTemplate = () => {
|
|
873
916
|
const CODE_BUILD_PROJECT_LOGS_LOGICAL_ID2 = "CodeBuildProjectLogsLogGroup";
|
|
874
917
|
const CODE_BUILD_PROJECT_SERVICE_ROLE_LOGICAL_ID2 = "ImageCodeBuildProjectIAMRole";
|
|
@@ -1404,6 +1447,7 @@ var handleDeployInitialization = async ({
|
|
|
1404
1447
|
var logPrefix4 = "base-stack";
|
|
1405
1448
|
var baseStackTemplate = deepmerge.all([
|
|
1406
1449
|
getBucketTemplate(),
|
|
1450
|
+
getCloudFrontTemplate(),
|
|
1407
1451
|
getLambdaImageBuilderTemplate(),
|
|
1408
1452
|
getLambdaLayerBuilderTemplate(),
|
|
1409
1453
|
getVpcTemplate()
|
|
@@ -3460,9 +3504,10 @@ var getBucketStaticWebsiteTemplate = ({
|
|
|
3460
3504
|
}
|
|
3461
3505
|
};
|
|
3462
3506
|
};
|
|
3463
|
-
var
|
|
3507
|
+
var getCloudFrontTemplate2 = ({
|
|
3464
3508
|
acm,
|
|
3465
3509
|
aliases = [],
|
|
3510
|
+
appendIndexHtml,
|
|
3466
3511
|
spa,
|
|
3467
3512
|
hostedZoneName
|
|
3468
3513
|
}) => {
|
|
@@ -3718,20 +3763,35 @@ var getCloudFrontTemplate = ({
|
|
|
3718
3763
|
Value: PACKAGE_VERSION
|
|
3719
3764
|
}
|
|
3720
3765
|
};
|
|
3766
|
+
if (appendIndexHtml) {
|
|
3767
|
+
template.Resources[CLOUDFRONT_DISTRIBUTION_LOGICAL_ID].Properties.DistributionConfig.DefaultCacheBehavior.LambdaFunctionAssociations = [
|
|
3768
|
+
/**
|
|
3769
|
+
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-lambdafunctionassociation.html
|
|
3770
|
+
*/
|
|
3771
|
+
{
|
|
3772
|
+
EventType: "viewer-request",
|
|
3773
|
+
LambdaFunctionARN: {
|
|
3774
|
+
"Fn::ImportValue": BASE_STACK_CLOUDFRONT_FUNCTION_APPEND_INDEX_HTML_EXPORTED_NAME
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
];
|
|
3778
|
+
}
|
|
3721
3779
|
return template;
|
|
3722
3780
|
};
|
|
3723
3781
|
var getStaticAppTemplate = ({
|
|
3724
3782
|
acm,
|
|
3725
3783
|
aliases,
|
|
3784
|
+
appendIndexHtml,
|
|
3726
3785
|
cloudfront,
|
|
3727
3786
|
spa,
|
|
3728
3787
|
hostedZoneName,
|
|
3729
3788
|
region
|
|
3730
3789
|
}) => {
|
|
3731
3790
|
if (cloudfront) {
|
|
3732
|
-
return
|
|
3791
|
+
return getCloudFrontTemplate2({
|
|
3733
3792
|
acm,
|
|
3734
3793
|
aliases,
|
|
3794
|
+
appendIndexHtml,
|
|
3735
3795
|
cloudfront,
|
|
3736
3796
|
spa,
|
|
3737
3797
|
hostedZoneName,
|
|
@@ -3846,6 +3906,7 @@ var logPrefix16 = "static-app";
|
|
|
3846
3906
|
var deployStaticApp = async ({
|
|
3847
3907
|
acm,
|
|
3848
3908
|
aliases,
|
|
3909
|
+
appendIndexHtml,
|
|
3849
3910
|
buildFolder,
|
|
3850
3911
|
cloudfront,
|
|
3851
3912
|
spa,
|
|
@@ -3859,6 +3920,7 @@ var deployStaticApp = async ({
|
|
|
3859
3920
|
const template = getStaticAppTemplate({
|
|
3860
3921
|
acm,
|
|
3861
3922
|
aliases,
|
|
3923
|
+
appendIndexHtml,
|
|
3862
3924
|
cloudfront,
|
|
3863
3925
|
spa,
|
|
3864
3926
|
hostedZoneName,
|
|
@@ -3896,6 +3958,11 @@ var options3 = {
|
|
|
3896
3958
|
implies: ["acm"],
|
|
3897
3959
|
type: "array"
|
|
3898
3960
|
},
|
|
3961
|
+
"append-index-html": {
|
|
3962
|
+
default: false,
|
|
3963
|
+
describe: "This option appends the `index.html` to the request URI. This is useful when deploying a Docusaurus website, for example.",
|
|
3964
|
+
type: "boolean"
|
|
3965
|
+
},
|
|
3899
3966
|
"build-folder": {
|
|
3900
3967
|
describe: `The folder that will be uploaded. If not provided, it'll search for the folders "${defaultBuildFolders.join(
|
|
3901
3968
|
", "
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carlin",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Pedro Arantes <arantespp@gmail.com> (https://twitter.com/arantespp)",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"vercel": "^34.2.0",
|
|
47
47
|
"yargs": "^17.7.2",
|
|
48
48
|
"@ttoss/config": "^1.34.1",
|
|
49
|
-
"@ttoss/
|
|
50
|
-
"@ttoss/
|
|
49
|
+
"@ttoss/cloudformation": "^0.10.11",
|
|
50
|
+
"@ttoss/read-config-file": "^2.0.4"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/adm-zip": "^0.5.5",
|