sst 2.0.0-rc.26 → 2.0.0-rc.29
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 -2
- package/bootstrap.js +28 -10
- package/cli/commands/bind.js +8 -5
- package/cli/commands/build.d.ts +2 -2
- package/cli/commands/build.js +7 -3
- package/cli/commands/console.d.ts +1 -1
- package/cli/commands/console.js +4 -4
- package/cli/commands/deploy.js +24 -14
- package/cli/commands/dev.js +26 -21
- package/cli/commands/diff.d.ts +1 -1
- package/cli/commands/diff.js +10 -11
- package/cli/commands/env.d.ts +1 -1
- package/cli/commands/env.js +10 -9
- package/cli/commands/remove.d.ts +2 -0
- package/cli/commands/remove.js +27 -7
- package/cli/commands/secrets/get.d.ts +3 -3
- package/cli/commands/secrets/get.js +8 -21
- package/cli/commands/secrets/list.d.ts +2 -2
- package/cli/commands/secrets/list.js +10 -7
- package/cli/commands/secrets/remove.d.ts +4 -4
- package/cli/commands/secrets/remove.js +8 -13
- package/cli/commands/secrets/secrets.js +4 -7
- package/cli/commands/secrets/set.d.ts +4 -6
- package/cli/commands/secrets/set.js +14 -31
- package/cli/commands/update.d.ts +2 -2
- package/cli/commands/update.js +24 -24
- package/cli/commands/version.d.ts +11 -0
- package/cli/commands/version.js +37 -0
- package/cli/program.js +18 -5
- package/cli/sst.js +14 -22
- package/cli/ui/deploy.js +7 -4
- package/logger.js +1 -1
- package/package.json +1 -1
- package/project.d.ts +1 -1
- package/project.js +3 -7
- package/runtime/handlers/node.js +4 -1
- package/sst.mjs +5146 -5155
- package/stacks/monitor.js +2 -1
- package/stacks/synth.js +2 -2
package/bootstrap.d.ts
CHANGED
package/bootstrap.js
CHANGED
|
@@ -23,10 +23,8 @@ const LATEST_VERSION = "4";
|
|
|
23
23
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
24
24
|
export const useBootstrap = Context.memo(async () => {
|
|
25
25
|
Logger.debug("Initializing bootstrap context");
|
|
26
|
-
|
|
27
|
-
if (!
|
|
28
|
-
!ret.bucket ||
|
|
29
|
-
ret.version !== LATEST_VERSION) {
|
|
26
|
+
let status = await loadBootstrapStatus();
|
|
27
|
+
if (!status || status.version !== LATEST_VERSION) {
|
|
30
28
|
const project = useProject();
|
|
31
29
|
const spinner = createSpinner("Deploying bootstrap stack, this only needs to happen once").start();
|
|
32
30
|
// Create bootstrap stack
|
|
@@ -89,22 +87,39 @@ export const useBootstrap = Context.memo(async () => {
|
|
|
89
87
|
// Create stack outputs to store bootstrap stack info
|
|
90
88
|
new CfnOutput(stack, OUTPUT_VERSION, { value: LATEST_VERSION });
|
|
91
89
|
new CfnOutput(stack, OUTPUT_BUCKET, { value: bucket.bucketName });
|
|
90
|
+
// Deploy bootstrap stack
|
|
92
91
|
const asm = app.synth();
|
|
93
92
|
const result = await Stacks.deploy(asm.stacks[0]);
|
|
94
93
|
if (Stacks.isFailed(result.status)) {
|
|
95
94
|
throw new VisibleError(`Failed to deploy bootstrap stack:\n${JSON.stringify(result.errors, null, 4)}`);
|
|
96
95
|
}
|
|
97
96
|
spinner.succeed();
|
|
98
|
-
|
|
97
|
+
// Fetch bootstrap status
|
|
98
|
+
status = await loadBootstrapStatus();
|
|
99
|
+
if (!status) {
|
|
100
|
+
throw new VisibleError("Failed to deploy bootstrap stack");
|
|
101
|
+
}
|
|
99
102
|
}
|
|
100
|
-
Logger.debug("Loaded bootstrap info: ", JSON.stringify(
|
|
101
|
-
return
|
|
103
|
+
Logger.debug("Loaded bootstrap info: ", JSON.stringify(status));
|
|
104
|
+
return status;
|
|
102
105
|
});
|
|
103
106
|
async function loadBootstrapStatus() {
|
|
107
|
+
// Get bootstrap CloudFormation stack
|
|
104
108
|
const cf = useAWSClient(CloudFormationClient);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
let result;
|
|
110
|
+
try {
|
|
111
|
+
result = await cf.send(new DescribeStacksCommand({
|
|
112
|
+
StackName: STACK_NAME,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
if (e.Code === "ValidationError"
|
|
117
|
+
&& e.message === `Stack with id ${STACK_NAME} does not exist`) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
throw e;
|
|
121
|
+
}
|
|
122
|
+
// Parse stack outputs
|
|
108
123
|
let version, bucket;
|
|
109
124
|
(result.Stacks[0].Outputs || []).forEach((o) => {
|
|
110
125
|
if (o.OutputKey === OUTPUT_VERSION) {
|
|
@@ -114,5 +129,8 @@ async function loadBootstrapStatus() {
|
|
|
114
129
|
bucket = o.OutputValue;
|
|
115
130
|
}
|
|
116
131
|
});
|
|
132
|
+
if (!version || !bucket) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
117
135
|
return { version, bucket };
|
|
118
136
|
}
|
package/cli/commands/bind.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export const bind = (program) => program.command("bind <command>", "Bind your app's resources to a command", (yargs) => yargs
|
|
2
|
+
.positional("command", {
|
|
3
3
|
type: "string",
|
|
4
|
-
describe: "
|
|
4
|
+
describe: "The command to bind to",
|
|
5
5
|
demandOption: true,
|
|
6
|
-
})
|
|
6
|
+
})
|
|
7
|
+
.example(`sst bind "vitest run"`, "Bind your resources to your tests")
|
|
8
|
+
.example(`sst bind "tsx scripts/myscript.ts"`, "Bind your resources to a script"), async (args) => {
|
|
7
9
|
const { Config } = await import("../../config.js");
|
|
8
|
-
const { spawnSync
|
|
10
|
+
const { spawnSync } = await import("child_process");
|
|
9
11
|
const { useAWSCredentials } = await import("../../credentials.js");
|
|
12
|
+
const { useProject } = await import("../../project.js");
|
|
10
13
|
const env = await Config.env();
|
|
11
14
|
const project = useProject();
|
|
12
15
|
const credentials = await useAWSCredentials();
|
package/cli/commands/build.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 build: (program: Program) => import("yargs").Argv<{
|
|
4
4
|
stage: string | undefined;
|
|
5
5
|
} & {
|
|
@@ -7,5 +7,5 @@ export declare const build: (program: Program) => import("yargs").Argv<{
|
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
9
|
} & {
|
|
10
|
-
|
|
10
|
+
to: string | undefined;
|
|
11
11
|
}>;
|
package/cli/commands/build.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export const build = (program) => program.command("build", "Build your app", (yargs) => yargs.option("to", {
|
|
2
|
+
type: "string",
|
|
3
|
+
describe: "Output directory, defaults to .sst/dist",
|
|
4
|
+
}), async (args) => {
|
|
5
|
+
const { useProject } = await import("../../project.js");
|
|
6
|
+
const { createSpinner } = await import("../spinner.js");
|
|
4
7
|
const { Stacks } = await import("../../stacks/index.js");
|
|
5
8
|
const spinner = createSpinner("Building stacks").start();
|
|
6
9
|
await Stacks.synth({
|
|
7
10
|
fn: useProject().stacks,
|
|
11
|
+
buildDir: args.to,
|
|
8
12
|
mode: "deploy",
|
|
9
13
|
});
|
|
10
14
|
spinner.succeed();
|
package/cli/commands/console.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const consoleCommand = async (program) => program.command("console", "Start the SST Console", (yargs) => yargs, async () => {
|
|
2
|
+
const { blue } = await import("colorette");
|
|
3
|
+
const { useRuntimeServer } = await import("../../runtime/server.js");
|
|
4
|
+
const { useLocalServer } = await import("../local/server.js");
|
|
5
5
|
await Promise.all([
|
|
6
6
|
useRuntimeServer(),
|
|
7
7
|
useLocalServer({
|
package/cli/commands/deploy.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const deploy = (program) => program.command("deploy [filter]", "Deploy your app to AWS", (yargs) => yargs
|
|
2
|
+
.option("from", {
|
|
3
|
+
type: "string",
|
|
4
|
+
describe: "Deploy using previously built output",
|
|
5
|
+
})
|
|
5
6
|
.option("fullscreen", {
|
|
6
7
|
type: "boolean",
|
|
7
8
|
describe: "Disable full screen UI",
|
|
8
9
|
default: true,
|
|
9
10
|
})
|
|
10
|
-
.positional("filter", {
|
|
11
|
+
.positional("filter", {
|
|
12
|
+
type: "string",
|
|
13
|
+
describe: "Optionally filter stacks to deploy",
|
|
14
|
+
}), async (args) => {
|
|
11
15
|
const React = await import("react");
|
|
16
|
+
const { printDeploymentResults } = await import("../ui/deploy.js");
|
|
17
|
+
const { createSpinner } = await import("../spinner.js");
|
|
12
18
|
const { CloudAssembly } = await import("aws-cdk-lib/cx-api");
|
|
13
19
|
const { blue, bold } = await import("colorette");
|
|
14
20
|
const { useProject } = await import("../../project.js");
|
|
@@ -34,18 +40,22 @@ export const deploy = (program) => program.command("deploy [filter]", "Work on y
|
|
|
34
40
|
if (!target.length) {
|
|
35
41
|
console.log(`No stacks found matching ${blue(args.filter)}`);
|
|
36
42
|
process.exit(1);
|
|
37
|
-
return;
|
|
38
43
|
}
|
|
39
44
|
console.log(`Deploying ${bold(target.length + " stacks")} for stage ${blue(project.config.stage)}...`);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
const cleanup = (() => {
|
|
46
|
+
if (args.fullscreen) {
|
|
47
|
+
process.stdout.write("\x1b[?1049h");
|
|
48
|
+
const component = render(React.createElement(DeploymentUI, { stacks: assembly.stacks.map((s) => s.stackName) }));
|
|
49
|
+
return () => {
|
|
50
|
+
component.unmount();
|
|
51
|
+
process.stdout.write("\x1b[?1049l");
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const spinner = createSpinner("Deploying stacks");
|
|
55
|
+
return () => spinner.succeed();
|
|
56
|
+
})();
|
|
45
57
|
const results = await Stacks.deployMany(target);
|
|
46
|
-
|
|
47
|
-
component.unmount();
|
|
48
|
-
process.stdout.write("\x1b[?1049l");
|
|
58
|
+
cleanup();
|
|
49
59
|
printDeploymentResults(results);
|
|
50
60
|
if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
|
|
51
61
|
process.exit(1);
|
package/cli/commands/dev.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import crypto from "crypto";
|
|
4
|
-
import { printDeploymentResults } from "../ui/deploy.js";
|
|
5
|
-
import { useFunctions } from "../../constructs/Function.js";
|
|
6
|
-
import { dim, gray, yellow } from "colorette";
|
|
7
|
-
import { SiteEnv } from "../../site-env.js";
|
|
8
|
-
import { usePothosBuilder } from "./plugins/pothos.js";
|
|
9
|
-
import { useKyselyTypeGenerator } from "./plugins/kysely.js";
|
|
10
|
-
import { useRDSWarmer } from "./plugins/warmer.js";
|
|
11
|
-
import { useProject } from "../../project.js";
|
|
12
|
-
import { useMetadata } from "../../stacks/metadata.js";
|
|
13
|
-
export const dev = (program) => program.command(["start", "dev"], "Work on your SST app locally", (yargs) => yargs.option("fullscreen", {
|
|
1
|
+
export const dev = (program) => program.command(["dev", "start"], "Work on your app locally", (yargs) => yargs.option("fullscreen", {
|
|
14
2
|
type: "boolean",
|
|
15
3
|
describe: "Disable full screen UI",
|
|
16
4
|
default: true,
|
|
@@ -29,6 +17,18 @@ export const dev = (program) => program.command(["start", "dev"], "Work on your
|
|
|
29
17
|
const { Context } = await import("../../context/context.js");
|
|
30
18
|
const { DeploymentUI } = await import("../ui/deploy.js");
|
|
31
19
|
const { useLocalServer } = await import("../local/server.js");
|
|
20
|
+
const path = await import("path");
|
|
21
|
+
const fs = await import("fs/promises");
|
|
22
|
+
const crypto = await import("crypto");
|
|
23
|
+
const { printDeploymentResults } = await import("../ui/deploy.js");
|
|
24
|
+
const { useFunctions } = await import("../../constructs/Function.js");
|
|
25
|
+
const { dim, gray, yellow } = await import("colorette");
|
|
26
|
+
const { SiteEnv } = await import("../../site-env.js");
|
|
27
|
+
const { usePothosBuilder } = await import("./plugins/pothos.js");
|
|
28
|
+
const { useKyselyTypeGenerator } = await import("./plugins/kysely.js");
|
|
29
|
+
const { useRDSWarmer } = await import("./plugins/warmer.js");
|
|
30
|
+
const { useProject } = await import("../../project.js");
|
|
31
|
+
const { useMetadata } = await import("../../stacks/metadata.js");
|
|
32
32
|
if (args._[0] === "start") {
|
|
33
33
|
console.log(yellow(`Warning: ${bold(`sst start`)} has been renamed to ${bold(`sst dev`)}`));
|
|
34
34
|
}
|
|
@@ -108,15 +108,20 @@ export const dev = (program) => program.command(["start", "dev"], "Work on your
|
|
|
108
108
|
const assembly = pending;
|
|
109
109
|
const nextChecksum = await checksum(assembly.directory);
|
|
110
110
|
pending = undefined;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
const cleanup = (() => {
|
|
112
|
+
if (args.fullscreen) {
|
|
113
|
+
process.stdout.write("\x1b[?1049h");
|
|
114
|
+
const component = render(React.createElement(DeploymentUI, { stacks: assembly.stacks.map((s) => s.stackName) }));
|
|
115
|
+
return () => {
|
|
116
|
+
component.unmount();
|
|
117
|
+
process.stdout.write("\x1b[?1049l");
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const spinner = createSpinner("Deploying stacks");
|
|
121
|
+
return () => spinner.succeed();
|
|
122
|
+
})();
|
|
116
123
|
const results = await Stacks.deployMany(assembly.stacks);
|
|
117
|
-
|
|
118
|
-
component.unmount();
|
|
119
|
-
process.stdout.write("\x1b[?1049l");
|
|
124
|
+
cleanup();
|
|
120
125
|
lastDeployed = nextChecksum;
|
|
121
126
|
printDeploymentResults(results);
|
|
122
127
|
const keys = await SiteEnv.keys();
|
package/cli/commands/diff.d.ts
CHANGED
package/cli/commands/diff.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { useAWSClient } from "../../credentials.js";
|
|
5
|
-
import { CloudFormationClient, GetTemplateCommand, } from "@aws-sdk/client-cloudformation";
|
|
6
|
-
import { createSpinner } from "../spinner.js";
|
|
7
|
-
export const diff = (program) => program.command("diff", "", (yargs) => yargs.option("mode", {
|
|
8
|
-
type: "string",
|
|
9
|
-
describe: "deploy or dev",
|
|
10
|
-
default: "deploy",
|
|
1
|
+
export const diff = (program) => program.command("diff", "Compare your app with what is deployed on AWS", (yargs) => yargs.option("dev", {
|
|
2
|
+
type: "boolean",
|
|
3
|
+
describe: "Compare in dev mode",
|
|
11
4
|
}), async (args) => {
|
|
5
|
+
const { printStackDiff } = await import("aws-cdk/lib/diff.js");
|
|
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");
|
|
12
11
|
const spinner = createSpinner("Building stacks");
|
|
13
12
|
const project = useProject();
|
|
14
13
|
const assembly = await Stacks.synth({
|
|
15
14
|
fn: project.stacks,
|
|
16
|
-
mode: args.
|
|
15
|
+
mode: args.dev ? "dev" : "deploy",
|
|
17
16
|
});
|
|
18
17
|
spinner.succeed();
|
|
19
18
|
const cfn = useAWSClient(CloudFormationClient);
|
package/cli/commands/env.d.ts
CHANGED
package/cli/commands/env.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import fs from "fs/promises";
|
|
4
|
-
import { SiteEnv } from "../../site-env.js";
|
|
5
|
-
import { spawnSync } from "child_process";
|
|
6
|
-
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", {
|
|
7
3
|
type: "string",
|
|
8
|
-
describe: "
|
|
4
|
+
describe: "The command to start your frontend",
|
|
9
5
|
demandOption: true,
|
|
10
|
-
})
|
|
11
|
-
|
|
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");
|
|
12
13
|
let spinner;
|
|
13
14
|
while (true) {
|
|
14
15
|
const exists = await fs
|
package/cli/commands/remove.d.ts
CHANGED
package/cli/commands/remove.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export const remove = (program) => program.command("remove [filter]", "Remove all stacks for this app", (yargs) => yargs
|
|
1
|
+
export const remove = (program) => program.command("remove [filter]", "Remove your app from AWS", (yargs) => yargs
|
|
3
2
|
.option("from", { type: "string" })
|
|
4
|
-
.
|
|
3
|
+
.option("fullscreen", {
|
|
4
|
+
type: "boolean",
|
|
5
|
+
describe: "Disable full screen UI",
|
|
6
|
+
default: true,
|
|
7
|
+
})
|
|
8
|
+
.positional("filter", {
|
|
9
|
+
type: "string",
|
|
10
|
+
describe: "Optionally filter stacks to remove",
|
|
11
|
+
}), async (args) => {
|
|
5
12
|
const React = await import("react");
|
|
6
13
|
const { CloudAssembly } = await import("aws-cdk-lib/cx-api");
|
|
7
14
|
const { blue, bold } = await import("colorette");
|
|
@@ -9,6 +16,8 @@ export const remove = (program) => program.command("remove [filter]", "Remove al
|
|
|
9
16
|
const { Stacks } = await import("../../stacks/index.js");
|
|
10
17
|
const { render } = await import("ink");
|
|
11
18
|
const { DeploymentUI } = await import("../ui/deploy.js");
|
|
19
|
+
const { printDeploymentResults } = await import("../ui/deploy.js");
|
|
20
|
+
const { createSpinner } = await import("../spinner.js");
|
|
12
21
|
const assembly = await (async function () {
|
|
13
22
|
if (args.from) {
|
|
14
23
|
const result = new CloudAssembly(args.from);
|
|
@@ -28,11 +37,22 @@ export const remove = (program) => program.command("remove [filter]", "Remove al
|
|
|
28
37
|
process.exit(1);
|
|
29
38
|
}
|
|
30
39
|
console.log(`Removing ${bold(target.length + " stacks")} for stage ${blue(project.config.stage)}...`);
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
const cleanup = (() => {
|
|
41
|
+
if (args.fullscreen) {
|
|
42
|
+
process.stdout.write("\x1b[?1049h");
|
|
43
|
+
const component = render(React.createElement(DeploymentUI, { stacks: assembly.stacks.map((s) => s.stackName) }));
|
|
44
|
+
return () => {
|
|
45
|
+
component.unmount();
|
|
46
|
+
process.stdout.write("\x1b[?1049l");
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const spinner = createSpinner("Removing stacks");
|
|
50
|
+
return () => spinner.succeed();
|
|
51
|
+
})();
|
|
33
52
|
const results = await Stacks.removeMany(target);
|
|
34
|
-
|
|
35
|
-
process.stdout.write("\x1b[?1049l");
|
|
53
|
+
cleanup();
|
|
36
54
|
printDeploymentResults(results);
|
|
55
|
+
if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
|
|
56
|
+
process.exit(1);
|
|
37
57
|
process.exit(0);
|
|
38
58
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
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;
|
|
@@ -8,6 +8,6 @@ export declare const get: (program: Program) => import("yargs").Argv<import("yar
|
|
|
8
8
|
region: string | undefined;
|
|
9
9
|
} & {
|
|
10
10
|
name: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
} & {
|
|
12
|
+
fallback: boolean | undefined;
|
|
13
13
|
}>;
|
|
@@ -1,33 +1,20 @@
|
|
|
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
13
|
const { bold } = await import("colorette");
|
|
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
19
|
console.log(bold(result));
|
|
33
20
|
}
|
|
@@ -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,5 @@ export declare const list: (program: Program) => import("yargs").Argv<{
|
|
|
7
7
|
} & {
|
|
8
8
|
region: string | undefined;
|
|
9
9
|
} & {
|
|
10
|
-
format: string;
|
|
10
|
+
format: string | undefined;
|
|
11
11
|
}>;
|
|
@@ -1,8 +1,11 @@
|
|
|
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");
|
|
4
7
|
const secrets = await Config.secrets();
|
|
5
|
-
switch (args.format) {
|
|
8
|
+
switch (args.format || "table") {
|
|
6
9
|
case "env":
|
|
7
10
|
for (const [key, value] of Object.entries(secrets)) {
|
|
8
11
|
console.log(`${key}=${value.value || value.fallback}`);
|
|
@@ -10,8 +13,8 @@ export const list = (program) => program.command("list [format]", "Fetch and dec
|
|
|
10
13
|
break;
|
|
11
14
|
case "table":
|
|
12
15
|
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
|
|
16
|
+
const keyLen = Math.max("Secrets".length, ...keys.map((key) => key.length));
|
|
17
|
+
const valueLen = Math.max("Values".length, ...keys.map((key) => secrets[key].value
|
|
15
18
|
? secrets[key].value.length
|
|
16
19
|
: `${secrets[key].fallback} (fallback)`.length));
|
|
17
20
|
console.log("┌".padEnd(keyLen + 3, "─") +
|
|
@@ -23,7 +26,7 @@ export const list = (program) => program.command("list [format]", "Fetch and dec
|
|
|
23
26
|
"┼" +
|
|
24
27
|
"".padEnd(valueLen + 2, "─") +
|
|
25
28
|
"┤");
|
|
26
|
-
keys.sort().forEach(key => {
|
|
29
|
+
keys.sort().forEach((key) => {
|
|
27
30
|
const value = secrets[key].value
|
|
28
31
|
? secrets[key].value
|
|
29
32
|
: `${secrets[key].fallback} ${gray("(fallback)")}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
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;
|
|
@@ -8,6 +8,6 @@ export declare const remove: (program: Program) => import("yargs").Argv<import("
|
|
|
8
8
|
region: string | undefined;
|
|
9
9
|
} & {
|
|
10
10
|
name: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
} & {
|
|
12
|
+
fallback: boolean | undefined;
|
|
13
13
|
}>;
|
|
@@ -1,21 +1,16 @@
|
|
|
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) => {
|
|
11
|
+
const { Config } = await import("../../../config.js");
|
|
17
12
|
await Config.removeSecret({
|
|
18
13
|
key: args.name,
|
|
19
|
-
fallback: true,
|
|
14
|
+
fallback: args.fallback === true,
|
|
20
15
|
});
|
|
21
16
|
});
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { get } from "./get.js";
|
|
2
|
-
import { list } from "./list.js";
|
|
3
|
-
import { remove } from "./remove.js";
|
|
4
1
|
import { set } from "./set.js";
|
|
5
2
|
export function secrets(program) {
|
|
6
|
-
program.command("secrets", "Manage secrets", (yargs) => {
|
|
3
|
+
program.command("secrets", "Manage the secrets in your app", (yargs) => {
|
|
7
4
|
yargs.demandCommand(1);
|
|
8
|
-
remove(yargs);
|
|
9
|
-
get(yargs);
|
|
10
|
-
list(yargs);
|
|
11
5
|
set(yargs);
|
|
6
|
+
// get(yargs);
|
|
7
|
+
// list(yargs);
|
|
8
|
+
// remove(yargs);
|
|
12
9
|
return yargs;
|
|
13
10
|
});
|
|
14
11
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
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;
|
|
@@ -10,8 +10,6 @@ export declare const set: (program: Program) => import("yargs").Argv<import("yar
|
|
|
10
10
|
name: string;
|
|
11
11
|
} & {
|
|
12
12
|
value: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
}, "value"> & {
|
|
16
|
-
value: string;
|
|
13
|
+
} & {
|
|
14
|
+
fallback: boolean | undefined;
|
|
17
15
|
}>;
|