zod-codegen 1.0.1 → 1.0.3
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/.github/workflows/ci.yml +5 -5
- package/.github/workflows/release.yml +1 -1
- package/.nvmrc +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/src/assets/manifest.json +2 -2
- package/dist/src/cli.js +25 -5
- package/dist/src/generator.js +3 -3
- package/dist/src/http/fetch-client.js +0 -1
- package/dist/src/services/code-generator.service.js +549 -58
- package/dist/src/services/file-reader.service.js +27 -14
- package/dist/src/services/import-builder.service.js +4 -11
- package/dist/src/services/type-builder.service.js +16 -9
- package/dist/tests/unit/generator.test.js +1 -0
- package/eslint.config.mjs +18 -0
- package/package.json +22 -22
- package/src/assets/manifest.json +2 -2
- package/src/cli.ts +30 -5
- package/src/generator.ts +3 -3
- package/src/http/fetch-client.ts +4 -4
- package/src/services/code-generator.service.ts +1212 -88
- package/src/services/file-reader.service.ts +26 -13
- package/src/services/import-builder.service.ts +8 -11
- package/src/services/type-builder.service.ts +19 -12
- package/tsconfig.json +4 -4
- package/scripts/update-manifest.js +0 -31
package/.github/workflows/ci.yml
CHANGED
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
runs-on: ${{ matrix.os }}
|
|
17
17
|
strategy:
|
|
18
18
|
matrix:
|
|
19
|
-
node-version: [
|
|
19
|
+
node-version: ['24.11.1']
|
|
20
20
|
os: [ubuntu-latest]
|
|
21
21
|
|
|
22
22
|
steps:
|
|
@@ -50,7 +50,7 @@ jobs:
|
|
|
50
50
|
run: npm run test:coverage
|
|
51
51
|
|
|
52
52
|
- name: Upload coverage to Codecov
|
|
53
|
-
if: matrix.node-version ==
|
|
53
|
+
if: matrix.node-version == '24.11.1' && matrix.os == 'ubuntu-latest'
|
|
54
54
|
uses: codecov/codecov-action@v5
|
|
55
55
|
with:
|
|
56
56
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -69,7 +69,7 @@ jobs:
|
|
|
69
69
|
- name: Setup Node.js
|
|
70
70
|
uses: actions/setup-node@v5
|
|
71
71
|
with:
|
|
72
|
-
node-version:
|
|
72
|
+
node-version: '24.11.1'
|
|
73
73
|
cache: 'npm'
|
|
74
74
|
|
|
75
75
|
- name: Install dependencies
|
|
@@ -90,7 +90,7 @@ jobs:
|
|
|
90
90
|
- name: Setup Node.js
|
|
91
91
|
uses: actions/setup-node@v5
|
|
92
92
|
with:
|
|
93
|
-
node-version:
|
|
93
|
+
node-version: '24.11.1'
|
|
94
94
|
cache: 'npm'
|
|
95
95
|
|
|
96
96
|
- name: Install dependencies
|
|
@@ -128,7 +128,7 @@ jobs:
|
|
|
128
128
|
- name: Setup Node.js
|
|
129
129
|
uses: actions/setup-node@v5
|
|
130
130
|
with:
|
|
131
|
-
node-version:
|
|
131
|
+
node-version: '24.11.1'
|
|
132
132
|
cache: 'npm'
|
|
133
133
|
|
|
134
134
|
- name: Install dependencies
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
24.11.1
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## <small>1.0.3 (2025-11-12)</small>
|
|
2
|
+
|
|
3
|
+
- Merge pull request #26 from julienandreu/refactor/modernize-typescript-strict-mode ([fb7c1bf](https://github.com/julienandreu/zod-codegen/commit/fb7c1bf)), closes [#26](https://github.com/julienandreu/zod-codegen/issues/26)
|
|
4
|
+
- fix: improve package.json path resolution for all installation scenarios ([c509691](https://github.com/julienandreu/zod-codegen/commit/c509691))
|
|
5
|
+
- fix: read version dynamically from package.json instead of manifest ([dd32cb2](https://github.com/julienandreu/zod-codegen/commit/dd32cb2))
|
|
6
|
+
|
|
7
|
+
## <small>1.0.2 (2025-11-12)</small>
|
|
8
|
+
|
|
9
|
+
- Merge pull request #25 from julienandreu/refactor/modernize-typescript-strict-mode ([9614fbd](https://github.com/julienandreu/zod-codegen/commit/9614fbd)), closes [#25](https://github.com/julienandreu/zod-codegen/issues/25)
|
|
10
|
+
- chore: update package-lock.json and pin Node.js to 24.11.1 in CI ([b165b43](https://github.com/julienandreu/zod-codegen/commit/b165b43))
|
|
11
|
+
- ci: update workflows to use Node.js 24 only ([1b56ad8](https://github.com/julienandreu/zod-codegen/commit/1b56ad8))
|
|
12
|
+
- refactor: modernize TypeScript to strict mode and fix all linting errors ([0dc2911](https://github.com/julienandreu/zod-codegen/commit/0dc2911))
|
|
13
|
+
|
|
1
14
|
## <small>1.0.1 (2025-09-16)</small>
|
|
2
15
|
|
|
3
16
|
- Merge pull request #10 from julienandreu/dependabot/npm_and_yarn/eslint-config-prettier-10.1.8 ([d9b786c](https://github.com/julienandreu/zod-codegen/commit/d9b786c)), closes [#10](https://github.com/julienandreu/zod-codegen/issues/10)
|
package/dist/src/cli.js
CHANGED
|
@@ -9,14 +9,34 @@ import loudRejection from 'loud-rejection';
|
|
|
9
9
|
import { handleErrors } from './utils/error-handler.js';
|
|
10
10
|
import { handleSignals } from './utils/signal-handler.js';
|
|
11
11
|
import debug from 'debug';
|
|
12
|
-
import { isManifest } from './utils/manifest.js';
|
|
13
12
|
import { Reporter } from './utils/reporter.js';
|
|
14
13
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// Read package.json from the project root
|
|
15
|
+
// Handle multiple scenarios:
|
|
16
|
+
// 1. Built locally: dist/src/cli.js -> go up 2 levels
|
|
17
|
+
// 2. Source: src/cli.ts -> go up 1 level
|
|
18
|
+
// 3. Installed via npm: node_modules/zod-codegen/dist/src/cli.js -> go up 2 levels
|
|
19
|
+
// Try multiple paths to ensure we find package.json
|
|
20
|
+
const possiblePaths = [
|
|
21
|
+
join(__dirname, '..', '..', 'package.json'), // dist/src/cli.js or node_modules/pkg/dist/src/cli.js
|
|
22
|
+
join(__dirname, '..', 'package.json'), // src/cli.ts
|
|
23
|
+
];
|
|
24
|
+
let packageJsonPath;
|
|
25
|
+
for (const path of possiblePaths) {
|
|
26
|
+
try {
|
|
27
|
+
readFileSync(path, 'utf-8');
|
|
28
|
+
packageJsonPath = path;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Try next path
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (!packageJsonPath) {
|
|
36
|
+
throw new Error('Could not find package.json. Please ensure the package is properly installed.');
|
|
18
37
|
}
|
|
19
|
-
const
|
|
38
|
+
const packageData = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
39
|
+
const { name, description, version } = packageData;
|
|
20
40
|
const reporter = new Reporter(process.stdout);
|
|
21
41
|
const startTime = process.hrtime.bigint();
|
|
22
42
|
debug(`${name}:${String(process.pid)}`);
|
package/dist/src/generator.js
CHANGED
|
@@ -23,7 +23,7 @@ export class Generator {
|
|
|
23
23
|
}
|
|
24
24
|
async run() {
|
|
25
25
|
try {
|
|
26
|
-
const rawSource = this.readFile();
|
|
26
|
+
const rawSource = await this.readFile();
|
|
27
27
|
const openApiSpec = this.parseFile(rawSource);
|
|
28
28
|
const generatedCode = this.generateCode(openApiSpec);
|
|
29
29
|
this.writeFile(generatedCode);
|
|
@@ -40,8 +40,8 @@ export class Generator {
|
|
|
40
40
|
return Promise.resolve(1);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
readFile() {
|
|
44
|
-
return this.fileReader.readFile(this.inputPath);
|
|
43
|
+
async readFile() {
|
|
44
|
+
return await this.fileReader.readFile(this.inputPath);
|
|
45
45
|
}
|
|
46
46
|
parseFile(source) {
|
|
47
47
|
return this.fileParser.parse(source);
|