schemashift-cli 0.5.0 → 0.7.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # schemashift
1
+ # schemashift-cli
2
2
 
3
- TypeScript schema migration CLI. Convert between Zod, Yup, Joi, io-ts, and Valibot.
3
+ TypeScript schema migration CLI. Convert between Zod, Yup, Joi, io-ts, and Valibot with AST-based transformations.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,19 +8,201 @@ TypeScript schema migration CLI. Convert between Zod, Yup, Joi, io-ts, and Valib
8
8
  npm install -g schemashift-cli
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Commands
12
+
13
+ ### `init`
14
+
15
+ Create a `.schemashiftrc.json` configuration file.
12
16
 
13
17
  ```bash
14
- # Analyze schemas
15
- schemashift analyze ./src
18
+ schemashift init [--force]
19
+ ```
20
+
21
+ ### `analyze`
22
+
23
+ Analyze schemas in your project without modifying files.
24
+
25
+ ```bash
26
+ schemashift analyze <path> [options]
27
+ ```
28
+
29
+ | Option | Description | Tier |
30
+ |--------|-------------|------|
31
+ | `--json` | Output as JSON | Free |
32
+ | `-v, --verbose` | Show detailed file paths | Free |
33
+ | `--detailed` | Full stats with complexity scoring | Individual+ |
34
+ | `--readiness <path>` | Migration readiness report, e.g. `yup->zod` | Individual+ |
35
+ | `--complexity` | Per-schema complexity scores | Individual+ |
36
+
37
+ ### `migrate`
38
+
39
+ Transform schemas from one library to another.
40
+
41
+ ```bash
42
+ schemashift migrate <path> [options]
43
+ ```
44
+
45
+ **Required (single-step):**
46
+
47
+ | Option | Description |
48
+ |--------|-------------|
49
+ | `-f, --from <library>` | Source library (`yup`, `joi`, `io-ts`, `zod-v3`, `zod`) |
50
+ | `-t, --to <library>` | Target library (`zod`, `v4`, `valibot`) |
51
+
52
+ **Or (chain migration):**
53
+
54
+ | Option | Description | Tier |
55
+ |--------|-------------|------|
56
+ | `--chain <path>` | Multi-step, e.g. `yup->zod->valibot` | Pro+ |
57
+
58
+ **Options:**
59
+
60
+ | Option | Description | Tier |
61
+ |--------|-------------|------|
62
+ | `-d, --dry-run` | Preview changes with diff output | Free |
63
+ | `-v, --verbose` | Show warnings and detailed info | Free |
64
+ | `-c, --config <path>` | Path to config file | Free |
65
+ | `--report <format>` | Generate report (`json`, `html`, `csv`) | Individual+ |
66
+ | `--report-output <path>` | Custom report output path | Individual+ |
67
+ | `--git-branch` | Create a git branch for changes | Individual+ |
68
+ | `--git-commit` | Auto-commit changes | Individual+ |
69
+ | `--no-backup` | Skip backup creation | Free |
70
+ | `--yes` | Skip confirmation prompt | Free |
71
+ | `--ci` | CI mode (non-interactive, exit 1 on failure) | Pro+ |
72
+ | `--cross-file` | Resolve cross-file schema dependencies | Pro+ |
73
+ | `--compat-check` | Run compatibility check before migration | Pro+ |
74
+ | `--fail-on-warnings` | Exit 1 if any warnings | Team |
75
+ | `--max-risk-score <n>` | Exit 1 if any file exceeds risk score | Team |
76
+
77
+ ### `watch`
78
+
79
+ Watch files and transform on save.
80
+
81
+ ```bash
82
+ schemashift watch <path> -f <library> -t <library> [-c <config>]
83
+ ```
84
+
85
+ **Tier:** Pro+
86
+
87
+ ### `rollback`
88
+
89
+ Restore files from a backup.
90
+
91
+ ```bash
92
+ schemashift rollback [backupId]
93
+ ```
94
+
95
+ | Option | Description |
96
+ |--------|-------------|
97
+ | `-l, --list` | List available backups |
98
+ | `--clean` | Remove old backups (keeps last 5) |
99
+
100
+ ### `license`
101
+
102
+ Manage your license.
103
+
104
+ ```bash
105
+ schemashift license [options]
106
+ ```
107
+
108
+ | Option | Description |
109
+ |--------|-------------|
110
+ | `-a, --activate <key>` | Activate a license key |
111
+ | `-d, --deactivate` | Deactivate current license |
112
+ | `-s, --status` | Show license status |
113
+
114
+ ### `compat`
115
+
116
+ Check schema library compatibility before migration.
117
+
118
+ ```bash
119
+ schemashift compat <path> [--json]
120
+ ```
121
+
122
+ Detects installed library versions, reports version-specific issues, and identifies ecosystem dependencies (drizzle-zod, tRPC, etc.) affected by your migration.
123
+
124
+ **Tier:** Pro+
125
+
126
+ ### `governance`
127
+
128
+ Run schema governance checks.
129
+
130
+ ```bash
131
+ schemashift governance <path> [--json] [-c <config>]
132
+ ```
133
+
134
+ Enforces naming conventions, complexity limits, required validations, and more. Configure rules in `.schemashiftrc.json`.
135
+
136
+ **Tier:** Team
137
+
138
+ ### `pricing`
16
139
 
