@xylabs/ts-scripts-yarn3 7.3.2 → 7.4.1
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 +316 -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 +213 -0
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/index.mjs +316 -35
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +319 -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 +75 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/index.mjs +319 -38
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +423 -142
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +366 -85
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +435 -154
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +366 -85
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +366 -85
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +339 -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,243 @@ 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
|
+
import fs7 from "fs";
|
|
1070
|
+
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1071
|
+
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1072
|
+
var hasTypescriptFiles = ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], tsExtensions);
|
|
1073
|
+
var decoratorPattern = /^\s*@[A-Z]\w*/m;
|
|
1074
|
+
var hasDecorators = ({ srcFiles }) => srcFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1075
|
+
try {
|
|
1076
|
+
const content = fs7.readFileSync(file, "utf8");
|
|
1077
|
+
return decoratorPattern.test(content);
|
|
1078
|
+
} catch {
|
|
1079
|
+
return false;
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
|
|
1083
|
+
function hasImportPlugin({ location, allDependencies }) {
|
|
1084
|
+
if (allDependencies.some((d) => importPlugins.has(d))) return true;
|
|
1085
|
+
for (const dep of allDependencies) {
|
|
1086
|
+
const pkgPath = findDepPackageJson(location, dep);
|
|
1087
|
+
if (!pkgPath) continue;
|
|
1088
|
+
try {
|
|
1089
|
+
const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf8"));
|
|
1090
|
+
const transitiveDeps = [
|
|
1091
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
1092
|
+
...Object.keys(pkg.peerDependencies ?? {})
|
|
1093
|
+
];
|
|
1094
|
+
if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
|
|
1095
|
+
} catch {
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1100
|
+
var rules = [
|
|
1101
|
+
{
|
|
1102
|
+
package: "typescript",
|
|
1103
|
+
isNeeded: hasTypescriptFiles
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
package: "eslint-import-resolver-typescript",
|
|
1107
|
+
isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
package: "tslib",
|
|
1111
|
+
isNeeded: hasDecorators
|
|
1112
|
+
}
|
|
1113
|
+
];
|
|
1114
|
+
function getImplicitDevDependencies(context) {
|
|
1115
|
+
const implicit = /* @__PURE__ */ new Set();
|
|
1116
|
+
for (const rule of rules) {
|
|
1117
|
+
if (rule.isNeeded(context)) {
|
|
1118
|
+
implicit.add(rule.package);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return implicit;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1125
|
+
var allExternalImports = ({
|
|
1126
|
+
externalSrcImports,
|
|
1127
|
+
externalDistImports,
|
|
1128
|
+
externalDistTypeImports,
|
|
1129
|
+
externalConfigImports
|
|
1130
|
+
}) => {
|
|
1131
|
+
const all = /* @__PURE__ */ new Set([
|
|
1132
|
+
...externalSrcImports,
|
|
1133
|
+
...externalDistImports,
|
|
1134
|
+
...externalDistTypeImports,
|
|
1135
|
+
...externalConfigImports
|
|
1136
|
+
]);
|
|
1137
|
+
return all;
|
|
1138
|
+
};
|
|
1139
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1140
|
+
if (implicitDeps.has(dep)) return true;
|
|
1141
|
+
if (requiredPeers.has(dep)) return true;
|
|
1142
|
+
if (scriptRefs.has(dep)) return true;
|
|
1143
|
+
if (dep.startsWith("@types/")) {
|
|
1144
|
+
const baseName = dep.replace(/^@types\//, "");
|
|
1145
|
+
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
1146
|
+
}
|
|
1147
|
+
return allImports.has(dep);
|
|
1148
|
+
}
|
|
1149
|
+
function getUnusedDevDependencies({ name, location }, {
|
|
1150
|
+
devDependencies,
|
|
1151
|
+
dependencies,
|
|
1152
|
+
peerDependencies
|
|
1153
|
+
}, sourceParams, fileContext) {
|
|
1154
|
+
const allImports = allExternalImports(sourceParams);
|
|
1155
|
+
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1156
|
+
const implicitDeps = getImplicitDevDependencies({
|
|
1157
|
+
...fileContext,
|
|
1158
|
+
allDependencies: allDeps,
|
|
1159
|
+
location
|
|
1160
|
+
});
|
|
1161
|
+
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1162
|
+
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1163
|
+
let unusedDevDependencies = 0;
|
|
1164
|
+
for (const dep of devDependencies) {
|
|
1165
|
+
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1166
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1167
|
+
unusedDevDependencies++;
|
|
1168
|
+
console.log(`[${chalk16.blue(name)}] Unused devDependency in package.json: ${chalk16.red(dep)}`);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
if (unusedDevDependencies > 0) {
|
|
1172
|
+
const packageLocation = `${location}/package.json`;
|
|
1173
|
+
console.log(` ${chalk16.yellow(packageLocation)}
|
|
1174
|
+
`);
|
|
1175
|
+
}
|
|
1176
|
+
return unusedDevDependencies;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1180
|
+
import chalk17 from "chalk";
|
|
925
1181
|
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
926
1182
|
let unusedDependencies = 0;
|
|
927
1183
|
for (const dep of peerDependencies) {
|
|
928
1184
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
929
1185
|
unusedDependencies++;
|
|
930
1186
|
if (dependencies.includes(dep)) {
|
|
931
|
-
console.log(`[${
|
|
1187
|
+
console.log(`[${chalk17.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk17.red(dep)}`);
|
|
932
1188
|
} else {
|
|
933
|
-
console.log(`[${
|
|
1189
|
+
console.log(`[${chalk17.blue(name)}] Unused peerDependency in package.json: ${chalk17.red(dep)}`);
|
|
934
1190
|
}
|
|
935
1191
|
}
|
|
936
1192
|
}
|
|
937
1193
|
if (unusedDependencies > 0) {
|
|
938
1194
|
const packageLocation = `${location}/package.json`;
|
|
939
|
-
console.log(` ${
|
|
1195
|
+
console.log(` ${chalk17.yellow(packageLocation)}
|
|
940
1196
|
`);
|
|
941
1197
|
}
|
|
942
1198
|
return unusedDependencies;
|
|
943
1199
|
}
|
|
944
1200
|
|
|
945
1201
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
1202
|
+
function logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends) {
|
|
1203
|
+
console.info(`Checking package: ${name} at ${location}`);
|
|
1204
|
+
console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}, Config files: ${configFiles.length}`);
|
|
1205
|
+
for (const file of srcFiles) {
|
|
1206
|
+
console.info(`Source file: ${file}`);
|
|
1207
|
+
}
|
|
1208
|
+
for (const file of distFiles) {
|
|
1209
|
+
console.info(`Distribution file: ${file}`);
|
|
1210
|
+
}
|
|
1211
|
+
for (const file of configFiles) {
|
|
1212
|
+
console.info(`Config file: ${file}`);
|
|
1213
|
+
}
|
|
1214
|
+
for (const ext of tsconfigExtends) {
|
|
1215
|
+
console.info(`Tsconfig extends: ${ext}`);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
946
1218
|
function checkPackage({
|
|
947
1219
|
name,
|
|
948
1220
|
location,
|
|
@@ -951,27 +1223,36 @@ function checkPackage({
|
|
|
951
1223
|
peerDeps = false,
|
|
952
1224
|
verbose = false
|
|
953
1225
|
}) {
|
|
954
|
-
const {
|
|
1226
|
+
const {
|
|
1227
|
+
srcFiles,
|
|
1228
|
+
distFiles,
|
|
1229
|
+
configFiles
|
|
1230
|
+
} = findFiles(location);
|
|
1231
|
+
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
955
1232
|
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
|
-
}
|
|
1233
|
+
logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends);
|
|
964
1234
|
}
|
|
965
1235
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
966
1236
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
967
1237
|
const checkPeerDeps = peerDeps;
|
|
968
|
-
const sourceParams = getExternalImportsFromFiles({
|
|
1238
|
+
const sourceParams = getExternalImportsFromFiles({
|
|
1239
|
+
srcFiles,
|
|
1240
|
+
distFiles,
|
|
1241
|
+
configFiles,
|
|
1242
|
+
tsconfigExtends
|
|
1243
|
+
});
|
|
969
1244
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
970
1245
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
971
1246
|
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
972
1247
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1248
|
+
const fileContext = {
|
|
1249
|
+
configFiles,
|
|
1250
|
+
distFiles,
|
|
1251
|
+
srcFiles
|
|
1252
|
+
};
|
|
1253
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
973
1254
|
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
974
|
-
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies;
|
|
1255
|
+
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
975
1256
|
return totalErrors;
|
|
976
1257
|
}
|
|
977
1258
|
|
|
@@ -1009,9 +1290,9 @@ var deplint = ({
|
|
|
1009
1290
|
});
|
|
1010
1291
|
}
|
|
1011
1292
|
if (totalErrors > 0) {
|
|
1012
|
-
console.warn(`Deplint: Found ${
|
|
1293
|
+
console.warn(`Deplint: Found ${chalk18.red(totalErrors)} dependency problems. ${chalk18.red("\u2716")}`);
|
|
1013
1294
|
} else {
|
|
1014
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1295
|
+
console.info(`Deplint: Found no dependency problems. ${chalk18.green("\u2714")}`);
|
|
1015
1296
|
}
|
|
1016
1297
|
return 0;
|
|
1017
1298
|
};
|
|
@@ -1113,22 +1394,22 @@ var deployNext = () => {
|
|
|
1113
1394
|
};
|
|
1114
1395
|
|
|
1115
1396
|
// src/actions/dupdeps.ts
|
|
1116
|
-
import
|
|
1397
|
+
import chalk19 from "chalk";
|
|
1117
1398
|
var dupdeps = () => {
|
|
1118
|
-
console.log(
|
|
1399
|
+
console.log(chalk19.green("Checking all Dependencies for Duplicates"));
|
|
1119
1400
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1120
1401
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1121
1402
|
return detectDuplicateDependencies(dependencies);
|
|
1122
1403
|
};
|
|
1123
1404
|
|
|
1124
1405
|
// src/actions/lint.ts
|
|
1125
|
-
import
|
|
1406
|
+
import chalk20 from "chalk";
|
|
1126
1407
|
var lintPackage = ({
|
|
1127
1408
|
pkg,
|
|
1128
1409
|
fix: fix2,
|
|
1129
1410
|
verbose
|
|
1130
1411
|
}) => {
|
|
1131
|
-
console.log(
|
|
1412
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1132
1413
|
const start = Date.now();
|
|
1133
1414
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1134
1415
|
["yarn", [
|
|
@@ -1138,7 +1419,7 @@ var lintPackage = ({
|
|
|
1138
1419
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1139
1420
|
]]
|
|
1140
1421
|
]);
|
|
1141
|
-
console.log(
|
|
1422
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
1142
1423
|
return result;
|
|
1143
1424
|
};
|
|
1144
1425
|
var lint = ({
|
|
@@ -1158,13 +1439,13 @@ var lint = ({
|
|
|
1158
1439
|
});
|
|
1159
1440
|
};
|
|
1160
1441
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1161
|
-
console.log(
|
|
1442
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1162
1443
|
const start = Date.now();
|
|
1163
1444
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1164
1445
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1165
1446
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1166
1447
|
]);
|
|
1167
|
-
console.log(
|
|
1448
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
1168
1449
|
return result;
|
|
1169
1450
|
};
|
|
1170
1451
|
|
|
@@ -1192,7 +1473,7 @@ var filename = ".gitignore";
|
|
|
1192
1473
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1193
1474
|
|
|
1194
1475
|
// src/actions/gitlint.ts
|
|
1195
|
-
import
|
|
1476
|
+
import chalk21 from "chalk";
|
|
1196
1477
|
import ParseGitConfig from "parse-git-config";
|
|
1197
1478
|
var gitlint = () => {
|
|
1198
1479
|
console.log(`
|
|
@@ -1203,7 +1484,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1203
1484
|
const errors = 0;
|
|
1204
1485
|
const gitConfig = ParseGitConfig.sync();
|
|
1205
1486
|
const warn = (message) => {
|
|
1206
|
-
console.warn(
|
|
1487
|
+
console.warn(chalk21.yellow(`Warning: ${message}`));
|
|
1207
1488
|
warnings++;
|
|
1208
1489
|
};
|
|
1209
1490
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1223,13 +1504,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1223
1504
|
}
|
|
1224
1505
|
const resultMessages = [];
|
|
1225
1506
|
if (valid > 0) {
|
|
1226
|
-
resultMessages.push(
|
|
1507
|
+
resultMessages.push(chalk21.green(`Passed: ${valid}`));
|
|
1227
1508
|
}
|
|
1228
1509
|
if (warnings > 0) {
|
|
1229
|
-
resultMessages.push(
|
|
1510
|
+
resultMessages.push(chalk21.yellow(`Warnings: ${warnings}`));
|
|
1230
1511
|
}
|
|
1231
1512
|
if (errors > 0) {
|
|
1232
|
-
resultMessages.push(
|
|
1513
|
+
resultMessages.push(chalk21.red(` Errors: ${errors}`));
|
|
1233
1514
|
}
|
|
1234
1515
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1235
1516
|
`);
|
|
@@ -1238,7 +1519,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1238
1519
|
|
|
1239
1520
|
// src/actions/gitlint-fix.ts
|
|
1240
1521
|
import { execSync as execSync2 } from "child_process";
|
|
1241
|
-
import
|
|
1522
|
+
import chalk22 from "chalk";
|
|
1242
1523
|
import ParseGitConfig2 from "parse-git-config";
|
|
1243
1524
|
var gitlintFix = () => {
|
|
1244
1525
|
console.log(`
|
|
@@ -1247,15 +1528,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1247
1528
|
const gitConfig = ParseGitConfig2.sync();
|
|
1248
1529
|
if (gitConfig.core.ignorecase) {
|
|
1249
1530
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1250
|
-
console.warn(
|
|
1531
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1251
1532
|
}
|
|
1252
1533
|
if (gitConfig.core.autocrlf !== false) {
|
|
1253
1534
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1254
|
-
console.warn(
|
|
1535
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1255
1536
|
}
|
|
1256
1537
|
if (gitConfig.core.eol !== "lf") {
|
|
1257
1538
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1258
|
-
console.warn(
|
|
1539
|
+
console.warn(chalk22.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1259
1540
|
}
|
|
1260
1541
|
return 1;
|
|
1261
1542
|
};
|
|
@@ -1266,7 +1547,7 @@ var knip = () => {
|
|
|
1266
1547
|
};
|
|
1267
1548
|
|
|
1268
1549
|
// src/actions/license.ts
|
|
1269
|
-
import
|
|
1550
|
+
import chalk23 from "chalk";
|
|
1270
1551
|
import { init } from "license-checker";
|
|
1271
1552
|
var license = async (pkg) => {
|
|
1272
1553
|
const workspaces = yarnWorkspaces();
|
|
@@ -1291,18 +1572,18 @@ var license = async (pkg) => {
|
|
|
1291
1572
|
"LGPL-3.0-or-later",
|
|
1292
1573
|
"Python-2.0"
|
|
1293
1574
|
]);
|
|
1294
|
-
console.log(
|
|
1575
|
+
console.log(chalk23.green("License Checker"));
|
|
1295
1576
|
return (await Promise.all(
|
|
1296
1577
|
workspaceList.map(({ location, name }) => {
|
|
1297
1578
|
return new Promise((resolve) => {
|
|
1298
1579
|
init({ production: true, start: location }, (error, packages) => {
|
|
1299
1580
|
if (error) {
|
|
1300
|
-
console.error(
|
|
1301
|
-
console.error(
|
|
1581
|
+
console.error(chalk23.red(`License Checker [${name}] Error`));
|
|
1582
|
+
console.error(chalk23.gray(error));
|
|
1302
1583
|
console.log("\n");
|
|
1303
1584
|
resolve(1);
|
|
1304
1585
|
} else {
|
|
1305
|
-
console.log(
|
|
1586
|
+
console.log(chalk23.green(`License Checker [${name}]`));
|
|
1306
1587
|
let count = 0;
|
|
1307
1588
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1308
1589
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1318,7 +1599,7 @@ var license = async (pkg) => {
|
|
|
1318
1599
|
}
|
|
1319
1600
|
if (!orLicenseFound) {
|
|
1320
1601
|
count++;
|
|
1321
|
-
console.warn(
|
|
1602
|
+
console.warn(chalk23.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1322
1603
|
}
|
|
1323
1604
|
}
|
|
1324
1605
|
}
|
|
@@ -1337,13 +1618,13 @@ var filename2 = ".npmignore";
|
|
|
1337
1618
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1338
1619
|
|
|
1339
1620
|
// src/actions/package/clean-outputs.ts
|
|
1340
|
-
import
|
|
1341
|
-
import
|
|
1621
|
+
import path7 from "path";
|
|
1622
|
+
import chalk24 from "chalk";
|
|
1342
1623
|
var packageCleanOutputs = () => {
|
|
1343
1624
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1344
1625
|
const pkgName = process.env.npm_package_name;
|
|
1345
|
-
const folders = [
|
|
1346
|
-
console.log(
|
|
1626
|
+
const folders = [path7.join(pkg, "dist"), path7.join(pkg, "build"), path7.join(pkg, "docs")];
|
|
1627
|
+
console.log(chalk24.green(`Cleaning Outputs [${pkgName}]`));
|
|
1347
1628
|
for (let folder of folders) {
|
|
1348
1629
|
deleteGlob(folder);
|
|
1349
1630
|
}
|
|
@@ -1351,13 +1632,13 @@ var packageCleanOutputs = () => {
|
|
|
1351
1632
|
};
|
|
1352
1633
|
|
|
1353
1634
|
// src/actions/package/clean-typescript.ts
|
|
1354
|
-
import
|
|
1355
|
-
import
|
|
1635
|
+
import path8 from "path";
|
|
1636
|
+
import chalk25 from "chalk";
|
|
1356
1637
|
var packageCleanTypescript = () => {
|
|
1357
1638
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1358
1639
|
const pkgName = process.env.npm_package_name;
|
|
1359
|
-
console.log(
|
|
1360
|
-
const files = [
|
|
1640
|
+
console.log(chalk25.green(`Cleaning Typescript [${pkgName}]`));
|
|
1641
|
+
const files = [path8.join(pkg, "*.tsbuildinfo"), path8.join(pkg, ".tsconfig.*"), path8.join(pkg, ".eslintcache")];
|
|
1361
1642
|
for (let file of files) {
|
|
1362
1643
|
deleteGlob(file);
|
|
1363
1644
|
}
|
|
@@ -1370,26 +1651,26 @@ var packageClean = async () => {
|
|
|
1370
1651
|
};
|
|
1371
1652
|
|
|
1372
1653
|
// src/actions/package/compile/compile.ts
|
|
1373
|
-
import
|
|
1654
|
+
import chalk30 from "chalk";
|
|
1374
1655
|
|
|
1375
1656
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1376
|
-
import
|
|
1657
|
+
import chalk29 from "chalk";
|
|
1377
1658
|
import { build as build2, defineConfig } from "tsup";
|
|
1378
1659
|
|
|
1379
1660
|
// src/actions/package/compile/inputs.ts
|
|
1380
|
-
import
|
|
1661
|
+
import chalk26 from "chalk";
|
|
1381
1662
|
import { glob as glob2 } from "glob";
|
|
1382
1663
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1383
1664
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1384
1665
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1385
1666
|
if (verbose) {
|
|
1386
|
-
console.log(
|
|
1667
|
+
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1387
1668
|
}
|
|
1388
1669
|
return result;
|
|
1389
1670
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1390
1671
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1391
1672
|
if (verbose) {
|
|
1392
|
-
console.log(
|
|
1673
|
+
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1393
1674
|
}
|
|
1394
1675
|
return result;
|
|
1395
1676
|
})];
|
|
@@ -1448,7 +1729,7 @@ function deepMergeObjects(objects) {
|
|
|
1448
1729
|
|
|
1449
1730
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1450
1731
|
import { cwd as cwd2 } from "process";
|
|
1451
|
-
import
|
|
1732
|
+
import chalk27 from "chalk";
|
|
1452
1733
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1453
1734
|
import ts2, {
|
|
1454
1735
|
DiagnosticCategory,
|
|
@@ -1470,7 +1751,7 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
1470
1751
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
1471
1752
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1472
1753
|
if (verbose) {
|
|
1473
|
-
console.log(
|
|
1754
|
+
console.log(chalk27.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1474
1755
|
}
|
|
1475
1756
|
const configFilePath = ts2.findConfigFile(
|
|
1476
1757
|
"./",
|
|
@@ -1493,10 +1774,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1493
1774
|
emitDeclarationOnly: true,
|
|
1494
1775
|
noEmit: false
|
|
1495
1776
|
};
|
|
1496
|
-
console.log(
|
|
1777
|
+
console.log(chalk27.cyan(`Validating Files: ${entries.length}`));
|
|
1497
1778
|
if (verbose) {
|
|
1498
1779
|
for (const entry of entries) {
|
|
1499
|
-
console.log(
|
|
1780
|
+
console.log(chalk27.grey(`Validating: ${entry}`));
|
|
1500
1781
|
}
|
|
1501
1782
|
}
|
|
1502
1783
|
try {
|
|
@@ -1526,22 +1807,22 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1526
1807
|
return 0;
|
|
1527
1808
|
} finally {
|
|
1528
1809
|
if (verbose) {
|
|
1529
|
-
console.log(
|
|
1810
|
+
console.log(chalk27.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1530
1811
|
}
|
|
1531
1812
|
}
|
|
1532
1813
|
};
|
|
1533
1814
|
|
|
1534
1815
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1535
|
-
import
|
|
1816
|
+
import path9 from "path";
|
|
1536
1817
|
import { cwd as cwd3 } from "process";
|
|
1537
|
-
import
|
|
1818
|
+
import chalk28 from "chalk";
|
|
1538
1819
|
import { rollup } from "rollup";
|
|
1539
1820
|
import dts from "rollup-plugin-dts";
|
|
1540
1821
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
1541
1822
|
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
1542
1823
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
1543
1824
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1544
|
-
const tsconfigPath =
|
|
1825
|
+
const tsconfigPath = path9.resolve(pkg, "tsconfig.json");
|
|
1545
1826
|
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
1546
1827
|
try {
|
|
1547
1828
|
const bundle = await rollup({
|
|
@@ -1559,8 +1840,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1559
1840
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
1560
1841
|
return;
|
|
1561
1842
|
}
|
|
1562
|
-
console.warn(
|
|
1563
|
-
console.warn(
|
|
1843
|
+
console.warn(chalk28.yellow(`[${warning.code}] ${warning.message}`));
|
|
1844
|
+
console.warn(chalk28.gray(inputPath));
|
|
1564
1845
|
warn(warning);
|
|
1565
1846
|
}
|
|
1566
1847
|
});
|
|
@@ -1570,8 +1851,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1570
1851
|
});
|
|
1571
1852
|
} catch (ex) {
|
|
1572
1853
|
const error = ex;
|
|
1573
|
-
console.warn(
|
|
1574
|
-
console.warn(
|
|
1854
|
+
console.warn(chalk28.red(error));
|
|
1855
|
+
console.warn(chalk28.gray(inputPath));
|
|
1575
1856
|
}
|
|
1576
1857
|
if (verbose) {
|
|
1577
1858
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -1579,7 +1860,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1579
1860
|
}
|
|
1580
1861
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
1581
1862
|
if (verbose) {
|
|
1582
|
-
console.log(
|
|
1863
|
+
console.log(chalk28.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1583
1864
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
1584
1865
|
}
|
|
1585
1866
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -1603,7 +1884,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
1603
1884
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
1604
1885
|
}));
|
|
1605
1886
|
if (verbose) {
|
|
1606
|
-
console.log(
|
|
1887
|
+
console.log(chalk28.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1607
1888
|
}
|
|
1608
1889
|
return 0;
|
|
1609
1890
|
};
|
|
@@ -1615,15 +1896,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1615
1896
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
1616
1897
|
}
|
|
1617
1898
|
if (entries.length === 0) {
|
|
1618
|
-
console.warn(
|
|
1899
|
+
console.warn(chalk29.yellow(`No entries found in ${srcDir} to compile`));
|
|
1619
1900
|
return 0;
|
|
1620
1901
|
}
|
|
1621
1902
|
if (verbose) {
|
|
1622
|
-
console.log(
|
|
1903
|
+
console.log(chalk29.gray(`buildDir [${buildDir}]`));
|
|
1623
1904
|
}
|
|
1624
1905
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
1625
1906
|
if (validationResult !== 0) {
|
|
1626
|
-
console.error(
|
|
1907
|
+
console.error(chalk29.red(`Compile:Validation had ${validationResult} errors`));
|
|
1627
1908
|
return validationResult;
|
|
1628
1909
|
}
|
|
1629
1910
|
const optionsParams = tsupOptions([{
|
|
@@ -1648,12 +1929,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1648
1929
|
})
|
|
1649
1930
|
)).flat();
|
|
1650
1931
|
if (verbose) {
|
|
1651
|
-
console.log(
|
|
1652
|
-
console.log(
|
|
1932
|
+
console.log(chalk29.cyan(`TSUP:build:start [${srcDir}]`));
|
|
1933
|
+
console.log(chalk29.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
1653
1934
|
}
|
|
1654
1935
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
1655
1936
|
if (verbose) {
|
|
1656
|
-
console.log(
|
|
1937
|
+
console.log(chalk29.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
1657
1938
|
}
|
|
1658
1939
|
if (bundleTypes) {
|
|
1659
1940
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -1764,14 +2045,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
1764
2045
|
// src/actions/package/compile/compile.ts
|
|
1765
2046
|
var packageCompile = async (inConfig = {}) => {
|
|
1766
2047
|
const pkg = process.env.INIT_CWD;
|
|
1767
|
-
console.log(
|
|
2048
|
+
console.log(chalk30.green(`Compiling ${pkg}`));
|
|
1768
2049
|
const config2 = await loadConfig(inConfig);
|
|
1769
2050
|
return await packageCompileTsup(config2);
|
|
1770
2051
|
};
|
|
1771
2052
|
|
|
1772
2053
|
// src/actions/package/copy-assets.ts
|
|
1773
|
-
import
|
|
1774
|
-
import
|
|
2054
|
+
import path10 from "path/posix";
|
|
2055
|
+
import chalk31 from "chalk";
|
|
1775
2056
|
import cpy2 from "cpy";
|
|
1776
2057
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1777
2058
|
try {
|
|
@@ -1779,12 +2060,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1779
2060
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1780
2061
|
`../dist/${target}`,
|
|
1781
2062
|
{
|
|
1782
|
-
cwd:
|
|
2063
|
+
cwd: path10.join(location, "src"),
|
|
1783
2064
|
flat: false
|
|
1784
2065
|
}
|
|
1785
2066
|
);
|
|
1786
2067
|
if (values.length > 0) {
|
|
1787
|
-
console.log(
|
|
2068
|
+
console.log(chalk31.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1788
2069
|
}
|
|
1789
2070
|
for (const value of values) {
|
|
1790
2071
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -1850,8 +2131,8 @@ var packageCycle = async () => {
|
|
|
1850
2131
|
|
|
1851
2132
|
// src/actions/package/gen-docs.ts
|
|
1852
2133
|
import { existsSync as existsSync5 } from "fs";
|
|
1853
|
-
import
|
|
1854
|
-
import
|
|
2134
|
+
import path11 from "path";
|
|
2135
|
+
import chalk32 from "chalk";
|
|
1855
2136
|
import {
|
|
1856
2137
|
Application,
|
|
1857
2138
|
ArgumentsReader,
|
|
@@ -1869,7 +2150,7 @@ var ExitCodes = {
|
|
|
1869
2150
|
};
|
|
1870
2151
|
var packageGenDocs = async () => {
|
|
1871
2152
|
const pkg = process.env.INIT_CWD;
|
|
1872
|
-
if (pkg !== void 0 && !existsSync5(
|
|
2153
|
+
if (pkg !== void 0 && !existsSync5(path11.join(pkg, "typedoc.json"))) {
|
|
1873
2154
|
return;
|
|
1874
2155
|
}
|
|
1875
2156
|
const app = await Application.bootstrap({
|
|
@@ -1955,16 +2236,16 @@ var runTypeDoc = async (app) => {
|
|
|
1955
2236
|
return ExitCodes.OutputError;
|
|
1956
2237
|
}
|
|
1957
2238
|
}
|
|
1958
|
-
console.log(
|
|
2239
|
+
console.log(chalk32.green(`${pkgName} - Ok`));
|
|
1959
2240
|
return ExitCodes.Ok;
|
|
1960
2241
|
};
|
|
1961
2242
|
|
|
1962
2243
|
// src/actions/package/lint.ts
|
|
1963
2244
|
import { readdirSync } from "fs";
|
|
1964
|
-
import
|
|
2245
|
+
import path12 from "path";
|
|
1965
2246
|
import { cwd as cwd4 } from "process";
|
|
1966
2247
|
import { pathToFileURL } from "url";
|
|
1967
|
-
import
|
|
2248
|
+
import chalk33 from "chalk";
|
|
1968
2249
|
import { ESLint } from "eslint";
|
|
1969
2250
|
import { findUp } from "find-up";
|
|
1970
2251
|
import picomatch from "picomatch";
|
|
@@ -1973,14 +2254,14 @@ var dumpMessages = (lintResults) => {
|
|
|
1973
2254
|
const severity = ["none", "warning", "error"];
|
|
1974
2255
|
for (const lintResult of lintResults) {
|
|
1975
2256
|
if (lintResult.messages.length > 0) {
|
|
1976
|
-
console.log(
|
|
2257
|
+
console.log(chalk33.gray(`
|
|
1977
2258
|
${lintResult.filePath}`));
|
|
1978
2259
|
for (const message of lintResult.messages) {
|
|
1979
2260
|
console.log(
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
2261
|
+
chalk33.gray(` ${message.line}:${message.column}`),
|
|
2262
|
+
chalk33[colors[message.severity]](` ${severity[message.severity]}`),
|
|
2263
|
+
chalk33.white(` ${message.message}`),
|
|
2264
|
+
chalk33.gray(` ${message.ruleId}`)
|
|
1984
2265
|
);
|
|
1985
2266
|
}
|
|
1986
2267
|
}
|
|
@@ -1998,7 +2279,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1998
2279
|
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
1999
2280
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2000
2281
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2001
|
-
const res =
|
|
2282
|
+
const res = path12.resolve(dir, dirent.name);
|
|
2002
2283
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2003
2284
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2004
2285
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2018,10 +2299,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2018
2299
|
cache
|
|
2019
2300
|
});
|
|
2020
2301
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
2021
|
-
console.log(
|
|
2302
|
+
console.log(chalk33.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2022
2303
|
if (verbose) {
|
|
2023
2304
|
for (const file of files) {
|
|
2024
|
-
console.log(
|
|
2305
|
+
console.log(chalk33.gray(` ${file}`));
|
|
2025
2306
|
}
|
|
2026
2307
|
}
|
|
2027
2308
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -2032,43 +2313,43 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2032
2313
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2033
2314
|
const lintTime = Date.now() - start;
|
|
2034
2315
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2035
|
-
console.log(
|
|
2316
|
+
console.log(chalk33.white(`Linted ${chalk33[filesCountColor](files.length)} files in ${chalk33[lintTimeColor](lintTime)}ms`));
|
|
2036
2317
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2037
2318
|
};
|
|
2038
2319
|
|
|
2039
2320
|
// src/actions/package/publint.ts
|
|
2040
|
-
import { promises as
|
|
2041
|
-
import
|
|
2321
|
+
import { promises as fs8 } from "fs";
|
|
2322
|
+
import chalk34 from "chalk";
|
|
2042
2323
|
import sortPackageJson from "sort-package-json";
|
|
2043
2324
|
var customPubLint = (pkg) => {
|
|
2044
2325
|
let errorCount = 0;
|
|
2045
2326
|
let warningCount = 0;
|
|
2046
2327
|
if (pkg.files === void 0) {
|
|
2047
|
-
console.warn(
|
|
2328
|
+
console.warn(chalk34.yellow('Publint [custom]: "files" field is missing'));
|
|
2048
2329
|
warningCount++;
|
|
2049
2330
|
}
|
|
2050
2331
|
if (pkg.main !== void 0) {
|
|
2051
|
-
console.warn(
|
|
2332
|
+
console.warn(chalk34.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
2052
2333
|
warningCount++;
|
|
2053
2334
|
}
|
|
2054
2335
|
if (pkg.sideEffects !== false) {
|
|
2055
|
-
console.warn(
|
|
2336
|
+
console.warn(chalk34.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
2056
2337
|
warningCount++;
|
|
2057
2338
|
}
|
|
2058
2339
|
if (pkg.resolutions !== void 0) {
|
|
2059
|
-
console.warn(
|
|
2060
|
-
console.warn(
|
|
2340
|
+
console.warn(chalk34.yellow('Publint [custom]: "resolutions" in use'));
|
|
2341
|
+
console.warn(chalk34.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
2061
2342
|
warningCount++;
|
|
2062
2343
|
}
|
|
2063
2344
|
return [errorCount, warningCount];
|
|
2064
2345
|
};
|
|
2065
2346
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2066
2347
|
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(
|
|
2348
|
+
const sortedPkg = sortPackageJson(await fs8.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2349
|
+
await fs8.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2350
|
+
const pkg = JSON.parse(await fs8.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2351
|
+
console.log(chalk34.green(`Publint: ${pkg.name}`));
|
|
2352
|
+
console.log(chalk34.gray(pkgDir));
|
|
2072
2353
|
const { publint: publint2 } = await import("publint");
|
|
2073
2354
|
const { messages } = await publint2({
|
|
2074
2355
|
level: "suggestion",
|
|
@@ -2079,22 +2360,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2079
2360
|
for (const message of messages) {
|
|
2080
2361
|
switch (message.type) {
|
|
2081
2362
|
case "error": {
|
|
2082
|
-
console.error(
|
|
2363
|
+
console.error(chalk34.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2083
2364
|
break;
|
|
2084
2365
|
}
|
|
2085
2366
|
case "warning": {
|
|
2086
|
-
console.warn(
|
|
2367
|
+
console.warn(chalk34.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2087
2368
|
break;
|
|
2088
2369
|
}
|
|
2089
2370
|
default: {
|
|
2090
|
-
console.log(
|
|
2371
|
+
console.log(chalk34.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2091
2372
|
break;
|
|
2092
2373
|
}
|
|
2093
2374
|
}
|
|
2094
2375
|
}
|
|
2095
2376
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
2096
2377
|
if (verbose) {
|
|
2097
|
-
console.log(
|
|
2378
|
+
console.log(chalk34.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
2098
2379
|
}
|
|
2099
2380
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
2100
2381
|
};
|
|
@@ -2130,7 +2411,7 @@ var rebuild = ({ target }) => {
|
|
|
2130
2411
|
};
|
|
2131
2412
|
|
|
2132
2413
|
// src/actions/recompile.ts
|
|
2133
|
-
import
|
|
2414
|
+
import chalk35 from "chalk";
|
|
2134
2415
|
var recompile = async ({
|
|
2135
2416
|
verbose,
|
|
2136
2417
|
target,
|
|
@@ -2166,7 +2447,7 @@ var recompileAll = async ({
|
|
|
2166
2447
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2167
2448
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2168
2449
|
if (jobs) {
|
|
2169
|
-
console.log(
|
|
2450
|
+
console.log(chalk35.blue(`Jobs set to [${jobs}]`));
|
|
2170
2451
|
}
|
|
2171
2452
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2172
2453
|
[
|
|
@@ -2197,7 +2478,7 @@ var recompileAll = async ({
|
|
|
2197
2478
|
]
|
|
2198
2479
|
]);
|
|
2199
2480
|
console.log(
|
|
2200
|
-
`${
|
|
2481
|
+
`${chalk35.gray("Recompiled in")} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`
|
|
2201
2482
|
);
|
|
2202
2483
|
return result;
|
|
2203
2484
|
};
|
|
@@ -2228,13 +2509,13 @@ var reinstall = () => {
|
|
|
2228
2509
|
};
|
|
2229
2510
|
|
|
2230
2511
|
// src/actions/relint.ts
|
|
2231
|
-
import
|
|
2512
|
+
import chalk36 from "chalk";
|
|
2232
2513
|
var relintPackage = ({
|
|
2233
2514
|
pkg,
|
|
2234
2515
|
fix: fix2,
|
|
2235
2516
|
verbose
|
|
2236
2517
|
}) => {
|
|
2237
|
-
console.log(
|
|
2518
|
+
console.log(chalk36.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2238
2519
|
const start = Date.now();
|
|
2239
2520
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2240
2521
|
["yarn", [
|
|
@@ -2244,7 +2525,7 @@ var relintPackage = ({
|
|
|
2244
2525
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2245
2526
|
]]
|
|
2246
2527
|
]);
|
|
2247
|
-
console.log(
|
|
2528
|
+
console.log(chalk36.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`));
|
|
2248
2529
|
return result;
|
|
2249
2530
|
};
|
|
2250
2531
|
var relint = ({
|
|
@@ -2264,13 +2545,13 @@ var relint = ({
|
|
|
2264
2545
|
});
|
|
2265
2546
|
};
|
|
2266
2547
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2267
|
-
console.log(
|
|
2548
|
+
console.log(chalk36.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2268
2549
|
const start = Date.now();
|
|
2269
2550
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2270
2551
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2271
2552
|
["yarn", ["eslint", ...fixOptions]]
|
|
2272
2553
|
]);
|
|
2273
|
-
console.log(
|
|
2554
|
+
console.log(chalk36.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`));
|
|
2274
2555
|
return result;
|
|
2275
2556
|
};
|
|
2276
2557
|
|
|
@@ -2288,10 +2569,10 @@ var sonar = () => {
|
|
|
2288
2569
|
};
|
|
2289
2570
|
|
|
2290
2571
|
// src/actions/statics.ts
|
|
2291
|
-
import
|
|
2572
|
+
import chalk37 from "chalk";
|
|
2292
2573
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2293
2574
|
var statics = () => {
|
|
2294
|
-
console.log(
|
|
2575
|
+
console.log(chalk37.green("Check Required Static Dependencies"));
|
|
2295
2576
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2296
2577
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2297
2578
|
};
|
|
@@ -2348,7 +2629,7 @@ var loadPackageConfig = async () => {
|
|
|
2348
2629
|
};
|
|
2349
2630
|
|
|
2350
2631
|
// src/xy/xy.ts
|
|
2351
|
-
import
|
|
2632
|
+
import chalk39 from "chalk";
|
|
2352
2633
|
|
|
2353
2634
|
// src/xy/xyBuildCommands.ts
|
|
2354
2635
|
var xyBuildCommands = (args) => {
|
|
@@ -2702,7 +2983,7 @@ var xyInstallCommands = (args) => {
|
|
|
2702
2983
|
};
|
|
2703
2984
|
|
|
2704
2985
|
// src/xy/xyLintCommands.ts
|
|
2705
|
-
import
|
|
2986
|
+
import chalk38 from "chalk";
|
|
2706
2987
|
var xyLintCommands = (args) => {
|
|
2707
2988
|
return args.command(
|
|
2708
2989
|
"cycle [package]",
|
|
@@ -2714,7 +2995,7 @@ var xyLintCommands = (args) => {
|
|
|
2714
2995
|
const start = Date.now();
|
|
2715
2996
|
if (argv.verbose) console.log("Cycle");
|
|
2716
2997
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
2717
|
-
console.log(
|
|
2998
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2718
2999
|
}
|
|
2719
3000
|
).command(
|
|
2720
3001
|
"lint [package]",
|
|
@@ -2744,7 +3025,7 @@ var xyLintCommands = (args) => {
|
|
|
2744
3025
|
cache: argv.cache,
|
|
2745
3026
|
verbose: !!argv.verbose
|
|
2746
3027
|
});
|
|
2747
|
-
console.log(
|
|
3028
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2748
3029
|
}
|
|
2749
3030
|
).command(
|
|
2750
3031
|
"deplint [package]",
|
|
@@ -2777,7 +3058,7 @@ var xyLintCommands = (args) => {
|
|
|
2777
3058
|
peerDeps: !!argv.peerDeps,
|
|
2778
3059
|
verbose: !!argv.verbose
|
|
2779
3060
|
});
|
|
2780
|
-
console.log(
|
|
3061
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2781
3062
|
}
|
|
2782
3063
|
).command(
|
|
2783
3064
|
"fix [package]",
|
|
@@ -2789,7 +3070,7 @@ var xyLintCommands = (args) => {
|
|
|
2789
3070
|
const start = Date.now();
|
|
2790
3071
|
if (argv.verbose) console.log("Fix");
|
|
2791
3072
|
process.exitCode = fix();
|
|
2792
|
-
console.log(
|
|
3073
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2793
3074
|
}
|
|
2794
3075
|
).command(
|
|
2795
3076
|
"relint [package]",
|
|
@@ -2801,7 +3082,7 @@ var xyLintCommands = (args) => {
|
|
|
2801
3082
|
if (argv.verbose) console.log("Relinting");
|
|
2802
3083
|
const start = Date.now();
|
|
2803
3084
|
process.exitCode = relint();
|
|
2804
|
-
console.log(
|
|
3085
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2805
3086
|
}
|
|
2806
3087
|
).command(
|
|
2807
3088
|
"publint [package]",
|
|
@@ -2813,7 +3094,7 @@ var xyLintCommands = (args) => {
|
|
|
2813
3094
|
if (argv.verbose) console.log("Publint");
|
|
2814
3095
|
const start = Date.now();
|
|
2815
3096
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
2816
|
-
console.log(
|
|
3097
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2817
3098
|
}
|
|
2818
3099
|
).command(
|
|
2819
3100
|
"knip",
|
|
@@ -2825,7 +3106,7 @@ var xyLintCommands = (args) => {
|
|
|
2825
3106
|
if (argv.verbose) console.log("Knip");
|
|
2826
3107
|
const start = Date.now();
|
|
2827
3108
|
process.exitCode = knip();
|
|
2828
|
-
console.log(
|
|
3109
|
+
console.log(chalk38.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
2829
3110
|
}
|
|
2830
3111
|
).command(
|
|
2831
3112
|
"sonar",
|
|
@@ -2837,7 +3118,7 @@ var xyLintCommands = (args) => {
|
|
|
2837
3118
|
const start = Date.now();
|
|
2838
3119
|
if (argv.verbose) console.log("Sonar Check");
|
|
2839
3120
|
process.exitCode = sonar();
|
|
2840
|
-
console.log(
|
|
3121
|
+
console.log(chalk38.blue(`Finished in ${Date.now() - start}ms`));
|
|
2841
3122
|
}
|
|
2842
3123
|
);
|
|
2843
3124
|
};
|
|
@@ -2873,8 +3154,8 @@ var xyParseOptions = () => {
|
|
|
2873
3154
|
var xy = async () => {
|
|
2874
3155
|
const options = xyParseOptions();
|
|
2875
3156
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
2876
|
-
console.error(
|
|
2877
|
-
console.log(
|
|
3157
|
+
console.error(chalk39.yellow(`Command not found [${chalk39.magenta(process.argv[2])}]`));
|
|
3158
|
+
console.log(chalk39.gray("Try 'yarn xy --help' for list of commands"));
|
|
2878
3159
|
}).version().help().argv;
|
|
2879
3160
|
};
|
|
2880
3161
|
export {
|