@xylabs/ts-scripts-yarn3 5.1.2 → 5.1.4

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/index.d.ts CHANGED
@@ -81,7 +81,7 @@ declare const depsAll: ({ incremental, jobs, verbose, }: DepsParams) => number;
81
81
 
82
82
  declare const dupdeps: () => number;
83
83
 
84
- declare const fix: () => number;
84
+ declare const fix: () => Promise<number>;
85
85
 
86
86
  interface GenDocsParams {
87
87
  incremental?: boolean;
@@ -113,7 +113,7 @@ interface LintPackageParams {
113
113
  verbose?: boolean;
114
114
  }
115
115
  declare const lintPackage: ({ pkg, fix }: LintParams) => Promise<number>;
116
- declare const lintAll: ({ fix }: LintParams) => Promise<void>;
116
+ declare const lintAll: ({ fix }: LintParams) => Promise<number>;
117
117
  declare const lint: ({ pkg, verbose, incremental, fix, }?: LintParams) => Promise<number>;
118
118
  declare const lintAllPackages: ({ fix, verbose, incremental, }?: LintParams) => number;
119
119
 
package/dist/index.mjs CHANGED
@@ -1007,19 +1007,103 @@ var dupdeps = /* @__PURE__ */ __name(() => {
1007
1007
  return detectDuplicateDependencies(dependencies);
1008
1008
  }, "dupdeps");
1009
1009
 
1010
- // src/actions/fix.ts
1011
- var fix = /* @__PURE__ */ __name(() => {
1012
- return runSteps("Fix", [
1010
+ // src/actions/lint.ts
1011
+ import chalk15 from "chalk";
1012
+ import { ESLint as ESLint2 } from "eslint";
1013
+ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
1014
+ const colors = [
1015
+ "white",
1016
+ "yellow",
1017
+ "red"
1018
+ ];
1019
+ const severity = [
1020
+ "none",
1021
+ "warning",
1022
+ "error"
1023
+ ];
1024
+ for (const lintResult of lintResults) {
1025
+ if (lintResult.messages.length > 0) {
1026
+ console.log(chalk15.gray(`${lintResult.filePath}`));
1027
+ for (const message of lintResult.messages) {
1028
+ console.log(chalk15.gray(` ${message.line}:${message.column}`), chalk15[colors[message.severity]](` ${severity[message.severity]}`), chalk15.white(` ${message.message}`), chalk15.gray(` ${message.ruleId}`));
1029
+ }
1030
+ }
1031
+ }
1032
+ }, "dumpMessages");
1033
+ var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
1034
+ const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
1035
+ if (!workspace) {
1036
+ console.error(chalk15.red(`Unable to locate package [${chalk15.magenta(pkg)}]`));
1037
+ process.exit(1);
1038
+ }
1039
+ const engine = new ESLint2({
1040
+ cache: true,
1041
+ fix: fix2
1042
+ });
1043
+ const lintResults = await engine.lintFiles(workspace.location);
1044
+ dumpMessages(lintResults);
1045
+ return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1046
+ }, "lintPackage");
1047
+ var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
1048
+ const workspace = yarnWorkspaces();
1049
+ return (await Promise.all(workspace.map((ws) => lintPackage({
1050
+ pkg: ws.name,
1051
+ fix: fix2
1052
+ })))).reduce((prev, curr) => prev + curr, 0);
1053
+ }, "lintAll");
1054
+ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
1055
+ return pkg ? await lintPackage({
1056
+ pkg,
1057
+ fix: fix2
1058
+ }) : lintAll({
1059
+ verbose,
1060
+ incremental,
1061
+ fix: fix2
1062
+ });
1063
+ }, "lint");
1064
+ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
1065
+ console.log(chalk15.gray("Linting [All-Packages]"));
1066
+ const start = Date.now();
1067
+ const verboseOptions = verbose ? [
1068
+ "--verbose"
1069
+ ] : [
1070
+ "--no-verbose"
1071
+ ];
1072
+ const fixOptions = fix2 ? [
1073
+ "--fix"
1074
+ ] : [
1075
+ ""
1076
+ ];
1077
+ const incrementalOptions = incremental ? [
1078
+ "--since",
1079
+ "-Apt"
1080
+ ] : [
1081
+ "--parallel",
1082
+ "-Apt"
1083
+ ];
1084
+ const result = runSteps("Lint [All-Packages]", [
1013
1085
  [
1014
1086
  "yarn",
1015
1087
  [
1016
- "eslint",
1017
- ".",
1018
- "--fix",
1019
- "--cache"
1088
+ "workspaces",
1089
+ "foreach",
1090
+ ...verboseOptions,
1091
+ ...incrementalOptions,
1092
+ "run",
1093
+ "package-lint",
1094
+ ...fixOptions
1020
1095
  ]
1021
1096
  ]
1022
1097
  ]);
