@envin/cli 1.1.13 → 1.1.14-canary.69df2fd
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 +24 -0
- package/dist/cli/index.mjs +145 -13
- 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 → 2f4fcd31324a1930.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 → pNBnHRQCbkVzht0Z4AvT-}/_buildManifest.js +0 -0
- /package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → pNBnHRQCbkVzht0Z4AvT-}/_clientMiddlewareManifest.json +0 -0
- /package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → pNBnHRQCbkVzht0Z4AvT-}/_ssgManifest.js +0 -0
package/dist/preview/.next/trace
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"generate-buildid","duration":
|
|
1
|
+
[{"name":"generate-buildid","duration":222,"timestamp":51572229,"id":4,"parentId":1,"tags":{},"startTime":1768473085626,"traceId":"588d75ac41217676"},{"name":"load-custom-routes","duration":329,"timestamp":51572557,"id":5,"parentId":1,"tags":{},"startTime":1768473085626,"traceId":"588d75ac41217676"},{"name":"create-dist-dir","duration":649,"timestamp":51572911,"id":6,"parentId":1,"tags":{},"startTime":1768473085627,"traceId":"588d75ac41217676"},{"name":"clean","duration":222,"timestamp":51574205,"id":7,"parentId":1,"tags":{},"startTime":1768473085628,"traceId":"588d75ac41217676"},{"name":"create-pages-mapping","duration":234,"timestamp":51631472,"id":8,"parentId":1,"tags":{},"startTime":1768473085685,"traceId":"588d75ac41217676"},{"name":"collect-app-files","duration":1768,"timestamp":51631744,"id":9,"parentId":1,"tags":{},"startTime":1768473085686,"traceId":"588d75ac41217676"},{"name":"create-app-mapping","duration":2281,"timestamp":51633539,"id":10,"parentId":1,"tags":{},"startTime":1768473085687,"traceId":"588d75ac41217676"},{"name":"create-app-layouts","duration":155,"timestamp":51635909,"id":11,"parentId":1,"tags":{},"startTime":1768473085690,"traceId":"588d75ac41217676"},{"name":"collect-default-files","duration":296,"timestamp":51636744,"id":13,"parentId":1,"tags":{},"startTime":1768473085691,"traceId":"588d75ac41217676"},{"name":"generate-route-types","duration":3349,"timestamp":51636353,"id":12,"parentId":1,"tags":{},"startTime":1768473085690,"traceId":"588d75ac41217676"},{"name":"public-dir-conflict-check","duration":80,"timestamp":51639721,"id":14,"parentId":1,"tags":{},"startTime":1768473085694,"traceId":"588d75ac41217676"},{"name":"generate-routes-manifest","duration":23611,"timestamp":51639855,"id":15,"parentId":1,"tags":{},"startTime":1768473085694,"traceId":"588d75ac41217676"},{"name":"run-turbopack","duration":6874380,"timestamp":51675660,"id":17,"parentId":1,"tags":{},"startTime":1768473085730,"traceId":"588d75ac41217676"},{"name":"run-typescript","duration":4991219,"timestamp":58554851,"id":19,"parentId":1,"tags":{},"startTime":1768473092609,"traceId":"588d75ac41217676"},{"name":"check-static-error-page","duration":2931,"timestamp":63584771,"id":22,"parentId":21,"tags":{},"startTime":1768473097639,"traceId":"588d75ac41217676"},{"name":"is-page-static","duration":261634,"timestamp":63589358,"id":28,"parentId":26,"tags":{},"startTime":1768473097643,"traceId":"588d75ac41217676"},{"name":"check-page","duration":263464,"timestamp":63587636,"id":26,"parentId":21,"tags":{"page":"/favicon.ico"},"startTime":1768473097642,"traceId":"588d75ac41217676"},{"name":"is-page-static","duration":281109,"timestamp":63589613,"id":29,"parentId":24,"tags":{},"startTime":1768473097644,"traceId":"588d75ac41217676"},{"name":"check-page","duration":283475,"timestamp":63587324,"id":24,"parentId":21,"tags":{"page":"/_global-error"},"startTime":1768473097641,"traceId":"588d75ac41217676"},{"name":"is-page-static","duration":326504,"timestamp":63589043,"id":27,"parentId":23,"tags":{},"startTime":1768473097643,"traceId":"588d75ac41217676"},{"name":"check-page","duration":329751,"timestamp":63585939,"id":23,"parentId":21,"tags":{"page":"/_not-found"},"startTime":1768473097640,"traceId":"588d75ac41217676"},{"name":"is-page-static","duration":491340,"timestamp":63603386,"id":30,"parentId":25,"tags":{},"startTime":1768473097657,"traceId":"588d75ac41217676"},{"name":"check-page","duration":507214,"timestamp":63587563,"id":25,"parentId":21,"tags":{"page":"/"},"startTime":1768473097641,"traceId":"588d75ac41217676"},{"name":"static-check","duration":510853,"timestamp":63583951,"id":21,"parentId":1,"tags":{},"startTime":1768473097638,"traceId":"588d75ac41217676"},{"name":"generate-required-server-files","duration":419,"timestamp":64094936,"id":32,"parentId":1,"tags":{},"startTime":1768473098149,"traceId":"588d75ac41217676"},{"name":"write-routes-manifest","duration":211,"timestamp":64095694,"id":33,"parentId":1,"tags":{},"startTime":1768473098150,"traceId":"588d75ac41217676"},{"name":"load-dotenv","duration":29,"timestamp":64103876,"id":36,"parentId":35,"tags":{},"startTime":1768473098158,"traceId":"588d75ac41217676"},{"name":"run-export-path-map","duration":293,"timestamp":64105526,"id":37,"parentId":35,"tags":{},"startTime":1768473098159,"traceId":"588d75ac41217676"},{"name":"next-export","duration":404315,"timestamp":64103021,"id":35,"parentId":1,"tags":{},"startTime":1768473098157,"traceId":"588d75ac41217676"},{"name":"move-exported-app-not-found-","duration":404,"timestamp":64508479,"id":38,"parentId":34,"tags":{},"startTime":1768473098562,"traceId":"588d75ac41217676"},{"name":"move-exported-app-global-error-","duration":318,"timestamp":64508950,"id":39,"parentId":34,"tags":{},"startTime":1768473098563,"traceId":"588d75ac41217676"},{"name":"static-generation","duration":411249,"timestamp":64099465,"id":34,"parentId":1,"tags":{},"startTime":1768473098153,"traceId":"588d75ac41217676"},{"name":"write-routes-manifest","duration":240,"timestamp":64510794,"id":40,"parentId":1,"tags":{},"startTime":1768473098565,"traceId":"588d75ac41217676"},{"name":"print-tree-view","duration":2180,"timestamp":64515214,"id":41,"parentId":1,"tags":{},"startTime":1768473098569,"traceId":"588d75ac41217676"},{"name":"telemetry-flush","duration":89013,"timestamp":64517409,"id":42,"parentId":1,"tags":{},"startTime":1768473098571,"traceId":"588d75ac41217676"},{"name":"next-build","duration":13061126,"timestamp":51545315,"id":1,"tags":{"buildMode":"default","version":"16.0.7","bundler":"turbopack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1768473085599,"traceId":"588d75ac41217676"}]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"run-turbopack","duration":
|
|
1
|
+
[{"name":"run-turbopack","duration":6874380,"timestamp":51675660,"id":17,"parentId":1,"tags":{},"startTime":1768473085730,"traceId":"588d75ac41217676"},{"name":"run-typescript","duration":4991219,"timestamp":58554851,"id":19,"parentId":1,"tags":{},"startTime":1768473092609,"traceId":"588d75ac41217676"},{"name":"static-check","duration":510853,"timestamp":63583951,"id":21,"parentId":1,"tags":{},"startTime":1768473097638,"traceId":"588d75ac41217676"},{"name":"static-generation","duration":411249,"timestamp":64099465,"id":34,"parentId":1,"tags":{},"startTime":1768473098153,"traceId":"588d75ac41217676"},{"name":"telemetry-flush","duration":89013,"timestamp":64517409,"id":42,"parentId":1,"tags":{},"startTime":1768473098571,"traceId":"588d75ac41217676"},{"name":"next-build","duration":13061126,"timestamp":51545315,"id":1,"tags":{"buildMode":"default","version":"16.0.7","bundler":"turbopack","has-custom-webpack-config":"false","use-build-worker":"true"},"startTime":1768473085599,"traceId":"588d75ac41217676"}]
|
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.69df2fd",
|
|
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.69df2fd",
|
|
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 → pNBnHRQCbkVzht0Z4AvT-}/_buildManifest.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/preview/.next/static/{2pe0g3qnZD70MXuT6-2Ym → pNBnHRQCbkVzht0Z4AvT-}/_ssgManifest.js
RENAMED
|
File without changes
|