@coffre/cli 0.1.1 → 0.1.3
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/README.md +4 -1
- package/dist/access-CO1kGjWW.js +74 -0
- package/dist/connect-BONR52al.js +770 -0
- package/dist/connect-BZdPYNbZ.js +2 -0
- package/dist/esm-B69mMLcR.js +2 -0
- package/dist/esm-Bts-esAl.js +4202 -0
- package/dist/keys-RhB7ayOY.js +726 -0
- package/dist/main.js +10 -137
- package/dist/migrations/postgres/0000_baseline.sql +505 -0
- package/dist/migrations/postgres/meta/0000_snapshot.json +1939 -0
- package/dist/migrations/postgres/meta/_journal.json +13 -0
- package/dist/migrator-W1a-ooWi.js +37 -0
- package/dist/node-postgres-BlNvYfq_.js +2 -0
- package/dist/node-postgres-_y-EeSHQ.js +2831 -0
- package/dist/portable-CPh2thNN.js +87 -0
- package/dist/relations-CJCGPRst.js +2712 -0
- package/dist/schema-sqlite-Byp7B3yI.js +1078 -0
- package/dist/setup-3OJc_VCA.js +756 -0
- package/dist/templates/node/README.md +41 -48
- package/dist/templates/node/package.json +3 -3
- package/dist/templates/node/server.env.example +5 -4
- package/dist/templates/node/src/server.ts +3 -3
- package/dist/templates/node/src/vault.ts +7 -5
- package/dist/templates/node/vault.env.example +7 -7
- package/dist/templates/workers/README.md +47 -57
- package/dist/templates/workers/app/src/worker.ts +2 -2
- package/dist/templates/workers/app/wrangler.jsonc +4 -4
- package/dist/templates/workers/package.json +4 -4
- package/dist/templates/workers/vault/src/worker.ts +8 -7
- package/dist/templates/workers/vault/wrangler.jsonc +8 -6
- package/package.json +7 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/migrator.js
|
|
4
|
+
function readMigrationFiles(config) {
|
|
5
|
+
const migrationFolderTo = config.migrationsFolder;
|
|
6
|
+
const migrationQueries = [];
|
|
7
|
+
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
|
|
8
|
+
if (!fs.existsSync(journalPath)) throw new Error(`Can't find meta/_journal.json file`);
|
|
9
|
+
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
|
|
10
|
+
const journal = JSON.parse(journalAsString);
|
|
11
|
+
for (const journalEntry of journal.entries) {
|
|
12
|
+
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
|
|
13
|
+
try {
|
|
14
|
+
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
|
|
15
|
+
const result = query.split("--> statement-breakpoint").map((it) => {
|
|
16
|
+
return it;
|
|
17
|
+
});
|
|
18
|
+
migrationQueries.push({
|
|
19
|
+
sql: result,
|
|
20
|
+
bps: journalEntry.breakpoints,
|
|
21
|
+
folderMillis: journalEntry.when,
|
|
22
|
+
hash: crypto.createHash("sha256").update(query).digest("hex")
|
|
23
|
+
});
|
|
24
|
+
} catch {
|
|
25
|
+
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return migrationQueries;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@5.20260920.1_@libsql+client@0.18.0_@types+pg@8.20.0_pg@8.16.3/node_modules/drizzle-orm/node-postgres/migrator.js
|
|
32
|
+
async function migrate(db, config) {
|
|
33
|
+
const migrations = readMigrationFiles(config);
|
|
34
|
+
await db.dialect.migrate(migrations, db.session, config);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { migrate };
|