@nexiq/cli 1.0.2 → 1.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.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from 'node:module';
3
+ const require = __createRequire(import.meta.url);
4
+
5
+ import t from"ws";var e=global;e.WebSocket||(e.WebSocket=t);e.window||(e.window=global);e.self||(e.self=global);e.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__=[{type:1,value:7,isEnabled:!0},{type:2,value:"InternalApp",isEnabled:!0,isValid:!0},{type:2,value:"InternalAppContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdoutContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStderrContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdinContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalFocusContext",isEnabled:!0,isValid:!0}];import l from"react-devtools-core";l.connectToDevTools();
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@nexiq/cli",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "CLI for the nexiq React analysis server",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "nexiq": "dist/cli.js"
8
8
  },
9
9
  "main": "dist/cli.js",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Naputt1/nexiq.git",
13
+ "directory": "packages/cli"
14
+ },
10
15
  "publishConfig": {
11
16
  "registry": "https://registry.npmjs.org/",
12
- "access": "public"
17
+ "access": "public",
18
+ "provenance": true
13
19
  },
14
20
  "dependencies": {
15
21
  "ink": "^4.4.1",
@@ -17,7 +23,7 @@
17
23
  "meow": "^13.2.0",
18
24
  "react": "^18.3.1",
19
25
  "ws": "^8.20.0",
20
- "@nexiq/server": "1.0.1"
26
+ "@nexiq/server": "1.1.0"
21
27
  },
22
28
  "devDependencies": {
23
29
  "@types/node": "^25.5.0",
@@ -25,6 +31,14 @@
25
31
  "tsup": "^8.5.1",
26
32
  "typescript": "^5.7.3"
27
33
  },
