@alint-js/cli 0.2.0 → 0.3.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 +1 @@
1
- export { };
1
+ export {}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as executeCli } from "../cli-3Ov9-ZVf.mjs";
2
+ import { t as executeCli } from "../cli-C-ZS6d3a.mjs";
3
3
  import process from "node:process";
4
4
  //#region src/bin/index.ts
5
5
  executeCli(process.argv, {
@@ -11,13 +11,13 @@ import { createColors } from "tinyrainbow";
11
11
  import cliSpinners from "cli-spinners";
12
12
  import fastStringWidth from "fast-string-width";
13
13
  import { relative as relative$1 } from "node:path";
14
- import { formatDuration, intervalToDuration } from "date-fns";
15
14
  import fastStringTruncatedWidth from "fast-string-truncated-width";
15
+ import { formatDuration, intervalToDuration } from "date-fns";
16
16
  import Gitignore from "gitignore-fs";
17
17
  import { Minimatch, minimatch } from "minimatch";
18
18
  import { errorMessageFrom as errorMessageFrom$1 } from "@moeru/std";
19
19
  //#region package.json
20
- var version = "0.2.0";
20
+ var version = "0.3.0";
21
21
  //#endregion
22
22
  //#region src/cli/output.ts
23
23
  function escapeLineValue(value) {
@@ -969,7 +969,8 @@ async function runPruneModelsCommand(context, options, confirm = confirmPruneMod
969
969
  }
970
970
  if (await confirm() !== "confirmed") return 1;
971
971
  }
972
- await writeSetupConfig(path, applyPlans(config, plans));
972
+ const nextConfig = applyPlans(config, plans);
973
+ await writeSetupConfig(path, nextConfig);
973
974
  return hadFailure ? 2 : 0;
974
975
  }
975
976
  function applyPlans(config, plans) {
@@ -1119,7 +1120,8 @@ async function runRemoveModelCommand(context, request, options) {
1119
1120
  context.io.stderr.write(`cannot remove default model "${escapeLineValue(target.provider.id)}/${escapeLineValue(target.model.id)}". select another default first.\n`);
1120
1121
  return 2;
1121
1122
  }
1122
- await writeSetupConfig(path, removeProviderModels(config, target.provider.id, /* @__PURE__ */ new Set([target.model.id])));
1123
+ const nextConfig = removeProviderModels(config, target.provider.id, /* @__PURE__ */ new Set([target.model.id]));
1124
+ await writeSetupConfig(path, nextConfig);
1123
1125
  context.io.stdout.write(`removed model: ${escapeLineValue(target.provider.id)}/${escapeLineValue(target.model.id)}\nscope: ${scope}\n`);
1124
1126
  return 0;
1125
1127
  }
@@ -1343,7 +1345,8 @@ async function runUnsetProviderCommand(context, key, options) {
1343
1345
  context.io.stderr.write("invalid provider header name. expected an HTTP field-name token.\n");
1344
1346
  return 2;
1345
1347
  }
1346
- await writeSetupConfig(path, unsetProviderHeader(config, providerId, headerName));
1348
+ const nextConfig = unsetProviderHeader(config, providerId, headerName);
1349
+ await writeSetupConfig(path, nextConfig);
1347
1350
  context.io.stdout.write(`provider: ${escapeLineValue(providerId)}\nkey: ${escapeLineValue(key)}\nscope: ${scope}\n`);
1348
1351
  return 0;
1349
1352
  }
@@ -1888,7 +1891,10 @@ async function runNonInteractiveUpdate(context, options, providerEndpoint, exist
1888
1891
  context.io.stderr.write(`failed to probe provider: ${errorMessageFrom(error) ?? "Unknown error."}\n`);
1889
1892
  return 2;
1890
1893
  }
1891
- await writeSetupConfig(path, addProviderModels(addProviderModels(replaceSetupProvider(config, draft), draft.id, remoteModelIds), draft.id, toArray$1(options.providerModel)));
1894
+ const replaced = replaceSetupProvider(config, draft);
1895
+ const withRemoteModels = addProviderModels(replaced, draft.id, remoteModelIds);
1896
+ const nextConfig = addProviderModels(withRemoteModels, draft.id, toArray$1(options.providerModel));
1897
+ await writeSetupConfig(path, nextConfig);
1892
1898
  return 0;
1893
1899
  }
