@xylabs/ts-scripts-yarn3 5.1.2 → 5.1.3

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.
@@ -897,19 +897,96 @@ var dupdeps = /* @__PURE__ */ __name(() => {
897
897
  return detectDuplicateDependencies(dependencies);
898
898
  }, "dupdeps");
899
899
 
900
- // src/actions/fix.ts
901
- var fix = /* @__PURE__ */ __name(() => {
902
- return runSteps("Fix", [
900
+ // src/actions/lint.ts
901
+ import chalk13 from "chalk";
902
+ import { ESLint as ESLint2 } from "eslint";
903
+ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
904
+ const colors = [
905
+ "white",
906
+ "yellow",
907
+ "red"
908
+ ];
909
+ const severity = [
910
+ "none",
911
+ "warning",
912
+ "error"
913
+ ];
914
+ for (const lintResult of lintResults) {
915
+ if (lintResult.messages.length > 0) {
916
+ console.log(chalk13.gray(`${lintResult.filePath}`));
917
+ for (const message of lintResult.messages) {
918
+ console.log(chalk13.gray(` ${message.line}:${message.column}`), chalk13[colors[message.severity]](` ${severity[message.severity]}`), chalk13.white(` ${message.message}`), chalk13.gray(` ${message.ruleId}`));
919
+ }
920
+ }
921
+ }
922
+ }, "dumpMessages");
923
+ var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
924
+ const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
925
+ if (!workspace) {
926
+ console.error(chalk13.red(`Unable to locate package [${chalk13.magenta(pkg)}]`));
927
+ process.exit(1);
928
+ }
929
+ const engine = new ESLint2({
930
+ cache: true,
931
+ fix: fix2
932
+ });
933
+ const lintResults = await engine.lintFiles(workspace.location);
934
+ dumpMessages(lintResults);
935
+ return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
936
+ }, "lintPackage");
937
+ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
938
+ return pkg ? await lintPackage({
939
+ pkg,
940
+ fix: fix2
941
+ }) : lintAllPackages({
942
+ verbose,
943
+ incremental,
944
+ fix: fix2
945
+ });
946
+ }, "lint");
947
+ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
948
+ console.log(chalk13.gray("Linting [All-Packages]"));
949
+ const start = Date.now();
950
+ const verboseOptions = verbose ? [
951
+ "--verbose"
952
+ ] : [
953
+ "--no-verbose"
954
+ ];
955
+ const fixOptions = fix2 ? [
956
+ "--fix"
957
+ ] : [
958
+ ""
959
+ ];
960
+ const incrementalOptions = incremental ? [
961
+ "--since",
962
+ "-Apt"
963
+ ] : [
964
+ "--parallel",
965
+ "-Apt"
966
+ ];
967
+ const result = runSteps("Lint [All-Packages]", [
903
968
  [
904
969
  "yarn",
905
970
  [
906
- "eslint",
907
- ".",
908
- "--fix",
909
- "--cache"
971
+ "workspaces",
972
+ "foreach",
973
+ ...verboseOptions,
974
+ ...incrementalOptions,
975
+ "run",
976
+ "package-lint",
977
+ ...fixOptions
910
978
  ]
911
979
  ]
912
980
  ]);
981
+ console.log(`${chalk13.gray("Linted in")} [${chalk13.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk13.gray("seconds")}`);
982
+ return result;
983
+ }, "lintAllPackages");
984
+
985
+ // src/actions/fix.ts
986
+ var fix = /* @__PURE__ */ __name(async () => {
987
+ return await lint({
988
+ fix: true
989
+ });
913
990
  }, "fix");
914
991
 
915
992
  // src/actions/gen-docs.ts
@@ -965,7 +1042,7 @@ var filename = ".gitignore";
965
1042
  var gitignoreGen = /* @__PURE__ */ __name((pkg) => generateIgnoreFiles(filename, pkg), "gitignoreGen");
966
1043
 
967
1044
  // src/actions/gitlint.ts
968
- import chalk13 from "chalk";
1045
+ import chalk14 from "chalk";
969
1046
  import ParseGitConfig from "parse-git-config";
