@xylabs/ts-scripts-yarn3 6.4.6 → 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/deploy-major.mjs +31 -3
- package/dist/actions/deploy-major.mjs.map +1 -1
- package/dist/actions/deploy-minor.mjs +31 -3
- package/dist/actions/deploy-minor.mjs.map +1 -1
- package/dist/actions/deploy-next.mjs +31 -3
- package/dist/actions/deploy-next.mjs.map +1 -1
- package/dist/actions/deploy.mjs +31 -3
- package/dist/actions/deploy.mjs.map +1 -1
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/index.mjs +295 -164
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/bin/xy.mjs +299 -159
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +342 -202
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +299 -159
- 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 +299 -159
- 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/xyDeployCommands.mjs +74 -6
- package/dist/xy/xyDeployCommands.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 +5 -5
- 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,132 +923,237 @@ 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;
|
|
967
1042
|
};
|
|
968
1043
|
|
|
969
1044
|
// src/actions/deploy.ts
|
|
1045
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
1046
|
+
var privatePackageExcludeList = () => {
|
|
1047
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1048
|
+
workspace,
|
|
1049
|
+
JSON.parse(readFileSync5(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1050
|
+
]);
|
|
1051
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1052
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
1053
|
+
return excludeList;
|
|
1054
|
+
};
|
|
970
1055
|
var deploy = () => {
|
|
1056
|
+
const excludeList = privatePackageExcludeList();
|
|
1057
|
+
if (excludeList.length > 0) {
|
|
1058
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
1059
|
+
}
|
|
971
1060
|
return runSteps("Deploy [Patch]", [
|
|
972
1061
|
["yarn", "workspaces foreach --all version patch --deferred"],
|
|
973
1062
|
["yarn", "xy clean"],
|
|
974
1063
|
["yarn", "xy build"],
|
|
975
1064
|
["yarn", "version apply --all"],
|
|
976
|
-
["yarn",
|
|
1065
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
|
|
977
1066
|
]);
|
|
978
1067
|
};
|
|
979
1068
|
|
|
980
1069
|
// src/actions/deploy-major.ts
|
|
1070
|
+
import { readFileSync as readFileSync6 } from "node:fs";
|
|
1071
|
+
var privatePackageExcludeList2 = () => {
|
|
1072
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1073
|
+
workspace,
|
|
1074
|
+
JSON.parse(readFileSync6(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1075
|
+
]);
|
|
1076
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1077
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
1078
|
+
return excludeList;
|
|
1079
|
+
};
|
|
981
1080
|
var deployMajor = () => {
|
|
1081
|
+
const excludeList = privatePackageExcludeList2();
|
|
1082
|
+
if (excludeList.length > 0) {
|
|
1083
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
1084
|
+
}
|
|
982
1085
|
return runSteps("Deploy [Major]", [
|
|
983
1086
|
["yarn", "workspaces foreach --all version major --deferred"],
|
|
984
1087
|
["yarn", "xy clean"],
|
|
985
1088
|
["yarn", "xy build"],
|
|
986
1089
|
["yarn", "version apply --all"],
|
|
987
|
-
["yarn",
|
|
1090
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
|
|
988
1091
|
]);
|
|
989
1092
|
};
|
|
990
1093
|
|
|
991
1094
|
// src/actions/deploy-minor.ts
|
|
1095
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
1096
|
+
var privatePackageExcludeList3 = () => {
|
|
1097
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1098
|
+
workspace,
|
|
1099
|
+
JSON.parse(readFileSync7(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1100
|
+
]);
|
|
1101
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1102
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
1103
|
+
return excludeList;
|
|
1104
|
+
};
|
|
992
1105
|
var deployMinor = () => {
|
|
1106
|
+
const excludeList = privatePackageExcludeList3();
|
|
1107
|
+
if (excludeList.length > 0) {
|
|
1108
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
1109
|
+
}
|
|
993
1110
|
return runSteps("Deploy [Minor]", [
|
|
994
1111
|
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
995
1112
|
["yarn", "xy clean"],
|
|
996
1113
|
["yarn", "xy build"],
|
|
997
1114
|
["yarn", "version apply --all"],
|
|
998
|
-
["yarn",
|
|
1115
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
|
|
999
1116
|
]);
|
|
1000
1117
|
};
|
|
1001
1118
|
|
|
1002
1119
|
// src/actions/deploy-next.ts
|
|
1120
|
+
import { readFileSync as readFileSync8 } from "node:fs";
|
|
1121
|
+
var privatePackageExcludeList4 = () => {
|
|
1122
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1123
|
+
workspace,
|
|
1124
|
+
JSON.parse(readFileSync8(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1125
|
+
]);
|
|
1126
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1127
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
1128
|
+
return excludeList;
|
|
1129
|
+
};
|
|
1003
1130
|
var deployNext = () => {
|
|
1131
|
+
const excludeList = privatePackageExcludeList4();
|
|
1132
|
+
if (excludeList.length > 0) {
|
|
1133
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
1134
|
+
}
|
|
1004
1135
|
return runSteps("Deploy [Next]", [
|
|
1005
1136
|
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
1006
1137
|
["yarn", "xy clean"],
|
|
1007
1138
|
["yarn", "xy build"],
|
|
1008
1139
|
["yarn", "version apply --all --prerelease"],
|
|
1009
|
-
["yarn",
|
|
1140
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish --tag next`]
|
|
1010
1141
|
]);
|
|
1011
1142
|
};
|
|
1012
1143
|
|
|
1013
1144
|
// src/actions/dupdeps.ts
|
|
1014
|
-
import
|
|
1145
|
+
import chalk20 from "chalk";
|
|
1015
1146
|
var dupdeps = () => {
|
|
1016
|
-
console.log(
|
|
1147
|
+
console.log(chalk20.green("Checking all Dependencies for Duplicates"));
|
|
1017
1148
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1018
1149
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1019
1150
|
return detectDuplicateDependencies(dependencies);
|
|
1020
1151
|
};
|
|
1021
1152
|
|
|
1022
1153
|
// src/actions/lint.ts
|
|
1023
|
-
import
|
|
1154
|
+
import chalk21 from "chalk";
|
|
1024
1155
|
var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
1025
|
-
console.log(
|
|
1156
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1026
1157
|
const start = Date.now();
|
|
1027
1158
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1028
1159
|
["yarn", [
|
|
@@ -1032,7 +1163,7 @@ var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
|
1032
1163
|
fix2 ? "package-fix" : "package-lint"
|
|
1033
1164
|
]]
|
|
1034
1165
|
]);
|
|
1035
|
-
console.log(
|
|
1166
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1036
1167
|
return result;
|
|
1037
1168
|
};
|
|
1038
1169
|
var lint = ({
|
|
@@ -1048,13 +1179,13 @@ var lint = ({
|
|
|
1048
1179
|
});
|
|
1049
1180
|
};
|
|
1050
1181
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1051
|
-
console.log(
|
|
1182
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1052
1183
|
const start = Date.now();
|
|
1053
1184
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1054
1185
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1055
1186
|
["yarn", ["eslint", ...fixOptions]]
|
|
1056
1187
|
]);
|
|
1057
|
-
console.log(
|
|
1188
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1058
1189
|
return result;
|
|
1059
1190
|
};
|
|
1060
1191
|
|
|
@@ -1082,7 +1213,7 @@ var filename = ".gitignore";
|
|
|
1082
1213
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1083
1214
|
|
|
1084
1215
|
// src/actions/gitlint.ts
|
|
1085
|
-
import
|
|
1216
|
+
import chalk22 from "chalk";
|
|
1086
1217
|
import ParseGitConfig from "parse-git-config";
|
|
1087
1218
|
var gitlint = () => {
|
|
1088
1219
|
console.log(`
|
|
@@ -1093,7 +1224,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1093
1224
|
const errors = 0;
|
|
1094
1225
|
const gitConfig = ParseGitConfig.sync();
|
|
1095
1226
|
const warn = (message) => {
|
|
1096
|
-
console.warn(
|
|
1227
|
+
console.warn(chalk22.yellow(`Warning: ${message}`));
|
|
1097
1228
|
warnings++;
|
|
1098
1229
|
};
|
|
1099
1230
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1113,13 +1244,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1113
1244
|
}
|
|
1114
1245
|
const resultMessages = [];
|
|
1115
1246
|
if (valid > 0) {
|
|
1116
|
-
resultMessages.push(
|
|
1247
|
+
resultMessages.push(chalk22.green(`Passed: ${valid}`));
|
|
1117
1248
|
}
|
|
1118
1249
|
if (warnings > 0) {
|
|
1119
|
-
resultMessages.push(
|
|
1250
|
+
resultMessages.push(chalk22.yellow(`Warnings: ${warnings}`));
|
|
1120
1251
|
}
|
|
1121
1252
|
if (errors > 0) {
|
|
1122
|
-
resultMessages.push(
|
|
1253
|
+
resultMessages.push(chalk22.red(` Errors: ${errors}`));
|
|
1123
1254
|
}
|
|
1124
1255
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1125
1256
|
`);
|
|
@@ -1128,7 +1259,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1128
1259
|
|
|
1129
1260
|
// src/actions/gitlint-fix.ts
|
|
1130
1261
|
import { execSync as execSync2 } from "node:child_process";
|
|
1131
|
-
import
|
|
1262
|
+
import chalk23 from "chalk";
|
|
1132
1263
|
import ParseGitConfig2 from "parse-git-config";
|
|
1133
1264
|
var gitlintFix = () => {
|
|
1134
1265
|
console.log(`
|
|
@@ -1137,15 +1268,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1137
1268
|
const gitConfig = ParseGitConfig2.sync();
|
|
1138
1269
|
if (gitConfig.core.ignorecase) {
|
|
1139
1270
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1140
|
-
console.warn(
|
|
1271
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1141
1272
|
}
|
|
1142
1273
|
if (gitConfig.core.autocrlf !== false) {
|
|
1143
1274
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1144
|
-
console.warn(
|
|
1275
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1145
1276
|
}
|
|
1146
1277
|
if (gitConfig.core.eol !== "lf") {
|
|
1147
1278
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1148
|
-
console.warn(
|
|
1279
|
+
console.warn(chalk23.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1149
1280
|
}
|
|
1150
1281
|
return 1;
|
|
1151
1282
|
};
|
|
@@ -1156,7 +1287,7 @@ var knip = () => {
|
|
|
1156
1287
|
};
|
|
1157
1288
|
|
|
1158
1289
|
// src/actions/license.ts
|
|
1159
|
-
import
|
|
1290
|
+
import chalk24 from "chalk";
|
|
1160
1291
|
import { init } from "license-checker";
|
|
1161
1292
|
var license = async (pkg) => {
|
|
1162
1293
|
const workspaces = yarnWorkspaces();
|
|
@@ -1181,18 +1312,18 @@ var license = async (pkg) => {
|
|
|
1181
1312
|
"LGPL-3.0-or-later",
|
|
1182
1313
|
"Python-2.0"
|
|
1183
1314
|
]);
|
|
1184
|
-
console.log(
|
|
1315
|
+
console.log(chalk24.green("License Checker"));
|
|
1185
1316
|
return (await Promise.all(
|
|
1186
1317
|
workspaceList.map(({ location, name }) => {
|
|
1187
1318
|
return new Promise((resolve) => {
|
|
1188
1319
|
init({ production: true, start: location }, (error, packages) => {
|
|
1189
1320
|
if (error) {
|
|
1190
|
-
console.error(
|
|
1191
|
-
console.error(
|
|
1321
|
+
console.error(chalk24.red(`License Checker [${name}] Error`));
|
|
1322
|
+
console.error(chalk24.gray(error));
|
|
1192
1323
|
console.log("\n");
|
|
1193
1324
|
resolve(1);
|
|
1194
1325
|
} else {
|
|
1195
|
-
console.log(
|
|
1326
|
+
console.log(chalk24.green(`License Checker [${name}]`));
|
|
1196
1327
|
let count = 0;
|
|
1197
1328
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1198
1329
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1208,7 +1339,7 @@ var license = async (pkg) => {
|
|
|
1208
1339
|
}
|
|
1209
1340
|
if (!orLicenseFound) {
|
|
1210
1341
|
count++;
|
|
1211
|
-
console.warn(
|
|
1342
|
+
console.warn(chalk24.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1212
1343
|
}
|
|
1213
1344
|
}
|
|
1214
1345
|
}
|
|
@@ -1227,13 +1358,13 @@ var filename2 = ".npmignore";
|
|
|
1227
1358
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1228
1359
|
|
|
1229
1360
|
// src/actions/package/clean-outputs.ts
|
|
1230
|
-
import
|
|
1231
|
-
import
|
|
1361
|
+
import path5 from "node:path";
|
|
1362
|
+
import chalk25 from "chalk";
|
|
1232
1363
|
var packageCleanOutputs = () => {
|
|
1233
1364
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1234
1365
|
const pkgName = process.env.npm_package_name;
|
|
1235
|
-
const folders = [
|
|
1236
|
-
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}]`));
|
|
1237
1368
|
for (let folder of folders) {
|
|
1238
1369
|
deleteGlob(folder);
|
|
1239
1370
|
}
|
|
@@ -1241,13 +1372,13 @@ var packageCleanOutputs = () => {
|
|
|
1241
1372
|
};
|
|
1242
1373
|
|
|
1243
1374
|
// src/actions/package/clean-typescript.ts
|
|
1244
|
-
import
|
|
1245
|
-
import
|
|
1375
|
+
import path6 from "node:path";
|
|
1376
|
+
import chalk26 from "chalk";
|
|
1246
1377
|
var packageCleanTypescript = () => {
|
|
1247
1378
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1248
1379
|
const pkgName = process.env.npm_package_name;
|
|
1249
|
-
console.log(
|
|
1250
|
-
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")];
|
|
1251
1382
|
for (let file of files) {
|
|
1252
1383
|
deleteGlob(file);
|
|
1253
1384
|
}
|
|
@@ -1260,19 +1391,19 @@ var packageClean = async () => {
|
|
|
1260
1391
|
};
|
|
1261
1392
|
|
|
1262
1393
|
// src/actions/package/compile/compile.ts
|
|
1263
|
-
import
|
|
1394
|
+
import chalk30 from "chalk";
|
|
1264
1395
|
|
|
1265
1396
|
// src/actions/package/publint.ts
|
|
1266
|
-
import { promises as
|
|
1267
|
-
import
|
|
1397
|
+
import { promises as fs4 } from "node:fs";
|
|
1398
|
+
import chalk27 from "chalk";
|
|
1268
1399
|
import sortPackageJson from "sort-package-json";
|
|
1269
1400
|
var packagePublint = async (params) => {
|
|
1270
1401
|
const pkgDir = process.env.INIT_CWD;
|
|
1271
|
-
const sortedPkg = sortPackageJson(await
|
|
1272
|
-
await
|
|
1273
|
-
const pkg = JSON.parse(await
|
|
1274
|
-
console.log(
|
|
1275
|
-
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));
|
|
1276
1407
|
const { publint: publint2 } = await import("publint");
|
|
1277
1408
|
const { messages } = await publint2({
|
|
1278
1409
|
level: "suggestion",
|
|
@@ -1287,21 +1418,21 @@ var packagePublint = async (params) => {
|
|
|
1287
1418
|
for (const message of validMessages) {
|
|
1288
1419
|
switch (message.type) {
|
|
1289
1420
|
case "error": {
|
|
1290
|
-
console.error(
|
|
1421
|
+
console.error(chalk27.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1291
1422
|
break;
|
|
1292
1423
|
}
|
|
1293
1424
|
case "warning": {
|
|
1294
|
-
console.warn(
|
|
1425
|
+
console.warn(chalk27.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1295
1426
|
break;
|
|
1296
1427
|
}
|
|
1297
1428
|
default: {
|
|
1298
|
-
console.log(
|
|
1429
|
+
console.log(chalk27.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1299
1430
|
break;
|
|
1300
1431
|
}
|
|
1301
1432
|
}
|
|
1302
1433
|
}
|
|
1303
1434
|
if (params?.verbose) {
|
|
1304
|
-
console.log(
|
|
1435
|
+
console.log(chalk27.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
|
|
1305
1436
|
}
|
|
1306
1437
|
return validMessages.filter((message) => message.type === "error").length;
|
|
1307
1438
|
};
|
|
@@ -1338,7 +1469,7 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1338
1469
|
|
|
1339
1470
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1340
1471
|
import { cwd } from "node:process";
|
|
1341
|
-
import
|
|
1472
|
+
import chalk28 from "chalk";
|
|
1342
1473
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1343
1474
|
import {
|
|
1344
1475
|
DiagnosticCategory,
|
|
@@ -1393,7 +1524,7 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1393
1524
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1394
1525
|
const excludes = [".stories.", ".spec."];
|
|
1395
1526
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
|
|
1396
|
-
console.log(
|
|
1527
|
+
console.log(chalk28.green(`Compiling Types ${pkg}: ${files.length}`));
|
|
1397
1528
|
if (files.length > 0) {
|
|
1398
1529
|
const program = createProgramFromConfig({
|
|
1399
1530
|
basePath: pkg ?? cwd(),
|
|
@@ -1450,7 +1581,7 @@ function deepMergeObjects(objects) {
|
|
|
1450
1581
|
|
|
1451
1582
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1452
1583
|
import { cwd as cwd2 } from "node:process";
|
|
1453
|
-
import
|
|
1584
|
+
import chalk29 from "chalk";
|
|
1454
1585
|
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1455
1586
|
import {
|
|
1456
1587
|
DiagnosticCategory as DiagnosticCategory2,
|
|
@@ -1476,7 +1607,7 @@ var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) =>
|
|
|
1476
1607
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1477
1608
|
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1478
1609
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1479
|
-
console.log(
|
|
1610
|
+
console.log(chalk29.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1480
1611
|
if (files.length > 0) {
|
|
1481
1612
|
const program = createProgramFromConfig2({
|
|
1482
1613
|
basePath: pkg ?? cwd2(),
|
|
@@ -1627,7 +1758,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1627
1758
|
// src/actions/package/compile/compile.ts
|
|
1628
1759
|
var packageCompile = async (inConfig = {}) => {
|
|
1629
1760
|
const pkg = process.env.INIT_CWD;
|
|
1630
|
-
console.log(
|
|
1761
|
+
console.log(chalk30.green(`Compiling ${pkg}`));
|
|
1631
1762
|
const config2 = await loadConfig(inConfig);
|
|
1632
1763
|
const publint2 = config2.publint;
|
|
1633
1764
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1638,8 +1769,8 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1638
1769
|
};
|
|
1639
1770
|
|
|
1640
1771
|
// src/actions/package/copy-assets.ts
|
|
1641
|
-
import
|
|
1642
|
-
import
|
|
1772
|
+
import path7 from "node:path/posix";
|
|
1773
|
+
import chalk31 from "chalk";
|
|
1643
1774
|
import cpy2 from "cpy";
|
|
1644
1775
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1645
1776
|
try {
|
|
@@ -1647,12 +1778,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1647
1778
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1648
1779
|
`../dist/${target}`,
|
|
1649
1780
|
{
|
|
1650
|
-
cwd:
|
|
1781
|
+
cwd: path7.join(location, "src"),
|
|
1651
1782
|
flat: false
|
|
1652
1783
|
}
|
|
1653
1784
|
);
|
|
1654
1785
|
if (values.length > 0) {
|
|
1655
|
-
console.log(
|
|
1786
|
+
console.log(chalk31.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1656
1787
|
}
|
|
1657
1788
|
for (const value of values) {
|
|
1658
1789
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -1720,8 +1851,8 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1720
1851
|
|
|
1721
1852
|
// src/actions/package/gen-docs.ts
|
|
1722
1853
|
import { existsSync as existsSync5 } from "node:fs";
|
|
1723
|
-
import
|
|
1724
|
-
import
|
|
1854
|
+
import path8 from "node:path";
|
|
1855
|
+
import chalk32 from "chalk";
|
|
1725
1856
|
import {
|
|
1726
1857
|
Application,
|
|
1727
1858
|
ArgumentsReader,
|
|
@@ -1739,7 +1870,7 @@ var ExitCodes = {
|
|
|
1739
1870
|
};
|
|
1740
1871
|
var packageGenDocs = async () => {
|
|
1741
1872
|
const pkg = process.env.INIT_CWD;
|
|
1742
|
-
if (pkg && !existsSync5(
|
|
1873
|
+
if (pkg && !existsSync5(path8.join(pkg, "typedoc.json"))) {
|
|
1743
1874
|
return;
|
|
1744
1875
|
}
|
|
1745
1876
|
const app = await Application.bootstrap({
|
|
@@ -1825,16 +1956,16 @@ var runTypeDoc = async (app) => {
|
|
|
1825
1956
|
return ExitCodes.OutputError;
|
|
1826
1957
|
}
|
|
1827
1958
|
}
|
|
1828
|
-
console.log(
|
|
1959
|
+
console.log(chalk32.green(`${pkgName} - Ok`));
|
|
1829
1960
|
return ExitCodes.Ok;
|
|
1830
1961
|
};
|
|
1831
1962
|
|
|
1832
1963
|
// src/actions/package/lint.ts
|
|
1833
1964
|
import { readdirSync } from "node:fs";
|
|
1834
|
-
import
|
|
1965
|
+
import path9 from "node:path";
|
|
1835
1966
|
import { cwd as cwd3 } from "node:process";
|
|
1836
1967
|
import { pathToFileURL } from "node:url";
|
|
1837
|
-
import
|
|
1968
|
+
import chalk33 from "chalk";
|
|
1838
1969
|
import { ESLint } from "eslint";
|
|
1839
1970
|
import { findUp } from "find-up";
|
|
1840
1971
|
import picomatch from "picomatch";
|
|
@@ -1843,14 +1974,14 @@ var dumpMessages = (lintResults) => {
|
|
|
1843
1974
|
const severity = ["none", "warning", "error"];
|
|
1844
1975
|
for (const lintResult of lintResults) {
|
|
1845
1976
|
if (lintResult.messages.length > 0) {
|
|
1846
|
-
console.log(
|
|
1977
|
+
console.log(chalk33.gray(`
|
|
1847
1978
|
${lintResult.filePath}`));
|
|
1848
1979
|
for (const message of lintResult.messages) {
|
|
1849
1980
|
console.log(
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
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}`)
|
|
1854
1985
|
);
|
|
1855
1986
|
}
|
|
1856
1987
|
}
|
|
@@ -1868,7 +1999,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1868
1999
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1869
2000
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1870
2001
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1871
|
-
const res =
|
|
2002
|
+
const res = path9.resolve(dir, dirent.name);
|
|
1872
2003
|
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
|
|
1873
2004
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1874
2005
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -1889,7 +2020,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1889
2020
|
});
|
|
1890
2021
|
const files = getFiles(cwd3(), ignoreFolders);
|
|
1891
2022
|
if (verbose) {
|
|
1892
|
-
console.log(
|
|
2023
|
+
console.log(chalk33.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
1893
2024
|
}
|
|
1894
2025
|
const lintResults = await engine.lintFiles(files);
|
|
1895
2026
|
dumpMessages(lintResults);
|
|
@@ -1899,7 +2030,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1899
2030
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
1900
2031
|
const lintTime = Date.now() - start;
|
|
1901
2032
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
1902
|
-
console.log(
|
|
2033
|
+
console.log(chalk33.white(`Linted ${chalk33[filesCountColor](files.length)} files in ${chalk33[lintTimeColor](lintTime)}ms`));
|
|
1903
2034
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1904
2035
|
};
|
|
1905
2036
|
|
|
@@ -1929,7 +2060,7 @@ var rebuild = ({ target }) => {
|
|
|
1929
2060
|
};
|
|
1930
2061
|
|
|
1931
2062
|
// src/actions/recompile.ts
|
|
1932
|
-
import
|
|
2063
|
+
import chalk34 from "chalk";
|
|
1933
2064
|
var recompile = async ({
|
|
1934
2065
|
verbose,
|
|
1935
2066
|
target,
|
|
@@ -1965,7 +2096,7 @@ var recompileAll = async ({
|
|
|
1965
2096
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
1966
2097
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
1967
2098
|
if (jobs) {
|
|
1968
|
-
console.log(
|
|
2099
|
+
console.log(chalk34.blue(`Jobs set to [${jobs}]`));
|
|
1969
2100
|
}
|
|
1970
2101
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
1971
2102
|
[
|
|
@@ -1996,7 +2127,7 @@ var recompileAll = async ({
|
|
|
1996
2127
|
]
|
|
1997
2128
|
]);
|
|
1998
2129
|
console.log(
|
|
1999
|
-
`${
|
|
2130
|
+
`${chalk34.gray("Recompiled in")} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`
|
|
2000
2131
|
);
|
|
2001
2132
|
return result;
|
|
2002
2133
|
};
|
|
@@ -2027,9 +2158,9 @@ var reinstall = () => {
|
|
|
2027
2158
|
};
|
|
2028
2159
|
|
|
2029
2160
|
// src/actions/relint.ts
|
|
2030
|
-
import
|
|
2161
|
+
import chalk35 from "chalk";
|
|
2031
2162
|
var relintPackage = ({ pkg }) => {
|
|
2032
|
-
console.log(
|
|
2163
|
+
console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
|
|
2033
2164
|
const start = Date.now();
|
|
2034
2165
|
const result = runSteps("Relint [All-Packages]", [
|
|
2035
2166
|
["yarn", [
|
|
@@ -2039,7 +2170,7 @@ var relintPackage = ({ pkg }) => {
|
|
|
2039
2170
|
"package-relint"
|
|
2040
2171
|
]]
|
|
2041
2172
|
]);
|
|
2042
|
-
console.log(
|
|
2173
|
+
console.log(chalk35.gray(`${"Relinted in"} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
|
|
2043
2174
|
return result;
|
|
2044
2175
|
};
|
|
2045
2176
|
var relint = ({
|
|
@@ -2050,7 +2181,7 @@ var relint = ({
|
|
|
2050
2181
|
return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
|
|
2051
2182
|
};
|
|
2052
2183
|
var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
2053
|
-
console.log(
|
|
2184
|
+
console.log(chalk35.gray(`${"Relint"} [All-Packages]`));
|
|
2054
2185
|
const start = Date.now();
|
|
2055
2186
|
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
2056
2187
|
const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
|
|
@@ -2064,7 +2195,7 @@ var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
|
2064
2195
|
"package-relint"
|
|
2065
2196
|
]]
|
|
2066
2197
|
]);
|
|
2067
|
-
console.log(
|
|
2198
|
+
console.log(chalk35.gray(`Relinted in [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`));
|
|
2068
2199
|
return result;
|
|
2069
2200
|
};
|
|
2070
2201
|
|
|
@@ -2082,10 +2213,10 @@ var sonar = () => {
|
|
|
2082
2213
|
};
|
|
2083
2214
|
|
|
2084
2215
|
// src/actions/statics.ts
|
|
2085
|
-
import
|
|
2216
|
+
import chalk36 from "chalk";
|
|
2086
2217
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2087
2218
|
var statics = () => {
|
|
2088
|
-
console.log(
|
|
2219
|
+
console.log(chalk36.green("Check Required Static Dependencies"));
|
|
2089
2220
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2090
2221
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2091
2222
|
};
|
|
@@ -2142,7 +2273,7 @@ var loadPackageConfig = async () => {
|
|
|
2142
2273
|
};
|
|
2143
2274
|
|
|
2144
2275
|
// src/xy/xy.ts
|
|
2145
|
-
import
|
|
2276
|
+
import chalk38 from "chalk";
|
|
2146
2277
|
|
|
2147
2278
|
// src/xy/xyBuildCommands.ts
|
|
2148
2279
|
var xyBuildCommands = (args) => {
|
|
@@ -2261,7 +2392,7 @@ var xyBuildCommands = (args) => {
|
|
|
2261
2392
|
|
|
2262
2393
|
// src/xy/param.ts
|
|
2263
2394
|
var packagePositionalParam = (yargs2) => {
|
|
2264
|
-
return yargs2.positional("package", { describe: "Specific package to target" });
|
|
2395
|
+
return yargs2.positional("package", { describe: "Specific package to target", type: "string" });
|
|
2265
2396
|
};
|
|
2266
2397
|
|
|
2267
2398
|
// src/xy/xyCommonCommands.ts
|
|
@@ -2503,7 +2634,7 @@ var xyInstallCommands = (args) => {
|
|
|
2503
2634
|
};
|
|
2504
2635
|
|
|
2505
2636
|
// src/xy/xyLintCommands.ts
|
|
2506
|
-
import
|
|
2637
|
+
import chalk37 from "chalk";
|
|
2507
2638
|
var xyLintCommands = (args) => {
|
|
2508
2639
|
return args.command(
|
|
2509
2640
|
"cycle [package]",
|
|
@@ -2515,31 +2646,61 @@ var xyLintCommands = (args) => {
|
|
|
2515
2646
|
const start = Date.now();
|
|
2516
2647
|
if (argv.verbose) console.log("Cycle");
|
|
2517
2648
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
2518
|
-
console.log(
|
|
2649
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2519
2650
|
}
|
|
2520
2651
|
).command(
|
|
2521
2652
|
"lint [package]",
|
|
2522
2653
|
"Lint - Run Eslint",
|
|
2523
2654
|
(yargs2) => {
|
|
2524
|
-
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
|
+
});
|
|
2525
2666
|
},
|
|
2526
2667
|
(argv) => {
|
|
2527
2668
|
if (argv.verbose) console.log("Lint");
|
|
2528
2669
|
const start = Date.now();
|
|
2529
|
-
process.exitCode = argv.fix ? fix({ pkg: argv.package }) : lint({ pkg: argv.package });
|
|
2530
|
-
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`));
|
|
2531
2672
|
}
|
|
2532
2673
|
).command(
|
|
2533
2674
|
"deplint [package]",
|
|
2534
2675
|
"Deplint - Run Deplint",
|
|
2535
2676
|
(yargs2) => {
|
|
2536
|
-
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
|
+
});
|
|
2537
2693
|
},
|
|
2538
2694
|
(argv) => {
|
|
2539
2695
|
if (argv.verbose) console.log("Deplint");
|
|
2540
2696
|
const start = Date.now();
|
|
2541
|
-
process.exitCode = deplint({
|
|
2542
|
-
|
|
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`));
|
|
2543
2704
|
}
|
|
2544
2705
|
).command(
|
|
2545
2706
|
"fix [package]",
|
|
@@ -2551,7 +2712,7 @@ var xyLintCommands = (args) => {
|
|
|
2551
2712
|
const start = Date.now();
|
|
2552
2713
|
if (argv.verbose) console.log("Fix");
|
|
2553
2714
|
process.exitCode = fix();
|
|
2554
|
-
console.log(
|
|
2715
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2555
2716
|
}
|
|
2556
2717
|
).command(
|
|
2557
2718
|
"relint [package]",
|
|
@@ -2563,7 +2724,7 @@ var xyLintCommands = (args) => {
|
|
|
2563
2724
|
if (argv.verbose) console.log("Relinting");
|
|
2564
2725
|
const start = Date.now();
|
|
2565
2726
|
process.exitCode = relint();
|
|
2566
|
-
console.log(
|
|
2727
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2567
2728
|
}
|
|
2568
2729
|
).command(
|
|
2569
2730
|
"publint [package]",
|
|
@@ -2575,7 +2736,7 @@ var xyLintCommands = (args) => {
|
|
|
2575
2736
|
if (argv.verbose) console.log("Publint");
|
|
2576
2737
|
const start = Date.now();
|
|
2577
2738
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
2578
|
-
console.log(
|
|
2739
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2579
2740
|
}
|
|
2580
2741
|
).command(
|
|
2581
2742
|
"knip",
|
|
@@ -2587,7 +2748,7 @@ var xyLintCommands = (args) => {
|
|
|
2587
2748
|
if (argv.verbose) console.log("Knip");
|
|
2588
2749
|
const start = Date.now();
|
|
2589
2750
|
process.exitCode = knip();
|
|
2590
|
-
console.log(
|
|
2751
|
+
console.log(chalk37.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
2591
2752
|
}
|
|
2592
2753
|
).command(
|
|
2593
2754
|
"sonar",
|
|
@@ -2599,7 +2760,7 @@ var xyLintCommands = (args) => {
|
|
|
2599
2760
|
const start = Date.now();
|
|
2600
2761
|
if (argv.verbose) console.log("Sonar Check");
|
|
2601
2762
|
process.exitCode = sonar();
|
|
2602
|
-
console.log(
|
|
2763
|
+
console.log(chalk37.blue(`Finished in ${Date.now() - start}ms`));
|
|
2603
2764
|
}
|
|
2604
2765
|
);
|
|
2605
2766
|
};
|
|
@@ -2618,37 +2779,16 @@ var xyParseOptions = () => {
|
|
|
2618
2779
|
default: false,
|
|
2619
2780
|
description: "Run with verbose logging",
|
|
2620
2781
|
type: "boolean"
|
|
2621
|
-
}).option("target", {
|
|
2622
|
-
alias: "t",
|
|
2623
|
-
default: "esm",
|
|
2624
|
-
choices: ["esm", "cjs"],
|
|
2625
|
-
description: "Limit output to specific target",
|
|
2626
|
-
type: "string"
|
|
2627
2782
|
}).option("incremental", {
|
|
2628
2783
|
alias: "i",
|
|
2629
2784
|
default: false,
|
|
2630
2785
|
description: "Attempt to perform the action only on changed packages",
|
|
2631
2786
|
type: "boolean"
|
|
2632
|
-
}).option("fix", {
|
|
2633
|
-
alias: "f",
|
|
2634
|
-
default: false,
|
|
2635
|
-
description: "Try to fix errors",
|
|
2636
|
-
type: "boolean"
|
|
2637
|
-
}).option("cache", {
|
|
2638
|
-
alias: "c",
|
|
2639
|
-
default: false,
|
|
2640
|
-
description: "Use caching for performance",
|
|
2641
|
-
type: "boolean"
|
|
2642
2787
|
}).option("profile", {
|
|
2643
2788
|
alias: "p",
|
|
2644
2789
|
default: false,
|
|
2645
2790
|
description: "Profile action",
|
|
2646
2791
|
type: "boolean"
|
|
2647
|
-
}).option("types", {
|
|
2648
|
-
default: "tsc",
|
|
2649
|
-
choices: ["tsc", "tsup"],
|
|
2650
|
-
description: "Tool to generate Typescript types",
|
|
2651
|
-
type: "string"
|
|
2652
2792
|
});
|
|
2653
2793
|
};
|
|
2654
2794
|
|
|
@@ -2656,8 +2796,8 @@ var xyParseOptions = () => {
|
|
|
2656
2796
|
var xy = async () => {
|
|
2657
2797
|
const options = xyParseOptions();
|
|
2658
2798
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
2659
|
-
console.error(
|
|
2660
|
-
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"));
|
|
2661
2801
|
}).version().help().argv;
|
|
2662
2802
|
};
|
|
2663
2803
|
export {
|