@mtndev/cli 2.0.0 → 2.0.1

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 (264) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/__chunks/VH7oDXx4.cjs +28 -0
  3. package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -12
  4. package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -55
  5. package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -13
  6. package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -39
  7. package/cjs/commands/aws/iam/admin-group.cjs +111 -15
  8. package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -12
  9. package/cjs/commands/aws/iam/break-glass/index.cjs +7 -19
  10. package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -12
  11. package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -10
  12. package/cjs/commands/aws/iam/check-admin/index.cjs +7 -17
  13. package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -12
  14. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  15. package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
  16. package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  17. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  18. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  19. package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  20. package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -11
  21. package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -18
  22. package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -12
  23. package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -14
  24. package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -33
  25. package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -7
  26. package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -20
  27. package/cjs/commands/aws/iam/users/handler.cjs +59 -12
  28. package/cjs/commands/aws/iam/users/index.cjs +18 -41
  29. package/cjs/commands/aws/iam/users/schema.cjs +17 -7
  30. package/cjs/commands/aws/iam/users/utils.cjs +454 -30
  31. package/cjs/commands/aws/index.cjs +223 -229
  32. package/cjs/commands/aws/route53/add-record/handler.cjs +264 -18
  33. package/cjs/commands/aws/route53/add-record/index.cjs +26 -57
  34. package/cjs/commands/aws/route53/add-record/schema.cjs +43 -11
  35. package/cjs/commands/aws/route53/add-record/utils.cjs +404 -37
  36. package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -14
  37. package/cjs/commands/aws/route53/remove-record/index.cjs +5 -18
  38. package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -8
  39. package/cjs/commands/aws/schema.cjs +19 -10
  40. package/cjs/commands/aws/ses/send-email/handler.cjs +73 -12
  41. package/cjs/commands/aws/ses/send-email/index.cjs +9 -23
  42. package/cjs/commands/aws/ses/send-email/schema.cjs +24 -7
  43. package/cjs/commands/aws/ses/send-email/utils.cjs +87 -11
  44. package/cjs/commands/aws/ses/smtp-password.cjs +72 -10
  45. package/cjs/commands/aws/utils/exec-aws.cjs +145 -16
  46. package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -6
  47. package/cjs/commands/aws/utils/resolve-profile.cjs +93 -11
  48. package/cjs/commands/aws/utils/tty.cjs +54 -10
  49. package/cjs/commands/db/create-readonly-user/handler.cjs +254 -11
  50. package/cjs/commands/db/create-readonly-user/index.cjs +18 -40
  51. package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -9
  52. package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -9
  53. package/cjs/commands/db/create-readonly-user/schema.cjs +39 -12
  54. package/cjs/commands/db/create-readonly-user/utils.cjs +160 -22
  55. package/cjs/commands/db/index.cjs +46 -44
  56. package/cjs/commands/doppler/handler.cjs +95 -11
  57. package/cjs/commands/doppler/index.cjs +33 -68
  58. package/cjs/commands/doppler/schema.cjs +130 -14
  59. package/cjs/commands/doppler/set-secret.cjs +378 -19
  60. package/cjs/commands/doppler/utils/exec.cjs +106 -12
  61. package/cjs/commands/doppler/utils.cjs +412 -34
  62. package/cjs/commands/icons/handler.cjs +82 -8
  63. package/cjs/commands/icons/index.cjs +15 -31
  64. package/cjs/commands/icons/schema.cjs +101 -13
  65. package/cjs/commands/icons/utils.cjs +131 -13
  66. package/cjs/commands/index.cjs +54 -161
  67. package/cjs/commands/schema.cjs +25 -8
  68. package/cjs/index.cjs +3 -4
  69. package/esm/commands/aws/ec2/allow-ip/handler.js +258 -12
  70. package/esm/commands/aws/ec2/allow-ip/index.js +4 -55
  71. package/esm/commands/aws/ec2/allow-ip/schema.js +29 -13
  72. package/esm/commands/aws/ec2/allow-ip/utils.js +363 -39
  73. package/esm/commands/aws/iam/admin-group.js +104 -15
  74. package/esm/commands/aws/iam/break-glass/handler.js +124 -12
  75. package/esm/commands/aws/iam/break-glass/index.js +4 -19
  76. package/esm/commands/aws/iam/break-glass/schema.js +19 -12
  77. package/esm/commands/aws/iam/check-admin/handler.js +86 -10
  78. package/esm/commands/aws/iam/check-admin/index.js +4 -17
  79. package/esm/commands/aws/iam/check-admin/schema.js +17 -12
  80. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  81. package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
  82. package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  83. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  84. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  85. package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  86. package/esm/commands/aws/iam/remove-admin/handler.js +117 -11
  87. package/esm/commands/aws/iam/remove-admin/index.js +4 -18
  88. package/esm/commands/aws/iam/remove-admin/schema.js +20 -12
  89. package/esm/commands/aws/iam/setup-acl/handler.js +224 -14
  90. package/esm/commands/aws/iam/setup-acl/index.js +4 -33
  91. package/esm/commands/aws/iam/setup-acl/schema.js +18 -7
  92. package/esm/commands/aws/iam/setup-acl/utils.js +298 -20
  93. package/esm/commands/aws/iam/users/handler.js +56 -12
  94. package/esm/commands/aws/iam/users/index.js +4 -41
  95. package/esm/commands/aws/iam/users/schema.js +16 -7
  96. package/esm/commands/aws/iam/users/utils.js +440 -30
  97. package/esm/commands/aws/index.js +142 -229
  98. package/esm/commands/aws/route53/add-record/handler.js +258 -18
  99. package/esm/commands/aws/route53/add-record/index.js +4 -57
  100. package/esm/commands/aws/route53/add-record/schema.js +40 -11
  101. package/esm/commands/aws/route53/add-record/utils.js +389 -37
  102. package/esm/commands/aws/route53/remove-record/handler.js +111 -14
  103. package/esm/commands/aws/route53/remove-record/index.js +3 -18
  104. package/esm/commands/aws/route53/remove-record/schema.js +21 -8
  105. package/esm/commands/aws/schema.js +16 -10
  106. package/esm/commands/aws/ses/send-email/handler.js +70 -12
  107. package/esm/commands/aws/ses/send-email/index.js +4 -23
  108. package/esm/commands/aws/ses/send-email/schema.js +23 -7
  109. package/esm/commands/aws/ses/send-email/utils.js +84 -11
  110. package/esm/commands/aws/ses/smtp-password.js +69 -10
  111. package/esm/commands/aws/utils/exec-aws.js +136 -15
  112. package/esm/commands/aws/utils/resolve-policy-path.js +14 -6
  113. package/esm/commands/aws/utils/resolve-profile.js +88 -11
  114. package/esm/commands/aws/utils/tty.js +51 -10
  115. package/esm/commands/db/create-readonly-user/handler.js +251 -11
  116. package/esm/commands/db/create-readonly-user/index.js +4 -40
  117. package/esm/commands/db/create-readonly-user/mysql.js +98 -9
  118. package/esm/commands/db/create-readonly-user/postgres.js +205 -9
  119. package/esm/commands/db/create-readonly-user/schema.js +35 -12
  120. package/esm/commands/db/create-readonly-user/utils.js +151 -22
  121. package/esm/commands/db/index.js +31 -44
  122. package/esm/commands/doppler/handler.js +92 -11
  123. package/esm/commands/doppler/index.js +6 -68
  124. package/esm/commands/doppler/schema.js +125 -15
  125. package/esm/commands/doppler/set-secret.js +370 -19
  126. package/esm/commands/doppler/utils/exec.js +100 -12
  127. package/esm/commands/doppler/utils.js +396 -34
  128. package/esm/commands/icons/handler.js +79 -8
  129. package/esm/commands/icons/index.js +4 -31
  130. package/esm/commands/icons/schema.js +97 -15
  131. package/esm/commands/icons/utils.js +125 -13
  132. package/esm/commands/index.js +47 -155
  133. package/esm/commands/schema.js +22 -7
  134. package/esm/index.js +3 -4
  135. package/package.json +5 -2
  136. package/vitest.config.ts +11 -0
  137. package/cjs/__chunks/2FSYDFUV.cjs +0 -146
  138. package/cjs/__chunks/3A5ZYU5M.cjs +0 -105
  139. package/cjs/__chunks/3BY5Y4W7.cjs +0 -1
  140. package/cjs/__chunks/3NOHGUCF.cjs +0 -9
  141. package/cjs/__chunks/3T2LXW7J.cjs +0 -387
  142. package/cjs/__chunks/4SFWHCB3.cjs +0 -133
  143. package/cjs/__chunks/4XT5JEAS.cjs +0 -1
  144. package/cjs/__chunks/AZEB4H4I.cjs +0 -208
  145. package/cjs/__chunks/B2KFW7T7.cjs +0 -1
  146. package/cjs/__chunks/B5ENMOCD.cjs +0 -288
  147. package/cjs/__chunks/B6XM5KSF.cjs +0 -338
  148. package/cjs/__chunks/BDU2UCE5.cjs +0 -1
  149. package/cjs/__chunks/BLMSMR5E.cjs +0 -46
  150. package/cjs/__chunks/CMUD7LLN.cjs +0 -47
  151. package/cjs/__chunks/DTQ2LB3I.cjs +0 -49
  152. package/cjs/__chunks/FM5MVRQF.cjs +0 -23
  153. package/cjs/__chunks/FRHST54J.cjs +0 -135
  154. package/cjs/__chunks/FU4VP2LN.cjs +0 -1
  155. package/cjs/__chunks/G5K4PVIL.cjs +0 -26
  156. package/cjs/__chunks/GU3R54MK.cjs +0 -127
  157. package/cjs/__chunks/GUL36IFZ.cjs +0 -61
  158. package/cjs/__chunks/GZMTNK5N.cjs +0 -1
  159. package/cjs/__chunks/H74JSDBU.cjs +0 -30
  160. package/cjs/__chunks/INFOPAHN.cjs +0 -117
  161. package/cjs/__chunks/J36P6UNE.cjs +0 -75
  162. package/cjs/__chunks/JB7T7PKQ.cjs +0 -538
  163. package/cjs/__chunks/JSL2JDMW.cjs +0 -1
  164. package/cjs/__chunks/K4QNHRTP.cjs +0 -163
  165. package/cjs/__chunks/KU76LC42.cjs +0 -192
  166. package/cjs/__chunks/LFDSHANP.cjs +0 -34
  167. package/cjs/__chunks/LHE24ECK.cjs +0 -192
  168. package/cjs/__chunks/LIKQ3SI4.cjs +0 -1
  169. package/cjs/__chunks/LXDF5QVZ.cjs +0 -313
  170. package/cjs/__chunks/LXOOJR2R.cjs +0 -74
  171. package/cjs/__chunks/N5MXFOQZ.cjs +0 -167
  172. package/cjs/__chunks/N7D56LPP.cjs +0 -25
  173. package/cjs/__chunks/NFXQNOQH.cjs +0 -393
  174. package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
  175. package/cjs/__chunks/NLKJIUEX.cjs +0 -126
  176. package/cjs/__chunks/NT2XXAI6.cjs +0 -89
  177. package/cjs/__chunks/NWZGFHKH.cjs +0 -121
  178. package/cjs/__chunks/R3GUC7O7.cjs +0 -110
  179. package/cjs/__chunks/RPVAXPJ4.cjs +0 -1
  180. package/cjs/__chunks/S3LVCWPN.cjs +0 -23
  181. package/cjs/__chunks/SBBNW2BF.cjs +0 -249
  182. package/cjs/__chunks/T2A7TN4F.cjs +0 -81
  183. package/cjs/__chunks/TKNNDDIB.cjs +0 -97
  184. package/cjs/__chunks/TNSRDJPR.cjs +0 -1
  185. package/cjs/__chunks/UWHPE2GI.cjs +0 -20
  186. package/cjs/__chunks/W6K7BV74.cjs +0 -1
  187. package/cjs/__chunks/WBOQ6AUN.cjs +0 -320
  188. package/cjs/__chunks/WHGN5PZI.cjs +0 -299
  189. package/cjs/__chunks/WOYF2L6T.cjs +0 -11
  190. package/cjs/__chunks/X26XY2N6.cjs +0 -18
  191. package/cjs/__chunks/XMKOKRXZ.cjs +0 -16
  192. package/cjs/__chunks/XTJPQ3EX.cjs +0 -1
  193. package/cjs/__chunks/YRHFKTW2.cjs +0 -63
  194. package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
  195. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.cjs +0 -28
  196. package/cjs/commands/aws/iam/policies/sts-federation.cjs +0 -19
  197. package/cjs/commands/aws/iam/policies/user-admins-deny-list.cjs +0 -183
  198. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.cjs +0 -49
  199. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.cjs +0 -64
  200. package/cjs/commands/aws/iam/policies/user-admins-write-list.cjs +0 -125
  201. package/esm/__chunks/2FTTEFEK.js +0 -97
  202. package/esm/__chunks/33UYMUQD.js +0 -338
  203. package/esm/__chunks/3BKWTHLJ.js +0 -25
  204. package/esm/__chunks/3HE4BEJX.js +0 -105
  205. package/esm/__chunks/3QLI5BDL.js +0 -387
  206. package/esm/__chunks/5GIUAFXL.js +0 -89
  207. package/esm/__chunks/5ZBVGSOK.js +0 -0
  208. package/esm/__chunks/6G4PXXKF.js +0 -75
  209. package/esm/__chunks/73BJG53F.js +0 -11
  210. package/esm/__chunks/7VF4Q43Q.js +0 -0
  211. package/esm/__chunks/AEDEAYF5.js +0 -0
  212. package/esm/__chunks/AZCP3SFJ.js +0 -0
  213. package/esm/__chunks/B2DVQ2UL.js +0 -61
  214. package/esm/__chunks/CVQVHLW5.js +0 -0
  215. package/esm/__chunks/D62SPZXC.js +0 -0
  216. package/esm/__chunks/DLEJ25GZ.js +0 -121
  217. package/esm/__chunks/DMYFNF54.js +0 -192
  218. package/esm/__chunks/DNFTUMGD.js +0 -23
  219. package/esm/__chunks/DVKD6YSR.js +0 -49
  220. package/esm/__chunks/EMSH4P76.js +0 -20
  221. package/esm/__chunks/FFKFVMIE.js +0 -167
  222. package/esm/__chunks/FL7AILGH.js +0 -133
  223. package/esm/__chunks/FNXUONAV.js +0 -110
  224. package/esm/__chunks/G4NJHFFU.js +0 -320
  225. package/esm/__chunks/HJSXC6HP.js +0 -117
  226. package/esm/__chunks/IEOGAQYI.js +0 -46
  227. package/esm/__chunks/IZFGBYGE.js +0 -34
  228. package/esm/__chunks/J34UVKLA.js +0 -26
  229. package/esm/__chunks/JZPBBBIG.js +0 -74
  230. package/esm/__chunks/KWUJP5MG.js +0 -135
  231. package/esm/__chunks/M35URMT4.js +0 -313
  232. package/esm/__chunks/NF3M2L6C.js +0 -81
  233. package/esm/__chunks/O3CCA76Q.js +0 -22
  234. package/esm/__chunks/PNPPDYKC.js +0 -299
  235. package/esm/__chunks/QFXN4EHM.js +0 -393
  236. package/esm/__chunks/QKDDLIWD.js +0 -146
  237. package/esm/__chunks/QSE66AKY.js +0 -208
  238. package/esm/__chunks/QUF7PS4R.js +0 -18
  239. package/esm/__chunks/S7IJPJ4R.js +0 -126
  240. package/esm/__chunks/SD3E3EPH.js +0 -163
  241. package/esm/__chunks/SJXQJ7RS.js +0 -92
  242. package/esm/__chunks/SNCKIAOR.js +0 -0
  243. package/esm/__chunks/T3TTUHTW.js +0 -30
  244. package/esm/__chunks/TIOVE6HR.js +0 -0
  245. package/esm/__chunks/TXKMEIDQ.js +0 -0
  246. package/esm/__chunks/U7HAE2RF.js +0 -288
  247. package/esm/__chunks/UXWY7BYE.js +0 -63
  248. package/esm/__chunks/VKAKISRG.js +0 -192
  249. package/esm/__chunks/WD2YR6I7.js +0 -0
  250. package/esm/__chunks/WOZFZKFY.js +0 -0
  251. package/esm/__chunks/XI7GZDE2.js +0 -0
  252. package/esm/__chunks/XOUWDB3T.js +0 -249
  253. package/esm/__chunks/XQN2TA4S.js +0 -23
  254. package/esm/__chunks/XXK32TIM.js +0 -16
  255. package/esm/__chunks/YGWTVPZE.js +0 -538
  256. package/esm/__chunks/YRG7PT33.js +0 -127
  257. package/esm/__chunks/ZHKVJO2U.js +0 -47
  258. package/esm/__chunks/ZO55YUSY.js +0 -9
  259. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.js +0 -28
  260. package/esm/commands/aws/iam/policies/sts-federation.js +0 -19
  261. package/esm/commands/aws/iam/policies/user-admins-deny-list.js +0 -183
  262. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.js +0 -49
  263. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.js +0 -64
  264. package/esm/commands/aws/iam/policies/user-admins-write-list.js +0 -125
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mtndev/cli
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#18](https://github.com/High-Country-Dev/core/pull/18) [`6afcc2a`](https://github.com/High-Country-Dev/core/commit/6afcc2a3d41b51afddd96adad77abae0b65b2e65) Thanks [@rnarcos](https://github.com/rnarcos)! - Fixed the published CLI crashing on every invocation with `SyntaxError: Cannot use 'import.meta' outside a module`. The CJS build (the target of the published `bin`) contained a raw `import.meta.url`: tsup's experimental CJS code splitting transpiles via sucrase, which leaves `import.meta` untouched. The build pipeline (libsync) was upgraded to 2.0.0, which replaces tsup with tsdown (Rolldown): `import.meta.url` is now rewritten inline per module for CJS output, the module structure is preserved 1:1 (no chunk relocation), and the bundled IAM policy JSON documents are shipped alongside the compiled code — so the original `resolvePolicyPath` design works as written. No CLI interface changes.
8
+
9
+ - [#16](https://github.com/High-Country-Dev/core/pull/16) [`4a43df1`](https://github.com/High-Country-Dev/core/commit/4a43df1064325da93a69df798c9213178b1027c8) Thanks [@dnishiyama](https://github.com/dnishiyama)! - Add Vitest testing infrastructure for `@mtndev/cli`: a Node-environment Vitest
10
+ setup with seed tests for the Doppler command utilities and schemas, wired into
11
+ Turbo and the PR CI checks. Tests are colocated under `src/` (so they are
12
+ typechecked, linted, and formatted) and excluded from the published build via
13
+ `libsync` ignore globs and `tsconfig.build.json`, so no test files ship in the
14
+ `cjs`/`esm` output. No runtime behavior changes.
15
+
3
16
  ## 2.0.0
4
17
 
5
18
  ### Major Changes
@@ -0,0 +1,28 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ Object.defineProperty(exports, "__toESM", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return __toESM;
27
+ }
28
+ });
@@ -1,12 +1,261 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _WHGN5PZIcjs = require('../../../../__chunks/WHGN5PZI.cjs');
4
- require('../../../../__chunks/B5ENMOCD.cjs');
5
- require('../../../../__chunks/G5K4PVIL.cjs');
6
- require('../../../../__chunks/R3GUC7O7.cjs');
7
- require('../../../../__chunks/NT2XXAI6.cjs');
8
- require('../../../../__chunks/WOYF2L6T.cjs');
9
- require('../../../../__chunks/CMUD7LLN.cjs');
10
-
11
-
12
- exports.allowIpCommand = _WHGN5PZIcjs.allowIpCommand;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("../../../../__chunks/VH7oDXx4.cjs");
3
+ const require_commands_aws_utils_tty = require("../../utils/tty.cjs");
4
+ const require_commands_aws_utils_exec_aws = require("../../utils/exec-aws.cjs");
5
+ const require_commands_aws_utils_resolve_profile = require("../../utils/resolve-profile.cjs");
6
+ const require_commands_aws_ec2_allow_ip_schema = require("./schema.cjs");
7
+ const require_commands_aws_ec2_allow_ip_utils = require("./utils.cjs");
8
+ let chalk = require("chalk");
9
+ chalk = require_rolldown_runtime.__toESM(chalk, 1);
10
+ let zod = require("zod");
11
+ //#region src/commands/aws/ec2/allow-ip/handler.js
12
+ /**
13
+ * Resolve which region to operate in: explicit, else default if it has instances,
14
+ * else prompt from the enabled regions.
15
+ * @param {{ profile?: string; region?: string; verbose: boolean }} params
16
+ * @returns {Promise<string>}
17
+ */
18
+ async function resolveRegion(params) {
19
+ const { profile, region, verbose } = params;
20
+ if (region) return region;
21
+ if (require_commands_aws_ec2_allow_ip_utils.listInstances({
22
+ profile,
23
+ region: "us-east-1",
24
+ verbose
25
+ }).length > 0) return require_commands_aws_ec2_allow_ip_schema.DEFAULT_REGION;
26
+ const regions = require_commands_aws_ec2_allow_ip_utils.listEnabledRegions({
27
+ profile,
28
+ region: require_commands_aws_ec2_allow_ip_schema.DEFAULT_REGION,
29
+ verbose
30
+ });
31
+ if (regions.length === 0) throw new Error("No enabled AWS regions found for this profile");
32
+ console.log(`No EC2 instances found in ${require_commands_aws_ec2_allow_ip_schema.DEFAULT_REGION}.`);
33
+ const chosen = regions[await require_commands_aws_utils_tty.promptChoice({
34
+ message: "Choose a region:",
35
+ options: regions
36
+ })];
37
+ if (!chosen) throw new Error("No region selected");
38
+ return chosen;
39
+ }
40
+ /**
41
+ * Handle errors from authorize/revoke with the same UX as the original script.
42
+ * Returns when the situation is benign (duplicate); exits the process on a
43
+ * permissions failure; rethrows anything else.
44
+ * @param {AwsCliError} error
45
+ * @param {{
46
+ * securityGroup: import("./utils.js").SecurityGroup;
47
+ * sshRules: import("./utils.js").SshIngressRule[];
48
+ * newCidr: string;
49
+ * ruleDescription: string;
50
+ * action: "create" | "update";
51
+ * }} ctx
52
+ */
53
+ function handleRuleChangeError(error, ctx) {
54
+ const { securityGroup, sshRules, newCidr, ruleDescription, action } = ctx;
55
+ if (error.code === "InvalidPermission.Duplicate") {
56
+ const matching = require_commands_aws_ec2_allow_ip_utils.ruleAlreadyAllowsIp(sshRules, newCidr);
57
+ const label = matching ? matching.description : ruleDescription;
58
+ console.log(`Security group ${securityGroup.groupId} already allows SSH from ${newCidr} (${label}). Nothing to do.`);
59
+ return;
60
+ }
61
+ if (error.code === "UnauthorizedOperation") {
62
+ console.error(`Could not ${action} the SSH rule: your AWS profile does not have ec2:AuthorizeSecurityGroupIngress or ec2:RevokeSecurityGroupIngress on ${securityGroup.groupName} (${securityGroup.groupId}).`);
63
+ console.error("");
64
+ console.error("Current single-host SSH rules on port 22:");
65
+ require_commands_aws_ec2_allow_ip_utils.printSshRules(sshRules, (message) => console.error(message));
66
+ if (action === "create" && sshRules.length > 0) {
67
+ console.error("");
68
+ console.error("A rule may already exist. Re-run to update your named roaming rule, or ask an admin to grant security group ingress permissions.");
69
+ }
70
+ process.exit(1);
71
+ }
72
+ throw error;
73
+ }
74
+ /**
75
+ * `aws ec2 allow-ip` handler: update or create a named roaming SSH rule for the
76
+ * caller's current public IP on a chosen EC2 instance's security group.
77
+ * @param {unknown} options
78
+ */
79
+ async function allowIpCommand(options) {
80
+ try {
81
+ const { profile: profileOption, region: regionOption, ruleName, verbose } = require_commands_aws_ec2_allow_ip_schema.allowIpOptionsSchema.parse(options);
82
+ const profile = await require_commands_aws_utils_resolve_profile.resolveProfile({ profile: profileOption });
83
+ if (!profile) {
84
+ console.error(chalk.default.red("Error: pass --profile or set AWS_PROFILE."));
85
+ process.exit(1);
86
+ }
87
+ require_commands_aws_utils_exec_aws.requireCommands(["aws"]);
88
+ const identity = require_commands_aws_utils_exec_aws.getCallerIdentity({
89
+ profile,
90
+ region: require_commands_aws_ec2_allow_ip_schema.DEFAULT_REGION,
91
+ verbose
92
+ });
93
+ const firstName = require_commands_aws_ec2_allow_ip_utils.extractRoamingFirstName({
94
+ profile,
95
+ identity
96
+ });
97
+ const ruleDescription = ruleName ?? require_commands_aws_ec2_allow_ip_utils.roamingRuleDescription(firstName);
98
+ console.log("Caller:");
99
+ console.log(` Account: ${identity.Account}`);
100
+ console.log(` Arn: ${identity.Arn}`);
101
+ console.log(` Roaming rule: ${ruleDescription}`);
102
+ console.log("");
103
+ const region = await resolveRegion({
104
+ profile,
105
+ region: regionOption,
106
+ verbose
107
+ });
108
+ console.log(`Region: ${region}`);
109
+ console.log("");
110
+ const instances = require_commands_aws_ec2_allow_ip_utils.listInstances({
111
+ profile,
112
+ region,
113
+ verbose
114
+ });
115
+ if (instances.length === 0) {
116
+ console.log(`No EC2 instances found in ${region}.`);
117
+ process.exit(1);
118
+ }
119
+ const instance = instances[await require_commands_aws_utils_tty.promptChoice({
120
+ message: "Choose an EC2 instance:",
121
+ options: instances.map((instance) => require_commands_aws_ec2_allow_ip_utils.instanceLabel(instance))
122
+ })];
123
+ if (!instance) throw new Error("No instance selected");
124
+ console.log("");
125
+ const securityGroups = require_commands_aws_ec2_allow_ip_utils.describeSecurityGroups({
126
+ profile,
127
+ region,
128
+ groupIds: instance.securityGroupIds,
129
+ verbose
130
+ });
131
+ if (securityGroups.length === 0) {
132
+ console.log("No security groups found on the selected instance.");
133
+ process.exit(1);
134
+ }
135
+ let securityGroup;
136
+ if (securityGroups.length === 1) {
137
+ const onlyGroup = securityGroups[0];
138
+ if (!onlyGroup) throw new Error("No security group found on the selected instance");
139
+ securityGroup = onlyGroup;
140
+ console.log(`Security group: ${require_commands_aws_ec2_allow_ip_utils.securityGroupLabel(securityGroup)}`);
141
+ } else securityGroup = securityGroups[await require_commands_aws_utils_tty.promptChoice({
142
+ message: "Choose a security group:",
143
+ options: securityGroups.map((group) => require_commands_aws_ec2_allow_ip_utils.securityGroupLabel(group))
144
+ })];
145
+ if (!securityGroup) throw new Error("No security group selected");
146
+ console.log("");
147
+ const currentIp = await require_commands_aws_ec2_allow_ip_utils.getCurrentPublicIp();
148
+ const newCidr = `${currentIp}/32`;
149
+ console.log(`Current public IP: ${currentIp}`);
150
+ console.log("");
151
+ const sgDetails = require_commands_aws_ec2_allow_ip_utils.getSecurityGroupDetails({
152
+ profile,
153
+ region,
154
+ groupId: securityGroup.groupId,
155
+ verbose
156
+ });
157
+ if (!sgDetails) {
158
+ console.log("Could not load security group details.");
159
+ process.exit(1);
160
+ }
161
+ const sshRules = require_commands_aws_ec2_allow_ip_utils.listSshIngressRules(sgDetails);
162
+ const roamingRule = require_commands_aws_ec2_allow_ip_utils.resolveRoamingRule(sshRules, ruleDescription);
163
+ if (roamingRule && roamingRule.cidrIp === newCidr) {
164
+ console.log(`Security group ${securityGroup.groupId} already allows SSH from ${newCidr} (${ruleDescription}). Nothing to do.`);
165
+ return;
166
+ }
167
+ const otherRuleAtIp = require_commands_aws_ec2_allow_ip_utils.ruleAlreadyAllowsIp(sshRules, newCidr);
168
+ if (otherRuleAtIp && (!roamingRule || otherRuleAtIp.cidrIp !== roamingRule.cidrIp)) {
169
+ const label = otherRuleAtIp.description || "(no description)";
170
+ console.log(`Security group ${securityGroup.groupId} already allows SSH from ${newCidr} (${label}). Nothing to do.`);
171
+ return;
172
+ }
173
+ if (roamingRule) {
174
+ console.log(`Updating SSH rule (${ruleDescription}): ${roamingRule.cidrIp} -> ${newCidr}`);
175
+ try {
176
+ require_commands_aws_ec2_allow_ip_utils.revokeRule({
177
+ profile,
178
+ region,
179
+ groupId: securityGroup.groupId,
180
+ rule: roamingRule,
181
+ verbose
182
+ });
183
+ require_commands_aws_ec2_allow_ip_utils.authorizeRule({
184
+ profile,
185
+ region,
186
+ groupId: securityGroup.groupId,
187
+ cidrIp: newCidr,
188
+ description: ruleDescription,
189
+ fromPort: roamingRule.fromPort,
190
+ toPort: roamingRule.toPort,
191
+ ipProtocol: roamingRule.ipProtocol,
192
+ verbose
193
+ });
194
+ } catch (error) {
195
+ if (error instanceof require_commands_aws_utils_exec_aws.AwsCliError) {
196
+ handleRuleChangeError(error, {
197
+ securityGroup,
198
+ sshRules,
199
+ newCidr,
200
+ ruleDescription,
201
+ action: "update"
202
+ });
203
+ return;
204
+ }
205
+ throw error;
206
+ }
207
+ } else {
208
+ if (sshRules.length > 0) {
209
+ console.log("Existing single-host SSH rules (unchanged):");
210
+ require_commands_aws_ec2_allow_ip_utils.printSshRules(sshRules);
211
+ console.log("");
212
+ }
213
+ console.log(`Creating new "${ruleDescription}" SSH rule for ${newCidr}`);
214
+ try {
215
+ require_commands_aws_ec2_allow_ip_utils.authorizeRule({
216
+ profile,
217
+ region,
218
+ groupId: securityGroup.groupId,
219
+ cidrIp: newCidr,
220
+ description: ruleDescription,
221
+ verbose
222
+ });
223
+ } catch (error) {
224
+ if (error instanceof require_commands_aws_utils_exec_aws.AwsCliError) {
225
+ handleRuleChangeError(error, {
226
+ securityGroup,
227
+ sshRules,
228
+ newCidr,
229
+ ruleDescription,
230
+ action: "create"
231
+ });
232
+ return;
233
+ }
234
+ throw error;
235
+ }
236
+ }
237
+ console.log("");
238
+ console.log(`Done. ${securityGroup.groupName} (${securityGroup.groupId}) now allows SSH from ${newCidr} (${ruleDescription}).`);
239
+ } catch (error) {
240
+ if (error instanceof zod.ZodError) {
241
+ console.error(chalk.default.red("\n❌ Invalid command options:"));
242
+ error.errors.forEach((err) => {
243
+ console.error(chalk.default.red(` ${err.path.join(".")}: ${err.message}`));
244
+ });
245
+ process.exit(1);
246
+ }
247
+ const verbose = options?.verbose || false;
248
+ console.error(chalk.default.red("\n❌ allow-ip failed:"));
249
+ if (error instanceof Error) {
250
+ console.error(chalk.default.red(` ${error.message}`));
251
+ if (verbose && error.stack) {
252
+ console.error(chalk.default.gray("\nStack trace:"));
253
+ console.error(chalk.default.gray(error.stack));
254
+ }
255
+ } else console.error(chalk.default.red(` ${String(error)}`));
256
+ console.error(chalk.default.yellow("\n💡 Use --verbose for detailed error information\n"));
257
+ process.exit(1);
258
+ }
259
+ }
260
+ //#endregion
261
+ exports.allowIpCommand = allowIpCommand;
@@ -1,55 +1,25 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../../../../__chunks/FU4VP2LN.cjs');
2
-
3
-
4
- var _WHGN5PZIcjs = require('../../../../__chunks/WHGN5PZI.cjs');
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
- var _B5ENMOCDcjs = require('../../../../__chunks/B5ENMOCD.cjs');
23
-
24
-
25
-
26
-
27
-
28
- var _G5K4PVILcjs = require('../../../../__chunks/G5K4PVIL.cjs');
29
- require('../../../../__chunks/R3GUC7O7.cjs');
30
- require('../../../../__chunks/NT2XXAI6.cjs');
31
- require('../../../../__chunks/WOYF2L6T.cjs');
32
- require('../../../../__chunks/CMUD7LLN.cjs');
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
- exports.DEFAULT_REGION = _G5K4PVILcjs.DEFAULT_REGION; exports.DEFAULT_ROAMING_NAME = _G5K4PVILcjs.DEFAULT_ROAMING_NAME; exports.SSH_PORT = _G5K4PVILcjs.SSH_PORT; exports.allowIpCommand = _WHGN5PZIcjs.allowIpCommand; exports.allowIpOptionsSchema = _G5K4PVILcjs.allowIpOptionsSchema; exports.authorizeRule = _B5ENMOCDcjs.authorizeRule; exports.describeSecurityGroups = _B5ENMOCDcjs.describeSecurityGroups; exports.extractRoamingFirstName = _B5ENMOCDcjs.extractRoamingFirstName; exports.getCurrentPublicIp = _B5ENMOCDcjs.getCurrentPublicIp; exports.getSecurityGroupDetails = _B5ENMOCDcjs.getSecurityGroupDetails; exports.instanceLabel = _B5ENMOCDcjs.instanceLabel; exports.listEnabledRegions = _B5ENMOCDcjs.listEnabledRegions; exports.listInstances = _B5ENMOCDcjs.listInstances; exports.listSshIngressRules = _B5ENMOCDcjs.listSshIngressRules; exports.printSshRules = _B5ENMOCDcjs.printSshRules; exports.resolveRoamingRule = _B5ENMOCDcjs.resolveRoamingRule; exports.revokeRule = _B5ENMOCDcjs.revokeRule; exports.roamingRuleDescription = _B5ENMOCDcjs.roamingRuleDescription; exports.ruleAlreadyAllowsIp = _B5ENMOCDcjs.ruleAlreadyAllowsIp; exports.securityGroupLabel = _B5ENMOCDcjs.securityGroupLabel; exports.sshRuleLabel = _B5ENMOCDcjs.sshRuleLabel;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_commands_aws_ec2_allow_ip_schema = require("./schema.cjs");
3
+ const require_commands_aws_ec2_allow_ip_utils = require("./utils.cjs");
4
+ const require_commands_aws_ec2_allow_ip_handler = require("./handler.cjs");
5
+ exports.DEFAULT_REGION = require_commands_aws_ec2_allow_ip_schema.DEFAULT_REGION;
6
+ exports.DEFAULT_ROAMING_NAME = require_commands_aws_ec2_allow_ip_schema.DEFAULT_ROAMING_NAME;
7
+ exports.SSH_PORT = require_commands_aws_ec2_allow_ip_schema.SSH_PORT;
8
+ exports.allowIpCommand = require_commands_aws_ec2_allow_ip_handler.allowIpCommand;
9
+ exports.allowIpOptionsSchema = require_commands_aws_ec2_allow_ip_schema.allowIpOptionsSchema;
10
+ exports.authorizeRule = require_commands_aws_ec2_allow_ip_utils.authorizeRule;
11
+ exports.describeSecurityGroups = require_commands_aws_ec2_allow_ip_utils.describeSecurityGroups;
12
+ exports.extractRoamingFirstName = require_commands_aws_ec2_allow_ip_utils.extractRoamingFirstName;
13
+ exports.getCurrentPublicIp = require_commands_aws_ec2_allow_ip_utils.getCurrentPublicIp;
14
+ exports.getSecurityGroupDetails = require_commands_aws_ec2_allow_ip_utils.getSecurityGroupDetails;
15
+ exports.instanceLabel = require_commands_aws_ec2_allow_ip_utils.instanceLabel;
16
+ exports.listEnabledRegions = require_commands_aws_ec2_allow_ip_utils.listEnabledRegions;
17
+ exports.listInstances = require_commands_aws_ec2_allow_ip_utils.listInstances;
18
+ exports.listSshIngressRules = require_commands_aws_ec2_allow_ip_utils.listSshIngressRules;
19
+ exports.printSshRules = require_commands_aws_ec2_allow_ip_utils.printSshRules;
20
+ exports.resolveRoamingRule = require_commands_aws_ec2_allow_ip_utils.resolveRoamingRule;
21
+ exports.revokeRule = require_commands_aws_ec2_allow_ip_utils.revokeRule;
22
+ exports.roamingRuleDescription = require_commands_aws_ec2_allow_ip_utils.roamingRuleDescription;
23
+ exports.ruleAlreadyAllowsIp = require_commands_aws_ec2_allow_ip_utils.ruleAlreadyAllowsIp;
24
+ exports.securityGroupLabel = require_commands_aws_ec2_allow_ip_utils.securityGroupLabel;
25
+ exports.sshRuleLabel = require_commands_aws_ec2_allow_ip_utils.sshRuleLabel;
@@ -1,13 +1,33 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
- var _G5K4PVILcjs = require('../../../../__chunks/G5K4PVIL.cjs');
7
- require('../../../../__chunks/WOYF2L6T.cjs');
8
-
9
-
10
-
11
-
12
-
13
- exports.DEFAULT_REGION = _G5K4PVILcjs.DEFAULT_REGION; exports.DEFAULT_ROAMING_NAME = _G5K4PVILcjs.DEFAULT_ROAMING_NAME; exports.SSH_PORT = _G5K4PVILcjs.SSH_PORT; exports.allowIpOptionsSchema = _G5K4PVILcjs.allowIpOptionsSchema;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_commands_aws_schema = require("../../schema.cjs");
3
+ let zod = require("zod");
4
+ //#region src/commands/aws/ec2/allow-ip/schema.js
5
+ /**
6
+ * Default region checked first before prompting.
7
+ */
8
+ const DEFAULT_REGION = "us-east-1";
9
+ /**
10
+ * SSH port managed by this command.
11
+ */
12
+ const SSH_PORT = 22;
13
+ /**
14
+ * Fallback first name when one cannot be derived from the profile/IAM user.
15
+ */
16
+ const DEFAULT_ROAMING_NAME = "Declan";
17
+ /**
18
+ * Zod schema for `aws ec2 allow-ip` options.
19
+ */
20
+ const allowIpOptionsSchema = zod.z.object({
21
+ profile: require_commands_aws_schema.profileField,
22
+ region: require_commands_aws_schema.regionField,
23
+ ruleName: zod.z.string().optional().describe("SSH rule description to update or create (default: \"{FirstName} Roaming\" derived from the profile/IAM user)"),
24
+ verbose: require_commands_aws_schema.verboseField
25
+ });
26
+ /**
27
+ * @typedef {z.infer<typeof allowIpOptionsSchema>} AllowIpOptions
28
+ */
29
+ //#endregion
30
+ exports.DEFAULT_REGION = DEFAULT_REGION;
31
+ exports.DEFAULT_ROAMING_NAME = DEFAULT_ROAMING_NAME;
32
+ exports.SSH_PORT = SSH_PORT;
33
+ exports.allowIpOptionsSchema = allowIpOptionsSchema;