@firtoz/worker-helper 1.6.0 → 1.6.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/CHANGELOG.md +6 -0
- package/dist/cf-typegen.js +1 -1
- package/dist/{chunk-DJHDLUBY.js → chunk-A4S7WGGQ.js} +4 -4
- package/dist/chunk-A4S7WGGQ.js.map +1 -0
- package/dist/utils/prepare-env.js +1 -1
- package/package.json +4 -4
- package/src/utils/prepare-env.ts +5 -2
- package/dist/chunk-DJHDLUBY.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @firtoz/worker-helper
|
|
2
2
|
|
|
3
|
+
## 1.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`80a7aa6`](https://github.com/firtoz/fullstack-toolkit/commit/80a7aa6abbca3b7ef621e6dd92f51954bee84b43) Thanks [@firtoz](https://github.com/firtoz)! - `prepareEnvFiles` no longer passes `.env` / `.env.local` to `wrangler types` when a matching `.env.example` / `.env.local.example` exists, so generated `worker-configuration.d.ts` headers match CI and local dev.
|
|
8
|
+
|
|
3
9
|
## 1.6.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/cf-typegen.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { findWorkspaceRoot, discoverWranglerConfigs } from './chunk-QEZL4IJI.js';
|
|
3
|
-
import { prepareEnvFiles } from './chunk-
|
|
3
|
+
import { prepareEnvFiles } from './chunk-A4S7WGGQ.js';
|
|
4
4
|
import { spawnSync } from 'child_process';
|
|
5
5
|
import * as fs from 'fs';
|
|
6
6
|
import path from 'path';
|
|
@@ -37,15 +37,15 @@ function prepareEnvFiles(targetDir) {
|
|
|
37
37
|
if (exampleLocalEnvExists) {
|
|
38
38
|
result.push(".env.local.example");
|
|
39
39
|
}
|
|
40
|
-
if (envExists) {
|
|
40
|
+
if (!exampleEnvExists && envExists) {
|
|
41
41
|
result.push(".env");
|
|
42
42
|
}
|
|
43
|
-
if (envLocalExists) {
|
|
43
|
+
if (!exampleLocalEnvExists && envLocalExists) {
|
|
44
44
|
result.push(".env.local");
|
|
45
45
|
}
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export { prepareEnvFiles };
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
50
|
+
//# sourceMappingURL=chunk-A4S7WGGQ.js.map
|
|
51
|
+
//# sourceMappingURL=chunk-A4S7WGGQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/prepare-env.ts"],"names":[],"mappings":";;;;;AAIA,SAAS,eAAA,GAA2B;AACnC,EAAA,OAAO,QAAQ,OAAA,CAAQ,GAAA,CAAI,EAAE,CAAA,IAAK,OAAA,CAAQ,IAAI,cAAA,KAAmB,MAAA;AAClE;AAWO,SAAS,gBAAgB,SAAA,EAA6B;AAC5D,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,cAAc,CAAA;AAC1D,EAAA,MAAM,mBAAA,GAAsB,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,oBAAoB,CAAA;AAErE,EAAA,MAAM,gBAAA,GAAsB,cAAW,cAAc,CAAA;AACrD,EAAA,MAAM,qBAAA,GAA2B,cAAW,mBAAmB,CAAA;AAE/D,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,MAAM,CAAA;AAC3C,EAAA,MAAM,YAAA,GAAe,IAAA,CAAK,IAAA,CAAK,SAAA,EAAW,YAAY,CAAA;AAEtD,EAAA,IAAI,SAAA,GAAe,cAAW,OAAO,CAAA;AACrC,EAAA,IAAI,cAAA,GAAoB,cAAW,YAAY,CAAA;AAE/C,EAAA,MAAM,WAAA,GAAc,CAAC,eAAA,EAAgB;AAErC,EAAA,IAAI,eAAe,gBAAA,EAAkB;AACpC,IAAA,IAAI,CAAC,SAAA,EAAW;AACf,MAAG,EAAA,CAAA,MAAA,CAAO,gBAAgB,OAAO,CAAA;AAEjC,MAAA,OAAA,CAAQ,IAAI,uCAAkC,CAAA;AAC9C,MAAA,SAAA,GAAY,IAAA;AAAA,IACb;AAAA,EACD;AAEA,EAAA,IAAI,eAAe,qBAAA,EAAuB;AACzC,IAAA,IAAI,CAAC,cAAA,EAAgB;AACpB,MAAG,EAAA,CAAA,MAAA,CAAO,qBAAqB,YAAY,CAAA;AAE3C,MAAA,OAAA,CAAQ,IAAI,mDAA8C,CAAA;AAC1D,MAAA,cAAA,GAAiB,IAAA;AAAA,IAClB;AAAA,EACD;AAEA,EAAA,MAAM,SAAmB,EAAC;AAE1B,EAAA,IAAI,gBAAA,EAAkB;AACrB,IAAA,MAAA,CAAO,KAAK,cAAc,CAAA;AAAA,EAC3B;AACA,EAAA,IAAI,qBAAA,EAAuB;AAC1B,IAAA,MAAA,CAAO,KAAK,oBAAoB,CAAA;AAAA,EACjC;AAIA,EAAA,IAAI,CAAC,oBAAoB,SAAA,EAAW;AACnC,IAAA,MAAA,CAAO,KAAK,MAAM,CAAA;AAAA,EACnB;AACA,EAAA,IAAI,CAAC,yBAAyB,cAAA,EAAgB;AAC7C,IAAA,MAAA,CAAO,KAAK,YAAY,CAAA;AAAA,EACzB;AAEA,EAAA,OAAO,MAAA;AACR","file":"chunk-A4S7WGGQ.js","sourcesContent":["import * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\n\nfunction isCiEnvironment(): boolean {\n\treturn Boolean(process.env.CI) || process.env.GITHUB_ACTIONS === \"true\";\n}\n\n/**\n * Ensures a .env and .env.local file exists in the target directory.\n * If it doesn't exist, copies from .env.example and .env.local.example.\n *\n * In CI, does not create those files — typegen uses `.env.example` / `.env.local.example` only when real files are absent.\n *\n * @param targetDir - The directory where the .env and .env.local files should exist\n * @returns An array of the files that were created or already existed\n */\nexport function prepareEnvFiles(targetDir: string): string[] {\n\tconst exampleEnvPath = path.join(targetDir, \".env.example\");\n\tconst exampleEnvLocalPath = path.join(targetDir, \".env.local.example\");\n\n\tconst exampleEnvExists = fs.existsSync(exampleEnvPath);\n\tconst exampleLocalEnvExists = fs.existsSync(exampleEnvLocalPath);\n\n\tconst envPath = path.join(targetDir, \".env\");\n\tconst envLocalPath = path.join(targetDir, \".env.local\");\n\n\tlet envExists = fs.existsSync(envPath);\n\tlet envLocalExists = fs.existsSync(envLocalPath);\n\n\tconst allowCopies = !isCiEnvironment();\n\n\tif (allowCopies && exampleEnvExists) {\n\t\tif (!envExists) {\n\t\t\tfs.cpSync(exampleEnvPath, envPath);\n\n\t\t\tconsole.log(\"✓ Created .env from .env.example\");\n\t\t\tenvExists = true;\n\t\t}\n\t}\n\n\tif (allowCopies && exampleLocalEnvExists) {\n\t\tif (!envLocalExists) {\n\t\t\tfs.cpSync(exampleEnvLocalPath, envLocalPath);\n\n\t\t\tconsole.log(\"✓ Created .env.local from .env.local.example\");\n\t\t\tenvLocalExists = true;\n\t\t}\n\t}\n\n\tconst result: string[] = [];\n\t// The order matters, because latter files' values will override former files' values\n\tif (exampleEnvExists) {\n\t\tresult.push(\".env.example\");\n\t}\n\tif (exampleLocalEnvExists) {\n\t\tresult.push(\".env.local.example\");\n\t}\n\t// Only pass real .env / .env.local when there is no corresponding example file.\n\t// Otherwise `wrangler types` embeds different `--env-file` lists locally (with\n\t// .env.local) vs CI (no .env.local), causing noisy diffs in committed worker-configuration.d.ts.\n\tif (!exampleEnvExists && envExists) {\n\t\tresult.push(\".env\");\n\t}\n\tif (!exampleLocalEnvExists && envLocalExists) {\n\t\tresult.push(\".env.local\");\n\t}\n\n\treturn result;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firtoz/worker-helper",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Type-safe Web Worker helper with Zod validation and Cloudflare Workers utilities (cf-typegen)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"zod": "^4.3.6"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@types/node": "^25.
|
|
75
|
-
"@firtoz/maybe-error": "^1.6.
|
|
76
|
-
"bun-types": "^1.3.
|
|
74
|
+
"@types/node": "^25.6.0",
|
|
75
|
+
"@firtoz/maybe-error": "^1.6.1",
|
|
76
|
+
"bun-types": "^1.3.12"
|
|
77
77
|
}
|
|
78
78
|
}
|
package/src/utils/prepare-env.ts
CHANGED
|
@@ -56,10 +56,13 @@ export function prepareEnvFiles(targetDir: string): string[] {
|
|
|
56
56
|
if (exampleLocalEnvExists) {
|
|
57
57
|
result.push(".env.local.example");
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
// Only pass real .env / .env.local when there is no corresponding example file.
|
|
60
|
+
// Otherwise `wrangler types` embeds different `--env-file` lists locally (with
|
|
61
|
+
// .env.local) vs CI (no .env.local), causing noisy diffs in committed worker-configuration.d.ts.
|
|
62
|
+
if (!exampleEnvExists && envExists) {
|
|
60
63
|
result.push(".env");
|
|
61
64
|
}
|
|
62
|
-
if (envLocalExists) {
|
|
65
|
+
if (!exampleLocalEnvExists && envLocalExists) {
|
|
63
66
|
result.push(".env.local");
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/prepare-env.ts"],"names":[],"mappings":";;;;;AAIA,SAAS,eAAA,GAA2B;AACnC,EAAA,OAAO,QAAQ,OAAA,CAAQ,GAAA,CAAI,EAAE,CAAA,IAAK,OAAA,CAAQ,IAAI,cAAA,KAAmB,MAAA;AAClE;AAWO,SAAS,gBAAgB,SAAA,EAA6B;AAC5D,EAAA,MAAM,cAAA,GAAiB,IAAA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AA,EAAW;AACd,IAAA,MAAA,CAAO,KAAK,MAAM,CAAA;AAAA,EACnB;AACA,EAAA,IAAI,cAAA,EAAgB;AACnB,IAAA,MAAA,CAAO,KAAK,YAAY,CAAA;AAAA,EACzB;AAEA,EAAA,OAAO,MAAA;AACR","file":"chunk-DJHDLUBY.js","sourcesContent":["import * as fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\n\nfunction isCiEnvironment(): boolean {\n\treturn Boolean(process.env.CI) || process.env.GITHUB_ACTIONS === \"true\";\n}\n\n/**\n * Ensures a .env and .env.local file exists in the target directory.\n * If it doesn't exist, copies from .env.example and .env.local.example.\n *\n * In CI, does not create those files — typegen uses `.env.example` / `.env.local.example` only when real files are absent.\n *\n * @param targetDir - The directory where the .env and .env.local files should exist\n * @returns An array of the files that were created or already existed\n */\nexport function prepareEnvFiles(targetDir: string): string[] {\n\tconst exampleEnvPath = path.join(targetDir, \".env.example\");\n\tconst exampleEnvLocalPath = path.join(targetDir, \".env.local.example\");\n\n\tconst exampleEnvExists = fs.existsSync(exampleEnvPath);\n\tconst exampleLocalEnvExists = fs.existsSync(exampleEnvLocalPath);\n\n\tconst envPath = path.join(targetDir, \".env\");\n\tconst envLocalPath = path.join(targetDir, \".env.local\");\n\n\tlet envExists = fs.existsSync(envPath);\n\tlet envLocalExists = fs.existsSync(envLocalPath);\n\n\tconst allowCopies = !isCiEnvironment();\n\n\tif (allowCopies && exampleEnvExists) {\n\t\tif (!envExists) {\n\t\t\tfs.cpSync(exampleEnvPath, envPath);\n\n\t\t\tconsole.log(\"✓ Created .env from .env.example\");\n\t\t\tenvExists = true;\n\t\t}\n\t}\n\n\tif (allowCopies && exampleLocalEnvExists) {\n\t\tif (!envLocalExists) {\n\t\t\tfs.cpSync(exampleEnvLocalPath, envLocalPath);\n\n\t\t\tconsole.log(\"✓ Created .env.local from .env.local.example\");\n\t\t\tenvLocalExists = true;\n\t\t}\n\t}\n\n\tconst result: string[] = [];\n\t// The order matters, because latter files' values will override former files' values\n\tif (exampleEnvExists) {\n\t\tresult.push(\".env.example\");\n\t}\n\tif (exampleLocalEnvExists) {\n\t\tresult.push(\".env.local.example\");\n\t}\n\tif (envExists) {\n\t\tresult.push(\".env\");\n\t}\n\tif (envLocalExists) {\n\t\tresult.push(\".env.local\");\n\t}\n\n\treturn result;\n}\n"]}
|