uilint 0.2.11 → 0.2.12

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(
@@ -3963,6 +3971,41 @@ function selectionsToUserChoices(selections, project, eslintRules) {
3963
3971
  function isInteractiveTerminal() {
3964
3972
  return Boolean(process.stdin.isTTY && process.stdout.isTTY);
3965
3973
  }
3974
+ function getRecommendedCommand(pm) {
3975
+ switch (pm) {
3976
+ case "pnpm":
3977
+ return "pnpm dlx uilint install";
3978
+ case "yarn":
3979
+ return "yarn dlx uilint install";
3980
+ case "bun":
3981
+ return "bunx uilint install";
3982
+ case "npm":
3983
+ default:
3984
+ return "npx uilint install";
3985
+ }
3986
+ }
3987
+ async function warnOnPackageManagerMismatch(projectPromise) {
3988
+ const executionPm = detectExecutionPackageManager();
3989
+ if (!executionPm) return;
3990
+ const project = await projectPromise;
3991
+ const projectPm = project.packageManager;
3992
+ if (executionPm === projectPm) return;
3993
+ const recommendedCmd = getRecommendedCommand(projectPm);
3994
+ printBox(
3995
+ "Package manager mismatch detected",
3996
+ [
3997
+ `This project uses ${projectPm}, but you ran this command with ${executionPm}.`,
3998
+ "",
3999
+ `This may create unwanted lockfiles (e.g., package-lock.json).`,
4000
+ "",
4001
+ "Recommended:",
4002
+ ` ${recommendedCmd}`,
4003
+ "",
4004
+ "Continuing anyway..."
4005
+ ],
4006
+ "warning"
4007
+ );
4008
+ }
3966
4009
  async function installUI(options = {}, executeOptions = {}) {
3967
4010
  const projectPath = process.cwd();
3968
4011
  if (!isInteractiveTerminal()) {
@@ -3971,6 +4014,7 @@ async function installUI(options = {}, executeOptions = {}) {
3971
4014
  process.exit(1);
3972
4015
  }
3973
4016
  const projectPromise = analyze(projectPath);
4017
+ await warnOnPackageManagerMismatch(projectPromise);
3974
4018
  const { waitUntilExit } = render(
3975
4019
  /* @__PURE__ */ jsx6(
3976
4020
  InstallApp,
@@ -4008,4 +4052,4 @@ async function installUI(options = {}, executeOptions = {}) {
4008
4052
  export {
4009
4053
  installUI
4010
4054
  };
4011
- //# sourceMappingURL=install-ui-KI7YHOVZ.js.map
4055
+ //# sourceMappingURL=install-ui-LK7HD2IM.js.map