sst 2.0.0-rc.20 → 2.0.0-rc.21

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.
@@ -642,7 +642,6 @@ export declare class Function extends lambda.Function implements SSTConstruct {
642
642
  static normalizeMemorySize(memorySize?: number | Size): number;
643
643
  static normalizeDiskSize(diskSize?: number | Size): cdk.Size;
644
644
  static normalizeTimeout(timeout?: number | Duration): cdk.Duration;
645
- static normalizeRuntime(runtime?: Runtime): Runtime;
646
645
  static normalizeSrcPath(srcPath: string): string;
647
646
  static handleImportedLayer(scope: Construct, layer: lambda.ILayerVersion): lambda.ILayerVersion;
648
647
  static isInlineDefinition(definition: any): definition is FunctionInlineDefinition;
@@ -77,6 +77,7 @@ export class Function extends lambda.Function {
77
77
  .forEach((per) => {
78
78
  props = Function.mergeProps(per, props);
79
79
  });
80
+ props.runtime = props.runtime || "nodejs16.x";
80
81
  // Set defaults
81
82
  const functionName = props.functionName &&
82
83
  (typeof props.functionName === "string"
@@ -84,7 +85,6 @@ export class Function extends lambda.Function {
84
85
  : props.functionName({ stack, functionProps: props }));
85
86
  const handler = props.handler;
86
87
  const timeout = Function.normalizeTimeout(props.timeout);
87
- const runtime = Function.normalizeRuntime(props.runtime);
88
88
  const architecture = (() => {
89
89
  if (props.architecture === "arm_64")
90
90
  return lambda.Architecture.ARM_64;
@@ -103,9 +103,7 @@ export class Function extends lambda.Function {
103
103
  throw new Error(`No handler defined for the "${id}" Lambda function`);
104
104
  }
105
105
  // Validate input
106
- const isNodeRuntime = runtime.startsWith("nodejs");
107
- const isPythonRuntime = runtime.startsWith("python");
108
- const isJavaRuntime = runtime.startsWith("java");
106
+ const isNodeRuntime = props.runtime.startsWith("nodejs");
109
107
  // Handle local development (ie. sst start)
110
108
  // - set runtime to nodejs12.x for non-Node runtimes (b/c the stub is in Node)
111
109
  // - set retry to 0. When the debugger is disconnected, the Cron construct
@@ -196,7 +194,8 @@ export class Function extends lambda.Function {
196
194
  // Update function's code
197
195
  const codeConfig = code.bind(this);
198
196
  const cfnFunction = this.node.defaultChild;
199
- cfnFunction.runtime = supportedRuntimes[runtime].toString();
197
+ cfnFunction.runtime =
198
+ supportedRuntimes[props.runtime].toString();
200
199
  /*
201
200
  if (isJavaRuntime) {
202
201
  const providedRuntime = (bundle as FunctionBundleJavaProps)
@@ -391,13 +390,6 @@ export class Function extends lambda.Function {
391
390
  }
392
391
  return cdk.Duration.seconds(timeout || 10);
393
392
  }
394
- static normalizeRuntime(runtime) {
395
- runtime = runtime || "nodejs18.x";
396
- if (!supportedRuntimes[runtime]) {
397
- throw new Error(`The specified runtime is not supported for sst.Function. Only NodeJS, Python, Go, and .NET runtimes are currently supported.`);
398
- }
399
- return runtime;
400
- }
401
393
  static normalizeSrcPath(srcPath) {
402
394
  return srcPath.replace(/\/+$/, "");
403
395
  }
package/credentials.js CHANGED
@@ -37,6 +37,8 @@ export function useAWSClient(client, force = false) {
37
37
  retryDecider: (err) => {
38
38
  if (err.$fault === "client")
39
39
  return false;
40
+ if (err.name === "CredentialsProviderError")
41
+ return false;
40
42
  if (err.message === "Could not load credentials from any providers")
41
43
  return false;
42
44
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.0-rc.20",
3
+ "version": "2.0.0-rc.21",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
package/project.js CHANGED
@@ -24,7 +24,6 @@ const CONFIG_EXTENSIONS = [
24
24
  ".config.cjs",
25
25
  ".config.mjs",
26
26
  ".config.js",
27
- ".json",
28
27
  ];
29
28
  export async function initProject(globals) {
30
29
  const root = globals.root || (await findRoot());
@@ -42,12 +41,10 @@ export async function initProject(globals) {
42
41
  catch {
43
42
  continue;
44
43
  }
45
- if (file.endsWith("js") || file.endsWith("ts")) {
46
- const [metafile, config] = await Stacks.load(file);
47
- return [metafile, config];
48
- }
44
+ const [metafile, config] = await Stacks.load(file);
45
+ return [metafile, config];
49
46
  }
50
- throw new VisibleError("Could not found a configuration file", "Make sure one of the following exists", " - sst.config.cjs", " - sst.config.mjs", " - sst.config.js", " - sst.config.ts", " - sst.json");
47
+ throw new VisibleError("Could not found a configuration file", "Make sure one of the following exists", ...CONFIG_EXTENSIONS.map((x) => ` - sst${x}`));
51
48
  })();
52
49
  const config = await Promise.resolve(sstConfig.config(globals));
53
50
  const stage = config.stage ||
package/sst.mjs CHANGED
@@ -269,6 +269,21 @@ async function load(input) {
269
269
  await fs3.rm(outfile, {
270
270
  force: true
271
271
  });
272
+ if (!mod.default?.config)
273
+ throw new VisibleError(
274
+ `The config file is improperly formatted.`,
275
+ `Example:`,
276
+ `export default {`,
277
+ ` config() {`,
278
+ ` return {`,
279
+ ` name: "my-app",`,
280
+ ` region: "us-east-1"`,
281
+ ` }`,
282
+ ` },`,
283
+ ` stacks(app) {`,
284
+ ` }`,
285
+ `}`
286
+ );
272
287
  return [result.metafile, mod.default];
273
288
  } catch (e) {
274
289
  await fs3.rm(outfile, {
@@ -282,6 +297,7 @@ var init_build = __esm({
282
297
  "use strict";
283
298
  init_module();
284
299
  init_fs();
300
+ init_error();
285
301
  }
286
302
  });
287
303
 
@@ -989,6 +1005,8 @@ function useAWSClient(client, force = false) {
989
1005
  retryDecider: (err) => {
990
1006
  if (err.$fault === "client")
991
1007
  return false;
1008
+ if (err.name === "CredentialsProviderError")
1009
+ return false;
992
1010
  if (err.message === "Could not load credentials from any providers")
993
1011
  return false;
994
1012
  return true;
@@ -3796,19 +3814,13 @@ async function initProject(globals) {
3796
3814
  } catch {
3797
3815
  continue;
3798
3816
  }
3799
- if (file.endsWith("js") || file.endsWith("ts")) {
3800
- const [metafile2, config2] = await stacks_exports.load(file);
3801
- return [metafile2, config2];
3802
- }
3817
+ const [metafile2, config2] = await stacks_exports.load(file);
3818
+ return [metafile2, config2];
3803
3819
  }
3804
3820
  throw new VisibleError(
3805
3821
  "Could not found a configuration file",
3806
3822
  "Make sure one of the following exists",
3807
- " - sst.config.cjs",
3808
- " - sst.config.mjs",
3809
- " - sst.config.js",
3810
- " - sst.config.ts",
3811
- " - sst.json"
3823
+ ...CONFIG_EXTENSIONS.map((x) => ` - sst${x}`)
3812
3824
  );
3813
3825
  }();
3814
3826
  const config = await Promise.resolve(sstConfig.config(globals));
@@ -3911,8 +3923,7 @@ var init_project = __esm({
3911
3923
  ".config.cts",
3912
3924
  ".config.cjs",
3913
3925
  ".config.mjs",
3914
- ".config.js",
3915
- ".json"
3926
+ ".config.js"
3916
3927
  ];
3917
3928
  }
3918
3929
  });
package/stacks/build.js CHANGED
@@ -3,6 +3,7 @@ import fs from "fs/promises";
3
3
  import path from "path";
4
4
  import { dynamicImport } from "../util/module.js";
5
5
  import { findAbove } from "../util/fs.js";
6
+ import { VisibleError } from "../error.js";
6
7
  export async function load(input) {
7
8
  const parsed = path.parse(input);
8
9
  const root = await findAbove(input, "package.json");
@@ -43,6 +44,8 @@ export async function load(input) {
43
44
  await fs.rm(outfile, {
44
45
  force: true,
45
46
  });
47
+ if (!mod.default?.config)
48
+ throw new VisibleError(`The config file is improperly formatted.`, `Example:`, `export default {`, ` config() {`, ` return {`, ` name: "my-app",`, ` region: "us-east-1"`, ` }`, ` },`, ` stacks(app) {`, ` }`, `}`);
46
49
  return [result.metafile, mod.default];
47
50
  }
48
51
  catch (e) {