@drzl/cli 0.0.1
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 +202 -0
- package/README.md +34 -0
- package/dist/cli.cjs +442 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +418 -0
- package/dist/cli.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# @drzl/cli
|
|
4
|
+
|
|
5
|
+
Analyze your Drizzle schema and generate validation, services, and routers.
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
- Init: `drzl init`
|
|
12
|
+
- Analyze: `drzl analyze <schema.ts> [--relations] [--validate]`
|
|
13
|
+
- Generate: `drzl generate -c drzl.config.ts`
|
|
14
|
+
- Watch: `drzl watch -c drzl.config.ts`
|
|
15
|
+
|
|
16
|
+
## Minimal config
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { defineConfig } from '@drzl/cli/config'
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
schema: 'src/db/schemas/index.ts',
|
|
23
|
+
outDir: 'src/api',
|
|
24
|
+
generators: [
|
|
25
|
+
{ kind: 'zod', path: 'src/validators/zod' },
|
|
26
|
+
{ kind: 'service', path: 'src/services', dataAccess: 'drizzle' },
|
|
27
|
+
{ kind: 'orpc', template: '@drzl/template-orpc-service' },
|
|
28
|
+
],
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Notes
|
|
33
|
+
|
|
34
|
+
- `format.engine: 'auto'` tries Prettier, then Biome.
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/cli.ts
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
29
|
+
var import_ora = __toESM(require("ora"), 1);
|
|
30
|
+
var import_cli_progress = __toESM(require("cli-progress"), 1);
|
|
31
|
+
|
|
32
|
+
// src/config.ts
|
|
33
|
+
var import_zod = require("zod");
|
|
34
|
+
var import_meta = {};
|
|
35
|
+
var NamingSchema = import_zod.z.object({
|
|
36
|
+
routerSuffix: import_zod.z.string().default("Router"),
|
|
37
|
+
procedureCase: import_zod.z.enum(["camel", "kebab", "snake"]).default("camel")
|
|
38
|
+
}).partial();
|
|
39
|
+
var GeneratorSchema = import_zod.z.object({
|
|
40
|
+
kind: import_zod.z.enum(["orpc", "service", "zod", "valibot", "arktype"]),
|
|
41
|
+
template: import_zod.z.string().optional(),
|
|
42
|
+
includeRelations: import_zod.z.boolean().optional(),
|
|
43
|
+
naming: NamingSchema.optional(),
|
|
44
|
+
outputHeader: import_zod.z.object({
|
|
45
|
+
enabled: import_zod.z.boolean().default(true).optional(),
|
|
46
|
+
text: import_zod.z.string().optional()
|
|
47
|
+
}).optional(),
|
|
48
|
+
format: import_zod.z.object({
|
|
49
|
+
enabled: import_zod.z.boolean().default(true).optional(),
|
|
50
|
+
engine: import_zod.z.enum(["auto", "prettier", "biome"]).default("auto").optional(),
|
|
51
|
+
configPath: import_zod.z.string().optional()
|
|
52
|
+
}).optional(),
|
|
53
|
+
// service generator specific options
|
|
54
|
+
path: import_zod.z.string().optional(),
|
|
55
|
+
dataAccess: import_zod.z.enum(["stub", "drizzle"]).default("stub").optional(),
|
|
56
|
+
dbImportPath: import_zod.z.string().optional(),
|
|
57
|
+
schemaImportPath: import_zod.z.string().optional(),
|
|
58
|
+
// zod generator specific options
|
|
59
|
+
schemaSuffix: import_zod.z.string().optional(),
|
|
60
|
+
fileSuffix: import_zod.z.string().optional(),
|
|
61
|
+
// orpc validation sharing
|
|
62
|
+
validation: import_zod.z.object({
|
|
63
|
+
useShared: import_zod.z.boolean().default(false).optional(),
|
|
64
|
+
library: import_zod.z.enum(["zod", "valibot", "arktype"]).default("zod").optional(),
|
|
65
|
+
importPath: import_zod.z.string().optional(),
|
|
66
|
+
schemaSuffix: import_zod.z.string().optional()
|
|
67
|
+
}).optional(),
|
|
68
|
+
// template options
|
|
69
|
+
templateOptions: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional()
|
|
70
|
+
});
|
|
71
|
+
var ConfigSchema = import_zod.z.object({
|
|
72
|
+
schema: import_zod.z.string(),
|
|
73
|
+
outDir: import_zod.z.string().default("src/api"),
|
|
74
|
+
analyzer: import_zod.z.object({
|
|
75
|
+
includeRelations: import_zod.z.boolean().default(true),
|
|
76
|
+
validateConstraints: import_zod.z.boolean().default(true),
|
|
77
|
+
includeHeuristicRelations: import_zod.z.boolean().default(false)
|
|
78
|
+
}).default({
|
|
79
|
+
includeRelations: true,
|
|
80
|
+
validateConstraints: true,
|
|
81
|
+
includeHeuristicRelations: false
|
|
82
|
+
}),
|
|
83
|
+
generators: import_zod.z.array(GeneratorSchema).min(1).default([{ kind: "orpc" }])
|
|
84
|
+
});
|
|
85
|
+
async function loadConfig(customPath) {
|
|
86
|
+
const path = await import("path");
|
|
87
|
+
const fs = await import("fs/promises");
|
|
88
|
+
const candidates = customPath ? [customPath] : ["drzl.config.ts", "drzl.config.mjs", "drzl.config.js"];
|
|
89
|
+
for (const c of candidates) {
|
|
90
|
+
const p = path.resolve(process.cwd(), c);
|
|
91
|
+
try {
|
|
92
|
+
await fs.access(p);
|
|
93
|
+
} catch {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (/\.json$/i.test(p)) {
|
|
97
|
+
try {
|
|
98
|
+
const content = await fs.readFile(p, "utf8");
|
|
99
|
+
const raw = JSON.parse(content);
|
|
100
|
+
const parsed = ConfigSchema.parse(raw);
|
|
101
|
+
return parsed;
|
|
102
|
+
} catch (e2) {
|
|
103
|
+
throw new Error(`Failed to load config from ${p}: ${String(e2)}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const { default: jiti } = await import("jiti");
|
|
108
|
+
const jit = jiti(import_meta.url);
|
|
109
|
+
const mod = jit(p);
|
|
110
|
+
const raw = mod && typeof mod === "object" && "default" in mod ? mod.default : mod;
|
|
111
|
+
const parsed = ConfigSchema.safeParse(raw);
|
|
112
|
+
if (!parsed.success) {
|
|
113
|
+
throw new Error(parsed.error.message);
|
|
114
|
+
}
|
|
115
|
+
return parsed.data;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
try {
|
|
118
|
+
const content = await fs.readFile(p, "utf8");
|
|
119
|
+
const raw = JSON.parse(content);
|
|
120
|
+
const parsed = ConfigSchema.parse(raw);
|
|
121
|
+
return parsed;
|
|
122
|
+
} catch (e2) {
|
|
123
|
+
throw new Error(`Failed to load config from ${p}: ${String(e2)}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/cli.ts
|
|
131
|
+
var import_analyzer = require("@drzl/analyzer");
|
|
132
|
+
var import_generator_orpc = require("@drzl/generator-orpc");
|
|
133
|
+
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
134
|
+
var program = new import_commander.Command();
|
|
135
|
+
program.name("drzl").description("DRZL - Drizzle Developer Toolkit").version("0.0.1");
|
|
136
|
+
program.command("analyze").argument("<schema>", "path to drizzle schema (TS)").option("--relations", "include relations", true).option("--validate", "validate constraints", true).option("--out <file>", "write analysis JSON to file").option("--json", "print JSON to stdout (overrides --out)", false).action(async (schema, opts) => {
|
|
137
|
+
try {
|
|
138
|
+
const analyzer = new import_analyzer.SchemaAnalyzer(schema);
|
|
139
|
+
const spinner = !opts.json ? (0, import_ora.default)("Analyzing schema...").start() : null;
|
|
140
|
+
const start = Date.now();
|
|
141
|
+
const res = await analyzer.analyze({
|
|
142
|
+
includeRelations: !!opts.relations,
|
|
143
|
+
validateConstraints: !!opts.validate
|
|
144
|
+
});
|
|
145
|
+
const ms = Date.now() - start;
|
|
146
|
+
const json = JSON.stringify(res, null, 2);
|
|
147
|
+
if (opts.json) {
|
|
148
|
+
console.log(json);
|
|
149
|
+
} else if (opts.out) {
|
|
150
|
+
const fs = await import("fs/promises");
|
|
151
|
+
await fs.writeFile(opts.out, json, "utf8");
|
|
152
|
+
spinner?.succeed(import_chalk.default.green(`Analysis written to ${opts.out} in ${ms}ms`));
|
|
153
|
+
} else {
|
|
154
|
+
spinner?.succeed(import_chalk.default.green(`Analyzed in ${ms}ms`));
|
|
155
|
+
console.log(json);
|
|
156
|
+
}
|
|
157
|
+
process.exit(res.issues.some((i) => i.level === "error") ? 2 : 0);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
const msg = e?.message ?? String(e);
|
|
160
|
+
if (opts.json)
|
|
161
|
+
console.log(JSON.stringify({ event: "error", code: "DRZL_CLI_ANALYZE", message: msg }));
|
|
162
|
+
else
|
|
163
|
+
console.error(
|
|
164
|
+
import_chalk.default.red("Analyze failed (DRZL_CLI_ANALYZE):"),
|
|
165
|
+
msg,
|
|
166
|
+
"\nTip: run with --json for structured output."
|
|
167
|
+
);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
program.command("generate").description("Run configured generators (drzl.config.*)").option("-c, --config <path>", "path to drzl.config").action(async (opts) => {
|
|
172
|
+
try {
|
|
173
|
+
const cfg = await loadConfig(opts.config);
|
|
174
|
+
if (!cfg) {
|
|
175
|
+
console.error(
|
|
176
|
+
import_chalk.default.red("No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.")
|
|
177
|
+
);
|
|
178
|
+
process.exit(2);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const analyzer = new import_analyzer.SchemaAnalyzer(cfg.schema);
|
|
182
|
+
const spinner = (0, import_ora.default)("Analyzing...").start();
|
|
183
|
+
const t0 = Date.now();
|
|
184
|
+
const analysis = await analyzer.analyze({
|
|
185
|
+
includeRelations: cfg.analyzer.includeRelations,
|
|
186
|
+
validateConstraints: cfg.analyzer.validateConstraints,
|
|
187
|
+
includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations
|
|
188
|
+
});
|
|
189
|
+
spinner.succeed(`Analysis complete in ${Date.now() - t0}ms`);
|
|
190
|
+
const progress = new import_cli_progress.default.SingleBar(
|
|
191
|
+
{ hideCursor: true },
|
|
192
|
+
import_cli_progress.default.Presets.shades_classic
|
|
193
|
+
);
|
|
194
|
+
const total = analysis.tables.length || 1;
|
|
195
|
+
progress.start(total, 0);
|
|
196
|
+
for (const g of cfg.generators) {
|
|
197
|
+
if (g.kind === "orpc") {
|
|
198
|
+
const gen = new import_generator_orpc.ORPCGenerator(analysis);
|
|
199
|
+
const { files } = await gen.generate({
|
|
200
|
+
outputDir: cfg.outDir,
|
|
201
|
+
template: g.template,
|
|
202
|
+
includeRelations: g.includeRelations,
|
|
203
|
+
naming: g.naming,
|
|
204
|
+
outputHeader: g.outputHeader,
|
|
205
|
+
format: g.format,
|
|
206
|
+
templateOptions: g.templateOptions,
|
|
207
|
+
validation: g.validation,
|
|
208
|
+
onProgress: ({ index }) => progress.update(index)
|
|
209
|
+
});
|
|
210
|
+
progress.stop();
|
|
211
|
+
(0, import_ora.default)().succeed(import_chalk.default.green(`Generated (${g.kind}): ${files.length} files`));
|
|
212
|
+
files.forEach((f) => console.log(" -", import_chalk.default.cyan(f)));
|
|
213
|
+
} else if (g.kind === "service") {
|
|
214
|
+
try {
|
|
215
|
+
const { ServiceGenerator } = await import("@drzl/generator-service");
|
|
216
|
+
const gen = new ServiceGenerator(analysis);
|
|
217
|
+
const target = g.path ?? "src/services";
|
|
218
|
+
const files = await gen.generate({
|
|
219
|
+
outDir: target,
|
|
220
|
+
outputHeader: g.outputHeader,
|
|
221
|
+
format: g.format,
|
|
222
|
+
dataAccess: g.dataAccess,
|
|
223
|
+
dbImportPath: g.dbImportPath,
|
|
224
|
+
schemaImportPath: g.schemaImportPath
|
|
225
|
+
});
|
|
226
|
+
progress.stop();
|
|
227
|
+
(0, import_ora.default)().succeed(import_chalk.default.green(`Generated (service): ${files.length} files`));
|
|
228
|
+
files.forEach((f) => console.log(" -", import_chalk.default.cyan(f)));
|
|
229
|
+
} catch (e) {
|
|
230
|
+
progress.stop();
|
|
231
|
+
console.error(
|
|
232
|
+
import_chalk.default.red("Service generator missing (install @drzl/generator-service)?"),
|
|
233
|
+
e?.message ?? e
|
|
234
|
+
);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
}
|
|
237
|
+
} else if (g.kind === "zod") {
|
|
238
|
+
try {
|
|
239
|
+
const { ZodGenerator } = await import("@drzl/generator-zod");
|
|
240
|
+
const gen = new ZodGenerator(analysis);
|
|
241
|
+
const target = g.path ?? "src/validators/zod";
|
|
242
|
+
const files = await gen.generate({
|
|
243
|
+
outDir: target,
|
|
244
|
+
outputHeader: g.outputHeader,
|
|
245
|
+
format: g.format,
|
|
246
|
+
schemaSuffix: g.schemaSuffix,
|
|
247
|
+
fileSuffix: g.fileSuffix
|
|
248
|
+
});
|
|
249
|
+
progress.stop();
|
|
250
|
+
(0, import_ora.default)().succeed(import_chalk.default.green(`Generated (zod): ${files.length} files`));
|
|
251
|
+
files.forEach((f) => console.log(" -", import_chalk.default.cyan(f)));
|
|
252
|
+
} catch (e) {
|
|
253
|
+
progress.stop();
|
|
254
|
+
console.error(
|
|
255
|
+
import_chalk.default.red("Zod generator missing (install @drzl/generator-zod)?"),
|
|
256
|
+
e?.message ?? e
|
|
257
|
+
);
|
|
258
|
+
process.exit(1);
|
|
259
|
+
}
|
|
260
|
+
} else if (g.kind === "valibot") {
|
|
261
|
+
try {
|
|
262
|
+
const { ValibotGenerator } = await import("@drzl/generator-valibot");
|
|
263
|
+
const gen = new ValibotGenerator(analysis);
|
|
264
|
+
const target = g.path ?? "src/validators/valibot";
|
|
265
|
+
const files = await gen.generate({
|
|
266
|
+
outDir: target,
|
|
267
|
+
outputHeader: g.outputHeader,
|
|
268
|
+
format: g.format,
|
|
269
|
+
schemaSuffix: g.schemaSuffix,
|
|
270
|
+
fileSuffix: g.fileSuffix
|
|
271
|
+
});
|
|
272
|
+
progress.stop();
|
|
273
|
+
(0, import_ora.default)().succeed(import_chalk.default.green(`Generated (valibot): ${files.length} files`));
|
|
274
|
+
files.forEach((f) => console.log(" -", import_chalk.default.cyan(f)));
|
|
275
|
+
} catch (e) {
|
|
276
|
+
progress.stop();
|
|
277
|
+
console.error(
|
|
278
|
+
import_chalk.default.red("Valibot generator missing (install @drzl/generator-valibot)?"),
|
|
279
|
+
e?.message ?? e
|
|
280
|
+
);
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
} else if (g.kind === "arktype") {
|
|
284
|
+
try {
|
|
285
|
+
const { ArkTypeGenerator } = await import("@drzl/generator-arktype");
|
|
286
|
+
const gen = new ArkTypeGenerator(analysis);
|
|
287
|
+
const target = g.path ?? "src/validators/arktype";
|
|
288
|
+
const files = await gen.generate({
|
|
289
|
+
outDir: target,
|
|
290
|
+
outputHeader: g.outputHeader,
|
|
291
|
+
format: g.format,
|
|
292
|
+
schemaSuffix: g.schemaSuffix,
|
|
293
|
+
fileSuffix: g.fileSuffix
|
|
294
|
+
});
|
|
295
|
+
progress.stop();
|
|
296
|
+
(0, import_ora.default)().succeed(import_chalk.default.green(`Generated (arktype): ${files.length} files`));
|
|
297
|
+
files.forEach((f) => console.log(" -", import_chalk.default.cyan(f)));
|
|
298
|
+
} catch (e) {
|
|
299
|
+
progress.stop();
|
|
300
|
+
console.error(
|
|
301
|
+
import_chalk.default.red("ArkType generator missing (install @drzl/generator-arktype)?"),
|
|
302
|
+
e?.message ?? e
|
|
303
|
+
);
|
|
304
|
+
process.exit(1);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
} catch (e) {
|
|
309
|
+
console.error(
|
|
310
|
+
import_chalk.default.red("Generate failed (DRZL_GEN_001):"),
|
|
311
|
+
e?.message ?? e,
|
|
312
|
+
"\nTip: check your drzl.config.ts and template path."
|
|
313
|
+
);
|
|
314
|
+
process.exit(1);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
program.command("generate:orpc").argument("<schema>", "path to drizzle schema (TS)").option("-o, --outDir <dir>", "output directory", "src/api").option("--template <name>", "template name", "standard").option("--includeRelations", "include relation endpoints").action(async (schema, opts) => {
|
|
318
|
+
try {
|
|
319
|
+
const analyzer = new import_analyzer.SchemaAnalyzer(schema);
|
|
320
|
+
const analysis = await analyzer.analyze({
|
|
321
|
+
includeRelations: !!opts.includeRelations,
|
|
322
|
+
validateConstraints: true
|
|
323
|
+
});
|
|
324
|
+
const gen = new import_generator_orpc.ORPCGenerator(analysis);
|
|
325
|
+
const { files } = await gen.generate({
|
|
326
|
+
outputDir: opts.outDir,
|
|
327
|
+
template: opts.template,
|
|
328
|
+
includeRelations: !!opts.includeRelations
|
|
329
|
+
});
|
|
330
|
+
console.log(import_chalk.default.green(`Generated:`), files.map((f) => import_chalk.default.cyan(f)).join(", "));
|
|
331
|
+
} catch (e) {
|
|
332
|
+
console.error(import_chalk.default.red("Generate orpc failed:"), e?.message ?? e);
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
program.command("watch").description("Watch schema and regenerate on changes").option("-c, --config <path>", "path to drzl.config").option("--pipeline <name>", "all | analyze | generate-orpc", "all").option("--debounce <ms>", "debounce ms", "200").option("--json", "emit JSON logs", false).action(async (opts) => {
|
|
337
|
+
const cfg = await loadConfig(opts.config);
|
|
338
|
+
if (!cfg) {
|
|
339
|
+
console.error(import_chalk.default.red("No config found. Create drzl.config.ts or pass --config."));
|
|
340
|
+
process.exit(2);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
let lastFiles = [];
|
|
344
|
+
const run = async () => {
|
|
345
|
+
try {
|
|
346
|
+
if (!opts.json) console.clear();
|
|
347
|
+
const analyzer = new import_analyzer.SchemaAnalyzer(cfg.schema);
|
|
348
|
+
const analysis = await analyzer.analyze({
|
|
349
|
+
includeRelations: cfg.analyzer.includeRelations,
|
|
350
|
+
validateConstraints: cfg.analyzer.validateConstraints
|
|
351
|
+
});
|
|
352
|
+
if (opts.pipeline === "analyze") {
|
|
353
|
+
if (opts.json) {
|
|
354
|
+
console.log(
|
|
355
|
+
JSON.stringify({
|
|
356
|
+
event: "analyze_complete",
|
|
357
|
+
issues: analysis.issues,
|
|
358
|
+
tables: analysis.tables.length
|
|
359
|
+
})
|
|
360
|
+
);
|
|
361
|
+
} else {
|
|
362
|
+
console.log(import_chalk.default.green("Analyze complete."));
|
|
363
|
+
}
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const newFiles = [];
|
|
367
|
+
for (const g of cfg.generators) {
|
|
368
|
+
if (g.kind === "orpc" && (opts.pipeline === "all" || opts.pipeline === "generate-orpc")) {
|
|
369
|
+
const gen = new import_generator_orpc.ORPCGenerator(analysis);
|
|
370
|
+
const { files } = await gen.generate({
|
|
371
|
+
outputDir: cfg.outDir,
|
|
372
|
+
template: g.template,
|
|
373
|
+
includeRelations: g.includeRelations,
|
|
374
|
+
naming: g.naming
|
|
375
|
+
});
|
|
376
|
+
if (opts.json) {
|
|
377
|
+
console.log(JSON.stringify({ event: "generate_complete", kind: g.kind, files }));
|
|
378
|
+
} else {
|
|
379
|
+
console.log(
|
|
380
|
+
import_chalk.default.green(`Generated (${g.kind}):`),
|
|
381
|
+
files.map((f) => import_chalk.default.cyan(f)).join(", ")
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
newFiles.push(...files);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const added = newFiles.filter((f) => !lastFiles.includes(f));
|
|
388
|
+
const removed = lastFiles.filter((f) => !newFiles.includes(f));
|
|
389
|
+
if (opts.json) {
|
|
390
|
+
console.log(JSON.stringify({ event: "diff", added, removed }));
|
|
391
|
+
} else {
|
|
392
|
+
if (added.length) console.log(import_chalk.default.blue(`Added: ${added.join(", ")}`));
|
|
393
|
+
if (removed.length) console.log(import_chalk.default.yellow(`Removed: ${removed.join(", ")}`));
|
|
394
|
+
}
|
|
395
|
+
lastFiles = newFiles;
|
|
396
|
+
} catch (e) {
|
|
397
|
+
if (opts.json)
|
|
398
|
+
console.log(JSON.stringify({ event: "error", message: String(e?.message ?? e) }));
|
|
399
|
+
else console.error(import_chalk.default.red("Watch pipeline failed:"), e?.message ?? e);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const debounced = Number(opts.debounce) || 200;
|
|
403
|
+
let timer = null;
|
|
404
|
+
const trigger = (file) => {
|
|
405
|
+
if (file && file.startsWith(cfg.outDir)) return;
|
|
406
|
+
clearTimeout(timer);
|
|
407
|
+
timer = setTimeout(run, debounced);
|
|
408
|
+
};
|
|
409
|
+
console.log(import_chalk.default.gray("Watching for changes..."));
|
|
410
|
+
const watchSet = /* @__PURE__ */ new Set([cfg.schema]);
|
|
411
|
+
for (const g of cfg.generators) {
|
|
412
|
+
if (g.template && g.template !== "standard" && g.template !== "minimal") {
|
|
413
|
+
watchSet.add(g.template);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
watchSet.add(cfg.outDir);
|
|
417
|
+
import_chokidar.default.watch(Array.from(watchSet), { ignoreInitial: true }).on("add", (p) => trigger(p)).on("change", (p) => trigger(p)).on("unlink", (p) => trigger(p));
|
|
418
|
+
await run();
|
|
419
|
+
});
|
|
420
|
+
program.command("init").description("Scaffold a drzl.config.ts").option("-y, --yes", "accept defaults").action(async (_opts) => {
|
|
421
|
+
const fs = await import("fs/promises");
|
|
422
|
+
const path = await import("path");
|
|
423
|
+
const target = path.resolve(process.cwd(), "drzl.config.ts");
|
|
424
|
+
const template = `export default {
|
|
425
|
+
schema: 'src/db/schema.ts',
|
|
426
|
+
outDir: 'src/api',
|
|
427
|
+
analyzer: { includeRelations: true, validateConstraints: true },
|
|
428
|
+
generators: [
|
|
429
|
+
{ kind: 'orpc', template: 'standard', includeRelations: true }
|
|
430
|
+
]
|
|
431
|
+
} as const
|
|
432
|
+
`;
|
|
433
|
+
try {
|
|
434
|
+
await fs.writeFile(target, template, { flag: "wx" });
|
|
435
|
+
console.log(import_chalk.default.green(`Created ${target}`));
|
|
436
|
+
} catch (e) {
|
|
437
|
+
console.error(import_chalk.default.red("Init failed:"), e?.message ?? e);
|
|
438
|
+
process.exit(1);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
program.parseAsync(process.argv);
|
|
442
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/config.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport cliProgress from 'cli-progress';\nimport { loadConfig } from './config.js';\nimport { SchemaAnalyzer } from '@drzl/analyzer';\nimport { ORPCGenerator } from '@drzl/generator-orpc';\nimport chokidar from 'chokidar';\n\nconst program = new Command();\nprogram.name('drzl').description('DRZL - Drizzle Developer Toolkit').version('0.0.1');\n\nprogram\n .command('analyze')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('--relations', 'include relations', true)\n .option('--validate', 'validate constraints', true)\n .option('--out <file>', 'write analysis JSON to file')\n .option('--json', 'print JSON to stdout (overrides --out)', false)\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const spinner = !opts.json ? ora('Analyzing schema...').start() : null;\n const start = Date.now();\n const res = await analyzer.analyze({\n includeRelations: !!opts.relations,\n validateConstraints: !!opts.validate,\n });\n const ms = Date.now() - start;\n const json = JSON.stringify(res, null, 2);\n if (opts.json) {\n console.log(json);\n } else if (opts.out) {\n const fs = await import('node:fs/promises');\n await fs.writeFile(opts.out, json, 'utf8');\n spinner?.succeed(chalk.green(`Analysis written to ${opts.out} in ${ms}ms`));\n } else {\n spinner?.succeed(chalk.green(`Analyzed in ${ms}ms`));\n console.log(json);\n }\n process.exit(res.issues.some((i) => i.level === 'error') ? 2 : 0);\n } catch (e: any) {\n const msg = e?.message ?? String(e);\n if (opts.json)\n console.log(JSON.stringify({ event: 'error', code: 'DRZL_CLI_ANALYZE', message: msg }));\n else\n console.error(\n chalk.red('Analyze failed (DRZL_CLI_ANALYZE):'),\n msg,\n '\\nTip: run with --json for structured output.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate')\n .description('Run configured generators (drzl.config.*)')\n .option('-c, --config <path>', 'path to drzl.config')\n .action(async (opts: any) => {\n try {\n const cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(\n chalk.red('No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.')\n );\n process.exit(2);\n return;\n }\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const spinner = ora('Analyzing...').start();\n const t0 = Date.now();\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations,\n });\n spinner.succeed(`Analysis complete in ${Date.now() - t0}ms`);\n const progress = new cliProgress.SingleBar(\n { hideCursor: true },\n cliProgress.Presets.shades_classic\n );\n const total = analysis.tables.length || 1;\n progress.start(total, 0);\n for (const g of cfg.generators) {\n if (g.kind === 'orpc') {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n templateOptions: g.templateOptions,\n validation: g.validation,\n onProgress: ({ index }) => progress.update(index),\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (${g.kind}): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await import('@drzl/generator-service');\n const gen = new ServiceGenerator(analysis);\n const target = g.path ?? 'src/services';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n dataAccess: g.dataAccess,\n dbImportPath: g.dbImportPath,\n schemaImportPath: g.schemaImportPath,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (service): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Service generator missing (install @drzl/generator-service)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await import('@drzl/generator-zod');\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (zod): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Zod generator missing (install @drzl/generator-zod)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await import('@drzl/generator-valibot');\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (valibot): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Valibot generator missing (install @drzl/generator-valibot)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await import('@drzl/generator-arktype');\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (arktype): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('ArkType generator missing (install @drzl/generator-arktype)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n }\n }\n } catch (e: any) {\n console.error(\n chalk.red('Generate failed (DRZL_GEN_001):'),\n e?.message ?? e,\n '\\nTip: check your drzl.config.ts and template path.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:orpc')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('-o, --outDir <dir>', 'output directory', 'src/api')\n .option('--template <name>', 'template name', 'standard')\n .option('--includeRelations', 'include relation endpoints')\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const analysis = await analyzer.analyze({\n includeRelations: !!opts.includeRelations,\n validateConstraints: true,\n });\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: opts.outDir,\n template: opts.template,\n includeRelations: !!opts.includeRelations,\n });\n console.log(chalk.green(`Generated:`), files.map((f) => chalk.cyan(f)).join(', '));\n } catch (e: any) {\n console.error(chalk.red('Generate orpc failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\nprogram\n .command('watch')\n .description('Watch schema and regenerate on changes')\n .option('-c, --config <path>', 'path to drzl.config')\n .option('--pipeline <name>', 'all | analyze | generate-orpc', 'all')\n .option('--debounce <ms>', 'debounce ms', '200')\n .option('--json', 'emit JSON logs', false)\n .action(async (opts: any) => {\n const cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(chalk.red('No config found. Create drzl.config.ts or pass --config.'));\n process.exit(2);\n return;\n }\n let lastFiles: string[] = [];\n const run = async () => {\n try {\n if (!opts.json) console.clear();\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n });\n if (opts.pipeline === 'analyze') {\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'analyze_complete',\n issues: analysis.issues,\n tables: analysis.tables.length,\n })\n );\n } else {\n console.log(chalk.green('Analyze complete.'));\n }\n return;\n }\n const newFiles: string[] = [];\n for (const g of cfg.generators) {\n if (g.kind === 'orpc' && (opts.pipeline === 'all' || opts.pipeline === 'generate-orpc')) {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n });\n if (opts.json) {\n console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }));\n } else {\n console.log(\n chalk.green(`Generated (${g.kind}):`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n }\n newFiles.push(...files);\n }\n }\n // Diff\n const added = newFiles.filter((f) => !lastFiles.includes(f));\n const removed = lastFiles.filter((f) => !newFiles.includes(f));\n if (opts.json) {\n console.log(JSON.stringify({ event: 'diff', added, removed }));\n } else {\n if (added.length) console.log(chalk.blue(`Added: ${added.join(', ')}`));\n if (removed.length) console.log(chalk.yellow(`Removed: ${removed.join(', ')}`));\n }\n lastFiles = newFiles;\n } catch (e: any) {\n if (opts.json)\n console.log(JSON.stringify({ event: 'error', message: String(e?.message ?? e) }));\n else console.error(chalk.red('Watch pipeline failed:'), e?.message ?? e);\n }\n };\n const debounced = Number(opts.debounce) || 200;\n let timer: any = null;\n const trigger = (file?: string) => {\n // Ignore changes in outDir to avoid loops\n if (file && file.startsWith(cfg.outDir)) return;\n clearTimeout(timer);\n timer = setTimeout(run, debounced);\n };\n console.log(chalk.gray('Watching for changes...'));\n const watchSet = new Set<string>([cfg.schema]);\n // Watch template paths (only when path-like and exists)\n for (const g of cfg.generators) {\n if (g.template && g.template !== 'standard' && g.template !== 'minimal') {\n watchSet.add(g.template);\n }\n }\n // Also watch outDir but ignore events from it to report diffs cleanly\n watchSet.add(cfg.outDir);\n chokidar\n .watch(Array.from(watchSet), { ignoreInitial: true })\n .on('add', (p) => trigger(p))\n .on('change', (p) => trigger(p))\n .on('unlink', (p) => trigger(p));\n await run();\n });\n\nprogram\n .command('init')\n .description('Scaffold a drzl.config.ts')\n .option('-y, --yes', 'accept defaults')\n .action(async (_opts: any) => {\n const fs = await import('node:fs/promises');\n const path = await import('node:path');\n const target = path.resolve(process.cwd(), 'drzl.config.ts');\n const template = `export default {\n schema: 'src/db/schema.ts',\n outDir: 'src/api',\n analyzer: { includeRelations: true, validateConstraints: true },\n generators: [\n { kind: 'orpc', template: 'standard', includeRelations: true }\n ]\n} as const\\n`;\n try {\n await fs.writeFile(target, template, { flag: 'wx' });\n console.log(chalk.green(`Created ${target}`));\n } catch (e: any) {\n console.error(chalk.red('Init failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\nprogram.parseAsync(process.argv);\n","import { z } from 'zod';\n\nexport const NamingSchema = z\n .object({\n routerSuffix: z.string().default('Router'),\n procedureCase: z.enum(['camel', 'kebab', 'snake']).default('camel'),\n })\n .partial();\n\nexport const GeneratorSchema = z.object({\n kind: z.enum(['orpc', 'service', 'zod', 'valibot', 'arktype']),\n template: z.string().optional(),\n includeRelations: z.boolean().optional(),\n naming: NamingSchema.optional(),\n outputHeader: z\n .object({\n enabled: z.boolean().default(true).optional(),\n text: z.string().optional(),\n })\n .optional(),\n format: z\n .object({\n enabled: z.boolean().default(true).optional(),\n engine: z.enum(['auto', 'prettier', 'biome']).default('auto').optional(),\n configPath: z.string().optional(),\n })\n .optional(),\n // service generator specific options\n path: z.string().optional(),\n dataAccess: z.enum(['stub', 'drizzle']).default('stub').optional(),\n dbImportPath: z.string().optional(),\n schemaImportPath: z.string().optional(),\n // zod generator specific options\n schemaSuffix: z.string().optional(),\n fileSuffix: z.string().optional(),\n // orpc validation sharing\n validation: z\n .object({\n useShared: z.boolean().default(false).optional(),\n library: z.enum(['zod', 'valibot', 'arktype']).default('zod').optional(),\n importPath: z.string().optional(),\n schemaSuffix: z.string().optional(),\n })\n .optional(),\n // template options\n templateOptions: z.record(z.string(), z.any()).optional(),\n});\n\nexport const ConfigSchema = z.object({\n schema: z.string(),\n outDir: z.string().default('src/api'),\n analyzer: z\n .object({\n includeRelations: z.boolean().default(true),\n validateConstraints: z.boolean().default(true),\n includeHeuristicRelations: z.boolean().default(false),\n })\n .default({\n includeRelations: true,\n validateConstraints: true,\n includeHeuristicRelations: false,\n }),\n generators: z\n .array(GeneratorSchema)\n .min(1)\n .default([{ kind: 'orpc' } as any]),\n});\n\nexport type DrzlConfig = z.infer<typeof ConfigSchema>;\n\nexport function defineConfig(cfg: DrzlConfig) {\n return cfg;\n}\n\nexport async function loadConfig(customPath?: string): Promise<DrzlConfig | null> {\n const path = await import('node:path');\n const fs = await import('node:fs/promises');\n\n const candidates = customPath\n ? [customPath]\n : ['drzl.config.ts', 'drzl.config.mjs', 'drzl.config.js'];\n\n for (const c of candidates) {\n const p = path.resolve(process.cwd(), c);\n try {\n await fs.access(p);\n } catch {\n continue;\n }\n // If JSON, parse directly and skip module loading\n if (/\\.json$/i.test(p)) {\n try {\n const content = await fs.readFile(p, 'utf8');\n const raw = JSON.parse(content);\n const parsed = ConfigSchema.parse(raw);\n return parsed;\n } catch (e2) {\n throw new Error(`Failed to load config from ${p}: ${String(e2)}`);\n }\n }\n // Try jiti to seamlessly load TS/ESM/CJS\n try {\n const { default: jiti } = await import('jiti');\n const jit = (jiti as any)(import.meta.url);\n const mod = jit(p);\n const raw = mod && typeof mod === 'object' && 'default' in mod ? (mod as any).default : mod;\n const parsed = ConfigSchema.safeParse(raw);\n if (!parsed.success) {\n throw new Error(parsed.error.message);\n }\n return parsed.data;\n } catch (e) {\n // Fallback: try JSON parse\n try {\n const content = await fs.readFile(p, 'utf8');\n const raw = JSON.parse(content);\n const parsed = ConfigSchema.parse(raw);\n return parsed;\n } catch (e2) {\n throw new Error(`Failed to load config from ${p}: ${String(e2)}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uBAAwB;AACxB,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AAAA;AAAA;AAQjB,MAAI;AACF,UAAM,GAAG,UAAU,QAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AACnD,YAAQ,IAAI,aAAAF,QAAM,MAAM,WAAW,MAAM,EAAE,CAAC;AAAA,EAC9C,SAAS,GAAQ;AACf,YAAQ,MAAM,aAAAA,QAAM,IAAI,cAAc,GAAG,GAAG,WAAW,CAAC;AACxD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,QAAQ,WAAW,QAAQ,IAAI;","names":["ora","chalk","cliProgress","chokidar"]}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import ora from "ora";
|
|
7
|
+
import cliProgress from "cli-progress";
|
|
8
|
+
|
|
9
|
+
// src/config.ts
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
var NamingSchema = z.object({
|
|
12
|
+
routerSuffix: z.string().default("Router"),
|
|
13
|
+
procedureCase: z.enum(["camel", "kebab", "snake"]).default("camel")
|
|
14
|
+
}).partial();
|
|
15
|
+
var GeneratorSchema = z.object({
|
|
16
|
+
kind: z.enum(["orpc", "service", "zod", "valibot", "arktype"]),
|
|
17
|
+
template: z.string().optional(),
|
|
18
|
+
includeRelations: z.boolean().optional(),
|
|
19
|
+
naming: NamingSchema.optional(),
|
|
20
|
+
outputHeader: z.object({
|
|
21
|
+
enabled: z.boolean().default(true).optional(),
|
|
22
|
+
text: z.string().optional()
|
|
23
|
+
}).optional(),
|
|
24
|
+
format: z.object({
|
|
25
|
+
enabled: z.boolean().default(true).optional(),
|
|
26
|
+
engine: z.enum(["auto", "prettier", "biome"]).default("auto").optional(),
|
|
27
|
+
configPath: z.string().optional()
|
|
28
|
+
}).optional(),
|
|
29
|
+
// service generator specific options
|
|
30
|
+
path: z.string().optional(),
|
|
31
|
+
dataAccess: z.enum(["stub", "drizzle"]).default("stub").optional(),
|
|
32
|
+
dbImportPath: z.string().optional(),
|
|
33
|
+
schemaImportPath: z.string().optional(),
|
|
34
|
+
// zod generator specific options
|
|
35
|
+
schemaSuffix: z.string().optional(),
|
|
36
|
+
fileSuffix: z.string().optional(),
|
|
37
|
+
// orpc validation sharing
|
|
38
|
+
validation: z.object({
|
|
39
|
+
useShared: z.boolean().default(false).optional(),
|
|
40
|
+
library: z.enum(["zod", "valibot", "arktype"]).default("zod").optional(),
|
|
41
|
+
importPath: z.string().optional(),
|
|
42
|
+
schemaSuffix: z.string().optional()
|
|
43
|
+
}).optional(),
|
|
44
|
+
// template options
|
|
45
|
+
templateOptions: z.record(z.string(), z.any()).optional()
|
|
46
|
+
});
|
|
47
|
+
var ConfigSchema = z.object({
|
|
48
|
+
schema: z.string(),
|
|
49
|
+
outDir: z.string().default("src/api"),
|
|
50
|
+
analyzer: z.object({
|
|
51
|
+
includeRelations: z.boolean().default(true),
|
|
52
|
+
validateConstraints: z.boolean().default(true),
|
|
53
|
+
includeHeuristicRelations: z.boolean().default(false)
|
|
54
|
+
}).default({
|
|
55
|
+
includeRelations: true,
|
|
56
|
+
validateConstraints: true,
|
|
57
|
+
includeHeuristicRelations: false
|
|
58
|
+
}),
|
|
59
|
+
generators: z.array(GeneratorSchema).min(1).default([{ kind: "orpc" }])
|
|
60
|
+
});
|
|
61
|
+
async function loadConfig(customPath) {
|
|
62
|
+
const path = await import("path");
|
|
63
|
+
const fs = await import("fs/promises");
|
|
64
|
+
const candidates = customPath ? [customPath] : ["drzl.config.ts", "drzl.config.mjs", "drzl.config.js"];
|
|
65
|
+
for (const c of candidates) {
|
|
66
|
+
const p = path.resolve(process.cwd(), c);
|
|
67
|
+
try {
|
|
68
|
+
await fs.access(p);
|
|
69
|
+
} catch {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (/\.json$/i.test(p)) {
|
|
73
|
+
try {
|
|
74
|
+
const content = await fs.readFile(p, "utf8");
|
|
75
|
+
const raw = JSON.parse(content);
|
|
76
|
+
const parsed = ConfigSchema.parse(raw);
|
|
77
|
+
return parsed;
|
|
78
|
+
} catch (e2) {
|
|
79
|
+
throw new Error(`Failed to load config from ${p}: ${String(e2)}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const { default: jiti } = await import("jiti");
|
|
84
|
+
const jit = jiti(import.meta.url);
|
|
85
|
+
const mod = jit(p);
|
|
86
|
+
const raw = mod && typeof mod === "object" && "default" in mod ? mod.default : mod;
|
|
87
|
+
const parsed = ConfigSchema.safeParse(raw);
|
|
88
|
+
if (!parsed.success) {
|
|
89
|
+
throw new Error(parsed.error.message);
|
|
90
|
+
}
|
|
91
|
+
return parsed.data;
|
|
92
|
+
} catch (e) {
|
|
93
|
+
try {
|
|
94
|
+
const content = await fs.readFile(p, "utf8");
|
|
95
|
+
const raw = JSON.parse(content);
|
|
96
|
+
const parsed = ConfigSchema.parse(raw);
|
|
97
|
+
return parsed;
|
|
98
|
+
} catch (e2) {
|
|
99
|
+
throw new Error(`Failed to load config from ${p}: ${String(e2)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/cli.ts
|
|
107
|
+
import { SchemaAnalyzer } from "@drzl/analyzer";
|
|
108
|
+
import { ORPCGenerator } from "@drzl/generator-orpc";
|
|
109
|
+
import chokidar from "chokidar";
|
|
110
|
+
var program = new Command();
|
|
111
|
+
program.name("drzl").description("DRZL - Drizzle Developer Toolkit").version("0.0.1");
|
|
112
|
+
program.command("analyze").argument("<schema>", "path to drizzle schema (TS)").option("--relations", "include relations", true).option("--validate", "validate constraints", true).option("--out <file>", "write analysis JSON to file").option("--json", "print JSON to stdout (overrides --out)", false).action(async (schema, opts) => {
|
|
113
|
+
try {
|
|
114
|
+
const analyzer = new SchemaAnalyzer(schema);
|
|
115
|
+
const spinner = !opts.json ? ora("Analyzing schema...").start() : null;
|
|
116
|
+
const start = Date.now();
|
|
117
|
+
const res = await analyzer.analyze({
|
|
118
|
+
includeRelations: !!opts.relations,
|
|
119
|
+
validateConstraints: !!opts.validate
|
|
120
|
+
});
|
|
121
|
+
const ms = Date.now() - start;
|
|
122
|
+
const json = JSON.stringify(res, null, 2);
|
|
123
|
+
if (opts.json) {
|
|
124
|
+
console.log(json);
|
|
125
|
+
} else if (opts.out) {
|
|
126
|
+
const fs = await import("fs/promises");
|
|
127
|
+
await fs.writeFile(opts.out, json, "utf8");
|
|
128
|
+
spinner?.succeed(chalk.green(`Analysis written to ${opts.out} in ${ms}ms`));
|
|
129
|
+
} else {
|
|
130
|
+
spinner?.succeed(chalk.green(`Analyzed in ${ms}ms`));
|
|
131
|
+
console.log(json);
|
|
132
|
+
}
|
|
133
|
+
process.exit(res.issues.some((i) => i.level === "error") ? 2 : 0);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
const msg = e?.message ?? String(e);
|
|
136
|
+
if (opts.json)
|
|
137
|
+
console.log(JSON.stringify({ event: "error", code: "DRZL_CLI_ANALYZE", message: msg }));
|
|
138
|
+
else
|
|
139
|
+
console.error(
|
|
140
|
+
chalk.red("Analyze failed (DRZL_CLI_ANALYZE):"),
|
|
141
|
+
msg,
|
|
142
|
+
"\nTip: run with --json for structured output."
|
|
143
|
+
);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
program.command("generate").description("Run configured generators (drzl.config.*)").option("-c, --config <path>", "path to drzl.config").action(async (opts) => {
|
|
148
|
+
try {
|
|
149
|
+
const cfg = await loadConfig(opts.config);
|
|
150
|
+
if (!cfg) {
|
|
151
|
+
console.error(
|
|
152
|
+
chalk.red("No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.")
|
|
153
|
+
);
|
|
154
|
+
process.exit(2);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const analyzer = new SchemaAnalyzer(cfg.schema);
|
|
158
|
+
const spinner = ora("Analyzing...").start();
|
|
159
|
+
const t0 = Date.now();
|
|
160
|
+
const analysis = await analyzer.analyze({
|
|
161
|
+
includeRelations: cfg.analyzer.includeRelations,
|
|
162
|
+
validateConstraints: cfg.analyzer.validateConstraints,
|
|
163
|
+
includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations
|
|
164
|
+
});
|
|
165
|
+
spinner.succeed(`Analysis complete in ${Date.now() - t0}ms`);
|
|
166
|
+
const progress = new cliProgress.SingleBar(
|
|
167
|
+
{ hideCursor: true },
|
|
168
|
+
cliProgress.Presets.shades_classic
|
|
169
|
+
);
|
|
170
|
+
const total = analysis.tables.length || 1;
|
|
171
|
+
progress.start(total, 0);
|
|
172
|
+
for (const g of cfg.generators) {
|
|
173
|
+
if (g.kind === "orpc") {
|
|
174
|
+
const gen = new ORPCGenerator(analysis);
|
|
175
|
+
const { files } = await gen.generate({
|
|
176
|
+
outputDir: cfg.outDir,
|
|
177
|
+
template: g.template,
|
|
178
|
+
includeRelations: g.includeRelations,
|
|
179
|
+
naming: g.naming,
|
|
180
|
+
outputHeader: g.outputHeader,
|
|
181
|
+
format: g.format,
|
|
182
|
+
templateOptions: g.templateOptions,
|
|
183
|
+
validation: g.validation,
|
|
184
|
+
onProgress: ({ index }) => progress.update(index)
|
|
185
|
+
});
|
|
186
|
+
progress.stop();
|
|
187
|
+
ora().succeed(chalk.green(`Generated (${g.kind}): ${files.length} files`));
|
|
188
|
+
files.forEach((f) => console.log(" -", chalk.cyan(f)));
|
|
189
|
+
} else if (g.kind === "service") {
|
|
190
|
+
try {
|
|
191
|
+
const { ServiceGenerator } = await import("@drzl/generator-service");
|
|
192
|
+
const gen = new ServiceGenerator(analysis);
|
|
193
|
+
const target = g.path ?? "src/services";
|
|
194
|
+
const files = await gen.generate({
|
|
195
|
+
outDir: target,
|
|
196
|
+
outputHeader: g.outputHeader,
|
|
197
|
+
format: g.format,
|
|
198
|
+
dataAccess: g.dataAccess,
|
|
199
|
+
dbImportPath: g.dbImportPath,
|
|
200
|
+
schemaImportPath: g.schemaImportPath
|
|
201
|
+
});
|
|
202
|
+
progress.stop();
|
|
203
|
+
ora().succeed(chalk.green(`Generated (service): ${files.length} files`));
|
|
204
|
+
files.forEach((f) => console.log(" -", chalk.cyan(f)));
|
|
205
|
+
} catch (e) {
|
|
206
|
+
progress.stop();
|
|
207
|
+
console.error(
|
|
208
|
+
chalk.red("Service generator missing (install @drzl/generator-service)?"),
|
|
209
|
+
e?.message ?? e
|
|
210
|
+
);
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
} else if (g.kind === "zod") {
|
|
214
|
+
try {
|
|
215
|
+
const { ZodGenerator } = await import("@drzl/generator-zod");
|
|
216
|
+
const gen = new ZodGenerator(analysis);
|
|
217
|
+
const target = g.path ?? "src/validators/zod";
|
|
218
|
+
const files = await gen.generate({
|
|
219
|
+
outDir: target,
|
|
220
|
+
outputHeader: g.outputHeader,
|
|
221
|
+
format: g.format,
|
|
222
|
+
schemaSuffix: g.schemaSuffix,
|
|
223
|
+
fileSuffix: g.fileSuffix
|
|
224
|
+
});
|
|
225
|
+
progress.stop();
|
|
226
|
+
ora().succeed(chalk.green(`Generated (zod): ${files.length} files`));
|
|
227
|
+
files.forEach((f) => console.log(" -", chalk.cyan(f)));
|
|
228
|
+
} catch (e) {
|
|
229
|
+
progress.stop();
|
|
230
|
+
console.error(
|
|
231
|
+
chalk.red("Zod generator missing (install @drzl/generator-zod)?"),
|
|
232
|
+
e?.message ?? e
|
|
233
|
+
);
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
} else if (g.kind === "valibot") {
|
|
237
|
+
try {
|
|
238
|
+
const { ValibotGenerator } = await import("@drzl/generator-valibot");
|
|
239
|
+
const gen = new ValibotGenerator(analysis);
|
|
240
|
+
const target = g.path ?? "src/validators/valibot";
|
|
241
|
+
const files = await gen.generate({
|
|
242
|
+
outDir: target,
|
|
243
|
+
outputHeader: g.outputHeader,
|
|
244
|
+
format: g.format,
|
|
245
|
+
schemaSuffix: g.schemaSuffix,
|
|
246
|
+
fileSuffix: g.fileSuffix
|
|
247
|
+
});
|
|
248
|
+
progress.stop();
|
|
249
|
+
ora().succeed(chalk.green(`Generated (valibot): ${files.length} files`));
|
|
250
|
+
files.forEach((f) => console.log(" -", chalk.cyan(f)));
|
|
251
|
+
} catch (e) {
|
|
252
|
+
progress.stop();
|
|
253
|
+
console.error(
|
|
254
|
+
chalk.red("Valibot generator missing (install @drzl/generator-valibot)?"),
|
|
255
|
+
e?.message ?? e
|
|
256
|
+
);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
} else if (g.kind === "arktype") {
|
|
260
|
+
try {
|
|
261
|
+
const { ArkTypeGenerator } = await import("@drzl/generator-arktype");
|
|
262
|
+
const gen = new ArkTypeGenerator(analysis);
|
|
263
|
+
const target = g.path ?? "src/validators/arktype";
|
|
264
|
+
const files = await gen.generate({
|
|
265
|
+
outDir: target,
|
|
266
|
+
outputHeader: g.outputHeader,
|
|
267
|
+
format: g.format,
|
|
268
|
+
schemaSuffix: g.schemaSuffix,
|
|
269
|
+
fileSuffix: g.fileSuffix
|
|
270
|
+
});
|
|
271
|
+
progress.stop();
|
|
272
|
+
ora().succeed(chalk.green(`Generated (arktype): ${files.length} files`));
|
|
273
|
+
files.forEach((f) => console.log(" -", chalk.cyan(f)));
|
|
274
|
+
} catch (e) {
|
|
275
|
+
progress.stop();
|
|
276
|
+
console.error(
|
|
277
|
+
chalk.red("ArkType generator missing (install @drzl/generator-arktype)?"),
|
|
278
|
+
e?.message ?? e
|
|
279
|
+
);
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
} catch (e) {
|
|
285
|
+
console.error(
|
|
286
|
+
chalk.red("Generate failed (DRZL_GEN_001):"),
|
|
287
|
+
e?.message ?? e,
|
|
288
|
+
"\nTip: check your drzl.config.ts and template path."
|
|
289
|
+
);
|
|
290
|
+
process.exit(1);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
program.command("generate:orpc").argument("<schema>", "path to drizzle schema (TS)").option("-o, --outDir <dir>", "output directory", "src/api").option("--template <name>", "template name", "standard").option("--includeRelations", "include relation endpoints").action(async (schema, opts) => {
|
|
294
|
+
try {
|
|
295
|
+
const analyzer = new SchemaAnalyzer(schema);
|
|
296
|
+
const analysis = await analyzer.analyze({
|
|
297
|
+
includeRelations: !!opts.includeRelations,
|
|
298
|
+
validateConstraints: true
|
|
299
|
+
});
|
|
300
|
+
const gen = new ORPCGenerator(analysis);
|
|
301
|
+
const { files } = await gen.generate({
|
|
302
|
+
outputDir: opts.outDir,
|
|
303
|
+
template: opts.template,
|
|
304
|
+
includeRelations: !!opts.includeRelations
|
|
305
|
+
});
|
|
306
|
+
console.log(chalk.green(`Generated:`), files.map((f) => chalk.cyan(f)).join(", "));
|
|
307
|
+
} catch (e) {
|
|
308
|
+
console.error(chalk.red("Generate orpc failed:"), e?.message ?? e);
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
program.command("watch").description("Watch schema and regenerate on changes").option("-c, --config <path>", "path to drzl.config").option("--pipeline <name>", "all | analyze | generate-orpc", "all").option("--debounce <ms>", "debounce ms", "200").option("--json", "emit JSON logs", false).action(async (opts) => {
|
|
313
|
+
const cfg = await loadConfig(opts.config);
|
|
314
|
+
if (!cfg) {
|
|
315
|
+
console.error(chalk.red("No config found. Create drzl.config.ts or pass --config."));
|
|
316
|
+
process.exit(2);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
let lastFiles = [];
|
|
320
|
+
const run = async () => {
|
|
321
|
+
try {
|
|
322
|
+
if (!opts.json) console.clear();
|
|
323
|
+
const analyzer = new SchemaAnalyzer(cfg.schema);
|
|
324
|
+
const analysis = await analyzer.analyze({
|
|
325
|
+
includeRelations: cfg.analyzer.includeRelations,
|
|
326
|
+
validateConstraints: cfg.analyzer.validateConstraints
|
|
327
|
+
});
|
|
328
|
+
if (opts.pipeline === "analyze") {
|
|
329
|
+
if (opts.json) {
|
|
330
|
+
console.log(
|
|
331
|
+
JSON.stringify({
|
|
332
|
+
event: "analyze_complete",
|
|
333
|
+
issues: analysis.issues,
|
|
334
|
+
tables: analysis.tables.length
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
} else {
|
|
338
|
+
console.log(chalk.green("Analyze complete."));
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const newFiles = [];
|
|
343
|
+
for (const g of cfg.generators) {
|
|
344
|
+
if (g.kind === "orpc" && (opts.pipeline === "all" || opts.pipeline === "generate-orpc")) {
|
|
345
|
+
const gen = new ORPCGenerator(analysis);
|
|
346
|
+
const { files } = await gen.generate({
|
|
347
|
+
outputDir: cfg.outDir,
|
|
348
|
+
template: g.template,
|
|
349
|
+
includeRelations: g.includeRelations,
|
|
350
|
+
naming: g.naming
|
|
351
|
+
});
|
|
352
|
+
if (opts.json) {
|
|
353
|
+
console.log(JSON.stringify({ event: "generate_complete", kind: g.kind, files }));
|
|
354
|
+
} else {
|
|
355
|
+
console.log(
|
|
356
|
+
chalk.green(`Generated (${g.kind}):`),
|
|
357
|
+
files.map((f) => chalk.cyan(f)).join(", ")
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
newFiles.push(...files);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const added = newFiles.filter((f) => !lastFiles.includes(f));
|
|
364
|
+
const removed = lastFiles.filter((f) => !newFiles.includes(f));
|
|
365
|
+
if (opts.json) {
|
|
366
|
+
console.log(JSON.stringify({ event: "diff", added, removed }));
|
|
367
|
+
} else {
|
|
368
|
+
if (added.length) console.log(chalk.blue(`Added: ${added.join(", ")}`));
|
|
369
|
+
if (removed.length) console.log(chalk.yellow(`Removed: ${removed.join(", ")}`));
|
|
370
|
+
}
|
|
371
|
+
lastFiles = newFiles;
|
|
372
|
+
} catch (e) {
|
|
373
|
+
if (opts.json)
|
|
374
|
+
console.log(JSON.stringify({ event: "error", message: String(e?.message ?? e) }));
|
|
375
|
+
else console.error(chalk.red("Watch pipeline failed:"), e?.message ?? e);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
const debounced = Number(opts.debounce) || 200;
|
|
379
|
+
let timer = null;
|
|
380
|
+
const trigger = (file) => {
|
|
381
|
+
if (file && file.startsWith(cfg.outDir)) return;
|
|
382
|
+
clearTimeout(timer);
|
|
383
|
+
timer = setTimeout(run, debounced);
|
|
384
|
+
};
|
|
385
|
+
console.log(chalk.gray("Watching for changes..."));
|
|
386
|
+
const watchSet = /* @__PURE__ */ new Set([cfg.schema]);
|
|
387
|
+
for (const g of cfg.generators) {
|
|
388
|
+
if (g.template && g.template !== "standard" && g.template !== "minimal") {
|
|
389
|
+
watchSet.add(g.template);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
watchSet.add(cfg.outDir);
|
|
393
|
+
chokidar.watch(Array.from(watchSet), { ignoreInitial: true }).on("add", (p) => trigger(p)).on("change", (p) => trigger(p)).on("unlink", (p) => trigger(p));
|
|
394
|
+
await run();
|
|
395
|
+
});
|
|
396
|
+
program.command("init").description("Scaffold a drzl.config.ts").option("-y, --yes", "accept defaults").action(async (_opts) => {
|
|
397
|
+
const fs = await import("fs/promises");
|
|
398
|
+
const path = await import("path");
|
|
399
|
+
const target = path.resolve(process.cwd(), "drzl.config.ts");
|
|
400
|
+
const template = `export default {
|
|
401
|
+
schema: 'src/db/schema.ts',
|
|
402
|
+
outDir: 'src/api',
|
|
403
|
+
analyzer: { includeRelations: true, validateConstraints: true },
|
|
404
|
+
generators: [
|
|
405
|
+
{ kind: 'orpc', template: 'standard', includeRelations: true }
|
|
406
|
+
]
|
|
407
|
+
} as const
|
|
408
|
+
`;
|
|
409
|
+
try {
|
|
410
|
+
await fs.writeFile(target, template, { flag: "wx" });
|
|
411
|
+
console.log(chalk.green(`Created ${target}`));
|
|
412
|
+
} catch (e) {
|
|
413
|
+
console.error(chalk.red("Init failed:"), e?.message ?? e);
|
|
414
|
+
process.exit(1);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
program.parseAsync(process.argv);
|
|
418
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/config.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport cliProgress from 'cli-progress';\nimport { loadConfig } from './config.js';\nimport { SchemaAnalyzer } from '@drzl/analyzer';\nimport { ORPCGenerator } from '@drzl/generator-orpc';\nimport chokidar from 'chokidar';\n\nconst program = new Command();\nprogram.name('drzl').description('DRZL - Drizzle Developer Toolkit').version('0.0.1');\n\nprogram\n .command('analyze')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('--relations', 'include relations', true)\n .option('--validate', 'validate constraints', true)\n .option('--out <file>', 'write analysis JSON to file')\n .option('--json', 'print JSON to stdout (overrides --out)', false)\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const spinner = !opts.json ? ora('Analyzing schema...').start() : null;\n const start = Date.now();\n const res = await analyzer.analyze({\n includeRelations: !!opts.relations,\n validateConstraints: !!opts.validate,\n });\n const ms = Date.now() - start;\n const json = JSON.stringify(res, null, 2);\n if (opts.json) {\n console.log(json);\n } else if (opts.out) {\n const fs = await import('node:fs/promises');\n await fs.writeFile(opts.out, json, 'utf8');\n spinner?.succeed(chalk.green(`Analysis written to ${opts.out} in ${ms}ms`));\n } else {\n spinner?.succeed(chalk.green(`Analyzed in ${ms}ms`));\n console.log(json);\n }\n process.exit(res.issues.some((i) => i.level === 'error') ? 2 : 0);\n } catch (e: any) {\n const msg = e?.message ?? String(e);\n if (opts.json)\n console.log(JSON.stringify({ event: 'error', code: 'DRZL_CLI_ANALYZE', message: msg }));\n else\n console.error(\n chalk.red('Analyze failed (DRZL_CLI_ANALYZE):'),\n msg,\n '\\nTip: run with --json for structured output.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate')\n .description('Run configured generators (drzl.config.*)')\n .option('-c, --config <path>', 'path to drzl.config')\n .action(async (opts: any) => {\n try {\n const cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(\n chalk.red('No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.')\n );\n process.exit(2);\n return;\n }\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const spinner = ora('Analyzing...').start();\n const t0 = Date.now();\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations,\n });\n spinner.succeed(`Analysis complete in ${Date.now() - t0}ms`);\n const progress = new cliProgress.SingleBar(\n { hideCursor: true },\n cliProgress.Presets.shades_classic\n );\n const total = analysis.tables.length || 1;\n progress.start(total, 0);\n for (const g of cfg.generators) {\n if (g.kind === 'orpc') {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n templateOptions: g.templateOptions,\n validation: g.validation,\n onProgress: ({ index }) => progress.update(index),\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (${g.kind}): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await import('@drzl/generator-service');\n const gen = new ServiceGenerator(analysis);\n const target = g.path ?? 'src/services';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n dataAccess: g.dataAccess,\n dbImportPath: g.dbImportPath,\n schemaImportPath: g.schemaImportPath,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (service): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Service generator missing (install @drzl/generator-service)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await import('@drzl/generator-zod');\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (zod): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Zod generator missing (install @drzl/generator-zod)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await import('@drzl/generator-valibot');\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (valibot): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Valibot generator missing (install @drzl/generator-valibot)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await import('@drzl/generator-arktype');\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (arktype): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('ArkType generator missing (install @drzl/generator-arktype)?'),\n e?.message ?? e\n );\n process.exit(1);\n }\n }\n }\n } catch (e: any) {\n console.error(\n chalk.red('Generate failed (DRZL_GEN_001):'),\n e?.message ?? e,\n '\\nTip: check your drzl.config.ts and template path.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:orpc')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('-o, --outDir <dir>', 'output directory', 'src/api')\n .option('--template <name>', 'template name', 'standard')\n .option('--includeRelations', 'include relation endpoints')\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const analysis = await analyzer.analyze({\n includeRelations: !!opts.includeRelations,\n validateConstraints: true,\n });\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: opts.outDir,\n template: opts.template,\n includeRelations: !!opts.includeRelations,\n });\n console.log(chalk.green(`Generated:`), files.map((f) => chalk.cyan(f)).join(', '));\n } catch (e: any) {\n console.error(chalk.red('Generate orpc failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\nprogram\n .command('watch')\n .description('Watch schema and regenerate on changes')\n .option('-c, --config <path>', 'path to drzl.config')\n .option('--pipeline <name>', 'all | analyze | generate-orpc', 'all')\n .option('--debounce <ms>', 'debounce ms', '200')\n .option('--json', 'emit JSON logs', false)\n .action(async (opts: any) => {\n const cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(chalk.red('No config found. Create drzl.config.ts or pass --config.'));\n process.exit(2);\n return;\n }\n let lastFiles: string[] = [];\n const run = async () => {\n try {\n if (!opts.json) console.clear();\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n });\n if (opts.pipeline === 'analyze') {\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'analyze_complete',\n issues: analysis.issues,\n tables: analysis.tables.length,\n })\n );\n } else {\n console.log(chalk.green('Analyze complete.'));\n }\n return;\n }\n const newFiles: string[] = [];\n for (const g of cfg.generators) {\n if (g.kind === 'orpc' && (opts.pipeline === 'all' || opts.pipeline === 'generate-orpc')) {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n });\n if (opts.json) {\n console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }));\n } else {\n console.log(\n chalk.green(`Generated (${g.kind}):`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n }\n newFiles.push(...files);\n }\n }\n // Diff\n const added = newFiles.filter((f) => !lastFiles.includes(f));\n const removed = lastFiles.filter((f) => !newFiles.includes(f));\n if (opts.json) {\n console.log(JSON.stringify({ event: 'diff', added, removed }));\n } else {\n if (added.length) console.log(chalk.blue(`Added: ${added.join(', ')}`));\n if (removed.length) console.log(chalk.yellow(`Removed: ${removed.join(', ')}`));\n }\n lastFiles = newFiles;\n } catch (e: any) {\n if (opts.json)\n console.log(JSON.stringify({ event: 'error', message: String(e?.message ?? e) }));\n else console.error(chalk.red('Watch pipeline failed:'), e?.message ?? e);\n }\n };\n const debounced = Number(opts.debounce) || 200;\n let timer: any = null;\n const trigger = (file?: string) => {\n // Ignore changes in outDir to avoid loops\n if (file && file.startsWith(cfg.outDir)) return;\n clearTimeout(timer);\n timer = setTimeout(run, debounced);\n };\n console.log(chalk.gray('Watching for changes...'));\n const watchSet = new Set<string>([cfg.schema]);\n // Watch template paths (only when path-like and exists)\n for (const g of cfg.generators) {\n if (g.template && g.template !== 'standard' && g.template !== 'minimal') {\n watchSet.add(g.template);\n }\n }\n // Also watch outDir but ignore events from it to report diffs cleanly\n watchSet.add(cfg.outDir);\n chokidar\n .watch(Array.from(watchSet), { ignoreInitial: true })\n .on('add', (p) => trigger(p))\n .on('change', (p) => trigger(p))\n .on('unlink', (p) => trigger(p));\n await run();\n });\n\nprogram\n .command('init')\n .description('Scaffold a drzl.config.ts')\n .option('-y, --yes', 'accept defaults')\n .action(async (_opts: any) => {\n const fs = await import('node:fs/promises');\n const path = await import('node:path');\n const target = path.resolve(process.cwd(), 'drzl.config.ts');\n const template = `export default {\n schema: 'src/db/schema.ts',\n outDir: 'src/api',\n analyzer: { includeRelations: true, validateConstraints: true },\n generators: [\n { kind: 'orpc', template: 'standard', includeRelations: true }\n ]\n} as const\\n`;\n try {\n await fs.writeFile(target, template, { flag: 'wx' });\n console.log(chalk.green(`Created ${target}`));\n } catch (e: any) {\n console.error(chalk.red('Init failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\nprogram.parseAsync(process.argv);\n","import { z } from 'zod';\n\nexport const NamingSchema = z\n .object({\n routerSuffix: z.string().default('Router'),\n procedureCase: z.enum(['camel', 'kebab', 'snake']).default('camel'),\n })\n .partial();\n\nexport const GeneratorSchema = z.object({\n kind: z.enum(['orpc', 'service', 'zod', 'valibot', 'arktype']),\n template: z.string().optional(),\n includeRelations: z.boolean().optional(),\n naming: NamingSchema.optional(),\n outputHeader: z\n .object({\n enabled: z.boolean().default(true).optional(),\n text: z.string().optional(),\n })\n .optional(),\n format: z\n .object({\n enabled: z.boolean().default(true).optional(),\n engine: z.enum(['auto', 'prettier', 'biome']).default('auto').optional(),\n configPath: z.string().optional(),\n })\n .optional(),\n // service generator specific options\n path: z.string().optional(),\n dataAccess: z.enum(['stub', 'drizzle']).default('stub').optional(),\n dbImportPath: z.string().optional(),\n schemaImportPath: z.string().optional(),\n // zod generator specific options\n schemaSuffix: z.string().optional(),\n fileSuffix: z.string().optional(),\n // orpc validation sharing\n validation: z\n .object({\n useShared: z.boolean().default(false).optional(),\n library: z.enum(['zod', 'valibot', 'arktype']).default('zod').optional(),\n importPath: z.string().optional(),\n schemaSuffix: z.string().optional(),\n })\n .optional(),\n // template options\n templateOptions: z.record(z.string(), z.any()).optional(),\n});\n\nexport const ConfigSchema = z.object({\n schema: z.string(),\n outDir: z.string().default('src/api'),\n analyzer: z\n .object({\n includeRelations: z.boolean().default(true),\n validateConstraints: z.boolean().default(true),\n includeHeuristicRelations: z.boolean().default(false),\n })\n .default({\n includeRelations: true,\n validateConstraints: true,\n includeHeuristicRelations: false,\n }),\n generators: z\n .array(GeneratorSchema)\n .min(1)\n .default([{ kind: 'orpc' } as any]),\n});\n\nexport type DrzlConfig = z.infer<typeof ConfigSchema>;\n\nexport function defineConfig(cfg: DrzlConfig) {\n return cfg;\n}\n\nexport async function loadConfig(customPath?: string): Promise<DrzlConfig | null> {\n const path = await import('node:path');\n const fs = await import('node:fs/promises');\n\n const candidates = customPath\n ? [customPath]\n : ['drzl.config.ts', 'drzl.config.mjs', 'drzl.config.js'];\n\n for (const c of candidates) {\n const p = path.resolve(process.cwd(), c);\n try {\n await fs.access(p);\n } catch {\n continue;\n }\n // If JSON, parse directly and skip module loading\n if (/\\.json$/i.test(p)) {\n try {\n const content = await fs.readFile(p, 'utf8');\n const raw = JSON.parse(content);\n const parsed = ConfigSchema.parse(raw);\n return parsed;\n } catch (e2) {\n throw new Error(`Failed to load config from ${p}: ${String(e2)}`);\n }\n }\n // Try jiti to seamlessly load TS/ESM/CJS\n try {\n const { default: jiti } = await import('jiti');\n const jit = (jiti as any)(import.meta.url);\n const mod = jit(p);\n const raw = mod && typeof mod === 'object' && 'default' in mod ? (mod as any).default : mod;\n const parsed = ConfigSchema.safeParse(raw);\n if (!parsed.success) {\n throw new Error(parsed.error.message);\n }\n return parsed.data;\n } catch (e) {\n // Fallback: try JSON parse\n try {\n const content = await fs.readFile(p, 'utf8');\n const raw = JSON.parse(content);\n const parsed = ConfigSchema.parse(raw);\n return parsed;\n } catch (e2) {\n throw new Error(`Failed to load config from ${p}: ${String(e2)}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;AACA,SAAS,eAAe;AACxB,OAAO,WAAW;AAClB,OAAO,SAAS;AAChB,OAAO,iBAAiB;;;ACJxB,SAAS,SAAS;AAEX,IAAM,eAA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|
|
2
|
+
"name": "@drzl/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"drzl": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/cli.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"commander": "^14.0.0",
|
|
16
|
+
"chalk": "^5.6.0",
|
|
17
|
+
"chokidar": "^4.0.3",
|
|
18
|
+
"ora": "^8.2.0",
|
|
19
|
+
"cli-progress": "^3.12.0",
|
|
20
|
+
"zod": "^4.1.5",
|
|
21
|
+
"jiti": "^2.5.1",
|
|
22
|
+
"@drzl/analyzer": "^0.0.1",
|
|
23
|
+
"@drzl/generator-orpc": "^0.0.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"tsup": "^8.5.0",
|
|
27
|
+
"typescript": "^5.9.2",
|
|
28
|
+
"ts-node": "^10.9.2"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18.17.0"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"registry": "https://registry.npmjs.org/",
|
|
36
|
+
"provenance": true
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/use-drzl/drzl",
|
|
41
|
+
"directory": "packages/cli"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup src/cli.ts --format esm,cjs --sourcemap",
|
|
45
|
+
"dev": "node --loader ts-node/esm src/cli.ts --help",
|
|
46
|
+
"lint": "eslint . --ext .ts",
|
|
47
|
+
"test": "vitest run"
|
|
48
|
+
}
|
|
49
|
+
}
|