@vexblocks/cli 1.0.5 → 1.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -490,7 +490,6 @@ async function installBackendPackage(targetPath, sourcePath, spinner) {
490
490
  "convex/auth.ts",
491
491
  "convex/auth.config.ts",
492
492
  "convex/http.ts",
493
- "convex/settings.ts",
494
493
  "better-auth",
495
494
  "emails"
496
495
  ];
@@ -509,23 +508,7 @@ async function installBackendPackage(targetPath, sourcePath, spinner) {
509
508
  }
510
509
  }
511
510
  }
512
- const schemaInstructions = `
513
- // === VEXBLOCKS CMS ===
514
- // Add the following imports and tables to your schema:
515
- //
516
- // import { cmsSchemaExports } from "./schema.cms"
517
- //
518
- // Then add to your defineSchema:
519
- // export default defineSchema({
520
- // ...yourExistingTables,
521
- // ...cmsSchemaExports,
522
- // })
523
- // === END VEXBLOCKS CMS ===
524
- `;
525
- const existingContent = await fs4.readFile(existingSchemaPath, "utf-8");
526
- if (!existingContent.includes("VEXBLOCKS CMS")) {
527
- await fs4.appendFile(existingSchemaPath, schemaInstructions);
528
- }
511
+ await mergeSchemaFile(existingSchemaPath, spinner);
529
512
  } else {
530
513
  await fs4.ensureDir(targetPath);
531
514
  await downloadAndExtractPackage(sourcePath, targetPath, (file) => {
@@ -587,6 +570,47 @@ function getOptionalEnvVars(packages) {
587
570
  }
588
571
  return vars;
589
572
  }
573
+ async function mergeSchemaFile(schemaPath, spinner) {
574
+ const content = await fs4.readFile(schemaPath, "utf-8");
575
+ if (content.includes('from "./schema.cms"')) {
576
+ spinner.text = "CMS schema already integrated";
577
+ return;
578
+ }
579
+ spinner.text = "Merging CMS schema into existing schema.ts...";
580
+ let newContent = content;
581
+ const importStatement = 'import { cmsSchemaExports } from "./schema.cms"';
582
+ const hasImport = content.includes(importStatement);
583
+ if (!hasImport) {
584
+ const importRegex = /^import\s+.*from\s+['"].*['"];?\s*$/gm;
585
+ const imports = [...content.matchAll(importRegex)];
586
+ if (imports.length > 0) {
587
+ const lastImport = imports[imports.length - 1];
588
+ const insertPosition = lastImport.index + lastImport[0].length;
589
+ newContent = newContent.slice(0, insertPosition) + `
590
+ ${importStatement}` + newContent.slice(insertPosition);
591
+ } else {
592
+ newContent = `${importStatement}
593
+
594
+ ${newContent}`;
595
+ }
596
+ }
597
+ const hasSpread = /defineSchema\s*\(\s*\{[^}]*\.\.\.cmsSchemaExports/s.test(
598
+ newContent
599
+ );
600
+ if (!hasSpread) {
601
+ const defineSchemaRegex = /defineSchema\s*\(\s*\{(\s*)/;
602
+ if (defineSchemaRegex.test(newContent)) {
603
+ newContent = newContent.replace(
604
+ defineSchemaRegex,
605
+ (_match, whitespace) => {
606
+ return `defineSchema({${whitespace}// VexBlocks CMS tables${whitespace}...cmsSchemaExports,${whitespace}`;
607
+ }
608
+ );
609
+ }
610
+ }
611
+ await fs4.writeFile(schemaPath, newContent, "utf-8");
612
+ spinner.text = "Successfully merged CMS schema";
613
+ }
590
614
 
591
615
  // src/commands/diff.ts
592
616
  import path5 from "path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vexblocks/cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "CLI for adding VexBlocks Headless CMS to your Turborepo project",
5
5
  "keywords": [
6
6
  "cms",