envilder 0.2.3 β†’ 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.
@@ -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 code quality checker
42
- run: yarn lint
43
-
44
- - name: 🚧 Build
45
- run: yarn build
46
-
47
- - name: πŸš΄β€β™€οΈ Run unit tests
48
- run: yarn test
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,95 +1,144 @@
1
- ![Envilder](https://github.com/user-attachments/assets/f646a3e7-6ae2-4f3b-8f51-3807067fc99c)
2
-
3
- Envilder is a CLI tool for managing AWS SSM Parameter Store parameters and automatically generating the required `.env` file. This tool simplifies project environment variable management, avoiding manual updates and ensuring consistency across environments.
4
-
5
- # ✨ Features
6
-
7
- - πŸ”’ Fetch parameters securely from AWS SSM Parameter Store.
8
- - ⚑ Automatically generates a `.env` file with specified parameters.
9
- - πŸ›‘οΈ Handles encrypted (currently only supported) SSM parameters.
10
- - πŸͺΆ Lightweight and simple to use.
11
-
12
- # Prerequisites
13
- Before using `Envilder`, ensure that you have the AWS CLI installed and properly configured on your local machine. This configuration is required for `Envilder` to access and manage parameters in AWS SSM.
14
-
15
- ## AWS CLI Installation & Configuration
16
- 1. Install the AWS CLI by following the instructions [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
17
- 2. After installation, configure the AWS CLI using the following command:
18
-
19
- ```bash
20
- aws configure
21
- ```
22
-
23
- You'll be prompted to provide:
24
- - AWS Access Key ID
25
- - AWS Secret Access Key
26
- - Default region name (e.g., `us-east-1`)
27
- - Default output format (e.g., `json`)
28
-
29
- Make sure that the AWS credentials you're using have the appropriate permissions to access the SSM Parameter Store in your AWS account.
30
-
31
- # Installation
32
- You can install `Envilder` globally using yarn. This will allow you to use the `envilder` command from any directory on your system.
33
-
34
- ```bash
35
- yarn global add envilder
36
- ```
37
-
38
- # πŸ“¦ Installation
39
-
40
- You can install **envilder** globally or locally using npm:
41
-
42
- ```bash
43
- npm install -g envilder
44
- ```
45
-
46
- # πŸš€ Usage
47
-
48
- Envilder requires two arguments:
49
-
50
- - `--map <path>`: Path to a JSON file mapping environment variable names to SSM parameters.
51
- - `--envfile <path>`: Path where the generated .env file will be saved.
52
-
53
- # πŸ”§ Example
54
-
55
- 1. Create a mapping file `param_map.json`:
56
-
57
- ```json
58
- {
59
- "SECRET_TOKEN": "/path/to/ssm/token",
60
- "SECRET_KEY": "/path/to/ssm/password"
61
- }
62
- ```
63
-
64
- 2. Run envilder to generate your `.env` file:
65
-
66
- ```bash
67
- envilder --map=param_map.json --envfile=.env
68
- ```
69
-
70
- 3. The `.env` file will be generated in the specified location.
71
-
72
- # πŸ“‚ Sample `.env` Output
73
-
74
- ```makefile
75
- SECRET_TOKEN=mockedEmail@example.com
76
- SECRET_KEY=mockedPassword
77
- ```
78
-
79
- # πŸ§ͺ Running Tests
80
-
81
- To run the tests with coverage:
82
-
83
- ```bash
84
- yarn test
85
- ```
86
-
87
- Here you can see the current coverage report: https://macalbert.github.io/envilder/
88
-
89
- # πŸ“ License
90
-
91
- This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
92
-
93
- # πŸ™Œ Contributing
94
-
95
- Contributions are welcome! Feel free to submit issues and pull requests.
1
+ ![Envilder](https://github.com/user-attachments/assets/f646a3e7-6ae2-4f3b-8f51-3807067fc99c)
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
- "./src/**",
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.2.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": "npm run build && node lib/cli/cliRunner.js --map=tests/sample/param_map.json --envfile=.env",
16
- "build": "npm run clean && tsc -p tsconfig.build.json --sourceMap --declaration",
17
- "lint": "biome lint --write && biome format --write && biome check --write && tsc --noEmit && secretlint **/*",
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": "npm run build && node --trace-warnings lib",
20
- "npm-publish": "npm run lint && npm run build && npm publish",
21
- "npm-release-patch": "npm version patch && npm run npm-publish",
22
- "npm-release-minor": "npm version minor && npm run npm-publish",
23
- "npm-release-prerelease": "npm version prerelease && npm run npm-publish"
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,29 +40,25 @@
37
40
  },
38
41
  "type": "module",
39
42
  "dependencies": {
40
- "@aws-sdk/client-ssm": "^3.654.0",
41
- "@secretlint/core": "^9.2.1",
42
- "@secretlint/secretlint-rule-preset-recommend": "^9.0.0",
43
+ "@aws-sdk/client-ssm": "^3.806.0",
44
+ "@aws-sdk/credential-providers": "^3.806.0",
43
45
  "@types/node": "^22.5.5",
44
- "commander": "^12.1.0",
46
+ "commander": "^13.1.0",
45
47
  "dotenv": "^16.4.5",
46
48
  "picocolors": "^1.1.0"
47
49
  },
48
50
  "devDependencies": {
49
51
  "@biomejs/biome": "^1.9.1",
52
+ "@secretlint/secretlint-rule-preset-recommend": "^9.3.2",
50
53
  "@vitest/coverage-v8": "^3.1.1",
51
54
  "rimraf": "^6.0.1",
52
- "secretlint": "^9.0.0",
55
+ "secretlint": "^9.3.2",
53
56
  "ts-node": "^10.9.2",
54
57
  "typescript": "^5.6.2",
55
58
  "vitest": "^3.1.1"
56
59
  },
57
- "resolutions": {
58
- "string-width": "4.2.3",
59
- "strip-ansi": "6.0.1"
60
- },
61
60
  "engines": {
62
61
  "node": ">=20.0.0",
63
62
  "yarn": ">=1.22"
64
63
  }
65
- }
64
+ }
@@ -1,8 +1,14 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  import { Command } from 'commander';
4
3
  import { run } from '../index.js';
