@awsless/awsless 0.0.123 → 0.0.125

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 {
@@ -6294,7 +6291,7 @@ var StackSchema = z28.object({
6294
6291
  tests: TestsSchema
6295
6292
  });
6296
6293
 
6297
- // src/config/load.ts
6294
+ // src/cli/error.ts
6298
6295
  var ConfigError = class extends Error {
6299
6296
  constructor(file, error, data) {
6300
6297
  super(error.message);
@@ -6303,6 +6300,32 @@ var ConfigError = class extends Error {
6303
6300
  this.data = data;
6304
6301
  }
6305
6302
  };
6303
+ var FileError = class extends Error {
6304
+ constructor(file, message) {
6305
+ super(message);
6306
+ this.file = file;
6307
+ }
6308
+ };
6309
+ var Cancelled = class extends Error {
6310
+ constructor() {
6311
+ super("Cancelled");
6312
+ }
6313
+ };
6314
+
6315
+ // src/config/load.ts
6316
+ import JSON5 from "json5";
6317
+ var readConfig = async (file) => {
6318
+ try {
6319
+ const json4 = await readFile5(file, "utf8");
6320
+ const data = JSON5.parse(json4);
6321
+ return data;
6322
+ } catch (error) {
6323
+ if (error instanceof Error) {
6324
+ throw new FileError(file, error.message);
6325
+ }
6326
+ throw error;
6327
+ }
6328
+ };
6306
6329
  var loadConfig = async (options) => {
6307
6330
  debug("Find the root directory");
6308
6331
  const configFile = options.configFile || "app.json";
@@ -6312,8 +6335,7 @@ var loadConfig = async (options) => {
6312
6335
  debug("CWD:", style.info(root2));
6313
6336
  debug("Load app config file");
6314
6337
  const appFileName = join7(root2, configFile);
6315
- const appJson = await readFile5(appFileName, "utf8");
6316
- const appConfig = JSON.parse(appJson);
6338
+ const appConfig = await readConfig(appFileName);
6317
6339
  debug("Validate app config file");
6318
6340
  let app;
6319
6341
  try {
@@ -6330,16 +6352,15 @@ var loadConfig = async (options) => {
6330
6352
  const account = await getAccountId(credentials, app.region);
6331
6353
  debug("Account ID:", style.info(account));
6332
6354
  debug("Load stacks config files");
6333
- const stackFiles = await glob(["**/stack.json", "**/*.stack.json"], {
6355
+ const stackFiles = await glob(["**/stack.{json,jsonc,json5}", "**/*.stack.{json,jsonc,json5}"], {
6334
6356
  ignore: ["**/node_modules/**", "**/dist/**"],
6335
6357
  cwd: root2
6336
6358
  });
6337
6359
  const stacks = [];
6338
6360
  for (const file of stackFiles) {
6339
6361
  debug(`Load stack: ${style.info(file)}`);
6340
- const stackJson = await readFile5(file, "utf8");
6341
- const stackConfig = JSON.parse(stackJson);
6342
- setLocalBasePath(dirname5(file));
6362
+ const stackConfig = await readConfig(file);
6363
+ setLocalBasePath(join7(process.cwd(), dirname5(file)));
6343
6364
  try {
6344
6365
  const stack = await StackSchema.parseAsync(stackConfig);
6345
6366
  stacks.push(stack);
@@ -6813,7 +6834,7 @@ var logs = () => {
6813
6834
  };
6814
6835
  };
6815
6836
 
6816
- // src/cli/ui/layout/zod-error.ts
6837
+ // src/cli/ui/error/config.ts
6817
6838
  var line = (value, level = 0, highlight = false) => {
6818
6839
  return [
6819
6840
  highlight ? style.error(symbol.pointerSmall) + style.placeholder(" | ") : style.placeholder.dim(" | "),
@@ -6847,7 +6868,7 @@ var format = (value) => {
6847
6868
  }
6848
6869
  return "";
6849
6870
  };
6850
- var zodError = (error) => {
6871
+ var configError = (error) => {
6851
6872
  return (term) => {
6852
6873
  for (const issue of error.error.issues) {
6853
6874
  term.out.gap();
@@ -6893,6 +6914,16 @@ var zodError = (error) => {
6893
6914
  };
6894
6915
  };
6895
6916
 
6917
+ // src/cli/ui/error/file.ts
6918
+ var fileError = (error) => {
6919
+ return (term) => {
6920
+ term.out.gap();
6921
+ term.out.write(dialog("error", [style.error(error.message)]));
6922
+ term.out.write(" " + style.placeholder(error.file));
6923
+ term.out.gap();
6924
+ };
6925
+ };
6926
+
6896
6927
  // src/cli/ui/layout/layout.ts
6897
6928
  var layout = async (cb) => {
6898
6929
  const term = createTerminal();
@@ -6908,8 +6939,10 @@ var layout = async (cb) => {
6908
6939
  await cb(config2, term.out.write.bind(term.out), term);
6909
6940
  } catch (error) {
6910
6941
  term.out.gap();
6911
- if (error instanceof ConfigError) {
6912
- term.out.write(zodError(error));
6942
+ if (error instanceof FileError) {
6943
+ term.out.write(fileError(error));
6944
+ } else if (error instanceof ConfigError) {
6945
+ term.out.write(configError(error));
6913
6946
  } else if (error instanceof Error) {
6914
6947
  term.out.write(dialog("error", [error.message]));
6915
6948
  } else if (typeof error === "string") {
@@ -7024,13 +7057,12 @@ var assetBuilder = (app) => {
7024
7057
  return join8(directories.asset, asset.type, app.name, stack.name, asset.id, file);
7025
7058
  };
7026
7059
  const getFingerPrint = async () => {
7027
- let value;
7028
7060
  try {
7029
- value = await readFile6(getFullPath("FINGER_PRINT"), "utf8");
7061
+ const value = await readFile6(getFullPath("FINGER_PRINT"), "utf8");
7062
+ return value;
7030
7063
  } catch (_) {
7031
7064
  return void 0;
7032
7065
  }
7033
- return value;
7034
7066
  };
7035
7067
  try {
7036
7068
  const data = await asset.build({
@@ -7039,16 +7071,20 @@ var assetBuilder = (app) => {
7039
7071
  if (prev === fingerprint && !process.env.NO_CACHE) {
7040
7072
  return;
7041
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
+ }
7042
7084
  const file = getFullPath("FINGER_PRINT");
7043
7085
  const basepath = dirname6(file);
7044
7086
  await mkdir2(basepath, { recursive: true });
7045
7087
  await writeFile2(file, fingerprint);
7046
- await cb(async (file2, data2) => {
7047
- const fullpath = getFullPath(file2);
7048
- const basepath2 = dirname6(fullpath);
7049
- await mkdir2(basepath2, { recursive: true });
7050
- await writeFile2(fullpath, data2);
7051
- });
7052
7088
  },
7053
7089
  async read(fingerprint, files) {
7054
7090
  const prev = await getFingerPrint();
@@ -7448,13 +7484,6 @@ var StackClient = class {
7448
7484
  }
7449
7485
  };
7450
7486
 
7451
- // src/cli/error.ts
7452
- var Cancelled = class extends Error {
7453
- constructor() {
7454
- super("Cancelled");
7455
- }
7456
- };
7457
-
7458
7487
  // src/cli/ui/prompt/toggle.ts
7459
7488
  var togglePrompt = (label, options = {}) => {
7460
7489
  return (term) => new Promise((resolve) => {
@@ -8322,8 +8351,10 @@ var dev = (program2) => {
8322
8351
  await write(typesGenerator(config2));
8323
8352
  },
8324
8353
  (error) => {
8325
- if (error instanceof ConfigError) {
8326
- write(zodError(error));
8354
+ if (error instanceof FileError) {
8355
+ write(fileError(error));
8356
+ } else if (error instanceof ConfigError) {
8357
+ write(configError(error));
8327
8358
  } else if (error instanceof Error) {
8328
8359
  write(dialog("error", [error.message]));
8329
8360
  } else if (typeof error === "string") {
package/dist/index.js CHANGED
@@ -125,7 +125,7 @@ import {
125
125
  import { constantCase as constantCase2 } from "change-case";
126
126
  var getQueueName = getLocalResourceName;
127
127
  var getQueueUrl = (name, stack = STACK) => {
128
- return process.env[`QUEUE_${constantCase2(stack)}_${constantCase2(name)}_URL`];
128
+ return process.env[`QUEUE_${constantCase2(stack)}_${constantCase2(name)}_URL`] || name;
129
129
  };
130
130
  var Queue = /* @__PURE__ */ createProxy((stack) => {
131
131
  return createProxy((queue2) => {
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.123",
3
+ "version": "0.0.125",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@awsless/lambda": "^0.0.15",
32
- "@awsless/redis": "^0.0.8",
33
32
  "@awsless/sns": "^0.0.7",
33
+ "@awsless/redis": "^0.0.10",
34
34
  "@awsless/sqs": "^0.0.7",
35
35
  "@awsless/ssm": "^0.0.7",
36
36
  "@awsless/validate": "^0.0.10",
@@ -70,6 +70,7 @@
70
70
  "filesize": "^10.0.7",
71
71
  "glob": "^10.3.9",
72
72
  "graphql": "^16.7.1",
73
+ "json5": "^2.2.3",
73
74
  "jszip": "^3.10.1",
74
75
  "mime-types": "^2.1.35",
75
76
  "parse-imports": "^1.1.2",