@agilecustoms/envctl 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/CliHelper.js +6 -6
- package/dist/client/TerraformAdapter.js +1 -45
- package/dist/commands/_keys.js +1 -1
- package/dist/commands/createEphemeral.js +3 -3
- package/dist/commands/delete.js +4 -4
- package/dist/commands/deploy.js +2 -3
- package/dist/commands/destroy.js +4 -4
- package/dist/commands/index.js +0 -1
- package/dist/commands/plan.js +2 -3
- package/dist/commands/status.js +4 -4
- package/dist/index.js +1 -2
- package/dist/service/EnvCtl.js +22 -36
- package/package.json +3 -3
- package/dist/commands/init.js +0 -17
package/dist/client/CliHelper.js
CHANGED
|
@@ -16,17 +16,17 @@ export class CliHelper {
|
|
|
16
16
|
}]);
|
|
17
17
|
return answer;
|
|
18
18
|
}
|
|
19
|
-
ensureEnv(
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
19
|
+
ensureEnv(key) {
|
|
20
|
+
if (key) {
|
|
21
|
+
return key;
|
|
22
22
|
}
|
|
23
23
|
const owner = this.configService.getOwner();
|
|
24
24
|
if (!owner) {
|
|
25
|
-
throw new KnownException('--
|
|
25
|
+
throw new KnownException('--key argument is not provided\n'
|
|
26
26
|
+ 'default to owner from local configuration, but it is not configured\n'
|
|
27
|
-
+ 'please call with --
|
|
27
|
+
+ 'please call with --key argument or run \'envctl configure\' to configure owner');
|
|
28
28
|
}
|
|
29
|
-
console.log(`
|
|
29
|
+
console.log(`Key is not provided, default to owner name ${owner}`);
|
|
30
30
|
return owner;
|
|
31
31
|
}
|
|
32
32
|
ensureOwner(owner) {
|
|
@@ -22,54 +22,10 @@ export class TerraformAdapter {
|
|
|
22
22
|
});
|
|
23
23
|
console.log(`\nTime EST: ${est}, UTC: ${utc}\n`);
|
|
24
24
|
}
|
|
25
|
-
async init(key, cwd, upgrade = false) {
|
|
26
|
-
let accAlias = '';
|
|
27
|
-
const accAliasScanner = (line) => {
|
|
28
|
-
accAlias = line;
|
|
29
|
-
};
|
|
30
|
-
await this.processRunner.runScript('get-acc-alias.sh', [], cwd, accAliasScanner);
|
|
31
|
-
console.log('Run terraform init to download providers, this doesn\'t create any resources in AWS even S3 object');
|
|
32
|
-
let emptyDir = false;
|
|
33
|
-
const scanner = (line) => {
|
|
34
|
-
if (line.includes('Terraform initialized in an empty directory!')) {
|
|
35
|
-
emptyDir = true;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const bucket = `agilecustoms-${accAlias}-tf-state`;
|
|
39
|
-
const args = [
|
|
40
|
-
'init',
|
|
41
|
-
'-reconfigure',
|
|
42
|
-
`-backend-config=bucket=${bucket}`,
|
|
43
|
-
`-backend-config=key=${key}`
|
|
44
|
-
];
|
|
45
|
-
if (upgrade) {
|
|
46
|
-
args.push('-upgrade');
|
|
47
|
-
}
|
|
48
|
-
this.printTime();
|
|
49
|
-
try {
|
|
50
|
-
await this.processRunner.run('terraform', args, cwd, scanner);
|
|
51
|
-
this.printTime();
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
if (error instanceof ProcessException) {
|
|
55
|
-
if (!upgrade && error.message.includes('Failed to query available provider packages')) {
|
|
56
|
-
args.push('-upgrade');
|
|
57
|
-
await this.processRunner.run('terraform', args, cwd);
|
|
58
|
-
this.printTime();
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
throw new KnownException(`terraform init failed with code ${error.code}:\n${error.message}`, { cause: error });
|
|
62
|
-
}
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
if (emptyDir) {
|
|
66
|
-
throw new KnownException('Can not find terraform files. Command needs to be run in a directory with terraform files');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
25
|
tfArgs(env, cwd) {
|
|
70
26
|
const varDefs = this.getVarDefs(cwd);
|
|
71
27
|
const argVars = this.getArgVars(env.args);
|
|
72
|
-
const specialFields = { ...env, env: env.
|
|
28
|
+
const specialFields = { ...env, env: env.key };
|
|
73
29
|
const extraArgs = [];
|
|
74
30
|
for (const name of ['env', 'owner', 'ephemeral']) {
|
|
75
31
|
if (varDefs[name] && !argVars[name]) {
|
package/dist/commands/_keys.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const _keys = {
|
|
2
2
|
CWD: 'Working directory (default: current directory)',
|
|
3
|
-
ENV: 'Environment name (can be git hash). = key used to store env state (s3 key in case of AWS)',
|
|
4
3
|
FORCE: 'Force deletion without confirmation',
|
|
4
|
+
KEY: 'Environment name/identifier - taken from remote stake key, must be unique for a given customer',
|
|
5
5
|
KIND: 'Environment kind: complete project (default) or some slice such as tt-core + tt-web',
|
|
6
6
|
OWNER: 'Environment owner (GH username)'
|
|
7
7
|
};
|
|
@@ -6,12 +6,12 @@ export function createEphemeral(program) {
|
|
|
6
6
|
program
|
|
7
7
|
.command('create-ephemeral')
|
|
8
8
|
.description('Create bare env w/o resources. Used in CI as first step just to pre-generate token for extension')
|
|
9
|
-
.requiredOption('--
|
|
9
|
+
.requiredOption('--key <key>', _keys.KEY)
|
|
10
10
|
.option('--owner <owner>', _keys.OWNER)
|
|
11
11
|
.action(wrap(handler));
|
|
12
12
|
}
|
|
13
13
|
async function handler(options) {
|
|
14
|
-
const {
|
|
15
|
-
const token = await envCtl.createEphemeral(
|
|
14
|
+
const { key, owner } = options;
|
|
15
|
+
const token = await envCtl.createEphemeral(key, owner);
|
|
16
16
|
console.log(token);
|
|
17
17
|
}
|
package/dist/commands/delete.js
CHANGED
|
@@ -6,13 +6,13 @@ export function deleteIt(program) {
|
|
|
6
6
|
program
|
|
7
7
|
.command('delete')
|
|
8
8
|
.description('Delete a development environment')
|
|
9
|
-
.option('--
|
|
9
|
+
.option('--key <key>', _keys.KEY)
|
|
10
10
|
.option('--force', _keys.FORCE)
|
|
11
11
|
.option('--cwd <cwd>', _keys.CWD)
|
|
12
12
|
.action(wrap(handler));
|
|
13
13
|
}
|
|
14
14
|
async function handler(options) {
|
|
15
|
-
const {
|
|
16
|
-
const
|
|
17
|
-
await envCtl.delete(
|
|
15
|
+
const { key, force, cwd } = options;
|
|
16
|
+
const theKey = cliHelper.ensureEnv(key);
|
|
17
|
+
await envCtl.delete(theKey, Boolean(force), cwd);
|
|
18
18
|
}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -6,7 +6,7 @@ export function deploy(program) {
|
|
|
6
6
|
program
|
|
7
7
|
.command('deploy')
|
|
8
8
|
.description('Create new or update existing dev environment')
|
|
9
|
-
.option('--
|
|
9
|
+
.option('--key <key>', _keys.KEY)
|
|
10
10
|
.option('--owner <owner>', _keys.OWNER)
|
|
11
11
|
.option('--kind <kind>', _keys.KIND)
|
|
12
12
|
.option('--cwd <cwd>', _keys.CWD)
|
|
@@ -16,7 +16,6 @@ export function deploy(program) {
|
|
|
16
16
|
}
|
|
17
17
|
async function handler(tfArgs, options) {
|
|
18
18
|
await awsCredsHelper.ensureCredentials();
|
|
19
|
-
const { cwd,
|
|
20
|
-
envDto.envName = env;
|
|
19
|
+
const { cwd, ...envDto } = options;
|
|
21
20
|
await envCtl.deploy(envDto, tfArgs, cwd);
|
|
22
21
|
}
|
package/dist/commands/destroy.js
CHANGED
|
@@ -8,7 +8,7 @@ export function destroy(program) {
|
|
|
8
8
|
.description('Destroy environment resources. This is thin wrapper for terraform destroy.'
|
|
9
9
|
+ ' Unlike "delete" command (which just schedule deletion) this command deletes resources synchronously.'
|
|
10
10
|
+ ' Main use case - test deletion process, basically that you have enough permissions to delete resources')
|
|
11
|
-
.option('--
|
|
11
|
+
.option('--key <key>', _keys.KEY)
|
|
12
12
|
.option('--force', _keys.FORCE)
|
|
13
13
|
.option('--cwd <cwd>', _keys.CWD)
|
|
14
14
|
.allowUnknownOption(true)
|
|
@@ -16,7 +16,7 @@ export function destroy(program) {
|
|
|
16
16
|
.action(wrap(handler));
|
|
17
17
|
}
|
|
18
18
|
async function handler(tfArgs, options) {
|
|
19
|
-
const {
|
|
20
|
-
const
|
|
21
|
-
await envCtl.destroy(
|
|
19
|
+
const { key, force, cwd } = options;
|
|
20
|
+
const theKey = cliHelper.ensureEnv(key);
|
|
21
|
+
await envCtl.destroy(theKey, tfArgs, Boolean(force), cwd);
|
|
22
22
|
}
|
package/dist/commands/index.js
CHANGED
|
@@ -3,6 +3,5 @@ export { createEphemeral } from './createEphemeral.js';
|
|
|
3
3
|
export { deleteIt } from './delete.js';
|
|
4
4
|
export { deploy } from './deploy.js';
|
|
5
5
|
export { destroy } from './destroy.js';
|
|
6
|
-
export { init } from './init.js';
|
|
7
6
|
export { plan } from './plan.js';
|
|
8
7
|
export { status } from './status.js';
|
package/dist/commands/plan.js
CHANGED
|
@@ -7,7 +7,7 @@ export function plan(program) {
|
|
|
7
7
|
.command('plan')
|
|
8
8
|
.description('High level wrapper for terraform plan. Compliments deploy command: if you plan to deploy env with envctl deploy,'
|
|
9
9
|
+ ' then it is recommended to do plan with envctl plan to guarantee consistent behavior')
|
|
10
|
-
.option('--
|
|
10
|
+
.option('--key <key>', _keys.KEY)
|
|
11
11
|
.option('--owner <owner>', _keys.OWNER)
|
|
12
12
|
.option('--cwd <cwd>', _keys.CWD)
|
|
13
13
|
.allowUnknownOption(true)
|
|
@@ -16,7 +16,6 @@ export function plan(program) {
|
|
|
16
16
|
}
|
|
17
17
|
async function handler(tfArgs, options) {
|
|
18
18
|
await awsCredsHelper.ensureCredentials();
|
|
19
|
-
const { cwd,
|
|
20
|
-
envDto.envName = env;
|
|
19
|
+
const { cwd, ...envDto } = options;
|
|
21
20
|
await envCtl.plan(envDto, tfArgs, cwd);
|
|
22
21
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -6,12 +6,12 @@ export function status(program) {
|
|
|
6
6
|
program
|
|
7
7
|
.command('status')
|
|
8
8
|
.description('Get env status')
|
|
9
|
-
.option('--
|
|
9
|
+
.option('--key <key>', _keys.KEY)
|
|
10
10
|
.option('--cwd <cwd>', _keys.CWD)
|
|
11
11
|
.action(wrap(handler));
|
|
12
12
|
}
|
|
13
13
|
async function handler(options) {
|
|
14
|
-
const {
|
|
15
|
-
const
|
|
16
|
-
await envCtl.status(
|
|
14
|
+
const { key, cwd } = options;
|
|
15
|
+
const theKey = cliHelper.ensureEnv(key);
|
|
16
|
+
await envCtl.status(theKey, cwd);
|
|
17
17
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import updateNotifier from 'update-notifier';
|
|
5
|
-
import { configure, createEphemeral, deleteIt, deploy, destroy,
|
|
5
|
+
import { configure, createEphemeral, deleteIt, deploy, destroy, plan, status } from './commands/index.js';
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
7
7
|
const pkg = require('../package.json');
|
|
8
8
|
updateNotifier({ pkg, updateCheckInterval: 0 }).notify();
|
|
@@ -16,7 +16,6 @@ createEphemeral(program);
|
|
|
16
16
|
deleteIt(program);
|
|
17
17
|
deploy(program);
|
|
18
18
|
destroy(program);
|
|
19
|
-
init(program);
|
|
20
19
|
plan(program);
|
|
21
20
|
status(program);
|
|
22
21
|
program.parse(process.argv);
|
package/dist/service/EnvCtl.js
CHANGED
|
@@ -9,11 +9,7 @@ export class EnvCtl {
|
|
|
9
9
|
this.envApi = envApi;
|
|
10
10
|
this.terraformAdapter = terraformAdapter;
|
|
11
11
|
}
|
|
12
|
-
key
|
|
13
|
-
return env;
|
|
14
|
-
}
|
|
15
|
-
async status(envName, cwd) {
|
|
16
|
-
const key = this.key(envName);
|
|
12
|
+
async status(key, cwd) {
|
|
17
13
|
console.log(`Retrieve env ${key}`);
|
|
18
14
|
const env = await this.envApi.get(key);
|
|
19
15
|
if (env === null) {
|
|
@@ -27,14 +23,13 @@ export class EnvCtl {
|
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
async tryGetEnv(input) {
|
|
30
|
-
let
|
|
26
|
+
let key = input.key;
|
|
31
27
|
let owner = input.owner;
|
|
32
|
-
if (!
|
|
28
|
+
if (!key) {
|
|
33
29
|
owner = this.cliHelper.ensureOwner(owner);
|
|
34
30
|
console.log(`Env name not provided, default to owner name ${owner}`);
|
|
35
|
-
|
|
31
|
+
key = owner;
|
|
36
32
|
}
|
|
37
|
-
const key = this.key(envName);
|
|
38
33
|
console.log(`Check if env ${key} already exists`);
|
|
39
34
|
const env = await this.envApi.get(key);
|
|
40
35
|
if (env) {
|
|
@@ -43,7 +38,7 @@ export class EnvCtl {
|
|
|
43
38
|
else {
|
|
44
39
|
console.log(`Env ${key} does not exist`);
|
|
45
40
|
}
|
|
46
|
-
return {
|
|
41
|
+
return { anOwner: owner, key, env };
|
|
47
42
|
}
|
|
48
43
|
checkInput(env, input, cwd) {
|
|
49
44
|
if (input.owner && env.owner !== input.owner) {
|
|
@@ -63,15 +58,11 @@ export class EnvCtl {
|
|
|
63
58
|
}
|
|
64
59
|
throw new KnownException(`Env ${env.key} status is ${env.status}, can not run this command`);
|
|
65
60
|
}
|
|
66
|
-
async init(envName, cwd) {
|
|
67
|
-
const key = this.key(envName);
|
|
68
|
-
await this.terraformAdapter.init(key, cwd, true);
|
|
69
|
-
}
|
|
70
61
|
async plan(input, tfArgs, cwd) {
|
|
71
|
-
const {
|
|
62
|
+
const { anOwner, key, env } = await this.tryGetEnv(input);
|
|
72
63
|
if (env == null) {
|
|
73
64
|
const owner = this.cliHelper.ensureOwner(anOwner);
|
|
74
|
-
await this.runPlan(key,
|
|
65
|
+
await this.runPlan(key, owner, tfArgs, undefined, cwd);
|
|
75
66
|
return;
|
|
76
67
|
}
|
|
77
68
|
this.checkInput(env, input, cwd);
|
|
@@ -81,15 +72,13 @@ export class EnvCtl {
|
|
|
81
72
|
if (env.status !== EnvStatus.Active) {
|
|
82
73
|
throw new KnownException(`Env ${env.key} status is ${env.status}, can not run plan`);
|
|
83
74
|
}
|
|
84
|
-
await this.runPlan(key,
|
|
75
|
+
await this.runPlan(key, owner, tfArgs, env.vars, cwd);
|
|
85
76
|
}
|
|
86
|
-
async runPlan(key,
|
|
87
|
-
const envTerraform = {
|
|
88
|
-
await this.terraformAdapter.init(key, cwd);
|
|
77
|
+
async runPlan(key, owner, args, vars, cwd) {
|
|
78
|
+
const envTerraform = { key, ephemeral: false, owner, args, vars };
|
|
89
79
|
await this.terraformAdapter.plan(envTerraform, cwd);
|
|
90
80
|
}
|
|
91
|
-
async createEphemeral(
|
|
92
|
-
const key = this.key(envName);
|
|
81
|
+
async createEphemeral(key, owner) {
|
|
93
82
|
const env = await this.envApi.get(key);
|
|
94
83
|
if (env !== null) {
|
|
95
84
|
throw new KnownException(`Env ${key} already exists`);
|
|
@@ -98,14 +87,14 @@ export class EnvCtl {
|
|
|
98
87
|
return await this.envApi.createEphemeral(createEnv);
|
|
99
88
|
}
|
|
100
89
|
async deploy(input, tfArgs, cwd) {
|
|
101
|
-
const {
|
|
90
|
+
const { anOwner, key, env } = await this.tryGetEnv(input);
|
|
102
91
|
if (env === null) {
|
|
103
92
|
const owner = this.cliHelper.ensureOwner(anOwner);
|
|
104
93
|
const kind = this.cliHelper.ensureKind(input.kind, cwd);
|
|
105
94
|
console.log('Creating env tracking record in DynamoDB');
|
|
106
95
|
const createEnv = { key, owner, kind };
|
|
107
96
|
const newEnv = await this.envApi.create(createEnv);
|
|
108
|
-
return await this.runDeploy(newEnv,
|
|
97
|
+
return await this.runDeploy(newEnv, key, tfArgs, cwd);
|
|
109
98
|
}
|
|
110
99
|
this.checkInput(env, input, cwd);
|
|
111
100
|
this.checkStatus(env);
|
|
@@ -124,13 +113,12 @@ export class EnvCtl {
|
|
|
124
113
|
console.log('Env status is ACTIVE\nWill lock for update and run terraform apply (to update resources)');
|
|
125
114
|
await this.envApi.lockForUpdate(env);
|
|
126
115
|
}
|
|
127
|
-
await this.runDeploy(env,
|
|
116
|
+
await this.runDeploy(env, key, tfArgs, cwd);
|
|
128
117
|
}
|
|
129
|
-
async runDeploy(env,
|
|
130
|
-
await this.terraformAdapter.init(env.key, cwd);
|
|
118
|
+
async runDeploy(env, key, tfArgs, cwd) {
|
|
131
119
|
console.log('Deploying resources');
|
|
132
120
|
const { ephemeral, vars } = env;
|
|
133
|
-
const envTerraform = {
|
|
121
|
+
const envTerraform = { key, ephemeral, owner: env.owner || 'system', args: tfArgs, vars };
|
|
134
122
|
const onDemandVars = {};
|
|
135
123
|
try {
|
|
136
124
|
await this.terraformAdapter.apply(envTerraform, onDemandVars, cwd);
|
|
@@ -146,8 +134,8 @@ export class EnvCtl {
|
|
|
146
134
|
console.log('Activating env (to finish creation)');
|
|
147
135
|
await this.envApi.activate(env);
|
|
148
136
|
}
|
|
149
|
-
async delete(
|
|
150
|
-
const env = await this.get(
|
|
137
|
+
async delete(key, force, cwd) {
|
|
138
|
+
const env = await this.get(key);
|
|
151
139
|
if (!force) {
|
|
152
140
|
this.checkStatus(env);
|
|
153
141
|
if (env.status === EnvStatus.Init) {
|
|
@@ -174,8 +162,8 @@ export class EnvCtl {
|
|
|
174
162
|
const message = await this.envApi.delete(env);
|
|
175
163
|
console.log(message);
|
|
176
164
|
}
|
|
177
|
-
async destroy(
|
|
178
|
-
const env = await this.get(
|
|
165
|
+
async destroy(key, tfArgs, force, cwd) {
|
|
166
|
+
const env = await this.get(key);
|
|
179
167
|
this.checkStatus(env);
|
|
180
168
|
if (env.status === EnvStatus.Init) {
|
|
181
169
|
console.log(`Env ${env.key} has no resources, nothing to destroy, call 'delete' command instead`);
|
|
@@ -196,9 +184,8 @@ export class EnvCtl {
|
|
|
196
184
|
await this.envApi.lockForUpdate(env);
|
|
197
185
|
}
|
|
198
186
|
const { ephemeral, owner, vars } = env;
|
|
199
|
-
const envTerraform = {
|
|
187
|
+
const envTerraform = { key, ephemeral, owner: owner || 'system', args: tfArgs, vars };
|
|
200
188
|
console.log('Destroying env resources');
|
|
201
|
-
await this.terraformAdapter.init(env.key, cwd);
|
|
202
189
|
await this.terraformAdapter.destroy(envTerraform, force, cwd);
|
|
203
190
|
console.log('Unlock env');
|
|
204
191
|
await this.envApi.activate(env);
|
|
@@ -206,8 +193,7 @@ export class EnvCtl {
|
|
|
206
193
|
await this.envApi.delete(env);
|
|
207
194
|
console.log('Please wait for ~15 sec before you can create env with same name');
|
|
208
195
|
}
|
|
209
|
-
async get(
|
|
210
|
-
const key = this.key(envName);
|
|
196
|
+
async get(key) {
|
|
211
197
|
console.log(`Retrieve env ${key}`);
|
|
212
198
|
const env = await this.envApi.get(key);
|
|
213
199
|
if (!env) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agilecustoms/envctl",
|
|
3
3
|
"description": "node.js CLI client for manage environments",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.0",
|
|
5
5
|
"author": "Alex Chekulaev",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"run-version": " tsc --sourceMap true && npm run run -- --version",
|
|
30
30
|
"run-configure": "tsc --sourceMap true && npm run run -- configure",
|
|
31
31
|
"~": "",
|
|
32
|
+
"run-init": "cd ../tt-core && terraform init -backend-config=key=laxa1986 -upgrade",
|
|
32
33
|
"run-status": " tsc --sourceMap true && npm run run -- status --cwd ../tt-core",
|
|
33
|
-
"run-init": " tsc --sourceMap true && npm run run -- init --cwd ../tt-core",
|
|
34
34
|
"run-plan": " tsc --sourceMap true && npm run run -- plan --cwd ../tt-core",
|
|
35
35
|
"run-deploy": " tsc --sourceMap true && npm run run -- deploy --cwd ../tt-core -var=\"env_size=min\"",
|
|
36
36
|
"run-delete": " tsc --sourceMap true && npm run run -- delete --cwd ../tt-core",
|
|
37
37
|
"run-destroy": "tsc --sourceMap true && npm run run -- destroy --cwd ../tt-core",
|
|
38
38
|
"-": "",
|
|
39
|
+
"run-ephemeral-init": "cd ../tt-gitops && terraform init -backend-config=key=test",
|
|
39
40
|
"run-ephemeral-create": " tsc --sourceMap true && npm run run -- create-ephemeral --env test",
|
|
40
41
|
"run-ephemeral-status": " tsc --sourceMap true && npm run run -- status --env test",
|
|
41
|
-
"run-ephemeral-init": " tsc --sourceMap true && npm run run -- init --env test --cwd ../tt-gitops",
|
|
42
42
|
"run-ephemeral-deploy": " tsc --sourceMap true && npm run run -- deploy --env test --cwd ../tt-gitops -var-file=versions.tfvars",
|
|
43
43
|
"run-ephemeral-delete": " tsc --sourceMap true && npm run run -- delete --env test --cwd ../tt-gitops --force",
|
|
44
44
|
"run-ephemeral-destroy": "tsc --sourceMap true && npm run run -- destroy --env test --cwd ../tt-gitops --force -var-file=versions.tfvars"
|
package/dist/commands/init.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { cliHelper, envCtl } from '../container.js';
|
|
3
|
-
import { _keys } from './_keys.js';
|
|
4
|
-
import { wrap } from './_utils.js';
|
|
5
|
-
export function init(program) {
|
|
6
|
-
program
|
|
7
|
-
.command('init')
|
|
8
|
-
.description('Terraform init wrapper')
|
|
9
|
-
.option('--env <env>', _keys.ENV)
|
|
10
|
-
.option('--cwd <cwd>', _keys.CWD)
|
|
11
|
-
.action(wrap(handler));
|
|
12
|
-
}
|
|
13
|
-
async function handler(options) {
|
|
14
|
-
const { env, cwd } = options;
|
|
15
|
-
const envName = cliHelper.ensureEnv(env);
|
|
16
|
-
await envCtl.init(envName, cwd);
|
|
17
|
-
}
|