@awsless/cli 0.1.37 → 0.1.39

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.
Files changed (2) hide show
  1. package/dist/bin.js +480 -117
  2. package/package.json +20 -18
package/dist/bin.js CHANGED
@@ -126318,6 +126318,11 @@ function useColor() {
126318
126318
  // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/index.js
126319
126319
  var program = new Command;
126320
126320
 
126321
+ // src/util/remote-agent.ts
126322
+ var isRemoteAgent = () => {
126323
+ return !!process.env.AWSLESS_REMOTE_AGENT && process.env.AWSLESS_REMOTE_AGENT !== "0";
126324
+ };
126325
+
126321
126326
  // src/cli/command/auth/user/create.ts
126322
126327
  import {
126323
126328
  AdminAddUserToGroupCommand as AdminAddUserToGroupCommand2,
@@ -155252,7 +155257,20 @@ var isError = (error52, name) => {
155252
155257
  return error52 instanceof Error && error52.name === name;
155253
155258
  };
155254
155259
  var hasRuntimeAwsCredentials = () => !!(process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI || process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI || process.env.AWS_ACCESS_KEY_ID || process.env.AWS_WEB_IDENTITY_TOKEN_FILE);
155260
+ var getRemoteAgentCredentials = async (profile) => {
155261
+ process.env.AWS_EC2_METADATA_DISABLED ??= "true";
155262
+ const provider = fromNodeProviderChain();
155263
+ try {
155264
+ await provider();
155265
+ } catch (error52) {
155266
+ throw new ExpectedError(`No AWS credentials found for the ${profile} profile while running as a remote agent. ` + `Set AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY in the environment.`, { cause: error52 });
155267
+ }
155268
+ return provider;
155269
+ };
155255
155270
  var getCredentials = async (profile) => {
155271
+ if (isRemoteAgent()) {
155272
+ return getRemoteAgentCredentials(profile);
155273
+ }
155256
155274
  if (hasRuntimeAwsCredentials()) {
155257
155275
  return fromNodeProviderChain();
155258
155276
  }
@@ -166956,6 +166974,10 @@ var LuaRuntime = class LuaRuntime2 {
166956
166974
  return this.raiseError("ERR First argument must be a number (log level).");
166957
166975
  return 0;
166958
166976
  });
166977
+ register("replicate_commands", (L3) => {
166978
+ import_fengari.lua.lua_pushboolean(L3, 1);
166979
+ return 1;
166980
+ });
166959
166981
  register("setresp", (L3) => {
166960
166982
  if (import_fengari.lua.lua_tonumber(L3, 1) === 2)
166961
166983
  return 0;
@@ -168027,8 +168049,32 @@ var persist = async () => {
168027
168049
  await mkdir5(dirname6(file3), { recursive: true });
168028
168050
  await writeFile7(file3, JSON.stringify([...tracked.values()]));
168029
168051
  };
168052
+ var proxyEnvNames = [
168053
+ "NODE_EXTRA_CA_CERTS",
168054
+ "SSL_CERT_FILE",
168055
+ "SSL_CERT_DIR",
168056
+ "HTTP_PROXY",
168057
+ "HTTPS_PROXY",
168058
+ "NO_PROXY",
168059
+ "http_proxy",
168060
+ "https_proxy",
168061
+ "no_proxy"
168062
+ ];
168063
+ var proxyEnv = () => {
168064
+ const env2 = {};
168065
+ for (const name of proxyEnvNames) {
168066
+ const value = process.env[name];
168067
+ if (value) {
168068
+ env2[name] = value;
168069
+ }
168070
+ }
168071
+ return env2;
168072
+ };
168030
168073
  var spawnDevChild = (command, args, options2 = {}) => {
168031
- const child = spawn3(command, args, options2);
168074
+ const child = spawn3(command, args, {
168075
+ ...options2,
168076
+ env: options2.env ? { ...proxyEnv(), ...options2.env } : options2.env
168077
+ });
168032
168078
  if (child.pid) {
168033
168079
  tracked.set(child.pid, { pid: child.pid, command: [command, ...args].join(" ") });
168034
168080
  persist().catch(() => {});
@@ -199939,8 +199985,78 @@ var deployments = (program3) => {
199939
199985
  };
199940
199986
 
199941
199987
  // src/config/load/watch.ts
199988
+ import { basename as basename4, sep as sep4 } from "path";
199989
+
199990
+ // src/dev/watch-tree.ts
199942
199991
  import { watch } from "fs";
199943
- import { basename as basename4, sep as sep3 } from "path";
199992
+ import { readdir as readdir5, stat as stat6 } from "fs/promises";
199993
+ import { join as join45, relative as relative11, sep as sep3 } from "path";
199994
+ var watchTree = async (root4, ignored, listener, options2 = {}) => {
199995
+ const native = options2.native ?? (process.platform === "darwin" || process.platform === "win32");
199996
+ if (native) {
199997
+ const watcher = watch(root4, { recursive: true }, (_event, filename) => {
199998
+ if (filename) {
199999
+ listener(filename);
200000
+ }
200001
+ });
200002
+ return { close: () => watcher.close() };
200003
+ }
200004
+ const watchers = new Map;
200005
+ let closed = false;
200006
+ const add = async (dir) => {
200007
+ if (closed || watchers.has(dir)) {
200008
+ return;
200009
+ }
200010
+ let watcher;
200011
+ try {
200012
+ watcher = watch(dir, (event, filename) => {
200013
+ if (!filename) {
200014
+ return;
200015
+ }
200016
+ const path6 = join45(dir, filename);
200017
+ const name = relative11(root4, path6);
200018
+ if (name.split(sep3).some((segment) => ignored.has(segment))) {
200019
+ return;
200020
+ }
200021
+ listener(name);
200022
+ if (event === "rename" && !ignored.has(filename)) {
200023
+ stat6(path6).then((info3) => info3.isDirectory() ? walk2(path6) : undefined).catch(() => {});
200024
+ }
200025
+ });
200026
+ } catch (error53) {
200027
+ debug(`Can't watch ${dir}`, error53);
200028
+ return;
200029
+ }
200030
+ watcher.on("error", (error53) => debug(`Watcher error in ${dir}`, error53));
200031
+ watchers.set(dir, watcher);
200032
+ };
200033
+ const walk2 = async (dir) => {
200034
+ await add(dir);
200035
+ let entries2;
200036
+ try {
200037
+ entries2 = await readdir5(dir, { withFileTypes: true });
200038
+ } catch {
200039
+ return;
200040
+ }
200041
+ for (const entry of entries2) {
200042
+ if (entry.isDirectory() && !entry.isSymbolicLink() && !ignored.has(entry.name)) {
200043
+ await walk2(join45(dir, entry.name));
200044
+ }
200045
+ }
200046
+ };
200047
+ await walk2(root4);
200048
+ return {
200049
+ close: () => {
200050
+ closed = true;
200051
+ for (const watcher of watchers.values()) {
200052
+ watcher.close();
200053
+ }
200054
+ watchers.clear();
200055
+ }
200056
+ };
200057
+ };
200058
+
200059
+ // src/config/load/watch.ts
199944
200060
  var ignoredDirectories = new Set(["node_modules", ".awsless", "dist", ".git"]);
199945
200061
  var isConfigFile = (path6) => {
199946
200062
  const base = basename4(path6);
@@ -199950,11 +200066,8 @@ var watchConfig = async (options2, resolve5, reject) => {
199950
200066
  await loadAppConfig(options2);
199951
200067
  debug("Start watching...");
199952
200068
  let reloadTimer;
199953
- const watcher = watch(directories.root, { recursive: true }, (_event, filename) => {
199954
- if (!filename) {
199955
- return;
199956
- }
199957
- if (filename.split(sep3).some((segment) => ignoredDirectories.has(segment))) {
200069
+ const watcher = await watchTree(directories.root, ignoredDirectories, (filename) => {
200070
+ if (filename.split(sep4).some((segment) => ignoredDirectories.has(segment))) {
199958
200071
  return;
199959
200072
  }
199960
200073
  if (!isConfigFile(filename)) {
@@ -199978,18 +200091,18 @@ var watchConfig = async (options2, resolve5, reject) => {
199978
200091
  // src/dev/index.ts
199979
200092
  import { watch as watch2 } from "fs";
199980
200093
  import { mkdir as mkdir12, rm as rm13, writeFile as writeFile16 } from "fs/promises";
199981
- import { basename as basename5, dirname as dirname26, join as join51, sep as sep6 } from "path";
200094
+ import { basename as basename5, dirname as dirname26, join as join52, sep as sep7 } from "path";
199982
200095
  import { loadWorkspace as loadWorkspace3 } from "@awsless/ts-file-cache";
199983
200096
 
199984
200097
  // src/dev/context.ts
199985
- import { join as join46 } from "path";
200098
+ import { join as join47 } from "path";
199986
200099
  import { DynamoDBServer } from "@awsless/dynamodb-server";
199987
200100
 
199988
200101
  // src/dev/servers/s3.ts
199989
200102
  import { createHash as createHash21 } from "crypto";
199990
- import { mkdir as mkdir10, readdir as readdir5, readFile as readFile19, rm as rm11, stat as stat6, writeFile as writeFile13 } from "fs/promises";
200103
+ import { mkdir as mkdir10, readdir as readdir6, readFile as readFile19, rm as rm11, stat as stat7, writeFile as writeFile13 } from "fs/promises";
199991
200104
  import { createServer as createServer9 } from "http";
199992
- import { dirname as dirname24, isAbsolute as isAbsolute6, join as join45, relative as relative11, sep as sep4 } from "path";
200105
+ import { dirname as dirname24, isAbsolute as isAbsolute6, join as join46, relative as relative12, sep as sep5 } from "path";
199993
200106
  var escapeXml = (value) => {
199994
200107
  return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;");
199995
200108
  };
@@ -200054,10 +200167,10 @@ var createS3Server = (props) => {
200054
200167
  res.end(xmlError("InvalidRequest", "Missing bucket name"));
200055
200168
  return;
200056
200169
  }
200057
- const bucketDir = join45(props.root, bucket);
200058
- const file3 = join45(bucketDir, ...keyParts);
200170
+ const bucketDir = join46(props.root, bucket);
200171
+ const file3 = join46(bucketDir, ...keyParts);
200059
200172
  const escapes = (base, path6) => {
200060
- const rel = relative11(base, path6);
200173
+ const rel = relative12(base, path6);
200061
200174
  return rel.startsWith("..") || isAbsolute6(rel);
200062
200175
  };
200063
200176
  if (escapes(props.root, bucketDir) || escapes(bucketDir, file3)) {
@@ -200071,20 +200184,20 @@ var createS3Server = (props) => {
200071
200184
  const walk2 = async (dir) => {
200072
200185
  let entries2;
200073
200186
  try {
200074
- entries2 = await readdir5(dir, { withFileTypes: true });
200187
+ entries2 = await readdir6(dir, { withFileTypes: true });
200075
200188
  } catch {
200076
200189
  return;
200077
200190
  }
200078
200191
  for (const entry of entries2) {
200079
- const path6 = join45(dir, entry.name);
200192
+ const path6 = join46(dir, entry.name);
200080
200193
  if (entry.isDirectory()) {
200081
200194
  await walk2(path6);
200082
200195
  } else {
200083
- const objectKey = relative11(bucketDir, path6).split(sep4).join("/");
200196
+ const objectKey = relative12(bucketDir, path6).split(sep5).join("/");
200084
200197
  if (!objectKey.startsWith(prefix)) {
200085
200198
  continue;
200086
200199
  }
200087
- const info3 = await stat6(path6);
200200
+ const info3 = await stat7(path6);
200088
200201
  contents.push(`<Contents><Key>${escapeXml(objectKey)}</Key><Size>${info3.size}</Size><LastModified>${info3.mtime.toISOString()}</LastModified><ETag>&quot;local&quot;</ETag></Contents>`);
200089
200202
  }
200090
200203
  }
@@ -200550,7 +200663,7 @@ var createDevContext = (props) => {
200550
200663
  const value = await props.pool.keep("store", null, async () => {
200551
200664
  const rules = [];
200552
200665
  const server = createS3Server({
200553
- root: join46(directories.output, "local", "store"),
200666
+ root: join47(directories.output, "local", "store"),
200554
200667
  region: props.appConfig.region,
200555
200668
  rules
200556
200669
  });
@@ -200678,16 +200791,16 @@ var createDevContext = (props) => {
200678
200791
  // src/dev/dashboard/index.ts
200679
200792
  var import_ioredis4 = __toESM(require_built3(), 1);
200680
200793
  import { randomUUID as randomUUID8 } from "crypto";
200681
- import { readdir as readdir6, readFile as readFile20, stat as stat7, writeFile as writeFile15 } from "fs/promises";
200794
+ import { readdir as readdir7, readFile as readFile20, stat as stat8, writeFile as writeFile15 } from "fs/promises";
200682
200795
  import { createServer as createServer11 } from "http";
200683
- import { join as join48, relative as relative12, sep as sep5 } from "path";
200796
+ import { join as join49, relative as relative13, sep as sep6 } from "path";
200684
200797
  import { DynamoDBClient as DynamoDBClient6 } from "@aws-sdk/client-dynamodb";
200685
200798
  import { DynamoDBDocumentClient, ScanCommand as ScanCommand2 } from "@aws-sdk/lib-dynamodb";
200686
200799
 
200687
200800
  // src/dev/worker.ts
200688
200801
  import { writeFile as writeFile14 } from "fs/promises";
200689
200802
  import { availableParallelism as availableParallelism2 } from "os";
200690
- import { join as join47 } from "path";
200803
+ import { join as join48 } from "path";
200691
200804
  class WorkerError extends Error {
200692
200805
  name;
200693
200806
  constructor(name, message3, stack) {
@@ -200907,7 +201020,7 @@ var createBundleWorker = (props) => {
200907
201020
  throw new Error("The bundle worker never became ready.");
200908
201021
  };
200909
201022
  const startWorker = async () => {
200910
- const entry = join47(props.buildDir, "worker.mjs");
201023
+ const entry = join48(props.buildDir, "worker.mjs");
200911
201024
  const port = await findFreePort();
200912
201025
  const child = spawnDevChild("node", ["--enable-source-maps", entry], {
200913
201026
  cwd: props.buildDir,
@@ -200968,7 +201081,7 @@ var createBundleWorker = (props) => {
200968
201081
  return worker;
200969
201082
  };
200970
201083
  const doStart = async () => {
200971
- await writeFile14(join47(props.buildDir, "worker.mjs"), WORKER_ENTRY);
201084
+ await writeFile14(join48(props.buildDir, "worker.mjs"), WORKER_ENTRY);
200972
201085
  const results = await Promise.allSettled(Array.from({ length: concurrency }, () => startWorker()));
200973
201086
  const started = results.filter((result) => result.status === "fulfilled").map((result) => result.value);
200974
201087
  const failed = results.find((result) => result.status === "rejected");
@@ -203416,18 +203529,18 @@ var createDashboardServer = (props) => {
203416
203529
  const walk2 = async (dir) => {
203417
203530
  let entries2;
203418
203531
  try {
203419
- entries2 = await readdir6(dir, { withFileTypes: true });
203532
+ entries2 = await readdir7(dir, { withFileTypes: true });
203420
203533
  } catch {
203421
203534
  return;
203422
203535
  }
203423
203536
  for (const entry of entries2) {
203424
- const path6 = join48(dir, entry.name);
203537
+ const path6 = join49(dir, entry.name);
203425
203538
  if (entry.isDirectory()) {
203426
203539
  await walk2(path6);
203427
203540
  } else {
203428
- const key = relative12(props.storeRoot, path6).split(sep5).slice(1).join("/");
203541
+ const key = relative13(props.storeRoot, path6).split(sep6).slice(1).join("/");
203429
203542
  if (key.startsWith(prefix)) {
203430
- const info3 = await stat7(path6);
203543
+ const info3 = await stat8(path6);
203431
203544
  files.push({ key, size: info3.size, modified: info3.mtime.toISOString() });
203432
203545
  }
203433
203546
  }
@@ -203636,17 +203749,17 @@ var createFailureReporter = (props) => {
203636
203749
  };
203637
203750
 
203638
203751
  // src/dev/sdk.ts
203639
- import { readdir as readdir7, readFile as readFile21, mkdir as mkdir11, rm as rm12, stat as stat8, symlink } from "fs/promises";
203752
+ import { readdir as readdir8, readFile as readFile21, mkdir as mkdir11, rm as rm12, stat as stat9, symlink } from "fs/promises";
203640
203753
  import { createRequire } from "module";
203641
- import { dirname as dirname25, join as join49 } from "path";
203754
+ import { dirname as dirname25, join as join50 } from "path";
203642
203755
  var linkSdkPackages = async (workspace, buildDir, onWarn) => {
203643
- const filesDir = join49(buildDir, "files");
203756
+ const filesDir = join50(buildDir, "files");
203644
203757
  const packages = new Set;
203645
- for (const file3 of await readdir7(filesDir)) {
203758
+ for (const file3 of await readdir8(filesDir)) {
203646
203759
  if (!file3.endsWith(".mjs")) {
203647
203760
  continue;
203648
203761
  }
203649
- const code = await readFile21(join49(filesDir, file3), "utf8");
203762
+ const code = await readFile21(join50(filesDir, file3), "utf8");
203650
203763
  for (const match3 of code.matchAll(/(?:from\s*|import\()\s*["'](@aws-sdk\/[a-z0-9-]+|sharp)["']/g)) {
203651
203764
  packages.add(match3[1]);
203652
203765
  }
@@ -203654,7 +203767,7 @@ var linkSdkPackages = async (workspace, buildDir, onWarn) => {
203654
203767
  const ownRequire = createRequire(import.meta.url);
203655
203768
  const isProjectDep = async (name) => {
203656
203769
  try {
203657
- await stat8(join49(directories.root, "node_modules", name, "package.json"));
203770
+ await stat9(join50(directories.root, "node_modules", name, "package.json"));
203658
203771
  return true;
203659
203772
  } catch {
203660
203773
  return false;
@@ -203663,19 +203776,19 @@ var linkSdkPackages = async (workspace, buildDir, onWarn) => {
203663
203776
  const resolveFromDependents = async (name) => {
203664
203777
  const roots = Object.values(workspace.packages).flatMap((pkg) => [
203665
203778
  pkg.path,
203666
- ...Object.entries(pkg.dependencies).map(([dependency, info3]) => info3.type === "workspace" ? workspace.packages[info3.link]?.path : join49(pkg.path, "node_modules", dependency))
203779
+ ...Object.entries(pkg.dependencies).map(([dependency, info3]) => info3.type === "workspace" ? workspace.packages[info3.link]?.path : join50(pkg.path, "node_modules", dependency))
203667
203780
  ]);
203668
203781
  for (const root4 of roots.filter((root5) => typeof root5 === "string").toSorted()) {
203669
- const path6 = join49(root4, "node_modules", name);
203782
+ const path6 = join50(root4, "node_modules", name);
203670
203783
  try {
203671
- await stat8(join49(path6, "package.json"));
203784
+ await stat9(join50(path6, "package.json"));
203672
203785
  return path6;
203673
203786
  } catch {}
203674
203787
  }
203675
203788
  return;
203676
203789
  };
203677
203790
  for (const name of packages) {
203678
- const target2 = join49(buildDir, "node_modules", name);
203791
+ const target2 = join50(buildDir, "node_modules", name);
203679
203792
  try {
203680
203793
  if (await isProjectDep(name)) {
203681
203794
  await rm12(target2, { recursive: true, force: true });
@@ -203694,7 +203807,7 @@ var linkSdkPackages = async (workspace, buildDir, onWarn) => {
203694
203807
  await mkdir11(dirname25(target2), { recursive: true });
203695
203808
  await rm12(target2, { recursive: true, force: true });
203696
203809
  await symlink(source, target2, "dir");
203697
- await stat8(join49(target2, "package.json"));
203810
+ await stat9(join50(target2, "package.json"));
203698
203811
  debug(`Sdk link ${name}: ${source}`);
203699
203812
  } catch (error53) {
203700
203813
  onWarn?.(`Linking the "${name}" sdk package failed: ${error53 instanceof Error ? error53.message : String(error53)}`);
@@ -203704,9 +203817,9 @@ var linkSdkPackages = async (workspace, buildDir, onWarn) => {
203704
203817
 
203705
203818
  // src/dev/seed.ts
203706
203819
  import { spawn as spawn5 } from "child_process";
203707
- import { isAbsolute as isAbsolute7, join as join50 } from "path";
203820
+ import { isAbsolute as isAbsolute7, join as join51 } from "path";
203708
203821
  var createSeedRunner = (props) => {
203709
- const file3 = props.seed && (isAbsolute7(props.seed) ? props.seed : join50(directories.root, props.seed));
203822
+ const file3 = props.seed && (isAbsolute7(props.seed) ? props.seed : join51(directories.root, props.seed));
203710
203823
  let running;
203711
203824
  const run = () => {
203712
203825
  running ??= (async () => {
@@ -203882,7 +203995,7 @@ var startDev = async (props) => {
203882
203995
  dev: true
203883
203996
  });
203884
203997
  ready2();
203885
- await mkdir12(join51(directories.output, "local"), { recursive: true });
203998
+ await mkdir12(join52(directories.output, "local"), { recursive: true });
203886
203999
  await writeFile16(watchdogPath(), WATCHDOG_SOURCE);
203887
204000
  const routerPorts = {};
203888
204001
  Object.keys(appConfig.router ?? {}).forEach((id, index) => {
@@ -203960,7 +204073,7 @@ var startDev = async (props) => {
203960
204073
  for (const [id, port] of Object.entries(routerPorts)) {
203961
204074
  env4[`ROUTER_${constantCase(id)}_ENDPOINT`] = `localhost:${port}`;
203962
204075
  }
203963
- await writeFile16(join51(directories.output, "local", "env.json"), JSON.stringify(env4, null, "\t") + `
204076
+ await writeFile16(join52(directories.output, "local", "env.json"), JSON.stringify(env4, null, "\t") + `
203964
204077
  `);
203965
204078
  return { env: env4, lambda: lambda2 };
203966
204079
  });
@@ -204214,8 +204327,8 @@ var startDev = async (props) => {
204214
204327
  resources: dev.resources,
204215
204328
  routes: dev.routes,
204216
204329
  env: env3,
204217
- storeRoot: join51(directories.output, "local", "store"),
204218
- configFile: join51(directories.output, "local", "config.json"),
204330
+ storeRoot: join52(directories.output, "local", "store"),
204331
+ configFile: join52(directories.output, "local", "config.json"),
204219
204332
  getEmails: () => props.pool.peek("shim:ses-email")?.server.list() ?? [],
204220
204333
  getAlerts: () => props.pool.peek("shim:sns")?.alerts ?? [],
204221
204334
  getSession: () => ({ startedAt, workers: worker.size() }),
@@ -204231,11 +204344,8 @@ var startDev = async (props) => {
204231
204344
  await dashboard.listen(dashboardPort);
204232
204345
  const ignoredDirectories2 = new Set(["node_modules", ".awsless", "dist", ".git"]);
204233
204346
  let rebuildTimer;
204234
- const watcher = watch2(directories.root, { recursive: true }, (_event, filename) => {
204235
- if (!filename) {
204236
- return;
204237
- }
204238
- if (filename.split(sep6).some((segment) => ignoredDirectories2.has(segment))) {
204347
+ const watcher = await watchTree(directories.root, ignoredDirectories2, (filename) => {
204348
+ if (filename.split(sep7).some((segment) => ignoredDirectories2.has(segment))) {
204239
204349
  return;
204240
204350
  }
204241
204351
  const base = basename5(filename);
@@ -204278,7 +204388,7 @@ var startDev = async (props) => {
204278
204388
  routerPorts,
204279
204389
  async stop() {
204280
204390
  stopping = true;
204281
- await rm13(join51(directories.output, "local", "env.json"), { force: true });
204391
+ await rm13(join52(directories.output, "local", "env.json"), { force: true });
204282
204392
  clearTimeout(rebuildTimer);
204283
204393
  watcher.close();
204284
204394
  for (const restartWatcher of restartWatchers) {
@@ -204346,7 +204456,7 @@ var createServerPool = () => {
204346
204456
 
204347
204457
  // src/type-gen/generate.ts
204348
204458
  import { mkdir as mkdir13, writeFile as writeFile17 } from "fs/promises";
204349
- import { dirname as dirname27, join as join52, relative as relative13 } from "path";
204459
+ import { dirname as dirname27, join as join53, relative as relative14 } from "path";
204350
204460
  var generateTypes = async (props) => {
204351
204461
  const files = [];
204352
204462
  await Promise.all(features.map(async (feature) => {
@@ -204354,10 +204464,10 @@ var generateTypes = async (props) => {
204354
204464
  ...props,
204355
204465
  async write(file3, data, include = false) {
204356
204466
  const code = data?.toString("utf8");
204357
- const path6 = join52(directories.types, file3);
204467
+ const path6 = join53(directories.types, file3);
204358
204468
  if (code) {
204359
204469
  if (include) {
204360
- files.push(relative13(directories.root, path6));
204470
+ files.push(relative14(directories.root, path6));
204361
204471
  }
204362
204472
  await mkdir13(dirname27(path6), { recursive: true });
204363
204473
  await writeFile17(path6, code);
@@ -204368,7 +204478,7 @@ var generateTypes = async (props) => {
204368
204478
  if (files.length) {
204369
204479
  const code = files.map((file3) => `/// <reference path='${file3}' />`).join(`
204370
204480
  `);
204371
- await writeFile17(join52(directories.root, `awsless.d.ts`), code);
204481
+ await writeFile17(join53(directories.root, `awsless.d.ts`), code);
204372
204482
  }
204373
204483
  };
204374
204484
 
@@ -205177,6 +205287,255 @@ var prune = (program3) => {
205177
205287
  });
205178
205288
  };
205179
205289
 
205290
+ // src/cli/command/remote-agent/credentials/shared.ts
205291
+ import { IAMClient as IAMClient2 } from "@aws-sdk/client-iam";
205292
+
205293
+ // src/util/remote-agent-iam.ts
205294
+ import {
205295
+ CreateAccessKeyCommand,
205296
+ CreateUserCommand,
205297
+ DeleteAccessKeyCommand,
205298
+ DeleteUserCommand,
205299
+ DeleteUserPolicyCommand,
205300
+ GetUserCommand,
205301
+ GetUserPolicyCommand,
205302
+ ListAccessKeysCommand,
205303
+ PutUserPolicyCommand
205304
+ } from "@aws-sdk/client-iam";
205305
+ var remoteAgentUserName = (appName) => `awsless-remote-agent-${appName}`;
205306
+ var remoteAgentPolicyName = "awsless-remote-agent";
205307
+ var buildRemoteAgentPolicy = ({ appName, region, accountId, auth: auth2 }) => {
205308
+ return {
205309
+ Version: "2012-10-17",
205310
+ Statement: [
205311
+ {
205312
+ Sid: "ReadConfig",
205313
+ Effect: "Allow",
205314
+ Action: ["ssm:GetParametersByPath", "ssm:GetParameter", "ssm:GetParameters"],
205315
+ Resource: `arn:aws:ssm:${region}:${accountId}:parameter${configParameterPrefix(appName)}/*`
205316
+ },
205317
+ {
205318
+ Sid: "DecryptConfig",
205319
+ Effect: "Allow",
205320
+ Action: "kms:Decrypt",
205321
+ Resource: `arn:aws:kms:${region}:${accountId}:key/*`,
205322
+ Condition: { StringEquals: { "kms:ViaService": `ssm.${region}.amazonaws.com` } }
205323
+ },
205324
+ ...auth2 ? [
205325
+ {
205326
+ Sid: "ResolveAuthPools",
205327
+ Effect: "Allow",
205328
+ Action: ["cognito-idp:ListUserPools", "cognito-idp:ListUserPoolClients"],
205329
+ Resource: "*"
205330
+ }
205331
+ ] : []
205332
+ ]
205333
+ };
205334
+ };
205335
+
205336
+ class RemoteAgentIam {
205337
+ client;
205338
+ appName;
205339
+ constructor(client2, appName) {
205340
+ this.client = client2;
205341
+ this.appName = appName;
205342
+ }
205343
+ get userName() {
205344
+ return remoteAgentUserName(this.appName);
205345
+ }
205346
+ async ensureUser() {
205347
+ try {
205348
+ await this.client.send(new GetUserCommand({ UserName: this.userName }));
205349
+ return "existing";
205350
+ } catch (error53) {
205351
+ if (!isError(error53, "NoSuchEntityException")) {
205352
+ throw error53;
205353
+ }
205354
+ }
205355
+ await this.client.send(new CreateUserCommand({
205356
+ UserName: this.userName,
205357
+ Tags: [
205358
+ { Key: "awsless:app", Value: this.appName },
205359
+ { Key: "awsless:purpose", Value: "remote-agent" }
205360
+ ]
205361
+ }));
205362
+ return "created";
205363
+ }
205364
+ async ensurePolicy(policy) {
205365
+ const document2 = JSON.stringify(policy);
205366
+ let current;
205367
+ try {
205368
+ const result = await this.client.send(new GetUserPolicyCommand({ UserName: this.userName, PolicyName: remoteAgentPolicyName }));
205369
+ current = result.PolicyDocument ? JSON.stringify(JSON.parse(decodeURIComponent(result.PolicyDocument))) : undefined;
205370
+ } catch (error53) {
205371
+ if (!isError(error53, "NoSuchEntityException")) {
205372
+ throw error53;
205373
+ }
205374
+ }
205375
+ if (current === document2) {
205376
+ return "unchanged";
205377
+ }
205378
+ await this.client.send(new PutUserPolicyCommand({
205379
+ UserName: this.userName,
205380
+ PolicyName: remoteAgentPolicyName,
205381
+ PolicyDocument: document2
205382
+ }));
205383
+ return current === undefined ? "created" : "updated";
205384
+ }
205385
+ async listKeys() {
205386
+ try {
205387
+ const result = await this.client.send(new ListAccessKeysCommand({ UserName: this.userName }));
205388
+ return (result.AccessKeyMetadata ?? []).filter((key) => key.AccessKeyId).map((key) => ({ id: key.AccessKeyId, createdAt: key.CreateDate }));
205389
+ } catch (error53) {
205390
+ if (isError(error53, "NoSuchEntityException")) {
205391
+ return [];
205392
+ }
205393
+ throw error53;
205394
+ }
205395
+ }
205396
+ async createKey() {
205397
+ const result = await this.client.send(new CreateAccessKeyCommand({ UserName: this.userName }));
205398
+ const key = result.AccessKey;
205399
+ if (!key?.AccessKeyId || !key.SecretAccessKey) {
205400
+ throw new Error("IAM returned an access key without an id or secret.");
205401
+ }
205402
+ return { id: key.AccessKeyId, secret: key.SecretAccessKey };
205403
+ }
205404
+ async deleteKey(id) {
205405
+ await this.client.send(new DeleteAccessKeyCommand({ UserName: this.userName, AccessKeyId: id }));
205406
+ }
205407
+ async deleteUser() {
205408
+ try {
205409
+ await this.client.send(new GetUserCommand({ UserName: this.userName }));
205410
+ } catch (error53) {
205411
+ if (isError(error53, "NoSuchEntityException")) {
205412
+ return false;
205413
+ }
205414
+ throw error53;
205415
+ }
205416
+ for (const key of await this.listKeys()) {
205417
+ await this.deleteKey(key.id);
205418
+ }
205419
+ try {
205420
+ await this.client.send(new DeleteUserPolicyCommand({ UserName: this.userName, PolicyName: remoteAgentPolicyName }));
205421
+ } catch (error53) {
205422
+ if (!isError(error53, "NoSuchEntityException")) {
205423
+ throw error53;
205424
+ }
205425
+ }
205426
+ await this.client.send(new DeleteUserCommand({ UserName: this.userName }));
205427
+ return true;
205428
+ }
205429
+ }
205430
+
205431
+ // src/cli/command/remote-agent/credentials/shared.ts
205432
+ var createRemoteAgentIam = async (appConfig) => {
205433
+ const credentials2 = await getCredentials(appConfig.profile);
205434
+ const accountId = await getAccountId(credentials2, appConfig.region);
205435
+ const client2 = new IAMClient2({ region: appConfig.region, credentials: credentials2 });
205436
+ const iam = new RemoteAgentIam(client2, appConfig.name);
205437
+ const policy = buildRemoteAgentPolicy({
205438
+ appName: appConfig.name,
205439
+ region: appConfig.region,
205440
+ accountId,
205441
+ auth: Object.keys(appConfig.auth ?? {}).length > 0
205442
+ });
205443
+ return { iam, policy };
205444
+ };
205445
+ var ensureRemoteAgentUser = async (iam, policy) => {
205446
+ const user2 = await logs_exports.task({
205447
+ initialMessage: `Ensuring the ${iam.userName} IAM user...`,
205448
+ successMessage: `The ${iam.userName} IAM user is in place.`,
205449
+ errorMessage: `Failed to ensure the ${iam.userName} IAM user.`,
205450
+ task: () => iam.ensureUser()
205451
+ });
205452
+ const state = await logs_exports.task({
205453
+ initialMessage: "Ensuring the remote agent policy...",
205454
+ successMessage: "The remote agent policy is in place.",
205455
+ errorMessage: "Failed to ensure the remote agent policy.",
205456
+ task: () => iam.ensurePolicy(policy)
205457
+ });
205458
+ return { user: user2, policy: state };
205459
+ };
205460
+ var printCredentials = (appConfig, key) => {
205461
+ logs_exports.list("Remote agent environment", {
205462
+ AWSLESS_REMOTE_AGENT: "1",
205463
+ AWS_REGION: appConfig.region,
205464
+ AWS_ACCESS_KEY_ID: key.id,
205465
+ AWS_SECRET_ACCESS_KEY: key.secret
205466
+ });
205467
+ logs_exports.warning(`The secret access key is shown only once. Copy these variables into the agent environment now - ` + `run ${color2.info("awsless remote-agent credentials rotate")} to get a new one later.`);
205468
+ };
205469
+
205470
+ // src/cli/command/remote-agent/credentials/create.ts
205471
+ var create2 = (program3) => {
205472
+ program3.command("create").description("Create the IAM user & access key a remote agent needs to run the dev & test commands").action(async () => {
205473
+ await layout("remote-agent credentials create", async ({ appConfig }) => {
205474
+ const { iam, policy } = await createRemoteAgentIam(appConfig);
205475
+ await ensureRemoteAgentUser(iam, policy);
205476
+ const keys = await iam.listKeys();
205477
+ if (keys.length > 0) {
205478
+ const key2 = keys[0];
205479
+ const created = key2.createdAt ? ` created ${key2.createdAt.toISOString()}` : "";
205480
+ throw new ExpectedError(`The ${iam.userName} user already has an access key (${key2.id}${created}). ` + `Its secret can't be shown again - run ${color2.info("awsless remote-agent credentials rotate")} to replace it.`);
205481
+ }
205482
+ const key = await iam.createKey();
205483
+ printCredentials(appConfig, key);
205484
+ });
205485
+ });
205486
+ };
205487
+
205488
+ // src/cli/command/remote-agent/credentials/delete.ts
205489
+ var del5 = (program3) => {
205490
+ program3.command("delete").description("Delete the remote agent IAM user, its policy & access keys").action(async () => {
205491
+ await layout("remote-agent credentials delete", async ({ appConfig }) => {
205492
+ const { iam } = await createRemoteAgentIam(appConfig);
205493
+ const deleted = await logs_exports.task({
205494
+ initialMessage: `Deleting the ${iam.userName} IAM user...`,
205495
+ successMessage: `Deleted the ${iam.userName} IAM user.`,
205496
+ errorMessage: `Failed to delete the ${iam.userName} IAM user.`,
205497
+ task: () => iam.deleteUser()
205498
+ });
205499
+ if (!deleted) {
205500
+ logs_exports.info(`The ${iam.userName} IAM user doesn't exist - nothing to delete.`);
205501
+ }
205502
+ });
205503
+ });
205504
+ };
205505
+
205506
+ // src/cli/command/remote-agent/credentials/rotate.ts
205507
+ var rotate = (program3) => {
205508
+ program3.command("rotate").description("Replace the access key of the remote agent IAM user").action(async () => {
205509
+ await layout("remote-agent credentials rotate", async ({ appConfig }) => {
205510
+ const { iam, policy } = await createRemoteAgentIam(appConfig);
205511
+ await ensureRemoteAgentUser(iam, policy);
205512
+ const old = await iam.listKeys();
205513
+ const key = await iam.createKey();
205514
+ for (const entry of old) {
205515
+ await iam.deleteKey(entry.id);
205516
+ }
205517
+ if (old.length > 0) {
205518
+ logs_exports.info(`Deleted ${old.length} previous access key${old.length === 1 ? "" : "s"}.`);
205519
+ }
205520
+ printCredentials(appConfig, key);
205521
+ });
205522
+ });
205523
+ };
205524
+
205525
+ // src/cli/command/remote-agent/credentials/index.ts
205526
+ var commands10 = [create2, rotate, del5];
205527
+ var credentials2 = (program3) => {
205528
+ const command3 = program3.command("credentials").description("Manage the AWS credentials a remote agent uses for the dev & test commands");
205529
+ commands10.forEach((cb) => cb(command3));
205530
+ };
205531
+
205532
+ // src/cli/command/remote-agent/index.ts
205533
+ var commands11 = [credentials2];
205534
+ var remoteAgent = (program3) => {
205535
+ const command3 = program3.command("remote-agent").description("Manage the setup for remote agents, like the Claude cloud sandbox");
205536
+ commands11.forEach((cb) => cb(command3));
205537
+ };
205538
+
205180
205539
  // src/cli/command/resources.ts
205181
205540
  var import_wildstring4 = __toESM(require_wildstring(), 1);
205182
205541
  import { DynamoDBClient as DynamoDBClient7 } from "@awsless/dynamodb";
@@ -205185,14 +205544,14 @@ var resources = (program3) => {
205185
205544
  await layout("resources", async ({ appConfig, stackConfigs }) => {
205186
205545
  const region = appConfig.region;
205187
205546
  const profile = appConfig.profile;
205188
- const credentials2 = await getCredentials(profile);
205189
- const accountId = await getAccountId(credentials2, region);
205190
- const dynamo = new DynamoDBClient7({ credentials: credentials2, region });
205547
+ const credentials3 = await getCredentials(profile);
205548
+ const accountId = await getAccountId(credentials3, region);
205549
+ const dynamo = new DynamoDBClient7({ credentials: credentials3, region });
205191
205550
  const deployment = await currentDeployment(dynamo, generateGlobalAppId({ accountId, region, appName: appConfig.name }));
205192
205551
  const { app, ready: ready2 } = createApp({ appConfig, stackConfigs, accountId, deploymentId: deployment?.id });
205193
205552
  ready2();
205194
205553
  const { workspace } = await createWorkSpace({
205195
- credentials: credentials2,
205554
+ credentials: credentials3,
205196
205555
  accountId,
205197
205556
  region
205198
205557
  });
@@ -206349,8 +206708,8 @@ var getHttpAuthExtensionConfiguration3 = (runtimeConfig) => {
206349
206708
  httpAuthSchemeProvider() {
206350
206709
  return _httpAuthSchemeProvider;
206351
206710
  },
206352
- setCredentials(credentials2) {
206353
- _credentials = credentials2;
206711
+ setCredentials(credentials3) {
206712
+ _credentials = credentials3;
206354
206713
  },
206355
206714
  credentials() {
206356
206715
  return _credentials;
@@ -206515,7 +206874,7 @@ var sinon;
206515
206874
  const arraySlice = arrayProto.slice;
206516
206875
  const concat = arrayProto.concat;
206517
206876
  const forEach = arrayProto.forEach;
206518
- const join53 = arrayProto.join;
206877
+ const join54 = arrayProto.join;
206519
206878
  const splice = arrayProto.splice;
206520
206879
  function applyDefaults(obj, defaults2) {
206521
206880
  for (const key of Object.keys(defaults2)) {
@@ -206551,7 +206910,7 @@ var sinon;
206551
206910
  let actual = "";
206552
206911
  if (!calledInOrder(arguments)) {
206553
206912
  try {
206554
- expected = join53(arguments, ", ");
206913
+ expected = join54(arguments, ", ");
206555
206914
  const calls = arraySlice(arguments);
206556
206915
  let i5 = calls.length;
206557
206916
  while (i5) {
@@ -206559,7 +206918,7 @@ var sinon;
206559
206918
  splice(calls, i5, 1);
206560
206919
  }
206561
206920
  }
206562
- actual = join53(orderByFirstCall(calls), ", ");
206921
+ actual = join54(orderByFirstCall(calls), ", ");
206563
206922
  } catch (e5) {}
206564
206923
  failAssertion(this, `expected ${expected} to be called in order but were called as ${actual}`);
206565
206924
  } else {
@@ -206604,7 +206963,7 @@ var sinon;
206604
206963
  ` expected = ${inspect2(expectation)}`,
206605
206964
  ` actual = ${inspect2(actual)}`
206606
206965
  ];
206607
- failAssertion(this, join53(formatted, `
206966
+ failAssertion(this, join54(formatted, `
206608
206967
  `));
206609
206968
  }
206610
206969
  }
@@ -206709,7 +207068,7 @@ var sinon;
206709
207068
  const valueToString = require2("@sinonjs/commons").valueToString;
206710
207069
  const exportAsyncBehaviors = require2("./util/core/export-async-behaviors");
206711
207070
  const concat = arrayProto.concat;
206712
- const join53 = arrayProto.join;
207071
+ const join54 = arrayProto.join;
206713
207072
  const reverse = arrayProto.reverse;
206714
207073
  const slice = arrayProto.slice;
206715
207074
  const useLeftMostCallback = -1;
@@ -206746,7 +207105,7 @@ var sinon;
206746
207105
  msg = `${functionName(behavior.stub)} expected to yield, but no callback was passed.`;
206747
207106
  }
206748
207107
  if (args.length > 0) {
206749
- msg += ` Received [${join53(args, ", ")}]`;
207108
+ msg += ` Received [${join54(args, ", ")}]`;
206750
207109
  }
206751
207110
  return msg;
206752
207111
  }
@@ -206777,7 +207136,7 @@ var sinon;
206777
207136
  return;
206778
207137
  }
206779
207138
  const proto2 = {
206780
- create: function create2(stub) {
207139
+ create: function create3(stub) {
206781
207140
  const behavior = extend2({}, proto2);
206782
207141
  delete behavior.create;
206783
207142
  delete behavior.addBehavior;
@@ -207386,7 +207745,7 @@ var sinon;
207386
207745
  const mockExpectation = {
207387
207746
  minCalls: 1,
207388
207747
  maxCalls: 1,
207389
- create: function create2(methodName) {
207748
+ create: function create3(methodName) {
207390
207749
  const expectation = extend2.nonEnum(stub(), mockExpectation);
207391
207750
  delete expectation.create;
207392
207751
  expectation.method = methodName;
@@ -207556,7 +207915,7 @@ var sinon;
207556
207915
  const filter2 = arrayProto.filter;
207557
207916
  const forEach = arrayProto.forEach;
207558
207917
  const every = arrayProto.every;
207559
- const join53 = arrayProto.join;
207918
+ const join54 = arrayProto.join;
207560
207919
  const push2 = arrayProto.push;
207561
207920
  const slice = arrayProto.slice;
207562
207921
  const unshift = arrayProto.unshift;
@@ -207579,7 +207938,7 @@ var sinon;
207579
207938
  });
207580
207939
  }
207581
207940
  extend2(mock, {
207582
- create: function create2(object3) {
207941
+ create: function create3(object3) {
207583
207942
  if (!object3) {
207584
207943
  throw new TypeError("object is null");
207585
207944
  }
@@ -207633,10 +207992,10 @@ var sinon;
207633
207992
  });
207634
207993
  this.restore();
207635
207994
  if (messages.length > 0) {
207636
- mockExpectation.fail(join53(concat(messages, met), `
207995
+ mockExpectation.fail(join54(concat(messages, met), `
207637
207996
  `));
207638
207997
  } else if (met.length > 0) {
207639
- mockExpectation.pass(join53(concat(messages, met), `
207998
+ mockExpectation.pass(join54(concat(messages, met), `
207640
207999
  `));
207641
208000
  }
207642
208001
  return true;
@@ -207689,7 +208048,7 @@ var sinon;
207689
208048
  args,
207690
208049
  stack: err.stack
207691
208050
  })}`);
207692
- mockExpectation.fail(join53(messages, `
208051
+ mockExpectation.fail(join54(messages, `
207693
208052
  `));
207694
208053
  }
207695
208054
  });
@@ -207796,14 +208155,14 @@ var sinon;
207796
208155
  const valueToString = require2("@sinonjs/commons").valueToString;
207797
208156
  const concat = arrayProto.concat;
207798
208157
  const filter2 = arrayProto.filter;
207799
- const join53 = arrayProto.join;
208158
+ const join54 = arrayProto.join;
207800
208159
  const map3 = arrayProto.map;
207801
208160
  const reduce2 = arrayProto.reduce;
207802
208161
  const slice = arrayProto.slice;
207803
208162
  function throwYieldError(proxy, text2, args) {
207804
208163
  let msg = functionName(proxy) + text2;
207805
208164
  if (args.length) {
207806
- msg += ` Received [${join53(slice(args), ", ")}]`;
208165
+ msg += ` Received [${join54(slice(args), ", ")}]`;
207807
208166
  }
207808
208167
  throw new Error(msg);
207809
208168
  }
@@ -207925,7 +208284,7 @@ var sinon;
207925
208284
  const formattedArgs = map3(this.args, function(arg) {
207926
208285
  return inspect2(arg);
207927
208286
  });
207928
- callStr = `${callStr + join53(formattedArgs, ", ")})`;
208287
+ callStr = `${callStr + join54(formattedArgs, ", ")})`;
207929
208288
  if (typeof this.returnValue !== "undefined") {
207930
208289
  callStr += ` => ${inspect2(this.returnValue)}`;
207931
208290
  }
@@ -208656,7 +209015,7 @@ var sinon;
208656
209015
  const timesInWords = require2("./util/core/times-in-words");
208657
209016
  const inspect2 = require2("util").inspect;
208658
209017
  const jsDiff = require2("diff");
208659
- const join53 = arrayProto.join;
209018
+ const join54 = arrayProto.join;
208660
209019
  const map3 = arrayProto.map;
208661
209020
  const push2 = arrayProto.push;
208662
209021
  const slice = arrayProto.slice;
@@ -208684,7 +209043,7 @@ var sinon;
208684
209043
  }
208685
209044
  return text2;
208686
209045
  });
208687
- return join53(objects, "");
209046
+ return join54(objects, "");
208688
209047
  }
208689
209048
  function quoteStringValue(value) {
208690
209049
  if (typeof value === "string") {
@@ -208742,7 +209101,7 @@ ${stringifiedCall}`;
208742
209101
  push2(calls, stringifiedCall);
208743
209102
  }
208744
209103
  return calls.length > 0 ? `
208745
- ${join53(calls, `
209104
+ ${join54(calls, `
208746
209105
  `)}` : "";
208747
209106
  },
208748
209107
  t: function(spyInstance) {
@@ -208750,10 +209109,10 @@ ${join53(calls, `
208750
209109
  for (let i5 = 0, l4 = spyInstance.callCount;i5 < l4; ++i5) {
208751
209110
  push2(objects, inspect2(spyInstance.thisValues[i5]));
208752
209111
  }
208753
- return join53(objects, ", ");
209112
+ return join54(objects, ", ");
208754
209113
  },
208755
209114
  "*": function(spyInstance, args) {
208756
- return join53(map3(args, function(arg) {
209115
+ return join54(map3(args, function(arg) {
208757
209116
  return inspect2(arg);
208758
209117
  }), ", ");
208759
209118
  }
@@ -209085,7 +209444,7 @@ ${join53(calls, `
209085
209444
  }, { "@sinonjs/commons": 48 }], 26: [function(require2, module, exports) {
209086
209445
  const arrayProto = require2("@sinonjs/commons").prototypes.array;
209087
209446
  const hasOwnProperty2 = require2("@sinonjs/commons").prototypes.object.hasOwnProperty;
209088
- const join53 = arrayProto.join;
209447
+ const join54 = arrayProto.join;
209089
209448
  const push2 = arrayProto.push;
209090
209449
  const hasDontEnumBug = function() {
209091
209450
  const obj = {
@@ -209126,7 +209485,7 @@ ${join53(calls, `
209126
209485
  push2(result, obj[prop]());
209127
209486
  }
209128
209487
  }
209129
- return join53(result, "") !== "0123456789";
209488
+ return join54(result, "") !== "0123456789";
209130
209489
  }();
209131
209490
  function extendCommon(target2, sources, doCopy) {
209132
209491
  let source, i5, prop;
@@ -211191,7 +211550,7 @@ ${job.error.stack.split(`
211191
211550
  module.exports = matcherPrototype;
211192
211551
  }, { "../create-matcher": 63 }], 71: [function(require2, module, exports) {
211193
211552
  var functionName = require2("@sinonjs/commons").functionName;
211194
- var join53 = require2("@sinonjs/commons").prototypes.array.join;
211553
+ var join54 = require2("@sinonjs/commons").prototypes.array.join;
211195
211554
  var map3 = require2("@sinonjs/commons").prototypes.array.map;
211196
211555
  var stringIndexOf = require2("@sinonjs/commons").prototypes.string.indexOf;
211197
211556
  var valueToString = require2("@sinonjs/commons").valueToString;
@@ -211222,7 +211581,7 @@ ${job.error.stack.split(`
211222
211581
  m4.test = function(actual) {
211223
211582
  return matchObject(actual, expectation, match3);
211224
211583
  };
211225
- m4.message = `match(${join53(array3, ", ")})`;
211584
+ m4.message = `match(${join54(array3, ", ")})`;
211226
211585
  return m4;
211227
211586
  },
211228
211587
  regexp: function(m4, expectation) {
@@ -214546,7 +214905,7 @@ ${job.error.stack.split(`
214546
214905
  tokenize: function tokenize(value) {
214547
214906
  return value.split("");
214548
214907
  },
214549
- join: function join53(chars) {
214908
+ join: function join54(chars) {
214550
214909
  return chars.join("");
214551
214910
  }
214552
214911
  };
@@ -218786,21 +219145,21 @@ var run = (program3) => {
218786
219145
  program3.command("run").allowUnknownOption(true).argument("[command]", "The command you want to run").description("Run one of your defined commands.").action(async (selected) => {
218787
219146
  await layout(`run ${selected ?? ""}`, async ({ appConfig, stackConfigs }) => {
218788
219147
  const region = appConfig.region;
218789
- const credentials2 = await getCredentials(appConfig.profile);
218790
- const accountId = await getAccountId(credentials2, region);
218791
- const { commands: commands10, appId } = createApp({ appConfig, stackConfigs, accountId });
219148
+ const credentials3 = await getCredentials(appConfig.profile);
219149
+ const accountId = await getAccountId(credentials3, region);
219150
+ const { commands: commands12, appId } = createApp({ appConfig, stackConfigs, accountId });
218792
219151
  let command3;
218793
219152
  if (selected) {
218794
- command3 = commands10.find((cmd) => {
219153
+ command3 = commands12.find((cmd) => {
218795
219154
  return cmd.name === selected;
218796
219155
  });
218797
219156
  } else if (process.env.SKIP_PROMPT) {
218798
- throw new ExpectedError(`Pass the command argument when running with --skip-prompt: [ ${commands10.map((cmd) => cmd.name).join(", ")} ]`);
219157
+ throw new ExpectedError(`Pass the command argument when running with --skip-prompt: [ ${commands12.map((cmd) => cmd.name).join(", ")} ]`);
218799
219158
  } else {
218800
219159
  command3 = await prompts_exports.select({
218801
219160
  message: "Pick the command you want to run:",
218802
- initialValue: commands10[0],
218803
- options: commands10.map((cmd) => ({
219161
+ initialValue: commands12[0],
219162
+ options: commands12.map((cmd) => ({
218804
219163
  value: cmd,
218805
219164
  label: cmd.name,
218806
219165
  hint: cmd.description
@@ -218824,15 +219183,15 @@ var run = (program3) => {
218824
219183
  if (!handler) {
218825
219184
  throw new ExpectedError(`No "${command3.handler}" handler found.`);
218826
219185
  }
218827
- dynamoDBClient.set(new DynamoDBClient8({ region, credentials: credentials2 }));
218828
- lambdaClient.set(new LambdaClient7({ region, credentials: credentials2 }));
218829
- snsClient.set(new SNSClient2({ region, credentials: credentials2 }));
218830
- iotClient.set(new IoTDataPlaneClient({ region, credentials: credentials2 }));
218831
- sqsClient.set(new SQSClient({ region, credentials: credentials2 }));
218832
- s3Client.set(new S3Client8({ region, credentials: credentials2 }));
219186
+ dynamoDBClient.set(new DynamoDBClient8({ region, credentials: credentials3 }));
219187
+ lambdaClient.set(new LambdaClient7({ region, credentials: credentials3 }));
219188
+ snsClient.set(new SNSClient2({ region, credentials: credentials3 }));
219189
+ iotClient.set(new IoTDataPlaneClient({ region, credentials: credentials3 }));
219190
+ sqsClient.set(new SQSClient({ region, credentials: credentials3 }));
219191
+ s3Client.set(new S3Client8({ region, credentials: credentials3 }));
218833
219192
  await handler({
218834
219193
  region,
218835
- credentials: credentials2,
219194
+ credentials: credentials3,
218836
219195
  accountId
218837
219196
  });
218838
219197
  });
@@ -218845,10 +219204,10 @@ var pull = (program3) => {
218845
219204
  await layout("state pull", async ({ appConfig, stackConfigs }) => {
218846
219205
  const region = appConfig.region;
218847
219206
  const profile = appConfig.profile;
218848
- const credentials2 = await getCredentials(profile);
218849
- const accountId = await getAccountId(credentials2, region);
219207
+ const credentials3 = await getCredentials(profile);
219208
+ const accountId = await getAccountId(credentials3, region);
218850
219209
  const { app } = createApp({ appConfig, stackConfigs, accountId });
218851
- const { state } = await createWorkSpace({ credentials: credentials2, region, accountId });
219210
+ const { state } = await createWorkSpace({ credentials: credentials3, region, accountId });
218852
219211
  await pullRemoteState(app, state);
218853
219212
  return "State pull was successful.";
218854
219213
  });
@@ -218861,10 +219220,10 @@ var push2 = (program3) => {
218861
219220
  await layout("state pull", async ({ appConfig, stackConfigs }) => {
218862
219221
  const region = appConfig.region;
218863
219222
  const profile = appConfig.profile;
218864
- const credentials2 = await getCredentials(profile);
218865
- const accountId = await getAccountId(credentials2, region);
219223
+ const credentials3 = await getCredentials(profile);
219224
+ const accountId = await getAccountId(credentials3, region);
218866
219225
  const { app } = createApp({ appConfig, stackConfigs, accountId });
218867
- const { state } = await createWorkSpace({ credentials: credentials2, region, accountId });
219226
+ const { state } = await createWorkSpace({ credentials: credentials3, region, accountId });
218868
219227
  if (!process.env.SKIP_PROMPT) {
218869
219228
  const ok2 = await prompts_exports.confirm({
218870
219229
  message: "Pushing up the local state might corrupt your remote state. Are you sure?",
@@ -220836,10 +221195,10 @@ var refresh2 = (program3) => {
220836
221195
  await layout("state refresh", async ({ appConfig, stackConfigs }) => {
220837
221196
  const region = appConfig.region;
220838
221197
  const profile = appConfig.profile;
220839
- const credentials2 = await getCredentials(profile);
220840
- const accountId = await getAccountId(credentials2, region);
221198
+ const credentials3 = await getCredentials(profile);
221199
+ const accountId = await getAccountId(credentials3, region);
220841
221200
  const { app } = createApp({ appConfig, stackConfigs, accountId });
220842
- const { workspace } = await createWorkSpace({ credentials: credentials2, region, accountId });
221201
+ const { workspace } = await createWorkSpace({ credentials: credentials3, region, accountId });
220843
221202
  const stackNames = app.stacks.filter((stack) => {
220844
221203
  return !!filters.find((f4) => import_wildstring5.default.match(f4, stack.name));
220845
221204
  }).map((s2) => s2.name);
@@ -220930,10 +221289,10 @@ var unlock2 = (program3) => {
220930
221289
  await layout("state unlock", async ({ appConfig, stackConfigs }) => {
220931
221290
  const region = appConfig.region;
220932
221291
  const profile = appConfig.profile;
220933
- const credentials2 = await getCredentials(profile);
220934
- const accountId = await getAccountId(credentials2, region);
221292
+ const credentials3 = await getCredentials(profile);
221293
+ const accountId = await getAccountId(credentials3, region);
220935
221294
  const { app } = createApp({ appConfig, stackConfigs, accountId });
220936
- const { lock: lock2 } = createDeploymentBackends({ credentials: credentials2, region, accountId });
221295
+ const { lock: lock2 } = createDeploymentBackends({ credentials: credentials3, region, accountId });
220937
221296
  const releaseUrn = getAppReleaseLockUrn(generateGlobalAppId({ accountId, region, appName: appConfig.name }));
220938
221297
  const lockedUrns = [];
220939
221298
  for (const urn of [app.urn, releaseUrn]) {
@@ -220962,10 +221321,10 @@ var unlock2 = (program3) => {
220962
221321
  };
220963
221322
 
220964
221323
  // src/cli/command/state/index.ts
220965
- var commands10 = [pull, push2, unlock2, refresh2];
221324
+ var commands12 = [pull, push2, unlock2, refresh2];
220966
221325
  var state = (program3) => {
220967
221326
  const command3 = program3.command("state").description(`Manage app state`);
220968
- commands10.forEach((cb) => cb(command3));
221327
+ commands12.forEach((cb) => cb(command3));
220969
221328
  };
220970
221329
 
220971
221330
  // src/cli/command/test.ts
@@ -221010,7 +221369,7 @@ var types2 = (program3) => {
221010
221369
  };
221011
221370
 
221012
221371
  // src/cli/command/index.ts
221013
- var commands11 = [
221372
+ var commands13 = [
221014
221373
  bootstrap,
221015
221374
  types2,
221016
221375
  build2,
@@ -221028,6 +221387,7 @@ var commands11 = [
221028
221387
  state,
221029
221388
  resources,
221030
221389
  config3,
221390
+ remoteAgent,
221031
221391
  test2,
221032
221392
  cron,
221033
221393
  image,
@@ -221047,10 +221407,13 @@ program2.exitOverride((error53) => {
221047
221407
  program2.on("option:skip-prompt", () => {
221048
221408
  process.env.SKIP_PROMPT = program2.opts().skipPrompt ? "1" : undefined;
221049
221409
  });
221410
+ if (isRemoteAgent()) {
221411
+ process.env.SKIP_PROMPT = "1";
221412
+ }
221050
221413
  program2.on("option:no-cache", () => {
221051
221414
  process.env.NO_CACHE = program2.opts().cache === false ? "1" : undefined;
221052
221415
  });
221053
- commands11.forEach((fn) => fn(program2));
221416
+ commands13.forEach((fn) => fn(program2));
221054
221417
 
221055
221418
  // src/bin.ts
221056
221419
  clearDebugLog();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/cli",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "bugs": {
5
5
  "url": "https://github.com/awsless/awsless/issues"
6
6
  },
@@ -29,6 +29,7 @@
29
29
  "@aws-sdk/client-cloudwatch-logs": "3.1113.0",
30
30
  "@aws-sdk/client-cognito-identity-provider": "3.1113.0",
31
31
  "@aws-sdk/client-dynamodb": "3.1113.0",
32
+ "@aws-sdk/client-iam": "3.1113.0",
32
33
  "@aws-sdk/client-lambda": "3.1113.0",
33
34
  "@aws-sdk/client-route-53": "3.1113.0",
34
35
  "@aws-sdk/client-s3": "3.1113.0",
@@ -82,32 +83,33 @@
82
83
  "wrap-ansi": "10.0.1",
83
84
  "zod": "4.4.3",
84
85
  "@awsless/big-float": "^0.1.8",
85
- "@awsless/cloudwatch": "^0.0.2",
86
+ "@awsless/clui": "^0.0.10",
86
87
  "@awsless/duration": "^0.0.4",
87
88
  "@awsless/dynamodb": "^0.3.28",
88
- "@awsless/clui": "^0.0.10",
89
+ "@awsless/cloudwatch": "^0.0.2",
89
90
  "@awsless/dynamodb-server": "^0.1.11",
90
- "@awsless/json": "^0.0.12",
91
+ "@awsless/lambda": "^0.0.50",
91
92
  "@awsless/open-search": "^0.0.32",
92
- "@awsless/open-search-server": "^0.0.1",
93
93
  "@awsless/iot": "^0.0.6",
94
- "@awsless/lambda": "^0.0.50",
95
- "@awsless/redis-server": "^0.1.0",
96
- "@awsless/redis": "^0.1.15",
94
+ "@awsless/json": "^0.0.12",
95
+ "@awsless/open-search-server": "^0.0.1",
96
+ "@awsless/redis-server": "^0.1.1",
97
+ "@awsless/redis": "^0.1.16",
97
98
  "@awsless/s3": "^0.0.23",
98
- "@awsless/ts-file-cache": "^0.0.22",
99
- "@awsless/size": "^0.0.3",
100
- "awsless": "^0.1.11",
101
- "@awsless/sns": "^0.0.12",
102
99
  "@awsless/sqs": "^0.0.25",
100
+ "@awsless/sns": "^0.0.12",
103
101
  "@awsless/validate": "^0.2.1",
104
- "@awsless/weak-cache": "^0.0.2"
102
+ "@awsless/size": "^0.0.3",
103
+ "awsless": "^0.1.11",
104
+ "@awsless/weak-cache": "^0.0.2",
105
+ "@awsless/ts-file-cache": "^0.0.22"
105
106
  },
106
107
  "peerDependencies": {
107
108
  "@aws-sdk/client-cloudfront-keyvaluestore": "3.1113.0",
108
109
  "@aws-sdk/client-cloudwatch-logs": "3.1113.0",
109
110
  "@aws-sdk/client-cognito-identity-provider": "3.1113.0",
110
111
  "@aws-sdk/client-dynamodb": "3.1113.0",
112
+ "@aws-sdk/client-iam": "3.1113.0",
111
113
  "@aws-sdk/client-lambda": "3.1113.0",
112
114
  "@aws-sdk/client-route-53": "3.1113.0",
113
115
  "@aws-sdk/client-s3": "3.1113.0",
@@ -119,16 +121,16 @@
119
121
  "@aws-sdk/lib-dynamodb": "3.1113.0",
120
122
  "@opensearch-project/opensearch": "3.6.0",
121
123
  "@awsless/duration": "^0.0.4",
124
+ "@awsless/dynamodb-server": "^0.1.11",
122
125
  "@awsless/dynamodb": "^0.3.28",
123
- "@awsless/big-float": "^0.1.8",
124
- "@awsless/lambda": "^0.0.50",
125
126
  "@awsless/json": "^0.0.12",
127
+ "@awsless/lambda": "^0.0.50",
126
128
  "@awsless/validate": "^0.2.1",
127
- "@awsless/ts-file-cache": "^0.0.22",
128
- "@awsless/dynamodb-server": "^0.1.11",
129
129
  "@awsless/weak-cache": "^0.0.2",
130
+ "@awsless/ts-file-cache": "^0.0.22",
130
131
  "awsless": "^0.1.11",
131
- "@awsless/s3": "^0.0.23"
132
+ "@awsless/s3": "^0.0.23",
133
+ "@awsless/big-float": "^0.1.8"
132
134
  },
133
135
  "scripts": {
134
136
  "test": "bun cli/build-handlers.ts && pnpm vitest run",