@agilecustoms/envctl 0.37.3 → 0.38.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.
@@ -1,11 +1,7 @@
1
- import aws4 from 'aws4';
2
1
  import { BusinessException, HttpException, NotFoundException } from '../exceptions.js';
3
- const HOST = 'env-api.maintenance.agilecustoms.com';
2
+ const HOST = 'cli.maintenance.agilecustoms.com';
4
3
  export class HttpClient {
5
- awsCredsHelper;
6
- constructor(awsCredsHelper) {
7
- this.awsCredsHelper = awsCredsHelper;
8
- }
4
+ constructor() { }
9
5
  async post(path, body, options = {}) {
10
6
  options.method = 'POST';
11
7
  if (body) {
@@ -19,19 +15,7 @@ export class HttpClient {
19
15
  return await this.fetch(path, options);
20
16
  }
21
17
  async fetch(path, options = {}) {
22
- const awsCreds = await this.awsCredsHelper.getCredentials();
23
- const requestOptions = {
24
- method: options.method,
25
- body: options.body,
26
- headers: (options.headers ?? {}),
27
- host: HOST,
28
- service: 'execute-api',
29
- path,
30
- };
31
- const signedOptions = aws4.sign(requestOptions, awsCreds);
32
- const signedHeaders = signedOptions.headers;
33
- const url = `https://${HOST}${path}`;
34
- options.headers = signedHeaders;
18
+ const url = `https://${HOST}/env-api${path}`;
35
19
  let response;
36
20
  try {
37
21
  response = await fetch(url, options);
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { awsCredsHelper, envService } from '../container.js';
2
+ import { envService } from '../container.js';
3
3
  import { _keys } from './_keys.js';
4
4
  import { wrap } from './_utils.js';
5
5
  export function deploy(program) {
@@ -12,7 +12,6 @@ export function deploy(program) {
12
12
  .action(wrap(handler));
13
13
  }
14
14
  async function handler(tfArgs, options) {
15
- await awsCredsHelper.ensureCredentials();
16
15
  const { cwd } = options;
17
16
  await envService.deploy(tfArgs, cwd);
18
17
  }
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { awsCredsHelper, envService } from '../container.js';
2
+ import { envService } from '../container.js';
3
3
  import { _keys } from './_keys.js';
4
4
  import { wrap } from './_utils.js';
5
5
  export function plan(program) {
@@ -13,7 +13,6 @@ export function plan(program) {
13
13
  .action(wrap(handler));
14
14
  }
15
15
  async function handler(tfArgs, options) {
16
- await awsCredsHelper.ensureCredentials();
17
16
  const { cwd } = options;
18
17
  await envService.plan(tfArgs, cwd);
19
18
  }
package/dist/container.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { S3Backend } from './backend/S3Backend.js';
2
- import { AwsCredsHelper } from './client/AwsCredsHelper.js';
3
2
  import { CliHelper, EnvApiClient, HttpClient, TerraformAdapter } from './client/index.js';
4
3
  import { ProcessRunner } from './client/ProcessRunner.js';
5
4
  import { ConfigService, EnvService } from './service/index.js';
@@ -7,15 +6,14 @@ import { LocalStateService } from './service/LocalStateService.js';
7
6
  import { LogService } from './service/LogService.js';
8
7
  const cliHelper = new CliHelper();
9
8
  const configService = new ConfigService();
10
- const awsCredsHelper = new AwsCredsHelper();
11
9
  const backends = [
12
10
  new S3Backend()
13
11
  ];
14
- const httpClient = new HttpClient(awsCredsHelper);
12
+ const httpClient = new HttpClient();
15
13
  const envApiClient = new EnvApiClient(httpClient);
16
14
  const processRunner = new ProcessRunner();
17
15
  const terraformAdapter = new TerraformAdapter(processRunner, cliHelper, backends);
18
16
  const localStateService = new LocalStateService();
19
17
  const envService = new EnvService(cliHelper, envApiClient, terraformAdapter, localStateService);
20
18
  const logService = new LogService(envApiClient, terraformAdapter, processRunner);
21
- export { awsCredsHelper, configService, envService, logService };
19
+ export { configService, envService, logService };
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.37.3",
4
+ "version": "0.38.0",
5
5
  "author": "Alex Chekulaev",
6
6
  "type": "module",
7
7
  "engines": {
@@ -55,16 +55,12 @@
55
55
  "run-ephemeral-destroy": "tsc --sourceMap true && npm run run -- destroy --cwd ../tt-gitops --force -var-file=versions.tfvars"
56
56
  },
57
57
  "dependencies": {
58
- "@aws-sdk/client-sts": "^3.716.0",
59
- "@aws-sdk/credential-providers": "^3.716.0",
60
- "aws4": "^1.13.2",
61
58
  "commander": "^14.0.0",
62
59
  "inquirer": "^13.0.0",
63
60
  "update-notifier": "^7.3.1"
64
61
  },
65
62
  "devDependencies": {
66
63
  "@stylistic/eslint-plugin": "^5.0.0",
67
- "@types/aws4": "^1.11.6",
68
64
  "@types/node": "^22.10.2",
69
65
  "@types/update-notifier": "^6.0.8",
70
66
  "@vitest/coverage-v8": "^4.0.0",
@@ -1,36 +0,0 @@
1
- import { fromEnv, fromNodeProviderChain } from '@aws-sdk/credential-providers';
2
- import { CredentialsProviderError } from '@smithy/property-provider';
3
- import { KnownException } from '../exceptions.js';
4
- export class AwsCredsHelper {
5
- creds;
6
- async ensureCredentials() {
7
- await this.getCredentials(true);
8
- }
9
- async getCredentials(printLogs = false) {
10
- if (!this.creds) {
11
- if (printLogs) {
12
- console.log('Fetching AWS credentials...');
13
- }
14
- this.creds = await this._getCredentials();
15
- }
16
- return this.creds;
17
- }
18
- async _getCredentials() {
19
- let identityProvider;
20
- if (process.env.CI) {
21
- identityProvider = fromEnv();
22
- }
23
- else {
24
- identityProvider = fromNodeProviderChain();
25
- }
26
- try {
27
- return await identityProvider();
28
- }
29
- catch (error) {
30
- if (error instanceof CredentialsProviderError) {
31
- throw new KnownException(error.message, { cause: error });
32
- }
33
- throw new Error('Unknown error fetching credentials:', { cause: error });
34
- }
35
- }
36
- }