@envin/cli 1.1.13 → 1.1.14-canary.79c6253
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 +25 -0
- package/dist/cli/index.mjs +139 -12
- package/dist/preview/.next/BUILD_ID +1 -1
- package/dist/preview/.next/build-manifest.json +2 -2
- package/dist/preview/.next/fallback-build-manifest.json +2 -2
- package/dist/preview/.next/prerender-manifest.json +3 -3
- package/dist/preview/.next/server/app/_global-error.html +2 -2
- package/dist/preview/.next/server/app/_global-error.rsc +1 -1
- package/dist/preview/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_not-found.html +1 -1
- package/dist/preview/.next/server/app/_not-found.rsc +1 -1
- package/dist/preview/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/preview/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/preview/.next/server/app/page/server-reference-manifest.json +4 -4
- package/dist/preview/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/preview/.next/server/chunks/ssr/[root-of-the-server]__3aaf07ce._.js +1 -1
- package/dist/preview/.next/server/chunks/ssr/[root-of-the-server]__3aaf07ce._.js.map +1 -1
- package/dist/preview/.next/server/chunks/ssr/[root-of-the-server]__e2e728e5._.js +1 -1
- package/dist/preview/.next/server/chunks/ssr/[root-of-the-server]__e2e728e5._.js.map +1 -1
- package/dist/preview/.next/server/chunks/ssr/[root-of-the-server]__e3d1c002._.js +20 -20
- package/dist/preview/.next/server/chunks/ssr/[root-of-the-server]__e3d1c002._.js.map +1 -1
- package/dist/preview/.next/server/pages/404.html +1 -1
- package/dist/preview/.next/server/pages/500.html +2 -2
- package/dist/preview/.next/server/server-reference-manifest.js +1 -1
- package/dist/preview/.next/server/server-reference-manifest.json +5 -5
- package/dist/preview/.next/static/chunks/{a933bffba6c37967.js → bbb5fb736577afdc.js} +1 -1
- package/dist/preview/.next/trace +1 -1
- package/dist/preview/.next/trace-build +1 -1
- package/package.json +2 -2
- package/src/app/env.ts +23 -0
- package/src/app/page.tsx +3 -5
- package/src/lib/config.ts +10 -7
- package/src/lib/types.ts +7 -2
- package/src/lib/variables/index.ts +46 -26
- /package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → ON209q3dIHdNhaLOJAxJ0}/_buildManifest.js +0 -0
- /package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → ON209q3dIHdNhaLOJAxJ0}/_clientMiddlewareManifest.json +0 -0
- /package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → ON209q3dIHdNhaLOJAxJ0}/_ssgManifest.js +0 -0
package/dist/preview/.next/trace
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"generate-buildid","duration":
|
|
1
|
+
[{"name":"generate-buildid","duration":218,"timestamp":186839366,"id":4,"parentId":1,"tags":{},"startTime":1768469502163,"traceId":"6d36fd25bf467639"},{"name":"load-custom-routes","duration":283,"timestamp":186839676,"id":5,"parentId":1,"tags":{},"startTime":1768469502163,"traceId":"6d36fd25bf467639"},{"name":"create-dist-dir","duration":646,"timestamp":186839983,"id":6,"parentId":1,"tags":{},"startTime":1768469502163,"traceId":"6d36fd25bf467639"},{"name":"clean","duration":206,"timestamp":186841220,"id":7,"parentId":1,"tags":{},"startTime":1768469502165,"traceId":"6d36fd25bf467639"},{"name":"create-pages-mapping","duration":216,"timestamp":187012339,"id":8,"parentId":1,"tags":{},"startTime":1768469502336,"traceId":"6d36fd25bf467639"},{"name":"collect-app-files","duration":1145,"timestamp":187012596,"id":9,"parentId":1,"tags":{},"startTime":1768469502336,"traceId":"6d36fd25bf467639"},{"name":"create-app-mapping","duration":1413,"timestamp":187013773,"id":10,"parentId":1,"tags":{},"startTime":1768469502337,"traceId":"6d36fd25bf467639"},{"name":"create-app-layouts","duration":106,"timestamp":187015282,"id":11,"parentId":1,"tags":{},"startTime":1768469502339,"traceId":"6d36fd25bf467639"},{"name":"collect-default-files","duration":239,"timestamp":187016051,"id":13,"parentId":1,"tags":{},"startTime":1768469502340,"traceId":"6d36fd25bf467639"},{"name":"generate-route-types","duration":3131,"timestamp":187015646,"id":12,"parentId":1,"tags":{},"startTime":1768469502339,"traceId":"6d36fd25bf467639"},{"name":"public-dir-conflict-check","duration":76,"timestamp":187018799,"id":14,"parentId":1,"tags":{},"startTime":1768469502342,"traceId":"6d36fd25bf467639"},{"name":"generate-routes-manifest","duration":18207,"timestamp":187018930,"id":15,"parentId":1,"tags":{},"startTime":1768469502342,"traceId":"6d36fd25bf467639"},{"name":"run-turbopack","duration":7561432,"timestamp":187040179,"id":17,"parentId":1,"tags":{},"startTime":1768469502364,"traceId":"6d36fd25bf467639"},{"name":"run-typescript","duration":4280152,"timestamp":194608100,"id":19,"parentId":1,"tags":{},"startTime":1768469509932,"traceId":"6d36fd25bf467639"},{"name":"check-static-error-page","duration":2371,"timestamp":198925887,"id":22,"parentId":21,"tags":{},"startTime":1768469514249,"traceId":"6d36fd25bf467639"},{"name":"is-page-static","duration":227945,"timestamp":198932356,"id":28,"parentId":24,"tags":{},"startTime":1768469514256,"traceId":"6d36fd25bf467639"},{"name":"check-page","duration":232465,"timestamp":198927936,"id":24,"parentId":21,"tags":{"page":"/_global-error"},"startTime":1768469514251,"traceId":"6d36fd25bf467639"},{"name":"is-page-static","duration":278115,"timestamp":198932061,"id":27,"parentId":23,"tags":{},"startTime":1768469514256,"traceId":"6d36fd25bf467639"},{"name":"check-page","duration":283337,"timestamp":198926913,"id":23,"parentId":21,"tags":{"page":"/_not-found"},"startTime":1768469514250,"traceId":"6d36fd25bf467639"},{"name":"is-page-static","duration":301845,"timestamp":198932982,"id":29,"parentId":26,"tags":{},"startTime":1768469514256,"traceId":"6d36fd25bf467639"},{"name":"check-page","duration":306688,"timestamp":198928205,"id":26,"parentId":21,"tags":{"page":"/favicon.ico"},"startTime":1768469514252,"traceId":"6d36fd25bf467639"},{"name":"is-page-static","duration":472961,"timestamp":198938732,"id":30,"parentId":25,"tags":{},"startTime":1768469514262,"traceId":"6d36fd25bf467639"},{"name":"check-page","duration":483594,"timestamp":198928138,"id":25,"parentId":21,"tags":{"page":"/"},"startTime":1768469514252,"traceId":"6d36fd25bf467639"},{"name":"static-check","duration":486638,"timestamp":198925112,"id":21,"parentId":1,"tags":{},"startTime":1768469514249,"traceId":"6d36fd25bf467639"},{"name":"generate-required-server-files","duration":357,"timestamp":199411871,"id":32,"parentId":1,"tags":{},"startTime":1768469514735,"traceId":"6d36fd25bf467639"},{"name":"write-routes-manifest","duration":193,"timestamp":199412550,"id":33,"parentId":1,"tags":{},"startTime":1768469514736,"traceId":"6d36fd25bf467639"},{"name":"load-dotenv","duration":30,"timestamp":199419304,"id":36,"parentId":35,"tags":{},"startTime":1768469514743,"traceId":"6d36fd25bf467639"},{"name":"run-export-path-map","duration":268,"timestamp":199421521,"id":37,"parentId":35,"tags":{},"startTime":1768469514745,"traceId":"6d36fd25bf467639"},{"name":"next-export","duration":364249,"timestamp":199418482,"id":35,"parentId":1,"tags":{},"startTime":1768469514742,"traceId":"6d36fd25bf467639"},{"name":"move-exported-app-not-found-","duration":464,"timestamp":199783860,"id":38,"parentId":34,"tags":{},"startTime":1768469515107,"traceId":"6d36fd25bf467639"},{"name":"move-exported-app-global-error-","duration":310,"timestamp":199784391,"id":39,"parentId":34,"tags":{},"startTime":1768469515108,"traceId":"6d36fd25bf467639"},{"name":"static-generation","duration":370358,"timestamp":199415452,"id":34,"parentId":1,"tags":{},"startTime":1768469514739,"traceId":"6d36fd25bf467639"},{"name":"write-routes-manifest","duration":211,"timestamp":199785892,"id":40,"parentId":1,"tags":{},"startTime":1768469515109,"traceId":"6d36fd25bf467639"},{"name":"print-tree-view","duration":1861,"timestamp":199792549,"id":41,"parentId":1,"tags":{},"startTime":1768469515116,"traceId":"6d36fd25bf467639"},{"name":"telemetry-flush","duration":58178,"timestamp":199794424,"id":42,"parentId":1,"tags":{},"startTime":1768469515118,"traceId":"6d36fd25bf467639"},{"name":"next-build","duration":13034152,"timestamp":186818469,"id":1,"tags":{"buildMode":"default","version":"16.0.7","bundler":"turbopack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1768469502142,"traceId":"6d36fd25bf467639"}]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-turbopack","duration":
|
|
1
|
+
[{"name":"run-turbopack","duration":7561432,"timestamp":187040179,"id":17,"parentId":1,"tags":{},"startTime":1768469502364,"traceId":"6d36fd25bf467639"},{"name":"run-typescript","duration":4280152,"timestamp":194608100,"id":19,"parentId":1,"tags":{},"startTime":1768469509932,"traceId":"6d36fd25bf467639"},{"name":"static-check","duration":486638,"timestamp":198925112,"id":21,"parentId":1,"tags":{},"startTime":1768469514249,"traceId":"6d36fd25bf467639"},{"name":"static-generation","duration":370358,"timestamp":199415452,"id":34,"parentId":1,"tags":{},"startTime":1768469514739,"traceId":"6d36fd25bf467639"},{"name":"telemetry-flush","duration":58178,"timestamp":199794424,"id":42,"parentId":1,"tags":{},"startTime":1768469515118,"traceId":"6d36fd25bf467639"},{"name":"next-build","duration":13034152,"timestamp":186818469,"id":1,"tags":{"buildMode":"default","version":"16.0.7","bundler":"turbopack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1768469502142,"traceId":"6d36fd25bf467639"}]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envin/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14-canary.79c6253",
|
|
4
4
|
"description": "Type-safe env validation with live previews",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"turbostarter",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"consola": "^3.4.2",
|
|
48
48
|
"debounce": "^2.2.0",
|
|
49
49
|
"dotenv": "^16.5.0",
|
|
50
|
-
"envin": "1.1.
|
|
50
|
+
"envin": "1.1.14-canary.79c6253",
|
|
51
51
|
"esbuild": "^0.27.2",
|
|
52
52
|
"log-symbols": "^7.0.0",
|
|
53
53
|
"mime-types": "^3.0.1",
|
package/src/app/env.ts
CHANGED
|
@@ -11,6 +11,29 @@ export const envDirectoryAbsolutePath =
|
|
|
11
11
|
// biome-ignore lint/style/noNonNullAssertion: always set
|
|
12
12
|
process.env.ENV_DIR_ABSOLUTE_PATH!;
|
|
13
13
|
|
|
14
|
+
const parseJsonArray = (raw: string | undefined) => {
|
|
15
|
+
if (!raw) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(raw);
|
|
20
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
21
|
+
} catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** ONLY ACCESSIBLE ON THE SERVER */
|
|
27
|
+
export const envDirectoryAbsolutePaths =
|
|
28
|
+
parseJsonArray(process.env.ENV_DIR_ABSOLUTE_PATHS) ??
|
|
29
|
+
(envDirectoryAbsolutePath ? [envDirectoryAbsolutePath] : []);
|
|
30
|
+
|
|
31
|
+
/** ONLY ACCESSIBLE ON THE SERVER */
|
|
32
|
+
export const envFilePaths = parseJsonArray(process.env.ENV_FILE_PATHS);
|
|
33
|
+
|
|
34
|
+
/** ONLY ACCESSIBLE ON THE SERVER */
|
|
35
|
+
export const envConfigPath = process.env.ENV_CONFIG_PATH ?? "";
|
|
36
|
+
|
|
14
37
|
export const isBuilding = process.env.NEXT_PUBLIC_IS_BUILDING === "true";
|
|
15
38
|
|
|
16
39
|
export const isPreviewDevelopment =
|
package/src/app/page.tsx
CHANGED
|
@@ -3,14 +3,12 @@ import { Ban } from "lucide-react";
|
|
|
3
3
|
import { Envin } from "@/components/envin";
|
|
4
4
|
import { getVariables } from "@/lib/variables";
|
|
5
5
|
import { getConfigFile } from "@/utils/get-config-file";
|
|
6
|
-
import { envDirectoryAbsolutePath } from "./env";
|
|
6
|
+
import { envConfigPath, envDirectoryAbsolutePath } from "./env";
|
|
7
7
|
|
|
8
8
|
export const dynamic = "force-dynamic";
|
|
9
9
|
|
|
10
|
-
export const envConfigFilePath =
|
|
11
|
-
envDirectoryAbsolutePath ?? "",
|
|
12
|
-
"env.config.ts",
|
|
13
|
-
);
|
|
10
|
+
export const envConfigFilePath =
|
|
11
|
+
envConfigPath || path.join(envDirectoryAbsolutePath ?? "", "env.config.ts");
|
|
14
12
|
|
|
15
13
|
export default async function Home() {
|
|
16
14
|
const { config, error } = await getConfigFile(envConfigFilePath);
|
package/src/lib/config.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { envDirectoryAbsolutePath } from "@/app/env";
|
|
2
|
+
import { envConfigPath, envDirectoryAbsolutePath } from "@/app/env";
|
|
3
3
|
import { Environment } from "@/lib/types";
|
|
4
4
|
import { getConfigFile } from "@/utils/get-config-file";
|
|
5
5
|
|
|
6
|
-
export const envConfigFilePath =
|
|
7
|
-
envDirectoryAbsolutePath ?? "",
|
|
8
|
-
"env.config.ts",
|
|
9
|
-
);
|
|
6
|
+
export const envConfigFilePath =
|
|
7
|
+
envConfigPath || path.join(envDirectoryAbsolutePath ?? "", "env.config.ts");
|
|
10
8
|
export const { config, error } = await getConfigFile(envConfigFilePath);
|
|
11
9
|
|
|
12
10
|
export const FILES = {
|
|
13
|
-
[Environment.DEVELOPMENT]: [
|
|
11
|
+
[Environment.DEVELOPMENT]: [
|
|
12
|
+
".env",
|
|
13
|
+
".env.local",
|
|
14
|
+
".env.development",
|
|
15
|
+
".env.development.local",
|
|
16
|
+
],
|
|
14
17
|
[Environment.PRODUCTION]: [
|
|
15
18
|
".env",
|
|
16
|
-
".env.production",
|
|
17
19
|
".env.local",
|
|
20
|
+
".env.production",
|
|
18
21
|
".env.production.local",
|
|
19
22
|
],
|
|
20
23
|
} as const;
|
package/src/lib/types.ts
CHANGED
|
@@ -33,11 +33,16 @@ export type Environment = (typeof Environment)[keyof typeof Environment];
|
|
|
33
33
|
export const DEFAULT_PRESET = "root";
|
|
34
34
|
|
|
35
35
|
export const FILES = {
|
|
36
|
-
[Environment.DEVELOPMENT]: [
|
|
36
|
+
[Environment.DEVELOPMENT]: [
|
|
37
|
+
".env",
|
|
38
|
+
".env.local",
|
|
39
|
+
".env.development",
|
|
40
|
+
".env.development.local",
|
|
41
|
+
],
|
|
37
42
|
[Environment.PRODUCTION]: [
|
|
38
43
|
".env",
|
|
39
|
-
".env.production",
|
|
40
44
|
".env.local",
|
|
45
|
+
".env.production",
|
|
41
46
|
".env.production.local",
|
|
42
47
|
],
|
|
43
48
|
} as const;
|
|
@@ -4,7 +4,11 @@ import { readFileSync } from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { parse } from "dotenv";
|
|
6
6
|
import type { Preset } from "envin/types";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
envDirectoryAbsolutePath,
|
|
9
|
+
envDirectoryAbsolutePaths,
|
|
10
|
+
envFilePaths,
|
|
11
|
+
} from "@/app/env";
|
|
8
12
|
import {
|
|
9
13
|
type Config,
|
|
10
14
|
DEFAULT_PRESET,
|
|
@@ -124,48 +128,64 @@ const getVariable = (
|
|
|
124
128
|
};
|
|
125
129
|
};
|
|
126
130
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
131
|
+
const readEnvFile = (filePath: string) => {
|
|
132
|
+
try {
|
|
133
|
+
return parse(readFileSync(filePath, "utf8"));
|
|
134
|
+
} catch {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const resolveEnvDirs = () => {
|
|
140
|
+
if (envDirectoryAbsolutePaths.length) {
|
|
141
|
+
return envDirectoryAbsolutePaths;
|
|
142
|
+
}
|
|
143
|
+
if (envDirectoryAbsolutePath) {
|
|
144
|
+
return [envDirectoryAbsolutePath];
|
|
145
|
+
}
|
|
146
|
+
return [];
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const getFilesForEnvironment = (environment: Environment) => {
|
|
150
|
+
if (envFilePaths.length) {
|
|
151
|
+
return envFilePaths.map((filePath) => ({
|
|
152
|
+
name: path.relative(process.cwd(), filePath),
|
|
153
|
+
values: readEnvFile(filePath),
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const envDirs = resolveEnvDirs();
|
|
158
|
+
const files = FILES[environment] ?? FILES[Environment.DEVELOPMENT];
|
|
159
|
+
return envDirs.flatMap((dir) =>
|
|
160
|
+
files.map((file) => {
|
|
161
|
+
const fullPath = path.join(dir, file);
|
|
162
|
+
return {
|
|
163
|
+
name: path.relative(process.cwd(), fullPath),
|
|
164
|
+
values: readEnvFile(fullPath),
|
|
165
|
+
};
|
|
166
|
+
}),
|
|
144
167
|
);
|
|
145
168
|
};
|
|
146
169
|
|
|
147
170
|
export const getFileValues = async (
|
|
148
171
|
environment: Environment = Environment.DEVELOPMENT,
|
|
149
172
|
): Promise<FileValues> => {
|
|
150
|
-
const
|
|
151
|
-
const variablesFromFiles = files[environment];
|
|
173
|
+
const variablesFromFiles = getFilesForEnvironment(environment);
|
|
152
174
|
|
|
153
175
|
const result: FileValues = {};
|
|
154
176
|
|
|
155
|
-
variablesFromFiles?.forEach((
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
Object.entries(file).forEach(([key, value]) => {
|
|
177
|
+
variablesFromFiles?.forEach(({ name, values }) => {
|
|
178
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
159
179
|
if (!result[key]) {
|
|
160
180
|
result[key] = {
|
|
161
181
|
value,
|
|
162
|
-
files: [
|
|
182
|
+
files: [name],
|
|
163
183
|
};
|
|
164
184
|
} else {
|
|
165
185
|
result[key] = {
|
|
166
186
|
...result[key],
|
|
167
187
|
value,
|
|
168
|
-
files: [...result[key].files,
|
|
188
|
+
files: [...result[key].files, name],
|
|
169
189
|
};
|
|
170
190
|
}
|
|
171
191
|
});
|
/package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → ON209q3dIHdNhaLOJAxJ0}/_buildManifest.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → ON209q3dIHdNhaLOJAxJ0}/_ssgManifest.js
RENAMED
|
File without changes
|