@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/src/inject/extension.ts
CHANGED
|
@@ -54,9 +54,12 @@ async function findVSCodeBinary(): Promise<string | null> {
|
|
|
54
54
|
async function tryOpenURI(uri: string): Promise<boolean> {
|
|
55
55
|
try {
|
|
56
56
|
const platform = process.platform
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (platform === 'win32') {
|
|
58
|
+
await shell(`cmd /c start "" "${uri}"`)
|
|
59
|
+
} else {
|
|
60
|
+
const openCmd = platform === 'darwin' ? 'open' : 'xdg-open'
|
|
61
|
+
await shell(`${openCmd} "${uri}"`)
|
|
62
|
+
}
|
|
60
63
|
return true
|
|
61
64
|
} catch {
|
|
62
65
|
return false
|
package/src/types.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface BuildToolDetection {
|
|
|
18
18
|
isLegacyRspack?: boolean
|
|
19
19
|
/** Whether this is Webpack 4.x */
|
|
20
20
|
isLegacyWebpack?: boolean
|
|
21
|
+
/** Relative package path when using --packages */
|
|
22
|
+
packagePath?: string
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/** Options passed to `inspecto init` */
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
2
|
+
import { detectBuildTools } from '../src/detect/build-tool.js'
|
|
3
|
+
import * as fsUtils from '../src/utils/fs.js'
|
|
4
|
+
|
|
5
|
+
vi.mock('../src/utils/fs.js', () => ({
|
|
6
|
+
exists: vi.fn(),
|
|
7
|
+
readJSON: vi.fn(),
|
|
8
|
+
}))
|
|
9
|
+
|
|
10
|
+
describe('detectBuildTools', () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
vi.resetAllMocks()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('detects Vite config inside a specified package path', async () => {
|
|
16
|
+
vi.mocked(fsUtils.readJSON).mockImplementation(async filePath => {
|
|
17
|
+
if (filePath.includes('packages/app/package.json')) {
|
|
18
|
+
return { devDependencies: { vite: '^5.0.0' } }
|
|
19
|
+
}
|
|
20
|
+
if (filePath.endsWith('/package.json')) {
|
|
21
|
+
return {}
|
|
22
|
+
}
|
|
23
|
+
return null
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
vi.mocked(fsUtils.exists).mockImplementation(async filePath =>
|
|
27
|
+
filePath.includes('packages/app/vite.config.ts'),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
const result = await detectBuildTools('/repo', ['packages/app'])
|
|
31
|
+
expect(result.supported).toHaveLength(1)
|
|
32
|
+
expect(result.supported[0]?.configPath).toBe('packages/app/vite.config.ts')
|
|
33
|
+
expect(result.supported[0]?.packagePath).toBe('packages/app')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('detects vite.config.cjs at the repo root', async () => {
|
|
37
|
+
vi.mocked(fsUtils.readJSON).mockResolvedValue({ devDependencies: { vite: '^5.0.0' } })
|
|
38
|
+
vi.mocked(fsUtils.exists).mockImplementation(async filePath =>
|
|
39
|
+
filePath.endsWith('vite.config.cjs'),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
const result = await detectBuildTools('/repo')
|
|
43
|
+
expect(result.supported).toHaveLength(1)
|
|
44
|
+
expect(result.supported[0]?.configPath).toBe('vite.config.cjs')
|
|
45
|
+
})
|
|
46
|
+
})
|