@xylabs/ts-scripts-yarn3 7.3.2 → 7.4.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.
Files changed (41) hide show
  1. package/dist/actions/cycle.mjs +1 -1
  2. package/dist/actions/cycle.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/checkPackage.mjs +316 -35
  4. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  5. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +13 -6
  6. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
  7. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +3 -1
  8. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
  9. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +213 -0
  10. package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
  11. package/dist/actions/deplint/checkPackage/index.mjs +316 -35
  12. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  13. package/dist/actions/deplint/deplint.mjs +319 -38
  14. package/dist/actions/deplint/deplint.mjs.map +1 -1
  15. package/dist/actions/deplint/findFiles.mjs +8 -2
  16. package/dist/actions/deplint/findFiles.mjs.map +1 -1
  17. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +44 -0
  18. package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
  19. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +15 -1
  20. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
  21. package/dist/actions/deplint/getRequiredPeerDependencies.mjs +36 -0
  22. package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +1 -0
  23. package/dist/actions/deplint/getScriptReferencedPackages.mjs +81 -0
  24. package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -0
  25. package/dist/actions/deplint/implicitDevDependencies.mjs +75 -0
  26. package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
  27. package/dist/actions/deplint/index.mjs +319 -38
  28. package/dist/actions/deplint/index.mjs.map +1 -1
  29. package/dist/actions/index.mjs +423 -142
  30. package/dist/actions/index.mjs.map +1 -1
  31. package/dist/bin/xy.mjs +366 -85
  32. package/dist/bin/xy.mjs.map +1 -1
  33. package/dist/index.mjs +435 -154
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/xy/index.mjs +366 -85
  36. package/dist/xy/index.mjs.map +1 -1
  37. package/dist/xy/xy.mjs +366 -85
  38. package/dist/xy/xy.mjs.map +1 -1
  39. package/dist/xy/xyLintCommands.mjs +339 -58
  40. package/dist/xy/xyLintCommands.mjs.map +1 -1
  41. package/package.json +15 -16
@@ -1,5 +1,5 @@
1
1
  // src/xy/xyLintCommands.ts
2
- import chalk12 from "chalk";
2
+ import chalk13 from "chalk";
3
3
 
4
4
  // src/lib/checkResult.ts
5
5
  import chalk from "chalk";
@@ -202,7 +202,7 @@ var cycleAll = async ({ verbose = false }) => {
202
202
  combinedDependencies: true,
203
203
  outputType: verbose ? "text" : "err"
204
204
  };
205
- const target = "**/src";
205
+ const target = "**/packages/*/src";
206
206
  console.log(`Checking for circular dependencies in ${target}...`);
207
207
  const result = await cruise([target], cruiseOptions);
208
208
  if (result.output) {
@@ -217,7 +217,7 @@ var cycleAll = async ({ verbose = false }) => {
217
217
  };
218
218
 
219
219
  // src/actions/deplint/deplint.ts
220
- import chalk9 from "chalk";
220
+ import chalk10 from "chalk";
221
221
 
222
222
  // src/actions/deplint/findFilesByGlob.ts
223
223
  import { globSync } from "glob";
@@ -226,12 +226,18 @@ function findFilesByGlob(cwd, pattern) {
226
226
  }
227
227
 
228
228
  // src/actions/deplint/findFiles.ts
229
- function findFiles(path3) {
230
- const allSourceInclude = ["./src/**/*.{ts,tsx}"];
229
+ function findFiles(path5) {
230
+ const allSourceInclude = ["./src/**/*.{ts,tsx,mts,cts,js,mjs,cjs}"];
231
231
  const allDistInclude = ["./dist/**/*.d.ts", "./dist/**/*.{mjs,js,cjs}"];
232
- const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path3, pattern));
233
- const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path3, pattern));
234
- return { srcFiles, distFiles };
232
+ const allConfigInclude = ["./*.config.{ts,mts,mjs,js}"];
233
+ const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path5, pattern));
234
+ const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path5, pattern));
235
+ const configFiles = allConfigInclude.flatMap((pattern) => findFilesByGlob(path5, pattern));
236
+ return {
237
+ srcFiles,
238
+ distFiles,
239
+ configFiles
240
+ };
235
241
  }