17
- # Migrate Yup to Zod
18
- schemashift migrate ./src --from yup --to zod
140
+ Display pricing information.
19
141
 
20
- # Preview first (recommended)
142
+ ```bash
143
+ schemashift pricing
144
+ ```
145
+
146
+ ## Configuration
147
+
148
+ Create `.schemashiftrc.json` with `schemashift init`:
149
+
150
+ ```json
151
+ {
152
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
153
+ "exclude": ["**/node_modules/**", "**/dist/**", "**/*.d.ts"],
154
+ "git": {
155
+ "enabled": false,
156
+ "createBranch": true,
157
+ "branchPrefix": "schemashift/",
158
+ "autoCommit": false
159
+ },
160
+ "backup": { "enabled": true, "dir": ".schemashift-backup" },
161
+ "customRules": [],
162
+ "suppressWarnings": [],
163
+ "governance": {
164
+ "rules": {
165
+ "naming-convention": { "pattern": ".*Schema$" },
166
+ "max-complexity": { "threshold": 80 },
167
+ "no-any": {},
168
+ "required-validations": {}
169
+ }
170
+ },
171
+ "plugins": ["./my-plugin.js"]
172
+ }
173
+ ```
174
+
175
+ ## Examples
176
+
177
+ ```bash
178
+ # Quick analysis
179
+ schemashift analyze ./src
180
+
181
+ # Preview Yup→Zod migration
21
182
  schemashift migrate ./src --from yup --to zod --dry-run
183
+
184
+ # Full migration with HTML report
185
+ schemashift migrate ./src --from yup --to zod --report html
186
+
187
+ # Zod v3→v4 upgrade with compatibility check
188
+ schemashift migrate ./src --from zod-v3 --to v4 --compat-check
189
+
190
+ # Chain migration: Yup→Zod→Valibot
191
+ schemashift migrate ./src --chain yup->zod->valibot
192
+
193
+ # CI mode
194
+ schemashift migrate ./src --from yup --to zod --ci --report json
195
+
196
+ # Rollback last migration
197
+ schemashift rollback
22
198
  ```
23
199
 
200
+ ## Environment Variables
201
+
202
+ | Variable | Description |
203
+ |----------|-------------|
204
+ | `SCHEMASHIFT_LICENSE_KEY` | License key for CI/CD (avoids interactive activation) |
205
+
24
206
  ## Links
25
207
 
26
208
  - [Documentation](https://schemashift.qwady.app/docs)
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined") return require.apply(this, arguments);
8
+ throw Error('Dynamic require of "' + x + '" is not supported');
9
+ });
10
+ var __esm = (fn, res) => function __init() {
11
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
+ };
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+
21
+ // ../../node_modules/tsup/assets/esm_shims.js
22
+ import path from "path";
23
+ import { fileURLToPath } from "url";
24
+ var getFilename, getDirname, __dirname, __filename;
25
+ var init_esm_shims = __esm({
26
+ "../../node_modules/tsup/assets/esm_shims.js"() {
27
+ "use strict";
28
+ getFilename = () => fileURLToPath(import.meta.url);
29
+ getDirname = () => path.dirname(getFilename());
30
+ __dirname = /* @__PURE__ */ getDirname();
31
+ __filename = /* @__PURE__ */ getFilename();
32
+ }
33
+ });
34
+
35
+ export {
36
+ __require,
37
+ __commonJS,
38
+ __export,
39
+ __dirname,
40
+ __filename,
41
+ init_esm_shims
42
+ };