envilder 0.6.0 → 0.6.2

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 (67) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +97 -284
  3. package/lib/apps/cli/Cli.d.ts +1 -0
  4. package/lib/apps/cli/Cli.d.ts.map +1 -1
  5. package/lib/apps/cli/Cli.js +12 -22
  6. package/lib/apps/cli/Cli.js.map +1 -1
  7. package/lib/apps/cli/Startup.d.ts +19 -0
  8. package/lib/apps/cli/Startup.d.ts.map +1 -0
  9. package/lib/apps/cli/Startup.js +75 -0
  10. package/lib/apps/cli/Startup.js.map +1 -0
  11. package/lib/envilder/application/dispatch/DispatchActionCommandHandler.d.ts.map +1 -1
  12. package/lib/envilder/application/dispatch/DispatchActionCommandHandler.js +24 -2
  13. package/lib/envilder/application/dispatch/DispatchActionCommandHandler.js.map +1 -1
  14. package/lib/envilder/application/pullSsmToEnv/PullSsmToEnvCommandHandler.d.ts +3 -3
  15. package/lib/envilder/application/pullSsmToEnv/PullSsmToEnvCommandHandler.d.ts.map +1 -1
  16. package/lib/envilder/application/pullSsmToEnv/PullSsmToEnvCommandHandler.js +35 -12
  17. package/lib/envilder/application/pullSsmToEnv/PullSsmToEnvCommandHandler.js.map +1 -1
  18. package/lib/envilder/application/pushEnvToSsm/PushEnvToSsmCommandHandler.d.ts +3 -3
  19. package/lib/envilder/application/pushEnvToSsm/PushEnvToSsmCommandHandler.d.ts.map +1 -1
  20. package/lib/envilder/application/pushEnvToSsm/PushEnvToSsmCommandHandler.js +28 -6
  21. package/lib/envilder/application/pushEnvToSsm/PushEnvToSsmCommandHandler.js.map +1 -1
  22. package/lib/envilder/application/pushSingle/PushSingleCommandHandler.d.ts.map +1 -1
  23. package/lib/envilder/application/pushSingle/PushSingleCommandHandler.js +23 -2
  24. package/lib/envilder/application/pushSingle/PushSingleCommandHandler.js.map +1 -1
  25. package/lib/envilder/domain/ports/IVariableStore.d.ts +6 -0
  26. package/lib/envilder/domain/ports/IVariableStore.d.ts.map +1 -0
  27. package/lib/envilder/domain/ports/IVariableStore.js +2 -0
  28. package/lib/envilder/domain/ports/IVariableStore.js.map +1 -0
  29. package/lib/envilder/infrastructure/{Aws → aws}/AwsSsmSecretProvider.d.ts +1 -1
  30. package/lib/envilder/infrastructure/{Aws → aws}/AwsSsmSecretProvider.d.ts.map +1 -1
  31. package/lib/envilder/infrastructure/{Aws → aws}/AwsSsmSecretProvider.js +17 -2
  32. package/lib/envilder/infrastructure/aws/AwsSsmSecretProvider.js.map +1 -0
  33. package/lib/envilder/infrastructure/{Logger → logger}/ConsoleLogger.d.ts +1 -1
  34. package/lib/envilder/infrastructure/logger/ConsoleLogger.d.ts.map +1 -0
  35. package/lib/envilder/infrastructure/logger/ConsoleLogger.js +23 -0
  36. package/lib/envilder/infrastructure/logger/ConsoleLogger.js.map +1 -0
  37. package/lib/envilder/infrastructure/package/PackageVersionReader.d.ts +5 -0
  38. package/lib/envilder/infrastructure/package/PackageVersionReader.d.ts.map +1 -0
  39. package/lib/envilder/infrastructure/{VersionFinder/PackageJsonFinder.js → package/PackageVersionReader.js} +3 -3
  40. package/lib/envilder/infrastructure/package/PackageVersionReader.js.map +1 -0
  41. package/lib/envilder/infrastructure/variableStore/FileVariableStore.d.ts +11 -0
  42. package/lib/envilder/infrastructure/variableStore/FileVariableStore.d.ts.map +1 -0
  43. package/lib/envilder/infrastructure/{EnvManager/EnvFileManager.js → variableStore/FileVariableStore.js} +33 -13
  44. package/lib/envilder/infrastructure/variableStore/FileVariableStore.js.map +1 -0
  45. package/lib/envilder/types.d.ts +22 -0
  46. package/lib/envilder/types.d.ts.map +1 -0
  47. package/lib/envilder/types.js +18 -0
  48. package/lib/envilder/types.js.map +1 -0
  49. package/package.json +4 -2
  50. package/lib/envilder/application/dispatch/builders/DispatchActionCommandHandlerBuilder.d.ts +0 -15
  51. package/lib/envilder/application/dispatch/builders/DispatchActionCommandHandlerBuilder.d.ts.map +0 -1
  52. package/lib/envilder/application/dispatch/builders/DispatchActionCommandHandlerBuilder.js +0 -38
  53. package/lib/envilder/application/dispatch/builders/DispatchActionCommandHandlerBuilder.js.map +0 -1
  54. package/lib/envilder/domain/ports/IEnvFileManager.d.ts +0 -6
  55. package/lib/envilder/domain/ports/IEnvFileManager.d.ts.map +0 -1
  56. package/lib/envilder/domain/ports/IEnvFileManager.js +0 -2
  57. package/lib/envilder/domain/ports/IEnvFileManager.js.map +0 -1
  58. package/lib/envilder/infrastructure/Aws/AwsSsmSecretProvider.js.map +0 -1
  59. package/lib/envilder/infrastructure/EnvManager/EnvFileManager.d.ts +0 -11
  60. package/lib/envilder/infrastructure/EnvManager/EnvFileManager.d.ts.map +0 -1
  61. package/lib/envilder/infrastructure/EnvManager/EnvFileManager.js.map +0 -1
  62. package/lib/envilder/infrastructure/Logger/ConsoleLogger.d.ts.map +0 -1
  63. package/lib/envilder/infrastructure/Logger/ConsoleLogger.js +0 -12
  64. package/lib/envilder/infrastructure/Logger/ConsoleLogger.js.map +0 -1
  65. package/lib/envilder/infrastructure/VersionFinder/PackageJsonFinder.d.ts +0 -5
  66. package/lib/envilder/infrastructure/VersionFinder/PackageJsonFinder.d.ts.map +0 -1
  67. package/lib/envilder/infrastructure/VersionFinder/PackageJsonFinder.js.map +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Marçal Albert
