env-secrets 0.1.3 → 0.1.7

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/.eslintrc CHANGED
@@ -8,8 +8,11 @@
8
8
  "plugin:@typescript-eslint/recommended",
9
9
  "prettier"
10
10
  ],
11
+ "env": {
12
+ "jest": true
13
+ },
11
14
  "rules": {
12
- "no-console": 1,
13
- "prettier/prettier": 2
15
+ "no-console": "warn",
16
+ "prettier/prettier": "error"
14
17
  }
15
18
  }
@@ -1,16 +1,16 @@
1
1
  version: 2
2
2
  updates:
3
- - package-ecosystem: "npm"
3
+ - package-ecosystem: 'npm'
4
4
  versioning-strategy: increase
5
- directory: "/"
5
+ directory: '/'
6
6
  schedule:
7
- interval: "monthly"
7
+ interval: 'monthly'
8
8
  labels:
9
- - "dependencies"
9
+ - 'dependencies'
10
10
  open-pull-requests-limit: 100
11
11
  pull-request-branch-name:
12
- separator: "-"
12
+ separator: '-'
13
13
  ignore:
14
- - dependency-name: "fs-extra"
15
- - dependency-name: "*"
16
- update-types: ["version-update:semver-major"]
14
+ - dependency-name: 'fs-extra'
15
+ - dependency-name: '*'
16
+ update-types: ['version-update:semver-major']
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: Build
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+
17
+ - name: Set up Node.js
18
+ uses: actions/setup-node@v3
19
+ with:
20
+ node-version: 18.14.0
21
+
22
+ - name: Install Node.js dependencies
23
+ run: yarn
24
+
25
+ - name: Slack Notification
26
+ uses: rtCamp/action-slack-notify@v2
27
+ env:
28
+ SLACK_CHANNEL: feed-github
29
+ SLACK_COLOR: ${{ job.status }}
30
+ SLACK_ICON: https://avatars.githubusercontent.com/u/82425418?s=200&v=4
31
+ SLACK_TITLE: 'env-secrets to dev :rocket:'
32
+ SLACK_USERNAME: env-secrets-bot
33
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
34
+
35
+ - name: Notify failures
36
+ if: failure()
37
+ uses: rtCamp/action-slack-notify@v2
38
+ env:
39
+ SLACK_LINK_NAMES: true
40
+ SLACK_MESSAGE:
41
+ # prettier-ignore
42
+ "hey @${{ github.actor }}, @mark, sorry to let you know you broke the build"
43
+ SLACK_CHANNEL: feed-github
44
+ SLACK_COLOR: ${{ job.status }}
45
+ SLACK_ICON: https://avatars.githubusercontent.com/u/82425418?s=200&v=4
46
+ SLACK_TITLE: 'Failed: env-secrets to dev :fire:'
47
+ SLACK_USERNAME: env-secrets-bot
48
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -0,0 +1,31 @@
1
+ name: Lint
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ run-linters:
10
+ name: Run linters
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Check out Git repository
15
+ uses: actions/checkout@v3
16
+
17
+ - name: Set up Node.js
18
+ uses: actions/setup-node@v3
19
+ with:
20
+ node-version: 18.14.2
21
+
22
+ # ESLint and Prettier must be in `package.json`
23
+ - name: Install Node.js dependencies
24
+ run: yarn --frozen-lockfile
25
+
26
+ - name: Run linters
27
+ uses: wearerequired/lint-action@v1
28
+ with:
29
+ eslint: true
30
+ eslint_extensions: js,ts
31
+ prettier: true
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: Release and Publish
3
+
4
+ on:
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ release:
9
+ if: ${{ github.ref == 'refs/heads/main' }}
10
+ name: Create Github Release
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Clone Repository
14
+ uses: actions/checkout@v3
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: git config
19
+ run: |
20
+ git config user.name "${GITHUB_ACTOR}"
21
+ git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
22
+
23
+ - name: Set up Node.js
24
+ uses: actions/setup-node@v3
25
+ with:
26
+ node-version: 18.14.0
27
+ registry-url: 'https://registry.npmjs.org'
28
+
29
+ - name: Install Node.js dependencies
30
+ run: yarn
31
+
32
+ - name: Install Node.js dependencies
33
+ run: yarn build
34
+
35
+ - name: Github release
36
+ run: yarn release patch --ci
37
+ env:
38
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
40
+
41
+ - name: Notify failures
42
+ if: failure()
43
+ uses: rtCamp/action-slack-notify@v2
44
+ env:
45
+ SLACK_LINK_NAMES: true
46
+ SLACK_MESSAGE:
47
+ # prettier-ignore
48
+ "hey @${{ github.actor }}, @mark, sorry to let you know you broke the build"
49
+ SLACK_CHANNEL: feed-github
50
+ SLACK_COLOR: ${{ job.status }}
51
+ SLACK_ICON: https://avatars.githubusercontent.com/u/82425418?s=200&v=4
52
+ SLACK_TITLE: 'Failed: cld-cli to dev :fire:'
53
+ SLACK_USERNAME: cld-cli-bot
54
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -0,0 +1,27 @@
1
+ name: Synk analysis
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ security:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v3
10
+ - name: Run Snyk to check for vulnerabilities
11
+ uses: snyk/actions/node@master
12
+ env:
13
+ SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
14
+ - name: Notify failures
15
+ if: failure()
16
+ uses: rtCamp/action-slack-notify@v2
17
+ env:
18
+ SLACK_LINK_NAMES: true
19
+ SLACK_MESSAGE:
20
+ # prettier-ignore
21
+ "hey @${{ github.actor }}, @mark, sorry to let you know you broke the build"
22
+ SLACK_CHANNEL: feed-github
23
+ SLACK_COLOR: ${{ job.status }}
24
+ SLACK_ICON: https://avatars.githubusercontent.com/u/82425418?s=200&v=4
25
+ SLACK_TITLE: 'Failed: env-secrets to dev :fire:'
26
+ SLACK_USERNAME: env-secrets-bot
27
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -0,0 +1,46 @@
1
+ name: Unit Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ push:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+
15
+ strategy:
16
+ matrix:
17
+ node-version: [14.x, 16.x, 18.x]
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v2
22
+
23
+ - name: Set up Node.js ${{ matrix.node-version }}
24
+ uses: actions/setup-node@v3
25
+ with:
26
+ node-version: ${{ matrix.node-version }}
27
+
28
+ - name: Install dependencies
29
+ run: yarn
30
+
31
+ - name: Build
32
+ run: yarn build
33
+
34
+ - name: Run the tests
35
+ run: yarn test --coverage
36
+
37
+ - name: Notify failures
38
+ if: failure()
39
+ uses: rtCamp/action-slack-notify@v2
40
+ env:
41
+ SLACK_LINK_NAMES: true
42
+ SLACK_MESSAGE:
43
+ # prettier-ignore
44
+ "hey @${{ github.actor }}, @mark, sorry to let you know you broke the build"
45
+ SLACK_CHANNEL: feed-github
46
+ SLACK_COLOR: ${{ job.status }}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
package/.lintstagedrc ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "*.{js,ts}": [
3
+ "prettier --write",
4
+ "eslint --fix"
5
+ ],
6
+ "*.{json,md,yaml}": [
7
+ "prettier --write"
8
+ ],
9
+ }
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v16.17.0
1
+ v18.14.2
@@ -0,0 +1 @@
1
+ dist/
@@ -0,0 +1,12 @@
1
+ {
2
+ "git": {
3
+ "commitMessage": "chore: release v${version}"
4
+ },
5
+ "github": {
6
+ "release": true,
7
+ "releaseNotes": "./generate-release-notes.sh ${tagName}"
8
+ },
9
+ "npm": {
10
+ "publish": true
11
+ }
12
+ }
package/README.md CHANGED
@@ -2,16 +2,101 @@
2
2
 
