sst 2.8.12 → 2.8.14
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 +3 -1
- package/constructs/Script.d.ts +14 -0
- package/constructs/Script.js +6 -4
- package/constructs/SsrSite.d.ts +10 -0
- package/constructs/SsrSite.js +2 -2
- package/constructs/StaticSite.d.ts +12 -0
- package/constructs/StaticSite.js +2 -2
- package/package.json +1 -1
- package/project.d.ts +3 -0
package/constructs/App.js
CHANGED
|
@@ -186,6 +186,7 @@ export class App extends CDKApp {
|
|
|
186
186
|
this.codegenTypes();
|
|
187
187
|
this.createBindingSsmParameters();
|
|
188
188
|
this.removeGovCloudUnsupportedResourceProperties();
|
|
189
|
+
const { config } = useProject();
|
|
189
190
|
for (const child of this.node.children) {
|
|
190
191
|
if (isStackConstruct(child)) {
|
|
191
192
|
// Tag stacks
|
|
@@ -195,7 +196,8 @@ export class App extends CDKApp {
|
|
|
195
196
|
if (this._defaultRemovalPolicy)
|
|
196
197
|
this.applyRemovalPolicy(child, this._defaultRemovalPolicy);
|
|
197
198
|
// Stack names need to be parameterized with the stage name
|
|
198
|
-
if (
|
|
199
|
+
if (config.advanced?.disableParameterizedStackNameCheck !== true &&
|
|
200
|
+
!child.stackName.startsWith(`${this.stage}-`) &&
|
|
199
201
|
!child.stackName.endsWith(`-${this.stage}`) &&
|
|
200
202
|
child.stackName.indexOf(`-${this.stage}-`) === -1) {
|
|
201
203
|
throw new Error(`Stack "${child.stackName}" is not parameterized with the stage name. The stack name needs to either start with "$stage-", end in "-$stage", or contain the stage name "-$stage-".`);
|
package/constructs/Script.d.ts
CHANGED
|
@@ -19,6 +19,20 @@ export interface ScriptProps {
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
params?: Record<string, any>;
|
|
22
|
+
/**
|
|
23
|
+
* By default, the script runs during each deployment. If a version is provided, the script will only run when the version changes.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* import { Script } from "sst/constructs";
|
|
28
|
+
*
|
|
29
|
+
* new Script(stack, "Script", {
|
|
30
|
+
* onCreate: "src/script.create",
|
|
31
|
+
* version: "v17",
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
version?: string;
|
|
22
36
|
defaults?: {
|
|
23
37
|
/**
|
|
24
38
|
* The default function props to be applied to all the Lambda functions in the API. The `environment`, `permissions` and `layers` properties will be merged with per route definitions if they are defined.
|
package/constructs/Script.js
CHANGED
|
@@ -125,15 +125,17 @@ export class Script extends Construct {
|
|
|
125
125
|
return handler;
|
|
126
126
|
}
|
|
127
127
|
createCustomResource(app, crFunction) {
|
|
128
|
-
// Note: "
|
|
128
|
+
// Note: "Version" is set to current timestamp to ensure the Custom
|
|
129
129
|
// Resource function is run on every update.
|
|
130
130
|
//
|
|
131
131
|
// Do not use the current timestamp in Live mode, b/c we want the
|
|
132
132
|
// this custom resource to remain the same in CloudFormation template
|
|
133
133
|
// when rebuilding infrastructure. Otherwise, there will always be
|
|
134
|
-
// a change when rebuilding infrastructure b/c the "
|
|
134
|
+
// a change when rebuilding infrastructure b/c the "version" property
|
|
135
135
|
// changes on each build.
|
|
136
|
-
const
|
|
136
|
+
const version = app.mode === "dev"
|
|
137
|
+
? app.debugStartedAt
|
|
138
|
+
: this.props.version ?? Date.now().toString();
|
|
137
139
|
new cdk.CustomResource(this, "ScriptResource", {
|
|
138
140
|
serviceToken: crFunction.functionArn,
|
|
139
141
|
resourceType: "Custom::SSTScript",
|
|
@@ -142,7 +144,7 @@ export class Script extends Construct {
|
|
|
142
144
|
UserUpdateFunction: this.updateFunction?.functionName,
|
|
143
145
|
UserDeleteFunction: this.deleteFunction?.functionName,
|
|
144
146
|
UserParams: JSON.stringify(this.props.params || {}),
|
|
145
|
-
|
|
147
|
+
Version: version,
|
|
146
148
|
},
|
|
147
149
|
});
|
|
148
150
|
}
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -145,6 +145,16 @@ export interface SsrSiteProps {
|
|
|
145
145
|
* ```
|
|
146
146
|
*/
|
|
147
147
|
deploy?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* The local site URL when running `sst dev`.
|
|
150
|
+
* @example
|
|
151
|
+
* ```js
|
|
152
|
+
* dev: {
|
|
153
|
+
* url: "http://localhost:3000"
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
url?: string;
|
|
148
158
|
};
|
|
149
159
|
/**
|
|
150
160
|
* While deploying, SST waits for the CloudFront cache invalidation process to finish. This ensures that the new content will be served once the deploy command finishes. However, this process can sometimes take more than 5 mins. For non-prod environments it might make sense to pass in `false`. That'll skip waiting for the cache to invalidate and speed up the deploy process.
|
package/constructs/SsrSite.js
CHANGED
|
@@ -120,7 +120,7 @@ export class SsrSite extends Construct {
|
|
|
120
120
|
*/
|
|
121
121
|
get url() {
|
|
122
122
|
if (this.doNotDeploy)
|
|
123
|
-
return;
|
|
123
|
+
return this.props.dev?.url;
|
|
124
124
|
return `https://${this.distribution.distributionDomainName}`;
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
@@ -204,7 +204,7 @@ export class SsrSite extends Construct {
|
|
|
204
204
|
url: this.doNotDeploy
|
|
205
205
|
? {
|
|
206
206
|
type: "plain",
|
|
207
|
-
value: "localhost",
|
|
207
|
+
value: this.props.dev?.url ?? "localhost",
|
|
208
208
|
}
|
|
209
209
|
: {
|
|
210
210
|
// Do not set real value b/c we don't want to make the Lambda function
|
|
@@ -193,6 +193,18 @@ export interface StaticSiteProps {
|
|
|
193
193
|
* ```
|
|
194
194
|
*/
|
|
195
195
|
deploy?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* The local site URL when running `sst dev`.
|
|
198
|
+
* @example
|
|
199
|
+
* ```js
|
|
200
|
+
* new StaticSite(stack, "frontend", {
|
|
201
|
+
* dev: {
|
|
202
|
+
* url: "http://localhost:3000"
|
|
203
|
+
* }
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
url?: string;
|
|
196
208
|
};
|
|
197
209
|
vite?: {
|
|
198
210
|
/**
|
package/constructs/StaticSite.js
CHANGED
|
@@ -99,7 +99,7 @@ export class StaticSite extends Construct {
|
|
|
99
99
|
*/
|
|
100
100
|
get url() {
|
|
101
101
|
if (this.doNotDeploy)
|
|
102
|
-
return;
|
|
102
|
+
return this.props.dev?.url;
|
|
103
103
|
return `https://${this.distribution.distributionDomainName}`;
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
@@ -150,7 +150,7 @@ export class StaticSite extends Construct {
|
|
|
150
150
|
url: this.doNotDeploy
|
|
151
151
|
? {
|
|
152
152
|
type: "plain",
|
|
153
|
-
value: "localhost",
|
|
153
|
+
value: this.props.dev?.url ?? "localhost",
|
|
154
154
|
}
|
|
155
155
|
: {
|
|
156
156
|
// Do not set real value b/c we don't want to make the Lambda function
|
package/package.json
CHANGED
package/project.d.ts
CHANGED