@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
@@ -1,105 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
-
4
-
5
- var _NWZGFHKHcjs = require('./NWZGFHKH.cjs');
6
-
7
- // src/commands/db/create-readonly-user/mysql.js
8
- var _promise = require('mysql2/promise'); var _promise2 = _interopRequireDefault(_promise);
9
- async function createConnection(config) {
10
- return _promise2.default.createConnection({
11
- host: config.host,
12
- port: config.port,
13
- user: config.user,
14
- password: config.password,
15
- database: config.database || void 0,
16
- ssl: config.ssl && typeof config.ssl === "object" ? config.ssl : void 0,
17
- multipleStatements: false
18
- });
19
- }
20
- async function listMysqlDatabases(config) {
21
- const connection = await createConnection(config);
22
- try {
23
- const [rows] = await connection.query("SHOW DATABASES");
24
- const names = (
25
- /** @type {Array<{ Database?: string }>} */
26
- rows.map(
27
- (row) => _nullishCoalesce(row.Database, () => ( ""))
28
- )
29
- );
30
- return names.filter((name) => Boolean(name)).filter((name) => !_NWZGFHKHcjs.isSystemDatabase.call(void 0, { engine: "mysql", name })).sort((a, b) => a.localeCompare(b));
31
- } finally {
32
- await connection.end();
33
- }
34
- }
35
- async function applyMysqlReadonly(params) {
36
- const {
37
- config,
38
- username,
39
- password,
40
- databases,
41
- hostPattern,
42
- dryRun = false,
43
- verbose = false
44
- } = params;
45
- const userLiteral = _NWZGFHKHcjs.quoteLiteral.call(void 0, username);
46
- const hostLiteral = _NWZGFHKHcjs.quoteLiteral.call(void 0, hostPattern);
47
- const passwordLiteral = _NWZGFHKHcjs.quoteLiteral.call(void 0, password);
48
- const account = `${userLiteral}@${hostLiteral}`;
49
- const statements = [];
50
- const createSql = `CREATE USER IF NOT EXISTS ${account} IDENTIFIED BY ${passwordLiteral}`;
51
- const alterSql = `ALTER USER ${account} IDENTIFIED BY ${passwordLiteral}`;
52
- const grantSqls = [];
53
- if (databases === "all") {
54
- grantSqls.push(
55
- `GRANT SELECT, SHOW VIEW, SHOW DATABASES ON *.* TO ${account}`
56
- );
57
- } else {
58
- for (const database of databases) {
59
- const dbIdent = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "mysql", name: database });
60
- grantSqls.push(`GRANT SELECT, SHOW VIEW ON ${dbIdent}.* TO ${account}`);
61
- }
62
- }
63
- const flushSql = "FLUSH PRIVILEGES";
64
- statements.push(createSql, alterSql, ...grantSqls, flushSql);
65
- if (dryRun) {
66
- return {
67
- created: true,
68
- statements: statements.map(
69
- (sql) => sql.includes("IDENTIFIED BY") ? sql.replace(/IDENTIFIED BY '.*'/, "IDENTIFIED BY ***") : sql
70
- ),
71
- databases
72
- };
73
- }
74
- const connection = await createConnection(config);
75
- try {
76
- if (verbose) {
77
- console.log(` Connected to MySQL as ${config.user}@${config.host}`);
78
- }
79
- const [existingRows] = await connection.query(
80
- "SELECT 1 AS ok FROM mysql.user WHERE User = ? AND Host = ? LIMIT 1",
81
- [username, hostPattern]
82
- );
83
- const existed = Array.isArray(existingRows) && existingRows.length > 0;
84
- await connection.query(createSql);
85
- await connection.query(alterSql);
86
- for (const grantSql of grantSqls) {
87
- await connection.query(grantSql);
88
- }
89
- await connection.query(flushSql);
90
- return {
91
- created: !existed,
92
- statements: statements.map(
93
- (sql) => sql.includes("IDENTIFIED BY") ? sql.replace(/IDENTIFIED BY '.*'/, "IDENTIFIED BY ***") : sql
94
- ),
95
- databases
96
- };
97
- } finally {
98
- await connection.end();
99
- }
100
- }
101
-
102
-
103
-
104
-
105
- exports.listMysqlDatabases = listMysqlDatabases; exports.applyMysqlReadonly = applyMysqlReadonly;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,9 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/commands/aws/utils/resolve-policy-path.js
2
- var _url = require('url');
3
- function resolvePolicyPath(fileName) {
4
- return _url.fileURLToPath.call(void 0, new URL(`../iam/policies/${fileName}`, import.meta.url));
5
- }
6
-
7
-
8
-
9
- exports.resolvePolicyPath = resolvePolicyPath;
@@ -1,387 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _R3GUC7O7cjs = require('./R3GUC7O7.cjs');
4
-
5
-
6
-
7
- var _CMUD7LLNcjs = require('./CMUD7LLN.cjs');
8
-
9
- // src/commands/aws/iam/users/utils.js
10
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
11
- var KNOWN_ROLES = ["read-only", "iam-admin", "power-user"];
12
- var REQUIRED_ACL_GROUPS = [
13
- "acl-read-only",
14
- "acl-iam-full-access",
15
- "acl-power-users"
16
- ];
17
- function roleToGroup(role) {
18
- switch (role) {
19
- case "read-only":
20
- return "acl-read-only";
21
- case "iam-admin":
22
- return "acl-iam-full-access";
23
- case "power-user":
24
- return "acl-power-users";
25
- default:
26
- throw new Error(`Unknown role: ${role}`);
27
- }
28
- }
29
- function normalizeSlug(value) {
30
- return value.toLowerCase().replace(/ /g, "-");
31
- }
32
- function isValidSlug(value) {
33
- return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(value);
34
- }
35
- function buildUsername(params) {
36
- const { identifier, accountName, role } = params;
37
- return `md-${identifier}-${accountName}-${role}`;
38
- }
39
- function normalizeIdentifier(params) {
40
- const { raw, accountName, role } = params;
41
- let identifier = normalizeSlug(raw);
42
- if (identifier.startsWith("md-")) {
43
- identifier = identifier.slice(3);
44
- }
45
- if (identifier.endsWith(`-${role}`)) {
46
- identifier = identifier.slice(0, -(role.length + 1));
47
- } else {
48
- for (const knownRole of KNOWN_ROLES) {
49
- if (identifier.endsWith(`-${knownRole}`)) {
50
- identifier = identifier.slice(0, -(knownRole.length + 1));
51
- break;
52
- }
53
- }
54
- }
55
- if (identifier.endsWith(`-${accountName}`)) {
56
- identifier = identifier.slice(0, -(accountName.length + 1));
57
- }
58
- return identifier;
59
- }
60
- function parseMdUsername(name) {
61
- let value = normalizeSlug(name);
62
- if (!value.startsWith("md-")) {
63
- return null;
64
- }
65
- value = value.slice(3);
66
- const rolesByLength = [...KNOWN_ROLES].sort((a, b) => b.length - a.length);
67
- let role = null;
68
- for (const knownRole of rolesByLength) {
69
- if (value.endsWith(`-${knownRole}`)) {
70
- role = knownRole;
71
- value = value.slice(0, -(knownRole.length + 1));
72
- break;
73
- }
74
- }
75
- if (!role) {
76
- return null;
77
- }
78
- const dash = value.indexOf("-");
79
- if (dash <= 0 || dash === value.length - 1) {
80
- return null;
81
- }
82
- const identifier = value.slice(0, dash);
83
- const accountName = value.slice(dash + 1);
84
- if (!isValidSlug(identifier) || !isValidSlug(accountName)) {
85
- return null;
86
- }
87
- return { identifier, accountName, role };
88
- }
89
- function inferAccountName(params) {
90
- const { profile, identity } = params;
91
- const arn = _nullishCoalesce(_optionalChain([identity, 'optionalAccess', _ => _.Arn]), () => ( ""));
92
- const username = arn.includes("/") ? _nullishCoalesce(arn.split("/").pop(), () => ( "")) : "";
93
- for (const candidate of [username, _nullishCoalesce(profile, () => ( ""))]) {
94
- if (!candidate) {
95
- continue;
96
- }
97
- const parsed = parseMdUsername(candidate);
98
- if (parsed) {
99
- return parsed.accountName;
100
- }
101
- }
102
- return null;
103
- }
104
- function userExists(params) {
105
- const { username, profile, verbose } = params;
106
- try {
107
- _R3GUC7O7cjs.runAws.call(void 0, {
108
- profile,
109
- args: ["iam", "get-user", "--user-name", username],
110
- verbose
111
- });
112
- return true;
113
- } catch (e) {
114
- return false;
115
- }
116
- }
117
- function ensureUser(params) {
118
- const { username, profile, verbose } = params;
119
- if (userExists({ username, profile, verbose })) {
120
- console.log(` User exists: ${username}`);
121
- return;
122
- }
123
- console.log(` Create user: ${username}`);
124
- _R3GUC7O7cjs.runAws.call(void 0, {
125
- profile,
126
- args: ["iam", "create-user", "--user-name", username, "--path", "/"],
127
- verbose
128
- });
129
- }
130
- function ensureUserInGroup(params) {
131
- const { username, group, profile, verbose } = params;
132
- const existing = _R3GUC7O7cjs.runAws.call(void 0, {
133
- profile,
134
- args: [
135
- "iam",
136
- "get-group",
137
- "--group-name",
138
- group,
139
- "--query",
140
- `Users[?UserName=='${username}'].UserName`,
141
- "--output",
142
- "text"
143
- ],
144
- expectJson: false,
145
- verbose
146
- });
147
- if (existing) {
148
- console.log(` Already in group: ${group}`);
149
- return;
150
- }
151
- console.log(` Add to group: ${group}`);
152
- _R3GUC7O7cjs.runAws.call(void 0, {
153
- profile,
154
- args: [
155
- "iam",
156
- "add-user-to-group",
157
- "--user-name",
158
- username,
159
- "--group-name",
160
- group
161
- ],
162
- expectJson: false,
163
- verbose
164
- });
165
- }
166
- function createCliAccessKey(params) {
167
- const { username, profile, verbose } = params;
168
- const keyCountRaw = _R3GUC7O7cjs.runAws.call(void 0, {
169
- profile,
170
- args: [
171
- "iam",
172
- "list-access-keys",
173
- "--user-name",
174
- username,
175
- "--query",
176
- "length(AccessKeyMetadata)",
177
- "--output",
178
- "text"
179
- ],
180
- expectJson: false,
181
- verbose
182
- });
183
- const keyCount = Number.parseInt(keyCountRaw, 10) || 0;
184
- if (keyCount >= 2) {
185
- console.log(
186
- _chalk2.default.yellow(
187
- ` WARNING: ${username} already has 2 access keys (AWS max).`
188
- )
189
- );
190
- console.log(
191
- _chalk2.default.yellow(" Delete an existing key before creating a new one.")
192
- );
193
- return false;
194
- }
195
- const created = _R3GUC7O7cjs.runAws.call(void 0, {
196
- profile,
197
- args: [
198
- "iam",
199
- "create-access-key",
200
- "--user-name",
201
- username,
202
- "--query",
203
- "AccessKey.[AccessKeyId,SecretAccessKey]",
204
- "--output",
205
- "text"
206
- ],
207
- expectJson: false,
208
- verbose
209
- });
210
- const [accessKeyId, secretAccessKey] = created.split(/\s+/);
211
- if (!accessKeyId || !secretAccessKey) {
212
- throw new Error("Failed to parse the newly created access key");
213
- }
214
- const setupCmd = ` export AWS_ACCESS_KEY_ID='${accessKeyId}' AWS_SECRET_ACCESS_KEY='${secretAccessKey}' && aws-vault add ${username} --env --add-config && aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID" --profile ${username} && aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY" --profile ${username} && aws configure set region us-east-1 --profile ${username}`;
215
- console.log("");
216
- console.log(
217
- ` CLI credentials for ${username} (secret shown once \u2014 copy now):`
218
- );
219
- console.log(
220
- " \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
221
- );
222
- console.log(
223
- " YOU MUST run the command below with a LEADING SPACE so it is not saved"
224
- );
225
- console.log(' to shell history \u2014 same idea as: TEST="a" && echo $TEST');
226
- console.log("");
227
- console.log(setupCmd);
228
- console.log(
229
- " \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
230
- );
231
- console.log("");
232
- return true;
233
- }
234
- function ensureAclGroupsExist(params) {
235
- const { profile, verbose } = params;
236
- const missing = REQUIRED_ACL_GROUPS.filter((group) => {
237
- try {
238
- _R3GUC7O7cjs.runAws.call(void 0, {
239
- profile,
240
- args: ["iam", "get-group", "--group-name", group],
241
- verbose
242
- });
243
- return false;
244
- } catch (e2) {
245
- return true;
246
- }
247
- });
248
- if (missing.length > 0) {
249
- missing.forEach((group) => console.log(` Missing group: ${group}`));
250
- console.log("");
251
- console.log(
252
- " Run `mtn aws iam setup-acl` first to create ACL groups and policies."
253
- );
254
- return false;
255
- }
256
- return true;
257
- }
258
- async function promptAccountName(params) {
259
- const { accountName, inferredAccountName } = params;
260
- if (accountName) {
261
- const slug = normalizeSlug(accountName);
262
- if (isValidSlug(slug)) {
263
- console.log(` Account name: ${slug}`);
264
- return slug;
265
- }
266
- console.log(" Invalid account name option \u2014 falling back to prompt.");
267
- }
268
- const defaultSlug = inferredAccountName && isValidSlug(normalizeSlug(inferredAccountName)) ? normalizeSlug(inferredAccountName) : null;
269
- for (; ; ) {
270
- const hint = defaultSlug ? ` [default: ${defaultSlug}]` : " (e.g. vincent)";
271
- const raw = await _CMUD7LLNcjs.prompt.call(void 0,
272
- ` AWS account name${hint} \u2014 used in md-{identifier}-{account}-{role}: `
273
- );
274
- if (raw === "" && defaultSlug) {
275
- console.log(` \u2192 account name: ${defaultSlug}`);
276
- return defaultSlug;
277
- }
278
- const slug = normalizeSlug(raw);
279
- if (isValidSlug(slug)) {
280
- if (raw !== slug) {
281
- console.log(` \u2192 account name: ${slug}`);
282
- }
283
- return slug;
284
- }
285
- console.log(
286
- " Invalid account name \u2014 use lowercase letters, numbers, and hyphens" + (defaultSlug ? ", or press Enter to accept the default." : ".")
287
- );
288
- }
289
- }
290
- async function promptRole() {
291
- for (; ; ) {
292
- console.log(" Role (username will be md-{identifier}-{account}-{role}):");
293
- console.log(" 1) read-only \u2192 acl-read-only");
294
- console.log(" 2) iam-admin \u2192 acl-iam-full-access");
295
- console.log(" 3) power-user \u2192 acl-power-users");
296
- const choice = await _CMUD7LLNcjs.prompt.call(void 0, " Choice [1-3]: ");
297
- switch (choice) {
298
- case "1":
299
- case "read-only":
300
- return "read-only";
301
- case "2":
302
- case "iam-admin":
303
- return "iam-admin";
304
- case "3":
305
- case "power-user":
306
- return "power-user";
307
- default:
308
- console.log(" Invalid choice \u2014 enter 1, 2, 3, or the role name.");
309
- }
310
- }
311
- }
312
- async function promptIdentifier(params) {
313
- const { accountName, role } = params;
314
- const exampleUser = buildUsername({
315
- identifier: "declan",
316
- accountName,
317
- role
318
- });
319
- for (; ; ) {
320
- const raw = await _CMUD7LLNcjs.prompt.call(void 0,
321
- ` Identifier (e.g. declan, or full ${exampleUser}): `
322
- );
323
- const lowerRaw = normalizeSlug(raw);
324
- const identifier = normalizeIdentifier({ raw, accountName, role });
325
- if (isValidSlug(identifier)) {
326
- if (lowerRaw !== identifier) {
327
- console.log(` \u2192 parsed identifier: ${identifier}`);
328
- }
329
- return identifier;
330
- }
331
- console.log(
332
- " Invalid identifier \u2014 use lowercase letters, numbers, and hyphens."
333
- );
334
- console.log(" Tip: enter just the short name (e.g. declan).");
335
- }
336
- }
337
- async function createUsersInteractive(params) {
338
- const { accountName: accountNameOption, profile, identity, verbose } = params;
339
- if (!ensureAclGroupsExist({ profile, verbose })) {
340
- return;
341
- }
342
- console.log("");
343
- const inferredAccountName = inferAccountName({ profile, identity });
344
- const accountName = await promptAccountName({
345
- accountName: accountNameOption,
346
- inferredAccountName
347
- });
348
- console.log("");
349
- while (await _CMUD7LLNcjs.promptYesNo.call(void 0, { message: " Create another user?", defaultYes: false })) {
350
- console.log("");
351
- const role = await promptRole();
352
- const identifier = await promptIdentifier({ accountName, role });
353
- const username = buildUsername({ identifier, accountName, role });
354
- const group = roleToGroup(role);
355
- console.log("");
356
- console.log(` \u2192 user: ${username}`);
357
- console.log(` \u2192 group: ${group}`);
358
- console.log("");
359
- ensureUser({ username, profile, verbose });
360
- ensureUserInGroup({ username, group, profile, verbose });
361
- try {
362
- createCliAccessKey({ username, profile, verbose });
363
- } catch (error) {
364
- console.log(
365
- _chalk2.default.yellow(
366
- ` Could not create access key: ${error instanceof Error ? error.message : String(error)}`
367
- )
368
- );
369
- }
370
- console.log("");
371
- }
372
- }
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
-
383
-
384
-
385
-
386
-
387
- exports.roleToGroup = roleToGroup; exports.normalizeSlug = normalizeSlug; exports.isValidSlug = isValidSlug; exports.buildUsername = buildUsername; exports.normalizeIdentifier = normalizeIdentifier; exports.parseMdUsername = parseMdUsername; exports.inferAccountName = inferAccountName; exports.ensureUser = ensureUser; exports.ensureUserInGroup = ensureUserInGroup; exports.createCliAccessKey = createCliAccessKey; exports.ensureAclGroupsExist = ensureAclGroupsExist; exports.createUsersInteractive = createUsersInteractive;
@@ -1,133 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
-
4
- var _J36P6UNEcjs = require('./J36P6UNE.cjs');
5
-
6
- // src/commands/icons/utils.js
7
- var _child_process = require('child_process');
8
- var _fs = require('fs');
9
- var _path = require('path');
10
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
11
- function checkDependencies(verbose = false) {
12
- if (verbose) {
13
- console.log(_chalk2.default.blue("\n\u{1F50D} Checking dependencies..."));
14
- }
15
- try {
16
- _child_process.execSync.call(void 0, "which magick", { stdio: "pipe" });
17
- if (verbose) {
18
- console.log(_chalk2.default.green(" \u2713 ImageMagick is installed"));
19
- }
20
- } catch (e) {
21
- throw new Error(
22
- "ImageMagick is not installed. Please install it (brew install imagemagick) and try again."
23
- );
24
- }
25
- }
26
- function validateBaseIcons(baseDir, iconTypes, verbose = false) {
27
- if (verbose) {
28
- console.log(_chalk2.default.blue("\n\u{1F4C1} Validating base icons..."));
29
- }
30
- const resolvedDir = _path.resolve.call(void 0, baseDir);
31
- if (!_fs.existsSync.call(void 0, resolvedDir)) {
32
- throw new Error(`Input directory does not exist: ${resolvedDir}`);
33
- }
34
- const missingIcons = [];
35
- for (const iconType of iconTypes) {
36
- const iconPath = _path.join.call(void 0, resolvedDir, `${iconType}.png`);
37
- if (!_fs.existsSync.call(void 0, iconPath)) {
38
- missingIcons.push(`${iconType}.png`);
39
- } else if (verbose) {
40
- console.log(_chalk2.default.green(` \u2713 Found: ${iconType}.png`));
41
- }
42
- }
43
- if (missingIcons.length > 0) {
44
- throw new Error(
45
- `Missing base icons in ${resolvedDir}: ${missingIcons.join(", ")}`
46
- );
47
- }
48
- }
49
- function generateIcon(options) {
50
- const { baseDir, channel, iconType, verbose } = options;
51
- const resolvedDir = _path.resolve.call(void 0, baseDir);
52
- const inputFile = _path.join.call(void 0, resolvedDir, `${iconType}.png`);
53
- const outputFile = _path.join.call(void 0, resolvedDir, `${iconType}-${channel}.png`);
54
- const size = _J36P6UNEcjs.ICON_SIZE_MAP[
55
- /** @type {keyof typeof ICON_SIZE_MAP} */
56
- iconType
57
- ] || 378;
58
- const text = _J36P6UNEcjs.CHANNEL_TEXT_MAP[
59
- /** @type {keyof typeof CHANNEL_TEXT_MAP} */
60
- channel
61
- ] || channel.toUpperCase().slice(0, 3);
62
- const command = [
63
- "magick",
64
- `"${inputFile}"`,
65
- `-pointsize ${size}`,
66
- "-fill white",
67
- "-gravity center",
68
- "-font Arial-Black",
69
- "-stroke black",
70
- "-strokewidth 5",
71
- `-draw "rotate -45 text 0,0 '${text}'"`,
72
- `"${outputFile}"`
73
- ].join(" ");
74
- if (verbose) {
75
- console.log(_chalk2.default.gray(` Command: ${command}`));
76
- }
77
- try {
78
- _child_process.execSync.call(void 0, command, { stdio: verbose ? "inherit" : "pipe" });
79
- return outputFile;
80
- } catch (error) {
81
- throw new Error(
82
- `Failed to generate ${iconType}-${channel}.png: ${error instanceof Error ? error.message : String(error)}`
83
- );
84
- }
85
- }
86
- function generateAllIcons(options) {
87
- const { baseDir, channels, iconTypes, verbose } = options;
88
- const success = [];
89
- const failed = [];
90
- const totalIcons = channels.length * iconTypes.length;
91
- let current = 0;
92
- if (verbose) {
93
- console.log(_chalk2.default.blue(`
94
- \u{1F3A8} Generating ${totalIcons} icon(s)...`));
95
- }
96
- for (const channel of channels) {
97
- for (const iconType of iconTypes) {
98
- current++;
99
- const iconName = `${iconType}-${channel}.png`;
100
- if (verbose) {
101
- console.log(
102
- _chalk2.default.blue(`
103
- [${current}/${totalIcons}] Generating ${iconName}...`)
104
- );
105
- }
106
- try {
107
- const outputPath = generateIcon({
108
- baseDir,
109
- channel,
110
- iconType,
111
- verbose
112
- });
113
- success.push(outputPath);
114
- console.log(_chalk2.default.green(` \u2713 Generated: ${iconName}`));
115
- } catch (error) {
116
- const errorMessage = error instanceof Error ? error.message : String(error);
117
- failed.push({ icon: iconName, error: errorMessage });
118
- console.log(_chalk2.default.red(` \u2717 Failed: ${iconName}`));
119
- if (verbose) {
120
- console.log(_chalk2.default.red(` ${errorMessage}`));
121
- }
122
- }
123
- }
124
- }
125
- return { success, failed };
126
- }
127
-
128
-
129
-
130
-
131
-
132
-
133
- exports.checkDependencies = checkDependencies; exports.validateBaseIcons = validateBaseIcons; exports.generateIcon = generateIcon; exports.generateAllIcons = generateAllIcons;
@@ -1 +0,0 @@
1
- "use strict";