@githumbi/grabby 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/CHANGELOG.md +11 -0
- package/LICENSE +22 -0
- package/README.md +262 -0
- package/builders.json +14 -0
- package/dist/angular/index.d.ts +279 -0
- package/dist/angular/index.js +5145 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/babel-plugin/index.cjs +95 -0
- package/dist/babel-plugin/index.cjs.map +1 -0
- package/dist/babel-plugin/index.d.cts +28 -0
- package/dist/babel-plugin/index.d.ts +28 -0
- package/dist/babel-plugin/index.js +60 -0
- package/dist/babel-plugin/index.js.map +1 -0
- package/dist/builder/builders/application/index.js +141 -0
- package/dist/builder/builders/application/index.js.map +1 -0
- package/dist/builder/builders/application/schema.json +7 -0
- package/dist/builder/builders/dev-server/index.js +137 -0
- package/dist/builder/builders/dev-server/index.js.map +1 -0
- package/dist/builder/builders/dev-server/schema.json +26 -0
- package/dist/builder/index.js +2 -0
- package/dist/builder/index.js.map +1 -0
- package/dist/builder/package.json +1 -0
- package/dist/chunk-6CBIOKZV.cjs +45 -0
- package/dist/chunk-6CBIOKZV.cjs.map +1 -0
- package/dist/chunk-M3DOFJA7.js +45 -0
- package/dist/chunk-M3DOFJA7.js.map +1 -0
- package/dist/cli/index.js +406 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.cjs +5081 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +96 -0
- package/dist/core/index.d.ts +96 -0
- package/dist/core/index.js +5081 -0
- package/dist/core/index.js.map +1 -0
- package/dist/esbuild-plugin/index.cjs +134 -0
- package/dist/esbuild-plugin/index.cjs.map +1 -0
- package/dist/esbuild-plugin/index.d.cts +21 -0
- package/dist/esbuild-plugin/index.d.ts +21 -0
- package/dist/esbuild-plugin/index.js +96 -0
- package/dist/esbuild-plugin/index.js.map +1 -0
- package/dist/export/index.cjs +166 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +86 -0
- package/dist/export/index.d.ts +86 -0
- package/dist/export/index.js +137 -0
- package/dist/export/index.js.map +1 -0
- package/dist/grabby.global.js +635 -0
- package/dist/live/index.cjs +30 -0
- package/dist/live/index.cjs.map +1 -0
- package/dist/live/index.d.cts +20 -0
- package/dist/live/index.d.ts +20 -0
- package/dist/live/index.js +30 -0
- package/dist/live/index.js.map +1 -0
- package/dist/loader.global.js +1 -0
- package/dist/plugin/index.cjs +229 -0
- package/dist/plugin/index.cjs.map +1 -0
- package/dist/plugin/index.d.cts +76 -0
- package/dist/plugin/index.d.ts +76 -0
- package/dist/plugin/index.js +186 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/react/index.d.ts +290 -0
- package/dist/react/index.js +5110 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types-CMgpkvBz.d.cts +265 -0
- package/dist/types-CMgpkvBz.d.ts +265 -0
- package/package.json +191 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/core/live/activation.ts
|
|
2
|
+
var LINK_PARAM = "grabby";
|
|
3
|
+
var FLAG_KEY = "grabby:v1:live";
|
|
4
|
+
function session() {
|
|
5
|
+
try {
|
|
6
|
+
return window.sessionStorage;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function isFeedbackSession() {
|
|
12
|
+
return _optionalChain([session, 'call', _ => _(), 'optionalAccess', _2 => _2.getItem, 'call', _3 => _3(FLAG_KEY)]) === "1";
|
|
13
|
+
}
|
|
14
|
+
function startFeedbackSession() {
|
|
15
|
+
try {
|
|
16
|
+
_optionalChain([session, 'call', _4 => _4(), 'optionalAccess', _5 => _5.setItem, 'call', _6 => _6(FLAG_KEY, "1")]);
|
|
17
|
+
} catch (e2) {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function endFeedbackSession() {
|
|
21
|
+
try {
|
|
22
|
+
_optionalChain([session, 'call', _7 => _7(), 'optionalAccess', _8 => _8.removeItem, 'call', _9 => _9(FLAG_KEY)]);
|
|
23
|
+
} catch (e3) {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function consumeFeedbackLink(projectKey) {
|
|
27
|
+
try {
|
|
28
|
+
const url = new URL(window.location.href);
|
|
29
|
+
const value = url.searchParams.get(LINK_PARAM);
|
|
30
|
+
if (value !== null) {
|
|
31
|
+
if (value && (!projectKey || value === projectKey)) startFeedbackSession();
|
|
32
|
+
url.searchParams.delete(LINK_PARAM);
|
|
33
|
+
window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash);
|
|
34
|
+
}
|
|
35
|
+
} catch (e4) {
|
|
36
|
+
}
|
|
37
|
+
return isFeedbackSession();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
exports.startFeedbackSession = startFeedbackSession; exports.endFeedbackSession = endFeedbackSession; exports.consumeFeedbackLink = consumeFeedbackLink;
|
|
45
|
+
//# sourceMappingURL=chunk-6CBIOKZV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/githumbi/Documents/angular-grab/packages/grabby/dist/chunk-6CBIOKZV.cjs","../src/core/live/activation.ts"],"names":[],"mappings":"AAAA;ACMO,IAAM,WAAA,EAAa,QAAA;AAC1B,IAAM,SAAA,EAAW,gBAAA;AAEjB,SAAS,OAAA,CAAA,EAA0B;AACjC,EAAA,IAAI;AAAE,IAAA,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OAAO,iBAAA,CAAkB,CAAA;AAC3B;ADHA;AACA;AACE;AACA;AACA;AACF,wJAAC","file":"/Users/githumbi/Documents/angular-grab/packages/grabby/dist/chunk-6CBIOKZV.cjs","sourcesContent":[null,"/**\n * Live sites keep Grabby hidden from ordinary visitors. It appears for\n * someone who opens a feedback link (https://site/?grabby=<projectKey>) and\n * stays for that browser tab until they exit feedback mode.\n */\n\nexport const LINK_PARAM = 'grabby';\nconst FLAG_KEY = 'grabby:v1:live';\n\nfunction session(): Storage | null {\n try { return window.sessionStorage; } catch { return null; }\n}\n\nexport function isFeedbackSession(): boolean {\n return session()?.getItem(FLAG_KEY) === '1';\n}\n\nexport function startFeedbackSession(): void {\n try { session()?.setItem(FLAG_KEY, '1'); } catch { /* private mode: lasts for this page only */ }\n}\n\nexport function endFeedbackSession(): void {\n try { session()?.removeItem(FLAG_KEY); } catch { /* ignore */ }\n}\n\n/**\n * Starts a feedback session if the URL carries a matching link, then removes\n * the parameter so it isn't shared by accident when the page is bookmarked\n * or copied. With no projectKey configured, any non-empty value works.\n */\nexport function consumeFeedbackLink(projectKey?: string): boolean {\n try {\n const url = new URL(window.location.href);\n const value = url.searchParams.get(LINK_PARAM);\n if (value !== null) {\n if (value && (!projectKey || value === projectKey)) startFeedbackSession();\n url.searchParams.delete(LINK_PARAM);\n window.history.replaceState(window.history.state, '', url.pathname + url.search + url.hash);\n }\n } catch { /* unusual URL; nothing to consume */ }\n return isFeedbackSession();\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/core/live/activation.ts
|
|
2
|
+
var LINK_PARAM = "grabby";
|
|
3
|
+
var FLAG_KEY = "grabby:v1:live";
|
|
4
|
+
function session() {
|
|
5
|
+
try {
|
|
6
|
+
return window.sessionStorage;
|
|
7
|
+
} catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function isFeedbackSession() {
|
|
12
|
+
return session()?.getItem(FLAG_KEY) === "1";
|
|
13
|
+
}
|
|
14
|
+
function startFeedbackSession() {
|
|
15
|
+
try {
|
|
16
|
+
session()?.setItem(FLAG_KEY, "1");
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function endFeedbackSession() {
|
|
21
|
+
try {
|
|
22
|
+
session()?.removeItem(FLAG_KEY);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function consumeFeedbackLink(projectKey) {
|
|
27
|
+
try {
|
|
28
|
+
const url = new URL(window.location.href);
|
|
29
|
+
const value = url.searchParams.get(LINK_PARAM);
|
|
30
|
+
if (value !== null) {
|
|
31
|
+
if (value && (!projectKey || value === projectKey)) startFeedbackSession();
|
|
32
|
+
url.searchParams.delete(LINK_PARAM);
|
|
33
|
+
window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash);
|
|
34
|
+
}
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
return isFeedbackSession();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
startFeedbackSession,
|
|
42
|
+
endFeedbackSession,
|
|
43
|
+
consumeFeedbackLink
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=chunk-M3DOFJA7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/live/activation.ts"],"sourcesContent":["/**\n * Live sites keep Grabby hidden from ordinary visitors. It appears for\n * someone who opens a feedback link (https://site/?grabby=<projectKey>) and\n * stays for that browser tab until they exit feedback mode.\n */\n\nexport const LINK_PARAM = 'grabby';\nconst FLAG_KEY = 'grabby:v1:live';\n\nfunction session(): Storage | null {\n try { return window.sessionStorage; } catch { return null; }\n}\n\nexport function isFeedbackSession(): boolean {\n return session()?.getItem(FLAG_KEY) === '1';\n}\n\nexport function startFeedbackSession(): void {\n try { session()?.setItem(FLAG_KEY, '1'); } catch { /* private mode: lasts for this page only */ }\n}\n\nexport function endFeedbackSession(): void {\n try { session()?.removeItem(FLAG_KEY); } catch { /* ignore */ }\n}\n\n/**\n * Starts a feedback session if the URL carries a matching link, then removes\n * the parameter so it isn't shared by accident when the page is bookmarked\n * or copied. With no projectKey configured, any non-empty value works.\n */\nexport function consumeFeedbackLink(projectKey?: string): boolean {\n try {\n const url = new URL(window.location.href);\n const value = url.searchParams.get(LINK_PARAM);\n if (value !== null) {\n if (value && (!projectKey || value === projectKey)) startFeedbackSession();\n url.searchParams.delete(LINK_PARAM);\n window.history.replaceState(window.history.state, '', url.pathname + url.search + url.hash);\n }\n } catch { /* unusual URL; nothing to consume */ }\n return isFeedbackSession();\n}\n"],"mappings":";AAMO,IAAM,aAAa;AAC1B,IAAM,WAAW;AAEjB,SAAS,UAA0B;AACjC,MAAI;AAAE,WAAO,OAAO;AAAA,EAAgB,QAAQ;AAAE,WAAO;AAAA,EAAM;AAC7D;AAEO,SAAS,oBAA6B;AAC3C,SAAO,QAAQ,GAAG,QAAQ,QAAQ,MAAM;AAC1C;AAEO,SAAS,uBAA6B;AAC3C,MAAI;AAAE,YAAQ,GAAG,QAAQ,UAAU,GAAG;AAAA,EAAG,QAAQ;AAAA,EAA+C;AAClG;AAEO,SAAS,qBAA2B;AACzC,MAAI;AAAE,YAAQ,GAAG,WAAW,QAAQ;AAAA,EAAG,QAAQ;AAAA,EAAe;AAChE;AAOO,SAAS,oBAAoB,YAA8B;AAChE,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,OAAO,SAAS,IAAI;AACxC,UAAM,QAAQ,IAAI,aAAa,IAAI,UAAU;AAC7C,QAAI,UAAU,MAAM;AAClB,UAAI,UAAU,CAAC,cAAc,UAAU,YAAa,sBAAqB;AACzE,UAAI,aAAa,OAAO,UAAU;AAClC,aAAO,QAAQ,aAAa,OAAO,QAAQ,OAAO,IAAI,IAAI,WAAW,IAAI,SAAS,IAAI,IAAI;AAAA,IAC5F;AAAA,EACF,QAAQ;AAAA,EAAwC;AAChD,SAAO,kBAAkB;AAC3B;","names":[]}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/index.ts
|
|
4
|
+
import { spawn } from "child_process";
|
|
5
|
+
import { parseArgs } from "util";
|
|
6
|
+
|
|
7
|
+
// src/cli/commands/init.ts
|
|
8
|
+
import { execSync } from "child_process";
|
|
9
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
10
|
+
import { join as join2, relative } from "path";
|
|
11
|
+
import { createInterface } from "readline";
|
|
12
|
+
|
|
13
|
+
// src/cli/utils/detect-stack.ts
|
|
14
|
+
import { existsSync, readFileSync } from "fs";
|
|
15
|
+
import { join, dirname } from "path";
|
|
16
|
+
var VITE_CONFIGS = ["vite.config.ts", "vite.config.mts", "vite.config.js", "vite.config.mjs"];
|
|
17
|
+
var ENTRIES = ["src/main.tsx", "src/main.ts", "src/main.jsx", "src/main.js", "src/index.tsx", "src/index.jsx", "src/index.ts", "src/index.js"];
|
|
18
|
+
function findProjectRoot(start = process.cwd()) {
|
|
19
|
+
let dir = start;
|
|
20
|
+
while (true) {
|
|
21
|
+
if (existsSync(join(dir, "package.json"))) return dir;
|
|
22
|
+
const parent = dirname(dir);
|
|
23
|
+
if (parent === dir) return start;
|
|
24
|
+
dir = parent;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function detectPackageManager(root) {
|
|
28
|
+
let dir = root;
|
|
29
|
+
while (true) {
|
|
30
|
+
if (existsSync(join(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
31
|
+
if (existsSync(join(dir, "yarn.lock"))) return "yarn";
|
|
32
|
+
if (existsSync(join(dir, "bun.lockb")) || existsSync(join(dir, "bun.lock"))) return "bun";
|
|
33
|
+
if (existsSync(join(dir, "package-lock.json"))) return "npm";
|
|
34
|
+
const parent = dirname(dir);
|
|
35
|
+
if (parent === dir) return "npm";
|
|
36
|
+
dir = parent;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function detectStack(start = process.cwd()) {
|
|
40
|
+
const root = findProjectRoot(start);
|
|
41
|
+
const pkgPath = join(root, "package.json");
|
|
42
|
+
const hasPackageJson = existsSync(pkgPath);
|
|
43
|
+
let deps = {};
|
|
44
|
+
if (hasPackageJson) {
|
|
45
|
+
try {
|
|
46
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
47
|
+
deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const has = (name) => name in deps;
|
|
52
|
+
let framework = "html";
|
|
53
|
+
if (existsSync(join(root, "angular.json")) || has("@angular/core")) framework = "angular";
|
|
54
|
+
else if (has("next")) framework = "next";
|
|
55
|
+
else if (has("nuxt")) framework = "nuxt";
|
|
56
|
+
else if (has("@sveltejs/kit")) framework = "sveltekit";
|
|
57
|
+
else if (has("astro")) framework = "astro";
|
|
58
|
+
else if (has("solid-js")) framework = "solid";
|
|
59
|
+
else if (has("preact")) framework = "preact";
|
|
60
|
+
else if (has("react")) framework = "react";
|
|
61
|
+
else if (has("vue")) framework = "vue";
|
|
62
|
+
else if (has("svelte")) framework = "svelte";
|
|
63
|
+
const viteConfig = VITE_CONFIGS.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;
|
|
64
|
+
const entry = ENTRIES.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;
|
|
65
|
+
return { root, packageManager: detectPackageManager(root), framework, viteConfig, entry, hasPackageJson };
|
|
66
|
+
}
|
|
67
|
+
function installCommand(pm, pkg, dev) {
|
|
68
|
+
switch (pm) {
|
|
69
|
+
case "pnpm":
|
|
70
|
+
return `pnpm add ${dev ? "-D " : ""}${pkg}`;
|
|
71
|
+
case "yarn":
|
|
72
|
+
return `yarn add ${dev ? "-D " : ""}${pkg}`;
|
|
73
|
+
case "bun":
|
|
74
|
+
return `bun add ${dev ? "-d " : ""}${pkg}`;
|
|
75
|
+
default:
|
|
76
|
+
return `npm install ${dev ? "-D " : ""}${pkg}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/cli/utils/patch-source.ts
|
|
81
|
+
function afterImports(code) {
|
|
82
|
+
const re = /^import\s[^;]*?(?:from\s+)?['"][^'"]+['"];?[ \t]*$/gm;
|
|
83
|
+
let end = 0;
|
|
84
|
+
for (let m = re.exec(code); m; m = re.exec(code)) end = m.index + m[0].length;
|
|
85
|
+
return end;
|
|
86
|
+
}
|
|
87
|
+
function insertImport(code, statement) {
|
|
88
|
+
const at = afterImports(code);
|
|
89
|
+
if (at === 0) return `${statement}
|
|
90
|
+
${code}`;
|
|
91
|
+
return `${code.slice(0, at)}
|
|
92
|
+
${statement}${code.slice(at)}`;
|
|
93
|
+
}
|
|
94
|
+
function patchViteConfig(code) {
|
|
95
|
+
if (code.includes("@githumbi/grabby/plugin")) return { status: "already" };
|
|
96
|
+
const plugins = /plugins\s*:\s*\[/.exec(code);
|
|
97
|
+
if (!plugins) return { status: "unrecognised", reason: "no `plugins: [ \u2026 ]` array found" };
|
|
98
|
+
const at = plugins.index + plugins[0].length;
|
|
99
|
+
const withPlugin = `${code.slice(0, at)}grabby.vite(), ${code.slice(at)}`;
|
|
100
|
+
return { status: "patched", code: insertImport(withPlugin, "import grabby from '@githumbi/grabby/plugin';") };
|
|
101
|
+
}
|
|
102
|
+
function patchEntry(code, options = {}) {
|
|
103
|
+
if (code.includes("@githumbi/grabby")) return { status: "already" };
|
|
104
|
+
const at = afterImports(code);
|
|
105
|
+
if (at === 0 && /\bimport\b/.test(code.slice(0, 200))) {
|
|
106
|
+
return { status: "unrecognised", reason: "could not find where the imports end" };
|
|
107
|
+
}
|
|
108
|
+
const call = options.live ? `initGrabbyLive({ server: ${JSON.stringify(options.live.server)}, projectKey: ${JSON.stringify(options.live.projectKey)} });` : "if (import.meta.env.DEV) initGrabby();";
|
|
109
|
+
const imp = options.live ? "import { initGrabbyLive } from '@githumbi/grabby/live';" : "import { initGrabby } from '@githumbi/grabby';";
|
|
110
|
+
const withImport = insertImport(code, imp);
|
|
111
|
+
const afterAll = afterImports(withImport);
|
|
112
|
+
return { status: "patched", code: `${withImport.slice(0, afterAll)}
|
|
113
|
+
|
|
114
|
+
${call}${withImport.slice(afterAll)}` };
|
|
115
|
+
}
|
|
116
|
+
function patchAngularJson(code) {
|
|
117
|
+
if (code.includes("@githumbi/grabby:")) return { status: "already" };
|
|
118
|
+
const next = code.replace(/"@angular(?:-devkit\/build-angular|\/build):application"/g, '"@githumbi/grabby:application"').replace(/"@angular(?:-devkit\/build-angular|\/build):dev-server"/g, '"@githumbi/grabby:dev-server"');
|
|
119
|
+
if (next === code) {
|
|
120
|
+
return { status: "unrecognised", reason: "no @angular/build:application or :dev-server builder found (Angular 17+ is required)" };
|
|
121
|
+
}
|
|
122
|
+
return { status: "patched", code: next };
|
|
123
|
+
}
|
|
124
|
+
function patchAngularAppConfig(code) {
|
|
125
|
+
if (code.includes("provideGrabby")) return { status: "already" };
|
|
126
|
+
const providers = /providers\s*:\s*\[/.exec(code);
|
|
127
|
+
if (!providers) return { status: "unrecognised", reason: "no `providers: [ \u2026 ]` array found" };
|
|
128
|
+
const at = providers.index + providers[0].length;
|
|
129
|
+
const withProvider = `${code.slice(0, at)}provideGrabby(), ${code.slice(at)}`;
|
|
130
|
+
return { status: "patched", code: insertImport(withProvider, "import { provideGrabby } from '@githumbi/grabby/angular';") };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/cli/commands/init.ts
|
|
134
|
+
var PKG = "@githumbi/grabby";
|
|
135
|
+
var c = {
|
|
136
|
+
cyan: (s) => `\x1B[36m${s}\x1B[0m`,
|
|
137
|
+
yellow: (s) => `\x1B[33m${s}\x1B[0m`,
|
|
138
|
+
green: (s) => `\x1B[32m${s}\x1B[0m`,
|
|
139
|
+
bold: (s) => `\x1B[1m${s}\x1B[0m`,
|
|
140
|
+
dim: (s) => `\x1B[2m${s}\x1B[0m`
|
|
141
|
+
};
|
|
142
|
+
var log = (msg = "") => console.log(msg && `${c.cyan("[grabby]")} ${msg}`);
|
|
143
|
+
var warn = (msg) => console.log(`${c.yellow("[grabby]")} ${msg}`);
|
|
144
|
+
function tryPatch(file, patch, describe, manual, changes, manualSteps) {
|
|
145
|
+
if (!file || !existsSync2(file)) {
|
|
146
|
+
manualSteps.push(manual);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const result = patch(readFileSync2(file, "utf8"));
|
|
150
|
+
if (result.status === "patched") changes.push({ file, describe, next: result.code });
|
|
151
|
+
else if (result.status === "already") log(`${describe}: already set up`);
|
|
152
|
+
else manualSteps.push(`${manual}
|
|
153
|
+
${c.dim(`(couldn't edit ${file} automatically: ${result.reason})`)}`);
|
|
154
|
+
}
|
|
155
|
+
function plan(stack, options) {
|
|
156
|
+
const changes = [];
|
|
157
|
+
const manual = [];
|
|
158
|
+
const live = options.live;
|
|
159
|
+
const liveCall = live ? `initGrabbyLive({ server: '${live.server}', projectKey: '${live.projectKey}' })` : "";
|
|
160
|
+
switch (stack.framework) {
|
|
161
|
+
case "angular": {
|
|
162
|
+
tryPatch(
|
|
163
|
+
join2(stack.root, "angular.json"),
|
|
164
|
+
patchAngularJson,
|
|
165
|
+
"use the Grabby builders",
|
|
166
|
+
'In angular.json, set build \u2192 "@githumbi/grabby:application" and serve \u2192 "@githumbi/grabby:dev-server".',
|
|
167
|
+
changes,
|
|
168
|
+
manual
|
|
169
|
+
);
|
|
170
|
+
const appConfig = ["src/app/app.config.ts", "src/app.config.ts"].map((f) => join2(stack.root, f)).find((f) => existsSync2(f)) ?? null;
|
|
171
|
+
tryPatch(
|
|
172
|
+
appConfig,
|
|
173
|
+
patchAngularAppConfig,
|
|
174
|
+
"add provideGrabby()",
|
|
175
|
+
"In app.config.ts: import { provideGrabby } from '@githumbi/grabby/angular'; and add provideGrabby() to providers.",
|
|
176
|
+
changes,
|
|
177
|
+
manual
|
|
178
|
+
);
|
|
179
|
+
if (live) manual.push(`For live feedback, pass the options: provideGrabby({ mode: 'live', server: '${live.server}', projectKey: '${live.projectKey}' })`);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "react":
|
|
183
|
+
case "vue":
|
|
184
|
+
case "svelte":
|
|
185
|
+
case "solid":
|
|
186
|
+
case "preact": {
|
|
187
|
+
if (stack.framework !== "svelte" && !live) {
|
|
188
|
+
tryPatch(
|
|
189
|
+
stack.viteConfig,
|
|
190
|
+
patchViteConfig,
|
|
191
|
+
"add the source-location plugin",
|
|
192
|
+
"In your bundler config add the plugin first: import grabby from '@githumbi/grabby/plugin'; plugins: [grabby.vite(), \u2026] (also grabby.webpack(), grabby.rspack(), \u2026)",
|
|
193
|
+
changes,
|
|
194
|
+
manual
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
tryPatch(
|
|
198
|
+
stack.entry,
|
|
199
|
+
(code) => patchEntry(code, { live }),
|
|
200
|
+
live ? "start live feedback" : "start Grabby in development builds",
|
|
201
|
+
live ? `In your entry file: import { initGrabbyLive } from '@githumbi/grabby/live'; ${liveCall};` : "In your entry file: import { initGrabby } from '@githumbi/grabby'; if (import.meta.env.DEV) initGrabby();",
|
|
202
|
+
changes,
|
|
203
|
+
manual
|
|
204
|
+
);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case "next":
|
|
208
|
+
manual.push(
|
|
209
|
+
"next.config: const grabby = require('@githumbi/grabby/plugin').default; webpack: (config) => { config.plugins.unshift(grabby.webpack()); return config; }",
|
|
210
|
+
live ? `In a client component rendered by your root layout: useEffect(() => { import('@githumbi/grabby/live').then((g) => g.${liveCall}); }, []);` : "In a client component rendered by your root layout: useEffect(() => { if (process.env.NODE_ENV === 'development') import('@githumbi/grabby').then((g) => g.initGrabby()); }, []);"
|
|
211
|
+
);
|
|
212
|
+
break;
|
|
213
|
+
case "nuxt":
|
|
214
|
+
case "sveltekit":
|
|
215
|
+
case "astro":
|
|
216
|
+
manual.push(
|
|
217
|
+
stack.framework === "nuxt" ? "nuxt.config: vite: { plugins: [require('@githumbi/grabby/plugin').default.vite()] }" : "No build plugin needed for Svelte-based apps; Astro can add grabby.vite() under vite.plugins.",
|
|
218
|
+
live ? `In a client-only script/plugin: import('@githumbi/grabby/live').then((g) => g.${liveCall});` : "In a client-only script/plugin: if (import.meta.env.DEV) import('@githumbi/grabby').then((g) => g.initGrabby());"
|
|
219
|
+
);
|
|
220
|
+
break;
|
|
221
|
+
default: {
|
|
222
|
+
const attrs = live ? ` data-mode="live" data-server="${live.server}" data-project-key="${live.projectKey}"` : "";
|
|
223
|
+
const file = live ? "loader.global.js" : "grabby.global.js";
|
|
224
|
+
manual.push(`Add before </body>:
|
|
225
|
+
<script src="https://cdn.jsdelivr.net/npm/${PKG}@0.1/dist/${file}"${attrs} defer></script>`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return { changes, manual, devDependency: !live };
|
|
229
|
+
}
|
|
230
|
+
async function confirm(question) {
|
|
231
|
+
if (!process.stdin.isTTY) return false;
|
|
232
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
233
|
+
const answer = await new Promise((resolve) => rl.question(question, resolve));
|
|
234
|
+
rl.close();
|
|
235
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
236
|
+
}
|
|
237
|
+
async function init(options = {}) {
|
|
238
|
+
const stack = detectStack(options.cwd);
|
|
239
|
+
const rel = (f) => relative(stack.root, f) || f;
|
|
240
|
+
log(`Project: ${stack.root}`);
|
|
241
|
+
log(`Detected: ${stack.framework}${stack.viteConfig ? " + Vite" : ""} \xB7 ${stack.packageManager}${options.live ? " \xB7 live feedback" : ""}`);
|
|
242
|
+
log();
|
|
243
|
+
const { changes, manual, devDependency } = plan(stack, options);
|
|
244
|
+
const install = stack.hasPackageJson && !options.noInstall ? installCommand(stack.packageManager, PKG, devDependency) : null;
|
|
245
|
+
if (!install && changes.length === 0 && manual.length === 0) {
|
|
246
|
+
log(c.green("Everything is already set up."));
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
console.log(c.bold(" Grabby will:"));
|
|
250
|
+
if (install) console.log(` \u2022 run ${c.bold(install)}`);
|
|
251
|
+
for (const ch of changes) console.log(` \u2022 edit ${c.bold(rel(ch.file))}: ${ch.describe}`);
|
|
252
|
+
if (manual.length) {
|
|
253
|
+
console.log(c.bold("\n You'll need to do by hand:"));
|
|
254
|
+
manual.forEach((m, i) => console.log(` ${i + 1}. ${m}`));
|
|
255
|
+
}
|
|
256
|
+
console.log("");
|
|
257
|
+
if (options.dryRun) return;
|
|
258
|
+
if (changes.length || install) {
|
|
259
|
+
const go = options.yes || await confirm(" Go ahead? [y/N] ");
|
|
260
|
+
if (!go) {
|
|
261
|
+
warn(process.stdin.isTTY ? "Nothing changed." : "Nothing changed (not a terminal; re-run with --yes to apply).");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (install) {
|
|
266
|
+
try {
|
|
267
|
+
execSync(install, { cwd: stack.root, stdio: "inherit" });
|
|
268
|
+
} catch {
|
|
269
|
+
warn(`Install failed; run it yourself: ${install}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
for (const ch of changes) {
|
|
273
|
+
writeFileSync(ch.file, ch.next, "utf8");
|
|
274
|
+
log(`${c.green("\u2713")} ${rel(ch.file)}`);
|
|
275
|
+
}
|
|
276
|
+
console.log("");
|
|
277
|
+
log(c.green("Done."));
|
|
278
|
+
if (options.live) {
|
|
279
|
+
console.log(`
|
|
280
|
+
Share this feedback link with reviewers: ${c.bold(`https://<your-site>/?grabby=${options.live.projectKey}`)}`);
|
|
281
|
+
console.log(` Pull their comments: ${c.bold(`npx @githumbi/grabby-server pull --server ${options.live.server} --token <admin token>`)}
|
|
282
|
+
`);
|
|
283
|
+
} else {
|
|
284
|
+
console.log(`
|
|
285
|
+
Start your dev server, press ${c.bold("Alt+G")} (${c.bold("Option+G")} on Mac), click anything, and comment.`);
|
|
286
|
+
console.log(` Then use ${c.bold("Copy all")} and paste into your AI agent.`);
|
|
287
|
+
console.log(` Want your agent to read comments directly? Run ${c.bold("npx grabby add mcp")}.
|
|
288
|
+
`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/cli/commands/add-mcp.ts
|
|
293
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
294
|
+
import { join as join3 } from "path";
|
|
295
|
+
var MCP_PACKAGE = "@githumbi/grabby-server@0";
|
|
296
|
+
var MCP_SERVER_NAME = "grabby";
|
|
297
|
+
function log2(msg) {
|
|
298
|
+
console.log(`\x1B[36m[grabby]\x1B[0m ${msg}`);
|
|
299
|
+
}
|
|
300
|
+
function warn2(msg) {
|
|
301
|
+
console.log(`\x1B[33m[grabby]\x1B[0m ${msg}`);
|
|
302
|
+
}
|
|
303
|
+
function success(msg) {
|
|
304
|
+
console.log(`\x1B[32m[grabby]\x1B[0m ${msg}`);
|
|
305
|
+
}
|
|
306
|
+
function getMcpServerEntry() {
|
|
307
|
+
const isWindows = process.platform === "win32";
|
|
308
|
+
if (isWindows) {
|
|
309
|
+
return {
|
|
310
|
+
type: "stdio",
|
|
311
|
+
command: "cmd",
|
|
312
|
+
args: ["/c", "npx", "-y", MCP_PACKAGE, "mcp"]
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
type: "stdio",
|
|
317
|
+
command: "npx",
|
|
318
|
+
args: ["-y", MCP_PACKAGE, "mcp"]
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async function addMcp() {
|
|
322
|
+
log2("Adding grabby MCP server...\n");
|
|
323
|
+
const mcpJsonPath = join3(process.cwd(), ".mcp.json");
|
|
324
|
+
let config = {};
|
|
325
|
+
if (existsSync3(mcpJsonPath)) {
|
|
326
|
+
try {
|
|
327
|
+
config = JSON.parse(readFileSync3(mcpJsonPath, "utf-8"));
|
|
328
|
+
} catch {
|
|
329
|
+
warn2(".mcp.json exists but is not valid JSON; leaving it alone. Add this entry by hand:");
|
|
330
|
+
console.log(JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: getMcpServerEntry() } }, null, 2));
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const servers = config.mcpServers ?? {};
|
|
335
|
+
servers[MCP_SERVER_NAME] = getMcpServerEntry();
|
|
336
|
+
config.mcpServers = servers;
|
|
337
|
+
writeFileSync2(mcpJsonPath, JSON.stringify(config, null, 2) + "\n");
|
|
338
|
+
success("Added grabby MCP server to .mcp.json");
|
|
339
|
+
console.log("");
|
|
340
|
+
console.log(" It also collects comments from your app on http://localhost:3456.");
|
|
341
|
+
console.log(" Point Grabby at it: initGrabby({ server: 'http://localhost:3456' })");
|
|
342
|
+
console.log("");
|
|
343
|
+
console.log(" \x1B[1mRestart your editor\x1B[0m to activate the MCP connection.");
|
|
344
|
+
console.log(" When prompted, \x1B[1mapprove the MCP server\x1B[0m in your editor.");
|
|
345
|
+
console.log("");
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/cli/index.ts
|
|
349
|
+
var HELP = `Grabby: point at any UI element, leave a comment, hand it to your AI agent.
|
|
350
|
+
|
|
351
|
+
Usage
|
|
352
|
+
npx grabby init Set up Grabby in this project (asks before changing files)
|
|
353
|
+
--yes Apply without asking
|
|
354
|
+
--dry-run Only show what would change
|
|
355
|
+
--no-install Don't install the package
|
|
356
|
+
--live --server <url> --key <pk_\u2026>
|
|
357
|
+
Set up live-site feedback instead of local dev mode
|
|
358
|
+
npx grabby add mcp Let your AI agent read comments over MCP (.mcp.json)
|
|
359
|
+
npx grabby pull [options] Print collected comments for your agent (runs grabby-server pull)
|
|
360
|
+
`;
|
|
361
|
+
function fail(err) {
|
|
362
|
+
console.error("\x1B[31mError:\x1B[0m", err instanceof Error ? err.message : String(err));
|
|
363
|
+
process.exit(1);
|
|
364
|
+
}
|
|
365
|
+
var argv = process.argv.slice(2);
|
|
366
|
+
var [command, subcommand] = argv;
|
|
367
|
+
if (command === "pull") {
|
|
368
|
+
const args = ["-y", "@githumbi/grabby-server@0", "pull", ...argv.slice(1)];
|
|
369
|
+
const windows = process.platform === "win32";
|
|
370
|
+
if (windows && !args.every((a) => /^[\w@./:=,+-]+$/.test(a))) {
|
|
371
|
+
fail(`unsupported characters in arguments; run it directly: npx ${args.join(" ")}`);
|
|
372
|
+
}
|
|
373
|
+
const child = spawn(windows ? "npx.cmd" : "npx", args, { stdio: "inherit", shell: windows });
|
|
374
|
+
child.on("exit", (code) => process.exit(code ?? 1));
|
|
375
|
+
} else if (command === "add" && subcommand === "mcp") {
|
|
376
|
+
addMcp().catch(fail);
|
|
377
|
+
} else if (!command || command === "init") {
|
|
378
|
+
const { values } = parseArgs({
|
|
379
|
+
args: argv.slice(command ? 1 : 0),
|
|
380
|
+
options: {
|
|
381
|
+
yes: { type: "boolean", short: "y" },
|
|
382
|
+
"dry-run": { type: "boolean" },
|
|
383
|
+
"no-install": { type: "boolean" },
|
|
384
|
+
live: { type: "boolean" },
|
|
385
|
+
server: { type: "string" },
|
|
386
|
+
key: { type: "string" }
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
if (values.live && (!values.server || !values.key)) {
|
|
390
|
+
fail("--live needs --server <collector url> and --key <project key> (from `npx @githumbi/grabby-server init`)");
|
|
391
|
+
}
|
|
392
|
+
init({
|
|
393
|
+
yes: values.yes,
|
|
394
|
+
dryRun: values["dry-run"],
|
|
395
|
+
noInstall: values["no-install"],
|
|
396
|
+
live: values.live ? { server: values.server, projectKey: values.key } : void 0
|
|
397
|
+
}).catch(fail);
|
|
398
|
+
} else if (command === "help" || command === "--help" || command === "-h") {
|
|
399
|
+
console.log(HELP);
|
|
400
|
+
} else {
|
|
401
|
+
console.error(`Unknown command: ${argv.join(" ")}
|
|
402
|
+
`);
|
|
403
|
+
console.log(HELP);
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/init.ts","../../src/cli/utils/detect-stack.ts","../../src/cli/utils/patch-source.ts","../../src/cli/commands/add-mcp.ts"],"sourcesContent":["import { spawn } from 'child_process';\nimport { parseArgs } from 'util';\nimport { init } from './commands/init';\nimport { addMcp } from './commands/add-mcp';\n\nconst HELP = `Grabby: point at any UI element, leave a comment, hand it to your AI agent.\n\nUsage\n npx grabby init Set up Grabby in this project (asks before changing files)\n --yes Apply without asking\n --dry-run Only show what would change\n --no-install Don't install the package\n --live --server <url> --key <pk_…>\n Set up live-site feedback instead of local dev mode\n npx grabby add mcp Let your AI agent read comments over MCP (.mcp.json)\n npx grabby pull [options] Print collected comments for your agent (runs grabby-server pull)\n`;\n\nfunction fail(err: unknown): never {\n console.error('\\x1b[31mError:\\x1b[0m', err instanceof Error ? err.message : String(err));\n process.exit(1);\n}\n\nconst argv = process.argv.slice(2);\nconst [command, subcommand] = argv;\n\nif (command === 'pull') {\n // The collector owns pulling; forward to it so there's one implementation.\n const args = ['-y', '@githumbi/grabby-server@0', 'pull', ...argv.slice(1)];\n const windows = process.platform === 'win32';\n // npx is a .cmd on Windows, which Node only runs through a shell. Only\n // pass plain flag/value characters so nothing can be interpreted by it.\n if (windows && !args.every((a) => /^[\\w@./:=,+-]+$/.test(a))) {\n fail(`unsupported characters in arguments; run it directly: npx ${args.join(' ')}`);\n }\n const child = spawn(windows ? 'npx.cmd' : 'npx', args, { stdio: 'inherit', shell: windows });\n child.on('exit', (code) => process.exit(code ?? 1));\n} else if (command === 'add' && subcommand === 'mcp') {\n addMcp().catch(fail);\n} else if (!command || command === 'init') {\n const { values } = parseArgs({\n args: argv.slice(command ? 1 : 0),\n options: {\n yes: { type: 'boolean', short: 'y' },\n 'dry-run': { type: 'boolean' },\n 'no-install': { type: 'boolean' },\n live: { type: 'boolean' },\n server: { type: 'string' },\n key: { type: 'string' },\n },\n });\n if (values.live && (!values.server || !values.key)) {\n fail('--live needs --server <collector url> and --key <project key> (from `npx @githumbi/grabby-server init`)');\n }\n init({\n yes: values.yes,\n dryRun: values['dry-run'],\n noInstall: values['no-install'],\n live: values.live ? { server: values.server!, projectKey: values.key! } : undefined,\n }).catch(fail);\n} else if (command === 'help' || command === '--help' || command === '-h') {\n console.log(HELP);\n} else {\n console.error(`Unknown command: ${argv.join(' ')}\\n`);\n console.log(HELP);\n process.exit(1);\n}\n","import { execSync } from 'child_process';\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join, relative } from 'path';\nimport { createInterface } from 'readline';\nimport { detectStack, installCommand, type Stack } from '../utils/detect-stack';\nimport { patchViteConfig, patchEntry, patchAngularJson, patchAngularAppConfig, type PatchResult } from '../utils/patch-source';\n\nconst PKG = '@githumbi/grabby';\n\nexport interface InitOptions {\n cwd?: string;\n /** Apply without asking. */\n yes?: boolean;\n /** Show the plan only. */\n dryRun?: boolean;\n /** Skip installing the package. */\n noInstall?: boolean;\n /** Set up live-site feedback instead of local developer mode. */\n live?: { server: string; projectKey: string };\n}\n\nconst c = {\n cyan: (s: string) => `\\x1b[36m${s}\\x1b[0m`,\n yellow: (s: string) => `\\x1b[33m${s}\\x1b[0m`,\n green: (s: string) => `\\x1b[32m${s}\\x1b[0m`,\n bold: (s: string) => `\\x1b[1m${s}\\x1b[0m`,\n dim: (s: string) => `\\x1b[2m${s}\\x1b[0m`,\n};\n\nconst log = (msg = '') => console.log(msg && `${c.cyan('[grabby]')} ${msg}`);\nconst warn = (msg: string) => console.log(`${c.yellow('[grabby]')} ${msg}`);\n\ninterface Change {\n file: string;\n describe: string;\n next: string;\n}\n\nfunction tryPatch(file: string | null, patch: (code: string) => PatchResult, describe: string, manual: string, changes: Change[], manualSteps: string[]): void {\n if (!file || !existsSync(file)) {\n manualSteps.push(manual);\n return;\n }\n const result = patch(readFileSync(file, 'utf8'));\n if (result.status === 'patched') changes.push({ file, describe, next: result.code });\n else if (result.status === 'already') log(`${describe}: already set up`);\n else manualSteps.push(`${manual}\\n ${c.dim(`(couldn't edit ${file} automatically: ${result.reason})`)}`);\n}\n\n/** What to change for each stack. Anything not safely automatable becomes a manual step. */\nfunction plan(stack: Stack, options: InitOptions): { changes: Change[]; manual: string[]; devDependency: boolean } {\n const changes: Change[] = [];\n const manual: string[] = [];\n const live = options.live;\n const liveCall = live ? `initGrabbyLive({ server: '${live.server}', projectKey: '${live.projectKey}' })` : '';\n\n switch (stack.framework) {\n case 'angular': {\n tryPatch(join(stack.root, 'angular.json'), patchAngularJson, 'use the Grabby builders',\n 'In angular.json, set build → \"@githumbi/grabby:application\" and serve → \"@githumbi/grabby:dev-server\".', changes, manual);\n const appConfig = ['src/app/app.config.ts', 'src/app.config.ts'].map((f) => join(stack.root, f)).find((f) => existsSync(f)) ?? null;\n tryPatch(appConfig, patchAngularAppConfig, 'add provideGrabby()',\n \"In app.config.ts: import { provideGrabby } from '@githumbi/grabby/angular'; and add provideGrabby() to providers.\", changes, manual);\n if (live) manual.push(`For live feedback, pass the options: provideGrabby({ mode: 'live', server: '${live.server}', projectKey: '${live.projectKey}' })`);\n break;\n }\n case 'react':\n case 'vue':\n case 'svelte':\n case 'solid':\n case 'preact': {\n if (stack.framework !== 'svelte' && !live) {\n tryPatch(stack.viteConfig, patchViteConfig, 'add the source-location plugin',\n \"In your bundler config add the plugin first: import grabby from '@githumbi/grabby/plugin'; plugins: [grabby.vite(), …] (also grabby.webpack(), grabby.rspack(), …)\", changes, manual);\n }\n tryPatch(stack.entry, (code) => patchEntry(code, { live }), live ? 'start live feedback' : 'start Grabby in development builds',\n live\n ? `In your entry file: import { initGrabbyLive } from '@githumbi/grabby/live'; ${liveCall};`\n : \"In your entry file: import { initGrabby } from '@githumbi/grabby'; if (import.meta.env.DEV) initGrabby();\", changes, manual);\n break;\n }\n case 'next':\n manual.push(\n \"next.config: const grabby = require('@githumbi/grabby/plugin').default; webpack: (config) => { config.plugins.unshift(grabby.webpack()); return config; }\",\n live\n ? `In a client component rendered by your root layout: useEffect(() => { import('@githumbi/grabby/live').then((g) => g.${liveCall}); }, []);`\n : \"In a client component rendered by your root layout: useEffect(() => { if (process.env.NODE_ENV === 'development') import('@githumbi/grabby').then((g) => g.initGrabby()); }, []);\",\n );\n break;\n case 'nuxt':\n case 'sveltekit':\n case 'astro':\n manual.push(\n stack.framework === 'nuxt' ? \"nuxt.config: vite: { plugins: [require('@githumbi/grabby/plugin').default.vite()] }\" : 'No build plugin needed for Svelte-based apps; Astro can add grabby.vite() under vite.plugins.',\n live\n ? `In a client-only script/plugin: import('@githumbi/grabby/live').then((g) => g.${liveCall});`\n : \"In a client-only script/plugin: if (import.meta.env.DEV) import('@githumbi/grabby').then((g) => g.initGrabby());\",\n );\n break;\n default: {\n const attrs = live ? ` data-mode=\"live\" data-server=\"${live.server}\" data-project-key=\"${live.projectKey}\"` : '';\n const file = live ? 'loader.global.js' : 'grabby.global.js';\n manual.push(`Add before </body>:\\n <script src=\"https://cdn.jsdelivr.net/npm/${PKG}@0.1/dist/${file}\"${attrs} defer></script>`);\n }\n }\n\n return { changes, manual, devDependency: !live };\n}\n\nasync function confirm(question: string): Promise<boolean> {\n if (!process.stdin.isTTY) return false;\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await new Promise<string>((resolve) => rl.question(question, resolve));\n rl.close();\n return /^y(es)?$/i.test(answer.trim());\n}\n\nexport async function init(options: InitOptions = {}): Promise<void> {\n const stack = detectStack(options.cwd);\n const rel = (f: string) => relative(stack.root, f) || f;\n log(`Project: ${stack.root}`);\n log(`Detected: ${stack.framework}${stack.viteConfig ? ' + Vite' : ''} · ${stack.packageManager}${options.live ? ' · live feedback' : ''}`);\n log();\n\n const { changes, manual, devDependency } = plan(stack, options);\n const install = stack.hasPackageJson && !options.noInstall ? installCommand(stack.packageManager, PKG, devDependency) : null;\n\n if (!install && changes.length === 0 && manual.length === 0) {\n log(c.green('Everything is already set up.'));\n return;\n }\n\n console.log(c.bold(' Grabby will:'));\n if (install) console.log(` • run ${c.bold(install)}`);\n for (const ch of changes) console.log(` • edit ${c.bold(rel(ch.file))}: ${ch.describe}`);\n if (manual.length) {\n console.log(c.bold('\\n You\\'ll need to do by hand:'));\n manual.forEach((m, i) => console.log(` ${i + 1}. ${m}`));\n }\n console.log('');\n\n if (options.dryRun) return;\n if (changes.length || install) {\n const go = options.yes || await confirm(' Go ahead? [y/N] ');\n if (!go) {\n warn(process.stdin.isTTY ? 'Nothing changed.' : 'Nothing changed (not a terminal; re-run with --yes to apply).');\n return;\n }\n }\n\n if (install) {\n try {\n execSync(install, { cwd: stack.root, stdio: 'inherit' });\n } catch {\n warn(`Install failed; run it yourself: ${install}`);\n }\n }\n for (const ch of changes) {\n writeFileSync(ch.file, ch.next, 'utf8');\n log(`${c.green('✓')} ${rel(ch.file)}`);\n }\n\n console.log('');\n log(c.green('Done.'));\n if (options.live) {\n console.log(`\\n Share this feedback link with reviewers: ${c.bold(`https://<your-site>/?grabby=${options.live.projectKey}`)}`);\n console.log(` Pull their comments: ${c.bold(`npx @githumbi/grabby-server pull --server ${options.live.server} --token <admin token>`)}\\n`);\n } else {\n console.log(`\\n Start your dev server, press ${c.bold('Alt+G')} (${c.bold('Option+G')} on Mac), click anything, and comment.`);\n console.log(` Then use ${c.bold('Copy all')} and paste into your AI agent.`);\n console.log(` Want your agent to read comments directly? Run ${c.bold('npx grabby add mcp')}.\\n`);\n }\n}\n","import { existsSync, readFileSync } from 'fs';\nimport { join, dirname } from 'path';\n\nexport type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';\nexport type Framework = 'angular' | 'next' | 'nuxt' | 'sveltekit' | 'astro' | 'react' | 'vue' | 'svelte' | 'solid' | 'preact' | 'html';\n\nexport interface Stack {\n root: string;\n packageManager: PackageManager;\n framework: Framework;\n /** vite.config.* when the project builds with Vite. */\n viteConfig: string | null;\n /** The file that mounts the app, where initGrabby() goes. */\n entry: string | null;\n hasPackageJson: boolean;\n}\n\nconst VITE_CONFIGS = ['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs'];\nconst ENTRIES = ['src/main.tsx', 'src/main.ts', 'src/main.jsx', 'src/main.js', 'src/index.tsx', 'src/index.jsx', 'src/index.ts', 'src/index.js'];\n\nexport function findProjectRoot(start: string = process.cwd()): string {\n let dir = start;\n while (true) {\n if (existsSync(join(dir, 'package.json'))) return dir;\n const parent = dirname(dir);\n if (parent === dir) return start;\n dir = parent;\n }\n}\n\nexport function detectPackageManager(root: string): PackageManager {\n // Walk up for lockfiles too: a workspace package's lockfile lives at the repo root.\n let dir = root;\n while (true) {\n if (existsSync(join(dir, 'pnpm-lock.yaml'))) return 'pnpm';\n if (existsSync(join(dir, 'yarn.lock'))) return 'yarn';\n if (existsSync(join(dir, 'bun.lockb')) || existsSync(join(dir, 'bun.lock'))) return 'bun';\n if (existsSync(join(dir, 'package-lock.json'))) return 'npm';\n const parent = dirname(dir);\n if (parent === dir) return 'npm';\n dir = parent;\n }\n}\n\nexport function detectStack(start: string = process.cwd()): Stack {\n const root = findProjectRoot(start);\n const pkgPath = join(root, 'package.json');\n const hasPackageJson = existsSync(pkgPath);\n let deps: Record<string, string> = {};\n if (hasPackageJson) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));\n deps = { ...pkg.dependencies, ...pkg.devDependencies };\n } catch { /* unreadable package.json: treat as plain HTML */ }\n }\n const has = (name: string) => name in deps;\n\n let framework: Framework = 'html';\n if (existsSync(join(root, 'angular.json')) || has('@angular/core')) framework = 'angular';\n else if (has('next')) framework = 'next';\n else if (has('nuxt')) framework = 'nuxt';\n else if (has('@sveltejs/kit')) framework = 'sveltekit';\n else if (has('astro')) framework = 'astro';\n else if (has('solid-js')) framework = 'solid';\n else if (has('preact')) framework = 'preact';\n else if (has('react')) framework = 'react';\n else if (has('vue')) framework = 'vue';\n else if (has('svelte')) framework = 'svelte';\n\n const viteConfig = VITE_CONFIGS.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;\n const entry = ENTRIES.map((f) => join(root, f)).find((f) => existsSync(f)) ?? null;\n\n return { root, packageManager: detectPackageManager(root), framework, viteConfig, entry, hasPackageJson };\n}\n\nexport function installCommand(pm: PackageManager, pkg: string, dev: boolean): string {\n switch (pm) {\n case 'pnpm': return `pnpm add ${dev ? '-D ' : ''}${pkg}`;\n case 'yarn': return `yarn add ${dev ? '-D ' : ''}${pkg}`;\n case 'bun': return `bun add ${dev ? '-d ' : ''}${pkg}`;\n default: return `npm install ${dev ? '-D ' : ''}${pkg}`;\n }\n}\n","/*\n * Small, conservative source edits. Each patch either applies cleanly to a\n * recognisable pattern or declines, so `grabby init` never writes a guess;\n * when it declines, init prints the lines to add by hand instead.\n */\n\nexport type PatchResult =\n | { status: 'patched'; code: string }\n | { status: 'already' }\n | { status: 'unrecognised'; reason: string };\n\n/** Index just after the last top-level import statement (0 when there are none). */\nfunction afterImports(code: string): number {\n const re = /^import\\s[^;]*?(?:from\\s+)?['\"][^'\"]+['\"];?[ \\t]*$/gm;\n let end = 0;\n for (let m = re.exec(code); m; m = re.exec(code)) end = m.index + m[0].length;\n return end;\n}\n\nfunction insertImport(code: string, statement: string): string {\n const at = afterImports(code);\n if (at === 0) return `${statement}\\n${code}`;\n return `${code.slice(0, at)}\\n${statement}${code.slice(at)}`;\n}\n\n/** Adds `grabby.vite()` first in the `plugins: [...]` array of a Vite config. */\nexport function patchViteConfig(code: string): PatchResult {\n if (code.includes('@githumbi/grabby/plugin')) return { status: 'already' };\n const plugins = /plugins\\s*:\\s*\\[/.exec(code);\n if (!plugins) return { status: 'unrecognised', reason: 'no `plugins: [ … ]` array found' };\n const at = plugins.index + plugins[0].length;\n // First, so it stamps source before framework plugins compile it.\n const withPlugin = `${code.slice(0, at)}grabby.vite(), ${code.slice(at)}`;\n return { status: 'patched', code: insertImport(withPlugin, \"import grabby from '@githumbi/grabby/plugin';\") };\n}\n\n/** Starts Grabby in the app's entry file, in development builds only. */\nexport function patchEntry(code: string, options: { live?: { server: string; projectKey: string } } = {}): PatchResult {\n if (code.includes('@githumbi/grabby')) return { status: 'already' };\n const at = afterImports(code);\n if (at === 0 && /\\bimport\\b/.test(code.slice(0, 200))) {\n return { status: 'unrecognised', reason: 'could not find where the imports end' };\n }\n const call = options.live\n ? `initGrabbyLive({ server: ${JSON.stringify(options.live.server)}, projectKey: ${JSON.stringify(options.live.projectKey)} });`\n : 'if (import.meta.env.DEV) initGrabby();';\n const imp = options.live\n ? \"import { initGrabbyLive } from '@githumbi/grabby/live';\"\n : \"import { initGrabby } from '@githumbi/grabby';\";\n const withImport = insertImport(code, imp);\n const afterAll = afterImports(withImport);\n return { status: 'patched', code: `${withImport.slice(0, afterAll)}\\n\\n${call}${withImport.slice(afterAll)}` };\n}\n\n/**\n * Swaps the Angular builders for Grabby's, editing the builder strings in\n * place so angular.json keeps its formatting (and any comments).\n */\nexport function patchAngularJson(code: string): PatchResult {\n if (code.includes('@githumbi/grabby:')) return { status: 'already' };\n const next = code\n .replace(/\"@angular(?:-devkit\\/build-angular|\\/build):application\"/g, '\"@githumbi/grabby:application\"')\n .replace(/\"@angular(?:-devkit\\/build-angular|\\/build):dev-server\"/g, '\"@githumbi/grabby:dev-server\"');\n if (next === code) {\n return { status: 'unrecognised', reason: 'no @angular/build:application or :dev-server builder found (Angular 17+ is required)' };\n }\n return { status: 'patched', code: next };\n}\n\n/** Adds provideGrabby() to the providers array of app.config.ts. */\nexport function patchAngularAppConfig(code: string): PatchResult {\n if (code.includes('provideGrabby')) return { status: 'already' };\n const providers = /providers\\s*:\\s*\\[/.exec(code);\n if (!providers) return { status: 'unrecognised', reason: 'no `providers: [ … ]` array found' };\n const at = providers.index + providers[0].length;\n const withProvider = `${code.slice(0, at)}provideGrabby(), ${code.slice(at)}`;\n return { status: 'patched', code: insertImport(withProvider, \"import { provideGrabby } from '@githumbi/grabby/angular';\") };\n}\n","import { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\n// Pinned to a major version: an MCP server runs with your editor's\n// permissions, so it shouldn't silently jump to whatever @latest becomes.\nconst MCP_PACKAGE = '@githumbi/grabby-server@0';\nconst MCP_SERVER_NAME = 'grabby';\n\nfunction log(msg: string): void {\n console.log(`\\x1b[36m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction warn(msg: string): void {\n console.log(`\\x1b[33m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction success(msg: string): void {\n console.log(`\\x1b[32m[grabby]\\x1b[0m ${msg}`);\n}\n\nfunction getMcpServerEntry(): { type: string; command: string; args: string[] } {\n const isWindows = process.platform === 'win32';\n if (isWindows) {\n return {\n type: 'stdio',\n command: 'cmd',\n args: ['/c', 'npx', '-y', MCP_PACKAGE, 'mcp'],\n };\n }\n return {\n type: 'stdio',\n command: 'npx',\n args: ['-y', MCP_PACKAGE, 'mcp'],\n };\n}\n\nexport async function addMcp(): Promise<void> {\n log('Adding grabby MCP server...\\n');\n\n const mcpJsonPath = join(process.cwd(), '.mcp.json');\n let config: Record<string, unknown> = {};\n\n if (existsSync(mcpJsonPath)) {\n try {\n config = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'));\n } catch {\n // Never clobber a file we can't read: it may hold other servers' config.\n warn('.mcp.json exists but is not valid JSON; leaving it alone. Add this entry by hand:');\n console.log(JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: getMcpServerEntry() } }, null, 2));\n return;\n }\n }\n\n const servers = (config.mcpServers as Record<string, unknown>) ?? {};\n servers[MCP_SERVER_NAME] = getMcpServerEntry();\n config.mcpServers = servers;\n\n writeFileSync(mcpJsonPath, JSON.stringify(config, null, 2) + '\\n');\n success('Added grabby MCP server to .mcp.json');\n\n console.log('');\n console.log(' It also collects comments from your app on http://localhost:3456.');\n console.log(\" Point Grabby at it: initGrabby({ server: 'http://localhost:3456' })\");\n console.log('');\n console.log(' \\x1b[1mRestart your editor\\x1b[0m to activate the MCP connection.');\n console.log(' When prompted, \\x1b[1mapprove the MCP server\\x1b[0m in your editor.');\n console.log('');\n}\n"],"mappings":";;;AAAA,SA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ACH,KAAK,OAAO;AAAA,IACZ,QAAQ,OAAO,SAAS;AAAA,IACxB,WAAW,OAAO,YAAY;AAAA,IAC9B,MAAM,OAAO,OAAO,EAAE,QAAQ,OAAO,QAAS,YAAY,OAAO,IAAK,IAAI;AAAA,EAC5E,CAAC,EAAE,MAAM,IAAI;AACf,WAAW,YAAY,UAAU,YAAY,YAAY,YAAY,MAAM;AACzE,UAAQ,IAAI,IAAI;AAClB,OAAO;AACL,UAAQ,MAAM,oBAAoB,KAAK,KAAK,GAAG,CAAC;AAAA,CAAI;AACpD,UAAQ,IAAI,IAAI;AAChB,UAAQ,KAAK,CAAC;AAChB;","names":["existsSync","readFileSync","join","existsSync","readFileSync","join","existsSync","readFileSync","writeFileSync","join","log","warn"]}
|