@xylabs/ts-scripts-yarn3 7.0.0 → 7.0.2

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.
Files changed (53) hide show
  1. package/dist/actions/deplint/checkPackage/checkPackage.mjs +11 -1
  2. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/index.mjs +11 -1
  4. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  5. package/dist/actions/deplint/deplint.mjs +33 -21
  6. package/dist/actions/deplint/deplint.mjs.map +1 -1
  7. package/dist/actions/deplint/index.mjs +33 -21
  8. package/dist/actions/deplint/index.mjs.map +1 -1
  9. package/dist/actions/index.mjs +132 -108
  10. package/dist/actions/index.mjs.map +1 -1
  11. package/dist/actions/package/compile/compile.mjs +25 -74
  12. package/dist/actions/package/compile/compile.mjs.map +1 -1
  13. package/dist/actions/package/compile/index.mjs +25 -74
  14. package/dist/actions/package/compile/index.mjs.map +1 -1
  15. package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
  16. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
  17. package/dist/actions/package/gen-docs.mjs +1 -1
  18. package/dist/actions/package/gen-docs.mjs.map +1 -1
  19. package/dist/actions/package/index.mjs +96 -84
  20. package/dist/actions/package/index.mjs.map +1 -1
  21. package/dist/actions/package/publint.mjs +27 -10
  22. package/dist/actions/package/publint.mjs.map +1 -1
  23. package/dist/actions/package/recompile.mjs +25 -74
  24. package/dist/actions/package/recompile.mjs.map +1 -1
  25. package/dist/actions/publint.mjs +3 -3
  26. package/dist/actions/publint.mjs.map +1 -1
  27. package/dist/bin/package/build-only.mjs +27 -76
  28. package/dist/bin/package/build-only.mjs.map +1 -1
  29. package/dist/bin/package/build.mjs +27 -76
  30. package/dist/bin/package/build.mjs.map +1 -1
  31. package/dist/bin/package/compile-only.mjs +27 -76
  32. package/dist/bin/package/compile-only.mjs.map +1 -1
  33. package/dist/bin/package/compile-tsup.mjs.map +1 -1
  34. package/dist/bin/package/compile.mjs +27 -76
  35. package/dist/bin/package/compile.mjs.map +1 -1
  36. package/dist/bin/package/gen-docs.mjs +1 -1
  37. package/dist/bin/package/gen-docs.mjs.map +1 -1
  38. package/dist/bin/package/publint.mjs +27 -10
  39. package/dist/bin/package/publint.mjs.map +1 -1
  40. package/dist/bin/package/recompile.mjs +27 -76
  41. package/dist/bin/package/recompile.mjs.map +1 -1
  42. package/dist/bin/xy.mjs +38 -25
  43. package/dist/bin/xy.mjs.map +1 -1
  44. package/dist/index.d.ts +125 -96
  45. package/dist/index.mjs +134 -109
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/xy/index.mjs +38 -25
  48. package/dist/xy/index.mjs.map +1 -1
  49. package/dist/xy/xy.mjs +38 -25
  50. package/dist/xy/xy.mjs.map +1 -1
  51. package/dist/xy/xyLintCommands.mjs +38 -25
  52. package/dist/xy/xyLintCommands.mjs.map +1 -1
  53. package/package.json +12 -14
