sst 2.0.0-rc.8 → 2.0.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/bootstrap.d.ts +2 -4
- package/bootstrap.js +208 -61
- package/bus.d.ts +3 -3
- package/bus.js +1 -1
- package/cache.js +1 -1
- package/cdk/cloudformation-deployments-wrapper.d.ts +3 -0
- package/cdk/cloudformation-deployments-wrapper.js +117 -0
- package/cdk/cloudformation-deployments.d.ts +19 -4
- package/cdk/deploy-stack.d.ts +17 -2
- package/cdk/deploy-stack.js +6 -1
- package/cli/colors.d.ts +28 -0
- package/cli/colors.js +27 -0
- package/cli/commands/bind.d.ts +4 -0
- package/cli/commands/bind.js +10 -7
- package/cli/commands/bootstrap.d.ts +13 -0
- package/cli/commands/bootstrap.js +11 -0
- package/cli/commands/build.d.ts +6 -2
- package/cli/commands/build.js +13 -8
- package/cli/commands/console.d.ts +5 -1
- package/cli/commands/console.js +8 -6
- package/cli/commands/deploy.d.ts +4 -2
- package/cli/commands/deploy.js +71 -29
- package/cli/commands/dev.d.ts +5 -1
- package/cli/commands/dev.js +157 -79
- package/cli/commands/diff.d.ts +15 -0
- package/cli/commands/diff.js +61 -0
- package/cli/commands/env.d.ts +5 -1
- package/cli/commands/env.js +14 -15
- package/cli/commands/plugins/kysely.js +13 -5
- package/cli/commands/plugins/pothos.js +9 -4
- package/cli/commands/remove.d.ts +4 -0
- package/cli/commands/remove.js +26 -18
- package/cli/commands/secrets/get.d.ts +7 -3
- package/cli/commands/secrets/get.js +11 -24
- package/cli/commands/secrets/list.d.ts +6 -2
- package/cli/commands/secrets/list.js +15 -7
- package/cli/commands/secrets/remove.d.ts +8 -4
- package/cli/commands/secrets/remove.js +18 -16
- package/cli/commands/secrets/secrets.js +3 -3
- package/cli/commands/secrets/set.d.ts +8 -6
- package/cli/commands/secrets/set.js +16 -33
- package/cli/commands/telemetry.d.ts +15 -0
- package/cli/commands/telemetry.js +17 -0
- package/cli/commands/transform.d.ts +15 -0
- package/cli/commands/transform.js +55 -0
- package/cli/commands/update.d.ts +6 -2
- package/cli/commands/update.js +41 -33
- package/cli/commands/version.d.ts +13 -0
- package/cli/commands/version.js +7 -0
- package/cli/local/router.d.ts +6 -6
- package/cli/local/router.js +3 -3
- package/cli/local/server.d.ts +5 -3
- package/cli/local/server.js +21 -14
- package/cli/program.d.ts +5 -1
- package/cli/program.js +29 -5
- package/cli/spinner.js +2 -0
- package/cli/sst.js +35 -23
- package/cli/telemetry/environment.d.ts +1 -1
- package/cli/telemetry/environment.js +1 -1
- package/cli/terminal.d.ts +1 -0
- package/cli/terminal.js +8 -0
- package/cli/ui/deploy.d.ts +3 -2
- package/cli/ui/deploy.js +106 -106
- package/cli/ui/functions.d.ts +2 -0
- package/cli/ui/functions.js +132 -0
- package/cli/ui/header.d.ts +5 -0
- package/cli/ui/header.js +16 -0
- package/cli/ui/stack.d.ts +1 -0
- package/cli/ui/stack.js +6 -0
- package/config.d.ts +1 -1
- package/config.js +8 -8
- package/constructs/Api.d.ts +3 -71
- package/constructs/Api.js +3 -42
- package/constructs/ApiGatewayV1Api.d.ts +3 -3
- package/constructs/ApiGatewayV1Api.js +4 -3
- package/constructs/App.d.ts +2 -22
- package/constructs/App.js +12 -25
- package/constructs/AppSyncApi.d.ts +4 -5
- package/constructs/AppSyncApi.js +8 -5
- package/constructs/AstroSite.d.ts +2 -3
- package/constructs/AstroSite.js +43 -53
- package/constructs/Auth.js +27 -16
- package/constructs/BaseSite.d.ts +10 -10
- package/constructs/BaseSite.js +2 -2
- package/constructs/Cognito.js +28 -28
- package/constructs/EdgeFunction.d.ts +6 -4
- package/constructs/EdgeFunction.js +56 -59
- package/constructs/EventBus.js +1 -1
- package/constructs/Function.d.ts +4 -44
- package/constructs/Function.js +14 -50
- package/constructs/FunctionalStack.d.ts +2 -2
- package/constructs/Job.d.ts +23 -63
- package/constructs/Job.js +11 -32
- package/constructs/Metadata.d.ts +18 -20
- package/constructs/NextjsSite.d.ts +21 -5
- package/constructs/NextjsSite.js +67 -101
- package/constructs/Queue.js +10 -10
- package/constructs/RDS.d.ts +1 -1
- package/constructs/RDS.js +1 -1
- package/constructs/RemixSite.d.ts +0 -2
- package/constructs/RemixSite.js +20 -20
- package/constructs/Script.js +1 -1
- package/constructs/Secret.js +5 -3
- package/constructs/SolidStartSite.d.ts +2 -3
- package/constructs/SolidStartSite.js +42 -52
- package/constructs/SsrFunction.d.ts +22 -0
- package/constructs/SsrFunction.js +113 -0
- package/constructs/SsrSite.d.ts +104 -104
- package/constructs/SsrSite.js +196 -217
- package/constructs/Stack.d.ts +1 -20
- package/constructs/Stack.js +3 -65
- package/constructs/StaticSite.d.ts +33 -53
- package/constructs/StaticSite.js +92 -118
- package/constructs/Table.d.ts +1 -1
- package/constructs/Table.js +4 -4
- package/constructs/Topic.js +1 -1
- package/constructs/cdk/certificate-base.d.ts +18 -0
- package/constructs/cdk/certificate-base.js +26 -0
- package/constructs/cdk/dns-validated-certificate.d.ts +77 -0
- package/constructs/cdk/dns-validated-certificate.js +125 -0
- package/constructs/cdk/website-redirect.d.ts +53 -0
- package/constructs/cdk/website-redirect.js +77 -0
- package/constructs/deferred_task.d.ts +1 -1
- package/constructs/deprecated/NextjsSite.js +8 -6
- package/constructs/index.d.ts +0 -6
- package/constructs/index.js +0 -6
- package/constructs/util/apiGatewayV1AccessLog.d.ts +1 -1
- package/constructs/util/apiGatewayV2AccessLog.js +4 -4
- package/constructs/util/apiGatewayV2Domain.js +9 -2
- package/constructs/util/appSyncApiDomain.d.ts +1 -1
- package/constructs/util/appSyncApiDomain.js +9 -15
- package/constructs/util/duration.d.ts +1 -1
- package/constructs/util/functionBinding.js +1 -1
- package/constructs/util/permission.d.ts +3 -3
- package/constructs/util/permission.js +16 -18
- package/constructs/util/size.d.ts +1 -1
- package/constructs/util/warning.js +2 -2
- package/context/context.d.ts +2 -2
- package/context/context.js +4 -4
- package/context/handler.d.ts +1 -1
- package/credentials.d.ts +1 -1
- package/credentials.js +42 -6
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/iot.js +6 -2
- package/logger.js +3 -1
- package/node/api/index.d.ts +4 -3
- package/node/api/index.js +8 -2
- package/node/auth/adapter/adapter.d.ts +1 -1
- package/node/auth/adapter/facebook.js +1 -1
- package/node/auth/adapter/github.js +4 -4
- package/node/auth/adapter/google.d.ts +1 -1
- package/node/auth/adapter/google.js +2 -2
- package/node/auth/adapter/twitch.js +1 -1
- package/node/auth/session.d.ts +1 -1
- package/node/config/index.d.ts +2 -2
- package/node/config/index.js +3 -8
- package/node/job/index.d.ts +2 -2
- package/node/site/index.js +3 -5
- package/package.json +26 -21
- package/pothos.js +1 -0
- package/project.d.ts +47 -0
- package/{app.js → project.js} +60 -53
- package/runtime/handlers/dotnet.d.ts +1 -1
- package/runtime/handlers/dotnet.js +4 -4
- package/runtime/handlers/go.d.ts +1 -1
- package/runtime/handlers/go.js +3 -3
- package/runtime/handlers/java.d.ts +1 -1
- package/runtime/handlers/java.js +4 -4
- package/runtime/handlers/node.d.ts +1 -1
- package/runtime/handlers/node.js +60 -39
- package/runtime/handlers/python.d.ts +1 -1
- package/runtime/handlers/python.js +3 -3
- package/runtime/handlers.js +15 -12
- package/runtime/iot.js +3 -0
- package/runtime/runtime.d.ts +4 -0
- package/runtime/server.d.ts +3 -3
- package/runtime/server.js +11 -5
- package/runtime/workers.d.ts +4 -2
- package/runtime/workers.js +13 -3
- package/site-env.js +2 -1
- package/sst.mjs +6357 -20846
- package/stacks/app-metadata.d.ts +7 -0
- package/stacks/app-metadata.js +78 -0
- package/stacks/assembly.d.ts +1 -0
- package/stacks/assembly.js +4 -0
- package/stacks/build.d.ts +1 -1
- package/stacks/build.js +41 -48
- package/stacks/deploy.d.ts +1 -0
- package/stacks/deploy.js +128 -7
- package/stacks/diff.d.ts +8 -0
- package/stacks/diff.js +62 -0
- package/stacks/index.d.ts +3 -0
- package/stacks/index.js +3 -0
- package/stacks/metadata.d.ts +2 -0
- package/stacks/metadata.js +14 -12
- package/stacks/monitor.d.ts +8 -3
- package/stacks/monitor.js +38 -4
- package/stacks/remove.js +0 -4
- package/stacks/synth.d.ts +1 -0
- package/stacks/synth.js +27 -13
- package/support/base-site-archiver.mjs +1 -1
- package/support/bootstrap-metadata-function/index.mjs +68740 -0
- package/support/bridge/bridge.mjs +28 -28
- package/support/certificate-requestor/index.js +549 -0
- package/support/custom-resources/index.mjs +3824 -26567
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.deps.json +1 -1
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +1 -1
- package/support/edge-function/edge-lambda.mjs +2 -2
- package/support/job-invoker/index.mjs +26 -0
- package/support/nodejs-runtime/index.mjs +75 -72
- package/support/rds-migrator/index.mjs +22 -23
- package/support/remix-site-function/edge-server.js +1 -1
- package/support/script-function/index.mjs +30485 -0
- package/support/{edge-function-code-replacer → sls-nextjs-site-function-code-replacer}/lambda-code-updater.py +0 -0
- package/support/ssr-site-function-archiver.mjs +96 -0
- package/util/process.d.ts +0 -1
- package/watcher.js +1 -1
- package/app.d.ts +0 -36
- package/constructs/DebugApp.d.ts +0 -49
- package/constructs/DebugApp.js +0 -63
- package/constructs/DebugStack.d.ts +0 -34
- package/constructs/DebugStack.js +0 -132
- package/constructs/GraphQLApi.d.ts +0 -98
- package/constructs/GraphQLApi.js +0 -80
- package/constructs/ReactStaticSite.d.ts +0 -20
- package/constructs/ReactStaticSite.js +0 -54
- package/constructs/Script/cfn-response.d.ts +0 -19
- package/constructs/Script/cfn-response.js +0 -77
- package/constructs/Script/index.d.ts +0 -1
- package/constructs/Script/index.js +0 -78
- package/constructs/Script/outbound.d.ts +0 -10
- package/constructs/Script/outbound.js +0 -42
- package/constructs/Script/util.d.ts +0 -2
- package/constructs/Script/util.js +0 -11
- package/constructs/ViteStaticSite.d.ts +0 -32
- package/constructs/ViteStaticSite.js +0 -66
- package/support/astro-site-html-stub/index.html +0 -99
- package/support/base-site-archiver.cjs +0 -116
- package/support/nextjs-site-html-stub/index.html +0 -99
- package/support/remix-site-html-stub/index.html +0 -99
- package/support/solid-start-site-html-stub/index.html +0 -99
- package/support/static-site-stub/index.html +0 -90
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export const transform = (program) => program.command("transform <mod>", "Apply a transform to your SST app", (yargs) => yargs.positional("mod", {
|
|
2
|
+
type: "string",
|
|
3
|
+
describe: "Name of the transform",
|
|
4
|
+
demandOption: true,
|
|
5
|
+
}), async (args) => {
|
|
6
|
+
const { Colors } = await import("../colors.js");
|
|
7
|
+
if (args.mod === "resource-binding-secrets") {
|
|
8
|
+
await handleSecretsMigration();
|
|
9
|
+
Colors.line(Colors.success(`✔ `), `Transform "${args.mod}" applied successfully!`);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
Colors.line(Colors.danger(`✖ `), `Transform "${args.mod}" not found`);
|
|
13
|
+
});
|
|
14
|
+
async function handleSecretsMigration() {
|
|
15
|
+
const { useProject } = await import("../../project.js");
|
|
16
|
+
const { useAWSClient } = await import("../../credentials.js");
|
|
17
|
+
const { SSMClient, GetParametersByPathCommand, PutParameterCommand } = await import("@aws-sdk/client-ssm");
|
|
18
|
+
const project = useProject();
|
|
19
|
+
const { name: app, stage } = project.config;
|
|
20
|
+
const ssm = useAWSClient(SSMClient);
|
|
21
|
+
async function* getAllPrametersByPath(prefix) {
|
|
22
|
+
let token;
|
|
23
|
+
while (true) {
|
|
24
|
+
const results = await ssm.send(new GetParametersByPathCommand({
|
|
25
|
+
Path: prefix,
|
|
26
|
+
WithDecryption: true,
|
|
27
|
+
Recursive: true,
|
|
28
|
+
NextToken: token,
|
|
29
|
+
}));
|
|
30
|
+
yield* results.Parameters || [];
|
|
31
|
+
if (!results.NextToken)
|
|
32
|
+
break;
|
|
33
|
+
token = results.NextToken;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function migrateSecretsSSMPath(stage) {
|
|
37
|
+
const oldPrefix = `/sst/${app}/${stage}/secrets/`;
|
|
38
|
+
const newPrefix = `/sst/${app}/${stage}/Secret/`;
|
|
39
|
+
for await (const secret of getAllPrametersByPath(oldPrefix)) {
|
|
40
|
+
const name = secret.Name.split("/")[5];
|
|
41
|
+
// Do not migrate SST Auth secrets b/c they are no longer secrets in v1.16.
|
|
42
|
+
if (name === "SST_AUTH_PRIVATE" || name === "SST_AUTH_PUBLIC") {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
await ssm.send(new PutParameterCommand({
|
|
46
|
+
Name: `${newPrefix}${name}/value`,
|
|
47
|
+
Value: secret.Value,
|
|
48
|
+
Type: secret.Type,
|
|
49
|
+
Overwrite: true,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
await migrateSecretsSSMPath(stage);
|
|
54
|
+
await migrateSecretsSSMPath(".fallback");
|
|
55
|
+
}
|
package/cli/commands/update.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
|
-
import { Program } from "../program.js";
|
|
2
|
+
import type { Program } from "../program.js";
|
|
3
3
|
export declare const update: (program: Program) => import("yargs").Argv<{
|
|
4
4
|
stage: string | undefined;
|
|
5
5
|
} & {
|
|
@@ -7,5 +7,9 @@ export declare const update: (program: Program) => import("yargs").Argv<{
|
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
9
|
} & {
|
|
10
|
-
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
version: string | undefined;
|
|
11
15
|
}>;
|
package/cli/commands/update.js
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import path from "path";
|
|
4
|
-
const PACKAGE_MATCH = ["sst", "aws-cdk", "@aws-cdk"];
|
|
1
|
+
const PACKAGE_MATCH = ["sst", "aws-cdk", "@aws-cdk", "constructs"];
|
|
5
2
|
const FIELDS = ["dependencies", "devDependencies"];
|
|
6
|
-
export const update = (program) => program.command("update [
|
|
3
|
+
export const update = (program) => program.command("update [version]", "Update your SST and CDK packages", (yargs) => yargs.positional("version", {
|
|
7
4
|
type: "string",
|
|
8
|
-
describe: "
|
|
5
|
+
describe: "Optionally specify a version to update to",
|
|
9
6
|
}), async (args) => {
|
|
7
|
+
const { green, yellow } = await import("colorette");
|
|
8
|
+
const fs = await import("fs/promises");
|
|
9
|
+
const path = await import("path");
|
|
10
10
|
const { fetch } = await import("undici");
|
|
11
|
-
const { useProject } = await import("../../
|
|
11
|
+
const { useProject } = await import("../../project.js");
|
|
12
|
+
const { Colors } = await import("../colors.js");
|
|
13
|
+
async function find(dir) {
|
|
14
|
+
const children = await fs.readdir(dir);
|
|
15
|
+
const tasks = children.map(async (item) => {
|
|
16
|
+
if (item === "node_modules")
|
|
17
|
+
return [];
|
|
18
|
+
// Ignore hidden paths
|
|
19
|
+
if (/(^|\/)\.[^\/\.]/g.test(item))
|
|
20
|
+
return [];
|
|
21
|
+
const full = path.join(dir, item);
|
|
22
|
+
if (item === "package.json")
|
|
23
|
+
return [full];
|
|
24
|
+
const stat = await fs.stat(full);
|
|
25
|
+
if (stat.isDirectory())
|
|
26
|
+
return find(full);
|
|
27
|
+
return [];
|
|
28
|
+
});
|
|
29
|
+
return (await Promise.all(tasks)).flat();
|
|
30
|
+
}
|
|
12
31
|
const project = useProject();
|
|
13
32
|
const files = await find(project.paths.root);
|
|
14
|
-
const metadata = await fetch(`https://registry.npmjs.org/sst/${args.
|
|
33
|
+
const metadata = await fetch(`https://registry.npmjs.org/sst/${args.version || "latest"}`).then((resp) => resp.json());
|
|
15
34
|
const results = new Map();
|
|
16
35
|
const tasks = files.map(async (file) => {
|
|
17
36
|
const data = await fs
|
|
@@ -25,9 +44,15 @@ export const update = (program) => program.command("update [ver]", "Update SST a
|
|
|
25
44
|
for (const [pkg, existing] of Object.entries(deps)) {
|
|
26
45
|
if (!PACKAGE_MATCH.some((x) => pkg.startsWith(x)))
|
|
27
46
|
continue;
|
|
28
|
-
const desired =
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
const desired = (() => {
|
|
48
|
+
if (pkg === "sst")
|
|
49
|
+
return metadata.version;
|
|
50
|
+
if (pkg === "constructs")
|
|
51
|
+
return metadata.dependencies.constructs;
|
|
52
|
+
if (pkg.endsWith("alpha"))
|
|
53
|
+
return metadata.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
|
|
54
|
+
return metadata.dependencies["aws-cdk-lib"];
|
|
55
|
+
})();
|
|
31
56
|
if (existing === desired)
|
|
32
57
|
continue;
|
|
33
58
|
let arr = results.get(file);
|
|
@@ -43,32 +68,15 @@ export const update = (program) => program.command("update [ver]", "Update SST a
|
|
|
43
68
|
});
|
|
44
69
|
await Promise.all(tasks);
|
|
45
70
|
if (results.size === 0) {
|
|
46
|
-
|
|
71
|
+
Colors.line(Colors.success(`✔ `), `Already using v${metadata.version}`);
|
|
47
72
|
return;
|
|
48
73
|
}
|
|
49
74
|
for (const [file, pkgs] of results.entries()) {
|
|
50
|
-
|
|
75
|
+
Colors.line(Colors.success(`✔ `), Colors.bold.dim(path.relative(project.paths.root, file)));
|
|
51
76
|
for (const [pkg, version] of pkgs) {
|
|
52
|
-
|
|
77
|
+
Colors.line(Colors.dim(` ${pkg}@${version}`));
|
|
53
78
|
}
|
|
54
79
|
}
|
|
55
|
-
|
|
80
|
+
Colors.gap();
|
|
81
|
+
Colors.line(`${Colors.primary(`➜`)} ${Colors.warning("Make sure to run: npm install (or pnpm install, or yarn)")}`);
|
|
56
82
|
});
|
|
57
|
-
async function find(dir) {
|
|
58
|
-
const children = await fs.readdir(dir);
|
|
59
|
-
const tasks = children.map(async (item) => {
|
|
60
|
-
if (item === "node_modules")
|
|
61
|
-
return [];
|
|
62
|
-
// Ignore hidden paths
|
|
63
|
-
if (/(^|\/)\.[^\/\.]/g.test(item))
|
|
64
|
-
return [];
|
|
65
|
-
const full = path.join(dir, item);
|
|
66
|
-
if (item === "package.json")
|
|
67
|
-
return [full];
|
|
68
|
-
const stat = await fs.stat(full);
|
|
69
|
-
if (stat.isDirectory())
|
|
70
|
-
return find(full);
|
|
71
|
-
return [];
|
|
72
|
-
});
|
|
73
|
-
return (await Promise.all(tasks)).flat();
|
|
74
|
-
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
import type { Program } from "../program.js";
|
|
3
|
+
export declare const version: (program: Program) => import("yargs").Argv<{
|
|
4
|
+
stage: string | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
profile: string | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
region: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const version = (program) => program.command("version", "Print SST and CDK version", (yargs) => yargs, async (args) => {
|
|
2
|
+
const { Colors } = await import("../colors.js");
|
|
3
|
+
const { useProject } = await import("../../project.js");
|
|
4
|
+
const project = useProject();
|
|
5
|
+
Colors.line(Colors.bold(`SST:`), `v${project.version}`);
|
|
6
|
+
Colors.line(Colors.bold(`CDK:`), `v${project.cdkVersion}`);
|
|
7
|
+
});
|
package/cli/local/router.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as trpc from "@trpc/server";
|
|
2
2
|
import { DendriformPatch } from "dendriform-immer-patch-optimiser";
|
|
3
|
-
export
|
|
3
|
+
export type State = {
|
|
4
4
|
app: string;
|
|
5
5
|
stage: string;
|
|
6
6
|
functions: Record<string, FunctionState>;
|
|
@@ -9,13 +9,13 @@ export declare type State = {
|
|
|
9
9
|
status: any;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type FunctionState = {
|
|
13
13
|
state: "idle" | "building" | "checking";
|
|
14
14
|
invocations: Invocation[];
|
|
15
15
|
issues: Record<string, any[]>;
|
|
16
16
|
warm: boolean;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type Invocation = {
|
|
19
19
|
id: string;
|
|
20
20
|
request: any;
|
|
21
21
|
response?: any;
|
|
@@ -28,15 +28,15 @@ export declare type Invocation = {
|
|
|
28
28
|
timestamp: number;
|
|
29
29
|
}[];
|
|
30
30
|
};
|
|
31
|
-
export
|
|
31
|
+
export type Context = {
|
|
32
32
|
state: State;
|
|
33
33
|
};
|
|
34
34
|
export declare const router: import("@trpc/server/dist/declarations/src/router.js").Router<Context, Context, Record<"getCredentials", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, {
|
|
35
|
-
region: string;
|
|
35
|
+
region: string | undefined;
|
|
36
36
|
credentials: {
|
|
37
37
|
accessKeyId: string;
|
|
38
38
|
secretAccessKey: string;
|
|
39
39
|
sessionToken: string | undefined;
|
|
40
40
|
};
|
|
41
41
|
}>> & Record<"getState", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, State>>, Record<"deploy", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, void>>, Record<"onStateChange", import("@trpc/server/dist/declarations/src/internals/procedure.js").Procedure<Context, Context, undefined, undefined, trpc.Subscription<DendriformPatch[]>>>, trpc.DefaultErrorShape>;
|
|
42
|
-
export
|
|
42
|
+
export type Router = typeof router;
|
package/cli/local/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as trpc from "@trpc/server";
|
|
2
|
-
import { useProject } from "../../
|
|
2
|
+
import { useProject } from "../../project.js";
|
|
3
3
|
import { useBus } from "../../bus.js";
|
|
4
4
|
import { useAWSCredentials } from "../../credentials.js";
|
|
5
5
|
export const router = trpc
|
|
@@ -9,7 +9,7 @@ export const router = trpc
|
|
|
9
9
|
const project = useProject();
|
|
10
10
|
const credentials = await useAWSCredentials();
|
|
11
11
|
return {
|
|
12
|
-
region: project.region,
|
|
12
|
+
region: project.config.region,
|
|
13
13
|
credentials: {
|
|
14
14
|
accessKeyId: credentials.accessKeyId,
|
|
15
15
|
secretAccessKey: credentials.secretAccessKey,
|
|
@@ -24,7 +24,7 @@ export const router = trpc
|
|
|
24
24
|
},
|
|
25
25
|
})
|
|
26
26
|
.mutation("deploy", {
|
|
27
|
-
async resolve(
|
|
27
|
+
async resolve() {
|
|
28
28
|
return;
|
|
29
29
|
},
|
|
30
30
|
})
|
package/cli/local/server.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FunctionState, State } from "./router.js";
|
|
2
2
|
import { WritableDraft } from "immer/dist/internal.js";
|
|
3
3
|
import { DendriformPatch } from "dendriform-immer-patch-optimiser";
|
|
4
|
-
|
|
5
|
-
port: number;
|
|
4
|
+
type Opts = {
|
|
6
5
|
key: any;
|
|
7
6
|
cert: any;
|
|
8
7
|
live: boolean;
|
|
@@ -12,8 +11,11 @@ declare module "../../bus.js" {
|
|
|
12
11
|
"local.patches": DendriformPatch[];
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
|
-
export declare
|
|
14
|
+
export declare const useLocalServerConfig: () => Promise<{
|
|
16
15
|
port: number;
|
|
16
|
+
url: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function useLocalServer(opts: Opts): Promise<{
|
|
17
19
|
updateState: (cb: (draft: WritableDraft<State>) => void) => void;
|
|
18
20
|
updateFunction: (id: string, cb: (draft: WritableDraft<FunctionState>) => void) => void;
|
|
19
21
|
}>;
|
package/cli/local/server.js
CHANGED
|
@@ -9,13 +9,26 @@ import { applyWSSHandler } from "@trpc/server/adapters/ws/dist/trpc-server-adapt
|
|
|
9
9
|
import { router } from "./router.js";
|
|
10
10
|
import { optimise } from "dendriform-immer-patch-optimiser";
|
|
11
11
|
import { sync } from "cross-spawn";
|
|
12
|
-
import { useProject } from "../../
|
|
12
|
+
import { useProject } from "../../project.js";
|
|
13
13
|
import { useBus } from "../../bus.js";
|
|
14
|
+
import getPort from "get-port";
|
|
15
|
+
import { Context } from "../../context/context.js";
|
|
16
|
+
export const useLocalServerConfig = Context.memo(async () => {
|
|
17
|
+
const project = useProject();
|
|
18
|
+
const port = await getPort({
|
|
19
|
+
port: 13557,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
port,
|
|
23
|
+
url: `https://console.sst.dev/${project.config.name}/${project.config.stage}${port !== 13557 ? `?_port=${port}` : ""}`,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
14
26
|
export async function useLocalServer(opts) {
|
|
27
|
+
const cfg = await useLocalServerConfig();
|
|
15
28
|
const project = useProject();
|
|
16
29
|
let state = {
|
|
17
|
-
app: project.name,
|
|
18
|
-
stage: project.stage,
|
|
30
|
+
app: project.config.name,
|
|
31
|
+
stage: project.config.stage,
|
|
19
32
|
live: opts.live,
|
|
20
33
|
stacks: {
|
|
21
34
|
status: "idle",
|
|
@@ -23,17 +36,12 @@ export async function useLocalServer(opts) {
|
|
|
23
36
|
functions: {},
|
|
24
37
|
};
|
|
25
38
|
const rest = express();
|
|
26
|
-
/*
|
|
27
39
|
rest.all(`/ping`, (req, res) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
req.header("access-control-request-headers")
|
|
33
|
-
);
|
|
34
|
-
res.sendStatus(200);
|
|
40
|
+
res.header("Access-Control-Allow-Origin", "*");
|
|
41
|
+
res.header("Access-Control-Allow-Methods", "GET, PUT, PATCH, POST, DELETE");
|
|
42
|
+
res.header("Access-Control-Allow-Headers", req.header("access-control-request-headers"));
|
|
43
|
+
res.sendStatus(200);
|
|
35
44
|
});
|
|
36
|
-
*/
|
|
37
45
|
rest.all(`/proxy*`, express.raw({
|
|
38
46
|
type: "*/*",
|
|
39
47
|
limit: "1024mb",
|
|
@@ -107,7 +115,7 @@ export async function useLocalServer(opts) {
|
|
|
107
115
|
console.log("Rejecting unauthorized connection from " + req.headers.origin);
|
|
108
116
|
socket.terminate();
|
|
109
117
|
});
|
|
110
|
-
server.listen(
|
|
118
|
+
server.listen(cfg.port);
|
|
111
119
|
const handler = applyWSSHandler({
|
|
112
120
|
wss,
|
|
113
121
|
router,
|
|
@@ -204,7 +212,6 @@ export async function useLocalServer(opts) {
|
|
|
204
212
|
});
|
|
205
213
|
});
|
|
206
214
|
const result = {
|
|
207
|
-
port: opts.port,
|
|
208
215
|
updateState,
|
|
209
216
|
updateFunction,
|
|
210
217
|
};
|
package/cli/program.d.ts
CHANGED
|
@@ -5,5 +5,9 @@ export declare const program: import("yargs").Argv<{
|
|
|
5
5
|
profile: string | undefined;
|
|
6
6
|
} & {
|
|
7
7
|
region: string | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
verbose: boolean | undefined;
|
|
10
|
+
} & {
|
|
11
|
+
role: string | undefined;
|
|
8
12
|
}>;
|
|
9
|
-
export
|
|
13
|
+
export type Program = typeof program;
|
package/cli/program.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import yargs from "yargs";
|
|
2
2
|
import { hideBin } from "yargs/helpers";
|
|
3
|
-
import { initProject } from "../app.js";
|
|
4
|
-
import { trackCli } from "./telemetry/telemetry.js";
|
|
5
3
|
export const program = yargs(hideBin(process.argv))
|
|
6
4
|
.scriptName("sst")
|
|
7
5
|
.option("stage", {
|
|
@@ -16,9 +14,35 @@ export const program = yargs(hideBin(process.argv))
|
|
|
16
14
|
type: "string",
|
|
17
15
|
describe: "The AWS region to use",
|
|
18
16
|
})
|
|
17
|
+
.option("verbose", {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
describe: "Print verbose logs",
|
|
20
|
+
})
|
|
21
|
+
.option("role", {
|
|
22
|
+
type: "string",
|
|
23
|
+
describe: "ARN of the IAM role to use when invoking AWS",
|
|
24
|
+
})
|
|
25
|
+
.group(["stage", "profile", "region", "role", "verbose", "help"], "Global:")
|
|
19
26
|
.middleware(async (argv) => {
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
if (argv.verbose) {
|
|
28
|
+
process.env.SST_VERBOSE = "1";
|
|
29
|
+
}
|
|
30
|
+
if (argv._.length > 0) {
|
|
31
|
+
const { initProject } = await import("../project.js");
|
|
32
|
+
await initProject(argv);
|
|
33
|
+
const { trackCli } = await import("./telemetry/telemetry.js");
|
|
34
|
+
trackCli(argv._[0]);
|
|
35
|
+
}
|
|
22
36
|
})
|
|
37
|
+
.version(false)
|
|
38
|
+
.epilogue(`Join the SST community on Discord https://sst.dev/discord`)
|
|
39
|
+
.recommendCommands()
|
|
40
|
+
.demandCommand()
|
|
23
41
|
.strict()
|
|
24
|
-
.
|
|
42
|
+
.fail((_, error, yargs) => {
|
|
43
|
+
if (!error) {
|
|
44
|
+
yargs.showHelp();
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
});
|
package/cli/spinner.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context } from "../context/context.js";
|
|
2
2
|
import ora from "ora";
|
|
3
|
+
import { Colors } from "./colors.js";
|
|
3
4
|
export const useSpinners = Context.memo(() => {
|
|
4
5
|
const spinners = [];
|
|
5
6
|
return spinners;
|
|
@@ -8,5 +9,6 @@ export function createSpinner(options) {
|
|
|
8
9
|
const spinners = useSpinners();
|
|
9
10
|
const next = ora(options);
|
|
10
11
|
spinners.push(next);
|
|
12
|
+
Colors.mode("line");
|
|
11
13
|
return next;
|
|
12
14
|
}
|
package/cli/sst.js
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { blue, red } from "colorette";
|
|
3
3
|
import { program } from "./program.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { VisibleError } from "../error.js";
|
|
5
|
+
import { useSpinners } from "./spinner.js";
|
|
6
|
+
import { Logger } from "../logger.js";
|
|
7
|
+
import dotenv from "dotenv";
|
|
8
|
+
dotenv.config({
|
|
9
|
+
override: true,
|
|
10
|
+
});
|
|
11
|
+
dotenv.config({
|
|
12
|
+
path: ".env.local",
|
|
13
|
+
override: true,
|
|
14
|
+
});
|
|
15
|
+
import { env } from "./commands/env.js";
|
|
6
16
|
import { dev } from "./commands/dev.js";
|
|
7
17
|
import { bind } from "./commands/bind.js";
|
|
8
18
|
import { build } from "./commands/build.js";
|
|
9
|
-
import { VisibleError } from "../error.js";
|
|
10
|
-
import { useSpinners } from "./spinner.js";
|
|
11
19
|
import { deploy } from "./commands/deploy.js";
|
|
12
20
|
import { remove } from "./commands/remove.js";
|
|
13
|
-
import dotenv from "dotenv";
|
|
14
|
-
import { env } from "./commands/env.js";
|
|
15
|
-
import { Logger } from "../logger.js";
|
|
16
21
|
import { consoleCommand } from "./commands/console.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
import { secrets } from "./commands/secrets/secrets.js";
|
|
23
|
+
import { update } from "./commands/update.js";
|
|
24
|
+
import { transform } from "./commands/transform.js";
|
|
25
|
+
import { diff } from "./commands/diff.js";
|
|
26
|
+
import { version } from "./commands/version.js";
|
|
27
|
+
import { telemetry } from "./commands/telemetry.js";
|
|
28
|
+
import { bootstrap } from "./commands/bootstrap.js";
|
|
20
29
|
dev(program);
|
|
21
|
-
bind(program);
|
|
22
|
-
build(program);
|
|
23
30
|
deploy(program);
|
|
24
|
-
|
|
31
|
+
build(program);
|
|
32
|
+
bind(program);
|
|
25
33
|
env(program);
|
|
34
|
+
secrets(program);
|
|
35
|
+
remove(program);
|
|
36
|
+
update(program);
|
|
37
|
+
transform(program);
|
|
26
38
|
consoleCommand(program);
|
|
39
|
+
diff(program);
|
|
40
|
+
version(program);
|
|
41
|
+
telemetry(program);
|
|
42
|
+
bootstrap(program);
|
|
43
|
+
if ("setSourceMapsEnabled" in process) {
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
process.setSourceMapsEnabled(true);
|
|
46
|
+
}
|
|
27
47
|
process.removeAllListeners("uncaughtException");
|
|
28
48
|
process.on("uncaughtException", (err) => {
|
|
29
49
|
Logger.debug(err);
|
|
@@ -38,16 +58,8 @@ process.on("uncaughtException", (err) => {
|
|
|
38
58
|
console.trace(err.stack);
|
|
39
59
|
}
|
|
40
60
|
console.log();
|
|
41
|
-
console.log(`Need help with this error? Join
|
|
61
|
+
console.log(`Need help with this error? Join the SST community on Discord ${blue(`https://sst.dev/discord`)}`);
|
|
42
62
|
process.exit(1);
|
|
43
63
|
});
|
|
44
64
|
process.on("beforeExit", () => { });
|
|
45
|
-
program
|
|
46
|
-
.fail((msg, error) => {
|
|
47
|
-
if (!error) {
|
|
48
|
-
console.log(msg);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
throw error;
|
|
52
|
-
})
|
|
53
|
-
.parse();
|
|
65
|
+
program.parse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clear(): void;
|
package/cli/terminal.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function clear() {
|
|
2
|
+
// console.clear() removes the content in the viewport in VSCode
|
|
3
|
+
// and on Windows. This is a workaround to preserve the viewport.
|
|
4
|
+
for (let i = 0, l = process.stdout.rows; i < l - 1; i++) {
|
|
5
|
+
console.log("");
|
|
6
|
+
}
|
|
7
|
+
console.clear();
|
|
8
|
+
}
|
package/cli/ui/deploy.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" resolution-mode="require"/>
|
|
2
2
|
import { Stacks } from "../../stacks/index.js";
|
|
3
|
+
import type { CloudAssembly } from "aws-cdk-lib/cx-api";
|
|
3
4
|
interface Props {
|
|
4
|
-
|
|
5
|
+
assembly: CloudAssembly;
|
|
5
6
|
}
|
|
6
7
|
export declare const DeploymentUI: (props: Props) => JSX.Element;
|
|
7
|
-
export declare function printDeploymentResults(results: Awaited<ReturnType<typeof Stacks.deployMany
|
|
8
|
+
export declare function printDeploymentResults(assembly: CloudAssembly, results: Awaited<ReturnType<typeof Stacks.deployMany>>, remove?: boolean): void;
|
|
8
9
|
export {};
|