@foundrykit/cli 2.0.11 → 3.0.0

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.
@@ -1,127 +0,0 @@
1
- import { Command } from 'commander';
2
- import chalk from 'chalk';
3
- import fs from 'fs-extra';
4
- import path from 'path';
5
- import { DEFAULT_REGISTRY_URL } from '../lib/constants.js';
6
- import { loadConfig } from './add.js';
7
-
8
- interface CheckResult {
9
- label: string;
10
- ok: boolean;
11
- detail: string;
12
- }
13
-
14
- export function doctorCommand() {
15
- return new Command('doctor')
16
- .description('Check project health and configuration')
17
- .action(async () => {
18
- console.log(chalk.blue('šŸ” Checking project health...'));
19
-
20
- const results: CheckResult[] = [];
21
-
22
- const packageJsonPath = path.join(process.cwd(), 'package.json');
23
- const hasPackageJson = await fs.pathExists(packageJsonPath);
24
- results.push({
25
- label: 'package.json',
26
- ok: hasPackageJson,
27
- detail: hasPackageJson
28
- ? 'Project manifest found'
29
- : 'Run this command in a project root',
30
- });
31
-
32
- let packageJson: Record<string, any> | null = null;
33
- if (hasPackageJson) {
34
- packageJson = await fs.readJson(packageJsonPath);
35
- }
36
-
37
- const hasNext =
38
- !!packageJson &&
39
- !!(packageJson.dependencies?.next || packageJson.devDependencies?.next);
40
- results.push({
41
- label: 'Framework',
42
- ok: hasNext,
43
- detail: hasNext
44
- ? 'Next.js dependency detected'
45
- : 'FoundryKit currently expects a Next.js project',
46
- });
47
-
48
- const configPath = path.join(process.cwd(), 'foundrykit.config.json');
49
- const hasConfig = await fs.pathExists(configPath);
50
- results.push({
51
- label: 'FoundryKit config',
52
- ok: hasConfig,
53
- detail: hasConfig
54
- ? 'foundrykit.config.json found'
55
- : 'Run "foundrykit init" to create the configuration file',
56
- });
57
-
58
- let config:
59
- | Awaited<ReturnType<typeof loadConfig>>
60
- | null = null;
61
- if (hasConfig) {
62
- try {
63
- config = await loadConfig();
64
- const hasRequiredPaths =
65
- !!config.paths?.utils &&
66
- !!config.paths?.primitives &&
67
- !!config.paths?.components &&
68
- !!config.paths?.blocks &&
69
- !!config.paths?.animations;
70
-
71
- results.push({
72
- label: 'Config shape',
73
- ok: hasRequiredPaths,
74
- detail: hasRequiredPaths
75
- ? 'Required install paths are configured'
76
- : 'Configuration is missing one or more required install paths',
77
- });
78
-
79
- const registryUrl = config.registry || DEFAULT_REGISTRY_URL;
80
- try {
81
- const response = await fetch(`${registryUrl}/registry`, {
82
- headers: { Accept: 'application/json' },
83
- });
84
-
85
- results.push({
86
- label: 'Registry',
87
- ok: response.ok,
88
- detail: response.ok
89
- ? `Registry reachable at ${registryUrl}`
90
- : `Registry returned ${response.status} ${response.statusText}`,
91
- });
92
- } catch (error) {
93
- results.push({
94
- label: 'Registry',
95
- ok: false,
96
- detail: `Unable to reach ${registryUrl}: ${
97
- error instanceof Error ? error.message : 'Unknown error'
98
- }`,
99
- });
100
- }
101
- } catch (error) {
102
- results.push({
103
- label: 'Config shape',
104
- ok: false,
105
- detail: `Failed to read foundrykit.config.json: ${
106
- error instanceof Error ? error.message : 'Unknown error'
107
- }`,
108
- });
109
- }
110
- }
111
-
112
- for (const result of results) {
113
- const icon = result.ok ? chalk.green('āœ…') : chalk.red('āŒ');
114
- console.log(`${icon} ${result.label}: ${result.detail}`);
115
- }
116
-
117
- const hasFailures = results.some(result => !result.ok);
118
- if (hasFailures) {
119
- console.log(
120
- chalk.yellow('\nāš ļø Found issues that should be resolved before continuing.')
121
- );
122
- process.exit(1);
123
- }
124
-
125
- console.log(chalk.green('\nāœ… All checks passed!'));
126
- });
127
- }