vercel-env-push
Version:
The missing Vercel CLI command to push environment variables from .env files.
51 lines (45 loc) • 1.94 kB
JavaScript
;
const cac = require('cac');
const kolorist = require('kolorist');
const index = require('./index.cjs');
require('node:assert');
require('node:fs');
require('dotenv');
require('dotenv-expand');
require('node:readline');
require('cli-table3');
require('nanospinner');
require('wyt');
require('node:child_process');
require('node:util');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
const cac__default = /*#__PURE__*/_interopDefaultLegacy(cac);
const version = "0.6.0";
const cli = cac__default("vercel-env-push");
cli.version(version).help((sections) => {
sections.splice(3, 0, {
body: "Default environments: development - preview - production (use --allow-custom-env for custom environments)"
});
});
cli.command("<file> <env> [...otherEnvs]").option("--allow-custom-env, --custom-env", "Allow custom environment names (e.g. staging, app-qa, qa_team)").option("--dry, --dry-run", "List environment variables without pushing them").option("-t, --token <token>", "Login token to use for pushing environment variables").option("-b, --branch <branch>", "Specific git branch for pushed preview environment variables").option("-y, --yes", "Skip confirmation prompt for pushing environment variables").action(async (file, env, otherEnvs, options) => {
const { allowCustomEnv, customEnv, ...otherOptions } = options;
await index.pushEnvVars(file, [env, ...otherEnvs], {
...otherOptions,
allowCustomEnv: customEnv ?? allowCustomEnv,
interactive: true
});
});
async function run() {
try {
cli.parse(process.argv, { run: false });
await cli.runMatchedCommand();
} catch (error) {
const isError = error instanceof Error;
console.error(kolorist.red(`Something went wrong: ${isError ? error.message : error}`));
if (isError && error.cause) {
console.error(error.cause);
}
process.exit(1);
}
}
run();