@awsless/awsless 0.0.536 → 0.0.538

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/dist/bin.js CHANGED
@@ -1508,7 +1508,8 @@ var SitesSchema = z32.record(
1508
1508
  ),
1509
1509
  cacheKey: z32.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1510
1510
  `Specifies the files and directories to generate the cache key for your custom build command.`
1511
- )
1511
+ ),
1512
+ configs: z32.string().array().describe("Define the config values for your build command.")
1512
1513
  }).optional().describe(`Specifies the build process for sites that need a build step.`),
1513
1514
  static: z32.union([LocalDirectorySchema, z32.boolean()]).optional().describe(
1514
1515
  "Specifies the path to the static files directory. Additionally you can also pass `true` when you don't have local static files, but still want to make an S3 bucket."
@@ -2622,6 +2623,11 @@ var configFeature = defineFeature({
2622
2623
  for (const name of stack.configs ?? []) {
2623
2624
  resources2.addConst(name, "string");
2624
2625
  }
2626
+ for (const site of Object.values(stack.sites ?? {})) {
2627
+ for (const name of site.build?.configs ?? []) {
2628
+ resources2.addConst(name, "string");
2629
+ }
2630
+ }
2625
2631
  }
2626
2632
  gen.addInterface("ConfigResources", resources2.toString());
2627
2633
  await ctx.write("config.d.ts", gen, true);
@@ -4884,12 +4890,18 @@ if (event.request.headers.host) {
4884
4890
  setLambdaOrigin('${url}');`;
4885
4891
 
4886
4892
  // src/feature/site/index.ts
4887
- import { camelCase as camelCase6 } from "change-case";
4893
+ import { camelCase as camelCase6, constantCase as constantCase10 } from "change-case";
4888
4894
 
4889
4895
  // src/util/exec.ts
4890
4896
  import { exec } from "promisify-child-process";
4891
- var execCommand = async ({ cwd, command }) => {
4892
- await exec(command, { cwd });
4897
+ var execCommand = async ({ cwd, env, command }) => {
4898
+ await exec(command, {
4899
+ cwd,
4900
+ env: {
4901
+ ...process.env,
4902
+ ...env ?? {}
4903
+ }
4904
+ });
4893
4905
  };
4894
4906
 
4895
4907
  // src/feature/site/index.ts
@@ -4912,9 +4924,14 @@ var siteFeature = defineFeature({
4912
4924
  const fingerprint = await generateCacheKey(buildProps.cacheKey);
4913
4925
  return build3(fingerprint, async (write) => {
4914
4926
  const cwd = join11(directories.root, dirname7(ctx.stackConfig.file));
4927
+ const env = {};
4928
+ for (const name2 of props.build?.configs ?? []) {
4929
+ env[`CONFIG_${constantCase10(name2)}`] = name2;
4930
+ }
4915
4931
  await execCommand({
4916
4932
  cwd,
4917
- command: buildProps.command
4933
+ command: buildProps.command,
4934
+ env
4918
4935
  });
4919
4936
  await write("HASH", fingerprint);
4920
4937
  return {
@@ -5387,7 +5404,7 @@ var storeFeature = defineFeature({
5387
5404
 
5388
5405
  // src/feature/table/index.ts
5389
5406
  import { $ as $17, Group as Group17 } from "@awsless/formation";
5390
- import { constantCase as constantCase10 } from "change-case";
5407
+ import { constantCase as constantCase11 } from "change-case";
5391
5408
  import { toSeconds as toSeconds7 } from "@awsless/duration";
5392
5409
  var tableFeature = defineFeature({
5393
5410
  name: "table",
@@ -5469,8 +5486,8 @@ var tableFeature = defineFeature({
5469
5486
  name,
5470
5487
  billingMode: "PAY_PER_REQUEST",
5471
5488
  streamEnabled: !!props.stream,
5472
- streamViewType: props.stream && constantCase10(props.stream?.type),
5473
- tableClass: constantCase10(props.class),
5489
+ streamViewType: props.stream && constantCase11(props.stream?.type),
5490
+ tableClass: constantCase11(props.class),
5474
5491
  hashKey: props.hash,
5475
5492
  rangeKey: props.sort,
5476
5493
  attribute: attributeDefinitions(),
@@ -5485,7 +5502,7 @@ var tableFeature = defineFeature({
5485
5502
  name: name2,
5486
5503
  hashKey: index.hash,
5487
5504
  rangeKey: index.sort,
5488
- projectionType: constantCase10(index.projection)
5505
+ projectionType: constantCase11(index.projection)
5489
5506
  })),
5490
5507
  deletionProtectionEnabled: ctx.appConfig.removal === "retain"
5491
5508
  },
@@ -6020,7 +6037,7 @@ import { $ as $22, Group as Group23 } from "@awsless/formation";
6020
6037
  import { join as join12, dirname as dirname8 } from "path";
6021
6038
  import { mebibytes as mebibytes4 } from "@awsless/size";
6022
6039
  import { days as days6, seconds as seconds9, toDays as toDays5, toSeconds as toSeconds8 } from "@awsless/duration";
6023
- import { constantCase as constantCase11 } from "change-case";
6040
+ import { constantCase as constantCase12 } from "change-case";
6024
6041
  import { fileURLToPath as fileURLToPath2 } from "url";
6025
6042
  import { glob as glob3 } from "glob";
6026
6043
  var __dirname2 = dirname8(fileURLToPath2(import.meta.url));
@@ -6313,7 +6330,7 @@ var imageFeature = defineFeature({
6313
6330
  });
6314
6331
  }
6315
6332
  ctx.bind(
6316
- `IMAGE_${constantCase11(ctx.stack.name)}_${constantCase11(id)}_ENDPOINT`,
6333
+ `IMAGE_${constantCase12(ctx.stack.name)}_${constantCase12(id)}_ENDPOINT`,
6317
6334
  domainName ?? distribution.domainName
6318
6335
  );
6319
6336
  ctx.shared.add("image", "distribution-id", id, distribution.id);
@@ -6327,7 +6344,7 @@ import { $ as $23, Group as Group24 } from "@awsless/formation";
6327
6344
  import { join as join13, dirname as dirname9 } from "path";
6328
6345
  import { mebibytes as mebibytes5 } from "@awsless/size";
6329
6346
  import { days as days7, seconds as seconds10, toDays as toDays6, toSeconds as toSeconds9 } from "@awsless/duration";
6330
- import { constantCase as constantCase12 } from "change-case";
6347
+ import { constantCase as constantCase13 } from "change-case";
6331
6348
  import { fileURLToPath as fileURLToPath3 } from "url";
6332
6349
  import { glob as glob4 } from "glob";
6333
6350
  var __dirname3 = dirname9(fileURLToPath3(import.meta.url));
@@ -6592,7 +6609,7 @@ var iconFeature = defineFeature({
6592
6609
  });
6593
6610
  }
6594
6611
  ctx.bind(
6595
- `ICON_${constantCase12(ctx.stack.name)}_${constantCase12(id)}_ENDPOINT`,
6612
+ `ICON_${constantCase13(ctx.stack.name)}_${constantCase13(id)}_ENDPOINT`,
6596
6613
  domainName ?? distribution.domainName
6597
6614
  );
6598
6615
  ctx.shared.add("icon", "distribution-id", id, distribution.id);
@@ -7996,7 +8013,7 @@ var auth = (program2) => {
7996
8013
 
7997
8014
  // src/cli/command/bind.ts
7998
8015
  import { log as log17 } from "@awsless/clui";
7999
- import { constantCase as constantCase13 } from "change-case";
8016
+ import { constantCase as constantCase14 } from "change-case";
8000
8017
  import { spawn } from "child_process";
8001
8018
  var bind = (program2) => {
8002
8019
  program2.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v) => v.split(",")).description(`Bind your site environment variables to a command`).action(async (commands9 = [], opts) => {
@@ -8025,10 +8042,10 @@ var bind = (program2) => {
8025
8042
  const configList = opts.config ?? [];
8026
8043
  const configs = {};
8027
8044
  for (const name of configList) {
8028
- configs[`CONFIG_${constantCase13(name)}`] = name;
8045
+ configs[`CONFIG_${constantCase14(name)}`] = name;
8029
8046
  }
8030
8047
  if (configList.length ?? 0 > 0) {
8031
- log17.note("Bind Config", configList.map((v) => color.label(constantCase13(v))).join("\n"));
8048
+ log17.note("Bind Config", configList.map((v) => color.label(constantCase14(v))).join("\n"));
8032
8049
  }
8033
8050
  if (commands9.length === 0) {
8034
8051
  return "No command to execute.";
@@ -903,7 +903,8 @@ var SitesSchema = z29.record(
903
903
  ),
904
904
  cacheKey: z29.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
905
905
  `Specifies the files and directories to generate the cache key for your custom build command.`
906
- )
906
+ ),
907
+ configs: z29.string().array().describe("Define the config values for your build command.")
907
908
  }).optional().describe(`Specifies the build process for sites that need a build step.`),
908
909
  static: z29.union([LocalDirectorySchema, z29.boolean()]).optional().describe(
909
910
  "Specifies the path to the static files directory. Additionally you can also pass `true` when you don't have local static files, but still want to make an S3 bucket."
Binary file
Binary file
Binary file