hollware 0.0.1 → 0.1.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/README.md +50 -11
- package/dist/args-CljWh-kZ.mjs +20 -0
- package/dist/d1-Bd-sdoDd.mjs +281 -0
- package/dist/entropy-CIYbTHkj.mjs +17 -0
- package/dist/format-BpRYEsGB.mjs +38 -0
- package/dist/import-Dlpn_w3s.mjs +506 -0
- package/dist/index.d.mts +49 -8
- package/dist/index.mjs +75 -28
- package/dist/init-Cl9Epsbp.mjs +108 -0
- package/dist/migrate-CLHWuUje.mjs +118 -0
- package/dist/token-BLkrPLio.mjs +228 -0
- package/dist/version-BMhdZaNo.mjs +9 -0
- package/dist/wrangler-BLIfwbcu.mjs +106 -0
- package/package.json +9 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { r as CliError } from "./format-BpRYEsGB.mjs";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
//#region src/wrangler.ts
|
|
6
|
+
/**
|
|
7
|
+
* The `wrangler` of the project: the nearest `node_modules/.bin/wrangler` from `cwd` upwards,
|
|
8
|
+
* so a workspace that hoists its dependencies finds it too. Never a global wrangler, never
|
|
9
|
+
* `npx`: the CLI runs the version the project pinned.
|
|
10
|
+
*/
|
|
11
|
+
function findWrangler(cwd) {
|
|
12
|
+
let directory = cwd;
|
|
13
|
+
for (;;) {
|
|
14
|
+
const candidate = join(directory, "node_modules", ".bin", "wrangler");
|
|
15
|
+
if (existsSync(candidate)) return candidate;
|
|
16
|
+
const parent = dirname(directory);
|
|
17
|
+
if (parent === directory) return void 0;
|
|
18
|
+
directory = parent;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A runner that starts the project's wrangler as a child process in `cwd`. Its stdin is closed
|
|
23
|
+
* and its output is captured, so wrangler runs without a terminal and never asks anything. It
|
|
24
|
+
* inherits the environment, which is where wrangler finds its Cloudflare credentials.
|
|
25
|
+
*/
|
|
26
|
+
function createWranglerRunner(cwd) {
|
|
27
|
+
return (args) => {
|
|
28
|
+
const bin = findWrangler(cwd);
|
|
29
|
+
if (bin === void 0) return Promise.reject(new CliError(`wrangler is not installed in ${cwd} or any directory above it. Install it in the project (for example "pnpm add -D wrangler") and run hollware from the project directory.`));
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const child = spawn(bin, [...args], {
|
|
32
|
+
cwd,
|
|
33
|
+
stdio: [
|
|
34
|
+
"ignore",
|
|
35
|
+
"pipe",
|
|
36
|
+
"pipe"
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
let stdout = "";
|
|
40
|
+
let stderr = "";
|
|
41
|
+
child.stdout.setEncoding("utf8");
|
|
42
|
+
child.stderr.setEncoding("utf8");
|
|
43
|
+
child.stdout.on("data", (chunk) => {
|
|
44
|
+
stdout += chunk;
|
|
45
|
+
});
|
|
46
|
+
child.stderr.on("data", (chunk) => {
|
|
47
|
+
stderr += chunk;
|
|
48
|
+
});
|
|
49
|
+
child.on("error", (error) => {
|
|
50
|
+
reject(new CliError(`could not run ${bin}: ${error.message}`));
|
|
51
|
+
});
|
|
52
|
+
child.on("close", (code, signal) => {
|
|
53
|
+
if (signal !== null) stderr += `\nwrangler was stopped by ${signal}`;
|
|
54
|
+
resolve({
|
|
55
|
+
code: code ?? 1,
|
|
56
|
+
stdout,
|
|
57
|
+
stderr
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const ANSI = new RegExp(String.raw`\u001B\[[0-9;]*[A-Za-z]`, "g");
|
|
64
|
+
/** `text` without terminal escape sequences. */
|
|
65
|
+
function stripAnsi(text) {
|
|
66
|
+
return text.replace(ANSI, "");
|
|
67
|
+
}
|
|
68
|
+
const MAX_REASON = 400;
|
|
69
|
+
/**
|
|
70
|
+
* Why a run of wrangler failed, in one line: the `error` of its `--json` answer, else the text
|
|
71
|
+
* of its first `[ERROR]` message, else the last line it wrote to stderr or, failing that, to
|
|
72
|
+
* stdout.
|
|
73
|
+
*/
|
|
74
|
+
function failureReason(result) {
|
|
75
|
+
const stdout = stripAnsi(result.stdout);
|
|
76
|
+
const stderr = stripAnsi(result.stderr);
|
|
77
|
+
const fromJson = jsonError(stdout.trim());
|
|
78
|
+
if (fromJson !== void 0) return oneLine(fromJson);
|
|
79
|
+
const stderrLines = linesOf(stderr);
|
|
80
|
+
for (const line of stderrLines) {
|
|
81
|
+
const message = /^\W*\[ERROR\]\s*(.+)$/.exec(line)?.[1];
|
|
82
|
+
if (message !== void 0) return oneLine(message);
|
|
83
|
+
}
|
|
84
|
+
return oneLine(stderrLines.at(-1) ?? linesOf(stdout).at(-1) ?? `wrangler exited with code ${result.code} and printed nothing`);
|
|
85
|
+
}
|
|
86
|
+
function linesOf(text) {
|
|
87
|
+
return text.split("\n").map((line) => line.trim()).filter((line) => line !== "" && !line.includes("Logs were written to"));
|
|
88
|
+
}
|
|
89
|
+
function jsonError(stdout) {
|
|
90
|
+
try {
|
|
91
|
+
const parsed = JSON.parse(stdout);
|
|
92
|
+
if (typeof parsed !== "object" || parsed === null || !("error" in parsed)) return void 0;
|
|
93
|
+
const { error } = parsed;
|
|
94
|
+
if (typeof error === "string") return error;
|
|
95
|
+
if (typeof error === "object" && error !== null && "text" in error) return typeof error.text === "string" ? error.text : void 0;
|
|
96
|
+
return;
|
|
97
|
+
} catch {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function oneLine(text) {
|
|
102
|
+
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
103
|
+
return collapsed.length > MAX_REASON ? `${collapsed.slice(0, MAX_REASON)}…` : collapsed;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { failureReason as n, stripAnsi as r, createWranglerRunner as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hollware",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "The Hollware CLI: init, migrate, token, import and export.",
|
|
5
5
|
"homepage": "https://hollware.com",
|
|
6
6
|
"bugs": {
|
|
@@ -30,11 +30,18 @@
|
|
|
30
30
|
"access": "public",
|
|
31
31
|
"provenance": true
|
|
32
32
|
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@hollware/core": "0.1.0",
|
|
35
|
+
"@modelcontextprotocol/client": "2.3.1",
|
|
36
|
+
"zod": "4.6.5"
|
|
37
|
+
},
|
|
33
38
|
"devDependencies": {
|
|
39
|
+
"@modelcontextprotocol/server": "2.3.1",
|
|
34
40
|
"@types/node": "24.19.2",
|
|
35
41
|
"publint": "0.3.25",
|
|
36
42
|
"typescript": "7.0.2",
|
|
37
|
-
"vite-plus": "1.1.0"
|
|
43
|
+
"vite-plus": "1.1.0",
|
|
44
|
+
"wrangler": "4.149.0"
|
|
38
45
|
},
|
|
39
46
|
"engines": {
|
|
40
47
|
"node": ">=24.11.0"
|