@mcpc-tech/unplugin-dev-inspector-mcp 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +46 -2
- package/dist/cli.js +46 -2
- package/dist/index.d.cts +4 -4
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -149,11 +149,42 @@ function transformViteConfig(code, options) {
|
|
|
149
149
|
error: "Could not find plugins array in config",
|
|
150
150
|
message: "Please add DevInspector manually to your plugins array"
|
|
151
151
|
};
|
|
152
|
+
if (options.host || options.allowedHosts && options.allowedHosts.length > 0) traverse$2(ast, { ExportDefaultDeclaration(path$1) {
|
|
153
|
+
if (path$1.node.declaration.type === "CallExpression" && path$1.node.declaration.arguments.length > 0 && path$1.node.declaration.arguments[0].type === "ObjectExpression") {
|
|
154
|
+
const configObj = path$1.node.declaration.arguments[0];
|
|
155
|
+
const serverProp = configObj.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "server");
|
|
156
|
+
if (serverProp) {
|
|
157
|
+
if (serverProp.value.start !== null && serverProp.value.start !== void 0) {
|
|
158
|
+
const serverContentStart = serverProp.value.start + 1;
|
|
159
|
+
let injection = "";
|
|
160
|
+
const serverBlockEnd = serverProp.value.end;
|
|
161
|
+
if (serverBlockEnd) {
|
|
162
|
+
const currentServerBlock = code.slice(serverContentStart, serverBlockEnd);
|
|
163
|
+
if (options.host && !currentServerBlock.includes("host:")) injection += `\n host: '${options.host}',`;
|
|
164
|
+
if (options.allowedHosts && options.allowedHosts.length > 0 && !currentServerBlock.includes("allowedHosts:")) {
|
|
165
|
+
const hostsStr = options.allowedHosts.map((h) => `'${h}'`).join(", ");
|
|
166
|
+
injection += `\n allowedHosts: [${hostsStr}],`;
|
|
167
|
+
}
|
|
168
|
+
if (injection) s.appendLeft(serverContentStart, injection);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} else if (configObj.start !== null && configObj.start !== void 0) {
|
|
172
|
+
let injection = "\n server: {\n";
|
|
173
|
+
if (options.host) injection += ` host: '${options.host}',\n`;
|
|
174
|
+
if (options.allowedHosts && options.allowedHosts.length > 0) {
|
|
175
|
+
const hostsStr = options.allowedHosts.map((h) => `'${h}'`).join(", ");
|
|
176
|
+
injection += ` allowedHosts: [${hostsStr}],\n`;
|
|
177
|
+
}
|
|
178
|
+
injection += " },";
|
|
179
|
+
s.appendLeft(configObj.start + 1, injection);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
} });
|
|
152
183
|
return {
|
|
153
184
|
success: true,
|
|
154
185
|
modified: true,
|
|
155
186
|
code: s.toString(),
|
|
156
|
-
message: "Successfully added DevInspector
|
|
187
|
+
message: "Successfully added DevInspector and configured server in Vite config"
|
|
157
188
|
};
|
|
158
189
|
} catch (error) {
|
|
159
190
|
return {
|
|
@@ -393,6 +424,8 @@ async function runSetupCommand() {
|
|
|
393
424
|
let configPath;
|
|
394
425
|
let bundlerType;
|
|
395
426
|
let entryPath;
|
|
427
|
+
let host;
|
|
428
|
+
const allowedHosts = [];
|
|
396
429
|
for (let i = 0; i < args.length; i++) if (args[i] === "--dry-run") dryRun = true;
|
|
397
430
|
else if (args[i] === "--config" && args[i + 1]) {
|
|
398
431
|
configPath = args[i + 1];
|
|
@@ -400,6 +433,13 @@ async function runSetupCommand() {
|
|
|
400
433
|
} else if (args[i] === "--entry" && args[i + 1]) {
|
|
401
434
|
entryPath = args[i + 1];
|
|
402
435
|
i++;
|
|
436
|
+
} else if (args[i] === "--host" && args[i + 1]) {
|
|
437
|
+
host = args[i + 1];
|
|
438
|
+
i++;
|
|
439
|
+
} else if (args[i] === "--allowed-hosts" && args[i + 1]) {
|
|
440
|
+
const hosts = args[i + 1].split(",").map((h) => h.trim()).filter(Boolean);
|
|
441
|
+
allowedHosts.push(...hosts);
|
|
442
|
+
i++;
|
|
403
443
|
} else if (args[i] === "--bundler" && args[i + 1]) {
|
|
404
444
|
bundlerType = args[i + 1];
|
|
405
445
|
i++;
|
|
@@ -489,7 +529,9 @@ async function runSetupCommand() {
|
|
|
489
529
|
const options = {
|
|
490
530
|
dryRun,
|
|
491
531
|
configPath: selectedConfigPath,
|
|
492
|
-
entryPath
|
|
532
|
+
entryPath,
|
|
533
|
+
host,
|
|
534
|
+
allowedHosts
|
|
493
535
|
};
|
|
494
536
|
const framework = frameworks.find((f) => f.type === selectedBundler);
|
|
495
537
|
if (!framework) {
|
|
@@ -544,6 +586,8 @@ Options:
|
|
|
544
586
|
--config <path> Specify config file path (auto-detect by default)
|
|
545
587
|
--entry <path> Specify entry file path to add import (optional)
|
|
546
588
|
--bundler <type> Specify bundler type: vite, webpack, nextjs
|
|
589
|
+
--host <string> Specify server host (e.g. 0.0.0.0)
|
|
590
|
+
--allowed-hosts <list> Specify allowed hosts (comma-separated)
|
|
547
591
|
--dry-run Preview changes without applying them
|
|
548
592
|
--help, -h Show this help message
|
|
549
593
|
`);
|
package/dist/cli.js
CHANGED
|
@@ -147,11 +147,42 @@ function transformViteConfig(code, options) {
|
|
|
147
147
|
error: "Could not find plugins array in config",
|
|
148
148
|
message: "Please add DevInspector manually to your plugins array"
|
|
149
149
|
};
|
|
150
|
+
if (options.host || options.allowedHosts && options.allowedHosts.length > 0) traverse$2(ast, { ExportDefaultDeclaration(path$1) {
|
|
151
|
+
if (path$1.node.declaration.type === "CallExpression" && path$1.node.declaration.arguments.length > 0 && path$1.node.declaration.arguments[0].type === "ObjectExpression") {
|
|
152
|
+
const configObj = path$1.node.declaration.arguments[0];
|
|
153
|
+
const serverProp = configObj.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "server");
|
|
154
|
+
if (serverProp) {
|
|
155
|
+
if (serverProp.value.start !== null && serverProp.value.start !== void 0) {
|
|
156
|
+
const serverContentStart = serverProp.value.start + 1;
|
|
157
|
+
let injection = "";
|
|
158
|
+
const serverBlockEnd = serverProp.value.end;
|
|
159
|
+
if (serverBlockEnd) {
|
|
160
|
+
const currentServerBlock = code.slice(serverContentStart, serverBlockEnd);
|
|
161
|
+
if (options.host && !currentServerBlock.includes("host:")) injection += `\n host: '${options.host}',`;
|
|
162
|
+
if (options.allowedHosts && options.allowedHosts.length > 0 && !currentServerBlock.includes("allowedHosts:")) {
|
|
163
|
+
const hostsStr = options.allowedHosts.map((h) => `'${h}'`).join(", ");
|
|
164
|
+
injection += `\n allowedHosts: [${hostsStr}],`;
|
|
165
|
+
}
|
|
166
|
+
if (injection) s.appendLeft(serverContentStart, injection);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
} else if (configObj.start !== null && configObj.start !== void 0) {
|
|
170
|
+
let injection = "\n server: {\n";
|
|
171
|
+
if (options.host) injection += ` host: '${options.host}',\n`;
|
|
172
|
+
if (options.allowedHosts && options.allowedHosts.length > 0) {
|
|
173
|
+
const hostsStr = options.allowedHosts.map((h) => `'${h}'`).join(", ");
|
|
174
|
+
injection += ` allowedHosts: [${hostsStr}],\n`;
|
|
175
|
+
}
|
|
176
|
+
injection += " },";
|
|
177
|
+
s.appendLeft(configObj.start + 1, injection);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} });
|
|
150
181
|
return {
|
|
151
182
|
success: true,
|
|
152
183
|
modified: true,
|
|
153
184
|
code: s.toString(),
|
|
154
|
-
message: "Successfully added DevInspector
|
|
185
|
+
message: "Successfully added DevInspector and configured server in Vite config"
|
|
155
186
|
};
|
|
156
187
|
} catch (error) {
|
|
157
188
|
return {
|
|
@@ -391,6 +422,8 @@ async function runSetupCommand() {
|
|
|
391
422
|
let configPath;
|
|
392
423
|
let bundlerType;
|
|
393
424
|
let entryPath;
|
|
425
|
+
let host;
|
|
426
|
+
const allowedHosts = [];
|
|
394
427
|
for (let i = 0; i < args.length; i++) if (args[i] === "--dry-run") dryRun = true;
|
|
395
428
|
else if (args[i] === "--config" && args[i + 1]) {
|
|
396
429
|
configPath = args[i + 1];
|
|
@@ -398,6 +431,13 @@ async function runSetupCommand() {
|
|
|
398
431
|
} else if (args[i] === "--entry" && args[i + 1]) {
|
|
399
432
|
entryPath = args[i + 1];
|
|
400
433
|
i++;
|
|
434
|
+
} else if (args[i] === "--host" && args[i + 1]) {
|
|
435
|
+
host = args[i + 1];
|
|
436
|
+
i++;
|
|
437
|
+
} else if (args[i] === "--allowed-hosts" && args[i + 1]) {
|
|
438
|
+
const hosts = args[i + 1].split(",").map((h) => h.trim()).filter(Boolean);
|
|
439
|
+
allowedHosts.push(...hosts);
|
|
440
|
+
i++;
|
|
401
441
|
} else if (args[i] === "--bundler" && args[i + 1]) {
|
|
402
442
|
bundlerType = args[i + 1];
|
|
403
443
|
i++;
|
|
@@ -487,7 +527,9 @@ async function runSetupCommand() {
|
|
|
487
527
|
const options = {
|
|
488
528
|
dryRun,
|
|
489
529
|
configPath: selectedConfigPath,
|
|
490
|
-
entryPath
|
|
530
|
+
entryPath,
|
|
531
|
+
host,
|
|
532
|
+
allowedHosts
|
|
491
533
|
};
|
|
492
534
|
const framework = frameworks.find((f) => f.type === selectedBundler);
|
|
493
535
|
if (!framework) {
|
|
@@ -542,6 +584,8 @@ Options:
|
|
|
542
584
|
--config <path> Specify config file path (auto-detect by default)
|
|
543
585
|
--entry <path> Specify entry file path to add import (optional)
|
|
544
586
|
--bundler <type> Specify bundler type: vite, webpack, nextjs
|
|
587
|
+
--host <string> Specify server host (e.g. 0.0.0.0)
|
|
588
|
+
--allowed-hosts <list> Specify allowed hosts (comma-separated)
|
|
545
589
|
--dry-run Preview changes without applying them
|
|
546
590
|
--help, -h Show this help message
|
|
547
591
|
`);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as unplugin1 from "unplugin";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/config-updater.d.ts
|
|
4
4
|
type EditorId = "cursor" | "vscode" | "windsurf" | "claude-code" | "antigravity";
|
|
@@ -192,10 +192,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
192
192
|
}
|
|
193
193
|
//#endregion
|
|
194
194
|
//#region src/core.d.ts
|
|
195
|
-
declare const unplugin:
|
|
195
|
+
declare const unplugin: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
196
196
|
//#endregion
|
|
197
197
|
//#region src/core-external.d.ts
|
|
198
|
-
declare const unpluginExternal:
|
|
198
|
+
declare const unpluginExternal: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
199
199
|
//#endregion
|
|
200
200
|
//#region src/turbopack.d.ts
|
|
201
201
|
interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
@@ -220,7 +220,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
|
220
220
|
declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region src/index.d.ts
|
|
223
|
-
declare const external:
|
|
223
|
+
declare const external: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
224
224
|
declare module "virtual:dev-inspector-mcp" {}
|
|
225
225
|
//#endregion
|
|
226
226
|
export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
|
package/package.json
CHANGED