envlock-next 0.1.0 → 0.3.0

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 CHANGED
@@ -96,39 +96,6 @@ In CI, set `DOTENV_PRIVATE_KEY_<ENV>` directly. envlock detects this and skips `
96
96
  DOTENV_PRIVATE_KEY_PRODUCTION: ${{ secrets.DOTENV_PRIVATE_KEY_PRODUCTION }}
97
97
  ```
98
98
 
99
- ## `createEnv` wrapper
100
-
101
- envlock re-exports a `createEnv` wrapper around [`@t3-oss/env-nextjs`](https://env.t3.gg) with sensible defaults:
102
-
103
- ```js
104
- // src/env.js
105
- import { createEnv } from 'envlock-next';
106
- import { z } from 'zod';
107
-
108
- export const env = createEnv({
109
- server: {
110
- DATABASE_URL: z.string().url(),
111
- API_SECRET: z.string().min(1),
112
- },
113
- client: {
114
- NEXT_PUBLIC_APP_URL: z.string().url(),
115
- },
116
- runtimeEnv: {
117
- DATABASE_URL: process.env.DATABASE_URL,
118
- API_SECRET: process.env.API_SECRET,
119
- NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
120
- },
121
- });
122
- ```
123
-
124
- Defaults applied: `emptyStringAsUndefined: true`, `skipValidation` reads from `SKIP_ENV_VALIDATION` env var.
125
-
126
- Requires `@t3-oss/env-nextjs` and `zod` as peer dependencies:
127
-
128
- ```bash
129
- pnpm add @t3-oss/env-nextjs zod
130
- ```
131
-
132
99
  ## License
133
100
 
134
101
  MIT — [Benjamin Davies](https://github.com/BenDavies1218)
package/dist/cli/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/cli/index.ts
4
4
  import { Command } from "commander";
5
- import { runWithSecrets, validateEnvFilePath } from "envlock-core";
5
+ import { ENVIRONMENTS, runWithSecrets, validateEnvFilePath } from "envlock-core";
6
6
 
7
7
  // src/cli/resolve-config.ts
8
8
  import { existsSync } from "fs";
@@ -37,11 +37,25 @@ async function resolveConfig(cwd) {
37
37
  }
38
38
 
39
39
  // src/cli/index.ts
40
+ var SUPPORTED_SUBCOMMANDS = {
41
+ dev: "development",
42
+ build: "production",
43
+ start: "production"
44
+ };
45
+ var SUBCOMMAND_DESCRIPTIONS = {
46
+ dev: "Start Next.js development server",
47
+ build: "Build Next.js application",
48
+ start: "Start Next.js production server"
49
+ };
40
50
  var DEFAULT_ENV_FILES = {
41
51
  development: ".env.development",
42
52
  staging: ".env.staging",
43
53
  production: ".env.production"
44
54
  };
55
+ var ARGUMENT_FLAGS = {
56
+ staging: "--staging",
57
+ production: "--production"
58
+ };
45
59
  async function runNextCommand(subcommand, environment, passthroughArgs) {
46
60
  const config = await resolveConfig(process.cwd());
47
61
  const envFile = config.envFiles?.[environment] ?? DEFAULT_ENV_FILES[environment];
@@ -55,37 +69,24 @@ async function runNextCommand(subcommand, environment, passthroughArgs) {
55
69
  });
56
70
  }
57
71
  function addEnvFlags(cmd) {
58
- return cmd.option("--staging", "use staging environment").option("--production", "use production environment").allowUnknownOption(true);
72
+ return cmd.option(ARGUMENT_FLAGS.staging, "use staging environment").option(ARGUMENT_FLAGS.production, "use production environment").allowUnknownOption(true);
59
73
  }
60
- function getEnvironment(opts) {
61
- if (opts.production) return "production";
62
- if (opts.staging) return "staging";
63
- return "development";
74
+ function getEnvironment(opts, defaultEnv) {
75
+ if (opts.production) return ENVIRONMENTS.production;
76
+ if (opts.staging) return ENVIRONMENTS.staging;
77
+ return defaultEnv;
64
78
  }
65
79
  var program = new Command("envlock");
66
80
  program.name("envlock").description("Run Next.js commands with 1Password + dotenvx secret injection").version("0.1.0");
67
- var devCmd = new Command("dev").description("Start Next.js development server").allowUnknownOption(true);
68
- addEnvFlags(devCmd).action(async (opts) => {
69
- const passthrough = devCmd.args.filter(
70
- (a) => a !== "--staging" && a !== "--production"
71
- );
72
- await runNextCommand("dev", getEnvironment(opts), passthrough);
73
- });
74
- var buildCmd = new Command("build").description("Build Next.js application").allowUnknownOption(true);
75
- addEnvFlags(buildCmd).action(async (opts) => {
76
- const passthrough = buildCmd.args.filter(
77
- (a) => a !== "--staging" && a !== "--production"
78
- );
79
- await runNextCommand("build", getEnvironment(opts), passthrough);
80
- });
81
- var startCmd = new Command("start").description("Start Next.js production server").allowUnknownOption(true);
82
- addEnvFlags(startCmd).action(async (opts) => {
83
- const passthrough = startCmd.args.filter(
84
- (a) => a !== "--staging" && a !== "--production"
81
+ for (const [subcommand, defaultEnv] of Object.entries(
82
+ SUPPORTED_SUBCOMMANDS
83
+ )) {
84
+ const cmd = new Command(subcommand).description(SUBCOMMAND_DESCRIPTIONS[subcommand]).allowUnknownOption(true);
85
+ addEnvFlags(cmd).action(
86
+ async (opts) => {
87
+ await runNextCommand(subcommand, getEnvironment(opts, defaultEnv), cmd.args);
88
+ }
85
89
  );
86
- await runNextCommand("start", getEnvironment(opts), passthrough);
87
- });
88
- program.addCommand(devCmd);
89
- program.addCommand(buildCmd);
90
- program.addCommand(startCmd);
90
+ program.addCommand(cmd);
91
+ }
91
92
  program.parse(process.argv);
package/dist/index.d.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import { NextConfig } from 'next';
2
2
  import { EnvlockOptions } from 'envlock-core';
3
3
  export { EnvlockOptions } from 'envlock-core';
4
- import { createEnv as createEnv$1 } from '@t3-oss/env-nextjs';
5
4
 
6
5
  type EnvlockNextConfig = NextConfig & {
7
6
  __envlock: EnvlockOptions;
8
7
  };
9
8
  declare function withEnvlock(nextConfig: NextConfig, options?: EnvlockOptions): EnvlockNextConfig;
10
9
 
11
- type CreateEnvArgs = Parameters<typeof createEnv$1>[0];
12
- declare function createEnv(options: CreateEnvArgs): never;
13
-
14
- export { type EnvlockNextConfig, createEnv, withEnvlock };
10
+ export { type EnvlockNextConfig, withEnvlock };
package/dist/index.js CHANGED
@@ -13,17 +13,6 @@ function withEnvlock(nextConfig, options) {
13
13
  __envlock: options ?? { onePasswordEnvId: "" }
14
14
  };
15
15
  }
16
-
17
- // src/env/index.ts
18
- import { createEnv as t3CreateEnv } from "@t3-oss/env-nextjs";
19
- function createEnv(options) {
20
- return t3CreateEnv({
21
- skipValidation: !!process.env["SKIP_ENV_VALIDATION"],
22
- emptyStringAsUndefined: true,
23
- ...options
24
- });
25
- }
26
16
  export {
27
- createEnv,
28
17
  withEnvlock
29
18
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "envlock-next",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
- "description": "Next.js plugin, createEnv wrapper, and CLI for envlock",
5
+ "description": "Next.js plugin and CLI for envlock",
6
6
  "license": "MIT",
7
7
  "author": "Benjamin Davies",
8
8
  "homepage": "https://github.com/BenDavies1218/envlock#readme",
@@ -31,30 +31,18 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "commander": "^12.0.0",
34
- "envlock-core": "0.1.0"
34
+ "envlock-core": "0.3.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@t3-oss/env-nextjs": ">=0.12.0",
38
- "next": ">=14.0.0",
39
- "zod": ">=3.0.0"
40
- },
41
- "peerDependenciesMeta": {
42
- "@t3-oss/env-nextjs": {
43
- "optional": true
44
- },
45
- "zod": {
46
- "optional": true
47
- }
37
+ "next": ">=14.0.0"
48
38
  },
49
39
  "devDependencies": {
50
- "@t3-oss/env-nextjs": "^0.12.0",
51
40
  "@types/node": "^20.14.10",
52
41
  "next": "^15.2.3",
53
42
  "tsup": "^8.0.0",
54
43
  "typescript": "^5.8.2",
55
44
  "vitest": "^3.0.0",
56
- "zod": "^3.24.2",
57
- "envlock-core": "0.1.0"
45
+ "envlock-core": "0.3.0"
58
46
  },
59
47
  "scripts": {
60
48
  "build": "tsup",