@ben-studios/envedit 0.0.0-stage → 1.0.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.
- package/.gitlab-ci.yml +133 -0
- package/.idea/envedit.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/@types/custom.d.ts +10 -0
- package/CHANGELOG.md +196 -0
- package/LICENSE +674 -0
- package/README.md +97 -2
- package/bun.lock +176 -0
- package/ci/npm.sh +4 -0
- package/cli/cmd/environment.ts +10 -0
- package/cli/cmd/environmentCmd/add.ts +115 -0
- package/cli/cmd/environmentCmd/edit.ts +74 -0
- package/cli/cmd/environmentCmd/index.ts +6 -0
- package/cli/cmd/environmentCmd/list.ts +16 -0
- package/cli/cmd/environmentCmd/remove.ts +47 -0
- package/cli/cmd/index.ts +7 -0
- package/cli/cmd/init.ts +60 -0
- package/cli/cmd/setup.ts +46 -0
- package/cli/cmd/use.ts +60 -0
- package/cli/cmd/variable.ts +10 -0
- package/cli/cmd/variableCmd/add.ts +92 -0
- package/cli/cmd/variableCmd/edit.ts +150 -0
- package/cli/cmd/variableCmd/index.ts +6 -0
- package/cli/cmd/variableCmd/list.ts +35 -0
- package/cli/cmd/variableCmd/remove.ts +39 -0
- package/cli/index.ts +28 -0
- package/coverage/.lcov.info.133d8750bda2c350.tmp +139 -0
- package/coverage/.lcov.info.64d068458fa931ef.tmp +139 -0
- package/coverage/junit.xml +37 -0
- package/coverage/lcov.info +139 -0
- package/lib/config.ts +133 -0
- package/lib/error.ts +6 -0
- package/lib/logger.ts +40 -0
- package/package.json +26 -3
- package/tsconfig.json +35 -0
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# {width=32} envedit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`envedit` is a simple CLI application used to manage environments.
|
|
4
|
+
It allows you to create, edit, and delete custom environments, as well as
|
|
5
|
+
control the variables within them. It is designed to be a simple and easy-to-use tool for managing environments.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
To install `envedit`, you must have [Bun](https://bun.sh/) installed.
|
|
10
|
+
Once you have Bun installed, you can install `envedit` using the following command:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
bun add @benshawmean/envedit
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
or you can install it globally using the following command:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bun add -g @benshawmean/envedit
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
After installation, you can run `envedit` from the command line.
|
|
23
|
+
|
|
24
|
+
## Setup
|
|
25
|
+
|
|
26
|
+
Setting up the application is simple. You first run the setup command,
|
|
27
|
+
which will create a configuration file in your current working directory.
|
|
28
|
+
All you need to do is run the following command:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
envedit setup
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
After that, you should see a new file called `env.config.yaml` in your current working directory.
|
|
35
|
+
You can then add a new environment by running the following command and following the prompts:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
envedit environment add
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To add a new variable to an environment, you can run the following command and follow the prompts:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
envedit variable add
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
After you have completed that, you can use the environment by running the following command
|
|
48
|
+
and selecting the environment you want to use from the list of available environments:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
envedit use
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Schema
|
|
55
|
+
|
|
56
|
+
I have released a JSON Schema spec. file for the outputted file. It can be found at <https://benshawmean.com/api/schema/envedit>.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### IDE Support for Schema
|
|
60
|
+
|
|
61
|
+
To add validation and description support for the schema, please try the following things:
|
|
62
|
+
|
|
63
|
+
#### VSCode
|
|
64
|
+
|
|
65
|
+
For VSCode (and/or VSCode Insiders), add the following to your `settings.json` file:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
"json.schemaDownload.trustedDomains": {
|
|
69
|
+
"https://benshawmean.com/": true,
|
|
70
|
+
},
|
|
71
|
+
"json.schemas": [
|
|
72
|
+
{
|
|
73
|
+
"fileMatch": ["**/env.config.yaml"],
|
|
74
|
+
"url": "https://benshawmean.com/api/schema/envedit",
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"yaml.schemas": {
|
|
78
|
+
"https://benshawmean.com/api/schema/envedit": "**/env.config.yaml"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### JetBrains IDEs
|
|
83
|
+
|
|
84
|
+
For JetBrains IDEs, you can do this by doing these steps:
|
|
85
|
+
|
|
86
|
+
1. In Settings, head to Languages & Frameworks > Schemas and DTDs > JSON Schema Mappings
|
|
87
|
+
2. Click the + (Add) icon
|
|
88
|
+
3. Name your mapping "EnvEdit"
|
|
89
|
+
4. Provide the URL `https://benshawmean.com/api/schema/envedit`
|
|
90
|
+
5. Define the file path pattern `**/env.config.yaml`
|
|
91
|
+
6. Click OK
|
|
92
|
+
|
|
93
|
+
Do note that this is on a project level, so you will need to do this for each project you want to use the schema in.
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
This project is licensed under the GNU General Public License version 3.
|
|
98
|
+
See the [LICENSE](https://benshawmean.com/legal/global/license/gpl3) file for more details.
|
package/bun.lock
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lockfileVersion": 1,
|
|
3
|
+
"configVersion": 1,
|
|
4
|
+
"workspaces": {
|
|
5
|
+
"": {
|
|
6
|
+
"name": "envedit",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@inquirer/prompts": "^8.5.2",
|
|
9
|
+
"dotenv": "^17.4.2",
|
|
10
|
+
"pino": "^10.3.1",
|
|
11
|
+
"pino-pretty": "^13.1.3",
|
|
12
|
+
"yargs": "^18.1.0",
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/bun": "^1.3.14",
|
|
16
|
+
"@types/yargs": "^17.0.35",
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"typescript": "^5",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"packages": {
|
|
24
|
+
"@inquirer/ansi": ["@inquirer/ansi@2.0.7", "", {}, "sha512-3eTuUO1vH2cZm2ZKHeQxnOqlTi9EfZDGgIe3BL3I4u+rJHocr9Fz86M4fjYABPvFnQG/gGK551HqDiIcETwU6Q=="],
|
|
25
|
+
|
|
26
|
+
"@inquirer/checkbox": ["@inquirer/checkbox@5.2.1", "", { "dependencies": { "@inquirer/ansi": "^2.0.7", "@inquirer/core": "^11.2.1", "@inquirer/figures": "^2.0.7", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-b6xmA/VlTe0ZgDQHDui+Nav470u7u49nRd8/iuhOcQPO9Ch7lGuogydhi2VOmNlZ+zXcM8IcPuNSwQcdJaF/kw=="],
|
|
27
|
+
|
|
28
|
+
"@inquirer/confirm": ["@inquirer/confirm@6.1.1", "", { "dependencies": { "@inquirer/core": "^11.2.1", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-eb8DBZcz/2qHWQda4rk2JiQk5h9QV/cVHi1yjt0f69WFZMRFn0sJTye3EAP8icut8UDMjQPsaH5KbcOogefrFQ=="],
|
|
29
|
+
|
|
30
|
+
"@inquirer/core": ["@inquirer/core@11.2.1", "", { "dependencies": { "@inquirer/ansi": "^2.0.7", "@inquirer/figures": "^2.0.7", "@inquirer/type": "^4.0.7", "cli-width": "^4.1.0", "fast-wrap-ansi": "^0.2.0", "mute-stream": "^3.0.0", "signal-exit": "^4.1.0" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-Qd6GJT1yVyrZZCfN8W2qKF5ApmqryXRhRKCuip8h01x2w/esJQ2XIYc6f9abMIHgKQdBfFTSOdbHRLAhuM09UA=="],
|
|
31
|
+
|
|
32
|
+
"@inquirer/editor": ["@inquirer/editor@5.2.2", "", { "dependencies": { "@inquirer/core": "^11.2.1", "@inquirer/external-editor": "^3.0.3", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-ZRVd/oD+sYsUd5zVm0NflqEzlqfYCyHNsqkHl2oWXEUHs12tCbcSFi+wVFEvD8+LGRaMUsVrE7qeo6lSG/S1Vg=="],
|
|
33
|
+
|
|
34
|
+
"@inquirer/expand": ["@inquirer/expand@5.1.1", "", { "dependencies": { "@inquirer/core": "^11.2.1", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-YmQpenjbFSHAK3sOd44puHh3V1KXXr+JiNpUztoSQ4drLh2rTVzTap/YtlAVu/5xavifIlBfNEzJ/neZJ1a/1g=="],
|
|
35
|
+
|
|
36
|
+
"@inquirer/external-editor": ["@inquirer/external-editor@3.0.3", "", { "dependencies": { "chardet": "^2.1.1", "iconv-lite": "^0.7.2" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-6thf5I8q7lZwzGLAxPaaGEREEkZ3nyePPDQ1oyobblxmEE8mqTLguScP7pDjUTAibiyb4hfXl+qjUEJ+di/aNA=="],
|
|
37
|
+
|
|
38
|
+
"@inquirer/figures": ["@inquirer/figures@2.0.7", "", {}, "sha512-aJ8TBPOGB6f/2qziPfElISTCEd5XOYTFckA2SGjhNmiKzfK/u4ot3v0DUzGVdUnKjN10EqnnEPck36BkyfLnJw=="],
|
|
39
|
+
|
|
40
|
+
"@inquirer/input": ["@inquirer/input@5.1.2", "", { "dependencies": { "@inquirer/core": "^11.2.1", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-9K/DDBSQpOyZSkt6sOVP9Vo0TR7atX2kuILsUu0x3wVcVbe97lJwIJKMLdMw25tDYuXl/qp6erT0Xs1rfmcfZg=="],
|
|
41
|
+
|
|
42
|
+
"@inquirer/number": ["@inquirer/number@4.1.1", "", { "dependencies": { "@inquirer/core": "^11.2.1", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-XF4IXAbPnGPgw0wsbC/i2tPcyfdZgDpUlhsqU0SfT4IRIGWha6Xm9VRgN5yYxJq+jnyXlfXI/nQ3ulfk0iEICA=="],
|
|
43
|
+
|
|
44
|
+
"@inquirer/password": ["@inquirer/password@5.1.1", "", { "dependencies": { "@inquirer/ansi": "^2.0.7", "@inquirer/core": "^11.2.1", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-3XBfF7DAsp5qeDsvN5Rd1HmbNokVvEQoUM0QLrRcybC9nX96w3Pbmu7qUsb3IT3J3jBvs2+mTXaKHOUsgHMLzg=="],
|
|
45
|
+
|
|
46
|
+
"@inquirer/prompts": ["@inquirer/prompts@8.5.2", "", { "dependencies": { "@inquirer/checkbox": "^5.2.1", "@inquirer/confirm": "^6.1.1", "@inquirer/editor": "^5.2.2", "@inquirer/expand": "^5.1.1", "@inquirer/input": "^5.1.2", "@inquirer/number": "^4.1.1", "@inquirer/password": "^5.1.1", "@inquirer/rawlist": "^5.3.1", "@inquirer/search": "^4.2.1", "@inquirer/select": "^5.2.1" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-IYR/3C/paEVVQYQvdDlFZVjRCJVYHHON0XXMH91KO9GSxs0TdKYWlUdvfQl2EfAHDxUaN3IBffkE/BDTh5nJ6g=="],
|
|
47
|
+
|
|
48
|
+
"@inquirer/rawlist": ["@inquirer/rawlist@5.3.1", "", { "dependencies": { "@inquirer/core": "^11.2.1", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-QqdTqQddL3qPX/PPrjobpsO25NZ4dWXgTLenrR445L2ptLEYE6Z+PD5c5CNDJNx4ugRgELAIpSIJxZaO2jJ2Og=="],
|
|
49
|
+
|
|
50
|
+
"@inquirer/search": ["@inquirer/search@4.2.1", "", { "dependencies": { "@inquirer/core": "^11.2.1", "@inquirer/figures": "^2.0.7", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-xJj8QWKRSrfKoBIITLZK61dD3zwo0Rz11fgDImku30/Oe81zMdIdGgrLY2h6RkJ+KZ/GhNYIRMKnH/62qBTA5g=="],
|
|
51
|
+
|
|
52
|
+
"@inquirer/select": ["@inquirer/select@5.2.1", "", { "dependencies": { "@inquirer/ansi": "^2.0.7", "@inquirer/core": "^11.2.1", "@inquirer/figures": "^2.0.7", "@inquirer/type": "^4.0.7" }, "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-FlDndEUww8m7BfukO2nJa25vhD+H5jxxCv4oGioKqzyWz3nPHhhw4LKdYRSlXuAx7DsdWia7iyaBPKKS95Evfw=="],
|
|
53
|
+
|
|
54
|
+
"@inquirer/type": ["@inquirer/type@4.0.7", "", { "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-t28inv14nMQ1PhKpsJPY+kEs/c00qzeCOS2gTNRyTjG5d6qsVA2fItxW4hkvGZ5lvanGLdtCzVIx5dwdRpN1+g=="],
|
|
55
|
+
|
|
56
|
+
"@pinojs/redact": ["@pinojs/redact@0.4.0", "", {}, "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg=="],
|
|
57
|
+
|
|
58
|
+
"@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
|
|
59
|
+
|
|
60
|
+
"@types/node": ["@types/node@26.1.2", "", { "dependencies": { "undici-types": "~8.3.0" } }, "sha512-Vu4a5UFA9rIIFJ7rB/Vaafh9lrCQszopTCx6KjFboXTGQbPNasehVR5TEiithSDGyd1DEiUByggTZsg8jukeIg=="],
|
|
61
|
+
|
|
62
|
+
"@types/yargs": ["@types/yargs@17.0.35", "", { "dependencies": { "@types/yargs-parser": "*" } }, "sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg=="],
|
|
63
|
+
|
|
64
|
+
"@types/yargs-parser": ["@types/yargs-parser@21.0.3", "", {}, "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ=="],
|
|
65
|
+
|
|
66
|
+
"ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
|
|
67
|
+
|
|
68
|
+
"ansi-styles": ["ansi-styles@6.2.3", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="],
|
|
69
|
+
|
|
70
|
+
"atomic-sleep": ["atomic-sleep@1.0.0", "", {}, "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ=="],
|
|
71
|
+
|
|
72
|
+
"bun-types": ["bun-types@1.3.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
|
|
73
|
+
|
|
74
|
+
"chardet": ["chardet@2.2.0", "", {}, "sha512-rddelWYNPRrXq6PtNEN2S3f6t9ILzvqaN5pVgi4kqt9jHQaXIial9PznB5iSPVlQSLNaaH22ItWz3EJtQ10+OA=="],
|
|
75
|
+
|
|
76
|
+
"cli-width": ["cli-width@4.1.0", "", {}, "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ=="],
|
|
77
|
+
|
|
78
|
+
"cliui": ["cliui@9.0.1", "", { "dependencies": { "string-width": "^7.2.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" } }, "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w=="],
|
|
79
|
+
|
|
80
|
+
"colorette": ["colorette@2.0.20", "", {}, "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w=="],
|
|
81
|
+
|
|
82
|
+
"dateformat": ["dateformat@4.6.3", "", {}, "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA=="],
|
|
83
|
+
|
|
84
|
+
"dotenv": ["dotenv@17.4.2", "", {}, "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw=="],
|
|
85
|
+
|
|
86
|
+
"emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="],
|
|
87
|
+
|
|
88
|
+
"end-of-stream": ["end-of-stream@1.4.5", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg=="],
|
|
89
|
+
|
|
90
|
+
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
|
91
|
+
|
|
92
|
+
"fast-copy": ["fast-copy@4.0.4", "", {}, "sha512-eVAiWVNPSEGIzDl5yPuLrx8fNMogScXvD9xp1Kzd41FjRIz2I3sSIcxsFeM5EzFfHAfobdvs8ZySffUopljvIA=="],
|
|
93
|
+
|
|
94
|
+
"fast-safe-stringify": ["fast-safe-stringify@2.1.1", "", {}, "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA=="],
|
|
95
|
+
|
|
96
|
+
"fast-string-truncated-width": ["fast-string-truncated-width@3.0.3", "", {}, "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g=="],
|
|
97
|
+
|
|
98
|
+
"fast-string-width": ["fast-string-width@3.0.2", "", { "dependencies": { "fast-string-truncated-width": "^3.0.2" } }, "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg=="],
|
|
99
|
+
|
|
100
|
+
"fast-wrap-ansi": ["fast-wrap-ansi@0.2.2", "", { "dependencies": { "fast-string-width": "^3.0.2" } }, "sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q=="],
|
|
101
|
+
|
|
102
|
+
"get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="],
|
|
103
|
+
|
|
104
|
+
"get-east-asian-width": ["get-east-asian-width@1.6.0", "", {}, "sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA=="],
|
|
105
|
+
|
|
106
|
+
"help-me": ["help-me@5.0.0", "", {}, "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg=="],
|
|
107
|
+
|
|
108
|
+
"iconv-lite": ["iconv-lite@0.7.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ=="],
|
|
109
|
+
|
|
110
|
+
"joycon": ["joycon@3.1.1", "", {}, "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw=="],
|
|
111
|
+
|
|
112
|
+
"minimist": ["minimist@1.2.8", "", {}, "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="],
|
|
113
|
+
|
|
114
|
+
"mute-stream": ["mute-stream@3.0.0", "", {}, "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw=="],
|
|
115
|
+
|
|
116
|
+
"on-exit-leak-free": ["on-exit-leak-free@2.1.2", "", {}, "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA=="],
|
|
117
|
+
|
|
118
|
+
"once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
|
|
119
|
+
|
|
120
|
+
"pino": ["pino@10.3.1", "", { "dependencies": { "@pinojs/redact": "^0.4.0", "atomic-sleep": "^1.0.0", "on-exit-leak-free": "^2.1.0", "pino-abstract-transport": "^3.0.0", "pino-std-serializers": "^7.0.0", "process-warning": "^5.0.0", "quick-format-unescaped": "^4.0.3", "real-require": "^0.2.0", "safe-stable-stringify": "^2.3.1", "sonic-boom": "^4.0.1", "thread-stream": "^4.0.0" }, "bin": { "pino": "bin.js" } }, "sha512-r34yH/GlQpKZbU1BvFFqOjhISRo1MNx1tWYsYvmj6KIRHSPMT2+yHOEb1SG6NMvRoHRF0a07kCOox/9yakl1vg=="],
|
|
121
|
+
|
|
122
|
+
"pino-abstract-transport": ["pino-abstract-transport@3.0.0", "", { "dependencies": { "split2": "^4.0.0" } }, "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg=="],
|
|
123
|
+
|
|
124
|
+
"pino-pretty": ["pino-pretty@13.1.3", "", { "dependencies": { "colorette": "^2.0.7", "dateformat": "^4.6.3", "fast-copy": "^4.0.0", "fast-safe-stringify": "^2.1.1", "help-me": "^5.0.0", "joycon": "^3.1.1", "minimist": "^1.2.6", "on-exit-leak-free": "^2.1.0", "pino-abstract-transport": "^3.0.0", "pump": "^3.0.0", "secure-json-parse": "^4.0.0", "sonic-boom": "^4.0.1", "strip-json-comments": "^5.0.2" }, "bin": { "pino-pretty": "bin.js" } }, "sha512-ttXRkkOz6WWC95KeY9+xxWL6AtImwbyMHrL1mSwqwW9u+vLp/WIElvHvCSDg0xO/Dzrggz1zv3rN5ovTRVowKg=="],
|
|
125
|
+
|
|
126
|
+
"pino-std-serializers": ["pino-std-serializers@7.1.0", "", {}, "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw=="],
|
|
127
|
+
|
|
128
|
+
"process-warning": ["process-warning@5.1.0", "", {}, "sha512-jQSaVHsPgtyw60e1rQ/A+/ArPEj/S8pS/vFnyGa/gYFXrKk/6RuDkoqVDQ5NI5MmS01698ltlAk0NoDBNLujRw=="],
|
|
129
|
+
|
|
130
|
+
"pump": ["pump@3.0.4", "", { "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA=="],
|
|
131
|
+
|
|
132
|
+
"quick-format-unescaped": ["quick-format-unescaped@4.0.4", "", {}, "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg=="],
|
|
133
|
+
|
|
134
|
+
"real-require": ["real-require@0.2.0", "", {}, "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg=="],
|
|
135
|
+
|
|
136
|
+
"safe-stable-stringify": ["safe-stable-stringify@2.5.0", "", {}, "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA=="],
|
|
137
|
+
|
|
138
|
+
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
|
139
|
+
|
|
140
|
+
"secure-json-parse": ["secure-json-parse@4.1.0", "", {}, "sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA=="],
|
|
141
|
+
|
|
142
|
+
"signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="],
|
|
143
|
+
|
|
144
|
+
"sonic-boom": ["sonic-boom@4.2.1", "", { "dependencies": { "atomic-sleep": "^1.0.0" } }, "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q=="],
|
|
145
|
+
|
|
146
|
+
"split2": ["split2@4.2.0", "", {}, "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg=="],
|
|
147
|
+
|
|
148
|
+
"string-width": ["string-width@8.2.2", "", { "dependencies": { "get-east-asian-width": "^1.5.0", "strip-ansi": "^7.1.2" } }, "sha512-GaPUh5gfdrYzqeVNZvUfT23vYYxXzKYidUcnMtJg/3rxRV63EFZy3k6xfKlmfeJD0176lnUV/Usr3XcwSvFzpg=="],
|
|
149
|
+
|
|
150
|
+
"strip-ansi": ["strip-ansi@7.2.0", "", { "dependencies": { "ansi-regex": "^6.2.2" } }, "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w=="],
|
|
151
|
+
|
|
152
|
+
"strip-json-comments": ["strip-json-comments@5.0.3", "", {}, "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw=="],
|
|
153
|
+
|
|
154
|
+
"thread-stream": ["thread-stream@4.2.0", "", { "dependencies": { "real-require": "^1.0.0" } }, "sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ=="],
|
|
155
|
+
|
|
156
|
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
157
|
+
|
|
158
|
+
"undici-types": ["undici-types@8.3.0", "", {}, "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ=="],
|
|
159
|
+
|
|
160
|
+
"wrap-ansi": ["wrap-ansi@9.0.2", "", { "dependencies": { "ansi-styles": "^6.2.1", "string-width": "^7.0.0", "strip-ansi": "^7.1.0" } }, "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww=="],
|
|
161
|
+
|
|
162
|
+
"wrappy": ["wrappy@1.0.2", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="],
|
|
163
|
+
|
|
164
|
+
"y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="],
|
|
165
|
+
|
|
166
|
+
"yargs": ["yargs@18.1.0", "", { "dependencies": { "cliui": "^9.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "string-width": "^8.2.1", "y18n": "^5.0.5", "yargs-parser": "^22.0.0" } }, "sha512-2rAgRKu54VsHkqI0/tYkmluGXHD4KW7yZoycuqDQ15QOTnc2VVfy0nN/1eMhnQLO00A+dwtK20xuCnc1YGeUyg=="],
|
|
167
|
+
|
|
168
|
+
"yargs-parser": ["yargs-parser@22.0.0", "", {}, "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw=="],
|
|
169
|
+
|
|
170
|
+
"cliui/string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
|
|
171
|
+
|
|
172
|
+
"thread-stream/real-require": ["real-require@1.0.0", "", {}, "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g=="],
|
|
173
|
+
|
|
174
|
+
"wrap-ansi/string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
|
|
175
|
+
}
|
|
176
|
+
}
|
package/ci/npm.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Commands from "./environmentCmd";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
command: 'environment',
|
|
5
|
+
describe: 'Manage environments',
|
|
6
|
+
builder: (yargs) => yargs
|
|
7
|
+
.usage('Usage: envedit environment <command> [options]')
|
|
8
|
+
.command(Commands)
|
|
9
|
+
.demandCommand(),
|
|
10
|
+
} as CommandModule;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync as exists,
|
|
3
|
+
unlinkSync as unlink,
|
|
4
|
+
symlinkSync as symlink,
|
|
5
|
+
} from "node:fs";
|
|
6
|
+
|
|
7
|
+
import { confirm, input, password, select } from "@inquirer/prompts";
|
|
8
|
+
|
|
9
|
+
import { Configuration, EnvironmentFile, VariableType } from "#lib/config";
|
|
10
|
+
import { NotFoundError } from "#lib/error";
|
|
11
|
+
import { Logger } from "#lib/logger";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
command: 'add',
|
|
15
|
+
describe: 'Add a new environment',
|
|
16
|
+
builder: (yargs) => yargs,
|
|
17
|
+
handler: async (argv) => {
|
|
18
|
+
const config = new Configuration();
|
|
19
|
+
const logger = new Logger(argv.level);
|
|
20
|
+
|
|
21
|
+
const name = await input({
|
|
22
|
+
message: "Enter the environment name:",
|
|
23
|
+
validate: (input) => {
|
|
24
|
+
if (!input) {
|
|
25
|
+
return "Environment name cannot be empty";
|
|
26
|
+
}
|
|
27
|
+
if (config.envs.has(input)) {
|
|
28
|
+
return "Environment name already exists";
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const prefix = await input({
|
|
35
|
+
message: "Enter the environment prefix:",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const file = await input({
|
|
39
|
+
message: "Enter the environment file path:",
|
|
40
|
+
default: `.env.${prefix}`,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const isActive = await confirm({
|
|
44
|
+
message: "Is this environment active?",
|
|
45
|
+
default: !config.active,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
logger.debug(`Adding new environment "${name}" with prefix "${prefix}" and file: "${file}"`);
|
|
49
|
+
|
|
50
|
+
config.envs.set(name, { name, prefix, file, isActive });
|
|
51
|
+
config.save();
|
|
52
|
+
|
|
53
|
+
const envFile = new EnvironmentFile(file);
|
|
54
|
+
|
|
55
|
+
if (!exists(file)) {
|
|
56
|
+
logger.debug(`Environment file not found: ${file}`);
|
|
57
|
+
|
|
58
|
+
const shouldClone = await confirm({
|
|
59
|
+
message: "Do you want to clone a pre-existing environment into the new file?",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (shouldClone) {
|
|
63
|
+
logger.debug(`Cloning a pre-existing environment into the new file: ${file}`);
|
|
64
|
+
|
|
65
|
+
const clonedEnv = await select({
|
|
66
|
+
message: "Select the environment to clone from:",
|
|
67
|
+
choices: Array.from(config.envs.keys()),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const selectedEnv = config.envs.get(clonedEnv);
|
|
71
|
+
|
|
72
|
+
if (!selectedEnv) {
|
|
73
|
+
throw new NotFoundError(`Environment not found: ${clonedEnv}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const envSpecificFile = new EnvironmentFile(selectedEnv.file);
|
|
77
|
+
|
|
78
|
+
for (const [key, value] of Object.entries(envSpecificFile.vars)) {
|
|
79
|
+
envFile.vars.set(key, value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
envFile.save();
|
|
83
|
+
} else {
|
|
84
|
+
for (const [_, variable] of config.vars) {
|
|
85
|
+
const request = {
|
|
86
|
+
message: `Enter the value for ${variable.name} in environment ${name}:`,
|
|
87
|
+
mask: variable.type === VariableType.Private ? "*" : undefined,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const value = variable.type === VariableType.Private
|
|
91
|
+
? await password(request)
|
|
92
|
+
: await input(request);
|
|
93
|
+
|
|
94
|
+
logger
|
|
95
|
+
.debug(`Setting variable "${variable.name}" with value "${value}" in environment "${name}"`);
|
|
96
|
+
|
|
97
|
+
envFile.vars.set(variable.name, value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
envFile.save();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (isActive) {
|
|
105
|
+
config.active = name;
|
|
106
|
+
|
|
107
|
+
if (exists('.env')) {
|
|
108
|
+
unlink('.env');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const properEnv = config.envs.get(name)!;
|
|
112
|
+
symlink(properEnv.file, '.env', 'file');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} satisfies CommandModule;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renameSync as rename,
|
|
3
|
+
existsSync as exists,
|
|
4
|
+
} from "node:fs";
|
|
5
|
+
|
|
6
|
+
import { input, select, checkbox } from "@inquirer/prompts";
|
|
7
|
+
|
|
8
|
+
import { Configuration } from "#lib/config";
|
|
9
|
+
import { NotFoundError } from "#lib/error";
|
|
10
|
+
import { Logger } from "#lib/logger";
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
command: 'edit',
|
|
14
|
+
describe: 'Edit an environment',
|
|
15
|
+
builder: (yargs) => yargs,
|
|
16
|
+
handler: async (argv) => {
|
|
17
|
+
const config = new Configuration();
|
|
18
|
+
const logger = new Logger(argv.level);
|
|
19
|
+
|
|
20
|
+
const name = await select({
|
|
21
|
+
message: "Select the environment to edit:",
|
|
22
|
+
choices: Array.from(config.envs.keys()),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const selectedEnv = config.envs.get(name);
|
|
26
|
+
|
|
27
|
+
if (!selectedEnv) {
|
|
28
|
+
throw new NotFoundError(`Environment not found: ${name}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const itemsToEdit = await checkbox({
|
|
32
|
+
message: "Select the items to edit:",
|
|
33
|
+
choices: [
|
|
34
|
+
{ name: "Name", value: "name" },
|
|
35
|
+
{ name: "Prefix", value: "prefix" },
|
|
36
|
+
{ name: "File", value: "file" },
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const updatedEnv = { ...selectedEnv };
|
|
41
|
+
|
|
42
|
+
if (itemsToEdit.includes("name")) {
|
|
43
|
+
logger.debug(`Editing environment name from "${selectedEnv.name}" to "${updatedEnv.name}"`);
|
|
44
|
+
updatedEnv.name = await input({
|
|
45
|
+
message: "Enter the new environment name:",
|
|
46
|
+
default: selectedEnv.name,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (itemsToEdit.includes("prefix")) {
|
|
51
|
+
logger.debug(`Editing environment prefix from "${selectedEnv.prefix}" to "${updatedEnv.prefix}"`);
|
|
52
|
+
updatedEnv.prefix = await input({
|
|
53
|
+
message: "Enter the new environment prefix:",
|
|
54
|
+
default: selectedEnv.prefix,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (itemsToEdit.includes("file")) {
|
|
59
|
+
logger.debug(`Editing environment file from "${selectedEnv.file}" to "${updatedEnv.file}"`);
|
|
60
|
+
updatedEnv.file = await input({
|
|
61
|
+
message: "Enter the new environment file path:",
|
|
62
|
+
default: selectedEnv.file,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
config.envs.set(name, updatedEnv);
|
|
67
|
+
config.save();
|
|
68
|
+
|
|
69
|
+
if (itemsToEdit.includes("file") && exists(selectedEnv.file)) {
|
|
70
|
+
logger.debug(`Renaming environment file from "${selectedEnv.file}" to "${updatedEnv.file}"`);
|
|
71
|
+
rename(selectedEnv.file, updatedEnv.file);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} satisfies CommandModule;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Configuration } from "#lib/config";
|
|
2
|
+
import { Logger } from "#lib/logger";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
command: 'list',
|
|
6
|
+
describe: 'List all environments',
|
|
7
|
+
builder: (yargs) => yargs,
|
|
8
|
+
handler: async (argv) => {
|
|
9
|
+
const config = new Configuration();
|
|
10
|
+
const logger = new Logger(argv.level);
|
|
11
|
+
|
|
12
|
+
logger.debug(`Listing all environments`);
|
|
13
|
+
|
|
14
|
+
console.log(JSON.stringify(Array.from(config.envs.values()), null, 2));
|
|
15
|
+
}
|
|
16
|
+
} satisfies CommandModule;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync as exists,
|
|
3
|
+
unlinkSync as unlink,
|
|
4
|
+
} from "node:fs";
|
|
5
|
+
|
|
6
|
+
import { confirm, select } from "@inquirer/prompts";
|
|
7
|
+
|
|
8
|
+
import { Configuration } from "#lib/config";
|
|
9
|
+
import { NotFoundError } from "#lib/error";
|
|
10
|
+
import { Logger } from "#lib/logger";
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
command: 'remove',
|
|
14
|
+
describe: 'Remove an environment',
|
|
15
|
+
builder: (yargs) => yargs,
|
|
16
|
+
handler: async (argv) => {
|
|
17
|
+
const config = new Configuration();
|
|
18
|
+
const logger = new Logger(argv.level);
|
|
19
|
+
|
|
20
|
+
const name = await select({
|
|
21
|
+
message: "Select the environment to remove:",
|
|
22
|
+
choices: Array.from(config.envs.keys()),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const selectedEnv = config.envs.get(name);
|
|
26
|
+
|
|
27
|
+
if (!selectedEnv) {
|
|
28
|
+
throw new NotFoundError(`Environment not found: ${name}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
logger.debug(`Removing environment "${name}" with file: "${selectedEnv.file}"`);
|
|
32
|
+
|
|
33
|
+
config.envs.delete(name);
|
|
34
|
+
config.save();
|
|
35
|
+
|
|
36
|
+
if (exists(selectedEnv.file)) {
|
|
37
|
+
const toDelete = await confirm({
|
|
38
|
+
message: `Environment file found: ${selectedEnv.file}. Do you want to delete it?`
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (toDelete) {
|
|
42
|
+
logger.debug(`Deleting environment file: ${selectedEnv.file}`);
|
|
43
|
+
unlink(selectedEnv.file);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} satisfies CommandModule;
|
package/cli/cmd/index.ts
ADDED
package/cli/cmd/init.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync as exists,
|
|
3
|
+
readFileSync as read,
|
|
4
|
+
writeFileSync as write,
|
|
5
|
+
appendFileSync as append,
|
|
6
|
+
} from "node:fs";
|
|
7
|
+
|
|
8
|
+
import { confirm } from "@inquirer/prompts";
|
|
9
|
+
|
|
10
|
+
import { Configuration } from "#lib/config";
|
|
11
|
+
import { Logger } from "#lib/logger";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
command: 'init',
|
|
15
|
+
describe: 'Initialize the project for use with envedit',
|
|
16
|
+
builder: (yargs) => yargs
|
|
17
|
+
.usage('Usage: envedit init')
|
|
18
|
+
.epilogue("Note that this command is meant to be used when the project is FIRST setup, not to setup based on a pre-existing configuration. for that, please run the 'setup' command"),
|
|
19
|
+
handler: async (argv) => {
|
|
20
|
+
const logger = new Logger(argv.level);
|
|
21
|
+
new Configuration();
|
|
22
|
+
|
|
23
|
+
if (exists('.git')) {
|
|
24
|
+
logger.debug(`Git repository found. Checking for git ignore file.`);
|
|
25
|
+
|
|
26
|
+
const gitignorePath = '.gitignore';
|
|
27
|
+
|
|
28
|
+
if (!exists('.gitignore')) {
|
|
29
|
+
const toCreate = await confirm({
|
|
30
|
+
message: `Git Repository without a git ignore file not found. Do you want to create it?`
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (toCreate) {
|
|
34
|
+
write('.gitignore', "");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const expectedItems = ['.env', '.env.*'];
|
|
39
|
+
|
|
40
|
+
logger.debug(`Checking for expected items in git ignore file: ${expectedItems.join(", ")}`);
|
|
41
|
+
|
|
42
|
+
for (const item of expectedItems) {
|
|
43
|
+
if (read(gitignorePath, "utf-8").includes(item)) {
|
|
44
|
+
logger.debug(`Item not found in git ignore file: ${item}`);
|
|
45
|
+
|
|
46
|
+
const toAdd = await confirm({
|
|
47
|
+
message: `The item ${item} is not in the git ignore file. Do you want to add it?`
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (!toAdd) {
|
|
51
|
+
console.error(`The item ${item} is not in the git ignore file.`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
append(gitignorePath, `\n${item}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} as CommandModule;
|