sst 2.0.0-rc.9 → 2.0.1
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 +69 -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 +2 -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 -20848
- 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/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,61 @@
|
|
|
1
|
+
import { stackNameToId } from "../ui/stack.js";
|
|
2
|
+
export const diff = (program) => program.command("diff", "Compare your app with what is deployed on AWS", (yargs) => yargs.option("dev", {
|
|
3
|
+
type: "boolean",
|
|
4
|
+
describe: "Compare in dev mode",
|
|
5
|
+
}), async (args) => {
|
|
6
|
+
const { useProject } = await import("../../project.js");
|
|
7
|
+
const { Stacks } = await import("../../stacks/index.js");
|
|
8
|
+
const { useAWSClient } = await import("../../credentials.js");
|
|
9
|
+
const { CloudFormationClient, GetTemplateCommand } = await import("@aws-sdk/client-cloudformation");
|
|
10
|
+
const { createSpinner } = await import("../spinner.js");
|
|
11
|
+
const { green } = await import("colorette");
|
|
12
|
+
const { Colors } = await import("../colors.js");
|
|
13
|
+
// Build app
|
|
14
|
+
const project = useProject();
|
|
15
|
+
const assembly = await Stacks.synth({
|
|
16
|
+
fn: project.stacks,
|
|
17
|
+
mode: args.dev ? "dev" : "deploy",
|
|
18
|
+
});
|
|
19
|
+
// Diff each stack
|
|
20
|
+
let changesAcc = 0;
|
|
21
|
+
let changedStacks = 0;
|
|
22
|
+
const cfn = useAWSClient(CloudFormationClient);
|
|
23
|
+
for (const stack of assembly.stacks) {
|
|
24
|
+
const spinner = createSpinner(`${stack.stackName}: Checking for changes...`);
|
|
25
|
+
// get old template
|
|
26
|
+
const response = await cfn.send(new GetTemplateCommand({
|
|
27
|
+
StackName: stack.stackName,
|
|
28
|
+
}));
|
|
29
|
+
const oldTemplate = JSON.parse(response.TemplateBody);
|
|
30
|
+
// generate diff
|
|
31
|
+
const { count, diff } = await Stacks.diff(stack, oldTemplate);
|
|
32
|
+
spinner.clear();
|
|
33
|
+
// print diff result
|
|
34
|
+
if (count === 0) {
|
|
35
|
+
Colors.line(`➜ ${Colors.dim.bold(stackNameToId(stack.stackName) + ":")} No changes`);
|
|
36
|
+
Colors.gap();
|
|
37
|
+
}
|
|
38
|
+
else if (count === 1) {
|
|
39
|
+
Colors.line(`➜ ${Colors.dim.bold(stackNameToId(stack.stackName) + ":")} ${count} change`);
|
|
40
|
+
Colors.gap();
|
|
41
|
+
console.log(diff);
|
|
42
|
+
changesAcc += count;
|
|
43
|
+
changedStacks++;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
Colors.line(`➜ ${Colors.dim.bold(stackNameToId(stack.stackName) + ":")} ${count} changes`);
|
|
47
|
+
Colors.gap();
|
|
48
|
+
console.log(diff);
|
|
49
|
+
changesAcc += count;
|
|
50
|
+
changedStacks++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Handle no changes
|
|
54
|
+
if (changedStacks === 0) {
|
|
55
|
+
Colors.line(Colors.success(`✔`), Colors.bold(" Diff:"), "No changes");
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
Colors.line(Colors.success(`✔`), Colors.bold(" Diff:"), changesAcc === 1 ? "1 change found in" : `${changesAcc} changes in`, changedStacks === 1 ? "1 stack" : `${changedStacks} stacks`);
|
|
59
|
+
}
|
|
60
|
+
process.exit(0);
|
|
61
|
+
});
|
package/cli/commands/env.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
|
-
import { Program } from "../program.js";
|
|
2
|
+
import type { Program } from "../program.js";
|
|
3
3
|
export declare const env: (program: Program) => import("yargs").Argv<{
|
|
4
4
|
stage: string | undefined;
|
|
5
5
|
} & {
|
|
6
6
|
profile: string | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
9
13
|
} & {
|
|
10
14
|
command: string;
|
|
11
15
|
}>;
|
package/cli/commands/env.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import fs from "fs/promises";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { SiteEnv } from "../../site-env.js";
|
|
6
|
-
import { spawnSync } from "child_process";
|
|
7
|
-
export const env = (program) => program.command("env <command>", "description", (yargs) => yargs.positional("command", {
|
|
1
|
+
export const env = (program) => program.command("env <command>", "Load environment variables and start your frontend", (yargs) => yargs
|
|
2
|
+
.positional("command", {
|
|
8
3
|
type: "string",
|
|
9
|
-
describe: "
|
|
4
|
+
describe: "The command to start your frontend",
|
|
10
5
|
demandOption: true,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
})
|
|
7
|
+
.example(`sst env "next dev"`, "Start Next.js with your environment variables")
|
|
8
|
+
.example(`sst env "vite dev"`, "Start Vite with your environment variables"), async (args) => {
|
|
9
|
+
const { createSpinner } = await import("../spinner.js");
|
|
10
|
+
const fs = await import("fs/promises");
|
|
11
|
+
const { SiteEnv } = await import("../../site-env.js");
|
|
12
|
+
const { spawnSync } = await import("child_process");
|
|
13
|
+
let spinner;
|
|
14
14
|
while (true) {
|
|
15
15
|
const exists = await fs
|
|
16
16
|
.access(SiteEnv.valuesFile())
|
|
17
17
|
.then(() => true)
|
|
18
18
|
.catch(() => false);
|
|
19
19
|
if (!exists) {
|
|
20
|
+
spinner = createSpinner("Cannot find SST environment variables. Waiting for SST to start...").start();
|
|
20
21
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
21
22
|
continue;
|
|
22
23
|
}
|
|
23
|
-
spinner
|
|
24
|
+
spinner?.succeed();
|
|
24
25
|
const sites = await SiteEnv.values();
|
|
25
|
-
const
|
|
26
|
-
const env = sites[current] || {};
|
|
27
|
-
console.log(args.command);
|
|
26
|
+
const env = sites[process.cwd()] || {};
|
|
28
27
|
const result = spawnSync(args.command, {
|
|
29
28
|
env: {
|
|
30
29
|
...process.env,
|
|
@@ -5,7 +5,9 @@ import * as fs from "fs/promises";
|
|
|
5
5
|
import { DatabaseMetadata, EnumCollection, PostgresDialect, Serializer, Transformer, } from "kysely-codegen";
|
|
6
6
|
import { Context } from "../../../context/context.js";
|
|
7
7
|
import { useBus } from "../../../bus.js";
|
|
8
|
-
import { useProject } from "../../../
|
|
8
|
+
import { useProject } from "../../../project.js";
|
|
9
|
+
import { Logger } from "../../../logger.js";
|
|
10
|
+
import { useAWSCredentials, } from "../../../credentials.js";
|
|
9
11
|
export const useKyselyTypeGenerator = Context.memo(async () => {
|
|
10
12
|
let databases = [];
|
|
11
13
|
const bus = useBus();
|
|
@@ -13,6 +15,8 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
|
|
|
13
15
|
async function generate(db) {
|
|
14
16
|
if (!db.types)
|
|
15
17
|
return;
|
|
18
|
+
Logger.debug("Generating types for", db.migratorID);
|
|
19
|
+
const credentials = await useAWSCredentials();
|
|
16
20
|
const k = new Kysely({
|
|
17
21
|
dialect: new DataApiDialect({
|
|
18
22
|
mode: db.engine.includes("postgres") ? "postgres" : "mysql",
|
|
@@ -21,7 +25,8 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
|
|
|
21
25
|
resourceArn: db.clusterArn,
|
|
22
26
|
database: db.defaultDatabaseName,
|
|
23
27
|
client: new RDSDataService({
|
|
24
|
-
region: project.region,
|
|
28
|
+
region: project.config.region,
|
|
29
|
+
credentials,
|
|
25
30
|
}),
|
|
26
31
|
},
|
|
27
32
|
}),
|
|
@@ -67,13 +72,13 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
|
|
|
67
72
|
await fs.writeFile(db.types.path, data);
|
|
68
73
|
}
|
|
69
74
|
bus.subscribe("stacks.metadata", (evt) => {
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
const constructs = Object.values(evt.properties).flat();
|
|
76
|
+
databases = constructs
|
|
72
77
|
.filter((c) => c.type === "RDS")
|
|
73
78
|
.filter((c) => c.data.migrator)
|
|
74
79
|
.filter((c) => c.data.types)
|
|
75
80
|
.map((c) => ({
|
|
76
|
-
migratorID:
|
|
81
|
+
migratorID: constructs.find((fn) => fn.addr == c.data.migrator?.node).addr,
|
|
77
82
|
clusterArn: c.data.clusterArn,
|
|
78
83
|
types: c.data.types,
|
|
79
84
|
engine: c.data.engine,
|
|
@@ -83,9 +88,12 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
|
|
|
83
88
|
databases.map((db) => generate(db));
|
|
84
89
|
});
|
|
85
90
|
bus.subscribe("function.success", async (evt) => {
|
|
91
|
+
if (!evt.properties.body?.results)
|
|
92
|
+
return;
|
|
86
93
|
const db = databases.find((db) => db.migratorID === evt.properties.functionID);
|
|
87
94
|
if (!db)
|
|
88
95
|
return;
|
|
89
96
|
generate(db);
|
|
90
97
|
});
|
|
98
|
+
Logger.debug("Loaded kyseley type generator");
|
|
91
99
|
});
|
|
@@ -6,6 +6,7 @@ import { exec } from "child_process";
|
|
|
6
6
|
import { promisify } from "util";
|
|
7
7
|
const execAsync = promisify(exec);
|
|
8
8
|
import path from "path";
|
|
9
|
+
import { Colors } from "../../colors.js";
|
|
9
10
|
export const usePothosBuilder = Context.memo(() => {
|
|
10
11
|
let routes = [];
|
|
11
12
|
const bus = useBus();
|
|
@@ -16,12 +17,16 @@ export const usePothosBuilder = Context.memo(() => {
|
|
|
16
17
|
});
|
|
17
18
|
await fs.writeFile(route.output, schema);
|
|
18
19
|
// bus.publish("pothos.extracted", { file: route.output });
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (Array.isArray(route.commands) && route.commands.length > 0) {
|
|
21
|
+
await Promise.all(route.commands.map((cmd) => execAsync(cmd)));
|
|
22
|
+
}
|
|
23
|
+
Colors.line(Colors.success(`✔`), " Pothos: Extracted pothos schema");
|
|
21
24
|
}
|
|
22
25
|
catch (ex) {
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
Colors.line(Colors.danger(`✖`), " Pothos: Failed to extract schema:");
|
|
27
|
+
for (let line of ex.message.split("\n")) {
|
|
28
|
+
console.log(` `, line);
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
bus.subscribe("file.changed", async (evt) => {
|
package/cli/commands/remove.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export declare const remove: (program: Program) => import("yargs").Argv<{
|
|
|
6
6
|
profile: string | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
9
13
|
} & {
|
|
10
14
|
from: string | undefined;
|
|
11
15
|
} & {
|
package/cli/commands/remove.js
CHANGED
|
@@ -1,39 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const remove = (program) => program.command("remove [filter]", "Remove your app from AWS", (yargs) => yargs.option("from", { type: "string" }).positional("filter", {
|
|
2
|
+
type: "string",
|
|
3
|
+
describe: "Optionally filter stacks to remove",
|
|
4
|
+
}), async (args) => {
|
|
5
5
|
const React = await import("react");
|
|
6
|
-
const {
|
|
7
|
-
const {
|
|
8
|
-
const {
|
|
9
|
-
const { Stacks } = await import("../../stacks/index.js");
|
|
6
|
+
const { dim, blue, bold } = await import("colorette");
|
|
7
|
+
const { useProject } = await import("../../project.js");
|
|
8
|
+
const { loadAssembly, clearAppMetadata, Stacks } = await import("../../stacks/index.js");
|
|
10
9
|
const { render } = await import("ink");
|
|
11
10
|
const { DeploymentUI } = await import("../ui/deploy.js");
|
|
11
|
+
const { printDeploymentResults } = await import("../ui/deploy.js");
|
|
12
|
+
const { Colors } = await import("../colors.js");
|
|
13
|
+
const { useSTSIdentity } = await import("../../credentials.js");
|
|
14
|
+
const project = useProject();
|
|
15
|
+
const identity = await useSTSIdentity();
|
|
16
|
+
Colors.line(`${Colors.primary.bold(`SST v${project.version}`)}`);
|
|
17
|
+
Colors.gap();
|
|
18
|
+
Colors.line(`${Colors.primary(`➜`)} ${Colors.bold("App:")} ${project.config.name}`);
|
|
19
|
+
Colors.line(` ${Colors.bold("Stage:")} ${project.config.stage}`);
|
|
20
|
+
Colors.line(` ${Colors.bold("Region:")} ${project.config.region}`);
|
|
21
|
+
Colors.line(` ${Colors.bold("Account:")} ${identity.Account}`);
|
|
12
22
|
const assembly = await (async function () {
|
|
13
23
|
if (args.from) {
|
|
14
|
-
const result =
|
|
24
|
+
const result = await loadAssembly(args.from);
|
|
15
25
|
return result;
|
|
16
26
|
}
|
|
17
|
-
const fn = await Stacks.build();
|
|
18
27
|
return await Stacks.synth({
|
|
19
|
-
fn,
|
|
28
|
+
fn: project.stacks,
|
|
20
29
|
mode: "remove",
|
|
21
30
|
});
|
|
22
31
|
})();
|
|
23
|
-
const project = useProject();
|
|
24
32
|
const target = assembly.stacks.filter((s) => !args.filter ||
|
|
25
33
|
s.stackName.toLowerCase().includes(args.filter.toLowerCase()));
|
|
26
34
|
if (!target.length) {
|
|
27
35
|
console.log(`No stacks found matching ${blue(args.filter)}`);
|
|
28
36
|
process.exit(1);
|
|
29
|
-
return;
|
|
30
37
|
}
|
|
31
|
-
|
|
32
|
-
process.stdout.write("\x1b[?1049h");
|
|
33
|
-
const component = render(React.createElement(DeploymentUI, { stacks: target.map((s) => s.stackName) }));
|
|
38
|
+
const component = render(React.createElement(DeploymentUI, { assembly: assembly }));
|
|
34
39
|
const results = await Stacks.removeMany(target);
|
|
40
|
+
component.clear();
|
|
35
41
|
component.unmount();
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
printDeploymentResults(assembly, results, true);
|
|
43
|
+
if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
|
|
44
|
+
process.exit(1);
|
|
45
|
+
await clearAppMetadata();
|
|
38
46
|
process.exit(0);
|
|
39
47
|
});
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
2
|
import { Program } from "../../program.js";
|
|
3
|
-
export declare const get: (program: Program) => import("yargs").Argv<
|
|
3
|
+
export declare const get: (program: Program) => import("yargs").Argv<{
|
|
4
4
|
stage: string | undefined;
|
|
5
5
|
} & {
|
|
6
6
|
profile: string | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
9
13
|
} & {
|
|
10
14
|
name: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
15
|
+
} & {
|
|
16
|
+
fallback: boolean | undefined;
|
|
13
17
|
}>;
|
|
@@ -1,37 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
.command("get <name>", "Get secret value", (yargs) => yargs.positional("name", {
|
|
1
|
+
export const get = (program) => program.command("get <name>", "Get the value of a secret", (yargs) => yargs
|
|
2
|
+
.positional("name", {
|
|
4
3
|
type: "string",
|
|
5
|
-
describe: "Name of secret",
|
|
4
|
+
describe: "Name of the secret",
|
|
6
5
|
demandOption: true,
|
|
7
|
-
}), async (args) => {
|
|
8
|
-
const { Config } = await import("../../../config.js");
|
|
9
|
-
const { bold } = await import("colorette");
|
|
10
|
-
try {
|
|
11
|
-
const result = await Config.getSecret({
|
|
12
|
-
key: args.name,
|
|
13
|
-
});
|
|
14
|
-
console.log(bold(result));
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
console.log(red(`${bold(args.name)} is not set`));
|
|
18
|
-
}
|
|
19
6
|
})
|
|
20
|
-
.
|
|
21
|
-
type: "
|
|
22
|
-
describe: "
|
|
23
|
-
demandOption: true,
|
|
7
|
+
.option("fallback", {
|
|
8
|
+
type: "boolean",
|
|
9
|
+
describe: "Get the fallback value",
|
|
24
10
|
}), async (args) => {
|
|
11
|
+
const { red } = await import("colorette");
|
|
25
12
|
const { Config } = await import("../../../config.js");
|
|
26
|
-
const {
|
|
13
|
+
const { Colors } = await import("../../colors.js");
|
|
27
14
|
try {
|
|
28
15
|
const result = await Config.getSecret({
|
|
29
16
|
key: args.name,
|
|
30
|
-
fallback: true,
|
|
17
|
+
fallback: args.fallback === true,
|
|
31
18
|
});
|
|
32
|
-
console.log(
|
|
19
|
+
console.log(result);
|
|
33
20
|
}
|
|
34
21
|
catch {
|
|
35
|
-
|
|
22
|
+
Colors.line(Colors.danger(`✖ `), `"${args.name}" is not set`);
|
|
36
23
|
}
|
|
37
24
|
});
|
|
@@ -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 list: (program: Program) => import("yargs").Argv<{
|
|
4
4
|
stage: string | undefined;
|
|
5
5
|
} & {
|
|
@@ -7,5 +7,9 @@ export declare const list: (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
|
+
format: string | undefined;
|
|
11
15
|
}>;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export const list = (program) => program.command("list [format]", "Fetch all the secrets", (yargs) => yargs.positional("format", {
|
|
2
|
+
type: "string",
|
|
3
|
+
choices: ["table", "env"],
|
|
4
|
+
}), async (args) => {
|
|
5
|
+
const { Config } = await import("../../../config.js");
|
|
6
|
+
const { gray } = await import("colorette");
|
|
7
|
+
const { Colors } = await import("../../colors.js");
|
|
4
8
|
const secrets = await Config.secrets();
|
|
5
|
-
|
|
9
|
+
if (Object.entries(secrets).length === 0) {
|
|
10
|
+
Colors.line("No secrets set");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
switch (args.format || "table") {
|
|
6
14
|
case "env":
|
|
7
15
|
for (const [key, value] of Object.entries(secrets)) {
|
|
8
16
|
console.log(`${key}=${value.value || value.fallback}`);
|
|
@@ -10,8 +18,8 @@ export const list = (program) => program.command("list [format]", "Fetch and dec
|
|
|
10
18
|
break;
|
|
11
19
|
case "table":
|
|
12
20
|
const keys = Object.keys(secrets);
|
|
13
|
-
const keyLen = Math.max("Secrets".length, ...keys.map(key => key.length));
|
|
14
|
-
const valueLen = Math.max("Values".length, ...keys.map(key => secrets[key].value
|
|
21
|
+
const keyLen = Math.max("Secrets".length, ...keys.map((key) => key.length));
|
|
22
|
+
const valueLen = Math.max("Values".length, ...keys.map((key) => secrets[key].value
|
|
15
23
|
? secrets[key].value.length
|
|
16
24
|
: `${secrets[key].fallback} (fallback)`.length));
|
|
17
25
|
console.log("┌".padEnd(keyLen + 3, "─") +
|
|
@@ -23,7 +31,7 @@ export const list = (program) => program.command("list [format]", "Fetch and dec
|
|
|
23
31
|
"┼" +
|
|
24
32
|
"".padEnd(valueLen + 2, "─") +
|
|
25
33
|
"┤");
|
|
26
|
-
keys.sort().forEach(key => {
|
|
34
|
+
keys.sort().forEach((key) => {
|
|
27
35
|
const value = secrets[key].value
|
|
28
36
|
? secrets[key].value
|
|
29
37
|
: `${secrets[key].fallback} ${gray("(fallback)")}`;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
|
-
import { Program } from "../../program.js";
|
|
3
|
-
export declare const remove: (program: Program) => import("yargs").Argv<
|
|
2
|
+
import type { Program } from "../../program.js";
|
|
3
|
+
export declare const remove: (program: Program) => import("yargs").Argv<{
|
|
4
4
|
stage: string | undefined;
|
|
5
5
|
} & {
|
|
6
6
|
profile: string | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
|
+
} & {
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
9
13
|
} & {
|
|
10
14
|
name: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
15
|
+
} & {
|
|
16
|
+
fallback: boolean | undefined;
|
|
13
17
|
}>;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
describe: "Name of secret to remove",
|
|
1
|
+
export const remove = (program) => program.command("remove <name>", "Remove a secret", (yargs) => yargs
|
|
2
|
+
.positional("name", {
|
|
3
|
+
describe: "Name of the secret",
|
|
5
4
|
type: "string",
|
|
6
5
|
demandOption: true,
|
|
7
|
-
}), async (args) => {
|
|
8
|
-
await Config.removeSecret({
|
|
9
|
-
key: args.name,
|
|
10
|
-
});
|
|
11
6
|
})
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
demandOption: true,
|
|
7
|
+
.option("fallback", {
|
|
8
|
+
type: "boolean",
|
|
9
|
+
describe: "Remove the fallback value",
|
|
16
10
|
}), async (args) => {
|
|
17
|
-
await
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const { Config } = await import("../../../config.js");
|
|
12
|
+
const { Colors } = await import("../../colors.js");
|
|
13
|
+
try {
|
|
14
|
+
await Config.removeSecret({
|
|
15
|
+
key: args.name,
|
|
16
|
+
fallback: args.fallback === true,
|
|
17
|
+
});
|
|
18
|
+
Colors.line(Colors.success(`✔ `), `Removed "${args.name}"`);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
Colors.line(Colors.danger(`✖ `), `"${args.name}" is not set`);
|
|
22
|
+
}
|
|
21
23
|
});
|
|
@@ -3,12 +3,12 @@ import { list } from "./list.js";
|
|
|
3
3
|
import { remove } from "./remove.js";
|
|
4
4
|
import { set } from "./set.js";
|
|
5
5
|
export function secrets(program) {
|
|
6
|
-
program.command("secrets", "Manage secrets", (yargs) => {
|
|
6
|
+
program.command("secrets", "Manage the secrets in your app", (yargs) => {
|
|
7
7
|
yargs.demandCommand(1);
|
|
8
|
-
|
|
8
|
+
set(yargs);
|
|
9
9
|
get(yargs);
|
|
10
10
|
list(yargs);
|
|
11
|
-
|
|
11
|
+
remove(yargs);
|
|
12
12
|
return yargs;
|
|
13
13
|
});
|
|
14
14
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
|
-
import { Program } from "../../program.js";
|
|
3
|
-
export declare const set: (program: Program) => import("yargs").Argv<
|
|
2
|
+
import type { Program } from "../../program.js";
|
|
3
|
+
export declare const set: (program: Program) => import("yargs").Argv<{
|
|
4
4
|
stage: string | undefined;
|
|
5
5
|
} & {
|
|
6
6
|
profile: string | undefined;
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
9
|
} & {
|
|
10
|
-
|
|
10
|
+
verbose: boolean | undefined;
|
|
11
|
+
} & {
|
|
12
|
+
role: string | undefined;
|
|
11
13
|
} & {
|
|
12
|
-
value: string;
|
|
13
|
-
}, "name"> & {
|
|
14
14
|
name: string;
|
|
15
|
-
}
|
|
15
|
+
} & {
|
|
16
16
|
value: string;
|
|
17
|
+
} & {
|
|
18
|
+
fallback: boolean | undefined;
|
|
17
19
|
}>;
|
|
@@ -1,46 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import { blue } from "colorette";
|
|
3
|
-
import { createSpinner } from "../../spinner.js";
|
|
4
|
-
export const set = (program) => program
|
|
5
|
-
.command("set <name> <value>", "Set secret value", yargs => yargs
|
|
1
|
+
export const set = (program) => program.command("set <name> <value>", "Set the value of a secret", (yargs) => yargs
|
|
6
2
|
.positional("name", {
|
|
7
3
|
type: "string",
|
|
8
|
-
describe: "Name of secret",
|
|
9
|
-
demandOption: true
|
|
4
|
+
describe: "Name of the secret",
|
|
5
|
+
demandOption: true,
|
|
10
6
|
})
|
|
11
7
|
.positional("value", {
|
|
12
8
|
type: "string",
|
|
13
|
-
describe: "Value
|
|
14
|
-
demandOption: true
|
|
15
|
-
}), async (args) => {
|
|
16
|
-
const setting = createSpinner(`Setting secret ${blue(args.name)}`).start();
|
|
17
|
-
await Config.setSecret({
|
|
18
|
-
key: args.name,
|
|
19
|
-
value: args.value
|
|
20
|
-
});
|
|
21
|
-
setting.succeed();
|
|
22
|
-
const restarting = createSpinner(`Restarting all functions using ${blue(args.name)}...`).start();
|
|
23
|
-
const count = await Config.restart(args.name);
|
|
24
|
-
restarting.succeed(`Restarted ${blue(count)} functions`);
|
|
9
|
+
describe: "Value of the secret",
|
|
10
|
+
demandOption: true,
|
|
25
11
|
})
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
describe: "Name of secret",
|
|
30
|
-
demandOption: true
|
|
31
|
-
})
|
|
32
|
-
.positional("value", {
|
|
33
|
-
type: "string",
|
|
34
|
-
describe: "Value to set",
|
|
35
|
-
demandOption: true
|
|
12
|
+
.option("fallback", {
|
|
13
|
+
type: "boolean",
|
|
14
|
+
describe: "Set the fallback value",
|
|
36
15
|
}), async (args) => {
|
|
37
|
-
|
|
16
|
+
const { Config } = await import("../../../config.js");
|
|
17
|
+
const { blue } = await import("colorette");
|
|
18
|
+
const { createSpinner } = await import("../../spinner.js");
|
|
19
|
+
const setting = createSpinner(` Setting "${args.name}"`).start();
|
|
38
20
|
await Config.setSecret({
|
|
39
21
|
key: args.name,
|
|
40
22
|
value: args.value,
|
|
41
|
-
fallback: true
|
|
23
|
+
fallback: args.fallback === true,
|
|
42
24
|
});
|
|
43
|
-
|
|
25
|
+
setting.succeed();
|
|
26
|
+
const restarting = createSpinner(` Restarting all functions using ${blue(args.name)}...`).start();
|
|
44
27
|
const count = await Config.restart(args.name);
|
|
45
|
-
|
|
28
|
+
restarting.succeed(` Restarted ${count} functions`);
|
|
46
29
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
import type { Program } from "../program.js";
|
|
3
|
+
export declare const telemetry: (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
|
+
} & {
|
|
14
|
+
action: string;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Colors } from "../colors.js";
|
|
2
|
+
export const telemetry = (program) => program.command("telemetry <action>", "Load environment variables and start your frontend", (yargs) => yargs.positional("action", {
|
|
3
|
+
type: "string",
|
|
4
|
+
describe: "Whether to enable or disable",
|
|
5
|
+
choices: ["enable", "disable"],
|
|
6
|
+
demandOption: true,
|
|
7
|
+
}), async (args) => {
|
|
8
|
+
const { enable, disable } = await import("../telemetry/telemetry.js");
|
|
9
|
+
if (args.action === "enable") {
|
|
10
|
+
enable();
|
|
11
|
+
Colors.line(Colors.success(`✔ `), `Telemetry enabled`);
|
|
12
|
+
}
|
|
13
|
+
if (args.action === "disable") {
|
|
14
|
+
disable();
|
|
15
|
+
Colors.line(Colors.success(`✔ `), `Telemetry disabled`);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="yargs" />
|
|
2
|
+
import type { Program } from "../program.js";
|
|
3
|
+
export declare const transform: (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
|
+
} & {
|
|
14
|
+
mod: string;
|
|
15
|
+
}>;
|