@dotenvx/dotenvx 0.4.0 → 0.4.12
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 +28 -0
- package/README.md +225 -251
- package/bin/dotenvx.cjs +34 -0
- package/config.cjs +1 -0
- package/config.d.ts +1 -0
- package/config.mjs +2 -0
- package/index.cjs +141 -0
- package/index.d.ts +66 -0
- package/index.mjs +3 -0
- package/lib/cli.cjs +43 -0
- package/lib/native-package.cjs +21 -0
- package/lib/platforms.cjs +18 -0
- package/lib/redactOutput.cjs +72 -0
- package/lib/redaction.cjs +64 -0
- package/lib/validateOptions.cjs +57 -0
- package/native.cjs +23 -0
- package/package.json +63 -36
- package/src/cli/dotenvx.js +0 -218
- package/src/cli/helpers.js +0 -147
- package/src/lib/main.js +0 -63
- package/src/shared/logger.js +0 -30
- package/src/shared/packageJson.js +0 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Scott Motte
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,307 +1,281 @@
|
|
|
1
|
-
|
|
1
|
+
# dotenvx Node.js SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Node.js adapter for Forge's shared Rust `dotenvx-sdk`. Parsing, expansion,
|
|
4
|
+
decryption, source selection, custody delegation, and Dotenvx.toml policy use
|
|
5
|
+
the same engine as Ruby and Python. JavaScript owns the public API, environment
|
|
6
|
+
updates, diagnostics, and output interception.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
* multi-environment
|
|
7
|
-
* encrypted envs
|
|
8
|
+
## Local development
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
### Quickstart
|
|
13
|
-
|
|
14
|
-
```sh
|
|
15
|
-
brew install dotenvx/brew/dotenvx
|
|
16
|
-
```
|
|
17
|
-
> * [other ways to install](#other-ways-to-install)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Run Anywhere
|
|
10
|
+
From Forge with Node.js 20+ and a Rust toolchain installed:
|
|
22
11
|
|
|
23
12
|
```sh
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
$ node index.js
|
|
27
|
-
Hello undefined
|
|
28
|
-
|
|
29
|
-
$ dotenvx run -- node index.js
|
|
30
|
-
Hello World
|
|
31
|
-
> :-D
|
|
13
|
+
npm run build:dotenvx-nodejs
|
|
14
|
+
npm run test:dotenvx-nodejs
|
|
32
15
|
```
|
|
33
16
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* <details><summary>Python 🐍</summary><br>
|
|
37
|
-
|
|
38
|
-
```sh
|
|
39
|
-
$ echo 'import os;print("Hello " + os.getenv("HELLO", ""))' > index.py
|
|
40
|
-
|
|
41
|
-
$ dotenvx run -- python3 index.py
|
|
42
|
-
Hello World
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
</details>
|
|
46
|
-
* <details><summary>PHP 🐘</summary><br>
|
|
47
|
-
|
|
48
|
-
```sh
|
|
49
|
-
$ echo '<?php echo "Hello {$_SERVER["HELLO"]}\n";' > index.php
|
|
50
|
-
|
|
51
|
-
$ dotenvx run -- php index.php
|
|
52
|
-
Hello World
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
</details>
|
|
56
|
-
* <details><summary>Ruby 💎</summary><br>
|
|
57
|
-
|
|
58
|
-
```sh
|
|
59
|
-
$ echo 'puts "Hello #{ENV["HELLO"]}"' > index.rb
|
|
60
|
-
|
|
61
|
-
$ dotenvx run -- ruby index.rb
|
|
62
|
-
Hello World
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
</details>
|
|
66
|
-
* <details><summary>Rust 🦀</summary><br>
|
|
67
|
-
|
|
68
|
-
```sh
|
|
69
|
-
$ echo 'fn main() {let hello = std::env::var("HELLO").unwrap_or("".to_string());println!("Hello {hello}");}' > src/main.rs
|
|
17
|
+
To install the local prototype in another project, pack and install the main
|
|
18
|
+
and matching platform packages together as described below.
|
|
70
19
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
$ dotenvx run -- next dev
|
|
80
|
-
$ dotenvx run -- npm start
|
|
81
|
-
$ dotenvx run -- bin/rails s
|
|
82
|
-
$ dotenvx run -- php artisan serve
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
</details>
|
|
86
|
-
* <details><summary>Docker 🐳</summary><br>
|
|
87
|
-
|
|
88
|
-
```sh
|
|
89
|
-
$ docker run -it --rm -v $(pwd):/app dotenv/dotenvx run -- node index.js
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Or in any image:
|
|
93
|
-
|
|
94
|
-
```sh
|
|
95
|
-
FROM node:latest
|
|
96
|
-
RUN echo "HELLO=World" > .env && echo "console.log('Hello ' + process.env.HELLO)" > index.js
|
|
97
|
-
RUN curl -fsS https://dotenvx.sh/ | sh
|
|
98
|
-
CMD ["dotenvx", "run", "--", "echo", "Hello $HELLO"]
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
</details>
|
|
102
|
-
|
|
103
|
-
* <details><summary>CI/CDs 🐙</summary><br>
|
|
104
|
-
|
|
105
|
-
```sh
|
|
106
|
-
examples coming soon
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
</details>
|
|
110
|
-
* <details><summary>Platforms</summary><br>
|
|
111
|
-
|
|
112
|
-
```sh
|
|
113
|
-
examples coming soon
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
</details>
|
|
117
|
-
* <details><summary>npx</summary><br>
|
|
118
|
-
|
|
119
|
-
```sh
|
|
120
|
-
# alternatively use npx
|
|
121
|
-
$ npx @dotenvx/dotenvx run -- node index.js
|
|
122
|
-
$ npx @dotenvx/dotenvx run -- next dev
|
|
123
|
-
$ npx @dotenvx/dotenvx run -- npm start
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
</details>
|
|
127
|
-
* <details><summary>Git</summary><br>
|
|
128
|
-
|
|
129
|
-
```sh
|
|
130
|
-
# use as a git submodule
|
|
131
|
-
$ git dotenvx run -- node index.js
|
|
132
|
-
$ git dotenvx run -- next dev
|
|
133
|
-
$ git dotenvx run -- npm start
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
</details>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
## Multiple Environments
|
|
141
|
-
|
|
142
|
-
Pass the `--env-file` flag (shorthand `-f`) to run any environment from a `.env.environment` file.
|
|
143
|
-
|
|
144
|
-
```sh
|
|
145
|
-
$ dotenvx run --env-file=.env.production -- node index.js
|
|
146
|
-
[dotenvx][INFO] Injecting 12 production environment variables into your application process
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
Combine multiple `.env` files if you like.
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
$ dotenvx run --env-file=.env.local --env-file=.env -- node index.js
|
|
153
|
-
[dotenvx][INFO] Injecting 12 local, 1 development environment variables into your application process
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
## Encrypt Your Env Files
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
dotenvx encrypt
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
> This will encrypt your `.env` file to a `.env.vault` file. Commit your `.env.vault` file safely to code.
|
|
165
|
-
> This will also generate a `.env.keys` file. Do NOT commit this file to code. Keep your `.env.keys` secret. 🤫
|
|
166
|
-
|
|
167
|
-
|
|
20
|
+
The package keeps the `@dotenvx/dotenvx` name and uses normal `0.4.x` versions
|
|
21
|
+
published under `next`. Install a specific version with
|
|
22
|
+
`npm install @dotenvx/dotenvx@0.4.11`, or follow Forge releases with
|
|
23
|
+
`npm install @dotenvx/dotenvx@next`. Unqualified installs continue to use `latest`.
|
|
24
|
+
There are no install-time downloads or compilation hooks. A local build writes
|
|
25
|
+
the current platform’s addon and default CLI to `native/` and prepares its npm
|
|
26
|
+
package under `dist/npm/`. The main npm package contains JavaScript only; native
|
|
27
|
+
files are delivered through exact-version optional platform dependencies.
|
|
168
28
|
|
|
169
29
|
## Usage
|
|
170
30
|
|
|
171
|
-
### Guide
|
|
172
|
-
|
|
173
|
-
Begin by creating a simple 'hello world' program.
|
|
174
|
-
|
|
175
31
|
```js
|
|
176
|
-
|
|
177
|
-
|
|
32
|
+
const dotenvx = require('@dotenvx/dotenvx')
|
|
33
|
+
const result = dotenvx.config()
|
|
34
|
+
console.log(process.env.HELLO)
|
|
178
35
|
```
|
|
179
36
|
|
|
180
|
-
|
|
37
|
+
ES modules support named and default imports:
|
|
181
38
|
|
|
182
39
|
```js
|
|
183
|
-
|
|
184
|
-
|
|
40
|
+
import dotenvx, { config } from '@dotenvx/dotenvx'
|
|
41
|
+
config({ path: '.env.production', strict: true })
|
|
185
42
|
```
|
|
186
43
|
|
|
187
|
-
|
|
44
|
+
Preload before application modules execute:
|
|
188
45
|
|
|
189
46
|
```sh
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Hello undefined
|
|
47
|
+
node --require @dotenvx/dotenvx/config app.cjs
|
|
48
|
+
node --import @dotenvx/dotenvx/config app.mjs
|
|
193
49
|
```
|
|
194
50
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
51
|
+
`import '@dotenvx/dotenvx/config'` also works. `DOTENV_CONFIG_PATH` selects a
|
|
52
|
+
preload file when `DOTENV_FILE` / `DOTENV_PATH` are absent. Quiet mode accepts
|
|
53
|
+
`DOTENV_QUIET` and the legacy `DOTENV_CONFIG_QUIET`.
|
|
54
|
+
|
|
55
|
+
## Core API
|
|
56
|
+
|
|
57
|
+
- `config(options)` synchronously resolves values and populates `process.env`,
|
|
58
|
+
returning `{ parsed, error? }`. `processEnv` selects a different environment
|
|
59
|
+
object to read and populate. Existing values win unless `overload` / `override`
|
|
60
|
+
is enabled. Strict or fatal errors throw before any resolved values are injected.
|
|
61
|
+
- `parse(stringOrBuffer, options)` uses Rust primitives without filesystem,
|
|
62
|
+
policy, or custody lookups. It expands values and decrypts using supplied
|
|
63
|
+
environment keys or `privateKey`, without changing the supplied environment.
|
|
64
|
+
- `get(key?, options)` resolves synchronously and returns the value directly.
|
|
65
|
+
`getSync` is an alias of the same function (`getSync === get`). Neither mutates
|
|
66
|
+
the environment. Calls block while reading files or resolving custody, and
|
|
67
|
+
failures throw synchronously. `await get(...)` still works with the returned
|
|
68
|
+
value; Promise methods such as `.then()` and `.catch()` are not supported.
|
|
69
|
+
With no key, they return the resolved object; `all: true` includes existing
|
|
70
|
+
environment values. `format` supports `eval`, `eval-export`, `shell`, and `colon`.
|
|
71
|
+
|
|
72
|
+
Files can be paths, file URLs, arrays, or directories. `envs` selects ordered
|
|
73
|
+
`{ type: 'envFile', value: path }` and `{ type: 'env', value: source }` inputs.
|
|
74
|
+
Explicit `envs` override `path`. `envKeysFile` / `keyFiles`
|
|
75
|
+
select private-key files. Conventions and implicit discovery are resolved in Rust.
|
|
76
|
+
This prototype supports UTF-8 files and includes TypeScript declarations.
|
|
77
|
+
|
|
78
|
+
Local `.env.keys` and environment private keys work without the CLI. Stored-key
|
|
79
|
+
custody uses `dotenvx sdk keyring` on PATH, like the other language SDKs. The CLI
|
|
80
|
+
needs `sdk` and the requested custody feature. Keys returned by the CLI remain
|
|
81
|
+
in the internal keyring and are not injected into the application's environment.
|
|
82
|
+
When using a custom `processEnv`, include the PATH and provider settings it needs.
|
|
83
|
+
Secret reference resolution is opt-in with `resolveReferences: true`.
|
|
84
|
+
|
|
85
|
+
Dotenvx.toml redaction is installed before diagnostics and injection. Console
|
|
86
|
+
output and stream writes are protected, including secrets split between writes.
|
|
87
|
+
|
|
88
|
+
## npm CLI
|
|
89
|
+
|
|
90
|
+
The matching optional platform package includes a default Rust CLI executable
|
|
91
|
+
alongside the SDK addon. The
|
|
92
|
+
npm launcher first looks for an installed standalone `dotenvx` on PATH, then
|
|
93
|
+
falls back to the bundled default CLI. An existing Armor or custom build is used
|
|
94
|
+
automatically, with its commands and features preserved. No separate curl
|
|
95
|
+
installation or install-time download is required for the bundled default.
|
|
205
96
|
|
|
206
97
|
```sh
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
Hello undefined
|
|
98
|
+
npx dotenvx encrypt
|
|
99
|
+
npx dotenvx run -- node app.cjs
|
|
210
100
|
```
|
|
211
101
|
|
|
212
|
-
|
|
102
|
+
Existing npm scripts such as `"start": "dotenvx run -- node app.cjs"` use the same
|
|
103
|
+
launcher, which forwards arguments, terminal input/output, exit status, and
|
|
104
|
+
termination signals without interpreting commands. The bundled CLI uses the
|
|
105
|
+
default feature set from Forge's CLI catalog. Command behavior follows the
|
|
106
|
+
selected Rust CLI rather than the former JavaScript CLI. `dotenvx --version`
|
|
107
|
+
reports the selected CLI's version; the prototype SDK and CLI currently have
|
|
108
|
+
separate version numbers.
|
|
109
|
+
|
|
110
|
+
PATH discovery skips script wrappers, including npm's own shims and older
|
|
111
|
+
JavaScript dotenvx CLIs, to avoid recursion. It selects the first executable
|
|
112
|
+
native binary named `dotenvx` (`dotenvx.exe` on Windows). The launcher does not
|
|
113
|
+
fall back if that installed CLI rejects a command or exits with an error.
|
|
114
|
+
Installing or updating a standalone CLI therefore changes what `npx dotenvx`
|
|
115
|
+
runs, even if the npm dependency is pinned.
|
|
116
|
+
|
|
117
|
+
Optionally, `DOTENVX_CLI` selects an explicit executable path ahead of PATH
|
|
118
|
+
discovery. No override is needed for Armor or custom builds on PATH. This setting
|
|
119
|
+
selects both the npm CLI executable and the SDK's delegated custody executable.
|
|
120
|
+
SDK custody uses the same standalone-binary discovery and packaged fallback as
|
|
121
|
+
the launcher, so it also works without a global CLI on PATH.
|
|
122
|
+
|
|
123
|
+
Decryption first checks matching environment private keys, then configured local
|
|
124
|
+
key files (including `.env.keys`), then the custodian named in the public-key
|
|
125
|
+
header. `armor pull` leaves the Armor custody metadata in place, but the pulled
|
|
126
|
+
matching local key can decrypt without a remote lookup. `armor down` additionally
|
|
127
|
+
removes remote custody and updates the header; local fallback does neither.
|
|
128
|
+
|
|
129
|
+
## Migrating from 2.x
|
|
130
|
+
|
|
131
|
+
The [central dotenvx 3.0 breaking-changes list](../README.md#dotenvx-30-breaking-changes)
|
|
132
|
+
records the removed SDK APIs (`set`, `ls`, `withEvents`, and public logging/color
|
|
133
|
+
helpers), migration guidance, and the decision to defer shared SDK event tracking.
|
|
134
|
+
|
|
135
|
+
## Platform packages and releases
|
|
136
|
+
|
|
137
|
+
Forge publishes these packages at the same version as `@dotenvx/dotenvx`:
|
|
138
|
+
|
|
139
|
+
| Runtime | Package |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| macOS ARM64 | `@dotenvx/dotenvx-darwin-arm64` |
|
|
142
|
+
| macOS x64 | `@dotenvx/dotenvx-darwin-x86_64` |
|
|
143
|
+
| Linux glibc ARM64 | `@dotenvx/dotenvx-linux-arm64` |
|
|
144
|
+
| Linux glibc x64 | `@dotenvx/dotenvx-linux-x86_64` |
|
|
145
|
+
| Linux musl ARM64 | `@dotenvx/dotenvx-linux-arm64-musl` |
|
|
146
|
+
| Linux musl x64 | `@dotenvx/dotenvx-linux-x86_64-musl` |
|
|
147
|
+
| Windows ARM64 | `@dotenvx/dotenvx-windows-arm64` |
|
|
148
|
+
| Windows x64 | `@dotenvx/dotenvx-windows-x86_64` |
|
|
149
|
+
|
|
150
|
+
Each package contains `dotenvx.node` and `dotenvx` (`dotenvx.exe` on Windows),
|
|
151
|
+
with `os`, `cpu`, and Linux `libc` filters. Existing binary package names are
|
|
152
|
+
reused; historical architecture aliases such as `amd64` are not additional SDK
|
|
153
|
+
dependencies. Linux glibc builds target glibc 2.28 or newer. Alpine uses separate
|
|
154
|
+
musl builds. The loader has no JavaScript fallback.
|
|
155
|
+
|
|
156
|
+
Do not omit optional dependencies when using the SDK. If they are omitted,
|
|
157
|
+
CLI commands can still use an installed standalone CLI, but SDK loading fails
|
|
158
|
+
with a reinstall hint. Local development can use the current platform's files
|
|
159
|
+
in `native/`; those files are excluded from the main npm tarball.
|
|
160
|
+
|
|
161
|
+
For a local packaged install, build and pack both packages, then install the two
|
|
162
|
+
resulting tarballs together. Unpublished optional packages for other platforms
|
|
163
|
+
can be skipped with npm's `--offline` flag:
|
|
213
164
|
|
|
214
165
|
```sh
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
[dotenvx@x.x.x][DEBUG] {"JELLO":"World"}
|
|
220
|
-
|
|
221
|
-
# Oops, HELLO not JELLO ^^
|
|
166
|
+
npm run build:dotenvx-nodejs
|
|
167
|
+
npm pack ./dotenvx-nodejs/dist/npm/dotenvx-darwin-arm64 --ignore-scripts
|
|
168
|
+
npm pack ./dotenvx-nodejs --ignore-scripts
|
|
169
|
+
npm install --offline ./dotenvx-dotenvx-0.4.11.tgz ./dotenvx-dotenvx-darwin-arm64-0.4.11.tgz
|
|
222
170
|
```
|
|
223
171
|
|
|
224
|
-
|
|
172
|
+
Substitute the current platform package and version. A direct local directory
|
|
173
|
+
install alone does not assemble optional packages for the consuming project.
|
|
225
174
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
175
|
+
`.github/workflows/nodejs.yml` builds and tests all eight native targets.
|
|
176
|
+
Pushing a matching `nodejs-v<version>` tag publishes the eight platform packages
|
|
177
|
+
under `next`, waits for npm to serve all eight exact versions, then prepares and
|
|
178
|
+
tests the core `@dotenvx/dotenvx` wrapper across all eight platforms before
|
|
179
|
+
publishing it under `next`. **Existing `latest` tags stay unchanged.** The source
|
|
180
|
+
core package stays private; only the validated staged wrapper is publishable.
|
|
181
|
+
Releases require normal `major.minor.patch` versions; prereleases are rejected.
|
|
230
182
|
|
|
231
|
-
|
|
183
|
+
From a clean working tree, prepare a Node.js release with:
|
|
232
184
|
|
|
233
185
|
```sh
|
|
234
|
-
|
|
235
|
-
[dotenvx@x.x.x][INFO] Injecting 1 environment variable into your application process
|
|
236
|
-
Hello World
|
|
186
|
+
npm run version:nodejs patch
|
|
237
187
|
```
|
|
238
188
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
## Install
|
|
245
|
-
|
|
246
|
-
Installing with [`brew`](https://brew.sh) is most straight forward:
|
|
189
|
+
`patch`, `minor`, and `major` perform normal version bumps. The helper synchronizes
|
|
190
|
+
npm/platform dependency versions, lockfile, and adapter Cargo versions, then
|
|
191
|
+
creates a local commit and `nodejs-v<version>` tag. It does not publish or push.
|
|
192
|
+
You can also include `nodejs` in `npm run version:batch -- cli,nodejs patch`
|
|
193
|
+
(with optional `--push`). It prints the exact atomic push command, for example:
|
|
247
194
|
|
|
248
195
|
```sh
|
|
249
|
-
|
|
196
|
+
git push --atomic origin HEAD refs/tags/nodejs-v0.4.12
|
|
250
197
|
```
|
|
251
198
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
199
|
+
Pushing the matching tag triggers the full platform-and-core release under `next`.
|
|
200
|
+
To backfill or retry an existing normal-version release, dispatch the workflow
|
|
201
|
+
from `main`, enter the exact version (for example `0.4.11`), choose
|
|
202
|
+
`target=platforms`, and enable `publish`. Every job checks out the corresponding
|
|
203
|
+
`nodejs-v0.4.11` tag, whose package version must match. The tag must exist;
|
|
204
|
+
CLI-only `cli-v*` tags and old beta tags cannot be used for this flow.
|
|
255
205
|
|
|
256
206
|
```sh
|
|
257
|
-
|
|
207
|
+
gh workflow run nodejs.yml --ref main -f target=platforms -f version=0.4.11 -f publish=true
|
|
258
208
|
```
|
|
259
209
|
|
|
260
|
-
|
|
210
|
+
Manual runs default to `publish=false` for build and test checks. Existing
|
|
211
|
+
`latest` tags remain untouched. Already published versions are reused only when
|
|
212
|
+
tarball integrity matches. A platform publication or core test failure stops the
|
|
213
|
+
release before core publication. Published npm versions cannot be overwritten.
|
|
261
214
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
215
|
+
Before the first release, configure npm trusted publishing for
|
|
216
|
+
every platform package: repository `dotenvx/forge`, workflow `nodejs.yml`,
|
|
217
|
+
environment `release`. The workflow uses Node 24 and npm with OIDC support. Forge is private, so
|
|
218
|
+
publication explicitly disables provenance; npm does not support provenance
|
|
219
|
+
from private repositories, even for public packages. See the
|
|
220
|
+
[npm trusted publishing documentation](https://docs.npmjs.com/trusted-publishers/).
|
|
221
|
+
The three new package names have been initialized at `0.1.0`. The release
|
|
222
|
+
workflow now uses trusted publishing only and does not read an `NPM_TOKEN`
|
|
223
|
+
secret. No credentials are needed for build-only runs. Platform manifests also
|
|
224
|
+
set `publishConfig.tag` to `next`, and artifact validation rejects any other tag.
|
|
265
225
|
|
|
266
|
-
|
|
226
|
+
Forge owns the new `0.4.x` platform packages and core wrapper releases.
|
|
227
|
+
Existing 2.x versions remain unchanged.
|
|
267
228
|
|
|
268
|
-
```sh
|
|
269
|
-
npm i @dotenvx/dotenvx --save
|
|
270
|
-
```
|
|
271
|
-
```json
|
|
272
|
-
// package.json
|
|
273
|
-
"scripts": {
|
|
274
|
-
"start": "./node_modules/.bin/dotenvx run -- nodex index.js"
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
229
|
|
|
278
|
-
|
|
230
|
+
## Core publication from Forge
|
|
279
231
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
232
|
+
Core publication follows successful platform publication automatically in
|
|
233
|
+
`nodejs.yml` tag releases. Preparation waits for npm's processing delay, then the
|
|
234
|
+
core test matrix must pass on all eight platforms. A separate `core` manual
|
|
235
|
+
mode remains available to test or retry only the wrapper. It uses the
|
|
236
|
+
already-published, exact-version platform packages. It never rebuilds or
|
|
237
|
+
republishes the CLI or native addons and never copies code to
|
|
238
|
+
the legacy dotenvx repository.
|
|
287
239
|
|
|
288
|
-
|
|
289
|
-
|
|
240
|
+
The source `package.json` stays private. Preparation creates a staged tarball
|
|
241
|
+
with `private: false`, no lifecycle scripts, and `publishConfig.tag: next`.
|
|
242
|
+
It validates all eight published platform versions and their metadata before
|
|
243
|
+
preparing the wrapper. No native files are included in the wrapper tarball.
|
|
290
244
|
|
|
291
|
-
|
|
292
|
-
sudo install -m 755 dotenvx /usr/local/bin
|
|
245
|
+
A local read-only registry check and package preparation is available:
|
|
293
246
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
# check it is in your path
|
|
298
|
-
which dotenv
|
|
299
|
-
dotenvx help
|
|
247
|
+
```sh
|
|
248
|
+
npm run prepare:nodejs:core
|
|
300
249
|
```
|
|
301
250
|
|
|
302
|
-
|
|
251
|
+
This produces `dist/nodejs-core/dotenvx-dotenvx-<version>.tgz` without publishing.
|
|
252
|
+
To exercise the staged wrapper against the published native dependencies on all
|
|
253
|
+
eight targets, after committing and pushing the workflow changes, dispatch:
|
|
303
254
|
|
|
304
|
-
|
|
255
|
+
```sh
|
|
256
|
+
gh workflow run nodejs.yml --ref main -f target=core -f version=0.4.11 -f publish=false
|
|
257
|
+
```
|
|
305
258
|
|
|
306
|
-
|
|
307
|
-
|
|
259
|
+
The core test matrix installs the existing npm binaries and tests the actual
|
|
260
|
+
staged tarball, SDK imports, preload entry points, CLI dispatch, encryption, and
|
|
261
|
+
decryption. No Rust toolchain or native rebuild is used in core mode.
|
|
262
|
+
|
|
263
|
+
To publish or retry only the core release, manually dispatch `nodejs.yml` from
|
|
264
|
+
`main`, choose `target=core`, enable `publish`, and enter the exact version
|
|
265
|
+
in the `version` input. All jobs check out its matching `nodejs-v<version>` tag.
|
|
266
|
+
Missing tags or mismatched package versions are rejected. Publication waits for the full core test matrix and uses
|
|
267
|
+
the `release` environment and GitHub OIDC, as do automatic tag releases.
|
|
268
|
+
The core package must trust
|
|
269
|
+
`dotenvx/forge`, workflow `nodejs.yml`, environment `release` on npm.
|
|
270
|
+
|
|
271
|
+
Only the validated `@dotenvx/dotenvx` tarball is published, with an explicit
|
|
272
|
+
`--tag next`, public npm registry, disabled lifecycle scripts, and disabled
|
|
273
|
+
provenance for this private repository. The publisher snapshots core/platform
|
|
274
|
+
tags, rechecks them before publication, and verifies them afterward. Only core's
|
|
275
|
+
`next` tag may change; `latest` and all platform tags must remain unchanged.
|
|
276
|
+
There is no `latest` publication option, platform-publish command, or dist-tag
|
|
277
|
+
mutation command in the core publisher. Existing versions are never overwritten. An
|
|
278
|
+
identical retry is accepted only if the published integrity and `next` tag match.
|
|
279
|
+
|
|
280
|
+
Both manual modes default to `publish=false`. Branch pushes do not publish;
|
|
281
|
+
matching `nodejs-v*` tag pushes publish platforms and core automatically.
|
package/bin/dotenvx.cjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('node:child_process')
|
|
3
|
+
const { resolveCli } = require('../lib/cli.cjs')
|
|
4
|
+
|
|
5
|
+
const libc = process.platform === 'linux' ? (process.report.getReport().header.glibcVersionRuntime ? '-gnu' : '-musl') : ''
|
|
6
|
+
const platform = `${process.platform}-${process.arch}${libc}`
|
|
7
|
+
let binary
|
|
8
|
+
try {
|
|
9
|
+
binary = resolveCli()
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error(error.message)
|
|
12
|
+
process.exit(1)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: 'inherit' })
|
|
16
|
+
const signals = process.platform === 'win32' ? ['SIGINT', 'SIGTERM'] : ['SIGINT', 'SIGTERM', 'SIGHUP']
|
|
17
|
+
const handlers = new Map(signals.map(signal => [signal, () => child.kill(signal)]))
|
|
18
|
+
for (const [signal, handler] of handlers) process.on(signal, handler)
|
|
19
|
+
const cleanup = () => {
|
|
20
|
+
for (const [signal, handler] of handlers) process.removeListener(signal, handler)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
child.on('error', error => {
|
|
24
|
+
cleanup()
|
|
25
|
+
console.error(`Could not launch the dotenvx CLI for ${platform}: ${error.message}`)
|
|
26
|
+
console.error('Reinstall @dotenvx/dotenvx with its native files included. For a local Forge checkout, run npm run build:dotenvx-nodejs.')
|
|
27
|
+
console.error('To use a standalone installation, set DOTENVX_CLI to the absolute path of its executable.')
|
|
28
|
+
process.exitCode = 1
|
|
29
|
+
})
|
|
30
|
+
child.on('exit', (code, signal) => {
|
|
31
|
+
cleanup()
|
|
32
|
+
if (signal) process.kill(process.pid, signal)
|
|
33
|
+
else process.exitCode = code
|
|
34
|
+
})
|
package/config.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('./index.cjs').config()
|
package/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/config.mjs
ADDED