@inspecto-dev/cli 0.2.0-alpha.4 → 0.2.0-alpha.6
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 +8 -8
- package/.turbo/turbo-test.log +16 -21
- package/CHANGELOG.md +12 -0
- package/README.md +58 -11
- package/bin/inspecto.js +5 -1
- package/dist/bin.d.ts +5 -1
- package/dist/bin.js +89 -50
- package/dist/{chunk-EUCQCD3Y.js → chunk-PDDFPQJS.js} +1954 -1053
- package/dist/index.d.ts +128 -2
- package/dist/index.js +15 -3
- package/package.json +2 -1
- package/src/bin.ts +139 -67
- package/src/commands/apply.ts +114 -0
- package/src/commands/detect.ts +59 -0
- package/src/commands/doctor.ts +225 -72
- package/src/commands/init.ts +106 -183
- package/src/commands/plan.ts +41 -0
- package/src/detect/build-tool.ts +107 -3
- package/src/index.ts +13 -2
- package/src/inject/ast-injector.ts +20 -9
- package/src/inject/extension.ts +3 -1
- package/src/inject/strategies/vite.ts +2 -1
- package/src/instructions.ts +60 -46
- package/src/onboarding/apply.ts +325 -0
- package/src/onboarding/context.ts +36 -0
- package/src/onboarding/planner.ts +278 -0
- package/src/prompts.ts +54 -11
- package/src/types.ts +95 -0
- package/src/utils/fs.ts +2 -1
- package/src/utils/logger.ts +9 -0
- package/src/utils/output.ts +40 -0
- package/tests/apply.test.ts +537 -0
- package/tests/ast-injector.test.ts +50 -0
- package/tests/build-tool.test.ts +3 -5
- package/tests/detect.test.ts +94 -0
- package/tests/doctor.test.ts +224 -0
- package/tests/init.test.ts +333 -0
- package/tests/instructions.test.ts +61 -0
- package/tests/logger.test.ts +100 -0
- package/tests/plan.test.ts +713 -0
- package/tests/workspace-build-tool.test.ts +75 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from 'node:fs/promises'
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { detectBuildTools } from '../src/detect/build-tool.js'
|
|
4
|
+
import * as fsUtils from '../src/utils/fs.js'
|
|
5
|
+
|
|
6
|
+
vi.mock('node:fs/promises', () => ({
|
|
7
|
+
default: {
|
|
8
|
+
readdir: vi.fn(),
|
|
9
|
+
},
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
vi.mock('../src/utils/fs.js', () => ({
|
|
13
|
+
exists: vi.fn(),
|
|
14
|
+
readJSON: vi.fn(),
|
|
15
|
+
readFile: vi.fn(),
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
describe('detectBuildTools in monorepo roots', () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.resetAllMocks()
|
|
21
|
+
vi.mocked(fs.readdir).mockResolvedValue([
|
|
22
|
+
{ name: 'web', isDirectory: () => true },
|
|
23
|
+
{ name: 'docs', isDirectory: () => true },
|
|
24
|
+
] as any)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('detects supported configs inside workspace packages when run from the monorepo root', async () => {
|
|
28
|
+
vi.mocked(fsUtils.readJSON).mockImplementation(async filePath => {
|
|
29
|
+
if (filePath === '/mock/root/package.json') {
|
|
30
|
+
return {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (filePath === '/mock/root/apps/web/package.json') {
|
|
34
|
+
return { devDependencies: { vite: '^5.0.0' } }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (filePath === '/mock/root/apps/docs/package.json') {
|
|
38
|
+
return { dependencies: { next: '^15.0.0' } }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
vi.mocked(fsUtils.readFile).mockImplementation(async filePath => {
|
|
45
|
+
if (filePath === '/mock/root/pnpm-workspace.yaml') {
|
|
46
|
+
return "packages:\n - 'apps/*'\n"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
vi.mocked(fsUtils.exists).mockImplementation(async filePath => {
|
|
53
|
+
return (
|
|
54
|
+
filePath === '/mock/root/apps' ||
|
|
55
|
+
filePath === '/mock/root/apps/web' ||
|
|
56
|
+
filePath === '/mock/root/apps/docs' ||
|
|
57
|
+
filePath === '/mock/root/apps/web/package.json' ||
|
|
58
|
+
filePath === '/mock/root/apps/docs/package.json' ||
|
|
59
|
+
filePath === '/mock/root/apps/web/vite.config.ts' ||
|
|
60
|
+
filePath === '/mock/root/apps/docs/next.config.ts'
|
|
61
|
+
)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const result = await detectBuildTools('/mock/root')
|
|
65
|
+
|
|
66
|
+
expect(result.supported).toContainEqual(
|
|
67
|
+
expect.objectContaining({
|
|
68
|
+
tool: 'vite',
|
|
69
|
+
configPath: 'apps/web/vite.config.ts',
|
|
70
|
+
packagePath: 'apps/web',
|
|
71
|
+
}),
|
|
72
|
+
)
|
|
73
|
+
expect(result.unsupported).toContain('Next.js')
|
|
74
|
+
})
|
|
75
|
+
})
|