sst 2.2.8 → 2.3.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/cli/commands/bind.js +191 -19
- package/cli/commands/dev.js +2 -17
- package/cli/commands/secrets/set.js +22 -5
- package/cli/sst.js +0 -2
- package/cli/ui/deploy.d.ts +1 -1
- package/cli/ui/deploy.js +3 -6
- package/cli/ui/functions.d.ts +1 -1
- package/config.d.ts +14 -1
- package/config.js +68 -31
- package/constructs/App.d.ts +2 -2
- package/constructs/App.js +2 -4
- package/constructs/AstroSite.d.ts +1 -0
- package/constructs/AstroSite.js +1 -0
- package/constructs/Function.d.ts +1 -1
- package/constructs/Metadata.d.ts +5 -1
- package/constructs/NextjsSite.d.ts +1 -0
- package/constructs/NextjsSite.js +1 -0
- package/constructs/RemixSite.d.ts +1 -0
- package/constructs/RemixSite.js +1 -0
- package/constructs/SolidStartSite.d.ts +1 -0
- package/constructs/SolidStartSite.js +1 -0
- package/constructs/SsrSite.d.ts +15 -7
- package/constructs/SsrSite.js +52 -21
- package/constructs/StaticSite.d.ts +2 -1
- package/constructs/StaticSite.js +3 -15
- package/constructs/deprecated/NextjsSite.d.ts +5 -2
- package/constructs/deprecated/NextjsSite.js +4 -16
- package/constructs/deprecated/cross-region-helper.js +3 -3
- package/package.json +1 -1
- package/sst.mjs +350 -268
- package/stacks/metadata.d.ts +0 -1
- package/stacks/metadata.js +1 -26
- package/stacks/monitor.js +1 -0
- package/support/bootstrap-metadata-function/index.mjs +2 -2
- package/cli/commands/env.d.ts +0 -15
- package/cli/commands/env.js +0 -48
- package/site-env.d.ts +0 -13
- package/site-env.js +0 -48
package/stacks/metadata.d.ts
CHANGED
package/stacks/metadata.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useBootstrap } from "../bootstrap.js";
|
|
2
|
-
import { useAWSCredentials,
|
|
2
|
+
import { useAWSCredentials, } from "../credentials.js";
|
|
3
3
|
import { S3Client, GetObjectCommand, ListObjectsV2Command, } from "@aws-sdk/client-s3";
|
|
4
4
|
import { useCache } from "../cache.js";
|
|
5
5
|
import { Context } from "../context/context.js";
|
|
@@ -34,31 +34,6 @@ export async function metadata() {
|
|
|
34
34
|
Logger.debug("Fetched metadata from", list.KeyCount, "stacks");
|
|
35
35
|
return result;
|
|
36
36
|
}
|
|
37
|
-
export async function metadataForStack(stackID) {
|
|
38
|
-
const [project, credentials, bootstrap] = await Promise.all([
|
|
39
|
-
useProject(),
|
|
40
|
-
useAWSCredentialsProvider(),
|
|
41
|
-
useBootstrap(),
|
|
42
|
-
]);
|
|
43
|
-
const s3 = new S3Client({
|
|
44
|
-
region: project.config.region,
|
|
45
|
-
credentials: credentials,
|
|
46
|
-
});
|
|
47
|
-
const key = `stackMetadata/app.${project.config.name}/stage.${project.config.stage}/stack.${stackID}.json`;
|
|
48
|
-
Logger.debug("Getting metadata", key, "from", bootstrap.bucket);
|
|
49
|
-
try {
|
|
50
|
-
const result = await s3.send(new GetObjectCommand({
|
|
51
|
-
Key: key,
|
|
52
|
-
Bucket: bootstrap.bucket,
|
|
53
|
-
}));
|
|
54
|
-
const body = await result.Body.transformToString();
|
|
55
|
-
return JSON.parse(body);
|
|
56
|
-
}
|
|
57
|
-
catch (ex) {
|
|
58
|
-
console.error(ex);
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
37
|
const MetadataContext = Context.create(async () => {
|
|
63
38
|
const bus = useBus();
|
|
64
39
|
const cache = await useCache();
|
package/stacks/monitor.js
CHANGED
|
@@ -60577,10 +60577,10 @@ async function processRecord(record) {
|
|
|
60577
60577
|
const stackName = stack.split("/")[1];
|
|
60578
60578
|
if (stackStatus === "DELETE_COMPLETE") {
|
|
60579
60579
|
await deleteMetadata(stackName, app, stage);
|
|
60580
|
-
await sendIotEvent(app, stage, `stacks.metadata.
|
|
60580
|
+
await sendIotEvent(app, stage, `stacks.metadata.deleted`);
|
|
60581
60581
|
} else {
|
|
60582
60582
|
await saveMetadata(stackName, app, stage, metadata);
|
|
60583
|
-
await sendIotEvent(app, stage, `stacks.metadata.
|
|
60583
|
+
await sendIotEvent(app, stage, `stacks.metadata.updated`);
|
|
60584
60584
|
}
|
|
60585
60585
|
}
|
|
60586
60586
|
__name(processRecord, "processRecord");
|
package/cli/commands/env.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="yargs" />
|
|
2
|
-
import type { Program } from "../program.js";
|
|
3
|
-
export declare const env: (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
|
-
command: (string | number)[] | undefined;
|
|
15
|
-
}>;
|
package/cli/commands/env.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { VisibleError } from "../../error.js";
|
|
2
|
-
export const env = (program) => program
|
|
3
|
-
.command("env <command..>", "Load environment variables and start your frontend", (yargs) => yargs
|
|
4
|
-
.array("command")
|
|
5
|
-
.example(`sst env "next dev"`, "Start Next.js with your environment variables")
|
|
6
|
-
.example(`sst env "vite dev"`, "Start Vite with your environment variables"), async (args) => {
|
|
7
|
-
const { createSpinner } = await import("../spinner.js");
|
|
8
|
-
const fs = await import("fs/promises");
|
|
9
|
-
const { SiteEnv } = await import("../../site-env.js");
|
|
10
|
-
const { spawnSync } = await import("child_process");
|
|
11
|
-
const { useAWSCredentials } = await import("../../credentials.js");
|
|
12
|
-
const { useProject } = await import("../../project.js");
|
|
13
|
-
let spinner;
|
|
14
|
-
while (true) {
|
|
15
|
-
const exists = await fs
|
|
16
|
-
.access(SiteEnv.valuesFile())
|
|
17
|
-
.then(() => true)
|
|
18
|
-
.catch(() => false);
|
|
19
|
-
if (!exists) {
|
|
20
|
-
spinner = createSpinner("Cannot find SST environment variables. Waiting for SST to start...").start();
|
|
21
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
spinner?.succeed();
|
|
25
|
-
const sites = await SiteEnv.values();
|
|
26
|
-
const env = sites[process.cwd()] || {};
|
|
27
|
-
const project = useProject();
|
|
28
|
-
const credentials = await useAWSCredentials();
|
|
29
|
-
const joined = args.command?.join(" ");
|
|
30
|
-
if (!joined)
|
|
31
|
-
throw new VisibleError("Command is required, e.g. sst env vite dev");
|
|
32
|
-
const result = spawnSync(joined, {
|
|
33
|
-
env: {
|
|
34
|
-
...process.env,
|
|
35
|
-
...env,
|
|
36
|
-
AWS_ACCESS_KEY_ID: credentials.accessKeyId,
|
|
37
|
-
AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
|
|
38
|
-
AWS_SESSION_TOKEN: credentials.sessionToken,
|
|
39
|
-
AWS_REGION: project.config.region,
|
|
40
|
-
},
|
|
41
|
-
stdio: "inherit",
|
|
42
|
-
shell: true,
|
|
43
|
-
});
|
|
44
|
-
process.exitCode = result.status || undefined;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
.strict(false);
|
package/site-env.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * as SiteEnv from "./site-env.js";
|
|
2
|
-
export declare function valuesFile(): string;
|
|
3
|
-
interface Key {
|
|
4
|
-
path: string;
|
|
5
|
-
output: string;
|
|
6
|
-
environment: string;
|
|
7
|
-
stack: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function keys(): Promise<Key[]>;
|
|
10
|
-
export declare function values(): Promise<Record<string, Record<string, string>>>;
|
|
11
|
-
export declare function writeValues(input: Record<string, Record<string, string>>): Promise<void>;
|
|
12
|
-
export declare function append(input: Key): void;
|
|
13
|
-
export declare function reset(): void;
|
package/site-env.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export * as SiteEnv from "./site-env.js";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { useProject } from "./project.js";
|
|
5
|
-
function keysFile() {
|
|
6
|
-
return path.join(useProject().paths.out, "site-environment-keys.jsonl");
|
|
7
|
-
}
|
|
8
|
-
export function valuesFile() {
|
|
9
|
-
return path.join(useProject().paths.out, "site-environment-values.json");
|
|
10
|
-
}
|
|
11
|
-
export async function keys() {
|
|
12
|
-
try {
|
|
13
|
-
const file = keysFile();
|
|
14
|
-
const data = await fs.promises
|
|
15
|
-
.readFile(file)
|
|
16
|
-
.then((x) => x.toString().split("\n"));
|
|
17
|
-
return data.filter(Boolean).map((x) => JSON.parse(x));
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export async function values() {
|
|
24
|
-
try {
|
|
25
|
-
const file = valuesFile();
|
|
26
|
-
const data = await fs.promises
|
|
27
|
-
.readFile(file)
|
|
28
|
-
.then((x) => JSON.parse(x.toString()));
|
|
29
|
-
return data;
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export async function writeValues(input) {
|
|
36
|
-
const file = valuesFile();
|
|
37
|
-
await fs.promises.writeFile(file, JSON.stringify(input));
|
|
38
|
-
}
|
|
39
|
-
export function append(input) {
|
|
40
|
-
input.path = path.resolve(useProject().paths.root, input.path);
|
|
41
|
-
fs.appendFileSync(keysFile(), JSON.stringify(input) + "\n");
|
|
42
|
-
}
|
|
43
|
-
export function reset() {
|
|
44
|
-
fs.rmSync(keysFile(), {
|
|
45
|
-
force: true,
|
|
46
|
-
recursive: true,
|
|
47
|
-
});
|
|
48
|
-
}
|