env-secrets 0.2.0 → 0.3.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.
Files changed (60) hide show
  1. package/.devcontainer/devcontainer.json +10 -6
  2. package/.dockerignore +9 -0
  3. package/.eslintignore +4 -2
  4. package/.github/dependabot.yml +4 -0
  5. package/.github/workflows/build-main.yml +6 -2
  6. package/.github/workflows/deploy-docs.yml +50 -0
  7. package/.github/workflows/e2e-tests.yaml +54 -0
  8. package/.github/workflows/lint.yaml +6 -2
  9. package/.github/workflows/release.yml +2 -2
  10. package/.github/workflows/snyk.yaml +5 -1
  11. package/.github/workflows/unittests.yaml +9 -66
  12. package/.lintstagedrc +2 -7
  13. package/.prettierignore +6 -0
  14. package/AGENTS.md +149 -0
  15. package/Dockerfile +14 -0
  16. package/README.md +331 -13
  17. package/__e2e__/README.md +160 -0
  18. package/__e2e__/index.test.ts +334 -32
  19. package/__e2e__/setup.ts +58 -0
  20. package/__e2e__/utils/debug-logger.ts +45 -0
  21. package/__e2e__/utils/test-utils.ts +645 -0
  22. package/__tests__/index.test.ts +266 -9
  23. package/__tests__/vaults/secretsmanager.test.ts +460 -0
  24. package/__tests__/vaults/utils.test.ts +9 -9
  25. package/dist/index.js +36 -10
  26. package/dist/vaults/secretsmanager.js +17 -5
  27. package/dist/vaults/utils.js +2 -2
  28. package/docker-compose.yaml +29 -0
  29. package/docs/AWS.md +257 -0
  30. package/jest.config.js +3 -1
  31. package/jest.e2e.config.js +8 -0
  32. package/package.json +10 -7
  33. package/src/index.ts +44 -10
  34. package/src/vaults/secretsmanager.ts +16 -5
  35. package/src/vaults/utils.ts +6 -4
  36. package/website/docs/advanced-usage.mdx +399 -0
  37. package/website/docs/best-practices.mdx +416 -0
  38. package/website/docs/cli-reference.mdx +204 -0
  39. package/website/docs/examples.mdx +960 -0
  40. package/website/docs/faq.mdx +302 -0
  41. package/website/docs/index.mdx +56 -0
  42. package/website/docs/installation.mdx +30 -0
  43. package/website/docs/overview.mdx +17 -0
  44. package/website/docs/production-deployment.mdx +622 -0
  45. package/website/docs/providers/aws-secrets-manager.mdx +28 -0
  46. package/website/docs/security.mdx +122 -0
  47. package/website/docs/troubleshooting.mdx +236 -0
  48. package/website/docs/tutorials/local-dev/devcontainer-localstack.mdx +31 -0
  49. package/website/docs/tutorials/local-dev/docker-compose.mdx +22 -0
  50. package/website/docs/tutorials/local-dev/nextjs.mdx +18 -0
  51. package/website/docs/tutorials/local-dev/node-python-go.mdx +39 -0
  52. package/website/docs/tutorials/local-dev/quickstart.mdx +23 -0
  53. package/website/docusaurus.config.ts +89 -0
  54. package/website/package.json +21 -0
  55. package/website/sidebars.ts +33 -0
  56. package/website/src/css/custom.css +1 -0
  57. package/website/static/img/env-secrets.png +0 -0
  58. package/website/static/img/favicon.ico +0 -0
  59. package/website/static/img/logo.svg +4 -0
  60. package/website/yarn.lock +8764 -0
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "Node.js Development",
3
- "image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye",
3
+ "build": {
4
+ "dockerfile": "../Dockerfile",
5
+ "context": ".."
6
+ },
4
7
  "features": {
5
8
  "ghcr.io/devcontainers/features/git:1": {},
6
- "ghcr.io/devcontainers/features/github-cli:1": {}
9
+ "ghcr.io/devcontainers/features/aws-cli:1": {},
10
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {},
11
+ "ghcr.io/localstack/devcontainer-feature/localstack-cli:0": {
12
+ "awslocal": true
13
+ }
7
14
  },
