@betterstart/cli 0.1.17 → 0.1.18

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/dist/cli.js CHANGED
@@ -4672,7 +4672,12 @@ export const ${toCamelCase5(junctionName)} = pgTable(
4672
4672
  }
4673
4673
  function mergeImports(content, requiredImports, needsSql) {
4674
4674
  const pgCoreMatch = content.match(/import\s+\{([^}]+)\}\s+from\s+['"]drizzle-orm\/pg-core['"]/);
4675
- const hasSqlImport = content.includes("import { sql } from 'drizzle-orm'");
4675
+ const drizzleOrmMatch = content.match(/import\s*\{([^}]*)\}\s*from\s*['"]drizzle-orm['"]/);
4676
+ const existingDrizzleOrmImports = /* @__PURE__ */ new Set();
4677
+ if (drizzleOrmMatch) {
4678
+ drizzleOrmMatch[1].split(",").map((i) => i.trim()).filter(Boolean).forEach((i) => existingDrizzleOrmImports.add(i));
4679
+ }
4680
+ const hasSqlImport = existingDrizzleOrmImports.has("sql");
4676
4681
  const existing = /* @__PURE__ */ new Set();
4677
4682
  if (pgCoreMatch) {
4678
4683
  pgCoreMatch[1].split(",").map((i) => i.trim()).filter(Boolean).forEach((i) => {
@@ -4687,9 +4692,9 @@ function mergeImports(content, requiredImports, needsSql) {
4687
4692
  let updated = content;
4688
4693
  if (pgCoreMatch) {
4689
4694
  updated = updated.replace(/import\s+\{[^}]+\}\s+from\s+['"]drizzle-orm\/pg-core['"]/, newImport);
4690
- } else if (hasSqlImport) {
4695
+ } else if (drizzleOrmMatch) {
4691
4696
  updated = updated.replace(
4692
- /import\s+\{[^}]+\}\s+from\s+['"]drizzle-orm['"]/,
4697
+ /import\s*\{[^}]*\}\s*from\s*['"]drizzle-orm['"]/,
4693
4698
  (match) => `${match}
4694
4699
  ${newImport}`
4695
4700
  );
@@ -4698,8 +4703,17 @@ ${newImport}`
4698
4703
  ${updated}`;
4699
4704
  }
4700
4705
  if (needsSql && !hasSqlImport) {
4701
- updated = `import { sql } from 'drizzle-orm'
4706
+ if (drizzleOrmMatch) {
4707
+ existingDrizzleOrmImports.add("sql");
4708
+ const sortedOrm = Array.from(existingDrizzleOrmImports).sort();
4709
+ updated = updated.replace(
4710
+ /import\s*\{[^}]*\}\s*from\s*['"]drizzle-orm['"]/,
4711
+ `import { ${sortedOrm.join(", ")} } from 'drizzle-orm'`
4712
+ );
4713
+ } else {
4714
+ updated = `import { sql } from 'drizzle-orm'
4702
4715
  ${updated}`;
4716
+ }
4703
4717
  }
4704
4718
  return updated;
4705
4719
  }