@famgia/omnify-cli 0.0.44 → 0.0.46
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 +29 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +24 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -670,7 +670,7 @@ function registerDiffCommand(program2) {
|
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
// src/commands/generate.ts
|
|
673
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
673
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readdirSync } from "fs";
|
|
674
674
|
import { resolve as resolve6, dirname as dirname4 } from "path";
|
|
675
675
|
import {
|
|
676
676
|
loadSchemas as loadSchemas3,
|
|
@@ -1179,6 +1179,24 @@ function generateAIGuides(rootDir, plugins) {
|
|
|
1179
1179
|
function hasPluginGenerators(plugins) {
|
|
1180
1180
|
return plugins.some((p) => p.generators && p.generators.length > 0);
|
|
1181
1181
|
}
|
|
1182
|
+
function getExistingMigrationTables(migrationsDir) {
|
|
1183
|
+
const existingTables = /* @__PURE__ */ new Set();
|
|
1184
|
+
if (!existsSync4(migrationsDir)) {
|
|
1185
|
+
return existingTables;
|
|
1186
|
+
}
|
|
1187
|
+
try {
|
|
1188
|
+
const files = readdirSync(migrationsDir);
|
|
1189
|
+
const createMigrationPattern = /^\d{4}_\d{2}_\d{2}_\d{6}_create_(.+)_table\.php$/;
|
|
1190
|
+
for (const file of files) {
|
|
1191
|
+
const match = file.match(createMigrationPattern);
|
|
1192
|
+
if (match) {
|
|
1193
|
+
existingTables.add(match[1]);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
} catch {
|
|
1197
|
+
}
|
|
1198
|
+
return existingTables;
|
|
1199
|
+
}
|
|
1182
1200
|
function logSchemaChange(change, verbose) {
|
|
1183
1201
|
logger.debug(` ${change.changeType}: ${change.schemaName}`);
|
|
1184
1202
|
if (!verbose || change.changeType !== "modified") {
|
|
@@ -1424,12 +1442,18 @@ function runDirectGeneration(schemas, config, rootDir, options, changes) {
|
|
|
1424
1442
|
const alterChanges = changes.filter(
|
|
1425
1443
|
(c) => c.changeType === "modified" || c.changeType === "removed"
|
|
1426
1444
|
);
|
|
1445
|
+
const existingTables = getExistingMigrationTables(migrationsDir);
|
|
1427
1446
|
if (addedSchemaNames.size > 0) {
|
|
1428
1447
|
const addedSchemas = Object.fromEntries(
|
|
1429
1448
|
Object.entries(schemas).filter(([name]) => addedSchemaNames.has(name))
|
|
1430
1449
|
);
|
|
1431
1450
|
const createMigrations = generateMigrations(addedSchemas, { customTypes: customTypesMap });
|
|
1432
1451
|
for (const migration of createMigrations) {
|
|
1452
|
+
const tableName = migration.tables[0];
|
|
1453
|
+
if (existingTables.has(tableName)) {
|
|
1454
|
+
logger.debug(`Skipped CREATE for ${tableName} (already exists)`);
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1433
1457
|
const filePath = resolve6(migrationsDir, migration.fileName);
|
|
1434
1458
|
writeFileSync3(filePath, migration.content);
|
|
1435
1459
|
logger.debug(`Created: ${migration.fileName}`);
|
|
@@ -1703,7 +1727,7 @@ function registerGenerateCommand(program2) {
|
|
|
1703
1727
|
}
|
|
1704
1728
|
|
|
1705
1729
|
// src/commands/reset.ts
|
|
1706
|
-
import { existsSync as existsSync5, readdirSync, rmSync, statSync } from "fs";
|
|
1730
|
+
import { existsSync as existsSync5, readdirSync as readdirSync2, rmSync, statSync } from "fs";
|
|
1707
1731
|
import { resolve as resolve7, dirname as dirname5, join } from "path";
|
|
1708
1732
|
import { createInterface } from "readline";
|
|
1709
1733
|
async function confirm2(message) {
|
|
@@ -1721,7 +1745,7 @@ async function confirm2(message) {
|
|
|
1721
1745
|
function countFiles(dir) {
|
|
1722
1746
|
if (!existsSync5(dir)) return 0;
|
|
1723
1747
|
let count = 0;
|
|
1724
|
-
const entries =
|
|
1748
|
+
const entries = readdirSync2(dir);
|
|
1725
1749
|
for (const entry of entries) {
|
|
1726
1750
|
const fullPath = join(dir, entry);
|
|
1727
1751
|
const stat = statSync(fullPath);
|
|
@@ -1745,7 +1769,7 @@ function deleteDir(dir, verbose) {
|
|
|
1745
1769
|
function deleteFilesInDir(dir, pattern, verbose) {
|
|
1746
1770
|
if (!existsSync5(dir)) return 0;
|
|
1747
1771
|
let count = 0;
|
|
1748
|
-
const entries =
|
|
1772
|
+
const entries = readdirSync2(dir);
|
|
1749
1773
|
for (const entry of entries) {
|
|
1750
1774
|
const fullPath = join(dir, entry);
|
|
1751
1775
|
const stat = statSync(fullPath);
|
|
@@ -1833,7 +1857,7 @@ async function runReset(options) {
|
|
|
1833
1857
|
const count = countFiles(item.path);
|
|
1834
1858
|
logger.info(` \u2022 ${item.name}: ${item.path} (${count} files)`);
|
|
1835
1859
|
} else if (item.type === "files" && item.pattern) {
|
|
1836
|
-
const count =
|
|
1860
|
+
const count = readdirSync2(item.path).filter((f) => item.pattern.test(f)).length;
|
|
1837
1861
|
logger.info(` \u2022 ${item.name}: ${item.path} (${count} files)`);
|
|
1838
1862
|
} else {
|
|
1839
1863
|
logger.info(` \u2022 ${item.name}: ${item.path}`);
|