@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/actions/index.mjs
CHANGED
|
@@ -313,8 +313,8 @@ var loadConfig = async (params) => {
|
|
|
313
313
|
|
|
314
314
|
// src/lib/parsedPackageJSON.ts
|
|
315
315
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
316
|
-
var parsedPackageJSON = (
|
|
317
|
-
const pathToPackageJSON =
|
|
316
|
+
var parsedPackageJSON = (path10) => {
|
|
317
|
+
const pathToPackageJSON = path10 ?? process.env.npm_package_json ?? "";
|
|
318
318
|
const packageJSON = readFileSync2(pathToPackageJSON).toString();
|
|
319
319
|
return JSON.parse(packageJSON);
|
|
320
320
|
};
|
|
@@ -671,12 +671,33 @@ var dead = () => {
|
|
|
671
671
|
return runSteps("Dead", [["yarn", ["ts-prune", "-p", "tsconfig.json"]]]);
|
|
672
672
|
};
|
|
673
673
|
|
|
674
|
-
// src/actions/deplint.ts
|
|
674
|
+
// src/actions/deplint/deplint.ts
|
|
675
|
+
import chalk18 from "chalk";
|
|
676
|
+
|
|
677
|
+
// src/actions/deplint/findFilesByGlob.ts
|
|
678
|
+
import { globSync } from "glob";
|
|
679
|
+
function findFilesByGlob(cwd4, pattern) {
|
|
680
|
+
return globSync(pattern, { cwd: cwd4, absolute: true });
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// src/actions/deplint/findFiles.ts
|
|
684
|
+
function findFiles(path10) {
|
|
685
|
+
const allSourceInclude = ["./src/**/*.{ts,tsx}", "./dist/**/*.d.ts"];
|
|
686
|
+
const prodExcludeEndswith = [".spec.ts", ".stories.tsx"];
|
|
687
|
+
const prodExcludeIncludes = ["/spec/", "/stories/", "/scripts/"];
|
|
688
|
+
const allSourceFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path10, pattern));
|
|
689
|
+
const prodSourceFiles = allSourceFiles.filter((file) => !prodExcludeEndswith.some((ext) => file.endsWith(ext)) && !prodExcludeIncludes.some((excl) => file.includes(excl)));
|
|
690
|
+
const devSourceFiles = allSourceFiles.filter((file) => !prodSourceFiles.includes(file));
|
|
691
|
+
return {
|
|
692
|
+
allSourceFiles,
|
|
693
|
+
prodSourceFiles,
|
|
694
|
+
devSourceFiles
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
675
699
|
import fs2 from "node:fs";
|
|
676
700
|
import path3 from "node:path";
|
|
677
|
-
import chalk13 from "chalk";
|
|
678
|
-
import { globSync } from "glob";
|
|
679
|
-
import ts from "typescript";
|
|
680
701
|
function getDependenciesFromPackageJson(packageJsonPath) {
|
|
681
702
|
const packageJsonFullPath = path3.resolve(packageJsonPath);
|
|
682
703
|
const rawContent = fs2.readFileSync(packageJsonFullPath, "utf8");
|
|
@@ -690,6 +711,13 @@ function getDependenciesFromPackageJson(packageJsonPath) {
|
|
|
690
711
|
peerDependencies
|
|
691
712
|
};
|
|
692
713
|
}
|
|
714
|
+
|
|
715
|
+
// src/actions/deplint/getImportsFromFile.ts
|
|
716
|
+
import fs3 from "node:fs";
|
|
717
|
+
import path4 from "node:path";
|
|
718
|
+
import ts from "typescript";
|
|
719
|
+
|
|
720
|
+
// src/actions/deplint/getBasePackageName.ts
|
|
693
721
|
function getBasePackageName(importName) {
|
|
694
722
|
if (importName.startsWith("@")) {
|
|
695
723
|
const parts = importName.split("/");
|
|
@@ -697,10 +725,12 @@ function getBasePackageName(importName) {
|
|
|
697
725
|
}
|
|
698
726
|
return importName.split("/")[0];
|
|
699
727
|
}
|
|
728
|
+
|
|
729
|
+
// src/actions/deplint/getImportsFromFile.ts
|
|
700
730
|
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
701
|
-
const sourceCode =
|
|
731
|
+
const sourceCode = fs3.readFileSync(filePath, "utf8");
|
|
702
732
|
const sourceFile = ts.createSourceFile(
|
|
703
|
-
|
|
733
|
+
path4.basename(filePath),
|
|
704
734
|
sourceCode,
|
|
705
735
|
ts.ScriptTarget.Latest,
|
|
706
736
|
true
|
|
@@ -743,36 +773,26 @@ function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
|
743
773
|
}
|
|
744
774
|
return [cleanedImports, cleanedTypeImports];
|
|
745
775
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
const prodExcludeIncludes = ["/spec/", "/stories/", "/scripts/"];
|
|
753
|
-
const allSourceFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path9, pattern));
|
|
754
|
-
const prodSourceFiles = allSourceFiles.filter((file) => !prodExcludeEndswith.some((ext) => file.endsWith(ext)) && !prodExcludeIncludes.some((excl) => file.includes(excl)));
|
|
755
|
-
const devSourceFiles = allSourceFiles.filter((file) => !prodSourceFiles.includes(file));
|
|
756
|
-
return {
|
|
757
|
-
allSourceFiles,
|
|
758
|
-
prodSourceFiles,
|
|
759
|
-
devSourceFiles
|
|
760
|
-
};
|
|
761
|
-
}
|
|
776
|
+
|
|
777
|
+
// src/actions/deplint/getExternalImportsFromFiles.ts
|
|
778
|
+
var internalImportPrefixes = [".", "#", "node:"];
|
|
779
|
+
var removeInternalImports = (imports) => {
|
|
780
|
+
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
781
|
+
};
|
|
762
782
|
function getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }) {
|
|
763
783
|
const prodImportPaths = {};
|
|
764
784
|
const prodTypeImportPaths = {};
|
|
765
|
-
const prodImportPairs = prodSourceFiles.map((
|
|
785
|
+
const prodImportPairs = prodSourceFiles.map((path10) => getImportsFromFile(path10, prodImportPaths, prodTypeImportPaths));
|
|
766
786
|
const prodImports = prodImportPairs.flatMap((pair) => pair[0]);
|
|
767
787
|
const prodTypeImports = prodImportPairs.flatMap((pair) => pair[1]);
|
|
768
788
|
const devImportPaths = {};
|
|
769
789
|
const devTypeImportPaths = {};
|
|
770
|
-
const devImportPairs = devSourceFiles.map((
|
|
790
|
+
const devImportPairs = devSourceFiles.map((path10) => getImportsFromFile(path10, devImportPaths, devTypeImportPaths));
|
|
771
791
|
const devImports = devImportPairs.flatMap((pair) => pair[0]);
|
|
772
792
|
const devTypeImports = devImportPairs.flatMap((pair) => pair[1]);
|
|
773
|
-
const externalProdImports = prodImports
|
|
774
|
-
const externalProdTypeImports = prodTypeImports
|
|
775
|
-
const externalDevImports = devImports
|
|
793
|
+
const externalProdImports = removeInternalImports(prodImports);
|
|
794
|
+
const externalProdTypeImports = removeInternalImports(prodTypeImports);
|
|
795
|
+
const externalDevImports = removeInternalImports(devImports);
|
|
776
796
|
return {
|
|
777
797
|
prodImports,
|
|
778
798
|
devImports,
|
|
@@ -786,34 +806,40 @@ function getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles }) {
|
|
|
786
806
|
externalProdTypeImports
|
|
787
807
|
};
|
|
788
808
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
809
|
+
|
|
810
|
+
// src/actions/deplint/checkPackage/getTypesInDependencies.ts
|
|
811
|
+
import chalk13 from "chalk";
|
|
812
|
+
function getTypesInDependencies({ name, location }, { dependencies }, {}) {
|
|
813
|
+
let typesInDependencies = 0;
|
|
814
|
+
for (const dep of dependencies) {
|
|
815
|
+
if (dep.startsWith("@types/")) {
|
|
816
|
+
typesInDependencies++;
|
|
817
|
+
console.log(`[${chalk13.blue(name)}] @types in dependencies in package.json: ${chalk13.red(dep)}`);
|
|
818
|
+
console.log(` ${location}/package.json
|
|
819
|
+
`);
|
|
820
|
+
console.log("");
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return typesInDependencies;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
827
|
+
import chalk14 from "chalk";
|
|
828
|
+
function getUnlistedDependencies({ name }, {
|
|
829
|
+
dependencies,
|
|
830
|
+
devDependencies,
|
|
831
|
+
peerDependencies
|
|
832
|
+
}, {
|
|
833
|
+
externalProdTypeImports,
|
|
834
|
+
prodTypeImportPaths,
|
|
835
|
+
externalProdImports,
|
|
836
|
+
prodImportPaths
|
|
794
837
|
}) {
|
|
795
|
-
const { prodSourceFiles, devSourceFiles } = findFiles(location);
|
|
796
|
-
const {
|
|
797
|
-
prodTypeImportPaths,
|
|
798
|
-
prodImportPaths,
|
|
799
|
-
externalProdTypeImports,
|
|
800
|
-
devImportPaths,
|
|
801
|
-
externalProdImports,
|
|
802
|
-
externalDevImports
|
|
803
|
-
} = getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles });
|
|
804
|
-
const {
|
|
805
|
-
dependencies,
|
|
806
|
-
devDependencies,
|
|
807
|
-
peerDependencies
|
|
808
|
-
} = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
809
838
|
let unlistedDependencies = 0;
|
|
810
|
-
let unlistedDevDependencies = 0;
|
|
811
|
-
let unusedDependencies = 0;
|
|
812
|
-
let typesInDependencies = 0;
|
|
813
839
|
for (const imp of externalProdTypeImports) {
|
|
814
840
|
if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`)) {
|
|
815
841
|
unlistedDependencies++;
|
|
816
|
-
console.log(`[${
|
|
842
|
+
console.log(`[${chalk14.blue(name)}] Missing dependency in package.json: ${chalk14.red(imp)}`);
|
|
817
843
|
console.log(` ${prodTypeImportPaths[imp].join("\n")}`);
|
|
818
844
|
console.log("");
|
|
819
845
|
}
|
|
@@ -821,132 +847,237 @@ function check({
|
|
|
821
847
|
for (const imp of externalProdImports) {
|
|
822
848
|
if (!dependencies.includes(imp) && !peerDependencies.includes(imp)) {
|
|
823
849
|
unlistedDependencies++;
|
|
824
|
-
console.log(`[${
|
|
850
|
+
console.log(`[${chalk14.blue(name)}] Missing dependency in package.json: ${chalk14.red(imp)}`);
|
|
825
851
|
console.log(` ${prodImportPaths[imp].join("\n")}`);
|
|
826
852
|
console.log("");
|
|
827
853
|
}
|
|
828
854
|
}
|
|
855
|
+
return unlistedDependencies;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
859
|
+
import chalk15 from "chalk";
|
|
860
|
+
function getUnlistedDevDependencies({ name }, { devDependencies }, { devImportPaths, externalDevImports }) {
|
|
861
|
+
let unlistedDevDependencies = 0;
|
|
862
|
+
for (const imp of externalDevImports) {
|
|
863
|
+
if (!devDependencies.includes(imp)) {
|
|
864
|
+
unlistedDevDependencies++;
|
|
865
|
+
console.log(`[${chalk15.blue(name)}] Missing devDependency in package.json: ${chalk15.red(imp)}`);
|
|
866
|
+
console.log(` Found in: ${devImportPaths[imp].join(", ")}`);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return unlistedDevDependencies;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
873
|
+
import chalk16 from "chalk";
|
|
874
|
+
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
875
|
+
externalProdImports,
|
|
876
|
+
externalProdTypeImports
|
|
877
|
+
}) {
|
|
878
|
+
let unusedDependencies = 0;
|
|
829
879
|
for (const dep of dependencies) {
|
|
830
|
-
if (dep.
|
|
831
|
-
|
|
832
|
-
console.log(`[${
|
|
880
|
+
if (!externalProdImports.includes(dep) && !externalProdTypeImports.includes(dep)) {
|
|
881
|
+
unusedDependencies++;
|
|
882
|
+
console.log(`[${chalk16.blue(name)}] Unused dependency in package.json: ${chalk16.red(dep)}`);
|
|
833
883
|
console.log(` ${location}/package.json
|
|
834
884
|
`);
|
|
835
885
|
console.log("");
|
|
836
886
|
}
|
|
837
|
-
|
|
887
|
+
}
|
|
888
|
+
return unusedDependencies;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
892
|
+
import chalk17 from "chalk";
|
|
893
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies }, { externalProdImports, externalProdTypeImports }) {
|
|
894
|
+
let unusedDependencies = 0;
|
|
895
|
+
for (const dep of peerDependencies) {
|
|
896
|
+
if (!externalProdImports.includes(dep) && !externalProdTypeImports.includes(dep)) {
|
|
838
897
|
unusedDependencies++;
|
|
839
|
-
console.log(`[${
|
|
898
|
+
console.log(`[${chalk17.blue(name)}] Unused peerDependency in package.json: ${chalk17.red(dep)}`);
|
|
840
899
|
console.log(` ${location}/package.json
|
|
841
900
|
`);
|
|
842
901
|
console.log("");
|
|
843
902
|
}
|
|
844
903
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
}
|
|
865
|
-
const
|
|
904
|
+
return unusedDependencies;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
908
|
+
function checkPackage({
|
|
909
|
+
name,
|
|
910
|
+
location,
|
|
911
|
+
deps = false,
|
|
912
|
+
devDeps = false,
|
|
913
|
+
peerDeps = false
|
|
914
|
+
}) {
|
|
915
|
+
const { prodSourceFiles, devSourceFiles } = findFiles(location);
|
|
916
|
+
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
917
|
+
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
918
|
+
const checkPeerDeps = peerDeps || !(deps || devDeps || peerDeps);
|
|
919
|
+
const sourceParams = getExternalImportsFromFiles({ prodSourceFiles, devSourceFiles });
|
|
920
|
+
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
921
|
+
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
922
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
923
|
+
const typesInDependencies = checkDeps ? getTypesInDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
924
|
+
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
925
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
926
|
+
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + typesInDependencies + unusedPeerDependencies;
|
|
866
927
|
return totalErrors;
|
|
867
928
|
}
|
|
868
|
-
|
|
929
|
+
|
|
930
|
+
// src/actions/deplint/deplint.ts
|
|
931
|
+
var deplint = ({
|
|
932
|
+
pkg,
|
|
933
|
+
deps,
|
|
934
|
+
devDeps,
|
|
935
|
+
peerDeps
|
|
936
|
+
}) => {
|
|
869
937
|
if (pkg) {
|
|
870
938
|
const { location, name } = yarnWorkspace(pkg);
|
|
871
939
|
console.log(`Running Deplint for ${name}`);
|
|
872
|
-
|
|
940
|
+
checkPackage({
|
|
873
941
|
name,
|
|
874
942
|
location,
|
|
875
|
-
devDeps
|
|
943
|
+
devDeps,
|
|
944
|
+
deps,
|
|
945
|
+
peerDeps
|
|
876
946
|
});
|
|
877
947
|
} else {
|
|
878
948
|
const workspaces = yarnWorkspaces();
|
|
879
949
|
console.log("Deplint Started...");
|
|
880
950
|
let totalErrors = 0;
|
|
881
951
|
for (const workspace of workspaces) {
|
|
882
|
-
totalErrors +=
|
|
952
|
+
totalErrors += checkPackage({
|
|
953
|
+
...workspace,
|
|
954
|
+
deps,
|
|
955
|
+
devDeps,
|
|
956
|
+
peerDeps
|
|
957
|
+
});
|
|
883
958
|
}
|
|
884
959
|
if (totalErrors > 0) {
|
|
885
|
-
console.log(`Found ${
|
|
960
|
+
console.log(`Deplint: Found ${chalk18.red(totalErrors)} dependency problems. ${chalk18.red("\u2716")}`);
|
|
886
961
|
} else {
|
|
887
|
-
console.log(`
|
|
962
|
+
console.log(`Deplint: Found no dependency problems. ${chalk18.green("\u2714")}`);
|
|
888
963
|
}
|
|
889
964
|
}
|
|
890
965
|
return 0;
|
|
891
966
|
};
|
|
892
967
|
|
|
893
968
|
// src/actions/deploy.ts
|
|
969
|
+
import { readFileSync as readFileSync3 } from "node:fs";
|
|
970
|
+
var privatePackageExcludeList = () => {
|
|
971
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
972
|
+
workspace,
|
|
973
|
+
JSON.parse(readFileSync3(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
974
|
+
]);
|
|
975
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
976
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
977
|
+
return excludeList;
|
|
978
|
+
};
|
|
894
979
|
var deploy = () => {
|
|
980
|
+
const excludeList = privatePackageExcludeList();
|
|
981
|
+
if (excludeList.length > 0) {
|
|
982
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
983
|
+
}
|
|
895
984
|
return runSteps("Deploy [Patch]", [
|
|
896
985
|
["yarn", "workspaces foreach --all version patch --deferred"],
|
|
897
986
|
["yarn", "xy clean"],
|
|
898
987
|
["yarn", "xy build"],
|
|
899
988
|
["yarn", "version apply --all"],
|
|
900
|
-
["yarn",
|
|
989
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
|
|
901
990
|
]);
|
|
902
991
|
};
|
|
903
992
|
|
|
904
993
|
// src/actions/deploy-major.ts
|
|
994
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
995
|
+
var privatePackageExcludeList2 = () => {
|
|
996
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
997
|
+
workspace,
|
|
998
|
+
JSON.parse(readFileSync4(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
999
|
+
]);
|
|
1000
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1001
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
1002
|
+
return excludeList;
|
|
1003
|
+
};
|
|
905
1004
|
var deployMajor = () => {
|
|
1005
|
+
const excludeList = privatePackageExcludeList2();
|
|
1006
|
+
if (excludeList.length > 0) {
|
|
1007
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
1008
|
+
}
|
|
906
1009
|
return runSteps("Deploy [Major]", [
|
|
907
1010
|
["yarn", "workspaces foreach --all version major --deferred"],
|
|
908
1011
|
["yarn", "xy clean"],
|
|
909
1012
|
["yarn", "xy build"],
|
|
910
1013
|
["yarn", "version apply --all"],
|
|
911
|
-
["yarn",
|
|
1014
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
|
|
912
1015
|
]);
|
|
913
1016
|
};
|
|
914
1017
|
|
|
915
1018
|
// src/actions/deploy-minor.ts
|
|
1019
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
1020
|
+
var privatePackageExcludeList3 = () => {
|
|
1021
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1022
|
+
workspace,
|
|
1023
|
+
JSON.parse(readFileSync5(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1024
|
+
]);
|
|
1025
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1026
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
1027
|
+
return excludeList;
|
|
1028
|
+
};
|
|
916
1029
|
var deployMinor = () => {
|
|
1030
|
+
const excludeList = privatePackageExcludeList3();
|
|
1031
|
+
if (excludeList.length > 0) {
|
|
1032
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
1033
|
+
}
|
|
917
1034
|
return runSteps("Deploy [Minor]", [
|
|
918
1035
|
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
919
1036
|
["yarn", "xy clean"],
|
|
920
1037
|
["yarn", "xy build"],
|
|
921
1038
|
["yarn", "version apply --all"],
|
|
922
|
-
["yarn",
|
|
1039
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish`]
|
|
923
1040
|
]);
|
|
924
1041
|
};
|
|
925
1042
|
|
|
926
1043
|
// src/actions/deploy-next.ts
|
|
1044
|
+
import { readFileSync as readFileSync6 } from "node:fs";
|
|
1045
|
+
var privatePackageExcludeList4 = () => {
|
|
1046
|
+
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1047
|
+
workspace,
|
|
1048
|
+
JSON.parse(readFileSync6(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1049
|
+
]);
|
|
1050
|
+
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1051
|
+
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
1052
|
+
return excludeList;
|
|
1053
|
+
};
|
|
927
1054
|
var deployNext = () => {
|
|
1055
|
+
const excludeList = privatePackageExcludeList4();
|
|
1056
|
+
if (excludeList.length > 0) {
|
|
1057
|
+
console.log("Excluding private packages from deployment:", excludeList);
|
|
1058
|
+
}
|
|
928
1059
|
return runSteps("Deploy [Next]", [
|
|
929
1060
|
["yarn", "workspaces foreach --all version minor --deferred"],
|
|
930
1061
|
["yarn", "xy clean"],
|
|
931
1062
|
["yarn", "xy build"],
|
|
932
1063
|
["yarn", "version apply --all --prerelease"],
|
|
933
|
-
["yarn",
|
|
1064
|
+
["yarn", `workspaces foreach --all ${excludeList.join(" ")} --parallel npm publish --tag next`]
|
|
934
1065
|
]);
|
|
935
1066
|
};
|
|
936
1067
|
|
|
937
1068
|
// src/actions/dupdeps.ts
|
|
938
|
-
import
|
|
1069
|
+
import chalk19 from "chalk";
|
|
939
1070
|
var dupdeps = () => {
|
|
940
|
-
console.log(
|
|
1071
|
+
console.log(chalk19.green("Checking all Dependencies for Duplicates"));
|
|
941
1072
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
942
1073
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
943
1074
|
return detectDuplicateDependencies(dependencies);
|
|
944
1075
|
};
|
|
945
1076
|
|
|
946
1077
|
// src/actions/lint.ts
|
|
947
|
-
import
|
|
1078
|
+
import chalk20 from "chalk";
|
|
948
1079
|
var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
949
|
-
console.log(
|
|
1080
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
950
1081
|
const start = Date.now();
|
|
951
1082
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
952
1083
|
["yarn", [
|
|
@@ -956,7 +1087,7 @@ var lintPackage = ({ pkg, fix: fix2 }) => {
|
|
|
956
1087
|
fix2 ? "package-fix" : "package-lint"
|
|
957
1088
|
]]
|
|
958
1089
|
]);
|
|
959
|
-
console.log(
|
|
1090
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
960
1091
|
return result;
|
|
961
1092
|
};
|
|
962
1093
|
var lint = ({
|
|
@@ -972,13 +1103,13 @@ var lint = ({
|
|
|
972
1103
|
});
|
|
973
1104
|
};
|
|
974
1105
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
975
|
-
console.log(
|
|
1106
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
976
1107
|
const start = Date.now();
|
|
977
1108
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
978
1109
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
979
1110
|
["yarn", ["eslint", ...fixOptions]]
|
|
980
1111
|
]);
|
|
981
|
-
console.log(
|
|
1112
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
982
1113
|
return result;
|
|
983
1114
|
};
|
|
984
1115
|
|
|
@@ -1006,7 +1137,7 @@ var filename = ".gitignore";
|
|
|
1006
1137
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1007
1138
|
|
|
1008
1139
|
// src/actions/gitlint.ts
|
|
1009
|
-
import
|
|
1140
|
+
import chalk21 from "chalk";
|
|
1010
1141
|
import ParseGitConfig from "parse-git-config";
|
|
1011
1142
|
var gitlint = () => {
|
|
1012
1143
|
console.log(`
|
|
@@ -1017,7 +1148,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1017
1148
|
const errors = 0;
|
|
1018
1149
|
const gitConfig = ParseGitConfig.sync();
|
|
1019
1150
|
const warn = (message) => {
|
|
1020
|
-
console.warn(
|
|
1151
|
+
console.warn(chalk21.yellow(`Warning: ${message}`));
|
|
1021
1152
|
warnings++;
|
|
1022
1153
|
};
|
|
1023
1154
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1037,13 +1168,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1037
1168
|
}
|
|
1038
1169
|
const resultMessages = [];
|
|
1039
1170
|
if (valid > 0) {
|
|
1040
|
-
resultMessages.push(
|
|
1171
|
+
resultMessages.push(chalk21.green(`Passed: ${valid}`));
|
|
1041
1172
|
}
|
|
1042
1173
|
if (warnings > 0) {
|
|
1043
|
-
resultMessages.push(
|
|
1174
|
+
resultMessages.push(chalk21.yellow(`Warnings: ${warnings}`));
|
|
1044
1175
|
}
|
|
1045
1176
|
if (errors > 0) {
|
|
1046
|
-
resultMessages.push(
|
|
1177
|
+
resultMessages.push(chalk21.red(` Errors: ${errors}`));
|
|
1047
1178
|
}
|
|
1048
1179
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1049
1180
|
`);
|
|
@@ -1052,7 +1183,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1052
1183
|
|
|
1053
1184
|
// src/actions/gitlint-fix.ts
|
|
1054
1185
|
import { execSync as execSync2 } from "node:child_process";
|
|
1055
|
-
import
|
|
1186
|
+
import chalk22 from "chalk";
|
|
1056
1187
|
import ParseGitConfig2 from "parse-git-config";
|
|
1057
1188
|
var gitlintFix = () => {
|
|
1058
1189
|
console.log(`
|
|
@@ -1061,15 +1192,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1061
1192
|
const gitConfig = ParseGitConfig2.sync();
|
|
1062
1193
|
if (gitConfig.core.ignorecase) {
|
|
1063
1194
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1064
|
-
console.warn(
|
|
1195
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1065
1196
|
}
|
|
1066
1197
|
if (gitConfig.core.autocrlf !== false) {
|
|
1067
1198
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1068
|
-
console.warn(
|
|
1199
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1069
1200
|
}
|
|
1070
1201
|
if (gitConfig.core.eol !== "lf") {
|
|
1071
1202
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1072
|
-
console.warn(
|
|
1203
|
+
console.warn(chalk22.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1073
1204
|
}
|
|
1074
1205
|
return 1;
|
|
1075
1206
|
};
|
|
@@ -1080,7 +1211,7 @@ var knip = () => {
|
|
|
1080
1211
|
};
|
|
1081
1212
|
|
|
1082
1213
|
// src/actions/license.ts
|
|
1083
|
-
import
|
|
1214
|
+
import chalk23 from "chalk";
|
|
1084
1215
|
import { init } from "license-checker";
|
|
1085
1216
|
var license = async (pkg) => {
|
|
1086
1217
|
const workspaces = yarnWorkspaces();
|
|
@@ -1105,18 +1236,18 @@ var license = async (pkg) => {
|
|
|
1105
1236
|
"LGPL-3.0-or-later",
|
|
1106
1237
|
"Python-2.0"
|
|
1107
1238
|
]);
|
|
1108
|
-
console.log(
|
|
1239
|
+
console.log(chalk23.green("License Checker"));
|
|
1109
1240
|
return (await Promise.all(
|
|
1110
1241
|
workspaceList.map(({ location, name }) => {
|
|
1111
1242
|
return new Promise((resolve) => {
|
|
1112
1243
|
init({ production: true, start: location }, (error, packages) => {
|
|
1113
1244
|
if (error) {
|
|
1114
|
-
console.error(
|
|
1115
|
-
console.error(
|
|
1245
|
+
console.error(chalk23.red(`License Checker [${name}] Error`));
|
|
1246
|
+
console.error(chalk23.gray(error));
|
|
1116
1247
|
console.log("\n");
|
|
1117
1248
|
resolve(1);
|
|
1118
1249
|
} else {
|
|
1119
|
-
console.log(
|
|
1250
|
+
console.log(chalk23.green(`License Checker [${name}]`));
|
|
1120
1251
|
let count = 0;
|
|
1121
1252
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1122
1253
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1132,7 +1263,7 @@ var license = async (pkg) => {
|
|
|
1132
1263
|
}
|
|
1133
1264
|
if (!orLicenseFound) {
|
|
1134
1265
|
count++;
|
|
1135
|
-
console.warn(
|
|
1266
|
+
console.warn(chalk23.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1136
1267
|
}
|
|
1137
1268
|
}
|
|
1138
1269
|
}
|
|
@@ -1151,13 +1282,13 @@ var filename2 = ".npmignore";
|
|
|
1151
1282
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1152
1283
|
|
|
1153
1284
|
// src/actions/package/clean-outputs.ts
|
|
1154
|
-
import
|
|
1155
|
-
import
|
|
1285
|
+
import path5 from "node:path";
|
|
1286
|
+
import chalk24 from "chalk";
|
|
1156
1287
|
var packageCleanOutputs = () => {
|
|
1157
1288
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1158
1289
|
const pkgName = process.env.npm_package_name;
|
|
1159
|
-
const folders = [
|
|
1160
|
-
console.log(
|
|
1290
|
+
const folders = [path5.join(pkg, "dist"), path5.join(pkg, "build"), path5.join(pkg, "docs")];
|
|
1291
|
+
console.log(chalk24.green(`Cleaning Outputs [${pkgName}]`));
|
|
1161
1292
|
for (let folder of folders) {
|
|
1162
1293
|
deleteGlob(folder);
|
|
1163
1294
|
}
|
|
@@ -1165,13 +1296,13 @@ var packageCleanOutputs = () => {
|
|
|
1165
1296
|
};
|
|
1166
1297
|
|
|
1167
1298
|
// src/actions/package/clean-typescript.ts
|
|
1168
|
-
import
|
|
1169
|
-
import
|
|
1299
|
+
import path6 from "node:path";
|
|
1300
|
+
import chalk25 from "chalk";
|
|
1170
1301
|
var packageCleanTypescript = () => {
|
|
1171
1302
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1172
1303
|
const pkgName = process.env.npm_package_name;
|
|
1173
|
-
console.log(
|
|
1174
|
-
const files = [
|
|
1304
|
+
console.log(chalk25.green(`Cleaning Typescript [${pkgName}]`));
|
|
1305
|
+
const files = [path6.join(pkg, "*.tsbuildinfo"), path6.join(pkg, ".tsconfig.*"), path6.join(pkg, ".eslintcache")];
|
|
1175
1306
|
for (let file of files) {
|
|
1176
1307
|
deleteGlob(file);
|
|
1177
1308
|
}
|
|
@@ -1184,19 +1315,19 @@ var packageClean = async () => {
|
|
|
1184
1315
|
};
|
|
1185
1316
|
|
|
1186
1317
|
// src/actions/package/compile/compile.ts
|
|
1187
|
-
import
|
|
1318
|
+
import chalk29 from "chalk";
|
|
1188
1319
|
|
|
1189
1320
|
// src/actions/package/publint.ts
|
|
1190
|
-
import { promises as
|
|
1191
|
-
import
|
|
1321
|
+
import { promises as fs4 } from "node:fs";
|
|
1322
|
+
import chalk26 from "chalk";
|
|
1192
1323
|
import sortPackageJson from "sort-package-json";
|
|
1193
1324
|
var packagePublint = async (params) => {
|
|
1194
1325
|
const pkgDir = process.env.INIT_CWD;
|
|
1195
|
-
const sortedPkg = sortPackageJson(await
|
|
1196
|
-
await
|
|
1197
|
-
const pkg = JSON.parse(await
|
|
1198
|
-
console.log(
|
|
1199
|
-
console.log(
|
|
1326
|
+
const sortedPkg = sortPackageJson(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
1327
|
+
await fs4.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
1328
|
+
const pkg = JSON.parse(await fs4.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
1329
|
+
console.log(chalk26.green(`Publint: ${pkg.name}`));
|
|
1330
|
+
console.log(chalk26.gray(pkgDir));
|
|
1200
1331
|
const { publint: publint2 } = await import("publint");
|
|
1201
1332
|
const { messages } = await publint2({
|
|
1202
1333
|
level: "suggestion",
|
|
@@ -1211,21 +1342,21 @@ var packagePublint = async (params) => {
|
|
|
1211
1342
|
for (const message of validMessages) {
|
|
1212
1343
|
switch (message.type) {
|
|
1213
1344
|
case "error": {
|
|
1214
|
-
console.error(
|
|
1345
|
+
console.error(chalk26.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1215
1346
|
break;
|
|
1216
1347
|
}
|
|
1217
1348
|
case "warning": {
|
|
1218
|
-
console.warn(
|
|
1349
|
+
console.warn(chalk26.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1219
1350
|
break;
|
|
1220
1351
|
}
|
|
1221
1352
|
default: {
|
|
1222
|
-
console.log(
|
|
1353
|
+
console.log(chalk26.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
1223
1354
|
break;
|
|
1224
1355
|
}
|
|
1225
1356
|
}
|
|
1226
1357
|
}
|
|
1227
1358
|
if (params?.verbose) {
|
|
1228
|
-
console.log(
|
|
1359
|
+
console.log(chalk26.gray(`Publint [Finish]: ${pkgDir} [${validMessages.length}]`));
|
|
1229
1360
|
}
|
|
1230
1361
|
return validMessages.filter((message) => message.type === "error").length;
|
|
1231
1362
|
};
|
|
@@ -1262,7 +1393,7 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1262
1393
|
|
|
1263
1394
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1264
1395
|
import { cwd } from "node:process";
|
|
1265
|
-
import
|
|
1396
|
+
import chalk27 from "chalk";
|
|
1266
1397
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1267
1398
|
import {
|
|
1268
1399
|
DiagnosticCategory,
|
|
@@ -1317,7 +1448,7 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1317
1448
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1318
1449
|
const excludes = [".stories.", ".spec."];
|
|
1319
1450
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
|
|
1320
|
-
console.log(
|
|
1451
|
+
console.log(chalk27.green(`Compiling Types ${pkg}: ${files.length}`));
|
|
1321
1452
|
if (files.length > 0) {
|
|
1322
1453
|
const program = createProgramFromConfig({
|
|
1323
1454
|
basePath: pkg ?? cwd(),
|
|
@@ -1374,7 +1505,7 @@ function deepMergeObjects(objects) {
|
|
|
1374
1505
|
|
|
1375
1506
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1376
1507
|
import { cwd as cwd2 } from "node:process";
|
|
1377
|
-
import
|
|
1508
|
+
import chalk28 from "chalk";
|
|
1378
1509
|
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1379
1510
|
import {
|
|
1380
1511
|
DiagnosticCategory as DiagnosticCategory2,
|
|
@@ -1400,7 +1531,7 @@ var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) =>
|
|
|
1400
1531
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1401
1532
|
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1402
1533
|
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1403
|
-
console.log(
|
|
1534
|
+
console.log(chalk28.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1404
1535
|
if (files.length > 0) {
|
|
1405
1536
|
const program = createProgramFromConfig2({
|
|
1406
1537
|
basePath: pkg ?? cwd2(),
|
|
@@ -1551,7 +1682,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1551
1682
|
// src/actions/package/compile/compile.ts
|
|
1552
1683
|
var packageCompile = async (inConfig = {}) => {
|
|
1553
1684
|
const pkg = process.env.INIT_CWD;
|
|
1554
|
-
console.log(
|
|
1685
|
+
console.log(chalk29.green(`Compiling ${pkg}`));
|
|
1555
1686
|
const config2 = await loadConfig(inConfig);
|
|
1556
1687
|
const publint2 = config2.publint;
|
|
1557
1688
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1562,8 +1693,8 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1562
1693
|
};
|
|
1563
1694
|
|
|
1564
1695
|
// src/actions/package/copy-assets.ts
|
|
1565
|
-
import
|
|
1566
|
-
import
|
|
1696
|
+
import path7 from "node:path/posix";
|
|
1697
|
+
import chalk30 from "chalk";
|
|
1567
1698
|
import cpy2 from "cpy";
|
|
1568
1699
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1569
1700
|
try {
|
|
@@ -1571,12 +1702,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1571
1702
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1572
1703
|
`../dist/${target}`,
|
|
1573
1704
|
{
|
|
1574
|
-
cwd:
|
|
1705
|
+
cwd: path7.join(location, "src"),
|
|
1575
1706
|
flat: false
|
|
1576
1707
|
}
|
|
1577
1708
|
);
|
|
1578
1709
|
if (values.length > 0) {
|
|
1579
|
-
console.log(
|
|
1710
|
+
console.log(chalk30.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1580
1711
|
}
|
|
1581
1712
|
for (const value of values) {
|
|
1582
1713
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -1644,8 +1775,8 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1644
1775
|
|
|
1645
1776
|
// src/actions/package/gen-docs.ts
|
|
1646
1777
|
import { existsSync as existsSync4 } from "node:fs";
|
|
1647
|
-
import
|
|
1648
|
-
import
|
|
1778
|
+
import path8 from "node:path";
|
|
1779
|
+
import chalk31 from "chalk";
|
|
1649
1780
|
import {
|
|
1650
1781
|
Application,
|
|
1651
1782
|
ArgumentsReader,
|
|
@@ -1663,7 +1794,7 @@ var ExitCodes = {
|
|
|
1663
1794
|
};
|
|
1664
1795
|
var packageGenDocs = async () => {
|
|
1665
1796
|
const pkg = process.env.INIT_CWD;
|
|
1666
|
-
if (pkg && !existsSync4(
|
|
1797
|
+
if (pkg && !existsSync4(path8.join(pkg, "typedoc.json"))) {
|
|
1667
1798
|
return;
|
|
1668
1799
|
}
|
|
1669
1800
|
const app = await Application.bootstrap({
|
|
@@ -1749,16 +1880,16 @@ var runTypeDoc = async (app) => {
|
|
|
1749
1880
|
return ExitCodes.OutputError;
|
|
1750
1881
|
}
|
|
1751
1882
|
}
|
|
1752
|
-
console.log(
|
|
1883
|
+
console.log(chalk31.green(`${pkgName} - Ok`));
|
|
1753
1884
|
return ExitCodes.Ok;
|
|
1754
1885
|
};
|
|
1755
1886
|
|
|
1756
1887
|
// src/actions/package/lint.ts
|
|
1757
1888
|
import { readdirSync } from "node:fs";
|
|
1758
|
-
import
|
|
1889
|
+
import path9 from "node:path";
|
|
1759
1890
|
import { cwd as cwd3 } from "node:process";
|
|
1760
1891
|
import { pathToFileURL } from "node:url";
|
|
1761
|
-
import
|
|
1892
|
+
import chalk32 from "chalk";
|
|
1762
1893
|
import { ESLint } from "eslint";
|
|
1763
1894
|
import { findUp } from "find-up";
|
|
1764
1895
|
import picomatch from "picomatch";
|
|
@@ -1767,14 +1898,14 @@ var dumpMessages = (lintResults) => {
|
|
|
1767
1898
|
const severity = ["none", "warning", "error"];
|
|
1768
1899
|
for (const lintResult of lintResults) {
|
|
1769
1900
|
if (lintResult.messages.length > 0) {
|
|
1770
|
-
console.log(
|
|
1901
|
+
console.log(chalk32.gray(`
|
|
1771
1902
|
${lintResult.filePath}`));
|
|
1772
1903
|
for (const message of lintResult.messages) {
|
|
1773
1904
|
console.log(
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1905
|
+
chalk32.gray(` ${message.line}:${message.column}`),
|
|
1906
|
+
chalk32[colors[message.severity]](` ${severity[message.severity]}`),
|
|
1907
|
+
chalk32.white(` ${message.message}`),
|
|
1908
|
+
chalk32.gray(` ${message.ruleId}`)
|
|
1778
1909
|
);
|
|
1779
1910
|
}
|
|
1780
1911
|
}
|
|
@@ -1792,7 +1923,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1792
1923
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1793
1924
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1794
1925
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1795
|
-
const res =
|
|
1926
|
+
const res = path9.resolve(dir, dirent.name);
|
|
1796
1927
|
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
|
|
1797
1928
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1798
1929
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -1813,7 +1944,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1813
1944
|
});
|
|
1814
1945
|
const files = getFiles(cwd3(), ignoreFolders);
|
|
1815
1946
|
if (verbose) {
|
|
1816
|
-
console.log(
|
|
1947
|
+
console.log(chalk32.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
1817
1948
|
}
|
|
1818
1949
|
const lintResults = await engine.lintFiles(files);
|
|
1819
1950
|
dumpMessages(lintResults);
|
|
@@ -1823,7 +1954,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
1823
1954
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
1824
1955
|
const lintTime = Date.now() - start;
|
|
1825
1956
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
1826
|
-
console.log(
|
|
1957
|
+
console.log(chalk32.white(`Linted ${chalk32[filesCountColor](files.length)} files in ${chalk32[lintTimeColor](lintTime)}ms`));
|
|
1827
1958
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1828
1959
|
};
|
|
1829
1960
|
|
|
@@ -1853,7 +1984,7 @@ var rebuild = ({ target }) => {
|
|
|
1853
1984
|
};
|
|
1854
1985
|
|
|
1855
1986
|
// src/actions/recompile.ts
|
|
1856
|
-
import
|
|
1987
|
+
import chalk33 from "chalk";
|
|
1857
1988
|
var recompile = async ({
|
|
1858
1989
|
verbose,
|
|
1859
1990
|
target,
|
|
@@ -1889,7 +2020,7 @@ var recompileAll = async ({
|
|
|
1889
2020
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
1890
2021
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
1891
2022
|
if (jobs) {
|
|
1892
|
-
console.log(
|
|
2023
|
+
console.log(chalk33.blue(`Jobs set to [${jobs}]`));
|
|
1893
2024
|
}
|
|
1894
2025
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
1895
2026
|
[
|
|
@@ -1920,7 +2051,7 @@ var recompileAll = async ({
|
|
|
1920
2051
|
]
|
|
1921
2052
|
]);
|
|
1922
2053
|
console.log(
|
|
1923
|
-
`${
|
|
2054
|
+
`${chalk33.gray("Recompiled in")} [${chalk33.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk33.gray("seconds")}`
|
|
1924
2055
|
);
|
|
1925
2056
|
return result;
|
|
1926
2057
|
};
|
|
@@ -1951,9 +2082,9 @@ var reinstall = () => {
|
|
|
1951
2082
|
};
|
|
1952
2083
|
|
|
1953
2084
|
// src/actions/relint.ts
|
|
1954
|
-
import
|
|
2085
|
+
import chalk34 from "chalk";
|
|
1955
2086
|
var relintPackage = ({ pkg }) => {
|
|
1956
|
-
console.log(
|
|
2087
|
+
console.log(chalk34.gray(`${"Relint"} [All-Packages]`));
|
|
1957
2088
|
const start = Date.now();
|
|
1958
2089
|
const result = runSteps("Relint [All-Packages]", [
|
|
1959
2090
|
["yarn", [
|
|
@@ -1963,7 +2094,7 @@ var relintPackage = ({ pkg }) => {
|
|
|
1963
2094
|
"package-relint"
|
|
1964
2095
|
]]
|
|
1965
2096
|
]);
|
|
1966
|
-
console.log(
|
|
2097
|
+
console.log(chalk34.gray(`${"Relinted in"} [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`));
|
|
1967
2098
|
return result;
|
|
1968
2099
|
};
|
|
1969
2100
|
var relint = ({
|
|
@@ -1974,7 +2105,7 @@ var relint = ({
|
|
|
1974
2105
|
return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
|
|
1975
2106
|
};
|
|
1976
2107
|
var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
1977
|
-
console.log(
|
|
2108
|
+
console.log(chalk34.gray(`${"Relint"} [All-Packages]`));
|
|
1978
2109
|
const start = Date.now();
|
|
1979
2110
|
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
1980
2111
|
const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
|
|
@@ -1988,7 +2119,7 @@ var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
|
1988
2119
|
"package-relint"
|
|
1989
2120
|
]]
|
|
1990
2121
|
]);
|
|
1991
|
-
console.log(
|
|
2122
|
+
console.log(chalk34.gray(`Relinted in [${chalk34.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk34.gray("seconds")}`));
|
|
1992
2123
|
return result;
|
|
1993
2124
|
};
|
|
1994
2125
|
|
|
@@ -2006,10 +2137,10 @@ var sonar = () => {
|
|
|
2006
2137
|
};
|
|
2007
2138
|
|
|
2008
2139
|
// src/actions/statics.ts
|
|
2009
|
-
import
|
|
2140
|
+
import chalk35 from "chalk";
|
|
2010
2141
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2011
2142
|
var statics = () => {
|
|
2012
|
-
console.log(
|
|
2143
|
+
console.log(chalk35.green("Check Required Static Dependencies"));
|
|
2013
2144
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2014
2145
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2015
2146
|
};
|