@awsless/awsless 0.0.601 → 0.0.603

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
@@ -532,8 +532,8 @@ var findRootDir = async (path, configFiles, level = 5) => {
532
532
  };
533
533
  var fileExist = async (file) => {
534
534
  try {
535
- const stat5 = await lstat(file);
536
- if (stat5.isFile()) {
535
+ const stat4 = await lstat(file);
536
+ if (stat4.isFile()) {
537
537
  return true;
538
538
  }
539
539
  } catch (error) {
@@ -1085,11 +1085,11 @@ var FunctionDefaultSchema = z15.object({
1085
1085
  // container
1086
1086
  warm: WarmSchema.default(0),
1087
1087
  vpc: VPCSchema.default(false),
1088
- log: LogSchema.default(true).transform((log29) => ({
1089
- retention: log29.retention ?? days(7),
1090
- level: "level" in log29 ? log29.level : "error",
1091
- system: "system" in log29 ? log29.system : "warn",
1092
- format: "format" in log29 ? log29.format : "json"
1088
+ log: LogSchema.default(true).transform((log30) => ({
1089
+ retention: log30.retention ?? days(7),
1090
+ level: "level" in log30 ? log30.level : "error",
1091
+ system: "system" in log30 ? log30.system : "warn",
1092
+ format: "format" in log30 ? log30.format : "json"
1093
1093
  })),
1094
1094
  timeout: TimeoutSchema.default("10 seconds"),
1095
1095
  memorySize: MemorySizeSchema.default("128 MB"),
@@ -1617,8 +1617,8 @@ var InstanceDefaultSchema = z25.object({
1617
1617
  permissions: PermissionsSchema2.optional(),
1618
1618
  healthCheck: HealthCheckSchema.optional(),
1619
1619
  // restartPolicy: RestartPolicySchema.default({ enabled: true }),
1620
- log: LogSchema2.default(true).transform((log29) => ({
1621
- retention: log29.retention ?? days4(7)
1620
+ log: LogSchema2.default(true).transform((log30) => ({
1621
+ retention: log30.retention ?? days4(7)
1622
1622
  }))
1623
1623
  }).default({});
1624
1624
 
@@ -2144,8 +2144,8 @@ var stats = {
2144
2144
  };
2145
2145
  var WhereSchema = z40.union([
2146
2146
  z40.string().regex(/(count|avg|sum|min|max) (>|>=|<|<=) (\d)/, "Invalid where query").transform((where) => {
2147
- const [stat5, op, value] = where.split(" ");
2148
- return { stat: stat5, op, value: parseFloat(value) };
2147
+ const [stat4, op, value] = where.split(" ");
2148
+ return { stat: stat4, op, value: parseFloat(value) };
2149
2149
  }),
2150
2150
  z40.object({
2151
2151
  stat: z40.enum(["count", "avg", "sum", "min", "max"]),
@@ -3204,14 +3204,14 @@ var createHashFromFile = (file) => {
3204
3204
  var listAllFiles = async (list3) => {
3205
3205
  const files = [];
3206
3206
  for (const entry of list3) {
3207
- const stat5 = await lstat2(entry);
3208
- if (stat5.isDirectory()) {
3207
+ const stat4 = await lstat2(entry);
3208
+ if (stat4.isDirectory()) {
3209
3209
  const dirents = await readdir(entry, {
3210
3210
  recursive: true,
3211
3211
  withFileTypes: true
3212
3212
  });
3213
3213
  files.push(...dirents.filter((d) => d.isFile()).map((file) => join7(file.path, file.name)));
3214
- } else if (stat5.isFile()) {
3214
+ } else if (stat4.isFile()) {
3215
3215
  files.push(entry);
3216
3216
  }
3217
3217
  }
@@ -6535,7 +6535,7 @@ var buildExecutable = async (input, outputPath, architecture) => {
6535
6535
  }
6536
6536
  if (!result.success) {
6537
6537
  throw new ExpectedError(`Executable build failed:
6538
- ${result.logs?.map((log29) => log29.message).join("\n")}`);
6538
+ ${result.logs?.map((log30) => log30.message).join("\n")}`);
6539
6539
  }
6540
6540
  const file = await readFile4(filePath);
6541
6541
  return {
@@ -7697,15 +7697,14 @@ var playErrorSound = () => {
7697
7697
  // src/cli/ui/app.ts
7698
7698
  import { log as log3 } from "@awsless/clui";
7699
7699
  var logApp = (app, opt) => {
7700
- const data = {
7700
+ log3.list("App Config", {
7701
7701
  App: app.name,
7702
7702
  Region: app.region,
7703
- Profile: app.profile
7704
- };
7705
- if (opt.stage) {
7706
- data.Stage = color.warning(opt.stage);
7707
- }
7708
- log3.list("App Config", data);
7703
+ Profile: app.profile,
7704
+ ...opt.stage ? {
7705
+ Stage: color.warning(opt.stage)
7706
+ } : {}
7707
+ });
7709
7708
  };
7710
7709
 
7711
7710
  // src/cli/ui/error/error.ts
@@ -7751,12 +7750,12 @@ var formatOperation = (operation) => {
7751
7750
  case "import":
7752
7751
  return color.success.bold.inverse(value);
7753
7752
  case "update":
7753
+ case "replace":
7754
7754
  return color.warning.bold.inverse(value);
7755
7755
  case "delete":
7756
7756
  return color.error.bold.inverse(value);
7757
- case "heal":
7758
- return color.warning.bold.inverse(value);
7759
7757
  case "get":
7758
+ case "resolve":
7760
7759
  return color.info.bold.inverse(value);
7761
7760
  }
7762
7761
  return color.primary.bold.inverse(value);
@@ -8653,80 +8652,17 @@ import wildstring4 from "wildstring";
8653
8652
 
8654
8653
  // src/cli/ui/complex/run-tests.ts
8655
8654
  import { log as log16 } from "@awsless/clui";
8656
- import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
8657
- import { join as join19 } from "path";
8655
+ import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
8656
+ import { join as join18 } from "path";
8658
8657
  import wildstring3 from "wildstring";
8659
-
8660
- // src/build/__fingerprint.ts
8661
- import { createHash as createHash6 } from "crypto";
8662
- import { readdir as readdir4, readFile as readFile5, stat as stat4 } from "fs/promises";
8663
- import { basename as basename4, dirname as dirname9, extname as extname4, join as join17 } from "path";
8664
- import parseStaticImports from "parse-static-imports";
8665
- var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
8666
- var generateFileHashes = async (file, hashes) => {
8667
- if (hashes.has(file)) {
8668
- return;
8669
- }
8670
- const code = await readModuleFile(file);
8671
- const deps = await findDependencies(file, code);
8672
- const hash = createHash6("sha1").update(code).digest();
8673
- hashes.set(file, hash);
8674
- for (const dep of deps) {
8675
- if (dep.startsWith("/")) {
8676
- await generateFileHashes(dep, hashes);
8677
- }
8678
- }
8679
- };
8680
- var fingerprintFromDirectory = async (dir) => {
8681
- const hashes = /* @__PURE__ */ new Map();
8682
- const files = await readdir4(dir, { recursive: true });
8683
- for (const file of files) {
8684
- if (extensions.includes(extname4(file).substring(1)) && file.at(0) !== "_") {
8685
- await generateFileHashes(join17(dir, file), hashes);
8686
- }
8687
- }
8688
- const merge = Buffer.concat(Array.from(hashes.values()).sort());
8689
- return createHash6("sha1").update(merge).digest("hex");
8690
- };
8691
- var readModuleFile = (file) => {
8692
- if (file.endsWith(".js")) {
8693
- return readFiles([file, file.substring(0, file.length - 3) + ".ts"]);
8694
- }
8695
- if (!basename4(file).includes(".")) {
8696
- return readFiles([
8697
- file,
8698
- ...extensions.map((exp) => `${file}.${exp}`),
8699
- ...extensions.map((exp) => join17(file, `/index.${exp}`))
8700
- ]);
8701
- }
8702
- return readFile5(file, "utf8");
8703
- };
8704
- var readFiles = async (files) => {
8705
- for (const file of files) {
8706
- try {
8707
- const s = await stat4(file);
8708
- if (s.isFile()) {
8709
- return readFile5(file, "utf8");
8710
- }
8711
- } catch (_) {
8712
- continue;
8713
- }
8714
- }
8715
- throw new Error(`No such file: ${files.join(", ")}`);
8716
- };
8717
- var findDependencies = async (file, code) => {
8718
- const imports = await parseStaticImports(code);
8719
- return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join17(dirname9(file), value) : value);
8720
- };
8721
-
8722
- // src/cli/ui/complex/run-tests.ts
8723
8658
  import { parse as parse4, stringify } from "@awsless/json";
8659
+ import { generateFolderHash, loadWorkspace as loadWorkspace2 } from "@awsless/ts-file-cache";
8724
8660
 
8725
8661
  // src/test/start.ts
8726
8662
  import commonjs from "@rollup/plugin-commonjs";
8727
8663
  import json from "@rollup/plugin-json";
8728
8664
  import nodeResolve from "@rollup/plugin-node-resolve";
8729
- import { dirname as dirname10, join as join18 } from "path";
8665
+ import { dirname as dirname9, join as join17 } from "path";
8730
8666
  import { swc } from "rollup-plugin-swc3";
8731
8667
  import { fileURLToPath as fileURLToPath4 } from "url";
8732
8668
  import { configDefaults } from "vitest/config";
@@ -8734,7 +8670,7 @@ import { startVitest } from "vitest/node";
8734
8670
  var NullReporter = class {
8735
8671
  };
8736
8672
  var startTest = async (props) => {
8737
- const __dirname4 = dirname10(fileURLToPath4(import.meta.url));
8673
+ const __dirname4 = dirname9(fileURLToPath4(import.meta.url));
8738
8674
  const startTime = process.hrtime.bigint();
8739
8675
  process.noDeprecation = true;
8740
8676
  const vitest = await startVitest(
@@ -8757,7 +8693,7 @@ var startTest = async (props) => {
8757
8693
  // },
8758
8694
  setupFiles: [
8759
8695
  //
8760
- join18(__dirname4, "test-global-setup.js")
8696
+ join17(__dirname4, "test-global-setup.js")
8761
8697
  ]
8762
8698
  // globalSetup: [
8763
8699
  // //
@@ -8828,10 +8764,10 @@ var startTest = async (props) => {
8828
8764
  tests.push(entry);
8829
8765
  if ("task" in test2) {
8830
8766
  const task2 = test2.task;
8831
- for (const log29 of task2.logs ?? []) {
8767
+ for (const log30 of task2.logs ?? []) {
8832
8768
  entry.logs.push({
8833
- time: log29.time,
8834
- text: log29.content
8769
+ time: log30.time,
8770
+ text: log30.content
8835
8771
  });
8836
8772
  }
8837
8773
  }
@@ -8899,7 +8835,7 @@ var logTestLogs = (event) => {
8899
8835
  ].join(" "),
8900
8836
  color.line(icon.dot)
8901
8837
  );
8902
- log16.message(test2.logs.map((log29) => log29.text).join("\n"));
8838
+ log16.message(test2.logs.map((log30) => log30.text).join("\n"));
8903
8839
  }
8904
8840
  }
8905
8841
  };
@@ -8948,14 +8884,14 @@ var logTestErrors = (event) => {
8948
8884
  }
8949
8885
  }
8950
8886
  };
8951
- var runTest = async (stack, dir, filters, opts) => {
8887
+ var runTest = async (stack, dir, filters, workspace, opts) => {
8952
8888
  await mkdir4(directories.test, { recursive: true });
8953
- const file = join19(directories.test, `${stack}.json`);
8954
- const fingerprint = await fingerprintFromDirectory(dir);
8889
+ const file = join18(directories.test, `${stack}.json`);
8890
+ const fingerprint = await generateFolderHash(workspace, dir);
8955
8891
  if (!process.env.NO_CACHE) {
8956
8892
  const exists = await fileExist(file);
8957
8893
  if (exists) {
8958
- const raw = await readFile6(file, { encoding: "utf8" });
8894
+ const raw = await readFile5(file, { encoding: "utf8" });
8959
8895
  const data = parse4(raw);
8960
8896
  if (data.fingerprint === fingerprint) {
8961
8897
  log16.step(
@@ -9008,6 +8944,7 @@ var runTest = async (stack, dir, filters, opts) => {
9008
8944
  return result.errors.length === 0 && result.failed === 0;
9009
8945
  };
9010
8946
  var runTests = async (tests, stackFilters = [], testFilters = [], opts) => {
8947
+ const workspace = await loadWorkspace2(directories.root);
9011
8948
  for (const test2 of tests) {
9012
8949
  if (stackFilters && stackFilters.length > 0) {
9013
8950
  const found = stackFilters.find((f) => wildstring3.match(f, test2.stackName));
@@ -9016,7 +8953,7 @@ var runTests = async (tests, stackFilters = [], testFilters = [], opts) => {
9016
8953
  }
9017
8954
  }
9018
8955
  for (const path of test2.paths) {
9019
- const result = await runTest(test2.name, path, testFilters, opts);
8956
+ const result = await runTest(test2.name, path, testFilters, workspace, opts);
9020
8957
  if (!result) {
9021
8958
  return false;
9022
8959
  }
@@ -9124,7 +9061,7 @@ import {
9124
9061
  } from "@aws-sdk/client-cognito-identity-provider";
9125
9062
  import { log as log19, prompt as prompt8 } from "@awsless/clui";
9126
9063
  var create = (program2) => {
9127
- program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user in your userpool").action(async (name) => {
9064
+ program2.command("create").description("Create an user in your userpool").action(async () => {
9128
9065
  await layout("auth user create", async ({ appConfig, stackConfigs }) => {
9129
9066
  const region = appConfig.region;
9130
9067
  const profile = appConfig.profile;
@@ -9133,20 +9070,15 @@ var create = (program2) => {
9133
9070
  if (Object.keys(appConfig.defaults.auth ?? {}).length === 0) {
9134
9071
  throw new ExpectedError("No auth resources are defined.");
9135
9072
  }
9136
- if (!name) {
9137
- name = await prompt8.select({
9138
- message: "Select the auth userpool:",
9139
- initialValue: Object.keys(appConfig.defaults.auth).at(0),
9140
- options: Object.keys(appConfig.defaults.auth).map((name2) => ({
9141
- label: name2,
9142
- value: name2
9143
- }))
9144
- });
9145
- }
9073
+ const name = await prompt8.select({
9074
+ message: "Select the auth userpool:",
9075
+ initialValue: Object.keys(appConfig.defaults.auth).at(0),
9076
+ options: Object.keys(appConfig.defaults.auth).map((name2) => ({
9077
+ label: name2,
9078
+ value: name2
9079
+ }))
9080
+ });
9146
9081
  const props = appConfig.defaults.auth[name];
9147
- if (!props) {
9148
- throw new ExpectedError(`Provided auth name doesn't exist inside your app config.`);
9149
- }
9150
9082
  const userPoolId = await log19.task({
9151
9083
  initialMessage: "Loading auth userpool...",
9152
9084
  successMessage: "Done loading auth userpool.",
@@ -9270,7 +9202,7 @@ import {
9270
9202
  } from "@aws-sdk/client-cognito-identity-provider";
9271
9203
  import { log as log20, prompt as prompt9 } from "@awsless/clui";
9272
9204
  var update = (program2) => {
9273
- program2.command("update").argument("[name]", "The name of the auth instance").description("Update an user in your userpool").action(async (name) => {
9205
+ program2.command("update").description("Update an user in your userpool").action(async () => {
9274
9206
  await layout("auth user update", async ({ appConfig, stackConfigs }) => {
9275
9207
  const region = appConfig.region;
9276
9208
  const profile = appConfig.profile;
@@ -9279,20 +9211,15 @@ var update = (program2) => {
9279
9211
  if (Object.keys(appConfig.defaults.auth ?? {}).length === 0) {
9280
9212
  throw new ExpectedError("No auth resources are defined.");
9281
9213
  }
9282
- if (!name) {
9283
- name = await prompt9.select({
9284
- message: "Select the auth userpool:",
9285
- initialValue: Object.keys(appConfig.defaults.auth).at(0),
9286
- options: Object.keys(appConfig.defaults.auth).map((name2) => ({
9287
- label: name2,
9288
- value: name2
9289
- }))
9290
- });
9291
- }
9214
+ const name = await prompt9.select({
9215
+ message: "Select the auth userpool:",
9216
+ initialValue: Object.keys(appConfig.defaults.auth).at(0),
9217
+ options: Object.keys(appConfig.defaults.auth).map((name2) => ({
9218
+ label: name2,
9219
+ value: name2
9220
+ }))
9221
+ });
9292
9222
  const props = appConfig.defaults.auth[name];
9293
- if (!props) {
9294
- throw new ExpectedError(`Provided auth name doesn't exist inside your app config.`);
9295
- }
9296
9223
  const userPoolId = await log20.task({
9297
9224
  initialMessage: "Loading auth userpool...",
9298
9225
  successMessage: "Done loading auth userpool.",
@@ -9445,8 +9372,97 @@ var update = (program2) => {
9445
9372
  });
9446
9373
  };
9447
9374
 
9375
+ // src/cli/command/auth/user/delete.ts
9376
+ import {
9377
+ AdminDeleteUserCommand,
9378
+ CognitoIdentityProviderClient as CognitoIdentityProviderClient3,
9379
+ UserNotFoundException as UserNotFoundException2
9380
+ } from "@aws-sdk/client-cognito-identity-provider";
9381
+ import { Cancelled as Cancelled2, log as log21, prompt as prompt10 } from "@awsless/clui";
9382
+ var del3 = (program2) => {
9383
+ program2.command("delete").description("Delete an user from your userpool").action(async () => {
9384
+ await layout("auth user delete", async ({ appConfig, stackConfigs }) => {
9385
+ const region = appConfig.region;
9386
+ const profile = appConfig.profile;
9387
+ const credentials = await getCredentials(profile);
9388
+ const accountId = await getAccountId(credentials, region);
9389
+ if (Object.keys(appConfig.defaults.auth ?? {}).length === 0) {
9390
+ throw new ExpectedError("No auth resources are defined.");
9391
+ }
9392
+ const name = await prompt10.select({
9393
+ message: "Select the auth userpool:",
9394
+ initialValue: Object.keys(appConfig.defaults.auth).at(0),
9395
+ options: Object.keys(appConfig.defaults.auth).map((name2) => ({
9396
+ label: name2,
9397
+ value: name2
9398
+ }))
9399
+ });
9400
+ const userPoolId = await log21.task({
9401
+ initialMessage: "Loading auth userpool...",
9402
+ successMessage: "Done loading auth userpool.",
9403
+ errorMessage: "Failed loading auth userpool.",
9404
+ async task() {
9405
+ const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
9406
+ const { workspace } = await createWorkSpace({
9407
+ credentials,
9408
+ accountId,
9409
+ profile,
9410
+ region
9411
+ });
9412
+ await workspace.hydrate(app);
9413
+ try {
9414
+ return await shared.entry("auth", `user-pool-id`, name);
9415
+ } catch (_) {
9416
+ throw new ExpectedError(`The auth userpool hasn't been deployed yet.`);
9417
+ }
9418
+ }
9419
+ });
9420
+ const username = await prompt10.text({
9421
+ message: "Username:",
9422
+ validate(value) {
9423
+ if (!value) {
9424
+ return "Required";
9425
+ }
9426
+ return;
9427
+ }
9428
+ });
9429
+ const confirm = await prompt10.confirm({
9430
+ message: "Are you sure you want to delete this user?",
9431
+ initialValue: false
9432
+ });
9433
+ if (!confirm) {
9434
+ throw new Cancelled2();
9435
+ }
9436
+ const client = new CognitoIdentityProviderClient3({
9437
+ region,
9438
+ credentials
9439
+ });
9440
+ await log21.task({
9441
+ initialMessage: "Deleting user...",
9442
+ successMessage: "User deleted.",
9443
+ errorMessage: "Failed deleting user.",
9444
+ async task() {
9445
+ try {
9446
+ await client.send(
9447
+ new AdminDeleteUserCommand({
9448
+ UserPoolId: userPoolId,
9449
+ Username: username
9450
+ })
9451
+ );
9452
+ } catch (error) {
9453
+ if (error instanceof UserNotFoundException2) {
9454
+ throw new ExpectedError(`User doesn't exist`);
9455
+ }
9456
+ throw error;
9457
+ }
9458
+ }
9459
+ });
9460
+ });
9461
+ });
9462
+ };
9463
+
9448
9464
  // src/cli/command/auth/user/index.ts
9449
- var commands2 = [create, update];
9465
+ var commands2 = [create, update, del3];
9450
9466
  var user = (program2) => {
9451
9467
  const command = program2.command("user").description(`Manage auth users`);
9452
9468
  commands2.forEach((cb) => cb(command));
@@ -9460,7 +9476,7 @@ var auth = (program2) => {
9460
9476
  };
9461
9477
 
9462
9478
  // src/cli/command/bind.ts
9463
- import { log as log21 } from "@awsless/clui";
9479
+ import { log as log22 } from "@awsless/clui";
9464
9480
  import { constantCase as constantCase15 } from "change-case";
9465
9481
  import { spawn } from "child_process";
9466
9482
  var bind = (program2) => {
@@ -9483,9 +9499,9 @@ var bind = (program2) => {
9483
9499
  env[name] = await value;
9484
9500
  }
9485
9501
  if (Object.keys(env).length > 0) {
9486
- log21.list("Bind Env", env);
9502
+ log22.list("Bind Env", env);
9487
9503
  } else {
9488
- log21.warning("No bindings available.");
9504
+ log22.warning("No bindings available.");
9489
9505
  }
9490
9506
  const configList = opts.config ?? [];
9491
9507
  const configs = {};
@@ -9493,7 +9509,7 @@ var bind = (program2) => {
9493
9509
  configs[`CONFIG_${constantCase15(name)}`] = name;
9494
9510
  }
9495
9511
  if (configList.length ?? 0 > 0) {
9496
- log21.note("Bind Config", configList.map((v) => color.label(constantCase15(v))).join("\n"));
9512
+ log22.note("Bind Config", configList.map((v) => color.label(constantCase15(v))).join("\n"));
9497
9513
  }
9498
9514
  if (commands9.length === 0) {
9499
9515
  return "No command to execute.";
@@ -9552,11 +9568,11 @@ var watchConfig = async (options, resolve, reject) => {
9552
9568
  };
9553
9569
 
9554
9570
  // src/cli/ui/complex/build-types.ts
9555
- import { log as log22 } from "@awsless/clui";
9571
+ import { log as log23 } from "@awsless/clui";
9556
9572
 
9557
9573
  // src/type-gen/generate.ts
9558
9574
  import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
9559
- import { dirname as dirname11, join as join20, relative as relative7 } from "path";
9575
+ import { dirname as dirname10, join as join19, relative as relative7 } from "path";
9560
9576
  var generateTypes = async (props) => {
9561
9577
  const files = [];
9562
9578
  await Promise.all(
@@ -9565,12 +9581,12 @@ var generateTypes = async (props) => {
9565
9581
  ...props,
9566
9582
  async write(file, data, include = false) {
9567
9583
  const code = data?.toString("utf8");
9568
- const path = join20(directories.types, file);
9584
+ const path = join19(directories.types, file);
9569
9585
  if (code) {
9570
9586
  if (include) {
9571
9587
  files.push(relative7(directories.root, path));
9572
9588
  }
9573
- await mkdir5(dirname11(path), { recursive: true });
9589
+ await mkdir5(dirname10(path), { recursive: true });
9574
9590
  await writeFile4(path, code);
9575
9591
  }
9576
9592
  }
@@ -9579,14 +9595,14 @@ var generateTypes = async (props) => {
9579
9595
  );
9580
9596
  if (files.length) {
9581
9597
  const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
9582
- await writeFile4(join20(directories.root, `awsless.d.ts`), code);
9598
+ await writeFile4(join19(directories.root, `awsless.d.ts`), code);
9583
9599
  }
9584
9600
  };
9585
9601
 
9586
9602
  // src/cli/ui/complex/build-types.ts
9587
9603
  var buildTypes = async (props) => {
9588
9604
  await generateTypes(props);
9589
- log22.step("Done generating type definition files.");
9605
+ log23.step("Done generating type definition files.");
9590
9606
  };
9591
9607
 
9592
9608
  // src/cli/command/dev.ts
@@ -9603,14 +9619,16 @@ var dev = (program2) => {
9603
9619
  logError(error);
9604
9620
  }
9605
9621
  );
9606
- await new Promise(() => {
9622
+ await new Promise((resolve) => {
9623
+ process.once("exit", resolve);
9624
+ process.once("SIGINT", resolve);
9607
9625
  });
9608
9626
  });
9609
9627
  });
9610
9628
  };
9611
9629
 
9612
9630
  // src/cli/command/resources.ts
9613
- import { log as log23 } from "@awsless/clui";
9631
+ import { log as log24 } from "@awsless/clui";
9614
9632
  import chalk4 from "chalk";
9615
9633
  import wildstring5 from "wildstring";
9616
9634
  var resources = (program2) => {
@@ -9653,9 +9671,9 @@ var resources = (program2) => {
9653
9671
  continue;
9654
9672
  }
9655
9673
  }
9656
- log23.step(chalk4.magenta(stack.name));
9674
+ log24.step(chalk4.magenta(stack.name));
9657
9675
  if (stack.resources.length) {
9658
- log23.message(
9676
+ log24.message(
9659
9677
  stack.resources.map((r) => {
9660
9678
  return [
9661
9679
  //
@@ -9666,7 +9684,7 @@ var resources = (program2) => {
9666
9684
  }).join("\n")
9667
9685
  );
9668
9686
  } else {
9669
- log23.message(color.line(`(empty)`));
9687
+ log24.message(color.line(`(empty)`));
9670
9688
  }
9671
9689
  }
9672
9690
  });
@@ -9674,7 +9692,7 @@ var resources = (program2) => {
9674
9692
  };
9675
9693
 
9676
9694
  // src/cli/command/run.ts
9677
- import { prompt as prompt10 } from "@awsless/clui";
9695
+ import { prompt as prompt11 } from "@awsless/clui";
9678
9696
  import { DynamoDBClient, dynamoDBClient } from "@awsless/dynamodb";
9679
9697
  import { iotClient, IoTDataPlaneClient } from "@awsless/iot";
9680
9698
  import { LambdaClient as LambdaClient3, lambdaClient } from "@awsless/lambda";
@@ -9694,7 +9712,7 @@ var run = (program2) => {
9694
9712
  return cmd.name === selected;
9695
9713
  });
9696
9714
  } else {
9697
- command = await prompt10.select({
9715
+ command = await prompt11.select({
9698
9716
  message: "Pick the command you want to run:",
9699
9717
  initialValue: commands9[0],
9700
9718
  options: commands9.map((cmd) => ({
@@ -9727,7 +9745,6 @@ var run = (program2) => {
9727
9745
  credentials,
9728
9746
  accountId
9729
9747
  });
9730
- return;
9731
9748
  });
9732
9749
  });
9733
9750
  };
@@ -9749,7 +9766,7 @@ var pull = (program2) => {
9749
9766
  };
9750
9767
 
9751
9768
  // src/cli/command/state/push.ts
9752
- import { prompt as prompt11 } from "@awsless/clui";
9769
+ import { prompt as prompt12 } from "@awsless/clui";
9753
9770
  var push = (program2) => {
9754
9771
  program2.command("push").description("Push the local state to the remote server").action(async () => {
9755
9772
  await layout("state pull", async ({ appConfig, stackConfigs }) => {
@@ -9759,7 +9776,7 @@ var push = (program2) => {
9759
9776
  const accountId = await getAccountId(credentials, region);
9760
9777
  const { app } = createApp({ appConfig, stackConfigs, accountId });
9761
9778
  const { state: state2 } = await createWorkSpace({ credentials, region, accountId, profile });
9762
- const ok = await prompt11.confirm({
9779
+ const ok = await prompt12.confirm({
9763
9780
  message: "Pushing up the local state might corrupt your remote state. Are you sure?",
9764
9781
  initialValue: false
9765
9782
  });
@@ -9773,7 +9790,7 @@ var push = (program2) => {
9773
9790
  };
9774
9791
 
9775
9792
  // src/cli/command/state/unlock.ts
9776
- import { prompt as prompt12 } from "@awsless/clui";
9793
+ import { prompt as prompt13 } from "@awsless/clui";
9777
9794
  var unlock = (program2) => {
9778
9795
  program2.command("unlock").description("Release the lock that ensures sequential deployments").action(async () => {
9779
9796
  await layout("state unlock", async ({ appConfig, stackConfigs }) => {
@@ -9787,7 +9804,7 @@ var unlock = (program2) => {
9787
9804
  if (!isLocked) {
9788
9805
  return "No lock is exists.";
9789
9806
  }
9790
- const ok = await prompt12.confirm({
9807
+ const ok = await prompt13.confirm({
9791
9808
  message: "Releasing the lock that ensures sequential deployments might result in corrupt state if a deployment is still running. Are you sure?",
9792
9809
  initialValue: false
9793
9810
  });
@@ -9837,7 +9854,7 @@ var types = (program2) => {
9837
9854
  };
9838
9855
 
9839
9856
  // src/cli/command/domain/list.ts
9840
- import { log as log24 } from "@awsless/clui";
9857
+ import { log as log25 } from "@awsless/clui";
9841
9858
  var list2 = (program2) => {
9842
9859
  program2.command("list").description("List all domains").action(async () => {
9843
9860
  await layout("domain list", async ({ appConfig, stackConfigs }) => {
@@ -9859,7 +9876,7 @@ var list2 = (program2) => {
9859
9876
  });
9860
9877
  await workspace.hydrate(app);
9861
9878
  for (const zone of domainZones) {
9862
- log24.step(
9879
+ log25.step(
9863
9880
  [
9864
9881
  //
9865
9882
  color.label.green(await zone.name),
@@ -9867,14 +9884,14 @@ var list2 = (program2) => {
9867
9884
  color.dim(await zone.id)
9868
9885
  ].join(" ")
9869
9886
  );
9870
- log24.message((await zone.nameServers).join("\n"));
9887
+ log25.message((await zone.nameServers).join("\n"));
9871
9888
  }
9872
9889
  });
9873
9890
  });
9874
9891
  };
9875
9892
 
9876
9893
  // src/cli/command/domain/deploy.ts
9877
- import { log as log25 } from "@awsless/clui";
9894
+ import { log as log26 } from "@awsless/clui";
9878
9895
  var deploy2 = (program2) => {
9879
9896
  program2.command("deploy").description("Deploy the domain zones to AWS").action(async () => {
9880
9897
  await layout("domain deploy", async ({ appConfig, stackConfigs }) => {
@@ -9894,7 +9911,7 @@ var deploy2 = (program2) => {
9894
9911
  profile,
9895
9912
  region
9896
9913
  });
9897
- await log25.task({
9914
+ await log26.task({
9898
9915
  initialMessage: "Deploying the domain zones to AWS...",
9899
9916
  successMessage: "Done deploying the domain zones to AWS.",
9900
9917
  errorMessage: "Failed deploying the domain zones to AWS.",
@@ -9903,7 +9920,7 @@ var deploy2 = (program2) => {
9903
9920
  }
9904
9921
  });
9905
9922
  for (const zone of domainZones) {
9906
- log25.step(
9923
+ log26.step(
9907
9924
  [
9908
9925
  //
9909
9926
  color.label.green(await zone.name),
@@ -9911,7 +9928,7 @@ var deploy2 = (program2) => {
9911
9928
  color.dim(await zone.id)
9912
9929
  ].join(" ")
9913
9930
  );
9914
- log25.message((await zone.nameServers).join("\n"));
9931
+ log26.message((await zone.nameServers).join("\n"));
9915
9932
  }
9916
9933
  });
9917
9934
  });
@@ -9930,7 +9947,7 @@ var domain = (program2) => {
9930
9947
 
9931
9948
  // src/cli/command/logs.ts
9932
9949
  import { CloudWatchLogsClient, StartLiveTailCommand } from "@aws-sdk/client-cloudwatch-logs";
9933
- import { log as log26 } from "@awsless/clui";
9950
+ import { log as log27 } from "@awsless/clui";
9934
9951
  import { aws as aws30 } from "@terraforge/aws";
9935
9952
  import chalk5 from "chalk";
9936
9953
  import chunk2 from "chunk";
@@ -9965,14 +9982,14 @@ var logs = (program2) => {
9965
9982
  credentials,
9966
9983
  region
9967
9984
  });
9968
- const abort = new AbortController();
9985
+ const controller = new AbortController();
9969
9986
  process.once("exit", () => {
9970
- abort.abort();
9987
+ controller.abort();
9971
9988
  });
9972
9989
  process.once("SIGINT", () => {
9973
- abort.abort();
9990
+ controller.abort();
9974
9991
  });
9975
- const streams = await log26.task({
9992
+ const streams = await log27.task({
9976
9993
  initialMessage: "Connecting to the log stream...",
9977
9994
  errorMessage: "Failed to connect to the log stream.",
9978
9995
  async task(ctx) {
@@ -9982,7 +9999,7 @@ var logs = (program2) => {
9982
9999
  logGroupIdentifiers: arns
9983
10000
  });
9984
10001
  const response = await client.send(command, {
9985
- abortSignal: abort.signal
10002
+ abortSignal: controller.signal
9986
10003
  });
9987
10004
  if (!response.responseStream) {
9988
10005
  throw new Error("Failed to connect to the log stream.");
@@ -10029,7 +10046,7 @@ var formatLog = (level, date, group, message) => {
10029
10046
  SYSTEM: chalk5.blue
10030
10047
  };
10031
10048
  const levelColor = levels[level] ?? chalk5.cyan;
10032
- log26.message(
10049
+ log27.message(
10033
10050
  [
10034
10051
  [
10035
10052
  //
@@ -10071,7 +10088,7 @@ var parseJsonLog = (message) => {
10071
10088
  // src/cli/command/image/clear-cache.ts
10072
10089
  import { CloudFrontClient as CloudFrontClient2, CreateInvalidationCommand as CreateInvalidationCommand2 } from "@aws-sdk/client-cloudfront";
10073
10090
  import { DeleteObjectsCommand, ListObjectsV2Command, S3Client as S3Client3 } from "@aws-sdk/client-s3";
10074
- import { Cancelled as Cancelled2, log as log27, prompt as prompt13 } from "@awsless/clui";
10091
+ import { Cancelled as Cancelled3, log as log28, prompt as prompt14 } from "@awsless/clui";
10075
10092
  import { randomUUID } from "crypto";
10076
10093
  var clearCache = (program2) => {
10077
10094
  program2.command("clear-cache").argument("[stack]", "The stack name of the image proxy").argument("[name]", "The name of the image proxy").description("Clears the cache of the image proxy").action(async (stack, name) => {
@@ -10087,7 +10104,7 @@ var clearCache = (program2) => {
10087
10104
  }
10088
10105
  return;
10089
10106
  });
10090
- stack = await prompt13.select({
10107
+ stack = await prompt14.select({
10091
10108
  message: "Select the stack:",
10092
10109
  options: imageStacks.map((stack2) => ({
10093
10110
  label: stack2.name,
@@ -10104,7 +10121,7 @@ var clearCache = (program2) => {
10104
10121
  if (!names) {
10105
10122
  throw new ExpectedError(`No image resources are defined in stack "${stack}".`);
10106
10123
  }
10107
- name = await prompt13.select({
10124
+ name = await prompt14.select({
10108
10125
  message: "Select the image resource:",
10109
10126
  options: names.map((name2) => ({
10110
10127
  label: name2,
@@ -10112,11 +10129,11 @@ var clearCache = (program2) => {
10112
10129
  }))
10113
10130
  });
10114
10131
  }
10115
- const ok = await prompt13.confirm({
10132
+ const ok = await prompt14.confirm({
10116
10133
  message: `Are you sure you want to clear the cache`
10117
10134
  });
10118
10135
  if (!ok) {
10119
- throw new Cancelled2();
10136
+ throw new Cancelled3();
10120
10137
  }
10121
10138
  const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
10122
10139
  const { workspace } = await createWorkSpace({
@@ -10143,7 +10160,7 @@ var clearCache = (program2) => {
10143
10160
  region: "us-east-1"
10144
10161
  });
10145
10162
  let totalDeleted = 0;
10146
- await log27.task({
10163
+ await log28.task({
10147
10164
  initialMessage: "Clearing cache...",
10148
10165
  successMessage: "Cache successfully cleared.",
10149
10166
  task: async () => {
@@ -10205,7 +10222,7 @@ var image = (program2) => {
10205
10222
  // src/cli/command/icon/clear-cache.ts
10206
10223
  import { CloudFrontClient as CloudFrontClient3, CreateInvalidationCommand as CreateInvalidationCommand3 } from "@aws-sdk/client-cloudfront";
10207
10224
  import { DeleteObjectsCommand as DeleteObjectsCommand2, ListObjectsV2Command as ListObjectsV2Command2, S3Client as S3Client4 } from "@aws-sdk/client-s3";
10208
- import { Cancelled as Cancelled3, log as log28, prompt as prompt14 } from "@awsless/clui";
10225
+ import { Cancelled as Cancelled4, log as log29, prompt as prompt15 } from "@awsless/clui";
10209
10226
  import { randomUUID as randomUUID2 } from "crypto";
10210
10227
  var clearCache2 = (program2) => {
10211
10228
  program2.command("clear-cache").argument("[stack]", "The stack name of the icon proxy").argument("[name]", "The name of the icon proxy").description("Clears the cache of the icon proxy").action(async (stack, name) => {
@@ -10221,7 +10238,7 @@ var clearCache2 = (program2) => {
10221
10238
  }
10222
10239
  return;
10223
10240
  });
10224
- stack = await prompt14.select({
10241
+ stack = await prompt15.select({
10225
10242
  message: "Select the stack:",
10226
10243
  options: iconStacks.map((stack2) => ({
10227
10244
  label: stack2.name,
@@ -10238,7 +10255,7 @@ var clearCache2 = (program2) => {
10238
10255
  if (!names) {
10239
10256
  throw new ExpectedError(`No icon resources are defined in stack "${stack}".`);
10240
10257
  }
10241
- name = await prompt14.select({
10258
+ name = await prompt15.select({
10242
10259
  message: "Select the icon resource:",
10243
10260
  options: names.map((name2) => ({
10244
10261
  label: name2,
@@ -10246,11 +10263,11 @@ var clearCache2 = (program2) => {
10246
10263
  }))
10247
10264
  });
10248
10265
  }
10249
- const ok = await prompt14.confirm({
10266
+ const ok = await prompt15.confirm({
10250
10267
  message: `Are you sure you want to clear the cache`
10251
10268
  });
10252
10269
  if (!ok) {
10253
- throw new Cancelled3();
10270
+ throw new Cancelled4();
10254
10271
  }
10255
10272
  const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
10256
10273
  const { workspace } = await createWorkSpace({
@@ -10277,7 +10294,7 @@ var clearCache2 = (program2) => {
10277
10294
  region: "us-east-1"
10278
10295
  });
10279
10296
  let totalDeleted = 0;
10280
- await log28.task({
10297
+ await log29.task({
10281
10298
  initialMessage: "Clearing cache...",
10282
10299
  successMessage: "Cache successfully cleared.",
10283
10300
  task: async () => {
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.601",
3
+ "version": "0.0.603",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -33,22 +33,22 @@
33
33
  ]
34
34
  },
35
35
  "peerDependencies": {
36
- "@awsless/cloudwatch": "^0.0.1",
37
36
  "@awsless/big-float": "^0.1.5",
37
+ "@awsless/cloudwatch": "^0.0.1",
38
38
  "@awsless/duration": "^0.0.4",
39
- "@awsless/json": "^0.0.10",
40
- "@awsless/clui": "^0.0.8",
41
39
  "@awsless/dynamodb": "^0.3.8",
42
40
  "@awsless/iot": "^0.0.3",
41
+ "@awsless/json": "^0.0.10",
42
+ "@awsless/lambda": "^0.0.35",
43
43
  "@awsless/mqtt": "^0.0.2",
44
44
  "@awsless/open-search": "^0.0.21",
45
- "@awsless/lambda": "^0.0.35",
46
- "@awsless/redis": "^0.0.14",
47
45
  "@awsless/s3": "^0.0.21",
48
- "@awsless/ssm": "^0.0.7",
49
- "@awsless/sqs": "^0.0.16",
50
46
  "@awsless/sns": "^0.0.10",
51
47
  "@awsless/validate": "^0.1.3",
48
+ "@awsless/redis": "^0.0.14",
49
+ "@awsless/ssm": "^0.0.7",
50
+ "@awsless/clui": "^0.0.8",
51
+ "@awsless/sqs": "^0.0.16",
52
52
  "@awsless/weak-cache": "^0.0.1"
53
53
  },
54
54
  "dependencies": {
@@ -140,15 +140,15 @@
140
140
  "zod": "^3.24.2",
141
141
  "zod-to-json-schema": "^3.24.3",
142
142
  "@awsless/big-float": "^0.1.5",
143
- "@awsless/cloudwatch": "^0.0.1",
144
143
  "@awsless/clui": "^0.0.8",
144
+ "@awsless/cloudwatch": "^0.0.1",
145
+ "@awsless/duration": "^0.0.4",
145
146
  "@awsless/graphql": "^0.0.9",
146
- "@awsless/scheduler": "^0.0.4",
147
147
  "@awsless/json": "^0.0.10",
148
+ "@awsless/scheduler": "^0.0.4",
148
149
  "@awsless/size": "^0.0.2",
149
- "@awsless/ts-file-cache": "^0.0.12",
150
- "@awsless/duration": "^0.0.4",
151
- "@awsless/validate": "^0.1.3"
150
+ "@awsless/validate": "^0.1.3",
151
+ "@awsless/ts-file-cache": "^0.0.12"
152
152
  },
153
153
  "devDependencies": {
154
154
  "@hono/node-server": "1.19.9",