@xylabs/ts-scripts-yarn3 7.3.2 → 7.4.0
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/cycle.mjs +1 -1
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +278 -35
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +13 -6
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +3 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +175 -0
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/index.mjs +278 -35
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +281 -38
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/findFiles.mjs +8 -2
- package/dist/actions/deplint/findFiles.mjs.map +1 -1
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +44 -0
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +15 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs +36 -0
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs +81 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs +25 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/index.mjs +281 -38
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +385 -142
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +328 -85
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +397 -154
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +328 -85
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +328 -85
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +301 -58
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +15 -16
package/dist/index.mjs
CHANGED
|
@@ -373,8 +373,8 @@ var loadConfig = async (params) => {
|
|
|
373
373
|
|
|
374
374
|
// src/lib/parsedPackageJSON.ts
|
|
375
375
|
import { readFileSync as readFileSync4 } from "fs";
|
|
376
|
-
var parsedPackageJSON = (
|
|
377
|
-
const pathToPackageJSON =
|
|
376
|
+
var parsedPackageJSON = (path13) => {
|
|
377
|
+
const pathToPackageJSON = path13 ?? process.env.npm_package_json ?? "";
|
|
378
378
|
const packageJSON = readFileSync4(pathToPackageJSON).toString();
|
|
379
379
|
return JSON.parse(packageJSON);
|
|
380
380
|
};
|
|
@@ -674,7 +674,7 @@ var cycleAll = async ({ verbose = false }) => {
|
|
|
674
674
|
combinedDependencies: true,
|
|
675
675
|
outputType: verbose ? "text" : "err"
|
|
676
676
|
};
|
|
677
|
-
const target = "**/src";
|
|
677
|
+
const target = "**/packages/*/src";
|
|
678
678
|
console.log(`Checking for circular dependencies in ${target}...`);
|
|
679
679
|
const result = await cruise([target], cruiseOptions);
|
|
680
680
|
if (result.output) {
|
|
@@ -694,7 +694,7 @@ var dead = () => {
|
|
|
694
694
|
};
|
|
695
695
|
|
|
696
696
|
// src/actions/deplint/deplint.ts
|
|
697
|
-
import
|
|
697
|
+
import chalk18 from "chalk";
|
|
698
698
|
|
|
699
699
|
// src/actions/deplint/findFilesByGlob.ts
|
|
700
700
|
import { globSync } from "glob";
|
|
@@ -703,12 +703,18 @@ function findFilesByGlob(cwd5, pattern) {
|
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
// src/actions/deplint/findFiles.ts
|
|
706
|
-
function findFiles(
|
|
707
|
-
const allSourceInclude = ["./src/**/*.{ts,tsx}"];
|
|
706
|
+
function findFiles(path13) {
|
|
707
|
+
const allSourceInclude = ["./src/**/*.{ts,tsx,mts,cts,js,mjs,cjs}"];
|
|
708
708
|
const allDistInclude = ["./dist/**/*.d.ts", "./dist/**/*.{mjs,js,cjs}"];
|
|
709
|
-
const
|
|
710
|
-
const
|
|
711
|
-
|
|
709
|
+
const allConfigInclude = ["./*.config.{ts,mts,mjs,js}"];
|
|
710
|
+
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path13, pattern));
|
|
711
|
+
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path13, pattern));
|
|
712
|
+
const configFiles = allConfigInclude.flatMap((pattern) => findFilesByGlob(path13, pattern));
|
|
713
|
+
return {
|
|
714
|
+
srcFiles,
|
|
715
|
+
distFiles,
|
|
716
|
+
configFiles
|
|
717
|
+
};
|
|
712
718
|
}
|
|
713
719
|
|
|
714
720
|
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
@@ -728,10 +734,9 @@ function getDependenciesFromPackageJson(packageJsonPath) {
|
|
|
728
734
|
};
|
|
729
735
|
}
|
|
730
736
|
|
|
731
|
-
// src/actions/deplint/
|
|
737
|
+
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
732
738
|
import fs3 from "fs";
|
|
733
|
-
import
|
|
734
|
-
import ts from "typescript";
|
|
739
|
+
import { globSync as globSync2 } from "glob";
|
|
735
740
|
|
|
736
741
|
// src/actions/deplint/getBasePackageName.ts
|
|
737
742
|
function getBasePackageName(importName) {
|
|
@@ -743,7 +748,37 @@ function getBasePackageName(importName) {
|
|
|
743
748
|
return importNameScrubbed.split("/")[0];
|
|
744
749
|
}
|
|
745
750
|
|
|
751
|
+
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
752
|
+
var isExternalReference = (ref) => !ref.startsWith(".") && !ref.startsWith("/");
|
|
753
|
+
function parseExtendsField(value) {
|
|
754
|
+
if (typeof value === "string") return [value];
|
|
755
|
+
if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
|
|
756
|
+
return [];
|
|
757
|
+
}
|
|
758
|
+
function getExtendsFromTsconfigs(location) {
|
|
759
|
+
const tsconfigFiles = globSync2("./tsconfig*.json", { cwd: location, absolute: true });
|
|
760
|
+
const packages = /* @__PURE__ */ new Set();
|
|
761
|
+
for (const file of tsconfigFiles) {
|
|
762
|
+
try {
|
|
763
|
+
const content = fs3.readFileSync(file, "utf8");
|
|
764
|
+
const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
|
|
765
|
+
const parsed = JSON.parse(cleaned);
|
|
766
|
+
const refs = parseExtendsField(parsed.extends);
|
|
767
|
+
for (const ref of refs) {
|
|
768
|
+
if (isExternalReference(ref)) {
|
|
769
|
+
packages.add(getBasePackageName(ref));
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
} catch {
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return [...packages];
|
|
776
|
+
}
|
|
777
|
+
|
|
746
778
|
// src/actions/deplint/getImportsFromFile.ts
|
|
779
|
+
import fs4 from "fs";
|
|
780
|
+
import path4 from "path";
|
|
781
|
+
import ts from "typescript";
|
|
747
782
|
function isTypeOnlyImportClause(clause) {
|
|
748
783
|
if (clause === void 0) {
|
|
749
784
|
return false;
|
|
@@ -756,7 +791,7 @@ function isTypeOnlyImportClause(clause) {
|
|
|
756
791
|
return clause.isTypeOnly;
|
|
757
792
|
}
|
|
758
793
|
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
759
|
-
const sourceCode =
|
|
794
|
+
const sourceCode = fs4.readFileSync(filePath, "utf8");
|
|
760
795
|
const isMjsFile = filePath.endsWith(".mjs");
|
|
761
796
|
const sourceFile = ts.createSourceFile(
|
|
762
797
|
path4.basename(filePath),
|
|
@@ -809,24 +844,38 @@ var internalImportPrefixes = [".", "#", "node:"];
|
|
|
809
844
|
var removeInternalImports = (imports) => {
|
|
810
845
|
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
811
846
|
};
|
|
812
|
-
function getExternalImportsFromFiles({
|
|
847
|
+
function getExternalImportsFromFiles({
|
|
848
|
+
srcFiles,
|
|
849
|
+
distFiles,
|
|
850
|
+
configFiles = [],
|
|
851
|
+
tsconfigExtends = []
|
|
852
|
+
}) {
|
|
813
853
|
const srcImportPaths = {};
|
|
814
854
|
const distImportPaths = {};
|
|
815
855
|
const distTypeImportPaths = {};
|
|
816
|
-
|
|
856
|
+
const configImportPaths = {};
|
|
857
|
+
for (const path13 of srcFiles) getImportsFromFile(path13, srcImportPaths, srcImportPaths).flat();
|
|
858
|
+
for (const path13 of configFiles) getImportsFromFile(path13, configImportPaths, configImportPaths).flat();
|
|
817
859
|
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
818
860
|
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
819
|
-
for (const
|
|
820
|
-
for (const
|
|
861
|
+
for (const path13 of distCodeFiles) getImportsFromFile(path13, distImportPaths, distImportPaths).flat();
|
|
862
|
+
for (const path13 of distTypeFiles) getImportsFromFile(path13, distTypeImportPaths, distTypeImportPaths).flat();
|
|
821
863
|
const srcImports = Object.keys(srcImportPaths);
|
|
822
864
|
const distImports = Object.keys(distImportPaths);
|
|
823
865
|
const distTypeImports = Object.keys(distTypeImportPaths);
|
|
824
866
|
const externalSrcImports = removeInternalImports(srcImports);
|
|
825
867
|
const externalDistImports = removeInternalImports(distImports);
|
|
826
868
|
const externalDistTypeImports = removeInternalImports(distTypeImports);
|
|
869
|
+
const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
|
|
870
|
+
for (const ext of tsconfigExtends) {
|
|
871
|
+
if (!externalSrcImports.includes(ext)) externalSrcImports.push(ext);
|
|
872
|
+
if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
|
|
873
|
+
}
|
|
827
874
|
return {
|
|
875
|
+
configImportPaths,
|
|
828
876
|
srcImports,
|
|
829
877
|
srcImportPaths,
|
|
878
|
+
externalConfigImports,
|
|
830
879
|
externalSrcImports,
|
|
831
880
|
distImports,
|
|
832
881
|
distImportPaths,
|
|
@@ -838,6 +887,15 @@ function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
|
838
887
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
839
888
|
import { builtinModules } from "module";
|
|
840
889
|
import chalk13 from "chalk";
|
|
890
|
+
function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
|
|
891
|
+
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
|
|
892
|
+
}
|
|
893
|
+
function logMissing(name, imp, importPaths) {
|
|
894
|
+
console.log(`[${chalk13.blue(name)}] Missing dependency in package.json: ${chalk13.red(imp)}`);
|
|
895
|
+
if (importPaths[imp]) {
|
|
896
|
+
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
841
899
|
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, {
|
|
842
900
|
externalDistImports,
|
|
843
901
|
externalDistTypeImports,
|
|
@@ -845,17 +903,15 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
845
903
|
}) {
|
|
846
904
|
let unlistedDependencies = 0;
|
|
847
905
|
for (const imp of externalDistImports) {
|
|
848
|
-
if (!
|
|
906
|
+
if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
|
|
849
907
|
unlistedDependencies++;
|
|
850
|
-
|
|
851
|
-
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
908
|
+
logMissing(name, imp, distImportPaths);
|
|
852
909
|
}
|
|
853
910
|
}
|
|
854
911
|
for (const imp of externalDistTypeImports) {
|
|
855
|
-
if (!
|
|
912
|
+
if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
|
|
856
913
|
unlistedDependencies++;
|
|
857
|
-
|
|
858
|
-
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
914
|
+
logMissing(name, imp, distImportPaths);
|
|
859
915
|
}
|
|
860
916
|
}
|
|
861
917
|
if (unlistedDependencies > 0) {
|
|
@@ -883,7 +939,9 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
883
939
|
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)) {
|
|
884
940
|
unlistedDevDependencies++;
|
|
885
941
|
console.log(`[${chalk14.blue(name)}] Missing devDependency in package.json: ${chalk14.red(imp)}`);
|
|
886
|
-
|
|
942
|
+
if (srcImportPaths[imp]) {
|
|
943
|
+
console.log(` ${srcImportPaths[imp].join("\n ")}`);
|
|
944
|
+
}
|
|
887
945
|
}
|
|
888
946
|
}
|
|
889
947
|
if (unlistedDevDependencies > 0) {
|
|
@@ -920,29 +978,205 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
920
978
|
return unusedDependencies;
|
|
921
979
|
}
|
|
922
980
|
|
|
923
|
-
// src/actions/deplint/checkPackage/
|
|
981
|
+
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
924
982
|
import chalk16 from "chalk";
|
|
983
|
+
|
|
984
|
+
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
985
|
+
import fs5 from "fs";
|
|
986
|
+
import path5 from "path";
|
|
987
|
+
function findDepPackageJson(location, dep) {
|
|
988
|
+
let dir = location;
|
|
989
|
+
while (true) {
|
|
990
|
+
const candidate = path5.join(dir, "node_modules", dep, "package.json");
|
|
991
|
+
if (fs5.existsSync(candidate)) return candidate;
|
|
992
|
+
const parent = path5.dirname(dir);
|
|
993
|
+
if (parent === dir) return void 0;
|
|
994
|
+
dir = parent;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function getRequiredPeerDependencies(location, allDeps) {
|
|
998
|
+
const required = /* @__PURE__ */ new Set();
|
|
999
|
+
for (const dep of allDeps) {
|
|
1000
|
+
const depPkgPath = findDepPackageJson(location, dep);
|
|
1001
|
+
if (!depPkgPath) continue;
|
|
1002
|
+
try {
|
|
1003
|
+
const raw = fs5.readFileSync(depPkgPath, "utf8");
|
|
1004
|
+
const pkg = JSON.parse(raw);
|
|
1005
|
+
if (pkg.peerDependencies) {
|
|
1006
|
+
for (const peer of Object.keys(pkg.peerDependencies)) {
|
|
1007
|
+
required.add(peer);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
} catch {
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return required;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1017
|
+
import fs6 from "fs";
|
|
1018
|
+
import path6 from "path";
|
|
1019
|
+
function getBinNames(location, dep) {
|
|
1020
|
+
const depPkgPath = findDepPackageJson(location, dep);
|
|
1021
|
+
if (!depPkgPath) return [];
|
|
1022
|
+
try {
|
|
1023
|
+
const raw = fs6.readFileSync(depPkgPath, "utf8");
|
|
1024
|
+
const pkg = JSON.parse(raw);
|
|
1025
|
+
if (!pkg.bin) return [];
|
|
1026
|
+
if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
|
|
1027
|
+
return Object.keys(pkg.bin);
|
|
1028
|
+
} catch {
|
|
1029
|
+
return [];
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
function tokenizeScript(script) {
|
|
1033
|
+
return script.split(/[&|;$()"`\s]+/).map((t) => t.trim()).filter(Boolean);
|
|
1034
|
+
}
|
|
1035
|
+
function getScriptReferencedPackages(location, allDeps) {
|
|
1036
|
+
const pkgPath = path6.join(location, "package.json");
|
|
1037
|
+
let scripts = {};
|
|
1038
|
+
try {
|
|
1039
|
+
const raw = fs6.readFileSync(pkgPath, "utf8");
|
|
1040
|
+
const pkg = JSON.parse(raw);
|
|
1041
|
+
scripts = pkg.scripts ?? {};
|
|
1042
|
+
} catch {
|
|
1043
|
+
return /* @__PURE__ */ new Set();
|
|
1044
|
+
}
|
|
1045
|
+
const scriptText = Object.values(scripts).join(" ");
|
|
1046
|
+
const tokens = new Set(tokenizeScript(scriptText));
|
|
1047
|
+
const binToPackage = /* @__PURE__ */ new Map();
|
|
1048
|
+
for (const dep of allDeps) {
|
|
1049
|
+
const bins = getBinNames(location, dep);
|
|
1050
|
+
for (const bin of bins) {
|
|
1051
|
+
binToPackage.set(bin, dep);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1055
|
+
for (const token of tokens) {
|
|
1056
|
+
const baseName = getBasePackageName(token);
|
|
1057
|
+
if (allDeps.includes(baseName)) {
|
|
1058
|
+
referenced.add(baseName);
|
|
1059
|
+
}
|
|
1060
|
+
const pkg = binToPackage.get(token);
|
|
1061
|
+
if (pkg) {
|
|
1062
|
+
referenced.add(pkg);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
return referenced;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// src/actions/deplint/implicitDevDependencies.ts
|
|
1069
|
+
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1070
|
+
var rules = [
|
|
1071
|
+
{
|
|
1072
|
+
package: "typescript",
|
|
1073
|
+
isNeeded: ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], [".ts", ".tsx", ".mts", ".cts"])
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
package: "eslint-import-resolver-typescript",
|
|
1077
|
+
isNeeded: ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], [".ts", ".tsx", ".mts", ".cts"])
|
|
1078
|
+
}
|
|
1079
|
+
];
|
|
1080
|
+
function getImplicitDevDependencies(context) {
|
|
1081
|
+
const implicit = /* @__PURE__ */ new Set();
|
|
1082
|
+
for (const rule of rules) {
|
|
1083
|
+
if (rule.isNeeded(context)) {
|
|
1084
|
+
implicit.add(rule.package);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return implicit;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1091
|
+
var allExternalImports = ({
|
|
1092
|
+
externalSrcImports,
|
|
1093
|
+
externalDistImports,
|
|
1094
|
+
externalDistTypeImports,
|
|
1095
|
+
externalConfigImports
|
|
1096
|
+
}) => {
|
|
1097
|
+
const all = /* @__PURE__ */ new Set([
|
|
1098
|
+
...externalSrcImports,
|
|
1099
|
+
...externalDistImports,
|
|
1100
|
+
...externalDistTypeImports,
|
|
1101
|
+
...externalConfigImports
|
|
1102
|
+
]);
|
|
1103
|
+
return all;
|
|
1104
|
+
};
|
|
1105
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1106
|
+
if (implicitDeps.has(dep)) return true;
|
|
1107
|
+
if (requiredPeers.has(dep)) return true;
|
|
1108
|
+
if (scriptRefs.has(dep)) return true;
|
|
1109
|
+
if (dep.startsWith("@types/")) {
|
|
1110
|
+
const baseName = dep.replace(/^@types\//, "");
|
|
1111
|
+
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
1112
|
+
}
|
|
1113
|
+
return allImports.has(dep);
|
|
1114
|
+
}
|
|
1115
|
+
function getUnusedDevDependencies({ name, location }, {
|
|
1116
|
+
devDependencies,
|
|
1117
|
+
dependencies,
|
|
1118
|
+
peerDependencies
|
|
1119
|
+
}, sourceParams, fileContext) {
|
|
1120
|
+
const allImports = allExternalImports(sourceParams);
|
|
1121
|
+
const implicitDeps = getImplicitDevDependencies(fileContext);
|
|
1122
|
+
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1123
|
+
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1124
|
+
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1125
|
+
let unusedDevDependencies = 0;
|
|
1126
|
+
for (const dep of devDependencies) {
|
|
1127
|
+
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1128
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1129
|
+
unusedDevDependencies++;
|
|
1130
|
+
console.log(`[${chalk16.blue(name)}] Unused devDependency in package.json: ${chalk16.red(dep)}`);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
if (unusedDevDependencies > 0) {
|
|
1134
|
+
const packageLocation = `${location}/package.json`;
|
|
1135
|
+
console.log(` ${chalk16.yellow(packageLocation)}
|
|
1136
|
+
`);
|
|
1137
|
+
}
|
|
1138
|
+
return unusedDevDependencies;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1142
|
+
import chalk17 from "chalk";
|
|
925
1143
|
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
926
1144
|
let unusedDependencies = 0;
|
|
927
1145
|
for (const dep of peerDependencies) {
|
|
928
1146
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
929
1147
|
unusedDependencies++;
|
|
930
1148
|
if (dependencies.includes(dep)) {
|
|
931
|
-
console.log(`[${
|
|
1149
|
+
console.log(`[${chalk17.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk17.red(dep)}`);
|
|
932
1150
|
} else {
|
|
933
|
-
console.log(`[${
|
|
1151
|
+
console.log(`[${chalk17.blue(name)}] Unused peerDependency in package.json: ${chalk17.red(dep)}`);
|
|
934
1152
|
}
|
|
935
1153
|
}
|
|
936
1154
|
}
|
|
937
1155
|
if (unusedDependencies > 0) {
|
|
938
1156
|
const packageLocation = `${location}/package.json`;
|
|
939
|
-
console.log(` ${
|
|
1157
|
+
console.log(` ${chalk17.yellow(packageLocation)}
|
|
940
1158
|
`);
|
|
941
1159
|
}
|
|
942
1160
|
return unusedDependencies;
|
|
943
1161
|
}
|
|
944
1162
|
|
|
945
1163
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
1164
|
+
function logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends) {
|
|
1165
|
+
console.info(`Checking package: ${name} at ${location}`);
|
|
1166
|
+
console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}, Config files: ${configFiles.length}`);
|
|
1167
|
+
for (const file of srcFiles) {
|
|
1168
|
+
console.info(`Source file: ${file}`);
|
|
1169
|
+
}
|
|
1170
|
+
for (const file of distFiles) {
|
|
1171
|
+
console.info(`Distribution file: ${file}`);
|
|
1172
|
+
}
|
|
1173
|
+
for (const file of configFiles) {
|
|
1174
|
+
console.info(`Config file: ${file}`);
|
|
1175
|
+
}
|
|
1176
|
+
for (const ext of tsconfigExtends) {
|
|
1177
|
+
console.info(`Tsconfig extends: ${ext}`);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
946
1180
|
function checkPackage({
|
|
947
1181
|
name,
|
|
948
1182
|
location,
|
|
@@ -951,27 +1185,36 @@ function checkPackage({
|
|
|
951
1185
|
peerDeps = false,
|
|
952
1186
|
verbose = false
|
|
953
1187
|
}) {
|
|
954
|
-
const {
|
|
1188
|
+
const {
|
|
1189
|
+
srcFiles,
|
|
1190
|
+
distFiles,
|
|
1191
|
+
configFiles
|
|
1192
|
+
} = findFiles(location);
|
|
1193
|
+
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
955
1194
|
if (verbose) {
|
|
956
|
-
|
|
957
|
-
console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`);
|
|
958
|
-
for (const file of srcFiles) {
|
|
959
|
-
console.info(`Source file: ${file}`);
|
|
960
|
-
}
|
|
961
|
-
for (const file of distFiles) {
|
|
962
|
-
console.info(`Distribution file: ${file}`);
|
|
963
|
-
}
|
|
1195
|
+
logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends);
|
|
964
1196
|
}
|
|
965
1197
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
966
1198
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
967
1199
|
const checkPeerDeps = peerDeps;
|
|
968
|
-
const sourceParams = getExternalImportsFromFiles({
|
|
1200
|
+
const sourceParams = getExternalImportsFromFiles({
|
|
1201
|
+
srcFiles,
|
|
1202
|
+
distFiles,
|
|
1203
|
+
configFiles,
|
|
1204
|
+
tsconfigExtends
|
|
1205
|
+
});
|
|
969
1206
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
970
1207
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
971
1208
|
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
972
1209
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1210
|
+
const fileContext = {
|
|
1211
|
+
configFiles,
|
|
1212
|
+
distFiles,
|
|
1213
|
+
srcFiles
|
|
1214
|
+
};
|
|
1215
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
973
1216
|
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
974
|
-
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies;
|
|
1217
|
+
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
975
1218
|
return totalErrors;
|
|
976
1219
|
}
|
|
977
1220
|
|
|
@@ -1009,9 +1252,9 @@ var deplint = ({
|
|
|
1009
1252
|
});
|
|
1010
1253
|
}
|
|
1011
1254
|
if (totalErrors > 0) {
|
|
1012
|
-
console.warn(`Deplint: Found ${
|
|
1255
|
+
console.warn(`Deplint: Found ${chalk18.red(totalErrors)} dependency problems. ${chalk18.red("\u2716")}`);
|
|
1013
1256
|
} else {
|
|
1014
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1257
|
+
console.info(`Deplint: Found no dependency problems. ${chalk18.green("\u2714")}`);
|
|
1015
1258
|
}
|
|
1016
1259
|
return 0;
|
|
1017
1260
|
};
|
|
@@ -1113,22 +1356,22 @@ var deployNext = () => {
|
|
|
1113
1356
|
};
|
|
1114
1357
|
|
|
1115
1358
|
// src/actions/dupdeps.ts
|
|
1116
|
-
import
|
|
1359
|
+
import chalk19 from "chalk";
|
|
1117
1360
|
var dupdeps = () => {
|
|
1118
|
-
console.log(
|
|
1361
|
+
console.log(chalk19.green("Checking all Dependencies for Duplicates"));
|
|
1119
1362
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1120
1363
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1121
1364
|
return detectDuplicateDependencies(dependencies);
|
|
1122
1365
|
};
|
|
1123
1366
|
|
|
1124
1367
|
// src/actions/lint.ts
|
|
1125
|
-
import
|
|
1368
|
+
import chalk20 from "chalk";
|
|
1126
1369
|
var lintPackage = ({
|
|
1127
1370
|
pkg,
|
|
1128
1371
|
fix: fix2,
|
|
1129
1372
|
verbose
|
|
1130
1373
|
}) => {
|
|
1131
|
-
console.log(
|
|
1374
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1132
1375
|
const start = Date.now();
|
|
1133
1376
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1134
1377
|
["yarn", [
|
|
@@ -1138,7 +1381,7 @@ var lintPackage = ({
|
|
|
1138
1381
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1139
1382
|
]]
|
|
1140
1383
|
]);
|
|
1141
|
-
console.log(
|
|
1384
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
1142
1385
|
return result;
|
|
1143
1386
|
};
|
|
1144
1387
|
var lint = ({
|
|
@@ -1158,13 +1401,13 @@ var lint = ({
|
|
|
1158
1401
|
});
|
|
1159
1402
|
};
|
|
1160
1403
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1161
|
-
console.log(
|
|
1404
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1162
1405
|
const start = Date.now();
|
|
1163
1406
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1164
1407
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1165
1408
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1166
1409
|
]);
|
|
1167
|
-
console.log(
|
|
1410
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
1168
1411
|
return result;
|
|
1169
1412
|
};
|
|
1170
1413
|
|
|
@@ -1192,7 +1435,7 @@ var filename = ".gitignore";
|
|
|
1192
1435
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1193
1436
|
|
|
1194
1437
|
// src/actions/gitlint.ts
|
|
1195
|
-
import
|
|
1438
|
+
import chalk21 from "chalk";
|
|
1196
1439
|
import ParseGitConfig from "parse-git-config";
|
|
1197
1440
|
var gitlint = () => {
|
|
1198
1441
|
console.log(`
|
|
@@ -1203,7 +1446,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1203
1446
|
const errors = 0;
|
|
1204
1447
|
const gitConfig = ParseGitConfig.sync();
|
|
1205
1448
|
const warn = (message) => {
|
|
1206
|
-
console.warn(
|
|
1449
|
+
console.warn(chalk21.yellow(`Warning: ${message}`));
|
|
1207
1450
|
warnings++;
|
|
1208
1451
|
};
|
|
1209
1452
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1223,13 +1466,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1223
1466
|
}
|
|
1224
1467
|
const resultMessages = [];
|
|
1225
1468
|
if (valid > 0) {
|
|
1226
|
-
resultMessages.push(
|
|
1469
|
+
resultMessages.push(chalk21.green(`Passed: ${valid}`));
|
|
1227
1470
|
}
|
|
1228
1471
|
if (warnings > 0) {
|
|
1229
|
-
resultMessages.push(
|
|
1472
|
+
resultMessages.push(chalk21.yellow(`Warnings: ${warnings}`));
|
|
1230
1473
|
}
|
|
1231
1474
|
if (errors > 0) {
|
|
1232
|
-
resultMessages.push(
|
|
1475
|
+
resultMessages.push(chalk21.red(` Errors: ${errors}`));
|
|
1233
1476
|
}
|
|
1234
1477
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1235
1478
|
`);
|
|
@@ -1238,7 +1481,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1238
1481
|
|
|
1239
1482
|
// src/actions/gitlint-fix.ts
|
|
1240
1483
|
import { execSync as execSync2 } from "child_process";
|
|
1241
|
-
import
|
|
1484
|
+
import chalk22 from "chalk";
|
|
1242
1485
|
import ParseGitConfig2 from "parse-git-config";
|
|
1243
1486
|
var gitlintFix = () => {
|
|
1244
1487
|
console.log(`
|
|
@@ -1247,15 +1490,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1247
1490
|
const gitConfig = ParseGitConfig2.sync();
|
|
1248
1491
|
if (gitConfig.core.ignorecase) {
|
|
1249
1492
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1250
|
-
console.warn(
|
|
1493
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1251
1494
|
}
|
|
1252
1495
|
if (gitConfig.core.autocrlf !== false) {
|
|
1253
1496
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1254
|
-
console.warn(
|
|
1497
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1255
1498
|
}
|
|
1256
1499
|
if (gitConfig.core.eol !== "lf") {
|
|
1257
1500
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1258
|
-
console.warn(
|
|
1501
|
+
console.warn(chalk22.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1259
1502
|
}
|
|
1260
1503
|
return 1;
|
|
1261
1504
|
};
|
|
@@ -1266,7 +1509,7 @@ var knip = () => {
|
|
|
1266
1509
|
};
|
|
1267
1510
|
|
|
1268
1511
|
// src/actions/license.ts
|
|
1269
|
-
import
|
|
1512
|
+
import chalk23 from "chalk";
|
|
1270
1513
|
import { init } from "license-checker";
|
|
1271
1514
|
var license = async (pkg) => {
|
|
1272
1515
|
const workspaces = yarnWorkspaces();
|
|
@@ -1291,18 +1534,18 @@ var license = async (pkg) => {
|
|
|
1291
1534
|
"LGPL-3.0-or-later",
|
|
1292
1535
|
"Python-2.0"
|
|
1293
1536
|
]);
|
|
1294
|
-
console.log(
|
|
1537
|
+
console.log(chalk23.green("License Checker"));
|
|
1295
1538
|
return (await Promise.all(
|
|
1296
1539
|
workspaceList.map(({ location, name }) => {
|
|
1297
1540
|
return new Promise((resolve) => {
|
|
1298
1541
|
init({ production: true, start: location }, (error, packages) => {
|
|
1299
1542
|
if (error) {
|
|
1300
|
-
console.error(
|
|
1301
|
-
console.error(
|
|
1543
|
+
console.error(chalk23.red(`License Checker [${name}] Error`));
|
|
1544
|
+
console.error(chalk23.gray(error));
|
|
1302
1545
|
console.log("\n");
|
|
1303
1546
|
resolve(1);
|
|
1304
1547
|
} else {
|
|
1305
|
-
console.log(
|
|
1548
|
+
console.log(chalk23.green(`License Checker [${name}]`));
|
|
1306
1549
|
let count = 0;
|
|
1307
1550
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1308
1551
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1318,7 +1561,7 @@ var license = async (pkg) => {
|
|
|
1318
1561
|
}
|
|
1319
1562
|
if (!orLicenseFound) {
|
|
1320
1563
|
count++;
|
|
1321
|
-
console.warn(
|
|
1564
|
+
console.warn(chalk23.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1322
1565
|
}
|
|
1323
1566
|
}
|
|
1324
1567
|
}
|
|
@@ -1337,13 +1580,13 @@ var filename2 = ".npmignore";
|
|
|
1337
1580
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1338
1581
|
|
|
1339
1582
|
// src/actions/package/clean-outputs.ts
|
|
1340
|
-
import
|
|
1341
|
-
import
|
|
1583
|
+
import path7 from "path";
|
|
1584
|
+
import chalk24 from "chalk";
|
|
1342
1585
|
var packageCleanOutputs = () => {
|
|
1343
1586
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1344
1587
|
const pkgName = process.env.npm_package_name;
|
|
1345
|
-
const folders = [
|
|
1346
|
-
console.log(
|
|
1588
|
+
const folders = [path7.join(pkg, "dist"), path7.join(pkg, "build"), path7.join(pkg, "docs")];
|
|
1589
|
+
console.log(chalk24.green(`Cleaning Outputs [${pkgName}]`));
|
|
1347
1590
|
for (let folder of folders) {
|
|
1348
1591
|
deleteGlob(folder);
|
|
1349
1592
|
}
|
|
@@ -1351,13 +1594,13 @@ var packageCleanOutputs = () => {
|
|
|
1351
1594
|
};
|
|
1352
1595
|
|
|
1353
1596
|
// src/actions/package/clean-typescript.ts
|
|
1354
|
-
import
|
|
1355
|
-
import
|
|
1597
|
+
import path8 from "path";
|
|
1598
|
+
import chalk25 from "chalk";
|
|
1356
1599
|
var packageCleanTypescript = () => {
|
|
1357
1600
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1358
1601
|
const pkgName = process.env.npm_package_name;
|
|
1359
|
-
console.log(
|
|
1360
|
-
const files = [
|
|
1602
|
+
console.log(chalk25.green(`Cleaning Typescript [${pkgName}]`));
|
|
1603
|
+
const files = [path8.join(pkg, "*.tsbuildinfo"), path8.join(pkg, ".tsconfig.*"), path8.join(pkg, ".eslintcache")];
|
|
1361
1604
|
for (let file of files) {
|
|
1362
1605
|
deleteGlob(file);
|
|
1363
1606
|
}
|
|
@@ -1370,26 +1613,26 @@ var packageClean = async () => {
|
|
|
1370
1613
|
};
|
|
1371
1614
|
|
|
1372
1615
|
// src/actions/package/compile/compile.ts
|
|
1373
|
-
import
|
|
1616
|
+
import chalk30 from "chalk";
|
|
1374
1617
|
|
|
1375
1618
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1376
|
-
import
|
|
1619
|
+
import chalk29 from "chalk";
|
|
1377
1620
|
import { build as build2, defineConfig } from "tsup";
|
|
1378
1621
|
|
|
1379
1622
|
// src/actions/package/compile/inputs.ts
|
|
1380
|
-
import
|
|
1623
|
+
import chalk26 from "chalk";
|
|
1381
1624
|
import { glob as glob2 } from "glob";
|
|
1382
1625
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1383
1626
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1384
1627
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1385
1628
|
if (verbose) {
|
|
1386
|
-
console.log(
|
|
1629
|
+
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1387
1630
|
}
|
|
1388
1631
|
return result;
|
|
1389
1632
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1390
1633
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1391
1634
|
if (verbose) {
|
|
1392
|
-
console.log(
|
|
1635
|
+
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1393
1636
|
}
|
|
1394
1637
|
return result;
|
|
1395
1638
|
})];
|
|
@@ -1448,7 +1691,7 @@ function deepMergeObjects(objects) {
|
|
|
1448
1691
|
|
|
1449
1692
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1450
1693
|
import { cwd as cwd2 } from "process";
|
|
1451
|
-
import
|
|
1694
|
+
import chalk27 from "chalk";
|
|
1452
1695
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1453
1696
|
import ts2, {
|
|
1454
1697
|
DiagnosticCategory,
|
|
@@ -1470,7 +1713,7 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
1470
1713
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
1471
1714
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1472
1715
|
if (verbose) {
|
|
1473
|
-
console.log(
|
|
1716
|
+
console.log(chalk27.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1474
1717
|
}
|
|
1475
1718
|
const configFilePath = ts2.findConfigFile(
|
|
1476
1719
|
"./",
|
|
@@ -1493,10 +1736,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1493
1736
|
emitDeclarationOnly: true,
|
|
1494
1737
|
noEmit: false
|
|
1495
1738
|
};
|
|
1496
|
-
console.log(
|
|
1739
|
+
console.log(chalk27.cyan(`Validating Files: ${entries.length}`));
|
|
1497
1740
|
if (verbose) {
|
|
1498
1741
|
for (const entry of entries) {
|
|
1499
|
-
console.log(
|
|
1742
|
+
console.log(chalk27.grey(`Validating: ${entry}`));
|
|
1500
1743
|
}
|
|
1501
1744
|
}
|
|
1502
1745
|
try {
|
|
@@ -1526,22 +1769,22 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1526
1769
|
return 0;
|
|
1527
1770
|
} finally {
|
|
1528
1771
|
if (verbose) {
|
|
1529
|
-
console.log(
|
|
1772
|
+
console.log(chalk27.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1530
1773
|
}
|
|
1531
1774
|
}
|
|
1532
1775
|
};
|
|
1533
1776
|
|
|
1534
1777
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1535
|
-
import
|
|
1778
|
+
import path9 from "path";
|
|
1536
1779
|
import { cwd as cwd3 } from "process";
|
|
1537
|
-
import
|
|
1780
|
+
import chalk28 from "chalk";
|
|
1538
1781
|
import { rollup } from "rollup";
|
|
1539
1782
|
import dts from "rollup-plugin-dts";
|
|
1540
1783
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
1541
1784
|
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
1542
1785
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
1543
1786
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1544
|
-
const tsconfigPath =
|
|
1787
|
+
const tsconfigPath = path9.resolve(pkg, "tsconfig.json");
|
|
1545
1788
|
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
1546
1789
|
try {
|
|
1547
1790
|
const bundle = await rollup({
|
|
@@ -1559,8 +1802,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1559
1802
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
1560
1803
|
return;
|
|
1561
1804
|
}
|
|
1562
|
-
console.warn(
|
|
1563
|
-
console.warn(
|
|
1805
|
+
console.warn(chalk28.yellow(`[${warning.code}] ${warning.message}`));
|
|
1806
|
+
console.warn(chalk28.gray(inputPath));
|
|
1564
1807
|
warn(warning);
|
|
1565
1808
|
}
|
|
1566
1809
|
});
|
|
@@ -1570,8 +1813,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1570
1813
|
});
|
|
1571
1814
|
} catch (ex) {
|
|
1572
1815
|
const error = ex;
|
|
1573
|
-
console.warn(
|
|
1574
|
-
console.warn(
|
|
1816
|
+
console.warn(chalk28.red(error));
|
|
1817
|
+
console.warn(chalk28.gray(inputPath));
|
|
1575
1818
|
}
|
|
1576
1819
|
if (verbose) {
|
|
1577
1820
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -1579,7 +1822,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1579
1822
|
}
|
|
1580
1823
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
1581
1824
|
if (verbose) {
|
|
1582
|
-
console.log(
|
|
1825
|
+
console.log(chalk28.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1583
1826
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
1584
1827
|
}
|
|
1585
1828
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -1603,7 +1846,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
1603
1846
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
1604
1847
|
}));
|
|
1605
1848
|
if (verbose) {
|
|
1606
|
-
console.log(
|
|
1849
|
+
console.log(chalk28.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1607
1850
|
}
|
|
1608
1851
|
return 0;
|
|
1609
1852
|
};
|
|
@@ -1615,15 +1858,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1615
1858
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
1616
1859
|
}
|
|
1617
1860
|
if (entries.length === 0) {
|
|
1618
|
-
console.warn(
|
|
1861
|
+
console.warn(chalk29.yellow(`No entries found in ${srcDir} to compile`));
|
|
1619
1862
|
return 0;
|
|
1620
1863
|
}
|
|
1621
1864
|
if (verbose) {
|
|
1622
|
-
console.log(
|
|
1865
|
+
console.log(chalk29.gray(`buildDir [${buildDir}]`));
|
|
1623
1866
|
}
|
|
1624
1867
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
1625
1868
|
if (validationResult !== 0) {
|
|
1626
|
-
console.error(
|
|
1869
|
+
console.error(chalk29.red(`Compile:Validation had ${validationResult} errors`));
|
|
1627
1870
|
return validationResult;
|
|
1628
1871
|
}
|
|
1629
1872
|
const optionsParams = tsupOptions([{
|
|
@@ -1648,12 +1891,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1648
1891
|
})
|
|
1649
1892
|
)).flat();
|
|
1650
1893
|
if (verbose) {
|
|
1651
|
-
console.log(
|
|
1652
|
-
console.log(
|
|
1894
|
+
console.log(chalk29.cyan(`TSUP:build:start [${srcDir}]`));
|
|
1895
|
+
console.log(chalk29.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
1653
1896
|
}
|
|
1654
1897
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
1655
1898
|
if (verbose) {
|
|
1656
|
-
console.log(
|
|
1899
|
+
console.log(chalk29.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
1657
1900
|
}
|
|
1658
1901
|
if (bundleTypes) {
|
|
1659
1902
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -1764,14 +2007,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
1764
2007
|
// src/actions/package/compile/compile.ts
|
|
1765
2008
|
var packageCompile = async (inConfig = {}) => {
|
|
1766
2009
|
const pkg = process.env.INIT_CWD;
|
|
1767
|
-
console.log(
|
|
2010
|
+
console.log(chalk30.green(`Compiling ${pkg}`));
|
|
1768
2011
|
const config2 = await loadConfig(inConfig);
|
|
1769
2012
|
return await packageCompileTsup(config2);
|
|
1770
2013
|
};
|
|
1771
2014
|
|
|
1772
2015
|
// src/actions/package/copy-assets.ts
|
|
1773
|
-
import
|
|
1774
|
-
import
|
|
2016
|
+
import path10 from "path/posix";
|
|
2017
|
+
import chalk31 from "chalk";
|
|
1775
2018
|
import cpy2 from "cpy";
|
|
1776
2019
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1777
2020
|
try {
|
|
@@ -1779,12 +2022,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1779
2022
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1780
2023
|
`../dist/${target}`,
|
|
1781
2024
|
{
|
|
1782
|
-
cwd:
|
|
2025
|
+
cwd: path10.join(location, "src"),
|
|
1783
2026
|
flat: false
|
|
1784
2027
|
}
|
|
1785
2028
|
);
|
|
1786
2029
|
if (values.length > 0) {
|
|
1787
|
-
console.log(
|
|
2030
|
+
console.log(chalk31.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1788
2031
|
}
|
|
1789
2032
|
for (const value of values) {
|
|
1790
2033
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -1850,8 +2093,8 @@ var packageCycle = async () => {
|
|
|
1850
2093
|
|
|
1851
2094
|
// src/actions/package/gen-docs.ts
|
|
1852
2095
|
import { existsSync as existsSync5 } from "fs";
|
|
1853
|
-
import
|
|
1854
|
-
import
|
|
2096
|
+
import path11 from "path";
|
|
2097
|
+
import chalk32 from "chalk";
|
|
1855
2098
|
import {
|
|
1856
2099
|
Application,
|
|
1857
2100
|
ArgumentsReader,
|
|
@@ -1869,7 +2112,7 @@ var ExitCodes = {
|
|
|
1869
2112
|
};
|
|
1870
2113
|
var packageGenDocs = async () => {
|
|
1871
2114
|
const pkg = process.env.INIT_CWD;
|
|
1872
|
-
if (pkg !== void 0 && !existsSync5(
|
|
2115
|
+
if (pkg !== void 0 && !existsSync5(path11.join(pkg, "typedoc.json"))) {
|
|
1873
2116
|
return;
|
|
1874
2117
|
}
|
|
1875
2118
|
const app = await Application.bootstrap({
|
|
@@ -1955,16 +2198,16 @@ var runTypeDoc = async (app) => {
|
|
|
1955
2198
|
return ExitCodes.OutputError;
|
|
1956
2199
|
}
|
|
1957
2200
|
}
|
|
1958
|
-
console.log(
|
|
2201
|
+
console.log(chalk32.green(`${pkgName} - Ok`));
|
|
1959
2202
|
return ExitCodes.Ok;
|
|
1960
2203
|
};
|
|
1961
2204
|
|
|
1962
2205
|
// src/actions/package/lint.ts
|
|
1963
2206
|
import { readdirSync } from "fs";
|
|
1964
|
-
import
|
|
2207
|
+
import path12 from "path";
|
|
1965
2208
|
import { cwd as cwd4 } from "process";
|
|
1966
2209
|
import { pathToFileURL } from "url";
|
|
1967
|
-
import
|
|
2210
|
+
import chalk33 from "chalk";
|
|
1968
2211
|
import { ESLint } from "eslint";
|
|
1969
2212
|
import { findUp } from "find-up";
|
|
1970
2213
|
import picomatch from "picomatch";
|
|
@@ -1973,14 +2216,14 @@ var dumpMessages = (lintResults) => {
|
|
|
1973
2216
|
const severity = ["none", "warning", "error"];
|
|
1974
2217
|
for (const lintResult of lintResults) {
|
|
1975
2218
|
if (lintResult.messages.length > 0) {
|
|
1976
|
-
console.log(
|
|
2219
|
+
console.log(chalk33.gray(`
|
|
1977
2220
|
${lintResult.filePath}`));
|
|
1978
2221
|
for (const message of lintResult.messages) {
|
|
1979
2222
|
console.log(
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
2223
|
+
chalk33.gray(` ${message.line}:${message.column}`),
|
|
2224
|
+
chalk33[colors[message.severity]](` ${severity[message.severity]}`),
|
|
2225
|
+
chalk33.white(` ${message.message}`),
|
|
2226
|
+
chalk33.gray(` ${message.ruleId}`)
|
|
1984
2227
|
);
|
|
1985
2228
|
}
|
|
1986
2229
|
}
|
|
@@ -1998,7 +2241,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1998
2241
|
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
1999
2242
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2000
2243
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2001
|
-
const res =
|
|
2244
|
+
const res = path12.resolve(dir, dirent.name);
|
|
2002
2245
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2003
2246
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2004
2247
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2018,10 +2261,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2018
2261
|
cache
|
|
2019
2262
|
});
|
|
2020
2263
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
2021
|
-
console.log(
|
|
2264
|
+
console.log(chalk33.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2022
2265
|
if (verbose) {
|
|
2023
2266
|
for (const file of files) {
|
|
2024
|
-
console.log(
|
|
2267
|
+
console.log(chalk33.gray(` ${file}`));
|
|
2025
2268
|
}
|
|
2026
2269
|
}
|
|
2027
2270
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -2032,43 +2275,43 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2032
2275
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2033
2276
|
const lintTime = Date.now() - start;
|
|
2034
2277
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2035
|
-
console.log(
|
|
2278
|
+
console.log(chalk33.white(`Linted ${chalk33[filesCountColor](files.length)} files in ${chalk33[lintTimeColor](lintTime)}ms`));
|
|
2036
2279
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2037
2280
|
};
|
|
2038
2281
|
|
|
2039
2282
|
// src/actions/package/publint.ts
|
|
2040
|
-
import { promises as
|
|
2041
|
-
import
|
|
2283
|
+
import { promises as fs7 } from "fs";
|
|
2284
|
+
import chalk34 from "chalk";
|
|
2042
2285
|
import sortPackageJson from "sort-package-json";
|
|
2043
2286
|
var customPubLint = (pkg) => {
|
|
2044
2287
|
let errorCount = 0;
|
|
2045
2288
|
let warningCount = 0;
|
|
2046
2289
|
if (pkg.files === void 0) {
|
|
2047
|
-
console.warn(
|
|
2290
|
+
console.warn(chalk34.yellow('Publint [custom]: "files" field is missing'));
|
|
2048
2291
|
warningCount++;
|
|
2049
2292
|
}
|
|
2050
2293
|
if (pkg.main !== void 0) {
|
|
2051
|
-
console.warn(
|
|
2294
|
+
console.warn(chalk34.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
2052
2295
|
warningCount++;
|
|
2053
2296
|
}
|
|
2054
2297
|
if (pkg.sideEffects !== false) {
|
|
2055
|
-
console.warn(
|
|
2298
|
+
console.warn(chalk34.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
2056
2299
|
warningCount++;
|
|
2057
2300
|
}
|
|
2058
2301
|
if (pkg.resolutions !== void 0) {
|
|
2059
|
-
console.warn(
|
|
2060
|
-
console.warn(
|
|
2302
|
+
console.warn(chalk34.yellow('Publint [custom]: "resolutions" in use'));
|
|
2303
|
+
console.warn(chalk34.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
2061
2304
|
warningCount++;
|
|
2062
2305
|
}
|
|
2063
2306
|
return [errorCount, warningCount];
|
|
2064
2307
|
};
|
|
2065
2308
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2066
2309
|
const pkgDir = process.env.INIT_CWD;
|
|
2067
|
-
const sortedPkg = sortPackageJson(await
|
|
2068
|
-
await
|
|
2069
|
-
const pkg = JSON.parse(await
|
|
2070
|
-
console.log(
|
|
2071
|
-
console.log(
|
|
2310
|
+
const sortedPkg = sortPackageJson(await fs7.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2311
|
+
await fs7.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2312
|
+
const pkg = JSON.parse(await fs7.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2313
|
+
console.log(chalk34.green(`Publint: ${pkg.name}`));
|
|
2314
|
+
console.log(chalk34.gray(pkgDir));
|
|
2072
2315
|
const { publint: publint2 } = await import("publint");
|
|
2073
2316
|
const { messages } = await publint2({
|
|
2074
2317
|
level: "suggestion",
|
|
@@ -2079,22 +2322,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2079
2322
|
for (const message of messages) {
|
|
2080
2323
|
switch (message.type) {
|
|
2081
2324
|
case "error": {
|
|
2082
|
-
console.error(
|
|
2325
|
+
console.error(chalk34.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2083
2326
|
break;
|
|
2084
2327
|
}
|
|
2085
2328
|
case "warning": {
|
|
2086
|
-
console.warn(
|
|
2329
|
+
console.warn(chalk34.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2087
2330
|
break;
|
|
2088
2331
|
}
|
|
2089
2332
|
default: {
|
|
2090
|
-
console.log(
|
|
2333
|
+
console.log(chalk34.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2091
2334
|
break;
|
|
2092
2335
|
}
|
|
2093
2336
|
}
|
|
2094
2337
|
}
|
|
2095
2338
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
2096
2339
|
if (verbose) {
|
|
2097
|
-
console.log(
|
|
2340
|
+
console.log(chalk34.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
2098
2341
|
}
|
|
2099
2342
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
2100
2343
|
};
|
|
@@ -2130,7 +2373,7 @@ var rebuild = ({ target }) => {
|
|
|
2130
2373
|
};
|
|
2131
2374
|
|
|
2132
2375
|
// src/actions/recompile.ts
|
|
2133
|
-
import
|
|
2376
|
+
import chalk35 from "chalk";
|
|
2134
2377
|
var recompile = async ({
|
|
2135
2378
|
verbose,
|
|
2136
2379
|
target,
|
|
@@ -2166,7 +2409,7 @@ var recompileAll = async ({
|
|
|
2166
2409
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2167
2410
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2168
2411
|
if (jobs) {
|
|
2169
|
-
console.log(
|
|
2412
|
+
console.log(chalk35.blue(`Jobs set to [${jobs}]`));
|
|
2170
2413
|
}
|
|
2171
2414
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2172
2415
|
[
|
|
@@ -2197,7 +2440,7 @@ var recompileAll = async ({
|
|
|
2197
2440
|
]
|
|
2198
2441
|
]);
|
|
2199
2442
|
console.log(
|
|
2200
|
-
`${
|
|
2443
|
+
`${chalk35.gray("Recompiled in")} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`
|
|
2201
2444
|
);
|
|
2202
2445
|
return result;
|
|
2203
2446
|
};
|
|
@@ -2228,13 +2471,13 @@ var reinstall = () => {
|
|
|
2228
2471
|
};
|
|
2229
2472
|
|
|
2230
2473
|
// src/actions/relint.ts
|
|
2231
|
-
import
|
|
2474
|
+
import chalk36 from "chalk";
|
|
2232
2475
|
var relintPackage = ({
|
|
2233
2476
|
pkg,
|
|
2234
2477
|
fix: fix2,
|
|
2235
2478
|
verbose
|
|
2236
2479
|
}) => {
|
|
2237
|
-
console.log(
|
|
2480
|
+
console.log(chalk36.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2238
2481
|
const start = Date.now();
|
|
2239
2482
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2240
2483
|
["yarn", [
|
|
@@ -2244,7 +2487,7 @@ var relintPackage = ({
|
|
|
2244
2487
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2245
2488
|
]]
|
|
2246
2489
|
]);
|
|
2247
|
-
console.log(
|
|
2490
|
+
console.log(chalk36.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`));
|
|
2248
2491
|
return result;
|
|
2249
2492
|
};
|
|
2250
2493
|
var relint = ({
|
|
@@ -2264,13 +2507,13 @@ var relint = ({
|
|
|
2264
2507
|
});
|
|
2265
2508
|
};
|
|
2266
2509
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2267
|
-
console.log(
|
|
2510
|
+
console.log(chalk36.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2268
2511
|
const start = Date.now();
|
|
2269
2512
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2270
2513
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2271
2514
|
["yarn", ["eslint", ...fixOptions]]
|
|
2272
2515
|
]);
|
|
2273
|
-
console.log(
|
|
2516
|
+
console.log(chalk36.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`));
|
|
2274
2517
|
return result;
|
|
2275
2518
|
};
|
|
2276
2519
|
|
|
@@ -2288,10 +2531,10 @@ var sonar = () => {
|
|
|
2288
2531
|
};
|
|
2289
2532
|
|
|
2290
2533
|
// src/actions/statics.ts
|
|
2291
|
-
import
|
|
2534
|
+
import chalk37 from "chalk";
|
|
2292
2535
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2293
2536
|
var statics = () => {
|
|
2294
|
-
console.log(
|
|
2537
|
+
console.log(chalk37.green("Check Required Static Dependencies"));
|
|
2295
2538
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2296
2539
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2297
2540
|
};
|
|
@@ -2348,7 +2591,7 @@ var loadPackageConfig = async () => {
|
|
|
2348
2591
|
};
|
|
2349
2592
|
|
|
2350
2593
|
// src/xy/xy.ts
|
|
2351
|
-
import
|
|
2594
|
+
import chalk39 from "chalk";
|
|
2352
2595
|
|
|
2353
2596
|
// src/xy/xyBuildCommands.ts
|
|
2354
2597
|
var xyBuildCommands = (args) => {
|
|
@@ -2702,7 +2945,7 @@ var xyInstallCommands = (args) => {
|
|
|
2702
2945
|
};
|
|
2703
2946
|
|
|
2704
2947
|
// src/xy/xyLintCommands.ts
|
|
2705
|
-
import
|
|
2948
|
+
import chalk38 from "chalk";
|
|
2706
2949
|
var xyLintCommands = (args) => {
|
|
2707
2950
|
return args.command(
|
|
2708
2951
|
"cycle [package]",
|
|
@@ -2714,7 +2957,7 @@ var xyLintCommands = (args) => {
|
|
|
2714
2957
|
const start = Date.now();
|
|
2715
2958
|
if (argv.verbose) console.log("Cycle");
|
|
2716
2959
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
2717
|
-
console.log(
|
|
2960
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2718
2961
|
}
|
|
2719
2962
|
).command(
|
|
2720
2963
|
"lint [package]",
|
|
@@ -2744,7 +2987,7 @@ var xyLintCommands = (args) => {
|
|
|
2744
2987
|
cache: argv.cache,
|
|
2745
2988
|
verbose: !!argv.verbose
|
|
2746
2989
|
});
|
|
2747
|
-
console.log(
|
|
2990
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2748
2991
|
}
|
|
2749
2992
|
).command(
|
|
2750
2993
|
"deplint [package]",
|
|
@@ -2777,7 +3020,7 @@ var xyLintCommands = (args) => {
|
|
|
2777
3020
|
peerDeps: !!argv.peerDeps,
|
|
2778
3021
|
verbose: !!argv.verbose
|
|
2779
3022
|
});
|
|
2780
|
-
console.log(
|
|
3023
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2781
3024
|
}
|
|
2782
3025
|
).command(
|
|
2783
3026
|
"fix [package]",
|
|
@@ -2789,7 +3032,7 @@ var xyLintCommands = (args) => {
|
|
|
2789
3032
|
const start = Date.now();
|
|
2790
3033
|
if (argv.verbose) console.log("Fix");
|
|
2791
3034
|
process.exitCode = fix();
|
|
2792
|
-
console.log(
|
|
3035
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2793
3036
|
}
|
|
2794
3037
|
).command(
|
|
2795
3038
|
"relint [package]",
|
|
@@ -2801,7 +3044,7 @@ var xyLintCommands = (args) => {
|
|
|
2801
3044
|
if (argv.verbose) console.log("Relinting");
|
|
2802
3045
|
const start = Date.now();
|
|
2803
3046
|
process.exitCode = relint();
|
|
2804
|
-
console.log(
|
|
3047
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2805
3048
|
}
|
|
2806
3049
|
).command(
|
|
2807
3050
|
"publint [package]",
|
|
@@ -2813,7 +3056,7 @@ var xyLintCommands = (args) => {
|
|
|
2813
3056
|
if (argv.verbose) console.log("Publint");
|
|
2814
3057
|
const start = Date.now();
|
|
2815
3058
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
2816
|
-
console.log(
|
|
3059
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2817
3060
|
}
|
|
2818
3061
|
).command(
|
|
2819
3062
|
"knip",
|
|
@@ -2825,7 +3068,7 @@ var xyLintCommands = (args) => {
|
|
|
2825
3068
|
if (argv.verbose) console.log("Knip");
|
|
2826
3069
|
const start = Date.now();
|
|
2827
3070
|
process.exitCode = knip();
|
|
2828
|
-
console.log(
|
|
3071
|
+
console.log(chalk38.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
2829
3072
|
}
|
|
2830
3073
|
).command(
|
|
2831
3074
|
"sonar",
|
|
@@ -2837,7 +3080,7 @@ var xyLintCommands = (args) => {
|
|
|
2837
3080
|
const start = Date.now();
|
|
2838
3081
|
if (argv.verbose) console.log("Sonar Check");
|
|
2839
3082
|
process.exitCode = sonar();
|
|
2840
|
-
console.log(
|
|
3083
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2841
3084
|
}
|
|
2842
3085
|
);
|
|
2843
3086
|
};
|
|
@@ -2873,8 +3116,8 @@ var xyParseOptions = () => {
|
|
|
2873
3116
|
var xy = async () => {
|
|
2874
3117
|
const options = xyParseOptions();
|
|
2875
3118
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
2876
|
-
console.error(
|
|
2877
|
-
console.log(
|
|
3119
|
+
console.error(chalk39.yellow(`Command not found [${chalk39.magenta(process.argv[2])}]`));
|
|
3120
|
+
console.log(chalk39.gray("Try 'yarn xy --help' for list of commands"));
|
|
2878
3121
|
}).version().help().argv;
|
|
2879
3122
|
};
|
|
2880
3123
|
export {
|