@xylabs/ts-scripts-yarn3 7.1.7 → 7.2.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 (38) hide show
  1. package/dist/actions/deplint/checkPackage/checkPackage.mjs +12 -1
  2. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/index.mjs +12 -1
  4. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  5. package/dist/actions/deplint/deplint.mjs +12 -1
  6. package/dist/actions/deplint/deplint.mjs.map +1 -1
  7. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +12 -1
  8. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
  9. package/dist/actions/deplint/getImportsFromFile.mjs +14 -2
  10. package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -1
  11. package/dist/actions/deplint/index.mjs +12 -1
  12. package/dist/actions/deplint/index.mjs.map +1 -1
  13. package/dist/actions/gitignore-gen.mjs +1 -1
  14. package/dist/actions/gitignore-gen.mjs.map +1 -1
  15. package/dist/actions/index.mjs +39 -23
  16. package/dist/actions/index.mjs.map +1 -1
  17. package/dist/actions/npmignore-gen.mjs +1 -1
  18. package/dist/actions/npmignore-gen.mjs.map +1 -1
  19. package/dist/actions/relint.mjs +26 -21
  20. package/dist/actions/relint.mjs.map +1 -1
  21. package/dist/bin/xy.mjs +39 -23
  22. package/dist/bin/xy.mjs.map +1 -1
  23. package/dist/index.d.ts +5 -3
  24. package/dist/index.mjs +39 -23
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/lib/generateIgnoreFiles.mjs +1 -1
  27. package/dist/lib/generateIgnoreFiles.mjs.map +1 -1
  28. package/dist/lib/index.mjs +1 -1
  29. package/dist/lib/index.mjs.map +1 -1
  30. package/dist/xy/index.mjs +39 -23
  31. package/dist/xy/index.mjs.map +1 -1
  32. package/dist/xy/xy.mjs +39 -23
  33. package/dist/xy/xy.mjs.map +1 -1
  34. package/dist/xy/xyCommonCommands.mjs +1 -1
  35. package/dist/xy/xyCommonCommands.mjs.map +1 -1
  36. package/dist/xy/xyLintCommands.mjs +38 -22
  37. package/dist/xy/xyLintCommands.mjs.map +1 -1
  38. package/package.json +19 -19
