ultraenv 1.0.1 → 1.0.3
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/README.md +67 -1857
- package/dist/{chunk-GC7RXHLA.js → chunk-2MBSLURI.js} +16 -17
- package/dist/{chunk-IGFVP24Q.js → chunk-3AF476D7.js} +1 -1
- package/dist/{chunk-N5PAV4NM.js → chunk-5WUBB633.js} +17 -26
- package/dist/{chunk-2USZPWLZ.js → chunk-6NFA23AY.js} +28 -39
- package/dist/{chunk-AWN6ADV7.js → chunk-6X3BUE5S.js} +45 -54
- package/dist/{chunk-NBOABPHM.js → chunk-72UKVOO5.js} +24 -40
- package/dist/{chunk-JB7RKV3C.js → chunk-7AHG2IP4.js} +1 -7
- package/dist/{chunk-6KS56D6E.js → chunk-7VJ7LK2M.js} +1 -1
- package/dist/{chunk-CIFMBJ4H.js → chunk-BNUHE2ZI.js} +57 -21
- package/dist/{chunk-HFXQGJY3.js → chunk-CVJPO3QY.js} +13 -27
- package/dist/{chunk-IKPTKALB.js → chunk-F7YSINGU.js} +1 -3
- package/dist/{chunk-3VYXPTYV.js → chunk-FSKVYBEP.js} +1 -1
- package/dist/{chunk-4XUYMRK5.js → chunk-GJC64ZG7.js} +4 -3
- package/dist/{chunk-YMMP4VQL.js → chunk-H3QEGEZ6.js} +1 -1
- package/dist/{chunk-CHVO6NWI.js → chunk-LFIKYFPS.js} +2 -2
- package/dist/{chunk-3UV2QNJL.js → chunk-LJSCUOD4.js} +19 -21
- package/dist/{chunk-YVWLXFUT.js → chunk-LQZK6BBQ.js} +2 -2
- package/dist/{chunk-5G2DU52U.js → chunk-N7GOHQBF.js} +7 -1
- package/dist/{chunk-MSXMESFP.js → chunk-OBLMAUCF.js} +8 -14
- package/dist/{chunk-UEWYFN6A.js → chunk-RJTUAMK3.js} +16 -29
- package/dist/{chunk-MNVFG7H4.js → chunk-XPZC32UY.js} +16 -25
- package/dist/{chunk-WMHN5RW2.js → chunk-YLGJQOMM.js} +3 -9
- package/dist/{ci-check-sync-VBMSVWIV.js → ci-check-sync-UO5PARKO.js} +4 -4
- package/dist/{ci-scan-24MT5XGS.js → ci-scan-5D7QBN5X.js} +2 -5
- package/dist/{ci-setup-C2NKEFRD.js → ci-setup-J34DS6KD.js} +2 -2
- package/dist/{ci-validate-7AW24LSQ.js → ci-validate-LWP5NBDN.js} +4 -4
- package/dist/cli/index.cjs +470 -390
- package/dist/cli/index.js +130 -55
- package/dist/comparator-AIRTWBOL.js +13 -0
- package/dist/{config-O5YRQP5Z.js → config-67GDO3CW.js} +3 -3
- package/dist/{debug-PTPXAF3K.js → debug-6VCX3QSP.js} +6 -6
- package/dist/{declaration-LEME4AFZ.js → declaration-YGOVZOXG.js} +3 -3
- package/dist/{doctor-FZAUPKHS.js → doctor-FF7QOTP2.js} +7 -5
- package/dist/{envs-compare-5K3HESX5.js → envs-compare-P7GPKGQX.js} +4 -4
- package/dist/{envs-create-2XXHXMGA.js → envs-create-ISG4SECU.js} +4 -4
- package/dist/{envs-list-NQM5252B.js → envs-list-PUW67HOC.js} +5 -5
- package/dist/{envs-switch-6L2AQYID.js → envs-switch-P4YDJ6LG.js} +4 -4
- package/dist/{envs-validate-FL73Q76T.js → envs-validate-VNKBKYO3.js} +6 -9
- package/dist/{fs-VH7ATUS3.js → fs-7HKOZY5K.js} +2 -2
- package/dist/{generator-LFZBMZZS.js → generator-O23ATCIY.js} +4 -4
- package/dist/{help-3XJBXEHE.js → help-THFLI6YT.js} +108 -26
- package/dist/index.cjs +295 -381
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +81 -100
- package/dist/{init-Y7JQ2KYJ.js → init-KBLVTHQW.js} +15 -11
- package/dist/{install-hook-SKXIV6NV.js → install-hook-42F22BLY.js} +2 -2
- package/dist/{json-schema-I26YNQBH.js → json-schema-YULPWDKA.js} +3 -3
- package/dist/{key-manager-O3G55WPU.js → key-manager-WDWPX3IQ.js} +3 -3
- package/dist/middleware/express.cjs +1 -3
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.cjs +1 -7
- package/dist/middleware/fastify.js +1 -1
- package/dist/{module-IDIZPP4M.js → module-FGH2V6N2.js} +3 -3
- package/dist/{protect-NCWPM6VC.js → protect-A4G7LQFJ.js} +26 -24
- package/dist/{scan-TRLY36TT.js → scan-4BXGHR33.js} +1 -1
- package/dist/schema/index.cjs +57 -21
- package/dist/schema/index.js +1 -1
- package/dist/{sync-TMHMTLH2.js → sync-MYLMDDY6.js} +23 -14
- package/dist/{typegen-SQOSXBWM.js → typegen-GLBRHWSK.js} +17 -23
- package/dist/{validate-IOAM5HWS.js → validate-J73ETKXD.js} +5 -5
- package/dist/{vault-decrypt-U6HJZNBV.js → vault-decrypt-V3GY5HES.js} +7 -7
- package/dist/{vault-diff-B3ZOQTWI.js → vault-diff-QVE6S6KP.js} +5 -5
- package/dist/{vault-encrypt-GUSLCSKS.js → vault-encrypt-WUBY3OVF.js} +7 -7
- package/dist/{vault-init-GUBOTOUL.js → vault-init-EWSAED44.js} +5 -5
- package/dist/{vault-rekey-DAHT7JCN.js → vault-rekey-VODMGCNA.js} +7 -7
- package/dist/{vault-status-GDLRU2OK.js → vault-status-YXDK6O7X.js} +4 -4
- package/dist/{vault-verify-CD76FJSF.js → vault-verify-SSXGTVBK.js} +7 -7
- package/package.json +1 -1
- package/dist/comparator-RDKX3OI7.js +0 -13
package/dist/index.d.cts
CHANGED
|
@@ -2414,7 +2414,7 @@ declare function shannonEntropy(str: string): number;
|
|
|
2414
2414
|
*
|
|
2415
2415
|
* @example
|
|
2416
2416
|
* isHighEntropy('my-database-password') // false (~3.1)
|
|
2417
|
-
* isHighEntropy('
|
|
2417
|
+
* isHighEntropy('super_secret_token_4eC39HqLyjWDarjtT1zdp7dc') // true (~4.2)
|
|
2418
2418
|
* isHighEntropy('a]c!D@f#G$h%J^k&L*m') // true (~4.0)
|
|
2419
2419
|
*/
|
|
2420
2420
|
declare function isHighEntropy(str: string, threshold?: number): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -2414,7 +2414,7 @@ declare function shannonEntropy(str: string): number;
|
|
|
2414
2414
|
*
|
|
2415
2415
|
* @example
|
|
2416
2416
|
* isHighEntropy('my-database-password') // false (~3.1)
|
|
2417
|
-
* isHighEntropy('
|
|
2417
|
+
* isHighEntropy('super_secret_token_4eC39HqLyjWDarjtT1zdp7dc') // true (~4.2)
|
|
2418
2418
|
* isHighEntropy('a]c!D@f#G$h%J^k&L*m') // true (~4.0)
|
|
2419
2419
|
*/
|
|
2420
2420
|
declare function isHighEntropy(str: string, threshold?: number): boolean;
|
package/dist/index.js
CHANGED
|
@@ -3,23 +3,23 @@ import {
|
|
|
3
3
|
computeVaultChecksum,
|
|
4
4
|
verifyIntegrity,
|
|
5
5
|
verifyVaultChecksum
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5WUBB633.js";
|
|
7
7
|
import {
|
|
8
8
|
compareEnvironments,
|
|
9
9
|
formatComparison
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LJSCUOD4.js";
|
|
11
11
|
import {
|
|
12
12
|
discoverEnvironments,
|
|
13
13
|
getActiveEnvironment,
|
|
14
14
|
listEnvironments,
|
|
15
15
|
switchEnvironment,
|
|
16
16
|
validateAllEnvironments
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-2MBSLURI.js";
|
|
18
18
|
import {
|
|
19
19
|
createEnvironment,
|
|
20
20
|
duplicateEnvironment,
|
|
21
21
|
removeEnvironment
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-6X3BUE5S.js";
|
|
23
23
|
import {
|
|
24
24
|
addCustomPattern,
|
|
25
25
|
detectHighEntropyStrings,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
scanLineForEntropy,
|
|
36
36
|
scanStagedFiles,
|
|
37
37
|
shannonEntropy
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-OBLMAUCF.js";
|
|
39
39
|
import {
|
|
40
40
|
getEnvironmentData,
|
|
41
41
|
getVaultEnvironments,
|
|
@@ -43,29 +43,29 @@ import {
|
|
|
43
43
|
readVaultFile,
|
|
44
44
|
serializeVaultFile,
|
|
45
45
|
writeVaultFile
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-72UKVOO5.js";
|
|
47
47
|
import "./chunk-R7PZRSZ7.js";
|
|
48
48
|
import {
|
|
49
49
|
generateExampleContent,
|
|
50
50
|
generateExampleFile,
|
|
51
51
|
needsUpdate
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-LFIKYFPS.js";
|
|
53
53
|
import {
|
|
54
54
|
maskValue
|
|
55
55
|
} from "./chunk-TE7HPLA6.js";
|
|
56
56
|
import {
|
|
57
57
|
compareSync,
|
|
58
58
|
compareValues
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-LQZK6BBQ.js";
|
|
60
60
|
import {
|
|
61
61
|
generateDeclaration
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-3AF476D7.js";
|
|
63
63
|
import {
|
|
64
64
|
generateModule
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-H3QEGEZ6.js";
|
|
66
66
|
import {
|
|
67
67
|
generateJsonSchema
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-7VJ7LK2M.js";
|
|
69
69
|
import {
|
|
70
70
|
expandVariables,
|
|
71
71
|
load,
|
|
@@ -74,28 +74,28 @@ import {
|
|
|
74
74
|
loadWithResultSync,
|
|
75
75
|
mergeCascade,
|
|
76
76
|
resolveCascade
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-XPZC32UY.js";
|
|
78
78
|
import {
|
|
79
79
|
parseEnvFile
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-CVJPO3QY.js";
|
|
81
81
|
import {
|
|
82
82
|
healthCheckRoute,
|
|
83
83
|
ultraenvMiddleware
|
|
84
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-F7YSINGU.js";
|
|
85
85
|
import {
|
|
86
86
|
createUltraenvPlugin,
|
|
87
87
|
ultraenvPlugin
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-7AHG2IP4.js";
|
|
89
89
|
import {
|
|
90
90
|
defineEnv,
|
|
91
91
|
t,
|
|
92
92
|
tryDefineEnv,
|
|
93
93
|
validate
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-BNUHE2ZI.js";
|
|
95
95
|
import {
|
|
96
96
|
findConfig,
|
|
97
97
|
loadConfig
|
|
98
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-GJC64ZG7.js";
|
|
99
99
|
import {
|
|
100
100
|
copyFile,
|
|
101
101
|
ensureDir,
|
|
@@ -108,7 +108,7 @@ import {
|
|
|
108
108
|
readFileSync,
|
|
109
109
|
removeFile,
|
|
110
110
|
writeFile
|
|
111
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-FSKVYBEP.js";
|
|
112
112
|
import {
|
|
113
113
|
deriveEnvironmentKey,
|
|
114
114
|
formatKey,
|
|
@@ -119,14 +119,14 @@ import {
|
|
|
119
119
|
parseKey,
|
|
120
120
|
parseKeysFile,
|
|
121
121
|
rotateKey
|
|
122
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-RJTUAMK3.js";
|
|
123
123
|
import {
|
|
124
124
|
decryptEnvironment,
|
|
125
125
|
decryptValue,
|
|
126
126
|
encryptEnvironment,
|
|
127
127
|
encryptValue,
|
|
128
128
|
isEncryptedValue
|
|
129
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-6NFA23AY.js";
|
|
130
130
|
import {
|
|
131
131
|
VERSION
|
|
132
132
|
} from "./chunk-XC65ORJ5.js";
|
|
@@ -141,7 +141,7 @@ import {
|
|
|
141
141
|
ValidationError,
|
|
142
142
|
VaultError,
|
|
143
143
|
isUltraenvError
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-N7GOHQBF.js";
|
|
145
145
|
|
|
146
146
|
// src/core/watcher.ts
|
|
147
147
|
import { watch } from "fs";
|
|
@@ -258,11 +258,15 @@ var EnvFileWatcher = class {
|
|
|
258
258
|
if (this.state.nativeWatchers.has(filePath)) return;
|
|
259
259
|
if (this.shouldIgnore(filePath)) return;
|
|
260
260
|
try {
|
|
261
|
-
const nativeWatcher = watch(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
const nativeWatcher = watch(
|
|
262
|
+
filePath,
|
|
263
|
+
{
|
|
264
|
+
persistent: true
|
|
265
|
+
},
|
|
266
|
+
(eventType, filename) => {
|
|
267
|
+
this.handleFileEvent(eventType, filePath, filename);
|
|
268
|
+
}
|
|
269
|
+
);
|
|
266
270
|
nativeWatcher.on("error", () => {
|
|
267
271
|
this.emitChangeEvent(filePath);
|
|
268
272
|
this.state.nativeWatchers.delete(filePath);
|
|
@@ -288,27 +292,31 @@ var EnvFileWatcher = class {
|
|
|
288
292
|
const dirWatchKey = `__dir__:${dirPath}`;
|
|
289
293
|
if (this.state.nativeWatchers.has(dirWatchKey)) return;
|
|
290
294
|
try {
|
|
291
|
-
const nativeWatcher = watch(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this.state.nativeWatchers.
|
|
295
|
+
const nativeWatcher = watch(
|
|
296
|
+
dirPath,
|
|
297
|
+
{
|
|
298
|
+
persistent: true
|
|
299
|
+
},
|
|
300
|
+
(eventType, filename) => {
|
|
301
|
+
if (filename === null) return;
|
|
302
|
+
const fullPath = resolve(join(dirPath, filename));
|
|
303
|
+
if (isEnvFileName(filename) && !this.shouldIgnore(fullPath)) {
|
|
304
|
+
if (eventType === "rename") {
|
|
305
|
+
if (existsSync(fullPath) && !this.state.nativeWatchers.has(fullPath)) {
|
|
306
|
+
this.watchFile(fullPath);
|
|
307
|
+
this.debouncedEmit(fullPath, "add");
|
|
308
|
+
} else if (!existsSync(fullPath) && this.state.nativeWatchers.has(fullPath)) {
|
|
309
|
+
const watcher = this.state.nativeWatchers.get(fullPath);
|
|
310
|
+
if (watcher !== void 0) {
|
|
311
|
+
watcher.close();
|
|
312
|
+
this.state.nativeWatchers.delete(fullPath);
|
|
313
|
+
}
|
|
314
|
+
this.debouncedEmit(fullPath, "unlink");
|
|
306
315
|
}
|
|
307
|
-
this.debouncedEmit(fullPath, "unlink");
|
|
308
316
|
}
|
|
309
317
|
}
|
|
310
318
|
}
|
|
311
|
-
|
|
319
|
+
);
|
|
312
320
|
nativeWatcher.on("error", () => {
|
|
313
321
|
this.state.nativeWatchers.delete(dirWatchKey);
|
|
314
322
|
setTimeout(() => {
|
|
@@ -429,9 +437,7 @@ var SecureBuffer = class _SecureBuffer {
|
|
|
429
437
|
*/
|
|
430
438
|
constructor(size) {
|
|
431
439
|
if (size < 1 || !Number.isInteger(size)) {
|
|
432
|
-
throw new RangeError(
|
|
433
|
-
`SecureBuffer: size must be a positive integer, got ${size}`
|
|
434
|
-
);
|
|
440
|
+
throw new RangeError(`SecureBuffer: size must be a positive integer, got ${size}`);
|
|
435
441
|
}
|
|
436
442
|
this._buffer = Buffer.alloc(size);
|
|
437
443
|
this._length = size;
|
|
@@ -485,9 +491,7 @@ var SecureBuffer = class _SecureBuffer {
|
|
|
485
491
|
*/
|
|
486
492
|
fill(value) {
|
|
487
493
|
if (value < 0 || value > 255 || !Number.isInteger(value)) {
|
|
488
|
-
throw new RangeError(
|
|
489
|
-
`SecureBuffer.fill: value must be an integer 0-255, got ${value}`
|
|
490
|
-
);
|
|
494
|
+
throw new RangeError(`SecureBuffer.fill: value must be an integer 0-255, got ${value}`);
|
|
491
495
|
}
|
|
492
496
|
this._buffer.fill(value);
|
|
493
497
|
this._zeroed = value === 0;
|
|
@@ -831,16 +835,12 @@ var SyncWatcher = class {
|
|
|
831
835
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
832
836
|
};
|
|
833
837
|
try {
|
|
834
|
-
const needs = await needsUpdate(
|
|
835
|
-
|
|
836
|
-
this.options.
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
includeTypes: this.options.includeTypes,
|
|
841
|
-
includeDefaults: this.options.includeDefaults
|
|
842
|
-
}
|
|
843
|
-
);
|
|
838
|
+
const needs = await needsUpdate(this.options.envPath, this.options.examplePath, {
|
|
839
|
+
schemaPath: void 0,
|
|
840
|
+
includeDescriptions: this.options.includeDescriptions,
|
|
841
|
+
includeTypes: this.options.includeTypes,
|
|
842
|
+
includeDefaults: this.options.includeDefaults
|
|
843
|
+
});
|
|
844
844
|
if (!needs) {
|
|
845
845
|
result.success = true;
|
|
846
846
|
if (this.options.onSync !== void 0) {
|
|
@@ -848,16 +848,12 @@ var SyncWatcher = class {
|
|
|
848
848
|
}
|
|
849
849
|
return;
|
|
850
850
|
}
|
|
851
|
-
await generateExampleFile(
|
|
852
|
-
|
|
853
|
-
this.options.
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
includeTypes: this.options.includeTypes,
|
|
858
|
-
includeDefaults: this.options.includeDefaults
|
|
859
|
-
}
|
|
860
|
-
);
|
|
851
|
+
await generateExampleFile(this.options.envPath, this.options.examplePath, {
|
|
852
|
+
schemaPath: void 0,
|
|
853
|
+
includeDescriptions: this.options.includeDescriptions,
|
|
854
|
+
includeTypes: this.options.includeTypes,
|
|
855
|
+
includeDefaults: this.options.includeDefaults
|
|
856
|
+
});
|
|
861
857
|
result.success = true;
|
|
862
858
|
this.emitEvent({
|
|
863
859
|
type: "change",
|
|
@@ -1296,11 +1292,7 @@ var nextjsPreset = {
|
|
|
1296
1292
|
};
|
|
1297
1293
|
|
|
1298
1294
|
// src/presets/vite.ts
|
|
1299
|
-
var VITE_MODES = [
|
|
1300
|
-
"development",
|
|
1301
|
-
"production",
|
|
1302
|
-
"test"
|
|
1303
|
-
];
|
|
1295
|
+
var VITE_MODES = ["development", "production", "test"];
|
|
1304
1296
|
var viteSchema = {
|
|
1305
1297
|
// ── Public (client-exposed) Variables ──────────────────────────────
|
|
1306
1298
|
VITE_API_URL: {
|
|
@@ -2522,10 +2514,8 @@ var awsLambdaPreset = {
|
|
|
2522
2514
|
var presets = {};
|
|
2523
2515
|
function registerPreset(name, preset) {
|
|
2524
2516
|
if (presets[name] !== void 0) {
|
|
2525
|
-
process.stderr.write(
|
|
2526
|
-
|
|
2527
|
-
`
|
|
2528
|
-
);
|
|
2517
|
+
process.stderr.write(`[ultraenv] Warning: overwriting existing preset "${name}"
|
|
2518
|
+
`);
|
|
2529
2519
|
}
|
|
2530
2520
|
presets[name] = preset;
|
|
2531
2521
|
}
|
|
@@ -2571,9 +2561,7 @@ function healthCheck(options = {}) {
|
|
|
2571
2561
|
validCount,
|
|
2572
2562
|
metadata = {}
|
|
2573
2563
|
} = options;
|
|
2574
|
-
const envKeys = Object.entries(source).filter(
|
|
2575
|
-
([, value]) => value !== void 0 && value !== ""
|
|
2576
|
-
);
|
|
2564
|
+
const envKeys = Object.entries(source).filter(([, value]) => value !== void 0 && value !== "");
|
|
2577
2565
|
const loaded = envKeys.length;
|
|
2578
2566
|
const environment = detectEnvironment(source);
|
|
2579
2567
|
const valid = validCount ?? loaded;
|
|
@@ -2616,13 +2604,7 @@ function readinessCheck(requiredVars, source) {
|
|
|
2616
2604
|
};
|
|
2617
2605
|
}
|
|
2618
2606
|
function detectEnvironment(env) {
|
|
2619
|
-
const candidates = [
|
|
2620
|
-
"NODE_ENV",
|
|
2621
|
-
"APP_ENV",
|
|
2622
|
-
"ENVIRONMENT",
|
|
2623
|
-
"ENV",
|
|
2624
|
-
"STAGE"
|
|
2625
|
-
];
|
|
2607
|
+
const candidates = ["NODE_ENV", "APP_ENV", "ENVIRONMENT", "ENV", "STAGE"];
|
|
2626
2608
|
for (const candidate of candidates) {
|
|
2627
2609
|
const value = env[candidate];
|
|
2628
2610
|
if (value !== void 0 && value !== "") {
|
|
@@ -2654,11 +2636,7 @@ function drawTitledBox(title, lines, chars = DOUBLE) {
|
|
|
2654
2636
|
if (lines.length === 0) {
|
|
2655
2637
|
return [hRuleTitled(title, 0, chars), boxLine("", 0, chars), hRuleBottom(0, chars)].join("\n");
|
|
2656
2638
|
}
|
|
2657
|
-
const innerWidth = Math.max(
|
|
2658
|
-
...lines.map((line) => stripAnsi(line).length),
|
|
2659
|
-
title.length + 2,
|
|
2660
|
-
0
|
|
2661
|
-
);
|
|
2639
|
+
const innerWidth = Math.max(...lines.map((line) => stripAnsi(line).length), title.length + 2, 0);
|
|
2662
2640
|
const result = [];
|
|
2663
2641
|
result.push(hRuleTitled(title, innerWidth, chars));
|
|
2664
2642
|
for (const line of lines) {
|
|
@@ -2713,7 +2691,9 @@ function reportValidation(result, options = {}) {
|
|
|
2713
2691
|
const c = color ? ANSI : noColorANSI();
|
|
2714
2692
|
if (result.valid) {
|
|
2715
2693
|
const lines = [];
|
|
2716
|
-
lines.push(
|
|
2694
|
+
lines.push(
|
|
2695
|
+
`${c.green}${c.bold} \u2713${c.reset} All ${Object.keys(result.validated).length} variables passed validation`
|
|
2696
|
+
);
|
|
2717
2697
|
if (result.warnings.length > 0) {
|
|
2718
2698
|
lines.push("");
|
|
2719
2699
|
for (const warning of result.warnings) {
|
|
@@ -2743,13 +2723,17 @@ function reportValidation(result, options = {}) {
|
|
|
2743
2723
|
output.push("");
|
|
2744
2724
|
const warningLines = [];
|
|
2745
2725
|
for (const warning of result.warnings) {
|
|
2746
|
-
warningLines.push(
|
|
2726
|
+
warningLines.push(
|
|
2727
|
+
`${c.yellow}\u26A0${c.reset} ${warning.field}: ${warning.message} ${c.dim}[${warning.code}]${c.reset}`
|
|
2728
|
+
);
|
|
2747
2729
|
}
|
|
2748
2730
|
output.push(warningLines.join("\n"));
|
|
2749
2731
|
}
|
|
2750
2732
|
if (result.unknown.length > 0) {
|
|
2751
2733
|
output.push("");
|
|
2752
|
-
output.push(
|
|
2734
|
+
output.push(
|
|
2735
|
+
`${c.gray}?${c.reset} Unknown variables: ${result.unknown.map((u) => `${c.dim}${u}${c.reset}`).join(", ")}`
|
|
2736
|
+
);
|
|
2753
2737
|
}
|
|
2754
2738
|
return output.join("\n");
|
|
2755
2739
|
}
|
|
@@ -2757,10 +2741,7 @@ function reportError(error, options = {}) {
|
|
|
2757
2741
|
const { color = true, boxStyle = DEFAULT_BOX } = options;
|
|
2758
2742
|
const c = color ? ANSI : noColorANSI();
|
|
2759
2743
|
const code = error.code ?? "ULTRAENV_ERROR";
|
|
2760
|
-
const lines = [
|
|
2761
|
-
`${c.red}${c.bold}Error [${code}]${c.reset}`,
|
|
2762
|
-
` ${error.message}`
|
|
2763
|
-
];
|
|
2744
|
+
const lines = [`${c.red}${c.bold}Error [${code}]${c.reset}`, ` ${error.message}`];
|
|
2764
2745
|
if (error.hint !== void 0) {
|
|
2765
2746
|
lines.push("");
|
|
2766
2747
|
lines.push(`${c.cyan} \u{1F4A1} ${error.hint}${c.reset}`);
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
exists,
|
|
17
17
|
writeFile
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FSKVYBEP.js";
|
|
19
19
|
import {
|
|
20
20
|
DEFAULT_GITIGNORE_ENTRIES
|
|
21
21
|
} from "./chunk-XC65ORJ5.js";
|
|
22
22
|
import {
|
|
23
23
|
FileSystemError,
|
|
24
24
|
getErrorMessage
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-N7GOHQBF.js";
|
|
26
26
|
|
|
27
27
|
// src/cli/commands/init.ts
|
|
28
28
|
import { resolve, join } from "path";
|
|
@@ -65,14 +65,18 @@ async function run(args, ctx) {
|
|
|
65
65
|
const envDir = await prompt(" Environment directory", { default: "." });
|
|
66
66
|
writeLine("");
|
|
67
67
|
writeLine(cyan(" Creating configuration..."));
|
|
68
|
-
const configContent = JSON.stringify(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
const configContent = JSON.stringify(
|
|
69
|
+
{
|
|
70
|
+
envDir,
|
|
71
|
+
expandVariables: true,
|
|
72
|
+
overrideProcessEnv: false,
|
|
73
|
+
mergeStrategy: "last-wins",
|
|
74
|
+
outputFormat: "terminal",
|
|
75
|
+
debug: false
|
|
76
|
+
},
|
|
77
|
+
null,
|
|
78
|
+
2
|
|
79
|
+
) + "\n";
|
|
76
80
|
await writeFile(configPath, configContent);
|
|
77
81
|
writeLine(green(` \u2713 Created ${configPath}`));
|
|
78
82
|
if (!await exists(envPath)) {
|
|
@@ -109,7 +113,7 @@ LOG_LEVEL=info
|
|
|
109
113
|
}
|
|
110
114
|
const gitignorePath = join(baseDir, ".gitignore");
|
|
111
115
|
if (await exists(gitignorePath)) {
|
|
112
|
-
const { readFile } = await import("./fs-
|
|
116
|
+
const { readFile } = await import("./fs-7HKOZY5K.js");
|
|
113
117
|
const existingContent = await readFile(gitignorePath);
|
|
114
118
|
if (!existingContent.includes("# ultraenv")) {
|
|
115
119
|
const { appendFileSync } = await import("fs");
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
ensureDir,
|
|
17
17
|
exists,
|
|
18
18
|
writeFile
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-FSKVYBEP.js";
|
|
20
|
+
import "./chunk-N7GOHQBF.js";
|
|
21
21
|
|
|
22
22
|
// src/cli/commands/install-hook.ts
|
|
23
23
|
import { resolve, join } from "path";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateJsonSchema,
|
|
3
3
|
generateJsonSchemaContent
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-7VJ7LK2M.js";
|
|
5
|
+
import "./chunk-FSKVYBEP.js";
|
|
6
|
+
import "./chunk-N7GOHQBF.js";
|
|
7
7
|
export {
|
|
8
8
|
generateJsonSchema,
|
|
9
9
|
generateJsonSchemaContent
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
parseKey,
|
|
9
9
|
parseKeysFile,
|
|
10
10
|
rotateKey
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-RJTUAMK3.js";
|
|
12
|
+
import "./chunk-6NFA23AY.js";
|
|
13
13
|
import "./chunk-XC65ORJ5.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-N7GOHQBF.js";
|
|
15
15
|
export {
|
|
16
16
|
deriveEnvironmentKey,
|
|
17
17
|
formatKey,
|
|
@@ -82,9 +82,7 @@ function buildFilteredEnv(source, prefixes, allowSet, denySet, exposePublic, exp
|
|
|
82
82
|
function healthCheckRoute(options = {}) {
|
|
83
83
|
const { source = process.env, metadata = {} } = options;
|
|
84
84
|
return (_req, res) => {
|
|
85
|
-
const envKeys = Object.keys(source).filter(
|
|
86
|
-
(k) => source[k] !== void 0 && source[k] !== ""
|
|
87
|
-
);
|
|
85
|
+
const envKeys = Object.keys(source).filter((k) => source[k] !== void 0 && source[k] !== "");
|
|
88
86
|
const nodeEnv = source["NODE_ENV"] ?? "unknown";
|
|
89
87
|
const response = {
|
|
90
88
|
status: "ok",
|
|
@@ -45,13 +45,7 @@ function ultraenvPlugin(fastify, options = {}, done) {
|
|
|
45
45
|
}
|
|
46
46
|
const allowSet = new Set(allowList.map((k) => k.toUpperCase()));
|
|
47
47
|
const denySet = new Set(denyList.map((k) => k.toUpperCase()));
|
|
48
|
-
const filteredEnv = buildFastifyEnv(
|
|
49
|
-
source,
|
|
50
|
-
allPrefixes,
|
|
51
|
-
allowSet,
|
|
52
|
-
denySet,
|
|
53
|
-
exposeNodeEnv
|
|
54
|
-
);
|
|
48
|
+
const filteredEnv = buildFastifyEnv(source, allPrefixes, allowSet, denySet, exposeNodeEnv);
|
|
55
49
|
fastify.decorate("env", filteredEnv);
|
|
56
50
|
done();
|
|
57
51
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateModule,
|
|
3
3
|
generateModuleContent
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-H3QEGEZ6.js";
|
|
5
|
+
import "./chunk-FSKVYBEP.js";
|
|
6
|
+
import "./chunk-N7GOHQBF.js";
|
|
7
7
|
export {
|
|
8
8
|
generateModule,
|
|
9
9
|
generateModuleContent
|
|
@@ -20,18 +20,12 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
exists,
|
|
22
22
|
readFile
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-FSKVYBEP.js";
|
|
24
|
+
import "./chunk-N7GOHQBF.js";
|
|
25
25
|
|
|
26
26
|
// src/cli/commands/protect.ts
|
|
27
27
|
import { resolve, join } from "path";
|
|
28
|
-
var PROTECTED_PATTERNS = [
|
|
29
|
-
".env",
|
|
30
|
-
".env.local",
|
|
31
|
-
".env.*.local",
|
|
32
|
-
".env.vault",
|
|
33
|
-
".env.keys"
|
|
34
|
-
];
|
|
28
|
+
var PROTECTED_PATTERNS = [".env", ".env.local", ".env.*.local", ".env.vault", ".env.keys"];
|
|
35
29
|
async function run(args, ctx) {
|
|
36
30
|
try {
|
|
37
31
|
const cwd = args.flags["--cwd"] ?? ctx.cwd;
|
|
@@ -51,13 +45,16 @@ async function run(args, ctx) {
|
|
|
51
45
|
if (!gitignoreExists) {
|
|
52
46
|
writeError(red(" \u2717 No .gitignore file found!"));
|
|
53
47
|
writeLine("");
|
|
54
|
-
const box = drawBox(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
const box = drawBox(
|
|
49
|
+
[
|
|
50
|
+
"Your project has no .gitignore file.",
|
|
51
|
+
"Secrets in .env files could be committed to version control.",
|
|
52
|
+
"Create a .gitignore with ultraenv entries:",
|
|
53
|
+
"",
|
|
54
|
+
" ultraenv init"
|
|
55
|
+
],
|
|
56
|
+
{ title: "DANGER", border: "double" }
|
|
57
|
+
);
|
|
61
58
|
writeLine(box);
|
|
62
59
|
writeLine("");
|
|
63
60
|
return 1;
|
|
@@ -73,7 +70,9 @@ async function run(args, ctx) {
|
|
|
73
70
|
issues.push(pattern);
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
|
-
writeLine(
|
|
73
|
+
writeLine(
|
|
74
|
+
green(` \u2713 ${protectedEntries.length}/${PROTECTED_PATTERNS.length} patterns protected`)
|
|
75
|
+
);
|
|
77
76
|
const envFiles = [".env", ".env.local", ".env.production", ".env.development"];
|
|
78
77
|
const notIgnored = [];
|
|
79
78
|
for (const envFile of envFiles) {
|
|
@@ -104,13 +103,16 @@ async function run(args, ctx) {
|
|
|
104
103
|
writeError(red(` - ${f}`));
|
|
105
104
|
}
|
|
106
105
|
writeLine("");
|
|
107
|
-
const warnBox = drawBox(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
const warnBox = drawBox(
|
|
107
|
+
[
|
|
108
|
+
"Tracked .env files may contain secrets.",
|
|
109
|
+
"Remove them from version control immediately:",
|
|
110
|
+
"",
|
|
111
|
+
" git rm --cached .env*",
|
|
112
|
+
' git commit -m "Remove tracked .env files"'
|
|
113
|
+
],
|
|
114
|
+
{ title: "WARNING", border: "double" }
|
|
115
|
+
);
|
|
114
116
|
writeLine(warnBox);
|
|
115
117
|
writeLine("");
|
|
116
118
|
return 1;
|