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