8
15
  "customizations": {
9
16
  "vscode": {
@@ -11,8 +18,6 @@
11
18
  "dbaeumer.vscode-eslint",
12
19
  "esbenp.prettier-vscode",
13
20
  "ms-vscode.vscode-typescript-next",
14
- "eamodio.gitlens",
15
- "streetsidesoftware.code-spell-checker",
16
21
  "orta.vscode-jest"
17
22
  ],
18
23
  "settings": {
@@ -24,6 +29,5 @@
24
29
  }
25
30
  }
26
31
  },
27
- "postCreateCommand": "yarn install",
28
- "remoteUser": "node"
32
+ "postAttachCommand": "yarn install"
29
33
  }
package/.dockerignore ADDED
@@ -0,0 +1,9 @@
1
+ node_modules
2
+ dist
3
+ .git
4
+ .env
5
+ .vscode
6
+ *.log
7
+ tsconfig.tsbuildinfo
8
+ yarn-error.log
9
+ coverage/
package/.eslintignore CHANGED
@@ -1,2 +1,4 @@
1
- node_modules
2
- dist
1
+ node_modules/
2
+ dist/
3
+ website/build/
4
+ website/node_modules/
@@ -6,10 +6,14 @@ updates:
6
6
  schedule:
7
7
  interval: 'weekly'
8
8
  labels:
9
+ - 'npm'
9
10
  - 'dependencies'
10
11
  open-pull-requests-limit: 100
11
12
  pull-request-branch-name:
12
13
  separator: '-'
14
+ groups:
15
+ aws-sdk:
16
+ patterns: ['@aws-sdk/*']
13
17
  ignore:
14
18
  - dependency-name: 'fs-extra'
15
19
  - dependency-name: '*'
@@ -6,16 +6,20 @@ on:
6
6
  branches:
7
7
  - main
8
8
 
9
+ concurrency:
10
+ group: build-main-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
9
13
  jobs:
10
14
  build:
11
15
  runs-on: ubuntu-latest
12
16
  steps:
13
- - uses: actions/checkout@v4
17
+ - uses: actions/checkout@v5
14
18
  with:
15
19
  fetch-depth: 0
16
20
 
17
21
  - name: Set up Node.js
18
- uses: actions/setup-node@v4
22
+ uses: actions/setup-node@v5
19
23
  with:
20
24
  node-version: 20.18.3
21
25
 
@@ -0,0 +1,50 @@
1
+ name: Deploy docs (GitHub Pages)
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - 'website/**'
8
+ - '.github/workflows/deploy-docs.yml'
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+ pages: write
14
+ id-token: write
15
+
16
+ concurrency:
17
+ group: deploy-docs-${{ github.ref }}
18
+ cancel-in-progress: true
19
+
20
+ jobs:
21
+ build:
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v5
25
+ - uses: actions/setup-node@v5
26
+ with:
27
+ node-version: 20
28
+ cache: 'yarn'
29
+ cache-dependency-path: website/package.json
30
+ - name: Install deps
31
+ working-directory: website
32
+ run: yarn install
33
+ - name: Build website
34
+ working-directory: website
35
+ run: yarn build
36
+ - name: Upload artifact
37
+ uses: actions/upload-pages-artifact@v4
38
+ with:
39
+ path: website/build
40
+
41
+ deploy:
42
+ needs: build
43
+ runs-on: ubuntu-latest
44
+ environment:
45
+ name: github-pages
46
+ url: ${{ steps.deployment.outputs.page_url }}
47
+ steps:
48
+ - name: Deploy to GitHub Pages
49
+ id: deployment
50
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,54 @@
1
+ name: E2E Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ push:
8
+ branches:
9
+ - main
10
+
11
+ concurrency:
12
+ group: e2e-tests-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ e2e:
17
+ runs-on: ubuntu-latest
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v5
22
+
23
+ - name: Set up Node.js
24
+ uses: actions/setup-node@v5
25
+ with:
26
+ node-version: 24.x
27
+
28
+ - name: Set up Python
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: '3.12'
32
+
33
+ - name: Install dependencies
34
+ run: yarn --ignore-scripts --frozen-lockfile
35
+
36
+ - name: Install awslocal
37
+ run: pip install awscli-local[ver1]
38
+
39
+ - name: Start localstack
40
+ run: docker compose up -d --wait localstack
41
+
42
+ - name: Run the tests
43
+ run: yarn test:e2e
44
+
45
+ - name: Notify failures
46
+ if: failure()
47
+ uses: rtCamp/action-slack-notify@v2
48
+ env:
49
+ SLACK_LINK_NAMES: true
50
+ SLACK_MESSAGE:
51
+ # prettier-ignore
52
+ "hey @${{ github.actor }}, @mark, sorry to let you know you broke the build"
53
+ SLACK_CHANNEL: feed-github
54
+ SLACK_COLOR: ${{ job.status }}
@@ -5,6 +5,10 @@ on:
5
5
  branches:
