@awsless/awsless 0.0.122 → 0.0.124

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
@@ -5597,13 +5597,10 @@ var setLocalBasePath = (path) => {
5597
5597
  basePath = path;
5598
5598
  };
5599
5599
  var resolvePath = (path) => {
5600
- if (path.startsWith(".")) {
5601
- return join6(basePath ?? directories.root, path);
5600
+ if (path.startsWith(".") && basePath) {
5601
+ return join6(basePath, path);
5602
5602
  }
5603
- if (path.startsWith("/")) {
5604
- return join6(directories.root, path);
5605
- }
5606
- return path;
5603
+ return join6(directories.root, path);
5607
5604
  };
5608
5605
  var LocalFileSchema = z5.string().transform((path) => resolvePath(path)).refine(async (path) => {
5609
5606
  try {
@@ -6296,8 +6293,9 @@ var StackSchema = z28.object({
6296
6293
 
6297
6294
  // src/config/load.ts
6298
6295
  var ConfigError = class extends Error {
6299
- constructor(error, data) {
6296
+ constructor(file, error, data) {
6300
6297
  super(error.message);
6298
+ this.file = file;
6301
6299
  this.error = error;
6302
6300
  this.data = data;
6303
6301
  }
@@ -6319,7 +6317,7 @@ var loadConfig = async (options) => {
6319
6317
  app = await AppSchema.parseAsync(appConfig);
6320
6318
  } catch (error) {
6321
6319
  if (error instanceof z29.ZodError) {
6322
- throw new ConfigError(error, appConfig);
6320
+ throw new ConfigError(appFileName, error, appConfig);
6323
6321
  }
6324
6322
  throw error;
6325
6323
  }
@@ -6338,13 +6336,13 @@ var loadConfig = async (options) => {
6338
6336
  debug(`Load stack: ${style.info(file)}`);
6339
6337
  const stackJson = await readFile5(file, "utf8");
6340
6338
  const stackConfig = JSON.parse(stackJson);
6341
- setLocalBasePath(dirname5(file));
6339
+ setLocalBasePath(join7(process.cwd(), dirname5(file)));
6342
6340
  try {
6343
6341
  const stack = await StackSchema.parseAsync(stackConfig);
6344
6342
  stacks.push(stack);
6345
6343
  } catch (error) {
6346
6344
  if (error instanceof z29.ZodError) {
6347
- throw new ConfigError(error, stackConfig);
6345
+ throw new ConfigError(file, error, stackConfig);
6348
6346
  }
6349
6347
  throw error;
6350
6348
  }
@@ -6846,14 +6844,15 @@ var format = (value) => {
6846
6844
  }
6847
6845
  return "";
6848
6846
  };
6849
- var zodError = (error, data) => {
6847
+ var zodError = (error) => {
6850
6848
  return (term) => {
6851
- for (const issue of error.issues) {
6849
+ for (const issue of error.error.issues) {
6852
6850
  term.out.gap();
6853
6851
  term.out.write(dialog("error", [style.error(issue.message)]));
6852
+ term.out.write(" " + style.placeholder(error.file));
6854
6853
  term.out.gap();
6855
6854
  term.out.write(line("{"));
6856
- let context = data;
6855
+ let context = error.data;
6857
6856
  const inStack = issue.path[0] === "stacks" && typeof issue.path[1] === "number";
6858
6857
  const length2 = issue.path.length;
6859
6858
  const end = [];
@@ -6873,7 +6872,7 @@ var zodError = (error, data) => {
6873
6872
  end.unshift(line("]", index));
6874
6873
  } else if (typeof context === "object") {
6875
6874
  if (inStack && index === 3) {
6876
- const name = data.stacks[issue.path[1]].name;
6875
+ const name = error.data.stacks[issue.path[1]].name;
6877
6876
  term.out.write(line("name: " + style.info(`"${name}"`) + ",", index));
6878
6877
  }
6879
6878
  term.out.write(line(key + "{", index));
@@ -6907,7 +6906,7 @@ var layout = async (cb) => {
6907
6906
  } catch (error) {
6908
6907
  term.out.gap();
6909
6908
  if (error instanceof ConfigError) {
6910
- term.out.write(zodError(error.error, error.data));
6909
+ term.out.write(zodError(error));
6911
6910
  } else if (error instanceof Error) {
6912
6911
  term.out.write(dialog("error", [error.message]));
6913
6912
  } else if (typeof error === "string") {
@@ -7022,13 +7021,12 @@ var assetBuilder = (app) => {
7022
7021
  return join8(directories.asset, asset.type, app.name, stack.name, asset.id, file);
7023
7022
  };
7024
7023
  const getFingerPrint = async () => {
7025
- let value;
7026
7024
  try {
7027
- value = await readFile6(getFullPath("FINGER_PRINT"), "utf8");
7025
+ const value = await readFile6(getFullPath("FINGER_PRINT"), "utf8");
7026
+ return value;
7028
7027
  } catch (_) {
7029
7028
  return void 0;
7030
7029
  }
7031
- return value;
7032
7030
  };
7033
7031
  try {
7034
7032
  const data = await asset.build({
@@ -7037,16 +7035,20 @@ var assetBuilder = (app) => {
7037
7035
  if (prev === fingerprint && !process.env.NO_CACHE) {
7038
7036
  return;
7039
7037
  }
7038
+ try {
7039
+ await cb(async (file2, data2) => {
7040
+ const fullpath = getFullPath(file2);
7041
+ const basepath2 = dirname6(fullpath);
7042
+ await mkdir2(basepath2, { recursive: true });
7043
+ await writeFile2(fullpath, data2);
7044
+ });
7045
+ } catch (error) {
7046
+ throw error;
7047
+ }
7040
7048
  const file = getFullPath("FINGER_PRINT");
7041
7049
  const basepath = dirname6(file);
7042
7050
  await mkdir2(basepath, { recursive: true });
7043
7051
  await writeFile2(file, fingerprint);
7044
- await cb(async (file2, data2) => {
7045
- const fullpath = getFullPath(file2);
7046
- const basepath2 = dirname6(fullpath);
7047
- await mkdir2(basepath2, { recursive: true });
7048
- await writeFile2(fullpath, data2);
7049
- });
7050
7052
  },
7051
7053
  async read(fingerprint, files) {
7052
7054
  const prev = await getFingerPrint();
@@ -8321,7 +8323,7 @@ var dev = (program2) => {
8321
8323
  },
8322
8324
  (error) => {
8323
8325
  if (error instanceof ConfigError) {
8324
- write(zodError(error.error, error.data));
8326
+ write(zodError(error));
8325
8327
  } else if (error instanceof Error) {
8326
8328
  write(dialog("error", [error.message]));
8327
8329
  } else if (typeof error === "string") {
package/dist/json.js CHANGED
@@ -116,13 +116,10 @@ var directories = {
116
116
  import { join as join2 } from "path";
117
117
  var basePath;
118
118
  var resolvePath = (path) => {
119
- if (path.startsWith(".")) {
120
- return join2(basePath ?? directories.root, path);
119
+ if (path.startsWith(".") && basePath) {
120
+ return join2(basePath, path);
121
121
  }
122
- if (path.startsWith("/")) {
123
- return join2(directories.root, path);
124
- }
125
- return path;
122
+ return join2(directories.root, path);
126
123
  };
127
124
  var LocalFileSchema = z3.string().transform((path) => resolvePath(path)).refine(async (path) => {
128
125
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.122",
3
+ "version": "0.0.124",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -30,8 +30,8 @@
30
30
  "peerDependencies": {
31
31
  "@awsless/lambda": "^0.0.15",
32
32
  "@awsless/redis": "^0.0.8",
33
- "@awsless/sns": "^0.0.7",
34
33
  "@awsless/sqs": "^0.0.7",
34
+ "@awsless/sns": "^0.0.7",
35
35
  "@awsless/ssm": "^0.0.7",
36
36
  "@awsless/validate": "^0.0.10",
37
37
  "@awsless/weak-cache": "^0.0.1"