@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.
package/dist/index.d.ts CHANGED
@@ -103,6 +103,7 @@ declare const gitlintFix: () => number;
103
103
  declare const license: (pkg?: string) => Promise<number>;
104
104
 
105
105
  interface LintParams {
106
+ incremental?: boolean;
106
107
  pkg?: string;
107
108
  verbose?: boolean;
108
109
  }
@@ -112,7 +113,8 @@ interface LintPackageParams {
112
113
  }
113
114
  declare const lintPackage: ({ pkg }: LintParams) => Promise<number>;
114
115
  declare const lintAll: () => Promise<number>;
115
- declare const lint: ({ pkg }?: LintParams) => Promise<number>;
116
+ declare const lint: ({ pkg, verbose, incremental, }?: LintParams) => Promise<number>;
117
+ declare const lintAllPackages: ({ verbose, incremental }?: LintParams) => number;
116
118
 
117
119
  declare const lintClean: () => Promise<number>;
118
120
 
@@ -184,6 +186,8 @@ declare const packageDeps: () => Promise<number>;
184
186
 
185
187
  declare const packageGenDocs: () => Promise<number | undefined>;
186
188
 
189
+ declare const packageLint: () => Promise<number>;
190
+
187
191
  interface PackagePublintParams {
188
192
  verbose?: boolean;
189
193
  }
@@ -360,4 +364,4 @@ declare const xyLintCommands: (args: Argv) => Argv<{}>;
360
364
 
361
365
  declare const xyParseOptions: () => Argv;
362
366
 
363
- export { type BuildParams, CROSS_PLATFORM_NEWLINE, type CleanPackageParams, type CleanParams, type CompileConfig, type CompileMode, type CompileParams, type CopyAssetsParams, type DepsPackageParams, type DepsParams, DuplicateDetector, type DynamicShareConfig, type EntryMode, type GenDocsPackageParams, type GenDocsParams, INIT_CWD, type LintPackageParams, type LintParams, type LiveShareConfig, type PackageCompileTscConfig, type PackageCompileTsupConfig, type PackageCopyAssetsParams, type PackageJsonEx, type PackagePublintParams, type PathConfig, type PublintPackageParams, type PublintParams, type ReadFileSyncOptions, type RebuildParams, type RecompilePackageParams, type RecompileParams, type ScriptStep, WINDOWS_NEWLINE_REGEX, type Workspace, type XyConfig, type XyConfigBase, type XyTscConfig, type XyTsupConfig, build, checkResult, clean, cleanAll, cleanDocs, cleanPackage, compile, compileAll, compilePackage, copyAssets, createBuildConfig, cycle, dead, defaultBuildConfig, defaultReadFileSyncOptions, deleteGlob, deploy, deployMajor, deployMinor, deployNext, deps, depsAll, depsPackage, detectDuplicateDependencies, dupdeps, empty, fix, genDocs, genDocsAll, genDocsPackage, generateIgnoreFiles, gitignoreGen, gitlint, gitlintFix, isYarnVersionOrGreater, license, lint, lintAll, lintClean, lintPackage, lintProfile, loadConfig, loadPackageConfig, multiLineToJSONArray, notEmpty, npmignoreGen, packageClean, packageCleanOutputs, packageCleanTypescript, packageCompile, packageCompileTsc, packageCompileTsup, packageCopyAssets, packageDeps, packageGenDocs, packagePublint, packageRecompile, parsedPackageJSON, processEx, publint, publintAll, publintPackage, readLines, readNonEmptyLines, rebuild, recompile, recompileAll, recompilePackage, reinstall, relint, retest, runStepAsync, runSteps, runStepsAsync, runXy, runXyWithWarning, safeExit, safeExitAsync, sonar, statics, test, tryReadFileSync, union, up, updateYarnPlugins, updateYarnVersion, updo, withErrnoException, withError, writeLines, xy, xyBuildCommands, xyCommonCommands, xyDeployCommands, xyInstallCommands, xyLintCommands, xyParseOptions, yarn3Only, yarnWorkspace, yarnWorkspaces };
367
+ export { type BuildParams, CROSS_PLATFORM_NEWLINE, type CleanPackageParams, type CleanParams, type CompileConfig, type CompileMode, type CompileParams, type CopyAssetsParams, type DepsPackageParams, type DepsParams, DuplicateDetector, type DynamicShareConfig, type EntryMode, type GenDocsPackageParams, type GenDocsParams, INIT_CWD, type LintPackageParams, type LintParams, type LiveShareConfig, type PackageCompileTscConfig, type PackageCompileTsupConfig, type PackageCopyAssetsParams, type PackageJsonEx, type PackagePublintParams, type PathConfig, type PublintPackageParams, type PublintParams, type ReadFileSyncOptions, type RebuildParams, type RecompilePackageParams, type RecompileParams, type ScriptStep, WINDOWS_NEWLINE_REGEX, type Workspace, type XyConfig, type XyConfigBase, type XyTscConfig, type XyTsupConfig, build, checkResult, clean, cleanAll, cleanDocs, cleanPackage, compile, compileAll, compilePackage, copyAssets, createBuildConfig, cycle, dead, defaultBuildConfig, defaultReadFileSyncOptions, deleteGlob, deploy, deployMajor, deployMinor, deployNext, deps, depsAll, depsPackage, detectDuplicateDependencies, dupdeps, empty, fix, genDocs, genDocsAll, genDocsPackage, generateIgnoreFiles, gitignoreGen, gitlint, gitlintFix, isYarnVersionOrGreater, license, lint, lintAll, lintAllPackages, lintClean, lintPackage, lintProfile, loadConfig, loadPackageConfig, multiLineToJSONArray, notEmpty, npmignoreGen, packageClean, packageCleanOutputs, packageCleanTypescript, packageCompile, packageCompileTsc, packageCompileTsup, packageCopyAssets, packageDeps, packageGenDocs, packageLint, packagePublint, packageRecompile, parsedPackageJSON, processEx, publint, publintAll, publintPackage, readLines, readNonEmptyLines, rebuild, recompile, recompileAll, recompilePackage, reinstall, relint, retest, runStepAsync, runSteps, runStepsAsync, runXy, runXyWithWarning, safeExit, safeExitAsync, sonar, statics, test, tryReadFileSync, union, up, updateYarnPlugins, updateYarnVersion, updo, withErrnoException, withError, writeLines, xy, xyBuildCommands, xyCommonCommands, xyDeployCommands, xyInstallCommands, xyLintCommands, xyParseOptions, yarn3Only, yarnWorkspace, yarnWorkspaces };
package/dist/index.mjs CHANGED
@@ -377,7 +377,7 @@ var mergeEntries = /* @__PURE__ */ __name((a, b) => [
377
377
  ].sort(localeCompare), "mergeEntries");