6
6
  - main
7
7
 
8
+ concurrency:
9
+ group: lint-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
8
12
  jobs:
9
13
  run-linters:
10
14
  name: Run linters
@@ -12,10 +16,10 @@ jobs:
12
16
 
13
17
  steps:
14
18
  - name: Check out Git repository
15
- uses: actions/checkout@v4
19
+ uses: actions/checkout@v5
16
20
 
17
21
  - name: Set up Node.js
18
- uses: actions/setup-node@v4
22
+ uses: actions/setup-node@v5
19
23
  with:
20
24
  node-version: 20.18.3
21
25
 
@@ -25,7 +25,7 @@ jobs:
25
25
  runs-on: ubuntu-latest
26
26
  steps:
27
27
  - name: Clone Repository
28
- uses: actions/checkout@v4
28
+ uses: actions/checkout@v5
29
29
  with:
30
30
  fetch-depth: 0
31
31
 
@@ -35,7 +35,7 @@ jobs:
35
35
  git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
36
36
 
37
37
  - name: Set up Node.js
38
- uses: actions/setup-node@v4
38
+ uses: actions/setup-node@v5
39
39
  with:
40
40
  node-version: 20.18.3
41
41
  registry-url: 'https://registry.npmjs.org'
@@ -6,11 +6,15 @@ on:
6
6
  branches:
7
7
  - main
8
8
 
9
+ concurrency:
10
+ group: snyk-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
9
13
  jobs:
10
14
  security:
11
15
  runs-on: ubuntu-latest
12
16
  steps:
13
- - uses: actions/checkout@v4
17
+ - uses: actions/checkout@v5
14
18
  - name: Run Snyk to check for vulnerabilities
15
19
  uses: snyk/actions/node@master
16
20
  continue-on-error: true # To make sure that SARIF upload gets called
@@ -8,6 +8,10 @@ on:
8
8
  branches:
9
9
  - main
10
10
 
11
+ concurrency:
12
+ group: unit-tests-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
11
15
  jobs:
12
16
  unit-tests:
13
17
  runs-on: ubuntu-latest
@@ -18,10 +22,10 @@ jobs:
18
22
 
19
23
  steps:
20
24
  - name: Checkout repository
21
- uses: actions/checkout@v4
25
+ uses: actions/checkout@v5
22
26
 
23
27
  - name: Set up Node.js ${{ matrix.node-version }}
24
- uses: actions/setup-node@v4
28
+ uses: actions/setup-node@v5
25
29
  with:
26
30
  node-version: ${{ matrix.node-version }}
27
31
 
@@ -31,38 +35,6 @@ jobs:
31
35
  - name: Build
32
36
  run: yarn build
33
37
 
34
- - name: Run the tests
35
- run: yarn test:unit
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 }}
47
-
48
- coverage:
49
- runs-on: ubuntu-latest
50
-
51
- steps:
52
- - name: Checkout repository
53
- uses: actions/checkout@v4
54
-
55
- - name: Set up Node.js ${{ matrix.node-version }}
56
- uses: actions/setup-node@v4
57
- with:
58
- node-version: 24.x
59
-
60
- - name: Install dependencies
61
- run: yarn --ignore-scripts --frozen-lockfile
62
-
63
- - name: Build
64
- run: yarn build
65
-
66
38
  - name: Run the tests
