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.
@@ -16,7 +16,7 @@ jobs:
16
16
  runs-on: ${{ matrix.os }}
17
17
  strategy:
18
18
  matrix:
19
- node-version: [20, 22, 24]
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 == 20 && matrix.os == 'ubuntu-latest'
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: 20
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: 22
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: 22
131
+ node-version: '24.11.1'
132
132
  cache: 'npm'
133
133
 
134
134
  - name: Install dependencies
@@ -28,7 +28,7 @@ jobs:
28
28
  - name: Setup Node.js
29
29
  uses: actions/setup-node@v5
30
30
  with:
31
- node-version: 22
31
+ node-version: '24.11.1'
32
32
  cache: 'npm'
33
33
  registry-url: 'https://registry.npmjs.org'
34
34
 
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 20.18.0
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)
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "zod-codegen",
3
- "version": "0.1.0-alpha.1",
4
- "description": "Zod code generator"
3
+ "version": "1.0.1",
4
+ "description": "A powerful TypeScript code generator that creates Zod schemas and type-safe clients from OpenAPI specifications"
5
5
  }
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
- const manifestData = JSON.parse(readFileSync(join(__dirname, 'assets', 'manifest.json'), 'utf-8'));
16
- if (!isManifest(manifestData)) {
17
- process.exit(1);
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 { name, description, version } = manifestData;
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)}`);
@@ -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);
@@ -131,7 +131,6 @@ export class FetchHttpClient {
131
131
  }
132
132
  try {
133
133
  const text = await response.text();
134
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
135
134
  return text ? JSON.parse(text) : {};
136
135
  }
137
136
  catch {