sst 2.0.29 → 2.0.31

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.js CHANGED
@@ -105,7 +105,9 @@ export async function bootstrapSST(tags) {
105
105
  const fn = new Function(stack, "MetadataHandler", {
106
106
  code: Code.fromAsset(path.resolve(__dirname, "support/bootstrap-metadata-function")),
107
107
  handler: "index.handler",
108
- runtime: Runtime.NODEJS_18_X,
108
+ runtime: app.region?.startsWith("us-gov-")
109
+ ? Runtime.NODEJS_16_X
110
+ : Runtime.NODEJS_18_X,
109
111
  environment: {
110
112
  BUCKET_NAME: bucket.bucketName,
111
113
  },
package/constructs/RDS.js CHANGED
@@ -263,7 +263,7 @@ export class RDS extends Construct {
263
263
  // - when running resources tests, __dirname is `resources/src`
264
264
  // For now we will do `__dirname/../dist` to make both cases work.
265
265
  const fn = new Fn(this, "MigrationFunction", {
266
- handler: path.resolve(path.join(__dirname, "../support/rds-migrator/index.handler")),
266
+ handler: path.resolve(path.join(__dirname, "../../support/rds-migrator/index.handler")),
267
267
  runtime: "nodejs16.x",
268
268
  timeout: 900,
269
269
  memorySize: 1024,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.29",
3
+ "version": "2.0.31",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -91,22 +91,30 @@ export const usePythonHandler = Context.memo(async () => {
91
91
  type: "error",
92
92
  errors: [`Could not find src for ${input.props.handler}`],
93
93
  };
94
+ await fs.cp(src, input.out, {
95
+ recursive: true,
96
+ filter: (src) => !src.includes(".sst"),
97
+ });
94
98
  if (await existsAsync(path.join(src, "Pipfile"))) {
95
- await execAsync("pipenv requirements > requirements.txt");
99
+ await execAsync("pipenv requirements > requirements.txt", {
100
+ cwd: input.out,
101
+ });
96
102
  }
97
103
  if (await existsAsync(path.join(src, "poetry.lock"))) {
98
- await execAsync("poetry export --with-credentials --format requirements.txt --output requirements.txt");
104
+ await execAsync("poetry export --with-credentials --format requirements.txt --output requirements.txt", {
105
+ cwd: input.out,
106
+ });
99
107
  }
100
108
  if (await existsAsync(path.join(src, "requirements.txt"))) {
101
- await execAsync("pip install -r requirements.txt");
109
+ await execAsync("pip install -r requirements.txt", {
110
+ cwd: input.out,
111
+ });
102
112
  }
103
- await fs.cp(src, input.out, {
104
- recursive: true,
105
- filter: (src) => !src.includes(".sst"),
106
- });
107
113
  if (input.props.python?.installCommands) {
108
114
  for (const cmd of input.props.python.installCommands) {
109
- await execAsync(cmd);
115
+ await execAsync(cmd, {
116
+ cwd: input.out,
117
+ });
110
118
  }
111
119
  }
112
120
  const result = {
@@ -58,6 +58,11 @@ export const useRustHandler = Context.memo(async () => {
58
58
  build: async (input) => {
59
59
  const parsed = path.parse(input.props.handler);
60
60
  const project = await findAbove(parsed.dir, "Cargo.toml");
61
+ if (!project)
62
+ return {
63
+ type: "error",
64
+ errors: ["Could not find a Cargo.toml file"],
65
+ };
61
66
  sources.set(input.functionID, project);
62
67
  if (input.mode === "start") {
63
68
  try {
package/sst.mjs CHANGED
@@ -181,7 +181,7 @@ import fs2 from "fs/promises";
181
181
  import path2 from "path";
182
182
  async function findAbove(dir, target) {
183
183
  if (dir === "/")
184
- throw new VisibleError(`Could not find a ${target} file`);
184
+ return void 0;
185
185
  if (await existsAsync(path2.join(dir, target)))
186
186
  return dir;
187
187
  return findAbove(path2.resolve(path2.join(dir, "..")), target);
@@ -235,6 +235,8 @@ import path3 from "path";
235
235
  async function load(input) {
236
236
  const parsed = path3.parse(input);
237
237
  const root = await findAbove(input, "package.json");
238
+ if (!root)
239
+ throw new VisibleError("Could not find a package.json file");
238
240
  const outfile = path3.join(parsed.dir, `.${parsed.name}.${Date.now()}.mjs`);
239
241
  const pkg = JSON.parse(
240
242
  await fs3.readFile(path3.join(root, "package.json")).then((x) => x.toString())
@@ -2708,7 +2710,7 @@ async function bootstrapSST(tags) {
2708
2710
  path8.resolve(__dirname, "support/bootstrap-metadata-function")
2709
2711
  ),
2710
2712
  handler: "index.handler",
2711
- runtime: Runtime.NODEJS_18_X,
2713
+ runtime: app.region?.startsWith("us-gov-") ? Runtime.NODEJS_16_X : Runtime.NODEJS_18_X,
2712
2714
  environment: {
2713
2715
  BUCKET_NAME: bucket.bucketName
2714
2716
  },
@@ -5132,6 +5134,11 @@ var init_rust = __esm({
5132
5134
  build: async (input) => {
5133
5135
  const parsed = path12.parse(input.props.handler);
5134
5136
  const project = await findAbove(parsed.dir, "Cargo.toml");
5137
+ if (!project)
5138
+ return {
5139
+ type: "error",
5140
+ errors: ["Could not find a Cargo.toml file"]
5141
+ };
5135
5142
  sources.set(input.functionID, project);
5136
5143
  if (input.mode === "start") {
5137
5144
  try {
@@ -5283,24 +5290,33 @@ var init_python = __esm({
5283
5290
  type: "error",
5284
5291
  errors: [`Could not find src for ${input.props.handler}`]
5285
5292
  };
5293
+ await fs13.cp(src, input.out, {
5294
+ recursive: true,
5295
+ filter: (src2) => !src2.includes(".sst")
5296
+ });
5286
5297
  if (await existsAsync(path13.join(src, "Pipfile"))) {
5287
- await execAsync4("pipenv requirements > requirements.txt");
5298
+ await execAsync4("pipenv requirements > requirements.txt", {
5299
+ cwd: input.out
5300
+ });
5288
5301
  }
5289
5302
  if (await existsAsync(path13.join(src, "poetry.lock"))) {
5290
5303
  await execAsync4(
5291
- "poetry export --with-credentials --format requirements.txt --output requirements.txt"
5304
+ "poetry export --with-credentials --format requirements.txt --output requirements.txt",
5305
+ {
5306
+ cwd: input.out
5307
+ }
5292
5308
  );
5293
5309
  }
5294
5310
  if (await existsAsync(path13.join(src, "requirements.txt"))) {
5295
- await execAsync4("pip install -r requirements.txt");
5311
+ await execAsync4("pip install -r requirements.txt", {
5312
+ cwd: input.out
5313
+ });
5296
5314
  }
5297
- await fs13.cp(src, input.out, {
5298
- recursive: true,
5299
- filter: (src2) => !src2.includes(".sst")
5300
- });
5301
5315
  if (input.props.python?.installCommands) {
5302
5316
  for (const cmd of input.props.python.installCommands) {
5303
- await execAsync4(cmd);
5317
+ await execAsync4(cmd, {
5318
+ cwd: input.out
5319
+ });
5304
5320
  }
5305
5321
  }
5306
5322
  const result = {
package/stacks/build.js CHANGED
@@ -7,6 +7,8 @@ import { VisibleError } from "../error.js";
7
7
  export async function load(input) {
8
8
  const parsed = path.parse(input);
9
9
  const root = await findAbove(input, "package.json");
10
+ if (!root)
11
+ throw new VisibleError("Could not find a package.json file");
10
12
  const outfile = path.join(parsed.dir, `.${parsed.name}.${Date.now()}.mjs`);
11
13
  const pkg = JSON.parse(await fs.readFile(path.join(root, "package.json")).then((x) => x.toString()));
12
14
  try {
package/util/fs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare function findAbove(dir: string, target: string): Promise<string>;
1
+ export declare function findAbove(dir: string, target: string): Promise<string | undefined>;
2
2
  export declare function findBelow(dir: string, target: string): Promise<string>;
3
3
  export declare function isChild(parent: string, child: string): boolean;
4
4
  export declare function existsAsync(input: string): Promise<boolean>;
package/util/fs.js CHANGED
@@ -3,7 +3,7 @@ import fs from "fs/promises";
3
3
  import path from "path";
4
4
  export async function findAbove(dir, target) {
5
5
  if (dir === "/")
6
- throw new VisibleError(`Could not find a ${target} file`);
6
+ return undefined;
7
7
  if (await existsAsync(path.join(dir, target)))
8
8
  return dir;
9
9
  return findAbove(path.resolve(path.join(dir, "..")), target);