@agilecustoms/envctl 0.16.0 → 0.17.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.
@@ -2,5 +2,6 @@ export { configure } from './configure.js';
2
2
  export { deleteIt } from './delete.js';
3
3
  export { deploy } from './deploy.js';
4
4
  export { destroy } from './destroy.js';
5
+ export { init } from './init.js';
5
6
  export { plan } from './plan.js';
6
7
  export { status } from './status.js';
@@ -0,0 +1,18 @@
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('--project <project>', _keys.PROJECT)
10
+ .option('--env <env>', _keys.ENV)
11
+ .option('--cwd <cwd>', _keys.CWD)
12
+ .action(wrap(handler));
13
+ }
14
+ async function handler(options) {
15
+ const { project, env, cwd } = options;
16
+ const envName = cliHelper.ensureEnv(env);
17
+ await envCtl.init(project, envName, cwd);
18
+ }
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, deleteIt, deploy, destroy, plan, status } from './commands/index.js';
5
+ import { configure, deleteIt, deploy, destroy, init, 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();
@@ -15,6 +15,7 @@ configure(program);
15
15
  deleteIt(program);
16
16
  deploy(program);
17
17
  destroy(program);
18
+ init(program);
18
19
  plan(program);
19
20
  status(program);
20
21
  program.parse(process.argv);
@@ -78,6 +78,10 @@ export class EnvCtl {
78
78
  }
79
79
  throw new KnownException(`Env status is ${env.status}, can not run this command`);
80
80
  }
81
+ async init(project, envName, cwd) {
82
+ const key = this.key(project, envName);
83
+ await this.terraformAdapter.init(key, cwd);
84
+ }
81
85
  async plan(input, tfArgs, cwd) {
82
86
  const { envName, owner, key, env } = await this.tryGetEnv(input);
83
87
  if (env == null) {
@@ -138,17 +142,14 @@ export class EnvCtl {
138
142
  }
139
143
  console.log('Activating env (to finish creation)');
140
144
  await this.envApi.activate(env);
141
- console.log('Lock env to run db evolution');
142
- await this.envApi.lockForUpdate(env);
143
- console.log('Unlock env after db evolution');
144
- await this.envApi.activate(env);
145
145
  }
146
146
  async delete(project, envName, cwd) {
147
147
  const env = await this.get(project, envName);
148
148
  this.checkStatus(env);
149
149
  const kind = this.cliHelper.ensureKind(undefined, cwd);
150
150
  if (env.kind && env.kind !== kind) {
151
- const answerYes = await this.cliHelper.promptYesNo(`Env ${env.key} kind (dir-name): ${env.kind} - you're deleting env deployed from different dir\n`
151
+ const answerYes = await this.cliHelper.promptYesNo(`Env ${env.key} kind (dir-name): ${env.kind}\n`
152
+ + 'You\'re deleting env deployed from different dir\n'
152
153
  + 'Do you want to proceed?');
153
154
  if (!answerYes) {
154
155
  console.log('Aborting deletion');
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.16.0",
4
+ "version": "0.17.0",
5
5
  "author": "Alex Chekulaev",
6
6
  "type": "module",
7
7
  "bin": {
@@ -28,6 +28,7 @@
28
28
  "run-version": "tsc --sourceMap true && npm run run -- --version",
29
29
  "run-configure": "tsc --sourceMap true && npm run run -- configure",
30
30
  "run-status": "tsc --sourceMap true && npm run run -- status --cwd ../tt-core",
31
+ "run-init": "tsc --sourceMap true && npm run run -- init --cwd ../tt-core",
31
32
  "run-plan": "tsc --sourceMap true && npm run run -- plan --size min --cwd ../tt-core",
32
33
  "run-deploy": "tsc --sourceMap true && npm run run -- deploy --size min --cwd ../tt-core",
33
34
  "run-delete": "tsc --sourceMap true && npm run run -- delete --cwd ../tt-core",