@willbooster/wb 14.2.0 → 15.0.1
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/bin/dotenv.js +37 -0
- package/dist/index.js +34 -34
- package/package.json +3 -1
package/bin/dotenv.js
CHANGED
|
@@ -64,6 +64,23 @@ export function runDotenvCommand(args) {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
// Mirrors src/commands/dotenv.ts (validateStandardWbEnv) for this startup fast path.
|
|
68
|
+
function validateStandardWbEnv(value, fixTarget) {
|
|
69
|
+
if (
|
|
70
|
+
!value ||
|
|
71
|
+
['development', 'test', 'staging', 'production'].includes(value) ||
|
|
72
|
+
process.env.WB_SKIP_ENV_CHECK === '1' ||
|
|
73
|
+
process.env.WB_SKIP_ENV_CHECK === 'true'
|
|
74
|
+
) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
console.error(
|
|
78
|
+
`WB_ENV must be one of development, test, staging, or production, but is "${value}". ` +
|
|
79
|
+
`Fix ${fixTarget}, or set WB_SKIP_ENV_CHECK=1 to skip this check.`
|
|
80
|
+
);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
67
84
|
// Mirrors src/commands/dotenv.ts (readAndApplyEnvironmentVariables) for this startup fast path.
|
|
68
85
|
function readAndApplyEnvironmentVariables(cwd) {
|
|
69
86
|
const mode = process.env.WB_ENV;
|
|
@@ -117,6 +134,26 @@ function readAndApplyEnvironmentVariables(cwd) {
|
|
|
117
134
|
}
|
|
118
135
|
// On CI, inherited variables intentionally win; no warning is emitted.
|
|
119
136
|
}
|
|
137
|
+
// Validate only AFTER applying the sources, so a WB_SKIP_ENV_CHECK defined in an env FILE is
|
|
138
|
+
// honored: both the captured exported mode (it selected the cascade) and the FINAL value the
|
|
139
|
+
// child will see.
|
|
140
|
+
validateStandardWbEnv(mode, 'the exported variable');
|
|
141
|
+
validateStandardWbEnv(process.env.WB_ENV, 'the env source or the exported variable');
|
|
142
|
+
// The exported mode selected the cascade, so a mode file silently replacing it with a DIFFERENT
|
|
143
|
+
// valid mode (e.g. `.env.production` containing `WB_ENV=development`) must be rejected as well.
|
|
144
|
+
if (
|
|
145
|
+
mode &&
|
|
146
|
+
process.env.WB_ENV &&
|
|
147
|
+
process.env.WB_ENV !== mode &&
|
|
148
|
+
process.env.WB_SKIP_ENV_CHECK !== '1' &&
|
|
149
|
+
process.env.WB_SKIP_ENV_CHECK !== 'true'
|
|
150
|
+
) {
|
|
151
|
+
console.error(
|
|
152
|
+
`WB_ENV resolves to "${process.env.WB_ENV}" although the "${mode}" environment was selected. ` +
|
|
153
|
+
`Fix the WB_ENV defined in the mode's env sources, or set WB_SKIP_ENV_CHECK=1 to skip this check.`
|
|
154
|
+
);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
120
157
|
}
|
|
121
158
|
|
|
122
159
|
// Mirrors readFnoxEnvironmentVariables in @willbooster/shared-lib-node for this startup fast path.
|