ormbridge 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +408 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +20 -0
- package/dist/cli.js.map +1 -0
- package/dist/cliRunner.d.ts +20 -0
- package/dist/cliRunner.js +343 -0
- package/dist/cliRunner.js.map +1 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.js +204 -0
- package/dist/config.js.map +1 -0
- package/dist/convert.d.ts +20 -0
- package/dist/convert.js +61 -0
- package/dist/convert.js.map +1 -0
- package/dist/emitters/django.d.ts +4 -0
- package/dist/emitters/django.js +501 -0
- package/dist/emitters/django.js.map +1 -0
- package/dist/emitters/doctrine.d.ts +20 -0
- package/dist/emitters/doctrine.js +1134 -0
- package/dist/emitters/doctrine.js.map +1 -0
- package/dist/emitters/graphene.d.ts +4 -0
- package/dist/emitters/graphene.js +431 -0
- package/dist/emitters/graphene.js.map +1 -0
- package/dist/emitters/laravel.d.ts +33 -0
- package/dist/emitters/laravel.js +1695 -0
- package/dist/emitters/laravel.js.map +1 -0
- package/dist/emitters/prisma.d.ts +21 -0
- package/dist/emitters/prisma.js +1058 -0
- package/dist/emitters/prisma.js.map +1 -0
- package/dist/emitters/typeorm.d.ts +9 -0
- package/dist/emitters/typeorm.js +833 -0
- package/dist/emitters/typeorm.js.map +1 -0
- package/dist/emitters/typescriptInterfaces.d.ts +15 -0
- package/dist/emitters/typescriptInterfaces.js +350 -0
- package/dist/emitters/typescriptInterfaces.js.map +1 -0
- package/dist/formats.d.ts +80 -0
- package/dist/formats.js +212 -0
- package/dist/formats.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +48 -0
- package/dist/io.js +328 -0
- package/dist/io.js.map +1 -0
- package/dist/ir.d.ts +197 -0
- package/dist/ir.js +10 -0
- package/dist/ir.js.map +1 -0
- package/dist/naming.d.ts +11 -0
- package/dist/naming.js +88 -0
- package/dist/naming.js.map +1 -0
- package/dist/parsers/django.d.ts +14 -0
- package/dist/parsers/django.js +1161 -0
- package/dist/parsers/django.js.map +1 -0
- package/dist/parsers/doctrine.d.ts +12 -0
- package/dist/parsers/doctrine.js +1782 -0
- package/dist/parsers/doctrine.js.map +1 -0
- package/dist/parsers/laravel.d.ts +17 -0
- package/dist/parsers/laravel.js +2824 -0
- package/dist/parsers/laravel.js.map +1 -0
- package/dist/parsers/phpSyntax.d.ts +124 -0
- package/dist/parsers/phpSyntax.js +429 -0
- package/dist/parsers/phpSyntax.js.map +1 -0
- package/dist/parsers/prisma.d.ts +12 -0
- package/dist/parsers/prisma.js +964 -0
- package/dist/parsers/prisma.js.map +1 -0
- package/dist/parsers/pythonSyntax.d.ts +38 -0
- package/dist/parsers/pythonSyntax.js +120 -0
- package/dist/parsers/pythonSyntax.js.map +1 -0
- package/dist/parsers/typeorm.d.ts +12 -0
- package/dist/parsers/typeorm.js +1614 -0
- package/dist/parsers/typeorm.js.map +1 -0
- package/dist/parsers/typescriptSyntax.d.ts +57 -0
- package/dist/parsers/typescriptSyntax.js +200 -0
- package/dist/parsers/typescriptSyntax.js.map +1 -0
- package/dist/prismaOnlyConstructs.d.ts +7 -0
- package/dist/prismaOnlyConstructs.js +76 -0
- package/dist/prismaOnlyConstructs.js.map +1 -0
- package/dist/result.d.ts +20 -0
- package/dist/result.js +18 -0
- package/dist/result.js.map +1 -0
- package/dist/transforms.d.ts +13 -0
- package/dist/transforms.js +142 -0
- package/dist/transforms.js.map +1 -0
- package/package.json +83 -4
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { extname, isAbsolute, relative, resolve } from 'node:path';
|
|
3
|
+
import { Command, CommanderError } from 'commander';
|
|
4
|
+
import { findConfigFile, loadConfigFile, } from './config.js';
|
|
5
|
+
import { PRISMA_PROVIDERS } from './emitters/prisma.js';
|
|
6
|
+
import { describeFormats, getFormat, getFormatByExtension, listFormatNames, listFormats, } from './formats.js';
|
|
7
|
+
import { countLines, runConversion, } from './io.js';
|
|
8
|
+
/** Exit codes of the `ormbridge` command. */
|
|
9
|
+
export const EXIT_OK = 0;
|
|
10
|
+
/** A conversion failed: unreadable input, parse error, unwritable output. */
|
|
11
|
+
export const EXIT_CONVERSION_ERROR = 1;
|
|
12
|
+
/** The command line or the config file is invalid. */
|
|
13
|
+
export const EXIT_USAGE_ERROR = 2;
|
|
14
|
+
/** `--check` found an output file that is stale or missing. */
|
|
15
|
+
export const EXIT_CHECK_FAILED = 3;
|
|
16
|
+
function readPackageVersion() {
|
|
17
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
18
|
+
const packageJson = requireFromHere('../package.json');
|
|
19
|
+
return packageJson.version ?? '0.0.0';
|
|
20
|
+
}
|
|
21
|
+
function inferFormatFromPath(filePath) {
|
|
22
|
+
if (filePath === undefined) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const adapter = getFormatByExtension(extname(filePath));
|
|
26
|
+
return adapter?.name;
|
|
27
|
+
}
|
|
28
|
+
function failure(code, message) {
|
|
29
|
+
return { ok: false, error: { code, message } };
|
|
30
|
+
}
|
|
31
|
+
/** Validates merged settings and builds the options for one conversion. */
|
|
32
|
+
function buildRunOptions(settings, mode) {
|
|
33
|
+
const inputs = settings.input ?? [];
|
|
34
|
+
if (inputs.length === 0) {
|
|
35
|
+
return failure('INVALID_OPTION', 'No input was given. Pass -i/--input, or set "input" in the config file.');
|
|
36
|
+
}
|
|
37
|
+
if (mode === 'check' && settings.output === undefined) {
|
|
38
|
+
return failure('INVALID_OPTION', '--check compares the conversion with an existing output, so an output path is required. Pass -o/--output, or set "output" in the config file.');
|
|
39
|
+
}
|
|
40
|
+
const fromValue = settings.from ?? inferFormatFromPath(inputs[0]) ?? 'django';
|
|
41
|
+
if (!getFormat(fromValue).ok) {
|
|
42
|
+
return failure('INVALID_OPTION', `Invalid --from value "${fromValue}". Expected one of: ${listFormatNames().join(', ')}.`);
|
|
43
|
+
}
|
|
44
|
+
const toValue = settings.to ??
|
|
45
|
+
inferFormatFromPath(settings.output) ??
|
|
46
|
+
(fromValue === 'django' ? 'prisma' : 'django');
|
|
47
|
+
if (!getFormat(toValue).ok) {
|
|
48
|
+
return failure('INVALID_OPTION', `Invalid --to value "${toValue}". Expected one of: ${listFormatNames().join(', ')}.`);
|
|
49
|
+
}
|
|
50
|
+
const namingValue = settings.naming ?? 'preserve';
|
|
51
|
+
if (namingValue !== 'preserve' && namingValue !== 'normalize') {
|
|
52
|
+
return failure('INVALID_OPTION', `Invalid --naming value "${namingValue}". Expected "preserve" or "normalize".`);
|
|
53
|
+
}
|
|
54
|
+
const naming = namingValue;
|
|
55
|
+
const providerValue = settings.provider ?? 'postgresql';
|
|
56
|
+
if (!PRISMA_PROVIDERS.includes(providerValue)) {
|
|
57
|
+
return failure('INVALID_OPTION', `Invalid --provider value "${providerValue}". Expected one of: ${PRISMA_PROVIDERS.join(', ')}.`);
|
|
58
|
+
}
|
|
59
|
+
const provider = providerValue;
|
|
60
|
+
const autoFieldValue = (settings.autoField ?? 'int').toLowerCase();
|
|
61
|
+
if (autoFieldValue !== 'int' && autoFieldValue !== 'bigint') {
|
|
62
|
+
return failure('INVALID_OPTION', `Invalid --auto-field value "${settings.autoField ?? ''}". Expected "int" or "bigint".`);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
ok: true,
|
|
66
|
+
value: {
|
|
67
|
+
from: fromValue,
|
|
68
|
+
to: toValue,
|
|
69
|
+
naming,
|
|
70
|
+
provider,
|
|
71
|
+
header: settings.header ?? true,
|
|
72
|
+
autoField: autoFieldValue === 'bigint' ? 'bigInt' : 'int',
|
|
73
|
+
inputs,
|
|
74
|
+
dryRun: mode === 'dry-run',
|
|
75
|
+
check: mode === 'check',
|
|
76
|
+
...(settings.output === undefined ? {} : { output: settings.output }),
|
|
77
|
+
...(settings.appLabel === undefined
|
|
78
|
+
? {}
|
|
79
|
+
: { appLabel: settings.appLabel }),
|
|
80
|
+
...(settings.namespace === undefined
|
|
81
|
+
? {}
|
|
82
|
+
: { namespace: settings.namespace }),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** Finds and loads the config file according to --config / --no-config. */
|
|
87
|
+
async function resolveConfig(flags, env) {
|
|
88
|
+
if (flags.config === false) {
|
|
89
|
+
return { ok: true, value: undefined };
|
|
90
|
+
}
|
|
91
|
+
if (typeof flags.config === 'string') {
|
|
92
|
+
return loadConfigFile(resolve(env.cwd, flags.config));
|
|
93
|
+
}
|
|
94
|
+
const found = await findConfigFile(env.cwd);
|
|
95
|
+
if (found === undefined) {
|
|
96
|
+
return { ok: true, value: undefined };
|
|
97
|
+
}
|
|
98
|
+
return loadConfigFile(found);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Merges the config file and the flags into the conversions to run. Flags
|
|
102
|
+
* override config values. With no -i and a config that lists `conversions`,
|
|
103
|
+
* every listed conversion runs.
|
|
104
|
+
*/
|
|
105
|
+
function planRuns(flags, headerFromFlag, config, env, mode) {
|
|
106
|
+
const useConversionList = config !== undefined &&
|
|
107
|
+
config.conversions.length > 0 &&
|
|
108
|
+
flags.input === undefined;
|
|
109
|
+
const entries = config === undefined
|
|
110
|
+
? [{}]
|
|
111
|
+
: useConversionList
|
|
112
|
+
? config.conversions.map((conversion) => ({
|
|
113
|
+
...config.defaults,
|
|
114
|
+
...conversion,
|
|
115
|
+
}))
|
|
116
|
+
: [config.defaults];
|
|
117
|
+
if (entries.length > 1 && flags.output !== undefined) {
|
|
118
|
+
return failure('INVALID_OPTION', `--output cannot be combined with the ${entries.length} conversions in the config file, because they would all write to the same path. Remove -o, or pass -i to run a single conversion.`);
|
|
119
|
+
}
|
|
120
|
+
const runs = [];
|
|
121
|
+
for (const [index, entry] of entries.entries()) {
|
|
122
|
+
const label = entries.length === 1 ? undefined : (entry.name ?? `#${index + 1}`);
|
|
123
|
+
const settings = { ...entry };
|
|
124
|
+
if (flags.input !== undefined) {
|
|
125
|
+
settings.input = flags.input.map((path) => resolve(env.cwd, path));
|
|
126
|
+
}
|
|
127
|
+
if (flags.output !== undefined) {
|
|
128
|
+
settings.output = resolve(env.cwd, flags.output);
|
|
129
|
+
}
|
|
130
|
+
if (flags.from !== undefined) {
|
|
131
|
+
settings.from = flags.from;
|
|
132
|
+
}
|
|
133
|
+
if (flags.to !== undefined) {
|
|
134
|
+
settings.to = flags.to;
|
|
135
|
+
}
|
|
136
|
+
if (flags.naming !== undefined) {
|
|
137
|
+
settings.naming = flags.naming;
|
|
138
|
+
}
|
|
139
|
+
if (flags.provider !== undefined) {
|
|
140
|
+
settings.provider = flags.provider;
|
|
141
|
+
}
|
|
142
|
+
if (headerFromFlag !== undefined) {
|
|
143
|
+
settings.header = headerFromFlag;
|
|
144
|
+
}
|
|
145
|
+
if (flags.appLabel !== undefined) {
|
|
146
|
+
settings.appLabel = flags.appLabel;
|
|
147
|
+
}
|
|
148
|
+
if (flags.autoField !== undefined) {
|
|
149
|
+
settings.autoField = flags.autoField;
|
|
150
|
+
}
|
|
151
|
+
if (flags.namespace !== undefined) {
|
|
152
|
+
settings.namespace = flags.namespace;
|
|
153
|
+
}
|
|
154
|
+
const options = buildRunOptions(settings, mode);
|
|
155
|
+
if (!options.ok) {
|
|
156
|
+
const where = label === undefined ? '' : `conversion ${label}: `;
|
|
157
|
+
return failure('INVALID_OPTION', `${where}${options.error.message}`);
|
|
158
|
+
}
|
|
159
|
+
runs.push({ label, options: options.value });
|
|
160
|
+
}
|
|
161
|
+
return { ok: true, value: runs };
|
|
162
|
+
}
|
|
163
|
+
function formatBytes(bytes) {
|
|
164
|
+
return bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
|
|
165
|
+
}
|
|
166
|
+
function describeFile(file) {
|
|
167
|
+
return `${file.lines} line(s), ${formatBytes(file.bytes)}`;
|
|
168
|
+
}
|
|
169
|
+
/** Shows a path relative to the working directory when it is inside it. */
|
|
170
|
+
function displayPath(path, cwd) {
|
|
171
|
+
const relativePath = relative(cwd, path);
|
|
172
|
+
return relativePath !== '' &&
|
|
173
|
+
!relativePath.startsWith('..') &&
|
|
174
|
+
!isAbsolute(relativePath)
|
|
175
|
+
? relativePath
|
|
176
|
+
: path;
|
|
177
|
+
}
|
|
178
|
+
/** Prints the result of one conversion. Returns true when --check found it stale. */
|
|
179
|
+
function report(run, summary, mode, env) {
|
|
180
|
+
const prefix = run.label === undefined ? '' : `[${run.label}] `;
|
|
181
|
+
const options = run.options;
|
|
182
|
+
for (const warning of summary.warnings) {
|
|
183
|
+
env.stderr(`${prefix}warning: ${warning}\n`);
|
|
184
|
+
}
|
|
185
|
+
const description = `${summary.modelCount} model(s) from ${summary.inputFiles.length} file(s) ` +
|
|
186
|
+
`(${options.from} -> ${options.to})`;
|
|
187
|
+
if (summary.outputPath === undefined) {
|
|
188
|
+
if (mode === 'dry-run') {
|
|
189
|
+
env.stderr(`${prefix}Dry run: converted ${description}; the result would be printed to stdout (${countLines(summary.output)} line(s)).\n`);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
env.stdout(summary.output);
|
|
193
|
+
}
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
let stale = false;
|
|
197
|
+
if (mode === 'check') {
|
|
198
|
+
for (const file of summary.plannedFiles) {
|
|
199
|
+
const path = displayPath(file.path, env.cwd);
|
|
200
|
+
if (file.state === 'unchanged') {
|
|
201
|
+
env.stderr(`${prefix}up to date: ${path}\n`);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
stale = true;
|
|
205
|
+
env.stderr(file.state === 'created'
|
|
206
|
+
? `${prefix}error: ${path} is missing; the conversion would create it (${describeFile(file)}).\n`
|
|
207
|
+
: `${prefix}error: ${path} is out of date: ${file.diff ?? 'contents differ'}.\n`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return stale;
|
|
211
|
+
}
|
|
212
|
+
const heading = mode === 'dry-run'
|
|
213
|
+
? `Dry run, nothing written: ${description}`
|
|
214
|
+
: `Converted ${description}`;
|
|
215
|
+
env.stderr(`${prefix}${heading}\n`);
|
|
216
|
+
for (const file of summary.plannedFiles) {
|
|
217
|
+
const path = displayPath(file.path, env.cwd);
|
|
218
|
+
const verb = file.state === 'unchanged'
|
|
219
|
+
? 'unchanged'
|
|
220
|
+
: mode === 'dry-run'
|
|
221
|
+
? file.state === 'created'
|
|
222
|
+
? 'would create'
|
|
223
|
+
: 'would update'
|
|
224
|
+
: file.state === 'created'
|
|
225
|
+
? 'created'
|
|
226
|
+
: 'updated';
|
|
227
|
+
const detail = file.diff === undefined
|
|
228
|
+
? describeFile(file)
|
|
229
|
+
: `${describeFile(file)}; ${file.diff}`;
|
|
230
|
+
env.stderr(`${prefix} ${verb} ${path} (${detail})\n`);
|
|
231
|
+
}
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
async function handleConvert(flags, headerFromFlag, env) {
|
|
235
|
+
const usageError = (message) => {
|
|
236
|
+
env.stderr(`error [USAGE]: ${message}\n`);
|
|
237
|
+
return EXIT_USAGE_ERROR;
|
|
238
|
+
};
|
|
239
|
+
if (flags.check === true && flags.dryRun === true) {
|
|
240
|
+
return usageError('--check and --dry-run cannot be combined: --check already writes nothing.');
|
|
241
|
+
}
|
|
242
|
+
const mode = flags.check === true
|
|
243
|
+
? 'check'
|
|
244
|
+
: flags.dryRun === true
|
|
245
|
+
? 'dry-run'
|
|
246
|
+
: 'write';
|
|
247
|
+
const config = await resolveConfig(flags, env);
|
|
248
|
+
if (!config.ok) {
|
|
249
|
+
return usageError(config.error.message);
|
|
250
|
+
}
|
|
251
|
+
const runs = planRuns(flags, headerFromFlag, config.value, env, mode);
|
|
252
|
+
if (!runs.ok) {
|
|
253
|
+
return usageError(runs.error.message);
|
|
254
|
+
}
|
|
255
|
+
if (config.value !== undefined && runs.value.length > 1) {
|
|
256
|
+
env.stderr(`Using ${displayPath(config.value.path, env.cwd)}: ${runs.value.length} conversions\n`);
|
|
257
|
+
}
|
|
258
|
+
let failedConversions = 0;
|
|
259
|
+
let staleOutputs = 0;
|
|
260
|
+
for (const run of runs.value) {
|
|
261
|
+
const prefix = run.label === undefined ? '' : `[${run.label}] `;
|
|
262
|
+
const summary = await runConversion(run.options);
|
|
263
|
+
if (!summary.ok) {
|
|
264
|
+
env.stderr(`${prefix}error [${summary.error.code}]: ${summary.error.message}\n`);
|
|
265
|
+
failedConversions += 1;
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (report(run, summary.value, mode, env)) {
|
|
269
|
+
staleOutputs += 1;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (failedConversions > 0) {
|
|
273
|
+
return EXIT_CONVERSION_ERROR;
|
|
274
|
+
}
|
|
275
|
+
if (staleOutputs > 0) {
|
|
276
|
+
env.stderr('Generated output is stale. Run "ormbridge convert" without --check to regenerate it.\n');
|
|
277
|
+
return EXIT_CHECK_FAILED;
|
|
278
|
+
}
|
|
279
|
+
return EXIT_OK;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Runs the CLI with the given arguments (without the node and script
|
|
283
|
+
* entries) and returns the exit code. Nothing is written to the real
|
|
284
|
+
* process streams, so tests can call this in-process.
|
|
285
|
+
*/
|
|
286
|
+
export async function runCli(argv, env) {
|
|
287
|
+
const program = new Command();
|
|
288
|
+
program
|
|
289
|
+
.name('ormbridge')
|
|
290
|
+
.description('Convert ORM schemas between Django, Prisma, TypeORM and more.')
|
|
291
|
+
.version(readPackageVersion())
|
|
292
|
+
.exitOverride()
|
|
293
|
+
.configureOutput({ writeOut: env.stdout, writeErr: env.stderr });
|
|
294
|
+
let exitCode = EXIT_OK;
|
|
295
|
+
program
|
|
296
|
+
.command('convert')
|
|
297
|
+
.description('Convert models from one ORM format to another')
|
|
298
|
+
.option('-i, --input <paths...>', 'file(s) or directories to read (models.py, models/ package, or .prisma); optional when a config file supplies them')
|
|
299
|
+
.option('-o, --output <path>', 'file to write (a directory for formats that produce several files); prints to stdout when omitted')
|
|
300
|
+
.option('-f, --from <format>', `source format (${listFormatNames().join(' | ')}); inferred from the input when omitted`)
|
|
301
|
+
.option('-t, --to <format>', `target format (${listFormatNames().join(' | ')}); inferred from the output when omitted`)
|
|
302
|
+
.option('--naming <mode>', 'preserve existing database names, or normalize to singular snake_case + UUID ids (default: preserve)')
|
|
303
|
+
.option('--provider <name>', `Prisma datasource provider (${PRISMA_PROVIDERS.join(' | ')}) (default: postgresql)`)
|
|
304
|
+
.option('--no-header', 'omit the Prisma generator and datasource blocks')
|
|
305
|
+
.option('--app-label <name>', 'Django app label used for default table names (default: derived from the directory)')
|
|
306
|
+
.option('--auto-field <type>', 'primary key type for Django models without one (int | bigint) (default: int)')
|
|
307
|
+
.option('--namespace <name>', 'PHP namespace of the Doctrine entities (default: App\\Entity) or Laravel models (default: App\\Models)')
|
|
308
|
+
.option('--dry-run', 'run the conversion and report what would be written, without touching any file')
|
|
309
|
+
.option('--check', 'exit with code 3 if an output file is missing or differs from the conversion; writes nothing')
|
|
310
|
+
.option('--config <path>', 'read settings from this JSON config file instead of searching for ormbridge.config.json')
|
|
311
|
+
.option('--no-config', 'ignore any config file')
|
|
312
|
+
.action(async (flags, command) => {
|
|
313
|
+
const conflict = argv.includes('--no-config') &&
|
|
314
|
+
argv.some((arg) => arg === '--config' || arg.startsWith('--config='));
|
|
315
|
+
if (conflict) {
|
|
316
|
+
env.stderr('error [USAGE]: --config and --no-config cannot be combined.\n');
|
|
317
|
+
exitCode = EXIT_USAGE_ERROR;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const headerFromFlag = command.getOptionValueSource('header') === 'cli'
|
|
321
|
+
? flags.header
|
|
322
|
+
: undefined;
|
|
323
|
+
exitCode = await handleConvert(flags, headerFromFlag, env);
|
|
324
|
+
});
|
|
325
|
+
program
|
|
326
|
+
.command('formats')
|
|
327
|
+
.description('List the supported formats, their file extensions, and whether each can be read and/or written')
|
|
328
|
+
.action(() => {
|
|
329
|
+
env.stdout(describeFormats(listFormats()));
|
|
330
|
+
});
|
|
331
|
+
try {
|
|
332
|
+
await program.parseAsync(argv, { from: 'user' });
|
|
333
|
+
}
|
|
334
|
+
catch (thrown) {
|
|
335
|
+
if (thrown instanceof CommanderError) {
|
|
336
|
+
// Commander already printed the message; help and version are not failures.
|
|
337
|
+
return thrown.exitCode === 0 ? EXIT_OK : EXIT_USAGE_ERROR;
|
|
338
|
+
}
|
|
339
|
+
throw thrown;
|
|
340
|
+
}
|
|
341
|
+
return exitCode;
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=cliRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliRunner.js","sourceRoot":"","sources":["../src/cliRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,cAAc,EACd,cAAc,GAGf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,WAAW,GAGZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,aAAa,GAId,MAAM,SAAS,CAAC;AAIjB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,OAAO,GAAW,CAAC,CAAC;AACjC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAW,CAAC,CAAC;AAC/C,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAW,CAAC,CAAC;AAC1C,+DAA+D;A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,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAC5D,CAAC;QACD,MAAM,MAAM,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Result } from './result.js';
|
|
2
|
+
/** File names searched for in each directory, in priority order. */
|
|
3
|
+
export declare const CONFIG_FILE_NAMES: readonly string[];
|
|
4
|
+
/** The settings of one conversion. Every key is optional; missing keys fall back to defaults. */
|
|
5
|
+
export interface ConversionConfig {
|
|
6
|
+
/** Label used in messages. Only meaningful inside `conversions`. */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** Input files or directories (absolute: relative paths resolve against the config file). */
|
|
9
|
+
input?: string[];
|
|
10
|
+
/** Output file or directory (absolute). */
|
|
11
|
+
output?: string;
|
|
12
|
+
from?: string;
|
|
13
|
+
to?: string;
|
|
14
|
+
naming?: 'preserve' | 'normalize';
|
|
15
|
+
provider?: string;
|
|
16
|
+
header?: boolean;
|
|
17
|
+
appLabel?: string;
|
|
18
|
+
autoField?: 'int' | 'bigint';
|
|
19
|
+
/** PHP namespace of the Doctrine entities or Laravel models. */
|
|
20
|
+
namespace?: string;
|
|
21
|
+
}
|
|
22
|
+
/** A parsed config file. Top-level settings are defaults shared by every entry in `conversions`. */
|
|
23
|
+
export interface ConfigFile {
|
|
24
|
+
/** Absolute path of the file the config was read from. */
|
|
25
|
+
path: string;
|
|
26
|
+
/** Top-level settings, used as defaults for each conversion. */
|
|
27
|
+
defaults: ConversionConfig;
|
|
28
|
+
/** Named conversions. Empty when the file describes a single conversion at the top level. */
|
|
29
|
+
conversions: ConversionConfig[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Looks for a config file in `startDirectory` and each parent directory. The
|
|
33
|
+
* search stops after the first directory that contains a package.json (the
|
|
34
|
+
* project root) and at the filesystem root. Returns undefined when none exists.
|
|
35
|
+
*/
|
|
36
|
+
export declare function findConfigFile(startDirectory: string): Promise<string | undefined>;
|
|
37
|
+
/** Reads and validates a JSON config file. Relative paths inside it resolve against its directory. */
|
|
38
|
+
export declare function loadConfigFile(path: string): Promise<Result<ConfigFile>>;
|
|
39
|
+
/** Validates already-parsed JSON. Every message names the config file and the offending key. */
|
|
40
|
+
export declare function parseConfig(raw: unknown, path: string): Result<ConfigFile>;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { PRISMA_PROVIDERS } from './emitters/prisma.js';
|
|
4
|
+
import { describeThrown, err, ok } from './result.js';
|
|
5
|
+
/** File names searched for in each directory, in priority order. */
|
|
6
|
+
export const CONFIG_FILE_NAMES = [
|
|
7
|
+
'ormbridge.config.json',
|
|
8
|
+
'.ormbridgerc.json',
|
|
9
|
+
];
|
|
10
|
+
const CONVERSION_KEYS = [
|
|
11
|
+
'name',
|
|
12
|
+
'input',
|
|
13
|
+
'output',
|
|
14
|
+
'from',
|
|
15
|
+
'to',
|
|
16
|
+
'naming',
|
|
17
|
+
'provider',
|
|
18
|
+
'header',
|
|
19
|
+
'appLabel',
|
|
20
|
+
'autoField',
|
|
21
|
+
'namespace',
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Looks for a config file in `startDirectory` and each parent directory. The
|
|
25
|
+
* search stops after the first directory that contains a package.json (the
|
|
26
|
+
* project root) and at the filesystem root. Returns undefined when none exists.
|
|
27
|
+
*/
|
|
28
|
+
export async function findConfigFile(startDirectory) {
|
|
29
|
+
let directory = resolve(startDirectory);
|
|
30
|
+
for (;;) {
|
|
31
|
+
for (const name of CONFIG_FILE_NAMES) {
|
|
32
|
+
const candidate = join(directory, name);
|
|
33
|
+
if (await isFile(candidate)) {
|
|
34
|
+
return candidate;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (await isFile(join(directory, 'package.json'))) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const parent = dirname(directory);
|
|
41
|
+
if (parent === directory) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
directory = parent;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function isFile(path) {
|
|
48
|
+
try {
|
|
49
|
+
return (await stat(path)).isFile();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Reads and validates a JSON config file. Relative paths inside it resolve against its directory. */
|
|
56
|
+
export async function loadConfigFile(path) {
|
|
57
|
+
const absolutePath = resolve(path);
|
|
58
|
+
let text;
|
|
59
|
+
try {
|
|
60
|
+
text = await readFile(absolutePath, 'utf8');
|
|
61
|
+
}
|
|
62
|
+
catch (thrown) {
|
|
63
|
+
return err('INVALID_CONFIG', `Could not read the config file "${absolutePath}": ${describeThrown(thrown)}`);
|
|
64
|
+
}
|
|
65
|
+
let raw;
|
|
66
|
+
try {
|
|
67
|
+
raw = JSON.parse(text);
|
|
68
|
+
}
|
|
69
|
+
catch (thrown) {
|
|
70
|
+
return err('INVALID_CONFIG', `The config file "${absolutePath}" is not valid JSON: ${describeThrown(thrown)}`);
|
|
71
|
+
}
|
|
72
|
+
return parseConfig(raw, absolutePath);
|
|
73
|
+
}
|
|
74
|
+
/** Validates already-parsed JSON. Every message names the config file and the offending key. */
|
|
75
|
+
export function parseConfig(raw, path) {
|
|
76
|
+
const fail = (message) => err('INVALID_CONFIG', `${path}: ${message}`);
|
|
77
|
+
if (!isRecord(raw)) {
|
|
78
|
+
return fail('the config must be a JSON object.');
|
|
79
|
+
}
|
|
80
|
+
const baseDirectory = dirname(path);
|
|
81
|
+
const topLevel = {};
|
|
82
|
+
let rawConversions;
|
|
83
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
84
|
+
if (key === '$schema') {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (key === 'conversions') {
|
|
88
|
+
rawConversions = value;
|
|
89
|
+
}
|
|
90
|
+
else if (key === 'name') {
|
|
91
|
+
return fail('"name" is only valid inside an entry of "conversions", not at the top level.');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
topLevel[key] = value;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const defaults = parseConversion(topLevel, '', baseDirectory);
|
|
98
|
+
if (!defaults.ok) {
|
|
99
|
+
return fail(defaults.error.message);
|
|
100
|
+
}
|
|
101
|
+
const conversions = [];
|
|
102
|
+
if (rawConversions !== undefined) {
|
|
103
|
+
if (!Array.isArray(rawConversions) || rawConversions.length === 0) {
|
|
104
|
+
return fail('"conversions" must be a non-empty array of objects.');
|
|
105
|
+
}
|
|
106
|
+
const names = new Set();
|
|
107
|
+
for (const [index, entry] of rawConversions.entries()) {
|
|
108
|
+
if (!isRecord(entry)) {
|
|
109
|
+
return fail(`"conversions[${index}]" must be an object.`);
|
|
110
|
+
}
|
|
111
|
+
const parsed = parseConversion(entry, `conversions[${index}].`, baseDirectory);
|
|
112
|
+
if (!parsed.ok) {
|
|
113
|
+
return fail(parsed.error.message);
|
|
114
|
+
}
|
|
115
|
+
const name = parsed.value.name;
|
|
116
|
+
if (name !== undefined) {
|
|
117
|
+
if (names.has(name)) {
|
|
118
|
+
return fail(`"conversions[${index}].name" duplicates the name "${name}" used by another conversion.`);
|
|
119
|
+
}
|
|
120
|
+
names.add(name);
|
|
121
|
+
}
|
|
122
|
+
conversions.push(parsed.value);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return ok({ path, defaults: defaults.value, conversions });
|
|
126
|
+
}
|
|
127
|
+
function isRecord(value) {
|
|
128
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
129
|
+
}
|
|
130
|
+
function describeValue(value) {
|
|
131
|
+
return JSON.stringify(value) ?? String(value);
|
|
132
|
+
}
|
|
133
|
+
/** Validates one conversion object. Error messages name the key (with its prefix) and the problem. */
|
|
134
|
+
function parseConversion(raw, prefix, baseDirectory) {
|
|
135
|
+
const fail = (key, problem) => err('INVALID_CONFIG', `"${prefix}${key}" ${problem}`);
|
|
136
|
+
const config = {};
|
|
137
|
+
for (const key of Object.keys(raw)) {
|
|
138
|
+
if (!CONVERSION_KEYS.includes(key)) {
|
|
139
|
+
const valid = CONVERSION_KEYS.filter((candidate) => prefix !== '' || candidate !== 'name');
|
|
140
|
+
if (prefix === '') {
|
|
141
|
+
valid.push('conversions');
|
|
142
|
+
}
|
|
143
|
+
return err('INVALID_CONFIG', `unknown key "${prefix}${key}". Valid keys: ${valid.join(', ')}.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const key of ['name', 'from', 'to', 'appLabel', 'namespace']) {
|
|
147
|
+
const value = raw[key];
|
|
148
|
+
if (value === undefined) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
152
|
+
return fail(key, `must be a non-empty string (got ${describeValue(value)}).`);
|
|
153
|
+
}
|
|
154
|
+
config[key] = value;
|
|
155
|
+
}
|
|
156
|
+
const output = raw['output'];
|
|
157
|
+
if (output !== undefined) {
|
|
158
|
+
if (typeof output !== 'string' || output.trim() === '') {
|
|
159
|
+
return fail('output', `must be a non-empty path string (got ${describeValue(output)}).`);
|
|
160
|
+
}
|
|
161
|
+
config.output = resolve(baseDirectory, output);
|
|
162
|
+
}
|
|
163
|
+
const input = raw['input'];
|
|
164
|
+
if (input !== undefined) {
|
|
165
|
+
const entries = Array.isArray(input) ? input : [input];
|
|
166
|
+
if (entries.length === 0 ||
|
|
167
|
+
entries.some((entry) => typeof entry !== 'string' || entry === '')) {
|
|
168
|
+
return fail('input', `must be a path string or a non-empty array of path strings (got ${describeValue(input)}).`);
|
|
169
|
+
}
|
|
170
|
+
config.input = entries.map((entry) => resolve(baseDirectory, entry));
|
|
171
|
+
}
|
|
172
|
+
const naming = raw['naming'];
|
|
173
|
+
if (naming !== undefined) {
|
|
174
|
+
if (naming !== 'preserve' && naming !== 'normalize') {
|
|
175
|
+
return fail('naming', `must be "preserve" or "normalize" (got ${describeValue(naming)}).`);
|
|
176
|
+
}
|
|
177
|
+
config.naming = naming;
|
|
178
|
+
}
|
|
179
|
+
const provider = raw['provider'];
|
|
180
|
+
if (provider !== undefined) {
|
|
181
|
+
if (typeof provider !== 'string' ||
|
|
182
|
+
!PRISMA_PROVIDERS.includes(provider)) {
|
|
183
|
+
return fail('provider', `must be one of ${PRISMA_PROVIDERS.join(', ')} (got ${describeValue(provider)}).`);
|
|
184
|
+
}
|
|
185
|
+
config.provider = provider;
|
|
186
|
+
}
|
|
187
|
+
const header = raw['header'];
|
|
188
|
+
if (header !== undefined) {
|
|
189
|
+
if (typeof header !== 'boolean') {
|
|
190
|
+
return fail('header', `must be true or false (got ${describeValue(header)}).`);
|
|
191
|
+
}
|
|
192
|
+
config.header = header;
|
|
193
|
+
}
|
|
194
|
+
const autoField = raw['autoField'];
|
|
195
|
+
if (autoField !== undefined) {
|
|
196
|
+
const lowered = typeof autoField === 'string' ? autoField.toLowerCase() : undefined;
|
|
197
|
+
if (lowered !== 'int' && lowered !== 'bigint') {
|
|
198
|
+
return fail('autoField', `must be "int" or "bigint" (got ${describeValue(autoField)}).`);
|
|
199
|
+
}
|
|
200
|
+
config.autoField = lowered;
|
|
201
|
+
}
|
|
202
|
+
return ok(config);
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,E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AAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAED,MAAM,MAAM,GAAY,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,IAAI,OAAO,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CACT,QAAQ,EACR,8BAA8B,aAAa,CAAC,MAAM,CAAC,IAAI,CACxD,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,MAAM,SAAS,GAAY,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,OAAO,GACX,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACtE,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9C,OAAO,IAAI,CACT,WAAW,EACX,kCAAkC,aAAa,CAAC,SAAS,CAAC,IAAI,CAC/D,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DEFAULT_APP_LABEL, type FormatName, type FormatOptions, type SourceText } from './formats.js';
|
|
2
|
+
import { type Result } from './result.js';
|
|
3
|
+
export { DEFAULT_APP_LABEL };
|
|
4
|
+
export type { FormatName, SourceText };
|
|
5
|
+
/** Names of the built-in formats. Use listFormatNames() for the live registry contents. */
|
|
6
|
+
export declare const FORMAT_NAMES: readonly FormatName[];
|
|
7
|
+
export interface ConvertOptions extends FormatOptions {
|
|
8
|
+
from: FormatName;
|
|
9
|
+
to: FormatName;
|
|
10
|
+
}
|
|
11
|
+
export interface ConvertResult {
|
|
12
|
+
/** The converted text. Empty when the emitter produced several files; see `files`. */
|
|
13
|
+
output: string;
|
|
14
|
+
/** Relative path to file text, present only when the emitter produced several files. */
|
|
15
|
+
files?: Record<string, string>;
|
|
16
|
+
warnings: string[];
|
|
17
|
+
modelCount: number;
|
|
18
|
+
}
|
|
19
|
+
/** Converts in-memory source text from one ORM format to another. */
|
|
20
|
+
export declare function convertText(sources: SourceText[], options: ConvertOptions): Promise<Result<ConvertResult>>;
|