package/dist/index.mjs CHANGED
@@ -1136,8 +1136,18 @@ function getUnusedPeerDependencies({ name, location }, { peerDependencies, depen
1136
1136
  __name(getUnusedPeerDependencies, "getUnusedPeerDependencies");
1137
1137
 
1138
1138
  // src/actions/deplint/checkPackage/checkPackage.ts
1139
- function checkPackage({ name, location, deps = false, devDeps = false, peerDeps = false }) {
1139
+ function checkPackage({ name, location, deps = false, devDeps = false, peerDeps = false, verbose = false }) {
1140
1140
  const { srcFiles, distFiles } = findFiles(location);
1141
+ if (verbose) {
1142
+ console.info(`Checking package: ${name} at ${location}`);
1143
+ console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`);
1144
+ for (const file of srcFiles) {
1145
+ console.info(`Source file: ${file}`);
1146
+ }
1147
+ for (const file of distFiles) {
1148
+ console.info(`Distribution file: ${file}`);
1149
+ }
1150
+ }
1141
1151
  const checkDeps = deps || !(deps || devDeps || peerDeps);
1142
1152
  const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
1143
1153
  const checkPeerDeps = peerDeps;
@@ -1168,34 +1178,36 @@ function checkPackage({ name, location, deps = false, devDeps = false, peerDeps
1168
1178
  __name(checkPackage, "checkPackage");
1169
1179
 
1170
1180
  // src/actions/deplint/deplint.ts
1171
- var deplint = /* @__PURE__ */ __name(({ pkg, deps, devDeps, peerDeps }) => {
1172
- if (pkg) {
1173
- const { location, name } = yarnWorkspace(pkg);
1174
- console.log(`Running Deplint for ${name}`);
1175
- checkPackage({
1176
- name,
1177
- location,
1178
- devDeps,
1179
- deps,
1180
- peerDeps
1181
- });
1182
- } else {
1181
+ var deplint = /* @__PURE__ */ __name(({ pkg, deps, devDeps, peerDeps, verbose }) => {
1182
+ let totalErrors = 0;
1183
+ if (pkg === void 0) {
1183
1184
  const workspaces = yarnWorkspaces();
1184
- console.log("Deplint Started...");
1185
- let totalErrors = 0;
1185
+ console.info("Deplint Started...");
1186
1186
  for (const workspace of workspaces) {
1187
1187
  totalErrors += checkPackage({
1188
1188
  ...workspace,
1189
1189
  deps,
1190
1190
  devDeps,
1191
- peerDeps
1191
+ peerDeps,
1192
+ verbose
1192
1193
  });
1193
1194
  }
1194
- if (totalErrors > 0) {
1195
- console.log(`Deplint: Found ${chalk17.red(totalErrors)} dependency problems. ${chalk17.red("\u2716")}`);
1196
- } else {
1197
- console.log(`Deplint: Found no dependency problems. ${chalk17.green("\u2714")}`);
1198
- }
1195
+ } else {
1196
+ const { location, name } = yarnWorkspace(pkg);
1197
+ console.info(`Running Deplint for ${name}`);
1198
+ totalErrors += checkPackage({
1199
+ name,
1200
+ location,
1201
+ devDeps,
1202
+ deps,
1203
+ peerDeps,
1204
+ verbose
1205
+ });
1206
+ }
1207
+ if (totalErrors > 0) {
1208
+ console.warn(`Deplint: Found ${chalk17.red(totalErrors)} dependency problems. ${chalk17.red("\u2716")}`);
1209
+ } else {
1210
+ console.info(`Deplint: Found no dependency problems. ${chalk17.green("\u2714")}`);
1199
1211
  }
1200
1212
  return 0;
1201
1213
  }, "deplint");
@@ -1693,58 +1705,14 @@ var packageClean = /* @__PURE__ */ __name(async () => {
1693
1705
  }, "packageClean");
1694
1706
 
1695
1707
  // src/actions/package/compile/compile.ts
1696
- import chalk30 from "chalk";
1697
-
1698
- // src/actions/package/publint.ts
1699
- import { promises as fs4 } from "fs";
1700
- import chalk25 from "chalk";
1701
- import sortPackageJson from "sort-package-json";
1702
- var packagePublint = /* @__PURE__ */ __name(async (params) => {
1703
- const pkgDir = process.env.INIT_CWD;
1704
- const sortedPkg = sortPackageJson(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
1705
- await fs4.writeFile(`${pkgDir}/package.json`, sortedPkg);
1706
- const pkg = JSON.parse(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
1707
- console.log(chalk25.green(`Publint: ${pkg.name}`));
1708
- console.log(chalk25.gray(pkgDir));
1709
- const { publint: publint2 } = await import("publint");
1710
- const { messages } = await publint2({
1711
- level: "suggestion",
1712
- pkgDir,
1713
- strict: true
1714
- });
1715
- const { formatMessage } = await import("publint/utils");
1716
- const validMessage = /* @__PURE__ */ __name((_message) => {
1717
- return true;
1718
- }, "validMessage");
1719
- const validMessages = messages.filter(validMessage);
1720
- for (const message of validMessages) {
1721
- switch (message.type) {
1722
- case "error": {
1723
- console.error(chalk25.red(`[${message.code}] ${formatMessage(message, pkg)}`));
1724
- break;
1725
- }
1726
- case "warning": {
1727
- console.warn(chalk25.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
1728
- break;
1729
- }
1730
- default: {
1731
- console.log(chalk25.white(`[${message.code}] ${formatMessage(message, pkg)}`));
1732
- break;
1733
- }
1734
- }
1735
- }
1736
- if (params?.verbose) {
1737
- console.log(chalk25.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
1738
- }
1739
- return validMessages.filter((message) => message.type === "error").length;
1740
- }, "packagePublint");
1708
+ import chalk29 from "chalk";
1741
1709
 
1742
1710
  // src/actions/package/compile/packageCompileTsup.ts
1743
- import chalk29 from "chalk";
1711
+ import chalk28 from "chalk";
1744
1712
  import { build as build2, defineConfig } from "tsup";
1745
1713
 
1746
1714
  // src/actions/package/compile/inputs.ts
1747
- import chalk26 from "chalk";
1715
+ import chalk25 from "chalk";
1748
1716
  import { glob as glob2 } from "glob";
1749
1717
  var getAllInputs = /* @__PURE__ */ __name((srcDir, verbose = false) => {
1750
1718
  return [
@@ -1753,7 +1721,7 @@ var getAllInputs = /* @__PURE__ */ __name((srcDir, verbose = false) => {
1753
1721
  }).map((file) => {
1754
1722
  const result = file.slice(Math.max(0, srcDir.length + 1));
1755
1723
  if (verbose) {
1756
- console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
1724
+ console.log(chalk25.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
1757
1725
  }
1758
1726
  return result;
1759
1727
  }),
@@ -1762,7 +1730,7 @@ var getAllInputs = /* @__PURE__ */ __name((srcDir, verbose = false) => {
1762
1730
  }).map((file) => {
1763
1731
  const result = file.slice(Math.max(0, srcDir.length + 1));
1764
1732
  if (verbose) {
1765
- console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
1733
+ console.log(chalk25.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
1766
1734
  }
1767
1735
  return result;
1768
1736
  })
@@ -1829,7 +1797,7 @@ __name(deepMergeObjects, "deepMergeObjects");
1829
1797
 
1830
1798
  // src/actions/package/compile/packageCompileTsc.ts
1831
1799
  import { cwd as cwd2 } from "process";
1832
- import chalk27 from "chalk";
1800
+ import chalk26 from "chalk";
1833
1801
  import { createProgramFromConfig } from "tsc-prog";
1834
1802
  import ts2, { DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys } from "typescript";
1835
1803
 
@@ -1846,7 +1814,7 @@ var getCompilerOptions = /* @__PURE__ */ __name((options = {}, fileName = "tscon
1846
1814
  var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
1847
1815
  const pkg = process.env.INIT_CWD ?? cwd2();
1848
1816
  if (verbose) {
1849
- console.log(chalk27.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
1817
+ console.log(chalk26.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
1850
1818
  }
1851
1819
  const configFilePath = ts2.findConfigFile("./", ts2.sys.fileExists, "tsconfig.json");
1852
1820
  if (configFilePath === void 0) {
@@ -1864,10 +1832,10 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
1864
1832
  emitDeclarationOnly: true,
1865
1833
  noEmit: false
1866
1834
  };
1867
- console.log(chalk27.cyan(`Validating Files: ${entries.length}`));
1835
+ console.log(chalk26.cyan(`Validating Files: ${entries.length}`));
1868
1836
  if (verbose) {
1869
1837
  for (const entry of entries) {
1870
- console.log(chalk27.grey(`Validating: ${entry}`));
1838
+ console.log(chalk26.grey(`Validating: ${entry}`));
1871
1839
  }
1872
1840
  }
1873
1841
  try {
@@ -1896,7 +1864,7 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
1896
1864
  return 0;
1897
1865
  } finally {
1898
1866
  if (verbose) {
1899
- console.log(chalk27.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
1867
+ console.log(chalk26.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
1900
1868
  }
1901
1869
  }
1902
1870
  }, "packageCompileTsc");
@@ -1904,7 +1872,7 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
1904
1872
  // src/actions/package/compile/packageCompileTscTypes.ts
1905
1873
  import path7 from "path";
1906
1874
  import { cwd as cwd3 } from "process";
1907
- import chalk28 from "chalk";
1875
+ import chalk27 from "chalk";
1908
1876
  import { rollup } from "rollup";
1909
1877
  import dts from "rollup-plugin-dts";
1910
1878
  import nodeExternals from "rollup-plugin-node-externals";
@@ -1937,8 +1905,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
1937
1905
  if (ignoredWarningCodes.has(warning.code ?? "")) {
1938
1906
  return;
1939
1907
  }
1940
- console.warn(chalk28.yellow(`[${warning.code}] ${warning.message}`));
1941
- console.warn(chalk28.gray(inputPath));
1908
+ console.warn(chalk27.yellow(`[${warning.code}] ${warning.message}`));
1909
+ console.warn(chalk27.gray(inputPath));
1942
1910
  warn(warning);
1943
1911
  }
1944
1912
  });
@@ -1948,8 +1916,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
1948
1916
  });
1949
1917
  } catch (ex) {
1950
1918
  const error = ex;
1951
- console.warn(chalk28.red(error));
1952
- console.warn(chalk28.gray(inputPath));
1919
+ console.warn(chalk27.red(error));
1920
+ console.warn(chalk27.gray(inputPath));
1953
1921
  }
1954
1922
  if (verbose) {
1955
1923
  console.log(`Bundled declarations written to ${outputPath}`);
@@ -1958,7 +1926,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
1958
1926
  __name(bundleDts, "bundleDts");
1959
1927
  var packageCompileTscTypes = /* @__PURE__ */ __name(async (entries, outDir, platform, srcDir = "build", verbose = false) => {
1960
1928
  if (verbose) {
1961
- console.log(chalk28.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
1929
+ console.log(chalk27.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
1962
1930
  console.log(`Entries: ${entries.join(", ")}`);
1963
1931
  }
1964
1932
  const pkg = process.env.INIT_CWD ?? cwd3();
@@ -1987,7 +1955,7 @@ var packageCompileTscTypes = /* @__PURE__ */ __name(async (entries, outDir, plat
1987
1955
  }, verbose);
1988
1956
  }));
1989
1957
  if (verbose) {
1990
- console.log(chalk28.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
1958
+ console.log(chalk27.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
1991
1959
  }
1992
1960
  return 0;
1993
1961
  }, "packageCompileTscTypes");
@@ -1999,15 +1967,15 @@ var compileFolder = /* @__PURE__ */ __name(async (srcDir, entries, buildDir, opt
1999
1967
  console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
2000
1968
  }
2001
1969
  if (entries.length === 0) {
2002
- console.warn(chalk29.yellow(`No entries found in ${srcDir} to compile`));
1970
+ console.warn(chalk28.yellow(`No entries found in ${srcDir} to compile`));
2003
1971
  return 0;
2004
1972
  }
2005
1973
  if (verbose) {
2006
- console.log(chalk29.gray(`buildDir [${buildDir}]`));
1974
+ console.log(chalk28.gray(`buildDir [${buildDir}]`));
2007
1975
  }
2008
1976
  const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
2009
1977
  if (validationResult !== 0) {
2010
- console.error(chalk29.red(`Compile:Validation had ${validationResult} errors`));
1978
+ console.error(chalk28.red(`Compile:Validation had ${validationResult} errors`));
2011
1979
  return validationResult;
2012
1980
  }
2013
1981
  const optionsParams = tsupOptions([
@@ -2040,12 +2008,12 @@ var compileFolder = /* @__PURE__ */ __name(async (srcDir, entries, buildDir, opt
2040
2008
  ];
2041
2009
  }))).flat();
2042
2010
  if (verbose) {
2043
- console.log(chalk29.cyan(`TSUP:build:start [${srcDir}]`));
2044
- console.log(chalk29.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
2011
+ console.log(chalk28.cyan(`TSUP:build:start [${srcDir}]`));
2012
+ console.log(chalk28.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
2045
2013
  }
2046
2014
  await Promise.all(optionsList.map((options2) => build2(options2)));
2047
2015
  if (verbose) {
2048
- console.log(chalk29.cyan(`TSUP:build:stop [${srcDir}]`));
2016
+ console.log(chalk28.cyan(`TSUP:build:stop [${srcDir}]`));
2049
2017
  }
2050
2018
  if (bundleTypes) {
2051
2019
  await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
@@ -2153,19 +2121,14 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
2153
2121
  // src/actions/package/compile/compile.ts
2154
2122
  var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}) => {
2155
2123
  const pkg = process.env.INIT_CWD;
2156
- console.log(chalk30.green(`Compiling ${pkg}`));
2124
+ console.log(chalk29.green(`Compiling ${pkg}`));
2157
2125
  const config2 = await loadConfig(inConfig);
2158
- const publint2 = config2.publint;
2159
- const tsupResults = await packageCompileTsup(config2);
2160
- if (tsupResults > 0) {
2161
- return tsupResults;
2162
- }
2163
- return publint2 ? await packagePublint(config2) : 0;
2126
+ return await packageCompileTsup(config2);
2164
2127
  }, "packageCompile");
2165
2128
 
2166
2129
  // src/actions/package/copy-assets.ts
2167
2130
  import path8 from "path/posix";
2168
- import chalk31 from "chalk";
2131
+ import chalk30 from "chalk";
2169
2132
  import cpy2 from "cpy";
2170
2133
  var copyTargetAssets2 = /* @__PURE__ */ __name(async (target, name, location) => {
2171
2134
  try {
@@ -2184,7 +2147,7 @@ var copyTargetAssets2 = /* @__PURE__ */ __name(async (target, name, location) =>
2184
2147
  flat: false
2185
2148
  });
2186
2149
  if (values.length > 0) {
2187
- console.log(chalk31.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
2150
+ console.log(chalk30.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
2188
2151
  }
2189
2152
  for (const value of values) {
2190
2153
  console.log(`${value.split("/").pop()} => ./dist/${target}`);
@@ -2257,7 +2220,7 @@ var packageCycle = /* @__PURE__ */ __name(async () => {
2257
2220
  // src/actions/package/gen-docs.ts
2258
2221
  import { existsSync as existsSync5 } from "fs";
2259
2222
  import path9 from "path";
2260
- import chalk32 from "chalk";
2223
+ import chalk31 from "chalk";
2261
2224
  import { Application, ArgumentsReader, TSConfigReader, TypeDocReader } from "typedoc";
2262
2225
  var ExitCodes = {
2263
2226
  CompileError: 3,
@@ -2270,7 +2233,7 @@ var ExitCodes = {
2270
2233
  };
2271
2234
  var packageGenDocs = /* @__PURE__ */ __name(async () => {
2272
2235
  const pkg = process.env.INIT_CWD;
2273
- if (pkg && !existsSync5(path9.join(pkg, "typedoc.json"))) {
2236
+ if (pkg !== void 0 && !existsSync5(path9.join(pkg, "typedoc.json"))) {
2274
2237
  return;
2275
2238
  }
2276
2239
  const app = await Application.bootstrap({
@@ -2359,7 +2322,7 @@ var runTypeDoc = /* @__PURE__ */ __name(async (app) => {
2359
2322
  return ExitCodes.OutputError;
2360
2323
  }
2361
2324
  }
2362
- console.log(chalk32.green(`${pkgName} - Ok`));
2325
+ console.log(chalk31.green(`${pkgName} - Ok`));
2363
2326
  return ExitCodes.Ok;
2364
2327
  }, "runTypeDoc");
2365
2328
 
@@ -2368,7 +2331,7 @@ import { readdirSync } from "fs";
2368
2331
  import path10 from "path";
2369
2332
  import { cwd as cwd4 } from "process";
2370
2333
  import { pathToFileURL } from "url";
2371
- import chalk33 from "chalk";
2334
+ import chalk32 from "chalk";
2372
2335
  import { ESLint } from "eslint";
2373
2336
  import { findUp } from "find-up";
2374
2337
  import picomatch from "picomatch";
@@ -2385,10 +2348,10 @@ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
2385
2348
  ];
2386
2349
  for (const lintResult of lintResults) {
2387
2350
  if (lintResult.messages.length > 0) {
2388
- console.log(chalk33.gray(`
2351
+ console.log(chalk32.gray(`
2389
2352
  ${lintResult.filePath}`));
2390
2353
  for (const message of lintResult.messages) {
2391
- console.log(chalk33.gray(` ${message.line}:${message.column}`), chalk33[colors[message.severity]](` ${severity[message.severity]}`), chalk33.white(` ${message.message}`), chalk33.gray(` ${message.ruleId}`));
2354
+ console.log(chalk32.gray(` ${message.line}:${message.column}`), chalk32[colors[message.severity]](` ${severity[message.severity]}`), chalk32.white(` ${message.message}`), chalk32.gray(` ${message.ruleId}`));
2392
2355
  }
2393
2356
  }
2394
2357
  }
@@ -2443,7 +2406,7 @@ var packageLint = /* @__PURE__ */ __name(async (fix2 = false, verbose = false, c
2443
2406
  });
2444
2407
  const files = getFiles(cwd4(), ignoreFolders);
2445
2408
  if (verbose) {
2446
- console.log(chalk33.green(`Linting ${pkg} [files = ${files.length}]`));
2409
+ console.log(chalk32.green(`Linting ${pkg} [files = ${files.length}]`));
2447
2410
  }
2448
2411
  const lintResults = await engine.lintFiles(files);
2449
2412
  dumpMessages(lintResults);
@@ -2453,10 +2416,71 @@ var packageLint = /* @__PURE__ */ __name(async (fix2 = false, verbose = false, c
2453
2416
  const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
2454
2417
  const lintTime = Date.now() - start;
2455
2418
  const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
2456
- console.log(chalk33.white(`Linted ${chalk33[filesCountColor](files.length)} files in ${chalk33[lintTimeColor](lintTime)}ms`));
2419
+ console.log(chalk32.white(`Linted ${chalk32[filesCountColor](files.length)} files in ${chalk32[lintTimeColor](lintTime)}ms`));
2457
2420
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
2458
2421
  }, "packageLint");
2459
2422
 
2423
+ // src/actions/package/publint.ts
2424
+ import { promises as fs4 } from "fs";
2425
+ import chalk33 from "chalk";
2426
+ import sortPackageJson from "sort-package-json";
2427
+ var customPubLint = /* @__PURE__ */ __name((pkg) => {
2428
+ let errorCount = 0;
2429
+ let warningCount = 0;
2430
+ if (pkg.files === void 0) {
2431
+ console.error(chalk33.yellow('Publint [custom]: "files" field is missing'));
2432
+ warningCount++;
2433
+ }
2434
+ if (pkg.main !== void 0) {
2435
+ console.error(chalk33.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
2436
+ warningCount++;
2437
+ }
2438
+ if (pkg.sideEffects !== false) {
2439
+ console.error(chalk33.yellow('Publint [custom]: "sideEffects" field should be set to false'));
2440
+ warningCount++;
2441
+ }
2442
+ return [
2443
+ errorCount,
2444
+ warningCount
2445
+ ];
2446
+ }, "customPubLint");
2447
+ var packagePublint = /* @__PURE__ */ __name(async ({ strict = true, verbose = false } = {}) => {
2448
+ const pkgDir = process.env.INIT_CWD;
2449
+ const sortedPkg = sortPackageJson(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
2450
+ await fs4.writeFile(`${pkgDir}/package.json`, sortedPkg);
2451
+ const pkg = JSON.parse(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
2452
+ console.log(chalk33.green(`Publint: ${pkg.name}`));
2453
+ console.log(chalk33.gray(pkgDir));
2454
+ const { publint: publint2 } = await import("publint");
2455
+ const { messages } = await publint2({
2456
+ level: "suggestion",
2457
+ pkgDir,
2458
+ strict
2459
+ });
2460
+ const { formatMessage } = await import("publint/utils");
2461
+ for (const message of messages) {
2462
+ switch (message.type) {
2463
+ case "error": {
2464
+ console.error(chalk33.red(`[${message.code}] ${formatMessage(message, pkg)}`));
2465
+ break;
2466
+ }
2467
+ case "warning": {
2468
+ console.warn(chalk33.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
2469
+ break;
2470
+ }
2471
+ default: {
2472
+ console.log(chalk33.white(`[${message.code}] ${formatMessage(message, pkg)}`));
2473
+ break;
2474
+ }
2475
+ }
2476
+ }
2477
+ const [errorCount, warningCount] = customPubLint(pkg);
2478
+ if (verbose) {
2479
+ console.log(chalk33.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
2480
+ }
2481
+ return messages.filter((message) => message.type === "error").length + errorCount;
2482
+ }, "packagePublint");
2483
+
2460
2484
  // src/actions/package/recompile.ts
2461
2485
  var packageRecompile = /* @__PURE__ */ __name(async () => {
2462
2486
  return await packageClean() || await packageCompile();
@@ -2464,10 +2488,10 @@ var packageRecompile = /* @__PURE__ */ __name(async () => {
2464
2488
 
2465
2489
  // src/actions/publint.ts
2466
2490
  var publint = /* @__PURE__ */ __name(async ({ verbose, pkg }) => {
2467
- return pkg ? await publintPackage({
2468
- pkg,
2491
+ return pkg === void 0 ? publintAll({
2469
2492
  verbose
2470
- }) : publintAll({
2493
+ }) : await publintPackage({
2494
+ pkg,
2471
2495
  verbose
2472
2496
  });
2473
2497
  }, "publint");
@@ -3148,7 +3172,8 @@ var xyLintCommands = /* @__PURE__ */ __name((args) => {
3148
3172
  pkg: argv.package,
3149
3173
  deps: !!argv.deps,
3150
3174
  devDeps: !!argv.devDeps,
3151
- peerDeps: !!argv.peerDeps
3175
+ peerDeps: !!argv.peerDeps,
3176
+ verbose: !!argv.verbose
3152
3177
  });
3153
3178
  console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
3154
3179
  }).command("fix [package]", "Fix - Run Eslint w/fix", (yargs2) => {