@xylabs/ts-scripts-yarn3 7.4.2 → 7.4.4
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/actions/deplint/checkPackage/checkPackage.mjs +85 -91
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +5 -5
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +2 -2
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +7 -10
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +85 -91
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +85 -91
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/findFiles.mjs +29 -14
- package/dist/actions/deplint/findFiles.mjs.map +1 -1
- package/dist/actions/deplint/findFilesByGlob.mjs +7 -2
- package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +19 -25
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
- package/dist/actions/deplint/getImportsFromFile.mjs +3 -2
- package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -1
- package/dist/actions/deplint/implicitDevDependencies.mjs +2 -2
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +85 -91
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +89 -95
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +85 -91
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +89 -95
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +85 -91
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +85 -91
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +85 -91
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +4 -3
package/dist/actions/index.mjs
CHANGED
|
@@ -620,33 +620,48 @@ var dead = () => {
|
|
|
620
620
|
// src/actions/deplint/deplint.ts
|
|
621
621
|
import chalk17 from "chalk";
|
|
622
622
|
|
|
623
|
+
// src/actions/deplint/findFiles.ts
|
|
624
|
+
import fs2 from "fs";
|
|
625
|
+
|
|
623
626
|
// src/actions/deplint/findFilesByGlob.ts
|
|
624
627
|
import { globSync } from "glob";
|
|
625
|
-
function findFilesByGlob(cwd5, pattern) {
|
|
626
|
-
return globSync(pattern, {
|
|
628
|
+
function findFilesByGlob(cwd5, pattern, ignore) {
|
|
629
|
+
return globSync(pattern, {
|
|
630
|
+
cwd: cwd5,
|
|
631
|
+
absolute: true,
|
|
632
|
+
ignore,
|
|
633
|
+
nodir: true
|
|
634
|
+
});
|
|
627
635
|
}
|
|
628
636
|
|
|
629
637
|
// src/actions/deplint/findFiles.ts
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
};
|
|
638
|
+
var codeExtensions = "*.{ts,tsx,mts,cts,js,mjs,cjs}";
|
|
639
|
+
function getWorkspaceIgnores(location) {
|
|
640
|
+
try {
|
|
641
|
+
const raw = fs2.readFileSync(`${location}/package.json`, "utf8");
|
|
642
|
+
const pkg = JSON.parse(raw);
|
|
643
|
+
return pkg.workspaces ?? [];
|
|
644
|
+
} catch {
|
|
645
|
+
return [];
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function findFiles(location) {
|
|
649
|
+
const workspaceIgnores = getWorkspaceIgnores(location).map((w) => `${w}/**`);
|
|
650
|
+
const ignore = ["**/node_modules/**", "dist/**", ...workspaceIgnores];
|
|
651
|
+
const allFiles = findFilesByGlob(location, `./**/${codeExtensions}`, ignore);
|
|
652
|
+
const distFiles = [
|
|
653
|
+
...findFilesByGlob(location, "./dist/**/*.d.ts"),
|
|
654
|
+
...findFilesByGlob(location, `./dist/**/${codeExtensions}`)
|
|
655
|
+
];
|
|
656
|
+
return { allFiles, distFiles };
|
|
642
657
|
}
|
|
643
658
|
|
|
644
659
|
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
645
|
-
import
|
|
660
|
+
import fs3 from "fs";
|
|
646
661
|
import path3 from "path";
|
|
647
662
|
function getDependenciesFromPackageJson(packageJsonPath) {
|
|
648
663
|
const packageJsonFullPath = path3.resolve(packageJsonPath);
|
|
649
|
-
const rawContent =
|
|
664
|
+
const rawContent = fs3.readFileSync(packageJsonFullPath, "utf8");
|
|
650
665
|
const packageJson = JSON.parse(rawContent);
|
|
651
666
|
const dependencies = packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
|
|
652
667
|
const devDependencies = packageJson.devDependencies ? Object.keys(packageJson.devDependencies) : [];
|
|
@@ -659,7 +674,7 @@ function getDependenciesFromPackageJson(packageJsonPath) {
|
|
|
659
674
|
}
|
|
660
675
|
|
|
661
676
|
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
662
|
-
import
|
|
677
|
+
import fs4 from "fs";
|
|
663
678
|
import { globSync as globSync2 } from "glob";
|
|
664
679
|
|
|
665
680
|
// src/actions/deplint/getBasePackageName.ts
|
|
@@ -684,7 +699,7 @@ function getExtendsFromTsconfigs(location) {
|
|
|
684
699
|
const packages = /* @__PURE__ */ new Set();
|
|
685
700
|
for (const file of tsconfigFiles) {
|
|
686
701
|
try {
|
|
687
|
-
const content =
|
|
702
|
+
const content = fs4.readFileSync(file, "utf8");
|
|
688
703
|
const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
|
|
689
704
|
const parsed = JSON.parse(cleaned);
|
|
690
705
|
const refs = parseExtendsField(parsed.extends);
|
|
@@ -700,7 +715,7 @@ function getExtendsFromTsconfigs(location) {
|
|
|
700
715
|
}
|
|
701
716
|
|
|
702
717
|
// src/actions/deplint/getImportsFromFile.ts
|
|
703
|
-
import
|
|
718
|
+
import fs5 from "fs";
|
|
704
719
|
import path4 from "path";
|
|
705
720
|
import ts from "typescript";
|
|
706
721
|
function isTypeOnlyImportClause(clause) {
|
|
@@ -715,7 +730,7 @@ function isTypeOnlyImportClause(clause) {
|
|
|
715
730
|
return clause.isTypeOnly;
|
|
716
731
|
}
|
|
717
732
|
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
718
|
-
const sourceCode =
|
|
733
|
+
const sourceCode = fs5.readFileSync(filePath, "utf8");
|
|
719
734
|
const isMjsFile = filePath.endsWith(".mjs");
|
|
720
735
|
const sourceFile = ts.createSourceFile(
|
|
721
736
|
path4.basename(filePath),
|
|
@@ -726,14 +741,14 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
726
741
|
);
|
|
727
742
|
const imports = [];
|
|
728
743
|
const typeImports = [];
|
|
729
|
-
const
|
|
744
|
+
const isDeclarationFile2 = filePath.endsWith(".d.ts");
|
|
730
745
|
function visit(node) {
|
|
731
746
|
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
732
747
|
const moduleSpecifier = node.moduleSpecifier?.getFullText();
|
|
733
748
|
const isTypeImport = ts.isImportDeclaration(node) ? isTypeOnlyImportClause(node.importClause) : false;
|
|
734
749
|
if (typeof moduleSpecifier === "string") {
|
|
735
750
|
const trimmed = moduleSpecifier.replaceAll("'", "").replaceAll('"', "").trim();
|
|
736
|
-
if (isTypeImport ||
|
|
751
|
+
if (isTypeImport || isDeclarationFile2) {
|
|
737
752
|
typeImports.push(trimmed);
|
|
738
753
|
} else {
|
|
739
754
|
imports.push(trimmed);
|
|
@@ -750,8 +765,9 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
750
765
|
}
|
|
751
766
|
visit(sourceFile);
|
|
752
767
|
const importsStartsWithExcludes = [".", "#", "node:"];
|
|
753
|
-
const
|
|
754
|
-
const
|
|
768
|
+
const isValidImport = (imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc)) && !imp.includes("*") && !imp.includes("!");
|
|
769
|
+
const cleanedImports = imports.filter(isValidImport).map(getBasePackageName);
|
|
770
|
+
const cleanedTypeImports = typeImports.filter(isValidImport).map(getBasePackageName);
|
|
755
771
|
for (const imp of cleanedImports) {
|
|
756
772
|
importPaths[imp] = importPaths[imp] ?? [];
|
|
757
773
|
importPaths[imp].push(filePath);
|
|
@@ -768,41 +784,34 @@ var internalImportPrefixes = [".", "#", "node:"];
|
|
|
768
784
|
var removeInternalImports = (imports) => {
|
|
769
785
|
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
770
786
|
};
|
|
787
|
+
var isDeclarationFile = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
|
|
771
788
|
function getExternalImportsFromFiles({
|
|
772
|
-
|
|
789
|
+
allFiles,
|
|
773
790
|
distFiles,
|
|
774
|
-
configFiles = [],
|
|
775
791
|
tsconfigExtends = []
|
|
776
792
|
}) {
|
|
777
|
-
const
|
|
793
|
+
const allImportPaths = {};
|
|
778
794
|
const distImportPaths = {};
|
|
779
795
|
const distTypeImportPaths = {};
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
784
|
-
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
796
|
+
for (const path13 of allFiles) getImportsFromFile(path13, allImportPaths, allImportPaths).flat();
|
|
797
|
+
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
798
|
+
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
785
799
|
for (const path13 of distCodeFiles) getImportsFromFile(path13, distImportPaths, distImportPaths).flat();
|
|
786
800
|
for (const path13 of distTypeFiles) getImportsFromFile(path13, distTypeImportPaths, distTypeImportPaths).flat();
|
|
787
|
-
const
|
|
801
|
+
const allImports = Object.keys(allImportPaths);
|
|
788
802
|
const distImports = Object.keys(distImportPaths);
|
|
789
|
-
const
|
|
790
|
-
const externalSrcImports = removeInternalImports(srcImports);
|
|
803
|
+
const externalAllImports = removeInternalImports(allImports);
|
|
791
804
|
const externalDistImports = removeInternalImports(distImports);
|
|
792
|
-
const externalDistTypeImports = removeInternalImports(
|
|
793
|
-
const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
|
|
805
|
+
const externalDistTypeImports = removeInternalImports(Object.keys(distTypeImportPaths));
|
|
794
806
|
for (const ext of tsconfigExtends) {
|
|
795
|
-
if (!
|
|
796
|
-
if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
|
|
807
|
+
if (!externalAllImports.includes(ext)) externalAllImports.push(ext);
|
|
797
808
|
}
|
|
798
809
|
return {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
srcImportPaths,
|
|
802
|
-
externalConfigImports,
|
|
803
|
-
externalSrcImports,
|
|
804
|
-
distImports,
|
|
810
|
+
allImportPaths,
|
|
811
|
+
allImports,
|
|
805
812
|
distImportPaths,
|
|
813
|
+
distImports,
|
|
814
|
+
externalAllImports,
|
|
806
815
|
externalDistImports,
|
|
807
816
|
externalDistTypeImports
|
|
808
817
|
};
|
|
@@ -854,17 +863,17 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
854
863
|
dependencies,
|
|
855
864
|
peerDependencies
|
|
856
865
|
}, {
|
|
857
|
-
|
|
858
|
-
|
|
866
|
+
allImportPaths,
|
|
867
|
+
externalAllImports,
|
|
859
868
|
distImports
|
|
860
869
|
}) {
|
|
861
870
|
let unlistedDevDependencies = 0;
|
|
862
|
-
for (const imp of
|
|
871
|
+
for (const imp of externalAllImports) {
|
|
863
872
|
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)) {
|
|
864
873
|
unlistedDevDependencies++;
|
|
865
874
|
console.log(`[${chalk13.blue(name)}] Missing devDependency in package.json: ${chalk13.red(imp)}`);
|
|
866
|
-
if (
|
|
867
|
-
console.log(` ${
|
|
875
|
+
if (allImportPaths[imp]) {
|
|
876
|
+
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
868
877
|
}
|
|
869
878
|
}
|
|
870
879
|
}
|
|
@@ -881,13 +890,13 @@ import chalk14 from "chalk";
|
|
|
881
890
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
882
891
|
externalDistImports,
|
|
883
892
|
externalDistTypeImports,
|
|
884
|
-
|
|
893
|
+
externalAllImports
|
|
885
894
|
}) {
|
|
886
895
|
let unusedDependencies = 0;
|
|
887
896
|
for (const dep of dependencies) {
|
|
888
897
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
889
898
|
unusedDependencies++;
|
|
890
|
-
if (
|
|
899
|
+
if (externalAllImports.includes(dep)) {
|
|
891
900
|
console.log(`[${chalk14.blue(name)}] dependency should be devDependency in package.json: ${chalk14.red(dep)}`);
|
|
892
901
|
} else {
|
|
893
902
|
console.log(`[${chalk14.blue(name)}] Unused dependency in package.json: ${chalk14.red(dep)}`);
|
|
@@ -906,13 +915,13 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
906
915
|
import chalk15 from "chalk";
|
|
907
916
|
|
|
908
917
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
909
|
-
import
|
|
918
|
+
import fs6 from "fs";
|
|
910
919
|
import path5 from "path";
|
|
911
920
|
function findDepPackageJson(location, dep) {
|
|
912
921
|
let dir = location;
|
|
913
922
|
while (true) {
|
|
914
923
|
const candidate = path5.join(dir, "node_modules", dep, "package.json");
|
|
915
|
-
if (
|
|
924
|
+
if (fs6.existsSync(candidate)) return candidate;
|
|
916
925
|
const parent = path5.dirname(dir);
|
|
917
926
|
if (parent === dir) return void 0;
|
|
918
927
|
dir = parent;
|
|
@@ -924,7 +933,7 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
924
933
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
925
934
|
if (!depPkgPath) continue;
|
|
926
935
|
try {
|
|
927
|
-
const raw =
|
|
936
|
+
const raw = fs6.readFileSync(depPkgPath, "utf8");
|
|
928
937
|
const pkg = JSON.parse(raw);
|
|
929
938
|
if (pkg.peerDependencies) {
|
|
930
939
|
for (const peer of Object.keys(pkg.peerDependencies)) {
|
|
@@ -938,13 +947,13 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
938
947
|
}
|
|
939
948
|
|
|
940
949
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
941
|
-
import
|
|
950
|
+
import fs7 from "fs";
|
|
942
951
|
import path6 from "path";
|
|
943
952
|
function getBinNames(location, dep) {
|
|
944
953
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
945
954
|
if (!depPkgPath) return [];
|
|
946
955
|
try {
|
|
947
|
-
const raw =
|
|
956
|
+
const raw = fs7.readFileSync(depPkgPath, "utf8");
|
|
948
957
|
const pkg = JSON.parse(raw);
|
|
949
958
|
if (!pkg.bin) return [];
|
|
950
959
|
if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
|
|
@@ -960,7 +969,7 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
960
969
|
const pkgPath = path6.join(location, "package.json");
|
|
961
970
|
let scripts = {};
|
|
962
971
|
try {
|
|
963
|
-
const raw =
|
|
972
|
+
const raw = fs7.readFileSync(pkgPath, "utf8");
|
|
964
973
|
const pkg = JSON.parse(raw);
|
|
965
974
|
scripts = pkg.scripts ?? {};
|
|
966
975
|
} catch {
|
|
@@ -990,14 +999,14 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
990
999
|
}
|
|
991
1000
|
|
|
992
1001
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
993
|
-
import
|
|
1002
|
+
import fs8 from "fs";
|
|
994
1003
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
995
1004
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
996
|
-
var hasTypescriptFiles = ({
|
|
1005
|
+
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
997
1006
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
998
|
-
var hasDecorators = ({
|
|
1007
|
+
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
999
1008
|
try {
|
|
1000
|
-
const content =
|
|
1009
|
+
const content = fs8.readFileSync(file, "utf8");
|
|
1001
1010
|
return decoratorPattern.test(content);
|
|
1002
1011
|
} catch {
|
|
1003
1012
|
return false;
|
|
@@ -1010,7 +1019,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1010
1019
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1011
1020
|
if (!pkgPath) continue;
|
|
1012
1021
|
try {
|
|
1013
|
-
const pkg = JSON.parse(
|
|
1022
|
+
const pkg = JSON.parse(fs8.readFileSync(pkgPath, "utf8"));
|
|
1014
1023
|
const transitiveDeps = [
|
|
1015
1024
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1016
1025
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1047,18 +1056,15 @@ function getImplicitDevDependencies(context) {
|
|
|
1047
1056
|
|
|
1048
1057
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1049
1058
|
var allExternalImports = ({
|
|
1050
|
-
|
|
1059
|
+
externalAllImports,
|
|
1051
1060
|
externalDistImports,
|
|
1052
|
-
externalDistTypeImports
|
|
1053
|
-
externalConfigImports
|
|
1061
|
+
externalDistTypeImports
|
|
1054
1062
|
}) => {
|
|
1055
|
-
|
|
1056
|
-
...
|
|
1063
|
+
return /* @__PURE__ */ new Set([
|
|
1064
|
+
...externalAllImports,
|
|
1057
1065
|
...externalDistImports,
|
|
1058
|
-
...externalDistTypeImports
|
|
1059
|
-
...externalConfigImports
|
|
1066
|
+
...externalDistTypeImports
|
|
1060
1067
|
]);
|
|
1061
|
-
return all;
|
|
1062
1068
|
};
|
|
1063
1069
|
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1064
1070
|
if (implicitDeps.has(dep)) return true;
|
|
@@ -1123,18 +1129,15 @@ function getUnusedPeerDependencies({ name, location }, { peerDependencies, depen
|
|
|
1123
1129
|
}
|
|
1124
1130
|
|
|
1125
1131
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
1126
|
-
function logVerbose(name, location,
|
|
1132
|
+
function logVerbose(name, location, allFiles, distFiles, tsconfigExtends) {
|
|
1127
1133
|
console.info(`Checking package: ${name} at ${location}`);
|
|
1128
|
-
console.info(`
|
|
1129
|
-
for (const file of
|
|
1130
|
-
console.info(`
|
|
1134
|
+
console.info(`All files: ${allFiles.length}, Distribution files: ${distFiles.length}`);
|
|
1135
|
+
for (const file of allFiles) {
|
|
1136
|
+
console.info(`File: ${file}`);
|
|
1131
1137
|
}
|
|
1132
1138
|
for (const file of distFiles) {
|
|
1133
1139
|
console.info(`Distribution file: ${file}`);
|
|
1134
1140
|
}
|
|
1135
|
-
for (const file of configFiles) {
|
|
1136
|
-
console.info(`Config file: ${file}`);
|
|
1137
|
-
}
|
|
1138
1141
|
for (const ext of tsconfigExtends) {
|
|
1139
1142
|
console.info(`Tsconfig extends: ${ext}`);
|
|
1140
1143
|
}
|
|
@@ -1147,33 +1150,24 @@ function checkPackage({
|
|
|
1147
1150
|
peerDeps = false,
|
|
1148
1151
|
verbose = false
|
|
1149
1152
|
}) {
|
|
1150
|
-
const {
|
|
1151
|
-
srcFiles,
|
|
1152
|
-
distFiles,
|
|
1153
|
-
configFiles
|
|
1154
|
-
} = findFiles(location);
|
|
1153
|
+
const { allFiles, distFiles } = findFiles(location);
|
|
1155
1154
|
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
1156
1155
|
if (verbose) {
|
|
1157
|
-
logVerbose(name, location,
|
|
1156
|
+
logVerbose(name, location, allFiles, distFiles, tsconfigExtends);
|
|
1158
1157
|
}
|
|
1159
1158
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
1160
1159
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
1161
1160
|
const checkPeerDeps = peerDeps;
|
|
1162
1161
|
const sourceParams = getExternalImportsFromFiles({
|
|
1163
|
-
|
|
1162
|
+
allFiles,
|
|
1164
1163
|
distFiles,
|
|
1165
|
-
configFiles,
|
|
1166
1164
|
tsconfigExtends
|
|
1167
1165
|
});
|
|
1168
1166
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1169
1167
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1170
1168
|
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1171
1169
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1172
|
-
const fileContext = {
|
|
1173
|
-
configFiles,
|
|
1174
|
-
distFiles,
|
|
1175
|
-
srcFiles
|
|
1176
|
-
};
|
|
1170
|
+
const fileContext = { allFiles, distFiles };
|
|
1177
1171
|
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1178
1172
|
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1179
1173
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
@@ -2242,7 +2236,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2242
2236
|
};
|
|
2243
2237
|
|
|
2244
2238
|
// src/actions/package/publint.ts
|
|
2245
|
-
import { promises as
|
|
2239
|
+
import { promises as fs9 } from "fs";
|
|
2246
2240
|
import chalk33 from "chalk";
|
|
2247
2241
|
import sortPackageJson from "sort-package-json";
|
|
2248
2242
|
var customPubLint = (pkg) => {
|
|
@@ -2269,9 +2263,9 @@ var customPubLint = (pkg) => {
|
|
|
2269
2263
|
};
|
|
2270
2264
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2271
2265
|
const pkgDir = process.env.INIT_CWD;
|
|
2272
|
-
const sortedPkg = sortPackageJson(await
|
|
2273
|
-
await
|
|
2274
|
-
const pkg = JSON.parse(await
|
|
2266
|
+
const sortedPkg = sortPackageJson(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2267
|
+
await fs9.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2268
|
+
const pkg = JSON.parse(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2275
2269
|
console.log(chalk33.green(`Publint: ${pkg.name}`));
|
|
2276
2270
|
console.log(chalk33.gray(pkgDir));
|
|
2277
2271
|
const { publint: publint2 } = await import("publint");
|