@awsless/awsless 0.0.12 → 0.0.14

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.cjs CHANGED
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var import_commander = require("commander");
28
28
 
29
29
  // src/app.ts
30
- var import_aws_cdk_lib7 = require("aws-cdk-lib");
30
+ var import_aws_cdk_lib9 = require("aws-cdk-lib");
31
31
 
32
32
  // src/stack.ts
33
33
  var import_aws_cdk_lib = require("aws-cdk-lib");
@@ -83,15 +83,15 @@ var flushDebug = () => {
83
83
 
84
84
  // src/util/param.ts
85
85
  var import_client_ssm = require("@aws-sdk/client-ssm");
86
- var configParameterPrefix = (config2) => {
87
- return `/${config2.stage}/awsless/${config2.name}`;
86
+ var configParameterPrefix = (config) => {
87
+ return `/${config.stage}/awsless/${config.name}`;
88
88
  };
89
89
  var Params = class {
90
- constructor(config2) {
91
- this.config = config2;
90
+ constructor(config) {
91
+ this.config = config;
92
92
  this.client = new import_client_ssm.SSMClient({
93
- credentials: config2.credentials,
94
- region: config2.region
93
+ credentials: config.credentials,
94
+ region: config.region
95
95
  });
96
96
  }
97
97
  client;
@@ -166,13 +166,17 @@ var Params = class {
166
166
  };
167
167
 
168
168
  // src/stack.ts
169
- var toStack = ({ config: config2, assets, app, stackConfig, plugins }) => {
170
- const stackName = `${config2.name}-${stackConfig.name}`;
169
+ var toStack = ({ config, assets, app, stackConfig, plugins }) => {
170
+ const stackName = `${config.name}-${stackConfig.name}`;
171
171
  const stack = new import_aws_cdk_lib.Stack(app, stackConfig.name, {
172
172
  stackName,
173
+ env: {
174
+ account: config.account,
175
+ region: config.region
176
+ },
173
177
  tags: {
174
- APP: config2.name,
175
- STAGE: config2.stage,
178
+ APP: config.name,
179
+ STAGE: config.stage,
176
180
  STACK: stackConfig.name
177
181
  }
178
182
  });
@@ -183,7 +187,7 @@ var toStack = ({ config: config2, assets, app, stackConfig, plugins }) => {
183
187
  };
184
188
  debug("Run plugin onStack listeners");
185
189
  const functions = plugins.map((plugin) => plugin.onStack?.({
186
- config: config2,
190
+ config,
187
191
  assets,
188
192
  app,
189
193
  stack,
@@ -202,12 +206,12 @@ var toStack = ({ config: config2, assets, app, stackConfig, plugins }) => {
202
206
  ],
203
207
  resources: [
204
208
  import_aws_cdk_lib.Arn.format({
205
- region: config2.region,
206
- account: config2.account,
209
+ region: config.region,
210
+ account: config.account,
207
211
  partition: "aws",
208
212
  service: "ssm",
209
213
  resource: "parameter",
210
- resourceName: configParameterPrefix(config2)
214
+ resourceName: configParameterPrefix(config)
211
215
  })
212
216
  // Fn.sub('arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter' + configParameterPrefix(config)),
213
217
  ]
@@ -230,7 +234,7 @@ var assetDir = (0, import_path.join)(outDir, "asset");
230
234
  var cacheDir = (0, import_path.join)(outDir, "cache");
231
235
 
232
236
  // src/stack/app-bootstrap.ts
233
- var import_aws_cdk_lib6 = require("aws-cdk-lib");
237
+ var import_aws_cdk_lib8 = require("aws-cdk-lib");
234
238
 
235
239
  // src/plugin.ts
236
240
  var definePlugin = (plugin) => plugin;
@@ -282,6 +286,9 @@ var toId = (resource, id) => {
282
286
  var toName = (stack, id) => {
283
287
  return (0, import_change_case.paramCase)(`${stack.stackName}-${id}`);
284
288
  };
289
+ var toExportName = (name) => {
290
+ return (0, import_change_case.paramCase)(name);
291
+ };
285
292
  var toEnvKey = (resource, id) => {
286
293
  return `RESOURCE_${resource.toUpperCase()}_${id}`;
287
294
  };
@@ -400,22 +407,22 @@ var zipFiles = (files) => {
400
407
  }
401
408
  });
402
409
  };
403
- var writeBuildHash = async (config2, stack, id, hash) => {
404
- const funcPath = (0, import_path3.join)(assetDir, "function", config2.name, stack.artifactId, id);
410
+ var writeBuildHash = async (config, stack, id, hash) => {
411
+ const funcPath = (0, import_path3.join)(assetDir, "function", config.name, stack.artifactId, id);
405
412
  const versionFile = (0, import_path3.join)(funcPath, "HASH");
406
413
  await (0, import_promises2.writeFile)(versionFile, hash);
407
414
  };
408
- var writeBuildFiles = async (config2, stack, id, files) => {
415
+ var writeBuildFiles = async (config, stack, id, files) => {
409
416
  const bundle = await zipFiles(files);
410
- const funcPath = (0, import_path3.join)(assetDir, "function", config2.name, stack.artifactId, id);
417
+ const funcPath = (0, import_path3.join)(assetDir, "function", config.name, stack.artifactId, id);
411
418
  const filesPath = (0, import_path3.join)(funcPath, "files");
412
419
  const bundleFile = (0, import_path3.join)(funcPath, "bundle.zip");
413
- debug("Bundle size of", style.info((0, import_path3.join)(config2.name, stack.artifactId, id)), "is", style.attr((0, import_filesize.filesize)(bundle.byteLength)));
420
+ debug("Bundle size of", style.info((0, import_path3.join)(config.name, stack.artifactId, id)), "is", style.attr((0, import_filesize.filesize)(bundle.byteLength)));
414
421
  await (0, import_promises2.mkdir)(filesPath, { recursive: true });
415
422
  await (0, import_promises2.writeFile)(bundleFile, bundle);
416
423
  await Promise.all(files.map(async (file) => {
417
424
  const fileName = (0, import_path3.join)(filesPath, file.name);
418
- await (0, import_promises2.mkdir)((0, import_path3.basename)(fileName), { recursive: true });
425
+ await (0, import_promises2.mkdir)((0, import_path3.dirname)(fileName), { recursive: true });
419
426
  await (0, import_promises2.writeFile)(fileName, file.code);
420
427
  if (file.map) {
421
428
  const mapName = (0, import_path3.join)(filesPath, `${file.name}.map`);
@@ -436,20 +443,20 @@ var import_client_s3 = require("@aws-sdk/client-s3");
436
443
  // src/stack/bootstrap.ts
437
444
  var import_aws_cdk_lib2 = require("aws-cdk-lib");
438
445
  var import_aws_s3 = require("aws-cdk-lib/aws-s3");
439
- var assetBucketName = (config2) => {
440
- return `awsless-bootstrap-${config2.account}-${config2.region}`;
446
+ var assetBucketName = (config) => {
447
+ return `awsless-bootstrap-${config.account}-${config.region}`;
441
448
  };
442
- var assetBucketUrl = (config2, stackName) => {
443
- const bucket = assetBucketName(config2);
444
- return `https://s3-${config2.region}.amazonaws.com/${bucket}/${stackName}/cloudformation.json`;
449
+ var assetBucketUrl = (config, stackName) => {
450
+ const bucket = assetBucketName(config);
451
+ return `https://s3-${config.region}.amazonaws.com/${bucket}/${stackName}/cloudformation.json`;
445
452
  };
446
- var version = "2";
447
- var bootstrapStack = (config2, app) => {
453
+ var version = "1";
454
+ var bootstrapStack = (config, app) => {
448
455
  const stack = new import_aws_cdk_lib2.Stack(app, "bootstrap", {
449
456
  stackName: `awsless-bootstrap`
450
457
  });
451
458
  new import_aws_s3.Bucket(stack, "assets", {
452
- bucketName: assetBucketName(config2),
459
+ bucketName: assetBucketName(config),
453
460
  versioned: true,
454
461
  accessControl: import_aws_s3.BucketAccessControl.PRIVATE,
455
462
  removalPolicy: import_aws_cdk_lib2.RemovalPolicy.DESTROY
@@ -467,17 +474,17 @@ var shouldDeployBootstrap = async (client, name) => {
467
474
  };
468
475
 
469
476
  // src/plugins/function/util/publish.ts
470
- var publishFunctionAsset = async (config2, stack, id) => {
471
- const bucket = assetBucketName(config2);
472
- const key = `${config2.name}/${stack.artifactId}/function/${id}.zip`;
473
- const funcPath = (0, import_path5.join)(assetDir, "function", config2.name, stack.artifactId, id);
477
+ var publishFunctionAsset = async (config, stack, id) => {
478
+ const bucket = assetBucketName(config);
479
+ const key = `${config.name}/${stack.artifactId}/function/${id}.zip`;
480
+ const funcPath = (0, import_path5.join)(assetDir, "function", config.name, stack.artifactId, id);
474
481
  const bundleFile = (0, import_path5.join)(funcPath, "bundle.zip");
475
482
  const hashFile = (0, import_path5.join)(funcPath, "HASH");
476
483
  const hash = await (0, import_promises3.readFile)(hashFile, "utf8");
477
484
  const file = await (0, import_promises3.readFile)(bundleFile);
478
485
  const client = new import_client_s3.S3Client({
479
- credentials: config2.credentials,
480
- region: config2.region
486
+ credentials: config.credentials,
487
+ region: config.region
481
488
  });
482
489
  let getResult;
483
490
  try {
@@ -612,8 +619,8 @@ var functionPlugin = definePlugin({
612
619
  });
613
620
  }
614
621
  });
615
- var toFunction = ({ config: config2, stack, assets }, id, fileOrProps) => {
616
- const props = typeof fileOrProps === "string" ? { ...config2.defaults?.function, file: fileOrProps } : { ...config2.defaults?.function, ...fileOrProps };
622
+ var toFunction = ({ config, stack, assets }, id, fileOrProps) => {
623
+ const props = typeof fileOrProps === "string" ? { ...config.defaults?.function, file: fileOrProps } : { ...config.defaults?.function, ...fileOrProps };
617
624
  const lambda = new import_aws_lambda3.Function(stack, toId("function", id), {
618
625
  functionName: toName(stack, id),
619
626
  handler: "index.default",
@@ -621,8 +628,8 @@ var toFunction = ({ config: config2, stack, assets }, id, fileOrProps) => {
621
628
  ...props,
622
629
  memorySize: props.memorySize.toMebibytes()
623
630
  });
624
- lambda.addEnvironment("APP", config2.name, { removeInEdge: true });
625
- lambda.addEnvironment("STAGE", config2.stage, { removeInEdge: true });
631
+ lambda.addEnvironment("APP", config.name, { removeInEdge: true });
632
+ lambda.addEnvironment("STAGE", config.stage, { removeInEdge: true });
626
633
  lambda.addEnvironment("STACK", stack.artifactId, { removeInEdge: true });
627
634
  if (lambda.runtime.toString().startsWith("nodejs")) {
628
635
  lambda.addEnvironment("AWS_NODEJS_CONNECTION_REUSE_ENABLED", "1", {
@@ -635,8 +642,8 @@ var toFunction = ({ config: config2, stack, assets }, id, fileOrProps) => {
635
642
  resourceName: id,
636
643
  async build() {
637
644
  const result = await rollupBuild(props.file);
638
- const bundle = await writeBuildFiles(config2, stack, id, result.files);
639
- await writeBuildHash(config2, stack, id, result.hash);
645
+ const bundle = await writeBuildFiles(config, stack, id, result.files);
646
+ await writeBuildHash(config, stack, id, result.hash);
640
647
  const func = lambda.node.defaultChild;
641
648
  func.handler = result.handler;
642
649
  return {
@@ -644,11 +651,11 @@ var toFunction = ({ config: config2, stack, assets }, id, fileOrProps) => {
644
651
  };
645
652
  },
646
653
  async publish() {
647
- const version2 = await publishFunctionAsset(config2, stack, id);
654
+ const version2 = await publishFunctionAsset(config, stack, id);
648
655
  const func = lambda.node.defaultChild;
649
656
  func.code = {
650
- s3Bucket: assetBucketName(config2),
651
- s3Key: `${config2.name}/${stack.artifactId}/function/${id}.zip`,
657
+ s3Bucket: assetBucketName(config),
658
+ s3Key: `${config.name}/${stack.artifactId}/function/${id}.zip`,
652
659
  s3ObjectVersion: version2
653
660
  };
654
661
  }
@@ -717,9 +724,9 @@ var queuePlugin = definePlugin({
717
724
  }).array()
718
725
  }),
719
726
  onStack(ctx) {
720
- const { stack, config: config2, stackConfig, bind } = ctx;
727
+ const { stack, config, stackConfig, bind } = ctx;
721
728
  return Object.entries(stackConfig.queues || {}).map(([id, functionOrProps]) => {
722
- const props = typeof functionOrProps === "string" ? { ...config2.defaults.queue, consumer: functionOrProps } : { ...config2.defaults.queue, ...functionOrProps };
729
+ const props = typeof functionOrProps === "string" ? { ...config.defaults.queue, consumer: functionOrProps } : { ...config.defaults.queue, ...functionOrProps };
723
730
  const queue2 = new import_aws_sqs.Queue(stack, toId("queue", id), {
724
731
  queueName: toName(stack, id),
725
732
  ...props,
@@ -883,20 +890,20 @@ var topicPlugin = definePlugin({
883
890
  topics: import_zod18.z.record(ResourceIdSchema, FunctionSchema).optional()
884
891
  }).array()
885
892
  }),
886
- onBootstrap({ config: config2, stack }) {
887
- const allTopicNames = config2.stacks.map((stack2) => {
893
+ onBootstrap({ config, stack }) {
894
+ const allTopicNames = config.stacks.map((stack2) => {
888
895
  return Object.keys(stack2.topics || {});
889
896
  }).flat();
890
897
  const uniqueTopicNames = [...new Set(allTopicNames)];
891
898
  uniqueTopicNames.forEach((id) => {
892
899
  new import_aws_sns.Topic(stack, toId("topic", id), {
893
- topicName: `${config2.name}-${id}`,
900
+ topicName: `${config.name}-${id}`,
894
901
  displayName: id
895
902
  });
896
903
  });
897
904
  },
898
905
  onStack(ctx) {
899
- const { config: config2, stack, stackConfig, bind } = ctx;
906
+ const { config, stack, stackConfig, bind } = ctx;
900
907
  return Object.entries(stackConfig.topics || {}).map(([id, props]) => {
901
908
  const lambda = toFunction(ctx, id, props);
902
909
  const topic = import_aws_sns.Topic.fromTopicArn(
@@ -905,7 +912,7 @@ var topicPlugin = definePlugin({
905
912
  import_aws_cdk_lib4.Arn.format({
906
913
  arnFormat: import_aws_cdk_lib4.ArnFormat.NO_RESOURCE_NAME,
907
914
  service: "sns",
908
- resource: `${config2.name}-${id}`
915
+ resource: `${config.name}-${id}`
909
916
  }, stack)
910
917
  );
911
918
  lambda.addEventSource(new import_aws_lambda_event_sources2.SnsEventSource(topic));
@@ -918,35 +925,8 @@ var topicPlugin = definePlugin({
918
925
  }
919
926
  });
920
927
 
921
- // src/plugins/search.ts
922
- var import_zod19 = require("zod");
923
- var import_aws_opensearchserverless = require("aws-cdk-lib/aws-opensearchserverless");
924
- var import_aws_iam2 = require("aws-cdk-lib/aws-iam");
925
- var searchPlugin = definePlugin({
926
- name: "search",
927
- schema: import_zod19.z.object({
928
- stacks: import_zod19.z.object({
929
- searchs: import_zod19.z.array(ResourceIdSchema).optional()
930
- }).array()
931
- }),
932
- onStack({ stack, stackConfig, bind }) {
933
- (stackConfig.searchs || []).forEach((id) => {
934
- const collection = new import_aws_opensearchserverless.CfnCollection(stack, toId("search", id), {
935
- name: toName(stack, id),
936
- type: "SEARCH"
937
- });
938
- bind((lambda) => {
939
- lambda.addToRolePolicy(new import_aws_iam2.PolicyStatement({
940
- actions: ["aoss:APIAccessAll"],
941
- resources: [collection.attrArn]
942
- }));
943
- });
944
- });
945
- }
946
- });
947
-
948
928
  // src/plugins/graphql/index.ts
949
- var import_zod21 = require("zod");
929
+ var import_zod20 = require("zod");
950
930
  var import_aws_appsync = require("aws-cdk-lib/aws-appsync");
951
931
  var import_merge = require("@graphql-tools/merge");
952
932
  var import_promises4 = require("fs/promises");
@@ -965,51 +945,51 @@ var import_graphql = require("graphql");
965
945
  var import_change_case2 = require("change-case");
966
946
 
967
947
  // src/plugins/graphql/schema/resolver-field.ts
968
- var import_zod20 = require("zod");
969
- var ResolverFieldSchema = import_zod20.z.custom((value) => {
970
- return import_zod20.z.string().regex(/([a-z0-9\_]+)(\s){1}([a-z0-9\_]+)/gi).safeParse(value).success;
948
+ var import_zod19 = require("zod");
949
+ var ResolverFieldSchema = import_zod19.z.custom((value) => {
950
+ return import_zod19.z.string().regex(/([a-z0-9\_]+)(\s){1}([a-z0-9\_]+)/gi).safeParse(value).success;
971
951
  }, `Invalid resolver field. Valid example: "Query list"`);
972
952
 
973
953
  // src/plugins/graphql/index.ts
974
954
  var import_aws_cdk_lib5 = require("aws-cdk-lib");
975
955
  var graphqlPlugin = definePlugin({
976
956
  name: "graphql",
977
- schema: import_zod21.z.object({
978
- defaults: import_zod21.z.object({
979
- graphql: import_zod21.z.record(ResourceIdSchema, import_zod21.z.object({
980
- authorization: import_zod21.z.object({
957
+ schema: import_zod20.z.object({
958
+ defaults: import_zod20.z.object({
959
+ graphql: import_zod20.z.record(ResourceIdSchema, import_zod20.z.object({
960
+ authorization: import_zod20.z.object({
981
961
  authorizer: FunctionSchema,
982
962
  ttl: DurationSchema.default("1 hour")
983
963
  }).optional(),
984
- mappingTemplate: import_zod21.z.object({
964
+ mappingTemplate: import_zod20.z.object({
985
965
  request: LocalFileSchema.optional(),
986
966
  response: LocalFileSchema.optional()
987
967
  }).optional()
988
968
  })).optional()
989
969
  }).default({}),
990
- stacks: import_zod21.z.object({
991
- graphql: import_zod21.z.record(ResourceIdSchema, import_zod21.z.object({
992
- schema: import_zod21.z.union([
970
+ stacks: import_zod20.z.object({
971
+ graphql: import_zod20.z.record(ResourceIdSchema, import_zod20.z.object({
972
+ schema: import_zod20.z.union([
993
973
  LocalFileSchema,
994
- import_zod21.z.array(LocalFileSchema).min(1)
974
+ import_zod20.z.array(LocalFileSchema).min(1)
995
975
  ]).optional(),
996
- resolvers: import_zod21.z.record(ResolverFieldSchema, FunctionSchema).optional()
976
+ resolvers: import_zod20.z.record(ResolverFieldSchema, FunctionSchema).optional()
997
977
  })).optional()
998
978
  }).array()
999
979
  }),
1000
- onBootstrap({ config: config2, stack, assets }) {
980
+ onBootstrap({ config, stack, assets }) {
1001
981
  const list3 = /* @__PURE__ */ new Set();
1002
- Object.values(config2.stacks).forEach((stackConfig) => {
982
+ Object.values(config.stacks).forEach((stackConfig) => {
1003
983
  Object.keys(stackConfig.graphql || {}).forEach((id) => {
1004
984
  list3.add(id);
1005
985
  });
1006
986
  });
1007
987
  list3.forEach((id) => {
1008
- const file = (0, import_path6.join)(assetDir, "graphql", config2.name, id, "schema.graphql");
1009
- const authorization = config2.defaults.graphql?.[id]?.authorization;
988
+ const file = (0, import_path6.join)(assetDir, "graphql", config.name, id, "schema.graphql");
989
+ const authorization = config.defaults.graphql?.[id]?.authorization;
1010
990
  const authProps = {};
1011
991
  if (authorization) {
1012
- const authorizer = toFunction({ config: config2, assets, stack }, `${id}-authorizer`, authorization.authorizer);
992
+ const authorizer = toFunction({ config, assets, stack }, `${id}-authorizer`, authorization.authorizer);
1013
993
  authProps.additionalAuthenticationProviders = [{
1014
994
  authenticationType: import_aws_appsync.AuthorizationType.LAMBDA,
1015
995
  lambdaAuthorizerConfig: {
@@ -1033,7 +1013,7 @@ var graphqlPlugin = definePlugin({
1033
1013
  resourceName: id,
1034
1014
  async build() {
1035
1015
  const schemas = [];
1036
- await Promise.all(Object.values(config2.stacks).map(async (stackConfig) => {
1016
+ await Promise.all(Object.values(config.stacks).map(async (stackConfig) => {
1037
1017
  const schemaFiles = toArray(stackConfig.graphql?.[id].schema || []);
1038
1018
  await Promise.all(schemaFiles.map(async (schemaFile) => {
1039
1019
  const schema3 = await (0, import_promises4.readFile)(schemaFile, "utf8");
@@ -1052,9 +1032,9 @@ var graphqlPlugin = definePlugin({
1052
1032
  });
1053
1033
  },
1054
1034
  onStack(ctx) {
1055
- const { config: config2, stack, stackConfig } = ctx;
1035
+ const { config, stack, stackConfig } = ctx;
1056
1036
  return Object.entries(stackConfig.graphql || {}).map(([id, props]) => {
1057
- const defaults = config2.defaults.graphql?.[id] || {};
1037
+ const defaults = config.defaults.graphql?.[id] || {};
1058
1038
  return Object.entries(props.resolvers || {}).map(([typeAndField, functionProps]) => {
1059
1039
  const api = import_aws_appsync.GraphqlApi.fromGraphqlApiAttributes(stack, toId("graphql", id), {
1060
1040
  graphqlApiId: import_aws_cdk_lib5.Fn.importValue(toId("graphql", id))
@@ -1077,6 +1057,272 @@ var graphqlPlugin = definePlugin({
1077
1057
  }
1078
1058
  });
1079
1059
 
1060
+ // src/plugins/pubsub.ts
1061
+ var import_zod21 = require("zod");
1062
+ var import_aws_iot = require("aws-cdk-lib/aws-iot");
1063
+ var import_aws_iam2 = require("aws-cdk-lib/aws-iam");
1064
+ var import_change_case3 = require("change-case");
1065
+ var pubsubPlugin = definePlugin({
1066
+ name: "pubsub",
1067
+ schema: import_zod21.z.object({
1068
+ stacks: import_zod21.z.object({
1069
+ pubsub: import_zod21.z.record(ResourceIdSchema, import_zod21.z.object({
1070
+ sql: import_zod21.z.string(),
1071
+ sqlVersion: import_zod21.z.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23"),
1072
+ consumer: FunctionSchema
1073
+ })).optional()
1074
+ }).array()
1075
+ }),
1076
+ onStack(ctx) {
1077
+ const { stack, stackConfig, bind } = ctx;
1078
+ bind((lambda) => {
1079
+ lambda.addToRolePolicy(new import_aws_iam2.PolicyStatement({
1080
+ actions: ["iot:publish"],
1081
+ resources: ["*"]
1082
+ }));
1083
+ });
1084
+ return Object.entries(stackConfig.pubsub || {}).map(([id, props]) => {
1085
+ const lambda = toFunction(ctx, id, props.consumer);
1086
+ new import_aws_iot.CfnTopicRule(stack, toId("pubsub", id), {
1087
+ ruleName: (0, import_change_case3.snakeCase)(toName(stack, id)),
1088
+ topicRulePayload: {
1089
+ sql: props.sql,
1090
+ awsIotSqlVersion: props.sqlVersion,
1091
+ actions: [{
1092
+ lambda: {
1093
+ functionArn: lambda.functionArn
1094
+ }
1095
+ }]
1096
+ }
1097
+ });
1098
+ return lambda;
1099
+ });
1100
+ }
1101
+ });
1102
+
1103
+ // src/plugins/http/index.ts
1104
+ var import_zod23 = require("zod");
1105
+ var import_aws_ec2 = require("aws-cdk-lib/aws-ec2");
1106
+ var import_aws_elasticloadbalancingv2 = require("aws-cdk-lib/aws-elasticloadbalancingv2");
1107
+ var import_aws_route53 = require("aws-cdk-lib/aws-route53");
1108
+ var import_aws_route53_targets = require("aws-cdk-lib/aws-route53-targets");
1109
+ var import_aws_elasticloadbalancingv2_targets = require("aws-cdk-lib/aws-elasticloadbalancingv2-targets");
1110
+ var import_aws_cdk_lib6 = require("aws-cdk-lib");
1111
+ var import_aws_certificatemanager = require("aws-cdk-lib/aws-certificatemanager");
1112
+ var import_change_case4 = require("change-case");
1113
+
1114
+ // src/plugins/http/schema/route.ts
1115
+ var import_zod22 = require("zod");
1116
+ var RouteSchema = import_zod22.z.custom((route) => {
1117
+ return import_zod22.z.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS)(\s\/[a-z0-9\+\_\-\/]*)$/ig).safeParse(route).success;
1118
+ }, "Invalid route");
1119
+
1120
+ // src/plugins/http/util/priority.ts
1121
+ var strToInt = (str) => {
1122
+ return parseInt(Buffer.from(str, "utf8").toString("hex"), 16);
1123
+ };
1124
+ var generatePriority = (stackName, route) => {
1125
+ const start = strToInt(stackName) % 500 + 1;
1126
+ const end = strToInt(route) % 100;
1127
+ const priority = start + "" + end;
1128
+ return parseInt(priority, 10);
1129
+ };
1130
+
1131
+ // src/plugins/http/index.ts
1132
+ var httpPlugin = definePlugin({
1133
+ name: "http",
1134
+ schema: import_zod23.z.object({
1135
+ defaults: import_zod23.z.object({
1136
+ http: import_zod23.z.record(
1137
+ ResourceIdSchema,
1138
+ import_zod23.z.object({
1139
+ domain: import_zod23.z.string(),
1140
+ subDomain: import_zod23.z.string()
1141
+ })
1142
+ ).optional()
1143
+ }).default({}),
1144
+ stacks: import_zod23.z.object({
1145
+ http: import_zod23.z.record(
1146
+ ResourceIdSchema,
1147
+ import_zod23.z.record(RouteSchema, FunctionSchema)
1148
+ ).optional()
1149
+ }).array()
1150
+ }),
1151
+ onBootstrap({ stack, config }) {
1152
+ if (Object.keys(config.defaults?.http || {}).length === 0) {
1153
+ return;
1154
+ }
1155
+ const vpc = new import_aws_ec2.Vpc(stack, toId("vpc", "http"), {
1156
+ subnetConfiguration: [{
1157
+ name: "public",
1158
+ subnetType: import_aws_ec2.SubnetType.PUBLIC,
1159
+ cidrMask: 24
1160
+ }],
1161
+ availabilityZones: [
1162
+ config.region + "a",
1163
+ config.region + "b",
1164
+ config.region + "c"
1165
+ ]
1166
+ });
1167
+ const securityGroup = new import_aws_ec2.SecurityGroup(stack, toId("security-group", "http"), {
1168
+ vpc
1169
+ });
1170
+ securityGroup.addIngressRule(import_aws_ec2.Peer.anyIpv4(), import_aws_ec2.Port.tcp(443));
1171
+ securityGroup.addIngressRule(import_aws_ec2.Peer.anyIpv6(), import_aws_ec2.Port.tcp(443));
1172
+ new import_aws_cdk_lib6.CfnOutput(stack, toId("output", "http-vpc"), {
1173
+ exportName: "http-vpc-id",
1174
+ value: vpc.vpcId
1175
+ });
1176
+ new import_aws_cdk_lib6.CfnOutput(stack, toId("output", "http-security-group"), {
1177
+ exportName: "http-security-group-id",
1178
+ value: securityGroup.securityGroupId
1179
+ });
1180
+ Object.entries(config.defaults?.http || {}).forEach(([id, props]) => {
1181
+ const loadBalancer = new import_aws_elasticloadbalancingv2.ApplicationLoadBalancer(stack, toId("load-balancer", id), {
1182
+ vpc,
1183
+ securityGroup
1184
+ });
1185
+ const zone = import_aws_route53.HostedZone.fromHostedZoneAttributes(
1186
+ stack,
1187
+ toId("hosted-zone", id),
1188
+ {
1189
+ hostedZoneId: import_aws_cdk_lib6.Token.asString(import_aws_cdk_lib6.Fn.ref(toId("hosted-zone", props.domain))),
1190
+ zoneName: props.domain + "."
1191
+ }
1192
+ );
1193
+ const certificate = import_aws_certificatemanager.Certificate.fromCertificateArn(
1194
+ stack,
1195
+ toId("certificate", id),
1196
+ import_aws_cdk_lib6.Token.asString(import_aws_cdk_lib6.Fn.ref(toId("certificate", props.domain)))
1197
+ );
1198
+ const target = import_aws_route53.RecordTarget.fromAlias(new import_aws_route53_targets.LoadBalancerTarget(loadBalancer));
1199
+ const recordName = props.subDomain ? `${props.subDomain}.${props.domain}` : props.domain;
1200
+ new import_aws_route53.RecordSet(stack, toId("record-set", id), {
1201
+ zone,
1202
+ target,
1203
+ recordName,
1204
+ recordType: import_aws_route53.RecordType.A
1205
+ });
1206
+ const listener = loadBalancer.addListener(toId("listener", id), {
1207
+ port: 443,
1208
+ protocol: import_aws_elasticloadbalancingv2.ApplicationProtocol.HTTPS,
1209
+ certificates: [certificate],
1210
+ defaultAction: import_aws_elasticloadbalancingv2.ListenerAction.fixedResponse(404, {
1211
+ contentType: "application/json",
1212
+ messageBody: JSON.stringify({
1213
+ message: "Route not found"
1214
+ })
1215
+ })
1216
+ });
1217
+ new import_aws_cdk_lib6.CfnOutput(stack, toId("output", `http-${id}-listener`), {
1218
+ exportName: `http-${id}-listener-arn`,
1219
+ value: listener.listenerArn
1220
+ });
1221
+ });
1222
+ },
1223
+ onStack(ctx) {
1224
+ const { stack, stackConfig } = ctx;
1225
+ return Object.entries(stackConfig.http || {}).map(([id, routes]) => {
1226
+ const listener = import_aws_elasticloadbalancingv2.ApplicationListener.fromApplicationListenerAttributes(stack, toId("listener", id), {
1227
+ listenerArn: import_aws_cdk_lib6.Fn.importValue(`http-${id}-listener-arn`),
1228
+ securityGroup: import_aws_ec2.SecurityGroup.fromLookupById(
1229
+ stack,
1230
+ toId("security-group", id),
1231
+ "http-security-group-id"
1232
+ )
1233
+ });
1234
+ return Object.entries(routes).map(([route, props]) => {
1235
+ const lambda = toFunction(ctx, (0, import_change_case4.paramCase)(route), props);
1236
+ const [method, ...paths] = route.split(" ");
1237
+ const path = paths.join(" ");
1238
+ new import_aws_elasticloadbalancingv2.ApplicationListenerRule(stack, toId("listener-rule", route), {
1239
+ listener,
1240
+ priority: generatePriority(stackConfig.name, route),
1241
+ action: import_aws_elasticloadbalancingv2.ListenerAction.forward([
1242
+ new import_aws_elasticloadbalancingv2.ApplicationTargetGroup(stack, toId("target-group", route), {
1243
+ targets: [new import_aws_elasticloadbalancingv2_targets.LambdaTarget(lambda)]
1244
+ })
1245
+ ]),
1246
+ conditions: [
1247
+ import_aws_elasticloadbalancingv2.ListenerCondition.httpRequestMethods([method]),
1248
+ import_aws_elasticloadbalancingv2.ListenerCondition.pathPatterns([path])
1249
+ ]
1250
+ });
1251
+ return lambda;
1252
+ });
1253
+ }).flat();
1254
+ }
1255
+ });
1256
+
1257
+ // src/plugins/domain/index.ts
1258
+ var import_zod26 = require("zod");
1259
+ var import_aws_route533 = require("aws-cdk-lib/aws-route53");
1260
+ var import_aws_certificatemanager2 = require("aws-cdk-lib/aws-certificatemanager");
1261
+
1262
+ // src/plugins/domain/schema/record-type.ts
1263
+ var import_aws_route532 = require("aws-cdk-lib/aws-route53");
1264
+ var import_zod24 = require("zod");
1265
+ var types4 = {
1266
+ "A": import_aws_route532.RecordType.A,
1267
+ "AAAA": import_aws_route532.RecordType.AAAA,
1268
+ "MX": import_aws_route532.RecordType.MX,
1269
+ "TXT": import_aws_route532.RecordType.TXT,
1270
+ "CNAME": import_aws_route532.RecordType.CNAME
1271
+ };
1272
+ var RecordTypeSchema = import_zod24.z.enum(Object.keys(types4)).transform((value) => types4[value]);
1273
+
1274
+ // src/plugins/domain/schema/domain-name.ts
1275
+ var import_zod25 = require("zod");
1276
+ var DomainNameSchema = import_zod25.z.string().regex(/[a-z\-\_\.]/g, "Invalid domain name");
1277
+
1278
+ // src/plugins/domain/index.ts
1279
+ var import_aws_cdk_lib7 = require("aws-cdk-lib");
1280
+ var domainPlugin = definePlugin({
1281
+ name: "domain",
1282
+ schema: import_zod26.z.object({
1283
+ domains: import_zod26.z.record(DomainNameSchema, import_zod26.z.object({
1284
+ name: DomainNameSchema.optional(),
1285
+ type: RecordTypeSchema,
1286
+ ttl: DurationSchema,
1287
+ records: import_zod26.z.string().array()
1288
+ }).array()).optional()
1289
+ }),
1290
+ onBootstrap({ config, stack }) {
1291
+ Object.entries(config.domains || {}).forEach(([domain, dnsRecords]) => {
1292
+ const hostedZone = new import_aws_route533.HostedZone(stack, toId("hosted-zone", domain), {
1293
+ zoneName: domain,
1294
+ addTrailingDot: true
1295
+ });
1296
+ hostedZone.node.defaultChild.overrideLogicalId(toId("hosted-zone", domain));
1297
+ const certificate = new import_aws_certificatemanager2.Certificate(stack, toId("certificate", domain), {
1298
+ domainName: domain,
1299
+ validation: import_aws_certificatemanager2.CertificateValidation.fromDns(hostedZone),
1300
+ subjectAlternativeNames: [`*.${domain}`]
1301
+ });
1302
+ certificate.node.defaultChild.overrideLogicalId(toId("certificate", domain));
1303
+ new import_aws_cdk_lib7.CfnOutput(stack, toId("output-hosted-zone", domain), {
1304
+ exportName: toExportName(`hosted-zone-${domain}-id`),
1305
+ value: hostedZone.hostedZoneId
1306
+ });
1307
+ new import_aws_cdk_lib7.CfnOutput(stack, toId("output-certificate", domain), {
1308
+ exportName: toExportName(`certificate-${domain}-arn`),
1309
+ value: certificate.certificateArn
1310
+ });
1311
+ if (dnsRecords.length > 0) {
1312
+ new import_aws_route533.CfnRecordSetGroup(stack, toId("record-set-group", domain), {
1313
+ hostedZoneId: hostedZone.hostedZoneId,
1314
+ recordSets: dnsRecords.map((props) => ({
1315
+ name: props.name || "",
1316
+ type: props.type,
1317
+ ttl: props.ttl.toSeconds().toString(),
1318
+ resourceRecords: props.records
1319
+ }))
1320
+ });
1321
+ }
1322
+ });
1323
+ }
1324
+ });
1325
+
1080
1326
  // src/plugins/index.ts
1081
1327
  var defaultPlugins = [
1082
1328
  functionPlugin,
@@ -1085,22 +1331,25 @@ var defaultPlugins = [
1085
1331
  tablePlugin,
1086
1332
  storePlugin,
1087
1333
  topicPlugin,
1088
- searchPlugin,
1089
- graphqlPlugin
1334
+ // searchPlugin,
1335
+ graphqlPlugin,
1336
+ pubsubPlugin,
1337
+ domainPlugin,
1338
+ httpPlugin
1090
1339
  ];
1091
1340
 
1092
1341
  // src/stack/app-bootstrap.ts
1093
- var appBootstrapStack = ({ config: config2, app, assets }) => {
1094
- const stack = new import_aws_cdk_lib6.Stack(app, "bootstrap", {
1095
- stackName: `${config2.name}-bootstrap`
1342
+ var appBootstrapStack = ({ config, app, assets }) => {
1343
+ const stack = new import_aws_cdk_lib8.Stack(app, "bootstrap", {
1344
+ stackName: `${config.name}-bootstrap`
1096
1345
  });
1097
1346
  const plugins = [
1098
1347
  ...defaultPlugins,
1099
- ...config2.plugins || []
1348
+ ...config.plugins || []
1100
1349
  ];
1101
1350
  debug("Run plugin onBootstrap listeners");
1102
1351
  const functions = plugins.map((plugin) => plugin.onBootstrap?.({
1103
- config: config2,
1352
+ config,
1104
1353
  app,
1105
1354
  stack,
1106
1355
  assets
@@ -1124,9 +1373,9 @@ var flattenDependencyTree = (stacks) => {
1124
1373
  return list3;
1125
1374
  };
1126
1375
  var createDependencyTree = (stacks, startingLevel) => {
1127
- const list3 = stacks.map(({ stack, config: config2 }) => ({
1376
+ const list3 = stacks.map(({ stack, config }) => ({
1128
1377
  stack,
1129
- depends: config2?.depends?.map((dep) => dep.name) || []
1378
+ depends: config?.depends?.map((dep) => dep.name) || []
1130
1379
  }));
1131
1380
  const findChildren = (list4, parents, level) => {
1132
1381
  const children = [];
@@ -1198,11 +1447,11 @@ var Assets = class {
1198
1447
  };
1199
1448
 
1200
1449
  // src/app.ts
1201
- var makeApp = (config2) => {
1202
- return new import_aws_cdk_lib7.App({
1450
+ var makeApp = (config) => {
1451
+ return new import_aws_cdk_lib9.App({
1203
1452
  outdir: assemblyDir,
1204
- defaultStackSynthesizer: new import_aws_cdk_lib7.DefaultStackSynthesizer({
1205
- fileAssetsBucketName: assetBucketName(config2),
1453
+ defaultStackSynthesizer: new import_aws_cdk_lib9.DefaultStackSynthesizer({
1454
+ fileAssetsBucketName: assetBucketName(config),
1206
1455
  fileAssetPublishingRoleArn: "",
1207
1456
  generateBootstrapVersionRule: false
1208
1457
  })
@@ -1219,26 +1468,26 @@ var getAllDepends = (filters) => {
1219
1468
  walk(filters);
1220
1469
  return list3;
1221
1470
  };
1222
- var toApp = async (config2, filters) => {
1471
+ var toApp = async (config, filters) => {
1223
1472
  const assets = new Assets();
1224
- const app = makeApp(config2);
1473
+ const app = makeApp(config);
1225
1474
  const stacks = [];
1226
1475
  const plugins = [
1227
1476
  ...defaultPlugins,
1228
- ...config2.plugins || []
1477
+ ...config.plugins || []
1229
1478
  ];
1230
1479
  debug("Plugins detected:", plugins.map((plugin) => style.info(plugin.name)).join(", "));
1231
1480
  debug("Run plugin onApp listeners");
1232
- plugins.forEach((plugin) => plugin.onApp?.({ config: config2, app, assets }));
1233
- const bootstrap2 = appBootstrapStack({ config: config2, app, assets });
1481
+ plugins.forEach((plugin) => plugin.onApp?.({ config, app, assets }));
1482
+ const bootstrap2 = appBootstrapStack({ config, app, assets });
1234
1483
  debug("Stack filters:", filters.map((filter) => style.info(filter)).join(", "));
1235
- const filterdStacks = filters.length === 0 ? config2.stacks : getAllDepends(
1484
+ const filterdStacks = filters.length === 0 ? config.stacks : getAllDepends(
1236
1485
  // config.stacks,
1237
- config2.stacks.filter((stack) => filters.includes(stack.name))
1486
+ config.stacks.filter((stack) => filters.includes(stack.name))
1238
1487
  );
1239
1488
  for (const stackConfig of filterdStacks) {
1240
1489
  const { stack, bindings } = toStack({
1241
- config: config2,
1490
+ config,
1242
1491
  stackConfig,
1243
1492
  assets,
1244
1493
  plugins,
@@ -1266,63 +1515,6 @@ var toApp = async (config2, filters) => {
1266
1515
  };
1267
1516
  };
1268
1517
 
1269
- // src/cli/ui/layout/basic.ts
1270
- var br = () => {
1271
- return "\n";
1272
- };
1273
- var hr = () => {
1274
- return (term) => {
1275
- term.out.write([
1276
- style.placeholder("\u2500".repeat(term.out.width())),
1277
- br()
1278
- ]);
1279
- };
1280
- };
1281
-
1282
- // src/cli/ui/layout/logs.ts
1283
- var import_wrap_ansi = __toESM(require("wrap-ansi"), 1);
1284
- var previous = /* @__PURE__ */ new Date();
1285
- var logs = () => {
1286
- if (!process.env.VERBOSE) {
1287
- return [];
1288
- }
1289
- const logs2 = flushDebug();
1290
- return (term) => {
1291
- term.out.write([
1292
- hr(),
1293
- br(),
1294
- " ".repeat(3),
1295
- style.label("Debug Logs:"),
1296
- br(),
1297
- br(),
1298
- logs2.map((log) => {
1299
- const diff = log.date.getTime() - previous.getTime();
1300
- const time = `+${diff}`.padStart(8);
1301
- previous = log.date;
1302
- return (0, import_wrap_ansi.default)([
1303
- style.attr(`${time}${style.attr.dim("ms")}`),
1304
- " [ ",
1305
- log.type,
1306
- " ] ",
1307
- log.message,
1308
- br(),
1309
- log.type === "error" ? br() : ""
1310
- ].join(""), term.out.width(), { hard: true, trim: false });
1311
- }),
1312
- br(),
1313
- hr()
1314
- ]);
1315
- };
1316
- };
1317
-
1318
- // src/cli/ui/layout/footer.ts
1319
- var footer = () => {
1320
- return [
1321
- br(),
1322
- logs()
1323
- ];
1324
- };
1325
-
1326
1518
  // src/config.ts
1327
1519
  var import_path11 = require("path");
1328
1520
 
@@ -1343,17 +1535,17 @@ var getCredentials = (profile) => {
1343
1535
  };
1344
1536
 
1345
1537
  // src/schema/app.ts
1346
- var import_zod25 = require("zod");
1538
+ var import_zod30 = require("zod");
1347
1539
 
1348
1540
  // src/schema/stack.ts
1349
- var import_zod22 = require("zod");
1350
- var StackSchema = import_zod22.z.object({
1541
+ var import_zod27 = require("zod");
1542
+ var StackSchema = import_zod27.z.object({
1351
1543
  name: ResourceIdSchema,
1352
- depends: import_zod22.z.array(import_zod22.z.lazy(() => StackSchema)).optional()
1544
+ depends: import_zod27.z.array(import_zod27.z.lazy(() => StackSchema)).optional()
1353
1545
  });
1354
1546
 
1355
1547
  // src/schema/region.ts
1356
- var import_zod23 = require("zod");
1548
+ var import_zod28 = require("zod");
1357
1549
  var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
1358
1550
  var AF = ["af-south-1"];
1359
1551
  var AP = ["ap-east-1", "ap-south-2", "ap-southeast-3", "ap-southeast-4", "ap-south-1", "ap-northeast-3", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1"];
@@ -1370,29 +1562,29 @@ var regions = [
1370
1562
  ...ME,
1371
1563
  ...SA
1372
1564
  ];
1373
- var RegionSchema = import_zod23.z.enum(regions);
1565
+ var RegionSchema = import_zod28.z.enum(regions);
1374
1566
 
1375
1567
  // src/schema/plugin.ts
1376
- var import_zod24 = require("zod");
1377
- var PluginSchema = import_zod24.z.object({
1378
- name: import_zod24.z.string(),
1379
- schema: import_zod24.z.custom().optional(),
1568
+ var import_zod29 = require("zod");
1569
+ var PluginSchema = import_zod29.z.object({
1570
+ name: import_zod29.z.string(),
1571
+ schema: import_zod29.z.custom().optional(),
1380
1572
  // depends: z.array(z.lazy(() => PluginSchema)).optional(),
1381
- onBootstrap: import_zod24.z.function().returns(import_zod24.z.any()).optional(),
1382
- onStack: import_zod24.z.function().returns(import_zod24.z.any()).optional(),
1383
- onApp: import_zod24.z.function().returns(import_zod24.z.void()).optional()
1573
+ onBootstrap: import_zod29.z.function().returns(import_zod29.z.any()).optional(),
1574
+ onStack: import_zod29.z.function().returns(import_zod29.z.any()).optional(),
1575
+ onApp: import_zod29.z.function().returns(import_zod29.z.void()).optional()
1384
1576
  // bind: z.function().optional(),
1385
1577
  });
1386
1578
 
1387
1579
  // src/schema/app.ts
1388
- var AppSchema = import_zod25.z.object({
1580
+ var AppSchema = import_zod30.z.object({
1389
1581
  name: ResourceIdSchema,
1390
1582
  region: RegionSchema,
1391
- profile: import_zod25.z.string(),
1392
- stage: import_zod25.z.string().regex(/[a-z]+/).default("prod"),
1393
- defaults: import_zod25.z.object({}).default({}),
1394
- stacks: import_zod25.z.array(StackSchema).min(1),
1395
- plugins: import_zod25.z.array(PluginSchema).optional()
1583
+ profile: import_zod30.z.string(),
1584
+ stage: import_zod30.z.string().regex(/[a-z]+/).default("prod"),
1585
+ defaults: import_zod30.z.object({}).default({}),
1586
+ stacks: import_zod30.z.array(StackSchema).min(1),
1587
+ plugins: import_zod30.z.array(PluginSchema).optional()
1396
1588
  });
1397
1589
 
1398
1590
  // src/util/import.ts
@@ -1408,7 +1600,7 @@ var resolveFileNameExtension = async (path) => {
1408
1600
  "/index.js"
1409
1601
  ];
1410
1602
  for (const option of options) {
1411
- const file = path + option;
1603
+ const file = path.replace(/\.js$/, "") + option;
1412
1604
  let stat;
1413
1605
  try {
1414
1606
  stat = await (0, import_promises5.lstat)(file);
@@ -1426,17 +1618,18 @@ var resolveDir = (path) => {
1426
1618
  };
1427
1619
  var importFile = async (path) => {
1428
1620
  const load = async (file) => {
1621
+ debug("Load file", file);
1429
1622
  let { code: code2 } = await (0, import_core3.transformFile)(file, {
1430
1623
  isModule: true
1431
1624
  });
1432
1625
  const path2 = (0, import_path9.dirname)(file);
1433
1626
  const dir = resolveDir(file);
1434
1627
  code2 = code2.replaceAll("__dirname", `"${dir}"`);
1435
- const matches = code2.match(/import\s*{\s*[a-z0-9\_]+\s*}\s*from\s*('|")(\.[\/a-z0-9\_\-]+)('|");?/ig);
1628
+ const matches = code2.match(/(import|export)\s*{\s*[a-z0-9\_\,\s\*]+\s*}\s*from\s*('|")(\.\.?[\/a-z0-9\_\-\.]+)('|");?/ig);
1436
1629
  if (!matches)
1437
1630
  return code2;
1438
1631
  await Promise.all(matches?.map(async (match) => {
1439
- const parts = /('|")(\.[\/a-z0-9\_\-]+)('|")/ig.exec(match);
1632
+ const parts = /('|")(\.\.?[\/a-z0-9\_\-\.]+)('|")/ig.exec(match);
1440
1633
  const from = parts[2];
1441
1634
  const file2 = await resolveFileNameExtension((0, import_path9.join)(path2, from));
1442
1635
  const result = await load(file2);
@@ -1456,11 +1649,7 @@ var importConfig = async (options) => {
1456
1649
  debug("Import config file");
1457
1650
  const fileName = (0, import_path11.join)(process.cwd(), options.configFile || "awsless.config.ts");
1458
1651
  const module2 = await importFile(fileName);
1459
- const appConfig = typeof module2.default === "function" ? await module2.default({
1460
- profile: options.profile,
1461
- region: options.region,
1462
- stage: options.stage
1463
- }) : module2.default;
1652
+ const appConfig = typeof module2.default === "function" ? await module2.default(options) : module2.default;
1464
1653
  debug("Validate config file");
1465
1654
  const plugins = [
1466
1655
  ...defaultPlugins,
@@ -1472,19 +1661,32 @@ var importConfig = async (options) => {
1472
1661
  schema2 = schema2.and(plugin.schema);
1473
1662
  }
1474
1663
  }
1475
- const config2 = await schema2.parseAsync(appConfig);
1476
- debug("Load credentials", style.info(config2.profile));
1477
- const credentials = getCredentials(config2.profile);
1664
+ const config = await schema2.parseAsync(appConfig);
1665
+ debug("Load credentials", style.info(config.profile));
1666
+ const credentials = getCredentials(config.profile);
1478
1667
  debug("Load AWS account ID");
1479
- const account = await getAccountId(credentials, config2.region);
1668
+ const account = await getAccountId(credentials, config.region);
1480
1669
  debug("Account ID:", style.info(account));
1481
1670
  return {
1482
- ...config2,
1671
+ ...config,
1483
1672
  account,
1484
1673
  credentials
1485
1674
  };
1486
1675
  };
1487
1676
 
1677
+ // src/cli/ui/layout/basic.ts
1678
+ var br = () => {
1679
+ return "\n";
1680
+ };
1681
+ var hr = () => {
1682
+ return (term) => {
1683
+ term.out.write([
1684
+ style.placeholder("\u2500".repeat(term.out.width())),
1685
+ br()
1686
+ ]);
1687
+ };
1688
+ };
1689
+
1488
1690
  // src/cli/ui/layout/list.ts
1489
1691
  var list = (data) => {
1490
1692
  const padding = 3;
@@ -1492,26 +1694,26 @@ var list = (data) => {
1492
1694
  const size = Object.keys(data).reduce((total, name) => {
1493
1695
  return name.length > total ? name.length : total;
1494
1696
  }, 0);
1495
- return Object.entries(data).map(([name, value]) => [
1496
- " ".repeat(padding),
1497
- style.label((name + ":").padEnd(size + gap + 1)),
1498
- value,
1499
- br()
1500
- ]);
1697
+ return (term) => {
1698
+ term.out.gap();
1699
+ term.out.write(Object.entries(data).map(([name, value]) => [
1700
+ " ".repeat(padding),
1701
+ style.label((name + ":").padEnd(size + gap + 1)),
1702
+ value,
1703
+ br()
1704
+ ]));
1705
+ term.out.gap();
1706
+ };
1501
1707
  };
1502
1708
 
1503
1709
  // src/cli/ui/layout/header.ts
1504
- var header = (config2) => {
1505
- return [
1506
- br(),
1507
- list({
1508
- App: config2.name,
1509
- Stage: config2.stage,
1510
- Region: config2.region,
1511
- Profile: config2.profile
1512
- }),
1513
- br()
1514
- ];
1710
+ var header = (config) => {
1711
+ return list({
1712
+ App: config.name,
1713
+ Stage: config.stage,
1714
+ Region: config.region,
1715
+ Profile: config.profile
1716
+ });
1515
1717
  };
1516
1718
 
1517
1719
  // src/util/timer.ts
@@ -1578,16 +1780,16 @@ var createSpinner = () => {
1578
1780
  };
1579
1781
 
1580
1782
  // src/cli/ui/layout/dialog.ts
1581
- var import_wrap_ansi2 = __toESM(require("wrap-ansi"), 1);
1783
+ var import_wrap_ansi = __toESM(require("wrap-ansi"), 1);
1582
1784
  var dialog = (type, lines) => {
1583
1785
  const padding = 3;
1584
1786
  const icon = style[type](symbol[type].padEnd(padding));
1585
1787
  return (term) => {
1586
1788
  term.out.write(lines.map((line, i) => {
1587
1789
  if (i === 0) {
1588
- return icon + (0, import_wrap_ansi2.default)(line, term.out.width(), { hard: true });
1790
+ return icon + (0, import_wrap_ansi.default)(line, term.out.width(), { hard: true });
1589
1791
  }
1590
- return (0, import_wrap_ansi2.default)(" ".repeat(padding) + line, term.out.width(), { hard: true });
1792
+ return (0, import_wrap_ansi.default)(" ".repeat(padding) + line, term.out.width(), { hard: true });
1591
1793
  }).join(br()) + br());
1592
1794
  };
1593
1795
  };
@@ -1729,6 +1931,7 @@ var Renderer = class {
1729
1931
  fragments = [];
1730
1932
  unsubs = [];
1731
1933
  timeout;
1934
+ flushing = false;
1732
1935
  screen = [];
1733
1936
  width() {
1734
1937
  return this.output.columns;
@@ -1748,14 +1951,58 @@ var Renderer = class {
1748
1951
  this.update();
1749
1952
  return fragment;
1750
1953
  }
1954
+ gap() {
1955
+ const walk = (fragment) => {
1956
+ if (typeof fragment === "string") {
1957
+ return fragment;
1958
+ }
1959
+ if (Array.isArray(fragment)) {
1960
+ return fragment.map(walk).join("");
1961
+ }
1962
+ return walk(fragment.get());
1963
+ };
1964
+ const end = walk(this.fragments.slice(-2));
1965
+ if (end.endsWith("\n\n")) {
1966
+ } else if (end.endsWith("\n")) {
1967
+ this.fragments.push("\n");
1968
+ } else {
1969
+ this.fragments.push("\n\n");
1970
+ }
1971
+ this.update();
1972
+ }
1751
1973
  update() {
1752
1974
  clearTimeout(this.timeout);
1753
1975
  this.timeout = setTimeout(() => {
1754
1976
  this.flush();
1755
1977
  }, 0);
1756
1978
  }
1757
- flush() {
1979
+ async end() {
1980
+ this.gap();
1981
+ await this.flush();
1982
+ const y = this.screen.length - 1;
1983
+ await this.setCursor(0, y);
1984
+ }
1985
+ setCursor(x, y) {
1986
+ return new Promise((resolve) => {
1987
+ this.output.cursorTo?.(x, y, () => resolve(void 0));
1988
+ });
1989
+ }
1990
+ writeString(value) {
1991
+ return new Promise((resolve) => {
1992
+ this.output.write?.(value, () => resolve(void 0));
1993
+ });
1994
+ }
1995
+ clearLine() {
1996
+ return new Promise((resolve) => {
1997
+ this.output.clearLine?.(1, () => resolve(void 0));
1998
+ });
1999
+ }
2000
+ async flush() {
1758
2001
  clearTimeout(this.timeout);
2002
+ if (this.flushing) {
2003
+ this.update();
2004
+ return;
2005
+ }
1759
2006
  const walk = (fragment) => {
1760
2007
  if (typeof fragment === "string") {
1761
2008
  return fragment;
@@ -1771,34 +2018,40 @@ var Renderer = class {
1771
2018
  this.unsubs.forEach((unsub) => unsub());
1772
2019
  this.unsubs = [];
1773
2020
  const screen = walk(this.fragments).split("\n");
2021
+ const height = this.height();
1774
2022
  const oldSize = this.screen.length;
1775
2023
  const newSize = screen.length;
1776
2024
  const size = Math.max(oldSize, newSize);
1777
- const height = this.height();
1778
2025
  const start = Math.max(oldSize - height, 0);
2026
+ this.flushing = true;
1779
2027
  for (let y = start; y < size; y++) {
1780
- const line = screen[y];
1781
- if (line !== this.screen[y]) {
1782
- if (y > oldSize) {
1783
- const x = (this.screen[y - 1]?.length || 0) - 1;
1784
- this.output.cursorTo?.(x, y - 1 - start);
1785
- this.output.write?.("\n" + line);
2028
+ const newLine = screen[y];
2029
+ const oldLine = this.screen[y];
2030
+ if (newLine !== oldLine) {
2031
+ if (y >= oldSize && y !== 0) {
2032
+ const p = y - start - 1;
2033
+ const x = screen[y - 1]?.length || 0;
2034
+ await this.setCursor(x, p);
2035
+ await this.writeString("\n" + newLine);
1786
2036
  } else {
1787
- this.output.cursorTo?.(0, y - start);
1788
- this.output.write?.(line);
2037
+ await this.setCursor(0, y - start);
2038
+ await this.writeString(newLine);
2039
+ await this.clearLine();
1789
2040
  }
1790
- this.output.clearLine?.(1);
1791
2041
  }
1792
2042
  }
1793
2043
  this.screen = screen;
1794
- }
1795
- clear() {
1796
- let count = this.output.rows;
1797
- while (count--) {
1798
- this.output.write("\n");
2044
+ this.flushing = false;
2045
+ }
2046
+ async clear() {
2047
+ await this.setCursor(0, 0);
2048
+ await this.writeString("\n".repeat(this.height()));
2049
+ await this.setCursor(0, 0);
2050
+ if (this.output.clearScreenDown) {
2051
+ await new Promise((resolve) => {
2052
+ this.output.clearScreenDown(() => resolve(void 0));
2053
+ });
1799
2054
  }
1800
- this.output.cursorTo?.(0, 0);
1801
- this.output.clearScreenDown?.();
1802
2055
  }
1803
2056
  };
1804
2057
 
@@ -1814,22 +2067,62 @@ var logo = () => {
1814
2067
  return [
1815
2068
  style.warning("\u26A1\uFE0F "),
1816
2069
  style.primary("AWS"),
1817
- style.primary.dim("LESS"),
1818
- br()
2070
+ style.primary.dim("LESS")
1819
2071
  ];
1820
2072
  };
1821
2073
 
2074
+ // src/cli/ui/layout/logs.ts
2075
+ var import_wrap_ansi2 = __toESM(require("wrap-ansi"), 1);
2076
+ var previous = /* @__PURE__ */ new Date();
2077
+ var logs = () => {
2078
+ if (!process.env.VERBOSE) {
2079
+ return [];
2080
+ }
2081
+ const logs2 = flushDebug();
2082
+ return (term) => {
2083
+ term.out.gap();
2084
+ term.out.write([
2085
+ hr(),
2086
+ br(),
2087
+ " ".repeat(3),
2088
+ style.label("Debug Logs:"),
2089
+ br(),
2090
+ br(),
2091
+ logs2.map((log) => {
2092
+ const diff = log.date.getTime() - previous.getTime();
2093
+ const time = `+${diff}`.padStart(8);
2094
+ previous = log.date;
2095
+ return (0, import_wrap_ansi2.default)([
2096
+ style.attr(`${time}${style.attr.dim("ms")}`),
2097
+ " [ ",
2098
+ log.type,
2099
+ " ] ",
2100
+ log.message,
2101
+ br(),
2102
+ log.type === "error" ? br() : ""
2103
+ ].join(""), term.out.width(), { hard: true, trim: false });
2104
+ }),
2105
+ br(),
2106
+ hr()
2107
+ ]);
2108
+ };
2109
+ };
2110
+
1822
2111
  // src/cli/ui/layout/layout.ts
1823
2112
  var layout = async (cb) => {
1824
2113
  const term = createTerminal();
1825
- term.out.clear();
2114
+ await term.out.clear();
2115
+ term.out.write(br());
1826
2116
  term.out.write(logo());
2117
+ term.out.gap();
1827
2118
  try {
1828
2119
  const options = program.optsWithGlobals();
1829
- const config2 = await importConfig(options);
1830
- term.out.write(header(config2));
1831
- await cb(config2, term.out.write.bind(term.out), term);
2120
+ const config = await importConfig(options);
2121
+ term.out.write(header(config));
2122
+ term.out.gap();
2123
+ await cb(config, term.out.write.bind(term.out), term);
1832
2124
  } catch (error) {
2125
+ term.out.gap();
1833
2126
  if (error instanceof Error) {
1834
2127
  term.out.write(dialog("error", [error.message]));
1835
2128
  } else if (typeof error === "string") {
@@ -1840,7 +2133,9 @@ var layout = async (cb) => {
1840
2133
  debugError(error);
1841
2134
  } finally {
1842
2135
  debug("Exit");
1843
- term.out.write(footer());
2136
+ term.out.gap();
2137
+ term.out.write(logs());
2138
+ await term.out.end();
1844
2139
  term.in.unref();
1845
2140
  setTimeout(() => {
1846
2141
  process.exit(0);
@@ -1872,7 +2167,8 @@ var flexLine = (term, left, right, reserveSpace = 0) => {
1872
2167
  var assetBuilder = (assets) => {
1873
2168
  return async (term) => {
1874
2169
  const done = term.out.write(loadingDialog("Building stack assets..."));
1875
- const groups = new Signal([br()]);
2170
+ const groups = new Signal([""]);
2171
+ term.out.gap();
1876
2172
  term.out.write(groups);
1877
2173
  const stackNameSize = Math.max(...Object.keys(assets.list()).map((stack) => stack.length));
1878
2174
  const resourceSize = Math.max(...Object.values(assets.list()).map((assets2) => assets2.map((asset) => asset.resource.length)).flat());
@@ -1918,6 +2214,7 @@ var assetBuilder = (assets) => {
1918
2214
  }));
1919
2215
  }));
1920
2216
  done("Done building stack assets");
2217
+ term.out.gap();
1921
2218
  };
1922
2219
  };
1923
2220
 
@@ -1943,8 +2240,8 @@ var cleanUp = async () => {
1943
2240
  // src/cli/command/build.ts
1944
2241
  var build = (program2) => {
1945
2242
  program2.command("build").argument("[stack...]", "Optionally filter stacks to build").description("Build your app").action(async (filters) => {
1946
- await layout(async (config2, write) => {
1947
- const { app, assets } = await toApp(config2, filters);
2243
+ await layout(async (config, write) => {
2244
+ const { app, assets } = await toApp(config, filters);
1948
2245
  await cleanUp();
1949
2246
  await write(assetBuilder(assets));
1950
2247
  app.synth();
@@ -1957,11 +2254,11 @@ var import_client_cloudformation = require("@aws-sdk/client-cloudformation");
1957
2254
  var import_client_s32 = require("@aws-sdk/client-s3");
1958
2255
  var StackClient = class {
1959
2256
  // 30 seconds
1960
- constructor(config2) {
1961
- this.config = config2;
2257
+ constructor(config) {
2258
+ this.config = config;
1962
2259
  this.client = new import_client_cloudformation.CloudFormationClient({
1963
- credentials: config2.credentials,
1964
- region: config2.region
2260
+ credentials: config.credentials,
2261
+ region: config.region
1965
2262
  });
1966
2263
  }
1967
2264
  client;
@@ -2190,12 +2487,12 @@ var confirmPrompt = (label, options = {}) => {
2190
2487
  };
2191
2488
 
2192
2489
  // src/cli/ui/complex/bootstrap.ts
2193
- var bootstrapDeployer = (config2) => {
2490
+ var bootstrapDeployer = (config) => {
2194
2491
  return async (term) => {
2195
2492
  debug("Initializing bootstrap");
2196
- const app = makeApp(config2);
2197
- const client = new StackClient(config2);
2198
- const bootstrap2 = bootstrapStack(config2, app);
2493
+ const app = makeApp(config);
2494
+ const client = new StackClient(config);
2495
+ const bootstrap2 = bootstrapStack(config, app);
2199
2496
  const shouldDeploy = await shouldDeployBootstrap(client, bootstrap2.stackName);
2200
2497
  if (shouldDeploy) {
2201
2498
  term.out.write(dialog("warning", [`Your app hasn't been bootstrapped yet`]));
@@ -2219,8 +2516,8 @@ var bootstrapDeployer = (config2) => {
2219
2516
  // src/cli/command/bootstrap.ts
2220
2517
  var bootstrap = (program2) => {
2221
2518
  program2.command("bootstrap").description("Create the awsless bootstrap stack").action(async () => {
2222
- await layout(async (config2, write) => {
2223
- await write(bootstrapDeployer(config2));
2519
+ await layout(async (config, write) => {
2520
+ await write(bootstrapDeployer(config));
2224
2521
  });
2225
2522
  });
2226
2523
  };
@@ -2257,29 +2554,28 @@ var stackTree = (nodes, statuses) => {
2257
2554
  render(node.children, deep + 1, [...parents, more]);
2258
2555
  });
2259
2556
  };
2557
+ term.out.gap();
2260
2558
  render(nodes);
2559
+ term.out.gap();
2261
2560
  };
2262
2561
  };
2263
2562
 
2264
2563
  // src/cli/command/status.ts
2265
2564
  var status = (program2) => {
2266
2565
  program2.command("status").argument("[stacks...]", "Optionally filter stacks to lookup status").description("View the application status").action(async (filters) => {
2267
- await layout(async (config2, write) => {
2268
- const { app, assets, dependencyTree } = await toApp(config2, filters);
2566
+ await layout(async (config, write) => {
2567
+ const { app, assets, dependencyTree } = await toApp(config, filters);
2269
2568
  await cleanUp();
2270
2569
  await write(assetBuilder(assets));
2271
- write(br());
2272
2570
  const assembly = app.synth();
2273
2571
  const doneLoading = write(loadingDialog("Loading stack information..."));
2274
- const client = new StackClient(config2);
2572
+ const client = new StackClient(config);
2275
2573
  const statuses = [];
2276
2574
  const stackStatuses = {};
2277
2575
  assembly.stacks.forEach((stack) => {
2278
2576
  stackStatuses[stack.id] = new Signal(style.info("Loading..."));
2279
2577
  });
2280
- write(br());
2281
2578
  write(stackTree(dependencyTree, stackStatuses));
2282
- write(br());
2283
2579
  debug("Load metadata for all deployed stacks on AWS");
2284
2580
  await Promise.all(assembly.stacks.map(async (stack, i) => {
2285
2581
  const info = await client.get(stack.stackName);
@@ -2311,9 +2607,9 @@ var status = (program2) => {
2311
2607
  // src/cli/command/deploy.ts
2312
2608
  var deploy = (program2) => {
2313
2609
  program2.command("deploy").argument("[stacks...]", "Optionally filter stacks to deploy").description("Deploy your app to AWS").action(async (filters) => {
2314
- await layout(async (config2, write) => {
2315
- await write(bootstrapDeployer(config2));
2316
- const { app, stackNames, assets, dependencyTree } = await toApp(config2, filters);
2610
+ await layout(async (config, write) => {
2611
+ await write(bootstrapDeployer(config));
2612
+ const { app, stackNames, assets, dependencyTree } = await toApp(config, filters);
2317
2613
  const formattedFilter = stackNames.map((i) => style.info(i)).join(style.placeholder(", "));
2318
2614
  debug("Stacks to deploy", formattedFilter);
2319
2615
  const deployAll = filters.length === 0;
@@ -2324,8 +2620,6 @@ var deploy = (program2) => {
2324
2620
  }
2325
2621
  await cleanUp();
2326
2622
  await write(assetBuilder(assets));
2327
- write(br());
2328
- write(br());
2329
2623
  const donePublishing = write(loadingDialog("Publishing stack assets to AWS..."));
2330
2624
  await Promise.all(assets.map(async (_, assets2) => {
2331
2625
  await Promise.all(assets2.map(async (asset) => {
@@ -2339,10 +2633,8 @@ var deploy = (program2) => {
2339
2633
  statuses[stack.id] = new Signal(style.info("waiting"));
2340
2634
  });
2341
2635
  const doneDeploying = write(loadingDialog("Deploying stacks to AWS..."));
2342
- write(br());
2343
2636
  write(stackTree(dependencyTree, statuses));
2344
- write(br());
2345
- const client = new StackClient(config2);
2637
+ const client = new StackClient(config);
2346
2638
  const deploymentLine = createDeploymentLine(dependencyTree);
2347
2639
  for (const stacks of deploymentLine) {
2348
2640
  const results = await Promise.allSettled(stacks.map(async (stack) => {
@@ -2431,36 +2723,34 @@ var textPrompt = (label, options = {}) => {
2431
2723
  };
2432
2724
  };
2433
2725
 
2434
- // src/cli/command/config/set.ts
2726
+ // src/cli/command/secrets/set.ts
2435
2727
  var set = (program2) => {
2436
- program2.command("set <name>").description("Set a config value").action(async (name) => {
2437
- await layout(async (config2, write) => {
2438
- const params = new Params(config2);
2728
+ program2.command("set <name>").description("Set a secret value").action(async (name) => {
2729
+ await layout(async (config, write) => {
2730
+ const params = new Params(config);
2439
2731
  write(list({
2440
- "Set config parameter": style.info(name)
2732
+ "Set secret parameter": style.info(name)
2441
2733
  }));
2442
- write(br());
2443
- const value = await write(textPrompt("Enter config value"));
2734
+ const value = await write(textPrompt("Enter secret value"));
2444
2735
  if (value === "") {
2445
- write(dialog("error", [`Provided config value can't be empty`]));
2736
+ write(dialog("error", [`Provided secret value can't be empty`]));
2446
2737
  } else {
2447
- const done = write(loadingDialog(`Saving remote config parameter`));
2738
+ const done = write(loadingDialog(`Saving remote secret parameter`));
2448
2739
  await params.set(name, value);
2449
- done(`Done saving remote config parameter`);
2740
+ done(`Done saving remote secret parameter`);
2450
2741
  }
2451
2742
  });
2452
2743
  });
2453
2744
  };
2454
2745
 
2455
- // src/cli/command/config/get.ts
2746
+ // src/cli/command/secrets/get.ts
2456
2747
  var get = (program2) => {
2457
- program2.command("get <name>").description("Get a config value").action(async (name) => {
2458
- await layout(async (config2, write) => {
2459
- const params = new Params(config2);
2460
- const done = write(loadingDialog(`Getting remote config parameter`));
2748
+ program2.command("get <name>").description("Get a secret value").action(async (name) => {
2749
+ await layout(async (config, write) => {
2750
+ const params = new Params(config);
2751
+ const done = write(loadingDialog(`Getting remote secret parameter`));
2461
2752
  const value = await params.get(name);
2462
- done(`Done getting remote config parameter`);
2463
- write(br());
2753
+ done(`Done getting remote secret parameter`);
2464
2754
  write(list({
2465
2755
  Name: name,
2466
2756
  Value: value || style.error("(empty)")
@@ -2469,21 +2759,20 @@ var get = (program2) => {
2469
2759
  });
2470
2760
  };
2471
2761
 
2472
- // src/cli/command/config/delete.ts
2762
+ // src/cli/command/secrets/delete.ts
2473
2763
  var del = (program2) => {
2474
- program2.command("delete <name>").description("Delete a config value").action(async (name) => {
2475
- await layout(async (config2, write) => {
2476
- const params = new Params(config2);
2477
- write(dialog("warning", [`Your deleting the ${style.info(name)} config parameter`]));
2764
+ program2.command("delete <name>").description("Delete a secret value").action(async (name) => {
2765
+ await layout(async (config, write) => {
2766
+ const params = new Params(config);
2767
+ write(dialog("warning", [`Your deleting the ${style.info(name)} secret parameter`]));
2478
2768
  const confirm = await write(confirmPrompt("Are you sure?"));
2479
2769
  if (!confirm) {
2480
2770
  throw new Cancelled();
2481
2771
  }
2482
- const done = write(loadingDialog(`Deleting remote config parameter`));
2772
+ const done = write(loadingDialog(`Deleting remote secret parameter`));
2483
2773
  const value = await params.get(name);
2484
2774
  await params.delete(name);
2485
- done(`Done deleting remote config parameter`);
2486
- write(br());
2775
+ done(`Done deleting remote secret parameter`);
2487
2776
  write(list({
2488
2777
  Name: name,
2489
2778
  Value: value || style.error("(empty)")
@@ -2492,45 +2781,47 @@ var del = (program2) => {
2492
2781
  });
2493
2782
  };
2494
2783
 
2495
- // src/cli/command/config/list.ts
2784
+ // src/cli/command/secrets/list.ts
2496
2785
  var list2 = (program2) => {
2497
- program2.command("list").description(`List all config value's`).action(async () => {
2498
- await layout(async (config2, write) => {
2499
- const params = new Params(config2);
2500
- const done = write(loadingDialog("Loading config parameters..."));
2786
+ program2.command("list").description(`List all secret value's`).action(async () => {
2787
+ await layout(async (config, write) => {
2788
+ const params = new Params(config);
2789
+ const done = write(loadingDialog("Loading secret parameters..."));
2501
2790
  const values = await params.list();
2502
- done("Done loading config values");
2791
+ done("Done loading secret values");
2503
2792
  if (Object.keys(values).length > 0) {
2504
- write(br());
2505
2793
  write(list(values));
2506
2794
  } else {
2507
- write(dialog("warning", ["No config parameters found"]));
2795
+ write(dialog("warning", ["No secret parameters found"]));
2508
2796
  }
2509
2797
  });
2510
2798
  });
2511
2799
  };
2512
2800
 
2513
- // src/cli/command/config/index.ts
2801
+ // src/cli/command/secrets/index.ts
2514
2802
  var commands = [
2515
2803
  set,
2516
2804
  get,
2517
2805
  del,
2518
2806
  list2
2519
2807
  ];
2520
- var config = (program2) => {
2521
- const command = program2.command("config").description("Manage config values");
2808
+ var secrets = (program2) => {
2809
+ const command = program2.command("secrets").description(`Manage app secrets`);
2522
2810
  commands.forEach((cb) => cb(command));
2523
2811
  };
2524
2812
 
2525
2813
  // src/cli/program.ts
2526
2814
  var program = new import_commander.Command();
2527
- program.name("awsless");
2815
+ program.name(logo().join("").replace(/\s+/, ""));
2528
2816
  program.option("--config-file <string>", "The config file location");
2529
2817
  program.option("--stage <string>", "The stage to use, defaults to prod stage", "prod");
2530
2818
  program.option("--profile <string>", "The AWS profile to use");
2531
2819
  program.option("--region <string>", "The AWS region to use");
2532
2820
  program.option("-m --mute", "Mute sound effects");
2533
2821
  program.option("-v --verbose", "Print verbose logs");
2822
+ program.exitOverride(() => {
2823
+ process.exit(0);
2824
+ });
2534
2825
  program.on("option:verbose", () => {
2535
2826
  process.env.VERBOSE = program.opts().verbose ? "1" : void 0;
2536
2827
  });
@@ -2539,13 +2830,11 @@ var commands2 = [
2539
2830
  status,
2540
2831
  build,
2541
2832
  deploy,
2542
- config
2833
+ secrets
2543
2834
  // diff,
2544
2835
  // remove,
2545
- // test,
2546
- // test2,
2547
2836
  ];
2548
- commands2.forEach((command) => command(program));
2837
+ commands2.forEach((fn) => fn(program));
2549
2838
 
2550
2839
  // src/bin.ts
2551
2840
  program.parse(process.argv);