236
242
 
237
243
  // src/actions/deplint/getDependenciesFromPackageJson.ts
@@ -251,10 +257,9 @@ function getDependenciesFromPackageJson(packageJsonPath) {
251
257
  };
252
258
  }
253
259
 
254
- // src/actions/deplint/getImportsFromFile.ts
260
+ // src/actions/deplint/getExtendsFromTsconfigs.ts
255
261
  import fs2 from "fs";
256
- import path2 from "path";
257
- import ts from "typescript";
262
+ import { globSync as globSync2 } from "glob";
258
263
 
259
264
  // src/actions/deplint/getBasePackageName.ts
260
265
  function getBasePackageName(importName) {
@@ -266,7 +271,37 @@ function getBasePackageName(importName) {
266
271
  return importNameScrubbed.split("/")[0];
267
272
  }
268
273
 
274
+ // src/actions/deplint/getExtendsFromTsconfigs.ts
275
+ var isExternalReference = (ref) => !ref.startsWith(".") && !ref.startsWith("/");
276
+ function parseExtendsField(value) {
277
+ if (typeof value === "string") return [value];
278
+ if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
279
+ return [];
280
+ }
281
+ function getExtendsFromTsconfigs(location) {
282
+ const tsconfigFiles = globSync2("./tsconfig*.json", { cwd: location, absolute: true });
283
+ const packages = /* @__PURE__ */ new Set();
284
+ for (const file of tsconfigFiles) {
285
+ try {
286
+ const content = fs2.readFileSync(file, "utf8");
287
+ const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
288
+ const parsed = JSON.parse(cleaned);
289
+ const refs = parseExtendsField(parsed.extends);
290
+ for (const ref of refs) {
291
+ if (isExternalReference(ref)) {
292
+ packages.add(getBasePackageName(ref));
293
+ }
294
+ }
295
+ } catch {
296
+ }
297
+ }
298
+ return [...packages];
299
+ }
300
+
269
301
  // src/actions/deplint/getImportsFromFile.ts
302
+ import fs3 from "fs";
303
+ import path2 from "path";
304
+ import ts from "typescript";
270
305
  function isTypeOnlyImportClause(clause) {
271
306
  if (clause === void 0) {
272
307
  return false;
@@ -279,7 +314,7 @@ function isTypeOnlyImportClause(clause) {
279
314
  return clause.isTypeOnly;
280
315
  }
281
316
  function getImportsFromFile(filePath, importPaths, typeImportPaths) {
282
- const sourceCode = fs2.readFileSync(filePath, "utf8");
317
+ const sourceCode = fs3.readFileSync(filePath, "utf8");
283
318
  const isMjsFile = filePath.endsWith(".mjs");
284
319
  const sourceFile = ts.createSourceFile(
285
320
  path2.basename(filePath),
@@ -332,24 +367,38 @@ var internalImportPrefixes = [".", "#", "node:"];
332
367
  var removeInternalImports = (imports) => {
333
368
  return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
334
369
  };
335
- function getExternalImportsFromFiles({ srcFiles, distFiles }) {
370
+ function getExternalImportsFromFiles({
371
+ srcFiles,
372
+ distFiles,
373
+ configFiles = [],
374
+ tsconfigExtends = []
375
+ }) {
336
376
  const srcImportPaths = {};
337
377
  const distImportPaths = {};
338
378
  const distTypeImportPaths = {};
339
- for (const path3 of srcFiles) getImportsFromFile(path3, srcImportPaths, srcImportPaths).flat();
379
+ const configImportPaths = {};
380
+ for (const path5 of srcFiles) getImportsFromFile(path5, srcImportPaths, srcImportPaths).flat();
381
+ for (const path5 of configFiles) getImportsFromFile(path5, configImportPaths, configImportPaths).flat();
340
382
  const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
341
383
  const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
342
- for (const path3 of distCodeFiles) getImportsFromFile(path3, distImportPaths, distImportPaths).flat();
343
- for (const path3 of distTypeFiles) getImportsFromFile(path3, distTypeImportPaths, distTypeImportPaths).flat();
384
+ for (const path5 of distCodeFiles) getImportsFromFile(path5, distImportPaths, distImportPaths).flat();
385
+ for (const path5 of distTypeFiles) getImportsFromFile(path5, distTypeImportPaths, distTypeImportPaths).flat();
344
386
  const srcImports = Object.keys(srcImportPaths);
345
387
  const distImports = Object.keys(distImportPaths);
346
388
  const distTypeImports = Object.keys(distTypeImportPaths);
347
389
  const externalSrcImports = removeInternalImports(srcImports);
348
390
  const externalDistImports = removeInternalImports(distImports);
349
391
  const externalDistTypeImports = removeInternalImports(distTypeImports);
392
+ const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
393
+ for (const ext of tsconfigExtends) {
394
+ if (!externalSrcImports.includes(ext)) externalSrcImports.push(ext);
395
+ if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
396
+ }
350
397
  return {
398
+ configImportPaths,
351
399
  srcImports,
352
400
  srcImportPaths,
401
+ externalConfigImports,
353
402
  externalSrcImports,
354
403
  distImports,
355
404
  distImportPaths,
@@ -361,6 +410,15 @@ function getExternalImportsFromFiles({ srcFiles, distFiles }) {
361
410
  // src/actions/deplint/checkPackage/getUnlistedDependencies.ts
362
411
  import { builtinModules } from "module";
363
412
  import chalk5 from "chalk";
413
+ function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
414
+ return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
415
+ }
416
+ function logMissing(name, imp, importPaths) {
417
+ console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
418
+ if (importPaths[imp]) {
419
+ console.log(` ${importPaths[imp].join("\n ")}`);
420
+ }
421
+ }
364
422
  function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, {
365
423
  externalDistImports,
366
424
  externalDistTypeImports,
@@ -368,17 +426,15 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
368
426
  }) {
369
427
  let unlistedDependencies = 0;
370
428
  for (const imp of externalDistImports) {
371
- if (!dependencies.includes(imp) && imp !== name && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && !builtinModules.includes(`@types/${imp}`)) {
429
+ if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
372
430
  unlistedDependencies++;
373
- console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
374
- console.log(` ${distImportPaths[imp].join("\n ")}`);
431
+ logMissing(name, imp, distImportPaths);
375
432
  }
376
433
  }
377
434
  for (const imp of externalDistTypeImports) {
378
- if (!dependencies.includes(imp) && imp !== name && dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && builtinModules.includes(`@types/${imp}`)) {
435
+ if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
379
436
  unlistedDependencies++;
380
- console.log(`[${chalk5.blue(name)}] Missing dependency in package.json: ${chalk5.red(imp)}`);
381
- console.log(` ${distImportPaths[imp].join("\n ")}`);
437
+ logMissing(name, imp, distImportPaths);
382
438
  }
383
439
  }
384
440
  if (unlistedDependencies > 0) {
@@ -406,7 +462,9 @@ function getUnlistedDevDependencies({ name, location }, {
406
462
  if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
407
463
  unlistedDevDependencies++;
408
464
  console.log(`[${chalk6.blue(name)}] Missing devDependency in package.json: ${chalk6.red(imp)}`);
409
- console.log(` ${srcImportPaths[imp].join("\n ")}`);
465
+ if (srcImportPaths[imp]) {
466
+ console.log(` ${srcImportPaths[imp].join("\n ")}`);
467
+ }
410
468
  }
411
469
  }
412
470
  if (unlistedDevDependencies > 0) {
@@ -443,29 +501,243 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
443
501
  return unusedDependencies;
444
502
  }
445
503
 
446
- // src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
504
+ // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
447
505
  import chalk8 from "chalk";
506
+
507
+ // src/actions/deplint/getRequiredPeerDependencies.ts
508
+ import fs4 from "fs";
509
+ import path3 from "path";
510
+ function findDepPackageJson(location, dep) {
511
+ let dir = location;
512
+ while (true) {
513
+ const candidate = path3.join(dir, "node_modules", dep, "package.json");
514
+ if (fs4.existsSync(candidate)) return candidate;
515
+ const parent = path3.dirname(dir);
516
+ if (parent === dir) return void 0;
517
+ dir = parent;
518
+ }
519
+ }
520
+ function getRequiredPeerDependencies(location, allDeps) {
521
+ const required = /* @__PURE__ */ new Set();
522
+ for (const dep of allDeps) {
523
+ const depPkgPath = findDepPackageJson(location, dep);
524
+ if (!depPkgPath) continue;
525
+ try {
526
+ const raw = fs4.readFileSync(depPkgPath, "utf8");
527
+ const pkg = JSON.parse(raw);
528
+ if (pkg.peerDependencies) {
529
+ for (const peer of Object.keys(pkg.peerDependencies)) {
530
+ required.add(peer);
531
+ }
532
+ }
533
+ } catch {
534
+ }
535
+ }
536
+ return required;
537
+ }
538
+
539
+ // src/actions/deplint/getScriptReferencedPackages.ts
540
+ import fs5 from "fs";
541
+ import path4 from "path";
542
+ function getBinNames(location, dep) {
543
+ const depPkgPath = findDepPackageJson(location, dep);
544
+ if (!depPkgPath) return [];
545
+ try {
546
+ const raw = fs5.readFileSync(depPkgPath, "utf8");
547
+ const pkg = JSON.parse(raw);
548
+ if (!pkg.bin) return [];
549
+ if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
550
+ return Object.keys(pkg.bin);
551
+ } catch {
552
+ return [];
553
+ }
554
+ }
555
+ function tokenizeScript(script) {
556
+ return script.split(/[&|;$()"`\s]+/).map((t) => t.trim()).filter(Boolean);
557
+ }
558
+ function getScriptReferencedPackages(location, allDeps) {
559
+ const pkgPath = path4.join(location, "package.json");
560
+ let scripts = {};
561
+ try {
562
+ const raw = fs5.readFileSync(pkgPath, "utf8");
563
+ const pkg = JSON.parse(raw);
564
+ scripts = pkg.scripts ?? {};
565
+ } catch {
566
+ return /* @__PURE__ */ new Set();
567
+ }
568
+ const scriptText = Object.values(scripts).join(" ");
569
+ const tokens = new Set(tokenizeScript(scriptText));
570
+ const binToPackage = /* @__PURE__ */ new Map();
571
+ for (const dep of allDeps) {
572
+ const bins = getBinNames(location, dep);
573
+ for (const bin of bins) {
574
+ binToPackage.set(bin, dep);
575
+ }
576
+ }
577
+ const referenced = /* @__PURE__ */ new Set();
578
+ for (const token of tokens) {
579
+ const baseName = getBasePackageName(token);
580
+ if (allDeps.includes(baseName)) {
581
+ referenced.add(baseName);
582
+ }
583
+ const pkg = binToPackage.get(token);
584
+ if (pkg) {
585
+ referenced.add(pkg);
586
+ }
587
+ }
588
+ return referenced;
589
+ }
590
+
591
+ // src/actions/deplint/implicitDevDependencies.ts
592
+ import fs6 from "fs";
593
+ var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
594
+ var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
595
+ var hasTypescriptFiles = ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], tsExtensions);
596
+ var decoratorPattern = /^\s*@[A-Z]\w*/m;
597
+ var hasDecorators = ({ srcFiles }) => srcFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
598
+ try {
599
+ const content = fs6.readFileSync(file, "utf8");
600
+ return decoratorPattern.test(content);
601
+ } catch {
602
+ return false;
603
+ }
604
+ });
605
+ var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
606
+ function hasImportPlugin({ location, allDependencies }) {
607
+ if (allDependencies.some((d) => importPlugins.has(d))) return true;
608
+ for (const dep of allDependencies) {
609
+ const pkgPath = findDepPackageJson(location, dep);
610
+ if (!pkgPath) continue;
611
+ try {
612
+ const pkg = JSON.parse(fs6.readFileSync(pkgPath, "utf8"));
613
+ const transitiveDeps = [
614
+ ...Object.keys(pkg.dependencies ?? {}),
615
+ ...Object.keys(pkg.peerDependencies ?? {})
616
+ ];
617
+ if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
618
+ } catch {
619
+ }
620
+ }
621
+ return false;
622
+ }
623
+ var rules = [
624
+ {
625
+ package: "typescript",
626
+ isNeeded: hasTypescriptFiles
627
+ },
628
+ {
629
+ package: "eslint-import-resolver-typescript",
630
+ isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
631
+ },
632
+ {
633
+ package: "tslib",
634
+ isNeeded: hasDecorators
635
+ }
636
+ ];
637
+ function getImplicitDevDependencies(context) {
638
+ const implicit = /* @__PURE__ */ new Set();
639
+ for (const rule of rules) {
640
+ if (rule.isNeeded(context)) {
641
+ implicit.add(rule.package);
642
+ }
643
+ }
644
+ return implicit;
645
+ }
646
+
647
+ // src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
648
+ var allExternalImports = ({
649
+ externalSrcImports,
650
+ externalDistImports,
651
+ externalDistTypeImports,
652
+ externalConfigImports
653
+ }) => {
654
+ const all = /* @__PURE__ */ new Set([
655
+ ...externalSrcImports,
656
+ ...externalDistImports,
657
+ ...externalDistTypeImports,
658
+ ...externalConfigImports
659
+ ]);
660
+ return all;
661
+ };
662
+ function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
663
+ if (implicitDeps.has(dep)) return true;
664
+ if (requiredPeers.has(dep)) return true;
665
+ if (scriptRefs.has(dep)) return true;
666
+ if (dep.startsWith("@types/")) {
667
+ const baseName = dep.replace(/^@types\//, "");
668
+ return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
669
+ }
670
+ return allImports.has(dep);
671
+ }
672
+ function getUnusedDevDependencies({ name, location }, {
673
+ devDependencies,
674
+ dependencies,
675
+ peerDependencies
676
+ }, sourceParams, fileContext) {
677
+ const allImports = allExternalImports(sourceParams);
678
+ const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
679
+ const implicitDeps = getImplicitDevDependencies({
680
+ ...fileContext,
681
+ allDependencies: allDeps,
682
+ location
683
+ });
684
+ const requiredPeers = getRequiredPeerDependencies(location, allDeps);
685
+ const scriptRefs = getScriptReferencedPackages(location, allDeps);
686
+ let unusedDevDependencies = 0;
687
+ for (const dep of devDependencies) {
688
+ if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
689
+ if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
690
+ unusedDevDependencies++;
691
+ console.log(`[${chalk8.blue(name)}] Unused devDependency in package.json: ${chalk8.red(dep)}`);
692
+ }
693
+ }
694
+ if (unusedDevDependencies > 0) {
695
+ const packageLocation = `${location}/package.json`;
696
+ console.log(` ${chalk8.yellow(packageLocation)}
697
+ `);
698
+ }
699
+ return unusedDevDependencies;
700
+ }
701
+
702
+ // src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
703
+ import chalk9 from "chalk";
448
704
  function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
449
705
  let unusedDependencies = 0;
450
706
  for (const dep of peerDependencies) {
451
707
  if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
452
708
  unusedDependencies++;
453
709
  if (dependencies.includes(dep)) {
454
- console.log(`[${chalk8.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk8.red(dep)}`);
710
+ console.log(`[${chalk9.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk9.red(dep)}`);
455
711
  } else {
456
- console.log(`[${chalk8.blue(name)}] Unused peerDependency in package.json: ${chalk8.red(dep)}`);
712
+ console.log(`[${chalk9.blue(name)}] Unused peerDependency in package.json: ${chalk9.red(dep)}`);
457
713
  }
458
714
  }
459
715
  }
460
716
  if (unusedDependencies > 0) {
461
717
  const packageLocation = `${location}/package.json`;
462
- console.log(` ${chalk8.yellow(packageLocation)}
718
+ console.log(` ${chalk9.yellow(packageLocation)}
463
719
  `);
464
720
  }
465
721
  return unusedDependencies;
466
722
  }
467
723
 
468
724
  // src/actions/deplint/checkPackage/checkPackage.ts
725
+ function logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends) {
726
+ console.info(`Checking package: ${name} at ${location}`);
727
+ console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}, Config files: ${configFiles.length}`);
728
+ for (const file of srcFiles) {
729
+ console.info(`Source file: ${file}`);
730
+ }
731
+ for (const file of distFiles) {
732
+ console.info(`Distribution file: ${file}`);
733
+ }
734
+ for (const file of configFiles) {
735
+ console.info(`Config file: ${file}`);
736
+ }
737
+ for (const ext of tsconfigExtends) {
738
+ console.info(`Tsconfig extends: ${ext}`);
739
+ }
740
+ }
469
741
  function checkPackage({
470
742
  name,
471
743
  location,
@@ -474,27 +746,36 @@ function checkPackage({
474
746
  peerDeps = false,
475
747
  verbose = false
476
748
  }) {
477
- const { srcFiles, distFiles } = findFiles(location);
749
+ const {
750
+ srcFiles,
751
+ distFiles,
752
+ configFiles
753
+ } = findFiles(location);
754
+ const tsconfigExtends = getExtendsFromTsconfigs(location);
478
755
  if (verbose) {
479
- console.info(`Checking package: ${name} at ${location}`);
480
- console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`);
481
- for (const file of srcFiles) {
482
- console.info(`Source file: ${file}`);
483
- }
484
- for (const file of distFiles) {
485
- console.info(`Distribution file: ${file}`);
486
- }
756
+ logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends);
487
757
  }
488
758
  const checkDeps = deps || !(deps || devDeps || peerDeps);
489
759
  const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
490
760
  const checkPeerDeps = peerDeps;
491
- const sourceParams = getExternalImportsFromFiles({ srcFiles, distFiles });
761
+ const sourceParams = getExternalImportsFromFiles({
762
+ srcFiles,
763
+ distFiles,
764
+ configFiles,
765
+ tsconfigExtends
766
+ });
492
767
  const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
493
768
  const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
494
769
  const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
495
770
  const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
771
+ const fileContext = {
772
+ configFiles,
773
+ distFiles,
774
+ srcFiles
775
+ };
776
+ const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
496
777
  const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
497
- const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies;
778
+ const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
498
779
  return totalErrors;
499
780
  }
500
781
 
@@ -532,21 +813,21 @@ var deplint = ({
532
813
  });
533
814
  }
534
815
  if (totalErrors > 0) {
535
- console.warn(`Deplint: Found ${chalk9.red(totalErrors)} dependency problems. ${chalk9.red("\u2716")}`);
816
+ console.warn(`Deplint: Found ${chalk10.red(totalErrors)} dependency problems. ${chalk10.red("\u2716")}`);
536
817
  } else {
537
- console.info(`Deplint: Found no dependency problems. ${chalk9.green("\u2714")}`);
818
+ console.info(`Deplint: Found no dependency problems. ${chalk10.green("\u2714")}`);
538
819
  }
539
820
  return 0;
540
821
  };
541
822
 
542
823
  // src/actions/lint.ts
543
- import chalk10 from "chalk";
824
+ import chalk11 from "chalk";
544
825
  var lintPackage = ({
545
826
  pkg,
546
827
  fix: fix2,
547
828
  verbose
548
829
  }) => {
549
- console.log(chalk10.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
830
+ console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
550
831
  const start = Date.now();
551
832
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
552
833
  ["yarn", [
@@ -556,7 +837,7 @@ var lintPackage = ({
556
837
  fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
557
838
  ]]
558
839
  ]);
559
- console.log(chalk10.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`));
840
+ console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
560
841
  return result;
561
842
  };
562
843
  var lint = ({
@@ -576,13 +857,13 @@ var lint = ({
576
857
  });
577
858
  };
578
859
  var lintAllPackages = ({ fix: fix2 = false } = {}) => {
579
- console.log(chalk10.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
860
+ console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
580
861
  const start = Date.now();
581
862
  const fixOptions = fix2 ? ["--fix"] : [];
582
863
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
583
864
  ["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
584
865
  ]);
585
- console.log(chalk10.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`));
866
+ console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
586
867
  return result;
587
868
  };
588
869
 
@@ -609,13 +890,13 @@ var publintAll = ({ verbose }) => {
609
890
  };
610
891
 
611
892
  // src/actions/relint.ts
612
- import chalk11 from "chalk";
893
+ import chalk12 from "chalk";
613
894
  var relintPackage = ({
614
895
  pkg,
615
896
  fix: fix2,
616
897
  verbose
617
898
  }) => {
618
- console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
899
+ console.log(chalk12.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
619
900
  const start = Date.now();
620
901
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
621
902
  ["yarn", [
@@ -625,7 +906,7 @@ var relintPackage = ({
625
906
  fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
626
907
  ]]
627
908
  ]);
628
- console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
909
+ console.log(chalk12.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`));
629
910
  return result;
630
911
  };
631
912
  var relint = ({
@@ -645,13 +926,13 @@ var relint = ({
645
926
  });
646
927
  };
647
928
  var relintAllPackages = ({ fix: fix2 = false } = {}) => {
648
- console.log(chalk11.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
929
+ console.log(chalk12.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
649
930
  const start = Date.now();
650
931
  const fixOptions = fix2 ? ["--fix"] : [];
651
932
  const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
652
933
  ["yarn", ["eslint", ...fixOptions]]
653
934
  ]);
654
- console.log(chalk11.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`));
935
+ console.log(chalk12.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`));
655
936
  return result;
656
937
  };
657
938
 
@@ -677,7 +958,7 @@ var xyLintCommands = (args) => {
677
958
  const start = Date.now();
678
959
  if (argv.verbose) console.log("Cycle");
679
960
  process.exitCode = await cycle({ pkg: argv.package });
680
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
961
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
681
962
  }
682
963
  ).command(
683
964
  "lint [package]",
@@ -707,7 +988,7 @@ var xyLintCommands = (args) => {
707
988
  cache: argv.cache,
708
989
  verbose: !!argv.verbose
709
990
  });
710
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
991
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
711
992
  }
712
993
  ).command(
713
994
  "deplint [package]",
@@ -740,7 +1021,7 @@ var xyLintCommands = (args) => {
740
1021
  peerDeps: !!argv.peerDeps,
741
1022
  verbose: !!argv.verbose
742
1023
  });
743
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1024
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
744
1025
  }
745
1026
  ).command(
746
1027
  "fix [package]",
@@ -752,7 +1033,7 @@ var xyLintCommands = (args) => {
752
1033
  const start = Date.now();
753
1034
  if (argv.verbose) console.log("Fix");
754
1035
  process.exitCode = fix();
755
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1036
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
756
1037
  }
757
1038
  ).command(
758
1039
  "relint [package]",
@@ -764,7 +1045,7 @@ var xyLintCommands = (args) => {
764
1045
  if (argv.verbose) console.log("Relinting");
765
1046
  const start = Date.now();
766
1047
  process.exitCode = relint();
767
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1048
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
768
1049
  }
769
1050
  ).command(
770
1051
  "publint [package]",
@@ -776,7 +1057,7 @@ var xyLintCommands = (args) => {
776
1057
  if (argv.verbose) console.log("Publint");
777
1058
  const start = Date.now();
778
1059
  process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
779
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1060
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
780
1061
  }
781
1062
  ).command(
782
1063
  "knip",
@@ -788,7 +1069,7 @@ var xyLintCommands = (args) => {
788
1069
  if (argv.verbose) console.log("Knip");
789
1070
  const start = Date.now();
790
1071
  process.exitCode = knip();
791
- console.log(chalk12.blue(`Knip finished in ${Date.now() - start}ms`));
1072
+ console.log(chalk13.blue(`Knip finished in ${Date.now() - start}ms`));
792
1073
  }
793
1074
  ).command(
794
1075
  "sonar",
@@ -800,7 +1081,7 @@ var xyLintCommands = (args) => {
800
1081
  const start = Date.now();
801
1082
  if (argv.verbose) console.log("Sonar Check");
802
1083
  process.exitCode = sonar();
803
- console.log(chalk12.blue(`Finished in ${Date.now() - start}ms`));
1084
+ console.log(chalk13.blue(`Finished in ${Date.now() - start}ms`));
804
1085
  }
805
1086
  );
806
1087
  };