sst 2.0.0-rc.69 → 2.0.0-rc.70

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 CHANGED
@@ -1,15 +1,4 @@
1
- export declare const BootstrapContext: {
2
- use(): {
3
- version: string;
4
- bucket: string;
5
- };
6
- provide(value: {
7
- version: string;
8
- bucket: string;
9
- }): void;
10
- };
11
- export declare const useBootstrap: () => {
1
+ export declare const useBootstrap: () => Promise<{
12
2
  version: string;
13
3
  bucket: string;
14
- };
15
- export declare function initBootstrap(): Promise<void>;
4
+ }>;
package/bootstrap.js CHANGED
@@ -23,9 +23,7 @@ const OUTPUT_VERSION = "Version";
23
23
  const OUTPUT_BUCKET = "BucketName";
24
24
  const LATEST_VERSION = "6";
25
25
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
26
- export const BootstrapContext = Context.create("Bootstrap");
27
- export const useBootstrap = BootstrapContext.use;
28
- export async function initBootstrap() {
26
+ export const useBootstrap = Context.memo(async () => {
29
27
  Logger.debug("Initializing bootstrap context");
30
28
  let [cdkStatus, sstStatus] = await Promise.all([
31
29
  loadCDKStatus(),
@@ -48,9 +46,9 @@ export async function initBootstrap() {
48
46
  }
49
47
  spinner.succeed();
50
48
  }
51
- BootstrapContext.provide(sstStatus);
52
49
  Logger.debug("Bootstrap context initialized", sstStatus);
53
- }
50
+ return sstStatus;
51
+ }, "Bootstrap");
54
52
  async function loadCDKStatus() {
55
53
  const client = useAWSClient(CloudFormationClient);
56
54
  try {
@@ -100,6 +98,9 @@ async function bootstrapSST() {
100
98
  code: Code.fromAsset(path.resolve(__dirname, "support/bootstrap-metadata-function")),
101
99
  handler: "index.handler",
102
100
  runtime: Runtime.NODEJS_18_X,
101
+ environment: {
102
+ BUCKET_NAME: bucket.bucketName,
103
+ },
103
104
  initialPolicy: [
104
105
  new PolicyStatement({
105
106
  actions: ["cloudformation:DescribeStacks"],
@@ -0,0 +1,13 @@
1
+ /// <reference types="yargs" />
2
+ import type { Program } from "../program.js";
3
+ export declare const bootstrap: (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,4 @@
1
+ export const bootstrap = (program) => program.command("bootstrap", "Create the SST bootstrap stack", (yargs) => yargs, async () => {
2
+ const { useBootstrap } = await import("../../bootstrap.js");
3
+ await useBootstrap();
4
+ });
package/cli/sst.js CHANGED
@@ -25,6 +25,7 @@ import { transform } from "./commands/transform.js";
25
25
  import { diff } from "./commands/diff.js";
26
26
  import { version } from "./commands/version.js";
27
27
  import { telemetry } from "./commands/telemetry.js";
28
+ import { bootstrap } from "./commands/bootstrap.js";
28
29
  dev(program);
29
30
  deploy(program);
30
31
  build(program);
@@ -38,6 +39,7 @@ consoleCommand(program);
38
39
  diff(program);
39
40
  version(program);
40
41
  telemetry(program);
42
+ bootstrap(program);
41
43
  if ("setSourceMapsEnabled" in process) {
42
44
  // @ts-expect-error
43
45
  process.setSourceMapsEnabled(true);
package/constructs/App.js CHANGED
@@ -14,7 +14,6 @@ import { createRequire } from "module";
14
14
  import { Auth } from "./Auth.js";
15
15
  import { useDeferredTasks } from "./deferred_task.js";
16
16
  import { AppContext } from "./context.js";
17
- import { useBootstrap } from "../bootstrap.js";
18
17
  import { useProject } from "../project.js";
19
18
  import { Logger } from "../logger.js";
20
19
  import { SiteEnv } from "../site-env.js";
@@ -290,7 +289,6 @@ export class App extends cdk.App {
290
289
  app: this.name,
291
290
  stage: this.stage,
292
291
  version: useProject().version,
293
- bootstrapBucket: useBootstrap().bucket,
294
292
  metadata: byStack[stackName] || [],
295
293
  }),
296
294
  });
@@ -186,8 +186,12 @@ export class Function extends lambda.Function {
186
186
  useDeferredTasks().add(async () => {
187
187
  // Build function
188
188
  const result = await useRuntimeHandlers().build(this.node.addr, "deploy");
189
- if (result.type === "error")
190
- throw new Error(`Failed to build function "${props.handler}"`);
189
+ if (result.type === "error") {
190
+ throw new Error([
191
+ `Failed to build function "${props.handler}"`,
192
+ ...result.errors,
193
+ ].join("\n"));
194
+ }
191
195
  const code = lambda.AssetCode.fromAsset(result.out);
192
196
  // Update function's code
193
197
  const codeConfig = code.bind(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.69",
3
+ "version": "2.0.0-rc.70",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/project.js CHANGED
@@ -81,8 +81,6 @@ export async function initProject(globals) {
81
81
  },
82
82
  };
83
83
  ProjectContext.provide(project);
84
- const { initBootstrap } = await import("./bootstrap.js");
85
- await initBootstrap();
86
84
  dotenv.config({
87
85
  path: path.join(project.paths.root, `.env.${project.config.stage}`),
88
86
  override: true,