3
+ Copyright (c) 2025 Marçal Albert Castellví <mac.albert@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -3,36 +3,59 @@
3
3
  <p align="center">
4
4
  <img src="https://github.com/user-attachments/assets/96bf1efa-7d21-440a-a414-3a20e7f9a1f1" alt="Envilder">
5
5
  </p>
6
- </p>
7
6
 
8
7
  <p align="center">
9
- <b>✨ A CLI that securely centralizes your environment variables from AWS SSM as a single source of truth ✨</b>
8
+ <b>Automate .env and secret management with Envilder</b><br>
9
+ <span>Streamline your environment setup with AWS Parameter Store</span>
10
10
  </p>
11
11
 
12
12
  <p align="center">
13
13
  <a href="https://www.npmjs.com/package/envilder">
14
14
  <img src="https://img.shields.io/npm/v/envilder.svg" alt="npm version">
15
15
  </a>
16
- <a href="./LICENSE">
17
- <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License">
16
+ <a href="https://img.shields.io/npm/dm/envilder.svg">
17
+ <img src="https://img.shields.io/npm/dm/envilder.svg" alt="npm downloads">
18
+ </a>
19
+ <a href="https://github.com/macalbert/envilder/actions/workflows/tests.yml">
20
+ <img src="https://github.com/macalbert/envilder/actions/workflows/tests.yml/badge.svg" alt="CI Tests">
18
21
  </a>
19
22
  <a href="https://macalbert.github.io/envilder/">
20
23
  <img src="https://img.shields.io/badge/coverage-report-green.svg" alt="Coverage Report">
21
24
  </a>
25
+ <a href="./LICENSE">
26
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License">
27
+ </a>
22
28
  </p>
23
29
 
24
30
  ## Why centralize environment variables?
25
31
 
26
- Environment variables are crucial for configuring applications across different environments
27
- (development, production) or even projects. Without proper management, they become:
32
+ Envilder is a CLI tool for .env automation, AWS SSM secrets management, and secure environment variable sync.
33
+ Generating and maintaining consistent .env files is a real pain point for any development team. From outdated
34
+ secrets to insecure practices, the risks are tangible. Envilder eliminates these pitfalls by centralizing and
35
+ automating secret management across real-world environments (dev, test, production) in a simple, secure, and
36
+ efficient way. Use Envilder to automate .env files, sync secrets with AWS Parameter Store, and streamline
37
+ onboarding and CI/CD workflows.
28
38
 
