v-transform 3.1.0 → 3.1.2

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/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "v-transform",
3
3
  "bin": {
4
- "vt": "src/index.js"
4
+ "vt": "bin/index.js"
5
5
  },
6
6
  "type": "module",
7
- "version": "3.1.0",
8
- "main": "index.js",
7
+ "version": "3.1.2",
8
+ "main": "src/index.js",
9
9
  "scripts": {
10
10
  "clean": "npx rimraf test",
11
11
  "vt": "vt",
12
- "transform": "vt transform"
12
+ "transform": "vt transform",
13
+ "build": "tsup src/index.js -d bin --format esm --minify"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -17,12 +18,14 @@
17
18
  },
18
19
  "author": "Vick Scarlet <scarlet_vick@outlook.com>",
19
20
  "license": "MIT",
20
- "dependencies": {
21
+ "devDependencies": {
21
22
  "commander": "^15.0.0",
22
23
  "glob": "^13.0.6",
23
- "js-yaml": "^5.2.2",
24
+ "js-yaml": "^5.2.3",
24
25
  "ts-to-zod": "^5.1.0",
26
+ "tsup": "^8.5.1",
25
27
  "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
26
28
  "zod": "^4.4.3"
27
- }
28
- }
29
+ },
30
+ "files": ["bin", "src"]
31
+ }
package/src/calibrator.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs'
2
- import path from 'node:path'
3
2
  import { generate } from 'ts-to-zod'
4
3
  import { z } from 'zod'
4
+ globalThis.__GLOBAL_ZOD__ = z
5
5
 
6
6
  export async function calibrateTsData(raw, name, dts) {
7
7
  if (!dts || !fs.existsSync(dts)) {
@@ -34,11 +34,10 @@ export async function calibrateTsData(raw, name, dts) {
34
34
  return Boolean(val)
35
35
  },
36
36
  }
37
- const localZodPath = require.resolve('zod').replace(/\\/g, '/')
38
37
  let zodRawCode = zod.getZodSchemasFile()
39
38
  zodRawCode = zodRawCode.replace(
40
- /from\s+['"]zod['"]/g,
41
- `from "${localZodPath}"`,
39
+ /import\s+\{\s*z\s*\}\s+from\s+['"]zod['"];?/g,
40
+ 'const z = globalThis.__GLOBAL_ZOD__;',
42
41
  )
43
42
  zodRawCode = zodRawCode.replace(
44
43
  /z\.string\(\)/g,