nextjs-cms 0.9.11 → 0.9.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update-sections.ts"],"names":[],"mappings":"AAGA,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,OAAO,iBAsBnD"}
1
+ {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update-sections.ts"],"names":[],"mappings":"AAGA,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,OAAO,iBAuBnD"}
@@ -15,7 +15,8 @@ export async function runUpdateSections(dev) {
15
15
  }
16
16
  catch (error) {
17
17
  p.log.error(chalk.red('✗ Error updating sections:'));
18
- console.error(error);
18
+ console.error(chalk.red(error.message ?? error));
19
+ console.log(''); // Add a new line for better readability
19
20
  exitCode = 1;
20
21
  }
21
22
  finally {
@@ -1 +1 @@
1
- {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/update-sections.ts"],"names":[],"mappings":"AA+xCA,wBAAsB,cAAc,CAAC,SAAS,UAAQ,iBAoBrD"}
1
+ {"version":3,"file":"update-sections.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/update-sections.ts"],"names":[],"mappings":"AAywCA,wBAAsB,cAAc,CAAC,SAAS,UAAQ,iBAoBrD"}
@@ -13,6 +13,17 @@ import { intro, select, spinner, log } from '@clack/prompts';
13
13
  import { MysqlTableChecker } from '../../core/db/index.js';
14
14
  import { generateDrizzleSchema, generateLocalesTableSchema, resolveCaseStyleFns } from '../utils/schema-generator.js';
15
15
  import { addTableKeys } from '../utils/add-table-keys.js';
16
+ /**
17
+ * Returns all DB column names a field owns.
18
+ * Most fields own a single column (field.name), but rarely some fields own two,
19
+ * like DateRangeField (startName, endName).
20
+ */
21
+ function getFieldColumnName(field) {
22
+ if (is(field, DateRangeField)) {
23
+ return [field.startName, field.endName];
24
+ }
25
+ return [field.name];
26
+ }
16
27
  function generateFieldSQL(input) {
17
28
  /**
18
29
  * DateRangeField emits two columns — one for startName, one for endName.
@@ -20,10 +31,7 @@ function generateFieldSQL(input) {
20
31
  if (is(input, DateRangeField)) {
21
32
  const colType = input.format === 'datetime' ? 'DATETIME' : 'DATE';
22
33
  const nullable = ' DEFAULT NULL';
23
- return [
24
- `\`${input.startName}\` ${colType}${nullable}`,
25
- `\`${input.endName}\` ${colType}${nullable}`,
26
- ];
34
+ return [`\`${input.startName}\` ${colType}${nullable}`, `\`${input.endName}\` ${colType}${nullable}`];
27
35
  }
28
36
  let fieldSQL = `\`${input.name}\` `;
29
37
  /**
@@ -187,6 +195,57 @@ function generateFieldSQL(input) {
187
195
  }
188
196
  return fieldSQL;
189
197
  }
198
+ function resolveCreateTableOptions(sectionType) {
199
+ switch (sectionType) {
200
+ case 'simple':
201
+ return {
202
+ createdAt: false,
203
+ updatedAt: true,
204
+ createdBy: false,
205
+ updatedBy: true,
206
+ };
207
+ case 'gallery':
208
+ return {
209
+ updatedBy: false,
210
+ updatedAt: false,
211
+ createdBy: true,
212
+ createdAt: true,
213
+ };
214
+ case 'destinationDb':
215
+ case 'locales':
216
+ return {
217
+ createdAt: true,
218
+ updatedAt: true,
219
+ createdBy: false,
220
+ updatedBy: false,
221
+ };
222
+ default:
223
+ return {
224
+ createdAt: true,
225
+ updatedAt: true,
226
+ createdBy: true,
227
+ updatedBy: true,
228
+ };
229
+ }
230
+ }
231
+ async function ensureTableRegistryEntry(tableName, sectionName) {
232
+ await db
233
+ .insert(NextJsCmsTablesTable)
234
+ .values({
235
+ tableName,
236
+ sectionName,
237
+ })
238
+ .catch((error) => {
239
+ const isDuplicateEntry = typeof error === 'object' &&
240
+ error !== null &&
241
+ 'code' in error &&
242
+ error.code === 'ER_DUP_ENTRY';
243
+ if (isDuplicateEntry) {
244
+ return;
245
+ }
246
+ console.error('Error inserting into __nextjs_cms_tables table:', error);
247
+ });
248
+ }
190
249
  async function createTable(table, options) {
191
250
  /**
192
251
  * Generate the CREATE TABLE SQL
@@ -257,15 +316,7 @@ async function createTable(table, options) {
257
316
  /**
258
317
  * Insert the table name into the `__nextjs_cms_tables` table
259
318
  */
260
- await db
261
- .insert(NextJsCmsTablesTable)
262
- .values({
263
- tableName: table.name,
264
- sectionName: table.sectionName,
265
- })
266
- .catch((error) => {
267
- console.error('Error inserting into __nextjs_cms_tables table:', error);
268
- });
319
+ await ensureTableRegistryEntry(table.name, table.sectionName);
269
320
  }
270
321
  catch (error) {
271
322
  console.log(chalk.red(` - Error creating table \`${table.name}\`:`, error));
@@ -322,21 +373,21 @@ async function updateTable(table, s) {
322
373
  * Filter out the fields that already exist in the table
323
374
  */
324
375
  const existingFields = existingFieldsData ? Object.keys(existingFieldsData) : [];
325
- const fieldsToAdd = table.fields.filter((field) => !existingFields.some((existingField) => existingField === field.name));
376
+ const fieldsToAdd = table.fields.filter((field) => !getFieldColumnName(field).some((col) => existingFields.includes(col)));
326
377
  /**
327
378
  * Let's find out fields that need to be updated.
328
379
  * If a field exists in both the desired fields and the existing fields, we should mark it for update.
329
380
  * TODO: Actually, we should check if the field needs to be updated, and only update if necessary. (INFORMATION_SCHEMA will help)
330
381
  */
331
- const fieldsToUpdate = table.fields.filter((field) => existingFields.some((existingField) => existingField === field.name));
382
+ const fieldsToUpdate = table.fields.filter((field) => getFieldColumnName(field).some((col) => existingFields.includes(col)));
332
383
  /**
333
384
  * Let's find out fields to remove as well.
334
385
  * If a field exists in the table but not in the desired fields,
335
386
  * or if it has a destinationDb, TODO: Add the values to the destination table? (CRITICAL! Loss of data if not done)
336
387
  * we should mark it for removal.
337
388
  */
338
- let fieldsToRemove = existingFields.filter((existingField) => !table.fields.some((field) => field.name === existingField) ||
339
- table.fields.some((field) => field.destinationDb && field.name === existingField));
389
+ let fieldsToRemove = existingFields.filter((existingField) => !table.fields.some((field) => getFieldColumnName(field).includes(existingField)) ||
390
+ table.fields.some((field) => field.destinationDb && getFieldColumnName(field).includes(existingField)));
340
391
  /**
341
392
  * Check if there are fields to update
342
393
  */
@@ -350,22 +401,15 @@ async function updateTable(table, s) {
350
401
  // and data may be lost! (e.g. changing a field from VARCHAR to INT)
351
402
  if (field.destinationDb)
352
403
  continue;
353
- let fieldSQL = generateFieldSQL(field);
354
- /**
355
- * Check if the field is a primary key
356
- */
357
- if (field.name === table.identifier?.name) {
358
- fieldSQL += ' FIRST';
404
+ const fieldSQLResult = [generateFieldSQL(field)].flat();
405
+ for (const fieldSQL of fieldSQLResult) {
406
+ alterTableSQLs.push({
407
+ field: field.name,
408
+ table: table.name,
409
+ action: 'modify',
410
+ sql: `MODIFY COLUMN ${fieldSQL}`,
411
+ });
359
412
  }
360
- /**
361
- * Add the SQL to modify the field
362
- */
363
- alterTableSQLs.push({
364
- field: field.name,
365
- table: table.name,
366
- action: 'modify',
367
- sql: `MODIFY COLUMN ${fieldSQL}`,
368
- });
369
413
  }
370
414
  }
371
415
  /**
@@ -378,13 +422,8 @@ async function updateTable(table, s) {
378
422
  for (const field of fieldsToAdd) {
379
423
  if (field.destinationDb)
380
424
  continue;
381
- let fieldSQL = generateFieldSQL(field);
382
- /**
383
- * Check if the field is an identifier
384
- */
385
- if (field.name === table.identifier?.name) {
386
- fieldSQL += ' UNIQUE FIRST';
387
- }
425
+ const fieldSQLResult = [generateFieldSQL(field)].flat();
426
+ const isIdentifier = fieldSQLResult.length === 1 && field.name === table.identifier?.name;
388
427
  /**
389
428
  * Check if there are fields to remove
390
429
  * If there are, ask the user if they want to add the new field or rename a to-be-removed field
@@ -405,12 +444,14 @@ async function updateTable(table, s) {
405
444
  * Field doesn't exist.
406
445
  * Add the field to the table
407
446
  */
408
- alterTableSQLs.push({
409
- field: field.name,
410
- table: table.name,
411
- action: 'add',
412
- sql: `ADD COLUMN ${fieldSQL}`,
413
- });
447
+ for (const fieldSQL of fieldSQLResult) {
448
+ alterTableSQLs.push({
449
+ field: field.name,
450
+ table: table.name,
451
+ action: 'add',
452
+ sql: `ADD COLUMN ${fieldSQL}${isIdentifier ? ' UNIQUE FIRST' : ''}`,
453
+ });
454
+ }
414
455
  break;
415
456
  case 'rename': {
416
457
  s.stop();
@@ -448,12 +489,14 @@ async function updateTable(table, s) {
448
489
  * Field doesn't exist.
449
490
  * Add the field to the table
450
491
  */
451
- alterTableSQLs.push({
452
- field: field.name,
453
- table: table.name,
454
- action: 'add',
455
- sql: `ADD COLUMN ${fieldSQL}`,
456
- });
492
+ for (const fieldSQL of fieldSQLResult) {
493
+ alterTableSQLs.push({
494
+ field: field.name,
495
+ table: table.name,
496
+ action: 'add',
497
+ sql: `ADD COLUMN ${fieldSQL}${isIdentifier ? ' UNIQUE FIRST' : ''}`,
498
+ });
499
+ }
457
500
  }
458
501
  }
459
502
  }
@@ -571,20 +614,10 @@ const main = async (s) => {
571
614
  const schemaFileName = cmsConfig.schemaGeneration.drizzle.fileName;
572
615
  const schemaFilePath = path.join(schemaOutDir, schemaFileName);
573
616
  /**
574
- * Remove the existing schema file
617
+ * Prepare schema generation.
618
+ * We intentionally keep the existing schema file in place until we are ready to write the new one.
575
619
  */
576
620
  if (schemaGenerationEnabled) {
577
- console.log(chalk.white(`Removing existing schema file...`));
578
- s.start();
579
- try {
580
- if (fs.existsSync(schemaFilePath)) {
581
- fs.unlinkSync(schemaFilePath);
582
- }
583
- }
584
- catch (error) {
585
- console.error('Error removing schema file:', error);
586
- }
587
- s.stop();
588
621
  console.log(chalk.white(`Generating Drizzle schema...`));
589
622
  s.start();
590
623
  }
@@ -853,13 +886,13 @@ const main = async (s) => {
853
886
  fs.mkdirSync(schemaOutDir, { recursive: true });
854
887
  }
855
888
  /**
856
- * Append the Drizzle imports to the schema file
857
- */
858
- fs.appendFileSync(schemaFilePath, 'import {' + [...drizzleImports].join(',') + "} from 'drizzle-orm/mysql-core'\n\n");
859
- /**
860
- * Append the Drizzle table schemas to the schema file
889
+ * Overwrite the schema only when generation is ready, so failed runs do not delete the previous schema.
861
890
  */
862
- fs.appendFileSync(schemaFilePath, drizzleTableSchemas.join('\n'));
891
+ const schemaFileContent = 'import {' +
892
+ [...drizzleImports].join(',') +
893
+ "} from 'drizzle-orm/mysql-core'\n\n" +
894
+ drizzleTableSchemas.join('\n');
895
+ fs.writeFileSync(schemaFilePath, schemaFileContent, 'utf8');
863
896
  s.stop();
864
897
  }
865
898
  console.log(chalk.white('Finding tables to create, update or remove...'));
@@ -911,6 +944,27 @@ const main = async (s) => {
911
944
  * Loop through the tables to create
912
945
  */
913
946
  for (const table of tablesToCreate) {
947
+ const tableExistsInDatabase = (await MysqlTableChecker.getExistingTableStructure(table.name)) !== null;
948
+ if (tableExistsInDatabase) {
949
+ s.stop();
950
+ const overwriteExistingTable = await select({
951
+ message: `Table '${table.name}' already exists in your database, overwrite its fields if any?`,
952
+ options: [
953
+ { value: 'yes', label: 'Yes, overwrite fields' },
954
+ { value: 'no', label: 'No, skip for now' },
955
+ ],
956
+ initialValue: 'yes',
957
+ });
958
+ s.start();
959
+ if (overwriteExistingTable === 'yes') {
960
+ await ensureTableRegistryEntry(table.name, table.sectionName);
961
+ await updateTable(table, s);
962
+ }
963
+ else {
964
+ console.log(chalk.yellow(`Skipping existing table '${table.name}'.`));
965
+ }
966
+ continue;
967
+ }
914
968
  /**
915
969
  * Check if there are tables to remove
916
970
  * If there are, ask the user if they want to create the new table or rename a removed table
@@ -928,44 +982,7 @@ const main = async (s) => {
928
982
  switch (opType) {
929
983
  case 'new': {
930
984
  console.log(chalk.blueBright(`Creating table '${table.name}' for section '${table.sectionName}'`));
931
- let options = {
932
- createdAt: true,
933
- updatedAt: true,
934
- createdBy: true,
935
- updatedBy: true,
936
- };
937
- if (table.sectionType === 'simple') {
938
- options = {
939
- createdAt: false,
940
- updatedAt: true,
941
- createdBy: false,
942
- updatedBy: true,
943
- };
944
- }
945
- if (table.sectionType === 'gallery') {
946
- options = {
947
- updatedBy: false,
948
- updatedAt: false,
949
- createdBy: true,
950
- createdAt: true,
951
- };
952
- }
953
- if (table.sectionType === 'destinationDb') {
954
- options = {
955
- createdAt: true,
956
- updatedAt: true,
957
- createdBy: false,
958
- updatedBy: false,
959
- };
960
- }
961
- if (table.sectionType === 'locales') {
962
- options = {
963
- createdAt: true,
964
- updatedAt: true,
965
- createdBy: false,
966
- updatedBy: false,
967
- };
968
- }
985
+ const options = resolveCreateTableOptions(table.sectionType);
969
986
  await createTable(table, options);
970
987
  break;
971
988
  }
@@ -1000,44 +1017,7 @@ const main = async (s) => {
1000
1017
  })
1001
1018
  ) {*/
1002
1019
  console.log(chalk.blueBright(`Creating table '${table.name}' for section '${table.sectionName}'`));
1003
- let options = {
1004
- createdAt: true,
1005
- updatedAt: true,
1006
- createdBy: true,
1007
- updatedBy: true,
1008
- };
1009
- if (table.sectionType === 'simple') {
1010
- options = {
1011
- createdAt: false,
1012
- updatedAt: true,
1013
- createdBy: false,
1014
- updatedBy: true,
1015
- };
1016
- }
1017
- if (table.sectionType === 'gallery') {
1018
- options = {
1019
- updatedBy: false,
1020
- updatedAt: false,
1021
- createdBy: true,
1022
- createdAt: true,
1023
- };
1024
- }
1025
- if (table.sectionType === 'destinationDb') {
1026
- options = {
1027
- createdAt: true,
1028
- updatedAt: true,
1029
- createdBy: false,
1030
- updatedBy: false,
1031
- };
1032
- }
1033
- if (table.sectionType === 'locales') {
1034
- options = {
1035
- createdAt: true,
1036
- updatedAt: true,
1037
- createdBy: false,
1038
- updatedBy: false,
1039
- };
1040
- }
1020
+ const options = resolveCreateTableOptions(table.sectionType);
1041
1021
  await createTable(table, options);
1042
1022
  /*} else {
1043
1023
  console.log('Aborting...')
@@ -1 +1 @@
1
- {"version":3,"file":"section-factory-with-esbuild.d.ts","sourceRoot":"","sources":["../../../src/core/factories/section-factory-with-esbuild.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,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;;;;;OASG;mBACkB,GAAG;IA6FxB;;;;OAIG;mBACkB,eAAe;IA4LpC,OAAO,CAAC,MAAM,CAAC,YAAY;IAqD3B,OAAO,CAAC,MAAM,CAAC,IAAI;CAatB"}
@@ -222,7 +222,11 @@ export class SectionFactory {
222
222
  */
223
223
  static async getSectionsSilently(type) {
224
224
  this.setIsCLI();
225
- return await this.getSections(type);
225
+ const sections = await this.getSections(type);
226
+ if (this.errorCount > 0) {
227
+ throw new Error('Section configuration errors detected. Fix section files and rerun the command.');
228
+ }
229
+ return sections;
226
230
  }
227
231
  /**
228
232
  * Get all sections
@@ -1 +1 @@
1
- {"version":3,"file":"section-factory-with-jiti.d.ts","sourceRoot":"","sources":["../../../src/core/factories/section-factory-with-jiti.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAgCrD,eAAO,MAAM,uBAAuB,cAAoC,CAAA;AAqFxE,KAAK,gBAAgB,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,qBAAqB,CAAA;AAE3F,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAwC;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAc;IAC5C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAQ;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAA+B;IACrE,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAA+B;IACnE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAI;IAE7B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA2C;IA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ACR,EAAE;QACC,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;QACpC,KAAK,EAAE;YACH,EAAE,EAAE,MAAM,CAAA;YACV,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;SACjC,CAAA;KACJ,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKpC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAClB,KAAK,EAAE,MAAM,eAAe,GAAG,aAAa,GAAG,eAAe,CAAA;QAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACrB,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe;IAYrD;;;;;;;;;OASG;mBACkB,GAAG;IA6FxB;;;;OAIG;mBACkB,eAAe;IA4LpC,OAAO,CAAC,MAAM,CAAC,YAAY;IA6E3B;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA+D5C,OAAO,CAAC,MAAM,CAAC,IAAI;CAatB"}
1
+ {"version":3,"file":"section-factory-with-jiti.d.ts","sourceRoot":"","sources":["../../../src/core/factories/section-factory-with-jiti.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC7G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAgCrD,eAAO,MAAM,uBAAuB,cAAoC,CAAA;AAqFxE,KAAK,gBAAgB,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,qBAAqB,CAAA;AAE3F,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAwC;IACrE,OAAO,CAAC,MA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AM,CAAA;SACf,EAAE,CAAA;KACN,CAAC;IAwCF;;;;;OAKG;WACU,UAAU,CAAC,EACpB,IAAI,EACJ,IAAI,GACP,EAAE;QACC,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;KACvC,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKpC;;;;;;OAMG;WACU,kBAAkB,CAAC,EAC5B,IAAI,EACJ,IAAI,EACJ,KAAK,GACR,EAAE;QACC,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,YAAY,GAAG,YAAY,EAAE,CAAA;QACpC,KAAK,EAAE;YACH,EAAE,EAAE,MAAM,CAAA;YACV,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;SACjC,CAAA;KACJ,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAKpC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAClB,KAAK,EAAE,MAAM,eAAe,GAAG,aAAa,GAAG,eAAe,CAAA;QAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KACrB,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe;IAYrD;;;;;;;;;OASG;mBACkB,GAAG;IA6FxB;;;;OAIG;mBACkB,eAAe;IA4LpC,OAAO,CAAC,MAAM,CAAC,YAAY;IA6E3B;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IA+D5C,OAAO,CAAC,MAAM,CAAC,IAAI;CAatB"}
@@ -172,7 +172,11 @@ export class SectionFactory {
172
172
  */
173
173
  static async getSectionsSilently(type) {
174
174
  this.setIsCLI();
175
- return await this.getSections(type);
175
+ const sections = await this.getSections(type);
176
+ if (this.errorCount > 0) {
177
+ throw new Error('Section configuration errors detected. Fix section files and rerun the command.');
178
+ }
179
+ return sections;
176
180
  }
177
181
  /**
178
182
  * Get all sections
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextjs-cms",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -210,8 +210,8 @@
210
210
  "tsx": "^4.20.6",
211
211
  "typescript": "^5.9.2",
212
212
  "@lzcms/eslint-config": "0.3.0",
213
- "@lzcms/tsconfig": "0.1.0",
214
- "@lzcms/prettier-config": "0.1.0"
213
+ "@lzcms/prettier-config": "0.1.0",
214
+ "@lzcms/tsconfig": "0.1.0"
215
215
  },
216
216
  "license": "MIT",
217
217
  "keywords": [