29
- - 🔐 **Security risks** when stored in code repositories
30
- - 🔄 **Out of sync** across team members and deployment environments
31
- - 🧩 **Scattered** across various documentation, chat messages, and emails
39
+ ---
32
40
 
33
- **Envilder** solves these problems by using AWS SSM Parameter Store as a secure, centralized location for all your
34
- environment variables, ensuring everyone on your team works with the same configuration and no secrets are exposed
35
- in your codebase.
41
+ ## What Envilder solves
42
+
43
+ - Desync between environments (dev, prod)
44
+ - Secrets not properly propagated across team members
45
+ - CI/CD pipeline failures due to outdated or missing .env files
46
+ - Slow and manual onboarding processes
47
+ - Security risks from sharing secrets via Slack, email, or other channels
48
+ - Insecure .env practices and manual secret sharing
49
+
50
+ ## ✅ How Envilder makes life easier
51
+
52
+ - 🛡️ Centralizes secrets in AWS Parameter Store
53
+ - ⚙️ Generates .env files automatically for every environment
54
+ - 🔄 Applies changes idempotently and instantly
55
+ - 🔐 Improves security: no need to share secrets manually; everything is managed via AWS SSM
56
+ - 👥 Simplifies onboarding and internal rotations
57
+ - 🚀 Enables cloud-native, infrastructure-as-code secret management
58
+ - 🤖 Perfect for DevOps, CI/CD, and team sync
36
59
 
37
60
  ---
38
61
 
@@ -40,26 +63,18 @@ in your codebase.
40
63
 
