vercel-env-push
Version:
The missing Vercel CLI command to push environment variables from .env files.
40 lines (37 loc) • 1.32 kB
JavaScript
import cac from 'cac';
import { red } from 'kolorist';
import { pushEnvVars } from './index.mjs';
import 'node:assert';
import 'node:fs';
import 'dotenv';
import 'dotenv-expand';
import 'node:readline';
import 'cli-table3';
import 'nanospinner';
import 'wyt';
import 'node:child_process';
import 'node:util';
const version = "0.4.0";
const cli = cac("vercel-env-push");
cli.version(version).help((sections) => {
sections.splice(3, 0, {
body: "Environments: development - preview - production"
});
});
cli.command("<file> <env> [...otherEnvs]").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").action(async (file, env, otherEnvs, options) => {
await pushEnvVars(file, [env, ...otherEnvs], { ...options, interactive: true });
});
async function run() {
try {
cli.parse(process.argv, { run: false });
await cli.runMatchedCommand();
} catch (error) {
const isError = error instanceof Error;
console.error(red(`Something went wrong: ${isError ? error.message : error}`));
if (isError && error.cause) {
console.error(error.cause);
}
process.exit(1);
}
}
run();