@react-grab/cli 0.1.32 → 0.1.34
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 +12 -38
- package/bin/cli.js +12 -0
- package/dist/cli.cjs +57 -42
- package/dist/cli.js +47 -32
- package/dist/cli.js.map +1 -1
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @react-grab/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI for installing React Grab and configuring its activation behavior.
|
|
4
|
+
|
|
5
|
+
The CLI detects supported React projects, applies the dev-only setup, and can reconfigure an existing installation without hand-editing framework files.
|
|
4
6
|
|
|
5
7
|
## Quick Start
|
|
6
8
|
|
|
@@ -12,7 +14,7 @@ npx grab@latest init
|
|
|
12
14
|
|
|
13
15
|
### `grab init`
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
Install React Grab in the current project. The CLI auto-detects the framework and applies the required development-only integration.
|
|
16
18
|
|
|
17
19
|
```bash
|
|
18
20
|
npx grab@latest init
|
|
@@ -27,35 +29,9 @@ npx grab@latest init
|
|
|
27
29
|
| `--pkg <pkg>` | | Custom package URL |
|
|
28
30
|
| `--cwd <cwd>` | `-c` | Working directory (default: current dir) |
|
|
29
31
|
|
|
30
|
-
### `grab add`
|
|
31
|
-
|
|
32
|
-
Connect React Grab to your coding agent via MCP.
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npx grab@latest add mcp
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
| Option | Alias | Description |
|
|
39
|
-
| ------------- | ----- | ---------------------------------------- |
|
|
40
|
-
| `--yes` | `-y` | Skip confirmation prompts |
|
|
41
|
-
| `--cwd <cwd>` | `-c` | Working directory (default: current dir) |
|
|
42
|
-
|
|
43
|
-
### `grab remove`
|
|
44
|
-
|
|
45
|
-
Disconnect React Grab from your coding agent.
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npx grab@latest remove mcp
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
| Option | Alias | Description |
|
|
52
|
-
| ------------- | ----- | ---------------------------------------- |
|
|
53
|
-
| `--yes` | `-y` | Skip confirmation prompts |
|
|
54
|
-
| `--cwd <cwd>` | `-c` | Working directory (default: current dir) |
|
|
55
|
-
|
|
56
32
|
### `grab configure`
|
|
57
33
|
|
|
58
|
-
|
|
34
|
+
Update React Grab options. Runs an interactive wizard when called without flags.
|
|
59
35
|
|
|
60
36
|
```bash
|
|
61
37
|
npx grab@latest configure
|
|
@@ -84,9 +60,6 @@ npx grab@latest init -y
|
|
|
84
60
|
# Set a custom activation key
|
|
85
61
|
npx grab@latest init -k "Meta+K"
|
|
86
62
|
|
|
87
|
-
# Connect MCP to your agent
|
|
88
|
-
npx grab@latest add mcp
|
|
89
|
-
|
|
90
63
|
# Change activation mode to hold
|
|
91
64
|
npx grab@latest configure --mode hold --hold-duration 500
|
|
92
65
|
|
|
@@ -96,9 +69,10 @@ npx grab@latest configure
|
|
|
96
69
|
|
|
97
70
|
## Supported Frameworks
|
|
98
71
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
72
|
+
The CLI currently configures:
|
|
73
|
+
|
|
74
|
+
- Next.js App Router
|
|
75
|
+
- Next.js Pages Router
|
|
76
|
+
- Vite
|
|
77
|
+
- TanStack Start
|
|
78
|
+
- Webpack
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import module from "node:module";
|
|
3
|
+
|
|
4
|
+
if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
|
|
5
|
+
try {
|
|
6
|
+
module.enableCompileCache();
|
|
7
|
+
} catch {
|
|
8
|
+
// Ignore compile-cache errors.
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
await import("../dist/cli.js");
|
package/dist/cli.cjs
CHANGED
|
@@ -23,27 +23,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let commander = require("commander");
|
|
25
25
|
let picocolors = require("picocolors");
|
|
26
|
-
picocolors = __toESM(picocolors);
|
|
26
|
+
picocolors = __toESM(picocolors, 1);
|
|
27
27
|
let node_fs = require("node:fs");
|
|
28
|
-
node_fs = __toESM(node_fs);
|
|
28
|
+
node_fs = __toESM(node_fs, 1);
|
|
29
29
|
let node_path = require("node:path");
|
|
30
|
-
node_path = __toESM(node_path);
|
|
31
|
-
let
|
|
30
|
+
node_path = __toESM(node_path, 1);
|
|
31
|
+
let package_manager_detector_detect = require("package-manager-detector/detect");
|
|
32
32
|
let ignore = require("ignore");
|
|
33
|
-
ignore = __toESM(ignore);
|
|
33
|
+
ignore = __toESM(ignore, 1);
|
|
34
34
|
let node_os = require("node:os");
|
|
35
|
-
node_os = __toESM(node_os);
|
|
35
|
+
node_os = __toESM(node_os, 1);
|
|
36
36
|
let node_process = require("node:process");
|
|
37
|
-
node_process = __toESM(node_process);
|
|
37
|
+
node_process = __toESM(node_process, 1);
|
|
38
38
|
let jsonc_parser = require("jsonc-parser");
|
|
39
|
-
jsonc_parser = __toESM(jsonc_parser);
|
|
39
|
+
jsonc_parser = __toESM(jsonc_parser, 1);
|
|
40
40
|
let smol_toml = require("smol-toml");
|
|
41
|
-
smol_toml = __toESM(smol_toml);
|
|
41
|
+
smol_toml = __toESM(smol_toml, 1);
|
|
42
42
|
let prompts = require("prompts");
|
|
43
|
-
prompts = __toESM(prompts);
|
|
43
|
+
prompts = __toESM(prompts, 1);
|
|
44
44
|
let ora = require("ora");
|
|
45
|
-
ora = __toESM(ora);
|
|
46
|
-
let
|
|
45
|
+
ora = __toESM(ora, 1);
|
|
46
|
+
let tinyexec = require("tinyexec");
|
|
47
47
|
//#region src/utils/is-non-interactive.ts
|
|
48
48
|
const AGENT_ENVIRONMENT_VARIABLES = [
|
|
49
49
|
"CI",
|
|
@@ -65,9 +65,9 @@ const VALID_PACKAGE_MANAGERS = new Set([
|
|
|
65
65
|
"bun"
|
|
66
66
|
]);
|
|
67
67
|
const detectPackageManager = async (projectRoot) => {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
const managerName =
|
|
68
|
+
const result = await (0, package_manager_detector_detect.detect)({ cwd: projectRoot });
|
|
69
|
+
if (result?.agent) {
|
|
70
|
+
const managerName = result.agent.split("@")[0];
|
|
71
71
|
if (VALID_PACKAGE_MANAGERS.has(managerName)) return managerName;
|
|
72
72
|
}
|
|
73
73
|
return "npm";
|
|
@@ -587,7 +587,7 @@ const promptMcpInstall = async () => {
|
|
|
587
587
|
};
|
|
588
588
|
//#endregion
|
|
589
589
|
//#region src/commands/add.ts
|
|
590
|
-
const VERSION$5 = "0.1.
|
|
590
|
+
const VERSION$5 = "0.1.34";
|
|
591
591
|
const add = new commander.Command().name("add").alias("install").description("connect React Grab to your agent via MCP").argument("[agent]", "agent to connect (mcp)").option("-y, --yes", "skip confirmation prompts", false).option("-c, --cwd <cwd>", "working directory (defaults to current directory)", process.cwd()).action(async (agentArg, opts) => {
|
|
592
592
|
console.log(`${picocolors.default.magenta("✿")} ${picocolors.default.bold("React Grab")} ${picocolors.default.gray(VERSION$5)}`);
|
|
593
593
|
console.log();
|
|
@@ -1217,7 +1217,7 @@ const formatActivationKeyDisplay = (activationKey) => {
|
|
|
1217
1217
|
};
|
|
1218
1218
|
//#endregion
|
|
1219
1219
|
//#region src/commands/configure.ts
|
|
1220
|
-
const VERSION$4 = "0.1.
|
|
1220
|
+
const VERSION$4 = "0.1.34";
|
|
1221
1221
|
const isMac = process.platform === "darwin";
|
|
1222
1222
|
const META_LABEL = isMac ? "Cmd" : "Win";
|
|
1223
1223
|
const ALT_LABEL = isMac ? "Option" : "Alt";
|
|
@@ -1408,7 +1408,7 @@ const formatCombo = (combo) => {
|
|
|
1408
1408
|
return parts.join("+");
|
|
1409
1409
|
};
|
|
1410
1410
|
const parseInput = (input) => {
|
|
1411
|
-
const parts = input.toLowerCase().replace(/\s+/g, "").split(/[
|
|
1411
|
+
const parts = input.toLowerCase().replace(/\s+/g, "").split(/[+-]/);
|
|
1412
1412
|
const modifiers = /* @__PURE__ */ new Set();
|
|
1413
1413
|
let partial = "";
|
|
1414
1414
|
for (const part of parts) {
|
|
@@ -1776,23 +1776,31 @@ const configure = new commander.Command().name("configure").alias("config").desc
|
|
|
1776
1776
|
});
|
|
1777
1777
|
//#endregion
|
|
1778
1778
|
//#region src/utils/install.ts
|
|
1779
|
-
const
|
|
1780
|
-
npm: "npm install",
|
|
1781
|
-
yarn: "yarn add",
|
|
1782
|
-
pnpm: "pnpm add",
|
|
1783
|
-
bun: "bun add"
|
|
1784
|
-
};
|
|
1785
|
-
const installPackages = (packages, packageManager, projectRoot, isDev = true) => {
|
|
1779
|
+
const installPackages = async (packages, options = {}) => {
|
|
1786
1780
|
if (packages.length === 0) return;
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1789
|
-
(
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1781
|
+
const detectedAgent = options.packageManager ?? await detectPackageManager(options.cwd ?? process.cwd());
|
|
1782
|
+
const args = [];
|
|
1783
|
+
if (options.preferOffline) args.push("--prefer-offline");
|
|
1784
|
+
if (detectedAgent === "pnpm") {
|
|
1785
|
+
args.push("--prod=false");
|
|
1786
|
+
if ((0, node_fs.existsSync)((0, node_path.resolve)(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) args.push("-w");
|
|
1787
|
+
}
|
|
1788
|
+
if (options.additionalArgs) args.push(...options.additionalArgs);
|
|
1789
|
+
await (0, tinyexec.x)(detectedAgent, [
|
|
1790
|
+
detectedAgent === "npm" ? "install" : "add",
|
|
1791
|
+
...options.isDev !== false ? ["-D"] : [],
|
|
1792
|
+
...args,
|
|
1793
|
+
...packages
|
|
1794
|
+
], {
|
|
1795
|
+
nodeOptions: {
|
|
1796
|
+
stdio: options.silent ? "ignore" : "inherit",
|
|
1797
|
+
cwd: options.cwd,
|
|
1798
|
+
env: {
|
|
1799
|
+
...process.env,
|
|
1800
|
+
REACT_GRAB_INIT: "1"
|
|
1801
|
+
}
|
|
1802
|
+
},
|
|
1803
|
+
throwOnError: true
|
|
1796
1804
|
});
|
|
1797
1805
|
};
|
|
1798
1806
|
const getPackagesToInstall = (includeReactGrab = true) => {
|
|
@@ -1812,11 +1820,14 @@ const applyTransformWithFeedback = (result, message) => {
|
|
|
1812
1820
|
}
|
|
1813
1821
|
writeSpinner.succeed();
|
|
1814
1822
|
};
|
|
1815
|
-
const installPackagesWithFeedback = (packages, packageManager, projectRoot) => {
|
|
1823
|
+
const installPackagesWithFeedback = async (packages, packageManager, projectRoot) => {
|
|
1816
1824
|
if (packages.length === 0) return;
|
|
1817
1825
|
const installSpinner = spinner(`Installing ${packages.join(", ")}.`).start();
|
|
1818
1826
|
try {
|
|
1819
|
-
installPackages(packages,
|
|
1827
|
+
await installPackages(packages, {
|
|
1828
|
+
packageManager,
|
|
1829
|
+
cwd: projectRoot
|
|
1830
|
+
});
|
|
1820
1831
|
installSpinner.succeed();
|
|
1821
1832
|
} catch (error) {
|
|
1822
1833
|
installSpinner.fail();
|
|
@@ -1825,7 +1836,7 @@ const installPackagesWithFeedback = (packages, packageManager, projectRoot) => {
|
|
|
1825
1836
|
};
|
|
1826
1837
|
//#endregion
|
|
1827
1838
|
//#region src/commands/init.ts
|
|
1828
|
-
const VERSION$3 = "0.1.
|
|
1839
|
+
const VERSION$3 = "0.1.34";
|
|
1829
1840
|
const REPORT_URL = "https://react-grab.com/api/report-cli";
|
|
1830
1841
|
const DOCS_URL = "https://github.com/aidenybai/react-grab";
|
|
1831
1842
|
const reportToCli = (type, config, error) => {
|
|
@@ -2183,7 +2194,7 @@ const init = new commander.Command().name("init").alias("setup").description("in
|
|
|
2183
2194
|
}
|
|
2184
2195
|
}
|
|
2185
2196
|
const shouldInstallReactGrab = !projectInfo.hasReactGrab;
|
|
2186
|
-
if (!opts.skipInstall && shouldInstallReactGrab) installPackagesWithFeedback(getPackagesToInstall(shouldInstallReactGrab), finalPackageManager, projectInfo.projectRoot);
|
|
2197
|
+
if (!opts.skipInstall && shouldInstallReactGrab) await installPackagesWithFeedback(getPackagesToInstall(shouldInstallReactGrab), finalPackageManager, projectInfo.projectRoot);
|
|
2187
2198
|
if (hasLayoutChanges) applyTransformWithFeedback(result);
|
|
2188
2199
|
logger.break();
|
|
2189
2200
|
logger.log(`${highlighter.success("Success!")} React Grab has been installed.`);
|
|
@@ -2203,7 +2214,7 @@ const init = new commander.Command().name("init").alias("setup").description("in
|
|
|
2203
2214
|
});
|
|
2204
2215
|
//#endregion
|
|
2205
2216
|
//#region src/commands/remove.ts
|
|
2206
|
-
const VERSION$2 = "0.1.
|
|
2217
|
+
const VERSION$2 = "0.1.34";
|
|
2207
2218
|
const remove = new commander.Command().name("remove").description("disconnect React Grab from your agent").argument("[agent]", "agent to disconnect (mcp)").option("-y, --yes", "skip confirmation prompts", false).option("-c, --cwd <cwd>", "working directory (defaults to current directory)", process.cwd()).action(async (agentArg, opts) => {
|
|
2208
2219
|
console.log(`${picocolors.default.magenta("✿")} ${picocolors.default.bold("React Grab")} ${picocolors.default.gray(VERSION$2)}`);
|
|
2209
2220
|
console.log();
|
|
@@ -2233,7 +2244,7 @@ const remove = new commander.Command().name("remove").description("disconnect Re
|
|
|
2233
2244
|
});
|
|
2234
2245
|
//#endregion
|
|
2235
2246
|
//#region src/commands/upgrade.ts
|
|
2236
|
-
const VERSION$1 = "0.1.
|
|
2247
|
+
const VERSION$1 = "0.1.34";
|
|
2237
2248
|
const NPM_REGISTRY_URL = "https://registry.npmjs.org/react-grab/latest";
|
|
2238
2249
|
const fetchLatestVersion = async () => {
|
|
2239
2250
|
try {
|
|
@@ -2286,7 +2297,11 @@ const upgrade = new commander.Command().name("upgrade").alias("update").descript
|
|
|
2286
2297
|
versionSpinner.succeed(`Update available: ${highlighter.dim(fromLabel)} → ${highlighter.info(`v${latestVersion}`)}.`);
|
|
2287
2298
|
const upgradeSpinner = spinner("Upgrading react-grab.").start();
|
|
2288
2299
|
try {
|
|
2289
|
-
installPackages(["react-grab@latest"],
|
|
2300
|
+
await installPackages(["react-grab@latest"], {
|
|
2301
|
+
packageManager: projectInfo.packageManager,
|
|
2302
|
+
cwd: projectInfo.projectRoot,
|
|
2303
|
+
isDev: isDevDependency(projectInfo.projectRoot)
|
|
2304
|
+
});
|
|
2290
2305
|
upgradeSpinner.succeed();
|
|
2291
2306
|
} catch {
|
|
2292
2307
|
upgradeSpinner.fail();
|
|
@@ -2304,7 +2319,7 @@ const upgrade = new commander.Command().name("upgrade").alias("update").descript
|
|
|
2304
2319
|
});
|
|
2305
2320
|
//#endregion
|
|
2306
2321
|
//#region src/cli.ts
|
|
2307
|
-
const VERSION = "0.1.
|
|
2322
|
+
const VERSION = "0.1.34";
|
|
2308
2323
|
const VERSION_API_URL = "https://www.react-grab.com/api/version";
|
|
2309
2324
|
process.on("SIGINT", () => process.exit(0));
|
|
2310
2325
|
process.on("SIGTERM", () => process.exit(0));
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Command } from "commander";
|
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
import fs, { accessSync, constants, existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
5
5
|
import path, { basename, dirname, join, relative, resolve } from "node:path";
|
|
6
|
-
import { detect } from "
|
|
6
|
+
import { detect } from "package-manager-detector/detect";
|
|
7
7
|
import ignore from "ignore";
|
|
8
8
|
import os from "node:os";
|
|
9
9
|
import process$1 from "node:process";
|
|
@@ -11,7 +11,7 @@ import * as jsonc from "jsonc-parser";
|
|
|
11
11
|
import * as TOML from "smol-toml";
|
|
12
12
|
import basePrompts from "prompts";
|
|
13
13
|
import ora from "ora";
|
|
14
|
-
import {
|
|
14
|
+
import { x } from "tinyexec";
|
|
15
15
|
//#region src/utils/is-non-interactive.ts
|
|
16
16
|
const AGENT_ENVIRONMENT_VARIABLES = [
|
|
17
17
|
"CI",
|
|
@@ -33,9 +33,9 @@ const VALID_PACKAGE_MANAGERS = new Set([
|
|
|
33
33
|
"bun"
|
|
34
34
|
]);
|
|
35
35
|
const detectPackageManager = async (projectRoot) => {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
const managerName =
|
|
36
|
+
const result = await detect({ cwd: projectRoot });
|
|
37
|
+
if (result?.agent) {
|
|
38
|
+
const managerName = result.agent.split("@")[0];
|
|
39
39
|
if (VALID_PACKAGE_MANAGERS.has(managerName)) return managerName;
|
|
40
40
|
}
|
|
41
41
|
return "npm";
|
|
@@ -555,7 +555,7 @@ const promptMcpInstall = async () => {
|
|
|
555
555
|
};
|
|
556
556
|
//#endregion
|
|
557
557
|
//#region src/commands/add.ts
|
|
558
|
-
const VERSION$5 = "0.1.
|
|
558
|
+
const VERSION$5 = "0.1.34";
|
|
559
559
|
const add = new Command().name("add").alias("install").description("connect React Grab to your agent via MCP").argument("[agent]", "agent to connect (mcp)").option("-y, --yes", "skip confirmation prompts", false).option("-c, --cwd <cwd>", "working directory (defaults to current directory)", process.cwd()).action(async (agentArg, opts) => {
|
|
560
560
|
console.log(`${pc.magenta("✿")} ${pc.bold("React Grab")} ${pc.gray(VERSION$5)}`);
|
|
561
561
|
console.log();
|
|
@@ -1185,7 +1185,7 @@ const formatActivationKeyDisplay = (activationKey) => {
|
|
|
1185
1185
|
};
|
|
1186
1186
|
//#endregion
|
|
1187
1187
|
//#region src/commands/configure.ts
|
|
1188
|
-
const VERSION$4 = "0.1.
|
|
1188
|
+
const VERSION$4 = "0.1.34";
|
|
1189
1189
|
const isMac = process.platform === "darwin";
|
|
1190
1190
|
const META_LABEL = isMac ? "Cmd" : "Win";
|
|
1191
1191
|
const ALT_LABEL = isMac ? "Option" : "Alt";
|
|
@@ -1376,7 +1376,7 @@ const formatCombo = (combo) => {
|
|
|
1376
1376
|
return parts.join("+");
|
|
1377
1377
|
};
|
|
1378
1378
|
const parseInput = (input) => {
|
|
1379
|
-
const parts = input.toLowerCase().replace(/\s+/g, "").split(/[
|
|
1379
|
+
const parts = input.toLowerCase().replace(/\s+/g, "").split(/[+-]/);
|
|
1380
1380
|
const modifiers = /* @__PURE__ */ new Set();
|
|
1381
1381
|
let partial = "";
|
|
1382
1382
|
for (const part of parts) {
|
|
@@ -1744,23 +1744,31 @@ const configure = new Command().name("configure").alias("config").description("c
|
|
|
1744
1744
|
});
|
|
1745
1745
|
//#endregion
|
|
1746
1746
|
//#region src/utils/install.ts
|
|
1747
|
-
const
|
|
1748
|
-
npm: "npm install",
|
|
1749
|
-
yarn: "yarn add",
|
|
1750
|
-
pnpm: "pnpm add",
|
|
1751
|
-
bun: "bun add"
|
|
1752
|
-
};
|
|
1753
|
-
const installPackages = (packages, packageManager, projectRoot, isDev = true) => {
|
|
1747
|
+
const installPackages = async (packages, options = {}) => {
|
|
1754
1748
|
if (packages.length === 0) return;
|
|
1755
|
-
const
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1749
|
+
const detectedAgent = options.packageManager ?? await detectPackageManager(options.cwd ?? process.cwd());
|
|
1750
|
+
const args = [];
|
|
1751
|
+
if (options.preferOffline) args.push("--prefer-offline");
|
|
1752
|
+
if (detectedAgent === "pnpm") {
|
|
1753
|
+
args.push("--prod=false");
|
|
1754
|
+
if (existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) args.push("-w");
|
|
1755
|
+
}
|
|
1756
|
+
if (options.additionalArgs) args.push(...options.additionalArgs);
|
|
1757
|
+
await x(detectedAgent, [
|
|
1758
|
+
detectedAgent === "npm" ? "install" : "add",
|
|
1759
|
+
...options.isDev !== false ? ["-D"] : [],
|
|
1760
|
+
...args,
|
|
1761
|
+
...packages
|
|
1762
|
+
], {
|
|
1763
|
+
nodeOptions: {
|
|
1764
|
+
stdio: options.silent ? "ignore" : "inherit",
|
|
1765
|
+
cwd: options.cwd,
|
|
1766
|
+
env: {
|
|
1767
|
+
...process.env,
|
|
1768
|
+
REACT_GRAB_INIT: "1"
|
|
1769
|
+
}
|
|
1770
|
+
},
|
|
1771
|
+
throwOnError: true
|
|
1764
1772
|
});
|
|
1765
1773
|
};
|
|
1766
1774
|
const getPackagesToInstall = (includeReactGrab = true) => {
|
|
@@ -1780,11 +1788,14 @@ const applyTransformWithFeedback = (result, message) => {
|
|
|
1780
1788
|
}
|
|
1781
1789
|
writeSpinner.succeed();
|
|
1782
1790
|
};
|
|
1783
|
-
const installPackagesWithFeedback = (packages, packageManager, projectRoot) => {
|
|
1791
|
+
const installPackagesWithFeedback = async (packages, packageManager, projectRoot) => {
|
|
1784
1792
|
if (packages.length === 0) return;
|
|
1785
1793
|
const installSpinner = spinner(`Installing ${packages.join(", ")}.`).start();
|
|
1786
1794
|
try {
|
|
1787
|
-
installPackages(packages,
|
|
1795
|
+
await installPackages(packages, {
|
|
1796
|
+
packageManager,
|
|
1797
|
+
cwd: projectRoot
|
|
1798
|
+
});
|
|
1788
1799
|
installSpinner.succeed();
|
|
1789
1800
|
} catch (error) {
|
|
1790
1801
|
installSpinner.fail();
|
|
@@ -1793,7 +1804,7 @@ const installPackagesWithFeedback = (packages, packageManager, projectRoot) => {
|
|
|
1793
1804
|
};
|
|
1794
1805
|
//#endregion
|
|
1795
1806
|
//#region src/commands/init.ts
|
|
1796
|
-
const VERSION$3 = "0.1.
|
|
1807
|
+
const VERSION$3 = "0.1.34";
|
|
1797
1808
|
const REPORT_URL = "https://react-grab.com/api/report-cli";
|
|
1798
1809
|
const DOCS_URL = "https://github.com/aidenybai/react-grab";
|
|
1799
1810
|
const reportToCli = (type, config, error) => {
|
|
@@ -2151,7 +2162,7 @@ const init = new Command().name("init").alias("setup").description("initialize R
|
|
|
2151
2162
|
}
|
|
2152
2163
|
}
|
|
2153
2164
|
const shouldInstallReactGrab = !projectInfo.hasReactGrab;
|
|
2154
|
-
if (!opts.skipInstall && shouldInstallReactGrab) installPackagesWithFeedback(getPackagesToInstall(shouldInstallReactGrab), finalPackageManager, projectInfo.projectRoot);
|
|
2165
|
+
if (!opts.skipInstall && shouldInstallReactGrab) await installPackagesWithFeedback(getPackagesToInstall(shouldInstallReactGrab), finalPackageManager, projectInfo.projectRoot);
|
|
2155
2166
|
if (hasLayoutChanges) applyTransformWithFeedback(result);
|
|
2156
2167
|
logger.break();
|
|
2157
2168
|
logger.log(`${highlighter.success("Success!")} React Grab has been installed.`);
|
|
@@ -2171,7 +2182,7 @@ const init = new Command().name("init").alias("setup").description("initialize R
|
|
|
2171
2182
|
});
|
|
2172
2183
|
//#endregion
|
|
2173
2184
|
//#region src/commands/remove.ts
|
|
2174
|
-
const VERSION$2 = "0.1.
|
|
2185
|
+
const VERSION$2 = "0.1.34";
|
|
2175
2186
|
const remove = new Command().name("remove").description("disconnect React Grab from your agent").argument("[agent]", "agent to disconnect (mcp)").option("-y, --yes", "skip confirmation prompts", false).option("-c, --cwd <cwd>", "working directory (defaults to current directory)", process.cwd()).action(async (agentArg, opts) => {
|
|
2176
2187
|
console.log(`${pc.magenta("✿")} ${pc.bold("React Grab")} ${pc.gray(VERSION$2)}`);
|
|
2177
2188
|
console.log();
|
|
@@ -2201,7 +2212,7 @@ const remove = new Command().name("remove").description("disconnect React Grab f
|
|
|
2201
2212
|
});
|
|
2202
2213
|
//#endregion
|
|
2203
2214
|
//#region src/commands/upgrade.ts
|
|
2204
|
-
const VERSION$1 = "0.1.
|
|
2215
|
+
const VERSION$1 = "0.1.34";
|
|
2205
2216
|
const NPM_REGISTRY_URL = "https://registry.npmjs.org/react-grab/latest";
|
|
2206
2217
|
const fetchLatestVersion = async () => {
|
|
2207
2218
|
try {
|
|
@@ -2254,7 +2265,11 @@ const upgrade = new Command().name("upgrade").alias("update").description("upgra
|
|
|
2254
2265
|
versionSpinner.succeed(`Update available: ${highlighter.dim(fromLabel)} → ${highlighter.info(`v${latestVersion}`)}.`);
|
|
2255
2266
|
const upgradeSpinner = spinner("Upgrading react-grab.").start();
|
|
2256
2267
|
try {
|
|
2257
|
-
installPackages(["react-grab@latest"],
|
|
2268
|
+
await installPackages(["react-grab@latest"], {
|
|
2269
|
+
packageManager: projectInfo.packageManager,
|
|
2270
|
+
cwd: projectInfo.projectRoot,
|
|
2271
|
+
isDev: isDevDependency(projectInfo.projectRoot)
|
|
2272
|
+
});
|
|
2258
2273
|
upgradeSpinner.succeed();
|
|
2259
2274
|
} catch {
|
|
2260
2275
|
upgradeSpinner.fail();
|
|
@@ -2272,7 +2287,7 @@ const upgrade = new Command().name("upgrade").alias("update").description("upgra
|
|
|
2272
2287
|
});
|
|
2273
2288
|
//#endregion
|
|
2274
2289
|
//#region src/cli.ts
|
|
2275
|
-
const VERSION = "0.1.
|
|
2290
|
+
const VERSION = "0.1.34";
|
|
2276
2291
|
const VERSION_API_URL = "https://www.react-grab.com/api/version";
|
|
2277
2292
|
process.on("SIGINT", () => process.exit(0));
|
|
2278
2293
|
process.on("SIGTERM", () => process.exit(0));
|