378
378
  var generateIgnoreFiles = /* @__PURE__ */ __name((filename3, pkg) => {
379
379
  console.log(chalk4.green(`Generate ${filename3} Files`));
380
- const cwd4 = INIT_CWD() ?? ".";
380
+ const cwd5 = INIT_CWD() ?? ".";
381
381
  const workspaces = pkg ? [
382
382
  yarnWorkspace(pkg)
383
383
  ] : yarnWorkspaces();
@@ -385,7 +385,7 @@ var generateIgnoreFiles = /* @__PURE__ */ __name((filename3, pkg) => {
385
385
  const writeEntries = /* @__PURE__ */ __name((location, entries) => writeLines(`${location}/${filename3}`, entries), "writeEntries");
386
386
  const results = workspaces.map(({ location, name }) => {
387
387
  try {
388
- writeEntries(location, mergeEntries(readEntries(cwd4), readEntries(location)));
388
+ writeEntries(location, mergeEntries(readEntries(cwd5), readEntries(location)));
389
389
  return 0;
390
390
  } catch (ex) {
391
391
  const error = ex;
@@ -419,8 +419,8 @@ var loadConfig = /* @__PURE__ */ __name(async (params) => {
419
419
 
420
420
  // src/lib/parsedPackageJSON.ts
421
421
  import { readFileSync as readFileSync4 } from "node:fs";
422
- var parsedPackageJSON = /* @__PURE__ */ __name((path7) => {
423
- const pathToPackageJSON = path7 ?? process.env.npm_package_json ?? "";
422
+ var parsedPackageJSON = /* @__PURE__ */ __name((path8) => {
423
+ const pathToPackageJSON = path8 ?? process.env.npm_package_json ?? "";
424
424
  const packageJSON = readFileSync4(pathToPackageJSON).toString();
425
425
  return JSON.parse(packageJSON);
426
426
  }, "parsedPackageJSON");
@@ -1263,20 +1263,45 @@ var lintAll = /* @__PURE__ */ __name(async () => {
1263
1263
  dumpMessages(lintResults);
1264
1264
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1265
1265
  }, "lintAll");
1266
- var lint = /* @__PURE__ */ __name(async ({ pkg } = {}) => {
1266
+ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental } = {}) => {
1267
1267
  return pkg ? await lintPackage({
1268
1268
  pkg
1269
- }) : runSteps("Lint-Caching [All]", [
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]", [
1270
1290
  [
1271
1291
  "yarn",
1272
1292
  [
1273
- "eslint",
1274
- ".",
1275
- "--cache"
1293
+ "workspaces",
1294
+ "foreach",
1295
+ ...verboseOptions,
1296
+ ...incrementalOptions,
1297
+ "run",
1298
+ "package-lint"
1276
1299
  ]
1277
1300
  ]
1278
1301
  ]);
1279
- }, "lint");
1302
+ console.log(`${chalk18.gray("Linted in")} [${chalk18.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk18.gray("seconds")}`);
1303
+ return result;
1304
+ }, "lintAllPackages");
1280
1305
 
1281
1306
  // src/actions/lint-clean.ts
1282
1307
  import { rmSync } from "node:fs";
@@ -2074,6 +2099,77 @@ var runTypeDoc = /* @__PURE__ */ __name(async (app) => {
2074
2099
  return ExitCodes.Ok;
2075
2100
  }, "runTypeDoc");
2076
2101
 
2102
+ // src/actions/package/lint.ts
2103
+ import { readdirSync } from "node:fs";
2104
+ import path7 from "node:path";
2105
+ import { cwd as cwd4 } from "node:process";
2106
+ import { pathToFileURL } from "node:url";
2107
+ import chalk28 from "chalk";
2108
+ import { ESLint as ESLint3 } from "eslint";
2109
+ import { findUp } from "find-up";
2110
+ var dumpMessages2 = /* @__PURE__ */ __name((lintResults) => {
2111
+ const colors = [
2112
+ "white",
2113
+ "yellow",
2114
+ "red"
2115
+ ];
2116
+ const severity = [
2117
+ "none",
2118
+ "warning",
2119
+ "error"
2120
+ ];
2121
+ for (const lintResult of lintResults) {
2122
+ if (lintResult.messages.length > 0) {
2123
+ console.log(chalk28.gray(`
2124
+ ${lintResult.filePath}`));
2125
+ for (const message of lintResult.messages) {
2126
+ console.log(chalk28.gray(` ${message.line}:${message.column}`), chalk28[colors[message.severity]](` ${severity[message.severity]}`), chalk28.white(` ${message.message}`), chalk28.gray(` ${message.ruleId}`));
2127
+ }
2128
+ }
2129
+ }
2130
+ }, "dumpMessages");
2131
+ async function getRootESLintConfig() {
2132
+ const configPath = await findUp("eslint.config.mjs");
2133
+ if (!configPath) {
2134
+ throw new Error("eslint.config.mjs not found in the monorepo");
2135
+ }
2136
+ return pathToFileURL(configPath);
2137
+ }
2138
+ __name(getRootESLintConfig, "getRootESLintConfig");
2139
+ var packageLint = /* @__PURE__ */ __name(async () => {
2140
+ const configPath = await getRootESLintConfig();
2141
+ const { default: eslintConfig } = await import(configPath.href);
2142
+ const ignoreFolders = /* @__PURE__ */ new Set([
2143
+ "node_modules",
2144
+ "dist",
2145
+ "packages"
2146
+ ]);
2147
+ function getFiles(dir, ignorePatterns2) {
2148
+ return readdirSync(dir, {
2149
+ withFileTypes: true
2150
+ }).flatMap((dirent) => {
2151
+ const res = path7.resolve(dir, dirent.name);
2152
+ if (ignorePatterns2.some((pattern) => dir.includes(pattern))) return [];
2153
+ return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") || res.endsWith(".js") || res.endsWith(".jsx") ? [
2154
+ res
2155
+ ] : [];
2156
+ });
2157
+ }
2158
+ __name(getFiles, "getFiles");
2159
+ const engine = new ESLint3({
2160
+ baseConfig: [
2161
+ ...eslintConfig
2162
+ ]
2163
+ });
2164
+ const ignorePatterns = [
2165
+ ...eslintConfig.find((cfg) => cfg.ignores)?.ignores ?? [],
2166
+ ...ignoreFolders
2167
+ ];
2168
+ const lintResults = await engine.lintFiles(getFiles(cwd4(), ignorePatterns));
2169
+ dumpMessages2(lintResults);
2170
+ return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
2171
+ }, "packageLint");
2172
+
2077
2173
  // src/actions/package/recompile.ts
2078
2174
  var packageRecompile = /* @__PURE__ */ __name(async () => {
2079
2175
  return await packageClean() || await packageCompile();
@@ -2137,7 +2233,7 @@ var rebuild = /* @__PURE__ */ __name(({ target }) => {
2137
2233
  }, "rebuild");
2138
2234
 
2139
2235
  // src/actions/recompile.ts
2140
- import chalk28 from "chalk";
2236
+ import chalk29 from "chalk";
2141
2237
  var recompile = /* @__PURE__ */ __name(async ({ verbose, target, pkg, incremental }) => {
2142
2238
  return pkg ? await recompilePackage({
2143
2239
  pkg,
@@ -2198,7 +2294,7 @@ var recompileAll = /* @__PURE__ */ __name(async ({ jobs, verbose, target, increm
2198
2294
  `${jobs}`
2199
2295
  ] : [];
2200
2296
  if (jobs) {
2201
- console.log(chalk28.blue(`Jobs set to [${jobs}]`));
2297
+ console.log(chalk29.blue(`Jobs set to [${jobs}]`));
2202
2298
  }
2203
2299
  const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
2204
2300
  [
@@ -2228,7 +2324,7 @@ var recompileAll = /* @__PURE__ */ __name(async ({ jobs, verbose, target, increm
2228
2324
  ]
2229
2325
  ]
2230
2326
  ]);
2231
- console.log(`${chalk28.gray("Recompiled in")} [${chalk28.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk28.gray("seconds")}`);
2327
+ console.log(`${chalk29.gray("Recompiled in")} [${chalk29.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk29.gray("seconds")}`);
2232
2328
  return result;
2233
2329
  }, "recompileAll");
2234
2330
 
@@ -2328,7 +2424,7 @@ var sonar = /* @__PURE__ */ __name(() => {
2328
2424
  }, "sonar");
2329
2425
 
2330
2426
  // src/actions/statics.ts
2331
- import chalk29 from "chalk";
2427
+ import chalk30 from "chalk";
2332
2428
  var DefaultDependencies = [
2333
2429
  "axios",
2334
2430
  "@xylabs/pixel",
@@ -2339,7 +2435,7 @@ var DefaultDependencies = [
2339
2435
  "@mui/system"
2340
2436
  ];
2341
2437
  var statics = /* @__PURE__ */ __name(() => {
2342
- console.log(chalk29.green("Check Required Static Dependencies"));
2438
+ console.log(chalk30.green("Check Required Static Dependencies"));
2343
2439
  const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
2344
2440
  return detectDuplicateDependencies(statics2, DefaultDependencies);
2345
2441
  }, "statics");
@@ -2457,7 +2553,7 @@ var loadPackageConfig = /* @__PURE__ */ __name(async () => {
2457
2553
  }, "loadPackageConfig");
2458
2554
 
2459
2555
  // src/xy/xy.ts
2460
- import chalk31 from "chalk";
2556
+ import chalk32 from "chalk";
2461
2557
 
2462
2558
  // src/xy/xyBuildCommands.ts
2463
2559
  var xyBuildCommands = /* @__PURE__ */ __name((args) => {
@@ -2694,7 +2790,7 @@ var xyInstallCommands = /* @__PURE__ */ __name((args) => {
2694
2790
  }, "xyInstallCommands");
2695
2791
 
2696
2792
  // src/xy/xyLintCommands.ts
2697
- import chalk30 from "chalk";
2793
+ import chalk31 from "chalk";
2698
2794
  var xyLintCommands = /* @__PURE__ */ __name((args) => {
2699
2795
  return args.command("cycle [package]", "Cycle - Check for dependency cycles", (yargs2) => {
2700
2796
  return packagePositionalParam(yargs2);
@@ -2702,7 +2798,7 @@ var xyLintCommands = /* @__PURE__ */ __name((args) => {
2702
2798
  const start = Date.now();
2703
2799
  if (argv.verbose) console.log("Cycle");
2704
2800
  process.exitCode = await cycle();
2705
- console.log(chalk30.blue(`Finished in ${Date.now() - start}ms`));
2801
+ console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2706
2802
  }).command("lint [package]", "Lint - Run Eslint", (yargs2) => {
2707
2803
  return packagePositionalParam(yargs2);
2708
2804
  }, async (argv) => {
@@ -2711,21 +2807,21 @@ var xyLintCommands = /* @__PURE__ */ __name((args) => {
2711
2807
  process.exitCode = argv.fix ? fix() : argv.profile ? lintProfile() : await lint({
2712
2808
  pkg: argv.package
2713
2809
  });
2714
- console.log(chalk30.blue(`Finished in ${Date.now() - start}ms`));
2810
+ console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2715
2811
  }).command("fix [package]", "Fix - Run Eslint w/fix", (yargs2) => {
2716
2812
  return packagePositionalParam(yargs2);
2717
2813
  }, (argv) => {
2718
2814
  const start = Date.now();
2719
2815
  if (argv.verbose) console.log("Fix");
2720
2816
  process.exitCode = fix();
2721
- console.log(chalk30.blue(`Finished in ${Date.now() - start}ms`));
2817
+ console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2722
2818
  }).command("relint [package]", "Relint - Clean & Lint", (yargs2) => {
2723
2819
  return packagePositionalParam(yargs2);
2724
2820
  }, (argv) => {
2725
2821
  if (argv.verbose) console.log("Relinting");
2726
2822
  const start = Date.now();
2727
2823
  process.exitCode = relint();
2728
- console.log(chalk30.blue(`Finished in ${Date.now() - start}ms`));
2824
+ console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2729
2825
  }).command("publint [package]", "Publint - Run Publint", (yargs2) => {
2730
2826
  return packagePositionalParam(yargs2);
2731
2827
  }, async (argv) => {
@@ -2735,14 +2831,14 @@ var xyLintCommands = /* @__PURE__ */ __name((args) => {
2735
2831
  pkg: argv.package,
2736
2832
  verbose: !!argv.verbose
2737
2833
  });
2738
- console.log(chalk30.blue(`Finished in ${Date.now() - start}ms`));
2834
+ console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2739
2835
  }).command("sonar", "Sonar - Run Sonar Check", (yargs2) => {
2740
2836
  return packagePositionalParam(yargs2);
2741
2837
  }, (argv) => {
2742
2838
  const start = Date.now();
2743
2839
  if (argv.verbose) console.log("Sonar Check");
2744
2840
  process.exitCode = sonar();
2745
- console.log(chalk30.blue(`Finished in ${Date.now() - start}ms`));
2841
+ console.log(chalk31.blue(`Finished in ${Date.now() - start}ms`));
2746
2842
  });
2747
2843
  }, "xyLintCommands");
2748
2844
 
@@ -2804,8 +2900,8 @@ var xyParseOptions = /* @__PURE__ */ __name(() => {
2804
2900
  var xy = /* @__PURE__ */ __name(async () => {
2805
2901
  const options = xyParseOptions();
2806
2902
  return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
2807
- console.error(chalk31.yellow(`Command not found [${chalk31.magenta(process.argv[2])}]`));
2808
- console.log(chalk31.gray("Try 'yarn xy --help' for list of commands"));
2903
+ console.error(chalk32.yellow(`Command not found [${chalk32.magenta(process.argv[2])}]`));
2904
+ console.log(chalk32.gray("Try 'yarn xy --help' for list of commands"));
2809
2905
  }).version().help().argv;
2810
2906
  }, "xy");
2811
2907
  export {
@@ -2851,6 +2947,7 @@ export {
2851
2947
  license,
2852
2948
  lint,
2853
2949
  lintAll,
2950
+ lintAllPackages,
2854
2951
  lintClean,
2855
2952
  lintPackage,
2856
2953
  lintProfile,
@@ -2868,6 +2965,7 @@ export {
2868
2965
  packageCopyAssets,
2869
2966
  packageDeps,
2870
2967
  packageGenDocs,
2968
+ packageLint,
2871
2969
  packagePublint,
2872
2970
  packageRecompile,
2873
2971
  parsedPackageJSON,