sst 2.31.0 → 2.32.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/constructs/App.js +7 -7
- package/constructs/Distribution.d.ts +5 -10
- package/constructs/Distribution.js +6 -4
- package/constructs/Function.d.ts +6 -6
- package/constructs/Function.js +3 -3
- package/constructs/NextjsSite.d.ts +13 -1
- package/constructs/NextjsSite.js +196 -35
- package/constructs/Service.d.ts +0 -1
- package/constructs/Service.js +0 -1
- package/constructs/SsrSite.d.ts +40 -16
- package/constructs/SsrSite.js +56 -46
- package/constructs/StaticSite.js +3 -2
- package/package.json +2 -2
- package/support/custom-resources/index.mjs +8510 -8439
package/constructs/SsrSite.js
CHANGED
|
@@ -55,18 +55,22 @@ export class SsrSite extends Construct {
|
|
|
55
55
|
const props = {
|
|
56
56
|
path: ".",
|
|
57
57
|
typesPath: ".",
|
|
58
|
-
waitForInvalidation: false,
|
|
59
58
|
runtime: "nodejs18.x",
|
|
60
59
|
timeout: "10 seconds",
|
|
61
60
|
memorySize: "1024 MB",
|
|
62
61
|
...rawProps,
|
|
62
|
+
invalidation: {
|
|
63
|
+
wait: rawProps?.waitForInvalidation,
|
|
64
|
+
paths: "all",
|
|
65
|
+
...rawProps?.invalidation,
|
|
66
|
+
},
|
|
63
67
|
};
|
|
64
68
|
this.id = id;
|
|
65
69
|
this.props = props;
|
|
66
70
|
const app = scope.node.root;
|
|
67
71
|
const stack = Stack.of(this);
|
|
68
72
|
const self = this;
|
|
69
|
-
const { path: sitePath, typesPath, buildCommand, runtime, timeout, memorySize, edge, regional, dev, assets, nodejs, permissions, environment, bind, customDomain,
|
|
73
|
+
const { path: sitePath, typesPath, buildCommand, runtime, timeout, memorySize, edge, regional, dev, assets, nodejs, permissions, environment, bind, customDomain, invalidation, warm, cdk, } = props;
|
|
70
74
|
this.doNotDeploy = !stack.isActive || (app.mode === "dev" && !dev?.deploy);
|
|
71
75
|
validateSiteExists();
|
|
72
76
|
validateTimeout();
|
|
@@ -259,7 +263,6 @@ export class SsrSite extends Construct {
|
|
|
259
263
|
const distribution = new Distribution(self, "CDN", {
|
|
260
264
|
scopeOverride: self,
|
|
261
265
|
customDomain,
|
|
262
|
-
waitForInvalidation,
|
|
263
266
|
cdk: {
|
|
264
267
|
distribution: {
|
|
265
268
|
// these values can be overwritten
|
|
@@ -689,18 +692,7 @@ function handler(event) {
|
|
|
689
692
|
return replaceValues;
|
|
690
693
|
}
|
|
691
694
|
function createDistributionInvalidation() {
|
|
692
|
-
const
|
|
693
|
-
if (cdnInvalidationStrategy === "never")
|
|
694
|
-
return;
|
|
695
|
-
if (plan.buildId) {
|
|
696
|
-
distribution.createInvalidation(plan.buildId);
|
|
697
|
-
return;
|
|
698
|
-
}
|
|
699
|
-
if (cdnInvalidationStrategy === "always") {
|
|
700
|
-
const buildId = Date.now().toString(16) + Math.random().toString(16).slice(2);
|
|
701
|
-
distribution.createInvalidation(buildId);
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
695
|
+
const paths = invalidation.paths;
|
|
704
696
|
// We will generate a hash based on the contents of the S3 files with cache enabled.
|
|
705
697
|
// This will be used to determine if we need to invalidate our CloudFront cache.
|
|
706
698
|
const s3Origin = Object.values(plan.origins).find((origin) => origin.type === "s3");
|
|
@@ -711,46 +703,64 @@ function handler(event) {
|
|
|
711
703
|
return;
|
|
712
704
|
// Build invalidation paths
|
|
713
705
|
const invalidationPaths = [];
|
|
714
|
-
if (
|
|
706
|
+
if (paths === "none") {
|
|
707
|
+
}
|
|
708
|
+
else if (paths === "all") {
|
|
709
|
+
invalidationPaths.push("/*");
|
|
710
|
+
}
|
|
711
|
+
else if (paths === "versioned") {
|
|
715
712
|
cachedS3Files.forEach((item) => {
|
|
716
713
|
if (!item.versionedSubDir)
|
|
717
714
|
return;
|
|
718
715
|
invalidationPaths.push(path.posix.join("/", item.to, item.versionedSubDir, "*"));
|
|
719
716
|
});
|
|
720
717
|
}
|
|
718
|
+
else {
|
|
719
|
+
invalidationPaths.push(...paths);
|
|
720
|
+
}
|
|
721
721
|
if (invalidationPaths.length === 0)
|
|
722
|
-
|
|
722
|
+
return;
|
|
723
723
|
// Build build ID
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
724
|
+
let invalidationBuildId;
|
|
725
|
+
if (plan.buildId) {
|
|
726
|
+
invalidationBuildId = plan.buildId;
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
const hash = crypto.createHash("md5");
|
|
730
|
+
cachedS3Files.forEach((item) => {
|
|
731
|
+
// The below options are needed to support following symlinks when building zip files:
|
|
732
|
+
// - nodir: This will prevent symlinks themselves from being copied into the zip.
|
|
733
|
+
// - follow: This will follow symlinks and copy the files within.
|
|
734
|
+
// For versioned files, use file path for digest since file version in name should change on content change
|
|
735
|
+
if (item.versionedSubDir) {
|
|
736
|
+
globSync("**", {
|
|
737
|
+
dot: true,
|
|
738
|
+
nodir: true,
|
|
739
|
+
follow: true,
|
|
740
|
+
cwd: path.resolve(sitePath, item.from, item.versionedSubDir),
|
|
741
|
+
}).forEach((filePath) => hash.update(filePath));
|
|
742
|
+
}
|
|
743
|
+
// For non-versioned files, use file content for digest
|
|
744
|
+
if (paths !== "versioned") {
|
|
745
|
+
globSync("**", {
|
|
746
|
+
ignore: item.versionedSubDir
|
|
747
|
+
? [path.posix.join(item.versionedSubDir, "**")]
|
|
748
|
+
: undefined,
|
|
749
|
+
dot: true,
|
|
750
|
+
nodir: true,
|
|
751
|
+
follow: true,
|
|
752
|
+
cwd: path.resolve(sitePath, item.from),
|
|
753
|
+
}).forEach((filePath) => hash.update(fs.readFileSync(path.resolve(sitePath, item.from, filePath))));
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
invalidationBuildId = hash.digest("hex");
|
|
757
|
+
Logger.debug(`Generated build ID ${invalidationBuildId}`);
|
|
758
|
+
}
|
|
759
|
+
distribution.createInvalidation({
|
|
760
|
+
version: invalidationBuildId,
|
|
761
|
+
paths: invalidationPaths,
|
|
762
|
+
wait: invalidation.wait,
|
|
750
763
|
});
|
|
751
|
-
const buildId = hash.digest("hex");
|
|
752
|
-
Logger.debug(`Generated build ID ${buildId}`);
|
|
753
|
-
distribution.createInvalidation(buildId, invalidationPaths);
|
|
754
764
|
}
|
|
755
765
|
}
|
|
756
766
|
static buildDefaultServerCachePolicyProps(allowedHeaders) {
|
package/constructs/StaticSite.js
CHANGED
|
@@ -49,7 +49,6 @@ export class StaticSite extends Construct {
|
|
|
49
49
|
this.id = id;
|
|
50
50
|
this.props = {
|
|
51
51
|
path: ".",
|
|
52
|
-
waitForInvalidation: false,
|
|
53
52
|
...props,
|
|
54
53
|
};
|
|
55
54
|
this.doNotDeploy =
|
|
@@ -74,7 +73,9 @@ export class StaticSite extends Construct {
|
|
|
74
73
|
const s3deployCR = this.createS3Deployment(assets, filenamesAsset);
|
|
75
74
|
this.distribution.node.addDependency(s3deployCR);
|
|
76
75
|
// Invalidate CloudFront
|
|
77
|
-
this.distribution.createInvalidation(
|
|
76
|
+
this.distribution.createInvalidation({
|
|
77
|
+
version: this.generateInvalidationId(assets),
|
|
78
|
+
});
|
|
78
79
|
});
|
|
79
80
|
app.registerTypes(this);
|
|
80
81
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.32.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@types/ws": "^8.5.3",
|
|
121
121
|
"@types/yargs": "^17.0.13",
|
|
122
122
|
"archiver": "^5.3.1",
|
|
123
|
-
"astro-sst": "2.
|
|
123
|
+
"astro-sst": "2.32.0",
|
|
124
124
|
"async": "^3.2.4",
|
|
125
125
|
"tsx": "^3.12.1",
|
|
126
126
|
"typescript": "^5.2.2",
|