uilint 0.2.22 → 0.2.26
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/dist/chunk-P4I4RKBY.js +126 -0
- package/dist/chunk-P4I4RKBY.js.map +1 -0
- package/dist/{chunk-PBEKMDUH.js → chunk-TWUDB36F.js} +62 -54
- package/dist/chunk-TWUDB36F.js.map +1 -0
- package/dist/chunk-VNANPKR2.js +1226 -0
- package/dist/chunk-VNANPKR2.js.map +1 -0
- package/dist/index.js +690 -29
- package/dist/index.js.map +1 -1
- package/dist/{install-ui-HTVB5HDB.js → install-ui-CCZ3XJDE.js} +438 -793
- package/dist/install-ui-CCZ3XJDE.js.map +1 -0
- package/dist/{plan-SIXVCXCK.js → plan-5WHKVACB.js} +95 -40
- package/dist/plan-5WHKVACB.js.map +1 -0
- package/package.json +9 -4
- package/dist/chunk-FRNXXIEM.js +0 -197
- package/dist/chunk-FRNXXIEM.js.map +0 -1
- package/dist/chunk-PBEKMDUH.js.map +0 -1
- package/dist/install-ui-HTVB5HDB.js.map +0 -1
- package/dist/plan-SIXVCXCK.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
GENSTYLEGUIDE_COMMAND_MD,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
4
|
+
loadSkill,
|
|
5
|
+
toInstallSpecifier
|
|
6
|
+
} from "./chunk-TWUDB36F.js";
|
|
7
|
+
import {
|
|
8
|
+
detectPackageManager
|
|
9
|
+
} from "./chunk-P4I4RKBY.js";
|
|
7
10
|
|
|
8
11
|
// src/commands/install/plan.ts
|
|
9
12
|
import { join as join2 } from "path";
|
|
10
|
-
import { createRequire as createRequire2 } from "module";
|
|
11
13
|
|
|
12
14
|
// src/utils/rule-loader.ts
|
|
13
15
|
import { readFileSync, existsSync, readdirSync } from "fs";
|
|
@@ -82,21 +84,53 @@ function getUilintEslintDistDir() {
|
|
|
82
84
|
'Could not find uilint-eslint "dist/" directory. This is a bug in uilint installation.'
|
|
83
85
|
);
|
|
84
86
|
}
|
|
87
|
+
var EXPORTED_UTILITIES = [
|
|
88
|
+
"create-rule",
|
|
89
|
+
"cache",
|
|
90
|
+
"styleguide-loader",
|
|
91
|
+
"import-graph",
|
|
92
|
+
"component-parser",
|
|
93
|
+
"export-resolver",
|
|
94
|
+
"coverage-aggregator",
|
|
95
|
+
"dependency-graph",
|
|
96
|
+
"file-categorizer",
|
|
97
|
+
"jsx-coverage-analyzer"
|
|
98
|
+
];
|
|
99
|
+
var EXPORT_RENAMES = {
|
|
100
|
+
"import-graph:clearCache": "clearImportGraphCache"
|
|
101
|
+
};
|
|
102
|
+
function transformImportSpecifier(specifier, utilFile) {
|
|
103
|
+
const trimmed = specifier.trim();
|
|
104
|
+
const aliasMatch = trimmed.match(/^(\w+)\s+as\s+(\w+)$/);
|
|
105
|
+
if (aliasMatch) {
|
|
106
|
+
const [, localName, alias] = aliasMatch;
|
|
107
|
+
const renameKey2 = `${utilFile}:${localName}`;
|
|
108
|
+
const externalName2 = EXPORT_RENAMES[renameKey2];
|
|
109
|
+
if (externalName2) {
|
|
110
|
+
if (alias === externalName2) {
|
|
111
|
+
return externalName2;
|
|
112
|
+
}
|
|
113
|
+
return `${externalName2} as ${alias}`;
|
|
114
|
+
}
|
|
115
|
+
return trimmed;
|
|
116
|
+
}
|
|
117
|
+
const renameKey = `${utilFile}:${trimmed}`;
|
|
118
|
+
const externalName = EXPORT_RENAMES[renameKey];
|
|
119
|
+
if (externalName) {
|
|
120
|
+
return externalName;
|
|
121
|
+
}
|
|
122
|
+
return trimmed;
|
|
123
|
+
}
|
|
85
124
|
function transformRuleContent(content) {
|
|
86
125
|
let transformed = content;
|
|
87
|
-
const utilsFromPackage = [
|
|
88
|
-
"create-rule",
|
|
89
|
-
"cache",
|
|
90
|
-
"styleguide-loader",
|
|
91
|
-
"import-graph",
|
|
92
|
-
"component-parser",
|
|
93
|
-
"export-resolver"
|
|
94
|
-
];
|
|
95
126
|
transformed = transformed.replace(
|
|
96
127
|
/import\s+{([^}]+)}\s+from\s+["']\.\.\/utils\/([^"']+)\.js["'];?/g,
|
|
97
128
|
(match, imports, utilFile) => {
|
|
98
|
-
if (
|
|
99
|
-
|
|
129
|
+
if (EXPORTED_UTILITIES.includes(utilFile)) {
|
|
130
|
+
const specifiers = imports.split(",").map(
|
|
131
|
+
(s) => transformImportSpecifier(s, utilFile)
|
|
132
|
+
);
|
|
133
|
+
return `import { ${specifiers.join(", ")} } from "uilint-eslint";`;
|
|
100
134
|
}
|
|
101
135
|
return match;
|
|
102
136
|
}
|
|
@@ -104,7 +138,7 @@ function transformRuleContent(content) {
|
|
|
104
138
|
transformed = transformed.replace(
|
|
105
139
|
/import\s+(\w+)\s+from\s+["']\.\.\/utils\/([^"']+)\.js["'];?/g,
|
|
106
140
|
(match, importName, utilFile) => {
|
|
107
|
-
if (
|
|
141
|
+
if (EXPORTED_UTILITIES.includes(utilFile)) {
|
|
108
142
|
return `import { ${importName} } from "uilint-eslint";`;
|
|
109
143
|
}
|
|
110
144
|
return match;
|
|
@@ -161,27 +195,6 @@ function loadSelectedRules(ruleIds, options = { typescript: true }) {
|
|
|
161
195
|
}
|
|
162
196
|
|
|
163
197
|
// src/commands/install/plan.ts
|
|
164
|
-
var require3 = createRequire2(import.meta.url);
|
|
165
|
-
function getSelfDependencyVersionRange(pkgName) {
|
|
166
|
-
try {
|
|
167
|
-
const pkgJson = require3("uilint/package.json");
|
|
168
|
-
const deps = pkgJson?.dependencies;
|
|
169
|
-
const optDeps = pkgJson?.optionalDependencies;
|
|
170
|
-
const peerDeps = pkgJson?.peerDependencies;
|
|
171
|
-
const v = deps?.[pkgName] ?? optDeps?.[pkgName] ?? peerDeps?.[pkgName];
|
|
172
|
-
return typeof v === "string" ? v : null;
|
|
173
|
-
} catch {
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
function toInstallSpecifier(pkgName) {
|
|
178
|
-
const range = getSelfDependencyVersionRange(pkgName);
|
|
179
|
-
if (!range) return pkgName;
|
|
180
|
-
if (range.startsWith("workspace:")) return pkgName;
|
|
181
|
-
if (range.startsWith("file:")) return pkgName;
|
|
182
|
-
if (range.startsWith("link:")) return pkgName;
|
|
183
|
-
return `${pkgName}@${range}`;
|
|
184
|
-
}
|
|
185
198
|
function createPlan(state, choices, options = {}) {
|
|
186
199
|
const actions = [];
|
|
187
200
|
const dependencies = [];
|
|
@@ -250,7 +263,19 @@ function createPlan(state, choices, options = {}) {
|
|
|
250
263
|
dependencies.push({
|
|
251
264
|
packagePath: projectPath,
|
|
252
265
|
packageManager: detectPackageManager(projectPath),
|
|
253
|
-
packages: [
|
|
266
|
+
packages: [
|
|
267
|
+
toInstallSpecifier("uilint-react", {
|
|
268
|
+
preferWorkspaceProtocol: state.packageManager === "pnpm",
|
|
269
|
+
workspaceRoot: state.workspaceRoot,
|
|
270
|
+
targetProjectPath: projectPath
|
|
271
|
+
}),
|
|
272
|
+
toInstallSpecifier("uilint-core", {
|
|
273
|
+
preferWorkspaceProtocol: state.packageManager === "pnpm",
|
|
274
|
+
workspaceRoot: state.workspaceRoot,
|
|
275
|
+
targetProjectPath: projectPath
|
|
276
|
+
}),
|
|
277
|
+
"jsx-loc-plugin"
|
|
278
|
+
]
|
|
254
279
|
});
|
|
255
280
|
actions.push({
|
|
256
281
|
type: "inject_react",
|
|
@@ -269,7 +294,19 @@ function createPlan(state, choices, options = {}) {
|
|
|
269
294
|
dependencies.push({
|
|
270
295
|
packagePath: projectPath,
|
|
271
296
|
packageManager: detectPackageManager(projectPath),
|
|
272
|
-
packages: [
|
|
297
|
+
packages: [
|
|
298
|
+
toInstallSpecifier("uilint-react", {
|
|
299
|
+
preferWorkspaceProtocol: state.packageManager === "pnpm",
|
|
300
|
+
workspaceRoot: state.workspaceRoot,
|
|
301
|
+
targetProjectPath: projectPath
|
|
302
|
+
}),
|
|
303
|
+
toInstallSpecifier("uilint-core", {
|
|
304
|
+
preferWorkspaceProtocol: state.packageManager === "pnpm",
|
|
305
|
+
workspaceRoot: state.workspaceRoot,
|
|
306
|
+
targetProjectPath: projectPath
|
|
307
|
+
}),
|
|
308
|
+
"jsx-loc-plugin"
|
|
309
|
+
]
|
|
273
310
|
});
|
|
274
311
|
actions.push({
|
|
275
312
|
type: "inject_react",
|
|
@@ -312,10 +349,28 @@ function createPlan(state, choices, options = {}) {
|
|
|
312
349
|
});
|
|
313
350
|
}
|
|
314
351
|
}
|
|
352
|
+
const packagesToInstall = [
|
|
353
|
+
toInstallSpecifier("uilint-eslint", {
|
|
354
|
+
preferWorkspaceProtocol: state.packageManager === "pnpm",
|
|
355
|
+
workspaceRoot: state.workspaceRoot,
|
|
356
|
+
targetProjectPath: pkgPath
|
|
357
|
+
}),
|
|
358
|
+
"typescript-eslint"
|
|
359
|
+
];
|
|
360
|
+
const hasCoverageRule = selectedRules.some(
|
|
361
|
+
(r) => r.id === "require-test-coverage"
|
|
362
|
+
);
|
|
363
|
+
if (hasCoverageRule) {
|
|
364
|
+
packagesToInstall.push("@vitest/coverage-v8");
|
|
365
|
+
actions.push({
|
|
366
|
+
type: "inject_vitest_coverage",
|
|
367
|
+
projectPath: pkgPath
|
|
368
|
+
});
|
|
369
|
+
}
|
|
315
370
|
dependencies.push({
|
|
316
371
|
packagePath: pkgPath,
|
|
317
372
|
packageManager: detectPackageManager(pkgPath),
|
|
318
|
-
packages:
|
|
373
|
+
packages: packagesToInstall
|
|
319
374
|
});
|
|
320
375
|
if (pkgInfo?.eslintConfigPath) {
|
|
321
376
|
actions.push({
|
|
@@ -345,4 +400,4 @@ export {
|
|
|
345
400
|
createPlan,
|
|
346
401
|
getMissingRules
|
|
347
402
|
};
|
|
348
|
-
//# sourceMappingURL=plan-
|
|
403
|
+
//# sourceMappingURL=plan-5WHKVACB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/install/plan.ts","../src/utils/rule-loader.ts"],"sourcesContent":["/**\n * Plan phase - pure function generating InstallPlan from state + choices\n *\n * This function has NO I/O whatsoever. It takes the analyzed ProjectState,\n * user choices, and options, then returns an InstallPlan describing exactly\n * what actions to take.\n */\n\nimport { join } from \"path\";\nimport type { RuleMetadata } from \"uilint-eslint\";\nimport type {\n ProjectState,\n UserChoices,\n InstallPlan,\n InstallAction,\n DependencyInstall,\n PlanOptions,\n} from \"./types.js\";\nimport { GENSTYLEGUIDE_COMMAND_MD } from \"./constants.js\";\nimport { toInstallSpecifier } from \"./versioning.js\";\nimport { loadSkill } from \"../../utils/skill-loader.js\";\nimport { loadSelectedRules } from \"../../utils/rule-loader.js\";\nimport { detectPackageManager } from \"../../utils/package-manager.js\";\n\n/**\n * Create the install plan from project state and user choices\n *\n * @param state - The analyzed project state\n * @param choices - User's installation choices\n * @param options - Planning options (force, etc.)\n * @returns InstallPlan with all actions and dependencies\n */\nexport function createPlan(\n state: ProjectState,\n choices: UserChoices,\n options: PlanOptions = {}\n): InstallPlan {\n const actions: InstallAction[] = [];\n const dependencies: DependencyInstall[] = [];\n\n const { force = false } = options;\n const { items } = choices;\n\n // Ensure .cursor directory exists if needed\n const needsCursorDir =\n items.includes(\"genstyleguide\") || items.includes(\"skill\");\n\n if (needsCursorDir && !state.cursorDir.exists) {\n actions.push({\n type: \"create_directory\",\n path: state.cursorDir.path,\n });\n }\n\n // =========================================================================\n // Genstyleguide Command\n // =========================================================================\n if (items.includes(\"genstyleguide\")) {\n const commandsDir = join(state.cursorDir.path, \"commands\");\n\n actions.push({\n type: \"create_directory\",\n path: commandsDir,\n });\n\n actions.push({\n type: \"create_file\",\n path: join(commandsDir, \"genstyleguide.md\"),\n content: GENSTYLEGUIDE_COMMAND_MD,\n });\n }\n\n // =========================================================================\n // Agent Skill Installation\n // =========================================================================\n if (items.includes(\"skill\")) {\n const skillsDir = join(state.cursorDir.path, \"skills\");\n\n // Create skills directory\n actions.push({\n type: \"create_directory\",\n path: skillsDir,\n });\n\n // Load and install the ui-consistency-enforcer skill\n try {\n const skill = loadSkill(\"ui-consistency-enforcer\");\n const skillDir = join(skillsDir, skill.name);\n\n // Create skill directory\n actions.push({\n type: \"create_directory\",\n path: skillDir,\n });\n\n // Create all skill files\n for (const file of skill.files) {\n const filePath = join(skillDir, file.relativePath);\n\n // Ensure subdirectories exist (e.g., references/)\n const fileDir = join(\n skillDir,\n file.relativePath.split(\"/\").slice(0, -1).join(\"/\")\n );\n if (fileDir !== skillDir && file.relativePath.includes(\"/\")) {\n actions.push({\n type: \"create_directory\",\n path: fileDir,\n });\n }\n\n actions.push({\n type: \"create_file\",\n path: filePath,\n content: file.content,\n });\n }\n } catch {\n // Skill not found - skip silently (shouldn't happen in normal install)\n }\n }\n\n // =========================================================================\n // Next.js Overlay Installation\n // =========================================================================\n if (items.includes(\"next\") && choices.next) {\n const { projectPath, detection, targetFile, createProviders } =\n choices.next;\n\n // Install Next.js routes\n actions.push({\n type: \"install_next_routes\",\n projectPath,\n appRoot: detection.appRoot,\n });\n\n // Install React overlay dependencies using the package manager for this specific target\n dependencies.push({\n packagePath: projectPath,\n packageManager: detectPackageManager(projectPath),\n packages: [\n toInstallSpecifier(\"uilint-react\", {\n preferWorkspaceProtocol: state.packageManager === \"pnpm\",\n workspaceRoot: state.workspaceRoot,\n targetProjectPath: projectPath,\n }),\n toInstallSpecifier(\"uilint-core\", {\n preferWorkspaceProtocol: state.packageManager === \"pnpm\",\n workspaceRoot: state.workspaceRoot,\n targetProjectPath: projectPath,\n }),\n \"jsx-loc-plugin\",\n ],\n });\n\n // Inject <uilint-devtools /> web component into React\n // Use targetFile or createProviders if specified by the user\n actions.push({\n type: \"inject_react\",\n projectPath,\n appRoot: detection.appRoot,\n targetFile,\n createProviders,\n });\n\n // Inject jsx-loc-plugin into next.config\n actions.push({\n type: \"inject_next_config\",\n projectPath,\n });\n }\n\n // =========================================================================\n // Vite Overlay Installation\n // =========================================================================\n if (items.includes(\"vite\") && choices.vite) {\n const { projectPath, detection } = choices.vite;\n\n // Install React overlay dependencies using the package manager for this specific target\n dependencies.push({\n packagePath: projectPath,\n packageManager: detectPackageManager(projectPath),\n packages: [\n toInstallSpecifier(\"uilint-react\", {\n preferWorkspaceProtocol: state.packageManager === \"pnpm\",\n workspaceRoot: state.workspaceRoot,\n targetProjectPath: projectPath,\n }),\n toInstallSpecifier(\"uilint-core\", {\n preferWorkspaceProtocol: state.packageManager === \"pnpm\",\n workspaceRoot: state.workspaceRoot,\n targetProjectPath: projectPath,\n }),\n \"jsx-loc-plugin\",\n ],\n });\n\n // Inject <uilint-devtools /> web component into React entry\n actions.push({\n type: \"inject_react\",\n projectPath,\n appRoot: detection.entryRoot,\n mode: \"vite\",\n });\n\n // Inject jsx-loc-plugin into vite.config\n actions.push({\n type: \"inject_vite_config\",\n projectPath,\n });\n }\n\n // =========================================================================\n // ESLint Plugin Installation\n // =========================================================================\n if (items.includes(\"eslint\") && choices.eslint) {\n const { packagePaths, selectedRules } = choices.eslint;\n\n for (const pkgPath of packagePaths) {\n const pkgInfo = state.packages.find((p) => p.path === pkgPath);\n\n // Create .uilint/rules directory alongside the target app (not at workspace root)\n const rulesDir = join(pkgPath, \".uilint\", \"rules\");\n actions.push({\n type: \"create_directory\",\n path: rulesDir,\n });\n\n // Load and copy rule files into this target package\n // Use TypeScript rule files if the ESLint config is TypeScript (.ts)\n // This ensures the imports match the actual rule files being copied\n const isTypeScriptConfig =\n pkgInfo?.eslintConfigPath?.endsWith(\".ts\") ?? false;\n const ruleFiles = loadSelectedRules(\n selectedRules.map((r) => r.id),\n {\n typescript: isTypeScriptConfig,\n }\n );\n for (const ruleFile of ruleFiles) {\n // Copy implementation file\n actions.push({\n type: \"create_file\",\n path: join(rulesDir, ruleFile.implementation.relativePath),\n content: ruleFile.implementation.content,\n });\n\n // Copy test file if it exists (only for TypeScript configs)\n if (ruleFile.test && isTypeScriptConfig) {\n actions.push({\n type: \"create_file\",\n path: join(rulesDir, ruleFile.test.relativePath),\n content: ruleFile.test.content,\n });\n }\n }\n\n // Install dependencies using the package manager for this specific target\n const packagesToInstall = [\n toInstallSpecifier(\"uilint-eslint\", {\n preferWorkspaceProtocol: state.packageManager === \"pnpm\",\n workspaceRoot: state.workspaceRoot,\n targetProjectPath: pkgPath,\n }),\n \"typescript-eslint\",\n ];\n\n // If require-test-coverage rule is selected, add coverage package and config\n const hasCoverageRule = selectedRules.some(\n (r) => r.id === \"require-test-coverage\"\n );\n if (hasCoverageRule) {\n packagesToInstall.push(\"@vitest/coverage-v8\");\n\n // Add action to inject coverage config into vitest.config.ts\n actions.push({\n type: \"inject_vitest_coverage\",\n projectPath: pkgPath,\n });\n }\n\n dependencies.push({\n packagePath: pkgPath,\n packageManager: detectPackageManager(pkgPath),\n packages: packagesToInstall,\n });\n\n // Inject ESLint rules (will reference local .uilint/rules/ files)\n if (pkgInfo?.eslintConfigPath) {\n actions.push({\n type: \"inject_eslint\",\n packagePath: pkgPath,\n configPath: pkgInfo.eslintConfigPath,\n rules: selectedRules,\n hasExistingRules: pkgInfo.hasUilintRules,\n });\n }\n }\n\n // Add .uilint/.cache to .gitignore at workspace root\n const gitignorePath = join(state.workspaceRoot, \".gitignore\");\n actions.push({\n type: \"append_to_file\",\n path: gitignorePath,\n content: \"\\n# UILint cache\\n.uilint/.cache\\n\",\n ifNotContains: \".uilint/.cache\",\n });\n }\n\n return { actions, dependencies };\n}\n\n/**\n * Get the list of rules that are missing from a package's ESLint config\n */\nexport function getMissingRules(\n configuredRuleIds: string[],\n selectedRules: RuleMetadata[]\n): RuleMetadata[] {\n const configuredSet = new Set(configuredRuleIds);\n return selectedRules.filter((rule) => !configuredSet.has(rule.id));\n}\n","/**\n * Rule Loader Utility\n *\n * Loads ESLint rule source files from the uilint-eslint package for installation\n * into user projects. Rules are copied to .uilint/rules/ in the target project.\n */\n\nimport { readFileSync, existsSync, readdirSync } from \"fs\";\nimport { join, dirname } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { createRequire } from \"module\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst require = createRequire(import.meta.url);\n\nfunction findNodeModulesPackageRoot(\n pkgName: string,\n startDir: string\n): string | null {\n let dir = startDir;\n while (true) {\n const candidate = join(dir, \"node_modules\", pkgName);\n if (existsSync(join(candidate, \"package.json\"))) return candidate;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\nfunction getUilintEslintPackageRoot(): string {\n // Prefer a filesystem-based lookup first. This avoids Node resolution edge\n // cases with package.json \"exports\" (especially ESM-only packages), and works\n // well for monorepos + pnpm where node_modules contains symlinks.\n //\n // Search upwards from process.cwd() (the user's project) and from this file\n // location (for test/dev environments).\n const fromCwd = findNodeModulesPackageRoot(\"uilint-eslint\", process.cwd());\n if (fromCwd) return fromCwd;\n\n const fromHere = findNodeModulesPackageRoot(\"uilint-eslint\", __dirname);\n if (fromHere) return fromHere;\n\n // Last resort: try resolver-based lookup.\n try {\n const entry = require.resolve(\"uilint-eslint\"); // typically .../dist/index.js\n const entryDir = dirname(entry); // typically .../dist\n return dirname(entryDir); // package root\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n throw new Error(\n `Unable to locate uilint-eslint in node_modules (searched upwards from cwd and uilint's install path).\\n` +\n `Resolver error: ${msg}\\n` +\n `Fix: ensure uilint-eslint is installed in the target project (or workspace) and try again.`\n );\n }\n}\n\n/**\n * Represents a file for a rule (implementation or test)\n */\nexport interface RuleFile {\n /** Relative path within the rules directory (e.g., \"no-arbitrary-tailwind.ts\") */\n relativePath: string;\n /** File content */\n content: string;\n}\n\n/**\n * Represents a complete rule ready for installation\n */\nexport interface RuleFiles {\n /** Rule identifier (e.g., \"no-arbitrary-tailwind\") */\n ruleId: string;\n /** Implementation file */\n implementation: RuleFile;\n /** Test file (if exists) */\n test?: RuleFile;\n}\n\n/**\n * Get the path to the uilint-eslint package source directory\n */\nfunction getUilintEslintSrcDir(): string {\n // In development: packages/uilint-eslint/src/\n // In production (installed): node_modules/uilint-eslint/src/\n\n // Try workspace/dev path first (repo layout)\n const devPath = join(\n __dirname,\n \"..\",\n \"..\",\n \"..\",\n \"..\",\n \"uilint-eslint\",\n \"src\"\n );\n if (existsSync(devPath)) return devPath;\n\n // Try from installed package root (works with \"exports\")\n const pkgRoot = getUilintEslintPackageRoot();\n const srcPath = join(pkgRoot, \"src\");\n if (existsSync(srcPath)) return srcPath;\n\n throw new Error(\n 'Could not find uilint-eslint \"src/\" directory. If you are using a published install of uilint-eslint, ensure it includes source files, or run a JS-only rules install.'\n );\n}\n\n/**\n * Get the path to the uilint-eslint package dist directory\n */\nfunction getUilintEslintDistDir(): string {\n // In development: packages/uilint-eslint/dist/\n // In production (installed): node_modules/uilint-eslint/dist/\n\n // Try workspace/dev path first (repo layout)\n const devPath = join(\n __dirname,\n \"..\",\n \"..\",\n \"..\",\n \"..\",\n \"uilint-eslint\",\n \"dist\"\n );\n if (existsSync(devPath)) return devPath;\n\n // Try from installed package root (works with \"exports\")\n const pkgRoot = getUilintEslintPackageRoot();\n const distPath = join(pkgRoot, \"dist\");\n if (existsSync(distPath)) return distPath;\n\n throw new Error(\n 'Could not find uilint-eslint \"dist/\" directory. This is a bug in uilint installation.'\n );\n}\n\n/**\n * All utilities that are exported from uilint-eslint and can be imported.\n * When adding a new utility to uilint-eslint that rules may import,\n * add it here AND export it from uilint-eslint/src/index.ts.\n *\n * Rules can also declare their dependencies via the `internalDependencies`\n * field in defineRuleMeta() - this serves as documentation and can be\n * used for validation.\n */\nconst EXPORTED_UTILITIES = [\n \"create-rule\",\n \"cache\",\n \"styleguide-loader\",\n \"import-graph\",\n \"component-parser\",\n \"export-resolver\",\n \"coverage-aggregator\",\n \"dependency-graph\",\n \"file-categorizer\",\n \"jsx-coverage-analyzer\",\n];\n\n/**\n * Maps internal export names to their uilint-eslint export names.\n * Some exports are renamed when re-exported from the main package\n * to avoid naming conflicts.\n *\n * Format: \"utilFile:internalName\" -> \"externalName\"\n */\nconst EXPORT_RENAMES: Record<string, string> = {\n \"import-graph:clearCache\": \"clearImportGraphCache\",\n};\n\n/**\n * Transform an import specifier, applying any necessary renames.\n * Handles both simple imports (foo) and aliased imports (foo as bar).\n */\nfunction transformImportSpecifier(specifier: string, utilFile: string): string {\n const trimmed = specifier.trim();\n\n // Check for aliased import: \"localName as alias\"\n const aliasMatch = trimmed.match(/^(\\w+)\\s+as\\s+(\\w+)$/);\n if (aliasMatch) {\n const [, localName, alias] = aliasMatch;\n const renameKey = `${utilFile}:${localName}`;\n const externalName = EXPORT_RENAMES[renameKey];\n if (externalName) {\n // If the alias matches the external name, simplify to just the name\n if (alias === externalName) {\n return externalName;\n }\n // Otherwise, use the external name with the original alias\n return `${externalName} as ${alias}`;\n }\n // No rename needed, keep original\n return trimmed;\n }\n\n // Simple import: check if it needs renaming\n const renameKey = `${utilFile}:${trimmed}`;\n const externalName = EXPORT_RENAMES[renameKey];\n if (externalName) {\n return externalName;\n }\n\n return trimmed;\n}\n\n/**\n * Transform rule content to fix imports for copied location\n * Changes imports from \"../utils/...\" to \"uilint-eslint\"\n */\nfunction transformRuleContent(content: string): string {\n let transformed = content;\n\n // Replace all relative utility imports with uilint-eslint imports\n // Pattern: import { ... } from \"../utils/create-rule.js\" or similar\n // This handles any combination of imports like { createRule, defineRuleMeta }\n transformed = transformed.replace(\n /import\\s+{([^}]+)}\\s+from\\s+[\"']\\.\\.\\/utils\\/([^\"']+)\\.js[\"'];?/g,\n (match, imports, utilFile) => {\n if (EXPORTED_UTILITIES.includes(utilFile)) {\n // Transform each import specifier\n const specifiers = imports.split(\",\").map((s: string) =>\n transformImportSpecifier(s, utilFile)\n );\n return `import { ${specifiers.join(\", \")} } from \"uilint-eslint\";`;\n }\n return match; // Keep original if not a known utility\n }\n );\n\n // Also handle default imports: import createRule from \"../utils/create-rule.js\"\n transformed = transformed.replace(\n /import\\s+(\\w+)\\s+from\\s+[\"']\\.\\.\\/utils\\/([^\"']+)\\.js[\"'];?/g,\n (match, importName, utilFile) => {\n if (EXPORTED_UTILITIES.includes(utilFile)) {\n return `import { ${importName} } from \"uilint-eslint\";`;\n }\n return match;\n }\n );\n\n return transformed;\n}\n\n/**\n * Load a specific rule by ID\n */\nexport function loadRule(\n ruleId: string,\n options: { typescript: boolean } = { typescript: true }\n): RuleFiles {\n const { typescript } = options;\n const extension = typescript ? \".ts\" : \".js\";\n\n if (typescript) {\n // Load TypeScript source files\n const rulesDir = join(getUilintEslintSrcDir(), \"rules\");\n const implPath = join(rulesDir, `${ruleId}.ts`);\n const testPath = join(rulesDir, `${ruleId}.test.ts`);\n\n if (!existsSync(implPath)) {\n throw new Error(`Rule \"${ruleId}\" not found at ${implPath}`);\n }\n\n const rawContent = readFileSync(implPath, \"utf-8\");\n const transformedContent = transformRuleContent(rawContent);\n\n const implementation: RuleFile = {\n relativePath: `${ruleId}.ts`,\n content: transformedContent,\n };\n\n const test: RuleFile | undefined = existsSync(testPath)\n ? {\n relativePath: `${ruleId}.test.ts`,\n content: transformRuleContent(readFileSync(testPath, \"utf-8\")),\n }\n : undefined;\n\n return {\n ruleId,\n implementation,\n test,\n };\n } else {\n // Load compiled JavaScript files\n const rulesDir = join(getUilintEslintDistDir(), \"rules\");\n const implPath = join(rulesDir, `${ruleId}.js`);\n\n if (!existsSync(implPath)) {\n throw new Error(\n `Rule \"${ruleId}\" not found at ${implPath}. ` +\n `For JavaScript-only projects, uilint-eslint must be built to include compiled rule files in dist/rules/. ` +\n `If you're developing uilint-eslint, run 'pnpm build' in packages/uilint-eslint. ` +\n `If you're using a published package, ensure it includes the dist/ directory.`\n );\n }\n\n // Compiled JS files don't need transformation - they already use uilint-eslint imports\n const content = readFileSync(implPath, \"utf-8\");\n\n const implementation: RuleFile = {\n relativePath: `${ruleId}.js`,\n content,\n };\n\n // Test files are not compiled, so we don't copy them for JS projects\n return {\n ruleId,\n implementation,\n };\n }\n}\n\n/**\n * Load multiple rules by their IDs\n */\nexport function loadSelectedRules(\n ruleIds: string[],\n options: { typescript: boolean } = { typescript: true }\n): RuleFiles[] {\n return ruleIds.map((id) => loadRule(id, options));\n}\n\n/**\n * Get the list of available rule IDs from the registry\n */\nexport function getAvailableRuleIds(): string[] {\n try {\n // Import the rule registry from uilint-eslint\n const { ruleRegistry } = require(\"uilint-eslint\");\n return ruleRegistry.map((rule: { id: string }) => rule.id);\n } catch {\n // Fallback: try to read from filesystem\n const rulesDir = join(getUilintEslintSrcDir(), \"rules\");\n if (!existsSync(rulesDir)) {\n return [];\n }\n\n // This is a fallback - ideally we'd use the registry\n // But if we can't import it, we can at least try to list files\n const files = readdirSync(rulesDir);\n return files\n .filter((f: string) => f.endsWith(\".ts\") && !f.endsWith(\".test.ts\"))\n .map((f: string) => f.replace(\".ts\", \"\"));\n }\n}\n"],"mappings":";;;;;;;;;;;AAQA,SAAS,QAAAA,aAAY;;;ACDrB,SAAS,cAAc,YAAY,mBAAmB;AACtD,SAAS,MAAM,eAAe;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AACpC,IAAMC,WAAU,cAAc,YAAY,GAAG;AAE7C,SAAS,2BACP,SACA,UACe;AACf,MAAI,MAAM;AACV,SAAO,MAAM;AACX,UAAM,YAAY,KAAK,KAAK,gBAAgB,OAAO;AACnD,QAAI,WAAW,KAAK,WAAW,cAAc,CAAC,EAAG,QAAO;AACxD,UAAM,SAAS,QAAQ,GAAG;AAC1B,QAAI,WAAW,IAAK;AACpB,UAAM;AAAA,EACR;AACA,SAAO;AACT;AAEA,SAAS,6BAAqC;AAO5C,QAAM,UAAU,2BAA2B,iBAAiB,QAAQ,IAAI,CAAC;AACzE,MAAI,QAAS,QAAO;AAEpB,QAAM,WAAW,2BAA2B,iBAAiB,SAAS;AACtE,MAAI,SAAU,QAAO;AAGrB,MAAI;AACF,UAAM,QAAQA,SAAQ,QAAQ,eAAe;AAC7C,UAAM,WAAW,QAAQ,KAA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QACb,gBAAgB,qBAAqB,OAAO;AAAA,QAC5C,UAAU;AAAA,MACZ,CAAC;AAGD,UAAI,SAAS,kBAAkB;AAC7B,gBAAQ,KAAK;AAAA,UACX,MAAM;AAAA,UACN,aAAa;AAAA,UACb,YAAY,QAAQ;AAAA,UACpB,OAAO;AAAA,UACP,kBAAkB,QAAQ;AAAA,QAC5B,CAAC;AAAA,MACH;AAAA,IACF;AAGA,UAAM,gBAAgBA,MAAK,MAAM,eAAe,YAAY;AAC5D,YAAQ,KAAK;AAAA,MACX,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,eAAe;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,SAAS,aAAa;AACjC;AAKO,SAAS,gBACd,mBACA,eACgB;AAChB,QAAM,gBAAgB,IAAI,IAAI,iBAAiB;AAC/C,SAAO,cAAc,OAAO,CAAC,SAAS,CAAC,cAAc,IAAI,KAAK,EAAE,CAAC;AACnE;","names":["join","require","renameKey","externalName","join"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uilint",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.26",
|
|
4
4
|
"description": "CLI for UILint - AI-powered UI consistency checking",
|
|
5
5
|
"author": "Peter Suggate",
|
|
6
6
|
"repository": {
|
|
@@ -42,12 +42,14 @@
|
|
|
42
42
|
"dotenv": "^17.2.3",
|
|
43
43
|
"ink": "^6.6.0",
|
|
44
44
|
"magicast": "^0.5.1",
|
|
45
|
+
"ora": "^9.0.0",
|
|
45
46
|
"picocolors": "^1.1.1",
|
|
46
47
|
"react": "^19.2.3",
|
|
47
48
|
"typescript": "^5.9.3",
|
|
48
49
|
"ws": "^8.19.0",
|
|
49
|
-
"uilint-core": "0.2.
|
|
50
|
-
"uilint-
|
|
50
|
+
"uilint-core": "0.2.26",
|
|
51
|
+
"uilint-duplicates": "0.1.2",
|
|
52
|
+
"uilint-eslint": "0.2.26"
|
|
51
53
|
},
|
|
52
54
|
"optionalDependencies": {
|
|
53
55
|
"@langfuse/client": "^4.5.1",
|
|
@@ -56,11 +58,14 @@
|
|
|
56
58
|
"@opentelemetry/sdk-node": "^0.209.0"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
61
|
+
"@inkjs/ui": "^2.0.0",
|
|
59
62
|
"@types/node": "^25.0.8",
|
|
60
63
|
"@types/react": "^19.2.8",
|
|
61
64
|
"@types/ws": "^8.18.1",
|
|
65
|
+
"ink-testing-library": "^4.0.0",
|
|
62
66
|
"tsup": "^8.5.1",
|
|
63
|
-
"vitest": "^4.0.17"
|
|
67
|
+
"vitest": "^4.0.17",
|
|
68
|
+
"uilint-react": "0.2.26"
|
|
64
69
|
},
|
|
65
70
|
"keywords": [
|
|
66
71
|
"cli",
|
package/dist/chunk-FRNXXIEM.js
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/utils/prompts.ts
|
|
4
|
-
import * as p from "@clack/prompts";
|
|
5
|
-
import pc from "picocolors";
|
|
6
|
-
import { readFileSync } from "fs";
|
|
7
|
-
import { dirname, join } from "path";
|
|
8
|
-
import { fileURLToPath } from "url";
|
|
9
|
-
function getCLIVersion() {
|
|
10
|
-
try {
|
|
11
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
-
const pkgPath = join(__dirname, "..", "..", "package.json");
|
|
13
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
14
|
-
return pkg.version || "0.0.0";
|
|
15
|
-
} catch {
|
|
16
|
-
return "0.0.0";
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function intro2(title) {
|
|
20
|
-
const version = getCLIVersion();
|
|
21
|
-
const header = pc.bold(pc.cyan("\u25C6 UILint")) + pc.dim(` v${version}`);
|
|
22
|
-
console.log();
|
|
23
|
-
p.intro(title ? `${header} ${pc.dim("\xB7")} ${title}` : header);
|
|
24
|
-
}
|
|
25
|
-
function outro2(message) {
|
|
26
|
-
p.outro(pc.green(message));
|
|
27
|
-
}
|
|
28
|
-
function cancel2(message = "Operation cancelled.") {
|
|
29
|
-
p.cancel(pc.yellow(message));
|
|
30
|
-
process.exit(0);
|
|
31
|
-
}
|
|
32
|
-
function handleCancel(value) {
|
|
33
|
-
if (p.isCancel(value)) {
|
|
34
|
-
cancel2();
|
|
35
|
-
process.exit(0);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
async function withSpinner(message, fn) {
|
|
40
|
-
const s = p.spinner();
|
|
41
|
-
s.start(message);
|
|
42
|
-
try {
|
|
43
|
-
const result = fn.length >= 1 ? await fn(s) : await fn();
|
|
44
|
-
s.stop(pc.green("\u2713 ") + message);
|
|
45
|
-
return result;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
s.stop(pc.red("\u2717 ") + message);
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function createSpinner() {
|
|
52
|
-
return p.spinner();
|
|
53
|
-
}
|
|
54
|
-
function note2(message, title) {
|
|
55
|
-
p.note(message, title);
|
|
56
|
-
}
|
|
57
|
-
function log2(message) {
|
|
58
|
-
p.log.message(message);
|
|
59
|
-
}
|
|
60
|
-
function logInfo(message) {
|
|
61
|
-
p.log.info(message);
|
|
62
|
-
}
|
|
63
|
-
function logSuccess(message) {
|
|
64
|
-
p.log.success(message);
|
|
65
|
-
}
|
|
66
|
-
function logWarning(message) {
|
|
67
|
-
p.log.warn(message);
|
|
68
|
-
}
|
|
69
|
-
function logError(message) {
|
|
70
|
-
p.log.error(message);
|
|
71
|
-
}
|
|
72
|
-
async function select2(options) {
|
|
73
|
-
const result = await p.select({
|
|
74
|
-
message: options.message,
|
|
75
|
-
options: options.options,
|
|
76
|
-
initialValue: options.initialValue
|
|
77
|
-
});
|
|
78
|
-
return handleCancel(result);
|
|
79
|
-
}
|
|
80
|
-
async function confirm2(options) {
|
|
81
|
-
const result = await p.confirm({
|
|
82
|
-
message: options.message,
|
|
83
|
-
initialValue: options.initialValue ?? true
|
|
84
|
-
});
|
|
85
|
-
return handleCancel(result);
|
|
86
|
-
}
|
|
87
|
-
async function multiselect2(options) {
|
|
88
|
-
const result = await p.multiselect({
|
|
89
|
-
message: options.message,
|
|
90
|
-
options: options.options,
|
|
91
|
-
required: options.required,
|
|
92
|
-
initialValues: options.initialValues
|
|
93
|
-
});
|
|
94
|
-
return handleCancel(result);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// src/utils/next-detect.ts
|
|
98
|
-
import { existsSync, readdirSync } from "fs";
|
|
99
|
-
import { join as join2 } from "path";
|
|
100
|
-
function fileExists(projectPath, relPath) {
|
|
101
|
-
return existsSync(join2(projectPath, relPath));
|
|
102
|
-
}
|
|
103
|
-
function detectNextAppRouter(projectPath) {
|
|
104
|
-
const roots = ["app", join2("src", "app")];
|
|
105
|
-
const candidates = [];
|
|
106
|
-
let chosenRoot = null;
|
|
107
|
-
for (const root of roots) {
|
|
108
|
-
if (existsSync(join2(projectPath, root))) {
|
|
109
|
-
chosenRoot = root;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (!chosenRoot) return null;
|
|
114
|
-
const entryCandidates = [
|
|
115
|
-
join2(chosenRoot, "layout.tsx"),
|
|
116
|
-
join2(chosenRoot, "layout.jsx"),
|
|
117
|
-
join2(chosenRoot, "layout.ts"),
|
|
118
|
-
join2(chosenRoot, "layout.js"),
|
|
119
|
-
// Fallbacks (less ideal, but can work):
|
|
120
|
-
join2(chosenRoot, "page.tsx"),
|
|
121
|
-
join2(chosenRoot, "page.jsx")
|
|
122
|
-
];
|
|
123
|
-
for (const rel of entryCandidates) {
|
|
124
|
-
if (fileExists(projectPath, rel)) candidates.push(rel);
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
appRoot: chosenRoot,
|
|
128
|
-
appRootAbs: join2(projectPath, chosenRoot),
|
|
129
|
-
candidates
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
var DEFAULT_IGNORE_DIRS = /* @__PURE__ */ new Set([
|
|
133
|
-
"node_modules",
|
|
134
|
-
".git",
|
|
135
|
-
".next",
|
|
136
|
-
"dist",
|
|
137
|
-
"build",
|
|
138
|
-
"out",
|
|
139
|
-
".turbo",
|
|
140
|
-
".vercel",
|
|
141
|
-
".cursor",
|
|
142
|
-
"coverage",
|
|
143
|
-
".uilint"
|
|
144
|
-
]);
|
|
145
|
-
function findNextAppRouterProjects(rootDir, options) {
|
|
146
|
-
const maxDepth = options?.maxDepth ?? 4;
|
|
147
|
-
const ignoreDirs = options?.ignoreDirs ?? DEFAULT_IGNORE_DIRS;
|
|
148
|
-
const results = [];
|
|
149
|
-
const visited = /* @__PURE__ */ new Set();
|
|
150
|
-
function walk(dir, depth) {
|
|
151
|
-
if (depth > maxDepth) return;
|
|
152
|
-
if (visited.has(dir)) return;
|
|
153
|
-
visited.add(dir);
|
|
154
|
-
const detection = detectNextAppRouter(dir);
|
|
155
|
-
if (detection) {
|
|
156
|
-
results.push({ projectPath: dir, detection });
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
let entries = [];
|
|
160
|
-
try {
|
|
161
|
-
entries = readdirSync(dir, { withFileTypes: true }).map((d) => ({
|
|
162
|
-
name: d.name,
|
|
163
|
-
isDirectory: d.isDirectory()
|
|
164
|
-
}));
|
|
165
|
-
} catch {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
for (const ent of entries) {
|
|
169
|
-
if (!ent.isDirectory) continue;
|
|
170
|
-
if (ignoreDirs.has(ent.name)) continue;
|
|
171
|
-
if (ent.name.startsWith(".") && ent.name !== ".") continue;
|
|
172
|
-
walk(join2(dir, ent.name), depth + 1);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
walk(rootDir, 0);
|
|
176
|
-
return results;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export {
|
|
180
|
-
pc,
|
|
181
|
-
intro2 as intro,
|
|
182
|
-
outro2 as outro,
|
|
183
|
-
withSpinner,
|
|
184
|
-
createSpinner,
|
|
185
|
-
note2 as note,
|
|
186
|
-
log2 as log,
|
|
187
|
-
logInfo,
|
|
188
|
-
logSuccess,
|
|
189
|
-
logWarning,
|
|
190
|
-
logError,
|
|
191
|
-
select2 as select,
|
|
192
|
-
confirm2 as confirm,
|
|
193
|
-
multiselect2 as multiselect,
|
|
194
|
-
detectNextAppRouter,
|
|
195
|
-
findNextAppRouterProjects
|
|
196
|
-
};
|
|
197
|
-
//# sourceMappingURL=chunk-FRNXXIEM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/prompts.ts","../src/utils/next-detect.ts"],"sourcesContent":["/**\n * Shared clack/prompts utilities for UILint CLI\n * Provides branded intro/outro, spinners, and common UI patterns\n */\n\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport { readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\n\n/**\n * Get the CLI version from package.json\n */\nfunction getCLIVersion(): string {\n try {\n const __dirname = dirname(fileURLToPath(import.meta.url));\n const pkgPath = join(__dirname, \"..\", \"..\", \"package.json\");\n const pkg = JSON.parse(readFileSync(pkgPath, \"utf-8\")) as {\n version?: string;\n };\n return pkg.version || \"0.0.0\";\n } catch {\n return \"0.0.0\";\n }\n}\n\n/**\n * Branded UILint intro with logo and version\n */\nexport function intro(title?: string): void {\n const version = getCLIVersion();\n const header = pc.bold(pc.cyan(\"◆ UILint\")) + pc.dim(` v${version}`);\n \n console.log();\n p.intro(title ? `${header} ${pc.dim(\"·\")} ${title}` : header);\n}\n\n/**\n * Styled outro with next steps\n */\nexport function outro(message: string): void {\n p.outro(pc.green(message));\n}\n\n/**\n * Cancel message when user exits\n */\nexport function cancel(message = \"Operation cancelled.\"): void {\n p.cancel(pc.yellow(message));\n process.exit(0);\n}\n\n/**\n * Check if user cancelled a prompt\n */\nexport function isCancel(value: unknown): value is symbol {\n return p.isCancel(value);\n}\n\n/**\n * Handle cancel check - exits if cancelled\n */\nexport function handleCancel<T>(value: T | symbol): T {\n if (p.isCancel(value)) {\n cancel();\n process.exit(0);\n }\n return value as T;\n}\n\n/**\n * Spinner wrapper with automatic error handling\n */\nexport async function withSpinner<T>(\n message: string,\n fn: (() => Promise<T>) | ((spinner: ReturnType<typeof p.spinner>) => Promise<T>)\n): Promise<T> {\n const s = p.spinner();\n s.start(message);\n try {\n const result =\n fn.length >= 1\n ? await (fn as (spinner: ReturnType<typeof p.spinner>) => Promise<T>)(s)\n : await (fn as () => Promise<T>)();\n s.stop(pc.green(\"✓ \") + message);\n return result;\n } catch (error) {\n s.stop(pc.red(\"✗ \") + message);\n throw error;\n }\n}\n\n/**\n * Spinner that can be updated\n */\nexport function createSpinner() {\n return p.spinner();\n}\n\n/**\n * Display a note box\n */\nexport function note(message: string, title?: string): void {\n p.note(message, title);\n}\n\n/**\n * Display a log message\n */\nexport function log(message: string): void {\n p.log.message(message);\n}\n\n/**\n * Display an info message\n */\nexport function logInfo(message: string): void {\n p.log.info(message);\n}\n\n/**\n * Display a success message\n */\nexport function logSuccess(message: string): void {\n p.log.success(message);\n}\n\n/**\n * Display a warning message\n */\nexport function logWarning(message: string): void {\n p.log.warn(message);\n}\n\n/**\n * Display an error message\n */\nexport function logError(message: string): void {\n p.log.error(message);\n}\n\n/**\n * Display a step message\n */\nexport function logStep(message: string): void {\n p.log.step(message);\n}\n\n/**\n * Select prompt wrapper\n */\nexport async function select<T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n initialValue?: T;\n}): Promise<T> {\n const result = await p.select({\n message: options.message,\n options: options.options as { value: T; label: string; hint?: string }[],\n initialValue: options.initialValue,\n } as Parameters<typeof p.select>[0]);\n return handleCancel(result) as T;\n}\n\n/**\n * Confirm prompt wrapper\n */\nexport async function confirm(options: {\n message: string;\n initialValue?: boolean;\n}): Promise<boolean> {\n const result = await p.confirm({\n message: options.message,\n initialValue: options.initialValue ?? true,\n });\n return handleCancel(result);\n}\n\n/**\n * Text input prompt wrapper\n */\nexport async function text(options: {\n message: string;\n placeholder?: string;\n defaultValue?: string;\n validate?: (value: string) => string | Error | undefined;\n}): Promise<string> {\n const result = await p.text(options);\n return handleCancel(result);\n}\n\n/**\n * Multiselect prompt wrapper\n */\nexport async function multiselect<T extends string>(options: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n required?: boolean;\n initialValues?: T[];\n}): Promise<T[]> {\n const result = await p.multiselect({\n message: options.message,\n options: options.options as { value: T; label: string; hint?: string }[],\n required: options.required,\n initialValues: options.initialValues,\n } as Parameters<typeof p.multiselect>[0]);\n return handleCancel(result) as T[];\n}\n\n/**\n * Group of tasks displayed together\n */\nexport async function group<T extends Record<string, unknown>>(\n prompts: p.PromptGroup<T>,\n options?: p.PromptGroupOptions<T>\n): Promise<T> {\n const result = await p.group(prompts, options);\n return result;\n}\n\n// Re-export picocolors for consistent styling\nexport { pc };\n","import { existsSync, readdirSync } from \"fs\";\nimport { join } from \"path\";\n\nexport interface NextAppRouterDetection {\n /**\n * Relative path to the Next App Router root dir (either \"app\" or \"src/app\").\n */\n appRoot: string;\n /**\n * Absolute path to the App Router root dir.\n */\n appRootAbs: string;\n /**\n * Candidate entry files (relative paths) that are good injection targets.\n */\n candidates: string[];\n}\n\nfunction fileExists(projectPath: string, relPath: string): boolean {\n return existsSync(join(projectPath, relPath));\n}\n\nexport function detectNextAppRouter(\n projectPath: string\n): NextAppRouterDetection | null {\n const roots = [\"app\", join(\"src\", \"app\")];\n const candidates: string[] = [];\n\n let chosenRoot: string | null = null;\n for (const root of roots) {\n if (existsSync(join(projectPath, root))) {\n chosenRoot = root;\n break;\n }\n }\n\n if (!chosenRoot) return null;\n\n // Prioritize layout files (Next App Router canonical integration point).\n const entryCandidates = [\n join(chosenRoot, \"layout.tsx\"),\n join(chosenRoot, \"layout.jsx\"),\n join(chosenRoot, \"layout.ts\"),\n join(chosenRoot, \"layout.js\"),\n // Fallbacks (less ideal, but can work):\n join(chosenRoot, \"page.tsx\"),\n join(chosenRoot, \"page.jsx\"),\n ];\n\n for (const rel of entryCandidates) {\n if (fileExists(projectPath, rel)) candidates.push(rel);\n }\n\n // If nothing exists, still return detection so routes can be installed.\n return {\n appRoot: chosenRoot,\n appRootAbs: join(projectPath, chosenRoot),\n candidates,\n };\n}\n\nexport interface NextAppRouterProjectMatch {\n /**\n * Absolute path to the Next project root (dir containing app/ or src/app/).\n */\n projectPath: string;\n detection: NextAppRouterDetection;\n}\n\nconst DEFAULT_IGNORE_DIRS = new Set([\n \"node_modules\",\n \".git\",\n \".next\",\n \"dist\",\n \"build\",\n \"out\",\n \".turbo\",\n \".vercel\",\n \".cursor\",\n \"coverage\",\n \".uilint\",\n]);\n\n/**\n * Best-effort monorepo discovery for Next.js App Router apps.\n *\n * Walks down from `rootDir` looking for directories that contain `app/` or\n * `src/app/`. Skips common large/irrelevant dirs.\n */\nexport function findNextAppRouterProjects(\n rootDir: string,\n options?: { maxDepth?: number; ignoreDirs?: Set<string> }\n): NextAppRouterProjectMatch[] {\n const maxDepth = options?.maxDepth ?? 4;\n const ignoreDirs = options?.ignoreDirs ?? DEFAULT_IGNORE_DIRS;\n const results: NextAppRouterProjectMatch[] = [];\n const visited = new Set<string>();\n\n function walk(dir: string, depth: number) {\n if (depth > maxDepth) return;\n if (visited.has(dir)) return;\n visited.add(dir);\n\n const detection = detectNextAppRouter(dir);\n if (detection) {\n results.push({ projectPath: dir, detection });\n // Don't descend further once we found a project root (avoid nested hits).\n return;\n }\n\n let entries: Array<{ name: string; isDirectory: boolean }> = [];\n try {\n entries = readdirSync(dir, { withFileTypes: true }).map((d) => ({\n name: d.name,\n isDirectory: d.isDirectory(),\n }));\n } catch {\n return;\n }\n\n for (const ent of entries) {\n if (!ent.isDirectory) continue;\n if (ignoreDirs.has(ent.name)) continue;\n // Skip hidden dirs by default (except `src` which matters)\n if (ent.name.startsWith(\".\") && ent.name !== \".\") continue;\n walk(join(dir, ent.name), depth + 1);\n }\n }\n\n walk(rootDir, 0);\n return results;\n}\n"],"mappings":";;;AAKA,YAAY,OAAO;AACnB,OAAO,QAAQ;AACf,SAAS,oBAAoB;AAC7B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAK9B,SAAS,gBAAwB;AAC/B,MAAI;AACF,UAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,UAAM,UAAU,KAAK,WAAW,MAAM,MAAM,cAAc;AAC1D,UAAM,MAAM,KAAK,MAAM,aAAa,SAAS,OAAO,CAAC;AAGrD,WAAO,IAAI,WAAW;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAKO,SAASA,OAAM,OAAsB;AAC1C,QAAM,UAAU,cAAc;AAC9B,QAAM,SAAS,GAAG,KAAK,GAAG,KAAK,eAAU,CAAC,IAAI,GAAG,IAAI,KAAK,OAAO,EAAE;AAEnE,UAAQ,IAAI;AACZ,EAAE,QAAM,QAAQ,GAAG,MAAM,IAAI,GAAG,IAAI,MAAG,CAAC,IAAI,KAAK,KAAK,MAAM;AAC9D;AAKO,SAASC,OAAM,SAAuB;AAC3C,EAAE,QAAM,GAAG,MAAM,OAAO,CAAC;AAC3B;AAKO,SAASC,QAAO,UAAU,wBAA8B;AAC7D,EAAE,SAAO,GAAG,OAAO,OAAO,CAAC;AAC3B,UAAQ,KAAK,CAAC;AAChB;AAYO,SAAS,aAAgB,OAAsB;AACpD,MAAM,WAAS,KAAK,GAAG;AACrB,IAAAC,QAAO;AACP,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAKA,eAAsB,YACpB,SACA,IACY;AACZ,QAAM,IAAM,UAAQ;AACpB,IAAE,MAAM,OAAO;AACf,MAAI;AACF,UAAM,SACJ,GAAG,UAAU,IACT,MAAO,GAA6D,CAAC,IACrE,MAAO,GAAwB;AACr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WAAW;AACb,cAAQ,KAAK,EAAE,aAAa,KAAK,UAAU,CAAC;AAE5C;AAAA,IACF;AAEA,QAAI,UAAyD,CAAC;AAC9D,QAAI;AACF,gBAAU,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO;AAAA,QAC9D,MAAM,EAAE;AAAA,QACR,aAAa,EAAE,YAAY;AAAA,MAC7B,EAAE;AAAA,IACJ,QAAQ;AACN;AAAA,IACF;AAEA,eAAW,OAAO,SAAS;AACzB,UAAI,CAAC,IAAI,YAAa;AACtB,UAAI,WAAW,IAAI,IAAI,IAAI,EAAG;AAE9B,UAAI,IAAI,KAAK,WAAW,GAAG,KAAK,IAAI,SAAS,IAAK;AAClD,WAAKA,MAAK,KAAK,IAAI,IAAI,GAAG,QAAQ,CAAC;AAAA,IACrC;AAAA,EACF;AAEA,OAAK,SAAS,CAAC;AACf,SAAO;AACT;","names":["intro","outro","cancel","cancel","note","log","select","confirm","multiselect","join"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/package-manager.ts","../src/commands/install/constants.ts","../src/utils/skill-loader.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { spawn } from \"child_process\";\nimport { dirname, join } from \"path\";\n\nexport type PackageManager = \"pnpm\" | \"yarn\" | \"npm\" | \"bun\";\n\n/**\n * Detect which package manager a project uses by looking for lockfiles.\n * Walks up the directory tree to support monorepos.\n */\nexport function detectPackageManager(projectPath: string): PackageManager {\n // Monorepo-friendly detection: walk up to find the lockfile/workspace marker.\n let dir = projectPath;\n for (;;) {\n // pnpm\n if (existsSync(join(dir, \"pnpm-lock.yaml\"))) return \"pnpm\";\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return \"pnpm\";\n\n // yarn\n if (existsSync(join(dir, \"yarn.lock\"))) return \"yarn\";\n\n // bun\n if (existsSync(join(dir, \"bun.lockb\"))) return \"bun\";\n if (existsSync(join(dir, \"bun.lock\"))) return \"bun\";\n\n // npm\n if (existsSync(join(dir, \"package-lock.json\"))) return \"npm\";\n\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Default: npm (best-effort)\n return \"npm\";\n}\n\nfunction spawnAsync(\n command: string,\n args: string[],\n cwd: string\n): Promise<void> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n cwd,\n stdio: \"inherit\",\n shell: process.platform === \"win32\",\n });\n\n child.on(\"error\", reject);\n child.on(\"close\", (code) => {\n if (code === 0) resolve();\n else\n reject(new Error(`${command} ${args.join(\" \")} exited with ${code}`));\n });\n });\n}\n\nexport async function installDependencies(\n pm: PackageManager,\n projectPath: string,\n packages: string[]\n): Promise<void> {\n if (!packages.length) return;\n\n switch (pm) {\n case \"pnpm\":\n await spawnAsync(\"pnpm\", [\"add\", ...packages], projectPath);\n return;\n case \"yarn\":\n await spawnAsync(\"yarn\", [\"add\", ...packages], projectPath);\n return;\n case \"bun\":\n await spawnAsync(\"bun\", [\"add\", ...packages], projectPath);\n return;\n case \"npm\":\n default:\n await spawnAsync(\"npm\", [\"install\", \"--save\", ...packages], projectPath);\n return;\n }\n}\n","/**\n * Constants for the install command\n *\n * Contains file content templates for commands.\n */\n\n// ============================================================================\n// Cursor Commands\n// ============================================================================\n\nexport const GENSTYLEGUIDE_COMMAND_MD = `# React Style Guide Generator\n\nAnalyze the React UI codebase to produce a **prescriptive, semantic** style guide. Focus on consistency, intent, and relationships—not specific values.\n\n## Philosophy\n\n1. **Identify the intended architecture** from the best patterns in use\n2. **Prescribe semantic rules** — about consistency and relationships, not pixels\n3. **Stay general** — \"primary buttons should be visually consistent\" not \"buttons use px-4\"\n4. **Focus on intent** — what should FEEL the same, not what values to use\n\n## Analysis Steps\n\n### 1. Detect the Stack\n- Framework: Next.js (App Router? Pages?), Vite, CRA\n- Component system: shadcn, MUI, Chakra, Radix, custom\n- Styling: Tailwind, CSS Modules, styled-components\n- Forms: react-hook-form, Formik, native\n- State: React context, Zustand, Redux, Jotai\n\n### 2. Identify Best Patterns\nExamine the **best-written** components. Look at:\n- \\`components/ui/*\\` — the design system\n- Recently modified files — current standards\n- Shared layouts — structural patterns\n\n### 3. Infer Visual Hierarchy & Intent\nUnderstand the design language:\n- What distinguishes primary vs secondary actions?\n- How is visual hierarchy established?\n- What creates consistency across similar elements?\n\n## Output Format\n\nGenerate at \\`<nextjs app root>/.uilint/styleguide.md\\`:\n\\`\\`\\`yaml\n# Stack\nframework: \nstyling: \ncomponents: \ncomponent_path: \nforms: \n\n# Component Usage (MUST use these)\nuse:\n buttons: \n inputs: \n modals: \n cards: \n feedback: \n icons: \n links: \n\n# Semantic Rules (consistency & relationships)\nsemantics:\n hierarchy:\n - <e.g., \"primary actions must be visually distinct from secondary\">\n - <e.g., \"destructive actions should be visually cautionary\">\n - <e.g., \"page titles should be visually heavier than section titles\">\n consistency:\n - <e.g., \"all primary buttons should share the same visual weight\">\n - <e.g., \"form inputs should have uniform height and padding\">\n - <e.g., \"card padding should be consistent across the app\">\n - <e.g., \"interactive elements should have consistent hover/focus states\">\n spacing:\n - <e.g., \"use the spacing scale — no arbitrary values\">\n - <e.g., \"related elements should be closer than unrelated\">\n - <e.g., \"section spacing should be larger than element spacing\">\n layout:\n - <e.g., \"use gap for sibling spacing, not margin\">\n - <e.g., \"containers should have consistent max-width and padding\">\n\n# Patterns (structural, not values)\npatterns:\n forms: <e.g., \"FormField + Controller + zod schema\">\n conditionals: <e.g., \"cn() for class merging\">\n loading: <e.g., \"Skeleton for content, Spinner for actions\">\n errors: <e.g., \"ErrorBoundary at route, inline for forms\">\n responsive: <e.g., \"mobile-first, standard breakpoints only\">\n\n# Component Authoring\nauthoring:\n - <e.g., \"forwardRef for interactive components\">\n - <e.g., \"variants via CVA or component props, not className overrides\">\n - <e.g., \"extract when used 2+ times\">\n - <e.g., \"'use client' only when needed\">\n\n# Forbidden\nforbidden:\n - <e.g., \"inline style={{}}\">\n - <e.g., \"raw HTML elements when component exists\">\n - <e.g., \"arbitrary values — use scale\">\n - <e.g., \"className overrides that break visual consistency\">\n - <e.g., \"one-off spacing that doesn't match siblings\">\n\n# Legacy (if migration in progress)\nlegacy:\n - <e.g., \"old: CSS modules → new: Tailwind\">\n - <e.g., \"old: Formik → new: react-hook-form\">\n\n# Conventions\nconventions:\n - \n - \n - \n\\`\\`\\`\n\n## Rules\n\n- **Semantic over specific**: \"consistent padding\" not \"p-4\"\n- **Relationships over absolutes**: \"heavier than\" not \"font-bold\"\n- **Intent over implementation**: \"visually distinct\" not \"blue background\"\n- **Prescriptive**: Define target state, not current state\n- **Terse**: No prose. Fragments and short phrases only.\n- **Actionable**: Every rule should be human-verifiable\n- **Omit if N/A**: Skip sections that don't apply\n- **Max 5 items** per section — highest impact only\n`;\n\n","/**\n * Skill Loader Utility\n *\n * Loads Agent Skill files from the bundled skills directory for installation\n * into user projects. Skills follow the Agent Skills specification\n * (agentskills.io).\n */\n\nimport { readFileSync, readdirSync, statSync, existsSync } from \"fs\";\nimport { join, dirname, relative } from \"path\";\nimport { fileURLToPath } from \"url\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Represents a file in a skill directory\n */\nexport interface SkillFile {\n /** Relative path within the skill directory */\n relativePath: string;\n /** File content */\n content: string;\n}\n\n/**\n * Represents a complete skill ready for installation\n */\nexport interface Skill {\n /** Skill name (directory name) */\n name: string;\n /** All files in the skill */\n files: SkillFile[];\n}\n\n/**\n * Get the path to the bundled skills directory\n */\nfunction getSkillsDir(): string {\n // In development: packages/uilint/skills/\n // In production (installed): node_modules/uilint/dist/ -> ../skills/\n const devPath = join(__dirname, \"..\", \"..\", \"skills\");\n const prodPath = join(__dirname, \"..\", \"skills\");\n\n if (existsSync(devPath)) {\n return devPath;\n }\n if (existsSync(prodPath)) {\n return prodPath;\n }\n\n throw new Error(\n \"Could not find skills directory. This is a bug in uilint installation.\"\n );\n}\n\n/**\n * Recursively collect all files in a directory\n */\nfunction collectFiles(dir: string, baseDir: string): SkillFile[] {\n const files: SkillFile[] = [];\n const entries = readdirSync(dir);\n\n for (const entry of entries) {\n const fullPath = join(dir, entry);\n const stat = statSync(fullPath);\n\n if (stat.isDirectory()) {\n files.push(...collectFiles(fullPath, baseDir));\n } else if (stat.isFile()) {\n const relativePath = relative(baseDir, fullPath);\n const content = readFileSync(fullPath, \"utf-8\");\n files.push({ relativePath, content });\n }\n }\n\n return files;\n}\n\n/**\n * Load a specific skill by name\n */\nexport function loadSkill(name: string): Skill {\n const skillsDir = getSkillsDir();\n const skillDir = join(skillsDir, name);\n\n if (!existsSync(skillDir)) {\n throw new Error(`Skill \"${name}\" not found in ${skillsDir}`);\n }\n\n const skillMdPath = join(skillDir, \"SKILL.md\");\n if (!existsSync(skillMdPath)) {\n throw new Error(`Skill \"${name}\" is missing SKILL.md`);\n }\n\n const files = collectFiles(skillDir, skillDir);\n\n return { name, files };\n}\n\n/**\n * Load all available skills\n */\nexport function loadAllSkills(): Skill[] {\n const skillsDir = getSkillsDir();\n const entries = readdirSync(skillsDir);\n const skills: Skill[] = [];\n\n for (const entry of entries) {\n const skillDir = join(skillsDir, entry);\n const stat = statSync(skillDir);\n\n if (stat.isDirectory()) {\n const skillMdPath = join(skillDir, \"SKILL.md\");\n if (existsSync(skillMdPath)) {\n skills.push(loadSkill(entry));\n }\n }\n }\n\n return skills;\n}\n\n/**\n * Get the list of available skill names\n */\nexport function getAvailableSkillNames(): string[] {\n const skillsDir = getSkillsDir();\n const entries = readdirSync(skillsDir);\n const names: string[] = [];\n\n for (const entry of entries) {\n const skillDir = join(skillsDir, entry);\n const stat = statSync(skillDir);\n\n if (stat.isDirectory()) {\n const skillMdPath = join(skillDir, \"SKILL.md\");\n if (existsSync(skillMdPath)) {\n names.push(entry);\n }\n }\n }\n\n return names;\n}\n"],"mappings":";;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,SAAS,YAAY;AAQvB,SAAS,qBAAqB,aAAqC;AAExE,MAAI,MAAM;AACV,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