uilint 0.2.11 → 0.2.13

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.
@@ -7,8 +7,9 @@ import {
7
7
  multiselect,
8
8
  note,
9
9
  pc,
10
+ printBox,
10
11
  select
11
- } from "./chunk-FRNXXIEM.js";
12
+ } from "./chunk-EYCSOCU4.js";
12
13
  import {
13
14
  GENSTYLEGUIDE_COMMAND_MD,
14
15
  loadSkill
@@ -1046,6 +1047,23 @@ function findPackages(rootDir, options) {
1046
1047
  import { existsSync as existsSync3 } from "fs";
1047
1048
  import { spawn } from "child_process";
1048
1049
  import { dirname, join as join3 } from "path";
1050
+ function detectExecutionPackageManager() {
1051
+ const userAgent = process.env.npm_config_user_agent;
1052
+ if (userAgent) {
1053
+ if (userAgent.startsWith("pnpm/")) return "pnpm";
1054
+ if (userAgent.startsWith("yarn/")) return "yarn";
1055
+ if (userAgent.startsWith("bun/")) return "bun";
1056
+ if (userAgent.startsWith("npm/")) return "npm";
1057
+ }
1058
+ const execPath = process.env.npm_execpath;
1059
+ if (execPath) {
1060
+ if (execPath.includes("pnpm")) return "pnpm";
1061
+ if (execPath.includes("yarn")) return "yarn";
1062
+ if (execPath.includes("bun")) return "bun";
1063
+ if (execPath.includes("npm")) return "npm";
1064
+ }
1065
+ return null;
1066
+ }
1049
1067
  function detectPackageManager(projectPath) {
1050
1068
  let dir = projectPath;
1051
1069
  for (; ; ) {
@@ -1571,18 +1589,8 @@ async function installEslintPlugin(opts) {
1571
1589
  const workspaceRoot = findWorkspaceRoot(opts.projectPath);
1572
1590
  const workspaceRulesDir = join4(workspaceRoot, ".uilint", "rules");
1573
1591
  const rulesRoot = existsSync4(localRulesDir) ? opts.projectPath : workspaceRoot;
1574
- let fileExtension = ".js";
1575
- if (rulesToApply.length > 0) {
1576
- const firstRulePath = join4(
1577
- rulesRoot,
1578
- ".uilint",
1579
- "rules",
1580
- `${rulesToApply[0].id}.ts`
1581
- );
1582
- if (existsSync4(firstRulePath)) {
1583
- fileExtension = ".ts";
1584
- }
1585
- }
1592
+ const isTypeScriptConfig = configPath.endsWith(".ts");
1593
+ let fileExtension = isTypeScriptConfig ? "" : ".js";
1586
1594
  let ruleImportNames;
1587
1595
  if (kind === "esm") {
1588
1596
  const result = addLocalRuleImportsAst(
@@ -3363,6 +3371,8 @@ async function execute(plan, options = {}) {
3363
3371
 
3364
3372
  // src/commands/install-ui.tsx
3365
3373
  import { ruleRegistry as ruleRegistry3 } from "uilint-eslint";
3374
+ import { existsSync as existsSync13 } from "fs";
3375
+ import { join as join14 } from "path";
3366
3376
 
3367
3377
  // src/commands/install/installers/genstyleguide.ts
3368
3378
  import { join as join11 } from "path";
@@ -3963,6 +3973,56 @@ function selectionsToUserChoices(selections, project, eslintRules) {
3963
3973
  function isInteractiveTerminal() {
3964
3974
  return Boolean(process.stdin.isTTY && process.stdout.isTTY);
3965
3975
  }
3976
+ function getRecommendedCommand(pm) {
3977
+ switch (pm) {
3978
+ case "pnpm":
3979
+ return "pnpm dlx uilint install";
3980
+ case "yarn":
3981
+ return "yarn dlx uilint install";
3982
+ case "bun":
3983
+ return "bunx uilint install";
3984
+ case "npm":
3985
+ default:
3986
+ return "npx uilint install";
3987
+ }
3988
+ }
3989
+ async function warnOnPackageManagerMismatch(projectPromise) {
3990
+ const executionPm = detectExecutionPackageManager();
3991
+ if (!executionPm) return;
3992
+ const project = await projectPromise;
3993
+ const packageManagers = /* @__PURE__ */ new Set();
3994
+ const hasRootPackageJson = existsSync13(join14(project.projectPath, "package.json"));
3995
+ if (hasRootPackageJson) {
3996
+ packageManagers.add(project.packageManager);
3997
+ } else {
3998
+ for (const pkg of project.packages) {
3999
+ const pm = detectPackageManager(pkg.path);
4000
+ packageManagers.add(pm);
4001
+ }
4002
+ }
4003
+ const specificPackageManagers = Array.from(packageManagers).filter(
4004
+ (pm) => pm !== "npm" || hasRootPackageJson
4005
+ );
4006
+ if (specificPackageManagers.length === 0) return;
4007
+ if (specificPackageManagers.includes(executionPm)) return;
4008
+ const primaryPm = specificPackageManagers[0];
4009
+ const recommendedCmd = getRecommendedCommand(primaryPm);
4010
+ const pmList = specificPackageManagers.length === 1 ? specificPackageManagers[0] : specificPackageManagers.join(", ");
4011
+ printBox(
4012
+ "Package manager mismatch detected",
4013
+ [
4014
+ `This project uses ${pmList}, but you ran this command with ${executionPm}.`,
4015
+ "",
4016
+ `Running with ${executionPm} may create unwanted lockfiles.`,
4017
+ "",
4018
+ "Recommended:",
4019
+ ` ${recommendedCmd}`,
4020
+ "",
4021
+ "Continuing anyway..."
4022
+ ],
4023
+ "warning"
4024
+ );
4025
+ }
3966
4026
  async function installUI(options = {}, executeOptions = {}) {
3967
4027
  const projectPath = process.cwd();
3968
4028
  if (!isInteractiveTerminal()) {
@@ -3971,6 +4031,7 @@ async function installUI(options = {}, executeOptions = {}) {
3971
4031
  process.exit(1);
3972
4032
  }
3973
4033
  const projectPromise = analyze(projectPath);
4034
+ await warnOnPackageManagerMismatch(projectPromise);
3974
4035
  const { waitUntilExit } = render(
3975
4036
  /* @__PURE__ */ jsx6(
3976
4037
  InstallApp,
@@ -4008,4 +4069,4 @@ async function installUI(options = {}, executeOptions = {}) {
4008
4069
  export {
4009
4070
  installUI
4010
4071
  };
4011
- //# sourceMappingURL=install-ui-KI7YHOVZ.js.map
4072
+ //# sourceMappingURL=install-ui-ITXPOUVQ.js.map