@veloxts/cli 0.7.4 → 0.7.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @veloxts/cli
2
2
 
3
+ ## 0.7.5
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(cli): address sync command review findings
8
+ - Updated dependencies
9
+ - @veloxts/auth@0.7.5
10
+ - @veloxts/core@0.7.5
11
+ - @veloxts/orm@0.7.5
12
+ - @veloxts/router@0.7.5
13
+ - @veloxts/validation@0.7.5
14
+
3
15
  ## 0.7.4
4
16
 
5
17
  ### Patch Changes
@@ -117,7 +117,7 @@ function findClosingBrace(content, openIndex) {
117
117
  return i;
118
118
  }
119
119
  }
120
- return content.length;
120
+ throw new Error('Prisma schema has unbalanced braces — model block not properly closed');
121
121
  }
122
122
  /**
123
123
  * Parse every field-like line from a model body into `RawFieldLine` objects.
@@ -52,7 +52,7 @@ export async function executeSync(projectRoot, options) {
52
52
  // ── Stage 3: Prompt ─────────────────────────────────────────
53
53
  let choices;
54
54
  if (options.force) {
55
- choices = models.map((model) => buildDefaultChoices(model));
55
+ choices = models.map((model) => buildDefaultChoices(model, existing));
56
56
  }
57
57
  else {
58
58
  const prompted = await promptAllModels(models, existing);
@@ -152,6 +152,7 @@ async function generateFiles(snapshot, plan, projectRoot, options) {
152
152
  }
153
153
  // ── Register procedures in router ───────────────────────────
154
154
  if (!options.skipRegistration) {
155
+ let registrationFailures = 0;
155
156
  for (const reg of plan.registrations) {
156
157
  try {
157
158
  const result = registerProcedures(projectRoot, reg.entityName, reg.procedureVarName, false);
@@ -159,14 +160,19 @@ async function generateFiles(snapshot, plan, projectRoot, options) {
159
160
  registered.push(reg.procedureVarName);
160
161
  }
161
162
  else if (result.error) {
163
+ registrationFailures++;
162
164
  errors.push(`Registration ${reg.procedureVarName}: ${result.error}`);
163
165
  }
164
166
  }
165
167
  catch (err) {
168
+ registrationFailures++;
166
169
  const msg = err instanceof Error ? err.message : String(err);
167
170
  errors.push(`Registration ${reg.procedureVarName}: ${msg}`);
168
171
  }
169
172
  }
173
+ if (registrationFailures > 0 && registrationFailures === plan.registrations.length) {
174
+ p.log.warn('All procedure registrations failed. You may need to manually register in src/index.ts.');
175
+ }
170
176
  }
171
177
  // ── Display results ─────────────────────────────────────────
172
178
  displayResults(created, overwritten, registered, errors, projectRoot);
@@ -237,11 +243,13 @@ function displayResults(created, overwritten, registered, errors, projectRoot) {
237
243
  /**
238
244
  * Build default ModelChoices for a model (used when --force is set).
239
245
  * Generates all CRUD, uses output strategy, includes no relations.
246
+ * Sets 'regenerate' if existing files are detected, so rollback works correctly.
240
247
  */
241
- function buildDefaultChoices(model) {
248
+ function buildDefaultChoices(model, existing) {
249
+ const hasExisting = existing.procedures.has(model.name) || existing.schemas.has(model.name);
242
250
  return {
243
251
  model: model.name,
244
- action: 'generate',
252
+ action: hasExisting ? 'regenerate' : 'generate',
245
253
  outputStrategy: 'output',
246
254
  crud: {
247
255
  get: true,
@@ -152,18 +152,15 @@ function generateListProcedure(plan, names) {
152
152
  const lines = [];
153
153
  lines.push(` ${procName}: procedure()`);
154
154
  lines.push(` .input(List${names.pascalPlural}Schema)`);
155
- if (plan.outputStrategy === 'output') {
156
- lines.push(` .query(async ({ input, ctx }) => {`);
157
- }
158
- else {
159
- lines.push(` .query(async ({ input, ctx }) => {`);
160
- }
155
+ lines.push(` .query(async ({ input, ctx }) => {`);
161
156
  lines.push(` const { page, perPage } = input;`);
162
157
  lines.push(` const [items, total] = await Promise.all([`);
163
158
  lines.push(` ctx.db.${names.camel}.findMany({`);
164
159
  lines.push(` skip: (page - 1) * perPage,`);
165
160
  lines.push(` take: perPage,`);
166
- lines.push(` orderBy: { createdAt: 'desc' },`);
161
+ if (plan.model.hasTimestamps) {
162
+ lines.push(` orderBy: { createdAt: 'desc' },`);
163
+ }
167
164
  if (hasIncludes) {
168
165
  lines.push(generateIncludeBlock(plan.includeRelations, 10));
169
166
  }
@@ -204,7 +201,7 @@ function generateUpdateProcedure(_plan, names) {
204
201
  const procName = `update${names.pascal}`;
205
202
  const lines = [];
206
203
  lines.push(` ${procName}: procedure()`);
207
- lines.push(` .input(z.object({ id: z.string().uuid() }).merge(Update${names.pascal}Schema))`);
204
+ lines.push(` .input(Update${names.pascal}Schema.extend({ id: z.string().uuid() }))`);
208
205
  lines.push(` .mutation(async ({ input, ctx }) => {`);
209
206
  lines.push(` const { id, ...data } = input;`);
210
207
  lines.push(` return ctx.db.${names.camel}.update({ where: { id }, data });`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veloxts/cli",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Developer tooling and CLI commands for VeloxTS framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,11 +41,11 @@
41
41
  "pluralize": "8.0.0",
42
42
  "tsx": "4.21.0",
43
43
  "yaml": "2.8.2",
44
- "@veloxts/core": "0.7.4",
45
- "@veloxts/auth": "0.7.4",
46
- "@veloxts/router": "0.7.4",
47
- "@veloxts/orm": "0.7.4",
48
- "@veloxts/validation": "0.7.4"
44
+ "@veloxts/auth": "0.7.5",
45
+ "@veloxts/core": "0.7.5",
46
+ "@veloxts/router": "0.7.5",
47
+ "@veloxts/orm": "0.7.5",
48
+ "@veloxts/validation": "0.7.5"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@prisma/client": ">=7.0.0"