@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/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);
|
|
@@ -768,41 +783,34 @@ var internalImportPrefixes = [".", "#", "node:"];
|
|
|
768
783
|
var removeInternalImports = (imports) => {
|
|
769
784
|
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
770
785
|
};
|
|
786
|
+
var isDeclarationFile = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
|
|
771
787
|
function getExternalImportsFromFiles({
|
|
772
|
-
|
|
788
|
+
allFiles,
|
|
773
789
|
distFiles,
|
|
774
|
-
configFiles = [],
|
|
775
790
|
tsconfigExtends = []
|
|
776
791
|
}) {
|
|
777
|
-
const
|
|
792
|
+
const allImportPaths = {};
|
|
778
793
|
const distImportPaths = {};
|
|
779
794
|
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")));
|
|
795
|
+
for (const path13 of allFiles) getImportsFromFile(path13, allImportPaths, allImportPaths).flat();
|
|
796
|
+
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
797
|
+
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
785
798
|
for (const path13 of distCodeFiles) getImportsFromFile(path13, distImportPaths, distImportPaths).flat();
|
|
786
799
|
for (const path13 of distTypeFiles) getImportsFromFile(path13, distTypeImportPaths, distTypeImportPaths).flat();
|
|
787
|
-
const
|
|
800
|
+
const allImports = Object.keys(allImportPaths);
|
|
788
801
|
const distImports = Object.keys(distImportPaths);
|
|
789
|
-
const
|
|
790
|
-
const externalSrcImports = removeInternalImports(srcImports);
|
|
802
|
+
const externalAllImports = removeInternalImports(allImports);
|
|
791
803
|
const externalDistImports = removeInternalImports(distImports);
|
|
792
|
-
const externalDistTypeImports = removeInternalImports(
|
|
793
|
-
const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
|
|
804
|
+
const externalDistTypeImports = removeInternalImports(Object.keys(distTypeImportPaths));
|
|
794
805
|
for (const ext of tsconfigExtends) {
|
|
795
|
-
if (!
|
|
796
|
-
if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
|
|
806
|
+
if (!externalAllImports.includes(ext)) externalAllImports.push(ext);
|
|
797
807
|
}
|
|
798
808
|
return {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
srcImportPaths,
|
|
802
|
-
externalConfigImports,
|
|
803
|
-
externalSrcImports,
|
|
804
|
-
distImports,
|
|
809
|
+
allImportPaths,
|
|
810
|
+
allImports,
|
|
805
811
|
distImportPaths,
|
|
812
|
+
distImports,
|
|
813
|
+
externalAllImports,
|
|
806
814
|
externalDistImports,
|
|
807
815
|
externalDistTypeImports
|
|
808
816
|
};
|
|
@@ -854,17 +862,17 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
854
862
|
dependencies,
|
|
855
863
|
peerDependencies
|
|
856
864
|
}, {
|
|
857
|
-
|
|
858
|
-
|
|
865
|
+
allImportPaths,
|
|
866
|
+
externalAllImports,
|
|
859
867
|
distImports
|
|
860
868
|
}) {
|
|
861
869
|
let unlistedDevDependencies = 0;
|
|
862
|
-
for (const imp of
|
|
870
|
+
for (const imp of externalAllImports) {
|
|
863
871
|
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
872
|
unlistedDevDependencies++;
|
|
865
873
|
console.log(`[${chalk13.blue(name)}] Missing devDependency in package.json: ${chalk13.red(imp)}`);
|
|
866
|
-
if (
|
|
867
|
-
console.log(` ${
|
|
874
|
+
if (allImportPaths[imp]) {
|
|
875
|
+
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
868
876
|
}
|
|
869
877
|
}
|
|
870
878
|
}
|
|
@@ -881,13 +889,13 @@ import chalk14 from "chalk";
|
|
|
881
889
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
882
890
|
externalDistImports,
|
|
883
891
|
externalDistTypeImports,
|
|
884
|
-
|
|
892
|
+
externalAllImports
|
|
885
893
|
}) {
|
|
886
894
|
let unusedDependencies = 0;
|
|
887
895
|
for (const dep of dependencies) {
|
|
888
896
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
889
897
|
unusedDependencies++;
|
|
890
|
-
if (
|
|
898
|
+
if (externalAllImports.includes(dep)) {
|
|
891
899
|
console.log(`[${chalk14.blue(name)}] dependency should be devDependency in package.json: ${chalk14.red(dep)}`);
|
|
892
900
|
} else {
|
|
893
901
|
console.log(`[${chalk14.blue(name)}] Unused dependency in package.json: ${chalk14.red(dep)}`);
|
|
@@ -906,13 +914,13 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
906
914
|
import chalk15 from "chalk";
|
|
907
915
|
|
|
908
916
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
909
|
-
import
|
|
917
|
+
import fs6 from "fs";
|
|
910
918
|
import path5 from "path";
|
|
911
919
|
function findDepPackageJson(location, dep) {
|
|
912
920
|
let dir = location;
|
|
913
921
|
while (true) {
|
|
914
922
|
const candidate = path5.join(dir, "node_modules", dep, "package.json");
|
|
915
|
-
if (
|
|
923
|
+
if (fs6.existsSync(candidate)) return candidate;
|
|
916
924
|
const parent = path5.dirname(dir);
|
|
917
925
|
if (parent === dir) return void 0;
|
|
918
926
|
dir = parent;
|
|
@@ -924,7 +932,7 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
924
932
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
925
933
|
if (!depPkgPath) continue;
|
|
926
934
|
try {
|
|
927
|
-
const raw =
|
|
935
|
+
const raw = fs6.readFileSync(depPkgPath, "utf8");
|
|
928
936
|
const pkg = JSON.parse(raw);
|
|
929
937
|
if (pkg.peerDependencies) {
|
|
930
938
|
for (const peer of Object.keys(pkg.peerDependencies)) {
|
|
@@ -938,13 +946,13 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
938
946
|
}
|
|
939
947
|
|
|
940
948
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
941
|
-
import
|
|
949
|
+
import fs7 from "fs";
|
|
942
950
|
import path6 from "path";
|
|
943
951
|
function getBinNames(location, dep) {
|
|
944
952
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
945
953
|
if (!depPkgPath) return [];
|
|
946
954
|
try {
|
|
947
|
-
const raw =
|
|
955
|
+
const raw = fs7.readFileSync(depPkgPath, "utf8");
|
|
948
956
|
const pkg = JSON.parse(raw);
|
|
949
957
|
if (!pkg.bin) return [];
|
|
950
958
|
if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
|
|
@@ -960,7 +968,7 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
960
968
|
const pkgPath = path6.join(location, "package.json");
|
|
961
969
|
let scripts = {};
|
|
962
970
|
try {
|
|
963
|
-
const raw =
|
|
971
|
+
const raw = fs7.readFileSync(pkgPath, "utf8");
|
|
964
972
|
const pkg = JSON.parse(raw);
|
|
965
973
|
scripts = pkg.scripts ?? {};
|
|
966
974
|
} catch {
|
|
@@ -990,14 +998,14 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
990
998
|
}
|
|
991
999
|
|
|
992
1000
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
993
|
-
import
|
|
1001
|
+
import fs8 from "fs";
|
|
994
1002
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
995
1003
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
996
|
-
var hasTypescriptFiles = ({
|
|
1004
|
+
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
997
1005
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
998
|
-
var hasDecorators = ({
|
|
1006
|
+
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
999
1007
|
try {
|
|
1000
|
-
const content =
|
|
1008
|
+
const content = fs8.readFileSync(file, "utf8");
|
|
1001
1009
|
return decoratorPattern.test(content);
|
|
1002
1010
|
} catch {
|
|
1003
1011
|
return false;
|
|
@@ -1010,7 +1018,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1010
1018
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1011
1019
|
if (!pkgPath) continue;
|
|
1012
1020
|
try {
|
|
1013
|
-
const pkg = JSON.parse(
|
|
1021
|
+
const pkg = JSON.parse(fs8.readFileSync(pkgPath, "utf8"));
|
|
1014
1022
|
const transitiveDeps = [
|
|
1015
1023
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1016
1024
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1047,18 +1055,15 @@ function getImplicitDevDependencies(context) {
|
|
|
1047
1055
|
|
|
1048
1056
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1049
1057
|
var allExternalImports = ({
|
|
1050
|
-
|
|
1058
|
+
externalAllImports,
|
|
1051
1059
|
externalDistImports,
|
|
1052
|
-
externalDistTypeImports
|
|
1053
|
-
externalConfigImports
|
|
1060
|
+
externalDistTypeImports
|
|
1054
1061
|
}) => {
|
|
1055
|
-
|
|
1056
|
-
...
|
|
1062
|
+
return /* @__PURE__ */ new Set([
|
|
1063
|
+
...externalAllImports,
|
|
1057
1064
|
...externalDistImports,
|
|
1058
|
-
...externalDistTypeImports
|
|
1059
|
-
...externalConfigImports
|
|
1065
|
+
...externalDistTypeImports
|
|
1060
1066
|
]);
|
|
1061
|
-
return all;
|
|
1062
1067
|
};
|
|
1063
1068
|
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1064
1069
|
if (implicitDeps.has(dep)) return true;
|
|
@@ -1123,18 +1128,15 @@ function getUnusedPeerDependencies({ name, location }, { peerDependencies, depen
|
|
|
1123
1128
|
}
|
|
1124
1129
|
|
|
1125
1130
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
1126
|
-
function logVerbose(name, location,
|
|
1131
|
+
function logVerbose(name, location, allFiles, distFiles, tsconfigExtends) {
|
|
1127
1132
|
console.info(`Checking package: ${name} at ${location}`);
|
|
1128
|
-
console.info(`
|
|
1129
|
-
for (const file of
|
|
1130
|
-
console.info(`
|
|
1133
|
+
console.info(`All files: ${allFiles.length}, Distribution files: ${distFiles.length}`);
|
|
1134
|
+
for (const file of allFiles) {
|
|
1135
|
+
console.info(`File: ${file}`);
|
|
1131
1136
|
}
|
|
1132
1137
|
for (const file of distFiles) {
|
|
1133
1138
|
console.info(`Distribution file: ${file}`);
|
|
1134
1139
|
}
|
|
1135
|
-
for (const file of configFiles) {
|
|
1136
|
-
console.info(`Config file: ${file}`);
|
|
1137
|
-
}
|
|
1138
1140
|
for (const ext of tsconfigExtends) {
|
|
1139
1141
|
console.info(`Tsconfig extends: ${ext}`);
|
|
1140
1142
|
}
|
|
@@ -1147,33 +1149,24 @@ function checkPackage({
|
|
|
1147
1149
|
peerDeps = false,
|
|
1148
1150
|
verbose = false
|
|
1149
1151
|
}) {
|
|
1150
|
-
const {
|
|
1151
|
-
srcFiles,
|
|
1152
|
-
distFiles,
|
|
1153
|
-
configFiles
|
|
1154
|
-
} = findFiles(location);
|
|
1152
|
+
const { allFiles, distFiles } = findFiles(location);
|
|
1155
1153
|
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
1156
1154
|
if (verbose) {
|
|
1157
|
-
logVerbose(name, location,
|
|
1155
|
+
logVerbose(name, location, allFiles, distFiles, tsconfigExtends);
|
|
1158
1156
|
}
|
|
1159
1157
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
1160
1158
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
1161
1159
|
const checkPeerDeps = peerDeps;
|
|
1162
1160
|
const sourceParams = getExternalImportsFromFiles({
|
|
1163
|
-
|
|
1161
|
+
allFiles,
|
|
1164
1162
|
distFiles,
|
|
1165
|
-
configFiles,
|
|
1166
1163
|
tsconfigExtends
|
|
1167
1164
|
});
|
|
1168
1165
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1169
1166
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1170
1167
|
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1171
1168
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1172
|
-
const fileContext = {
|
|
1173
|
-
configFiles,
|
|
1174
|
-
distFiles,
|
|
1175
|
-
srcFiles
|
|
1176
|
-
};
|
|
1169
|
+
const fileContext = { allFiles, distFiles };
|
|
1177
1170
|
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1178
1171
|
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1179
1172
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
@@ -2242,7 +2235,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2242
2235
|
};
|
|
2243
2236
|
|
|
2244
2237
|
// src/actions/package/publint.ts
|
|
2245
|
-
import { promises as
|
|
2238
|
+
import { promises as fs9 } from "fs";
|
|
2246
2239
|
import chalk33 from "chalk";
|
|
2247
2240
|
import sortPackageJson from "sort-package-json";
|
|
2248
2241
|
var customPubLint = (pkg) => {
|
|
@@ -2269,9 +2262,9 @@ var customPubLint = (pkg) => {
|
|
|
2269
2262
|
};
|
|
2270
2263
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2271
2264
|
const pkgDir = process.env.INIT_CWD;
|
|
2272
|
-
const sortedPkg = sortPackageJson(await
|
|
2273
|
-
await
|
|
2274
|
-
const pkg = JSON.parse(await
|
|
2265
|
+
const sortedPkg = sortPackageJson(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2266
|
+
await fs9.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2267
|
+
const pkg = JSON.parse(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2275
2268
|
console.log(chalk33.green(`Publint: ${pkg.name}`));
|
|
2276
2269
|
console.log(chalk33.gray(pkgDir));
|
|
2277
2270
|
const { publint: publint2 } = await import("publint");
|