sst 2.23.2 → 2.23.4
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/cli/commands/update.js +61 -41
- package/constructs/Function.js +3 -1
- package/constructs/Job.js +3 -1
- package/constructs/Service.d.ts +39 -44
- package/constructs/Service.js +16 -9
- package/package.json +1 -1
- package/sst.mjs +67 -47
package/cli/commands/update.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { VisibleError } from "../../error.js";
|
|
2
2
|
const FIELDS = ["dependencies", "devDependencies"];
|
|
3
|
+
const SST_PKGS = ["sst", "astro-sst", "svelte-kit-sst", "solid-start-sst"];
|
|
3
4
|
export const update = (program) => program.command("update [version]", "Update your SST and CDK packages", (yargs) => yargs.positional("version", {
|
|
4
5
|
type: "string",
|
|
5
6
|
describe: "Optionally specify a version to update to",
|
|
@@ -9,7 +10,42 @@ export const update = (program) => program.command("update [version]", "Update y
|
|
|
9
10
|
const { fetch } = await import("undici");
|
|
10
11
|
const { useProject } = await import("../../project.js");
|
|
11
12
|
const { Colors } = await import("../colors.js");
|
|
12
|
-
|
|
13
|
+
const project = useProject();
|
|
14
|
+
const files = await findAllPackageJson(project.paths.root);
|
|
15
|
+
const metadata = await fetch(`https://registry.npmjs.org/sst/${args.version || "latest"}`).then((resp) => resp.json());
|
|
16
|
+
const allChanges = new Map();
|
|
17
|
+
const allOldPackages = new Map();
|
|
18
|
+
// Update all package.json files
|
|
19
|
+
await Promise.all(files.map(updatePackageJson));
|
|
20
|
+
// Print status
|
|
21
|
+
if (allOldPackages.size > 0) {
|
|
22
|
+
for (const [file, pkgs] of allOldPackages.entries()) {
|
|
23
|
+
Colors.line(Colors.danger(`✖ `), Colors.bold.dim(path.relative(project.paths.root, file)));
|
|
24
|
+
for (const [pkg, version] of pkgs) {
|
|
25
|
+
Colors.line(Colors.dim(` ${pkg}@${version}`));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
Colors.gap();
|
|
29
|
+
throw new VisibleError("We've detected AWS CDK v1 dependencies in your package.json. SST requires CDK v2. Please update to CDK v2 dependencies, and then execute `sst update`. For guidance, refer to the official AWS CDK migration documentation — https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html#migrating-v2-v1-upgrade");
|
|
30
|
+
}
|
|
31
|
+
// Print status
|
|
32
|
+
if (allChanges.size === 0) {
|
|
33
|
+
Colors.line(Colors.success(`✔ `), `Already using v${metadata.version}`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
for (const [file, pkgs] of allChanges.entries()) {
|
|
37
|
+
Colors.line(Colors.success(`✔ `), Colors.bold.dim(path.relative(project.paths.root, file)));
|
|
38
|
+
for (const [pkg, version] of pkgs) {
|
|
39
|
+
Colors.line(Colors.dim(` ${pkg}@${version}`));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
Colors.gap();
|
|
43
|
+
Colors.line(`${Colors.primary(`➜`)} ${Colors.warning("Make sure to run: npm install (or pnpm install, or yarn)")}`);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
/////////////
|
|
46
|
+
// Helpers
|
|
47
|
+
/////////////
|
|
48
|
+
async function findAllPackageJson(dir) {
|
|
13
49
|
const children = await fs.readdir(dir);
|
|
14
50
|
const tasks = children.map(async (item) => {
|
|
15
51
|
if (item === "node_modules")
|
|
@@ -22,69 +58,53 @@ export const update = (program) => program.command("update [version]", "Update y
|
|
|
22
58
|
return [full];
|
|
23
59
|
const stat = await fs.stat(full);
|
|
24
60
|
if (stat.isDirectory())
|
|
25
|
-
return
|
|
61
|
+
return findAllPackageJson(full);
|
|
26
62
|
return [];
|
|
27
63
|
});
|
|
28
64
|
return (await Promise.all(tasks)).flat();
|
|
29
65
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const results = new Map();
|
|
34
|
-
const tasks = files.map(async (file) => {
|
|
66
|
+
async function updatePackageJson(file) {
|
|
67
|
+
const changes = new Set();
|
|
68
|
+
const oldPackages = new Set();
|
|
35
69
|
const data = await fs.readFile(file).then((x) => x.toString());
|
|
36
|
-
// Note: preserve ending new line characters in package.json
|
|
37
|
-
const tailingNewline = data.match(/\r?\n$/)?.[0];
|
|
38
70
|
const json = JSON.parse(data);
|
|
71
|
+
// Update versions
|
|
39
72
|
for (const field of FIELDS) {
|
|
40
73
|
const deps = json[field];
|
|
41
74
|
for (const [pkg, existing] of Object.entries(deps || {})) {
|
|
42
75
|
const desired = (() => {
|
|
43
|
-
if (
|
|
44
|
-
"sst",
|
|
45
|
-
"astro-sst",
|
|
46
|
-
"svelte-kit-sst",
|
|
47
|
-
"solid-start-sst",
|
|
48
|
-
].includes(pkg)) {
|
|
76
|
+
if (SST_PKGS.includes(pkg)) {
|
|
49
77
|
return metadata.version;
|
|
50
78
|
}
|
|
51
79
|
else if (pkg === "constructs") {
|
|
52
80
|
return metadata.dependencies.constructs;
|
|
53
81
|
}
|
|
54
|
-
else if (pkg
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
else if (pkg === "aws-cdk-lib") {
|
|
83
|
+
return metadata.dependencies["aws-cdk-lib"];
|
|
84
|
+
}
|
|
85
|
+
else if (pkg.startsWith("@aws-cdk/aws-")) {
|
|
86
|
+
if (!pkg.endsWith("-alpha")) {
|
|
87
|
+
oldPackages.add([pkg, existing]);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
return metadata.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
|
|
59
91
|
}
|
|
60
92
|
})();
|
|
61
93
|
if (!desired || existing === desired)
|
|
62
94
|
continue;
|
|
63
|
-
|
|
64
|
-
if (!arr) {
|
|
65
|
-
arr = new Set();
|
|
66
|
-
results.set(file, arr);
|
|
67
|
-
}
|
|
68
|
-
arr.add([pkg, desired]);
|
|
95
|
+
changes.add([pkg, desired]);
|
|
69
96
|
deps[pkg] = desired;
|
|
70
97
|
}
|
|
71
98
|
}
|
|
72
|
-
|
|
99
|
+
// Write to package.json
|
|
100
|
+
if (changes.size > 0) {
|
|
101
|
+
// note: preserve ending new line characters in package.json
|
|
102
|
+
const tailingNewline = data.match(/\r?\n$/)?.[0];
|
|
73
103
|
await fs.writeFile(file, `${JSON.stringify(json, null, 2)}${tailingNewline ?? ""}`);
|
|
104
|
+
allChanges.set(file, changes);
|
|
74
105
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (results.size === 0) {
|
|
78
|
-
Colors.line(Colors.success(`✔ `), `Already using v${metadata.version}`);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
for (const [file, pkgs] of results.entries()) {
|
|
82
|
-
Colors.line(Colors.success(`✔ `), Colors.bold.dim(path.relative(project.paths.root, file)));
|
|
83
|
-
for (const [pkg, version] of pkgs) {
|
|
84
|
-
Colors.line(Colors.dim(` ${pkg}@${version}`));
|
|
106
|
+
if (oldPackages.size > 0) {
|
|
107
|
+
allOldPackages.set(file, oldPackages);
|
|
85
108
|
}
|
|
86
109
|
}
|
|
87
|
-
Colors.gap();
|
|
88
|
-
Colors.line(`${Colors.primary(`➜`)} ${Colors.warning("Make sure to run: npm install (or pnpm install, or yarn)")}`);
|
|
89
|
-
process.exit(0);
|
|
90
110
|
});
|
package/constructs/Function.js
CHANGED
|
@@ -18,7 +18,7 @@ import { createAppContext } from "./context.js";
|
|
|
18
18
|
import { useWarning } from "./util/warning.js";
|
|
19
19
|
import { Architecture, AssetCode, Code, Function as CDKFunction, FunctionUrlAuthType, Handler as CDKHandler, LayerVersion, Runtime as CDKRuntime, Tracing, } from "aws-cdk-lib/aws-lambda";
|
|
20
20
|
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
21
|
-
import { Token, Size as CDKSize, Duration as CDKDuration, } from "aws-cdk-lib/core";
|
|
21
|
+
import { Token, Size as CDKSize, Duration as CDKDuration, IgnoreMode, } from "aws-cdk-lib/core";
|
|
22
22
|
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
23
23
|
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
24
24
|
import { Platform } from "aws-cdk-lib/aws-ecr-assets";
|
|
@@ -202,6 +202,8 @@ export class Function extends CDKFunction {
|
|
|
202
202
|
...(props.container?.file
|
|
203
203
|
? { file: props.container.file }
|
|
204
204
|
: {}),
|
|
205
|
+
exclude: [".sst"],
|
|
206
|
+
ignoreMode: IgnoreMode.GLOB,
|
|
205
207
|
}),
|
|
206
208
|
handler: CDKHandler.FROM_IMAGE,
|
|
207
209
|
runtime: CDKRuntime.FROM_IMAGE,
|
package/constructs/Job.js
CHANGED
|
@@ -2,7 +2,7 @@ import url from "url";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs/promises";
|
|
4
4
|
import { Construct } from "constructs";
|
|
5
|
-
import { Duration as CdkDuration } from "aws-cdk-lib/core";
|
|
5
|
+
import { Duration as CdkDuration, IgnoreMode } from "aws-cdk-lib/core";
|
|
6
6
|
import { Platform } from "aws-cdk-lib/aws-ecr-assets";
|
|
7
7
|
import { PolicyStatement, Effect } from "aws-cdk-lib/aws-iam";
|
|
8
8
|
import { AssetCode, Code, Runtime, Function as CdkFunction, } from "aws-cdk-lib/aws-lambda";
|
|
@@ -213,6 +213,8 @@ export class Job extends Construct {
|
|
|
213
213
|
? Platform.custom("linux/arm64")
|
|
214
214
|
: Platform.custom("linux/amd64"),
|
|
215
215
|
file: container?.file,
|
|
216
|
+
exclude: [".sst"],
|
|
217
|
+
ignoreMode: IgnoreMode.GLOB,
|
|
216
218
|
});
|
|
217
219
|
image.repository?.grantPull(this.job.role);
|
|
218
220
|
const project = this.job.node.defaultChild;
|
package/constructs/Service.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import { DistributionDomainProps } from "./Distribution.js";
|
|
|
3
3
|
import { SSTConstruct } from "./Construct.js";
|
|
4
4
|
import { Permissions } from "./util/permission.js";
|
|
5
5
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
6
|
-
import {
|
|
7
|
-
import { Cluster } from "aws-cdk-lib/aws-ecs";
|
|
6
|
+
import { IVpc } from "aws-cdk-lib/aws-ec2";
|
|
7
|
+
import { Cluster, ContainerDefinitionOptions } from "aws-cdk-lib/aws-ecs";
|
|
8
|
+
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
8
9
|
declare const supportedCpus: {
|
|
9
10
|
"0.25 vCPU": number;
|
|
10
11
|
"0.5 vCPU": number;
|
|
@@ -191,6 +192,28 @@ export interface ServiceProps {
|
|
|
191
192
|
* ```
|
|
192
193
|
*/
|
|
193
194
|
environment?: Record<string, string>;
|
|
195
|
+
/**
|
|
196
|
+
* The duration logs are kept in CloudWatch Logs.
|
|
197
|
+
* @default Logs retained indefinitely
|
|
198
|
+
* @example
|
|
199
|
+
* ```js
|
|
200
|
+
* {
|
|
201
|
+
* logRetention: "one_week"
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
logRetention?: Lowercase<keyof typeof RetentionDays>;
|
|
206
|
+
/**
|
|
207
|
+
* 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.
|
|
208
|
+
* @default false
|
|
209
|
+
* @example
|
|
210
|
+
* ```js
|
|
211
|
+
* {
|
|
212
|
+
* waitForInvalidation: true
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
waitForInvalidation?: boolean;
|
|
194
217
|
dev?: {
|
|
195
218
|
/**
|
|
196
219
|
* When running `sst dev, site is not deployed. This is to ensure `sst dev` can start up quickly.
|
|
@@ -218,69 +241,40 @@ export interface ServiceProps {
|
|
|
218
241
|
*/
|
|
219
242
|
url?: string;
|
|
220
243
|
};
|
|
221
|
-
/**
|
|
222
|
-
* 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.
|
|
223
|
-
* @default false
|
|
224
|
-
* @example
|
|
225
|
-
* ```js
|
|
226
|
-
* {
|
|
227
|
-
* waitForInvalidation: true
|
|
228
|
-
* }
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
waitForInvalidation?: boolean;
|
|
232
244
|
cdk?: {
|
|
233
245
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
246
|
+
* Customizing the container definition for the ECS task.
|
|
236
247
|
* @example
|
|
237
248
|
* ```js
|
|
238
|
-
* import { Vpc } from "aws-cdk-lib/aws-ec2";
|
|
239
|
-
*
|
|
240
249
|
* {
|
|
241
250
|
* cdk: {
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
251
|
+
* container: {
|
|
252
|
+
* healthCheck: {
|
|
253
|
+
* command: ["CMD-SHELL", "curl -f http://localhost/ || exit 1"],
|
|
254
|
+
* },
|
|
255
|
+
* }
|
|
245
256
|
* }
|
|
246
257
|
* }
|
|
247
258
|
* ```
|
|
248
259
|
*/
|
|
249
|
-
|
|
260
|
+
container?: Omit<ContainerDefinitionOptions, "image">;
|
|
250
261
|
/**
|
|
251
|
-
*
|
|
252
|
-
* @default All private subnets.
|
|
253
|
-
* @example
|
|
254
|
-
* ```js
|
|
255
|
-
* import { SubnetType } from "aws-cdk-lib/aws-ec2";
|
|
262
|
+
* Runs codebuild job in the specified VPC. Note this will only work once deployed.
|
|
256
263
|
*
|
|
257
|
-
* {
|
|
258
|
-
* cdk: {
|
|
259
|
-
* vpc,
|
|
260
|
-
* vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS }
|
|
261
|
-
* }
|
|
262
|
-
* }
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
vpcSubnets?: SubnetSelection;
|
|
266
|
-
/**
|
|
267
|
-
* The list of security groups to associate with the Job's network interfaces.
|
|
268
|
-
* @default A new security group is created.
|
|
269
264
|
* @example
|
|
270
265
|
* ```js
|
|
271
|
-
* import {
|
|
266
|
+
* import { Vpc } from "aws-cdk-lib/aws-ec2";
|
|
272
267
|
*
|
|
273
268
|
* {
|
|
274
269
|
* cdk: {
|
|
275
|
-
* vpc,
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* ]
|
|
270
|
+
* vpc: Vpc.fromLookup(stack, "VPC", {
|
|
271
|
+
* vpcId: "vpc-xxxxxxxxxx",
|
|
272
|
+
* }),
|
|
279
273
|
* }
|
|
280
274
|
* }
|
|
281
275
|
* ```
|
|
282
276
|
*/
|
|
283
|
-
|
|
277
|
+
vpc?: IVpc;
|
|
284
278
|
};
|
|
285
279
|
}
|
|
286
280
|
type ServiceNormalizedProps = ServiceProps & {
|
|
@@ -288,6 +282,7 @@ type ServiceNormalizedProps = ServiceProps & {
|
|
|
288
282
|
cpu: Exclude<ServiceProps["cpu"], undefined>;
|
|
289
283
|
memory: Exclude<ServiceProps["memory"], undefined>;
|
|
290
284
|
port: Exclude<ServiceProps["port"], undefined>;
|
|
285
|
+
logRetention: Exclude<ServiceProps["logRetention"], undefined>;
|
|
291
286
|
waitForInvalidation: Exclude<ServiceProps["waitForInvalidation"], undefined>;
|
|
292
287
|
};
|
|
293
288
|
/**
|
package/constructs/Service.js
CHANGED
|
@@ -6,7 +6,7 @@ import { execAsync } from "../util/process.js";
|
|
|
6
6
|
import { existsAsync } from "../util/fs.js";
|
|
7
7
|
import { Colors } from "../cli/colors.js";
|
|
8
8
|
import { Construct } from "constructs";
|
|
9
|
-
import { Duration as CdkDuration } from "aws-cdk-lib/core";
|
|
9
|
+
import { Duration as CdkDuration, IgnoreMode } from "aws-cdk-lib/core";
|
|
10
10
|
import { Role, Effect, PolicyStatement, AccountPrincipal, ServicePrincipal, CompositePrincipal, } from "aws-cdk-lib/aws-iam";
|
|
11
11
|
import { ViewerProtocolPolicy, AllowedMethods, CachedMethods, CachePolicy, CacheQueryStringBehavior, CacheHeaderBehavior, CacheCookieBehavior, OriginProtocolPolicy, OriginRequestPolicy, } from "aws-cdk-lib/aws-cloudfront";
|
|
12
12
|
import { HttpOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
@@ -20,7 +20,7 @@ import { bindEnvironment, bindPermissions, getParameterPath, getReferencedSecret
|
|
|
20
20
|
import { useProject } from "../project.js";
|
|
21
21
|
import { Vpc, } from "aws-cdk-lib/aws-ec2";
|
|
22
22
|
import { AwsLogDriver, Cluster, FargateTaskDefinition, ContainerImage, FargateService, } from "aws-cdk-lib/aws-ecs";
|
|
23
|
-
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
23
|
+
import { LogGroup, LogRetention, RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
24
24
|
import { Platform } from "aws-cdk-lib/aws-ecr-assets";
|
|
25
25
|
import { ApplicationLoadBalancer, } from "aws-cdk-lib/aws-elasticloadbalancingv2";
|
|
26
26
|
import { createAppContext } from "./context.js";
|
|
@@ -153,10 +153,11 @@ export class Service extends Construct {
|
|
|
153
153
|
this.id = id;
|
|
154
154
|
this.props = {
|
|
155
155
|
path: ".",
|
|
156
|
-
waitForInvalidation: false,
|
|
157
156
|
cpu: props?.cpu || "0.25 vCPU",
|
|
158
157
|
memory: props?.memory || "0.5 GB",
|
|
159
158
|
port: props?.port || 3000,
|
|
159
|
+
logRetention: props?.logRetention || "infinite",
|
|
160
|
+
waitForInvalidation: false,
|
|
160
161
|
...props,
|
|
161
162
|
};
|
|
162
163
|
this.doNotDeploy =
|
|
@@ -359,16 +360,19 @@ export class Service extends Construct {
|
|
|
359
360
|
const { cdk } = this.props;
|
|
360
361
|
return (cdk?.vpc ??
|
|
361
362
|
new Vpc(this, "Vpc", {
|
|
362
|
-
natGateways:
|
|
363
|
+
natGateways: 1,
|
|
363
364
|
}));
|
|
364
365
|
}
|
|
365
366
|
createService(vpc) {
|
|
366
|
-
const { cpu, memory, port } = this.props;
|
|
367
|
+
const { cpu, memory, port, logRetention, cdk } = this.props;
|
|
367
368
|
const app = this.node.root;
|
|
368
369
|
const clusterName = app.logicalPrefixedName(this.node.id);
|
|
369
|
-
const logGroup = new
|
|
370
|
+
const logGroup = new LogRetention(this, "LogRetention", {
|
|
370
371
|
logGroupName: `/sst/service/${clusterName}`,
|
|
371
|
-
retention: RetentionDays.
|
|
372
|
+
retention: RetentionDays[logRetention.toUpperCase()],
|
|
373
|
+
logRetentionRetryOptions: {
|
|
374
|
+
maxRetries: 100,
|
|
375
|
+
},
|
|
372
376
|
});
|
|
373
377
|
const cluster = new Cluster(this, "Cluster", {
|
|
374
378
|
clusterName,
|
|
@@ -380,9 +384,8 @@ export class Service extends Construct {
|
|
|
380
384
|
cpu: supportedCpus[cpu],
|
|
381
385
|
});
|
|
382
386
|
const container = taskDefinition.addContainer("Container", {
|
|
383
|
-
image: { bind: () => ({ imageName: "placeholder" }) },
|
|
384
387
|
logging: new AwsLogDriver({
|
|
385
|
-
logGroup,
|
|
388
|
+
logGroup: LogGroup.fromLogGroupArn(this, "LogGroup", logGroup.logGroupArn),
|
|
386
389
|
streamPrefix: "service",
|
|
387
390
|
}),
|
|
388
391
|
portMappings: [{ containerPort: port }],
|
|
@@ -391,6 +394,8 @@ export class Service extends Construct {
|
|
|
391
394
|
SST_STAGE: app.stage,
|
|
392
395
|
SST_SSM_PREFIX: useProject().config.ssmPrefix,
|
|
393
396
|
},
|
|
397
|
+
...cdk?.container,
|
|
398
|
+
image: { bind: () => ({ imageName: "placeholder" }) },
|
|
394
399
|
});
|
|
395
400
|
const service = new FargateService(this, "Service", {
|
|
396
401
|
cluster,
|
|
@@ -578,6 +583,8 @@ export class Service extends Construct {
|
|
|
578
583
|
const image = ContainerImage.fromAsset(this.props.path, {
|
|
579
584
|
platform: Platform.LINUX_AMD64,
|
|
580
585
|
file: dockerfile,
|
|
586
|
+
exclude: [".sst"],
|
|
587
|
+
ignoreMode: IgnoreMode.GLOB,
|
|
581
588
|
});
|
|
582
589
|
const cfnTask = taskDefinition.node.defaultChild;
|
|
583
590
|
cfnTask.addPropertyOverride("ContainerDefinitions.0.Image", image.bind(this, container).imageName);
|
package/package.json
CHANGED
package/sst.mjs
CHANGED
|
@@ -8852,7 +8852,9 @@ function secrets(program2) {
|
|
|
8852
8852
|
}
|
|
8853
8853
|
|
|
8854
8854
|
// src/cli/commands/update.ts
|
|
8855
|
+
init_error();
|
|
8855
8856
|
var FIELDS = ["dependencies", "devDependencies"];
|
|
8857
|
+
var SST_PKGS = ["sst", "astro-sst", "svelte-kit-sst", "solid-start-sst"];
|
|
8856
8858
|
var update = (program2) => program2.command(
|
|
8857
8859
|
"update [version]",
|
|
8858
8860
|
"Update your SST and CDK packages",
|
|
@@ -8866,9 +8868,52 @@ var update = (program2) => program2.command(
|
|
|
8866
8868
|
const { fetch } = await import("undici");
|
|
8867
8869
|
const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
|
|
8868
8870
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
8869
|
-
|
|
8871
|
+
const project = useProject2();
|
|
8872
|
+
const files = await findAllPackageJson(project.paths.root);
|
|
8873
|
+
const metadata3 = await fetch(
|
|
8874
|
+
`https://registry.npmjs.org/sst/${args.version || "latest"}`
|
|
8875
|
+
).then((resp) => resp.json());
|
|
8876
|
+
const allChanges = /* @__PURE__ */ new Map();
|
|
8877
|
+
const allOldPackages = /* @__PURE__ */ new Map();
|
|
8878
|
+
await Promise.all(files.map(updatePackageJson));
|
|
8879
|
+
if (allOldPackages.size > 0) {
|
|
8880
|
+
for (const [file, pkgs] of allOldPackages.entries()) {
|
|
8881
|
+
Colors2.line(
|
|
8882
|
+
Colors2.danger(`\u2716 `),
|
|
8883
|
+
Colors2.bold.dim(path22.relative(project.paths.root, file))
|
|
8884
|
+
);
|
|
8885
|
+
for (const [pkg, version2] of pkgs) {
|
|
8886
|
+
Colors2.line(Colors2.dim(` ${pkg}@${version2}`));
|
|
8887
|
+
}
|
|
8888
|
+
}
|
|
8889
|
+
Colors2.gap();
|
|
8890
|
+
throw new VisibleError(
|
|
8891
|
+
"We've detected AWS CDK v1 dependencies in your package.json. SST requires CDK v2. Please update to CDK v2 dependencies, and then execute `sst update`. For guidance, refer to the official AWS CDK migration documentation \u2014 https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html#migrating-v2-v1-upgrade"
|
|
8892
|
+
);
|
|
8893
|
+
}
|
|
8894
|
+
if (allChanges.size === 0) {
|
|
8895
|
+
Colors2.line(Colors2.success(`\u2714 `), `Already using v${metadata3.version}`);
|
|
8896
|
+
return;
|
|
8897
|
+
}
|
|
8898
|
+
for (const [file, pkgs] of allChanges.entries()) {
|
|
8899
|
+
Colors2.line(
|
|
8900
|
+
Colors2.success(`\u2714 `),
|
|
8901
|
+
Colors2.bold.dim(path22.relative(project.paths.root, file))
|
|
8902
|
+
);
|
|
8903
|
+
for (const [pkg, version2] of pkgs) {
|
|
8904
|
+
Colors2.line(Colors2.dim(` ${pkg}@${version2}`));
|
|
8905
|
+
}
|
|
8906
|
+
}
|
|
8907
|
+
Colors2.gap();
|
|
8908
|
+
Colors2.line(
|
|
8909
|
+
`${Colors2.primary(`\u279C`)} ${Colors2.warning(
|
|
8910
|
+
"Make sure to run: npm install (or pnpm install, or yarn)"
|
|
8911
|
+
)}`
|
|
8912
|
+
);
|
|
8913
|
+
process.exit(0);
|
|
8914
|
+
async function findAllPackageJson(dir) {
|
|
8870
8915
|
const children = await fs19.readdir(dir);
|
|
8871
|
-
const
|
|
8916
|
+
const tasks = children.map(async (item) => {
|
|
8872
8917
|
if (item === "node_modules")
|
|
8873
8918
|
return [];
|
|
8874
8919
|
if (/(^|\/)\.[^\/\.]/g.test(item))
|
|
@@ -8878,77 +8923,52 @@ var update = (program2) => program2.command(
|
|
|
8878
8923
|
return [full];
|
|
8879
8924
|
const stat = await fs19.stat(full);
|
|
8880
8925
|
if (stat.isDirectory())
|
|
8881
|
-
return
|
|
8926
|
+
return findAllPackageJson(full);
|
|
8882
8927
|
return [];
|
|
8883
8928
|
});
|
|
8884
|
-
return (await Promise.all(
|
|
8929
|
+
return (await Promise.all(tasks)).flat();
|
|
8885
8930
|
}
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
`https://registry.npmjs.org/sst/${args.version || "latest"}`
|
|
8890
|
-
).then((resp) => resp.json());
|
|
8891
|
-
const results = /* @__PURE__ */ new Map();
|
|
8892
|
-
const tasks = files.map(async (file) => {
|
|
8931
|
+
async function updatePackageJson(file) {
|
|
8932
|
+
const changes = /* @__PURE__ */ new Set();
|
|
8933
|
+
const oldPackages = /* @__PURE__ */ new Set();
|
|
8893
8934
|
const data2 = await fs19.readFile(file).then((x) => x.toString());
|
|
8894
|
-
const tailingNewline = data2.match(/\r?\n$/)?.[0];
|
|
8895
8935
|
const json = JSON.parse(data2);
|
|
8896
8936
|
for (const field of FIELDS) {
|
|
8897
8937
|
const deps = json[field];
|
|
8898
8938
|
for (const [pkg, existing] of Object.entries(deps || {})) {
|
|
8899
8939
|
const desired = (() => {
|
|
8900
|
-
if (
|
|
8901
|
-
"sst",
|
|
8902
|
-
"astro-sst",
|
|
8903
|
-
"svelte-kit-sst",
|
|
8904
|
-
"solid-start-sst"
|
|
8905
|
-
].includes(pkg)) {
|
|
8940
|
+
if (SST_PKGS.includes(pkg)) {
|
|
8906
8941
|
return metadata3.version;
|
|
8907
8942
|
} else if (pkg === "constructs") {
|
|
8908
8943
|
return metadata3.dependencies.constructs;
|
|
8909
|
-
} else if (pkg
|
|
8910
|
-
return
|
|
8944
|
+
} else if (pkg === "aws-cdk-lib") {
|
|
8945
|
+
return metadata3.dependencies["aws-cdk-lib"];
|
|
8946
|
+
} else if (pkg.startsWith("@aws-cdk/aws-")) {
|
|
8947
|
+
if (!pkg.endsWith("-alpha")) {
|
|
8948
|
+
oldPackages.add([pkg, existing]);
|
|
8949
|
+
return;
|
|
8950
|
+
}
|
|
8951
|
+
return metadata3.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
|
|
8911
8952
|
}
|
|
8912
8953
|
})();
|
|
8913
8954
|
if (!desired || existing === desired)
|
|
8914
8955
|
continue;
|
|
8915
|
-
|
|
8916
|
-
if (!arr) {
|
|
8917
|
-
arr = /* @__PURE__ */ new Set();
|
|
8918
|
-
results.set(file, arr);
|
|
8919
|
-
}
|
|
8920
|
-
arr.add([pkg, desired]);
|
|
8956
|
+
changes.add([pkg, desired]);
|
|
8921
8957
|
deps[pkg] = desired;
|
|
8922
8958
|
}
|
|
8923
8959
|
}
|
|
8924
|
-
if (
|
|
8960
|
+
if (changes.size > 0) {
|
|
8961
|
+
const tailingNewline = data2.match(/\r?\n$/)?.[0];
|
|
8925
8962
|
await fs19.writeFile(
|
|
8926
8963
|
file,
|
|
8927
8964
|
`${JSON.stringify(json, null, 2)}${tailingNewline ?? ""}`
|
|
8928
8965
|
);
|
|
8966
|
+
allChanges.set(file, changes);
|
|
8929
8967
|
}
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
if (results.size === 0) {
|
|
8933
|
-
Colors2.line(Colors2.success(`\u2714 `), `Already using v${metadata3.version}`);
|
|
8934
|
-
return;
|
|
8935
|
-
}
|
|
8936
|
-
for (const [file, pkgs] of results.entries()) {
|
|
8937
|
-
Colors2.line(
|
|
8938
|
-
Colors2.success(`\u2714 `),
|
|
8939
|
-
Colors2.bold.dim(path22.relative(project.paths.root, file))
|
|
8940
|
-
);
|
|
8941
|
-
for (const [pkg, version2] of pkgs) {
|
|
8942
|
-
Colors2.line(Colors2.dim(` ${pkg}@${version2}`));
|
|
8968
|
+
if (oldPackages.size > 0) {
|
|
8969
|
+
allOldPackages.set(file, oldPackages);
|
|
8943
8970
|
}
|
|
8944
8971
|
}
|
|
8945
|
-
Colors2.gap();
|
|
8946
|
-
Colors2.line(
|
|
8947
|
-
`${Colors2.primary(`\u279C`)} ${Colors2.warning(
|
|
8948
|
-
"Make sure to run: npm install (or pnpm install, or yarn)"
|
|
8949
|
-
)}`
|
|
8950
|
-
);
|
|
8951
|
-
process.exit(0);
|
|
8952
8972
|
}
|
|
8953
8973
|
);
|
|
8954
8974
|
|