@agilecustoms/envctl 1.10.0 → 1.10.2

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.
@@ -1,8 +1,6 @@
1
1
  export const _keys = {
2
- CWD: 'Working directory (default: current directory)',
3
2
  FORCE: 'Force deletion without confirmation',
4
3
  KEY: 'Environment name/identifier - taken from remote stake key, must be unique for a given customer',
5
4
  KIND: 'Environment kind: complete project (default) or some slice such as tt-core + tt-web',
6
- OWNER: 'Environment owner (GH username)',
7
- VERBOSE: 'Verbose output (w/ debug logs)'
5
+ OWNER: 'Environment owner (GH username)'
8
6
  };
@@ -1,13 +1,11 @@
1
1
  import { Command } from 'commander';
2
2
  import inquirer from 'inquirer';
3
3
  import { ConfigService } from '../service/index.js';
4
- import { _keys } from './_keys.js';
5
4
  import { wrap } from './_utils.js';
6
5
  export function configure(program, configService) {
7
6
  program
8
7
  .command('configure')
9
8
  .description('Configure user settings on your local machine')
10
- .option('-v, --verbose', _keys.VERBOSE)
11
9
  .action(wrap(async () => {
12
10
  const answers = await inquirer.prompt([
13
11
  {
@@ -7,7 +7,6 @@ export function createEphemeral(program, envService) {
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
9
  .requiredOption('--key <key>', _keys.KEY)
10
- .option('-v, --verbose', _keys.VERBOSE)
11
10
  .action(wrap(async (options) => {
12
11
  const { key } = options;
13
12
  const token = await envService.createEphemeral(key);
@@ -8,12 +8,8 @@ export function deleteIt(program, envService) {
8
8
  .description('Delete a development environment')
9
9
  .option('--key <key>', _keys.KEY)
10
10
  .option('--force', _keys.FORCE)
11
- .option('--cwd <cwd>', _keys.CWD)
12
- .option('-v, --verbose', _keys.VERBOSE)
13
11
  .action(wrap(async (options) => {
14
- const { key, force, cwd } = options;
15
- if (cwd)
16
- process.chdir(cwd);
12
+ const { key, force } = options;
17
13
  await envService.delete(Boolean(force), key);
18
14
  }));
19
15
  }
@@ -1,19 +1,13 @@
1
1
  import { Command } from 'commander';
2
2
  import { EnvService } from '../service/index.js';
3
- import { _keys } from './_keys.js';
4
3
  import { wrap } from './_utils.js';
5
4
  export function deploy(program, envService) {
6
5
  program
7
6
  .command('deploy')
8
7
  .description('Create new or update existing environment')
9
- .option('--cwd <cwd>', _keys.CWD)
10
- .option('-v, --verbose', _keys.VERBOSE)
11
8
  .allowUnknownOption(true)
12
9
  .argument('[args...]')
13
- .action(wrap(async (tfArgs, options) => {
14
- const { cwd } = options;
15
- if (cwd)
16
- process.chdir(cwd);
10
+ .action(wrap(async (tfArgs) => {
17
11
  await envService.deploy(tfArgs);
18
12
  }));
19
13
  }
@@ -10,14 +10,10 @@ export function destroy(program, envService) {
10
10
  + ' Unlike "delete" command, this command doesn\'t have --key option, it can only delete env after key you provided during terraform init.'
11
11
  + ' Main use case - test deletion process, basically that you have enough permissions to delete resources')
12
12
  .option('--force', _keys.FORCE)
13
- .option('--cwd <cwd>', _keys.CWD)
14
- .option('-v, --verbose', _keys.VERBOSE)
15
13
  .allowUnknownOption(true)
16
14
  .argument('[args...]')
17
15
  .action(wrap(async (tfArgs, options) => {
18
- const { force, cwd } = options;
19
- if (cwd)
20
- process.chdir(cwd);
16
+ const { force } = options;
21
17
  await envService.destroy(tfArgs, Boolean(force));
22
18
  }));
23
19
  }
@@ -6,12 +6,8 @@ export function logs(program, logService) {
6
6
  .command('logs')
7
7
  .description('Get most recent env destroy logs')
8
8
  .option('--key <key>', _keys.KEY)
9
- .option('--cwd <cwd>', _keys.CWD)
10
- .option('-v, --verbose', _keys.VERBOSE)
11
9
  .action(wrap(async (options) => {
12
- const { key, cwd } = options;
13
- if (cwd)
14
- process.chdir(cwd);
10
+ const { key } = options;
15
11
  await logService.getLogs(key);
16
12
  }));
17
13
  }
@@ -1,20 +1,14 @@
1
1
  import { Command } from 'commander';
2
2
  import { EnvService } from '../service/index.js';
3
- import { _keys } from './_keys.js';
4
3
  import { wrap } from './_utils.js';
5
4
  export function plan(program, envService) {
6
5
  program
7
6
  .command('plan')
8
7
  .description('High level wrapper for terraform plan. Compliments deploy command: if you plan to deploy env with envctl deploy,'
9
8
  + ' then it is recommended to do plan with envctl plan to guarantee consistent behavior')
10
- .option('--cwd <cwd>', _keys.CWD)
11
- .option('-v, --verbose', _keys.VERBOSE)
12
9
  .allowUnknownOption(true)
13
10
  .argument('[args...]')
14
- .action(wrap(async (tfArgs, options) => {
15
- const { cwd } = options;
16
- if (cwd)
17
- process.chdir(cwd);
11
+ .action(wrap(async (tfArgs) => {
18
12
  await envService.plan(tfArgs);
19
13
  }));
20
14
  }
@@ -7,12 +7,8 @@ export function status(program, envService) {
7
7
  .command('status')
8
8
  .description('Get env status')
9
9
  .option('--key <key>', _keys.KEY)
10
- .option('--cwd <cwd>', _keys.CWD)
11
- .option('-v, --verbose', _keys.VERBOSE)
12
10
  .action(wrap(async (options) => {
13
- const { key, cwd } = options;
14
- if (cwd)
15
- process.chdir(cwd);
11
+ const { key } = options;
16
12
  await envService.status(key);
17
13
  }));
18
14
  }
package/dist/index.js CHANGED
@@ -7,9 +7,16 @@ import { buildContainer } from './container.js';
7
7
  const require = createRequire(import.meta.url);
8
8
  const pkg = require('../package.json');
9
9
  updateNotifier({ pkg, updateCheckInterval: 0 }).notify();
10
+ if (process.env.TEST_CWD) {
11
+ process.chdir(process.env.TEST_CWD);
12
+ }
10
13
  const { configService, envService, logService } = buildContainer(pkg.version);
11
14
  const program = new Command();
12
- program.name('envctl').description('CLI to manage environments').version(pkg.version);
15
+ program
16
+ .name('envctl')
17
+ .description('CLI to manage environments')
18
+ .version(pkg.version)
19
+ .option('-v, --verbose', 'Verbose output (w/ debug logs)');
13
20
  configure(program, configService);
14
21
  createEphemeral(program, envService);
15
22
  deleteIt(program, envService);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilecustoms/envctl",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "node.js CLI client for manage environments",
5
5
  "keywords": [
6
6
  "terraform wrapper",
@@ -36,33 +36,33 @@
36
36
  "lint:fix": "npm run lint -- --fix",
37
37
  "test": "vitest run --coverage",
38
38
  "build": "tsc -p tsconfig.build.json",
39
- "run": "tsc -p tsconfig.build.json --sourceMap true && node dist/index.js",
40
- "run-help": " npm run run -- deploy --help",
41
- "run-version": " npm run run -- --version",
42
- "run-configure": "npm run run -- configure",
39
+ "it": "tsc -p tsconfig.build.json --sourceMap true && TEST_CWD=\"$CWD\" node dist/index.js",
40
+ "run-help": " npm run it -- --help",
41
+ "run-version": " npm run it -- --version",
42
+ "run-configure": "npm run it -- configure",
43
43
  "~": "",
44
44
  "run-core-init": " cd ../tt-core && terraform init -upgrade -backend-config=key=laxa1986 -reconfigure",
45
- "run-core-status": " npm run run -- status --cwd ../tt-core -v",
46
- "run-core-plan": " npm run run -- plan --cwd ../tt-core -out=.terraform/plan",
47
- "run-core-deployp": "npm run run -- deploy --cwd ../tt-core .terraform/plan",
48
- "run-core-deploy": " npm run run -- deploy --cwd ../tt-core -var=\"env_size=min\"",
49
- "run-core-delete": " npm run run -- delete --cwd ../tt-core",
50
- "run-core-destroy": "npm run run -- destroy --cwd ../tt-core",
51
- "run-core-logs": " npm run run -- logs --cwd ../tt-core",
45
+ "run-core-status": " CWD=../tt-core npm run it -- status -v",
46
+ "run-core-plan": " CWD=../tt-core npm run it -- plan -out=.terraform/plan",
47
+ "run-core-deployp": "CWD=../tt-core npm run it -- deploy .terraform/plan",
48
+ "run-core-deploy": " CWD=../tt-core npm run it -- deploy -var=\"env_size=min\"",
49
+ "run-core-delete": " CWD=../tt-core npm run it -- delete",
50
+ "run-core-destroy": "CWD=../tt-core npm run it -- destroy",
51
+ "run-core-logs": " CWD=../tt-core npm run it -- logs",
52
52
  "*": "",
53
53
  "run-init": "cd ../tt-gitops && terraform init -upgrade -backend-config=key=laxa1986 -reconfigure",
54
- "run-status": " npm run run -- status --cwd ../tt-gitops",
55
- "run-plan": " AWS_PROFILE=ac-tt-dev-deployer npm run run -- plan --cwd ../tt-gitops -var=\"env_size=min\" -var-file=versions.tfvars",
56
- "run-deploy": " AWS_PROFILE=ac-tt-dev-deployer npm run run -- deploy --cwd ../tt-gitops -var=\"env_size=min\" -var-file=versions.tfvars",
57
- "run-delete": " npm run run -- delete --cwd ../tt-gitops",
58
- "run-destroy": "AWS_PROFILE=ac-tt-dev-destroyer npm run run -- destroy --cwd ../tt-gitops -var=\"env_size=min\" -var-file=versions.tfvars",
54
+ "run-status": " CWD=../tt-gitops npm run it -- status",
55
+ "run-plan": " AWS_PROFILE=ac-tt-dev-deployer CWD=../tt-gitops npm run it -- plan -var=\"env_size=min\" -var-file=versions.tfvars",
56
+ "run-deploy": " AWS_PROFILE=ac-tt-dev-deployer CWD=../tt-gitops npm run it -- deploy -var=\"env_size=min\" -var-file=versions.tfvars",
57
+ "run-delete": " CWD=../tt-gitops npm run it -- delete",
58
+ "run-destroy": "AWS_PROFILE=ac-tt-dev-destroyer CWD=../tt-gitops npm run it -- destroy -var=\"env_size=min\" -var-file=versions.tfvars",
59
59
  "-": "",
60
- "run-ephemeral-create": " npm run run -- create-ephemeral --key test",
60
+ "run-ephemeral-create": " npm run it -- create-ephemeral --key test",
61
61
  "run-ephemeral-init": "cd ../tt-gitops && terraform init -upgrade -backend-config=key=test -reconfigure",
62
- "run-ephemeral-status": " npm run run -- status --key test",
63
- "run-ephemeral-deploy": " npm run run -- deploy --cwd ../tt-gitops -var-file=versions.tfvars",
64
- "run-ephemeral-delete": " npm run run -- delete --cwd ../tt-gitops --force",
65
- "run-ephemeral-destroy": "npm run run -- destroy --cwd ../tt-gitops --force -var-file=versions.tfvars"
62
+ "run-ephemeral-status": " CWD=../tt-gitops npm run it -- status --key test",
63
+ "run-ephemeral-deploy": " CWD=../tt-gitops npm run it -- deploy -var-file=versions.tfvars",
64
+ "run-ephemeral-delete": " CWD=../tt-gitops npm run it -- delete --force",
65
+ "run-ephemeral-destroy": "CWD=../tt-gitops npm run it -- destroy --force -var-file=versions.tfvars"
66
66
  },
67
67
  "dependencies": {
68
68
  "commander": "^14.0.0",