@agilecustoms/envctl 1.20.2 → 1.21.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.
@@ -64,24 +64,22 @@ export class HttpClient {
64
64
  throw new Error('Error (network?) making the request:', { cause: error });
65
65
  }
66
66
  const contentType = response.headers?.get('Content-Type') || '';
67
+ const body = contentType.includes('application/json') ? await response.json() : await response.text();
67
68
  if (response.ok) {
68
- if (contentType.includes('application/json')) {
69
- return await response.json();
70
- }
71
- else {
72
- return await response.text();
73
- }
69
+ return body;
74
70
  }
75
- const message = await response.text();
76
71
  if (response.status === 404) {
77
- throw new NotFoundException(message);
72
+ throw new NotFoundException(body);
78
73
  }
79
74
  if (response.status === 422) {
80
- throw new BusinessException(message);
75
+ throw new BusinessException(body);
76
+ }
77
+ if (response.status === 426) {
78
+ throw new KnownException(body.message);
81
79
  }
82
80
  if (response.status >= 500) {
83
81
  logger.info('API Gateway request ID: ' + response.headers.get('x-amzn-requestid'));
84
82
  }
85
- throw new HttpException(`status: ${response.status}, ` + message);
83
+ throw new HttpException(`status: ${response.status}, ` + JSON.stringify(body));
86
84
  }
87
85
  }
@@ -210,7 +210,10 @@ export class TerraformAdapter {
210
210
  }
211
211
  }
212
212
  async apply(env, args) {
213
- args = this.tfArgs(env, args);
213
+ const noPlan = args.every(arg => arg.startsWith('-'));
214
+ if (noPlan) {
215
+ args = this.tfArgs(env, args);
216
+ }
214
217
  logger.info('Running: terraform apply ' + args.join(' ') + '\n');
215
218
  try {
216
219
  await this._apply(args, env.ttl, 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilecustoms/envctl",
3
- "version": "1.20.2",
3
+ "version": "1.21.0",
4
4
  "description": "node.js CLI client for manage environments",
5
5
  "keywords": [
6
6
  "terraform wrapper",
@@ -41,12 +41,14 @@
41
41
  "run-version": " npm run it -- --version",
42
42
  "run-configure": "npm run it -- configure",
43
43
  "run-logs": " npm run it -- logs",
44
+ "-t1-": "",
44
45
  "t1-desc": "dev env (fully fledged ~/.envctl/default.json)",
45
46
  "t1": "CWD=../tt-core npm run it --",
46
47
  "t1-init": "cd ../tt-core && terraform init -upgrade -backend-config=key=t1 -reconfigure",
47
48
  "t1-status": "npm run t1 -- status --verbose",
48
49
  "t1-apply": " npm run t1 -- apply --auto-approve",
49
50
  "t1-delete": "npm run t1 -- delete",
51
+ "-t2-": "",
50
52
  "t2-desc": "ephemeral env in CI (must have ENVCTL_API_KEY_ in env vars)",
51
53
  "t2": "CWD=../tt-core CI=true ENVCTL_HOME=non-existing ENVCTL_API_KEY=\"$ENVCTL_API_KEY_\" npm run it --",
52
54
  "t2-create": "npm run t2 -- create-ephemeral t2",
@@ -54,12 +56,14 @@
54
56
  "t2-plan": " npm run t2 -- plan -var=env_size=min -var=env=t2 -out=plan",
55
57
  "t2-apply": " npm run t2 -- apply plan",
56
58
  "t2-delete": "npm run t2 -- delete",
57
- "t3-desc": "dev env destroy w/ plan",
59
+ "-t3-": "",
60
+ "t3-desc": "dev env destroy",
58
61
  "t3": "CWD=../tt-core npm run it --",
59
62
  "t3-init": "cd ../tt-core && terraform init -upgrade -backend-config=key=t3 -reconfigure",
60
- "t3-apply": " npm run t3 -- apply --auto-approve -var=env_size=min",
61
- "t3-plan": " npm run t3 -- plan -destroy -var=env_size=min -out=plan",
62
- "t3-delete": "npm run t3 -- destroy plan",
63
+ "t3-status": " npm run t3 -- status",
64
+ "t3-apply": " npm run t3 -- apply --auto-approve -var=env_size=min",
65
+ "t3-destroy": "npm run t3 -- destroy -var=env_size=min --auto-approve",
66
+ "-tt-": "",
63
67
  "tt-desc": "deploy TT project from local machine",
64
68
  "tt": "CWD=../tt-gitops AWS_PROFILE=ac-tt-dev-deployer npm run it --",
65
69
  "run-init": "cd ../tt-gitops && terraform init -upgrade -backend-config=key=laxa1986 -reconfigure",