@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/index.mjs
CHANGED
|
@@ -696,33 +696,48 @@ var dead = () => {
|
|
|
696
696
|
// src/actions/deplint/deplint.ts
|
|
697
697
|
import chalk18 from "chalk";
|
|
698
698
|
|
|
699
|
+
// src/actions/deplint/findFiles.ts
|
|
700
|
+
import fs2 from "fs";
|
|
701
|
+
|
|
699
702
|
// src/actions/deplint/findFilesByGlob.ts
|
|
700
703
|
import { globSync } from "glob";
|
|
701
|
-
function findFilesByGlob(cwd5, pattern) {
|
|
702
|
-
return globSync(pattern, {
|
|
704
|
+
function findFilesByGlob(cwd5, pattern, ignore) {
|
|
705
|
+
return globSync(pattern, {
|
|
706
|
+
cwd: cwd5,
|
|
707
|
+
absolute: true,
|
|
708
|
+
ignore,
|
|
709
|
+
nodir: true
|
|
710
|
+
});
|
|
703
711
|
}
|
|
704
712
|
|
|
705
713
|
// src/actions/deplint/findFiles.ts
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
};
|
|
714
|
+
var codeExtensions = "*.{ts,tsx,mts,cts,js,mjs,cjs}";
|
|
715
|
+
function getWorkspaceIgnores(location) {
|
|
716
|
+
try {
|
|
717
|
+
const raw = fs2.readFileSync(`${location}/package.json`, "utf8");
|
|
718
|
+
const pkg = JSON.parse(raw);
|
|
719
|
+
return pkg.workspaces ?? [];
|
|
720
|
+
} catch {
|
|
721
|
+
return [];
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
function findFiles(location) {
|
|
725
|
+
const workspaceIgnores = getWorkspaceIgnores(location).map((w) => `${w}/**`);
|
|
726
|
+
const ignore = ["**/node_modules/**", "dist/**", ...workspaceIgnores];
|
|
727
|
+
const allFiles = findFilesByGlob(location, `./**/${codeExtensions}`, ignore);
|
|
728
|
+
const distFiles = [
|
|
729
|
+
...findFilesByGlob(location, "./dist/**/*.d.ts"),
|
|
730
|
+
...findFilesByGlob(location, `./dist/**/${codeExtensions}`)
|
|
731
|
+
];
|
|
732
|
+
return { allFiles, distFiles };
|
|
718
733
|
}
|
|
719
734
|
|
|
720
735
|
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
721
|
-
import
|
|
736
|
+
import fs3 from "fs";
|
|
722
737
|
import path3 from "path";
|
|
723
738
|
function getDependenciesFromPackageJson(packageJsonPath) {
|
|
724
739
|
const packageJsonFullPath = path3.resolve(packageJsonPath);
|
|
725
|
-
const rawContent =
|
|
740
|
+
const rawContent = fs3.readFileSync(packageJsonFullPath, "utf8");
|
|
726
741
|
const packageJson = JSON.parse(rawContent);
|
|
727
742
|
const dependencies = packageJson.dependencies ? Object.keys(packageJson.dependencies) : [];
|
|
728
743
|
const devDependencies = packageJson.devDependencies ? Object.keys(packageJson.devDependencies) : [];
|
|
@@ -735,7 +750,7 @@ function getDependenciesFromPackageJson(packageJsonPath) {
|
|
|
735
750
|
}
|
|
736
751
|
|
|
737
752
|
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
738
|
-
import
|
|
753
|
+
import fs4 from "fs";
|
|
739
754
|
import { globSync as globSync2 } from "glob";
|
|
740
755
|
|
|
741
756
|
// src/actions/deplint/getBasePackageName.ts
|
|
@@ -760,7 +775,7 @@ function getExtendsFromTsconfigs(location) {
|
|
|
760
775
|
const packages = /* @__PURE__ */ new Set();
|
|
761
776
|
for (const file of tsconfigFiles) {
|
|
762
777
|
try {
|
|
763
|
-
const content =
|
|
778
|
+
const content = fs4.readFileSync(file, "utf8");
|
|
764
779
|
const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
|
|
765
780
|
const parsed = JSON.parse(cleaned);
|
|
766
781
|
const refs = parseExtendsField(parsed.extends);
|
|
@@ -776,7 +791,7 @@ function getExtendsFromTsconfigs(location) {
|
|
|
776
791
|
}
|
|
777
792
|
|
|
778
793
|
// src/actions/deplint/getImportsFromFile.ts
|
|
779
|
-
import
|
|
794
|
+
import fs5 from "fs";
|
|
780
795
|
import path4 from "path";
|
|
781
796
|
import ts from "typescript";
|
|
782
797
|
function isTypeOnlyImportClause(clause) {
|
|
@@ -791,7 +806,7 @@ function isTypeOnlyImportClause(clause) {
|
|
|
791
806
|
return clause.isTypeOnly;
|
|
792
807
|
}
|
|
793
808
|
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
794
|
-
const sourceCode =
|
|
809
|
+
const sourceCode = fs5.readFileSync(filePath, "utf8");
|
|
795
810
|
const isMjsFile = filePath.endsWith(".mjs");
|
|
796
811
|
const sourceFile = ts.createSourceFile(
|
|
797
812
|
path4.basename(filePath),
|
|
@@ -802,14 +817,14 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
802
817
|
);
|
|
803
818
|
const imports = [];
|
|
804
819
|
const typeImports = [];
|
|
805
|
-
const
|
|
820
|
+
const isDeclarationFile2 = filePath.endsWith(".d.ts");
|
|
806
821
|
function visit(node) {
|
|
807
822
|
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
808
823
|
const moduleSpecifier = node.moduleSpecifier?.getFullText();
|
|
809
824
|
const isTypeImport = ts.isImportDeclaration(node) ? isTypeOnlyImportClause(node.importClause) : false;
|
|
810
825
|
if (typeof moduleSpecifier === "string") {
|
|
811
826
|
const trimmed = moduleSpecifier.replaceAll("'", "").replaceAll('"', "").trim();
|
|
812
|
-
if (isTypeImport ||
|
|
827
|
+
if (isTypeImport || isDeclarationFile2) {
|
|
813
828
|
typeImports.push(trimmed);
|
|
814
829
|
} else {
|
|
815
830
|
imports.push(trimmed);
|
|
@@ -826,8 +841,9 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
826
841
|
}
|
|
827
842
|
visit(sourceFile);
|
|
828
843
|
const importsStartsWithExcludes = [".", "#", "node:"];
|
|
829
|
-
const
|
|
830
|
-
const
|
|
844
|
+
const isValidImport = (imp) => !importsStartsWithExcludes.some((exc) => imp.startsWith(exc)) && !imp.includes("*") && !imp.includes("!");
|
|
845
|
+
const cleanedImports = imports.filter(isValidImport).map(getBasePackageName);
|
|
846
|
+
const cleanedTypeImports = typeImports.filter(isValidImport).map(getBasePackageName);
|
|
831
847
|
for (const imp of cleanedImports) {
|
|
832
848
|
importPaths[imp] = importPaths[imp] ?? [];
|
|
833
849
|
importPaths[imp].push(filePath);
|
|
@@ -844,41 +860,34 @@ var internalImportPrefixes = [".", "#", "node:"];
|
|
|
844
860
|
var removeInternalImports = (imports) => {
|
|
845
861
|
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
846
862
|
};
|
|
863
|
+
var isDeclarationFile = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
|
|
847
864
|
function getExternalImportsFromFiles({
|
|
848
|
-
|
|
865
|
+
allFiles,
|
|
849
866
|
distFiles,
|
|
850
|
-
configFiles = [],
|
|
851
867
|
tsconfigExtends = []
|
|
852
868
|
}) {
|
|
853
|
-
const
|
|
869
|
+
const allImportPaths = {};
|
|
854
870
|
const distImportPaths = {};
|
|
855
871
|
const distTypeImportPaths = {};
|
|
856
|
-
const
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
860
|
-
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
872
|
+
for (const path13 of allFiles) getImportsFromFile(path13, allImportPaths, allImportPaths).flat();
|
|
873
|
+
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
874
|
+
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
861
875
|
for (const path13 of distCodeFiles) getImportsFromFile(path13, distImportPaths, distImportPaths).flat();
|
|
862
876
|
for (const path13 of distTypeFiles) getImportsFromFile(path13, distTypeImportPaths, distTypeImportPaths).flat();
|
|
863
|
-
const
|
|
877
|
+
const allImports = Object.keys(allImportPaths);
|
|
864
878
|
const distImports = Object.keys(distImportPaths);
|
|
865
|
-
const
|
|
866
|
-
const externalSrcImports = removeInternalImports(srcImports);
|
|
879
|
+
const externalAllImports = removeInternalImports(allImports);
|
|
867
880
|
const externalDistImports = removeInternalImports(distImports);
|
|
868
|
-
const externalDistTypeImports = removeInternalImports(
|
|
869
|
-
const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
|
|
881
|
+
const externalDistTypeImports = removeInternalImports(Object.keys(distTypeImportPaths));
|
|
870
882
|
for (const ext of tsconfigExtends) {
|
|
871
|
-
if (!
|
|
872
|
-
if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
|
|
883
|
+
if (!externalAllImports.includes(ext)) externalAllImports.push(ext);
|
|
873
884
|
}
|
|
874
885
|
return {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
srcImportPaths,
|
|
878
|
-
externalConfigImports,
|
|
879
|
-
externalSrcImports,
|
|
880
|
-
distImports,
|
|
886
|
+
allImportPaths,
|
|
887
|
+
allImports,
|
|
881
888
|
distImportPaths,
|
|
889
|
+
distImports,
|
|
890
|
+
externalAllImports,
|
|
882
891
|
externalDistImports,
|
|
883
892
|
externalDistTypeImports
|
|
884
893
|
};
|
|
@@ -930,17 +939,17 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
930
939
|
dependencies,
|
|
931
940
|
peerDependencies
|
|
932
941
|
}, {
|
|
933
|
-
|
|
934
|
-
|
|
942
|
+
allImportPaths,
|
|
943
|
+
externalAllImports,
|
|
935
944
|
distImports
|
|
936
945
|
}) {
|
|
937
946
|
let unlistedDevDependencies = 0;
|
|
938
|
-
for (const imp of
|
|
947
|
+
for (const imp of externalAllImports) {
|
|
939
948
|
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)) {
|
|
940
949
|
unlistedDevDependencies++;
|
|
941
950
|
console.log(`[${chalk14.blue(name)}] Missing devDependency in package.json: ${chalk14.red(imp)}`);
|
|
942
|
-
if (
|
|
943
|
-
console.log(` ${
|
|
951
|
+
if (allImportPaths[imp]) {
|
|
952
|
+
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
944
953
|
}
|
|
945
954
|
}
|
|
946
955
|
}
|
|
@@ -957,13 +966,13 @@ import chalk15 from "chalk";
|
|
|
957
966
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
958
967
|
externalDistImports,
|
|
959
968
|
externalDistTypeImports,
|
|
960
|
-
|
|
969
|
+
externalAllImports
|
|
961
970
|
}) {
|
|
962
971
|
let unusedDependencies = 0;
|
|
963
972
|
for (const dep of dependencies) {
|
|
964
973
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
965
974
|
unusedDependencies++;
|
|
966
|
-
if (
|
|
975
|
+
if (externalAllImports.includes(dep)) {
|
|
967
976
|
console.log(`[${chalk15.blue(name)}] dependency should be devDependency in package.json: ${chalk15.red(dep)}`);
|
|
968
977
|
} else {
|
|
969
978
|
console.log(`[${chalk15.blue(name)}] Unused dependency in package.json: ${chalk15.red(dep)}`);
|
|
@@ -982,13 +991,13 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
982
991
|
import chalk16 from "chalk";
|
|
983
992
|
|
|
984
993
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
985
|
-
import
|
|
994
|
+
import fs6 from "fs";
|
|
986
995
|
import path5 from "path";
|
|
987
996
|
function findDepPackageJson(location, dep) {
|
|
988
997
|
let dir = location;
|
|
989
998
|
while (true) {
|
|
990
999
|
const candidate = path5.join(dir, "node_modules", dep, "package.json");
|
|
991
|
-
if (
|
|
1000
|
+
if (fs6.existsSync(candidate)) return candidate;
|
|
992
1001
|
const parent = path5.dirname(dir);
|
|
993
1002
|
if (parent === dir) return void 0;
|
|
994
1003
|
dir = parent;
|
|
@@ -1000,7 +1009,7 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1000
1009
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1001
1010
|
if (!depPkgPath) continue;
|
|
1002
1011
|
try {
|
|
1003
|
-
const raw =
|
|
1012
|
+
const raw = fs6.readFileSync(depPkgPath, "utf8");
|
|
1004
1013
|
const pkg = JSON.parse(raw);
|
|
1005
1014
|
if (pkg.peerDependencies) {
|
|
1006
1015
|
for (const peer of Object.keys(pkg.peerDependencies)) {
|
|
@@ -1014,13 +1023,13 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1014
1023
|
}
|
|
1015
1024
|
|
|
1016
1025
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1017
|
-
import
|
|
1026
|
+
import fs7 from "fs";
|
|
1018
1027
|
import path6 from "path";
|
|
1019
1028
|
function getBinNames(location, dep) {
|
|
1020
1029
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1021
1030
|
if (!depPkgPath) return [];
|
|
1022
1031
|
try {
|
|
1023
|
-
const raw =
|
|
1032
|
+
const raw = fs7.readFileSync(depPkgPath, "utf8");
|
|
1024
1033
|
const pkg = JSON.parse(raw);
|
|
1025
1034
|
if (!pkg.bin) return [];
|
|
1026
1035
|
if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
|
|
@@ -1036,7 +1045,7 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1036
1045
|
const pkgPath = path6.join(location, "package.json");
|
|
1037
1046
|
let scripts = {};
|
|
1038
1047
|
try {
|
|
1039
|
-
const raw =
|
|
1048
|
+
const raw = fs7.readFileSync(pkgPath, "utf8");
|
|
1040
1049
|
const pkg = JSON.parse(raw);
|
|
1041
1050
|
scripts = pkg.scripts ?? {};
|
|
1042
1051
|
} catch {
|
|
@@ -1066,14 +1075,14 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1066
1075
|
}
|
|
1067
1076
|
|
|
1068
1077
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1069
|
-
import
|
|
1078
|
+
import fs8 from "fs";
|
|
1070
1079
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1071
1080
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1072
|
-
var hasTypescriptFiles = ({
|
|
1081
|
+
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1073
1082
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1074
|
-
var hasDecorators = ({
|
|
1083
|
+
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1075
1084
|
try {
|
|
1076
|
-
const content =
|
|
1085
|
+
const content = fs8.readFileSync(file, "utf8");
|
|
1077
1086
|
return decoratorPattern.test(content);
|
|
1078
1087
|
} catch {
|
|
1079
1088
|
return false;
|
|
@@ -1086,7 +1095,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1086
1095
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1087
1096
|
if (!pkgPath) continue;
|
|
1088
1097
|
try {
|
|
1089
|
-
const pkg = JSON.parse(
|
|
1098
|
+
const pkg = JSON.parse(fs8.readFileSync(pkgPath, "utf8"));
|
|
1090
1099
|
const transitiveDeps = [
|
|
1091
1100
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1092
1101
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1123,18 +1132,15 @@ function getImplicitDevDependencies(context) {
|
|
|
1123
1132
|
|
|
1124
1133
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1125
1134
|
var allExternalImports = ({
|
|
1126
|
-
|
|
1135
|
+
externalAllImports,
|
|
1127
1136
|
externalDistImports,
|
|
1128
|
-
externalDistTypeImports
|
|
1129
|
-
externalConfigImports
|
|
1137
|
+
externalDistTypeImports
|
|
1130
1138
|
}) => {
|
|
1131
|
-
|
|
1132
|
-
...
|
|
1139
|
+
return /* @__PURE__ */ new Set([
|
|
1140
|
+
...externalAllImports,
|
|
1133
1141
|
...externalDistImports,
|
|
1134
|
-
...externalDistTypeImports
|
|
1135
|
-
...externalConfigImports
|
|
1142
|
+
...externalDistTypeImports
|
|
1136
1143
|
]);
|
|
1137
|
-
return all;
|
|
1138
1144
|
};
|
|
1139
1145
|
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1140
1146
|
if (implicitDeps.has(dep)) return true;
|
|
@@ -1199,18 +1205,15 @@ function getUnusedPeerDependencies({ name, location }, { peerDependencies, depen
|
|
|
1199
1205
|
}
|
|
1200
1206
|
|
|
1201
1207
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
1202
|
-
function logVerbose(name, location,
|
|
1208
|
+
function logVerbose(name, location, allFiles, distFiles, tsconfigExtends) {
|
|
1203
1209
|
console.info(`Checking package: ${name} at ${location}`);
|
|
1204
|
-
console.info(`
|
|
1205
|
-
for (const file of
|
|
1206
|
-
console.info(`
|
|
1210
|
+
console.info(`All files: ${allFiles.length}, Distribution files: ${distFiles.length}`);
|
|
1211
|
+
for (const file of allFiles) {
|
|
1212
|
+
console.info(`File: ${file}`);
|
|
1207
1213
|
}
|
|
1208
1214
|
for (const file of distFiles) {
|
|
1209
1215
|
console.info(`Distribution file: ${file}`);
|
|
1210
1216
|
}
|
|
1211
|
-
for (const file of configFiles) {
|
|
1212
|
-
console.info(`Config file: ${file}`);
|
|
1213
|
-
}
|
|
1214
1217
|
for (const ext of tsconfigExtends) {
|
|
1215
1218
|
console.info(`Tsconfig extends: ${ext}`);
|
|
1216
1219
|
}
|
|
@@ -1223,33 +1226,24 @@ function checkPackage({
|
|
|
1223
1226
|
peerDeps = false,
|
|
1224
1227
|
verbose = false
|
|
1225
1228
|
}) {
|
|
1226
|
-
const {
|
|
1227
|
-
srcFiles,
|
|
1228
|
-
distFiles,
|
|
1229
|
-
configFiles
|
|
1230
|
-
} = findFiles(location);
|
|
1229
|
+
const { allFiles, distFiles } = findFiles(location);
|
|
1231
1230
|
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
1232
1231
|
if (verbose) {
|
|
1233
|
-
logVerbose(name, location,
|
|
1232
|
+
logVerbose(name, location, allFiles, distFiles, tsconfigExtends);
|
|
1234
1233
|
}
|
|
1235
1234
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
1236
1235
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
1237
1236
|
const checkPeerDeps = peerDeps;
|
|
1238
1237
|
const sourceParams = getExternalImportsFromFiles({
|
|
1239
|
-
|
|
1238
|
+
allFiles,
|
|
1240
1239
|
distFiles,
|
|
1241
|
-
configFiles,
|
|
1242
1240
|
tsconfigExtends
|
|
1243
1241
|
});
|
|
1244
1242
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1245
1243
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1246
1244
|
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1247
1245
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1248
|
-
const fileContext = {
|
|
1249
|
-
configFiles,
|
|
1250
|
-
distFiles,
|
|
1251
|
-
srcFiles
|
|
1252
|
-
};
|
|
1246
|
+
const fileContext = { allFiles, distFiles };
|
|
1253
1247
|
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1254
1248
|
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1255
1249
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
@@ -2318,7 +2312,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2318
2312
|
};
|
|
2319
2313
|
|
|
2320
2314
|
// src/actions/package/publint.ts
|
|
2321
|
-
import { promises as
|
|
2315
|
+
import { promises as fs9 } from "fs";
|
|
2322
2316
|
import chalk34 from "chalk";
|
|
2323
2317
|
import sortPackageJson from "sort-package-json";
|
|
2324
2318
|
var customPubLint = (pkg) => {
|
|
@@ -2345,9 +2339,9 @@ var customPubLint = (pkg) => {
|
|
|
2345
2339
|
};
|
|
2346
2340
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2347
2341
|
const pkgDir = process.env.INIT_CWD;
|
|
2348
|
-
const sortedPkg = sortPackageJson(await
|
|
2349
|
-
await
|
|
2350
|
-
const pkg = JSON.parse(await
|
|
2342
|
+
const sortedPkg = sortPackageJson(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2343
|
+
await fs9.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2344
|
+
const pkg = JSON.parse(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2351
2345
|
console.log(chalk34.green(`Publint: ${pkg.name}`));
|
|
2352
2346
|
console.log(chalk34.gray(pkgDir));
|
|
2353
2347
|
const { publint: publint2 } = await import("publint");
|