@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
|
@@ -1,30 +1,412 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../../__chunks/VH7oDXx4.cjs");
|
|
3
|
+
const require_commands_doppler_utils_exec = require("./utils/exec.cjs");
|
|
4
|
+
let chalk = require("chalk");
|
|
5
|
+
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
6
|
+
let child_process = require("child_process");
|
|
7
|
+
let fs = require("fs");
|
|
8
|
+
let path = require("path");
|
|
9
|
+
let readline = require("readline");
|
|
10
|
+
let os = require("os");
|
|
11
|
+
//#region src/commands/doppler/utils.js
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import('./utils/exec.js').VerbosityLevel} VerbosityLevel
|
|
14
|
+
* @typedef {import('./utils/exec.js').ExecOptions} ExecOptions
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_DOPPLER_ENVIRONMENT = "dev";
|
|
17
|
+
const DOPPLER_INTERNAL_KEYS = /* @__PURE__ */ new Set([
|
|
18
|
+
"DOPPLER_CONFIG",
|
|
19
|
+
"DOPPLER_ENVIRONMENT",
|
|
20
|
+
"DOPPLER_PROJECT"
|
|
21
|
+
]);
|
|
22
|
+
/**
|
|
23
|
+
* Execute a doppler command and return the result
|
|
24
|
+
* @param {string[]} args - Command arguments
|
|
25
|
+
* @param {'string' | 'json'} parser - How to parse the output
|
|
26
|
+
* @param {boolean} silent - Suppress output
|
|
27
|
+
* @param {boolean} verbose - Show verbose output
|
|
28
|
+
* @returns {string | any}
|
|
29
|
+
*/
|
|
30
|
+
function execDoppler(args, parser = "string", silent = false, verbose = false) {
|
|
31
|
+
const command = `doppler ${args.join(" ")}`;
|
|
32
|
+
/** @type {import('./utils/exec.js').VerbosityLevel} */
|
|
33
|
+
let verbosity = "default";
|
|
34
|
+
if (verbose) verbosity = "verbose";
|
|
35
|
+
else if (silent) verbosity = "silent";
|
|
36
|
+
return require_commands_doppler_utils_exec.exec(command, {
|
|
37
|
+
verbosity,
|
|
38
|
+
stdoutParser: parser,
|
|
39
|
+
throwOnError: true
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if the Doppler CLI is installed and the user is logged in.
|
|
44
|
+
* Does not require a local project setup (doppler setup).
|
|
45
|
+
* @param {boolean} verbose - Show verbose output
|
|
46
|
+
*/
|
|
47
|
+
function checkDopplerAuth(verbose = false) {
|
|
48
|
+
if (verbose) console.log(chalk.default.blue("\nš Checking Doppler authentication..."));
|
|
49
|
+
try {
|
|
50
|
+
(0, child_process.execSync)("which doppler", { stdio: "pipe" });
|
|
51
|
+
if (verbose) console.log(chalk.default.green(" ā Doppler CLI is installed"));
|
|
52
|
+
} catch {
|
|
53
|
+
throw new Error("Doppler is not installed. Please install Doppler (brew install dopplerhq/cli/doppler), login, and try again.");
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
execDoppler(["me"], "string", true, verbose);
|
|
57
|
+
if (verbose) console.log(chalk.default.green(" ā Doppler is authenticated"));
|
|
58
|
+
} catch {
|
|
59
|
+
throw new Error("Doppler is not logged in. Please run 'doppler login' and try again.");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if doppler CLI is installed, logged in, and a project is configured.
|
|
64
|
+
* @param {boolean} verbose - Show verbose output
|
|
65
|
+
*/
|
|
66
|
+
function checkDependencies(verbose = false) {
|
|
67
|
+
checkDopplerAuth(verbose);
|
|
68
|
+
if (verbose) console.log(chalk.default.blue("\nš Checking Doppler project setup..."));
|
|
69
|
+
try {
|
|
70
|
+
execDoppler(["configs", "--json"], "json", true, verbose);
|
|
71
|
+
if (verbose) console.log(chalk.default.green(" ā Doppler project is configured"));
|
|
72
|
+
} catch {
|
|
73
|
+
throw new Error("Doppler is not configured. Please run 'doppler setup' and try again.");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get list of configurations based on environments parameter
|
|
78
|
+
* @param {string} environments - Comma-separated env names ('all', 'dev', 'dev,stg', etc.)
|
|
79
|
+
* @param {boolean} verbose - Show verbose output
|
|
80
|
+
* @param {string | null} project - Optional Doppler project name
|
|
81
|
+
* @returns {string[]}
|
|
82
|
+
*/
|
|
83
|
+
function getConfigs(environments, verbose = false, project = null) {
|
|
84
|
+
if (verbose) console.log(chalk.default.blue(`\nš Resolving configurations for environments: ${chalk.default.cyan(environments)}`));
|
|
85
|
+
const configArgs = ["configs", "--json"];
|
|
86
|
+
if (project) configArgs.push("--project", project);
|
|
87
|
+
const availableConfigs = execDoppler(configArgs, "json", true, verbose);
|
|
88
|
+
const configNames = Array.isArray(availableConfigs) ? availableConfigs.map((config) => config.name) : [];
|
|
89
|
+
if (verbose && configNames.length > 0) console.log(chalk.default.gray(` Available configurations: ${configNames.join(", ")}`));
|
|
90
|
+
if (environments === "all") {
|
|
91
|
+
if (configNames.length === 0) throw new Error("No configurations found in Doppler");
|
|
92
|
+
if (verbose) console.log(chalk.default.green(` ā Using all ${configNames.length} configurations`));
|
|
93
|
+
return configNames;
|
|
94
|
+
}
|
|
95
|
+
const requested = environments.split(",").map((e) => e.trim());
|
|
96
|
+
if (configNames.length > 0) {
|
|
97
|
+
const missing = requested.filter((e) => !configNames.includes(e));
|
|
98
|
+
if (missing.length > 0) throw new Error(`Configurations not found: ${missing.join(", ")}. Available: ${configNames.join(", ")}`);
|
|
99
|
+
}
|
|
100
|
+
if (verbose) console.log(chalk.default.green(` ā Using configurations: ${requested.join(", ")}`));
|
|
101
|
+
return requested;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Normalize escape sequences in file content
|
|
105
|
+
* @param {string} content - File content
|
|
106
|
+
* @returns {string}
|
|
107
|
+
*/
|
|
108
|
+
function normalizeEscapeSequences(content) {
|
|
109
|
+
return content.replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\r/g, "\r");
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a unified diff between two strings
|
|
113
|
+
* @param {string} oldContent - Original content
|
|
114
|
+
* @param {string} newContent - New content
|
|
115
|
+
* @returns {string[]}
|
|
116
|
+
*/
|
|
117
|
+
function createDiff(oldContent, newContent) {
|
|
118
|
+
const oldLines = oldContent.split("\n");
|
|
119
|
+
const newLines = newContent.split("\n");
|
|
120
|
+
const diff = [];
|
|
121
|
+
const maxLines = Math.max(oldLines.length, newLines.length);
|
|
122
|
+
for (let i = 0; i < maxLines; i++) {
|
|
123
|
+
const oldLine = oldLines[i] || "";
|
|
124
|
+
const newLine = newLines[i] || "";
|
|
125
|
+
if (oldLine !== newLine) {
|
|
126
|
+
if (oldLine && !newLine) diff.push(`-${oldLine}`);
|
|
127
|
+
else if (!oldLine && newLine) diff.push(`+${newLine}`);
|
|
128
|
+
else {
|
|
129
|
+
diff.push(`-${oldLine}`);
|
|
130
|
+
diff.push(`+${newLine}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return diff;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Prompt user for confirmation
|
|
138
|
+
* @param {string} message - Prompt message
|
|
139
|
+
* @returns {Promise<boolean>}
|
|
140
|
+
*/
|
|
141
|
+
function promptConfirmation(message) {
|
|
142
|
+
return new Promise((resolve) => {
|
|
143
|
+
const rl = (0, readline.createInterface)({
|
|
144
|
+
input: process.stdin,
|
|
145
|
+
output: process.stdout
|
|
146
|
+
});
|
|
147
|
+
rl.question(message, (answer) => {
|
|
148
|
+
rl.close();
|
|
149
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Download configurations from Doppler
|
|
155
|
+
* @param {{
|
|
156
|
+
* verbose: boolean;
|
|
157
|
+
* environments: string;
|
|
158
|
+
* }} options - Options for downloading configurations
|
|
159
|
+
*/
|
|
160
|
+
async function downloadConfigs(options) {
|
|
161
|
+
const { environments, verbose } = options;
|
|
162
|
+
const actualEnvironments = environments ?? DEFAULT_DOPPLER_ENVIRONMENT;
|
|
163
|
+
const configs = getConfigs(actualEnvironments, verbose);
|
|
164
|
+
if (verbose) console.log(chalk.default.blue(`\nā¬ļø Starting download process for ${configs.length} configuration(s)...`));
|
|
165
|
+
if (configs.length === 1 && actualEnvironments !== "all") console.log("You can use -e all to download all configurations, or -e dev,stg for specific environments.");
|
|
166
|
+
for (const config of configs) {
|
|
167
|
+
const envFile = `.env.${config}`;
|
|
168
|
+
const backupFile = `${envFile}.backup`;
|
|
169
|
+
let backupMsg = "";
|
|
170
|
+
if (verbose) console.log(chalk.default.blue(`\nš¦ Processing config: ${chalk.default.cyan(config)}`));
|
|
171
|
+
try {
|
|
172
|
+
if ((0, fs.existsSync)(envFile)) {
|
|
173
|
+
if (verbose) console.log(chalk.default.gray(` Creating backup: ${backupFile}`));
|
|
174
|
+
(0, fs.renameSync)(envFile, backupFile);
|
|
175
|
+
backupMsg = "Backed up existing file, ";
|
|
176
|
+
}
|
|
177
|
+
if (verbose) console.log(chalk.default.gray(` Downloading secrets from Doppler...`));
|
|
178
|
+
const content = execDoppler([
|
|
179
|
+
"secrets",
|
|
180
|
+
"download",
|
|
181
|
+
"--no-file",
|
|
182
|
+
"--format",
|
|
183
|
+
"env",
|
|
184
|
+
"--config",
|
|
185
|
+
config
|
|
186
|
+
], "string", !verbose, verbose);
|
|
187
|
+
if (typeof content === "string") {
|
|
188
|
+
(0, fs.writeFileSync)(envFile, content, "utf-8");
|
|
189
|
+
if (verbose) console.log(chalk.default.gray(` Written to: ${envFile}`));
|
|
190
|
+
} else throw new Error("Invalid content received from Doppler");
|
|
191
|
+
console.log(`Config ${chalk.default.blue(config)}: ${backupMsg}downloaded successfully to ${chalk.default.green(envFile)}`);
|
|
192
|
+
if (config === "dev" && !(0, fs.existsSync)(".env")) {
|
|
193
|
+
(0, fs.copyFileSync)(envFile, ".env");
|
|
194
|
+
console.log(`Copied ${chalk.default.green(".env.dev")} to ${chalk.default.green(".env")}`);
|
|
195
|
+
}
|
|
196
|
+
if ((0, fs.existsSync)(backupFile)) {
|
|
197
|
+
if (verbose) console.log(chalk.default.gray(` Removing backup file`));
|
|
198
|
+
(0, fs.unlinkSync)(backupFile);
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error(`Failed to download ${config}: ${error?.message || error}`);
|
|
202
|
+
if ((0, fs.existsSync)(backupFile)) {
|
|
203
|
+
(0, fs.renameSync)(backupFile, envFile);
|
|
204
|
+
console.log(`Restored backup for ${envFile}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Upload configurations to Doppler
|
|
211
|
+
* @param {{
|
|
212
|
+
* environments: string;
|
|
213
|
+
* verbose: boolean;
|
|
214
|
+
* }} options - Options for uploading configurations
|
|
215
|
+
*/
|
|
216
|
+
async function uploadConfigs(options) {
|
|
217
|
+
const { environments, verbose } = options;
|
|
218
|
+
const configs = getConfigs(environments, verbose);
|
|
219
|
+
if (verbose) console.log(chalk.default.blue(`\nā¬ļø Starting upload process for ${configs.length} configuration(s)...`));
|
|
220
|
+
for (const config of configs) {
|
|
221
|
+
const envFile = `.env.${config}`;
|
|
222
|
+
const backupFile = `${envFile}.doppler`;
|
|
223
|
+
const normalizedFile = `${envFile}.normalized`;
|
|
224
|
+
if (verbose) console.log(chalk.default.blue(`\nš¦ Processing config: ${chalk.default.cyan(config)}`));
|
|
225
|
+
try {
|
|
226
|
+
if (!(0, fs.existsSync)(envFile)) {
|
|
227
|
+
console.log(`Config ${config}: ${chalk.default.green(envFile)} does not exist. Skipping upload.`);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (verbose) console.log(chalk.default.gray(` Creating backup of current Doppler config...`));
|
|
231
|
+
try {
|
|
232
|
+
const backupContent = execDoppler([
|
|
233
|
+
"secrets",
|
|
234
|
+
"download",
|
|
235
|
+
"--no-file",
|
|
236
|
+
"--format",
|
|
237
|
+
"env",
|
|
238
|
+
"--config",
|
|
239
|
+
config
|
|
240
|
+
], "string", !verbose, verbose);
|
|
241
|
+
if (typeof backupContent === "string") {
|
|
242
|
+
(0, fs.writeFileSync)(backupFile, backupContent, "utf-8");
|
|
243
|
+
if (verbose) console.log(chalk.default.gray(` Backup created: ${backupFile}`));
|
|
244
|
+
} else throw new Error("Invalid backup content received from Doppler");
|
|
245
|
+
} catch {
|
|
246
|
+
console.log(`Config ${config}: Failed to create backup. Skipping upload.`);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (verbose) console.log(chalk.default.gray(` Reading local file: ${envFile}`));
|
|
250
|
+
const normalizedContent = normalizeEscapeSequences((0, fs.readFileSync)(envFile, "utf-8"));
|
|
251
|
+
(0, fs.writeFileSync)(normalizedFile, normalizedContent, "utf-8");
|
|
252
|
+
if (verbose) console.log(chalk.default.gray(` Comparing local changes with Doppler...`));
|
|
253
|
+
const diff = createDiff((0, fs.readFileSync)(backupFile, "utf-8"), normalizedContent);
|
|
254
|
+
if (diff.length === 0) {
|
|
255
|
+
console.log(`Config ${config}: No differences found. Skipping upload.`);
|
|
256
|
+
(0, fs.unlinkSync)(backupFile);
|
|
257
|
+
(0, fs.unlinkSync)(normalizedFile);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
if (verbose) console.log(chalk.default.yellow(` Found ${diff.length} line changes`));
|
|
261
|
+
console.log("\nChanges to be uploaded:");
|
|
262
|
+
for (const line of diff) if (line.startsWith("-")) console.log(chalk.default.red(line));
|
|
263
|
+
else if (line.startsWith("+")) console.log(chalk.default.green(line));
|
|
264
|
+
if (!await promptConfirmation("\nDo you want to proceed with the upload? (y/n) ")) {
|
|
265
|
+
console.log(`Upload cancelled for ${chalk.default.green(envFile)}`);
|
|
266
|
+
(0, fs.unlinkSync)(backupFile);
|
|
267
|
+
(0, fs.unlinkSync)(normalizedFile);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (verbose) console.log(chalk.default.gray(` Uploading to Doppler...`));
|
|
271
|
+
try {
|
|
272
|
+
execDoppler([
|
|
273
|
+
"secrets",
|
|
274
|
+
"upload",
|
|
275
|
+
normalizedFile,
|
|
276
|
+
"--config",
|
|
277
|
+
config,
|
|
278
|
+
"--silent"
|
|
279
|
+
], "string", !verbose, verbose);
|
|
280
|
+
if (config === "dev") console.log(`Config ${chalk.default.blue(config)}: Successfully uploaded ${chalk.default.green(envFile)}`);
|
|
281
|
+
else console.log(`Config ${config}: Successfully uploaded ${chalk.default.green(envFile)}`);
|
|
282
|
+
} catch {
|
|
283
|
+
console.error(`Config ${config}: Failed to upload ${chalk.default.green(envFile)}. Restoring previous configuration.`);
|
|
284
|
+
try {
|
|
285
|
+
if (verbose) console.log(chalk.default.gray(` Restoring previous configuration...`));
|
|
286
|
+
execDoppler([
|
|
287
|
+
"secrets",
|
|
288
|
+
"upload",
|
|
289
|
+
backupFile,
|
|
290
|
+
"--config",
|
|
291
|
+
config,
|
|
292
|
+
"--silent"
|
|
293
|
+
], "string", !verbose, verbose);
|
|
294
|
+
console.log(`Config ${config}: Successfully restored previous configuration`);
|
|
295
|
+
} catch {
|
|
296
|
+
console.error(`Config ${config}: Failed to restore previous configuration`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if ((0, fs.existsSync)(backupFile)) (0, fs.unlinkSync)(backupFile);
|
|
300
|
+
if ((0, fs.existsSync)(normalizedFile)) (0, fs.unlinkSync)(normalizedFile);
|
|
301
|
+
} catch (error) {
|
|
302
|
+
console.error(`Error processing config ${config}: ${error?.message || error}`);
|
|
303
|
+
if ((0, fs.existsSync)(backupFile)) (0, fs.unlinkSync)(backupFile);
|
|
304
|
+
if ((0, fs.existsSync)(normalizedFile)) (0, fs.unlinkSync)(normalizedFile);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Clone secrets from one Doppler project to another
|
|
310
|
+
* @param {{
|
|
311
|
+
* from: string;
|
|
312
|
+
* to: string;
|
|
313
|
+
* environments: string;
|
|
314
|
+
* force: boolean;
|
|
315
|
+
* verbose: boolean;
|
|
316
|
+
* }} options
|
|
317
|
+
*/
|
|
318
|
+
async function cloneProject({ from, to, environments, force, verbose }) {
|
|
319
|
+
if (verbose) console.log(chalk.default.blue(`\nš Cloning from ${chalk.default.cyan(from)} to ${chalk.default.cyan(to)}...`));
|
|
320
|
+
const configsToClone = getConfigs(environments, verbose, from);
|
|
321
|
+
if (configsToClone.length === 0) throw new Error(`No configurations found in source project "${from}"`);
|
|
322
|
+
const targetConfigsRaw = execDoppler([
|
|
323
|
+
"configs",
|
|
324
|
+
"--json",
|
|
325
|
+
"--project",
|
|
326
|
+
to
|
|
327
|
+
], "json", true, verbose);
|
|
328
|
+
const targetConfigNames = Array.isArray(targetConfigsRaw) ? targetConfigsRaw.map((c) => c.name) : [];
|
|
329
|
+
const missingInTarget = configsToClone.filter((c) => !targetConfigNames.includes(c));
|
|
330
|
+
if (missingInTarget.length > 0) throw new Error(`Configs missing in target project "${to}": ${missingInTarget.join(", ")}. Create them in Doppler first.`);
|
|
331
|
+
for (const config of configsToClone) {
|
|
332
|
+
if (verbose) console.log(chalk.default.blue(`\nš¦ Processing config: ${chalk.default.cyan(config)}`));
|
|
333
|
+
const sourceSecrets = execDoppler([
|
|
334
|
+
"secrets",
|
|
335
|
+
"--json",
|
|
336
|
+
"--project",
|
|
337
|
+
from,
|
|
338
|
+
"--config",
|
|
339
|
+
config
|
|
340
|
+
], "json", true, verbose);
|
|
341
|
+
const sourceKeys = sourceSecrets ? Object.keys(sourceSecrets).filter((k) => !DOPPLER_INTERNAL_KEYS.has(k)) : [];
|
|
342
|
+
const targetSecrets = execDoppler([
|
|
343
|
+
"secrets",
|
|
344
|
+
"--json",
|
|
345
|
+
"--project",
|
|
346
|
+
to,
|
|
347
|
+
"--config",
|
|
348
|
+
config
|
|
349
|
+
], "json", true, verbose);
|
|
350
|
+
const targetKeys = targetSecrets ? Object.keys(targetSecrets) : [];
|
|
351
|
+
const conflicts = sourceKeys.filter((k) => targetKeys.includes(k));
|
|
352
|
+
if (conflicts.length > 0) {
|
|
353
|
+
if (process.env["CI"]) throw new Error(`Config "${config}" has ${conflicts.length} conflicting key(s) in target: ${conflicts.join(", ")}`);
|
|
354
|
+
if (!force) {
|
|
355
|
+
console.log(`\nConfig ${chalk.default.cyan(config)}: ${conflicts.length} key(s) already exist in ${chalk.default.cyan(to)}:`);
|
|
356
|
+
conflicts.forEach((k) => console.log(chalk.default.yellow(` ⢠${k}`)));
|
|
357
|
+
if (!await promptConfirmation(`\nOverwrite these keys in "${to}/${config}"? (y/n) `)) {
|
|
358
|
+
console.log(`Skipped ${chalk.default.blue(config)}`);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const tmpFile = (0, path.join)((0, os.tmpdir)(), `doppler-clone-${config}-${Date.now()}.env`);
|
|
364
|
+
try {
|
|
365
|
+
const content = execDoppler([
|
|
366
|
+
"secrets",
|
|
367
|
+
"download",
|
|
368
|
+
"--no-file",
|
|
369
|
+
"--format",
|
|
370
|
+
"env",
|
|
371
|
+
"--project",
|
|
372
|
+
from,
|
|
373
|
+
"--config",
|
|
374
|
+
config
|
|
375
|
+
], "string", true, verbose);
|
|
376
|
+
if (typeof content !== "string" || !content) throw new Error(`No secrets returned for config "${config}"`);
|
|
377
|
+
const filtered = content.split("\n").filter((line) => {
|
|
378
|
+
const key = line.split("=")[0] ?? "";
|
|
379
|
+
return !DOPPLER_INTERNAL_KEYS.has(key);
|
|
380
|
+
}).join("\n");
|
|
381
|
+
(0, fs.writeFileSync)(tmpFile, filtered, "utf-8");
|
|
382
|
+
execDoppler([
|
|
383
|
+
"secrets",
|
|
384
|
+
"upload",
|
|
385
|
+
tmpFile,
|
|
386
|
+
"--project",
|
|
387
|
+
to,
|
|
388
|
+
"--config",
|
|
389
|
+
config,
|
|
390
|
+
"--silent"
|
|
391
|
+
], "string", true, verbose);
|
|
392
|
+
console.log(`Config ${chalk.default.blue(config)}: cloned to ${chalk.default.green(to)}`);
|
|
393
|
+
} finally {
|
|
394
|
+
if ((0, fs.existsSync)(tmpFile)) (0, fs.unlinkSync)(tmpFile);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
exports.checkDependencies = checkDependencies;
|
|
400
|
+
exports.checkDopplerAuth = checkDopplerAuth;
|
|
401
|
+
exports.cloneProject = cloneProject;
|
|
402
|
+
exports.createDiff = createDiff;
|
|
403
|
+
exports.downloadConfigs = downloadConfigs;
|
|
404
|
+
exports.exec = require_commands_doppler_utils_exec.exec;
|
|
405
|
+
exports.execDoppler = execDoppler;
|
|
406
|
+
exports.execJson = require_commands_doppler_utils_exec.execJson;
|
|
407
|
+
exports.execNumber = require_commands_doppler_utils_exec.execNumber;
|
|
408
|
+
exports.execString = require_commands_doppler_utils_exec.execString;
|
|
409
|
+
exports.getConfigs = getConfigs;
|
|
410
|
+
exports.normalizeEscapeSequences = normalizeEscapeSequences;
|
|
411
|
+
exports.promptConfirmation = promptConfirmation;
|
|
412
|
+
exports.uploadConfigs = uploadConfigs;
|
|
@@ -8,17 +8,24 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export function execDoppler(args: string[], parser?: "string" | "json", silent?: boolean, verbose?: boolean): string | any;
|
|
10
10
|
/**
|
|
11
|
-
* Check if
|
|
11
|
+
* Check if the Doppler CLI is installed and the user is logged in.
|
|
12
|
+
* Does not require a local project setup (doppler setup).
|
|
13
|
+
* @param {boolean} verbose - Show verbose output
|
|
14
|
+
*/
|
|
15
|
+
export function checkDopplerAuth(verbose?: boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* Check if doppler CLI is installed, logged in, and a project is configured.
|
|
12
18
|
* @param {boolean} verbose - Show verbose output
|
|
13
19
|
*/
|
|
14
20
|
export function checkDependencies(verbose?: boolean): void;
|
|
15
21
|
/**
|
|
16
|
-
* Get list of configurations based on
|
|
17
|
-
* @param {string}
|
|
22
|
+
* Get list of configurations based on environments parameter
|
|
23
|
+
* @param {string} environments - Comma-separated env names ('all', 'dev', 'dev,stg', etc.)
|
|
18
24
|
* @param {boolean} verbose - Show verbose output
|
|
25
|
+
* @param {string | null} project - Optional Doppler project name
|
|
19
26
|
* @returns {string[]}
|
|
20
27
|
*/
|
|
21
|
-
export function getConfigs(
|
|
28
|
+
export function getConfigs(environments: string, verbose?: boolean, project?: string | null): string[];
|
|
22
29
|
/**
|
|
23
30
|
* Normalize escape sequences in file content
|
|
24
31
|
* @param {string} content - File content
|
|
@@ -42,22 +49,39 @@ export function promptConfirmation(message: string): Promise<boolean>;
|
|
|
42
49
|
* Download configurations from Doppler
|
|
43
50
|
* @param {{
|
|
44
51
|
* verbose: boolean;
|
|
45
|
-
*
|
|
52
|
+
* environments: string;
|
|
46
53
|
* }} options - Options for downloading configurations
|
|
47
54
|
*/
|
|
48
55
|
export function downloadConfigs(options: {
|
|
49
56
|
verbose: boolean;
|
|
50
|
-
|
|
57
|
+
environments: string;
|
|
51
58
|
}): Promise<void>;
|
|
52
59
|
/**
|
|
53
60
|
* Upload configurations to Doppler
|
|
54
61
|
* @param {{
|
|
55
|
-
*
|
|
62
|
+
* environments: string;
|
|
56
63
|
* verbose: boolean;
|
|
57
64
|
* }} options - Options for uploading configurations
|
|
58
65
|
*/
|
|
59
66
|
export function uploadConfigs(options: {
|
|
60
|
-
|
|
67
|
+
environments: string;
|
|
68
|
+
verbose: boolean;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Clone secrets from one Doppler project to another
|
|
72
|
+
* @param {{
|
|
73
|
+
* from: string;
|
|
74
|
+
* to: string;
|
|
75
|
+
* environments: string;
|
|
76
|
+
* force: boolean;
|
|
77
|
+
* verbose: boolean;
|
|
78
|
+
* }} options
|
|
79
|
+
*/
|
|
80
|
+
export function cloneProject({ from, to, environments, force, verbose }: {
|
|
81
|
+
from: string;
|
|
82
|
+
to: string;
|
|
83
|
+
environments: string;
|
|
84
|
+
force: boolean;
|
|
61
85
|
verbose: boolean;
|
|
62
86
|
}): Promise<void>;
|
|
63
87
|
export type VerbosityLevel = import("./utils/exec.js").VerbosityLevel;
|
|
@@ -1,8 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require(
|
|
5
|
-
require(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../../__chunks/VH7oDXx4.cjs");
|
|
3
|
+
const require_commands_icons_schema = require("./schema.cjs");
|
|
4
|
+
const require_commands_icons_utils = require("./utils.cjs");
|
|
5
|
+
let chalk = require("chalk");
|
|
6
|
+
chalk = require_rolldown_runtime.__toESM(chalk, 1);
|
|
7
|
+
let zod = require("zod");
|
|
8
|
+
//#region src/commands/icons/handler.js
|
|
9
|
+
/**
|
|
10
|
+
* Main icons command handler
|
|
11
|
+
* @param {unknown} options - Command options (will be validated)
|
|
12
|
+
*/
|
|
13
|
+
async function iconsCommand(options) {
|
|
14
|
+
try {
|
|
15
|
+
const validatedOptions = require_commands_icons_schema.iconsCommandOptionsSchema.parse(options);
|
|
16
|
+
if (validatedOptions.help) {
|
|
17
|
+
console.log(chalk.default.bold(`\nUsage: mtn icons <input> [options]`));
|
|
18
|
+
console.log(chalk.default.gray(require_commands_icons_schema.iconsCommandMetadata.description));
|
|
19
|
+
console.log(chalk.default.bold("\nOptions:"));
|
|
20
|
+
Object.entries(require_commands_icons_schema.iconsCommandOptionsSchema.shape).forEach(([key, fieldSchema]) => {
|
|
21
|
+
if (key === "input") return;
|
|
22
|
+
const description = fieldSchema.description || "No description available";
|
|
23
|
+
const optionMeta = require_commands_icons_schema.iconsCommandMetadata.options[key];
|
|
24
|
+
const defaultValue = optionMeta?.default ?? false;
|
|
25
|
+
const alias = optionMeta?.alias ? chalk.default.cyan(`, -${optionMeta.alias}`) : "";
|
|
26
|
+
console.log(chalk.default.cyan(` --${key}`) + alias + ` ${description} (default: ${defaultValue})`);
|
|
27
|
+
});
|
|
28
|
+
console.log("");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { input, channels, iconTypes, verbose } = validatedOptions;
|
|
32
|
+
if (verbose) {
|
|
33
|
+
console.log(chalk.default.blue("\nš± Icon Generation"));
|
|
34
|
+
console.log(chalk.default.gray(` Input directory: ${input}`));
|
|
35
|
+
console.log(chalk.default.gray(` Channels: ${channels.join(", ")}`));
|
|
36
|
+
console.log(chalk.default.gray(` Icon types: ${iconTypes.join(", ")}`));
|
|
37
|
+
}
|
|
38
|
+
require_commands_icons_utils.checkDependencies(verbose);
|
|
39
|
+
require_commands_icons_utils.validateBaseIcons(input, iconTypes, verbose);
|
|
40
|
+
const result = require_commands_icons_utils.generateAllIcons({
|
|
41
|
+
baseDir: input,
|
|
42
|
+
channels,
|
|
43
|
+
iconTypes,
|
|
44
|
+
verbose
|
|
45
|
+
});
|
|
46
|
+
console.log(chalk.default.bold("\nš Summary:"));
|
|
47
|
+
console.log(chalk.default.green(` ā Successfully generated: ${result.success.length} icon(s)`));
|
|
48
|
+
if (result.failed.length > 0) {
|
|
49
|
+
console.log(chalk.default.red(` ā Failed: ${result.failed.length} icon(s)`));
|
|
50
|
+
result.failed.forEach(({ icon, error }) => {
|
|
51
|
+
console.log(chalk.default.red(` - ${icon}: ${error}`));
|
|
52
|
+
});
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
console.log(chalk.default.green(`\nā
All icons generated successfully!`));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error instanceof zod.ZodError) {
|
|
58
|
+
console.error(chalk.default.red(`\nā Invalid command options:`));
|
|
59
|
+
error.errors.forEach((err) => {
|
|
60
|
+
console.error(chalk.default.red(` ${err.path.join(".")}: ${err.message}`));
|
|
61
|
+
});
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
const verbose = options?.verbose || false;
|
|
65
|
+
console.error(chalk.default.red(`\nā Icon generation failed:`));
|
|
66
|
+
if (error instanceof Error) {
|
|
67
|
+
console.error(chalk.default.red(` ${error.message}`));
|
|
68
|
+
if (verbose && error.stack) {
|
|
69
|
+
console.error(chalk.default.gray("\nStack trace:"));
|
|
70
|
+
console.error(chalk.default.gray(error.stack));
|
|
71
|
+
}
|
|
72
|
+
} else console.error(chalk.default.red(` ${String(error)}`));
|
|
73
|
+
console.error(chalk.default.yellow("\nš” Troubleshooting tips:"));
|
|
74
|
+
console.error(chalk.default.yellow(" ⢠Ensure ImageMagick is installed (brew install imagemagick)"));
|
|
75
|
+
console.error(chalk.default.yellow(" ⢠Make sure icon.png and adaptive-icon.png exist in the input directory"));
|
|
76
|
+
console.error(chalk.default.yellow(" ⢠Verify the input directory path is correct"));
|
|
77
|
+
console.error(chalk.default.yellow(" ⢠Use --verbose for detailed error information\n"));
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
exports.iconsCommand = iconsCommand;
|
|
@@ -1,31 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _J36P6UNEcjs = require('../../__chunks/J36P6UNE.cjs');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
exports.CHANNELS = _J36P6UNEcjs.CHANNELS; exports.CHANNEL_TEXT_MAP = _J36P6UNEcjs.CHANNEL_TEXT_MAP; exports.ICON_SIZE_MAP = _J36P6UNEcjs.ICON_SIZE_MAP; exports.ICON_TYPES = _J36P6UNEcjs.ICON_TYPES; exports.checkDependencies = _4SFWHCB3cjs.checkDependencies; exports.generateAllIcons = _4SFWHCB3cjs.generateAllIcons; exports.generateIcon = _4SFWHCB3cjs.generateIcon; exports.iconsCommand = _INFOPAHNcjs.iconsCommand; exports.iconsCommandMetadata = _J36P6UNEcjs.iconsCommandMetadata; exports.iconsCommandOptionsSchema = _J36P6UNEcjs.iconsCommandOptionsSchema; exports.validateBaseIcons = _4SFWHCB3cjs.validateBaseIcons;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commands_icons_schema = require("./schema.cjs");
|
|
3
|
+
const require_commands_icons_utils = require("./utils.cjs");
|
|
4
|
+
const require_commands_icons_handler = require("./handler.cjs");
|
|
5
|
+
exports.CHANNELS = require_commands_icons_schema.CHANNELS;
|
|
6
|
+
exports.CHANNEL_TEXT_MAP = require_commands_icons_schema.CHANNEL_TEXT_MAP;
|
|
7
|
+
exports.ICON_SIZE_MAP = require_commands_icons_schema.ICON_SIZE_MAP;
|
|
8
|
+
exports.ICON_TYPES = require_commands_icons_schema.ICON_TYPES;
|
|
9
|
+
exports.checkDependencies = require_commands_icons_utils.checkDependencies;
|
|
10
|
+
exports.generateAllIcons = require_commands_icons_utils.generateAllIcons;
|
|
11
|
+
exports.generateIcon = require_commands_icons_utils.generateIcon;
|
|
12
|
+
exports.iconsCommand = require_commands_icons_handler.iconsCommand;
|
|
13
|
+
exports.iconsCommandMetadata = require_commands_icons_schema.iconsCommandMetadata;
|
|
14
|
+
exports.iconsCommandOptionsSchema = require_commands_icons_schema.iconsCommandOptionsSchema;
|
|
15
|
+
exports.validateBaseIcons = require_commands_icons_utils.validateBaseIcons;
|