zod-codegen 1.0.2 → 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/CHANGELOG.md +6 -0
- package/dist/src/cli.js +25 -5
- package/package.json +1 -1
- package/src/cli.ts +30 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
|
|
1
7
|
## <small>1.0.2 (2025-11-12)</small>
|
|
2
8
|
|
|
3
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)
|
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/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -11,17 +11,42 @@ import loudRejection from 'loud-rejection';
|
|
|
11
11
|
import {handleErrors} from './utils/error-handler.js';
|
|
12
12
|
import {handleSignals} from './utils/signal-handler.js';
|
|
13
13
|
import debug from 'debug';
|
|
14
|
-
import {isManifest} from './utils/manifest.js';
|
|
15
14
|
import {Reporter} from './utils/reporter.js';
|
|
16
15
|
|
|
17
16
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
|
|
17
|
+
// Read package.json from the project root
|
|
18
|
+
// Handle multiple scenarios:
|
|
19
|
+
// 1. Built locally: dist/src/cli.js -> go up 2 levels
|
|
20
|
+
// 2. Source: src/cli.ts -> go up 1 level
|
|
21
|
+
// 3. Installed via npm: node_modules/zod-codegen/dist/src/cli.js -> go up 2 levels
|
|
22
|
+
// Try multiple paths to ensure we find package.json
|
|
23
|
+
const possiblePaths = [
|
|
24
|
+
join(__dirname, '..', '..', 'package.json'), // dist/src/cli.js or node_modules/pkg/dist/src/cli.js
|
|
25
|
+
join(__dirname, '..', 'package.json'), // src/cli.ts
|
|
26
|
+
];
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
let packageJsonPath: string | undefined;
|
|
29
|
+
for (const path of possiblePaths) {
|
|
30
|
+
try {
|
|
31
|
+
readFileSync(path, 'utf-8');
|
|
32
|
+
packageJsonPath = path;
|
|
33
|
+
break;
|
|
34
|
+
} catch {
|
|
35
|
+
// Try next path
|
|
36
|
+
}
|
|
22
37
|
}
|
|
23
38
|
|
|
24
|
-
|
|
39
|
+
if (!packageJsonPath) {
|
|
40
|
+
throw new Error('Could not find package.json. Please ensure the package is properly installed.');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const packageData = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {
|
|
44
|
+
name: string;
|
|
45
|
+
version: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const {name, description, version} = packageData;
|
|
25
50
|
const reporter = new Reporter(process.stdout);
|
|
26
51
|
const startTime = process.hrtime.bigint();
|
|
27
52
|
|