envilder 0.3.0 β 0.3.1
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/.gitattributes +66 -66
- package/.gitconfig +2 -2
- package/.github/dependabot.yml +39 -39
- package/.github/pull_request_template.md +20 -20
- package/.github/workflows/codeql-analysis.yml +49 -49
- package/.github/workflows/coverage-report.yml +73 -73
- package/.github/workflows/publish.yml +78 -0
- package/.github/workflows/unit-tests.yml +51 -48
- package/LICENSE +21 -21
- package/README.md +144 -144
- package/biome.json +2 -11
- package/package.json +17 -19
- package/src/cli/cliRunner.ts +0 -1
- package/tests/index.test.ts +11 -22
- package/tests/sample/autogenerated.env +1 -0
- package/vitest.config.js +12 -12
- package/lib/cli/cliRunner.d.ts +0 -10
- package/lib/cli/cliRunner.d.ts.map +0 -1
- package/lib/cli/cliRunner.js +0 -41
- package/lib/cli/cliRunner.js.map +0 -1
- package/lib/index.d.ts +0 -11
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -116
- package/lib/index.js.map +0 -1
- /package/tests/sample/{param_map.json β param-map.json} +0 -0
|
@@ -1,48 +1,51 @@
|
|
|
1
|
-
name: π± unit-tests
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch: {}
|
|
5
|
-
|
|
6
|
-
pull_request:
|
|
7
|
-
branches:
|
|
8
|
-
- "*"
|
|
9
|
-
types:
|
|
10
|
-
- opened
|
|
11
|
-
- reopened
|
|
12
|
-
- synchronize
|
|
13
|
-
- ready_for_review
|
|
14
|
-
paths:
|
|
15
|
-
- ".github/workflows/unit-tests.yml"
|
|
16
|
-
- "src/**"
|
|
17
|
-
|
|
18
|
-
concurrency:
|
|
19
|
-
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
|
|
20
|
-
cancel-in-progress: true
|
|
21
|
-
|
|
22
|
-
jobs:
|
|
23
|
-
envilder-test:
|
|
24
|
-
runs-on: ubuntu-24.04
|
|
25
|
-
if: ${{ !github.event.pull_request.draft }}
|
|
26
|
-
timeout-minutes: 30
|
|
27
|
-
|
|
28
|
-
steps:
|
|
29
|
-
- name: π βοΈ Checkout
|
|
30
|
-
uses: actions/checkout@v4
|
|
31
|
-
|
|
32
|
-
- name: π οΈ Setup Node.js with Cache
|
|
33
|
-
uses: actions/setup-node@v4
|
|
34
|
-
with:
|
|
35
|
-
node-version: '20.x'
|
|
36
|
-
cache: 'yarn'
|
|
37
|
-
|
|
38
|
-
- name: π¦ Install packages
|
|
39
|
-
run: yarn install
|
|
40
|
-
|
|
41
|
-
- name: π Run
|
|
42
|
-
run: yarn
|
|
43
|
-
|
|
44
|
-
- name:
|
|
45
|
-
run: yarn
|
|
46
|
-
|
|
47
|
-
- name:
|
|
48
|
-
run: yarn
|
|
1
|
+
name: π± unit-tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch: {}
|
|
5
|
+
|
|
6
|
+
pull_request:
|
|
7
|
+
branches:
|
|
8
|
+
- "*"
|
|
9
|
+
types:
|
|
10
|
+
- opened
|
|
11
|
+
- reopened
|
|
12
|
+
- synchronize
|
|
13
|
+
- ready_for_review
|
|
14
|
+
paths:
|
|
15
|
+
- ".github/workflows/unit-tests.yml"
|
|
16
|
+
- "src/**"
|
|
17
|
+
|
|
18
|
+
concurrency:
|
|
19
|
+
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
envilder-test:
|
|
24
|
+
runs-on: ubuntu-24.04
|
|
25
|
+
if: ${{ !github.event.pull_request.draft }}
|
|
26
|
+
timeout-minutes: 30
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- name: π βοΈ Checkout
|
|
30
|
+
uses: actions/checkout@v4
|
|
31
|
+
|
|
32
|
+
- name: π οΈ Setup Node.js with Cache
|
|
33
|
+
uses: actions/setup-node@v4
|
|
34
|
+
with:
|
|
35
|
+
node-version: '20.x'
|
|
36
|
+
cache: 'yarn'
|
|
37
|
+
|
|
38
|
+
- name: π¦ Install packages
|
|
39
|
+
run: yarn install --frozen-lockfile
|
|
40
|
+
|
|
41
|
+
- name: π Run formatting checker
|
|
42
|
+
run: yarn format
|
|
43
|
+
|
|
44
|
+
- name: π Run code quality checker
|
|
45
|
+
run: yarn lint
|
|
46
|
+
|
|
47
|
+
- name: π§ Build
|
|
48
|
+
run: yarn build
|
|
49
|
+
|
|
50
|
+
- name: π΄ββοΈ Run unit tests
|
|
51
|
+
run: yarn test
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 MarΓ§al Albert
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 MarΓ§al Albert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
Envilder is a CLI tool for managing AWS SSM Parameter Store parameters and automatically generating the required
|
|
4
|
-
`.env` file. This tool simplifies project environment variable management, avoiding manual updates and ensuring
|
|
5
|
-
consistency across environments.
|
|
6
|
-
|
|
7
|
-
# β¨ Features
|
|
8
|
-
|
|
9
|
-
- π Fetch parameters securely from AWS SSM Parameter Store.
|
|
10
|
-
- β‘ Automatically generates a `.env` file with specified parameters.
|
|
11
|
-
- π‘οΈ Handles encrypted SSM parameters.
|
|
12
|
-
- πͺΆ Lightweight and simple to use.
|
|
13
|
-
- π Support for multiple AWS profiles.
|
|
14
|
-
|
|
15
|
-
# Prerequisites
|
|
16
|
-
|
|
17
|
-
Before using `Envilder`, ensure that you have the AWS CLI installed and properly configured on your local
|
|
18
|
-
machine. This configuration is required for `Envilder` to access and manage parameters in AWS SSM.
|
|
19
|
-
|
|
20
|
-
## AWS CLI Installation & Configuration
|
|
21
|
-
|
|
22
|
-
1. Install the AWS CLI by following the instructions [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
|
|
23
|
-
2. After installation, configure the AWS CLI using the following command:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
aws configure
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
You'll be prompted to provide:
|
|
30
|
-
- AWS Access Key ID
|
|
31
|
-
- AWS Secret Access Key
|
|
32
|
-
- Default region name (e.g., `us-east-1`)
|
|
33
|
-
- Default output format (e.g., `json`)
|
|
34
|
-
|
|
35
|
-
Make sure that the AWS credentials you're using have the appropriate permissions to access the SSM Parameter
|
|
36
|
-
Store in your AWS account.
|
|
37
|
-
|
|
38
|
-
# Installation
|
|
39
|
-
|
|
40
|
-
You can install `Envilder` globally using yarn. This will allow you to use the `envilder` command from any
|
|
41
|
-
directory on your system.
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
yarn global add envilder
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
# π¦ Installation
|
|
48
|
-
|
|
49
|
-
You can install **envilder** globally or locally using npm:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm install -g envilder
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
# π Usage
|
|
56
|
-
|
|
57
|
-
Envilder requires two arguments:
|
|
58
|
-
|
|
59
|
-
- `--map <path>`: Path to a JSON file mapping environment variable names to SSM parameters.
|
|
60
|
-
- `--envfile <path>`: Path where the generated .env file will be saved.
|
|
61
|
-
|
|
62
|
-
Optional arguments:
|
|
63
|
-
|
|
64
|
-
- `--profile <name>`: AWS CLI profile to use for credentials (if not using the default profile).
|
|
65
|
-
|
|
66
|
-
# π§ Example
|
|
67
|
-
|
|
68
|
-
1. Create a mapping file `
|
|
69
|
-
|
|
70
|
-
```json
|
|
71
|
-
{
|
|
72
|
-
"SECRET_TOKEN": "/path/to/ssm/token",
|
|
73
|
-
"SECRET_KEY": "/path/to/ssm/password"
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
2. Run envilder to generate your `.env` file:
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
envilder --map=
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
3. To use a specific AWS profile:
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
envilder --map=
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
4. The `.env` file will be generated in the specified location.
|
|
90
|
-
|
|
91
|
-
## π Working with Multiple AWS Profiles
|
|
92
|
-
|
|
93
|
-
If you work with multiple AWS accounts or environments, you can configure different profiles in your AWS credentials file:
|
|
94
|
-
|
|
95
|
-
1. Edit your AWS credentials file (usually at `~/.aws/credentials` on Linux/Mac or `%USERPROFILE%\.aws\credentials` on Windows):
|
|
96
|
-
|
|
97
|
-
```ini
|
|
98
|
-
[default]
|
|
99
|
-
aws_access_key_id=YOUR_DEFAULT_ACCESS_KEY
|
|
100
|
-
aws_secret_access_key=YOUR_DEFAULT_SECRET_KEY
|
|
101
|
-
|
|
102
|
-
[dev-account]
|
|
103
|
-
aws_access_key_id=YOUR_DEV_ACCESS_KEY
|
|
104
|
-
aws_secret_access_key=YOUR_DEV_SECRET_KEY
|
|
105
|
-
|
|
106
|
-
[prod-account]
|
|
107
|
-
aws_access_key_id=YOUR_PROD_ACCESS_KEY
|
|
108
|
-
aws_secret_access_key=YOUR_PROD_SECRET_KEY
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
2. When running Envilder, specify which profile to use with the `--profile` option:
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
# For development environment
|
|
115
|
-
envilder --map=
|
|
116
|
-
|
|
117
|
-
# For production environment
|
|
118
|
-
envilder --map=
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
# π Sample `.env` Output
|
|
122
|
-
|
|
123
|
-
```makefile
|
|
124
|
-
SECRET_TOKEN=mockedEmail@example.com
|
|
125
|
-
SECRET_KEY=mockedPassword
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
# π§ͺ Running Tests
|
|
129
|
-
|
|
130
|
-
To run the tests with coverage:
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
yarn test
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Here you can see the current coverage report: <https://macalbert.github.io/envilder/>
|
|
137
|
-
|
|
138
|
-
# π License
|
|
139
|
-
|
|
140
|
-
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
141
|
-
|
|
142
|
-
# π Contributing
|
|
143
|
-
|
|
144
|
-
Contributions are welcome! Feel free to submit issues and pull requests.
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
Envilder is a CLI tool for managing AWS SSM Parameter Store parameters and automatically generating the required
|
|
4
|
+
`.env` file. This tool simplifies project environment variable management, avoiding manual updates and ensuring
|
|
5
|
+
consistency across environments.
|
|
6
|
+
|
|
7
|
+
# β¨ Features
|
|
8
|
+
|
|
9
|
+
- π Fetch parameters securely from AWS SSM Parameter Store.
|
|
10
|
+
- β‘ Automatically generates a `.env` file with specified parameters.
|
|
11
|
+
- π‘οΈ Handles encrypted SSM parameters.
|
|
12
|
+
- πͺΆ Lightweight and simple to use.
|
|
13
|
+
- π Support for multiple AWS profiles.
|
|
14
|
+
|
|
15
|
+
# Prerequisites
|
|
16
|
+
|
|
17
|
+
Before using `Envilder`, ensure that you have the AWS CLI installed and properly configured on your local
|
|
18
|
+
machine. This configuration is required for `Envilder` to access and manage parameters in AWS SSM.
|
|
19
|
+
|
|
20
|
+
## AWS CLI Installation & Configuration
|
|
21
|
+
|
|
22
|
+
1. Install the AWS CLI by following the instructions [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
|
|
23
|
+
2. After installation, configure the AWS CLI using the following command:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
aws configure
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You'll be prompted to provide:
|
|
30
|
+
- AWS Access Key ID
|
|
31
|
+
- AWS Secret Access Key
|
|
32
|
+
- Default region name (e.g., `us-east-1`)
|
|
33
|
+
- Default output format (e.g., `json`)
|
|
34
|
+
|
|
35
|
+
Make sure that the AWS credentials you're using have the appropriate permissions to access the SSM Parameter
|
|
36
|
+
Store in your AWS account.
|
|
37
|
+
|
|
38
|
+
# Installation
|
|
39
|
+
|
|
40
|
+
You can install `Envilder` globally using yarn. This will allow you to use the `envilder` command from any
|
|
41
|
+
directory on your system.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
yarn global add envilder
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# π¦ Installation
|
|
48
|
+
|
|
49
|
+
You can install **envilder** globally or locally using npm:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install -g envilder
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
# π Usage
|
|
56
|
+
|
|
57
|
+
Envilder requires two arguments:
|
|
58
|
+
|
|
59
|
+
- `--map <path>`: Path to a JSON file mapping environment variable names to SSM parameters.
|
|
60
|
+
- `--envfile <path>`: Path where the generated .env file will be saved.
|
|
61
|
+
|
|
62
|
+
Optional arguments:
|
|
63
|
+
|
|
64
|
+
- `--profile <name>`: AWS CLI profile to use for credentials (if not using the default profile).
|
|
65
|
+
|
|
66
|
+
# π§ Example
|
|
67
|
+
|
|
68
|
+
1. Create a mapping file `param-map.json`:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"SECRET_TOKEN": "/path/to/ssm/token",
|
|
73
|
+
"SECRET_KEY": "/path/to/ssm/password"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
2. Run envilder to generate your `.env` file:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
envilder --map=param-map.json --envfile=.env
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
3. To use a specific AWS profile:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
envilder --map=param-map.json --envfile=.env --profile=dev-account
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
4. The `.env` file will be generated in the specified location.
|
|
90
|
+
|
|
91
|
+
## π Working with Multiple AWS Profiles
|
|
92
|
+
|
|
93
|
+
If you work with multiple AWS accounts or environments, you can configure different profiles in your AWS credentials file:
|
|
94
|
+
|
|
95
|
+
1. Edit your AWS credentials file (usually at `~/.aws/credentials` on Linux/Mac or `%USERPROFILE%\.aws\credentials` on Windows):
|
|
96
|
+
|
|
97
|
+
```ini
|
|
98
|
+
[default]
|
|
99
|
+
aws_access_key_id=YOUR_DEFAULT_ACCESS_KEY
|
|
100
|
+
aws_secret_access_key=YOUR_DEFAULT_SECRET_KEY
|
|
101
|
+
|
|
102
|
+
[dev-account]
|
|
103
|
+
aws_access_key_id=YOUR_DEV_ACCESS_KEY
|
|
104
|
+
aws_secret_access_key=YOUR_DEV_SECRET_KEY
|
|
105
|
+
|
|
106
|
+
[prod-account]
|
|
107
|
+
aws_access_key_id=YOUR_PROD_ACCESS_KEY
|
|
108
|
+
aws_secret_access_key=YOUR_PROD_SECRET_KEY
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
2. When running Envilder, specify which profile to use with the `--profile` option:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# For development environment
|
|
115
|
+
envilder --map=param-map.json --envfile=.env.development --profile=dev-account
|
|
116
|
+
|
|
117
|
+
# For production environment
|
|
118
|
+
envilder --map=param-map.json --envfile=.env.production --profile=prod-account
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
# π Sample `.env` Output
|
|
122
|
+
|
|
123
|
+
```makefile
|
|
124
|
+
SECRET_TOKEN=mockedEmail@example.com
|
|
125
|
+
SECRET_KEY=mockedPassword
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
# π§ͺ Running Tests
|
|
129
|
+
|
|
130
|
+
To run the tests with coverage:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
yarn test
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Here you can see the current coverage report: <https://macalbert.github.io/envilder/>
|
|
137
|
+
|
|
138
|
+
# π License
|
|
139
|
+
|
|
140
|
+
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
|
|
141
|
+
|
|
142
|
+
# π Contributing
|
|
143
|
+
|
|
144
|
+
Contributions are welcome! Feel free to submit issues and pull requests.
|
package/biome.json
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
|
|
3
3
|
"files": {
|
|
4
|
-
"include": [
|
|
5
|
-
|
|
6
|
-
"./tests/**",
|
|
7
|
-
"package.json",
|
|
8
|
-
"biome.json",
|
|
9
|
-
".secretlintrc.json",
|
|
10
|
-
"tsconfig.json",
|
|
11
|
-
"tsconfig.build.json",
|
|
12
|
-
"vite.config.ts",
|
|
13
|
-
"repopack.config.json"
|
|
14
|
-
]
|
|
4
|
+
"include": ["./src/**", "./tests/**"],
|
|
5
|
+
"ignore": ["**/node_modules/**", "**/lib/**", "**/dist/**", "**/coverage/**", "**/.lock", "**/.md"]
|
|
15
6
|
},
|
|
16
7
|
"organizeImports": {
|
|
17
8
|
"enabled": true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envilder",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A CLI tool to generate .env files from AWS SSM parameters",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -11,16 +11,19 @@
|
|
|
11
11
|
"envilder": "lib/cli/cliRunner.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"clean": "rimraf lib",
|
|
15
|
-
"test-run": "
|
|
16
|
-
"build": "
|
|
17
|
-
"
|
|
14
|
+
"clean": "npx jest --clearCache && yarn cache clean --force && npx rimraf lib && npx rimraf node_modules && npx rimraf coverage && npx rimraf yarn.lock",
|
|
15
|
+
"test-run": "yarn build && node lib/cli/cliRunner.js --map=tests/sample/param-map.json --envfile=tests/sample/autogenerated.env",
|
|
16
|
+
"build": "tsc -p tsconfig.build.json --sourceMap --declaration",
|
|
17
|
+
"format": "npx biome format",
|
|
18
|
+
"format:write": "npx biome format --write",
|
|
19
|
+
"lint": "npx secretlint \"**/*\" && biome lint --write && biome format --write && biome check --write && tsc --noEmit",
|
|
20
|
+
"lint:fix": "npx biome lint --fix",
|
|
18
21
|
"test": "vitest run --reporter verbose --coverage",
|
|
19
|
-
"cli-run": "
|
|
20
|
-
"npm-publish": "
|
|
21
|
-
"npm-release-patch": "
|
|
22
|
-
"npm-release-minor": "
|
|
23
|
-
"npm-release-prerelease": "
|
|
22
|
+
"cli-run": "yarn build && node --trace-warnings lib",
|
|
23
|
+
"npm-publish": "yarn lint && yarn build && yarn publish",
|
|
24
|
+
"npm-release-patch": "yarn version --new-version patch",
|
|
25
|
+
"npm-release-minor": "yarn version --new-version minor",
|
|
26
|
+
"npm-release-prerelease": "yarn version --new-version prerelease"
|
|
24
27
|
},
|
|
25
28
|
"keywords": [],
|
|
26
29
|
"repository": {
|
|
@@ -37,10 +40,8 @@
|
|
|
37
40
|
},
|
|
38
41
|
"type": "module",
|
|
39
42
|
"dependencies": {
|
|
40
|
-
"@aws-sdk/client-ssm": "^3.
|
|
43
|
+
"@aws-sdk/client-ssm": "^3.806.0",
|
|
41
44
|
"@aws-sdk/credential-providers": "^3.806.0",
|
|
42
|
-
"@secretlint/core": "^9.2.1",
|
|
43
|
-
"@secretlint/secretlint-rule-preset-recommend": "^9.0.0",
|
|
44
45
|
"@types/node": "^22.5.5",
|
|
45
46
|
"commander": "^13.1.0",
|
|
46
47
|
"dotenv": "^16.4.5",
|
|
@@ -48,19 +49,16 @@
|
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@biomejs/biome": "^1.9.1",
|
|
52
|
+
"@secretlint/secretlint-rule-preset-recommend": "^9.3.2",
|
|
51
53
|
"@vitest/coverage-v8": "^3.1.1",
|
|
52
54
|
"rimraf": "^6.0.1",
|
|
53
|
-
"secretlint": "^9.
|
|
55
|
+
"secretlint": "^9.3.2",
|
|
54
56
|
"ts-node": "^10.9.2",
|
|
55
57
|
"typescript": "^5.6.2",
|
|
56
58
|
"vitest": "^3.1.1"
|
|
57
59
|
},
|
|
58
|
-
"resolutions": {
|
|
59
|
-
"string-width": "4.2.3",
|
|
60
|
-
"strip-ansi": "6.0.1"
|
|
61
|
-
},
|
|
62
60
|
"engines": {
|
|
63
61
|
"node": ">=20.0.0",
|
|
64
62
|
"yarn": ">=1.22"
|
|
65
63
|
}
|
|
66
|
-
}
|
|
64
|
+
}
|
package/src/cli/cliRunner.ts
CHANGED
package/tests/index.test.ts
CHANGED
|
@@ -33,14 +33,23 @@ vi.mock('@aws-sdk/client-ssm', () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
describe('Envilder CLI', () => {
|
|
36
|
+
const mockMapPath = './tests/param-map.json';
|
|
37
|
+
const mockEnvFilePath = './tests/.env.test';
|
|
38
|
+
|
|
36
39
|
afterEach(() => {
|
|
37
40
|
vi.clearAllMocks();
|
|
41
|
+
|
|
42
|
+
if (fs.existsSync(mockEnvFilePath)) {
|
|
43
|
+
fs.unlinkSync(mockEnvFilePath);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (fs.existsSync(mockMapPath)) {
|
|
47
|
+
fs.unlinkSync(mockMapPath);
|
|
48
|
+
}
|
|
38
49
|
});
|
|
39
50
|
|
|
40
51
|
it('Should_GenerateEnvFileFromSSMParameters_When_ValidSSMParametersAreProvided', async () => {
|
|
41
52
|
// Arrange
|
|
42
|
-
const mockMapPath = './tests/param_map.json';
|
|
43
|
-
const mockEnvFilePath = './tests/.env.test';
|
|
44
53
|
const paramMapContent = {
|
|
45
54
|
NEXT_PUBLIC_CREDENTIAL_EMAIL: '/path/to/ssm/email',
|
|
46
55
|
NEXT_PUBLIC_CREDENTIAL_PASSWORD: '/path/to/ssm/password',
|
|
@@ -54,14 +63,10 @@ describe('Envilder CLI', () => {
|
|
|
54
63
|
const envFileContent = fs.readFileSync(mockEnvFilePath, 'utf-8');
|
|
55
64
|
expect(envFileContent).toContain('NEXT_PUBLIC_CREDENTIAL_EMAIL=mockedEmail@example.com');
|
|
56
65
|
expect(envFileContent).toContain('NEXT_PUBLIC_CREDENTIAL_PASSWORD=mockedPassword');
|
|
57
|
-
fs.unlinkSync(mockEnvFilePath);
|
|
58
|
-
fs.unlinkSync(mockMapPath);
|
|
59
66
|
});
|
|
60
67
|
|
|
61
68
|
it('Should_ThrowError_When_SSMParameterIsNotFound', async () => {
|
|
62
69
|
// Arrange
|
|
63
|
-
const mockMapPath = './tests/param_map.json';
|
|
64
|
-
const mockEnvFilePath = './tests/.env.test';
|
|
65
70
|
const paramMapContent = {
|
|
66
71
|
NEXT_PUBLIC_CREDENTIAL_EMAIL: 'non-existent parameter',
|
|
67
72
|
};
|
|
@@ -72,14 +77,10 @@ describe('Envilder CLI', () => {
|
|
|
72
77
|
|
|
73
78
|
// Assert
|
|
74
79
|
await expect(action).rejects.toThrow('ParameterNotFound: non-existent parameter');
|
|
75
|
-
fs.unlinkSync(mockMapPath);
|
|
76
80
|
});
|
|
77
81
|
|
|
78
82
|
it('Should_AppendNewSSMParameters_When_EnvFileContainsExistingVariables', async () => {
|
|
79
83
|
// Arrange
|
|
80
|
-
const mockMapPath = './tests/param_map.json';
|
|
81
|
-
const mockEnvFilePath = './tests/.env.test';
|
|
82
|
-
|
|
83
84
|
const existingEnvContent = 'EXISTING_VAR=existingValue';
|
|
84
85
|
fs.writeFileSync(mockEnvFilePath, existingEnvContent);
|
|
85
86
|
const paramMapContent = {
|
|
@@ -96,14 +97,10 @@ describe('Envilder CLI', () => {
|
|
|
96
97
|
expect(updatedEnvFileContent).toContain('EXISTING_VAR=existingValue');
|
|
97
98
|
expect(updatedEnvFileContent).toContain('NEXT_PUBLIC_CREDENTIAL_EMAIL=mockedEmail@example.com');
|
|
98
99
|
expect(updatedEnvFileContent).toContain('NEXT_PUBLIC_CREDENTIAL_PASSWORD=mockedPassword');
|
|
99
|
-
fs.unlinkSync(mockEnvFilePath);
|
|
100
|
-
fs.unlinkSync(mockMapPath);
|
|
101
100
|
});
|
|
102
101
|
|
|
103
102
|
it('Should_OverwriteSSMParameters_When_EnvFileContainsSameVariables', async () => {
|
|
104
103
|
// Arrange
|
|
105
|
-
const mockMapPath = './tests/param_map.json';
|
|
106
|
-
const mockEnvFilePath = './tests/.env.test';
|
|
107
104
|
const existingEnvContent = 'NEXT_PUBLIC_CREDENTIAL_EMAIL=oldEmail@example.com';
|
|
108
105
|
fs.writeFileSync(mockEnvFilePath, existingEnvContent);
|
|
109
106
|
const paramMapContent = {
|
|
@@ -119,14 +116,10 @@ describe('Envilder CLI', () => {
|
|
|
119
116
|
const updatedEnvFileContent = fs.readFileSync(mockEnvFilePath, 'utf-8');
|
|
120
117
|
expect(updatedEnvFileContent).toContain('NEXT_PUBLIC_CREDENTIAL_EMAIL=mockedEmail@example.com');
|
|
121
118
|
expect(updatedEnvFileContent).toContain('NEXT_PUBLIC_CREDENTIAL_PASSWORD=mockedPassword');
|
|
122
|
-
fs.unlinkSync(mockEnvFilePath);
|
|
123
|
-
fs.unlinkSync(mockMapPath);
|
|
124
119
|
});
|
|
125
120
|
|
|
126
121
|
it('Should_LogWarning_When_SSMParameterHasNoValue', async () => {
|
|
127
122
|
// Arrange
|
|
128
|
-
const mockMapPath = './tests/param_map.json';
|
|
129
|
-
const mockEnvFilePath = './tests/.env.test';
|
|
130
123
|
const paramMapContent = {
|
|
131
124
|
NEXT_PUBLIC_CREDENTIAL_PASSWORD: '/path/to/ssm/password_no_value',
|
|
132
125
|
};
|
|
@@ -138,14 +131,10 @@ describe('Envilder CLI', () => {
|
|
|
138
131
|
|
|
139
132
|
// Assert
|
|
140
133
|
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Warning: No value found for'));
|
|
141
|
-
fs.unlinkSync(mockEnvFilePath);
|
|
142
|
-
fs.unlinkSync(mockMapPath);
|
|
143
134
|
});
|
|
144
135
|
|
|
145
136
|
it('Should_ConfigureSSMClientWithProfile_When_ProfileIsProvided', async () => {
|
|
146
137
|
// Arrange
|
|
147
|
-
const mockMapPath = './tests/param_map.json';
|
|
148
|
-
const mockEnvFilePath = './tests/.env.test';
|
|
149
138
|
const mockProfile = 'test-profile';
|
|
150
139
|
const paramMapContent = {
|
|
151
140
|
NEXT_PUBLIC_CREDENTIAL_EMAIL: '/path/to/ssm/email',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
TOKEN_SECRET=this_is_for_test
|
package/vitest.config.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
// vitest.config.js
|
|
2
|
-
import { defineConfig } from 'vitest/config';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
test: {
|
|
6
|
-
coverage: {
|
|
7
|
-
provider: 'v8',
|
|
8
|
-
reporter: ['text', 'html'],
|
|
9
|
-
reportsDirectory: './coverage',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
});
|
|
1
|
+
// vitest.config.js
|
|
2
|
+
import { defineConfig } from 'vitest/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
coverage: {
|
|
7
|
+
provider: 'v8',
|
|
8
|
+
reporter: ['text', 'html'],
|
|
9
|
+
reportsDirectory: './coverage',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
package/lib/cli/cliRunner.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Parses CLI arguments and runs the environment file generator.
|
|
4
|
-
*
|
|
5
|
-
* Expects `--map` and `--envfile` options to be provided, with an optional `--profile` for AWS CLI profile selection. Invokes the main process to generate a `.env` file from AWS SSM parameters based on the provided mapping.
|
|
6
|
-
*
|
|
7
|
-
* @throws {Error} If either `--map` or `--envfile` arguments are missing.
|
|
8
|
-
*/
|
|
9
|
-
export declare function cliRunner(): Promise<void>;
|
|
10
|
-
//# sourceMappingURL=cliRunner.d.ts.map
|