5
4
 
5
+ /**
6
+ * Parses CLI arguments and runs the environment file generator.
7
+ *
8
+ * 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.
9
+ *
10
+ * @throws {Error} If either `--map` or `--envfile` arguments are missing.
11
+ */
6
12
  export async function cliRunner() {
7
13
  const program = new Command();
8
14
 
@@ -11,7 +17,8 @@ export async function cliRunner() {
11
17
  .description('A CLI tool to generate .env files from AWS SSM parameters')
12
18
  .version('0.1.0')
13
19
  .requiredOption('--map <path>', 'Path to the JSON file with environment variable mapping')
14
- .requiredOption('--envfile <path>', 'Path to the .env file to be generated');
20
+ .requiredOption('--envfile <path>', 'Path to the .env file to be generated')
21
+ .option('--profile <name>', 'AWS CLI profile to use');
15
22
 
16
23
  await program.parseAsync(process.argv);
17
24
  const options = program.opts();
@@ -20,7 +27,7 @@ export async function cliRunner() {
20
27
  throw new Error('Missing required arguments: --map and --envfile');
21
28
  }
22
29
 
23
- await run(options.map, options.envfile);
30
+ await run(options.map, options.envfile, options.profile);
24
31
  }
25
32
 
26
33
  cliRunner().catch((error) => {
package/src/index.ts CHANGED
@@ -1,14 +1,26 @@
1
1
  import * as fs from 'node:fs';
2
2
  import { GetParameterCommand, SSM } from '@aws-sdk/client-ssm';
3
+ import { fromIni } from '@aws-sdk/credential-providers';
3
4
  import * as dotenv from 'dotenv';
4
5
 
5
- const ssm = new SSM({});
6
+ /**
7
+ * Orchestrates the process of fetching environment variable values from AWS SSM Parameter Store and writing them to a local environment file.
8
+ *
9
+ * Loads a parameter mapping from a JSON file, retrieves existing environment variables, fetches updated values from SSM (optionally using a specified AWS profile), merges them, and writes the result to the specified environment file.
10
+ *
11
+ * @param mapPath - Path to the JSON file mapping environment variable names to SSM parameter names.
12
+ * @param envFilePath - Path to the local environment file to read and update.
13
+ * @param profile - Optional AWS profile name to use for credentials.
14
+ */
15
+ export async function run(mapPath: string, envFilePath: string, profile?: string) {
16
+ const defaultAwsConfig = {};
17
+ const ssmClientConfig = profile ? { credentials: fromIni({ profile }) } : defaultAwsConfig;
18
+ const ssm = new SSM(ssmClientConfig);
6
19
 
7
- export async function run(mapPath: string, envFilePath: string) {
8
20
  const paramMap = loadParamMap(mapPath);
9
21
  const existingEnvVariables = loadExistingEnvVariables(envFilePath);
10
22
 
11
- const updatedEnvVariables = await fetchAndUpdateEnvVariables(paramMap, existingEnvVariables);
23
+ const updatedEnvVariables = await fetchAndUpdateEnvVariables(paramMap, existingEnvVariables, ssm);
12
24
 
13
25
  writeEnvFile(envFilePath, updatedEnvVariables);
14
26
  console.log(`Environment File generated at '${envFilePath}'`);
@@ -36,15 +48,28 @@ function loadExistingEnvVariables(envFilePath: string): Record<string, string> {
36
48
  return envVariables;
37
49
  }
38
50
 
51
+ /**
52
+ * Fetches parameter values from AWS SSM for each environment variable in the map and updates the existing environment variables record.
53
+ *
54
+ * For each mapping, retrieves the corresponding SSM parameter value and updates the environment variable if found. Logs masked values and warnings for missing parameters. Throws an error if any parameters fail to fetch.
55
+ *
56
+ * @param paramMap - Mapping of environment variable names to SSM parameter names.
57
+ * @param existingEnvVariables - Current environment variables to be updated.
58
+ * @param ssm - AWS SSM client instance used for fetching parameters.
59
+ * @returns The updated environment variables record.
60
+ *
61
+ * @throws {Error} If any SSM parameters cannot be fetched.
62
+ */
39
63
  async function fetchAndUpdateEnvVariables(
40
64
  paramMap: Record<string, string>,
41
65
  existingEnvVariables: Record<string, string>,
66
+ ssm: SSM,
42
67
  ): Promise<Record<string, string>> {
43
68
  const errors: string[] = [];
44
69
 
45
70
  for (const [envVar, ssmName] of Object.entries(paramMap)) {
46
71
  try {
47
- const value = await fetchSSMParameter(ssmName);
72
+ const value = await fetchSSMParameter(ssmName, ssm);
48
73
  if (value) {
49
74
  existingEnvVariables[envVar] = value;
50
75
  console.log(
@@ -66,7 +91,13 @@ async function fetchAndUpdateEnvVariables(
66
91
  return existingEnvVariables;
67
92
  }
68
93
 
69
- async function fetchSSMParameter(ssmName: string): Promise<string | undefined> {
94
+ /**
95
+ * Retrieves the value of a parameter from AWS SSM Parameter Store with decryption enabled.
96
+ *
97
+ * @param ssmName - The name of the SSM parameter to retrieve.
98
+ * @returns The decrypted parameter value if found, or undefined if the parameter does not exist.
99
+ */
100
+ async function fetchSSMParameter(ssmName: string, ssm: SSM): Promise<string | undefined> {
70
101
  const command = new GetParameterCommand({
71
102
  Name: ssmName,
72
103
  WithDecryption: true,
@@ -12,9 +12,9 @@ describe('cliRunner', () => {
12
12
  beforeEach(() => {
13
13
  process.argv = [...originalArgv.slice(0, 2)];
14
14
  });
15
-
16
15
  afterEach(() => {
17
16
  vi.clearAllMocks();
17
+ process.argv = originalArgv;
18
18
  });
19
19
 
20
20
  it('Should_CallRunWithCorrectArguments_When_ValidArgumentsAreProvided', async () => {
@@ -27,7 +27,7 @@ describe('cliRunner', () => {
27
27
  await cliRunner();
28
28
 
29
29
  // Assert
30
- expect(run).toHaveBeenCalledWith(mockMapPath, mockEnvFilePath);
30
+ expect(run).toHaveBeenCalledWith(mockMapPath, mockEnvFilePath, undefined);
31
31
  });
32
32
 
33
33
  it('Should_ThrowError_When_RequiredArgumentsAreMissing', async () => {
@@ -42,4 +42,18 @@ describe('cliRunner', () => {
42
42
  // Assert
43
43
  await expect(action).rejects.toThrow('process.exit called');
44
44
  });
45
+
46
+ it('Should_CallRunWithCorrectArgumentsIncludingProfile_When_ProfileIsProvided', async () => {
47
+ // Arrange
48
+ const mockMapPath = 'path/to/mockMap.json';
49
+ const mockEnvFilePath = 'path/to/.env';
50
+ const mockProfile = 'test-profile';
51
+ process.argv.push('--map', mockMapPath, '--envfile', mockEnvFilePath, '--profile', mockProfile);
52
+
53
+ // Act
54
+ await cliRunner();
55
+
56
+ // Assert
57
+ expect(run).toHaveBeenCalledWith(mockMapPath, mockEnvFilePath, mockProfile);
58
+ });
45
59
  });