make-json-to-env 1.0.5 → 1.0.6
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/LICENSE +21 -0
- package/README.md +87 -32
- package/package.json +17 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ajay Vishwakarma
|
|
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,82 +1,137 @@
|
|
|
1
|
-
# make-json-to-env
|
|
1
|
+
# 🚀 make-json-to-env
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**The ultimate zero-dependency CLI tool to transform complex, nested JSON into clean, production-ready `.env` files.**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 💡 Why `make-json-to-env`?
|
|
8
|
+
|
|
9
|
+
Most JSON-to-ENV converters stop at the first level or handle arrays poorly. `make-json-to-env` was built to solve the "Deep Config" problem. Whether you have a 10-level nested Firebase config or a simple flat JSON, this tool generates a standard, predictable `.env` structure that works with `dotenv`, Docker, and Shell scripts.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 🔥 Features
|
|
14
|
+
|
|
15
|
+
* **⚡ Ultra-Lightweight** – Zero dependencies. It uses native Node.js `fs` and `path` modules.
|
|
16
|
+
* **🌳 Infinite Recursion** – No depth limits. It flattens deep objects into a `PARENT_CHILD_KEY` convention.
|
|
17
|
+
* **🔢 Intelligent Array Mapping** – Converts arrays into indexed variables (e.g., `TAGS_0`, `TAGS_1`).
|
|
18
|
+
* **🛡️ Built with TypeScript** – Fully type-safe with robust error handling for invalid JSON.
|
|
19
|
+
* **⚙️ Prefix Support** – Prepend `export `, `SET `, or `REACT_APP_` to every variable automatically.
|
|
20
|
+
* **🚫 Smart Flattening Toggle** – Use `--no-flatten` if you want nested objects to stay as JSON strings.
|
|
4
21
|
|
|
5
22
|
---
|
|
6
23
|
|
|
7
24
|
## 📦 Installation
|
|
8
25
|
|
|
9
|
-
|
|
26
|
+
### Use without installing (Recommended)
|
|
10
27
|
|
|
11
28
|
```bash
|
|
12
|
-
npx make-json-to-env
|
|
29
|
+
npx make-json-to-env config.json
|
|
13
30
|
|
|
14
31
|
```
|
|
15
32
|
|
|
16
|
-
|
|
33
|
+
### Global Installation
|
|
17
34
|
|
|
18
35
|
```bash
|
|
19
36
|
npm install -g make-json-to-env
|
|
20
37
|
|
|
21
38
|
```
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🛠 Usage & Commands
|
|
24
43
|
|
|
25
|
-
|
|
44
|
+
The tool provides the `make-json-to-env` command.
|
|
26
45
|
|
|
27
|
-
### Basic Conversion
|
|
46
|
+
### 1. Basic Conversion
|
|
47
|
+
|
|
48
|
+
Converts `config.json` to `config.env`.
|
|
28
49
|
|
|
29
50
|
```bash
|
|
30
|
-
|
|
51
|
+
make-json-to-env config.json
|
|
31
52
|
|
|
32
53
|
```
|
|
33
54
|
|
|
34
|
-
|
|
55
|
+
### 2. Using Custom Prefixes
|
|
56
|
+
|
|
57
|
+
Great for shell scripts or specific frameworks (like Create React App).
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
make-json-to-env config.json --prefix="export "
|
|
61
|
+
|
|
62
|
+
```
|
|
35
63
|
|
|
36
|
-
###
|
|
64
|
+
### 3. Disabling Flattening
|
|
37
65
|
|
|
38
|
-
|
|
66
|
+
Keep nested objects as serialized strings.
|
|
39
67
|
|
|
40
68
|
```bash
|
|
41
|
-
|
|
69
|
+
make-json-to-env data.json --no-flatten
|
|
42
70
|
|
|
43
71
|
```
|
|
44
72
|
|
|
45
73
|
---
|
|
46
74
|
|
|
47
|
-
## 📋 Example
|
|
75
|
+
## 📋 Deep-Flattening Example
|
|
48
76
|
|
|
49
|
-
**Input (`
|
|
77
|
+
**Input (`settings.json`):**
|
|
50
78
|
|
|
51
79
|
```json
|
|
52
80
|
{
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
81
|
+
"server": {
|
|
82
|
+
"port": 3000,
|
|
83
|
+
"auth": {
|
|
84
|
+
"methods": ["google", "github"],
|
|
85
|
+
"enabled": true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"log_level": "info"
|
|
56
89
|
}
|
|
57
90
|
|
|
58
91
|
```
|
|
59
92
|
|
|
60
|
-
**
|
|
93
|
+
**Output (`settings.env`):**
|
|
61
94
|
|
|
62
|
-
```
|
|
63
|
-
|
|
95
|
+
```env
|
|
96
|
+
SERVER_PORT=3000
|
|
97
|
+
SERVER_AUTH_METHODS_0=google
|
|
98
|
+
SERVER_AUTH_METHODS_1=github
|
|
99
|
+
SERVER_AUTH_ENABLED=true
|
|
100
|
+
LOG_LEVEL=info
|
|
64
101
|
|
|
65
102
|
```
|
|
66
103
|
|
|
67
|
-
|
|
104
|
+
---
|
|
68
105
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
## 🚀 Advanced Flag Reference
|
|
107
|
+
|
|
108
|
+
| Flag | Type | Description |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| `<filename>` | `string` | **Required.** The path to your JSON source file. |
|
|
111
|
+
| `--prefix` | `string` | Prepend a string to every key (e.g., `--prefix="VITE_"`). |
|
|
112
|
+
| `--no-flatten` | `boolean` | Stops recursion. Nested objects are saved as JSON strings. |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🛠 Development & Contributing
|
|
117
|
+
|
|
118
|
+
Contributions are welcome! To set up the project locally:
|
|
119
|
+
|
|
120
|
+
1. **Clone the repo:** `git clone https://github.com/ajay-vish/make-json-to-env.git`
|
|
121
|
+
2. **Install types:** `npm install`
|
|
122
|
+
3. **Build from TS:** `npm run build`
|
|
123
|
+
4. **Test locally:** `node dist/index.js example.json`
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 📄 License
|
|
128
|
+
|
|
129
|
+
Distributed under the **MIT License**. See the `LICENSE` file for full text.
|
|
74
130
|
|
|
75
131
|
---
|
|
76
132
|
|
|
77
|
-
##
|
|
133
|
+
## ⭐️ Support
|
|
134
|
+
|
|
135
|
+
If this tool saved you time, please give it a star on [GitHub](https://github.com/ajay-vish/make-json-to-env)!
|
|
78
136
|
|
|
79
|
-
|
|
80
|
-
* **Smart Naming:** Automatically generates the output filename based on your input.
|
|
81
|
-
* **Case Formatting:** Automatically converts keys to `UPPER_CASE` for standard `.env` compliance.
|
|
82
|
-
* **Security First:** Helps you create `.env.example` files so you never accidentally commit your real secrets.
|
|
137
|
+
---
|
package/package.json
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "make-json-to-env",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Infinite recursive JSON to ENV flattener written in TypeScript.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"make-json-to-env": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
11
13
|
],
|
|
12
14
|
"scripts": {
|
|
13
15
|
"build": "tsc",
|
|
14
16
|
"prepare": "npm run build",
|
|
15
|
-
"start": "ts-node src/index.ts"
|
|
17
|
+
"start": "ts-node src/index.ts",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
16
19
|
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/ajay-vish/make-json-to-env.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/ajay-vish/make-json-to-env/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/ajay-vish/make-json-to-env#readme",
|
|
17
28
|
"devDependencies": {
|
|
18
29
|
"@types/node": "^20.19.35",
|
|
19
30
|
"ts-node": "^10.9.2",
|
|
@@ -23,19 +34,19 @@
|
|
|
23
34
|
"env",
|
|
24
35
|
"json",
|
|
25
36
|
"converter",
|
|
26
|
-
"
|
|
37
|
+
"recursive",
|
|
38
|
+
"flatten",
|
|
27
39
|
"dot-env",
|
|
28
40
|
"environment-variables",
|
|
29
41
|
"config-to-env",
|
|
30
42
|
"cli",
|
|
31
43
|
"devtools",
|
|
32
44
|
"automation",
|
|
33
|
-
"boilerplate",
|
|
34
45
|
"env-example",
|
|
35
46
|
"dotenv-generator",
|
|
36
47
|
"configuration",
|
|
37
48
|
"secrets-management"
|
|
38
49
|
],
|
|
39
|
-
"author": "
|
|
50
|
+
"author": "Ajay Vishwakarma",
|
|
40
51
|
"license": "MIT"
|
|
41
52
|
}
|