41
64
  - [🗝️ Envilder ☁️](#️-envilder-️)
42
65
  - [Why centralize environment variables?](#why-centralize-environment-variables)
66
+ - [❗ What Envilder solves](#-what-envilder-solves)
67
+ - [✅ How Envilder makes life easier](#-how-envilder-makes-life-easier)
43
68
  - [📚 Table of Contents](#-table-of-contents)
44
69
  - [⚙️ Features](#️-features)
45
70
  - [🧱 Feature Status](#-feature-status)
46
71
  - [💾 Installation](#-installation)
47
72
  - [🚀 Quick Start](#-quick-start)
48
- - [🎥 Video Demonstration](#-video-demonstration)
73
+ - [🎥 Video Demonstration](#-video-demonstration)
74
+ - [🏁 Get Started (3 steps)](#-get-started-3-steps)
75
+ - [📚 Quick Links](#-quick-links)
49
76
  - [🛠️ How it works](#️-how-it-works)
50
- - [🎮 Usage](#-usage)
51
- - [🚀 Push Mode (`--push`)](#-push-mode---push)
52
- - [🍄 Method 1: Push from .env file](#-method-1-push-from-env-file)
53
- - [⭐ Method 2: Push a single variable](#-method-2-push-a-single-variable)
54
- - [🧰 Push Mode options summary](#-push-mode-options-summary)
55
- - [🧪 Push Mode Examples](#-push-mode-examples)
56
- - [⬇️ Pull Mode (`--map` and `--envfile`)](#️-pull-mode---map-and---envfile)
57
- - [⚙️ Pull Mode Options](#️-pull-mode-options)
58
- - [🧪 Pull Mode Examples](#-pull-mode-examples)
59
- - [📜 Sample Output](#-sample-output)
60
- - [👥 Working with multiple AWS profiles](#-working-with-multiple-aws-profiles)
61
- - [⬇️ Pull Mode Example](#️-pull-mode-example)
62
- - [🚀 Push Mode Example](#-push-mode-example)
77
+ - [Frequently Asked Questions (FAQ)](#frequently-asked-questions-faq)
63
78
  - [🏁 Roadmap](#-roadmap)
64
79
  - [🤝 Contributing](#-contributing)
65
80
  - [📜 License](#-license)
@@ -94,7 +109,7 @@ in your codebase.
94
109
 
95
110
  🛠 Requirements:
96
111
 
97
- - Node.js **v20+**
112
+ - Node.js **v20+** (cloud-native compatible)
98
113
  - AWS CLI installed and configured
99
114
  - IAM user/role with `ssm:GetParameter`, `ssm:PutParameter`
100
115
 
@@ -112,293 +127,93 @@ npm install -g envilder
112
127
 
113
128
  ## 🚀 Quick Start
114
129
 
115
- Get started with **Envilder** in 3 simple steps. Remember to add `.env` to your `.gitignore` file for security.
130
+ ### 🎥 Video Demonstration
116
131
 
117
- Initial Setup
132
+ Watch how easy it is to automate your .env management in less than 1 minute:
118
133
 
119
- ```bash
120
- # Step 1: Create a parameter mapping file
121
- echo '{
122
- "DB_PASSWORD": "/my-app/db/password"
123
- }' > param-map.json
134
+ ![Watch the video](https://github.com/user-attachments/assets/9f194143-117d-49f3-a6fb-f400040ea514)
124
135
 
125
- # Step 2: Push a secret to AWS SSM Parameter Store
126
- envilder --push --key=DB_PASSWORD --value=12345 --ssm-path=/my-app/db/password
127
- ```
136
+ ### 🏁 Get Started (3 steps)
128
137
 
129
- Ongoing Usage
138
+ After configuring the AWS CLI and ensuring you have the necessary permissions to create SSM parameters,
139
+ you can begin pushing your first environment variables.
130
140
 
131
- ```bash
132
- # Step 3: Generate your .env file from AWS SSM
133
- envilder --map=param-map.json --envfile=.env
134
- ```
141
+ Let me know if you want it split into two lines to resolve the markdown lint warning.
135
142
 
136
- 🎯 That’s it your secrets are now managed and versioned from AWS SSM.
143
+ 1. **Create a mapping file:**
137
144
 
138
- ---
139
-
140
- ## 🎥 Video Demonstration
141
-
142
- Watch how Envilder works in less than 1 minute:
143
-
144
- ![Watch the video](https://github.com/user-attachments/assets/2de7cac3-0c13-4706-96f6-bf2ef12b661a)
145
-
146
- ---
147
-
148
- ## 🛠️ How it works
145
+ ```json
146
+ {
147
+ "DB_PASSWORD": "/my-app/db/password"
148
+ }
149
+ ```
149
150
 
150
- ```mermaid
151
- graph LR
152
- A[Mapping File (param-map.json)] --> B[Envilder]
153
- C[.env File or --key] --> B
154
- D[AWS Credentials] --> B
155
- E[AWS SSM] --> B
156
- B --> F[Pull/Push Secrets 💾]
157
- ```
158
-
159
- 1. Define mappings in JSON: `{"ENV_VAR": "ssm/path"}`
160
- 2. Run Envilder: `--push` to upload, or `--map` + `--envfile` to generate
161
- 3. It talks to SSM using your AWS credentials
162
- 4. Result: your secrets synced ✅
163
-
164
- ---
151
+ 2. **Push a secret to AWS SSM:**
165
152
 
166
- ## 🎮 Usage
153
+ ```bash
154
+ envilder --push --key=DB_PASSWORD --value=12345 --ssm-path=/my-app/db/password
155
+ ```
167
156
 
168
- ### 🚀 Push Mode (`--push`)
157
+ Once your secrets are stored in AWS, you can easily generate or synchronize your local .env files:
169
158
 
170
- Push Mode uploads environment variables to AWS SSM Parameter Store. It has two distinct operation methods:
159
+ 1. **Generate your .env file from AWS SSM:**
171
160
 
172
- #### 🍄 Method 1: Push from .env file
161
+ ```bash
162
+ envilder --map=param-map.json --envfile=.env
163
+ ```
173
164
 
174
- **Requirements:**
165
+ Your secrets are now managed and versioned from AWS SSM. Add `.env` to your `.gitignore` for security.
166
+ Envilder is designed for automation, onboarding, and secure cloud-native workflows.
175
167
 
176
- - `--push` flag to enable Push Mode
177
- - `--envfile` pointing to your local .env file
178
- - `--map` pointing to your parameter mapping JSON file
168
+ ### 📚 Quick Links
179
169
 
180
- **How File-Based Push Works:**
170
+ - [Requirements & Installation](docs/requirements-installation.md)
171
+ - [Push Command Guide](docs/push-command.md)
172
+ - [Pull Command Guide](docs/pull-command.md)
181
173
 
182
- 1. Envilder reads your local `.env` file to get variable names and values
183
- 2. Envilder reads your `map` file to find the corresponding SSM paths
184
- 3. For each variable found in both files, Envilder pushes the value to AWS SSM
185
- 4. No modifications are made to your local files
186
-
187
- ```mermaid
188
- graph LR
189
- A[.env File] --> |Variables & Values| B[Envilder]
190
- C[Mapping File] --> |SSM Paths| B
191
- D[AWS Profile] --> B
192
- B --> E[AWS SSM Parameter Store]
193
- ```
194
-
195
- **Example:**
196
- If your `.env` file contains:
197
-
198
- ```text
199
- API_KEY=abc123
200
- DB_PASSWORD=secret456
201
- ```
202
-
203
- And your `param-map.json` file contains:
204
-
205
- ```json
206
- {
207
- "API_KEY": "/myapp/api/key",
208
- "DB_PASSWORD": "/myapp/db/password"
209
- }
210
- ```
211
-
212
- Running this command:
213
-
214
- ```bash
215
- envilder --push --envfile=.env --map=param-map.json
216
- ```
217
-
218
- Will push:
219
-
220
- - Value `abc123` to SSM path `/myapp/api/key`
221
- - Value `secret456` to SSM path `/myapp/db/password`
222
-
223
- ### ⭐ Method 2: Push a single variable
224
-
225
- **What it does:**
226
- Uploads a single environment variable directly to AWS SSM Parameter Store without using any files.
227
-
228
- **Required parameters:**
229
-
230
- - `--push`: Activates Push Mode
231
- - `--key=VAR_NAME`: The name of the environment variable
232
- - `--value=secret123`: The value to store in AWS SSM
233
- - `--ssm-path=/your/path`: The full AWS SSM parameter path
234
-
235
- **Important notes:**
174
+ ---
236
175
 
237
- - NO files are read or modified
238
- - This is a direct command-to-SSM operation
239
- - Useful for quick updates or CI/CD pipelines
176
+ ## 🛠️ How it works
240
177
 
241
178
  ```mermaid
242
179
  graph LR
243
- A[Command Line Arguments] --> B[Envilder]
244
- C[AWS Profile] --> B
245
- B --> D[AWS SSM Parameter Store]
246
- ```
247
-
248
- **Example:**
180
+ A["Mapping File<br/>(param-map.json)"] --> B[Envilder]:::core
181
+ C["Environment File<br/> '.env' or --key"] --> B
182
+ D["AWS Credentials"]:::aws --> B
183
+ E["AWS SSM"]:::aws --> B
184
+ B --> F["Pull/Push Secrets 💾"]
249
185
 
250
- ```bash
251
- envilder --push --key=API_KEY --value=abc123 --ssm-path=/myapp/api/key
186
+ classDef aws fill:#ffcc66,color:#000000,stroke:#333,stroke-width:1.5px;
187
+ classDef core fill:#1f3b57,color:#fff,stroke:#ccc,stroke-width:2px;
252
188
  ```
253
189
 
254
- Will push:
255
-
256
- - Value `abc123` to SSM path `/myapp/api/key`
257
-
258
- ### 🧰 Push Mode options summary
259
-
260
- **Common Options:**
261
-
262
- | Option | Description |
263
- |------------- | ---------------------------------- |
264
- | `--push` | Required: Enables push mode |
265
- | `--profile` | Optional: AWS CLI profile to use |
266
-
267
- **Method 1: File-Based Push Options:**
268
-
269
- | Option | Description |
270
- |------------- | -------------------------------------------------- |
271
- | `--envfile` | Required: Path to your local .env file |
272
- | `--map` | Required: Path to your parameter mapping JSON file |
273
-
274
- **Method 2: Single-Variable Push Options:**
275
-
276
- | Option | Description |
277
- |------------- | ------------------------------------------- |
278
- | `--key` | Required: Environment variable name |
279
- | `--value` | Required: Value to store in AWS SSM |
280
- | `--ssm-path` | Required: Full SSM parameter path |
281
-
282
- ### 🧪 Push Mode Examples
283
-
284
- **Method 1: Push from .env file (multiple variables at once):**
285
-
286
- ```bash
287
- # Basic usage - pushes all variables found in both .env and map files
288
- envilder --push --envfile=.env --map=param-map.json
289
-
290
- # With AWS profile - for different environments
291
- envilder --push --envfile=.env.prod --map=param-map.json --profile=prod-account
292
- ```
293
-
294
- **Method 2: Push a single variable (no files needed):**
295
-
296
- ```bash
297
- # Basic usage - pushes one variable directly to SSM
298
- envilder --push --key=API_KEY --value=secret123 --ssm-path=/my/path
299
-
300
- # With AWS profile
301
- envilder --push --key=API_KEY --value=secret123 --ssm-path=/my/path --profile=dev
302
- ```
303
-
304
- ---
305
-
306
- ### ⬇️ Pull Mode (`--map` and `--envfile`)
307
-
308
- Downloads secrets from SSM and writes to `.env`.
309
-
310
- #### ⚙️ Pull Mode Options
311
-
312
- | Option | Description |
313
- | ----------- | ----------------------------------- |
314
- | `--map` | JSON mapping of env var to SSM path |
315
- | `--envfile` | Path to write `.env` |
316
- | `--profile` | AWS profile to use |
317
-
318
- #### 🧪 Pull Mode Examples
319
-
320
- ```bash
321
- envilder --map=param-map.json --envfile=.env
322
- ```
323
-
324
- With profile:
325
-
326
- ```bash
327
- envilder --map=param-map.json --envfile=.env --profile=dev-account
328
- ```
329
-
330
- #### 📜 Sample Output
331
-
332
- After running the pull command above with a `param-map.json` file containing:
333
-
334
- ```json
335
- {
336
- "API_KEY": "/myapp/api/key",
337
- "DB_PASSWORD": "/myapp/db/password",
338
- "SECRET_TOKEN": "/myapp/auth/token"
339
- }
340
- ```
341
-
342
- Your generated `.env` file would look like:
343
-
344
- ```dotenv
345
- # Generated by Envilder on 2025-07-13
346
- API_KEY=abc123
347
- DB_PASSWORD=secret456
348
- SECRET_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
349
- ```
350
-
351
- This keeps your sensitive values secure in AWS SSM while providing local access for development.
352
-
353
- ---
354
-
355
- ## 👥 Working with multiple AWS profiles
356
-
357
- Edit your `~/.aws/credentials`:
358
-
359
- ```ini
360
- [default]
361
- aws_access_key_id=DEFAULT_KEY
362
- aws_secret_access_key=DEFAULT_SECRET
363
-
364
- [dev-account]
365
- aws_access_key_id=DEV_KEY
366
- aws_secret_access_key=DEV_SECRET
367
-
368
- [prod-account]
369
- aws_access_key_id=PROD_KEY
370
- aws_secret_access_key=PROD_SECRET
371
- ```
190
+ 1. Create a new `.env` file like `'ENV_VAR=12345'`
191
+ 2. Define mappings in a JSON file : `{"ENV_VAR": "ssm/path"}`
192
+ 3. Run Envilder: `--push` to upload, or `--map` + `--envfile` to generate
193
+ 4. Envilder syncs secrets securely with AWS SSM Parameter Store using your AWS credentials
194
+ 5. Result: your secrets are always up-to-date, secure, and ready for any environment
372
195
 
373
196
  ---
374
197
 
375
- ### ⬇️ Pull Mode Example
376
-
377
- ```bash
378
- # Default
379
- envilder --map=param-map.json --envfile=.env.dev
380
-
381
- # Development
382
- envilder --map=param-map.json --envfile=.env.dev --profile=dev-account
198
+ ## Frequently Asked Questions (FAQ)
383
199
 
384
- # Production
385
- envilder --map=param-map.json --envfile=.env.prod --profile=prod-account
386
- ```
200
+ **Q: What is Envilder?**
201
+ A: Envilder is a CLI tool for automating .env and secret management using AWS SSM Parameter Store.
387
202
 
388
- ---
203
+ **Q: How does Envilder improve security?**
204
+ A: Secrets are never stored in code or shared via chat/email. All secrets are managed and synced securely via AWS SSM.
389
205
 
390
- ### 🚀 Push Mode Example
206
+ **Q: Can I use Envilder in CI/CD pipelines?**
207
+ A: Yes! Envilder is designed for automation and works seamlessly in CI/CD workflows.
391
208
 
392
- ```bash
393
- # Default
394
- envilder --push --key=API_KEY --value=secret123 --ssm-path=/dev/api/key
209
+ **Q: Does Envilder support multiple AWS profiles?**
210
+ A: Yes, you can use the `--profile` flag to select different AWS credentials.
395
211
 
396
- # Development
397
- envilder --push --key=API_KEY --value=secret123 --ssm-path=/dev/api/key --profile=dev-account
212
+ **Q: What environments does Envilder support?**
213
+ A: Any environment supported by AWS SSM—dev, test, staging, production, etc.
398
214
 
399
- # Production
400
- envilder --push --key=API_KEY --value=secret123 --ssm-path=/prod/api/key --profile=prod-account
401
- ```
215
+ **Q: Is Envilder open source?**
216
+ A: Yes, licensed under MIT.
402
217
 
403
218
  ---
404
219
 
@@ -429,5 +244,3 @@ All help is welcome — PRs, issues, ideas!
429
244
 
430
245
  MIT © [Marçal Albert](https://github.com/macalbert)
431
246
  See [LICENSE](./LICENSE)
432
-
433
- ---
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
+ import 'reflect-metadata';
2
3
  export declare function main(): Promise<void>;
3
4
  //# sourceMappingURL=Cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Cli.d.ts","sourceRoot":"","sources":["../../../src/apps/cli/Cli.ts"],"names":[],"mappings":";AAqCA,wBAAsB,IAAI,kBA2CzB"}
1
+ {"version":3,"file":"Cli.d.ts","sourceRoot":"","sources":["../../../src/apps/cli/Cli.ts"],"names":[],"mappings":";AACA,OAAO,kBAAkB,CAAC;AAwB1B,wBAAsB,IAAI,kBAgDzB"}
@@ -8,32 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ import 'reflect-metadata';
11
12
  import { dirname, join } from 'node:path';
12
13
  import { fileURLToPath } from 'node:url';
13
- import { SSM } from '@aws-sdk/client-ssm';
14
- import { fromIni } from '@aws-sdk/credential-providers';
15
14
  import { Command } from 'commander';
16
- import { DispatchActionCommandHandlerBuilder } from '../../envilder/application/dispatch/builders/DispatchActionCommandHandlerBuilder.js';
17
15
  import { DispatchActionCommand } from '../../envilder/application/dispatch/DispatchActionCommand.js';
18
- import { AwsSsmSecretProvider } from '../../envilder/infrastructure/Aws/AwsSsmSecretProvider.js';
19
- import { EnvFileManager } from '../../envilder/infrastructure/EnvManager/EnvFileManager.js';
20
- import { ConsoleLogger } from '../../envilder/infrastructure/Logger/ConsoleLogger.js';
21
- import { PackageJsonFinder } from '../../envilder/infrastructure/VersionFinder/PackageJsonFinder.js';
16
+ import { PackageVersionReader } from '../../envilder/infrastructure/package/PackageVersionReader.js';
17
+ import { TYPES } from '../../envilder/types.js';
18
+ import { Startup } from './Startup.js';
19
+ let serviceProvider;
22
20
  function executeCommand(options) {
23
21
  return __awaiter(this, void 0, void 0, function* () {
24
- const logger = new ConsoleLogger();
25
- const fileManager = new EnvFileManager(logger);
26
- const ssm = options.profile
27
- ? new SSM({
28
- credentials: fromIni({ profile: options.profile }),
29
- })
30
- : new SSM();
31
- const secretProvider = new AwsSsmSecretProvider(ssm);
32
- const commandHandler = DispatchActionCommandHandlerBuilder.build()
33
- .withLogger(logger)
34
- .withEnvFileManager(fileManager)
35
- .withProvider(secretProvider)
36
- .create();
22
+ const commandHandler = serviceProvider.get(TYPES.DispatchActionCommandHandler);
37
23
  const command = DispatchActionCommand.fromCliOptions(options);
38
24
  yield commandHandler.handleCommand(command);
39
25
  });
@@ -60,6 +46,10 @@ export function main() {
60
46
  .option('--value <value>', 'Value of the single environment variable to push (only with --push)')
61
47
  .option('--ssm-path <path>', 'SSM path for the single environment variable (only with --push)')
62
48
  .action((options) => __awaiter(this, void 0, void 0, function* () {
49
+ serviceProvider = Startup.build()
50
+ .configureServices()
51
+ .configureInfrastructure(options.profile)
52
+ .create();
63
53
  yield executeCommand(options);
64
54
  }));
65
55
  yield program.parseAsync(process.argv);
@@ -69,10 +59,10 @@ function readPackageVersion() {
69
59
  const __filename = fileURLToPath(import.meta.url);
70
60
  const __dirname = dirname(__filename);
71
61
  const packageJsonPath = join(__dirname, '../../../package.json');
72
- return new PackageJsonFinder().readPackageJsonVersion(packageJsonPath);
62
+ return new PackageVersionReader().getVersion(packageJsonPath);
73
63
  }
74
64
  main().catch((error) => {
75
- const logger = new ConsoleLogger();
65
+ const logger = serviceProvider.get(TYPES.ILogger);
76
66
  logger.error('🚨 Uh-oh! Looks like Mario fell into the wrong pipe! 🍄💥');
77
67
  logger.error(error instanceof Error ? error.message : String(error));
78
68
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../../src/apps/cli/Cli.ts"],"names":[],"mappings":";;;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mCAA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readonly container;
4
+ constructor();
5
+ static build(): Startup;
6
+ configureServices(): this;
7
+ /**
8
+ * Configures infrastructure services for the application.
9
+ * Optionally accepts an AWS profile to use for service configuration.
10
+ * @param awsProfile - The AWS profile to use for configuring infrastructure services.
11
+ * @returns The current instance for method chaining.
12
+ */
13
+ configureInfrastructure(awsProfile?: string): this;
14
+ create(): Container;
15
+ getServiceProvider(): Container;
16
+ private configureInfrastructureServices;
17
+ private configureApplicationServices;
18
+ }
19
+ //# sourceMappingURL=Startup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Startup.d.ts","sourceRoot":"","sources":["../../../src/apps/cli/Startup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAgBtC,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;;IAMtC,MAAM,CAAC,KAAK,IAAI,OAAO;IAIvB,iBAAiB,IAAI,IAAI;IAKzB;;;;;OAKG;IACH,uBAAuB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAKlD,MAAM,IAAI,SAAS;IAInB,kBAAkB,IAAI,SAAS;IAI/B,OAAO,CAAC,+BAA+B;IAsBvC,OAAO,CAAC,4BAA4B;CAqBrC"}
@@ -0,0 +1,75 @@
1
+ import { SSM } from '@aws-sdk/client-ssm';
2
+ import { fromIni } from '@aws-sdk/credential-providers';
3
+ import { Container } from 'inversify';
4
+ import { DispatchActionCommandHandler } from '../../envilder/application/dispatch/DispatchActionCommandHandler.js';
5
+ import { PullSsmToEnvCommandHandler } from '../../envilder/application/pullSsmToEnv/PullSsmToEnvCommandHandler.js';
6
+ import { PushEnvToSsmCommandHandler } from '../../envilder/application/pushEnvToSsm/PushEnvToSsmCommandHandler.js';
7
+ import { PushSingleCommandHandler } from '../../envilder/application/pushSingle/PushSingleCommandHandler.js';
8
+ import { AwsSsmSecretProvider } from '../../envilder/infrastructure/aws/AwsSsmSecretProvider.js';
9
+ import { ConsoleLogger } from '../../envilder/infrastructure/logger/ConsoleLogger.js';
10
+ import { FileVariableStore } from '../../envilder/infrastructure/variableStore/FileVariableStore.js';
11
+ import { TYPES } from '../../envilder/types.js';
12
+ export class Startup {
13
+ constructor() {
14
+ this.container = new Container();
15
+ }
16
+ static build() {
17
+ return new Startup();
18
+ }
19
+ configureServices() {
20
+ this.configureApplicationServices();
21
+ return this;
22
+ }
23
+ /**
24
+ * Configures infrastructure services for the application.
25
+ * Optionally accepts an AWS profile to use for service configuration.
26
+ * @param awsProfile - The AWS profile to use for configuring infrastructure services.
27
+ * @returns The current instance for method chaining.
28
+ */
29
+ configureInfrastructure(awsProfile) {
30
+ this.configureInfrastructureServices(awsProfile);
31
+ return this;
32
+ }
33
+ create() {
34
+ return this.container;
35
+ }
36
+ getServiceProvider() {
37
+ return this.container;
38
+ }
39
+ configureInfrastructureServices(awsProfile) {
40
+ this.container
41
+ .bind(TYPES.ILogger)
42
+ .to(ConsoleLogger)
43
+ .inSingletonScope();
44
+ this.container
45
+ .bind(TYPES.IVariableStore)
46
+ .to(FileVariableStore)
47
+ .inSingletonScope();
48
+ const ssm = awsProfile
49
+ ? new SSM({ credentials: fromIni({ profile: awsProfile }) })
50
+ : new SSM();
51
+ const secretProvider = new AwsSsmSecretProvider(ssm);
52
+ this.container
53
+ .bind(TYPES.ISecretProvider)
54
+ .toConstantValue(secretProvider);
55
+ }
56
+ configureApplicationServices() {
57
+ this.container
58
+ .bind(TYPES.PullSsmToEnvCommandHandler)
59
+ .to(PullSsmToEnvCommandHandler)
60
+ .inTransientScope();
61
+ this.container
62
+ .bind(TYPES.PushEnvToSsmCommandHandler)
63
+ .to(PushEnvToSsmCommandHandler)
64
+ .inTransientScope();
65
+ this.container
66
+ .bind(TYPES.PushSingleCommandHandler)
67
+ .to(PushSingleCommandHandler)
68
+ .inTransientScope();
69
+ this.container
70
+ .bind(TYPES.DispatchActionCommandHandler)
71
+ .to(DispatchActionCommandHandler)
72
+ .inTransientScope();
73
+ }
74
+ }
75
+ //# sourceMappingURL=Startup.js.map