@xylabs/ts-scripts-yarn3 7.4.2 → 7.4.3
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 +82 -89
- 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 +82 -89
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +82 -89
- 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 +16 -23
- package/dist/actions/deplint/getExternalImportsFromFiles.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 +82 -89
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +86 -93
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +82 -89
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +86 -93
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +82 -89
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +82 -89
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +82 -89
- 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);
|
|
@@ -844,41 +859,34 @@ var internalImportPrefixes = [".", "#", "node:"];
|
|
|
844
859
|
var removeInternalImports = (imports) => {
|
|
845
860
|
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
846
861
|
};
|
|
862
|
+
var isDeclarationFile = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
|
|
847
863
|
function getExternalImportsFromFiles({
|
|
848
|
-
|
|
864
|
+
allFiles,
|
|
849
865
|
distFiles,
|
|
850
|
-
configFiles = [],
|
|
851
866
|
tsconfigExtends = []
|
|
852
867
|
}) {
|
|
853
|
-
const
|
|
868
|
+
const allImportPaths = {};
|
|
854
869
|
const distImportPaths = {};
|
|
855
870
|
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")));
|
|
871
|
+
for (const path13 of allFiles) getImportsFromFile(path13, allImportPaths, allImportPaths).flat();
|
|
872
|
+
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
873
|
+
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
861
874
|
for (const path13 of distCodeFiles) getImportsFromFile(path13, distImportPaths, distImportPaths).flat();
|
|
862
875
|
for (const path13 of distTypeFiles) getImportsFromFile(path13, distTypeImportPaths, distTypeImportPaths).flat();
|
|
863
|
-
const
|
|
876
|
+
const allImports = Object.keys(allImportPaths);
|
|
864
877
|
const distImports = Object.keys(distImportPaths);
|
|
865
|
-
const
|
|
866
|
-
const externalSrcImports = removeInternalImports(srcImports);
|
|
878
|
+
const externalAllImports = removeInternalImports(allImports);
|
|
867
879
|
const externalDistImports = removeInternalImports(distImports);
|
|
868
|
-
const externalDistTypeImports = removeInternalImports(
|
|
869
|
-
const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
|
|
880
|
+
const externalDistTypeImports = removeInternalImports(Object.keys(distTypeImportPaths));
|
|
870
881
|
for (const ext of tsconfigExtends) {
|
|
871
|
-
if (!
|
|
872
|
-
if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
|
|
882
|
+
if (!externalAllImports.includes(ext)) externalAllImports.push(ext);
|
|
873
883
|
}
|
|
874
884
|
return {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
srcImportPaths,
|
|
878
|
-
externalConfigImports,
|
|
879
|
-
externalSrcImports,
|
|
880
|
-
distImports,
|
|
885
|
+
allImportPaths,
|
|
886
|
+
allImports,
|
|
881
887
|
distImportPaths,
|
|
888
|
+
distImports,
|
|
889
|
+
externalAllImports,
|
|
882
890
|
externalDistImports,
|
|
883
891
|
externalDistTypeImports
|
|
884
892
|
};
|
|
@@ -930,17 +938,17 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
930
938
|
dependencies,
|
|
931
939
|
peerDependencies
|
|
932
940
|
}, {
|
|
933
|
-
|
|
934
|
-
|
|
941
|
+
allImportPaths,
|
|
942
|
+
externalAllImports,
|
|
935
943
|
distImports
|
|
936
944
|
}) {
|
|
937
945
|
let unlistedDevDependencies = 0;
|
|
938
|
-
for (const imp of
|
|
946
|
+
for (const imp of externalAllImports) {
|
|
939
947
|
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
948
|
unlistedDevDependencies++;
|
|
941
949
|
console.log(`[${chalk14.blue(name)}] Missing devDependency in package.json: ${chalk14.red(imp)}`);
|
|
942
|
-
if (
|
|
943
|
-
console.log(` ${
|
|
950
|
+
if (allImportPaths[imp]) {
|
|
951
|
+
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
944
952
|
}
|
|
945
953
|
}
|
|
946
954
|
}
|
|
@@ -957,13 +965,13 @@ import chalk15 from "chalk";
|
|
|
957
965
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
958
966
|
externalDistImports,
|
|
959
967
|
externalDistTypeImports,
|
|
960
|
-
|
|
968
|
+
externalAllImports
|
|
961
969
|
}) {
|
|
962
970
|
let unusedDependencies = 0;
|
|
963
971
|
for (const dep of dependencies) {
|
|
964
972
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
965
973
|
unusedDependencies++;
|
|
966
|
-
if (
|
|
974
|
+
if (externalAllImports.includes(dep)) {
|
|
967
975
|
console.log(`[${chalk15.blue(name)}] dependency should be devDependency in package.json: ${chalk15.red(dep)}`);
|
|
968
976
|
} else {
|
|
969
977
|
console.log(`[${chalk15.blue(name)}] Unused dependency in package.json: ${chalk15.red(dep)}`);
|
|
@@ -982,13 +990,13 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
982
990
|
import chalk16 from "chalk";
|
|
983
991
|
|
|
984
992
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
985
|
-
import
|
|
993
|
+
import fs6 from "fs";
|
|
986
994
|
import path5 from "path";
|
|
987
995
|
function findDepPackageJson(location, dep) {
|
|
988
996
|
let dir = location;
|
|
989
997
|
while (true) {
|
|
990
998
|
const candidate = path5.join(dir, "node_modules", dep, "package.json");
|
|
991
|
-
if (
|
|
999
|
+
if (fs6.existsSync(candidate)) return candidate;
|
|
992
1000
|
const parent = path5.dirname(dir);
|
|
993
1001
|
if (parent === dir) return void 0;
|
|
994
1002
|
dir = parent;
|
|
@@ -1000,7 +1008,7 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1000
1008
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1001
1009
|
if (!depPkgPath) continue;
|
|
1002
1010
|
try {
|
|
1003
|
-
const raw =
|
|
1011
|
+
const raw = fs6.readFileSync(depPkgPath, "utf8");
|
|
1004
1012
|
const pkg = JSON.parse(raw);
|
|
1005
1013
|
if (pkg.peerDependencies) {
|
|
1006
1014
|
for (const peer of Object.keys(pkg.peerDependencies)) {
|
|
@@ -1014,13 +1022,13 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1014
1022
|
}
|
|
1015
1023
|
|
|
1016
1024
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1017
|
-
import
|
|
1025
|
+
import fs7 from "fs";
|
|
1018
1026
|
import path6 from "path";
|
|
1019
1027
|
function getBinNames(location, dep) {
|
|
1020
1028
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1021
1029
|
if (!depPkgPath) return [];
|
|
1022
1030
|
try {
|
|
1023
|
-
const raw =
|
|
1031
|
+
const raw = fs7.readFileSync(depPkgPath, "utf8");
|
|
1024
1032
|
const pkg = JSON.parse(raw);
|
|
1025
1033
|
if (!pkg.bin) return [];
|
|
1026
1034
|
if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
|
|
@@ -1036,7 +1044,7 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1036
1044
|
const pkgPath = path6.join(location, "package.json");
|
|
1037
1045
|
let scripts = {};
|
|
1038
1046
|
try {
|
|
1039
|
-
const raw =
|
|
1047
|
+
const raw = fs7.readFileSync(pkgPath, "utf8");
|
|
1040
1048
|
const pkg = JSON.parse(raw);
|
|
1041
1049
|
scripts = pkg.scripts ?? {};
|
|
1042
1050
|
} catch {
|
|
@@ -1066,14 +1074,14 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1066
1074
|
}
|
|
1067
1075
|
|
|
1068
1076
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1069
|
-
import
|
|
1077
|
+
import fs8 from "fs";
|
|
1070
1078
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1071
1079
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1072
|
-
var hasTypescriptFiles = ({
|
|
1080
|
+
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1073
1081
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1074
|
-
var hasDecorators = ({
|
|
1082
|
+
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1075
1083
|
try {
|
|
1076
|
-
const content =
|
|
1084
|
+
const content = fs8.readFileSync(file, "utf8");
|
|
1077
1085
|
return decoratorPattern.test(content);
|
|
1078
1086
|
} catch {
|
|
1079
1087
|
return false;
|
|
@@ -1086,7 +1094,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1086
1094
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1087
1095
|
if (!pkgPath) continue;
|
|
1088
1096
|
try {
|
|
1089
|
-
const pkg = JSON.parse(
|
|
1097
|
+
const pkg = JSON.parse(fs8.readFileSync(pkgPath, "utf8"));
|
|
1090
1098
|
const transitiveDeps = [
|
|
1091
1099
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1092
1100
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1123,18 +1131,15 @@ function getImplicitDevDependencies(context) {
|
|
|
1123
1131
|
|
|
1124
1132
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1125
1133
|
var allExternalImports = ({
|
|
1126
|
-
|
|
1134
|
+
externalAllImports,
|
|
1127
1135
|
externalDistImports,
|
|
1128
|
-
externalDistTypeImports
|
|
1129
|
-
externalConfigImports
|
|
1136
|
+
externalDistTypeImports
|
|
1130
1137
|
}) => {
|
|
1131
|
-
|
|
1132
|
-
...
|
|
1138
|
+
return /* @__PURE__ */ new Set([
|
|
1139
|
+
...externalAllImports,
|
|
1133
1140
|
...externalDistImports,
|
|
1134
|
-
...externalDistTypeImports
|
|
1135
|
-
...externalConfigImports
|
|
1141
|
+
...externalDistTypeImports
|
|
1136
1142
|
]);
|
|
1137
|
-
return all;
|
|
1138
1143
|
};
|
|
1139
1144
|
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1140
1145
|
if (implicitDeps.has(dep)) return true;
|
|
@@ -1199,18 +1204,15 @@ function getUnusedPeerDependencies({ name, location }, { peerDependencies, depen
|
|
|
1199
1204
|
}
|
|
1200
1205
|
|
|
1201
1206
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
1202
|
-
function logVerbose(name, location,
|
|
1207
|
+
function logVerbose(name, location, allFiles, distFiles, tsconfigExtends) {
|
|
1203
1208
|
console.info(`Checking package: ${name} at ${location}`);
|
|
1204
|
-
console.info(`
|
|
1205
|
-
for (const file of
|
|
1206
|
-
console.info(`
|
|
1209
|
+
console.info(`All files: ${allFiles.length}, Distribution files: ${distFiles.length}`);
|
|
1210
|
+
for (const file of allFiles) {
|
|
1211
|
+
console.info(`File: ${file}`);
|
|
1207
1212
|
}
|
|
1208
1213
|
for (const file of distFiles) {
|
|
1209
1214
|
console.info(`Distribution file: ${file}`);
|
|
1210
1215
|
}
|
|
1211
|
-
for (const file of configFiles) {
|
|
1212
|
-
console.info(`Config file: ${file}`);
|
|
1213
|
-
}
|
|
1214
1216
|
for (const ext of tsconfigExtends) {
|
|
1215
1217
|
console.info(`Tsconfig extends: ${ext}`);
|
|
1216
1218
|
}
|
|
@@ -1223,33 +1225,24 @@ function checkPackage({
|
|
|
1223
1225
|
peerDeps = false,
|
|
1224
1226
|
verbose = false
|
|
1225
1227
|
}) {
|
|
1226
|
-
const {
|
|
1227
|
-
srcFiles,
|
|
1228
|
-
distFiles,
|
|
1229
|
-
configFiles
|
|
1230
|
-
} = findFiles(location);
|
|
1228
|
+
const { allFiles, distFiles } = findFiles(location);
|
|
1231
1229
|
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
1232
1230
|
if (verbose) {
|
|
1233
|
-
logVerbose(name, location,
|
|
1231
|
+
logVerbose(name, location, allFiles, distFiles, tsconfigExtends);
|
|
1234
1232
|
}
|
|
1235
1233
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
1236
1234
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
1237
1235
|
const checkPeerDeps = peerDeps;
|
|
1238
1236
|
const sourceParams = getExternalImportsFromFiles({
|
|
1239
|
-
|
|
1237
|
+
allFiles,
|
|
1240
1238
|
distFiles,
|
|
1241
|
-
configFiles,
|
|
1242
1239
|
tsconfigExtends
|
|
1243
1240
|
});
|
|
1244
1241
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1245
1242
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1246
1243
|
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1247
1244
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1248
|
-
const fileContext = {
|
|
1249
|
-
configFiles,
|
|
1250
|
-
distFiles,
|
|
1251
|
-
srcFiles
|
|
1252
|
-
};
|
|
1245
|
+
const fileContext = { allFiles, distFiles };
|
|
1253
1246
|
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1254
1247
|
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1255
1248
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
@@ -2318,7 +2311,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2318
2311
|
};
|
|
2319
2312
|
|
|
2320
2313
|
// src/actions/package/publint.ts
|
|
2321
|
-
import { promises as
|
|
2314
|
+
import { promises as fs9 } from "fs";
|
|
2322
2315
|
import chalk34 from "chalk";
|
|
2323
2316
|
import sortPackageJson from "sort-package-json";
|
|
2324
2317
|
var customPubLint = (pkg) => {
|
|
@@ -2345,9 +2338,9 @@ var customPubLint = (pkg) => {
|
|
|
2345
2338
|
};
|
|
2346
2339
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2347
2340
|
const pkgDir = process.env.INIT_CWD;
|
|
2348
|
-
const sortedPkg = sortPackageJson(await
|
|
2349
|
-
await
|
|
2350
|
-
const pkg = JSON.parse(await
|
|
2341
|
+
const sortedPkg = sortPackageJson(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2342
|
+
await fs9.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2343
|
+
const pkg = JSON.parse(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2351
2344
|
console.log(chalk34.green(`Publint: ${pkg.name}`));
|
|
2352
2345
|
console.log(chalk34.gray(pkgDir));
|
|
2353
2346
|
const { publint: publint2 } = await import("publint");
|