@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
@@ -87,58 +87,14 @@ var packageClean = /* @__PURE__ */ __name(async () => {
87
87
  }, "packageClean");
88
88
 
89
89
  // src/actions/package/compile/compile.ts
90
- import chalk9 from "chalk";
91
-
92
- // src/actions/package/publint.ts
93
- import { promises as fs2 } from "fs";
94
- import chalk4 from "chalk";
95
- import sortPackageJson from "sort-package-json";
96
- var packagePublint = /* @__PURE__ */ __name(async (params) => {
97
- const pkgDir = process.env.INIT_CWD;
98
- const sortedPkg = sortPackageJson(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
99
- await fs2.writeFile(`${pkgDir}/package.json`, sortedPkg);
100
- const pkg = JSON.parse(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
101
- console.log(chalk4.green(`Publint: ${pkg.name}`));
102
- console.log(chalk4.gray(pkgDir));
103
- const { publint } = await import("publint");
104
- const { messages } = await publint({
105
- level: "suggestion",
106
- pkgDir,
107
- strict: true
108
- });
109
- const { formatMessage } = await import("publint/utils");
110
- const validMessage = /* @__PURE__ */ __name((_message) => {
111
- return true;
112
- }, "validMessage");
113
- const validMessages = messages.filter(validMessage);
114
- for (const message of validMessages) {
115
- switch (message.type) {
116
- case "error": {
117
- console.error(chalk4.red(`[${message.code}] ${formatMessage(message, pkg)}`));
118
- break;
119
- }
120
- case "warning": {
121
- console.warn(chalk4.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
122
- break;
123
- }
124
- default: {
125
- console.log(chalk4.white(`[${message.code}] ${formatMessage(message, pkg)}`));
126
- break;
127
- }
128
- }
129
- }
130
- if (params?.verbose) {
131
- console.log(chalk4.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
132
- }
133
- return validMessages.filter((message) => message.type === "error").length;
134
- }, "packagePublint");
90
+ import chalk8 from "chalk";
135
91
 
136
92
  // src/actions/package/compile/packageCompileTsup.ts
137
- import chalk8 from "chalk";
93
+ import chalk7 from "chalk";
138
94
  import { build, defineConfig } from "tsup";
139
95
 
140
96
  // src/actions/package/compile/inputs.ts
141
- import chalk5 from "chalk";
97
+ import chalk4 from "chalk";
142
98
  import { glob as glob2 } from "glob";
143
99
  var getAllInputs = /* @__PURE__ */ __name((srcDir, verbose = false) => {
144
100
  return [
@@ -147,7 +103,7 @@ var getAllInputs = /* @__PURE__ */ __name((srcDir, verbose = false) => {
147
103
  }).map((file) => {
148
104
  const result = file.slice(Math.max(0, srcDir.length + 1));
149
105
  if (verbose) {
150
- console.log(chalk5.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
106
+ console.log(chalk4.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
151
107
  }
152
108
  return result;
153
109
  }),
@@ -156,7 +112,7 @@ var getAllInputs = /* @__PURE__ */ __name((srcDir, verbose = false) => {
156
112
  }).map((file) => {
157
113
  const result = file.slice(Math.max(0, srcDir.length + 1));
158
114
  if (verbose) {
159
- console.log(chalk5.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
115
+ console.log(chalk4.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
160
116
  }
161
117
  return result;
162
118
  })
@@ -223,7 +179,7 @@ __name(deepMergeObjects, "deepMergeObjects");
223
179
 
224
180
  // src/actions/package/compile/packageCompileTsc.ts
225
181
  import { cwd as cwd2 } from "process";
226
- import chalk6 from "chalk";
182
+ import chalk5 from "chalk";
227
183
  import { createProgramFromConfig } from "tsc-prog";
228
184
  import ts, { DiagnosticCategory, formatDiagnosticsWithColorAndContext, getPreEmitDiagnostics, sys } from "typescript";
229
185
 
@@ -240,7 +196,7 @@ var getCompilerOptions = /* @__PURE__ */ __name((options = {}, fileName = "tscon
240
196
  var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
241
197
  const pkg = process.env.INIT_CWD ?? cwd2();
242
198
  if (verbose) {
243
- console.log(chalk6.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
199
+ console.log(chalk5.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
244
200
  }
245
201
  const configFilePath = ts.findConfigFile("./", ts.sys.fileExists, "tsconfig.json");
246
202
  if (configFilePath === void 0) {
@@ -258,10 +214,10 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
258
214
  emitDeclarationOnly: true,
259
215
  noEmit: false
260
216
  };
261
- console.log(chalk6.cyan(`Validating Files: ${entries.length}`));
217
+ console.log(chalk5.cyan(`Validating Files: ${entries.length}`));
262
218
  if (verbose) {
263
219
  for (const entry of entries) {
264
- console.log(chalk6.grey(`Validating: ${entry}`));
220
+ console.log(chalk5.grey(`Validating: ${entry}`));
265
221
  }
266
222
  }
267
223
  try {
@@ -290,7 +246,7 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
290
246
  return 0;
291
247
  } finally {
292
248
  if (verbose) {
293
- console.log(chalk6.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
249
+ console.log(chalk5.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
294
250
  }
295
251
  }
296
252
  }, "packageCompileTsc");
@@ -298,7 +254,7 @@ var packageCompileTsc = /* @__PURE__ */ __name((platform, entries, srcDir = "src
298
254
  // src/actions/package/compile/packageCompileTscTypes.ts
299
255
  import path3 from "path";
300
256
  import { cwd as cwd3 } from "process";
301
- import chalk7 from "chalk";
257
+ import chalk6 from "chalk";
302
258
  import { rollup } from "rollup";
303
259
  import dts from "rollup-plugin-dts";
304
260
  import nodeExternals from "rollup-plugin-node-externals";
@@ -331,8 +287,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
331
287
  if (ignoredWarningCodes.has(warning.code ?? "")) {
332
288
  return;
333
289
  }
334
- console.warn(chalk7.yellow(`[${warning.code}] ${warning.message}`));
335
- console.warn(chalk7.gray(inputPath));
290
+ console.warn(chalk6.yellow(`[${warning.code}] ${warning.message}`));
291
+ console.warn(chalk6.gray(inputPath));
336
292
  warn(warning);
337
293
  }
338
294
  });
@@ -342,8 +298,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
342
298
  });
343
299
  } catch (ex) {
344
300
  const error = ex;
345
- console.warn(chalk7.red(error));
346
- console.warn(chalk7.gray(inputPath));
301
+ console.warn(chalk6.red(error));
302
+ console.warn(chalk6.gray(inputPath));
347
303
  }
348
304
  if (verbose) {
349
305
  console.log(`Bundled declarations written to ${outputPath}`);
@@ -352,7 +308,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
352
308
  __name(bundleDts, "bundleDts");
353
309
  var packageCompileTscTypes = /* @__PURE__ */ __name(async (entries, outDir, platform, srcDir = "build", verbose = false) => {
354
310
  if (verbose) {
355
- console.log(chalk7.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
311
+ console.log(chalk6.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
356
312
  console.log(`Entries: ${entries.join(", ")}`);
357
313
  }
358
314
  const pkg = process.env.INIT_CWD ?? cwd3();
@@ -381,7 +337,7 @@ var packageCompileTscTypes = /* @__PURE__ */ __name(async (entries, outDir, plat
381
337
  }, verbose);
382
338
  }));
383
339
  if (verbose) {
384
- console.log(chalk7.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
340
+ console.log(chalk6.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
385
341
  }
386
342
  return 0;
387
343
  }, "packageCompileTscTypes");
@@ -393,15 +349,15 @@ var compileFolder = /* @__PURE__ */ __name(async (srcDir, entries, buildDir, opt
393
349
  console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
394
350
  }
395
351
  if (entries.length === 0) {
396
- console.warn(chalk8.yellow(`No entries found in ${srcDir} to compile`));
352
+ console.warn(chalk7.yellow(`No entries found in ${srcDir} to compile`));
397
353
  return 0;
398
354
  }
399
355
  if (verbose) {
400
- console.log(chalk8.gray(`buildDir [${buildDir}]`));
356
+ console.log(chalk7.gray(`buildDir [${buildDir}]`));
401
357
  }
402
358
  const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
403
359
  if (validationResult !== 0) {
404
- console.error(chalk8.red(`Compile:Validation had ${validationResult} errors`));
360
+ console.error(chalk7.red(`Compile:Validation had ${validationResult} errors`));
405
361
  return validationResult;
406
362
  }
407
363
  const optionsParams = tsupOptions([
@@ -434,12 +390,12 @@ var compileFolder = /* @__PURE__ */ __name(async (srcDir, entries, buildDir, opt
434
390
  ];
435
391
  }))).flat();
436
392
  if (verbose) {
437
- console.log(chalk8.cyan(`TSUP:build:start [${srcDir}]`));
438
- console.log(chalk8.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
393
+ console.log(chalk7.cyan(`TSUP:build:start [${srcDir}]`));
394
+ console.log(chalk7.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
439
395
  }
440
396
  await Promise.all(optionsList.map((options2) => build(options2)));
441
397
  if (verbose) {
442
- console.log(chalk8.cyan(`TSUP:build:stop [${srcDir}]`));
398
+ console.log(chalk7.cyan(`TSUP:build:stop [${srcDir}]`));
443
399
  }
444
400
  if (bundleTypes) {
445
401
  await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
@@ -547,19 +503,14 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
547
503
  // src/actions/package/compile/compile.ts
548
504
  var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}) => {
549
505
  const pkg = process.env.INIT_CWD;
550
- console.log(chalk9.green(`Compiling ${pkg}`));
506
+ console.log(chalk8.green(`Compiling ${pkg}`));
551
507
  const config2 = await loadConfig(inConfig);
552
- const publint = config2.publint;
553
- const tsupResults = await packageCompileTsup(config2);
554
- if (tsupResults > 0) {
555
- return tsupResults;
556
- }
557
- return publint ? await packagePublint(config2) : 0;
508
+ return await packageCompileTsup(config2);
558
509
  }, "packageCompile");
559
510
 
560
511
  // src/actions/package/copy-assets.ts
561
512
  import path4 from "path/posix";
562
- import chalk10 from "chalk";
513
+ import chalk9 from "chalk";
563
514
  import cpy from "cpy";
564
515
  var copyTargetAssets = /* @__PURE__ */ __name(async (target, name, location) => {
565
516
  try {
@@ -578,7 +529,7 @@ var copyTargetAssets = /* @__PURE__ */ __name(async (target, name, location) =>
578
529
  flat: false
579
530
  });
580
531
  if (values.length > 0) {
581
- console.log(chalk10.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
532
+ console.log(chalk9.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
582
533
  }
583
534
  for (const value of values) {
584
535
  console.log(`${value.split("/").pop()} => ./dist/${target}`);
@@ -651,7 +602,7 @@ var packageCycle = /* @__PURE__ */ __name(async () => {
651
602
  // src/actions/package/gen-docs.ts
652
603
  import { existsSync } from "fs";
653
604
  import path5 from "path";
654
- import chalk11 from "chalk";
605
+ import chalk10 from "chalk";
655
606
  import { Application, ArgumentsReader, TSConfigReader, TypeDocReader } from "typedoc";
656
607
  var ExitCodes = {
657
608
  CompileError: 3,
@@ -664,7 +615,7 @@ var ExitCodes = {
664
615
  };
665
616
  var packageGenDocs = /* @__PURE__ */ __name(async () => {
666
617
  const pkg = process.env.INIT_CWD;
667
- if (pkg && !existsSync(path5.join(pkg, "typedoc.json"))) {
618
+ if (pkg !== void 0 && !existsSync(path5.join(pkg, "typedoc.json"))) {
668
619
  return;
669
620
  }
670
621
  const app = await Application.bootstrap({
@@ -753,7 +704,7 @@ var runTypeDoc = /* @__PURE__ */ __name(async (app) => {
753
704
  return ExitCodes.OutputError;
754
705
  }
755
706
  }
756
- console.log(chalk11.green(`${pkgName} - Ok`));
707
+ console.log(chalk10.green(`${pkgName} - Ok`));
757
708
  return ExitCodes.Ok;
758
709
  }, "runTypeDoc");
759
710
 
@@ -762,7 +713,7 @@ import { readdirSync } from "fs";
762
713
  import path6 from "path";
763
714
  import { cwd as cwd4 } from "process";
764
715
  import { pathToFileURL } from "url";
765
- import chalk12 from "chalk";
716
+ import chalk11 from "chalk";
766
717
  import { ESLint } from "eslint";
767
718
  import { findUp } from "find-up";
768
719
  import picomatch from "picomatch";
@@ -779,10 +730,10 @@ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
779
730
  ];
780
731
  for (const lintResult of lintResults) {
781
732
  if (lintResult.messages.length > 0) {
782
- console.log(chalk12.gray(`
733
+ console.log(chalk11.gray(`
783
734
  ${lintResult.filePath}`));
784
735
  for (const message of lintResult.messages) {
785
- console.log(chalk12.gray(` ${message.line}:${message.column}`), chalk12[colors[message.severity]](` ${severity[message.severity]}`), chalk12.white(` ${message.message}`), chalk12.gray(` ${message.ruleId}`));
736
+ console.log(chalk11.gray(` ${message.line}:${message.column}`), chalk11[colors[message.severity]](` ${severity[message.severity]}`), chalk11.white(` ${message.message}`), chalk11.gray(` ${message.ruleId}`));
786
737
  }
787
738
  }
788
739
  }
@@ -837,7 +788,7 @@ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, ca
837
788
  });
838
789
  const files = getFiles(cwd4(), ignoreFolders);
839
790
  if (verbose) {
840
- console.log(chalk12.green(`Linting ${pkg} [files = ${files.length}]`));
791
+ console.log(chalk11.green(`Linting ${pkg} [files = ${files.length}]`));
841
792
  }
842
793
  const lintResults = await engine.lintFiles(files);
843
794
  dumpMessages(lintResults);
@@ -847,10 +798,71 @@ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, ca
847
798
  const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
848
799
  const lintTime = Date.now() - start;
849
800
  const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
850
- console.log(chalk12.white(`Linted ${chalk12[filesCountColor](files.length)} files in ${chalk12[lintTimeColor](lintTime)}ms`));
801
+ console.log(chalk11.white(`Linted ${chalk11[filesCountColor](files.length)} files in ${chalk11[lintTimeColor](lintTime)}ms`));
851
802
  return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
852
803
  }, "packageLint");
853
804
 
805
+ // src/actions/package/publint.ts
806
+ import { promises as fs2 } from "fs";
807
+ import chalk12 from "chalk";
808
+ import sortPackageJson from "sort-package-json";
809
+ var customPubLint = /* @__PURE__ */ __name((pkg) => {
810
+ let errorCount = 0;
811
+ let warningCount = 0;
812
+ if (pkg.files === void 0) {
813
+ console.error(chalk12.yellow('Publint [custom]: "files" field is missing'));
814
+ warningCount++;
815
+ }
816
+ if (pkg.main !== void 0) {
817
+ console.error(chalk12.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
818
+ warningCount++;
819
+ }
820
+ if (pkg.sideEffects !== false) {
821
+ console.error(chalk12.yellow('Publint [custom]: "sideEffects" field should be set to false'));
822
+ warningCount++;
823
+ }
824
+ return [
825
+ errorCount,
826
+ warningCount
827
+ ];
828
+ }, "customPubLint");
829
+ var packagePublint = /* @__PURE__ */ __name(async ({ strict = true, verbose = false } = {}) => {
830
+ const pkgDir = process.env.INIT_CWD;
831
+ const sortedPkg = sortPackageJson(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
832
+ await fs2.writeFile(`${pkgDir}/package.json`, sortedPkg);
833
+ const pkg = JSON.parse(await fs2.readFile(`${pkgDir}/package.json`, "utf8"));
834
+ console.log(chalk12.green(`Publint: ${pkg.name}`));
835
+ console.log(chalk12.gray(pkgDir));
836
+ const { publint } = await import("publint");
837
+ const { messages } = await publint({
838
+ level: "suggestion",
839
+ pkgDir,
840
+ strict
841
+ });
842
+ const { formatMessage } = await import("publint/utils");
843
+ for (const message of messages) {
844
+ switch (message.type) {
845
+ case "error": {
846
+ console.error(chalk12.red(`[${message.code}] ${formatMessage(message, pkg)}`));
847
+ break;
848
+ }
849
+ case "warning": {
850
+ console.warn(chalk12.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
851
+ break;
852
+ }
853
+ default: {
854
+ console.log(chalk12.white(`[${message.code}] ${formatMessage(message, pkg)}`));
855
+ break;
856
+ }
857
+ }
858
+ }
859
+ const [errorCount, warningCount] = customPubLint(pkg);
860
+ if (verbose) {
861
+ console.log(chalk12.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
862
+ }
863
+ return messages.filter((message) => message.type === "error").length + errorCount;
864
+ }, "packagePublint");
865
+
854
866
  // src/actions/package/recompile.ts
855
867
  var packageRecompile = /* @__PURE__ */ __name(async () => {
856
868
  return await packageClean() || await packageCompile();