1894
1900
  /**
@@ -1938,7 +1944,8 @@ async function runUpdateProviderCommand(context, options) {
1938
1944
  });
1939
1945
  if (result.status !== "confirmed") return 0;
1940
1946
  const replaced = replaceSetupProvider(config, result.provider);
1941
- await writeSetupConfig(path, result.defaultAliasTarget === void 0 ? replaced : applyDefaultAlias(replaced, result.defaultAliasTarget));
1947
+ const nextConfig = result.defaultAliasTarget === void 0 ? replaced : applyDefaultAlias(replaced, result.defaultAliasTarget);
1948
+ await writeSetupConfig(path, nextConfig);
1942
1949
  return 0;
1943
1950
  }
1944
1951
  function scalarOption(value, flag) {
@@ -2819,6 +2826,10 @@ function formatFailureGroups(groups, color) {
2819
2826
  for (const failure of group) {
2820
2827
  lines.push(` ${formatTarget(failure)}`);
2821
2828
  lines.push(` [${failure.kind}] ${failure.message}`);
2829
+ for (const cause of failure.causes) {
2830
+ const code = cause.code === void 0 ? "" : `[${cause.code}] `;
2831
+ lines.push(` Caused by: ${code}${cause.message}`);
2832
+ }
2822
2833
  }
2823
2834
  lines.push("");
2824
2835
  }
@@ -2935,7 +2946,7 @@ const UNIT_MS = {
2935
2946
  h: HOUR_MS,
2936
2947
  m: 720 * HOUR_MS,
2937
2948
  w: 168 * HOUR_MS,
2938
- y: 365 * 24 * HOUR_MS
2949
+ y: 8760 * HOUR_MS
2939
2950
  };
2940
2951
  function parseSince(time, now) {
2941
2952
  if (time === void 0 || time === "") return;
@@ -3690,7 +3701,8 @@ async function runInteractiveSetup(io) {
3690
3701
  providers: [result.provider],
3691
3702
  version: 1
3692
3703
  });
3693
- await writeSetupConfig(configPath, result.defaultAliasTarget === void 0 ? merged : applyDefaultAlias(merged, result.defaultAliasTarget));
3704
+ const nextConfig = result.defaultAliasTarget === void 0 ? merged : applyDefaultAlias(merged, result.defaultAliasTarget);
3705
+ await writeSetupConfig(configPath, nextConfig);
3694
3706
  prompts.outro(`Wrote ${configPath}`);
3695
3707
  return 0;
3696
3708
  }
@@ -3770,7 +3782,9 @@ async function runSetupCommand(options, io) {
3770
3782
  return 2;
3771
3783
  }
3772
3784
  const setupConfigPath = options.local ? getProjectSetupConfigPath(io.cwd) : getGlobalSetupConfigPath(io.env ?? process.env);
3773
- await writeSetupConfig(setupConfigPath, mergeSetupConfigs(await loadSetupConfig(setupConfigPath), createSetupConfig(options.providerId, options.providerEndpoint, options)));
3785
+ const existingConfig = await loadSetupConfig(setupConfigPath);
3786
+ const nextConfig = mergeSetupConfigs(existingConfig, createSetupConfig(options.providerId, options.providerEndpoint, options));
3787
+ await writeSetupConfig(setupConfigPath, nextConfig);
3774
3788
  return 0;
3775
3789
  }
3776
3790
  function toArray(value) {
@@ -3969,13 +3983,13 @@ function renderVertical(buckets, values, maxValue, axisWidth, ctx) {
3969
3983
  });
3970
3984
  const gutter = " ".repeat(axisWidth);
3971
3985
  const lines = [];
3972
- for (let row = CHART_HEIGHT - 1; row >= 0; row -= 1) {
3986
+ for (let row = 5; row >= 0; row -= 1) {
3973
3987
  const cells = Array.from({ length: chartWidth }).fill(" ");
3974
3988
  eighths.forEach((total, index) => {
3975
3989
  cells[columnAt(index)] = VERTICAL_BLOCKS[Math.max(0, Math.min(8, total - row * 8))];
3976
3990
  });
3977
- const label = row === CHART_HEIGHT - 1 ? formatMetricValue(maxValue, ctx.metric, ctx.exact).padStart(axisWidth) : gutter;
3978
- const axis = row === CHART_HEIGHT - 1 ? "┤" : "│";
3991
+ const label = row === 5 ? formatMetricValue(maxValue, ctx.metric, ctx.exact).padStart(axisWidth) : gutter;
3992
+ const axis = row === 5 ? "┤" : "│";
3979
3993
  lines.push(`${label} ${axis}${ctx.paint(cells.join("").replace(/\s+$/u, ""), colors.cyan)}`);
3980
3994
  }
3981
3995
  const baseline = Array.from({ length: chartWidth }).fill("─");
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-3Ov9-ZVf.mjs";
1
+ import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-C-ZS6d3a.mjs";
2
2
  import { ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated } from "@alint-js/config";
3
3
  import { defineConfig } from "@alint-js/core";
4
4
  export { defineConfig, executeCli, formatDiagnostics, formatJson, formatStylish, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alint-js/cli",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.mts",
@@ -24,12 +24,12 @@
24
24
  "fast-string-truncated-width": "^3.0.3",
25
25
  "fast-string-width": "^3.0.2",
26
26
  "gitignore-fs": "^2.2.3",
27
- "minimatch": "^10.2.5",
27
+ "minimatch": "^10.2.6",
28
28
  "pathe": "^2.0.3",
29
29
  "table": "^6.9.0",
30
- "tinyrainbow": "^3.1.0",
31
- "@alint-js/config": "0.2.0",
32
- "@alint-js/core": "0.2.0"
30
+ "tinyrainbow": "^3.1.1",
31
+ "@alint-js/core": "0.3.0",
32
+ "@alint-js/config": "0.3.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@pnpm/find-workspace-dir": "^1000.1.5",