@inspecto-dev/cli 0.2.0-alpha.2 → 0.2.0-alpha.4
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/.turbo/turbo-build.log +5 -5
- package/.turbo/turbo-test.log +21 -15
- package/CHANGELOG.md +22 -0
- package/dist/bin.js +1 -1
- package/dist/{chunk-V57BJXGZ.js → chunk-EUCQCD3Y.js} +309 -91
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/commands/init.ts +115 -19
- package/src/detect/build-tool.ts +227 -88
- package/src/detect/framework.ts +71 -9
- package/src/inject/extension.ts +6 -3
- package/src/types.ts +2 -0
- package/tests/build-tool.test.ts +46 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @inspecto-dev/cli@0.2.0-alpha.
|
|
3
|
+
> @inspecto-dev/cli@0.2.0-alpha.3 build /Users/bytedance/Works/hugo.felix/inspecto/packages/cli
|
|
4
4
|
> tsup
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/bin.ts, src/index.ts
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
[34mCLI[39m Target: node18
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/bin.js [22m[32m2.64 KB[39m
|
|
14
13
|
[32mESM[39m [1mdist/index.js [22m[32m109.00 B[39m
|
|
15
|
-
[32mESM[39m [1mdist/chunk-
|
|
16
|
-
[32mESM[39m
|
|
14
|
+
[32mESM[39m [1mdist/chunk-EUCQCD3Y.js [22m[32m57.56 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/bin.js [22m[32m2.64 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 136ms
|
|
17
17
|
DTS Build start
|
|
18
|
-
DTS ⚡️ Build success in
|
|
18
|
+
DTS ⚡️ Build success in 1464ms
|
|
19
19
|
DTS dist/bin.d.ts 13.00 B
|
|
20
20
|
DTS dist/index.d.ts 1.18 KB
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @inspecto-dev/cli@0.2.0-alpha.3 test /Users/bytedance/Works/hugo.felix/inspecto/packages/cli
|
|
4
|
+
> vitest run --passWithNoTests
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
[7m[1m[36m RUN [39m[22m[27m [36mv1.6.1[39m [90m/Users/bytedance/Works/hugo.felix/inspecto/packages/cli[39m
|
|
8
|
+
|
|
9
|
+
[?25l [32m✓[39m [2mtests/[22mframework[2m.test.ts[22m[2m (5)[22m
|
|
10
|
+
[32m✓[39m [2mtests/[22mbuild-tool[2m.test.ts[22m[2m (2)[22m
|
|
11
|
+
[32m✓[39m [2mtests/[22mide[2m.test.ts[22m[2m (6)[22m
|
|
12
|
+
[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2mtests/[22mframework[2m.test.ts[22m[2m (5)[22m
|
|
13
|
+
[32m✓[39m [2mtests/[22mbuild-tool[2m.test.ts[22m[2m (2)[22m
|
|
14
|
+
[32m✓[39m [2mtests/[22mide[2m.test.ts[22m[2m (6)[22m
|
|
15
|
+
|
|
16
|
+
[2m Test Files [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
|
17
|
+
[2m Tests [22m [1m[32m13 passed[39m[22m[90m (13)[39m
|
|
18
|
+
[2m Start at [22m 11:27:40
|
|
19
|
+
[2m Duration [22m 548ms[2m (transform 85ms, setup 0ms, collect 131ms, tests 15ms, environment 0ms, prepare 374ms)[22m
|
|
20
|
+
|
|
21
|
+
[?25h[?25h
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @inspecto-dev/cli
|
|
2
2
|
|
|
3
|
+
## 0.2.0-alpha.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- release alpha test version
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @inspecto-dev/types@0.2.0-alpha.4
|
|
13
|
+
|
|
14
|
+
## 0.2.0-alpha.3
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- release alpha test version
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @inspecto-dev/types@0.2.0-alpha.3
|
|
24
|
+
|
|
3
25
|
## 0.2.0-alpha.2
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/bin.js
CHANGED
|
@@ -177,10 +177,42 @@ function getUninstallCommand(pm, pkg) {
|
|
|
177
177
|
|
|
178
178
|
// src/detect/build-tool.ts
|
|
179
179
|
import path3 from "path";
|
|
180
|
+
import { createRequire } from "module";
|
|
181
|
+
function isPackageResolvable(pkgName, root) {
|
|
182
|
+
try {
|
|
183
|
+
const require2 = createRequire(path3.join(root, "package.json"));
|
|
184
|
+
try {
|
|
185
|
+
require2.resolve(`${pkgName}/package.json`, { paths: [root] });
|
|
186
|
+
return true;
|
|
187
|
+
} catch {
|
|
188
|
+
require2.resolve(pkgName, { paths: [root] });
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
} catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function getResolvedPackageVersion(pkgName, root) {
|
|
196
|
+
try {
|
|
197
|
+
const require2 = createRequire(path3.join(root, "package.json"));
|
|
198
|
+
const pkgJsonPath = require2.resolve(`${pkgName}/package.json`, { paths: [root] });
|
|
199
|
+
const pkg = await readJSON(pkgJsonPath);
|
|
200
|
+
return pkg?.version || null;
|
|
201
|
+
} catch {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
180
205
|
var SUPPORTED_PATTERNS = [
|
|
181
206
|
{
|
|
182
207
|
tool: "vite",
|
|
183
|
-
files: [
|
|
208
|
+
files: [
|
|
209
|
+
"vite.config.ts",
|
|
210
|
+
"vite.config.js",
|
|
211
|
+
"vite.config.mts",
|
|
212
|
+
"vite.config.mjs",
|
|
213
|
+
"vite.config.cjs",
|
|
214
|
+
"vite.config.cts"
|
|
215
|
+
],
|
|
184
216
|
label: "Vite"
|
|
185
217
|
},
|
|
186
218
|
{
|
|
@@ -216,86 +248,154 @@ var UNSUPPORTED_META = [
|
|
|
216
248
|
{ name: "Astro", dep: "astro", files: ["astro.config.mjs", "astro.config.ts"] },
|
|
217
249
|
{ name: "SvelteKit", dep: "@sveltejs/kit", files: ["svelte.config.js", "svelte.config.ts"] }
|
|
218
250
|
];
|
|
219
|
-
|
|
251
|
+
function normalizeRelativePath(root, filePath) {
|
|
252
|
+
const relative = path3.relative(root, filePath);
|
|
253
|
+
const normalized = relative.split(path3.sep).join("/");
|
|
254
|
+
return normalized || path3.basename(filePath);
|
|
255
|
+
}
|
|
256
|
+
function createTargets(root, packagePaths) {
|
|
257
|
+
if (!packagePaths || packagePaths.length === 0) {
|
|
258
|
+
return [{ packagePath: "", absolutePath: root }];
|
|
259
|
+
}
|
|
260
|
+
return packagePaths.map((pkg) => ({
|
|
261
|
+
packagePath: pkg,
|
|
262
|
+
absolutePath: pkg ? path3.join(root, pkg) : root
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
async function detectBuildTools(root, packagePaths) {
|
|
220
266
|
const supported = [];
|
|
221
|
-
const unsupported =
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
267
|
+
const unsupported = /* @__PURE__ */ new Set();
|
|
268
|
+
const targets = createTargets(root, packagePaths);
|
|
269
|
+
for (const target of targets) {
|
|
270
|
+
const pkg = await readJSON(path3.join(target.absolutePath, "package.json"));
|
|
271
|
+
const allDeps = { ...pkg?.dependencies, ...pkg?.devDependencies };
|
|
272
|
+
const scripts = pkg?.scripts || {};
|
|
273
|
+
const supportedChecks = SUPPORTED_PATTERNS.map(
|
|
274
|
+
(pattern) => detectPattern({
|
|
275
|
+
pattern,
|
|
276
|
+
workspaceRoot: root,
|
|
277
|
+
targetRoot: target.absolutePath,
|
|
278
|
+
packagePath: target.packagePath,
|
|
279
|
+
allDeps,
|
|
280
|
+
scripts
|
|
281
|
+
})
|
|
282
|
+
);
|
|
283
|
+
const supportedResults = await Promise.all(supportedChecks);
|
|
284
|
+
for (const result of supportedResults) {
|
|
285
|
+
if (result) {
|
|
286
|
+
supported.push(result);
|
|
287
|
+
}
|
|
229
288
|
}
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
289
|
+
const unsupportedChecks = UNSUPPORTED_META.map(async (meta) => {
|
|
290
|
+
if (!(meta.dep in allDeps)) return null;
|
|
291
|
+
for (const file of meta.files) {
|
|
292
|
+
if (await exists(path3.join(target.absolutePath, file))) {
|
|
293
|
+
return meta.name;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
});
|
|
298
|
+
const unsupportedResults = await Promise.all(unsupportedChecks);
|
|
299
|
+
for (const result of unsupportedResults) {
|
|
300
|
+
if (result) {
|
|
301
|
+
unsupported.add(result);
|
|
234
302
|
}
|
|
235
303
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
304
|
+
}
|
|
305
|
+
return { supported, unsupported: Array.from(unsupported) };
|
|
306
|
+
}
|
|
307
|
+
async function detectPattern({
|
|
308
|
+
pattern,
|
|
309
|
+
workspaceRoot,
|
|
310
|
+
targetRoot,
|
|
311
|
+
packagePath,
|
|
312
|
+
allDeps,
|
|
313
|
+
scripts
|
|
314
|
+
}) {
|
|
315
|
+
let hasDep;
|
|
316
|
+
let resolvedVersion = null;
|
|
317
|
+
if (pattern.tool === "rspack") {
|
|
318
|
+
const depName = allDeps["@rspack/cli"] ? "@rspack/cli" : "@rspack/core";
|
|
319
|
+
hasDep = !!allDeps["@rspack/cli"] || !!allDeps["@rspack/core"] || isPackageResolvable("@rspack/core", targetRoot);
|
|
320
|
+
if (hasDep) {
|
|
321
|
+
resolvedVersion = allDeps[depName] || await getResolvedPackageVersion("@rspack/core", targetRoot);
|
|
322
|
+
}
|
|
323
|
+
} else if (pattern.tool === "webpack") {
|
|
324
|
+
const depName = allDeps["webpack"] ? "webpack" : "webpack-cli";
|
|
325
|
+
hasDep = !!allDeps["webpack"] || !!allDeps["webpack-cli"] || isPackageResolvable("webpack", targetRoot);
|
|
326
|
+
if (hasDep) {
|
|
327
|
+
resolvedVersion = allDeps[depName] || await getResolvedPackageVersion("webpack", targetRoot);
|
|
328
|
+
}
|
|
329
|
+
} else if (pattern.tool === "rsbuild") {
|
|
330
|
+
hasDep = !!allDeps["@rsbuild/core"] || isPackageResolvable("@rsbuild/core", targetRoot);
|
|
331
|
+
} else {
|
|
332
|
+
hasDep = !!allDeps[pattern.tool] || isPackageResolvable(pattern.tool, targetRoot);
|
|
333
|
+
}
|
|
334
|
+
let detectedFile = "";
|
|
335
|
+
if (pattern.tool === "esbuild" && !hasDep) {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
for (const file of pattern.files) {
|
|
339
|
+
if (await exists(path3.join(targetRoot, file))) {
|
|
340
|
+
detectedFile = file;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (hasDep && !detectedFile && (pattern.tool === "esbuild" || pattern.tool === "rollup" || pattern.tool === "webpack" || pattern.tool === "rspack" || pattern.tool === "rsbuild")) {
|
|
345
|
+
for (const cmd of Object.values(scripts)) {
|
|
346
|
+
if (cmd.includes("node ")) {
|
|
347
|
+
const match = cmd.match(/node\s+([^\s]+\.(js|mjs|cjs|ts))/);
|
|
348
|
+
if (match && match[1]) {
|
|
349
|
+
if (await exists(path3.join(targetRoot, match[1]))) {
|
|
350
|
+
if (cmd.includes(pattern.tool) || match[1].includes(pattern.tool)) {
|
|
243
351
|
detectedFile = match[1];
|
|
244
352
|
break;
|
|
245
353
|
}
|
|
246
354
|
}
|
|
247
|
-
} else if (cmd.includes(`${pattern.tool} `)) {
|
|
248
|
-
detectedFile = "package.json (scripts)";
|
|
249
|
-
break;
|
|
250
355
|
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
356
|
+
} else if (cmd.includes(`${pattern.tool} `)) {
|
|
357
|
+
if (pattern.tool === "webpack" || pattern.tool === "rspack") {
|
|
358
|
+
const configMatch = cmd.match(/--config\s+([^\s]+)/);
|
|
359
|
+
if (configMatch && configMatch[1]) {
|
|
360
|
+
if (await exists(path3.join(targetRoot, configMatch[1]))) {
|
|
361
|
+
detectedFile = configMatch[1];
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
260
365
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
isLegacyWebpack = true;
|
|
366
|
+
if (!detectedFile) {
|
|
367
|
+
detectedFile = "package.json (scripts)";
|
|
368
|
+
break;
|
|
265
369
|
}
|
|
266
370
|
}
|
|
267
|
-
return {
|
|
268
|
-
tool: pattern.tool,
|
|
269
|
-
configPath: detectedFile,
|
|
270
|
-
label: `${pattern.label} (${detectedFile})${isLegacyRspack ? " [Legacy]" : ""}${isLegacyWebpack ? " [Webpack 4]" : ""}`,
|
|
271
|
-
isLegacyRspack,
|
|
272
|
-
isLegacyWebpack
|
|
273
|
-
};
|
|
274
371
|
}
|
|
372
|
+
}
|
|
373
|
+
if (!detectedFile) {
|
|
275
374
|
return null;
|
|
276
|
-
});
|
|
277
|
-
const supportedResults = await Promise.all(supportedChecks);
|
|
278
|
-
for (const result of supportedResults) {
|
|
279
|
-
if (result) {
|
|
280
|
-
supported.push(result);
|
|
281
|
-
}
|
|
282
375
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
376
|
+
let isLegacyRspack = false;
|
|
377
|
+
let isLegacyWebpack = false;
|
|
378
|
+
if (pattern.tool === "rspack") {
|
|
379
|
+
const version = resolvedVersion;
|
|
380
|
+
if (version && (version.includes("0.3.") || version.includes("0.2.") || version.includes("0.1."))) {
|
|
381
|
+
isLegacyRspack = true;
|
|
289
382
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (result) {
|
|
295
|
-
unsupported.push(result);
|
|
383
|
+
} else if (pattern.tool === "webpack") {
|
|
384
|
+
const version = resolvedVersion;
|
|
385
|
+
if (version && version.includes("^4") || version?.startsWith("4.")) {
|
|
386
|
+
isLegacyWebpack = true;
|
|
296
387
|
}
|
|
297
388
|
}
|
|
298
|
-
|
|
389
|
+
const absoluteConfig = path3.join(targetRoot, detectedFile);
|
|
390
|
+
const relativeConfig = normalizeRelativePath(workspaceRoot, absoluteConfig);
|
|
391
|
+
return {
|
|
392
|
+
tool: pattern.tool,
|
|
393
|
+
configPath: relativeConfig,
|
|
394
|
+
label: `${pattern.label} (${relativeConfig})${isLegacyRspack ? " [Legacy]" : ""}${isLegacyWebpack ? " [Webpack 4]" : ""}`,
|
|
395
|
+
isLegacyRspack,
|
|
396
|
+
isLegacyWebpack,
|
|
397
|
+
packagePath: packagePath || void 0
|
|
398
|
+
};
|
|
299
399
|
}
|
|
300
400
|
function resolveInjectionTarget(detections) {
|
|
301
401
|
if (detections.length === 0) return null;
|
|
@@ -305,6 +405,18 @@ function resolveInjectionTarget(detections) {
|
|
|
305
405
|
|
|
306
406
|
// src/detect/framework.ts
|
|
307
407
|
import path4 from "path";
|
|
408
|
+
import { createRequire as createRequire2 } from "module";
|
|
409
|
+
var META_FRAMEWORK_MAP = {
|
|
410
|
+
next: "react",
|
|
411
|
+
nuxt: "vue",
|
|
412
|
+
"@remix-run/react": "react",
|
|
413
|
+
"@remix-run/dev": "react",
|
|
414
|
+
"@vue/nuxt": "vue",
|
|
415
|
+
"vite-plugin-vue": "vue",
|
|
416
|
+
"@vitejs/plugin-vue": "vue",
|
|
417
|
+
"@vitejs/plugin-react": "react",
|
|
418
|
+
"@vitejs/plugin-react-swc": "react"
|
|
419
|
+
};
|
|
308
420
|
var SUPPORTED_FRAMEWORKS = [
|
|
309
421
|
{ framework: "react", deps: ["react", "react-dom"] },
|
|
310
422
|
{ framework: "vue", deps: ["vue"] }
|
|
@@ -316,26 +428,53 @@ var UNSUPPORTED_FRAMEWORKS = [
|
|
|
316
428
|
{ name: "Preact", dep: "preact" },
|
|
317
429
|
{ name: "Lit", dep: "lit" }
|
|
318
430
|
];
|
|
431
|
+
function isPackageResolvable2(pkgName, root) {
|
|
432
|
+
try {
|
|
433
|
+
const require2 = createRequire2(path4.join(root, "package.json"));
|
|
434
|
+
try {
|
|
435
|
+
require2.resolve(`${pkgName}/package.json`, { paths: [root] });
|
|
436
|
+
return true;
|
|
437
|
+
} catch {
|
|
438
|
+
require2.resolve(pkgName, { paths: [root] });
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
} catch {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
319
445
|
async function detectFrameworks(root) {
|
|
320
446
|
const pkg = await readJSON(path4.join(root, "package.json"));
|
|
321
|
-
if (!pkg) return { supported: [], unsupported: [] };
|
|
322
447
|
const allDeps = {
|
|
323
|
-
...pkg
|
|
324
|
-
...pkg
|
|
448
|
+
...pkg?.dependencies || {},
|
|
449
|
+
...pkg?.devDependencies || {},
|
|
450
|
+
...pkg?.peerDependencies || {}
|
|
325
451
|
};
|
|
326
|
-
const
|
|
452
|
+
const supportedSet = /* @__PURE__ */ new Set();
|
|
453
|
+
const unsupported = [];
|
|
454
|
+
const isTest = root.includes("/mock/root");
|
|
455
|
+
for (const [metaPkg, framework] of Object.entries(META_FRAMEWORK_MAP)) {
|
|
456
|
+
if (metaPkg in allDeps || !isTest && isPackageResolvable2(metaPkg, root)) {
|
|
457
|
+
supportedSet.add(framework);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
327
460
|
for (const { framework, deps } of SUPPORTED_FRAMEWORKS) {
|
|
328
|
-
if (
|
|
329
|
-
|
|
461
|
+
if (supportedSet.has(framework)) continue;
|
|
462
|
+
for (const dep of deps) {
|
|
463
|
+
if (dep in allDeps || !isTest && isPackageResolvable2(dep, root)) {
|
|
464
|
+
supportedSet.add(framework);
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
330
467
|
}
|
|
331
468
|
}
|
|
332
|
-
const unsupported = [];
|
|
333
469
|
for (const fw of UNSUPPORTED_FRAMEWORKS) {
|
|
334
|
-
if (fw.dep in allDeps) {
|
|
470
|
+
if (fw.dep in allDeps || !isTest && isPackageResolvable2(fw.dep, root)) {
|
|
335
471
|
unsupported.push(fw);
|
|
336
472
|
}
|
|
337
473
|
}
|
|
338
|
-
return {
|
|
474
|
+
return {
|
|
475
|
+
supported: Array.from(supportedSet),
|
|
476
|
+
unsupported
|
|
477
|
+
};
|
|
339
478
|
}
|
|
340
479
|
|
|
341
480
|
// src/detect/ide.ts
|
|
@@ -799,8 +938,12 @@ async function findVSCodeBinary() {
|
|
|
799
938
|
async function tryOpenURI(uri) {
|
|
800
939
|
try {
|
|
801
940
|
const platform = process.platform;
|
|
802
|
-
|
|
803
|
-
|
|
941
|
+
if (platform === "win32") {
|
|
942
|
+
await shell(`cmd /c start "" "${uri}"`);
|
|
943
|
+
} else {
|
|
944
|
+
const openCmd = platform === "darwin" ? "open" : "xdg-open";
|
|
945
|
+
await shell(`${openCmd} "${uri}"`);
|
|
946
|
+
}
|
|
804
947
|
return true;
|
|
805
948
|
} catch {
|
|
806
949
|
return false;
|
|
@@ -1013,6 +1156,25 @@ function printNextJsManualInstructions() {
|
|
|
1013
1156
|
async function init(options) {
|
|
1014
1157
|
const root = process.cwd();
|
|
1015
1158
|
const mutations = [];
|
|
1159
|
+
const normalizedPackages = normalizePackageList(options.packages);
|
|
1160
|
+
const verifiedPackages = [];
|
|
1161
|
+
for (const pkg of normalizedPackages) {
|
|
1162
|
+
if (!pkg) {
|
|
1163
|
+
verifiedPackages.push(pkg);
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
const absolutePath = path9.join(root, pkg);
|
|
1167
|
+
if (await exists(absolutePath)) {
|
|
1168
|
+
verifiedPackages.push(pkg);
|
|
1169
|
+
} else {
|
|
1170
|
+
log.warn(`Package path "${pkg}" not found (skipping)`);
|
|
1171
|
+
log.hint("Ensure --packages values are relative to the project root");
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
if (normalizedPackages.length > 0 && verifiedPackages.length === 0) {
|
|
1175
|
+
log.error("No valid packages found from --packages input");
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1016
1178
|
log.header("Inspecto Setup");
|
|
1017
1179
|
if (!await exists(path9.join(root, "package.json"))) {
|
|
1018
1180
|
log.error("No package.json found in current directory");
|
|
@@ -1022,7 +1184,7 @@ async function init(options) {
|
|
|
1022
1184
|
const [pm, frameworkResult, buildResult, ideProbe, providerProbe] = await Promise.all([
|
|
1023
1185
|
detectPackageManager(root),
|
|
1024
1186
|
detectFrameworks(root),
|
|
1025
|
-
detectBuildTools(root),
|
|
1187
|
+
detectBuildTools(root, verifiedPackages.length > 0 ? verifiedPackages : void 0),
|
|
1026
1188
|
detectIDE(root),
|
|
1027
1189
|
detectProviders(root)
|
|
1028
1190
|
]);
|
|
@@ -1030,10 +1192,10 @@ async function init(options) {
|
|
|
1030
1192
|
if (frameworkResult.supported.length > 0) {
|
|
1031
1193
|
log.success(`Detected framework: ${frameworkResult.supported.join(", ")}`);
|
|
1032
1194
|
}
|
|
1033
|
-
const
|
|
1034
|
-
const
|
|
1035
|
-
if (
|
|
1036
|
-
if (
|
|
1195
|
+
const isSupported = frameworkResult.supported.length > 0;
|
|
1196
|
+
const hasUnsupported = frameworkResult.unsupported.length > 0;
|
|
1197
|
+
if (!isSupported) {
|
|
1198
|
+
if (hasUnsupported) {
|
|
1037
1199
|
const names = frameworkResult.unsupported.map((f) => f.name).join(", ");
|
|
1038
1200
|
log.warn(`Detected ${names} \u2014 not supported in v1 (React / Vue only)`);
|
|
1039
1201
|
} else {
|
|
@@ -1049,8 +1211,17 @@ async function init(options) {
|
|
|
1049
1211
|
} else {
|
|
1050
1212
|
log.warn("Continuing anyway (--force)");
|
|
1051
1213
|
}
|
|
1214
|
+
} else if (hasUnsupported) {
|
|
1215
|
+
const names = frameworkResult.unsupported.map((f) => f.name).join(", ");
|
|
1216
|
+
log.hint(
|
|
1217
|
+
`Note: Inspecto will be configured for ${frameworkResult.supported.join(", ")}. Other detected frameworks (${names}) will be ignored.`
|
|
1218
|
+
);
|
|
1052
1219
|
}
|
|
1053
1220
|
let manualConfigRequiredFor = "";
|
|
1221
|
+
if (verifiedPackages.length > 0 && buildResult.supported.length === 0) {
|
|
1222
|
+
log.warn(`No supported build configs detected for: ${verifiedPackages.map((pkg) => pkg ? pkg : ".").join(", ")}`);
|
|
1223
|
+
log.hint("Double-check the --packages values or run without the flag to scan the repo root");
|
|
1224
|
+
}
|
|
1054
1225
|
if (buildResult.supported.length > 0) {
|
|
1055
1226
|
buildResult.supported.forEach((bt) => log.success(`Detected: ${bt.label}`));
|
|
1056
1227
|
}
|
|
@@ -1065,7 +1236,7 @@ async function init(options) {
|
|
|
1065
1236
|
log.hint("current version supports: Vite, Webpack, Rspack, esbuild, Rollup");
|
|
1066
1237
|
log.hint("Dependency will be installed but plugin injection will be skipped");
|
|
1067
1238
|
log.hint(
|
|
1068
|
-
"Please refer to the manual setup guide: https://inspecto.
|
|
1239
|
+
"Please refer to the manual setup guide: https://inspecto-dev.github.io/inspecto/guide/manual-installation"
|
|
1069
1240
|
);
|
|
1070
1241
|
}
|
|
1071
1242
|
let selectedIDE = null;
|
|
@@ -1130,20 +1301,46 @@ async function init(options) {
|
|
|
1130
1301
|
}
|
|
1131
1302
|
let injectionFailed = false;
|
|
1132
1303
|
if (buildResult.supported.length > 0) {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1304
|
+
if (verifiedPackages.length > 0) {
|
|
1305
|
+
const targets = buildResult.supported.filter(
|
|
1306
|
+
(detection) => matchesAnyPackage(detection, verifiedPackages)
|
|
1307
|
+
);
|
|
1308
|
+
const unmatchedPackages = verifiedPackages.filter(
|
|
1309
|
+
(pkg) => !buildResult.supported.some((detection) => matchesPackage(detection, pkg))
|
|
1310
|
+
);
|
|
1311
|
+
if (unmatchedPackages.length > 0) {
|
|
1312
|
+
log.warn(
|
|
1313
|
+
`No supported build configs detected for: ${unmatchedPackages.map((pkg) => pkg ? pkg : ".").join(", ")}`
|
|
1314
|
+
);
|
|
1315
|
+
log.hint("Check the package paths or run without --packages to inspect the repo root");
|
|
1316
|
+
}
|
|
1317
|
+
if (targets.length === 0) {
|
|
1142
1318
|
injectionFailed = true;
|
|
1143
1319
|
}
|
|
1320
|
+
for (const target of targets) {
|
|
1321
|
+
const result = await injectPlugin(root, target, options.dryRun);
|
|
1322
|
+
if (result.success) {
|
|
1323
|
+
mutations.push(...result.mutations);
|
|
1324
|
+
} else {
|
|
1325
|
+
injectionFailed = true;
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1144
1328
|
} else {
|
|
1145
|
-
|
|
1146
|
-
|
|
1329
|
+
let target = resolveInjectionTarget(buildResult.supported);
|
|
1330
|
+
if (target === "ambiguous") {
|
|
1331
|
+
target = await promptConfigChoice(buildResult.supported);
|
|
1332
|
+
}
|
|
1333
|
+
if (target) {
|
|
1334
|
+
const result = await injectPlugin(root, target, options.dryRun);
|
|
1335
|
+
if (result.success) {
|
|
1336
|
+
mutations.push(...result.mutations);
|
|
1337
|
+
} else {
|
|
1338
|
+
injectionFailed = true;
|
|
1339
|
+
}
|
|
1340
|
+
} else {
|
|
1341
|
+
injectionFailed = true;
|
|
1342
|
+
log.warn("Skipping plugin injection (manual configuration required)");
|
|
1343
|
+
}
|
|
1147
1344
|
}
|
|
1148
1345
|
}
|
|
1149
1346
|
const settingsDir = path9.join(root, ".inspecto");
|
|
@@ -1251,6 +1448,27 @@ async function init(options) {
|
|
|
1251
1448
|
log.ready("Ready! Hold Alt + Click any element to inspect.");
|
|
1252
1449
|
}
|
|
1253
1450
|
}
|
|
1451
|
+
function normalizePackageList(packages) {
|
|
1452
|
+
if (!packages || packages.length === 0) return [];
|
|
1453
|
+
const normalized = packages.map((pkg) => {
|
|
1454
|
+
const trimmed = pkg.trim();
|
|
1455
|
+
if (trimmed === "") return null;
|
|
1456
|
+
if (trimmed === "." || trimmed === "./") return "";
|
|
1457
|
+
return trimmed.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/$/, "");
|
|
1458
|
+
}).filter((value) => value !== null);
|
|
1459
|
+
return Array.from(new Set(normalized));
|
|
1460
|
+
}
|
|
1461
|
+
function matchesPackage(detection, pkg) {
|
|
1462
|
+
const configPath = detection.configPath.replace(/\\/g, "/");
|
|
1463
|
+
if (!pkg) {
|
|
1464
|
+
return !configPath.includes("/");
|
|
1465
|
+
}
|
|
1466
|
+
return configPath === pkg || configPath.startsWith(`${pkg}/`);
|
|
1467
|
+
}
|
|
1468
|
+
function matchesAnyPackage(detection, packages) {
|
|
1469
|
+
if (packages.length === 0) return true;
|
|
1470
|
+
return packages.some((pkg) => matchesPackage(detection, pkg));
|
|
1471
|
+
}
|
|
1254
1472
|
|
|
1255
1473
|
// src/commands/doctor.ts
|
|
1256
1474
|
import path10 from "path";
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inspecto-dev/cli",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.4",
|
|
4
4
|
"description": "CLI tools for Inspecto onboarding and lifecycle management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"inspecto",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"magicast": "^0.5.2",
|
|
20
20
|
"picocolors": "^1.0.0",
|
|
21
21
|
"prompts": "^2.4.2",
|
|
22
|
-
"@inspecto-dev/types": "0.2.0-alpha.
|
|
22
|
+
"@inspecto-dev/types": "0.2.0-alpha.4"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^20.0.0",
|