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