@xylabs/ts-scripts-yarn3 6.5.0 → 6.5.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/deplint/checkPackage/checkPackage.mjs +256 -0
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs +1 -0
- package/dist/actions/deplint/checkPackage/checkPackageTypes.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getTypesInDependencies.mjs +19 -0
- package/dist/actions/deplint/checkPackage/getTypesInDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +35 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +17 -0
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +22 -0
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +19 -0
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/index.mjs +256 -0
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -0
- package/dist/actions/deplint/deplint.mjs +316 -0
- package/dist/actions/deplint/deplint.mjs.map +1 -0
- package/dist/actions/deplint/findFiles.mjs +24 -0
- package/dist/actions/deplint/findFiles.mjs.map +1 -0
- package/dist/actions/deplint/findFilesByGlob.mjs +9 -0
- package/dist/actions/deplint/findFilesByGlob.mjs.map +1 -0
- package/dist/actions/deplint/getBasePackageName.mjs +12 -0
- package/dist/actions/deplint/getBasePackageName.mjs.map +1 -0
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs +20 -0
- package/dist/actions/deplint/getDependenciesFromPackageJson.mjs.map +1 -0
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +98 -0
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -0
- package/dist/actions/deplint/getImportsFromFile.mjs +65 -0
- package/dist/actions/deplint/getImportsFromFile.mjs.map +1 -0
- package/dist/actions/{deplint.mjs → deplint/index.mjs} +160 -87
- package/dist/actions/deplint/index.mjs.map +1 -0
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/index.mjs +235 -160
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/bin/xy.mjs +239 -155
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +282 -198
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +239 -155
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/param.mjs +1 -1
- package/dist/xy/param.mjs.map +1 -1
- package/dist/xy/xy.mjs +239 -155
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +1 -1
- package/dist/xy/xyCommonCommands.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +212 -107
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/dist/xy/xyParseOptions.mjs +0 -21
- package/dist/xy/xyParseOptions.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/actions/deplint.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -371,8 +371,8 @@ var loadConfig = async (params) => {
|
|
|
371
371
|
|
|
372
372
|
// src/lib/parsedPackageJSON.ts
|
|
373
373
|
import { readFileSync as readFileSync4 } from "node:fs";
|
|
374
|
-
var parsedPackageJSON = (
|
|
375
|
-
const pathToPackageJSON =
|
|
374
|
+
var parsedPackageJSON = (path10) => {
|
|
375
|
+
const pathToPackageJSON = path10 ?? process.env.npm_package_json ?? "";
|
|
376
376
|
const packageJSON = readFileSync4(pathToPackageJSON).toString();
|
|
377
377
|
return JSON.parse(packageJSON);
|
|
378
378
|
};
|
|
@@ -747,12 +747,33 @@ var dead = () => {
|
|
|
747
747
|
return runSteps("Dead", [["yarn", ["ts-prune", "-p", "tsconfig.json"]]]);
|
|
748
748
|
};
|
|
749
749
|
|
|
750
|
-
// src/actions/deplint.ts
|
|
750
|
+
// src/actions/deplint/deplint.ts
|
|
751
|
+
import chalk19 from "chalk";
|
|
752
|
+
|
|
753
|
+
// src/actions/deplint/findFilesByGlob.ts
|
|
754
|
+
import { globSync } from "glob";
|
|
755
|
+
function findFilesByGlob(cwd4, pattern) {
|
|
756
|
+
return globSync(pattern, { cwd: cwd4, absolute: true });
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// src/actions/deplint/findFiles.ts
|
|
760
|
+
function findFiles(path10) {
|
|
761
|
+
const allSourceInclude = ["./src/**/*.{ts,tsx}", "./dist/**/*.d.ts"];
|
|
762
|
+
const prodExcludeEndswith = [".spec.ts", ".stories.tsx"];
|
|
763
|
+
const prodExcludeIncludes = ["/spec/", "/stories/", "/scripts/"];
|
|
764
|
+
const allSourceFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path10, pattern));
|
|
765
|
+
const prodSourceFiles = allSourceFiles.filter((file) => !prodExcludeEndswith.some((ext) => file.endsWith(ext)) && !prodExcludeIncludes.some((excl) => file.includes(excl)));
|
|
766
|
+
const devSourceFiles = allSourceFiles.filter((file) => !prodSourceFiles.includes(file));
|
|
767
|
+
return {
|
|
768
|
+
allSourceFiles,
|
|
769
|
+
prodSourceFiles,
|
|
770
|
+
devSourceFiles
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
751
775
|
import fs2 from "node:fs";
|
|
752
776
|
import path3 from "node:path";
|
|
753
|
-
import chalk14 from "chalk";
|
|
754
|
-
import { globSync } from "glob";
|
|
755
|
-
import ts from "typescript";
|
|
756
777
|
function getDependenciesFromPackageJson(packageJsonPath) {
|
|
757
778
|
const packageJsonFullPath = path3.resolve(packageJsonPath);
|
|
758
779
|
const rawContent = fs2.readFileSync(packageJsonFullPath, "utf8");
|
|
@@ -766,6 +787,13 @@ function getDependenciesFromPackageJson(packageJsonPath) {
|
|
|
766
787
|
peerDependencies
|
|
767
788
|
};
|
|
768
789
|
}
|
|
790
|
+
|
|
791
|
+
// src/actions/deplint/getImportsFromFile.ts
|
|
792
|
+
import fs3 from "node:fs";
|
|
793
|
+
import path4 from "node:path";
|
|
794
|
+
import ts from "typescript";
|
|
795
|
+
|
|
796
|
+
// src/actions/deplint/getBasePackageName.ts
|
|
769
797
|
function getBasePackageName(importName) {
|
|
770
798
|
if (importName.startsWith("@")) {
|
|
771
799
|
const parts = importName.split("/");
|
|
@@ -773,10 +801,12 @@ function getBasePackageName(importName) {
|
|
|
773
801
|
}
|
|
774
802
|
return importName.split("/")[0];
|
|
775
803
|
}
|
|
804
|
+
|
|
805
|
+
// src/actions/deplint/getImportsFromFile.ts
|
|
776
806
|
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
777
|
-
const sourceCode =
|
|
807
|
+
const sourceCode = fs3.readFileSync(filePath, "utf8");
|
|
778
808
|
const sourceFile = ts.createSourceFile(
|
|
779
|
-
|
|
809
|
+
path4.basename(filePath),
|
|
780
810
|
sourceCode,
|
|
781
811
|
ts.ScriptTarget.Latest,
|
|
782
812
|
true
|
|
@@ -819,36 +849,26 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
819
849
|
}
|
|
820
850
|
return [cleanedImports, cleanedTypeImports];
|
|
821
851
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
const prodExcludeIncludes = ["/spec/", "/stories/", "/scripts/"];
|
|
829
|
-
const allSourceFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path9, pattern));
|
|
830
|
-
const prodSourceFiles = allSourceFiles.filter((file) => !prodExcludeEndswith.some((ext) => file.endsWith(ext)) && !prodExcludeIncludes.some((excl) => file.includes(excl)));
|
|
831
|
-
const devSourceFiles = allSourceFiles.filter((file) => !prodSourceFiles.includes(file));
|
|
832
|
-
return {
|
|
833
|
-
allSourceFiles,
|
|
834
|
-
prodSourceFiles,
|
|
835
|
-
devSourceFiles
|
|
836
|
-
};
|
|
837
|
-
}
|
|
852
|
+
|
|
853
|
+
// src/actions/deplint/getExternalImportsFromFiles.ts
|
|
854
|
+
var internalImportPrefixes = [".", "#", "node:"];
|
|
855
|
+
var removeInternalImports = (imports) => {
|
|
856
|
+
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
857
|
+
};
|
|
838
858
|
function getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }) {
|
|
839
859
|
const prodImportPaths = {};
|
|
840
860
|
const prodTypeImportPaths = {};
|
|
841
|
-
const prodImportPairs = prodSourceFiles.map((
|
|
861
|
+
const prodImportPairs = prodSourceFiles.map((path10) => getImportsFromFile(path10, prodImportPaths, prodTypeImportPaths));
|
|
842
862
|
const prodImports = prodImportPairs.flatMap((pair) => pair[0]);
|
|
843
863
|
const prodTypeImports = prodImportPairs.flatMap((pair) => pair[1]);
|
|
844
864
|
const devImportPaths = {};
|
|
845
865
|
const devTypeImportPaths = {};
|
|
846
|
-
const devImportPairs = devSourceFiles.map((
|
|
866
|
+
const devImportPairs = devSourceFiles.map((path10) => getImportsFromFile(path10, devImportPaths, devTypeImportPaths));
|
|
847
867
|
const devImports = devImportPairs.flatMap((pair) => pair[0]);
|
|
848
868
|
const devTypeImports = devImportPairs.flatMap((pair) => pair[1]);
|
|
849
|
-
const externalProdImports = prodImports
|
|
850
|
-
const externalProdTypeImports = prodTypeImports
|
|
851
|
-
const externalDevImports = devImports
|
|
869
|
+
const externalProdImports = removeInternalImports(prodImports);
|
|
870
|
+
const externalProdTypeImports = removeInternalImports(prodTypeImports);
|
|
871
|
+
const externalDevImports = removeInternalImports(devImports);
|
|
852
872
|
return {
|
|
853
873
|
prodImports,
|
|
854
874
|
devImports,
|
|
@@ -862,34 +882,40 @@ function getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }) {
|
|
|
862
882
|
externalProdTypeImports
|
|
863
883
|
};
|
|
864
884
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
885
|
+
|
|
886
|
+
// src/actions/deplint/checkPackage/getTypesInDependencies.ts
|
|
887
|
+
import chalk14 from "chalk";
|
|
888
|
+
function getTypesInDependencies({ name, location }, { dependencies }, {}) {
|
|
889
|
+
let typesInDependencies = 0;
|
|
890
|
+
for (const dep of dependencies) {
|
|
891
|
+
if (dep.startsWith("@types/")) {
|
|
892
|
+
typesInDependencies++;
|
|
893
|
+
console.log(`[${chalk14.blue(name)}] @types in dependencies in package.json: ${chalk14.red(dep)}`);
|
|
894
|
+
console.log(` ${location}/package.json
|
|
895
|
+
`);
|
|
896
|
+
console.log("");
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return typesInDependencies;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
903
|
+
import chalk15 from "chalk";
|
|
904
|
+
function getUnlistedDependencies({ name }, {
|
|
905
|
+
dependencies,
|
|
906
|
+
devDependencies,
|
|
907
|
+
peerDependencies
|
|
908
|
+
}, {
|
|
909
|
+
externalProdTypeImports,
|
|
910
|
+
prodTypeImportPaths,
|
|
911
|
+
externalProdImports,
|
|
912
|
+
prodImportPaths
|
|
870
913
|
}) {
|
|
871
|
-
const { prodSourceFiles, devSourceFiles } = findFiles(location);
|
|
872
|
-
const {
|
|
873
|
-
prodTypeImportPaths,
|
|
874
|
-
prodImportPaths,
|
|
875
|
-
externalProdTypeImports,
|
|
876
|
-
devImportPaths,
|
|
877
|
-
externalProdImports,
|
|
878
|
-
externalDevImports
|
|
879
|
-
} = getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles });
|
|
880
|
-
const {
|
|
881
|
-
dependencies,
|
|
882
|
-
devDependencies,
|
|
883
|
-
peerDependencies
|
|
884
|
-
} = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
885
914
|
let unlistedDependencies = 0;
|
|
886
|
-
let unlistedDevDependencies = 0;
|
|
887
|
-
let unusedDependencies = 0;
|
|
888
|
-
let typesInDependencies = 0;
|
|
889
915
|
for (const imp of externalProdTypeImports) {
|
|
890
916
|
if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`)) {
|
|
891
917
|
unlistedDependencies++;
|
|
892
|
-
console.log(`[${
|
|
918
|
+
console.log(`[${chalk15.blue(name)}] Missing dependency in package.json: ${chalk15.red(imp)}`);
|
|
893
919
|
console.log(` ${prodTypeImportPaths[imp].join("\n")}`);
|
|
894
920
|
console.log("");
|
|
895
921
|
}
|
|
@@ -897,70 +923,119 @@ function check({
|
|
|
897
923
|
for (const imp of externalProdImports) {
|
|
898
924
|
if (!dependencies.includes(imp) && !peerDependencies.includes(imp)) {
|
|
899
925
|
unlistedDependencies++;
|
|
900
|
-
console.log(`[${
|
|
926
|
+
console.log(`[${chalk15.blue(name)}] Missing dependency in package.json: ${chalk15.red(imp)}`);
|
|
901
927
|
console.log(` ${prodImportPaths[imp].join("\n")}`);
|
|
902
928
|
console.log("");
|
|
903
929
|
}
|
|
904
930
|
}
|
|
931
|
+
return unlistedDependencies;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
935
|
+
import chalk16 from "chalk";
|
|
936
|
+
function getUnlistedDevDependencies({ name }, { devDependencies }, { devImportPaths, externalDevImports }) {
|
|
937
|
+
let unlistedDevDependencies = 0;
|
|
938
|
+
for (const imp of externalDevImports) {
|
|
939
|
+
if (!devDependencies.includes(imp)) {
|
|
940
|
+
unlistedDevDependencies++;
|
|
941
|
+
console.log(`[${chalk16.blue(name)}] Missing devDependency in package.json: ${chalk16.red(imp)}`);
|
|
942
|
+
console.log(` Found in: ${devImportPaths[imp].join(", ")}`);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return unlistedDevDependencies;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
949
|
+
import chalk17 from "chalk";
|
|
950
|
+
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
951
|
+
externalProdImports,
|
|
952
|
+
externalProdTypeImports
|
|
953
|
+
}) {
|
|
954
|
+
let unusedDependencies = 0;
|
|
905
955
|
for (const dep of dependencies) {
|
|
906
|
-
if (dep.
|
|
907
|
-
|
|
908
|
-
console.log(`[${
|
|
956
|
+
if (!externalProdImports.includes(dep) && !externalProdTypeImports.includes(dep)) {
|
|
957
|
+
unusedDependencies++;
|
|
958
|
+
console.log(`[${chalk17.blue(name)}] Unused dependency in package.json: ${chalk17.red(dep)}`);
|
|
909
959
|
console.log(` ${location}/package.json
|
|
910
960
|
`);
|
|
911
961
|
console.log("");
|
|
912
962
|
}
|
|
913
|
-
|
|
963
|
+
}
|
|
964
|
+
return unusedDependencies;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
968
|
+
import chalk18 from "chalk";
|
|
969
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies }, { externalProdImports, externalProdTypeImports }) {
|
|
970
|
+
let unusedDependencies = 0;
|
|
971
|
+
for (const dep of peerDependencies) {
|
|
972
|
+
if (!externalProdImports.includes(dep) && !externalProdTypeImports.includes(dep)) {
|
|
914
973
|
unusedDependencies++;
|
|
915
|
-
console.log(`[${
|
|
974
|
+
console.log(`[${chalk18.blue(name)}] Unused peerDependency in package.json: ${chalk18.red(dep)}`);
|
|
916
975
|
console.log(` ${location}/package.json
|
|
917
976
|
`);
|
|
918
977
|
console.log("");
|
|
919
978
|
}
|
|
920
979
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
}
|
|
941
|
-
const
|
|
980
|
+
return unusedDependencies;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
984
|
+
function checkPackage({
|
|
985
|
+
name,
|
|
986
|
+
location,
|
|
987
|
+
deps = false,
|
|
988
|
+
devDeps = false,
|
|
989
|
+
peerDeps = false
|
|
990
|
+
}) {
|
|
991
|
+
const { prodSourceFiles, devSourceFiles } = findFiles(location);
|
|
992
|
+
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
993
|
+
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
994
|
+
const checkPeerDeps = peerDeps || !(deps || devDeps || peerDeps);
|
|
995
|
+
const sourceParams = getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles });
|
|
996
|
+
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
997
|
+
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
998
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
999
|
+
const typesInDependencies = checkDeps ? getTypesInDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1000
|
+
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1001
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1002
|
+
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + typesInDependencies + unusedPeerDependencies;
|
|
942
1003
|
return totalErrors;
|
|
943
1004
|
}
|
|
944
|
-
|
|
1005
|
+
|
|
1006
|
+
// src/actions/deplint/deplint.ts
|
|
1007
|
+
var deplint = ({
|
|
1008
|
+
pkg,
|
|
1009
|
+
deps,
|
|
1010
|
+
devDeps,
|
|
1011
|
+
peerDeps
|
|
1012
|
+
}) => {
|
|
945
1013
|
if (pkg) {
|
|
946
1014
|
const { location, name } = yarnWorkspace(pkg);
|
|
947
1015
|
console.log(`Running Deplint for ${name}`);
|
|
948
|
-
|
|
1016
|
+
checkPackage({
|
|
949
1017
|
name,
|
|
950
1018
|
location,
|
|
951
|
-
devDeps
|
|
1019
|
+
devDeps,
|
|
1020
|
+
deps,
|
|
1021
|
+
peerDeps
|
|
952
1022
|
});
|
|
953
1023
|
} else {
|
|
954
1024
|
const workspaces = yarnWorkspaces();
|
|
955
1025
|
console.log("Deplint Started...");
|
|
956
1026
|
let totalErrors = 0;
|
|
957
1027
|
for (const workspace of workspaces) {
|
|
958
|
-
totalErrors +=
|
|
1028
|
+
totalErrors += checkPackage({
|
|
1029
|
+
...workspace,
|
|
1030
|
+
deps,
|
|
1031
|
+
devDeps,
|
|
1032
|
+
peerDeps
|
|
1033
|
+
});
|
|
959
1034
|
}
|
|
960
1035
|
if (totalErrors > 0) {
|
|
961
|
-
console.log(`Found ${
|
|
1036
|
+
console.log(`Deplint: Found ${chalk19.red(totalErrors)} dependency problems. ${chalk19.red("\u2716")}`);
|
|
962
1037
|
} else {
|
|
963
|
-
console.log(`
|
|
1038
|
+
console.log(`Deplint: Found no dependency problems. ${chalk19.green("\u2714")}`);
|
|
964
1039
|
}
|
|
965
1040
|
}
|
|
966
1041
|
return 0;
|
|
@@ -1067,18 +1142,18 @@ var deployNext = () => {
|
|
|
1067
1142
|
};
|
|
1068
1143
|
|
|
1069
1144
|
// src/actions/dupdeps.ts
|
|
1070
|
-
import
|
|
1145
|
+
import chalk20 from "chalk";
|
|
1071
1146
|
var dupdeps = () => {
|
|
1072
|
-
console.log(
|
|
1147
|
+
console.log(chalk20.green("Checking all Dependencies for Duplicates"));
|
|
1073
1148
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1074
1149
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1075
1150
|
return detectDuplicateDependencies(dependencies);
|
|
1076
1151
|
};
|
|
1077
1152
|
|
|
1078
1153
|
// src/actions/lint.ts
|
|
1079
|
-
import
|
|
1154
|
+
import chalk21 from "chalk";
|
|
1080
1155
|
var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
1081
|
-
console.log(
|
|
1156
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1082
1157
|
const start = Date.now();
|
|
1083
1158
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1084
1159
|
["yarn", [
|
|
@@ -1088,7 +1163,7 @@ var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
|
1088
1163
|
fix2 ? "package-fix" : "package-lint"
|
|
1089
1164
|
]]
|
|
1090
1165
|
]);
|
|
1091
|
-
console.log(
|
|
1166
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1092
1167
|
return result;
|
|
1093
1168
|
};
|
|
1094
1169
|
var lint = ({
|
|
@@ -1104,13 +1179,13 @@ var lint = ({
|
|
|
1104
1179
|
});
|
|
1105
1180
|
};
|
|
1106
1181
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1107
|
-
console.log(
|
|
1182
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1108
1183
|
const start = Date.now();
|
|
1109
1184
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1110
1185
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1111
1186
|
["yarn", ["eslint", ...fixOptions]]
|
|
1112
1187
|
]);
|
|
1113
|
-
console.log(
|
|
1188
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1114
1189
|
return result;
|
|
1115
1190
|
};
|
|
1116
1191
|
|
|
@@ -1138,7 +1213,7 @@ var filename = ".gitignore";
|
|
|
1138
1213
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1139
1214
|
|
|
1140
1215
|
// src/actions/gitlint.ts
|
|
1141
|
-
import
|
|
1216
|
+
import chalk22 from "chalk";
|
|
1142
1217
|
import ParseGitConfig from "parse-git-config";
|
|
1143
1218
|
var gitlint = () => {
|
|
1144
1219
|
console.log(`
|
|
@@ -1149,7 +1224,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1149
1224
|
const errors = 0;
|
|
1150
1225
|
const gitConfig = ParseGitConfig.sync();
|
|
1151
1226
|
const warn = (message) => {
|
|
1152
|
-
console.warn(
|
|
1227
|
+
console.warn(chalk22.yellow(`Warning: ${message}`));
|
|
1153
1228
|
warnings++;
|
|
1154
1229
|
};
|
|
1155
1230
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1169,13 +1244,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1169
1244
|
}
|
|
1170
1245
|
const resultMessages = [];
|
|
1171
1246
|
if (valid > 0) {
|
|
1172
|
-
resultMessages.push(
|
|
1247
|
+
resultMessages.push(chalk22.green(`Passed: ${valid}`));
|
|
1173
1248
|
}
|
|
1174
1249
|
if (warnings > 0) {
|
|
1175
|
-
resultMessages.push(
|
|
1250
|
+
resultMessages.push(chalk22.yellow(`Warnings: ${warnings}`));
|
|
1176
1251
|
}
|
|
1177
1252
|
if (errors > 0) {
|
|
1178
|
-
resultMessages.push(
|
|
1253
|
+
resultMessages.push(chalk22.red(` Errors: ${errors}`));
|
|
1179
1254
|
}
|
|
1180
1255
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1181
1256
|
`);
|
|
@@ -1184,7 +1259,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1184
1259
|
|
|
1185
1260
|
// src/actions/gitlint-fix.ts
|
|
1186
1261
|
import { execSync as execSync2 } from "node:child_process";
|
|
1187
|
-
import
|
|
1262
|
+
import chalk23 from "chalk";
|
|
1188
1263
|
import ParseGitConfig2 from "parse-git-config";
|
|
1189
1264
|
var gitlintFix = () => {
|
|
1190
1265
|
console.log(`
|
|
@@ -1193,15 +1268,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1193
1268
|
const gitConfig = ParseGitConfig2.sync();
|
|
1194
1269
|
if (gitConfig.core.ignorecase) {
|
|
1195
1270
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1196
|
-
console.warn(
|
|
1271
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1197
1272
|
}
|
|
1198
1273
|
if (gitConfig.core.autocrlf !== false) {
|
|
1199
1274
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1200
|
-
console.warn(
|
|
1275
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1201
1276
|
}
|
|
1202
1277
|
if (gitConfig.core.eol !== "lf") {
|
|
1203
1278
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1204
|
-
console.warn(
|
|
1279
|
+
console.warn(chalk23.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1205
1280
|
}
|
|
1206
1281
|
return 1;
|
|
1207
1282
|
};
|
|
@@ -1212,7 +1287,7 @@ var knip = () => {
|
|
|
1212
1287
|
};
|
|
1213
1288
|
|
|
1214
1289
|
// src/actions/license.ts
|
|
1215
|
-
import
|
|
1290
|
+
import chalk24 from "chalk";
|
|
1216
1291
|
import { init } from "license-checker";
|
|
1217
1292
|
var license = async (pkg) => {
|
|
1218
1293
|
const workspaces = yarnWorkspaces();
|
|
@@ -1237,18 +1312,18 @@ var license = async (pkg) => {
|
|
|
1237
1312
|
"LGPL-3.0-or-later",
|
|
1238
1313
|
"Python-2.0"
|
|
1239
1314
|
]);
|
|
1240
|
-
console.log(
|
|
1315
|
+
console.log(chalk24.green("License Checker"));
|
|
1241
1316
|
return (await Promise.all(
|
|
1242
1317
|
workspaceList.map(({ location, name }) => {
|
|
1243
1318
|
return new Promise((resolve) => {
|
|
1244
1319
|
init({ production: true, start: location }, (error, packages) => {
|
|
1245
1320
|
if (error) {
|
|
1246
|
-
console.error(
|
|
1247
|
-
console.error(
|
|
1321
|
+
console.error(chalk24.red(`License Checker [${name}] Error`));
|
|
1322
|
+
console.error(chalk24.gray(error));
|
|
1248
1323
|
console.log("\n");
|
|
1249
1324
|
resolve(1);
|
|
1250
1325
|
} else {
|
|
1251
|
-
console.log(
|
|
1326
|
+
console.log(chalk24.green(`License Checker [${name}]`));
|
|
1252
1327
|
let count = 0;
|
|
1253
1328
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1254
1329
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1264,7 +1339,7 @@ var license = async (pkg) => {
|
|
|
1264
1339
|
}
|
|
1265
1340
|
if (!orLicenseFound) {
|
|
1266
1341
|
count++;
|
|
1267
|
-
console.warn(
|
|
1342
|
+
console.warn(chalk24.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1268
1343
|
}
|
|
1269
1344
|
}
|
|
1270
1345
|
}
|
|
@@ -1283,13 +1358,13 @@ var filename2 = ".npmignore";
|
|
|
1283
1358
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1284
1359
|
|
|
1285
1360
|
// src/actions/package/clean-outputs.ts
|
|
1286
|
-
import
|
|
1287
|
-
import
|
|
1361
|
+
import path5 from "node:path";
|
|
1362
|
+
import chalk25 from "chalk";
|
|
1288
1363
|
var packageCleanOutputs = () => {
|
|
1289
1364
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1290
1365
|
const pkgName = process.env.npm_package_name;
|
|
1291
|
-
const folders = [
|
|
1292
|
-
console.log(
|
|
1366
|
+
const folders = [path5.join(pkg, "dist"), path5.join(pkg, "build"), path5.join(pkg, "docs")];
|
|
1367
|
+
console.log(chalk25.green(`Cleaning Outputs [${pkgName}]`));
|
|
1293
1368
|
for (let folder of folders) {
|
|
1294
1369
|
deleteGlob(folder);
|
|
1295
1370
|
}
|
|
@@ -1297,13 +1372,13 @@ var packageCleanOutputs = () => {
|
|
|
1297
1372
|
};
|
|
1298
1373
|
|
|
1299
1374
|
// src/actions/package/clean-typescript.ts
|
|
1300
|
-
import
|
|
1301
|
-
import
|
|
1375
|
+
import path6 from "node:path";
|
|
1376
|
+
import chalk26 from "chalk";
|
|
1302
1377
|
var packageCleanTypescript = () => {
|
|
1303
1378
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1304
1379
|
const pkgName = process.env.npm_package_name;
|
|
1305
|
-
console.log(
|
|
1306
|
-
const files = [
|
|
1380
|
+
console.log(chalk26.green(`Cleaning Typescript [${pkgName}]`));
|
|
1381
|
+
const files = [path6.join(pkg, "*.tsbuildinfo"), path6.join(pkg, ".tsconfig.*"), path6.join(pkg, ".eslintcache")];
|
|
1307
1382
|
for (let file of files) {
|
|
1308
1383
|
deleteGlob(file);
|
|
1309
1384
|
}
|
|
@@ -1316,19 +1391,19 @@ var packageClean = async () => {
|
|
|
1316
1391
|
};
|
|
1317
1392
|
|
|
1318
1393
|
// src/actions/package/compile/compile.ts
|
|
1319
|
-
import
|
|
1394
|
+
import chalk30 from "chalk";
|
|
1320
1395
|
|
|
1321
1396
|
// src/actions/package/publint.ts
|
|
1322
|
-
import { promises as
|
|
1323
|
-
import
|
|
1397
|
+
import { promises as fs4 } from "node:fs";
|
|
1398
|
+
import chalk27 from "chalk";
|
|
1324
1399
|
import sortPackageJson from "sort-package-json";
|
|
1325
1400
|
var packagePublint = async (params) => {
|
|
1326
1401
|
const pkgDir = process.env.INIT_CWD;
|
|
1327
|
-
const sortedPkg = sortPackageJson(await
|
|
1328
|
-
await
|
|
1329
|
-
const pkg = JSON.parse(await
|
|
1330
|
-
console.log(
|
|
1331
|
-
console.log(
|
|
1402
|
+
const sortedPkg = sortPackageJson(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
1403
|
+
await fs4.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
1404
|
+
const pkg = JSON.parse(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
1405
|
+
console.log(chalk27.green(`Publint: ${pkg.name}`));
|
|
1406
|
+
console.log(chalk27.gray(pkgDir));
|
|
1332
1407
|
const { publint: publint2 } = await import("publint");
|
|
1333
1408
|
const { messages } = await publint2({
|
|
1334
1409
|
level: "suggestion",
|
|
@@ -1343,21 +1418,21 @@ var packagePublint = async (params) => {
|
|
|
1343
1418
|
for (const message of validMessages) {
|
|
1344
1419
|
switch (message.type) {
|
|
1345
1420
|
case "error": {
|
|
1346
|
-
console.error(
|
|
1421
|
+
console.error(chalk27.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1347
1422
|
break;
|
|
1348
1423
|
}
|
|
1349
1424
|
case "warning": {
|
|
1350
|
-
console.warn(
|
|
1425
|
+
console.warn(chalk27.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1351
1426
|
break;
|
|
1352
1427
|
}
|
|
1353
1428
|
default: {
|
|
1354
|
-
console.log(
|
|
1429
|
+
console.log(chalk27.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1355
1430
|
break;
|
|
1356
1431
|
}
|
|
1357
1432
|
}
|
|
1358
1433
|
}
|
|
1359
1434
|
if (params?.verbose) {
|
|
1360
|
-
console.log(
|
|
1435
|
+
console.log(chalk27.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
|
|
1361
1436
|
}
|
|
1362
1437
|
return validMessages.filter((message) => message.type === "error").length;
|
|
1363
1438
|
};
|
|
@@ -1394,7 +1469,7 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1394
1469
|
|
|
1395
1470
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1396
1471
|
import { cwd } from "node:process";
|
|
1397
|
-
import
|
|
1472
|
+
import chalk28 from "chalk";
|
|
1398
1473
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1399
1474
|
import {
|
|
1400
1475
|
DiagnosticCategory,
|
|
@@ -1449,7 +1524,7 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1449
1524
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1450
1525
|
const excludes = [".stories.", ".spec."];
|
|
1451
1526
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
|
|
1452
|
-
console.log(
|
|
1527
|
+
console.log(chalk28.green(`Compiling Types ${pkg}: ${files.length}`));
|
|
1453
1528
|
if (files.length > 0) {
|
|
1454
1529
|
const program = createProgramFromConfig({
|
|
1455
1530
|
basePath: pkg ?? cwd(),
|
|
@@ -1506,7 +1581,7 @@ function deepMergeObjects(objects) {
|
|
|
1506
1581
|
|
|
1507
1582
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1508
1583
|
import { cwd as cwd2 } from "node:process";
|
|
1509
|
-
import
|
|
1584
|
+
import chalk29 from "chalk";
|
|
1510
1585
|
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1511
1586
|
import {
|
|
1512
1587
|
DiagnosticCategory as DiagnosticCategory2,
|
|
@@ -1532,7 +1607,7 @@ var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) =>
|
|
|
1532
1607
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1533
1608
|
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1534
1609
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1535
|
-
console.log(
|
|
1610
|
+
console.log(chalk29.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1536
1611
|
if (files.length > 0) {
|
|
1537
1612
|
const program = createProgramFromConfig2({
|
|
1538
1613
|
basePath: pkg ?? cwd2(),
|
|
@@ -1683,7 +1758,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1683
1758
|
// src/actions/package/compile/compile.ts
|
|
1684
1759
|
var packageCompile = async (inConfig = {}) => {
|
|
1685
1760
|
const pkg = process.env.INIT_CWD;
|
|
1686
|
-
console.log(
|
|
1761
|
+
console.log(chalk30.green(`Compiling ${pkg}`));
|
|
1687
1762
|
const config2 = await loadConfig(inConfig);
|
|
1688
1763
|
const publint2 = config2.publint;
|
|
1689
1764
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1694,8 +1769,8 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1694
1769
|
};
|
|
1695
1770
|
|
|
1696
1771
|
// src/actions/package/copy-assets.ts
|
|
1697
|
-
import
|
|
1698
|
-
import
|
|
1772
|
+
import path7 from "node:path/posix";
|
|
1773
|
+
import chalk31 from "chalk";
|
|
1699
1774
|
import cpy2 from "cpy";
|
|
1700
1775
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1701
1776
|
try {
|
|
@@ -1703,12 +1778,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1703
1778
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1704
1779
|
`../dist/${target}`,
|
|
1705
1780
|
{
|
|
1706
|
-
cwd:
|
|
1781
|
+
cwd: path7.join(location, "src"),
|
|
1707
1782
|
flat: false
|
|
1708
1783
|
}
|
|
1709
1784
|
);
|
|
1710
1785
|
if (values.length > 0) {
|
|
1711
|
-
console.log(
|
|
1786
|
+
console.log(chalk31.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1712
1787
|
}
|
|
1713
1788
|
for (const value of values) {
|
|
1714
1789
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -1776,8 +1851,8 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1776
1851
|
|
|
1777
1852
|
// src/actions/package/gen-docs.ts
|
|
1778
1853
|
import { existsSync as existsSync5 } from "node:fs";
|
|
1779
|
-
import
|
|
1780
|
-
import
|
|
1854
|
+
import path8 from "node:path";
|
|
1855
|
+
import chalk32 from "chalk";
|
|
1781
1856
|
import {
|
|
1782
1857
|
Application,
|
|
1783
1858
|
ArgumentsReader,
|
|
@@ -1795,7 +1870,7 @@ var ExitCodes = {
|
|
|
1795
1870
|
};
|
|
1796
1871
|
var packageGenDocs = async () => {
|
|
1797
1872
|
const pkg = process.env.INIT_CWD;
|
|
1798
|
-
if (pkg && !existsSync5(
|
|
1873
|
+
if (pkg && !existsSync5(path8.join(pkg, "typedoc.json"))) {
|
|
1799
1874
|
return;
|
|
1800
1875
|
}
|
|
1801
1876
|
const app = await Application.bootstrap({
|
|
@@ -1881,16 +1956,16 @@ var runTypeDoc = async (app) => {
|
|
|
1881
1956
|
return ExitCodes.OutputError;
|
|
1882
1957
|
}
|
|
1883
1958
|
}
|
|
1884
|
-
console.log(
|
|
1959
|
+
console.log(chalk32.green(`${pkgName} - Ok`));
|
|
1885
1960
|
return ExitCodes.Ok;
|
|
1886
1961
|
};
|
|
1887
1962
|
|
|
1888
1963
|
// src/actions/package/lint.ts
|
|
1889
1964
|
import { readdirSync } from "node:fs";
|
|
1890
|
-
import
|
|
1965
|
+
import path9 from "node:path";
|
|
1891
1966
|
import { cwd as cwd3 } from "node:process";
|
|
1892
1967
|
import { pathToFileURL } from "node:url";
|
|
1893
|
-
import
|
|
1968
|
+
import chalk33 from "chalk";
|
|
1894
1969
|
import { ESLint } from "eslint";
|
|
1895
1970
|
import { findUp } from "find-up";
|
|
1896
1971
|
import picomatch from "picomatch";
|
|
@@ -1899,14 +1974,14 @@ var dumpMessages = (lintResults) => {
|
|
|
1899
1974
|
const severity = ["none", "warning", "error"];
|
|
1900
1975
|
for (const lintResult of lintResults) {
|
|
1901
1976
|
if (lintResult.messages.length > 0) {
|
|
1902
|
-
console.log(
|
|
1977
|
+
console.log(chalk33.gray(`
|
|
1903
1978
|
${lintResult.filePath}`));
|
|
1904
1979
|
for (const message of lintResult.messages) {
|
|
1905
1980
|
console.log(
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1981
|
+
chalk33.gray(` ${message.line}:${message.column}`),
|
|
1982
|
+
chalk33[colors[message.severity]](` ${severity[message.severity]}`),
|
|
1983
|
+
chalk33.white(` ${message.message}`),
|
|
1984
|
+
chalk33.gray(` ${message.ruleId}`)
|
|
1910
1985
|
);
|
|
1911
1986
|
}
|
|
1912
1987
|
}
|
|
@@ -1924,7 +1999,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1924
1999
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1925
2000
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1926
2001
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1927
|
-
const res =
|
|
2002
|
+
const res = path9.resolve(dir, dirent.name);
|
|
1928
2003
|
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
|
|
1929
2004
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1930
2005
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -1945,7 +2020,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1945
2020
|
});
|
|
1946
2021
|
const files = getFiles(cwd3(), ignoreFolders);
|
|
1947
2022
|
if (verbose) {
|
|
1948
|
-
console.log(
|
|
2023
|
+
console.log(chalk33.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
1949
2024
|
}
|
|
1950
2025
|
const lintResults = await engine.lintFiles(files);
|
|
1951
2026
|
dumpMessages(lintResults);
|
|
@@ -1955,7 +2030,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1955
2030
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
1956
2031
|
const lintTime = Date.now() - start;
|
|
1957
2032
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
1958
|
-
console.log(
|
|
2033
|
+
console.log(chalk33.white(`Linted ${chalk33[filesCountColor](files.length)} files in ${chalk33[lintTimeColor](lintTime)}ms`));
|
|
1959
2034
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1960
2035
|
};
|
|
1961
2036
|
|
|
@@ -1985,7 +2060,7 @@ var rebuild = ({ target }) => {
|
|
|
1985
2060
|
};
|
|
1986
2061
|
|
|
1987
2062
|
// src/actions/recompile.ts
|
|
1988
|
-
import
|
|
2063
|
+
import chalk34 from "chalk";
|
|
1989
2064
|
var recompile = async ({
|
|
1990
2065
|
verbose,
|
|
1991
2066
|
target,
|
|
@@ -2021,7 +2096,7 @@ var recompileAll = async ({
|
|
|
2021
2096
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2022
2097
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2023
2098
|
if (jobs) {
|
|
2024
|
-
console.log(
|
|
2099
|
+
console.log(chalk34.blue(`Jobs set to [${jobs}]`));
|
|
2025
2100
|
}
|
|
2026
2101
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2027
2102
|
[
|
|
@@ -2052,7 +2127,7 @@ var recompileAll = async ({
|
|
|
2052
2127
|
]
|
|
2053
2128
|
]);
|
|
2054
2129
|
console.log(
|
|
2055
|
-
`${
|
|
2130
|
+
`${chalk34.gray("Recompiled in")} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`
|
|
2056
2131
|
);
|
|
2057
2132
|
return result;
|
|
2058
2133
|
};
|
|
@@ -2083,9 +2158,9 @@ var reinstall = () => {
|
|
|
2083
2158
|
};
|
|
2084
2159
|
|
|
2085
2160
|
// src/actions/relint.ts
|
|
2086
|
-
import
|
|
2161
|
+
import chalk35 from "chalk";
|
|
2087
2162
|
var relintPackage = ({ pkg }) => {
|
|
2088
|
-
console.log(
|
|
2163
|
+
console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
|
|
2089
2164
|
const start = Date.now();
|
|
2090
2165
|
const result = runSteps("Relint [All-Packages]", [
|
|
2091
2166
|
["yarn", [
|
|
@@ -2095,7 +2170,7 @@ var relintPackage = ({ pkg }) => {
|
|
|
2095
2170
|
"package-relint"
|
|
2096
2171
|
]]
|
|
2097
2172
|
]);
|
|
2098
|
-
console.log(
|
|
2173
|
+
console.log(chalk35.gray(`${"Relinted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
|
|
2099
2174
|
return result;
|
|
2100
2175
|
};
|
|
2101
2176
|
var relint = ({
|
|
@@ -2106,7 +2181,7 @@ var relint = ({
|
|
|
2106
2181
|
return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
|
|
2107
2182
|
};
|
|
2108
2183
|
var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
2109
|
-
console.log(
|
|
2184
|
+
console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
|
|
2110
2185
|
const start = Date.now();
|
|
2111
2186
|
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
2112
2187
|
const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
|
|
@@ -2120,7 +2195,7 @@ var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
|
2120
2195
|
"package-relint"
|
|
2121
2196
|
]]
|
|
2122
2197
|
]);
|
|
2123
|
-
console.log(
|
|
2198
|
+
console.log(chalk35.gray(`Relinted in [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
|
|
2124
2199
|
return result;
|
|
2125
2200
|
};
|
|
2126
2201
|
|
|
@@ -2138,10 +2213,10 @@ var sonar = () => {
|
|
|
2138
2213
|
};
|
|
2139
2214
|
|
|
2140
2215
|
// src/actions/statics.ts
|
|
2141
|
-
import
|
|
2216
|
+
import chalk36 from "chalk";
|
|
2142
2217
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2143
2218
|
var statics = () => {
|
|
2144
|
-
console.log(
|
|
2219
|
+
console.log(chalk36.green("Check Required Static Dependencies"));
|
|
2145
2220
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2146
2221
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2147
2222
|
};
|
|
@@ -2198,7 +2273,7 @@ var loadPackageConfig = async () => {
|
|
|
2198
2273
|
};
|
|
2199
2274
|
|
|
2200
2275
|
// src/xy/xy.ts
|
|
2201
|
-
import
|
|
2276
|
+
import chalk38 from "chalk";
|
|
2202
2277
|
|
|
2203
2278
|
// src/xy/xyBuildCommands.ts
|
|
2204
2279
|
var xyBuildCommands = (args) => {
|
|
@@ -2317,7 +2392,7 @@ var xyBuildCommands = (args) => {
|
|
|
2317
2392
|
|
|
2318
2393
|
// src/xy/param.ts
|
|
2319
2394
|
var packagePositionalParam = (yargs2) => {
|
|
2320
|
-
return yargs2.positional("package", { describe: "Specific package to target" });
|
|
2395
|
+
return yargs2.positional("package", { describe: "Specific package to target", type: "string" });
|
|
2321
2396
|
};
|
|
2322
2397
|
|
|
2323
2398
|
// src/xy/xyCommonCommands.ts
|
|
@@ -2559,7 +2634,7 @@ var xyInstallCommands = (args) => {
|
|
|
2559
2634
|
};
|
|
2560
2635
|
|
|
2561
2636
|
// src/xy/xyLintCommands.ts
|
|
2562
|
-
import
|
|
2637
|
+
import chalk37 from "chalk";
|
|
2563
2638
|
var xyLintCommands = (args) => {
|
|
2564
2639
|
return args.command(
|
|
2565
2640
|
"cycle [package]",
|
|
@@ -2571,31 +2646,61 @@ var xyLintCommands = (args) => {
|
|
|
2571
2646
|
const start = Date.now();
|
|
2572
2647
|
if (argv.verbose) console.log("Cycle");
|
|
2573
2648
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
2574
|
-
console.log(
|
|
2649
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2575
2650
|
}
|
|
2576
2651
|
).command(
|
|
2577
2652
|
"lint [package]",
|
|
2578
2653
|
"Lint - Run Eslint",
|
|
2579
2654
|
(yargs2) => {
|
|
2580
|
-
return packagePositionalParam(yargs2)
|
|
2655
|
+
return packagePositionalParam(yargs2).option("fix", {
|
|
2656
|
+
alias: "f",
|
|
2657
|
+
default: false,
|
|
2658
|
+
description: "Fix fixable issues",
|
|
2659
|
+
type: "boolean"
|
|
2660
|
+
}).option("cache", {
|
|
2661
|
+
alias: "c",
|
|
2662
|
+
default: false,
|
|
2663
|
+
description: "Use caching for performance",
|
|
2664
|
+
type: "boolean"
|
|
2665
|
+
});
|
|
2581
2666
|
},
|
|
2582
2667
|
(argv) => {
|
|
2583
2668
|
if (argv.verbose) console.log("Lint");
|
|
2584
2669
|
const start = Date.now();
|
|
2585
|
-
process.exitCode = argv.fix ? fix({ pkg: argv.package }) : lint({ pkg: argv.package });
|
|
2586
|
-
console.log(
|
|
2670
|
+
process.exitCode = argv.fix ? fix({ pkg: argv.package, cache: argv.cache }) : lint({ pkg: argv.package, cache: argv.cache });
|
|
2671
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2587
2672
|
}
|
|
2588
2673
|
).command(
|
|
2589
2674
|
"deplint [package]",
|
|
2590
2675
|
"Deplint - Run Deplint",
|
|
2591
2676
|
(yargs2) => {
|
|
2592
|
-
return packagePositionalParam(yargs2)
|
|
2677
|
+
return packagePositionalParam(yargs2).option("deps", {
|
|
2678
|
+
alias: "d",
|
|
2679
|
+
default: false,
|
|
2680
|
+
description: "Check dependencies",
|
|
2681
|
+
type: "boolean"
|
|
2682
|
+
}).option("devDeps", {
|
|
2683
|
+
alias: "v",
|
|
2684
|
+
default: false,
|
|
2685
|
+
description: "Check devDependencies",
|
|
2686
|
+
type: "boolean"
|
|
2687
|
+
}).option("peerDeps", {
|
|
2688
|
+
alias: "p",
|
|
2689
|
+
default: false,
|
|
2690
|
+
description: "Check peerDependencies",
|
|
2691
|
+
type: "boolean"
|
|
2692
|
+
});
|
|
2593
2693
|
},
|
|
2594
2694
|
(argv) => {
|
|
2595
2695
|
if (argv.verbose) console.log("Deplint");
|
|
2596
2696
|
const start = Date.now();
|
|
2597
|
-
process.exitCode = deplint({
|
|
2598
|
-
|
|
2697
|
+
process.exitCode = deplint({
|
|
2698
|
+
pkg: argv.package,
|
|
2699
|
+
deps: !!argv.deps,
|
|
2700
|
+
devDeps: !!argv.devDeps,
|
|
2701
|
+
peerDeps: !!argv.peerDeps
|
|
2702
|
+
});
|
|
2703
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2599
2704
|
}
|
|
2600
2705
|
).command(
|
|
2601
2706
|
"fix [package]",
|
|
@@ -2607,7 +2712,7 @@ var xyLintCommands = (args) => {
|
|
|
2607
2712
|
const start = Date.now();
|
|
2608
2713
|
if (argv.verbose) console.log("Fix");
|
|
2609
2714
|
process.exitCode = fix();
|
|
2610
|
-
console.log(
|
|
2715
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2611
2716
|
}
|
|
2612
2717
|
).command(
|
|
2613
2718
|
"relint [package]",
|
|
@@ -2619,7 +2724,7 @@ var xyLintCommands = (args) => {
|
|
|
2619
2724
|
if (argv.verbose) console.log("Relinting");
|
|
2620
2725
|
const start = Date.now();
|
|
2621
2726
|
process.exitCode = relint();
|
|
2622
|
-
console.log(
|
|
2727
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2623
2728
|
}
|
|
2624
2729
|
).command(
|
|
2625
2730
|
"publint [package]",
|
|
@@ -2631,7 +2736,7 @@ var xyLintCommands = (args) => {
|
|
|
2631
2736
|
if (argv.verbose) console.log("Publint");
|
|
2632
2737
|
const start = Date.now();
|
|
2633
2738
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
2634
|
-
console.log(
|
|
2739
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2635
2740
|
}
|
|
2636
2741
|
).command(
|
|
2637
2742
|
"knip",
|
|
@@ -2643,7 +2748,7 @@ var xyLintCommands = (args) => {
|
|
|
2643
2748
|
if (argv.verbose) console.log("Knip");
|
|
2644
2749
|
const start = Date.now();
|
|
2645
2750
|
process.exitCode = knip();
|
|
2646
|
-
console.log(
|
|
2751
|
+
console.log(chalk37.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
2647
2752
|
}
|
|
2648
2753
|
).command(
|
|
2649
2754
|
"sonar",
|
|
@@ -2655,7 +2760,7 @@ var xyLintCommands = (args) => {
|
|
|
2655
2760
|
const start = Date.now();
|
|
2656
2761
|
if (argv.verbose) console.log("Sonar Check");
|
|
2657
2762
|
process.exitCode = sonar();
|
|
2658
|
-
console.log(
|
|
2763
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2659
2764
|
}
|
|
2660
2765
|
);
|
|
2661
2766
|
};
|
|
@@ -2674,37 +2779,16 @@ var xyParseOptions = () => {
|
|
|
2674
2779
|
default: false,
|
|
2675
2780
|
description: "Run with verbose logging",
|
|
2676
2781
|
type: "boolean"
|
|
2677
|
-
}).option("target", {
|
|
2678
|
-
alias: "t",
|
|
2679
|
-
default: "esm",
|
|
2680
|
-
choices: ["esm", "cjs"],
|
|
2681
|
-
description: "Limit output to specific target",
|
|
2682
|
-
type: "string"
|
|
2683
2782
|
}).option("incremental", {
|
|
2684
2783
|
alias: "i",
|
|
2685
2784
|
default: false,
|
|
2686
2785
|
description: "Attempt to perform the action only on changed packages",
|
|
2687
2786
|
type: "boolean"
|
|
2688
|
-
}).option("fix", {
|
|
2689
|
-
alias: "f",
|
|
2690
|
-
default: false,
|
|
2691
|
-
description: "Try to fix errors",
|
|
2692
|
-
type: "boolean"
|
|
2693
|
-
}).option("cache", {
|
|
2694
|
-
alias: "c",
|
|
2695
|
-
default: false,
|
|
2696
|
-
description: "Use caching for performance",
|
|
2697
|
-
type: "boolean"
|
|
2698
2787
|
}).option("profile", {
|
|
2699
2788
|
alias: "p",
|
|
2700
2789
|
default: false,
|
|
2701
2790
|
description: "Profile action",
|
|
2702
2791
|
type: "boolean"
|
|
2703
|
-
}).option("types", {
|
|
2704
|
-
default: "tsc",
|
|
2705
|
-
choices: ["tsc", "tsup"],
|
|
2706
|
-
description: "Tool to generate Typescript types",
|
|
2707
|
-
type: "string"
|
|
2708
2792
|
});
|
|
2709
2793
|
};
|
|
2710
2794
|
|
|
@@ -2712,8 +2796,8 @@ var xyParseOptions = () => {
|
|
|
2712
2796
|
var xy = async () => {
|
|
2713
2797
|
const options = xyParseOptions();
|
|
2714
2798
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
2715
|
-
console.error(
|
|
2716
|
-
console.log(
|
|
2799
|
+
console.error(chalk38.yellow(`Command not found [${chalk38.magenta(process.argv[2])}]`));
|
|
2800
|
+
console.log(chalk38.gray("Try 'yarn xy --help' for list of commands"));
|
|
2717
2801
|
}).version().help().argv;
|
|
2718
2802
|
};
|
|
2719
2803
|
export {
|