package/dist/index.d.ts CHANGED
@@ -371,6 +371,8 @@ declare const recompileAll: ({ jobs, verbose, target, incremental, }: RecompileP
371
371
  declare const reinstall: () => number;
372
372
 
373
373
  interface RelintParams {
374
+ cache?: boolean;
375
+ fix?: boolean;
374
376
  incremental?: boolean;
375
377
  pkg?: string;
376
378
  verbose?: boolean;
@@ -379,9 +381,9 @@ interface RelintPackageParams {
379
381
  pkg: string;
380
382
  verbose?: boolean;
381
383
  }
382
- declare const relintPackage: ({ pkg }: RelintParams & Required<Pick<RelintParams, "pkg">>) => number;
383
- declare const relint: ({ pkg, verbose, incremental, }?: RelintParams) => number;
384
- declare const relintAllPackages: ({ verbose, incremental }?: RelintParams) => number;
384
+ declare const relintPackage: ({ pkg, fix, verbose, }: RelintParams & Required<Pick<RelintParams, "pkg">>) => number;
385
+ declare const relint: ({ pkg, verbose, incremental, fix, }?: RelintParams) => number;
386
+ declare const relintAllPackages: ({ fix }?: RelintParams) => number;
385
387
 
386
388
  declare const retest: () => number;
387
389
 
package/dist/index.mjs CHANGED
@@ -329,7 +329,7 @@ var INIT_CWD = () => {
329
329
 
330
330
  // src/lib/generateIgnoreFiles.ts
331
331
  var localeCompare = (a, b) => a.localeCompare(b);
332
- var mergeEntries = (a, b) => [...union(a, b)].sort(localeCompare);
332
+ var mergeEntries = (a, b) => [...union(a, b)].toSorted(localeCompare);
333
333
  var generateIgnoreFiles = (filename3, pkg) => {
334
334
  console.log(chalk4.green(`Generate ${filename3} Files`));
335
335
  const cwd5 = INIT_CWD() ?? ".";
@@ -744,6 +744,17 @@ function getBasePackageName(importName) {
744
744
  }
745
745
 
746
746
  // src/actions/deplint/getImportsFromFile.ts
747
+ function isTypeOnlyImportClause(clause) {
748
+ if (clause === void 0) {
749
+ return false;
750
+ }
751
+ if ("phaseModifier" in clause) {
752
+ const mod = clause.phaseModifier;
753
+ const kind = typeof mod === "number" ? mod : mod?.kind;
754
+ return kind === ts.SyntaxKind.TypeKeyword;
755
+ }
756
+ return clause.isTypeOnly;
757
+ }
747
758
  function getImportsFromFile(filePath, importPaths, typeImportPaths) {
748
759
  const sourceCode = fs3.readFileSync(filePath, "utf8");
749
760
  const isMjsFile = filePath.endsWith(".mjs");
@@ -760,7 +771,7 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
760
771
  function visit(node) {
761
772
  if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
762
773
  const moduleSpecifier = node.moduleSpecifier?.getFullText();
763
- const isTypeImport = ts.isImportDeclaration(node) ? node.importClause?.isTypeOnly ?? false : false;
774
+ const isTypeImport = ts.isImportDeclaration(node) ? isTypeOnlyImportClause(node.importClause) : false;
764
775
  if (typeof moduleSpecifier === "string") {
765
776
  const trimmed = moduleSpecifier.replaceAll("'", "").replaceAll('"', "").trim();
766
777
  if (isTypeImport || isDeclarationFile) {
@@ -2217,43 +2228,48 @@ var reinstall = () => {
2217
2228
 
2218
2229
  // src/actions/relint.ts
2219
2230
  import chalk35 from "chalk";
2220
- var relintPackage = ({ pkg }) => {
2221
- console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
2231
+ var relintPackage = ({
2232
+ pkg,
2233
+ fix: fix2,
2234
+ verbose
2235
+ }) => {
2236
+ console.log(chalk35.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
2222
2237
  const start = Date.now();
2223
- const result = runSteps("Relint [All-Packages]", [
2238
+ const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
2224
2239
  ["yarn", [
2225
2240
  "workspace",
2226
2241
  pkg,
2227
2242
  "run",
2228
- "package-relint"
2243
+ fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
2229
2244
  ]]
2230
2245
  ]);
2231
- console.log(chalk35.gray(`${"Relinted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
2246
+ console.log(chalk35.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
2232
2247
  return result;
2233
2248
  };
2234
2249
  var relint = ({
2235
2250
  pkg,
2236
2251
  verbose,
2237
- incremental
2252
+ incremental,
2253
+ fix: fix2
2238
2254
  } = {}) => {
2239
- return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
2255
+ return pkg === void 0 ? relintAllPackages({
2256
+ verbose,
2257
+ incremental,
2258
+ fix: fix2
2259
+ }) : relintPackage({
2260
+ pkg,
2261
+ fix: fix2,
2262
+ verbose
2263
+ });
2240
2264
  };
2241
- var relintAllPackages = ({ verbose = false, incremental } = {}) => {
2242
- console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
2265
+ var relintAllPackages = ({ fix: fix2 = false } = {}) => {
2266
+ console.log(chalk35.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
2243
2267
  const start = Date.now();
2244
- const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
2245
- const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
2246
- const result = runSteps(`${"Relint"} [All-Packages]`, [
2247
- ["yarn", [
2248
- "workspaces",
2249
- "foreach",
2250
- ...verboseOptions,
2251
- ...incrementalOptions,
2252
- "run",
2253
- "package-relint"
2254
- ]]
2268
+ const fixOptions = fix2 ? ["--fix"] : [];
2269
+ const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
2270
+ ["yarn", ["eslint", ...fixOptions]]
2255
2271
  ]);
2256
- console.log(chalk35.gray(`Relinted in [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
2272
+ console.log(chalk35.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
2257
2273
  return result;
2258
2274
  };
2259
2275