3
3
  Get secrets from a vault and inject them as environment variables
4
4
 
5
+ [![Version](https://img.shields.io/npm/v/env-secrets.svg)](https://npmjs.org/package/env-secrets)
6
+ [![build](https://img.shields.io/github/actions/workflow/status/markcallen/env-secrets/build-main.yml)](https://github.com/markcallen/env-secrets/tree/main)
7
+ [![test](https://img.shields.io/github/actions/workflow/status/markcallen/env-secrets/unittests.yaml)](https://github.com/markcallen/env-secrets/tree/main)
8
+ ![vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/markcallen/env-secrets)
9
+ [![Downloads/week](https://img.shields.io/npm/dw/env-secrets.svg)](https://npmjs.org/package/env-secrets)
10
+ [![License](https://img.shields.io/npm/l/env-secrets.svg)](https://github.com/markcallen/env-secrets/blob/main/LICENSE)
11
+
5
12
  ## Setup
6
13
 
7
14
  Install node
8
15
 
9
- ## Debug
16
+ ## Installation
17
+
18
+ Globally
19
+
20
+ ```
21
+ npm install -g env-secrets
22
+ ```
23
+
24
+ Project specific
25
+
26
+ ```
27
+ npm install env-secrets
28
+ ```
29
+
30
+ when using project specific run using npx
31
+
32
+ ```
33
+ npx env-secrets ...
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ AWS
39
+
40
+ ```
41
+ env-secrets aws -s <secret name> -r <region> -p <profile> -- <program to run>
42
+ ```
43
+
44
+ `<secret name>` is the name of the secret in Secrets Manager
45
+
46
+ `<region>` is the region where the secret to stored. It is optional, the AWS_DEFAULT_REGION environment variable will be used instead.
47
+
48
+ `<profile>` is the local aws profile to use. It is optional, the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables will be used instead.
49
+
50
+ example:
51
+
52
+ ```
53
+ env-secrets aws -s local/sample -r us-east-1 -p marka -- env
54
+ ```
55
+
56
+ Create a Secret using AWS cli
10
57
 
11
- Use debug-js pass in env-secrets for the main application and env-secrets:<vault> for vault specific debugging
58
+ ```
59
+ aws secretsmanager create-secret \
60
+ --region us-east-1 \
61
+ --profile marka \
62
+ --name local/sample \
63
+ --description "local/sample secret" \
64
+ --secret-string "{\"user\":\"marka\",\"password\":\"mypassword\"}"
65
+ ```
66
+
67
+ ## Development
68
+
69
+ Setup node using [nvm](https://github.com/nvm-sh/nvm). Or use node 18.x.
70
+
71
+ ```
72
+ nvm use
73
+ ```
74
+
75
+ Install yarn
76
+
77
+ ```
78
+ npm install -y yarn
79
+ ```
80
+
81
+ Setup
82
+
83
+ ```
84
+ yarn
85
+ ```
86
+
87
+ Run
12
88
 
13
89
  ```
14
- DEBUG=env-secrets,env-secrets:secretsmanager npx ts-node src/index.ts aws -s local/sample -r ca-central-1 -p marka -- env
90
+ npx ts-node src/index.ts aws -s local/sample -r us-east-1 -p marka -- env
91
+ ```
92
+
93
+ ### Debug
94
+
95
+ Uses debug-js to show debug logs by passing in env-secrets for the main application
96
+ and env-secrets:{vault} for vault specific debugging
97
+
98
+ ```
99
+ DEBUG=env-secrets,env-secrets:secretsmanager npx ts-node src/index.ts aws -s local/sample -r us-east-1 -p marka -- env
15
100
  ```
16
101
 
17
102
  ## Publishing
@@ -33,3 +118,13 @@ Run:
33
118
  ```
34
119
  npm run release -- patch
35
120
  ```
121
+
122
+ ## License
123
+
124
+ Distributed under the MIT License. See `LICENSE` for more information.
125
+
126
+ ## Contact
127
+
128
+ Mark C Allen - [@markcallen](https://www.linkedin.com/in/markcallen/)
129
+
130
+ Project Link: [https://github.com/markcallen/env-secrets](https://github.com/markcallen/env-secrets)
@@ -0,0 +1,37 @@
1
+ import * as path from 'path';
2
+ import { exec } from 'child_process';
3
+
4
+ type Cli = {
5
+ code: number;
6
+ error: Error;
7
+ stdout: any;
8
+ stderr: any;
9
+ };
10
+
11
+ describe('CLI tests', () => {
12
+ test('general help', async () => {
13
+ const result = await cli(['-h'], '.');
14
+ expect(result.code).toBe(0);
15
+ });
16
+ test('aws help', async () => {
17
+ const result = await cli(['aws -h'], '.');
18
+ expect(result.code).toBe(0);
19
+ });
20
+ });
21
+
22
+ function cli(args, cwd): Promise<Cli> {
23
+ return new Promise((resolve) => {
24
+ exec(
25
+ `node ${path.resolve('./dist/index')} ${args.join(' ')}`,
26
+ { cwd },
27
+ (error, stdout, stderr) => {
28
+ resolve({
29
+ code: error && error.code ? error.code : 0,
30
+ error,
31
+ stdout,
32
+ stderr
33
+ });
34
+ }
35
+ );
36
+ });
37
+ }
package/dist/index.js CHANGED
@@ -20,10 +20,12 @@ const version_1 = require("./version");
20
20
  const secretsmanager_1 = require("./vaults/secretsmanager");
21
21
  const debug = (0, debug_1.default)('env-secrets');
22
22
  const program = new commander_1.Command();
23
+ // main program
23
24
  program
24
25
  .name('env-secrets')
25
26
  .description('pull secrets from vaults and inject them into the running environment')
26
27
  .version(version_1.LIB_VERSION);
28
+ // aws secretsmanager
27
29
  program
28
30
  .command('aws')
29
31
  .description('get secrets from AWS secrets manager')
@@ -35,7 +37,7 @@ program
35
37
  let env = yield (0, secretsmanager_1.secretsmanager)(options);
36
38
  env = Object.assign({}, process.env, env);
37
39
  debug(env);
38
- if (program) {
40
+ if (program && program.length > 0) {
39
41
  debug(`${program[0]} ${program.slice(1)}`);
40
42
  (0, node_child_process_1.spawn)(program[0], program.slice(1), {
41
43
  stdio: 'inherit',
@@ -18,7 +18,7 @@ const debug_1 = __importDefault(require("debug"));
18
18
  const debug = (0, debug_1.default)('env-secrets:secretsmanager');
19
19
  const checkConnection = () => __awaiter(void 0, void 0, void 0, function* () {
20
20
  const sts = new aws_sdk_1.default.STS();
21
- const myPromise = new Promise((resolve, reject) => {
21
+ const getCallerPromise = new Promise((resolve, reject) => {
22
22
  sts.getCallerIdentity({}, (err, data) => {
23
23
  if (err)
24
24
  reject(err);
@@ -29,7 +29,7 @@ const checkConnection = () => __awaiter(void 0, void 0, void 0, function* () {
29
29
  });
30
30
  let value;
31
31
  let err;
32
- yield myPromise
32
+ yield getCallerPromise
33
33
  .then((v) => {
34
34
  value = v;
35
35
  })
@@ -38,6 +38,7 @@ const checkConnection = () => __awaiter(void 0, void 0, void 0, function* () {
38
38
  });
39
39
  if (err) {
40
40
  console.error(err);
41
+ return false;
41
42
  }
42
43
  debug(value);
43
44
  return !!value;
@@ -46,23 +47,23 @@ const secretsmanager = (options) => __awaiter(void 0, void 0, void 0, function*
46
47
  const { secret, profile, region } = options;
47
48
  const { AWS_ACCESS_KEY_ID: awsAccessKeyId, AWS_SECRET_ACCESS_KEY: awsSecretAccessKey } = process.env;
48
49
  if (profile) {
49
- console.log(`Using profile: ${profile}`);
50
+ debug(`Using profile: ${profile}`);
50
51
  const credentials = new aws_sdk_1.default.SharedIniFileCredentials({
51
52
  profile
52
53
  });
53
54
  aws_sdk_1.default.config.credentials = credentials;
54
55
  }
55
56
  else if (awsAccessKeyId && awsSecretAccessKey) {
56
- console.log('Using environment variables');
57
+ debug('Using environment variables');
57
58
  }
58
59
  else {
59
- console.log('Using profile: default');
60
+ debug('Using profile: default');
60
61
  }
61
62
  if (region) {
62
63
  aws_sdk_1.default.config.update({ region });
63
64
  }
64
65
  if (!aws_sdk_1.default.config.region) {
65
- console.log('no region set');
66
+ debug('no region set');
66
67
  }
67
68
  const connected = yield checkConnection();
68
69
  if (connected) {
@@ -96,5 +97,8 @@ const secretsmanager = (options) => __awaiter(void 0, void 0, void 0, function*
96
97
  }
97
98
  return {};
98
99
  }
100
+ else {
101
+ console.error('Unable to connect to AWS');
102
+ }
99
103
  });
100
104
  exports.secretsmanager = secretsmanager;
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ #
3
+
4
+ url=$(git config --get remote.origin.url)
5
+
6
+ re="^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+)(\.git)?$"
7
+
8
+ if [[ $url =~ $re ]]; then
9
+ protocol=${BASH_REMATCH[1]}
10
+ separator=${BASH_REMATCH[2]}
11
+ hostname=${BASH_REMATCH[3]}
12
+ user=${BASH_REMATCH[4]}
13
+ repo=$(basename ${BASH_REMATCH[5]} .git)
14
+ fi
15
+
16
+ REPO=$user/$repo
17
+
18
+ LAST=$(curl -s -L \
19
+ -H "Accept: application/vnd.github+json" \
20
+ -H "Authorization: Bearer ${GITHUB_TOKEN}" \
21
+ -H "X-GitHub-Api-Version: 2022-11-28" \
22
+ https://api.github.com/repos/${REPO}/releases | jq -r .[0].tag_name)
23
+
24
+ LATEST=$1
25
+
26
+ echo **Full Changelog**: https://github.com/${REPO}/compare/${LAST}...${LATEST}
27
+
28
+ git log --pretty="- %s" ${LAST}..HEAD
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ // eslint-disable-next-line no-undef
3
+ module.exports = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: 'node'
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "env-secrets",
3
- "version": "0.1.3",
3
+ "version": "0.1.7",
4
4
  "description": "get secrets from a secrets vault and inject them into the running environment",
5
5
  "main": "index.js",
6
6
  "author": "Mark C Allen (@markcallen)",
@@ -9,32 +9,51 @@
9
9
  "license": "MIT",
10
10
  "private": false,
11
11
  "scripts": {
12
+ "prepare": "husky install",
12
13
  "build": "rimraf ./dist && tsc -b src",
13
14
  "postbuild": "chmod 755 ./dist/index.js",
14
- "lint": "eslint . --ext .ts",
15
+ "lint": "eslint . --ext .ts,.js",
15
16
  "release": "release-it",
16
17
  "prettier:fix": "npx prettier --write .",
17
- "prettier:check": "npx prettier --check ."
18
+ "prettier:check": "npx prettier --check .",
19
+ "test": "jest"
18
20
  },
19
21
  "devDependencies": {
20
22
  "@types/debug": "^4.1.7",
21
- "@types/node": "^18.11.18",
22
- "@typescript-eslint/eslint-plugin": "^5.48.0",
23
- "@typescript-eslint/parser": "^5.48.0",
24
- "eslint": "^8.31.0",
25
- "eslint-config-prettier": "^8.5.0",
23
+ "@types/jest": "^29.4.0",
24
+ "@types/node": "^18.15.11",
25
+ "@typescript-eslint/eslint-plugin": "^5.57.1",
26
+ "@typescript-eslint/parser": "^5.57.0",
27
+ "eslint": "^8.37.0",
28
+ "eslint-config-prettier": "^8.8.0",
26
29
  "eslint-plugin-prettier": "^4.2.1",
27
- "prettier": "^2.8.1",
28
- "release-it": "^15.6.0",
30
+ "husky": "^8.0.3",
31
+ "jest": "^29.5.0",
32
+ "lint-staged": "^13.2.0",
33
+ "prettier": "^2.8.7",
34
+ "release-it": "^15.10.1",
29
35
  "rimraf": "^3.0.2",
36
+ "ts-jest": "^29.0.5",
30
37
  "ts-node": "^10.9.1",
31
- "typescript": "^4.9.4"
38
+ "typescript": "^4.9.5"
32
39
  },
33
40
  "dependencies": {
34
- "aws-sdk": "^2.1287.0",
35
- "commander": "^9.4.1",
41
+ "aws-sdk": "^2.1351.0",
42
+ "commander": "^9.5.0",
36
43
  "debug": "^4.3.4"
37
44
  },
45
+ "lint-staged": {
46
+ "*.{ts,js}": [
47
+ "prettier --write .",
48
+ "eslint --fix ."
49
+ ],
50
+ "*.{json,md,yaml}": [
51
+ "prettier --write ."
52
+ ]
53
+ },
54
+ "publishConfig": {
55
+ "registry": "https://registry.npmjs.org/"
56
+ },
38
57
  "bin": {
39
58
  "env-secrets": "./dist/index.js"
40
59
  }
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ const debug = Debug('env-secrets');
11
11
 
12
12
  const program = new Command();
13
13
 
14
+ // main program
14
15
  program
15
16
  .name('env-secrets')
16
17
  .description(
@@ -18,6 +19,7 @@ program
18
19
  )
19
20
  .version(LIB_VERSION);
20
21
 
22
+ // aws secretsmanager
21
23
  program
22
24
  .command('aws')
23
25
  .description('get secrets from AWS secrets manager')
@@ -29,7 +31,7 @@ program
29
31
  let env = await secretsmanager(options);
30
32
  env = Object.assign({}, process.env, env);
31
33
  debug(env);
32
- if (program) {
34
+ if (program && program.length > 0) {
33
35
  debug(`${program[0]} ${program.slice(1)}`);
34
36
  spawn(program[0], program.slice(1), {
35
37
  stdio: 'inherit',
package/src/tsconfig.json CHANGED
@@ -1,9 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "es2016",
4
- "lib": [
5
- "es6"
6
- ],
4
+ "lib": ["es6"],
7
5
  "module": "commonjs",
8
6
  "rootDir": ".",
9
7
  "resolveJsonModule": true,
@@ -12,7 +12,7 @@ interface secretsmanagerType {
12
12
  const checkConnection = async () => {
13
13
  const sts = new AWS.STS();
14
14
 
15
- const myPromise = new Promise((resolve, reject) => {
15
+ const getCallerPromise = new Promise((resolve, reject) => {
16
16
  sts.getCallerIdentity({}, (err, data) => {
17
17
  if (err) reject(err);
18
18
  else {
@@ -24,7 +24,7 @@ const checkConnection = async () => {
24
24
  let value;
25
25
  let err;
26
26
 
27
- await myPromise
27
+ await getCallerPromise
28
28
  .then((v) => {
29
29
  value = v;
30
30
  })
@@ -34,6 +34,7 @@ const checkConnection = async () => {
34
34
 
35
35
  if (err) {
36
36
  console.error(err);
37
+ return false;
37
38
  }
38
39
  debug(value);
39
40
 
@@ -47,22 +48,22 @@ export const secretsmanager = async (options: secretsmanagerType) => {
47
48
  AWS_SECRET_ACCESS_KEY: awsSecretAccessKey
48
49
  } = process.env;
49
50
  if (profile) {
50
- console.log(`Using profile: ${profile}`);
51
+ debug(`Using profile: ${profile}`);
51
52
  const credentials = new AWS.SharedIniFileCredentials({
52
53
  profile
53
54
  });
54
55
  AWS.config.credentials = credentials;
55
56
  } else if (awsAccessKeyId && awsSecretAccessKey) {
56
- console.log('Using environment variables');
57
+ debug('Using environment variables');
57
58
  } else {
58
- console.log('Using profile: default');
59
+ debug('Using profile: default');
59
60
  }
60
61
 
61
62
  if (region) {
62
63
  AWS.config.update({ region });
63
64
  }
64
65
  if (!AWS.config.region) {
65
- console.log('no region set');
66
+ debug('no region set');
66
67
  }
67
68
 
68
69
  const connected = await checkConnection();
@@ -97,5 +98,7 @@ export const secretsmanager = async (options: secretsmanagerType) => {
97
98
  }
98
99
 
99
100
  return {};
101
+ } else {
102
+ console.error('Unable to connect to AWS');
100
103
  }
101
104
  };
package/tsconfig.json CHANGED
@@ -3,9 +3,8 @@
3
3
  "rootDir": ".",
4
4
  "outDir": ".",
5
5
  "resolveJsonModule": true,
6
+ "esModuleInterop": true,
6
7
  "composite": true
7
8
  },
8
- "files": [
9
- "package.json"
10
- ]
9
+ "files": ["package.json"]
11
10
  }