@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,538 +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 _NIMXXHJQcjs = require('./NIMXXHJQ.cjs');
4
-
5
- // src/commands/doppler/utils.js
6
- var _child_process = require('child_process');
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
- var _fs = require('fs');
15
- var _os = require('os');
16
- var _path = require('path');
17
- var _readline = require('readline');
18
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
19
- var DEFAULT_DOPPLER_ENVIRONMENT = "dev";
20
- var DOPPLER_INTERNAL_KEYS = /* @__PURE__ */ new Set([
21
- "DOPPLER_CONFIG",
22
- "DOPPLER_ENVIRONMENT",
23
- "DOPPLER_PROJECT"
24
- ]);
25
- function execDoppler(args, parser = "string", silent = false, verbose = false) {
26
- const command = `doppler ${args.join(" ")}`;
27
- let verbosity = "default";
28
- if (verbose) {
29
- verbosity = "verbose";
30
- } else if (silent) {
31
- verbosity = "silent";
32
- }
33
- return _NIMXXHJQcjs.exec.call(void 0, command, {
34
- verbosity,
35
- stdoutParser: parser,
36
- throwOnError: true
37
- });
38
- }
39
- function checkDopplerAuth(verbose = false) {
40
- if (verbose) {
41
- console.log(_chalk2.default.blue("\n\u{1F50D} Checking Doppler authentication..."));
42
- }
43
- try {
44
- _child_process.execSync.call(void 0, "which doppler", { stdio: "pipe" });
45
- if (verbose) {
46
- console.log(_chalk2.default.green(" \u2713 Doppler CLI is installed"));
47
- }
48
- } catch (e2) {
49
- throw new Error(
50
- "Doppler is not installed. Please install Doppler (brew install dopplerhq/cli/doppler), login, and try again."
51
- );
52
- }
53
- try {
54
- execDoppler(["me"], "string", true, verbose);
55
- if (verbose) {
56
- console.log(_chalk2.default.green(" \u2713 Doppler is authenticated"));
57
- }
58
- } catch (e3) {
59
- throw new Error(
60
- "Doppler is not logged in. Please run 'doppler login' and try again."
61
- );
62
- }
63
- }
64
- function checkDependencies(verbose = false) {
65
- checkDopplerAuth(verbose);
66
- if (verbose) {
67
- console.log(_chalk2.default.blue("\n\u{1F50D} Checking Doppler project setup..."));
68
- }
69
- try {
70
- execDoppler(["configs", "--json"], "json", true, verbose);
71
- if (verbose) {
72
- console.log(_chalk2.default.green(" \u2713 Doppler project is configured"));
73
- }
74
- } catch (e4) {
75
- throw new Error(
76
- "Doppler is not configured. Please run 'doppler setup' and try again."
77
- );
78
- }
79
- }
80
- function getConfigs(environments, verbose = false, project = null) {
81
- if (verbose) {
82
- console.log(
83
- _chalk2.default.blue(
84
- `
85
- \u{1F4CB} Resolving configurations for environments: ${_chalk2.default.cyan(environments)}`
86
- )
87
- );
88
- }
89
- const configArgs = ["configs", "--json"];
90
- if (project) configArgs.push("--project", project);
91
- const availableConfigs = execDoppler(configArgs, "json", true, verbose);
92
- const configNames = Array.isArray(availableConfigs) ? availableConfigs.map(
93
- (config) => config.name
94
- ) : [];
95
- if (verbose && configNames.length > 0) {
96
- console.log(
97
- _chalk2.default.gray(` Available configurations: ${configNames.join(", ")}`)
98
- );
99
- }
100
- if (environments === "all") {
101
- if (configNames.length === 0) {
102
- throw new Error("No configurations found in Doppler");
103
- }
104
- if (verbose) {
105
- console.log(
106
- _chalk2.default.green(` \u2713 Using all ${configNames.length} configurations`)
107
- );
108
- }
109
- return configNames;
110
- }
111
- const requested = environments.split(",").map((e) => e.trim());
112
- if (configNames.length > 0) {
113
- const missing = requested.filter((e) => !configNames.includes(e));
114
- if (missing.length > 0) {
115
- throw new Error(
116
- `Configurations not found: ${missing.join(", ")}. Available: ${configNames.join(", ")}`
117
- );
118
- }
119
- }
120
- if (verbose) {
121
- console.log(
122
- _chalk2.default.green(` \u2713 Using configurations: ${requested.join(", ")}`)
123
- );
124
- }
125
- return requested;
126
- }
127
- function normalizeEscapeSequences(content) {
128
- return content.replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\r/g, "\r");
129
- }
130
- function createDiff(oldContent, newContent) {
131
- const oldLines = oldContent.split("\n");
132
- const newLines = newContent.split("\n");
133
- const diff = [];
134
- const maxLines = Math.max(oldLines.length, newLines.length);
135
- for (let i = 0; i < maxLines; i++) {
136
- const oldLine = oldLines[i] || "";
137
- const newLine = newLines[i] || "";
138
- if (oldLine !== newLine) {
139
- if (oldLine && !newLine) {
140
- diff.push(`-${oldLine}`);
141
- } else if (!oldLine && newLine) {
142
- diff.push(`+${newLine}`);
143
- } else {
144
- diff.push(`-${oldLine}`);
145
- diff.push(`+${newLine}`);
146
- }
147
- }
148
- }
149
- return diff;
150
- }
151
- function promptConfirmation(message) {
152
- return new Promise((resolve) => {
153
- const rl = _readline.createInterface.call(void 0, {
154
- input: process.stdin,
155
- output: process.stdout
156
- });
157
- rl.question(message, (answer) => {
158
- rl.close();
159
- resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
160
- });
161
- });
162
- }
163
- async function downloadConfigs(options) {
164
- const { environments, verbose } = options;
165
- const actualEnvironments = _nullishCoalesce(environments, () => ( DEFAULT_DOPPLER_ENVIRONMENT));
166
- const configs = getConfigs(actualEnvironments, verbose);
167
- if (verbose) {
168
- console.log(
169
- _chalk2.default.blue(
170
- `
171
- \u2B07\uFE0F Starting download process for ${configs.length} configuration(s)...`
172
- )
173
- );
174
- }
175
- if (configs.length === 1 && actualEnvironments !== "all") {
176
- console.log(
177
- "You can use -e all to download all configurations, or -e dev,stg for specific environments."
178
- );
179
- }
180
- for (const config of configs) {
181
- const envFile = `.env.${config}`;
182
- const backupFile = `${envFile}.backup`;
183
- let backupMsg = "";
184
- if (verbose) {
185
- console.log(_chalk2.default.blue(`
186
- \u{1F4E6} Processing config: ${_chalk2.default.cyan(config)}`));
187
- }
188
- try {
189
- if (_fs.existsSync.call(void 0, envFile)) {
190
- if (verbose) {
191
- console.log(_chalk2.default.gray(` Creating backup: ${backupFile}`));
192
- }
193
- _fs.renameSync.call(void 0, envFile, backupFile);
194
- backupMsg = "Backed up existing file, ";
195
- }
196
- if (verbose) {
197
- console.log(_chalk2.default.gray(` Downloading secrets from Doppler...`));
198
- }
199
- const content = execDoppler(
200
- [
201
- "secrets",
202
- "download",
203
- "--no-file",
204
- "--format",
205
- "env",
206
- "--config",
207
- config
208
- ],
209
- "string",
210
- !verbose,
211
- // Only silent if not verbose
212
- verbose
213
- );
214
- if (typeof content === "string") {
215
- _fs.writeFileSync.call(void 0, envFile, content, "utf-8");
216
- if (verbose) {
217
- console.log(_chalk2.default.gray(` Written to: ${envFile}`));
218
- }
219
- } else {
220
- throw new Error("Invalid content received from Doppler");
221
- }
222
- console.log(
223
- `Config ${_chalk2.default.blue(config)}: ${backupMsg}downloaded successfully to ${_chalk2.default.green(envFile)}`
224
- );
225
- if (config === "dev" && !_fs.existsSync.call(void 0, ".env")) {
226
- _fs.copyFileSync.call(void 0, envFile, ".env");
227
- console.log(
228
- `Copied ${_chalk2.default.green(".env.dev")} to ${_chalk2.default.green(".env")}`
229
- );
230
- }
231
- if (_fs.existsSync.call(void 0, backupFile)) {
232
- if (verbose) {
233
- console.log(_chalk2.default.gray(` Removing backup file`));
234
- }
235
- _fs.unlinkSync.call(void 0, backupFile);
236
- }
237
- } catch (error) {
238
- console.error(`Failed to download ${config}: ${_optionalChain([error, 'optionalAccess', _ => _.message]) || error}`);
239
- if (_fs.existsSync.call(void 0, backupFile)) {
240
- _fs.renameSync.call(void 0, backupFile, envFile);
241
- console.log(`Restored backup for ${envFile}`);
242
- }
243
- }
244
- }
245
- }
246
- async function uploadConfigs(options) {
247
- const { environments, verbose } = options;
248
- const configs = getConfigs(environments, verbose);
249
- if (verbose) {
250
- console.log(
251
- _chalk2.default.blue(
252
- `
253
- \u2B06\uFE0F Starting upload process for ${configs.length} configuration(s)...`
254
- )
255
- );
256
- }
257
- for (const config of configs) {
258
- const envFile = `.env.${config}`;
259
- const backupFile = `${envFile}.doppler`;
260
- const normalizedFile = `${envFile}.normalized`;
261
- if (verbose) {
262
- console.log(_chalk2.default.blue(`
263
- \u{1F4E6} Processing config: ${_chalk2.default.cyan(config)}`));
264
- }
265
- try {
266
- if (!_fs.existsSync.call(void 0, envFile)) {
267
- console.log(
268
- `Config ${config}: ${_chalk2.default.green(envFile)} does not exist. Skipping upload.`
269
- );
270
- continue;
271
- }
272
- if (verbose) {
273
- console.log(
274
- _chalk2.default.gray(` Creating backup of current Doppler config...`)
275
- );
276
- }
277
- try {
278
- const backupContent2 = execDoppler(
279
- [
280
- "secrets",
281
- "download",
282
- "--no-file",
283
- "--format",
284
- "env",
285
- "--config",
286
- config
287
- ],
288
- "string",
289
- !verbose,
290
- // Only silent if not verbose
291
- verbose
292
- );
293
- if (typeof backupContent2 === "string") {
294
- _fs.writeFileSync.call(void 0, backupFile, backupContent2, "utf-8");
295
- if (verbose) {
296
- console.log(_chalk2.default.gray(` Backup created: ${backupFile}`));
297
- }
298
- } else {
299
- throw new Error("Invalid backup content received from Doppler");
300
- }
301
- } catch (e5) {
302
- console.log(
303
- `Config ${config}: Failed to create backup. Skipping upload.`
304
- );
305
- continue;
306
- }
307
- if (verbose) {
308
- console.log(_chalk2.default.gray(` Reading local file: ${envFile}`));
309
- }
310
- const localContent = _fs.readFileSync.call(void 0, envFile, "utf-8");
311
- const normalizedContent = normalizeEscapeSequences(localContent);
312
- _fs.writeFileSync.call(void 0, normalizedFile, normalizedContent, "utf-8");
313
- if (verbose) {
314
- console.log(_chalk2.default.gray(` Comparing local changes with Doppler...`));
315
- }
316
- const backupContent = _fs.readFileSync.call(void 0, backupFile, "utf-8");
317
- const diff = createDiff(backupContent, normalizedContent);
318
- if (diff.length === 0) {
319
- console.log(`Config ${config}: No differences found. Skipping upload.`);
320
- _fs.unlinkSync.call(void 0, backupFile);
321
- _fs.unlinkSync.call(void 0, normalizedFile);
322
- continue;
323
- }
324
- if (verbose) {
325
- console.log(_chalk2.default.yellow(` Found ${diff.length} line changes`));
326
- }
327
- console.log("\nChanges to be uploaded:");
328
- for (const line of diff) {
329
- if (line.startsWith("-")) {
330
- console.log(_chalk2.default.red(line));
331
- } else if (line.startsWith("+")) {
332
- console.log(_chalk2.default.green(line));
333
- }
334
- }
335
- const confirmed = await promptConfirmation(
336
- "\nDo you want to proceed with the upload? (y/n) "
337
- );
338
- if (!confirmed) {
339
- console.log(`Upload cancelled for ${_chalk2.default.green(envFile)}`);
340
- _fs.unlinkSync.call(void 0, backupFile);
341
- _fs.unlinkSync.call(void 0, normalizedFile);
342
- continue;
343
- }
344
- if (verbose) {
345
- console.log(_chalk2.default.gray(` Uploading to Doppler...`));
346
- }
347
- try {
348
- execDoppler(
349
- ["secrets", "upload", normalizedFile, "--config", config, "--silent"],
350
- "string",
351
- !verbose,
352
- // Only silent if not verbose
353
- verbose
354
- );
355
- if (config === "dev") {
356
- console.log(
357
- `Config ${_chalk2.default.blue(config)}: Successfully uploaded ${_chalk2.default.green(envFile)}`
358
- );
359
- } else {
360
- console.log(
361
- `Config ${config}: Successfully uploaded ${_chalk2.default.green(envFile)}`
362
- );
363
- }
364
- } catch (e6) {
365
- console.error(
366
- `Config ${config}: Failed to upload ${_chalk2.default.green(envFile)}. Restoring previous configuration.`
367
- );
368
- try {
369
- if (verbose) {
370
- console.log(_chalk2.default.gray(` Restoring previous configuration...`));
371
- }
372
- execDoppler(
373
- ["secrets", "upload", backupFile, "--config", config, "--silent"],
374
- "string",
375
- !verbose,
376
- // Only silent if not verbose
377
- verbose
378
- );
379
- console.log(
380
- `Config ${config}: Successfully restored previous configuration`
381
- );
382
- } catch (e7) {
383
- console.error(
384
- `Config ${config}: Failed to restore previous configuration`
385
- );
386
- }
387
- }
388
- if (_fs.existsSync.call(void 0, backupFile)) {
389
- _fs.unlinkSync.call(void 0, backupFile);
390
- }
391
- if (_fs.existsSync.call(void 0, normalizedFile)) {
392
- _fs.unlinkSync.call(void 0, normalizedFile);
393
- }
394
- } catch (error) {
395
- console.error(
396
- `Error processing config ${config}: ${_optionalChain([error, 'optionalAccess', _2 => _2.message]) || error}`
397
- );
398
- if (_fs.existsSync.call(void 0, backupFile)) {
399
- _fs.unlinkSync.call(void 0, backupFile);
400
- }
401
- if (_fs.existsSync.call(void 0, normalizedFile)) {
402
- _fs.unlinkSync.call(void 0, normalizedFile);
403
- }
404
- }
405
- }
406
- }
407
- async function cloneProject({ from, to, environments, force, verbose }) {
408
- if (verbose) {
409
- console.log(
410
- _chalk2.default.blue(
411
- `
412
- \u{1F501} Cloning from ${_chalk2.default.cyan(from)} to ${_chalk2.default.cyan(to)}...`
413
- )
414
- );
415
- }
416
- const configsToClone = getConfigs(environments, verbose, from);
417
- if (configsToClone.length === 0) {
418
- throw new Error(`No configurations found in source project "${from}"`);
419
- }
420
- const targetConfigsRaw = execDoppler(
421
- ["configs", "--json", "--project", to],
422
- "json",
423
- true,
424
- verbose
425
- );
426
- const targetConfigNames = Array.isArray(targetConfigsRaw) ? targetConfigsRaw.map((c) => c.name) : [];
427
- const missingInTarget = configsToClone.filter(
428
- (c) => !targetConfigNames.includes(c)
429
- );
430
- if (missingInTarget.length > 0) {
431
- throw new Error(
432
- `Configs missing in target project "${to}": ${missingInTarget.join(", ")}. Create them in Doppler first.`
433
- );
434
- }
435
- for (const config of configsToClone) {
436
- if (verbose) {
437
- console.log(_chalk2.default.blue(`
438
- \u{1F4E6} Processing config: ${_chalk2.default.cyan(config)}`));
439
- }
440
- const sourceSecrets = execDoppler(
441
- ["secrets", "--json", "--project", from, "--config", config],
442
- "json",
443
- true,
444
- verbose
445
- );
446
- const sourceKeys = sourceSecrets ? Object.keys(sourceSecrets).filter((k) => !DOPPLER_INTERNAL_KEYS.has(k)) : [];
447
- const targetSecrets = execDoppler(
448
- ["secrets", "--json", "--project", to, "--config", config],
449
- "json",
450
- true,
451
- verbose
452
- );
453
- const targetKeys = targetSecrets ? Object.keys(targetSecrets) : [];
454
- const conflicts = sourceKeys.filter((k) => targetKeys.includes(k));
455
- if (conflicts.length > 0) {
456
- if (process.env["CI"]) {
457
- throw new Error(
458
- `Config "${config}" has ${conflicts.length} conflicting key(s) in target: ${conflicts.join(", ")}`
459
- );
460
- }
461
- if (!force) {
462
- console.log(
463
- `
464
- Config ${_chalk2.default.cyan(config)}: ${conflicts.length} key(s) already exist in ${_chalk2.default.cyan(to)}:`
465
- );
466
- conflicts.forEach((k) => console.log(_chalk2.default.yellow(` \u2022 ${k}`)));
467
- const confirmed = await promptConfirmation(
468
- `
469
- Overwrite these keys in "${to}/${config}"? (y/n) `
470
- );
471
- if (!confirmed) {
472
- console.log(`Skipped ${_chalk2.default.blue(config)}`);
473
- continue;
474
- }
475
- }
476
- }
477
- const tmpFile = _path.join.call(void 0, _os.tmpdir.call(void 0, ), `doppler-clone-${config}-${Date.now()}.env`);
478
- try {
479
- const content = execDoppler(
480
- [
481
- "secrets",
482
- "download",
483
- "--no-file",
484
- "--format",
485
- "env",
486
- "--project",
487
- from,
488
- "--config",
489
- config
490
- ],
491
- "string",
492
- true,
493
- verbose
494
- );
495
- if (typeof content !== "string" || !content) {
496
- throw new Error(`No secrets returned for config "${config}"`);
497
- }
498
- const filtered = content.split("\n").filter((line) => {
499
- const key = _nullishCoalesce(line.split("=")[0], () => ( ""));
500
- return !DOPPLER_INTERNAL_KEYS.has(key);
501
- }).join("\n");
502
- _fs.writeFileSync.call(void 0, tmpFile, filtered, "utf-8");
503
- execDoppler(
504
- [
505
- "secrets",
506
- "upload",
507
- tmpFile,
508
- "--project",
509
- to,
510
- "--config",
511
- config,
512
- "--silent"
513
- ],
514
- "string",
515
- true,
516
- verbose
517
- );
518
- console.log(`Config ${_chalk2.default.blue(config)}: cloned to ${_chalk2.default.green(to)}`);
519
- } finally {
520
- if (_fs.existsSync.call(void 0, tmpFile)) {
521
- _fs.unlinkSync.call(void 0, tmpFile);
522
- }
523
- }
524
- }
525
- }
526
-
527
-
528
-
529
-
530
-
531
-
532
-
533
-
534
-
535
-
536
-
537
-
538
- exports.execDoppler = execDoppler; exports.checkDopplerAuth = checkDopplerAuth; exports.checkDependencies = checkDependencies; exports.getConfigs = getConfigs; exports.normalizeEscapeSequences = normalizeEscapeSequences; exports.createDiff = createDiff; exports.promptConfirmation = promptConfirmation; exports.downloadConfigs = downloadConfigs; exports.uploadConfigs = uploadConfigs; exports.cloneProject = cloneProject;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,163 +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/postgres.js
8
- var _pg = require('pg'); var _pg2 = _interopRequireDefault(_pg);
9
- var { Client } = _pg2.default;
10
- function createClient(config, database) {
11
- return new Client({
12
- host: config.host,
13
- port: config.port,
14
- user: config.user,
15
- password: config.password,
16
- database: _nullishCoalesce(database, () => ( (config.database || "postgres"))),
17
- ssl: config.ssl
18
- });
19
- }
20
- async function query(client, sql, params) {
21
- return client.query(sql, params);
22
- }
23
- async function listPostgresDatabases(config) {
24
- const client = createClient(config, config.database || "postgres");
25
- await client.connect();
26
- try {
27
- const result = await query(
28
- client,
29
- `SELECT datname
30
- FROM pg_database
31
- WHERE datistemplate = false
32
- ORDER BY datname`
33
- );
34
- return result.rows.map((row) => row.datname).filter((name) => !_NWZGFHKHcjs.isSystemDatabase.call(void 0, { engine: "postgres", name }));
35
- } finally {
36
- await client.end();
37
- }
38
- }
39
- async function ensureRole(client, params) {
40
- const { username, password } = params;
41
- const ident = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "postgres", name: username });
42
- const passwordLiteral = _NWZGFHKHcjs.quoteLiteral.call(void 0, password);
43
- const existing = await query(
44
- client,
45
- "SELECT 1 FROM pg_roles WHERE rolname = $1",
46
- [username]
47
- );
48
- const statements = [];
49
- if (existing.rowCount && existing.rowCount > 0) {
50
- const sql2 = `ALTER ROLE ${ident} WITH LOGIN PASSWORD ${passwordLiteral}`;
51
- statements.push(sql2);
52
- await query(client, sql2);
53
- return { created: false, statements };
54
- }
55
- const sql = `CREATE ROLE ${ident} WITH LOGIN PASSWORD ${passwordLiteral}`;
56
- statements.push(sql);
57
- await query(client, sql);
58
- return { created: true, statements };
59
- }
60
- async function grantReadonlyInDatabase(client, params) {
61
- const { username } = params;
62
- const ident = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "postgres", name: username });
63
- const statements = [];
64
- const schemasResult = await query(
65
- client,
66
- `SELECT nspname
67
- FROM pg_namespace
68
- WHERE nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast')
69
- AND nspname NOT LIKE 'pg_temp_%'
70
- AND nspname NOT LIKE 'pg_toast_temp_%'
71
- ORDER BY nspname`
72
- );
73
- const schemas = schemasResult.rows.map(
74
- (row) => row.nspname
75
- );
76
- if (schemas.length === 0) {
77
- schemas.push("public");
78
- }
79
- for (const schema of schemas) {
80
- const schemaIdent = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "postgres", name: schema });
81
- const grants = [
82
- `GRANT USAGE ON SCHEMA ${schemaIdent} TO ${ident}`,
83
- `GRANT SELECT ON ALL TABLES IN SCHEMA ${schemaIdent} TO ${ident}`,
84
- `GRANT SELECT ON ALL SEQUENCES IN SCHEMA ${schemaIdent} TO ${ident}`,
85
- `ALTER DEFAULT PRIVILEGES IN SCHEMA ${schemaIdent} GRANT SELECT ON TABLES TO ${ident}`,
86
- `ALTER DEFAULT PRIVILEGES IN SCHEMA ${schemaIdent} GRANT SELECT ON SEQUENCES TO ${ident}`
87
- ];
88
- for (const sql of grants) {
89
- statements.push(sql);
90
- await query(client, sql);
91
- }
92
- }
93
- return statements;
94
- }
95
- async function applyPostgresReadonly(params) {
96
- const {
97
- config,
98
- username,
99
- password,
100
- databases,
101
- dryRun = false,
102
- verbose = false
103
- } = params;
104
- const statements = [];
105
- let created = false;
106
- if (dryRun) {
107
- const ident = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "postgres", name: username });
108
- statements.push(
109
- `-- Would CREATE/ALTER ROLE ${ident} WITH LOGIN PASSWORD ***`
110
- );
111
- for (const database of databases) {
112
- const dbIdent = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "postgres", name: database });
113
- statements.push(`GRANT CONNECT ON DATABASE ${dbIdent} TO ${ident}`);
114
- statements.push(
115
- `-- In database ${database}: GRANT USAGE/SELECT on all user schemas + ALTER DEFAULT PRIVILEGES`
116
- );
117
- }
118
- return { created: true, statements, databases };
119
- }
120
- const adminDb = config.database || "postgres";
121
- const adminClient = createClient(config, adminDb);
122
- await adminClient.connect();
123
- try {
124
- if (verbose) {
125
- console.log(
126
- ` Connected to Postgres as ${config.user}@${config.host}/${adminDb}`
127
- );
128
- }
129
- const roleResult = await ensureRole(adminClient, { username, password });
130
- created = roleResult.created;
131
- statements.push(...roleResult.statements);
132
- const ident = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "postgres", name: username });
133
- for (const database of databases) {
134
- const dbIdent = _NWZGFHKHcjs.quoteIdent.call(void 0, { engine: "postgres", name: database });
135
- const connectSql = `GRANT CONNECT ON DATABASE ${dbIdent} TO ${ident}`;
136
- statements.push(connectSql);
137
- await query(adminClient, connectSql);
138
- }
139
- } finally {
140
- await adminClient.end();
141
- }
142
- for (const database of databases) {
143
- const dbClient = createClient(config, database);
144
- await dbClient.connect();
145
- try {
146
- if (verbose) {
147
- console.log(` Granting read-only in database ${database}`);
148
- }
149
- const dbStatements = await grantReadonlyInDatabase(dbClient, {
150
- username
151
- });
152
- statements.push(...dbStatements);
153
- } finally {
154
- await dbClient.end();
155
- }
156
- }
157
- return { created, statements, databases };
158
- }
159
-
160
-
161
-
162
-
163
- exports.listPostgresDatabases = listPostgresDatabases; exports.applyPostgresReadonly = applyPostgresReadonly;