@inspecto-dev/cli 0.2.0-alpha.5 → 0.3.0-alpha.1
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 +19 -20
- package/CHANGELOG.md +22 -0
- package/README.md +93 -11
- package/bin/inspecto.js +5 -1
- package/dist/bin.d.ts +5 -1
- package/dist/bin.js +530 -49
- package/dist/chunk-FZS2TLXQ.js +3140 -0
- package/dist/index.d.ts +233 -2
- package/dist/index.js +17 -3
- package/package.json +3 -2
- package/src/bin.ts +286 -66
- package/src/commands/apply.ts +118 -0
- package/src/commands/detect.ts +59 -0
- package/src/commands/doctor.ts +225 -72
- package/src/commands/init.ts +143 -183
- package/src/commands/integration-install.ts +452 -0
- package/src/commands/onboard.ts +50 -0
- package/src/commands/plan.ts +41 -0
- package/src/detect/build-tool.ts +107 -3
- package/src/index.ts +17 -2
- package/src/inject/ast-injector.ts +17 -6
- package/src/inject/extension.ts +40 -22
- package/src/inject/gitignore.ts +10 -3
- package/src/instructions.ts +60 -46
- package/src/onboarding/apply.ts +364 -0
- package/src/onboarding/context.ts +36 -0
- package/src/onboarding/planner.ts +284 -0
- package/src/onboarding/session.ts +434 -0
- package/src/onboarding/target-resolution.ts +116 -0
- package/src/prompts.ts +54 -11
- package/src/types.ts +184 -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 +583 -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 +364 -0
- package/tests/install-wrapper.test.ts +76 -0
- package/tests/instructions.test.ts +61 -0
- package/tests/integration-install.test.ts +294 -0
- package/tests/logger.test.ts +100 -0
- package/tests/onboard.test.ts +258 -0
- package/tests/plan.test.ts +713 -0
- package/tests/workspace-build-tool.test.ts +75 -0
- package/.turbo/turbo-test.log +0 -16
- package/dist/chunk-MIHQGC3L.js +0 -1720
|
@@ -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
|
+
})
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @inspecto-dev/cli@0.2.0-alpha.4 test /Users/bytedance/Works/hugo.felix/inspecto/packages/cli
|
|
3
|
-
> vitest run --passWithNoTests
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
RUN v1.6.1 /Users/bytedance/Works/hugo.felix/inspecto/packages/cli
|
|
7
|
-
|
|
8
|
-
✓ tests/framework.test.ts (5 tests) 4ms
|
|
9
|
-
✓ tests/build-tool.test.ts (2 tests) 9ms
|
|
10
|
-
✓ tests/ide.test.ts (6 tests) 8ms
|
|
11
|
-
|
|
12
|
-
Test Files 3 passed (3)
|
|
13
|
-
Tests 13 passed (13)
|
|
14
|
-
Start at 15:41:01
|
|
15
|
-
Duration 771ms (transform 133ms, setup 1ms, collect 221ms, tests 21ms, environment 0ms, prepare 367ms)
|
|
16
|
-
|