schemashift-cli 0.3.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 +31 -0
- package/dist/cli.js +810 -0
- package/dist/index.cjs +472 -0
- package/dist/index.d.cts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +432 -0
- package/package.json +67 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
BackupManager: () => BackupManager,
|
|
34
|
+
GitIntegration: () => GitIntegration,
|
|
35
|
+
LicenseManager: () => import_license.LicenseManager,
|
|
36
|
+
LicenseTier: () => import_license.LicenseTier,
|
|
37
|
+
ReportGenerator: () => ReportGenerator,
|
|
38
|
+
SchemaAnalyzer: () => import_core.SchemaAnalyzer,
|
|
39
|
+
TIER_FEATURES: () => import_license.TIER_FEATURES,
|
|
40
|
+
TransformEngine: () => import_core.TransformEngine,
|
|
41
|
+
WatchMode: () => WatchMode,
|
|
42
|
+
createIoTsToZodHandler: () => import_io_ts_zod.createIoTsToZodHandler,
|
|
43
|
+
createJoiToZodHandler: () => import_joi_zod.createJoiToZodHandler,
|
|
44
|
+
createYupToZodHandler: () => import_yup_zod.createYupToZodHandler,
|
|
45
|
+
createZodV3ToV4Handler: () => import_zod_v3_v4.createZodV3ToV4Handler,
|
|
46
|
+
loadConfig: () => import_core.loadConfig
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(src_exports);
|
|
49
|
+
var import_core = require("@schemashift/core");
|
|
50
|
+
var import_io_ts_zod = require("@schemashift/io-ts-zod");
|
|
51
|
+
var import_joi_zod = require("@schemashift/joi-zod");
|
|
52
|
+
var import_license = require("@schemashift/license");
|
|
53
|
+
var import_yup_zod = require("@schemashift/yup-zod");
|
|
54
|
+
var import_zod_v3_v4 = require("@schemashift/zod-v3-v4");
|
|
55
|
+
|
|
56
|
+
// src/backup.ts
|
|
57
|
+
var import_node_fs = require("fs");
|
|
58
|
+
var import_node_path = require("path");
|
|
59
|
+
var BackupManager = class {
|
|
60
|
+
backupDir;
|
|
61
|
+
constructor(backupDir = ".schemashift-backup") {
|
|
62
|
+
this.backupDir = backupDir;
|
|
63
|
+
}
|
|
64
|
+
createBackup(files, from, to) {
|
|
65
|
+
const id = `backup-${Date.now()}`;
|
|
66
|
+
const backupPath = (0, import_node_path.join)(this.backupDir, id);
|
|
67
|
+
if (!(0, import_node_fs.existsSync)(backupPath)) {
|
|
68
|
+
(0, import_node_fs.mkdirSync)(backupPath, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
const manifest = {
|
|
71
|
+
id,
|
|
72
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
73
|
+
from,
|
|
74
|
+
to,
|
|
75
|
+
files: []
|
|
76
|
+
};
|
|
77
|
+
for (const file of files) {
|
|
78
|
+
const relativePath = (0, import_node_path.relative)(process.cwd(), file);
|
|
79
|
+
const backupFile = (0, import_node_path.join)(backupPath, relativePath);
|
|
80
|
+
const backupFileDir = (0, import_node_path.dirname)(backupFile);
|
|
81
|
+
if (!(0, import_node_fs.existsSync)(backupFileDir)) {
|
|
82
|
+
(0, import_node_fs.mkdirSync)(backupFileDir, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
(0, import_node_fs.copyFileSync)(file, backupFile);
|
|
85
|
+
manifest.files.push({
|
|
86
|
+
original: file,
|
|
87
|
+
backup: backupFile,
|
|
88
|
+
transformed: false
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
(0, import_node_fs.writeFileSync)((0, import_node_path.join)(backupPath, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
92
|
+
return manifest;
|
|
93
|
+
}
|
|
94
|
+
listBackups() {
|
|
95
|
+
if (!(0, import_node_fs.existsSync)(this.backupDir)) return [];
|
|
96
|
+
const backups = [];
|
|
97
|
+
const dirs = (0, import_node_fs.readdirSync)(this.backupDir, { withFileTypes: true }).filter(
|
|
98
|
+
(d) => d.isDirectory() && d.name.startsWith("backup-")
|
|
99
|
+
);
|
|
100
|
+
for (const dir of dirs) {
|
|
101
|
+
const manifestPath = (0, import_node_path.join)(this.backupDir, dir.name, "manifest.json");
|
|
102
|
+
if ((0, import_node_fs.existsSync)(manifestPath)) {
|
|
103
|
+
backups.push(JSON.parse((0, import_node_fs.readFileSync)(manifestPath, "utf-8")));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return backups.sort(
|
|
107
|
+
(a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
restore(backupId) {
|
|
111
|
+
const backupPath = (0, import_node_path.join)(this.backupDir, backupId);
|
|
112
|
+
const manifestPath = (0, import_node_path.join)(backupPath, "manifest.json");
|
|
113
|
+
if (!(0, import_node_fs.existsSync)(manifestPath)) {
|
|
114
|
+
throw new Error(`Backup ${backupId} not found`);
|
|
115
|
+
}
|
|
116
|
+
const manifest = JSON.parse((0, import_node_fs.readFileSync)(manifestPath, "utf-8"));
|
|
117
|
+
for (const file of manifest.files) {
|
|
118
|
+
if ((0, import_node_fs.existsSync)(file.backup)) {
|
|
119
|
+
(0, import_node_fs.copyFileSync)(file.backup, file.original);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
deleteBackup(backupId) {
|
|
124
|
+
const backupPath = (0, import_node_path.join)(this.backupDir, backupId);
|
|
125
|
+
if ((0, import_node_fs.existsSync)(backupPath)) {
|
|
126
|
+
(0, import_node_fs.rmSync)(backupPath, { recursive: true });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
cleanOldBackups(keepCount = 5) {
|
|
130
|
+
const backups = this.listBackups();
|
|
131
|
+
const toDelete = backups.slice(keepCount);
|
|
132
|
+
for (const backup of toDelete) {
|
|
133
|
+
this.deleteBackup(backup.id);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/git.ts
|
|
139
|
+
var import_node_child_process = require("child_process");
|
|
140
|
+
var import_node_fs2 = require("fs");
|
|
141
|
+
var GitIntegration = class {
|
|
142
|
+
isGitRepo;
|
|
143
|
+
constructor() {
|
|
144
|
+
this.isGitRepo = (0, import_node_fs2.existsSync)(".git");
|
|
145
|
+
}
|
|
146
|
+
isAvailable() {
|
|
147
|
+
if (!this.isGitRepo) return false;
|
|
148
|
+
try {
|
|
149
|
+
(0, import_node_child_process.execSync)("git --version", { stdio: "ignore" });
|
|
150
|
+
return true;
|
|
151
|
+
} catch {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
getCurrentBranch() {
|
|
156
|
+
return (0, import_node_child_process.execSync)("git rev-parse --abbrev-ref HEAD", {
|
|
157
|
+
encoding: "utf-8"
|
|
158
|
+
}).trim();
|
|
159
|
+
}
|
|
160
|
+
hasUncommittedChanges() {
|
|
161
|
+
const status = (0, import_node_child_process.execSync)("git status --porcelain", { encoding: "utf-8" });
|
|
162
|
+
return status.length > 0;
|
|
163
|
+
}
|
|
164
|
+
createBranch(name) {
|
|
165
|
+
(0, import_node_child_process.execSync)(`git checkout -b ${name}`, { stdio: "inherit" });
|
|
166
|
+
}
|
|
167
|
+
stageFiles(files) {
|
|
168
|
+
for (const file of files) {
|
|
169
|
+
(0, import_node_child_process.execSync)(`git add "${file}"`, { stdio: "ignore" });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
commit(message) {
|
|
173
|
+
(0, import_node_child_process.execSync)(`git commit -m "${message}"`, { stdio: "inherit" });
|
|
174
|
+
}
|
|
175
|
+
generateBranchName(prefix, from, to) {
|
|
176
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
177
|
+
return `${prefix}${from}-to-${to}-${timestamp}`;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/report.ts
|
|
182
|
+
var import_node_fs3 = require("fs");
|
|
183
|
+
var ReportGenerator = class {
|
|
184
|
+
generateReport(results, from, to, startTime, customRules = []) {
|
|
185
|
+
const endTime = Date.now();
|
|
186
|
+
return {
|
|
187
|
+
summary: {
|
|
188
|
+
totalFiles: results.length,
|
|
189
|
+
successfulFiles: results.filter((r) => r.success).length,
|
|
190
|
+
failedFiles: results.filter((r) => !r.success).length,
|
|
191
|
+
totalWarnings: results.reduce((acc, r) => acc + r.warnings.length, 0),
|
|
192
|
+
from,
|
|
193
|
+
to,
|
|
194
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
195
|
+
duration: endTime - startTime
|
|
196
|
+
},
|
|
197
|
+
files: results.map((r) => ({
|
|
198
|
+
path: r.filePath,
|
|
199
|
+
success: r.success,
|
|
200
|
+
errors: r.errors.map((e) => e.message),
|
|
201
|
+
warnings: r.warnings,
|
|
202
|
+
diff: r.transformedCode ? {
|
|
203
|
+
before: r.originalCode,
|
|
204
|
+
after: r.transformedCode
|
|
205
|
+
} : void 0
|
|
206
|
+
})),
|
|
207
|
+
customRulesApplied: customRules
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
writeJson(report, outputPath) {
|
|
211
|
+
(0, import_node_fs3.writeFileSync)(outputPath, JSON.stringify(report, null, 2));
|
|
212
|
+
}
|
|
213
|
+
writeHtml(report, outputPath) {
|
|
214
|
+
const html = this.generateHtml(report);
|
|
215
|
+
(0, import_node_fs3.writeFileSync)(outputPath, html);
|
|
216
|
+
}
|
|
217
|
+
generateHtml(report) {
|
|
218
|
+
const successRate = Math.round(
|
|
219
|
+
report.summary.successfulFiles / report.summary.totalFiles * 100
|
|
220
|
+
);
|
|
221
|
+
return `<!DOCTYPE html>
|
|
222
|
+
<html lang="en">
|
|
223
|
+
<head>
|
|
224
|
+
<meta charset="UTF-8">
|
|
225
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
226
|
+
<title>SchemaShift Migration Report</title>
|
|
227
|
+
<style>
|
|
228
|
+
:root {
|
|
229
|
+
--success: #10b981;
|
|
230
|
+
--error: #ef4444;
|
|
231
|
+
--warning: #f59e0b;
|
|
232
|
+
--bg: #0f172a;
|
|
233
|
+
--surface: #1e293b;
|
|
234
|
+
--text: #e2e8f0;
|
|
235
|
+
--muted: #94a3b8;
|
|
236
|
+
}
|
|
237
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
238
|
+
body {
|
|
239
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
240
|
+
background: var(--bg);
|
|
241
|
+
color: var(--text);
|
|
242
|
+
line-height: 1.6;
|
|
243
|
+
padding: 2rem;
|
|
244
|
+
}
|
|
245
|
+
.container { max-width: 1200px; margin: 0 auto; }
|
|
246
|
+
h1 { font-size: 2rem; margin-bottom: 0.5rem; }
|
|
247
|
+
.subtitle { color: var(--muted); margin-bottom: 2rem; }
|
|
248
|
+
.summary {
|
|
249
|
+
display: grid;
|
|
250
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
251
|
+
gap: 1rem;
|
|
252
|
+
margin-bottom: 2rem;
|
|
253
|
+
}
|
|
254
|
+
.card {
|
|
255
|
+
background: var(--surface);
|
|
256
|
+
border-radius: 0.5rem;
|
|
257
|
+
padding: 1.5rem;
|
|
258
|
+
}
|
|
259
|
+
.card-label { color: var(--muted); font-size: 0.875rem; }
|
|
260
|
+
.card-value { font-size: 2rem; font-weight: bold; }
|
|
261
|
+
.card-value.success { color: var(--success); }
|
|
262
|
+
.card-value.error { color: var(--error); }
|
|
263
|
+
.card-value.warning { color: var(--warning); }
|
|
264
|
+
.progress-bar {
|
|
265
|
+
height: 8px;
|
|
266
|
+
background: var(--surface);
|
|
267
|
+
border-radius: 4px;
|
|
268
|
+
margin: 1rem 0;
|
|
269
|
+
overflow: hidden;
|
|
270
|
+
}
|
|
271
|
+
.progress-fill {
|
|
272
|
+
height: 100%;
|
|
273
|
+
background: var(--success);
|
|
274
|
+
transition: width 0.3s;
|
|
275
|
+
}
|
|
276
|
+
.file-list { list-style: none; }
|
|
277
|
+
.file-item {
|
|
278
|
+
background: var(--surface);
|
|
279
|
+
border-radius: 0.5rem;
|
|
280
|
+
padding: 1rem;
|
|
281
|
+
margin-bottom: 0.5rem;
|
|
282
|
+
}
|
|
283
|
+
.file-header {
|
|
284
|
+
display: flex;
|
|
285
|
+
justify-content: space-between;
|
|
286
|
+
align-items: center;
|
|
287
|
+
}
|
|
288
|
+
.file-path { font-family: monospace; }
|
|
289
|
+
.badge {
|
|
290
|
+
padding: 0.25rem 0.5rem;
|
|
291
|
+
border-radius: 0.25rem;
|
|
292
|
+
font-size: 0.75rem;
|
|
293
|
+
font-weight: bold;
|
|
294
|
+
}
|
|
295
|
+
.badge.success { background: var(--success); color: white; }
|
|
296
|
+
.badge.error { background: var(--error); color: white; }
|
|
297
|
+
.warnings {
|
|
298
|
+
margin-top: 0.5rem;
|
|
299
|
+
padding-left: 1rem;
|
|
300
|
+
border-left: 2px solid var(--warning);
|
|
301
|
+
color: var(--warning);
|
|
302
|
+
font-size: 0.875rem;
|
|
303
|
+
}
|
|
304
|
+
.diff {
|
|
305
|
+
margin-top: 1rem;
|
|
306
|
+
background: #0d1117;
|
|
307
|
+
border-radius: 0.25rem;
|
|
308
|
+
padding: 1rem;
|
|
309
|
+
font-family: monospace;
|
|
310
|
+
font-size: 0.75rem;
|
|
311
|
+
overflow-x: auto;
|
|
312
|
+
}
|
|
313
|
+
details summary { cursor: pointer; color: var(--muted); }
|
|
314
|
+
</style>
|
|
315
|
+
</head>
|
|
316
|
+
<body>
|
|
317
|
+
<div class="container">
|
|
318
|
+
<h1>SchemaShift Migration Report</h1>
|
|
319
|
+
<p class="subtitle">${report.summary.from} \u2192 ${report.summary.to} | ${new Date(report.summary.timestamp).toLocaleString()}</p>
|
|
320
|
+
|
|
321
|
+
<div class="summary">
|
|
322
|
+
<div class="card">
|
|
323
|
+
<div class="card-label">Total Files</div>
|
|
324
|
+
<div class="card-value">${report.summary.totalFiles}</div>
|
|
325
|
+
</div>
|
|
326
|
+
<div class="card">
|
|
327
|
+
<div class="card-label">Successful</div>
|
|
328
|
+
<div class="card-value success">${report.summary.successfulFiles}</div>
|
|
329
|
+
</div>
|
|
330
|
+
<div class="card">
|
|
331
|
+
<div class="card-label">Failed</div>
|
|
332
|
+
<div class="card-value error">${report.summary.failedFiles}</div>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="card">
|
|
335
|
+
<div class="card-label">Warnings</div>
|
|
336
|
+
<div class="card-value warning">${report.summary.totalWarnings}</div>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<div class="card">
|
|
341
|
+
<div class="card-label">Success Rate</div>
|
|
342
|
+
<div class="progress-bar">
|
|
343
|
+
<div class="progress-fill" style="width: ${successRate}%"></div>
|
|
344
|
+
</div>
|
|
345
|
+
<div class="card-value">${successRate}%</div>
|
|
346
|
+
</div>
|
|
347
|
+
|
|
348
|
+
<h2 style="margin: 2rem 0 1rem;">Files</h2>
|
|
349
|
+
<ul class="file-list">
|
|
350
|
+
${report.files.map(
|
|
351
|
+
(file) => `
|
|
352
|
+
<li class="file-item">
|
|
353
|
+
<div class="file-header">
|
|
354
|
+
<span class="file-path">${file.path}</span>
|
|
355
|
+
<span class="badge ${file.success ? "success" : "error"}">${file.success ? "Success" : "Failed"}</span>
|
|
356
|
+
</div>
|
|
357
|
+
${file.errors.length > 0 ? `
|
|
358
|
+
<div class="warnings" style="border-color: var(--error); color: var(--error);">
|
|
359
|
+
${file.errors.map((e) => `<div>${e}</div>`).join("")}
|
|
360
|
+
</div>
|
|
361
|
+
` : ""}
|
|
362
|
+
${file.warnings.length > 0 ? `
|
|
363
|
+
<div class="warnings">
|
|
364
|
+
${file.warnings.map((w) => `<div>${w}</div>`).join("")}
|
|
365
|
+
</div>
|
|
366
|
+
` : ""}
|
|
367
|
+
${file.diff ? `
|
|
368
|
+
<details>
|
|
369
|
+
<summary>View diff</summary>
|
|
370
|
+
<div class="diff">
|
|
371
|
+
<pre>${this.escapeHtml(file.diff.after)}</pre>
|
|
372
|
+
</div>
|
|
373
|
+
</details>
|
|
374
|
+
` : ""}
|
|
375
|
+
</li>
|
|
376
|
+
`
|
|
377
|
+
).join("")}
|
|
378
|
+
</ul>
|
|
379
|
+
|
|
380
|
+
<footer style="margin-top: 2rem; text-align: center; color: var(--muted);">
|
|
381
|
+
Generated by SchemaShift | Duration: ${report.summary.duration}ms
|
|
382
|
+
</footer>
|
|
383
|
+
</div>
|
|
384
|
+
</body>
|
|
385
|
+
</html>`;
|
|
386
|
+
}
|
|
387
|
+
escapeHtml(text) {
|
|
388
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// src/watch.ts
|
|
393
|
+
var import_node_fs4 = require("fs");
|
|
394
|
+
var import_node_path2 = require("path");
|
|
395
|
+
var import_glob = require("glob");
|
|
396
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
397
|
+
var WatchMode = class {
|
|
398
|
+
watchers = [];
|
|
399
|
+
debounceTimers = /* @__PURE__ */ new Map();
|
|
400
|
+
async start(options) {
|
|
401
|
+
const files = await (0, import_glob.glob)(options.patterns, {
|
|
402
|
+
ignore: options.exclude
|
|
403
|
+
});
|
|
404
|
+
console.log(import_picocolors.default.cyan(`
|
|
405
|
+
Watching ${files.length} files for changes...
|
|
406
|
+
`));
|
|
407
|
+
console.log(import_picocolors.default.dim("Press Ctrl+C to stop\n"));
|
|
408
|
+
const directories = new Set(files.map((f) => f.split("/").slice(0, -1).join("/")));
|
|
409
|
+
for (const dir of directories) {
|
|
410
|
+
const watcher = (0, import_node_fs4.watch)(dir || ".", { recursive: true }, async (_event, filename) => {
|
|
411
|
+
if (!filename) return;
|
|
412
|
+
const fullPath = dir ? `${dir}/${filename}` : filename;
|
|
413
|
+
if (!this.matchesPatterns(fullPath, options.patterns, options.exclude)) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const existingTimer = this.debounceTimers.get(fullPath);
|
|
417
|
+
if (existingTimer) {
|
|
418
|
+
clearTimeout(existingTimer);
|
|
419
|
+
}
|
|
420
|
+
this.debounceTimers.set(
|
|
421
|
+
fullPath,
|
|
422
|
+
setTimeout(async () => {
|
|
423
|
+
console.log(import_picocolors.default.yellow(`
|
|
424
|
+
Changed: ${(0, import_node_path2.relative)(process.cwd(), fullPath)}`));
|
|
425
|
+
try {
|
|
426
|
+
await options.onTransform(fullPath);
|
|
427
|
+
console.log(import_picocolors.default.green(`Transformed successfully
|
|
428
|
+
`));
|
|
429
|
+
} catch (error) {
|
|
430
|
+
console.error(import_picocolors.default.red(`Transform failed: ${error}
|
|
431
|
+
`));
|
|
432
|
+
}
|
|
433
|
+
this.debounceTimers.delete(fullPath);
|
|
434
|
+
}, 100)
|
|
435
|
+
);
|
|
436
|
+
});
|
|
437
|
+
this.watchers.push(watcher);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
stop() {
|
|
441
|
+
for (const watcher of this.watchers) {
|
|
442
|
+
watcher.close();
|
|
443
|
+
}
|
|
444
|
+
this.watchers = [];
|
|
445
|
+
for (const timer of this.debounceTimers.values()) {
|
|
446
|
+
clearTimeout(timer);
|
|
447
|
+
}
|
|
448
|
+
this.debounceTimers.clear();
|
|
449
|
+
}
|
|
450
|
+
matchesPatterns(file, _include, _exclude) {
|
|
451
|
+
const isIncluded = file.endsWith(".ts") || file.endsWith(".tsx");
|
|
452
|
+
const isExcluded = file.includes("node_modules") || file.includes("dist");
|
|
453
|
+
return isIncluded && !isExcluded;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
457
|
+
0 && (module.exports = {
|
|
458
|
+
BackupManager,
|
|
459
|
+
GitIntegration,
|
|
460
|
+
LicenseManager,
|
|
461
|
+
LicenseTier,
|
|
462
|
+
ReportGenerator,
|
|
463
|
+
SchemaAnalyzer,
|
|
464
|
+
TIER_FEATURES,
|
|
465
|
+
TransformEngine,
|
|
466
|
+
WatchMode,
|
|
467
|
+
createIoTsToZodHandler,
|
|
468
|
+
createJoiToZodHandler,
|
|
469
|
+
createYupToZodHandler,
|
|
470
|
+
createZodV3ToV4Handler,
|
|
471
|
+
loadConfig
|
|
472
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { TransformResult } from '@schemashift/core';
|
|
2
|
+
export { SchemaAnalyzer, TransformEngine, loadConfig } from '@schemashift/core';
|
|
3
|
+
export { createIoTsToZodHandler } from '@schemashift/io-ts-zod';
|
|
4
|
+
export { createJoiToZodHandler } from '@schemashift/joi-zod';
|
|
5
|
+
export { LicenseManager, LicenseTier, TIER_FEATURES } from '@schemashift/license';
|
|
6
|
+
export { createYupToZodHandler } from '@schemashift/yup-zod';
|
|
7
|
+
export { createZodV3ToV4Handler } from '@schemashift/zod-v3-v4';
|
|
8
|
+
|
|
9
|
+
interface BackupManifest {
|
|
10
|
+
id: string;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
files: Array<{
|
|
15
|
+
original: string;
|
|
16
|
+
backup: string;
|
|
17
|
+
transformed: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
declare class BackupManager {
|
|
21
|
+
private backupDir;
|
|
22
|
+
constructor(backupDir?: string);
|
|
23
|
+
createBackup(files: string[], from: string, to: string): BackupManifest;
|
|
24
|
+
listBackups(): BackupManifest[];
|
|
25
|
+
restore(backupId: string): void;
|
|
26
|
+
deleteBackup(backupId: string): void;
|
|
27
|
+
cleanOldBackups(keepCount?: number): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare class GitIntegration {
|
|
31
|
+
private isGitRepo;
|
|
32
|
+
constructor();
|
|
33
|
+
isAvailable(): boolean;
|
|
34
|
+
getCurrentBranch(): string;
|
|
35
|
+
hasUncommittedChanges(): boolean;
|
|
36
|
+
createBranch(name: string): void;
|
|
37
|
+
stageFiles(files: string[]): void;
|
|
38
|
+
commit(message: string): void;
|
|
39
|
+
generateBranchName(prefix: string, from: string, to: string): string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface MigrationReport {
|
|
43
|
+
summary: {
|
|
44
|
+
totalFiles: number;
|
|
45
|
+
successfulFiles: number;
|
|
46
|
+
failedFiles: number;
|
|
47
|
+
totalWarnings: number;
|
|
48
|
+
from: string;
|
|
49
|
+
to: string;
|
|
50
|
+
timestamp: string;
|
|
51
|
+
duration: number;
|
|
52
|
+
};
|
|
53
|
+
files: Array<{
|
|
54
|
+
path: string;
|
|
55
|
+
success: boolean;
|
|
56
|
+
errors: string[];
|
|
57
|
+
warnings: string[];
|
|
58
|
+
diff?: {
|
|
59
|
+
before: string;
|
|
60
|
+
after: string;
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
customRulesApplied: string[];
|
|
64
|
+
}
|
|
65
|
+
declare class ReportGenerator {
|
|
66
|
+
generateReport(results: TransformResult[], from: string, to: string, startTime: number, customRules?: string[]): MigrationReport;
|
|
67
|
+
writeJson(report: MigrationReport, outputPath: string): void;
|
|
68
|
+
writeHtml(report: MigrationReport, outputPath: string): void;
|
|
69
|
+
private generateHtml;
|
|
70
|
+
private escapeHtml;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface WatchOptions {
|
|
74
|
+
patterns: string[];
|
|
75
|
+
exclude: string[];
|
|
76
|
+
from: string;
|
|
77
|
+
to: string;
|
|
78
|
+
onTransform: (file: string) => Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
declare class WatchMode {
|
|
81
|
+
private watchers;
|
|
82
|
+
private debounceTimers;
|
|
83
|
+
start(options: WatchOptions): Promise<void>;
|
|
84
|
+
stop(): void;
|
|
85
|
+
private matchesPatterns;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { BackupManager, GitIntegration, ReportGenerator, WatchMode };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { TransformResult } from '@schemashift/core';
|
|
2
|
+
export { SchemaAnalyzer, TransformEngine, loadConfig } from '@schemashift/core';
|
|
3
|
+
export { createIoTsToZodHandler } from '@schemashift/io-ts-zod';
|
|
4
|
+
export { createJoiToZodHandler } from '@schemashift/joi-zod';
|
|
5
|
+
export { LicenseManager, LicenseTier, TIER_FEATURES } from '@schemashift/license';
|
|
6
|
+
export { createYupToZodHandler } from '@schemashift/yup-zod';
|
|
7
|
+
export { createZodV3ToV4Handler } from '@schemashift/zod-v3-v4';
|
|
8
|
+
|
|
9
|
+
interface BackupManifest {
|
|
10
|
+
id: string;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
files: Array<{
|
|
15
|
+
original: string;
|
|
16
|
+
backup: string;
|
|
17
|
+
transformed: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
declare class BackupManager {
|
|
21
|
+
private backupDir;
|
|
22
|
+
constructor(backupDir?: string);
|
|
23
|
+
createBackup(files: string[], from: string, to: string): BackupManifest;
|
|
24
|
+
listBackups(): BackupManifest[];
|
|
25
|
+
restore(backupId: string): void;
|
|
26
|
+
deleteBackup(backupId: string): void;
|
|
27
|
+
cleanOldBackups(keepCount?: number): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare class GitIntegration {
|
|
31
|
+
private isGitRepo;
|
|
32
|
+
constructor();
|
|
33
|
+
isAvailable(): boolean;
|
|
34
|
+
getCurrentBranch(): string;
|
|
35
|
+
hasUncommittedChanges(): boolean;
|
|
36
|
+
createBranch(name: string): void;
|
|
37
|
+
stageFiles(files: string[]): void;
|
|
38
|
+
commit(message: string): void;
|
|
39
|
+
generateBranchName(prefix: string, from: string, to: string): string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface MigrationReport {
|
|
43
|
+
summary: {
|
|
44
|
+
totalFiles: number;
|
|
45
|
+
successfulFiles: number;
|
|
46
|
+
failedFiles: number;
|
|
47
|
+
totalWarnings: number;
|
|
48
|
+
from: string;
|
|
49
|
+
to: string;
|
|
50
|
+
timestamp: string;
|
|
51
|
+
duration: number;
|
|
52
|
+
};
|
|
53
|
+
files: Array<{
|
|
54
|
+
path: string;
|
|
55
|
+
success: boolean;
|
|
56
|
+
errors: string[];
|
|
57
|
+
warnings: string[];
|
|
58
|
+
diff?: {
|
|
59
|
+
before: string;
|
|
60
|
+
after: string;
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
customRulesApplied: string[];
|
|
64
|
+
}
|
|
65
|
+
declare class ReportGenerator {
|
|
66
|
+
generateReport(results: TransformResult[], from: string, to: string, startTime: number, customRules?: string[]): MigrationReport;
|
|
67
|
+
writeJson(report: MigrationReport, outputPath: string): void;
|
|
68
|
+
writeHtml(report: MigrationReport, outputPath: string): void;
|
|
69
|
+
private generateHtml;
|
|
70
|
+
private escapeHtml;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface WatchOptions {
|
|
74
|
+
patterns: string[];
|
|
75
|
+
exclude: string[];
|
|
76
|
+
from: string;
|
|
77
|
+
to: string;
|
|
78
|
+
onTransform: (file: string) => Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
declare class WatchMode {
|
|
81
|
+
private watchers;
|
|
82
|
+
private debounceTimers;
|
|
83
|
+
start(options: WatchOptions): Promise<void>;
|
|
84
|
+
stop(): void;
|
|
85
|
+
private matchesPatterns;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { BackupManager, GitIntegration, ReportGenerator, WatchMode };
|