67
39
  run: yarn test:unit:coverage
68
40
 
@@ -70,38 +42,9 @@ jobs:
70
42
  uses: codecov/codecov-action@v5
71
43
  with:
72
44
  token: ${{ secrets.CODECOV_TOKEN }}
73
-
74
- - name: Notify failures
75
- if: failure()
76
- uses: rtCamp/action-slack-notify@v2
77
- env:
78
- SLACK_LINK_NAMES: true
79
- SLACK_MESSAGE:
80
- # prettier-ignore
81
- "hey @${{ github.actor }}, @mark, sorry to let you know you broke the build"
82
- SLACK_CHANNEL: feed-github
83
- SLACK_COLOR: ${{ job.status }}
84
-
85
- e2e:
86
- runs-on: ubuntu-latest
87
-
88
- steps:
89
- - name: Checkout repository
90
- uses: actions/checkout@v4
91
-
92
- - name: Set up Node.js ${{ matrix.node-version }}
93
- uses: actions/setup-node@v4
94
- with:
95
- node-version: 24.x
96
-
97
- - name: Install dependencies
98
- run: yarn --ignore-scripts --frozen-lockfile
99
-
100
- - name: Build
101
- run: yarn build
102
-
103
- - name: Run the tests
104
- run: yarn test:e2e
45
+ directory: ./coverage
46
+ flags: unittests
47
+ name: codecov-umbrella
105
48
 
106
49
  - name: Notify failures
107
50
  if: failure()
package/.lintstagedrc CHANGED
@@ -1,9 +1,4 @@
1
1
  {
2
- "*.{js,ts}": [
3
- "prettier --write",
4
- "eslint --fix"
5
- ],
6
- "*.{json,md,yaml}": [
7
- "prettier --write"
8
- ],
2
+ "*.{js,ts}": ["prettier --write", "eslint --fix"],
3
+ "*.{json,md,yaml}": ["prettier --write"]
9
4
  }
package/.prettierignore CHANGED
@@ -1 +1,7 @@
1
+ node_modules/
1
2
  dist/