34
+ "private": false,
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "engines": {
39
+ "node": ">=20"
40
+ },
41
+ "prepublishOnly": "pnpm build",
28
42
  "scripts": {
29
43
  "build": "tsup",
30
44
  "dev": "tsup --watch",
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __createRequire } from 'node:module';
3
- const require = __createRequire(import.meta.url);
4
-
5
-
6
- // ../../node_modules/.pnpm/ink@4.4.1_@types+react@18.3.28_react@18.3.1/node_modules/ink/build/devtools-window-polyfill.js
7
- import ws from "ws";
8
- var customGlobal = global;
9
- if (!customGlobal.WebSocket) {
10
- customGlobal.WebSocket = ws;
11
- }
12
- if (!customGlobal.window) {
13
- customGlobal.window = global;
14
- }
15
- if (!customGlobal.self) {
16
- customGlobal.self = global;
17
- }
18
- customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
19
- {
20
- // ComponentFilterElementType
21
- type: 1,
22
- // ElementTypeHostComponent
23
- value: 7,
24
- isEnabled: true
25
- },
26
- {
27
- // ComponentFilterDisplayName
28
- type: 2,
29
- value: "InternalApp",
30
- isEnabled: true,
31
- isValid: true
32
- },
33
- {
34
- // ComponentFilterDisplayName
35
- type: 2,
36
- value: "InternalAppContext",
37
- isEnabled: true,
38
- isValid: true
39
- },
40
- {
41
- // ComponentFilterDisplayName
42
- type: 2,
43
- value: "InternalStdoutContext",
44
- isEnabled: true,
45
- isValid: true
46
- },
47
- {
48
- // ComponentFilterDisplayName
49
- type: 2,
50
- value: "InternalStderrContext",
51
- isEnabled: true,
52
- isValid: true
53
- },
54
- {
55
- // ComponentFilterDisplayName
56
- type: 2,
57
- value: "InternalStdinContext",
58
- isEnabled: true,
59
- isValid: true
60
- },
61
- {
62
- // ComponentFilterDisplayName
63
- type: 2,
64
- value: "InternalFocusContext",
65
- isEnabled: true,
66
- isValid: true
67
- }
68
- ];
69
-
70
- // ../../node_modules/.pnpm/ink@4.4.1_@types+react@18.3.28_react@18.3.1/node_modules/ink/build/devtools.js
71
- import devtools from "react-devtools-core";
72
- devtools.connectToDevTools();
package/src/cli.tsx DELETED
@@ -1,107 +0,0 @@
1
- /**
2
- * nexiq CLI entry point.
3
- *
4
- * Usage:
5
- * nexiq start [--port 3030]
6
- * nexiq stop
7
- * nexiq status
8
- * nexiq cache [clear [--force]]
9
- * nexiq --help
10
- */
11
-
12
- import React from "react";
13
- import { render } from "ink";
14
- import { StartApp } from "./components/StartApp.js";
15
- import { StopApp } from "./components/StopApp.js";
16
- import { StatusApp } from "./components/StatusApp.js";
17
- import { CacheApp } from "./components/CacheApp.js";
18
- import { HelpApp } from "./components/HelpApp.js";
19
- import { startServerForeground, BACKEND_PORT } from "./server-process.js";
20
-
21
- // ---------------------------------------------------------------------------
22
- // Argument parsing (no external dependency)
23
- // ---------------------------------------------------------------------------
24
-
25
- const args = process.argv.slice(2);
26
-
27
- function hasFlag(...flags: string[]): boolean {
28
- return flags.some((f) => args.includes(f));
29
- }
30
-
31
- function getFlagValue(flag: string): string | undefined {
32
- const idx = args.indexOf(flag);
33
- if (idx !== -1 && idx + 1 < args.length) {
34
- return args[idx + 1];
35
- }
36
- return undefined;
37
- }
38
-
39
- // Parse port from --port or PORT env var
40
- const portStr = getFlagValue("--port") ?? process.env.PORT;
41
- const port = portStr ? parseInt(portStr, 10) : BACKEND_PORT;
42
-
43
- // ---------------------------------------------------------------------------
44
- // Subcommand routing
45
- // ---------------------------------------------------------------------------
46
-
47
- async function run() {
48
- const [command, subcommand] = args.filter((a) => !a.startsWith("-"));
49
-
50
- // Foreground mode: used by Electron — skips the ink UI entirely so the
51
- // process stays alive and writes directly to inherited stdio.
52
- if (hasFlag("--foreground")) {
53
- // Only valid for `start`
54
- await startServerForeground(port);
55
- process.exit(0);
56
- }
57
-
58
- if (hasFlag("--help", "-h") || !command) {
59
- const { waitUntilExit } = render(<HelpApp />);
60
- await waitUntilExit();
61
- process.exit(0);
62
- }
63
-
64
- switch (command) {
65
- case "start": {
66
- const { waitUntilExit } = render(<StartApp port={port} />);
67
- await waitUntilExit();
68
- process.exit(0);
69
- break;
70
- }
71
-
72
- case "stop": {
73
- const { waitUntilExit } = render(<StopApp port={port} />);
74
- await waitUntilExit();
75
- process.exit(0);
76
- break;
77
- }
78
-
79
- case "status": {
80
- const { waitUntilExit } = render(<StatusApp port={port} />);
81
- await waitUntilExit();
82
- process.exit(0);
83
- break;
84
- }
85
-
86
- case "cache": {
87
- const clear = subcommand === "clear";
88
- const force = hasFlag("--force", "-f");
89
- const { waitUntilExit } = render(<CacheApp clear={clear} force={force} />);
90
- await waitUntilExit();
91
- process.exit(0);
92
- break;
93
- }
94
-
95
- default: {
96
- process.stderr.write(`Unknown command: ${command}\n\n`);
97
- const { waitUntilExit } = render(<HelpApp />);
98
- await waitUntilExit();
99
- process.exit(1);
100
- }
101
- }
102
- }
103
-
104
- run().catch((err) => {
105
- console.error(err);
106
- process.exit(1);
107
- });
@@ -1,187 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import { Box, Text, useApp, useInput } from "ink";
3
- import Spinner from "ink-spinner";
4
- import {
5
- getCacheEntries,
6
- clearCacheEntries,
7
- formatBytes,
8
- type CacheEntry,
9
- } from "../server-process.js";
10
- import {
11
- COLORS,
12
- NexiqBanner,
13
- Divider,
14
- SectionTitle,
15
- } from "./ui.js";
16
-
17
- interface CacheAppProps {
18
- /** If true, clear cache without confirmation (use --force flag) */
19
- clear?: boolean;
20
- force?: boolean;
21
- }
22
-
23
- type Phase =
24
- | "loading"
25
- | "list"
26
- | "confirm-clear"
27
- | "clearing"
28
- | "cleared"
29
- | "no-cache"
30
- | "error";
31
-
32
- export function CacheApp({ clear = false, force = false }: CacheAppProps) {
33
- const { exit } = useApp();
34
-
35
- const [phase, setPhase] = useState<Phase>("loading");
36
- const [entries, setEntries] = useState<CacheEntry[]>([]);
37
- const [errorMsg, setErrorMsg] = useState("");
38
-
39
- useEffect(() => {
40
- try {
41
- const found = getCacheEntries();
42
- setEntries(found);
43
-
44
- if (found.length === 0) {
45
- setPhase("no-cache");
46
- setTimeout(() => exit(), 600);
47
- return;
48
- }
49
-
50
- if (clear) {
51
- if (force) {
52
- // Clear immediately
53
- setPhase("clearing");
54
- clearCacheEntries(found);
55
- setPhase("cleared");
56
- setTimeout(() => exit(), 800);
57
- } else {
58
- setPhase("confirm-clear");
59
- }
60
- } else {
61
- setPhase("list");
62
- // Auto-exit after display
63
- setTimeout(() => exit(), 5000);
64
- }
65
- } catch (e) {
66
- setErrorMsg(e instanceof Error ? e.message : String(e));
67
- setPhase("error");
68
- setTimeout(() => exit(), 1200);
69
- }
70
- }, []);
71
-
72
- // Handle keyboard for confirmation
73
- useInput((input, key) => {
74
- if (phase !== "confirm-clear") return;
75
-
76
- if (input.toLowerCase() === "y") {
77
- setPhase("clearing");
78
- try {
79
- clearCacheEntries(entries);
80
- setPhase("cleared");
81
- setTimeout(() => exit(), 800);
82
- } catch (e) {
83
- setErrorMsg(e instanceof Error ? e.message : String(e));
84
- setPhase("error");
85
- setTimeout(() => exit(), 1200);
86
- }
87
- } else if (input.toLowerCase() === "n" || key.escape) {
88
- setPhase("list");
89
- setTimeout(() => exit(), 600);
90
- }
91
- });
92
-
93
- const totalBytes = entries.reduce((sum, e) => sum + e.sizeBytes, 0);
94
-
95
- return (
96
- <Box flexDirection="column" padding={1}>
97
- <NexiqBanner />
98
- <SectionTitle title="Cache" />
99
-
100
- {phase === "loading" && (
101
- <Box gap={1}>
102
- <Text color={COLORS.cyan}>
103
- <Spinner type="dots" />
104
- </Text>
105
- <Text> Scanning cache…</Text>
106
- </Box>
107
- )}
108
-
109
- {phase === "no-cache" && (
110
- <Box marginTop={1}>
111
- <Text color={COLORS.muted}>No cache entries found in ~/.nexiq/</Text>
112
- </Box>
113
- )}
114
-
115
- {(phase === "list" || phase === "confirm-clear") && (
116
- <Box flexDirection="column" marginTop={1}>
117
- {entries.map((entry, i) => (
118
- <Box key={i} flexDirection="column" marginBottom={0}>
119
- <Box gap={2}>
120
- <Box flexGrow={1}>
121
- <Text color={COLORS.white} wrap="truncate">
122
- {entry.label}
123
- </Text>
124
- </Box>
125
- <Text color={COLORS.muted}>{formatBytes(entry.sizeBytes)}</Text>
126
- <Text color={COLORS.muted}>
127
- {entry.lastModified.toLocaleDateString()}
128
- </Text>
129
- </Box>
130
- </Box>
131
- ))}
132
-
133
- <Divider />
134
- <Box gap={2}>
135
- <Text color={COLORS.cyan} bold>
136
- {entries.length} entries
137
- </Text>
138
- <Text color={COLORS.muted}>{formatBytes(totalBytes)} total</Text>
139
- </Box>
140
-
141
- {phase === "confirm-clear" && (
142
- <Box flexDirection="column" marginTop={1}>
143
- <Text color={COLORS.yellow} bold>
144
- ⚠ Clear all cache? This cannot be undone. (y/N)
145
- </Text>
146
- </Box>
147
- )}
148
-
149
- {phase === "list" && !clear && (
150
- <Box marginTop={1}>
151
- <Text color={COLORS.muted}>
152
- Run{" "}
153
- <Text color={COLORS.accent} bold>
154
- nexiq cache clear
155
- </Text>{" "}
156
- to remove all entries.
157
- </Text>
158
- </Box>
159
- )}
160
- </Box>
161
- )}
162
-
163
- {phase === "clearing" && (
164
- <Box gap={1} marginTop={1}>
165
- <Text color={COLORS.cyan}>
166
- <Spinner type="dots" />
167
- </Text>
168
- <Text> Clearing…</Text>
169
- </Box>
170
- )}
171
-
172
- {phase === "cleared" && (
173
- <Box marginTop={1}>
174
- <Text color={COLORS.green} bold>
175
- ✓ Cache cleared ({entries.length} entries, {formatBytes(totalBytes)})
176
- </Text>
177
- </Box>
178
- )}
179
-
180
- {phase === "error" && (
181
- <Box marginTop={1}>
182
- <Text color={COLORS.red}>{errorMsg}</Text>
183
- </Box>
184
- )}
185
- </Box>
186
- );
187
- }
@@ -1,90 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { Box, Text, useApp } from "ink";
3
- import { COLORS, NexiqBanner, Divider } from "./ui.js";
4
-
5
- interface Command {
6
- usage: string;
7
- description: string;
8
- }
9
-
10
- const COMMANDS: Command[] = [
11
- {
12
- usage: "nexiq start",
13
- description: "Start the nexiq backend server (runs in background)",
14
- },
15
- {
16
- usage: "nexiq stop",
17
- description: "Stop the running backend server",
18
- },
19
- {
20
- usage: "nexiq status",
21
- description: "Show server health, port, PID, and uptime",
22
- },
23
- {
24
- usage: "nexiq cache",
25
- description: "List all project cache entries and their disk usage",
26
- },
27
- {
28
- usage: "nexiq cache clear",
29
- description: "Remove all project caches (prompts for confirmation)",
30
- },
31
- {
32
- usage: "nexiq cache clear --force",
33
- description: "Remove all project caches without confirmation",
34
- },
35
- ];
36
-
37
- export function HelpApp() {
38
- const { exit } = useApp();
39
-
40
- useEffect(() => {
41
- setTimeout(() => exit(), 8000);
42
- }, []);
43
-
44
- return (
45
- <Box flexDirection="column" padding={1}>
46
- <NexiqBanner />
47
-
48
- <Box marginBottom={1}>
49
- <Text color={COLORS.muted}>
50
- React component analysis server — CLI management tool
51
- </Text>
52
- </Box>
53
-
54
- <Divider />
55
-
56
- <Box flexDirection="column" marginTop={1} gap={0}>
57
- {COMMANDS.map((cmd, i) => (
58
- <Box key={i} flexDirection="column" marginBottom={1}>
59
- <Text color={COLORS.accent} bold>
60
- {cmd.usage}
61
- </Text>
62
- <Box marginLeft={2}>
63
- <Text color={COLORS.muted}>{cmd.description}</Text>
64
- </Box>
65
- </Box>
66
- ))}
67
- </Box>
68
-
69
- <Divider />
70
-
71
- <Box marginTop={1} flexDirection="column" gap={0}>
72
- <Text color={COLORS.cyan} bold>
73
- Environment variables
74
- </Text>
75
- <Box marginLeft={2} flexDirection="column">
76
- <Box gap={1}>
77
- <Text color={COLORS.yellow}>REACT_MAP_SERVER_PATH</Text>
78
- <Text color={COLORS.muted}>Override path to server dist/index.js</Text>
79
- </Box>
80
- <Box gap={1}>
81
- <Text color={COLORS.yellow}>PORT</Text>
82
- <Text color={COLORS.muted}>
83
- WebSocket port (default: 3030)
84
- </Text>
85
- </Box>
86
- </Box>
87
- </Box>
88
- </Box>
89
- );
90
- }
@@ -1,125 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import { Box, Text, useApp } from "ink";
3
- import Spinner from "ink-spinner";
4
- import {
5
- isServerAlive,
6
- startServerDetached,
7
- BACKEND_PORT,
8
- } from "../server-process.js";
9
- import { COLORS, NexiqBanner, KvRow, StatusDot } from "./ui.js";
10
-
11
- interface StartAppProps {
12
- port?: number;
13
- }
14
-
15
- type Phase = "checking" | "starting" | "done" | "error";
16
-
17
- export function StartApp({ port = BACKEND_PORT }: StartAppProps) {
18
- const { exit } = useApp();
19
-
20
- const [phase, setPhase] = useState<Phase>("checking");
21
- const [message, setMessage] = useState("");
22
- const [pid, setPid] = useState<number | undefined>();
23
- const [alreadyRunning, setAlreadyRunning] = useState(false);
24
-
25
- useEffect(() => {
26
- let cancelled = false;
27
-
28
- async function run() {
29
- // Phase 1: check if already alive
30
- const alive = await isServerAlive(port);
31
- if (cancelled) return;
32
-
33
- if (alive) {
34
- setAlreadyRunning(true);
35
- setPhase("done");
36
- setMessage(`Server is already running on ws://localhost:${port}`);
37
- setTimeout(() => exit(), 600);
38
- return;
39
- }
40
-
41
- // Phase 2: start detached
42
- setPhase("starting");
43
- const result = await startServerDetached(port);
44
- if (cancelled) return;
45
-
46
- if (result.ok) {
47
- setPid(result.pid);
48
- setPhase("done");
49
- setMessage(`Server started on ws://localhost:${port}`);
50
- } else {
51
- setPhase("error");
52
- setMessage(result.error ?? "Unknown error");
53
- }
54
- setTimeout(() => exit(), result.ok ? 800 : 1200);
55
- }
56
-
57
- run().catch((e) => {
58
- if (!cancelled) {
59
- setPhase("error");
60
- setMessage(e instanceof Error ? e.message : String(e));
61
- setTimeout(() => exit(), 1200);
62
- }
63
- });
64
-
65
- return () => {
66
- cancelled = true;
67
- };
68
- }, []);
69
-
70
- return (
71
- <Box flexDirection="column" padding={1}>
72
- <NexiqBanner />
73
-
74
- {phase === "checking" && (
75
- <Box>
76
- <Text color={COLORS.cyan}>
77
- <Spinner type="dots" />
78
- </Text>
79
- <Text> Checking server…</Text>
80
- </Box>
81
- )}
82
-
83
- {phase === "starting" && (
84
- <Box>
85
- <Text color={COLORS.cyan}>
86
- <Spinner type="dots" />
87
- </Text>
88
- <Text> Starting server on port {port}…</Text>
89
- </Box>
90
- )}
91
-
92
- {phase === "done" && (
93
- <Box flexDirection="column" gap={0}>
94
- <Box gap={1}>
95
- <StatusDot running={true} />
96
- <Text color={COLORS.green} bold>
97
- {alreadyRunning ? "Already running" : "Server started"}
98
- </Text>
99
- </Box>
100
- <KvRow label="Address" value={`ws://localhost:${port}`} />
101
- {pid !== undefined && (
102
- <KvRow label="PID" value={String(pid)} />
103
- )}
104
- <Box marginTop={1}>
105
- <Text color={COLORS.muted}>{message}</Text>
106
- </Box>
107
- </Box>
108
- )}
109
-
110
- {phase === "error" && (
111
- <Box flexDirection="column" gap={0}>
112
- <Box gap={1}>
113
- <StatusDot running={false} />
114
- <Text color={COLORS.red} bold>
115
- Failed to start server
116
- </Text>
117
- </Box>
118
- <Box marginTop={1}>
119
- <Text color={COLORS.red}>{message}</Text>
120
- </Box>
121
- </Box>
122
- )}
123
- </Box>
124
- );
125
- }