@awsless/awsless 0.0.126 → 0.0.127

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
@@ -104,10 +104,13 @@ var formatArn = (props) => {
104
104
  if (!props.resourceName) {
105
105
  return sub("arn:${AWS::Partition}:${service}:${AWS::Region}:${AWS::AccountId}:${resource}", props);
106
106
  }
107
- return sub("arn:${AWS::Partition}:${service}:${AWS::Region}:${AWS::AccountId}:${resource}${seperator}${resourceName}", {
108
- seperator: "/",
109
- ...props
110
- });
107
+ return sub(
108
+ "arn:${AWS::Partition}:${service}:${AWS::Region}:${AWS::AccountId}:${resource}${seperator}${resourceName}",
109
+ {
110
+ seperator: "/",
111
+ ...props
112
+ }
113
+ );
111
114
  };
112
115
 
113
116
  // src/formation/resource.ts
@@ -3709,10 +3712,10 @@ var onFailurePlugin = definePlugin({
3709
3712
  if (!hasOnFailure(config2)) {
3710
3713
  return;
3711
3714
  }
3712
- const queue2 = new Queue("on-failure", {
3715
+ const queue3 = new Queue("on-failure", {
3713
3716
  name: `${config2.app.name}-failure`
3714
3717
  });
3715
- bootstrap2.add(queue2).export("on-failure-queue-arn", queue2.arn);
3718
+ bootstrap2.add(queue3).export("on-failure-queue-arn", queue3.arn);
3716
3719
  },
3717
3720
  onStack(ctx) {
3718
3721
  const { stack, stackConfig, bootstrap: bootstrap2 } = ctx;
@@ -3859,22 +3862,22 @@ var queuePlugin = definePlugin({
3859
3862
  const { stack, config: config2, stackConfig, bind } = ctx;
3860
3863
  for (const [id, functionOrProps] of Object.entries(stackConfig.queues || {})) {
3861
3864
  const props = typeof functionOrProps === "string" ? { ...config2.app.defaults.queue, consumer: functionOrProps } : { ...config2.app.defaults.queue, ...functionOrProps };
3862
- const queue2 = new Queue(id, {
3865
+ const queue3 = new Queue(id, {
3863
3866
  name: `${config2.app.name}-${stack.name}-${id}`,
3864
3867
  deadLetterArn: getGlobalOnFailure(ctx),
3865
3868
  ...props
3866
3869
  });
3867
3870
  const lambda = toLambdaFunction(ctx, `queue-${id}`, props.consumer);
3868
3871
  const source = new SqsEventSource(id, lambda, {
3869
- queueArn: queue2.arn,
3872
+ queueArn: queue3.arn,
3870
3873
  batchSize: props.batchSize,
3871
3874
  maxConcurrency: props.maxConcurrency,
3872
3875
  maxBatchingWindow: props.maxBatchingWindow
3873
3876
  });
3874
- stack.add(queue2, lambda, source);
3877
+ stack.add(queue3, lambda, source);
3875
3878
  bind((lambda2) => {
3876
- lambda2.addPermissions(queue2.permissions);
3877
- lambda2.addEnvironment(`QUEUE_${constantCase10(stack.name)}_${constantCase10(id)}_URL`, queue2.url);
3879
+ lambda2.addPermissions(queue3.permissions);
3880
+ lambda2.addEnvironment(`QUEUE_${constantCase10(stack.name)}_${constantCase10(id)}_URL`, queue3.url);
3878
3881
  });
3879
3882
  }
3880
3883
  }
@@ -6326,6 +6329,17 @@ var readConfig = async (file) => {
6326
6329
  throw error;
6327
6330
  }
6328
6331
  };
6332
+ var parseConfig = async (schema, file, data) => {
6333
+ try {
6334
+ const result = await schema.parseAsync(data);
6335
+ return result;
6336
+ } catch (error) {
6337
+ if (error instanceof z29.ZodError) {
6338
+ throw new ConfigError(file, error, data);
6339
+ }
6340
+ throw error;
6341
+ }
6342
+ };
6329
6343
  var loadConfig = async (options) => {
6330
6344
  debug("Find the root directory");
6331
6345
  const configFile = options.configFile || "app.json";
@@ -6337,22 +6351,15 @@ var loadConfig = async (options) => {
6337
6351
  const appFileName = join7(root2, configFile);
6338
6352
  const appConfig = await readConfig(appFileName);
6339
6353
  debug("Validate app config file");
6340
- let app;
6341
- try {
6342
- app = await AppSchema.parseAsync(appConfig);
6343
- } catch (error) {
6344
- if (error instanceof z29.ZodError) {
6345
- throw new ConfigError(appFileName, error, appConfig);
6346
- }
6347
- throw error;
6348
- }
6354
+ const app = await parseConfig(AppSchema, appFileName, appConfig);
6349
6355
  debug("Load credentials", style.info(app.profile));
6350
6356
  const credentials = getCredentials(app.profile);
6351
6357
  debug("Load AWS account ID");
6352
6358
  const account = await getAccountId(credentials, app.region);
6353
6359
  debug("Account ID:", style.info(account));
6354
6360
  debug("Load stacks config files");
6355
- const stackFiles = await glob(["**/stack.{json,jsonc,json5}", "**/*.stack.{json,jsonc,json5}"], {
6361
+ const ext = "{json,jsonc,json5}";
6362
+ const stackFiles = await glob([`**/stack.${ext}`, `**/*.stack.${ext}`], {
6356
6363
  ignore: ["**/node_modules/**", "**/dist/**"],
6357
6364
  cwd: root2
6358
6365
  });
@@ -6361,15 +6368,8 @@ var loadConfig = async (options) => {
6361
6368
  debug(`Load stack: ${style.info(file)}`);
6362
6369
  const stackConfig = await readConfig(file);
6363
6370
  setLocalBasePath(join7(process.cwd(), dirname5(file)));
6364
- try {
6365
- const stack = await StackSchema.parseAsync(stackConfig);
6366
- stacks.push(stack);
6367
- } catch (error) {
6368
- if (error instanceof z29.ZodError) {
6369
- throw new ConfigError(file, error, stackConfig);
6370
- }
6371
- throw error;
6372
- }
6371
+ const stack = await parseConfig(StackSchema, file, stackConfig);
6372
+ stacks.push(stack);
6373
6373
  }
6374
6374
  return {
6375
6375
  app,
@@ -6988,6 +6988,7 @@ var flexLine = (term, left, right, reserveSpace = 0) => {
6988
6988
 
6989
6989
  // src/cli/ui/complex/builder.ts
6990
6990
  import { dirname as dirname6, join as join8 } from "path";
6991
+ import queue2 from "fastq";
6991
6992
  var assetBuilder = (app) => {
6992
6993
  return async (term) => {
6993
6994
  const assets = [];
@@ -7003,7 +7004,7 @@ var assetBuilder = (app) => {
7003
7004
  if (assets.length === 0) {
7004
7005
  return;
7005
7006
  }
7006
- const showDetailedView = assets.length <= term.out.height() - 2;
7007
+ const showDetailedView = true;
7007
7008
  const done = term.out.write(loadingDialog("Building stack assets..."));
7008
7009
  const groups = new Signal([""]);
7009
7010
  if (showDetailedView) {
@@ -7012,6 +7013,52 @@ var assetBuilder = (app) => {
7012
7013
  }
7013
7014
  const stackNameSize = Math.max(...stacks.map((stack) => stack.name.length));
7014
7015
  const assetTypeSize = Math.max(...assets.map((asset) => asset.type.length));
7016
+ const q = queue2.promise(async ({ stack, asset }) => {
7017
+ const getFullPath = (file) => {
7018
+ return join8(directories.asset, asset.type, app.name, stack.name, asset.id, file);
7019
+ };
7020
+ const getFingerPrint = async () => {
7021
+ try {
7022
+ const value = await readFile6(getFullPath("FINGER_PRINT"), "utf8");
7023
+ return value;
7024
+ } catch (_) {
7025
+ return void 0;
7026
+ }
7027
+ };
7028
+ return asset.build({
7029
+ async write(fingerprint, cb) {
7030
+ const prev = await getFingerPrint();
7031
+ if (prev === fingerprint && !process.env.NO_CACHE) {
7032
+ return;
7033
+ }
7034
+ try {
7035
+ await cb(async (file2, data) => {
7036
+ const fullpath = getFullPath(file2);
7037
+ const basepath2 = dirname6(fullpath);
7038
+ await mkdir2(basepath2, { recursive: true });
7039
+ await writeFile2(fullpath, data);
7040
+ });
7041
+ } catch (error) {
7042
+ throw error;
7043
+ }
7044
+ const file = getFullPath("FINGER_PRINT");
7045
+ const basepath = dirname6(file);
7046
+ await mkdir2(basepath, { recursive: true });
7047
+ await writeFile2(file, fingerprint);
7048
+ },
7049
+ async read(fingerprint, files) {
7050
+ const prev = await getFingerPrint();
7051
+ if (prev !== fingerprint) {
7052
+ throw new TypeError(`Outdated fingerprint: ${fingerprint}`);
7053
+ }
7054
+ return Promise.all(
7055
+ files.map((file) => {
7056
+ return readFile6(getFullPath(file));
7057
+ })
7058
+ );
7059
+ }
7060
+ });
7061
+ }, 3);
7015
7062
  await Promise.all(
7016
7063
  app.stacks.map(async (stack) => {
7017
7064
  const group = new Signal([]);
@@ -7053,51 +7100,8 @@ var assetBuilder = (app) => {
7053
7100
  );
7054
7101
  group.update((group2) => [...group2, line2]);
7055
7102
  const timer = createTimer();
7056
- const getFullPath = (file) => {
7057
- return join8(directories.asset, asset.type, app.name, stack.name, asset.id, file);
7058
- };
7059
- const getFingerPrint = async () => {
7060
- try {
7061
- const value = await readFile6(getFullPath("FINGER_PRINT"), "utf8");
7062
- return value;
7063
- } catch (_) {
7064
- return void 0;
7065
- }
7066
- };
7067
7103
  try {
7068
- const data = await asset.build({
7069
- async write(fingerprint, cb) {
7070
- const prev = await getFingerPrint();
7071
- if (prev === fingerprint && !process.env.NO_CACHE) {
7072
- return;
7073
- }
7074
- try {
7075
- await cb(async (file2, data2) => {
7076
- const fullpath = getFullPath(file2);
7077
- const basepath2 = dirname6(fullpath);
7078
- await mkdir2(basepath2, { recursive: true });
7079
- await writeFile2(fullpath, data2);
7080
- });
7081
- } catch (error) {
7082
- throw error;
7083
- }
7084
- const file = getFullPath("FINGER_PRINT");
7085
- const basepath = dirname6(file);
7086
- await mkdir2(basepath, { recursive: true });
7087
- await writeFile2(file, fingerprint);
7088
- },
7089
- async read(fingerprint, files) {
7090
- const prev = await getFingerPrint();
7091
- if (prev !== fingerprint) {
7092
- throw new TypeError(`Outdated fingerprint: ${fingerprint}`);
7093
- }
7094
- return Promise.all(
7095
- files.map((file) => {
7096
- return readFile6(getFullPath(file));
7097
- })
7098
- );
7099
- }
7100
- });
7104
+ const data = await q.push({ asset, stack });
7101
7105
  details.set({
7102
7106
  ...data,
7103
7107
  time: timer()
@@ -8328,7 +8332,8 @@ var watchConfig = async (options, resolve, reject) => {
8328
8332
  const ext = "{json,jsonc,json5}";
8329
8333
  const watcher = watch([`app.${ext}`, `**/stack.${ext}`, `**/*.stack.${ext}`], {
8330
8334
  cwd: root2,
8331
- ignored: ["**/node_modules/**", "**/dist/**"]
8335
+ ignored: ["**/node_modules/**", "**/dist/**"],
8336
+ awaitWriteFinish: true
8332
8337
  });
8333
8338
  watcher.on("change", async () => {
8334
8339
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.126",
3
+ "version": "0.0.127",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -32,8 +32,8 @@
32
32
  "@awsless/redis": "^0.0.10",
33
33
  "@awsless/sns": "^0.0.7",
34
34
  "@awsless/sqs": "^0.0.7",
35
- "@awsless/validate": "^0.0.10",
36
35
  "@awsless/ssm": "^0.0.7",
36
+ "@awsless/validate": "^0.0.10",
37
37
  "@awsless/weak-cache": "^0.0.1"
38
38
  },
39
39
  "dependencies": {
@@ -67,6 +67,7 @@
67
67
  "commander": "^9.4.1",
68
68
  "decompress": "^4.2.1",
69
69
  "event-iterator": "^2.0.0",
70
+ "fastq": "^1.16.0",
70
71
  "filesize": "^10.0.7",
71
72
  "glob": "^10.3.9",
72
73
  "graphql": "^16.7.1",
@@ -85,8 +86,8 @@
85
86
  "wrap-ansi": "^8.1.0",
86
87
  "zod": "^3.21.4",
87
88
  "zod-to-json-schema": "^3.22.3",
88
- "@awsless/graphql": "^0.0.6",
89
- "@awsless/code": "^0.0.10"
89
+ "@awsless/code": "^0.0.10",
90
+ "@awsless/graphql": "^0.0.6"
90
91
  },
91
92
  "scripts": {
92
93
  "test": "pnpm code test",