1098
+ console.log(`${chalk15.gray("Linted in")} [${chalk15.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk15.gray("seconds")}`);
1099
+ return result;
1100
+ }, "lintAllPackages");
1101
+
1102
+ // src/actions/fix.ts
1103
+ var fix = /* @__PURE__ */ __name(async () => {
1104
+ return await lint({
1105
+ fix: true
1106
+ });
1023
1107
  }, "fix");
1024
1108
 
1025
1109
  // src/actions/gen-docs.ts
@@ -1075,7 +1159,7 @@ var filename = ".gitignore";
1075
1159
  var gitignoreGen = /* @__PURE__ */ __name((pkg) => generateIgnoreFiles(filename, pkg), "gitignoreGen");
1076
1160
 
1077
1161
  // src/actions/gitlint.ts
1078
- import chalk15 from "chalk";
1162
+ import chalk16 from "chalk";
1079
1163
  import ParseGitConfig from "parse-git-config";
1080
1164
  var gitlint = /* @__PURE__ */ __name(() => {
1081
1165
  console.log(`
@@ -1086,7 +1170,7 @@ Gitlint Start [${process.cwd()}]
1086
1170
  const errors = 0;
1087
1171
  const gitConfig = ParseGitConfig.sync();
1088
1172
  const warn = /* @__PURE__ */ __name((message) => {
1089
- console.warn(chalk15.yellow(`Warning: ${message}`));
1173
+ console.warn(chalk16.yellow(`Warning: ${message}`));
1090
1174
  warnings++;
1091
1175
  }, "warn");
1092
1176
  if (gitConfig.core.ignorecase) {
@@ -1106,13 +1190,13 @@ Gitlint Start [${process.cwd()}]
1106
1190
  }
1107
1191
  const resultMessages = [];
1108
1192
  if (valid > 0) {
1109
- resultMessages.push(chalk15.green(`Passed: ${valid}`));
1193
+ resultMessages.push(chalk16.green(`Passed: ${valid}`));
1110
1194
  }
1111
1195
  if (warnings > 0) {
1112
- resultMessages.push(chalk15.yellow(`Warnings: ${warnings}`));
1196
+ resultMessages.push(chalk16.yellow(`Warnings: ${warnings}`));
1113
1197
  }
1114
1198
  if (errors > 0) {
1115
- resultMessages.push(chalk15.red(` Errors: ${errors}`));
1199
+ resultMessages.push(chalk16.red(` Errors: ${errors}`));
1116
1200
  }
1117
1201
  console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
1118
1202
  `);
@@ -1121,7 +1205,7 @@ Gitlint Start [${process.cwd()}]
1121
1205
 
1122
1206
  // src/actions/gitlint-fix.ts
1123
1207
  import { execSync as execSync2 } from "node:child_process";
1124
- import chalk16 from "chalk";
1208
+ import chalk17 from "chalk";
1125
1209
  import ParseGitConfig2 from "parse-git-config";
1126
1210
  var gitlintFix = /* @__PURE__ */ __name(() => {
1127
1211
  console.log(`
@@ -1132,25 +1216,25 @@ Gitlint Fix Start [${process.cwd()}]
1132
1216
  execSync2("git config core.ignorecase false", {
1133
1217
  stdio: "inherit"
1134
1218
  });
1135
- console.warn(chalk16.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
1219
+ console.warn(chalk17.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
1136
1220
  }
1137
1221
  if (gitConfig.core.autocrlf !== false) {
1138
1222
  execSync2("git config core.autocrlf false", {
1139
1223
  stdio: "inherit"
1140
1224
  });
1141
- console.warn(chalk16.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
1225
+ console.warn(chalk17.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
1142
1226
  }
1143
1227
  if (gitConfig.core.eol !== "lf") {
1144
1228
  execSync2("git config core.eol lf", {
1145
1229
  stdio: "inherit"
1146
1230
  });
1147
- console.warn(chalk16.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
1231
+ console.warn(chalk17.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
1148
1232
  }
1149
1233
  return 1;
1150
1234
  }, "gitlintFix");
1151
1235
 
1152
1236
  // src/actions/license.ts
1153
- import chalk17 from "chalk";
1237
+ import chalk18 from "chalk";
1154
1238
  import { init } from "license-checker";
1155
1239
  var license = /* @__PURE__ */ __name(async (pkg) => {
1156
1240
  const workspaces = yarnWorkspaces();
@@ -1175,7 +1259,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1175
1259
  "LGPL-3.0-or-later",
1176
1260
  "Python-2.0"
1177
1261
  ]);
1178
- console.log(chalk17.green("License Checker"));
1262
+ console.log(chalk18.green("License Checker"));
1179
1263
  return (await Promise.all(workspaceList.map(({ location, name }) => {
1180
1264
  return new Promise((resolve) => {
1181
1265
  init({
@@ -1183,12 +1267,12 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1183
1267
  start: location
1184
1268
  }, (error, packages) => {
1185
1269
  if (error) {
1186
- console.error(chalk17.red(`License Checker [${name}] Error`));
1187
- console.error(chalk17.gray(error));
1270
+ console.error(chalk18.red(`License Checker [${name}] Error`));
1271
+ console.error(chalk18.gray(error));
1188
1272
  console.log("\n");
1189
1273
  resolve(1);
1190
1274
  } else {
1191
- console.log(chalk17.green(`License Checker [${name}]`));
1275
+ console.log(chalk18.green(`License Checker [${name}]`));
1192
1276
  let count = 0;
1193
1277
  for (const [name2, info] of Object.entries(packages)) {
1194
1278
  const licenses = Array.isArray(info.licenses) ? info.licenses : [
@@ -1206,7 +1290,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1206
1290
  }
1207
1291
  if (!orLicenseFound) {
1208
1292
  count++;
1209
- console.warn(chalk17.yellow(`${name2}: Package License not allowed [${license2}]`));
1293
+ console.warn(chalk18.yellow(`${name2}: Package License not allowed [${license2}]`));
1210
1294
  }
1211
1295
  }
1212
1296
  }
@@ -1219,100 +1303,6 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1219
1303
  }))).reduce((prev, value) => prev || value, 0);
1220
1304
  }, "license");
1221
1305
 
1222
- // src/actions/lint.ts
1223
- import chalk18 from "chalk";
1224
- import { ESLint as ESLint2 } from "eslint";
1225
- var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
1226
- const colors = [
1227
- "white",
1228
- "yellow",
1229
- "red"
1230
- ];
1231
- const severity = [
1232
- "none",
1233
- "warning",
1234
- "error"
1235
- ];
1236
- for (const lintResult of lintResults) {
1237
- if (lintResult.messages.length > 0) {
1238
- console.log(chalk18.gray(`${lintResult.filePath}`));
1239
- for (const message of lintResult.messages) {
1240
- console.log(chalk18.gray(` ${message.line}:${message.column}`), chalk18[colors[message.severity]](` ${severity[message.severity]}`), chalk18.white(` ${message.message}`), chalk18.gray(` ${message.ruleId}`));
1241
- }
1242
- }
1243
- }
1244
- }, "dumpMessages");
1245
- var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
1246
- const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
1247
- if (!workspace) {
1248
- console.error(chalk18.red(`Unable to locate package [${chalk18.magenta(pkg)}]`));
1249
- process.exit(1);
1250
- }
1251
- const engine = new ESLint2({
1252
- cache: true,
1253
- fix: fix2
1254
- });
1255
- const lintResults = await engine.lintFiles(workspace.location);
1256
- dumpMessages(lintResults);
1257
- return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1258
- }, "lintPackage");
1259
- var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
1260
- const workspace = yarnWorkspaces();
1261
- for (const ws of workspace) {
1262
- await lintPackage({
1263
- pkg: ws.name,
1264
- fix: fix2
1265
- });
1266
- }
1267
- }, "lintAll");
1268
- var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
1269
- return pkg ? await lintPackage({
1270
- pkg,
1271
- fix: fix2
1272
- }) : lintAllPackages({
1273
- verbose,
1274
- incremental,
1275
- fix: fix2
1276
- });
1277
- }, "lint");
1278
- var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
1279
- console.log(chalk18.gray("Linting [All-Packages]"));
1280
- const start = Date.now();
1281
- const verboseOptions = verbose ? [
1282
- "--verbose"
1283
- ] : [
1284
- "--no-verbose"
1285
- ];
1286
- const fixOptions = fix2 ? [
1287
- "--fix"
1288
- ] : [
1289
- ""
1290
- ];
1291
- const incrementalOptions = incremental ? [
1292
- "--since",
1293
- "-Apt"
1294
- ] : [
1295
- "--parallel",
1296
- "-Apt"
1297
- ];
1298
- const result = runSteps("Lint [All-Packages]", [
1299
- [
1300
- "yarn",
1301
- [
1302
- "workspaces",
1303
- "foreach",
1304
- ...verboseOptions,
1305
- ...incrementalOptions,
1306
- "run",
1307
- "package-lint",
1308
- ...fixOptions
1309
- ]
1310
- ]
1311
- ]);
1312
- console.log(`${chalk18.gray("Linted in")} [${chalk18.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk18.gray("seconds")}`);
1313
- return result;
1314
- }, "lintAllPackages");
1315
-
1316
1306
  // src/actions/lint-clean.ts
1317
1307
  import { rmSync } from "node:fs";
1318
1308
  var lintClean = /* @__PURE__ */ __name(async () => {
@@ -2814,16 +2804,16 @@ var xyLintCommands = /* @__PURE__ */ __name((args) => {
2814
2804
  }, async (argv) => {
2815
2805
  if (argv.verbose) console.log("Lint");
2816
2806
  const start = Date.now();
2817
- process.exitCode = argv.fix ? fix() : argv.profile ? lintProfile() : await lint({
2807
+ process.exitCode = argv.fix ? await fix() : argv.profile ? lintProfile() : await lint({
2818
2808
  pkg: argv.package
2819
2809
  });
2820
2810
  console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2821
2811
  }).command("fix [package]", "Fix - Run Eslint w/fix", (yargs2) => {
2822
2812
  return packagePositionalParam(yargs2);
2823
- }, (argv) => {
2813
+ }, async (argv) => {
2824
2814
  const start = Date.now();
2825
2815
  if (argv.verbose) console.log("Fix");
2826
- process.exitCode = fix();
2816
+ process.exitCode = await fix();
2827
2817
  console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2828
2818
  }).command("relint [package]", "Relint - Clean & Lint", (yargs2) => {
2829
2819
  return packagePositionalParam(yargs2);