/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@viewdo/devops-cli@2.0.7/src/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
#!/usr/bin/env node
"use strict";const program=require("commander"),env=require("dotenv"),path=require("path"),{logger:logger}=require("./commands/services/utils");let command_found=!1;env.config({path:path.resolve(process.cwd(),".env")});const runCommand=async(e={},o,a={})=>{let i=Object.assign(a,e.parent||{},e);try{let e=`./commands/${o}`,a=require(e);command_found=!0,"function"==typeof i.version&&(i.version=void 0);let t=await a(i,logger);switch(typeof t){case"object":process.stdout.write(JSON.stringify(t,null,2)),process.exit(0);case"string":process.stdout.write(t),process.exit(0);default:process.exit(t)}}catch(e){console.error(e),process.exit(1)}};program.command("docker-publish").alias("dp").description("Push a docker image to docker hub.").option("-f, --file <file>","Dockerfile path").option("-o, --org <org>","Docker org (Default: viewdo").option("-u, --user <user>","Docker Hub username").option("-p, --password <password>","Docker Hub password").option("-d, --path <path>","Path to image context").option("-i, --image <image>","Image name (Default: Repository slug").option("-v, --version <version>","Image version").option("-b, --build_id <build>","Build ID to tag with").option("-t, --tag <tag>","Tag (Default: latest)").option("-D, --debug","Debug",!1).action((async e=>{await runCommand(e,"docker-publish")})),program.command("gcp-auth").alias("gcr-auth").description("Authenticate gcloud with using a keyfile.").option("-k, --keyfile <keyfile>","Keyfile with service-accoun.json").option("-p, --project <project>","GCR project").option("-D, --debug","Debug",!1).action((async e=>{await runCommand(e,"gcp-auth")})),program.command("gcr-publish").alias("gp").description("Push a docker image to gcr.").option("-f, --file <file>","Dockerfile path").option("-k, --keyfile <keyfile>","Key file with service-account.json").option("-p, --project <project>","GCR project").option("-r, --repository <repository>","GCP repository URL").option("-d, --path <path>","Path to image context").option("-i, --image <image>","Image name (Default: Repository slug").option("-v, --version <version>","Image version").option("-b, --build_id <build>","Build ID to tag with").option("-t, --tag <tag>","Tag (Default: latest)").option("-D, --debug","Debug",!1).option("-a, --build_args <args>","String of build args to pass to build command (i.e. ARG1=value1,ARG2=value2)").action((async e=>{await runCommand(e,"gcr-publish")})),program.command("get-namespace <branch>").alias("ns").description("Translate a namespace from the passed in branch.").action((async(e,o)=>{await runCommand(o,"get-namespace",{branch:e})})),program.command("git-tag [version]").alias("tag").option("-v, --version <version>"," Version").option("-b, --build_id <build>","Build ID").option("-D, --debug","Debug",!1).description("Tags git with the version and build info").action((async(e,o)=>{await runCommand(o,"git-tag",{version:e})})),program.command("git-version").alias("version").option("-v, --version <version>"," Version").description("Uses gitverion to write version.json to the clone directory.").action((async e=>{await runCommand(e,"git-version")})),program.command("jira-release <project> [version]").alias("release").description("Create a release in Jira with the specified version, and release all done issues.").option("-c, --component <component>","Jira Component").option("-D, --debug","Debug",!1).action((async(e,o,a)=>{await runCommand(a,"jira-release",{project:e,version:o})})),program.command("kube-auth").alias("auth").description("Runs the steps to authenticate with k8s in bitbucket.").option("-u, --user <user>","Kube User").option("-t, --token <token>","Kube token").option("-a, --authority <authority>","Kube CA").option("-c, --cluster <cluster>","Kube cluster").option("-s, --server <server>","Kube server").option("-n, --namespace <namespace>","Default namespace").action((async e=>{await runCommand(e,"kube-auth")})),program.command("kube-build [source] [output]").alias("kb").description("Copies all files from .kube to ./kube and replaces all variables.").option("-v, --version <version>","Replace $VERSION").option("-b, --build_id <build>","Replace $BUILD_ID").option("-n, --namespace <namespace>","Replace $NAMESPACE").option("-B, --branch","Replace $BRANCH").action((async(e,o,a)=>{await runCommand(a,"kube-build",{source:e,destination:o})})),program.command("lighthouse-run").alias("lhr").description("Runs a Lighthouse analysis against the configured site.").option("--auth_token <auth_token>","Auth token (or set LIGHTHOUSE_SERVERLESS_AUTH_TOKEN env var)").option("--sitemap_url <sitemap_url>","Sitemap URL (or set SITEMAP_URL env var)").option("--api_url <api_url>","API URL for trigger").option("--result_url_base <result_url_base>","Base URL for result polling").option("--max_urls <max_urls>","Maximum number of URLs to test").option("--poll_interval <poll_interval>","Polling interval in seconds").option("--max_attempts <max_attempts>","Maximum number of polling attempts").action((async e=>{await runCommand(e,"lighthouse-run")})),program.command("run-pipeline [pipeline]").alias("pipeline").description("Run any pipeline within this organization.").option("-u, --user <user>","Bitbucket User").option("-p, --password <password>","Bitbucket Password").option("-r, --repository <repository>","Bitbucket repository slug").option("-b, --branch <branch>","Git branch to run pipeline on (default: main)","main").option("-D, --debug","Debug",!1).action((async(e,o)=>{await runCommand(o,"pipeline-run",{pipeline:e})})),program.command("run-configure-environments").alias("dns").description("Run the DNS/Environments control pipeline on devops-dns-control main branch.").option("-u, --user <user>","Bitbucket User").option("-p, --password <password>","Bitbucket Password").option("-D, --debug","Debug",!1).action((async e=>{await runCommand(e,"pipeline-run",{repository:"devops-dns-control",pipeline:"configure_environments",branch:"main"})})),program.command("variable-set <key> <value>").alias("set-var").option("-u, --user <user>","Bitbucket User").option("-p, --password <password>","Bitbucket Password").option("-P, --project <project>","Repository / project key").option("-w, --workspace","Flag to set in the workspace instead of in the project").option("-s, --secure","Encrypts the variable").description("Create or update an environment variable in the given repository or workspace").action((async(e,o,a)=>{await runCommand(a,"variable-set",{key:e,value:o})})),program.command("variables-get").alias("vars-get").alias("get-vars").option("-v, --version <version>","Replace $VERSION").option("-b, --build_id <build>","Override $BUILD_ID").option("-n, --namespace <namespace>","Override $NAMESPACE").option("-s, --branch_slug <slug>","Override derived branch slug").description("Creates vars: VERSION, ASSEMBLY_VERSION, NAMESPACE & BUILD_ID (Requires: version.json).").action((async e=>{await runCommand(e,"variables-get")})),program.command("variables-replace [path]").alias("rv").alias("replace-vars").option("-v, --version <version>","Replace $VERSION").option("-b, --build_id <build>","Replace $BUILD_ID").option("-n, --namespace <namespace>","Replace $NAMESPACE").option("-B, --branch","Replace $BRANCH").description("Replaces environment $VARIABLES in text files at a given path (default: /kube)").action((async(e,o)=>{await runCommand(o,"variables-replace",{path:e})})),program.command("send-slack <text>").alias("slack").description("Send a slack message to the #delivery-log channel.").option("-c, --channel <channel>","Override the channel").option("-u, --url <url>","Slack webhook URL").option("-D, --debug","Debug",!1).action((async(e,o)=>{o.text=e,await runCommand(o,"send-slack")})),program.command("npm-publish").alias("npp").description("Tags and publishes git repository to npm and pushes tags back into the branch.").option("-br, --branch <branch","Target branch to publish. Defaults to current branch").option("-b, --build_id <build>","Replaces $BUILD_ID").option("-v, --version <version>","Replaces $VERSION").option("-e, --email <email>","Email with access to npm repository. Replaces $NPM_EMAIL.").option("-r, --registry <registry>","Target npm registry. Replaces $NPM_REGISTRY.").option("-nu, --npm_user <npm_user>","Npm user with access to npm registry. Replaces $NPM_USER.").option("-nt, --npm_token <npm_token>","Npm token for npm user. Replaces $NPM_TOKEN.").option("-bu, --bitbucket_user <bb_user>","Bitbucket user with access to git repo. Replaces $BITBUCKET_APP_USERNAME").option("-bt, --bitbucket_token <bb_token>","Bitbucket token for user. Replaces $BITBUCKET_APP_TOKEN.").option("-t, --tag_prefix <tag>","Additional tags to add to current branch.").action((async e=>{await runCommand(e,"npm-publish")})),program.command("help").alias("h").action((()=>{program.outputHelp()})),program.parse(process.argv),process.argv.slice(2).length||(program.outputHelp(),process.exit(1)),program.on("option:verbose",(()=>{process.env.VERBOSE="true"})),command_found||(console.error("Invalid command: %s\n",program.args.join(" ")),program.outputHelp(),process.exit(1)),process.on("unhandledRejection",((e,o)=>{console.log("Unhandled Rejection at: Promise",o,"reason:",e)}));
//# sourceMappingURL=/sm/c82c41cae3288bc3fd1c6aa83ac4c5398838cd2bffc7a017a33b4d40fc67178d.map