@xylabs/ts-scripts-yarn3 6.5.0 → 6.5.2
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 +260 -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 +21 -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 +260 -0
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -0
- package/dist/actions/deplint/deplint.mjs +320 -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} +165 -88
- package/dist/actions/deplint/index.mjs.map +1 -0
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/index.mjs +240 -161
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/bin/xy.mjs +244 -156
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +287 -199
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +244 -156
- 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 +244 -156
- 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 +217 -108
- 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
|
-
if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !
|
|
916
|
+
if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.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,123 @@ 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 }, {
|
|
937
|
+
devDependencies,
|
|
938
|
+
dependencies,
|
|
939
|
+
peerDependencies
|
|
940
|
+
}, { devImportPaths, externalDevImports }) {
|
|
941
|
+
let unlistedDevDependencies = 0;
|
|
942
|
+
for (const imp of externalDevImports) {
|
|
943
|
+
if (!devDependencies.includes(imp) && !dependencies.includes(imp) && !peerDependencies.includes(imp)) {
|
|
944
|
+
unlistedDevDependencies++;
|
|
945
|
+
console.log(`[${chalk16.blue(name)}] Missing devDependency in package.json: ${chalk16.red(imp)}`);
|
|
946
|
+
console.log(` Found in: ${devImportPaths[imp].join(", ")}`);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
return unlistedDevDependencies;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
953
|
+
import chalk17 from "chalk";
|
|
954
|
+
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
955
|
+
externalProdImports,
|
|
956
|
+
externalProdTypeImports
|
|
957
|
+
}) {
|
|
958
|
+
let unusedDependencies = 0;
|
|
905
959
|
for (const dep of dependencies) {
|
|
906
|
-
if (dep.
|
|
907
|
-
|
|
908
|
-
console.log(`[${
|
|
960
|
+
if (!externalProdImports.includes(dep) && !externalProdTypeImports.includes(dep)) {
|
|
961
|
+
unusedDependencies++;
|
|
962
|
+
console.log(`[${chalk17.blue(name)}] Unused dependency in package.json: ${chalk17.red(dep)}`);
|
|
909
963
|
console.log(` ${location}/package.json
|
|
910
964
|
`);
|
|
911
965
|
console.log("");
|
|
912
966
|
}
|
|
913
|
-
|
|
967
|
+
}
|
|
968
|
+
return unusedDependencies;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
972
|
+
import chalk18 from "chalk";
|
|
973
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies }, { externalProdImports, externalProdTypeImports }) {
|
|
974
|
+
let unusedDependencies = 0;
|
|
975
|
+
for (const dep of peerDependencies) {
|
|
976
|
+
if (!externalProdImports.includes(dep) && !externalProdTypeImports.includes(dep)) {
|
|
914
977
|
unusedDependencies++;
|
|
915
|
-
console.log(`[${
|
|
978
|
+
console.log(`[${chalk18.blue(name)}] Unused peerDependency in package.json: ${chalk18.red(dep)}`);
|
|
916
979
|
console.log(` ${location}/package.json
|
|
917
980
|
`);
|
|
918
981
|
console.log("");
|
|
919
982
|
}
|
|
920
983
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
}
|
|
941
|
-
const
|
|
984
|
+
return unusedDependencies;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
988
|
+
function checkPackage({
|
|
989
|
+
name,
|
|
990
|
+
location,
|
|
991
|
+
deps = false,
|
|
992
|
+
devDeps = false,
|
|
993
|
+
peerDeps = false
|
|
994
|
+
}) {
|
|
995
|
+
const { prodSourceFiles, devSourceFiles } = findFiles(location);
|
|
996
|
+
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
997
|
+
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
998
|
+
const checkPeerDeps = peerDeps || !(deps || devDeps || peerDeps);
|
|
999
|
+
const sourceParams = getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles });
|
|
1000
|
+
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1001
|
+
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1002
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1003
|
+
const typesInDependencies = checkDeps ? getTypesInDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1004
|
+
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1005
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1006
|
+
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + typesInDependencies + unusedPeerDependencies;
|
|
942
1007
|
return totalErrors;
|
|
943
1008
|
}
|
|
944
|
-
|
|
1009
|
+
|
|
1010
|
+
// src/actions/deplint/deplint.ts
|
|
1011
|
+
var deplint = ({
|
|
1012
|
+
pkg,
|
|
1013
|
+
deps,
|
|
1014
|
+
devDeps,
|
|
1015
|
+
peerDeps
|
|
1016
|
+
}) => {
|
|
945
1017
|
if (pkg) {
|
|
946
1018
|
const { location, name } = yarnWorkspace(pkg);
|
|
947
1019
|
console.log(`Running Deplint for ${name}`);
|
|
948
|
-
|
|
1020
|
+
checkPackage({
|
|
949
1021
|
name,
|
|
950
1022
|
location,
|
|
951
|
-
devDeps
|
|
1023
|
+
devDeps,
|
|
1024
|
+
deps,
|
|
1025
|
+
peerDeps
|
|
952
1026
|
});
|
|
953
1027
|
} else {
|
|
954
1028
|
const workspaces = yarnWorkspaces();
|
|
955
1029
|
console.log("Deplint Started...");
|
|
956
1030
|
let totalErrors = 0;
|
|
957
1031
|
for (const workspace of workspaces) {
|
|
958
|
-
totalErrors +=
|
|
1032
|
+
totalErrors += checkPackage({
|
|
1033
|
+
...workspace,
|
|
1034
|
+
deps,
|
|
1035
|
+
devDeps,
|
|
1036
|
+
peerDeps
|
|
1037
|
+
});
|
|
959
1038
|
}
|
|
960
1039
|
if (totalErrors > 0) {
|
|
961
|
-
console.log(`Found ${
|
|
1040
|
+
console.log(`Deplint: Found ${chalk19.red(totalErrors)} dependency problems. ${chalk19.red("\u2716")}`);
|
|
962
1041
|
} else {
|
|
963
|
-
console.log(`
|
|
1042
|
+
console.log(`Deplint: Found no dependency problems. ${chalk19.green("\u2714")}`);
|
|
964
1043
|
}
|
|
965
1044
|
}
|
|
966
1045
|
return 0;
|
|
@@ -1067,18 +1146,18 @@ var deployNext = () => {
|
|
|
1067
1146
|
};
|
|
1068
1147
|
|
|
1069
1148
|
// src/actions/dupdeps.ts
|
|
1070
|
-
import
|
|
1149
|
+
import chalk20 from "chalk";
|
|
1071
1150
|
var dupdeps = () => {
|
|
1072
|
-
console.log(
|
|
1151
|
+
console.log(chalk20.green("Checking all Dependencies for Duplicates"));
|
|
1073
1152
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1074
1153
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1075
1154
|
return detectDuplicateDependencies(dependencies);
|
|
1076
1155
|
};
|
|
1077
1156
|
|
|
1078
1157
|
// src/actions/lint.ts
|
|
1079
|
-
import
|
|
1158
|
+
import chalk21 from "chalk";
|
|
1080
1159
|
var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
1081
|
-
console.log(
|
|
1160
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1082
1161
|
const start = Date.now();
|
|
1083
1162
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1084
1163
|
["yarn", [
|
|
@@ -1088,7 +1167,7 @@ var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
|
1088
1167
|
fix2 ? "package-fix" : "package-lint"
|
|
1089
1168
|
]]
|
|
1090
1169
|
]);
|
|
1091
|
-
console.log(
|
|
1170
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1092
1171
|
return result;
|
|
1093
1172
|
};
|
|
1094
1173
|
var lint = ({
|
|
@@ -1104,13 +1183,13 @@ var lint = ({
|
|
|
1104
1183
|
});
|
|
1105
1184
|
};
|
|
1106
1185
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1107
|
-
console.log(
|
|
1186
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1108
1187
|
const start = Date.now();
|
|
1109
1188
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1110
1189
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1111
1190
|
["yarn", ["eslint", ...fixOptions]]
|
|
1112
1191
|
]);
|
|
1113
|
-
console.log(
|
|
1192
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1114
1193
|
return result;
|
|
1115
1194
|
};
|
|
1116
1195
|
|
|
@@ -1138,7 +1217,7 @@ var filename = ".gitignore";
|
|
|
1138
1217
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1139
1218
|
|
|
1140
1219
|
// src/actions/gitlint.ts
|
|
1141
|
-
import
|
|
1220
|
+
import chalk22 from "chalk";
|
|
1142
1221
|
import ParseGitConfig from "parse-git-config";
|
|
1143
1222
|
var gitlint = () => {
|
|
1144
1223
|
console.log(`
|
|
@@ -1149,7 +1228,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1149
1228
|
const errors = 0;
|
|
1150
1229
|
const gitConfig = ParseGitConfig.sync();
|
|
1151
1230
|
const warn = (message) => {
|
|
1152
|
-
console.warn(
|
|
1231
|
+
console.warn(chalk22.yellow(`Warning: ${message}`));
|
|
1153
1232
|
warnings++;
|
|
1154
1233
|
};
|
|
1155
1234
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1169,13 +1248,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1169
1248
|
}
|
|
1170
1249
|
const resultMessages = [];
|
|
1171
1250
|
if (valid > 0) {
|
|
1172
|
-
resultMessages.push(
|
|
1251
|
+
resultMessages.push(chalk22.green(`Passed: ${valid}`));
|
|
1173
1252
|
}
|
|
1174
1253
|
if (warnings > 0) {
|
|
1175
|
-
resultMessages.push(
|
|
1254
|
+
resultMessages.push(chalk22.yellow(`Warnings: ${warnings}`));
|
|
1176
1255
|
}
|
|
1177
1256
|
if (errors > 0) {
|
|
1178
|
-
resultMessages.push(
|
|
1257
|
+
resultMessages.push(chalk22.red(` Errors: ${errors}`));
|
|
1179
1258
|
}
|
|
1180
1259
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1181
1260
|
`);
|
|
@@ -1184,7 +1263,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1184
1263
|
|
|
1185
1264
|
// src/actions/gitlint-fix.ts
|
|
1186
1265
|
import { execSync as execSync2 } from "node:child_process";
|
|
1187
|
-
import
|
|
1266
|
+
import chalk23 from "chalk";
|
|
1188
1267
|
import ParseGitConfig2 from "parse-git-config";
|
|
1189
1268
|
var gitlintFix = () => {
|
|
1190
1269
|
console.log(`
|
|
@@ -1193,15 +1272,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1193
1272
|
const gitConfig = ParseGitConfig2.sync();
|
|
1194
1273
|
if (gitConfig.core.ignorecase) {
|
|
1195
1274
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1196
|
-
console.warn(
|
|
1275
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1197
1276
|
}
|
|
1198
1277
|
if (gitConfig.core.autocrlf !== false) {
|
|
1199
1278
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1200
|
-
console.warn(
|
|
1279
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1201
1280
|
}
|
|
1202
1281
|
if (gitConfig.core.eol !== "lf") {
|
|
1203
1282
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1204
|
-
console.warn(
|
|
1283
|
+
console.warn(chalk23.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1205
1284
|
}
|
|
1206
1285
|
return 1;
|
|
1207
1286
|
};
|
|
@@ -1212,7 +1291,7 @@ var knip = () => {
|
|
|
1212
1291
|
};
|
|
1213
1292
|
|
|
1214
1293
|
// src/actions/license.ts
|
|
1215
|
-
import
|
|
1294
|
+
import chalk24 from "chalk";
|
|
1216
1295
|
import { init } from "license-checker";
|
|
1217
1296
|
var license = async (pkg) => {
|
|
1218
1297
|
const workspaces = yarnWorkspaces();
|
|
@@ -1237,18 +1316,18 @@ var license = async (pkg) => {
|
|
|
1237
1316
|
"LGPL-3.0-or-later",
|
|
1238
1317
|
"Python-2.0"
|
|
1239
1318
|
]);
|
|
1240
|
-
console.log(
|
|
1319
|
+
console.log(chalk24.green("License Checker"));
|
|
1241
1320
|
return (await Promise.all(
|
|
1242
1321
|
workspaceList.map(({ location, name }) => {
|
|
1243
1322
|
return new Promise((resolve) => {
|
|
1244
1323
|
init({ production: true, start: location }, (error, packages) => {
|
|
1245
1324
|
if (error) {
|
|
1246
|
-
console.error(
|
|
1247
|
-
console.error(
|
|
1325
|
+
console.error(chalk24.red(`License Checker [${name}] Error`));
|
|
1326
|
+
console.error(chalk24.gray(error));
|
|
1248
1327
|
console.log("\n");
|
|
1249
1328
|
resolve(1);
|
|
1250
1329
|
} else {
|
|
1251
|
-
console.log(
|
|
1330
|
+
console.log(chalk24.green(`License Checker [${name}]`));
|
|
1252
1331
|
let count = 0;
|
|
1253
1332
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1254
1333
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1264,7 +1343,7 @@ var license = async (pkg) => {
|
|
|
1264
1343
|
}
|
|
1265
1344
|
if (!orLicenseFound) {
|
|
1266
1345
|
count++;
|
|
1267
|
-
console.warn(
|
|
1346
|
+
console.warn(chalk24.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1268
1347
|
}
|
|
1269
1348
|
}
|
|
1270
1349
|
}
|
|
@@ -1283,13 +1362,13 @@ var filename2 = ".npmignore";
|
|
|
1283
1362
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1284
1363
|
|
|
1285
1364
|
// src/actions/package/clean-outputs.ts
|
|
1286
|
-
import
|
|
1287
|
-
import
|
|
1365
|
+
import path5 from "node:path";
|
|
1366
|
+
import chalk25 from "chalk";
|
|
1288
1367
|
var packageCleanOutputs = () => {
|
|
1289
1368
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1290
1369
|
const pkgName = process.env.npm_package_name;
|
|
1291
|
-
const folders = [
|
|
1292
|
-
console.log(
|
|
1370
|
+
const folders = [path5.join(pkg, "dist"), path5.join(pkg, "build"), path5.join(pkg, "docs")];
|
|
1371
|
+
console.log(chalk25.green(`Cleaning Outputs [${pkgName}]`));
|
|
1293
1372
|
for (let folder of folders) {
|
|
1294
1373
|
deleteGlob(folder);
|
|
1295
1374
|
}
|
|
@@ -1297,13 +1376,13 @@ var packageCleanOutputs = () => {
|
|
|
1297
1376
|
};
|
|
1298
1377
|
|
|
1299
1378
|
// src/actions/package/clean-typescript.ts
|
|
1300
|
-
import
|
|
1301
|
-
import
|
|
1379
|
+
import path6 from "node:path";
|
|
1380
|
+
import chalk26 from "chalk";
|
|
1302
1381
|
var packageCleanTypescript = () => {
|
|
1303
1382
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1304
1383
|
const pkgName = process.env.npm_package_name;
|
|
1305
|
-
console.log(
|
|
1306
|
-
const files = [
|
|
1384
|
+
console.log(chalk26.green(`Cleaning Typescript [${pkgName}]`));
|
|
1385
|
+
const files = [path6.join(pkg, "*.tsbuildinfo"), path6.join(pkg, ".tsconfig.*"), path6.join(pkg, ".eslintcache")];
|
|
1307
1386
|
for (let file of files) {
|
|
1308
1387
|
deleteGlob(file);
|
|
1309
1388
|
}
|
|
@@ -1316,19 +1395,19 @@ var packageClean = async () => {
|
|
|
1316
1395
|
};
|
|
1317
1396
|
|
|
1318
1397
|
// src/actions/package/compile/compile.ts
|
|
1319
|
-
import
|
|
1398
|
+
import chalk30 from "chalk";
|
|
1320
1399
|
|
|
1321
1400
|
// src/actions/package/publint.ts
|
|
1322
|
-
import { promises as
|
|
1323
|
-
import
|
|
1401
|
+
import { promises as fs4 } from "node:fs";
|
|
1402
|
+
import chalk27 from "chalk";
|
|
1324
1403
|
import sortPackageJson from "sort-package-json";
|
|
1325
1404
|
var packagePublint = async (params) => {
|
|
1326
1405
|
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(
|
|
1406
|
+
const sortedPkg = sortPackageJson(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
1407
|
+
await fs4.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
1408
|
+
const pkg = JSON.parse(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
1409
|
+
console.log(chalk27.green(`Publint: ${pkg.name}`));
|
|
1410
|
+
console.log(chalk27.gray(pkgDir));
|
|
1332
1411
|
const { publint: publint2 } = await import("publint");
|
|
1333
1412
|
const { messages } = await publint2({
|
|
1334
1413
|
level: "suggestion",
|
|
@@ -1343,21 +1422,21 @@ var packagePublint = async (params) => {
|
|
|
1343
1422
|
for (const message of validMessages) {
|
|
1344
1423
|
switch (message.type) {
|
|
1345
1424
|
case "error": {
|
|
1346
|
-
console.error(
|
|
1425
|
+
console.error(chalk27.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1347
1426
|
break;
|
|
1348
1427
|
}
|
|
1349
1428
|
case "warning": {
|
|
1350
|
-
console.warn(
|
|
1429
|
+
console.warn(chalk27.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1351
1430
|
break;
|
|
1352
1431
|
}
|
|
1353
1432
|
default: {
|
|
1354
|
-
console.log(
|
|
1433
|
+
console.log(chalk27.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1355
1434
|
break;
|
|
1356
1435
|
}
|
|
1357
1436
|
}
|
|
1358
1437
|
}
|
|
1359
1438
|
if (params?.verbose) {
|
|
1360
|
-
console.log(
|
|
1439
|
+
console.log(chalk27.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
|
|
1361
1440
|
}
|
|
1362
1441
|
return validMessages.filter((message) => message.type === "error").length;
|
|
1363
1442
|
};
|
|
@@ -1394,7 +1473,7 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1394
1473
|
|
|
1395
1474
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1396
1475
|
import { cwd } from "node:process";
|
|
1397
|
-
import
|
|
1476
|
+
import chalk28 from "chalk";
|
|
1398
1477
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1399
1478
|
import {
|
|
1400
1479
|
DiagnosticCategory,
|
|
@@ -1449,7 +1528,7 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1449
1528
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1450
1529
|
const excludes = [".stories.", ".spec."];
|
|
1451
1530
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
|
|
1452
|
-
console.log(
|
|
1531
|
+
console.log(chalk28.green(`Compiling Types ${pkg}: ${files.length}`));
|
|
1453
1532
|
if (files.length > 0) {
|
|
1454
1533
|
const program = createProgramFromConfig({
|
|
1455
1534
|
basePath: pkg ?? cwd(),
|
|
@@ -1506,7 +1585,7 @@ function deepMergeObjects(objects) {
|
|
|
1506
1585
|
|
|
1507
1586
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1508
1587
|
import { cwd as cwd2 } from "node:process";
|
|
1509
|
-
import
|
|
1588
|
+
import chalk29 from "chalk";
|
|
1510
1589
|
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1511
1590
|
import {
|
|
1512
1591
|
DiagnosticCategory as DiagnosticCategory2,
|
|
@@ -1532,7 +1611,7 @@ var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) =>
|
|
|
1532
1611
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1533
1612
|
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1534
1613
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1535
|
-
console.log(
|
|
1614
|
+
console.log(chalk29.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1536
1615
|
if (files.length > 0) {
|
|
1537
1616
|
const program = createProgramFromConfig2({
|
|
1538
1617
|
basePath: pkg ?? cwd2(),
|
|
@@ -1683,7 +1762,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1683
1762
|
// src/actions/package/compile/compile.ts
|
|
1684
1763
|
var packageCompile = async (inConfig = {}) => {
|
|
1685
1764
|
const pkg = process.env.INIT_CWD;
|
|
1686
|
-
console.log(
|
|
1765
|
+
console.log(chalk30.green(`Compiling ${pkg}`));
|
|
1687
1766
|
const config2 = await loadConfig(inConfig);
|
|
1688
1767
|
const publint2 = config2.publint;
|
|
1689
1768
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1694,8 +1773,8 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1694
1773
|
};
|
|
1695
1774
|
|
|
1696
1775
|
// src/actions/package/copy-assets.ts
|
|
1697
|
-
import
|
|
1698
|
-
import
|
|
1776
|
+
import path7 from "node:path/posix";
|
|
1777
|
+
import chalk31 from "chalk";
|
|
1699
1778
|
import cpy2 from "cpy";
|
|
1700
1779
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1701
1780
|
try {
|
|
@@ -1703,12 +1782,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1703
1782
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1704
1783
|
`../dist/${target}`,
|
|
1705
1784
|
{
|
|
1706
|
-
cwd:
|
|
1785
|
+
cwd: path7.join(location, "src"),
|
|
1707
1786
|
flat: false
|
|
1708
1787
|
}
|
|
1709
1788
|
);
|
|
1710
1789
|
if (values.length > 0) {
|
|
1711
|
-
console.log(
|
|
1790
|
+
console.log(chalk31.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1712
1791
|
}
|
|
1713
1792
|
for (const value of values) {
|
|
1714
1793
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -1776,8 +1855,8 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1776
1855
|
|
|
1777
1856
|
// src/actions/package/gen-docs.ts
|
|
1778
1857
|
import { existsSync as existsSync5 } from "node:fs";
|
|
1779
|
-
import
|
|
1780
|
-
import
|
|
1858
|
+
import path8 from "node:path";
|
|
1859
|
+
import chalk32 from "chalk";
|
|
1781
1860
|
import {
|
|
1782
1861
|
Application,
|
|
1783
1862
|
ArgumentsReader,
|
|
@@ -1795,7 +1874,7 @@ var ExitCodes = {
|
|
|
1795
1874
|
};
|
|
1796
1875
|
var packageGenDocs = async () => {
|
|
1797
1876
|
const pkg = process.env.INIT_CWD;
|
|
1798
|
-
if (pkg && !existsSync5(
|
|
1877
|
+
if (pkg && !existsSync5(path8.join(pkg, "typedoc.json"))) {
|
|
1799
1878
|
return;
|
|
1800
1879
|
}
|
|
1801
1880
|
const app = await Application.bootstrap({
|
|
@@ -1881,16 +1960,16 @@ var runTypeDoc = async (app) => {
|
|
|
1881
1960
|
return ExitCodes.OutputError;
|
|
1882
1961
|
}
|
|
1883
1962
|
}
|
|
1884
|
-
console.log(
|
|
1963
|
+
console.log(chalk32.green(`${pkgName} - Ok`));
|
|
1885
1964
|
return ExitCodes.Ok;
|
|
1886
1965
|
};
|
|
1887
1966
|
|
|
1888
1967
|
// src/actions/package/lint.ts
|
|
1889
1968
|
import { readdirSync } from "node:fs";
|
|
1890
|
-
import
|
|
1969
|
+
import path9 from "node:path";
|
|
1891
1970
|
import { cwd as cwd3 } from "node:process";
|
|
1892
1971
|
import { pathToFileURL } from "node:url";
|
|
1893
|
-
import
|
|
1972
|
+
import chalk33 from "chalk";
|
|
1894
1973
|
import { ESLint } from "eslint";
|
|
1895
1974
|
import { findUp } from "find-up";
|
|
1896
1975
|
import picomatch from "picomatch";
|
|
@@ -1899,14 +1978,14 @@ var dumpMessages = (lintResults) => {
|
|
|
1899
1978
|
const severity = ["none", "warning", "error"];
|
|
1900
1979
|
for (const lintResult of lintResults) {
|
|
1901
1980
|
if (lintResult.messages.length > 0) {
|
|
1902
|
-
console.log(
|
|
1981
|
+
console.log(chalk33.gray(`
|
|
1903
1982
|
${lintResult.filePath}`));
|
|
1904
1983
|
for (const message of lintResult.messages) {
|
|
1905
1984
|
console.log(
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1985
|
+
chalk33.gray(` ${message.line}:${message.column}`),
|
|
1986
|
+
chalk33[colors[message.severity]](` ${severity[message.severity]}`),
|
|
1987
|
+
chalk33.white(` ${message.message}`),
|
|
1988
|
+
chalk33.gray(` ${message.ruleId}`)
|
|
1910
1989
|
);
|
|
1911
1990
|
}
|
|
1912
1991
|
}
|
|
@@ -1924,7 +2003,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1924
2003
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1925
2004
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1926
2005
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1927
|
-
const res =
|
|
2006
|
+
const res = path9.resolve(dir, dirent.name);
|
|
1928
2007
|
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
|
|
1929
2008
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1930
2009
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -1945,7 +2024,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1945
2024
|
});
|
|
1946
2025
|
const files = getFiles(cwd3(), ignoreFolders);
|
|
1947
2026
|
if (verbose) {
|
|
1948
|
-
console.log(
|
|
2027
|
+
console.log(chalk33.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
1949
2028
|
}
|
|
1950
2029
|
const lintResults = await engine.lintFiles(files);
|
|
1951
2030
|
dumpMessages(lintResults);
|
|
@@ -1955,7 +2034,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1955
2034
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
1956
2035
|
const lintTime = Date.now() - start;
|
|
1957
2036
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
1958
|
-
console.log(
|
|
2037
|
+
console.log(chalk33.white(`Linted ${chalk33[filesCountColor](files.length)} files in ${chalk33[lintTimeColor](lintTime)}ms`));
|
|
1959
2038
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1960
2039
|
};
|
|
1961
2040
|
|
|
@@ -1985,7 +2064,7 @@ var rebuild = ({ target }) => {
|
|
|
1985
2064
|
};
|
|
1986
2065
|
|
|
1987
2066
|
// src/actions/recompile.ts
|
|
1988
|
-
import
|
|
2067
|
+
import chalk34 from "chalk";
|
|
1989
2068
|
var recompile = async ({
|
|
1990
2069
|
verbose,
|
|
1991
2070
|
target,
|
|
@@ -2021,7 +2100,7 @@ var recompileAll = async ({
|
|
|
2021
2100
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2022
2101
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2023
2102
|
if (jobs) {
|
|
2024
|
-
console.log(
|
|
2103
|
+
console.log(chalk34.blue(`Jobs set to [${jobs}]`));
|
|
2025
2104
|
}
|
|
2026
2105
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2027
2106
|
[
|
|
@@ -2052,7 +2131,7 @@ var recompileAll = async ({
|
|
|
2052
2131
|
]
|
|
2053
2132
|
]);
|
|
2054
2133
|
console.log(
|
|
2055
|
-
`${
|
|
2134
|
+
`${chalk34.gray("Recompiled in")} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`
|
|
2056
2135
|
);
|
|
2057
2136
|
return result;
|
|
2058
2137
|
};
|
|
@@ -2083,9 +2162,9 @@ var reinstall = () => {
|
|
|
2083
2162
|
};
|
|
2084
2163
|
|
|
2085
2164
|
// src/actions/relint.ts
|
|
2086
|
-
import
|
|
2165
|
+
import chalk35 from "chalk";
|
|
2087
2166
|
var relintPackage = ({ pkg }) => {
|
|
2088
|
-
console.log(
|
|
2167
|
+
console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
|
|
2089
2168
|
const start = Date.now();
|
|
2090
2169
|
const result = runSteps("Relint [All-Packages]", [
|
|
2091
2170
|
["yarn", [
|
|
@@ -2095,7 +2174,7 @@ var relintPackage = ({ pkg }) => {
|
|
|
2095
2174
|
"package-relint"
|
|
2096
2175
|
]]
|
|
2097
2176
|
]);
|
|
2098
|
-
console.log(
|
|
2177
|
+
console.log(chalk35.gray(`${"Relinted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
|
|
2099
2178
|
return result;
|
|
2100
2179
|
};
|
|
2101
2180
|
var relint = ({
|
|
@@ -2106,7 +2185,7 @@ var relint = ({
|
|
|
2106
2185
|
return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
|
|
2107
2186
|
};
|
|
2108
2187
|
var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
2109
|
-
console.log(
|
|
2188
|
+
console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
|
|
2110
2189
|
const start = Date.now();
|
|
2111
2190
|
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
2112
2191
|
const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
|
|
@@ -2120,7 +2199,7 @@ var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
|
2120
2199
|
"package-relint"
|
|
2121
2200
|
]]
|
|
2122
2201
|
]);
|
|
2123
|
-
console.log(
|
|
2202
|
+
console.log(chalk35.gray(`Relinted in [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
|
|
2124
2203
|
return result;
|
|
2125
2204
|
};
|
|
2126
2205
|
|
|
@@ -2138,10 +2217,10 @@ var sonar = () => {
|
|
|
2138
2217
|
};
|
|
2139
2218
|
|
|
2140
2219
|
// src/actions/statics.ts
|
|
2141
|
-
import
|
|
2220
|
+
import chalk36 from "chalk";
|
|
2142
2221
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2143
2222
|
var statics = () => {
|
|
2144
|
-
console.log(
|
|
2223
|
+
console.log(chalk36.green("Check Required Static Dependencies"));
|
|
2145
2224
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2146
2225
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2147
2226
|
};
|
|
@@ -2198,7 +2277,7 @@ var loadPackageConfig = async () => {
|
|
|
2198
2277
|
};
|
|
2199
2278
|
|
|
2200
2279
|
// src/xy/xy.ts
|
|
2201
|
-
import
|
|
2280
|
+
import chalk38 from "chalk";
|
|
2202
2281
|
|
|
2203
2282
|
// src/xy/xyBuildCommands.ts
|
|
2204
2283
|
var xyBuildCommands = (args) => {
|
|
@@ -2317,7 +2396,7 @@ var xyBuildCommands = (args) => {
|
|
|
2317
2396
|
|
|
2318
2397
|
// src/xy/param.ts
|
|
2319
2398
|
var packagePositionalParam = (yargs2) => {
|
|
2320
|
-
return yargs2.positional("package", { describe: "Specific package to target" });
|
|
2399
|
+
return yargs2.positional("package", { describe: "Specific package to target", type: "string" });
|
|
2321
2400
|
};
|
|
2322
2401
|
|
|
2323
2402
|
// src/xy/xyCommonCommands.ts
|
|
@@ -2559,7 +2638,7 @@ var xyInstallCommands = (args) => {
|
|
|
2559
2638
|
};
|
|
2560
2639
|
|
|
2561
2640
|
// src/xy/xyLintCommands.ts
|
|
2562
|
-
import
|
|
2641
|
+
import chalk37 from "chalk";
|
|
2563
2642
|
var xyLintCommands = (args) => {
|
|
2564
2643
|
return args.command(
|
|
2565
2644
|
"cycle [package]",
|
|
@@ -2571,31 +2650,61 @@ var xyLintCommands = (args) => {
|
|
|
2571
2650
|
const start = Date.now();
|
|
2572
2651
|
if (argv.verbose) console.log("Cycle");
|
|
2573
2652
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
2574
|
-
console.log(
|
|
2653
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2575
2654
|
}
|
|
2576
2655
|
).command(
|
|
2577
2656
|
"lint [package]",
|
|
2578
2657
|
"Lint - Run Eslint",
|
|
2579
2658
|
(yargs2) => {
|
|
2580
|
-
return packagePositionalParam(yargs2)
|
|
2659
|
+
return packagePositionalParam(yargs2).option("fix", {
|
|
2660
|
+
alias: "f",
|
|
2661
|
+
default: false,
|
|
2662
|
+
description: "Fix fixable issues",
|
|
2663
|
+
type: "boolean"
|
|
2664
|
+
}).option("cache", {
|
|
2665
|
+
alias: "c",
|
|
2666
|
+
default: false,
|
|
2667
|
+
description: "Use caching for performance",
|
|
2668
|
+
type: "boolean"
|
|
2669
|
+
});
|
|
2581
2670
|
},
|
|
2582
2671
|
(argv) => {
|
|
2583
2672
|
if (argv.verbose) console.log("Lint");
|
|
2584
2673
|
const start = Date.now();
|
|
2585
|
-
process.exitCode = argv.fix ? fix({ pkg: argv.package }) : lint({ pkg: argv.package });
|
|
2586
|
-
console.log(
|
|
2674
|
+
process.exitCode = argv.fix ? fix({ pkg: argv.package, cache: argv.cache }) : lint({ pkg: argv.package, cache: argv.cache });
|
|
2675
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2587
2676
|
}
|
|
2588
2677
|
).command(
|
|
2589
2678
|
"deplint [package]",
|
|
2590
2679
|
"Deplint - Run Deplint",
|
|
2591
2680
|
(yargs2) => {
|
|
2592
|
-
return packagePositionalParam(yargs2)
|
|
2681
|
+
return packagePositionalParam(yargs2).option("deps", {
|
|
2682
|
+
alias: "d",
|
|
2683
|
+
default: false,
|
|
2684
|
+
description: "Check dependencies",
|
|
2685
|
+
type: "boolean"
|
|
2686
|
+
}).option("devDeps", {
|
|
2687
|
+
alias: "v",
|
|
2688
|
+
default: false,
|
|
2689
|
+
description: "Check devDependencies",
|
|
2690
|
+
type: "boolean"
|
|
2691
|
+
}).option("peerDeps", {
|
|
2692
|
+
alias: "p",
|
|
2693
|
+
default: false,
|
|
2694
|
+
description: "Check peerDependencies",
|
|
2695
|
+
type: "boolean"
|
|
2696
|
+
});
|
|
2593
2697
|
},
|
|
2594
2698
|
(argv) => {
|
|
2595
2699
|
if (argv.verbose) console.log("Deplint");
|
|
2596
2700
|
const start = Date.now();
|
|
2597
|
-
process.exitCode = deplint({
|
|
2598
|
-
|
|
2701
|
+
process.exitCode = deplint({
|
|
2702
|
+
pkg: argv.package,
|
|
2703
|
+
deps: !!argv.deps,
|
|
2704
|
+
devDeps: !!argv.devDeps,
|
|
2705
|
+
peerDeps: !!argv.peerDeps
|
|
2706
|
+
});
|
|
2707
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2599
2708
|
}
|
|
2600
2709
|
).command(
|
|
2601
2710
|
"fix [package]",
|
|
@@ -2607,7 +2716,7 @@ var xyLintCommands = (args) => {
|
|
|
2607
2716
|
const start = Date.now();
|
|
2608
2717
|
if (argv.verbose) console.log("Fix");
|
|
2609
2718
|
process.exitCode = fix();
|
|
2610
|
-
console.log(
|
|
2719
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2611
2720
|
}
|
|
2612
2721
|
).command(
|
|
2613
2722
|
"relint [package]",
|
|
@@ -2619,7 +2728,7 @@ var xyLintCommands = (args) => {
|
|
|
2619
2728
|
if (argv.verbose) console.log("Relinting");
|
|
2620
2729
|
const start = Date.now();
|
|
2621
2730
|
process.exitCode = relint();
|
|
2622
|
-
console.log(
|
|
2731
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2623
2732
|
}
|
|
2624
2733
|
).command(
|
|
2625
2734
|
"publint [package]",
|
|
@@ -2631,7 +2740,7 @@ var xyLintCommands = (args) => {
|
|
|
2631
2740
|
if (argv.verbose) console.log("Publint");
|
|
2632
2741
|
const start = Date.now();
|
|
2633
2742
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
2634
|
-
console.log(
|
|
2743
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2635
2744
|
}
|
|
2636
2745
|
).command(
|
|
2637
2746
|
"knip",
|
|
@@ -2643,7 +2752,7 @@ var xyLintCommands = (args) => {
|
|
|
2643
2752
|
if (argv.verbose) console.log("Knip");
|
|
2644
2753
|
const start = Date.now();
|
|
2645
2754
|
process.exitCode = knip();
|
|
2646
|
-
console.log(
|
|
2755
|
+
console.log(chalk37.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
2647
2756
|
}
|
|
2648
2757
|
).command(
|
|
2649
2758
|
"sonar",
|
|
@@ -2655,7 +2764,7 @@ var xyLintCommands = (args) => {
|
|
|
2655
2764
|
const start = Date.now();
|
|
2656
2765
|
if (argv.verbose) console.log("Sonar Check");
|
|
2657
2766
|
process.exitCode = sonar();
|
|
2658
|
-
console.log(
|
|
2767
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2659
2768
|
}
|
|
2660
2769
|
);
|
|
2661
2770
|
};
|
|
@@ -2674,37 +2783,16 @@ var xyParseOptions = () => {
|
|
|
2674
2783
|
default: false,
|
|
2675
2784
|
description: "Run with verbose logging",
|
|
2676
2785
|
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
2786
|
}).option("incremental", {
|
|
2684
2787
|
alias: "i",
|
|
2685
2788
|
default: false,
|
|
2686
2789
|
description: "Attempt to perform the action only on changed packages",
|
|
2687
2790
|
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
2791
|
}).option("profile", {
|
|
2699
2792
|
alias: "p",
|
|
2700
2793
|
default: false,
|
|
2701
2794
|
description: "Profile action",
|
|
2702
2795
|
type: "boolean"
|
|
2703
|
-
}).option("types", {
|
|
2704
|
-
default: "tsc",
|
|
2705
|
-
choices: ["tsc", "tsup"],
|
|
2706
|
-
description: "Tool to generate Typescript types",
|
|
2707
|
-
type: "string"
|
|
2708
2796
|
});
|
|
2709
2797
|
};
|
|
2710
2798
|
|
|
@@ -2712,8 +2800,8 @@ var xyParseOptions = () => {
|
|
|
2712
2800
|
var xy = async () => {
|
|
2713
2801
|
const options = xyParseOptions();
|
|
2714
2802
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
2715
|
-
console.error(
|
|
2716
|
-
console.log(
|
|
2803
|
+
console.error(chalk38.yellow(`Command not found [${chalk38.magenta(process.argv[2])}]`));
|
|
2804
|
+
console.log(chalk38.gray("Try 'yarn xy --help' for list of commands"));
|
|
2717
2805
|
}).version().help().argv;
|
|
2718
2806
|
};
|
|
2719
2807
|
export {
|