Skip to content

Commit e9d3436

Browse files
committed
feat: Update example dependencies, refine package manager version syncing, and enhance basic example with type helper and Zod integration.
1 parent 7950845 commit e9d3436

9 files changed

Lines changed: 54 additions & 38 deletions

File tree

bin/sync-examples.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,16 @@ function transformPackageJson(pkg, exampleConfig, catalog) {
168168
// Get latest stable version for each package manager
169169
const packageManagers = {
170170
npm: "npm@11.6.4",
171-
bun: "bun@1.3.2",
172171
pnpm: "pnpm@10.23.0",
173172
};
174-
transformed.packageManager =
175-
packageManagers[exampleConfig.packageManager] ||
176-
exampleConfig.packageManager;
173+
174+
if (catalog[exampleConfig.packageManager]) {
175+
transformed.packageManager = `${exampleConfig.packageManager}@${catalog[exampleConfig.packageManager]}`;
176+
} else {
177+
transformed.packageManager =
178+
packageManagers[exampleConfig.packageManager] ||
179+
exampleConfig.packageManager;
180+
}
177181
}
178182

179183
// Remove workspace-specific scripts (like pnpm -w run fix)

examples/basic-js/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const env = arkenv({
77
});
88

99
// Automatically validate and parse process.env
10-
// Runtime validation still works without TypeScript!
10+
// TypeScript knows the ✨exact✨ types!
1111
const host = env.HOST;
1212
const port = env.PORT;
1313
const nodeEnv = env.NODE_ENV;

examples/basic-js/package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99
"clean": "rimraf dist node_modules"
1010
},
1111
"dependencies": {
12-
13-
"arkenv": "^0.7.6",
14-
"arktype": "^2.1.27"
12+
"arkenv": "^0.7.7",
13+
"arktype": "^2.1.28"
1514
},
16-
"devDependencies": {
17-
"rimraf": "^6.1.2"
18-
},
19-
"packageManager": "npm@11.6.4",
2015
"engines": {
2116
"node": "24"
2217
},
2318
"stackblitz": {
2419
"startCommand": "npm install && npm run dev:example"
25-
}
20+
},
21+
"packageManager": "npm@11.6.4"
2622
}

examples/basic/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
HOST=localhost
22
PORT=3000
33
NODE_ENV=development
4+
DEBUG=true
5+
ZED_ENV=development

examples/basic/index.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1-
import arkenv from "arkenv";
1+
import arkenv, { type } from "arkenv";
2+
import * as z from "zod";
23

34
const env = arkenv({
45
HOST: "string.host",
56
PORT: "number.port",
67
NODE_ENV: "'development' | 'production' | 'test' = 'development'",
8+
ALLOWED_ORIGINS: type("string[]").default(() => []),
9+
DEBUG: "boolean = true",
10+
ZED_ENV: z.string(),
711
});
812

913
// Automatically validate and parse process.env
1014
// TypeScript knows the ✨exact✨ types!
1115
const host = env.HOST;
1216
const port = env.PORT;
1317
const nodeEnv = env.NODE_ENV;
14-
15-
console.log({ host, port, nodeEnv });
18+
const allowedOrigins = env.ALLOWED_ORIGINS;
19+
const debug = env.DEBUG;
20+
const zedEnv = env.ZED_ENV;
21+
console.log({
22+
host,
23+
port,
24+
nodeEnv,
25+
allowedOrigins,
26+
debug,
27+
zedEnv,
28+
});
1629

1730
export default env;

examples/basic/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
"clean": "rimraf dist node_modules"
1111
},
1212
"dependencies": {
13-
"arkenv": "^0.7.6",
14-
"arktype": "^2.1.27"
13+
"arkenv": "^0.7.7",
14+
"arktype": "^2.1.28",
15+
"zod": "^4.1.13"
1516
},
1617
"devDependencies": {
1718
"@types/node": "^24.10.1",

examples/with-bun-react/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
"clean": "rimraf dist node_modules"
1212
},
1313
"dependencies": {
14-
"@arkenv/bun-plugin": "^0.0.1",
15-
"arkenv": "^0.7.6",
16-
"arktype": "^2.1.27",
17-
"react": "^19.2.0",
18-
"react-dom": "^19.2.0"
14+
"@arkenv/bun-plugin": "^0.0.2",
15+
"arkenv": "^0.7.7",
16+
"arktype": "^2.1.28",
17+
"react": "^19.2.1",
18+
"react-dom": "^19.2.1"
1919
},
2020
"devDependencies": {
2121
"@types/bun": "^1.3.3",
2222
"@types/react": "^19.2.7",
23-
"@types/react-dom": "^19.2.3"
23+
"@types/react-dom": "^19.2.3",
24+
"rimraf": "^6.1.2"
2425
},
25-
"packageManager": "bun@1.3.2"
26+
"packageManager": "bun@1.3.3"
2627
}

examples/with-bun/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
"clean": "rimraf dist node_modules"
1111
},
1212
"dependencies": {
13-
"arkenv": "^0.7.6",
14-
"arktype": "^2.1.27"
13+
"arkenv": "^0.7.7",
14+
"arktype": "^2.1.28"
1515
},
1616
"devDependencies": {
1717
"@types/bun": "^1.3.3",
18-
"typescript": "^5.9.3",
19-
"bun-types": "^1.3.2",
20-
"rimraf": "^6.1.2"
18+
"rimraf": "^6.1.2",
19+
"typescript": "^5.9.3"
2120
},
22-
"packageManager": "bun@1.3.2"
21+
"packageManager": "bun@1.3.3"
2322
}

examples/with-vite-react/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
"clean": "rimraf dist node_modules"
1212
},
1313
"dependencies": {
14-
"@arkenv/vite-plugin": "^0.0.18",
15-
"arkenv": "^0.7.6",
16-
"arktype": "^2.1.27",
17-
"react": "^19.2.0",
18-
"react-dom": "^19.2.0"
14+
"@arkenv/vite-plugin": "^0.0.19",
15+
"arkenv": "^0.7.7",
16+
"arktype": "^2.1.28",
17+
"react": "^19.2.1",
18+
"react-dom": "^19.2.1"
1919
},
2020
"devDependencies": {
2121
"@julr/vite-plugin-validate-env": "2.2.0",
2222
"@types/react": "^19.2.7",
2323
"@types/react-dom": "^19.2.3",
2424
"@vitejs/plugin-react": "^5.1.1",
2525
"globals": "^16.5.0",
26+
"rimraf": "^6.1.2",
2627
"typescript": "^5.9.3",
2728
"vite": "npm:rolldown-vite@latest",
28-
"vite-tsconfig-paths": "^5.1.4",
29-
"rimraf": "^6.1.2"
29+
"vite-tsconfig-paths": "^5.1.4"
3030
},
3131
"packageManager": "npm@11.6.4"
3232
}

0 commit comments

Comments
 (0)