uilint 0.2.153 → 0.2.154
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-GFJDTSYD.js → chunk-GYGQ7HHN.js} +6 -6
- package/dist/chunk-GYGQ7HHN.js.map +1 -0
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/{init-ui-CIK6YKOZ.js → init-ui-ATSYWDOI.js} +2 -2
- package/dist/{plugin-loader-V5CAMTYQ.js → plugin-loader-VTAJHQNK.js} +2 -2
- package/dist/{upgrade-WP6U3LEO.js → upgrade-QKD7JRI7.js} +2 -2
- package/package.json +9 -9
- package/dist/chunk-GFJDTSYD.js.map +0 -1
- /package/dist/{init-ui-CIK6YKOZ.js.map → init-ui-ATSYWDOI.js.map} +0 -0
- /package/dist/{plugin-loader-V5CAMTYQ.js.map → plugin-loader-VTAJHQNK.js.map} +0 -0
- /package/dist/{upgrade-WP6U3LEO.js.map → upgrade-QKD7JRI7.js.map} +0 -0
|
@@ -8,7 +8,6 @@ import { createRequire } from "module";
|
|
|
8
8
|
import { existsSync, readFileSync } from "fs";
|
|
9
9
|
import { join } from "path";
|
|
10
10
|
import { pathToFileURL } from "url";
|
|
11
|
-
var KNOWN_PLUGIN_PACKAGES = ["uilint-vision", "uilint-semantic", "uilint-duplicates", "uilint-coverage"];
|
|
12
11
|
async function importFromProject(specifier, projectPath) {
|
|
13
12
|
try {
|
|
14
13
|
const req = createRequire(join(projectPath, "package.json"));
|
|
@@ -33,15 +32,16 @@ async function importFromProject(specifier, projectPath) {
|
|
|
33
32
|
return await import(pathToFileURL(fullPath).href);
|
|
34
33
|
}
|
|
35
34
|
async function discoverPlugins(resolveFrom) {
|
|
35
|
+
const core = await import("uilint-core");
|
|
36
|
+
const KNOWN_PLUGINS = core.KNOWN_PLUGINS ?? [];
|
|
36
37
|
const manifests = [];
|
|
37
|
-
for (const
|
|
38
|
-
const specifier = `${pkg}/cli-manifest`;
|
|
38
|
+
for (const known of KNOWN_PLUGINS) {
|
|
39
39
|
try {
|
|
40
40
|
let mod;
|
|
41
41
|
if (resolveFrom) {
|
|
42
|
-
mod = await importFromProject(
|
|
42
|
+
mod = await importFromProject(known.manifestSpecifier, resolveFrom);
|
|
43
43
|
} else {
|
|
44
|
-
mod = await import(
|
|
44
|
+
mod = await import(known.manifestSpecifier);
|
|
45
45
|
}
|
|
46
46
|
if (mod?.cliManifest) {
|
|
47
47
|
manifests.push(mod.cliManifest);
|
|
@@ -77,4 +77,4 @@ export {
|
|
|
77
77
|
discoverPlugins,
|
|
78
78
|
loadPluginESLintRules
|
|
79
79
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-GYGQ7HHN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/plugin-loader.ts"],"sourcesContent":["/**\n * Dynamic plugin loader for the CLI.\n *\n * Probes known plugin package names for a `cli-manifest` subpath export.\n * Each manifest describes the CLI flag, help text, and registration entry\n * point, keeping the core CLI free of plugin-specific knowledge.\n *\n * The list of known plugins comes from `uilint-core/KNOWN_PLUGINS` —\n * a single source of truth shared by the CLI, React loader, and plugins.\n */\n\nimport { createRequire } from \"module\";\nimport { existsSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { pathToFileURL } from \"url\";\nimport { logInfo } from \"./prompts.js\";\n\n/**\n * Metadata a plugin exposes via its `<pkg>/cli-manifest` subpath export.\n * Plugins define a plain object matching this shape — no shared type import needed.\n */\nexport interface PluginCLIManifest {\n /** npm package name, e.g. \"uilint-vision\" */\n packageName: string;\n /** CLI flag name (without --), e.g. \"vision\" */\n cliFlag: string;\n /** Description shown in --help */\n cliDescription: string;\n /** Import specifier for the register module, e.g. \"uilint-vision/eslint-rules/register\" */\n registerSpecifier: string;\n /** Display name shown in the interactive install UI, e.g. \"Vision Analysis\" */\n displayName: string;\n /** Description shown in the interactive install UI */\n displayDescription: string;\n /** Emoji icon for the interactive install UI, e.g. \"👁️\" */\n displayIcon: string;\n}\n\n/**\n * Resolve and import a package subpath specifier from a given project directory.\n *\n * First tries CJS `createRequire().resolve()`, which works for packages with\n * a `\"require\"` export condition. If that fails (e.g. the package only defines\n * `\"import\"`), falls back to manually reading the package's `exports` map and\n * constructing a file URL.\n */\nasync function importFromProject(\n specifier: string,\n projectPath: string,\n): Promise<unknown> {\n // Try CJS resolution first (fast path)\n try {\n const req = createRequire(join(projectPath, \"package.json\"));\n const resolved = req.resolve(specifier);\n return await import(resolved);\n } catch {\n // CJS resolution failed — try ESM-only export resolution\n }\n\n // Parse \"pkg/subpath\" → [\"pkg\", \"./subpath\"]\n const slashIdx = specifier.indexOf(\"/\");\n if (slashIdx === -1) return undefined;\n const pkgName = specifier.slice(0, slashIdx);\n const subpath = `./${specifier.slice(slashIdx + 1)}`;\n\n const pkgDir = join(projectPath, \"node_modules\", pkgName);\n const pkgJsonPath = join(pkgDir, \"package.json\");\n if (!existsSync(pkgJsonPath)) return undefined;\n\n const pkgJson = JSON.parse(readFileSync(pkgJsonPath, \"utf8\"));\n const exportEntry = pkgJson.exports?.[subpath];\n if (!exportEntry) return undefined;\n\n const importPath =\n typeof exportEntry === \"string\"\n ? exportEntry\n : exportEntry.import ?? exportEntry.default;\n if (!importPath) return undefined;\n\n const fullPath = join(pkgDir, importPath);\n if (!existsSync(fullPath)) return undefined;\n\n return await import(pathToFileURL(fullPath).href);\n}\n\n/**\n * Discover available plugin manifests by probing `<pkg>/cli-manifest`.\n *\n * Uses `KNOWN_PLUGINS` from uilint-core as the single source of truth\n * for which packages to probe.\n *\n * @param resolveFrom - Optional project path to resolve plugins from.\n * When provided, resolves plugins from the project's node_modules\n * so plugins installed in the project can be found.\n * @returns Array of discovered plugin manifests\n */\nexport async function discoverPlugins(\n resolveFrom?: string,\n): Promise<PluginCLIManifest[]> {\n // Dynamic import — avoids a static named-export binding on uilint-core which\n // tsup auto-externalizes. Gracefully degrades if the installed uilint-core\n // version doesn't yet export KNOWN_PLUGINS (e.g. preview deploys).\n const core = await import(\"uilint-core\");\n const KNOWN_PLUGINS: ReadonlyArray<{ packageName: string; manifestSpecifier: string }> =\n core.KNOWN_PLUGINS ?? [];\n\n const manifests: PluginCLIManifest[] = [];\n\n for (const known of KNOWN_PLUGINS) {\n try {\n let mod: { cliManifest?: PluginCLIManifest } | undefined;\n if (resolveFrom) {\n mod = (await importFromProject(known.manifestSpecifier, resolveFrom)) as typeof mod;\n } else {\n mod = (await import(known.manifestSpecifier)) as typeof mod;\n }\n if (mod?.cliManifest) {\n manifests.push(mod.cliManifest);\n }\n } catch {\n // Plugin not installed — skip silently\n }\n }\n\n return manifests;\n}\n\n/**\n * Load ESLint rules from discovered plugins by importing their register modules.\n *\n * The register modules call `registerRuleMeta()` from `uilint-eslint`, which\n * mutates the shared `ruleRegistry` array. To avoid the dual-package problem\n * (project-resolved plugin getting a different `uilint-eslint` instance), we\n * always try a bare `import()` first — this resolves from the CLI's own\n * context so both the CLI and the plugin share the same `ruleRegistry`.\n * Only falls back to project-scoped resolution when the bare import fails\n * (e.g. when running via `npx` where plugins aren't alongside the CLI).\n *\n * @param manifests - Plugin manifests (from discoverPlugins)\n * @param resolveFrom - Optional project path to resolve plugins from.\n * @returns Array of loaded plugin package names\n */\nexport async function loadPluginESLintRules(\n manifests: PluginCLIManifest[],\n resolveFrom?: string,\n): Promise<string[]> {\n const loaded: string[] = [];\n\n for (const manifest of manifests) {\n try {\n // Prefer bare import so the register module shares the CLI's uilint-eslint\n await import(manifest.registerSpecifier);\n loaded.push(manifest.packageName);\n } catch {\n // Bare import failed — try from consumer project if a path was provided\n if (resolveFrom) {\n try {\n await importFromProject(manifest.registerSpecifier, resolveFrom);\n loaded.push(manifest.packageName);\n } catch {\n // Plugin register module not available — skip silently\n }\n }\n }\n }\n\n if (loaded.length > 0) {\n logInfo(`Loaded plugin rules: ${loaded.join(\", \")}`);\n }\n\n return loaded;\n}\n"],"mappings":";;;;;;AAWA,S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,kBAAU,KAAK,IAAI,WAAW;AAAA,MAChC;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,SAAO;AACT;AAiBA,eAAsB,sBACpB,WACA,aACmB;AACnB,QAAM,SAAmB,CAAC;AAE1B,aAAW,YAAY,WAAW;AAChC,QAAI;AAEF,YAAM,OAAO,SAAS;AACtB,aAAO,KAAK,SAAS,WAAW;AAAA,IAClC,QAAQ;AAEN,UAAI,aAAa;AACf,YAAI;AACF,gBAAM,kBAAkB,SAAS,mBAAmB,WAAW;AAC/D,iBAAO,KAAK,SAAS,WAAW;AAAA,QAClC,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,GAAG;AACrB,YAAQ,wBAAwB,OAAO,KAAK,IAAI,CAAC,EAAE;AAAA,EACrD;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
discoverPlugins,
|
|
18
18
|
loadPluginESLintRules
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GYGQ7HHN.js";
|
|
20
20
|
import {
|
|
21
21
|
createSpinner,
|
|
22
22
|
intro,
|
|
@@ -6043,7 +6043,7 @@ program.command("update").description("Update existing style guide with new styl
|
|
|
6043
6043
|
llm: options.llm
|
|
6044
6044
|
});
|
|
6045
6045
|
});
|
|
6046
|
-
var initCommand = program.command("init").description("Initialize UILint integration").option("--force", "Overwrite existing configuration files").option("--react", "Install React DevTool (non-interactive)").option("--eslint", "Install ESLint rules (non-interactive)").option("--genstyleguide", "Generate styleguide (non-interactive)").option("--skill", "Install Claude skill (non-interactive)")
|
|
6046
|
+
var initCommand = program.command("init").description("Initialize UILint integration").option("--force", "Overwrite existing configuration files").option("--react", "Install React DevTool (non-interactive)").option("--eslint", "Install ESLint rules (non-interactive)").option("--genstyleguide", "Generate styleguide (non-interactive)").option("--skill", "Install Claude skill (non-interactive)");
|
|
6047
6047
|
program.command("remove").description("Remove UILint components from your project").option("--dry-run", "Preview changes without removing anything").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
|
|
6048
6048
|
const { removeUI } = await import("./remove-ui-GZRFA2AC.js");
|
|
6049
6049
|
await removeUI({ dryRun: options.dryRun, yes: options.yes });
|
|
@@ -6102,7 +6102,7 @@ program.addCommand(createDuplicatesCommand());
|
|
|
6102
6102
|
program.addCommand(createManifestCommand());
|
|
6103
6103
|
program.addCommand(createSocketCommand());
|
|
6104
6104
|
program.command("upgrade").description("Update installed ESLint rules to latest versions").option("--check", "Show available updates without applying").option("-y, --yes", "Auto-confirm all updates").option("--dry-run", "Show what would change without modifying files").option("--rule <id>", "Upgrade only a specific rule").action(async (options) => {
|
|
6105
|
-
const { upgrade } = await import("./upgrade-
|
|
6105
|
+
const { upgrade } = await import("./upgrade-QKD7JRI7.js");
|
|
6106
6106
|
await upgrade({
|
|
6107
6107
|
check: options.check,
|
|
6108
6108
|
yes: options.yes,
|
|
@@ -6111,9 +6111,21 @@ program.command("upgrade").description("Update installed ESLint rules to latest
|
|
|
6111
6111
|
});
|
|
6112
6112
|
});
|
|
6113
6113
|
async function main() {
|
|
6114
|
-
const
|
|
6114
|
+
const core = await import("uilint-core");
|
|
6115
|
+
const KNOWN_PLUGINS = core.KNOWN_PLUGINS ?? [
|
|
6116
|
+
{ packageName: "uilint-vision" },
|
|
6117
|
+
{ packageName: "uilint-semantic" },
|
|
6118
|
+
{ packageName: "uilint-duplicates" },
|
|
6119
|
+
{ packageName: "uilint-coverage" }
|
|
6120
|
+
];
|
|
6121
|
+
const KNOWN_PLUGIN_FLAGS = [];
|
|
6122
|
+
for (const kp of KNOWN_PLUGINS) {
|
|
6123
|
+
const flag = kp.packageName.replace(/^uilint-/, "");
|
|
6124
|
+
KNOWN_PLUGIN_FLAGS.push(flag);
|
|
6125
|
+
initCommand.option(`--${flag}`, `Install ${kp.packageName} plugin`);
|
|
6126
|
+
}
|
|
6127
|
+
const { discoverPlugins: discoverPlugins2 } = await import("./plugin-loader-VTAJHQNK.js");
|
|
6115
6128
|
const pluginManifests = await discoverPlugins2();
|
|
6116
|
-
const KNOWN_PLUGIN_FLAGS = ["vision", "semantic", "duplicates", "coverage"];
|
|
6117
6129
|
for (const manifest of pluginManifests) {
|
|
6118
6130
|
if (!KNOWN_PLUGIN_FLAGS.includes(manifest.cliFlag)) {
|
|
6119
6131
|
initCommand.option(`--${manifest.cliFlag}`, manifest.cliDescription);
|
|
@@ -6125,7 +6137,7 @@ async function main() {
|
|
|
6125
6137
|
...pluginManifests.map((m) => m.cliFlag)
|
|
6126
6138
|
]);
|
|
6127
6139
|
const plugins = [...allFlags].filter((flag) => options[flag]);
|
|
6128
|
-
const { initUI } = await import("./init-ui-
|
|
6140
|
+
const { initUI } = await import("./init-ui-ATSYWDOI.js");
|
|
6129
6141
|
await initUI({
|
|
6130
6142
|
force: options.force,
|
|
6131
6143
|
react: options.react,
|