hollware 0.5.0 → 0.6.0
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/{deploy-B89D8gdO.mjs → deploy-BsMVUmdo.mjs} +1 -1
- package/dist/{doctor-Djx_3mLE.mjs → doctor-BjyO0PtA.mjs} +1 -1
- package/dist/index.mjs +3 -3
- package/dist/{migrate-D6Sgxnwx.mjs → migrate-DMeZtKzG.mjs} +34 -4
- package/dist/migrate-TZn5XR3F.mjs +2 -0
- package/package.json +2 -2
- package/dist/migrate-R7NAXgQT.mjs +0 -2
|
@@ -3,7 +3,7 @@ import { n as failureReason, r as stripAnsi } from "./wrangler-BLIfwbcu.mjs";
|
|
|
3
3
|
import { t as parseFlags } from "./args-CljWh-kZ.mjs";
|
|
4
4
|
import { f as ownerQuery, i as resolveDatabase, r as query } from "./d1-D5A6OVDD.mjs";
|
|
5
5
|
import { t as publicUrlOf } from "./public-url-DURHzCaC.mjs";
|
|
6
|
-
import { i as migrate } from "./migrate-
|
|
6
|
+
import { i as migrate } from "./migrate-DMeZtKzG.mjs";
|
|
7
7
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
//#region src/commands/deploy.ts
|
|
@@ -2,7 +2,7 @@ import { r as CliError } from "./format-BpRYEsGB.mjs";
|
|
|
2
2
|
import { n as failureReason } from "./wrangler-BLIfwbcu.mjs";
|
|
3
3
|
import { t as parseFlags } from "./args-CljWh-kZ.mjs";
|
|
4
4
|
import { S as parseJsonc, f as ownerQuery, r as query, t as chooseTarget } from "./d1-D5A6OVDD.mjs";
|
|
5
|
-
import { a as parsePendingMigrations } from "./migrate-
|
|
5
|
+
import { a as parsePendingMigrations } from "./migrate-DMeZtKzG.mjs";
|
|
6
6
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
//#region src/commands/doctor.ts
|
package/dist/index.mjs
CHANGED
|
@@ -106,9 +106,9 @@ async function main(argv, io) {
|
|
|
106
106
|
async function run(command, args, io) {
|
|
107
107
|
switch (command) {
|
|
108
108
|
case "init": return (await import("./init-D-q1JzcO.mjs")).init(args, io);
|
|
109
|
-
case "migrate": return (await import("./migrate-
|
|
110
|
-
case "deploy": return (await import("./deploy-
|
|
111
|
-
case "doctor": return (await import("./doctor-
|
|
109
|
+
case "migrate": return (await import("./migrate-TZn5XR3F.mjs")).migrate(args, io);
|
|
110
|
+
case "deploy": return (await import("./deploy-BsMVUmdo.mjs")).deploy(args, io);
|
|
111
|
+
case "doctor": return (await import("./doctor-BjyO0PtA.mjs")).doctor(args, io);
|
|
112
112
|
case "token": return (await import("./token-DeVLRP0z.mjs")).token(args, io);
|
|
113
113
|
case "invite": return (await import("./invite-PpZ5QNLx.mjs")).invite(args, io);
|
|
114
114
|
default: return (await import("./import-DG8AABZQ.mjs")).importContent(args, io);
|
|
@@ -9,9 +9,11 @@ const MIGRATE_USAGE = [
|
|
|
9
9
|
"Usage: hollware migrate [--local | --remote] [--check] [--database <name>]",
|
|
10
10
|
"",
|
|
11
11
|
"Applies the D1 migrations the project has not applied yet, with wrangler. Before it applies",
|
|
12
|
-
"anything to the remote database it exports a backup, and it stops if the backup fails.
|
|
13
|
-
"export
|
|
14
|
-
"
|
|
12
|
+
"anything to the remote database it exports a backup, and it stops if the backup fails. D1",
|
|
13
|
+
"cannot export a database with a full-text index (0.5 and later): it takes a Time Travel",
|
|
14
|
+
"bookmark instead, which restores the database as it was. The export can make the database",
|
|
15
|
+
"unavailable for a moment; with nothing pending, or on a new database that has none of the",
|
|
16
|
+
"migrations yet, there is no backup.",
|
|
15
17
|
"",
|
|
16
18
|
"Options:",
|
|
17
19
|
" --local Use the local database (the default)",
|
|
@@ -110,10 +112,38 @@ async function takeBackup(io, database) {
|
|
|
110
112
|
file,
|
|
111
113
|
"--skip-confirmation"
|
|
112
114
|
]);
|
|
113
|
-
if (exported.code !== 0)
|
|
115
|
+
if (exported.code !== 0) {
|
|
116
|
+
const reason = failureReason(exported);
|
|
117
|
+
if (/virtual tables?/i.test(reason)) return takeBookmark(io, database);
|
|
118
|
+
throw new CliError(`the backup of ${where} failed, so no migration was applied: ${reason}`);
|
|
119
|
+
}
|
|
114
120
|
if (!existsSync(file) || statSync(file).size === 0) throw new CliError(`wrangler reported success but wrote no backup to ${file}, so no migration was applied. Check "wrangler d1 export ${database} --remote --output <file>" by hand.`);
|
|
115
121
|
return file;
|
|
116
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* The backup of a database D1 cannot export: a Time Travel bookmark of now, and the command that
|
|
125
|
+
* restores the database to it.
|
|
126
|
+
*/
|
|
127
|
+
async function takeBookmark(io, database) {
|
|
128
|
+
const where = describeDatabase("remote", database);
|
|
129
|
+
io.out(`D1 cannot export ${where}, which has a full-text index; taking a Time Travel bookmark instead ...`);
|
|
130
|
+
const info = await io.wrangler([
|
|
131
|
+
"d1",
|
|
132
|
+
"time-travel",
|
|
133
|
+
"info",
|
|
134
|
+
database,
|
|
135
|
+
"--json"
|
|
136
|
+
]);
|
|
137
|
+
let bookmark = null;
|
|
138
|
+
try {
|
|
139
|
+
const parsed = JSON.parse(stripAnsi(info.stdout));
|
|
140
|
+
bookmark = typeof parsed === "object" && parsed !== null && "bookmark" in parsed ? parsed.bookmark : null;
|
|
141
|
+
} catch {
|
|
142
|
+
bookmark = null;
|
|
143
|
+
}
|
|
144
|
+
if (info.code !== 0 || typeof bookmark !== "string" || bookmark === "") throw new CliError(`no Time Travel bookmark of ${where} could be taken, so no migration was applied: ${info.code === 0 ? "wrangler answered no bookmark" : failureReason(info)}`);
|
|
145
|
+
return `the Time Travel bookmark ${bookmark}; restore it with "npx wrangler d1 time-travel restore ${database} --bookmark=${bookmark}"`;
|
|
146
|
+
}
|
|
117
147
|
/** `20261012T120000Z`: a moment, in UTC, that is safe in a file name. */
|
|
118
148
|
function timestamp(date) {
|
|
119
149
|
return date.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hollware",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "The Hollware CLI: init, migrate, token, import and export.",
|
|
5
5
|
"homepage": "https://hollware.com",
|
|
6
6
|
"bugs": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"provenance": true
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@hollware/core": "0.
|
|
34
|
+
"@hollware/core": "0.6.0",
|
|
35
35
|
"@modelcontextprotocol/client": "2.3.1",
|
|
36
36
|
"zod": "4.6.5"
|
|
37
37
|
},
|