@cleocode/cleo 2026.4.53 → 2026.4.54
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/index.js +52 -4
- package/dist/cli/index.js.map +2 -2
- package/package.json +8 -8
package/dist/cli/index.js
CHANGED
|
@@ -11434,6 +11434,54 @@ function insertJournalEntry(nativeDb, hash2, createdAt, name2) {
|
|
|
11434
11434
|
`INSERT OR IGNORE INTO "__drizzle_migrations" ("hash", "created_at", "name") VALUES ('${hash2}', ${createdAt}, '${name2}')`
|
|
11435
11435
|
);
|
|
11436
11436
|
}
|
|
11437
|
+
function probeAndMarkApplied(nativeDb, migration, logSubsystem) {
|
|
11438
|
+
const sqlStatements = Array.isArray(migration.sql) ? migration.sql : [migration.sql ?? ""];
|
|
11439
|
+
const fullSql = sqlStatements.join("\n");
|
|
11440
|
+
const alterColumnRegex = /ALTER\s+TABLE\s+[`"]?(\w+)[`"]?\s+ADD\s+COLUMN\s+[`"]?(\w+)[`"]?/gi;
|
|
11441
|
+
const createTableRegex = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?/gi;
|
|
11442
|
+
const createIndexRegex = /CREATE\s+(?:UNIQUE\s+)?INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?/gi;
|
|
11443
|
+
const alterTargets = [];
|
|
11444
|
+
for (const m2 of fullSql.matchAll(alterColumnRegex)) {
|
|
11445
|
+
alterTargets.push({ table: m2[1], column: m2[2] });
|
|
11446
|
+
}
|
|
11447
|
+
const tableTargets = [];
|
|
11448
|
+
for (const m2 of fullSql.matchAll(createTableRegex)) {
|
|
11449
|
+
tableTargets.push(m2[1]);
|
|
11450
|
+
}
|
|
11451
|
+
const indexTargets = [];
|
|
11452
|
+
for (const m2 of fullSql.matchAll(createIndexRegex)) {
|
|
11453
|
+
indexTargets.push(m2[1]);
|
|
11454
|
+
}
|
|
11455
|
+
const totalTargets = alterTargets.length + tableTargets.length + indexTargets.length;
|
|
11456
|
+
if (totalTargets === 0) {
|
|
11457
|
+
return false;
|
|
11458
|
+
}
|
|
11459
|
+
const allAltersPresent = alterTargets.every(({ table, column }) => {
|
|
11460
|
+
if (!tableExists(nativeDb, table)) return false;
|
|
11461
|
+
const cols = nativeDb.prepare(`PRAGMA table_info(${table})`).all();
|
|
11462
|
+
return cols.some((c) => c.name === column);
|
|
11463
|
+
});
|
|
11464
|
+
const allTablesPresent = tableTargets.every((t) => tableExists(nativeDb, t));
|
|
11465
|
+
const allIndexesPresent = indexTargets.every((idx) => {
|
|
11466
|
+
const rows = nativeDb.prepare(`SELECT name FROM sqlite_master WHERE type='index' AND name=?`).all(idx);
|
|
11467
|
+
return rows.length > 0;
|
|
11468
|
+
});
|
|
11469
|
+
if (allAltersPresent && allTablesPresent && allIndexesPresent) {
|
|
11470
|
+
insertJournalEntry(nativeDb, migration.hash, migration.folderMillis, migration.name ?? "");
|
|
11471
|
+
const log13 = getLogger(logSubsystem);
|
|
11472
|
+
log13.debug(
|
|
11473
|
+
{
|
|
11474
|
+
migration: migration.name,
|
|
11475
|
+
alters: alterTargets.length,
|
|
11476
|
+
tables: tableTargets.length,
|
|
11477
|
+
indexes: indexTargets.length
|
|
11478
|
+
},
|
|
11479
|
+
`Migration ${migration.name} DDL already present in schema \u2014 marked applied.`
|
|
11480
|
+
);
|
|
11481
|
+
return true;
|
|
11482
|
+
}
|
|
11483
|
+
return false;
|
|
11484
|
+
}
|
|
11437
11485
|
function reconcileJournal(nativeDb, migrationsFolder, existenceTable, logSubsystem) {
|
|
11438
11486
|
if (tableExists(nativeDb, existenceTable) && !tableExists(nativeDb, "__drizzle_migrations")) {
|
|
11439
11487
|
const migrations = readMigrationFiles({ migrationsFolder });
|
|
@@ -11470,11 +11518,11 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable, logSubsyst
|
|
|
11470
11518
|
const log13 = getLogger(logSubsystem);
|
|
11471
11519
|
log13.warn(
|
|
11472
11520
|
{ orphaned: orphanedEntries.length },
|
|
11473
|
-
`Detected stale migration journal entries from a previous CLEO version. Reconciling.`
|
|
11521
|
+
`Detected stale migration journal entries from a previous CLEO version. Reconciling via DDL probe.`
|
|
11474
11522
|
);
|
|
11475
11523
|
nativeDb.exec('DELETE FROM "__drizzle_migrations"');
|
|
11476
11524
|
for (const m2 of localMigrations) {
|
|
11477
|
-
|
|
11525
|
+
probeAndMarkApplied(nativeDb, m2, logSubsystem);
|
|
11478
11526
|
}
|
|
11479
11527
|
}
|
|
11480
11528
|
}
|
|
@@ -15001,7 +15049,6 @@ function runBrainMigrations(nativeDb, db) {
|
|
|
15001
15049
|
"brain"
|
|
15002
15050
|
);
|
|
15003
15051
|
}
|
|
15004
|
-
ensureColumns(nativeDb, "brain_observations", [{ name: "agent", ddl: "text" }], "brain");
|
|
15005
15052
|
if (tableExists(nativeDb, "brain_page_edges")) {
|
|
15006
15053
|
nativeDb.prepare(
|
|
15007
15054
|
`UPDATE brain_page_edges
|
|
@@ -144911,7 +144958,8 @@ Logs: ${logFile}`
|
|
|
144911
144958
|
const port = opts["port"] ?? String(DEFAULT_PORT);
|
|
144912
144959
|
const host = opts["host"] ?? DEFAULT_HOST;
|
|
144913
144960
|
const startOpts = { port, host };
|
|
144914
|
-
const
|
|
144961
|
+
const startCmd = webCmd.commands.find((c) => c.name() === "start");
|
|
144962
|
+
const startAction = startCmd?.action;
|
|
144915
144963
|
if (startAction) {
|
|
144916
144964
|
await startAction(startOpts);
|
|
144917
144965
|
} else {
|