970
1047
  var gitlint = /* @__PURE__ */ __name(() => {
971
1048
  console.log(`
@@ -976,7 +1053,7 @@ Gitlint Start [${process.cwd()}]
976
1053
  const errors = 0;
977
1054
  const gitConfig = ParseGitConfig.sync();
978
1055
  const warn = /* @__PURE__ */ __name((message) => {
979
- console.warn(chalk13.yellow(`Warning: ${message}`));
1056
+ console.warn(chalk14.yellow(`Warning: ${message}`));
980
1057
  warnings++;
981
1058
  }, "warn");
982
1059
  if (gitConfig.core.ignorecase) {
@@ -996,13 +1073,13 @@ Gitlint Start [${process.cwd()}]
996
1073
  }
997
1074
  const resultMessages = [];
998
1075
  if (valid > 0) {
999
- resultMessages.push(chalk13.green(`Passed: ${valid}`));
1076
+ resultMessages.push(chalk14.green(`Passed: ${valid}`));
1000
1077
  }
1001
1078
  if (warnings > 0) {
1002
- resultMessages.push(chalk13.yellow(`Warnings: ${warnings}`));
1079
+ resultMessages.push(chalk14.yellow(`Warnings: ${warnings}`));
1003
1080
  }
1004
1081
  if (errors > 0) {
1005
- resultMessages.push(chalk13.red(` Errors: ${errors}`));
1082
+ resultMessages.push(chalk14.red(` Errors: ${errors}`));
1006
1083
  }
1007
1084
  console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
1008
1085
  `);
@@ -1011,7 +1088,7 @@ Gitlint Start [${process.cwd()}]
1011
1088
 
1012
1089
  // src/actions/gitlint-fix.ts
1013
1090
  import { execSync as execSync2 } from "node:child_process";
1014
- import chalk14 from "chalk";
1091
+ import chalk15 from "chalk";
1015
1092
  import ParseGitConfig2 from "parse-git-config";
1016
1093
  var gitlintFix = /* @__PURE__ */ __name(() => {
1017
1094
  console.log(`
@@ -1022,25 +1099,25 @@ Gitlint Fix Start [${process.cwd()}]
1022
1099
  execSync2("git config core.ignorecase false", {
1023
1100
  stdio: "inherit"
1024
1101
  });
1025
- console.warn(chalk14.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
1102
+ console.warn(chalk15.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
1026
1103
  }
1027
1104
  if (gitConfig.core.autocrlf !== false) {
1028
1105
  execSync2("git config core.autocrlf false", {
1029
1106
  stdio: "inherit"
1030
1107
  });
1031
- console.warn(chalk14.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
1108
+ console.warn(chalk15.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
1032
1109
  }
1033
1110
  if (gitConfig.core.eol !== "lf") {
1034
1111
  execSync2("git config core.eol lf", {
1035
1112
  stdio: "inherit"
1036
1113
  });
1037
- console.warn(chalk14.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
1114
+ console.warn(chalk15.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
1038
1115
  }
1039
1116
  return 1;
1040
1117
  }, "gitlintFix");
1041
1118
 
1042
1119
  // src/actions/license.ts
1043
- import chalk15 from "chalk";
1120
+ import chalk16 from "chalk";
1044
1121
  import { init } from "license-checker";
1045
1122
  var license = /* @__PURE__ */ __name(async (pkg) => {
1046
1123
  const workspaces = yarnWorkspaces();
@@ -1065,7 +1142,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1065
1142
  "LGPL-3.0-or-later",
1066
1143
  "Python-2.0"
1067
1144
  ]);
1068
- console.log(chalk15.green("License Checker"));
1145
+ console.log(chalk16.green("License Checker"));
1069
1146
  return (await Promise.all(workspaceList.map(({ location, name }) => {
1070
1147
  return new Promise((resolve) => {
1071
1148
  init({
@@ -1073,12 +1150,12 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1073
1150
  start: location
1074
1151
  }, (error, packages) => {
1075
1152
  if (error) {
1076
- console.error(chalk15.red(`License Checker [${name}] Error`));
1077
- console.error(chalk15.gray(error));
1153
+ console.error(chalk16.red(`License Checker [${name}] Error`));
1154
+ console.error(chalk16.gray(error));
1078
1155
  console.log("\n");
1079
1156
  resolve(1);
1080
1157
  } else {
1081
- console.log(chalk15.green(`License Checker [${name}]`));
1158
+ console.log(chalk16.green(`License Checker [${name}]`));
1082
1159
  let count = 0;
1083
1160
  for (const [name2, info] of Object.entries(packages)) {
1084
1161
  const licenses = Array.isArray(info.licenses) ? info.licenses : [
@@ -1096,7 +1173,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1096
1173
  }
1097
1174
  if (!orLicenseFound) {
1098
1175
  count++;
1099
- console.warn(chalk15.yellow(`${name2}: Package License not allowed [${license2}]`));
1176
+ console.warn(chalk16.yellow(`${name2}: Package License not allowed [${license2}]`));
1100
1177
  }
1101
1178
  }
1102
1179
  }
@@ -1109,91 +1186,6 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1109
1186
  }))).reduce((prev, value) => prev || value, 0);
1110
1187
  }, "license");
1111
1188
 
1112
- // src/actions/lint.ts
1113
- import chalk16 from "chalk";
1114
- import { ESLint as ESLint2 } from "eslint";
1115
- var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
1116
- const colors = [
1117
- "white",
1118
- "yellow",
1119
- "red"
1120
- ];
1121
- const severity = [
1122
- "none",
1123
- "warning",
1124
- "error"
1125
- ];
1126
- for (const lintResult of lintResults) {
1127
- if (lintResult.messages.length > 0) {
1128
- console.log(chalk16.gray(`${lintResult.filePath}`));
1129
- for (const message of lintResult.messages) {
1130
- console.log(chalk16.gray(` ${message.line}:${message.column}`), chalk16[colors[message.severity]](` ${severity[message.severity]}`), chalk16.white(` ${message.message}`), chalk16.gray(` ${message.ruleId}`));
1131
- }
1132
- }
1133
- }
1134
- }, "dumpMessages");
1135
- var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
1136
- const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
1137
- if (!workspace) {
1138
- console.error(chalk16.red(`Unable to locate package [${chalk16.magenta(pkg)}]`));
1139
- process.exit(1);
1140
- }
1141
- const engine = new ESLint2({
1142
- cache: true,
1143
- fix: fix2
1144
- });
1145
- const lintResults = await engine.lintFiles(workspace.location);
1146
- dumpMessages(lintResults);
1147
- return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1148
- }, "lintPackage");
1149
- var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
1150
- return pkg ? await lintPackage({
1151
- pkg,
1152
- fix: fix2
1153
- }) : lintAllPackages({
1154
- verbose,
1155
- incremental,
1156
- fix: fix2
1157
- });
1158
- }, "lint");
1159
- var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
1160
- console.log(chalk16.gray("Linting [All-Packages]"));
1161
- const start = Date.now();
1162
- const verboseOptions = verbose ? [
1163
- "--verbose"
1164
- ] : [
1165
- "--no-verbose"
1166
- ];
1167
- const fixOptions = fix2 ? [
1168
- "--fix"
1169
- ] : [
1170
- ""
1171
- ];
1172
- const incrementalOptions = incremental ? [
1173
- "--since",
1174
- "-Apt"
1175
- ] : [
1176
- "--parallel",
1177
- "-Apt"
1178
- ];
1179
- const result = runSteps("Lint [All-Packages]", [
1180
- [
1181
- "yarn",
1182
- [
1183
- "workspaces",
1184
- "foreach",
1185
- ...verboseOptions,
1186
- ...incrementalOptions,
1187
- "run",
1188
- "package-lint",
1189
- ...fixOptions
1190
- ]
1191
- ]
1192
- ]);
1193
- console.log(`${chalk16.gray("Linted in")} [${chalk16.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk16.gray("seconds")}`);
1194
- return result;
1195
- }, "lintAllPackages");
1196
-
1197
1189
  // src/actions/lint-profile.ts
1198
1190
  var lintProfile = /* @__PURE__ */ __name(() => {
1199
1191
  return runSteps("Lint Profile", [
@@ -1833,16 +1825,16 @@ var xyLintCommands = /* @__PURE__ */ __name((args) => {
1833
1825
  }, async (argv) => {
1834
1826
  if (argv.verbose) console.log("Lint");
1835
1827
  const start = Date.now();
1836
- process.exitCode = argv.fix ? fix() : argv.profile ? lintProfile() : await lint({
1828
+ process.exitCode = argv.fix ? await fix() : argv.profile ? lintProfile() : await lint({
1837
1829
  pkg: argv.package
1838
1830
  });
1839
1831
  console.log(chalk19.blue(`Finished in ${Date.now() - start}ms`));
1840
1832
  }).command("fix [package]", "Fix - Run Eslint w/fix", (yargs2) => {
1841
1833
  return packagePositionalParam(yargs2);
1842
- }, (argv) => {
1834
+ }, async (argv) => {
1843
1835
  const start = Date.now();
1844
1836
  if (argv.verbose) console.log("Fix");
1845
- process.exitCode = fix();
1837
+ process.exitCode = await fix();
1846
1838
  console.log(chalk19.blue(`Finished in ${Date.now() - start}ms`));
1847
1839
  }).command("relint [package]", "Relint - Clean & Lint", (yargs2) => {
1848
1840
  return packagePositionalParam(yargs2);