@mtndev/cli 1.1.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.
- package/CHANGELOG.md +91 -0
- package/cjs/__chunks/VH7oDXx4.cjs +28 -0
- package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -0
- package/cjs/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
- package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -0
- package/cjs/commands/aws/ec2/allow-ip/index.d.ts +3 -0
- package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -0
- package/cjs/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
- package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -0
- package/cjs/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
- package/cjs/commands/aws/iam/admin-group.cjs +111 -0
- package/cjs/commands/aws/iam/admin-group.d.ts +55 -0
- package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -0
- package/cjs/commands/aws/iam/break-glass/handler.d.ts +7 -0
- package/cjs/commands/aws/iam/break-glass/index.cjs +7 -0
- package/cjs/commands/aws/iam/break-glass/index.d.ts +2 -0
- package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -0
- package/cjs/commands/aws/iam/break-glass/schema.d.ts +25 -0
- package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -0
- package/cjs/commands/aws/iam/check-admin/handler.d.ts +5 -0
- package/cjs/commands/aws/iam/check-admin/index.cjs +7 -0
- package/cjs/commands/aws/iam/check-admin/index.d.ts +2 -0
- package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -0
- package/cjs/commands/aws/iam/check-admin/schema.d.ts +19 -0
- package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
- package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
- package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
- package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
- package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
- package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
- package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -0
- package/cjs/commands/aws/iam/remove-admin/handler.d.ts +6 -0
- package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -0
- package/cjs/commands/aws/iam/remove-admin/index.d.ts +2 -0
- package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -0
- package/cjs/commands/aws/iam/remove-admin/schema.d.ts +28 -0
- package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -0
- package/cjs/commands/aws/iam/setup-acl/handler.d.ts +6 -0
- package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -0
- package/cjs/commands/aws/iam/setup-acl/index.d.ts +3 -0
- package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -0
- package/cjs/commands/aws/iam/setup-acl/schema.d.ts +24 -0
- package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -0
- package/cjs/commands/aws/iam/setup-acl/utils.d.ts +61 -0
- package/cjs/commands/aws/iam/users/handler.cjs +59 -0
- package/cjs/commands/aws/iam/users/handler.d.ts +5 -0
- package/cjs/commands/aws/iam/users/index.cjs +18 -0
- package/cjs/commands/aws/iam/users/index.d.ts +3 -0
- package/cjs/commands/aws/iam/users/schema.cjs +17 -0
- package/cjs/commands/aws/iam/users/schema.d.ts +18 -0
- package/cjs/commands/aws/iam/users/utils.cjs +454 -0
- package/cjs/commands/aws/iam/users/utils.d.ts +119 -0
- package/cjs/commands/aws/index.cjs +223 -0
- package/cjs/commands/aws/index.d.ts +14 -0
- package/cjs/commands/aws/route53/add-record/handler.cjs +264 -0
- package/cjs/commands/aws/route53/add-record/handler.d.ts +36 -0
- package/cjs/commands/aws/route53/add-record/index.cjs +26 -0
- package/cjs/commands/aws/route53/add-record/index.d.ts +3 -0
- package/cjs/commands/aws/route53/add-record/schema.cjs +43 -0
- package/cjs/commands/aws/route53/add-record/schema.d.ts +45 -0
- package/cjs/commands/aws/route53/add-record/utils.cjs +404 -0
- package/cjs/commands/aws/route53/add-record/utils.d.ts +216 -0
- package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -0
- package/cjs/commands/aws/route53/remove-record/handler.d.ts +6 -0
- package/cjs/commands/aws/route53/remove-record/index.cjs +5 -0
- package/cjs/commands/aws/route53/remove-record/index.d.ts +2 -0
- package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -0
- package/cjs/commands/aws/route53/remove-record/schema.d.ts +30 -0
- package/cjs/commands/aws/schema.cjs +19 -0
- package/cjs/commands/aws/schema.d.ts +13 -0
- package/cjs/commands/aws/ses/send-email/handler.cjs +73 -0
- package/cjs/commands/aws/ses/send-email/handler.d.ts +5 -0
- package/cjs/commands/aws/ses/send-email/index.cjs +9 -0
- package/cjs/commands/aws/ses/send-email/index.d.ts +3 -0
- package/cjs/commands/aws/ses/send-email/schema.cjs +24 -0
- package/cjs/commands/aws/ses/send-email/schema.d.ts +39 -0
- package/cjs/commands/aws/ses/send-email/utils.cjs +87 -0
- package/cjs/commands/aws/ses/send-email/utils.d.ts +47 -0
- package/cjs/commands/aws/ses/smtp-password.cjs +72 -0
- package/cjs/commands/aws/ses/smtp-password.d.ts +21 -0
- package/cjs/commands/aws/utils/exec-aws.cjs +145 -0
- package/cjs/commands/aws/utils/exec-aws.d.ts +79 -0
- package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -0
- package/cjs/commands/aws/utils/resolve-policy-path.d.ts +8 -0
- package/cjs/commands/aws/utils/resolve-profile.cjs +93 -0
- package/cjs/commands/aws/utils/resolve-profile.d.ts +28 -0
- package/cjs/commands/aws/utils/tty.cjs +54 -0
- package/cjs/commands/aws/utils/tty.d.ts +24 -0
- package/cjs/commands/db/create-readonly-user/handler.cjs +254 -0
- package/cjs/commands/db/create-readonly-user/handler.d.ts +5 -0
- package/cjs/commands/db/create-readonly-user/index.cjs +18 -0
- package/cjs/commands/db/create-readonly-user/index.d.ts +3 -0
- package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -0
- package/cjs/commands/db/create-readonly-user/mysql.d.ts +33 -0
- package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -0
- package/cjs/commands/db/create-readonly-user/postgres.d.ts +31 -0
- package/cjs/commands/db/create-readonly-user/schema.cjs +39 -0
- package/cjs/commands/db/create-readonly-user/schema.d.ts +55 -0
- package/cjs/commands/db/create-readonly-user/utils.cjs +160 -0
- package/cjs/commands/db/create-readonly-user/utils.d.ts +112 -0
- package/cjs/commands/db/index.cjs +46 -0
- package/cjs/commands/db/index.d.ts +6 -0
- package/cjs/commands/doppler/handler.cjs +95 -9
- package/cjs/commands/doppler/index.cjs +33 -41
- package/cjs/commands/doppler/index.d.ts +1 -0
- package/cjs/commands/doppler/schema.cjs +130 -6
- package/cjs/commands/doppler/schema.d.ts +233 -17
- package/cjs/commands/doppler/set-secret.cjs +378 -0
- package/cjs/commands/doppler/set-secret.d.ts +113 -0
- package/cjs/commands/doppler/utils/exec.cjs +106 -12
- package/cjs/commands/doppler/utils.cjs +412 -30
- package/cjs/commands/doppler/utils.d.ts +32 -8
- package/cjs/commands/icons/handler.cjs +82 -8
- package/cjs/commands/icons/index.cjs +15 -31
- package/cjs/commands/icons/schema.cjs +101 -13
- package/cjs/commands/icons/schema.d.ts +1 -1
- package/cjs/commands/icons/utils.cjs +131 -13
- package/cjs/commands/index.cjs +54 -82
- package/cjs/commands/schema.cjs +25 -8
- package/cjs/index.cjs +3 -4
- package/esm/commands/aws/ec2/allow-ip/handler.d.ts +6 -0
- package/esm/commands/aws/ec2/allow-ip/handler.js +258 -0
- package/esm/commands/aws/ec2/allow-ip/index.d.ts +3 -0
- package/esm/commands/aws/ec2/allow-ip/index.js +4 -0
- package/esm/commands/aws/ec2/allow-ip/schema.d.ts +33 -0
- package/esm/commands/aws/ec2/allow-ip/schema.js +29 -0
- package/esm/commands/aws/ec2/allow-ip/utils.d.ts +189 -0
- package/esm/commands/aws/ec2/allow-ip/utils.js +363 -0
- package/esm/commands/aws/iam/admin-group.d.ts +55 -0
- package/esm/commands/aws/iam/admin-group.js +104 -0
- package/esm/commands/aws/iam/break-glass/handler.d.ts +7 -0
- package/esm/commands/aws/iam/break-glass/handler.js +124 -0
- package/esm/commands/aws/iam/break-glass/index.d.ts +2 -0
- package/esm/commands/aws/iam/break-glass/index.js +4 -0
- package/esm/commands/aws/iam/break-glass/schema.d.ts +25 -0
- package/esm/commands/aws/iam/break-glass/schema.js +19 -0
- package/esm/commands/aws/iam/check-admin/handler.d.ts +5 -0
- package/esm/commands/aws/iam/check-admin/handler.js +86 -0
- package/esm/commands/aws/iam/check-admin/index.d.ts +2 -0
- package/esm/commands/aws/iam/check-admin/index.js +4 -0
- package/esm/commands/aws/iam/check-admin/schema.d.ts +19 -0
- package/esm/commands/aws/iam/check-admin/schema.js +17 -0
- package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
- package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
- package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
- package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
- package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
- package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
- package/esm/commands/aws/iam/remove-admin/handler.d.ts +6 -0
- package/esm/commands/aws/iam/remove-admin/handler.js +117 -0
- package/esm/commands/aws/iam/remove-admin/index.d.ts +2 -0
- package/esm/commands/aws/iam/remove-admin/index.js +4 -0
- package/esm/commands/aws/iam/remove-admin/schema.d.ts +28 -0
- package/esm/commands/aws/iam/remove-admin/schema.js +20 -0
- package/esm/commands/aws/iam/setup-acl/handler.d.ts +6 -0
- package/esm/commands/aws/iam/setup-acl/handler.js +224 -0
- package/esm/commands/aws/iam/setup-acl/index.d.ts +3 -0
- package/esm/commands/aws/iam/setup-acl/index.js +4 -0
- package/esm/commands/aws/iam/setup-acl/schema.d.ts +24 -0
- package/esm/commands/aws/iam/setup-acl/schema.js +18 -0
- package/esm/commands/aws/iam/setup-acl/utils.d.ts +61 -0
- package/esm/commands/aws/iam/setup-acl/utils.js +298 -0
- package/esm/commands/aws/iam/users/handler.d.ts +5 -0
- package/esm/commands/aws/iam/users/handler.js +56 -0
- package/esm/commands/aws/iam/users/index.d.ts +3 -0
- package/esm/commands/aws/iam/users/index.js +4 -0
- package/esm/commands/aws/iam/users/schema.d.ts +18 -0
- package/esm/commands/aws/iam/users/schema.js +16 -0
- package/esm/commands/aws/iam/users/utils.d.ts +119 -0
- package/esm/commands/aws/iam/users/utils.js +440 -0
- package/esm/commands/aws/index.d.ts +14 -0
- package/esm/commands/aws/index.js +142 -0
- package/esm/commands/aws/route53/add-record/handler.d.ts +36 -0
- package/esm/commands/aws/route53/add-record/handler.js +258 -0
- package/esm/commands/aws/route53/add-record/index.d.ts +3 -0
- package/esm/commands/aws/route53/add-record/index.js +4 -0
- package/esm/commands/aws/route53/add-record/schema.d.ts +45 -0
- package/esm/commands/aws/route53/add-record/schema.js +40 -0
- package/esm/commands/aws/route53/add-record/utils.d.ts +216 -0
- package/esm/commands/aws/route53/add-record/utils.js +389 -0
- package/esm/commands/aws/route53/remove-record/handler.d.ts +6 -0
- package/esm/commands/aws/route53/remove-record/handler.js +111 -0
- package/esm/commands/aws/route53/remove-record/index.d.ts +2 -0
- package/esm/commands/aws/route53/remove-record/index.js +3 -0
- package/esm/commands/aws/route53/remove-record/schema.d.ts +30 -0
- package/esm/commands/aws/route53/remove-record/schema.js +21 -0
- package/esm/commands/aws/schema.d.ts +13 -0
- package/esm/commands/aws/schema.js +16 -0
- package/esm/commands/aws/ses/send-email/handler.d.ts +5 -0
- package/esm/commands/aws/ses/send-email/handler.js +70 -0
- package/esm/commands/aws/ses/send-email/index.d.ts +3 -0
- package/esm/commands/aws/ses/send-email/index.js +4 -0
- package/esm/commands/aws/ses/send-email/schema.d.ts +39 -0
- package/esm/commands/aws/ses/send-email/schema.js +23 -0
- package/esm/commands/aws/ses/send-email/utils.d.ts +47 -0
- package/esm/commands/aws/ses/send-email/utils.js +84 -0
- package/esm/commands/aws/ses/smtp-password.d.ts +21 -0
- package/esm/commands/aws/ses/smtp-password.js +69 -0
- package/esm/commands/aws/utils/exec-aws.d.ts +79 -0
- package/esm/commands/aws/utils/exec-aws.js +137 -0
- package/esm/commands/aws/utils/resolve-policy-path.d.ts +8 -0
- package/esm/commands/aws/utils/resolve-policy-path.js +14 -0
- package/esm/commands/aws/utils/resolve-profile.d.ts +28 -0
- package/esm/commands/aws/utils/resolve-profile.js +88 -0
- package/esm/commands/aws/utils/tty.d.ts +24 -0
- package/esm/commands/aws/utils/tty.js +51 -0
- package/esm/commands/db/create-readonly-user/handler.d.ts +5 -0
- package/esm/commands/db/create-readonly-user/handler.js +251 -0
- package/esm/commands/db/create-readonly-user/index.d.ts +3 -0
- package/esm/commands/db/create-readonly-user/index.js +4 -0
- package/esm/commands/db/create-readonly-user/mysql.d.ts +33 -0
- package/esm/commands/db/create-readonly-user/mysql.js +98 -0
- package/esm/commands/db/create-readonly-user/postgres.d.ts +31 -0
- package/esm/commands/db/create-readonly-user/postgres.js +205 -0
- package/esm/commands/db/create-readonly-user/schema.d.ts +55 -0
- package/esm/commands/db/create-readonly-user/schema.js +35 -0
- package/esm/commands/db/create-readonly-user/utils.d.ts +112 -0
- package/esm/commands/db/create-readonly-user/utils.js +151 -0
- package/esm/commands/db/index.d.ts +6 -0
- package/esm/commands/db/index.js +31 -0
- package/esm/commands/doppler/handler.js +92 -9
- package/esm/commands/doppler/index.d.ts +1 -0
- package/esm/commands/doppler/index.js +6 -41
- package/esm/commands/doppler/schema.d.ts +233 -17
- package/esm/commands/doppler/schema.js +125 -7
- package/esm/commands/doppler/set-secret.d.ts +113 -0
- package/esm/commands/doppler/set-secret.js +370 -0
- package/esm/commands/doppler/utils/exec.js +100 -12
- package/esm/commands/doppler/utils.d.ts +32 -8
- package/esm/commands/doppler/utils.js +396 -30
- package/esm/commands/icons/handler.js +79 -8
- package/esm/commands/icons/index.js +4 -31
- package/esm/commands/icons/schema.d.ts +1 -1
- package/esm/commands/icons/schema.js +97 -15
- package/esm/commands/icons/utils.js +125 -13
- package/esm/commands/index.js +49 -78
- package/esm/commands/schema.js +22 -7
- package/esm/index.js +3 -4
- package/package.json +12 -2
- package/vitest.config.ts +11 -0
- package/cjs/__chunks/4GFJUCSP.cjs +0 -52
- package/cjs/__chunks/4SFWHCB3.cjs +0 -133
- package/cjs/__chunks/B2KFW7T7.cjs +0 -1
- package/cjs/__chunks/EMMC33QA.cjs +0 -401
- package/cjs/__chunks/INFOPAHN.cjs +0 -117
- package/cjs/__chunks/J36P6UNE.cjs +0 -75
- package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
- package/cjs/__chunks/NSRFG4DF.cjs +0 -100
- package/cjs/__chunks/WNJ3ZYLI.cjs +0 -1
- package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
- package/esm/__chunks/46HGXFME.js +0 -0
- package/esm/__chunks/6G4PXXKF.js +0 -75
- package/esm/__chunks/6L5RNR7G.js +0 -100
- package/esm/__chunks/FL7AILGH.js +0 -133
- package/esm/__chunks/HJSXC6HP.js +0 -117
- package/esm/__chunks/O262GK4B.js +0 -401
- package/esm/__chunks/O3CCA76Q.js +0 -22
- package/esm/__chunks/SJXQJ7RS.js +0 -92
- package/esm/__chunks/SNCKIAOR.js +0 -0
- package/esm/__chunks/X3R5PSWH.js +0 -52
|
@@ -0,0 +1,378 @@
|
|
|
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("../aws/utils/tty.cjs");
|
|
4
|
+
const require_commands_doppler_utils = require("./utils.cjs");
|
|
5
|
+
let chalk = require("chalk");
|
|
6
|
+
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
7
|
+
let child_process = require("child_process");
|
|
8
|
+
//#region src/commands/doppler/set-secret.js
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} DopplerProject
|
|
11
|
+
* @property {string} id
|
|
12
|
+
* @property {string} name
|
|
13
|
+
* @property {string} [description]
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} DopplerEnvironment
|
|
17
|
+
* @property {string} id
|
|
18
|
+
* @property {string} name
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} DopplerConfig
|
|
22
|
+
* @property {string} name
|
|
23
|
+
* @property {string} environment
|
|
24
|
+
* @property {boolean} [root]
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* List Doppler projects (paginated until exhausted or cap).
|
|
28
|
+
* @param {{ verbose?: boolean; limit?: number }} [params]
|
|
29
|
+
* @returns {DopplerProject[]}
|
|
30
|
+
*/
|
|
31
|
+
function listProjects(params = {}) {
|
|
32
|
+
const { verbose = false, limit = 500 } = params;
|
|
33
|
+
/** @type {DopplerProject[]} */
|
|
34
|
+
const projects = [];
|
|
35
|
+
let page = 1;
|
|
36
|
+
while (projects.length < limit) {
|
|
37
|
+
const batch = require_commands_doppler_utils.execDoppler([
|
|
38
|
+
"projects",
|
|
39
|
+
"--json",
|
|
40
|
+
"--page",
|
|
41
|
+
String(page),
|
|
42
|
+
"--number",
|
|
43
|
+
"100"
|
|
44
|
+
], "json", true, verbose);
|
|
45
|
+
if (!Array.isArray(batch) || batch.length === 0) break;
|
|
46
|
+
for (const raw of batch) projects.push({
|
|
47
|
+
id: String(raw.id ?? raw.name ?? ""),
|
|
48
|
+
name: String(raw.name ?? raw.id ?? ""),
|
|
49
|
+
description: raw.description ? String(raw.description) : ""
|
|
50
|
+
});
|
|
51
|
+
if (batch.length < 100) break;
|
|
52
|
+
page += 1;
|
|
53
|
+
}
|
|
54
|
+
return projects.filter((project) => project.name).sort((a, b) => a.name.localeCompare(b.name));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* List environments for a project.
|
|
58
|
+
* @param {{ project: string; verbose?: boolean }} params
|
|
59
|
+
* @returns {DopplerEnvironment[]}
|
|
60
|
+
*/
|
|
61
|
+
function listEnvironments(params) {
|
|
62
|
+
const { project, verbose = false } = params;
|
|
63
|
+
const data = require_commands_doppler_utils.execDoppler([
|
|
64
|
+
"environments",
|
|
65
|
+
"--json",
|
|
66
|
+
"--project",
|
|
67
|
+
project
|
|
68
|
+
], "json", true, verbose);
|
|
69
|
+
if (!Array.isArray(data)) return [];
|
|
70
|
+
return data.map((raw) => ({
|
|
71
|
+
id: String(raw.id ?? ""),
|
|
72
|
+
name: String(raw.name ?? raw.id ?? "")
|
|
73
|
+
})).filter((env) => env.id).sort((a, b) => a.id.localeCompare(b.id));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* List configs for a project, optionally filtered by environment.
|
|
77
|
+
* @param {{ project: string; environment?: string; verbose?: boolean }} params
|
|
78
|
+
* @returns {DopplerConfig[]}
|
|
79
|
+
*/
|
|
80
|
+
function listConfigs(params) {
|
|
81
|
+
const { project, environment, verbose = false } = params;
|
|
82
|
+
/** @type {string[]} */
|
|
83
|
+
const args = [
|
|
84
|
+
"configs",
|
|
85
|
+
"--json",
|
|
86
|
+
"--project",
|
|
87
|
+
project
|
|
88
|
+
];
|
|
89
|
+
if (environment) args.push("--environment", environment);
|
|
90
|
+
const data = require_commands_doppler_utils.execDoppler(args, "json", true, verbose);
|
|
91
|
+
if (!Array.isArray(data)) return [];
|
|
92
|
+
return data.map((raw) => ({
|
|
93
|
+
name: String(raw.name ?? ""),
|
|
94
|
+
environment: String(raw.environment ?? ""),
|
|
95
|
+
root: Boolean(raw.root)
|
|
96
|
+
})).filter((config) => config.name).sort((a, b) => a.name.localeCompare(b.name));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get an existing secret value (raw), or null if missing.
|
|
100
|
+
* @param {{
|
|
101
|
+
* project: string;
|
|
102
|
+
* config: string;
|
|
103
|
+
* name: string;
|
|
104
|
+
* verbose?: boolean;
|
|
105
|
+
* }} params
|
|
106
|
+
* @returns {string | null}
|
|
107
|
+
*/
|
|
108
|
+
function getSecret(params) {
|
|
109
|
+
const { project, config, name, verbose = false } = params;
|
|
110
|
+
try {
|
|
111
|
+
const data = require_commands_doppler_utils.execDoppler([
|
|
112
|
+
"secrets",
|
|
113
|
+
"get",
|
|
114
|
+
name,
|
|
115
|
+
"--project",
|
|
116
|
+
project,
|
|
117
|
+
"--config",
|
|
118
|
+
config,
|
|
119
|
+
"--plain",
|
|
120
|
+
"--raw"
|
|
121
|
+
], "string", true, verbose);
|
|
122
|
+
if (typeof data !== "string") return null;
|
|
123
|
+
const value = data.replace(/\n$/, "");
|
|
124
|
+
return value.length > 0 ? value : "";
|
|
125
|
+
} catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Set a secret via stdin so values need no shell escaping.
|
|
131
|
+
* @param {{
|
|
132
|
+
* project: string;
|
|
133
|
+
* config: string;
|
|
134
|
+
* name: string;
|
|
135
|
+
* value: string;
|
|
136
|
+
* verbose?: boolean;
|
|
137
|
+
* }} params
|
|
138
|
+
*/
|
|
139
|
+
function setSecret(params) {
|
|
140
|
+
const { project, config, name, value, verbose = false } = params;
|
|
141
|
+
const args = [
|
|
142
|
+
"secrets",
|
|
143
|
+
"set",
|
|
144
|
+
name,
|
|
145
|
+
"--project",
|
|
146
|
+
project,
|
|
147
|
+
"--config",
|
|
148
|
+
config,
|
|
149
|
+
"--no-interactive"
|
|
150
|
+
];
|
|
151
|
+
if (verbose) console.log(chalk.default.gray(` Executing: doppler ${args.join(" ")} <stdin value (${value.length} chars)>`));
|
|
152
|
+
const result = (0, child_process.spawnSync)("doppler", args, {
|
|
153
|
+
encoding: "utf-8",
|
|
154
|
+
input: value
|
|
155
|
+
});
|
|
156
|
+
if (result.error) throw new Error(result.error.message);
|
|
157
|
+
if (result.status !== 0) {
|
|
158
|
+
const stderr = (result.stderr || result.stdout || "").trim();
|
|
159
|
+
throw new Error(stderr || `doppler secrets set failed for ${name}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @param {{ projects: DopplerProject[]; projectOption?: string }} params
|
|
164
|
+
* @returns {Promise<string>}
|
|
165
|
+
*/
|
|
166
|
+
async function resolveProject(params) {
|
|
167
|
+
const { projects, projectOption } = params;
|
|
168
|
+
if (projectOption) {
|
|
169
|
+
const match = projects.find((project) => project.name === projectOption || project.id === projectOption);
|
|
170
|
+
if (!match) throw new Error(`Project "${projectOption}" not found. Available examples: ${projects.slice(0, 8).map((project) => project.name).join(", ")}`);
|
|
171
|
+
return match.name;
|
|
172
|
+
}
|
|
173
|
+
if (projects.length === 0) throw new Error("No Doppler projects found for this account.");
|
|
174
|
+
let candidates = projects;
|
|
175
|
+
if (projects.length > 30) {
|
|
176
|
+
const filter = await require_commands_aws_utils_tty.prompt(` Filter projects (${projects.length} total, Enter for all): `);
|
|
177
|
+
if (filter) {
|
|
178
|
+
const lower = filter.toLowerCase();
|
|
179
|
+
candidates = projects.filter((project) => project.name.toLowerCase().includes(lower) || project.id.toLowerCase().includes(lower));
|
|
180
|
+
if (candidates.length === 0) throw new Error(`No projects matched "${filter}".`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const maxShown = 50;
|
|
184
|
+
const shown = candidates.slice(0, maxShown);
|
|
185
|
+
if (candidates.length > maxShown) console.log(chalk.default.yellow(` Showing first ${maxShown} of ${candidates.length} matches — refine with a filter next time.`));
|
|
186
|
+
const chosen = shown[await require_commands_aws_utils_tty.promptChoice({
|
|
187
|
+
message: "Choose a Doppler project:",
|
|
188
|
+
options: shown.map((project) => project.description ? `${project.name} — ${project.description}` : project.name)
|
|
189
|
+
})];
|
|
190
|
+
if (!chosen) throw new Error("No project selected");
|
|
191
|
+
return chosen.name;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @param {{
|
|
195
|
+
* environments: DopplerEnvironment[];
|
|
196
|
+
* environmentOption?: string;
|
|
197
|
+
* }} params
|
|
198
|
+
* @returns {Promise<string | "all">}
|
|
199
|
+
*/
|
|
200
|
+
async function resolveEnvironment(params) {
|
|
201
|
+
const { environments, environmentOption } = params;
|
|
202
|
+
if (environmentOption) {
|
|
203
|
+
const normalized = environmentOption.trim().toLowerCase();
|
|
204
|
+
if (normalized === "all" || normalized === "*") return "all";
|
|
205
|
+
const match = environments.find((env) => env.id.toLowerCase() === normalized || env.name.toLowerCase() === normalized);
|
|
206
|
+
if (!match) throw new Error(`Environment "${environmentOption}" not found. Available: ${environments.map((env) => env.id).join(", ")}`);
|
|
207
|
+
return match.id;
|
|
208
|
+
}
|
|
209
|
+
if (environments.length === 0) return "all";
|
|
210
|
+
const options = [...environments.map((env) => `${env.id} (${env.name})`), "all environments"];
|
|
211
|
+
const index = await require_commands_aws_utils_tty.promptChoice({
|
|
212
|
+
message: "Choose an environment:",
|
|
213
|
+
options
|
|
214
|
+
});
|
|
215
|
+
if (index === options.length - 1) return "all";
|
|
216
|
+
const chosen = environments[index];
|
|
217
|
+
if (!chosen) throw new Error("No environment selected");
|
|
218
|
+
return chosen.id;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @param {{
|
|
222
|
+
* configs: DopplerConfig[];
|
|
223
|
+
* configOption?: string;
|
|
224
|
+
* environment: string | "all";
|
|
225
|
+
* }} params
|
|
226
|
+
* @returns {Promise<string[]>}
|
|
227
|
+
*/
|
|
228
|
+
async function resolveConfigs(params) {
|
|
229
|
+
const { configs, configOption, environment } = params;
|
|
230
|
+
const scoped = environment === "all" ? configs : configs.filter((config) => config.environment === environment);
|
|
231
|
+
if (scoped.length === 0) throw new Error(environment === "all" ? "No configs found in this project." : `No configs found for environment "${environment}".`);
|
|
232
|
+
if (configOption) {
|
|
233
|
+
const normalized = configOption.trim().toLowerCase();
|
|
234
|
+
if (normalized === "all" || normalized === "*") return scoped.map((config) => config.name);
|
|
235
|
+
const requested = configOption.split(",").map((value) => value.trim());
|
|
236
|
+
const names = new Set(scoped.map((config) => config.name));
|
|
237
|
+
const missing = requested.filter((name) => !names.has(name));
|
|
238
|
+
if (missing.length > 0) throw new Error(`Config(s) not found: ${missing.join(", ")}. Available: ${[...names].join(", ")}`);
|
|
239
|
+
return requested;
|
|
240
|
+
}
|
|
241
|
+
if (scoped.length === 1) {
|
|
242
|
+
const only = scoped[0];
|
|
243
|
+
if (!only) throw new Error("No config selected");
|
|
244
|
+
console.log(` Config: ${only.name}`);
|
|
245
|
+
return [only.name];
|
|
246
|
+
}
|
|
247
|
+
const options = [...scoped.map((config) => config.root ? `${config.name} (root, env: ${config.environment})` : `${config.name} (env: ${config.environment})`), `all configs listed (${scoped.length})`];
|
|
248
|
+
const index = await require_commands_aws_utils_tty.promptChoice({
|
|
249
|
+
message: "Choose a config:",
|
|
250
|
+
options
|
|
251
|
+
});
|
|
252
|
+
if (index === options.length - 1) return scoped.map((config) => config.name);
|
|
253
|
+
const chosen = scoped[index];
|
|
254
|
+
if (!chosen) throw new Error("No config selected");
|
|
255
|
+
return [chosen.name];
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @param {string | undefined} nameOption
|
|
259
|
+
* @returns {Promise<string>}
|
|
260
|
+
*/
|
|
261
|
+
async function resolveSecretName(nameOption) {
|
|
262
|
+
if (nameOption) return nameOption;
|
|
263
|
+
const raw = await require_commands_aws_utils_tty.prompt(" Secret name (e.g. DATABASE_URL): ");
|
|
264
|
+
if (!raw) throw new Error("Secret name is required");
|
|
265
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(raw)) throw new Error("Secret name must be a valid env var identifier (letters, numbers, underscore)");
|
|
266
|
+
return raw;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* @param {string | undefined} valueOption
|
|
270
|
+
* @returns {Promise<string>}
|
|
271
|
+
*/
|
|
272
|
+
async function resolveSecretValue(valueOption) {
|
|
273
|
+
if (valueOption !== void 0) return valueOption;
|
|
274
|
+
const raw = await require_commands_aws_utils_tty.prompt(" Secret value: ");
|
|
275
|
+
if (raw === "") {
|
|
276
|
+
if (!await require_commands_aws_utils_tty.promptYesNo({
|
|
277
|
+
message: " Set an empty value?",
|
|
278
|
+
defaultYes: false
|
|
279
|
+
})) throw new Error("Secret value is required");
|
|
280
|
+
}
|
|
281
|
+
return raw;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Interactively (or via flags) set a Doppler secret on one or more configs.
|
|
285
|
+
* @param {{
|
|
286
|
+
* project?: string;
|
|
287
|
+
* environment?: string;
|
|
288
|
+
* config?: string;
|
|
289
|
+
* name?: string;
|
|
290
|
+
* value?: string;
|
|
291
|
+
* yes?: boolean;
|
|
292
|
+
* verbose?: boolean;
|
|
293
|
+
* }} options
|
|
294
|
+
*/
|
|
295
|
+
async function setSecretInteractive(options) {
|
|
296
|
+
const { project: projectOption, environment: environmentOption, config: configOption, name: nameOption, value: valueOption, yes = false, verbose = false } = options;
|
|
297
|
+
console.log(chalk.default.blue("\nSet Doppler secret"));
|
|
298
|
+
console.log("");
|
|
299
|
+
const project = await resolveProject({
|
|
300
|
+
projects: listProjects({ verbose }),
|
|
301
|
+
projectOption
|
|
302
|
+
});
|
|
303
|
+
console.log(`Project: ${project}`);
|
|
304
|
+
console.log("");
|
|
305
|
+
const environment = await resolveEnvironment({
|
|
306
|
+
environments: listEnvironments({
|
|
307
|
+
project,
|
|
308
|
+
verbose
|
|
309
|
+
}),
|
|
310
|
+
environmentOption
|
|
311
|
+
});
|
|
312
|
+
console.log(environment === "all" ? "Environment: all" : `Environment: ${environment}`);
|
|
313
|
+
console.log("");
|
|
314
|
+
const targetConfigs = await resolveConfigs({
|
|
315
|
+
configs: listConfigs({
|
|
316
|
+
project,
|
|
317
|
+
environment: environment === "all" ? void 0 : environment,
|
|
318
|
+
verbose
|
|
319
|
+
}),
|
|
320
|
+
configOption,
|
|
321
|
+
environment
|
|
322
|
+
});
|
|
323
|
+
console.log(`Config(s): ${targetConfigs.join(", ")}`);
|
|
324
|
+
console.log("");
|
|
325
|
+
const name = await resolveSecretName(nameOption);
|
|
326
|
+
const value = await resolveSecretValue(valueOption);
|
|
327
|
+
/** @type {{ config: string; existing: string | null }[]} */
|
|
328
|
+
const existingByConfig = [];
|
|
329
|
+
for (const config of targetConfigs) {
|
|
330
|
+
const existing = getSecret({
|
|
331
|
+
project,
|
|
332
|
+
config,
|
|
333
|
+
name,
|
|
334
|
+
verbose
|
|
335
|
+
});
|
|
336
|
+
existingByConfig.push({
|
|
337
|
+
config,
|
|
338
|
+
existing
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
const overwrites = existingByConfig.filter((entry) => entry.existing !== null);
|
|
342
|
+
console.log("");
|
|
343
|
+
console.log("Plan:");
|
|
344
|
+
console.log(` Project: ${project}`);
|
|
345
|
+
console.log(` Configs: ${targetConfigs.join(", ")}`);
|
|
346
|
+
console.log(` Name: ${name}`);
|
|
347
|
+
console.log(` Value: ${value.length === 0 ? "(empty)" : `(${value.length} chars)`}`);
|
|
348
|
+
if (overwrites.length > 0) console.log(chalk.default.yellow(` Overwrite: ${overwrites.length} config(s) already have this secret (${overwrites.map((entry) => entry.config).join(", ")})`));
|
|
349
|
+
else console.log(chalk.default.green(" Overwrite: none (new secret on all targets)"));
|
|
350
|
+
console.log("");
|
|
351
|
+
if (!yes) {
|
|
352
|
+
if (!await require_commands_aws_utils_tty.promptYesNo({
|
|
353
|
+
message: overwrites.length > 0 ? "Overwrite / set this secret?" : "Set this secret?",
|
|
354
|
+
defaultYes: false
|
|
355
|
+
})) {
|
|
356
|
+
console.log("Aborted.");
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
console.log("");
|
|
360
|
+
}
|
|
361
|
+
for (const config of targetConfigs) {
|
|
362
|
+
setSecret({
|
|
363
|
+
project,
|
|
364
|
+
config,
|
|
365
|
+
name,
|
|
366
|
+
value,
|
|
367
|
+
verbose
|
|
368
|
+
});
|
|
369
|
+
console.log(chalk.default.green(` ✓ set ${name} on ${project}/${config}`));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
//#endregion
|
|
373
|
+
exports.getSecret = getSecret;
|
|
374
|
+
exports.listConfigs = listConfigs;
|
|
375
|
+
exports.listEnvironments = listEnvironments;
|
|
376
|
+
exports.listProjects = listProjects;
|
|
377
|
+
exports.setSecret = setSecret;
|
|
378
|
+
exports.setSecretInteractive = setSecretInteractive;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} DopplerProject
|
|
3
|
+
* @property {string} id
|
|
4
|
+
* @property {string} name
|
|
5
|
+
* @property {string} [description]
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} DopplerEnvironment
|
|
9
|
+
* @property {string} id
|
|
10
|
+
* @property {string} name
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} DopplerConfig
|
|
14
|
+
* @property {string} name
|
|
15
|
+
* @property {string} environment
|
|
16
|
+
* @property {boolean} [root]
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* List Doppler projects (paginated until exhausted or cap).
|
|
20
|
+
* @param {{ verbose?: boolean; limit?: number }} [params]
|
|
21
|
+
* @returns {DopplerProject[]}
|
|
22
|
+
*/
|
|
23
|
+
export function listProjects(params?: {
|
|
24
|
+
verbose?: boolean;
|
|
25
|
+
limit?: number;
|
|
26
|
+
}): DopplerProject[];
|
|
27
|
+
/**
|
|
28
|
+
* List environments for a project.
|
|
29
|
+
* @param {{ project: string; verbose?: boolean }} params
|
|
30
|
+
* @returns {DopplerEnvironment[]}
|
|
31
|
+
*/
|
|
32
|
+
export function listEnvironments(params: {
|
|
33
|
+
project: string;
|
|
34
|
+
verbose?: boolean;
|
|
35
|
+
}): DopplerEnvironment[];
|
|
36
|
+
/**
|
|
37
|
+
* List configs for a project, optionally filtered by environment.
|
|
38
|
+
* @param {{ project: string; environment?: string; verbose?: boolean }} params
|
|
39
|
+
* @returns {DopplerConfig[]}
|
|
40
|
+
*/
|
|
41
|
+
export function listConfigs(params: {
|
|
42
|
+
project: string;
|
|
43
|
+
environment?: string;
|
|
44
|
+
verbose?: boolean;
|
|
45
|
+
}): DopplerConfig[];
|
|
46
|
+
/**
|
|
47
|
+
* Get an existing secret value (raw), or null if missing.
|
|
48
|
+
* @param {{
|
|
49
|
+
* project: string;
|
|
50
|
+
* config: string;
|
|
51
|
+
* name: string;
|
|
52
|
+
* verbose?: boolean;
|
|
53
|
+
* }} params
|
|
54
|
+
* @returns {string | null}
|
|
55
|
+
*/
|
|
56
|
+
export function getSecret(params: {
|
|
57
|
+
project: string;
|
|
58
|
+
config: string;
|
|
59
|
+
name: string;
|
|
60
|
+
verbose?: boolean;
|
|
61
|
+
}): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Set a secret via stdin so values need no shell escaping.
|
|
64
|
+
* @param {{
|
|
65
|
+
* project: string;
|
|
66
|
+
* config: string;
|
|
67
|
+
* name: string;
|
|
68
|
+
* value: string;
|
|
69
|
+
* verbose?: boolean;
|
|
70
|
+
* }} params
|
|
71
|
+
*/
|
|
72
|
+
export function setSecret(params: {
|
|
73
|
+
project: string;
|
|
74
|
+
config: string;
|
|
75
|
+
name: string;
|
|
76
|
+
value: string;
|
|
77
|
+
verbose?: boolean;
|
|
78
|
+
}): void;
|
|
79
|
+
/**
|
|
80
|
+
* Interactively (or via flags) set a Doppler secret on one or more configs.
|
|
81
|
+
* @param {{
|
|
82
|
+
* project?: string;
|
|
83
|
+
* environment?: string;
|
|
84
|
+
* config?: string;
|
|
85
|
+
* name?: string;
|
|
86
|
+
* value?: string;
|
|
87
|
+
* yes?: boolean;
|
|
88
|
+
* verbose?: boolean;
|
|
89
|
+
* }} options
|
|
90
|
+
*/
|
|
91
|
+
export function setSecretInteractive(options: {
|
|
92
|
+
project?: string;
|
|
93
|
+
environment?: string;
|
|
94
|
+
config?: string;
|
|
95
|
+
name?: string;
|
|
96
|
+
value?: string;
|
|
97
|
+
yes?: boolean;
|
|
98
|
+
verbose?: boolean;
|
|
99
|
+
}): Promise<void>;
|
|
100
|
+
export type DopplerProject = {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
description?: string | undefined;
|
|
104
|
+
};
|
|
105
|
+
export type DopplerEnvironment = {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
};
|
|
109
|
+
export type DopplerConfig = {
|
|
110
|
+
name: string;
|
|
111
|
+
environment: string;
|
|
112
|
+
root?: boolean | undefined;
|
|
113
|
+
};
|
|
@@ -1,12 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../../../__chunks/VH7oDXx4.cjs");
|
|
3
|
+
let chalk = require("chalk");
|
|
4
|
+
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
5
|
+
let child_process = require("child_process");
|
|
6
|
+
//#region src/commands/doppler/utils/exec.js
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {'silent' | 'verbose' | 'default'} VerbosityLevel
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} ExecOptions
|
|
12
|
+
* @property {'string' | 'number' | 'json'} [stdoutParser='string'] - How to parse stdout
|
|
13
|
+
* @property {boolean} [throwOnError=true] - Whether to throw on error
|
|
14
|
+
* @property {VerbosityLevel} [verbosity='default'] - Output verbosity level
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Execute a command and parse the output
|
|
18
|
+
* @param {string} command - Command to execute
|
|
19
|
+
* @param {import('child_process').ExecSyncOptions & ExecOptions} [options={}] - Execution options (inherits all execSync options + custom options)
|
|
20
|
+
* @returns {string | number | any} - Parsed output based on stdoutParser
|
|
21
|
+
*/
|
|
22
|
+
function exec(command, options = {}) {
|
|
23
|
+
const { stdoutParser = "string", throwOnError = true, verbosity = "default", stdio: userStdio, ...execSyncOptions } = options;
|
|
24
|
+
try {
|
|
25
|
+
if (verbosity === "verbose") console.log(chalk.default.gray(` Executing: ${command}`));
|
|
26
|
+
/** @type {import('child_process').StdioOptions} */
|
|
27
|
+
let stdio;
|
|
28
|
+
if (userStdio) stdio = userStdio;
|
|
29
|
+
else if (verbosity === "verbose") stdio = "inherit";
|
|
30
|
+
else if (verbosity === "silent") stdio = "pipe";
|
|
31
|
+
else stdio = [
|
|
32
|
+
"pipe",
|
|
33
|
+
"pipe",
|
|
34
|
+
"pipe"
|
|
35
|
+
];
|
|
36
|
+
const result = (0, child_process.execSync)(command, {
|
|
37
|
+
encoding: "utf-8",
|
|
38
|
+
stdio,
|
|
39
|
+
...execSyncOptions
|
|
40
|
+
});
|
|
41
|
+
if (stdio === "inherit") return stdoutParser === "string" ? "" : void 0;
|
|
42
|
+
if (!result || typeof result === "string" && !result.trim()) return stdoutParser === "string" ? "" : void 0;
|
|
43
|
+
switch (stdoutParser) {
|
|
44
|
+
case "json": try {
|
|
45
|
+
return JSON.parse(result);
|
|
46
|
+
} catch (parseError) {
|
|
47
|
+
if (throwOnError) throw new Error(`Failed to parse JSON output: ${parseError.message}`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
case "number": {
|
|
51
|
+
const num = parseFloat(result.trim());
|
|
52
|
+
if (isNaN(num)) {
|
|
53
|
+
if (throwOnError) throw new Error(`Failed to parse number from output: ${result}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
return num;
|
|
57
|
+
}
|
|
58
|
+
default: return result;
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (!throwOnError) return;
|
|
62
|
+
if (error.stderr) throw new Error(error.stderr.toString());
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Execute a command with string output
|
|
68
|
+
* @param {string} command - Command to execute
|
|
69
|
+
* @param {import('child_process').ExecSyncOptions & ExecOptions} [options] - Execution options
|
|
70
|
+
* @returns {string}
|
|
71
|
+
*/
|
|
72
|
+
function execString(command, options = {}) {
|
|
73
|
+
return exec(command, {
|
|
74
|
+
...options,
|
|
75
|
+
stdoutParser: "string"
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Execute a command with JSON output
|
|
80
|
+
* @param {string} command - Command to execute
|
|
81
|
+
* @param {import('child_process').ExecSyncOptions & ExecOptions} [options] - Execution options
|
|
82
|
+
* @returns {any}
|
|
83
|
+
*/
|
|
84
|
+
function execJson(command, options = {}) {
|
|
85
|
+
return exec(command, {
|
|
86
|
+
...options,
|
|
87
|
+
stdoutParser: "json"
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Execute a command with number output
|
|
92
|
+
* @param {string} command - Command to execute
|
|
93
|
+
* @param {import('child_process').ExecSyncOptions & ExecOptions} [options] - Execution options
|
|
94
|
+
* @returns {number}
|
|
95
|
+
*/
|
|
96
|
+
function execNumber(command, options = {}) {
|
|
97
|
+
return exec(command, {
|
|
98
|
+
...options,
|
|
99
|
+
stdoutParser: "number"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
exports.exec = exec;
|
|
104
|
+
exports.execJson = execJson;
|
|
105
|
+
exports.execNumber = execNumber;
|
|
106
|
+
exports.execString = execString;
|