3
+ website/build/
4
+ website/node_modules/
5
+ website/.docusaurus/
6
+ coverage/
7
+ coverage-e2e/
package/AGENTS.md ADDED
@@ -0,0 +1,149 @@
1
+ # AGENTS.md
2
+
3
+ ## Project Overview
4
+
5
+ - **env-secrets**: A Node.js CLI tool that retrieves secrets from vaults and injects them as environment variables
6
+ - **Repository**: https://github.com/markcallen/env-secrets
7
+ - **Issue Tracking**: Uses GitHub issues for feature requests and bugs
8
+
9
+ ## Code Style Guidelines
10
+
11
+ ### TypeScript
12
+
13
+ - **Strict Mode**: Enabled, use proper types, avoid `any`
14
+ - **Type Definitions**: Prefer interfaces over types for object shapes
15
+ - **Generic Types**: Use when appropriate for reusable components
16
+
17
+ ### Imports
18
+
19
+ - **Order**: Group by: external libraries, internal modules, relative imports
20
+ - **Style**: ES6 imports (`import`/`export`)
21
+ - **Barrel Exports**: Use index files for clean import paths
22
+
23
+ ### Formatting
24
+
25
+ - **Prettier**: Default config (.prettierrc), 2-space indentation
26
+ - **Line Length**: Let Prettier handle line wrapping
27
+ - **Trailing Commas**: Use in objects and arrays
28
+
29
+ ### Naming Conventions
30
+
31
+ - **Variables/Functions**: camelCase
32
+ - **Components/Types**: PascalCase
33
+ - **Constants**: UPPER_CASE
34
+ - **Files**: kebab-case for files, PascalCase for components
35
+
36
+ ## Development Workflow
37
+
38
+ ### Pre-commit Hooks
39
+
40
+ - Husky is configured for pre-commit hooks
41
+ - lint-staged runs prettier and eslint on staged files
42
+
43
+ ### Quality Checks
44
+
45
+ Always run quaity checks after creating or modifing files
46
+
47
+ - **Linting**: `yarn lint` - runs ESLint with TypeScript support
48
+ - **Formatting**: `yarn prettier:fix` - formats code with Prettier
49
+ - **Type Checking**: `yarn build` - compiles TypeScript and checks types
50
+
51
+ ### Testing Strategy
52
+
53
+ Always run unit tests after creating or modifying files.
54
+ Always run end to end tests before pushing code to a remote git repository.
55
+
56
+ - **Unit Tests**: Jest framework, located in `__tests__/`
57
+ - **E2E Tests**: Located in `__e2e__/`
58
+ - **Coverage**: Run `yarn test:unit:coverage` for coverage reports
59
+ - **Test Commands**:
60
+ - `yarn test` - runs all tests
61
+ - `yarn test:unit` - runs unit tests only
62
+ - `yarn test:e2e` - builds and runs e2e tests
63
+
64
+ ## Project Structure
65
+
66
+ ```
67
+ src/ # Source code
68
+ ├── index.ts # Main entry point
69
+ ├── aws.ts # AWS Secrets Manager integration
70
+ └── types.ts # TypeScript type definitions
71
+
72
+ __tests__/ # Unit tests
73
+ __e2e__/ # End-to-end tests
74
+ docs/ # Documentation
75
+ website/ # Documentation website
76
+ dist/ # Compiled output (generated)
77
+ ```
78
+
79
+ ## Dependencies and Tools
80
+
81
+ ### Key Dependencies
82
+
83
+ - **AWS SDK**: For Secrets Manager integration
84
+ - **Commander**: CLI argument parsing
85
+ - **Debug**: Debug logging support
86
+
87
+ ### Development Tools
88
+
89
+ - **TypeScript**: 4.9.5 with strict mode
90
+ - **ESLint**: Code linting with TypeScript support
91
+ - **Prettier**: Code formatting
92
+ - **Jest**: Testing framework
93
+ - **Husky**: Git hooks
94
+ - **lint-staged**: Pre-commit linting
95
+
96
+ ## Common Commands
97
+
98
+ ### Development
99
+
100
+ ```bash
101
+ yarn build # Build the project
102
+ yarn start # Run the built application
103
+ yarn lint # Run ESLint
104
+ yarn prettier:fix # Format code with Prettier
105
+ yarn test # Run all tests
106
+ yarn test:unit # Run unit tests only
107
+ yarn test:e2e # Run e2e tests
108
+ ```
109
+
110
+ ### Quality Assurance
111
+
112
+ ```bash
113
+ yarn prettier:check # Check formatting without fixing
114
+ yarn test:unit:coverage # Run tests with coverage
115
+ ```
116
+
117
+ ## Contributing
118
+
119
+ ### Before Submitting
120
+
121
+ 1. Run `yarn prettier:fix && yarn lint` to ensure code quality
122
+ 2. Run `yarn test` to ensure all tests pass
123
+ 3. Update tests for new features or bug fixes
124
+ 4. Update documentation if needed
125
+
126
+ ### Pull Request Process
127
+
128
+ 1. Create a feature branch from `main`
129
+ 2. Make your changes following the code style guidelines
130
+ 3. Add tests for new functionality
131
+ 4. Ensure all CI checks pass
132
+ 5. Submit a pull request with a clear description
133
+
134
+ ## Development Environment
135
+
136
+ ### Prerequisites
137
+
138
+ - Node.js 18.0.0 or higher (see .nvmrc)
139
+ - Yarn package manager
140
+ - AWS CLI (for testing AWS integration)
141
+
142
+ ### Setup
143
+
144
+ ```bash
145
+ git clone https://github.com/markcallen/env-secrets.git
146
+ cd env-secrets
147
+ yarn install
148
+ yarn build
149
+ ```
package/Dockerfile ADDED
@@ -0,0 +1,14 @@
1
+ FROM node:20-bookworm
2
+
3
+ WORKDIR /app
4
+
5
+ COPY package.json yarn.lock ./
6
+ RUN yarn install --frozen-lockfile --ignore-scripts
7
+
8
+ COPY tsconfig.json .
9
+ COPY src/ src
10
+
11
+ # build the code
12
+ RUN yarn build
13
+
14
+ ENTRYPOINT [ "yarn", "start" ]