import { captureEvent } from "../common/analytics/lib.js";
import { authenticate } from "../common/middleware/authentication.js";
import { configure } from "../common/middleware/user-configuration.js";
import { identify } from "../common/middleware/user-identification.js";
import setBlocking from "../common/output.js";
import { deploy } from "../deploy/handler.js";
import { fetchAccount } from "../common/middleware/get-account-param.js";
import { fetchProject } from "../common/middleware/get-project-param.js";
import { fetchEnvironment } from "../common/middleware/get-environment-param.js";
export default {
    desc: "Deploys current Git branch of the current directory",
    command: "deploy",
    builder: (yargs) => {
        return yargs
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
        })
            .option("project", {
            type: "string",
            hidden: true,
            describe: "The project name",
        })
            .option("account", {
            type: "string",
            describe: "The account name",
        })
            .option("dir", {
            type: "string",
            describe: "The directory containing your Zuplo API",
            default: ".",
            normalize: true,
            hidden: true,
        })
            .option("verify-remote", {
            deprecated: true,
            type: "boolean",
            describe: "Verify that this Git repository matches the one configured on Zuplo. Use --no-verify-remote to disable.",
            default: false,
        })
            .option("environment", {
            type: "string",
            describe: "The value to use for environment name, instead of the current branch name",
        })
            .option("self-hosted-endpoint", {
            type: "string",
            describe: "The endpoint of your self-hosted service to deploy to",
        })
            .option("override-repo-url", {
            type: "string",
            describe: "Override the repo url reference",
            default: undefined,
            hidden: true,
        })
            .option("fetch-environments", {
            type: "boolean",
            describe: "Fetch the environments for your project from Zuplo. If this is false, then the environment will automatically be detected from the git branch.",
            default: false,
        })
            .boolean("verify-remote")
            .middleware([
            setBlocking,
            authenticate,
            configure,
            fetchAccount,
            fetchProject,
            fetchEnvironment,
            identify,
        ]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo deploy" });
        await deploy(argv);
    },
};
//# sourceMappingURL=deploy.js.map