@swell/cli
Version:
Swell's command line interface/utility
32 lines (31 loc) • 1.1 kB
JavaScript
import { Args } from '@oclif/core';
import { env, setEnv } from '../lib/config.js';
import style from '../lib/style.js';
import { SwellCommand } from '../swell-command.js';
export default class Env extends SwellCommand {
static args = {
name: Args.string({
description: 'name of the environment (production, staging, local, review)',
}),
reviewBranch: Args.string({
description: 'name of a review branch',
}),
};
static description = `Internal: Display the current environment configuration.`;
static hidden = true;
constructor(argv, config) {
super(argv, config);
this.requiresAuth = false;
}
async run() {
const { args } = await this.parse(Env);
const { name, reviewBranch } = args;
if (name) {
const newEnv = setEnv(name, reviewBranch);
this.log(`Environment set to ${style.appEnv(name)}:`, JSON.stringify(newEnv, null, 2));
}
else {
this.log('Current environment:', JSON.stringify(env.store, null, 2));
}
}
}