@xylabs/ts-scripts-yarn3 5.0.39 → 5.1.1

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.
@@ -307,7 +307,7 @@ var mergeEntries = /* @__PURE__ */ __name((a, b) => [
307
307
  ].sort(localeCompare), "mergeEntries");
308
308
  var generateIgnoreFiles = /* @__PURE__ */ __name((filename3, pkg) => {
309
309
  console.log(chalk4.green(`Generate ${filename3} Files`));
310
- const cwd4 = INIT_CWD() ?? ".";
310
+ const cwd5 = INIT_CWD() ?? ".";
311
311
  const workspaces = pkg ? [
312
312
  yarnWorkspace(pkg)
313
313
  ] : yarnWorkspaces();
@@ -315,7 +315,7 @@ var generateIgnoreFiles = /* @__PURE__ */ __name((filename3, pkg) => {
315
315
  const writeEntries = /* @__PURE__ */ __name((location, entries) => writeLines(`${location}/${filename3}`, entries), "writeEntries");
316
316
  const results = workspaces.map(({ location, name }) => {
317
317
  try {
318
- writeEntries(location, mergeEntries(readEntries(cwd4), readEntries(location)));
318
+ writeEntries(location, mergeEntries(readEntries(cwd5), readEntries(location)));
319
319
  return 0;
320
320
  } catch (ex) {
321
321
  const error = ex;
@@ -349,8 +349,8 @@ var loadConfig = /* @__PURE__ */ __name(async (params) => {
349
349
 
350
350
  // src/lib/parsedPackageJSON.ts
351
351
  import { readFileSync as readFileSync2 } from "node:fs";
352
- var parsedPackageJSON = /* @__PURE__ */ __name((path7) => {
353
- const pathToPackageJSON = path7 ?? process.env.npm_package_json ?? "";
352
+ var parsedPackageJSON = /* @__PURE__ */ __name((path8) => {
353
+ const pathToPackageJSON = path8 ?? process.env.npm_package_json ?? "";
354
354
  const packageJSON = readFileSync2(pathToPackageJSON).toString();
355
355
  return JSON.parse(packageJSON);
356
356
  }, "parsedPackageJSON");
@@ -1169,20 +1169,45 @@ var lintAll = /* @__PURE__ */ __name(async () => {
1169
1169
  dumpMessages(lintResults);
1170
1170
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1171
1171
  }, "lintAll");
1172
- var lint = /* @__PURE__ */ __name(async ({ pkg } = {}) => {
1172
+ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental } = {}) => {
1173
1173
  return pkg ? await lintPackage({
1174
1174
  pkg
1175
- }) : runSteps("Lint-Caching [All]", [
1175
+ }) : lintAllPackages({
1176
+ verbose,
1177
+ incremental
1178
+ });
1179
+ }, "lint");
1180
+ var lintAllPackages = /* @__PURE__ */ __name(({ verbose = true, incremental } = {}) => {
1181
+ console.log(chalk17.gray("Linting [All-Packages]"));
1182
+ const start = Date.now();
1183
+ const verboseOptions = verbose ? [
1184
+ "--verbose"
1185
+ ] : [
1186
+ "--no-verbose"
1187
+ ];
1188
+ const incrementalOptions = incremental ? [
1189
+ "--since",
1190
+ "-Apt"
1191
+ ] : [
1192
+ "--parallel",
1193
+ "-Apt"
1194
+ ];
1195
+ const result = runSteps("Lint [All-Packages]", [
1176
1196
  [
1177
1197
  "yarn",
1178
1198
  [
1179
- "eslint",
1180
- ".",
1181
- "--cache"
1199
+ "workspaces",
1200
+ "foreach",
1201
+ ...verboseOptions,
1202
+ ...incrementalOptions,
1203
+ "run",
1204
+ "package-lint"
1182
1205
  ]
1183
1206
  ]
1184
1207
  ]);
1185
- }, "lint");
1208
+ console.log(`${chalk17.gray("Linted in")} [${chalk17.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk17.gray("seconds")}`);
1209
+ return result;
1210
+ }, "lintAllPackages");
1186
1211
 
1187
1212
  // src/actions/lint-clean.ts
1188
1213
  import { rmSync } from "node:fs";
@@ -1980,6 +2005,77 @@ var runTypeDoc = /* @__PURE__ */ __name(async (app) => {
1980
2005
  return ExitCodes.Ok;
1981
2006
  }, "runTypeDoc");
1982
2007
 
2008
+ // src/actions/package/lint.ts
2009
+ import { readdirSync } from "node:fs";
2010
+ import path7 from "node:path";
2011
+ import { cwd as cwd4 } from "node:process";
2012
+ import { pathToFileURL } from "node:url";
2013
+ import chalk27 from "chalk";
2014
+ import { ESLint as ESLint3 } from "eslint";
2015
+ import { findUp } from "find-up";
2016
+ var dumpMessages2 = /* @__PURE__ */ __name((lintResults) => {
2017
+ const colors = [
2018
+ "white",
2019
+ "yellow",
2020
+ "red"
2021
+ ];
2022
+ const severity = [
2023
+ "none",
2024
+ "warning",
2025
+ "error"
2026
+ ];
2027
+ for (const lintResult of lintResults) {
2028
+ if (lintResult.messages.length > 0) {
2029
+ console.log(chalk27.gray(`
2030
+ ${lintResult.filePath}`));
2031
+ for (const message of lintResult.messages) {
2032
+ console.log(chalk27.gray(` ${message.line}:${message.column}`), chalk27[colors[message.severity]](` ${severity[message.severity]}`), chalk27.white(` ${message.message}`), chalk27.gray(` ${message.ruleId}`));
2033
+ }
2034
+ }
2035
+ }
2036
+ }, "dumpMessages");
2037
+ async function getRootESLintConfig() {
2038
+ const configPath = await findUp("eslint.config.mjs");
2039
+ if (!configPath) {
2040
+ throw new Error("eslint.config.mjs not found in the monorepo");
2041
+ }
2042
+ return pathToFileURL(configPath);
2043
+ }
2044
+ __name(getRootESLintConfig, "getRootESLintConfig");
2045
+ var packageLint = /* @__PURE__ */ __name(async () => {
2046
+ const configPath = await getRootESLintConfig();
2047
+ const { default: eslintConfig } = await import(configPath.href);
2048
+ const ignoreFolders = /* @__PURE__ */ new Set([
2049
+ "node_modules",
2050
+ "dist",
2051
+ "packages"
2052
+ ]);
2053
+ function getFiles(dir, ignorePatterns2) {
2054
+ return readdirSync(dir, {
2055
+ withFileTypes: true
2056
+ }).flatMap((dirent) => {
2057
+ const res = path7.resolve(dir, dirent.name);
2058
+ if (ignorePatterns2.some((pattern) => dir.includes(pattern))) return [];
2059
+ return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") || res.endsWith(".js") || res.endsWith(".jsx") ? [
2060
+ res
2061
+ ] : [];
2062
+ });
2063
+ }
2064
+ __name(getFiles, "getFiles");
2065
+ const engine = new ESLint3({
2066
+ baseConfig: [
2067
+ ...eslintConfig
2068
+ ]
2069
+ });
2070
+ const ignorePatterns = [
2071
+ ...eslintConfig.find((cfg) => cfg.ignores)?.ignores ?? [],
2072
+ ...ignoreFolders
2073
+ ];
2074
+ const lintResults = await engine.lintFiles(getFiles(cwd4(), ignorePatterns));
2075
+ dumpMessages2(lintResults);
2076
+ return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
2077
+ }, "packageLint");
2078
+
1983
2079
  // src/actions/package/recompile.ts
1984
2080
  var packageRecompile = /* @__PURE__ */ __name(async () => {
1985
2081
  return await packageClean() || await packageCompile();
@@ -2043,7 +2139,7 @@ var rebuild = /* @__PURE__ */ __name(({ target }) => {
2043
2139
  }, "rebuild");
2044
2140
 
2045
2141
  // src/actions/recompile.ts
2046
- import chalk27 from "chalk";
2142
+ import chalk28 from "chalk";
2047
2143
  var recompile = /* @__PURE__ */ __name(async ({ verbose, target, pkg, incremental }) => {
2048
2144
  return pkg ? await recompilePackage({
2049
2145
  pkg,
@@ -2104,7 +2200,7 @@ var recompileAll = /* @__PURE__ */ __name(async ({ jobs, verbose, target, increm
2104
2200
  `${jobs}`
2105
2201
  ] : [];
2106
2202
  if (jobs) {
2107
- console.log(chalk27.blue(`Jobs set to [${jobs}]`));
2203
+ console.log(chalk28.blue(`Jobs set to [${jobs}]`));
2108
2204
  }
2109
2205
  const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
2110
2206
  [
@@ -2134,7 +2230,7 @@ var recompileAll = /* @__PURE__ */ __name(async ({ jobs, verbose, target, increm
2134
2230
  ]
2135
2231
  ]
2136
2232
  ]);
2137
- console.log(`${chalk27.gray("Recompiled in")} [${chalk27.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk27.gray("seconds")}`);
2233
+ console.log(`${chalk28.gray("Recompiled in")} [${chalk28.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk28.gray("seconds")}`);
2138
2234
  return result;
2139
2235
  }, "recompileAll");
2140
2236
 
@@ -2234,7 +2330,7 @@ var sonar = /* @__PURE__ */ __name(() => {
2234
2330
  }, "sonar");
2235
2331
 
2236
2332
  // src/actions/statics.ts
2237
- import chalk28 from "chalk";
2333
+ import chalk29 from "chalk";
2238
2334
  var DefaultDependencies = [
2239
2335
  "axios",
2240
2336
  "@xylabs/pixel",
@@ -2245,7 +2341,7 @@ var DefaultDependencies = [
2245
2341
  "@mui/system"
2246
2342
  ];
2247
2343
  var statics = /* @__PURE__ */ __name(() => {
2248
- console.log(chalk28.green("Check Required Static Dependencies"));
2344
+ console.log(chalk29.green("Check Required Static Dependencies"));
2249
2345
  const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
2250
2346
  return detectDuplicateDependencies(statics2, DefaultDependencies);
2251
2347
  }, "statics");
@@ -2381,6 +2477,7 @@ export {
2381
2477
  license,
2382
2478
  lint,
2383
2479
  lintAll,
2480
+ lintAllPackages,
2384
2481
  lintClean,
2385
2482
  lintPackage,
2386
2483
  lintProfile,
@@ -2394,6 +2491,7 @@ export {
2394
2491
  packageCopyAssets,
2395
2492
  packageDeps,
2396
2493
  packageGenDocs,
2494
+ packageLint,
2397
2495
  packagePublint,
2398
2496
  packageRecompile,
2399
2497
  publint,