@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.
Files changed (49) hide show
  1. package/.turbo/turbo-build.log +19 -20
  2. package/CHANGELOG.md +22 -0
  3. package/README.md +93 -11
  4. package/bin/inspecto.js +5 -1
  5. package/dist/bin.d.ts +5 -1
  6. package/dist/bin.js +530 -49
  7. package/dist/chunk-FZS2TLXQ.js +3140 -0
  8. package/dist/index.d.ts +233 -2
  9. package/dist/index.js +17 -3
  10. package/package.json +3 -2
  11. package/src/bin.ts +286 -66
  12. package/src/commands/apply.ts +118 -0
  13. package/src/commands/detect.ts +59 -0
  14. package/src/commands/doctor.ts +225 -72
  15. package/src/commands/init.ts +143 -183
  16. package/src/commands/integration-install.ts +452 -0
  17. package/src/commands/onboard.ts +50 -0
  18. package/src/commands/plan.ts +41 -0
  19. package/src/detect/build-tool.ts +107 -3
  20. package/src/index.ts +17 -2
  21. package/src/inject/ast-injector.ts +17 -6
  22. package/src/inject/extension.ts +40 -22
  23. package/src/inject/gitignore.ts +10 -3
  24. package/src/instructions.ts +60 -46
  25. package/src/onboarding/apply.ts +364 -0
  26. package/src/onboarding/context.ts +36 -0
  27. package/src/onboarding/planner.ts +284 -0
  28. package/src/onboarding/session.ts +434 -0
  29. package/src/onboarding/target-resolution.ts +116 -0
  30. package/src/prompts.ts +54 -11
  31. package/src/types.ts +184 -0
  32. package/src/utils/fs.ts +2 -1
  33. package/src/utils/logger.ts +9 -0
  34. package/src/utils/output.ts +40 -0
  35. package/tests/apply.test.ts +583 -0
  36. package/tests/ast-injector.test.ts +50 -0
  37. package/tests/build-tool.test.ts +3 -5
  38. package/tests/detect.test.ts +94 -0
  39. package/tests/doctor.test.ts +224 -0
  40. package/tests/init.test.ts +364 -0
  41. package/tests/install-wrapper.test.ts +76 -0
  42. package/tests/instructions.test.ts +61 -0
  43. package/tests/integration-install.test.ts +294 -0
  44. package/tests/logger.test.ts +100 -0
  45. package/tests/onboard.test.ts +258 -0
  46. package/tests/plan.test.ts +713 -0
  47. package/tests/workspace-build-tool.test.ts +75 -0
  48. package/.turbo/turbo-test.log +0 -16
  49. 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
+ })
@@ -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
-