runcastle 1.6.1 → 1.6.2
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/bin/runcastle.js +2166 -18
- package/index.js +28 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2060,11 +2060,35 @@ var init_schema = __esm(() => {
|
|
|
2060
2060
|
// src/db/client.ts
|
|
2061
2061
|
var exports_client = {};
|
|
2062
2062
|
__export(exports_client, {
|
|
2063
|
+
openRawSqlite: () => openRawSqlite,
|
|
2063
2064
|
createDb: () => createDb,
|
|
2064
2065
|
BUSY_TIMEOUT_MS: () => BUSY_TIMEOUT_MS
|
|
2065
2066
|
});
|
|
2066
2067
|
import { Database } from "bun:sqlite";
|
|
2067
2068
|
import { drizzle } from "drizzle-orm/bun-sqlite";
|
|
2069
|
+
function openRawSqlite(path, opts) {
|
|
2070
|
+
const sqlite = new Database(path, opts.readonly ? { readonly: true } : { readwrite: true });
|
|
2071
|
+
sqlite.exec(`PRAGMA busy_timeout = ${BUSY_TIMEOUT_MS};`);
|
|
2072
|
+
return {
|
|
2073
|
+
all: (sql, ...params) => {
|
|
2074
|
+
const statement = sqlite.prepare(sql);
|
|
2075
|
+
try {
|
|
2076
|
+
return statement.all(...params);
|
|
2077
|
+
} finally {
|
|
2078
|
+
statement.finalize();
|
|
2079
|
+
}
|
|
2080
|
+
},
|
|
2081
|
+
run: (sql, ...params) => {
|
|
2082
|
+
const statement = sqlite.prepare(sql);
|
|
2083
|
+
try {
|
|
2084
|
+
statement.run(...params);
|
|
2085
|
+
} finally {
|
|
2086
|
+
statement.finalize();
|
|
2087
|
+
}
|
|
2088
|
+
},
|
|
2089
|
+
close: () => sqlite.close()
|
|
2090
|
+
};
|
|
2091
|
+
}
|
|
2068
2092
|
function createDb(path) {
|
|
2069
2093
|
const sqlite = new Database(path, { create: true });
|
|
2070
2094
|
sqlite.exec(`PRAGMA busy_timeout = ${BUSY_TIMEOUT_MS};`);
|
|
@@ -2132,6 +2156,9 @@ var init_asset_paths = __esm(() => {
|
|
|
2132
2156
|
import { readFileSync as readFileSync2, readdirSync } from "fs";
|
|
2133
2157
|
import { join as join4 } from "path";
|
|
2134
2158
|
import { sql } from "drizzle-orm";
|
|
2159
|
+
function bundledMigrations(dir = MIGRATIONS_DIR) {
|
|
2160
|
+
return readdirSync(dir).filter((f) => f.endsWith(".sql")).sort();
|
|
2161
|
+
}
|
|
2135
2162
|
function runMigrations(db, dir = MIGRATIONS_DIR) {
|
|
2136
2163
|
db.run(sql.raw(`CREATE TABLE IF NOT EXISTS __migrations (
|
|
2137
2164
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -2140,8 +2167,7 @@ function runMigrations(db, dir = MIGRATIONS_DIR) {
|
|
|
2140
2167
|
)`));
|
|
2141
2168
|
const appliedRows = db.all(sql.raw("SELECT name FROM __migrations"));
|
|
2142
2169
|
const applied = new Set(appliedRows.map((r) => r.name));
|
|
2143
|
-
const
|
|
2144
|
-
for (const file of files) {
|
|
2170
|
+
for (const file of bundledMigrations(dir)) {
|
|
2145
2171
|
if (applied.has(file))
|
|
2146
2172
|
continue;
|
|
2147
2173
|
const contents = readFileSync2(join4(dir, file), "utf8");
|