@xylabs/ts-scripts-yarn3 7.3.2 → 7.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/cycle.mjs +1 -1
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +316 -35
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +13 -6
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +3 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +213 -0
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/checkPackage/index.mjs +316 -35
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +319 -38
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/findFiles.mjs +8 -2
- package/dist/actions/deplint/findFiles.mjs.map +1 -1
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs +44 -0
- package/dist/actions/deplint/getExtendsFromTsconfigs.mjs.map +1 -0
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +15 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs +36 -0
- package/dist/actions/deplint/getRequiredPeerDependencies.mjs.map +1 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs +81 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs +75 -0
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -0
- package/dist/actions/deplint/index.mjs +319 -38
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +423 -142
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +366 -85
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +435 -154
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +366 -85
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +366 -85
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +339 -58
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +15 -16
package/dist/bin/xy.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/xy/xy.ts
|
|
4
|
-
import
|
|
4
|
+
import chalk26 from "chalk";
|
|
5
5
|
|
|
6
6
|
// src/actions/build.ts
|
|
7
7
|
import chalk7 from "chalk";
|
|
@@ -299,8 +299,8 @@ var generateIgnoreFiles = (filename3, pkg) => {
|
|
|
299
299
|
|
|
300
300
|
// src/lib/parsedPackageJSON.ts
|
|
301
301
|
import { readFileSync as readFileSync2 } from "fs";
|
|
302
|
-
var parsedPackageJSON = (
|
|
303
|
-
const pathToPackageJSON =
|
|
302
|
+
var parsedPackageJSON = (path7) => {
|
|
303
|
+
const pathToPackageJSON = path7 ?? process.env.npm_package_json ?? "";
|
|
304
304
|
const packageJSON = readFileSync2(pathToPackageJSON).toString();
|
|
305
305
|
return JSON.parse(packageJSON);
|
|
306
306
|
};
|
|
@@ -582,7 +582,7 @@ var cycleAll = async ({ verbose = false }) => {
|
|
|
582
582
|
combinedDependencies: true,
|
|
583
583
|
outputType: verbose ? "text" : "err"
|
|
584
584
|
};
|
|
585
|
-
const target = "**/src";
|
|
585
|
+
const target = "**/packages/*/src";
|
|
586
586
|
console.log(`Checking for circular dependencies in ${target}...`);
|
|
587
587
|
const result = await cruise([target], cruiseOptions);
|
|
588
588
|
if (result.output) {
|
|
@@ -602,7 +602,7 @@ var dead = () => {
|
|
|
602
602
|
};
|
|
603
603
|
|
|
604
604
|
// src/actions/deplint/deplint.ts
|
|
605
|
-
import
|
|
605
|
+
import chalk16 from "chalk";
|
|
606
606
|
|
|
607
607
|
// src/actions/deplint/findFilesByGlob.ts
|
|
608
608
|
import { globSync } from "glob";
|
|
@@ -611,12 +611,18 @@ function findFilesByGlob(cwd, pattern) {
|
|
|
611
611
|
}
|
|
612
612
|
|
|
613
613
|
// src/actions/deplint/findFiles.ts
|
|
614
|
-
function findFiles(
|
|
615
|
-
const allSourceInclude = ["./src/**/*.{ts,tsx}"];
|
|
614
|
+
function findFiles(path7) {
|
|
615
|
+
const allSourceInclude = ["./src/**/*.{ts,tsx,mts,cts,js,mjs,cjs}"];
|
|
616
616
|
const allDistInclude = ["./dist/**/*.d.ts", "./dist/**/*.{mjs,js,cjs}"];
|
|
617
|
-
const
|
|
618
|
-
const
|
|
619
|
-
|
|
617
|
+
const allConfigInclude = ["./*.config.{ts,mts,mjs,js}"];
|
|
618
|
+
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path7, pattern));
|
|
619
|
+
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path7, pattern));
|
|
620
|
+
const configFiles = allConfigInclude.flatMap((pattern) => findFilesByGlob(path7, pattern));
|
|
621
|
+
return {
|
|
622
|
+
srcFiles,
|
|
623
|
+
distFiles,
|
|
624
|
+
configFiles
|
|
625
|
+
};
|
|
620
626
|
}
|
|
621
627
|
|
|
622
628
|
// src/actions/deplint/getDependenciesFromPackageJson.ts
|
|
@@ -636,10 +642,9 @@ function getDependenciesFromPackageJson(packageJsonPath) {
|
|
|
636
642
|
};
|
|
637
643
|
}
|
|
638
644
|
|
|
639
|
-
// src/actions/deplint/
|
|
645
|
+
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
640
646
|
import fs3 from "fs";
|
|
641
|
-
import
|
|
642
|
-
import ts from "typescript";
|
|
647
|
+
import { globSync as globSync2 } from "glob";
|
|
643
648
|
|
|
644
649
|
// src/actions/deplint/getBasePackageName.ts
|
|
645
650
|
function getBasePackageName(importName) {
|
|
@@ -651,7 +656,37 @@ function getBasePackageName(importName) {
|
|
|
651
656
|
return importNameScrubbed.split("/")[0];
|
|
652
657
|
}
|
|
653
658
|
|
|
659
|
+
// src/actions/deplint/getExtendsFromTsconfigs.ts
|
|
660
|
+
var isExternalReference = (ref) => !ref.startsWith(".") && !ref.startsWith("/");
|
|
661
|
+
function parseExtendsField(value) {
|
|
662
|
+
if (typeof value === "string") return [value];
|
|
663
|
+
if (Array.isArray(value)) return value.filter((v) => typeof v === "string");
|
|
664
|
+
return [];
|
|
665
|
+
}
|
|
666
|
+
function getExtendsFromTsconfigs(location) {
|
|
667
|
+
const tsconfigFiles = globSync2("./tsconfig*.json", { cwd: location, absolute: true });
|
|
668
|
+
const packages = /* @__PURE__ */ new Set();
|
|
669
|
+
for (const file of tsconfigFiles) {
|
|
670
|
+
try {
|
|
671
|
+
const content = fs3.readFileSync(file, "utf8");
|
|
672
|
+
const cleaned = content.replaceAll(/\/\/.*/g, "").replaceAll(/,\s*([}\]])/g, "$1");
|
|
673
|
+
const parsed = JSON.parse(cleaned);
|
|
674
|
+
const refs = parseExtendsField(parsed.extends);
|
|
675
|
+
for (const ref of refs) {
|
|
676
|
+
if (isExternalReference(ref)) {
|
|
677
|
+
packages.add(getBasePackageName(ref));
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
} catch {
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return [...packages];
|
|
684
|
+
}
|
|
685
|
+
|
|
654
686
|
// src/actions/deplint/getImportsFromFile.ts
|
|
687
|
+
import fs4 from "fs";
|
|
688
|
+
import path4 from "path";
|
|
689
|
+
import ts from "typescript";
|
|
655
690
|
function isTypeOnlyImportClause(clause) {
|
|
656
691
|
if (clause === void 0) {
|
|
657
692
|
return false;
|
|
@@ -664,7 +699,7 @@ function isTypeOnlyImportClause(clause) {
|
|
|
664
699
|
return clause.isTypeOnly;
|
|
665
700
|
}
|
|
666
701
|
function getImportsFromFile(filePath, importPaths, typeImportPaths) {
|
|
667
|
-
const sourceCode =
|
|
702
|
+
const sourceCode = fs4.readFileSync(filePath, "utf8");
|
|
668
703
|
const isMjsFile = filePath.endsWith(".mjs");
|
|
669
704
|
const sourceFile = ts.createSourceFile(
|
|
670
705
|
path4.basename(filePath),
|
|
@@ -717,24 +752,38 @@ var internalImportPrefixes = [".", "#", "node:"];
|
|
|
717
752
|
var removeInternalImports = (imports) => {
|
|
718
753
|
return imports.filter((imp) => !internalImportPrefixes.some((prefix) => imp.startsWith(prefix)));
|
|
719
754
|
};
|
|
720
|
-
function getExternalImportsFromFiles({
|
|
755
|
+
function getExternalImportsFromFiles({
|
|
756
|
+
srcFiles,
|
|
757
|
+
distFiles,
|
|
758
|
+
configFiles = [],
|
|
759
|
+
tsconfigExtends = []
|
|
760
|
+
}) {
|
|
721
761
|
const srcImportPaths = {};
|
|
722
762
|
const distImportPaths = {};
|
|
723
763
|
const distTypeImportPaths = {};
|
|
724
|
-
|
|
764
|
+
const configImportPaths = {};
|
|
765
|
+
for (const path7 of srcFiles) getImportsFromFile(path7, srcImportPaths, srcImportPaths).flat();
|
|
766
|
+
for (const path7 of configFiles) getImportsFromFile(path7, configImportPaths, configImportPaths).flat();
|
|
725
767
|
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
726
768
|
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
727
|
-
for (const
|
|
728
|
-
for (const
|
|
769
|
+
for (const path7 of distCodeFiles) getImportsFromFile(path7, distImportPaths, distImportPaths).flat();
|
|
770
|
+
for (const path7 of distTypeFiles) getImportsFromFile(path7, distTypeImportPaths, distTypeImportPaths).flat();
|
|
729
771
|
const srcImports = Object.keys(srcImportPaths);
|
|
730
772
|
const distImports = Object.keys(distImportPaths);
|
|
731
773
|
const distTypeImports = Object.keys(distTypeImportPaths);
|
|
732
774
|
const externalSrcImports = removeInternalImports(srcImports);
|
|
733
775
|
const externalDistImports = removeInternalImports(distImports);
|
|
734
776
|
const externalDistTypeImports = removeInternalImports(distTypeImports);
|
|
777
|
+
const externalConfigImports = removeInternalImports(Object.keys(configImportPaths));
|
|
778
|
+
for (const ext of tsconfigExtends) {
|
|
779
|
+
if (!externalSrcImports.includes(ext)) externalSrcImports.push(ext);
|
|
780
|
+
if (!externalConfigImports.includes(ext)) externalConfigImports.push(ext);
|
|
781
|
+
}
|
|
735
782
|
return {
|
|
783
|
+
configImportPaths,
|
|
736
784
|
srcImports,
|
|
737
785
|
srcImportPaths,
|
|
786
|
+
externalConfigImports,
|
|
738
787
|
externalSrcImports,
|
|
739
788
|
distImports,
|
|
740
789
|
distImportPaths,
|
|
@@ -746,6 +795,15 @@ function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
|
746
795
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
747
796
|
import { builtinModules } from "module";
|
|
748
797
|
import chalk11 from "chalk";
|
|
798
|
+
function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
|
|
799
|
+
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
|
|
800
|
+
}
|
|
801
|
+
function logMissing(name, imp, importPaths) {
|
|
802
|
+
console.log(`[${chalk11.blue(name)}] Missing dependency in package.json: ${chalk11.red(imp)}`);
|
|
803
|
+
if (importPaths[imp]) {
|
|
804
|
+
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
749
807
|
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, {
|
|
750
808
|
externalDistImports,
|
|
751
809
|
externalDistTypeImports,
|
|
@@ -753,17 +811,15 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
753
811
|
}) {
|
|
754
812
|
let unlistedDependencies = 0;
|
|
755
813
|
for (const imp of externalDistImports) {
|
|
756
|
-
if (!
|
|
814
|
+
if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
|
|
757
815
|
unlistedDependencies++;
|
|
758
|
-
|
|
759
|
-
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
816
|
+
logMissing(name, imp, distImportPaths);
|
|
760
817
|
}
|
|
761
818
|
}
|
|
762
819
|
for (const imp of externalDistTypeImports) {
|
|
763
|
-
if (!
|
|
820
|
+
if (!isListedOrBuiltin(imp, name, dependencies, peerDependencies)) {
|
|
764
821
|
unlistedDependencies++;
|
|
765
|
-
|
|
766
|
-
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
822
|
+
logMissing(name, imp, distImportPaths);
|
|
767
823
|
}
|
|
768
824
|
}
|
|
769
825
|
if (unlistedDependencies > 0) {
|
|
@@ -791,7 +847,9 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
791
847
|
if (!distImports.includes(imp) && imp !== name && !dependencies.includes(imp) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.includes(imp)) {
|
|
792
848
|
unlistedDevDependencies++;
|
|
793
849
|
console.log(`[${chalk12.blue(name)}] Missing devDependency in package.json: ${chalk12.red(imp)}`);
|
|
794
|
-
|
|
850
|
+
if (srcImportPaths[imp]) {
|
|
851
|
+
console.log(` ${srcImportPaths[imp].join("\n ")}`);
|
|
852
|
+
}
|
|
795
853
|
}
|
|
796
854
|
}
|
|
797
855
|
if (unlistedDevDependencies > 0) {
|
|
@@ -828,29 +886,243 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
828
886
|
return unusedDependencies;
|
|
829
887
|
}
|
|
830
888
|
|
|
831
|
-
// src/actions/deplint/checkPackage/
|
|
889
|
+
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
832
890
|
import chalk14 from "chalk";
|
|
891
|
+
|
|
892
|
+
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
893
|
+
import fs5 from "fs";
|
|
894
|
+
import path5 from "path";
|
|
895
|
+
function findDepPackageJson(location, dep) {
|
|
896
|
+
let dir = location;
|
|
897
|
+
while (true) {
|
|
898
|
+
const candidate = path5.join(dir, "node_modules", dep, "package.json");
|
|
899
|
+
if (fs5.existsSync(candidate)) return candidate;
|
|
900
|
+
const parent = path5.dirname(dir);
|
|
901
|
+
if (parent === dir) return void 0;
|
|
902
|
+
dir = parent;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function getRequiredPeerDependencies(location, allDeps) {
|
|
906
|
+
const required = /* @__PURE__ */ new Set();
|
|
907
|
+
for (const dep of allDeps) {
|
|
908
|
+
const depPkgPath = findDepPackageJson(location, dep);
|
|
909
|
+
if (!depPkgPath) continue;
|
|
910
|
+
try {
|
|
911
|
+
const raw = fs5.readFileSync(depPkgPath, "utf8");
|
|
912
|
+
const pkg = JSON.parse(raw);
|
|
913
|
+
if (pkg.peerDependencies) {
|
|
914
|
+
for (const peer of Object.keys(pkg.peerDependencies)) {
|
|
915
|
+
required.add(peer);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
} catch {
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
return required;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
925
|
+
import fs6 from "fs";
|
|
926
|
+
import path6 from "path";
|
|
927
|
+
function getBinNames(location, dep) {
|
|
928
|
+
const depPkgPath = findDepPackageJson(location, dep);
|
|
929
|
+
if (!depPkgPath) return [];
|
|
930
|
+
try {
|
|
931
|
+
const raw = fs6.readFileSync(depPkgPath, "utf8");
|
|
932
|
+
const pkg = JSON.parse(raw);
|
|
933
|
+
if (!pkg.bin) return [];
|
|
934
|
+
if (typeof pkg.bin === "string") return [pkg.name?.split("/").pop() ?? dep];
|
|
935
|
+
return Object.keys(pkg.bin);
|
|
936
|
+
} catch {
|
|
937
|
+
return [];
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
function tokenizeScript(script) {
|
|
941
|
+
return script.split(/[&|;$()"`\s]+/).map((t) => t.trim()).filter(Boolean);
|
|
942
|
+
}
|
|
943
|
+
function getScriptReferencedPackages(location, allDeps) {
|
|
944
|
+
const pkgPath = path6.join(location, "package.json");
|
|
945
|
+
let scripts = {};
|
|
946
|
+
try {
|
|
947
|
+
const raw = fs6.readFileSync(pkgPath, "utf8");
|
|
948
|
+
const pkg = JSON.parse(raw);
|
|
949
|
+
scripts = pkg.scripts ?? {};
|
|
950
|
+
} catch {
|
|
951
|
+
return /* @__PURE__ */ new Set();
|
|
952
|
+
}
|
|
953
|
+
const scriptText = Object.values(scripts).join(" ");
|
|
954
|
+
const tokens = new Set(tokenizeScript(scriptText));
|
|
955
|
+
const binToPackage = /* @__PURE__ */ new Map();
|
|
956
|
+
for (const dep of allDeps) {
|
|
957
|
+
const bins = getBinNames(location, dep);
|
|
958
|
+
for (const bin of bins) {
|
|
959
|
+
binToPackage.set(bin, dep);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
963
|
+
for (const token of tokens) {
|
|
964
|
+
const baseName = getBasePackageName(token);
|
|
965
|
+
if (allDeps.includes(baseName)) {
|
|
966
|
+
referenced.add(baseName);
|
|
967
|
+
}
|
|
968
|
+
const pkg = binToPackage.get(token);
|
|
969
|
+
if (pkg) {
|
|
970
|
+
referenced.add(pkg);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
return referenced;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
// src/actions/deplint/implicitDevDependencies.ts
|
|
977
|
+
import fs7 from "fs";
|
|
978
|
+
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
979
|
+
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
980
|
+
var hasTypescriptFiles = ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], tsExtensions);
|
|
981
|
+
var decoratorPattern = /^\s*@[A-Z]\w*/m;
|
|
982
|
+
var hasDecorators = ({ srcFiles }) => srcFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
983
|
+
try {
|
|
984
|
+
const content = fs7.readFileSync(file, "utf8");
|
|
985
|
+
return decoratorPattern.test(content);
|
|
986
|
+
} catch {
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
|
|
991
|
+
function hasImportPlugin({ location, allDependencies }) {
|
|
992
|
+
if (allDependencies.some((d) => importPlugins.has(d))) return true;
|
|
993
|
+
for (const dep of allDependencies) {
|
|
994
|
+
const pkgPath = findDepPackageJson(location, dep);
|
|
995
|
+
if (!pkgPath) continue;
|
|
996
|
+
try {
|
|
997
|
+
const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf8"));
|
|
998
|
+
const transitiveDeps = [
|
|
999
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
1000
|
+
...Object.keys(pkg.peerDependencies ?? {})
|
|
1001
|
+
];
|
|
1002
|
+
if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
|
|
1003
|
+
} catch {
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return false;
|
|
1007
|
+
}
|
|
1008
|
+
var rules = [
|
|
1009
|
+
{
|
|
1010
|
+
package: "typescript",
|
|
1011
|
+
isNeeded: hasTypescriptFiles
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
package: "eslint-import-resolver-typescript",
|
|
1015
|
+
isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
package: "tslib",
|
|
1019
|
+
isNeeded: hasDecorators
|
|
1020
|
+
}
|
|
1021
|
+
];
|
|
1022
|
+
function getImplicitDevDependencies(context) {
|
|
1023
|
+
const implicit = /* @__PURE__ */ new Set();
|
|
1024
|
+
for (const rule of rules) {
|
|
1025
|
+
if (rule.isNeeded(context)) {
|
|
1026
|
+
implicit.add(rule.package);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
return implicit;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1033
|
+
var allExternalImports = ({
|
|
1034
|
+
externalSrcImports,
|
|
1035
|
+
externalDistImports,
|
|
1036
|
+
externalDistTypeImports,
|
|
1037
|
+
externalConfigImports
|
|
1038
|
+
}) => {
|
|
1039
|
+
const all = /* @__PURE__ */ new Set([
|
|
1040
|
+
...externalSrcImports,
|
|
1041
|
+
...externalDistImports,
|
|
1042
|
+
...externalDistTypeImports,
|
|
1043
|
+
...externalConfigImports
|
|
1044
|
+
]);
|
|
1045
|
+
return all;
|
|
1046
|
+
};
|
|
1047
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1048
|
+
if (implicitDeps.has(dep)) return true;
|
|
1049
|
+
if (requiredPeers.has(dep)) return true;
|
|
1050
|
+
if (scriptRefs.has(dep)) return true;
|
|
1051
|
+
if (dep.startsWith("@types/")) {
|
|
1052
|
+
const baseName = dep.replace(/^@types\//, "");
|
|
1053
|
+
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
1054
|
+
}
|
|
1055
|
+
return allImports.has(dep);
|
|
1056
|
+
}
|
|
1057
|
+
function getUnusedDevDependencies({ name, location }, {
|
|
1058
|
+
devDependencies,
|
|
1059
|
+
dependencies,
|
|
1060
|
+
peerDependencies
|
|
1061
|
+
}, sourceParams, fileContext) {
|
|
1062
|
+
const allImports = allExternalImports(sourceParams);
|
|
1063
|
+
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1064
|
+
const implicitDeps = getImplicitDevDependencies({
|
|
1065
|
+
...fileContext,
|
|
1066
|
+
allDependencies: allDeps,
|
|
1067
|
+
location
|
|
1068
|
+
});
|
|
1069
|
+
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1070
|
+
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1071
|
+
let unusedDevDependencies = 0;
|
|
1072
|
+
for (const dep of devDependencies) {
|
|
1073
|
+
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1074
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1075
|
+
unusedDevDependencies++;
|
|
1076
|
+
console.log(`[${chalk14.blue(name)}] Unused devDependency in package.json: ${chalk14.red(dep)}`);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (unusedDevDependencies > 0) {
|
|
1080
|
+
const packageLocation = `${location}/package.json`;
|
|
1081
|
+
console.log(` ${chalk14.yellow(packageLocation)}
|
|
1082
|
+
`);
|
|
1083
|
+
}
|
|
1084
|
+
return unusedDevDependencies;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1088
|
+
import chalk15 from "chalk";
|
|
833
1089
|
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
834
1090
|
let unusedDependencies = 0;
|
|
835
1091
|
for (const dep of peerDependencies) {
|
|
836
1092
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
837
1093
|
unusedDependencies++;
|
|
838
1094
|
if (dependencies.includes(dep)) {
|
|
839
|
-
console.log(`[${
|
|
1095
|
+
console.log(`[${chalk15.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk15.red(dep)}`);
|
|
840
1096
|
} else {
|
|
841
|
-
console.log(`[${
|
|
1097
|
+
console.log(`[${chalk15.blue(name)}] Unused peerDependency in package.json: ${chalk15.red(dep)}`);
|
|
842
1098
|
}
|
|
843
1099
|
}
|
|
844
1100
|
}
|
|
845
1101
|
if (unusedDependencies > 0) {
|
|
846
1102
|
const packageLocation = `${location}/package.json`;
|
|
847
|
-
console.log(` ${
|
|
1103
|
+
console.log(` ${chalk15.yellow(packageLocation)}
|
|
848
1104
|
`);
|
|
849
1105
|
}
|
|
850
1106
|
return unusedDependencies;
|
|
851
1107
|
}
|
|
852
1108
|
|
|
853
1109
|
// src/actions/deplint/checkPackage/checkPackage.ts
|
|
1110
|
+
function logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends) {
|
|
1111
|
+
console.info(`Checking package: ${name} at ${location}`);
|
|
1112
|
+
console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}, Config files: ${configFiles.length}`);
|
|
1113
|
+
for (const file of srcFiles) {
|
|
1114
|
+
console.info(`Source file: ${file}`);
|
|
1115
|
+
}
|
|
1116
|
+
for (const file of distFiles) {
|
|
1117
|
+
console.info(`Distribution file: ${file}`);
|
|
1118
|
+
}
|
|
1119
|
+
for (const file of configFiles) {
|
|
1120
|
+
console.info(`Config file: ${file}`);
|
|
1121
|
+
}
|
|
1122
|
+
for (const ext of tsconfigExtends) {
|
|
1123
|
+
console.info(`Tsconfig extends: ${ext}`);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
854
1126
|
function checkPackage({
|
|
855
1127
|
name,
|
|
856
1128
|
location,
|
|
@@ -859,27 +1131,36 @@ function checkPackage({
|
|
|
859
1131
|
peerDeps = false,
|
|
860
1132
|
verbose = false
|
|
861
1133
|
}) {
|
|
862
|
-
const {
|
|
1134
|
+
const {
|
|
1135
|
+
srcFiles,
|
|
1136
|
+
distFiles,
|
|
1137
|
+
configFiles
|
|
1138
|
+
} = findFiles(location);
|
|
1139
|
+
const tsconfigExtends = getExtendsFromTsconfigs(location);
|
|
863
1140
|
if (verbose) {
|
|
864
|
-
|
|
865
|
-
console.info(`Source files: ${srcFiles.length}, Distribution files: ${distFiles.length}`);
|
|
866
|
-
for (const file of srcFiles) {
|
|
867
|
-
console.info(`Source file: ${file}`);
|
|
868
|
-
}
|
|
869
|
-
for (const file of distFiles) {
|
|
870
|
-
console.info(`Distribution file: ${file}`);
|
|
871
|
-
}
|
|
1141
|
+
logVerbose(name, location, srcFiles, distFiles, configFiles, tsconfigExtends);
|
|
872
1142
|
}
|
|
873
1143
|
const checkDeps = deps || !(deps || devDeps || peerDeps);
|
|
874
1144
|
const checkDevDeps = devDeps || !(deps || devDeps || peerDeps);
|
|
875
1145
|
const checkPeerDeps = peerDeps;
|
|
876
|
-
const sourceParams = getExternalImportsFromFiles({
|
|
1146
|
+
const sourceParams = getExternalImportsFromFiles({
|
|
1147
|
+
srcFiles,
|
|
1148
|
+
distFiles,
|
|
1149
|
+
configFiles,
|
|
1150
|
+
tsconfigExtends
|
|
1151
|
+
});
|
|
877
1152
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
878
1153
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
879
1154
|
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
880
1155
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1156
|
+
const fileContext = {
|
|
1157
|
+
configFiles,
|
|
1158
|
+
distFiles,
|
|
1159
|
+
srcFiles
|
|
1160
|
+
};
|
|
1161
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
881
1162
|
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
882
|
-
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedPeerDependencies;
|
|
1163
|
+
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
883
1164
|
return totalErrors;
|
|
884
1165
|
}
|
|
885
1166
|
|
|
@@ -917,9 +1198,9 @@ var deplint = ({
|
|
|
917
1198
|
});
|
|
918
1199
|
}
|
|
919
1200
|
if (totalErrors > 0) {
|
|
920
|
-
console.warn(`Deplint: Found ${
|
|
1201
|
+
console.warn(`Deplint: Found ${chalk16.red(totalErrors)} dependency problems. ${chalk16.red("\u2716")}`);
|
|
921
1202
|
} else {
|
|
922
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1203
|
+
console.info(`Deplint: Found no dependency problems. ${chalk16.green("\u2714")}`);
|
|
923
1204
|
}
|
|
924
1205
|
return 0;
|
|
925
1206
|
};
|
|
@@ -1021,22 +1302,22 @@ var deployNext = () => {
|
|
|
1021
1302
|
};
|
|
1022
1303
|
|
|
1023
1304
|
// src/actions/dupdeps.ts
|
|
1024
|
-
import
|
|
1305
|
+
import chalk17 from "chalk";
|
|
1025
1306
|
var dupdeps = () => {
|
|
1026
|
-
console.log(
|
|
1307
|
+
console.log(chalk17.green("Checking all Dependencies for Duplicates"));
|
|
1027
1308
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1028
1309
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1029
1310
|
return detectDuplicateDependencies(dependencies);
|
|
1030
1311
|
};
|
|
1031
1312
|
|
|
1032
1313
|
// src/actions/lint.ts
|
|
1033
|
-
import
|
|
1314
|
+
import chalk18 from "chalk";
|
|
1034
1315
|
var lintPackage = ({
|
|
1035
1316
|
pkg,
|
|
1036
1317
|
fix: fix2,
|
|
1037
1318
|
verbose
|
|
1038
1319
|
}) => {
|
|
1039
|
-
console.log(
|
|
1320
|
+
console.log(chalk18.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1040
1321
|
const start = Date.now();
|
|
1041
1322
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1042
1323
|
["yarn", [
|
|
@@ -1046,7 +1327,7 @@ var lintPackage = ({
|
|
|
1046
1327
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1047
1328
|
]]
|
|
1048
1329
|
]);
|
|
1049
|
-
console.log(
|
|
1330
|
+
console.log(chalk18.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk18.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk18.gray("seconds")}`));
|
|
1050
1331
|
return result;
|
|
1051
1332
|
};
|
|
1052
1333
|
var lint = ({
|
|
@@ -1066,13 +1347,13 @@ var lint = ({
|
|
|
1066
1347
|
});
|
|
1067
1348
|
};
|
|
1068
1349
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1069
|
-
console.log(
|
|
1350
|
+
console.log(chalk18.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1070
1351
|
const start = Date.now();
|
|
1071
1352
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1072
1353
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1073
1354
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1074
1355
|
]);
|
|
1075
|
-
console.log(
|
|
1356
|
+
console.log(chalk18.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk18.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk18.gray("seconds")}`));
|
|
1076
1357
|
return result;
|
|
1077
1358
|
};
|
|
1078
1359
|
|
|
@@ -1100,7 +1381,7 @@ var filename = ".gitignore";
|
|
|
1100
1381
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1101
1382
|
|
|
1102
1383
|
// src/actions/gitlint.ts
|
|
1103
|
-
import
|
|
1384
|
+
import chalk19 from "chalk";
|
|
1104
1385
|
import ParseGitConfig from "parse-git-config";
|
|
1105
1386
|
var gitlint = () => {
|
|
1106
1387
|
console.log(`
|
|
@@ -1111,7 +1392,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1111
1392
|
const errors = 0;
|
|
1112
1393
|
const gitConfig = ParseGitConfig.sync();
|
|
1113
1394
|
const warn = (message) => {
|
|
1114
|
-
console.warn(
|
|
1395
|
+
console.warn(chalk19.yellow(`Warning: ${message}`));
|
|
1115
1396
|
warnings++;
|
|
1116
1397
|
};
|
|
1117
1398
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1131,13 +1412,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1131
1412
|
}
|
|
1132
1413
|
const resultMessages = [];
|
|
1133
1414
|
if (valid > 0) {
|
|
1134
|
-
resultMessages.push(
|
|
1415
|
+
resultMessages.push(chalk19.green(`Passed: ${valid}`));
|
|
1135
1416
|
}
|
|
1136
1417
|
if (warnings > 0) {
|
|
1137
|
-
resultMessages.push(
|
|
1418
|
+
resultMessages.push(chalk19.yellow(`Warnings: ${warnings}`));
|
|
1138
1419
|
}
|
|
1139
1420
|
if (errors > 0) {
|
|
1140
|
-
resultMessages.push(
|
|
1421
|
+
resultMessages.push(chalk19.red(` Errors: ${errors}`));
|
|
1141
1422
|
}
|
|
1142
1423
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1143
1424
|
`);
|
|
@@ -1146,7 +1427,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1146
1427
|
|
|
1147
1428
|
// src/actions/gitlint-fix.ts
|
|
1148
1429
|
import { execSync as execSync2 } from "child_process";
|
|
1149
|
-
import
|
|
1430
|
+
import chalk20 from "chalk";
|
|
1150
1431
|
import ParseGitConfig2 from "parse-git-config";
|
|
1151
1432
|
var gitlintFix = () => {
|
|
1152
1433
|
console.log(`
|
|
@@ -1155,15 +1436,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1155
1436
|
const gitConfig = ParseGitConfig2.sync();
|
|
1156
1437
|
if (gitConfig.core.ignorecase) {
|
|
1157
1438
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1158
|
-
console.warn(
|
|
1439
|
+
console.warn(chalk20.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1159
1440
|
}
|
|
1160
1441
|
if (gitConfig.core.autocrlf !== false) {
|
|
1161
1442
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1162
|
-
console.warn(
|
|
1443
|
+
console.warn(chalk20.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1163
1444
|
}
|
|
1164
1445
|
if (gitConfig.core.eol !== "lf") {
|
|
1165
1446
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1166
|
-
console.warn(
|
|
1447
|
+
console.warn(chalk20.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1167
1448
|
}
|
|
1168
1449
|
return 1;
|
|
1169
1450
|
};
|
|
@@ -1174,7 +1455,7 @@ var knip = () => {
|
|
|
1174
1455
|
};
|
|
1175
1456
|
|
|
1176
1457
|
// src/actions/license.ts
|
|
1177
|
-
import
|
|
1458
|
+
import chalk21 from "chalk";
|
|
1178
1459
|
import { init } from "license-checker";
|
|
1179
1460
|
var license = async (pkg) => {
|
|
1180
1461
|
const workspaces = yarnWorkspaces();
|
|
@@ -1199,18 +1480,18 @@ var license = async (pkg) => {
|
|
|
1199
1480
|
"LGPL-3.0-or-later",
|
|
1200
1481
|
"Python-2.0"
|
|
1201
1482
|
]);
|
|
1202
|
-
console.log(
|
|
1483
|
+
console.log(chalk21.green("License Checker"));
|
|
1203
1484
|
return (await Promise.all(
|
|
1204
1485
|
workspaceList.map(({ location, name }) => {
|
|
1205
1486
|
return new Promise((resolve) => {
|
|
1206
1487
|
init({ production: true, start: location }, (error, packages) => {
|
|
1207
1488
|
if (error) {
|
|
1208
|
-
console.error(
|
|
1209
|
-
console.error(
|
|
1489
|
+
console.error(chalk21.red(`License Checker [${name}] Error`));
|
|
1490
|
+
console.error(chalk21.gray(error));
|
|
1210
1491
|
console.log("\n");
|
|
1211
1492
|
resolve(1);
|
|
1212
1493
|
} else {
|
|
1213
|
-
console.log(
|
|
1494
|
+
console.log(chalk21.green(`License Checker [${name}]`));
|
|
1214
1495
|
let count = 0;
|
|
1215
1496
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1216
1497
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1226,7 +1507,7 @@ var license = async (pkg) => {
|
|
|
1226
1507
|
}
|
|
1227
1508
|
if (!orLicenseFound) {
|
|
1228
1509
|
count++;
|
|
1229
|
-
console.warn(
|
|
1510
|
+
console.warn(chalk21.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1230
1511
|
}
|
|
1231
1512
|
}
|
|
1232
1513
|
}
|
|
@@ -1270,7 +1551,7 @@ var rebuild = ({ target }) => {
|
|
|
1270
1551
|
};
|
|
1271
1552
|
|
|
1272
1553
|
// src/actions/recompile.ts
|
|
1273
|
-
import
|
|
1554
|
+
import chalk22 from "chalk";
|
|
1274
1555
|
var recompile = async ({
|
|
1275
1556
|
verbose,
|
|
1276
1557
|
target,
|
|
@@ -1306,7 +1587,7 @@ var recompileAll = async ({
|
|
|
1306
1587
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
1307
1588
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
1308
1589
|
if (jobs) {
|
|
1309
|
-
console.log(
|
|
1590
|
+
console.log(chalk22.blue(`Jobs set to [${jobs}]`));
|
|
1310
1591
|
}
|
|
1311
1592
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
1312
1593
|
[
|
|
@@ -1337,7 +1618,7 @@ var recompileAll = async ({
|
|
|
1337
1618
|
]
|
|
1338
1619
|
]);
|
|
1339
1620
|
console.log(
|
|
1340
|
-
`${
|
|
1621
|
+
`${chalk22.gray("Recompiled in")} [${chalk22.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk22.gray("seconds")}`
|
|
1341
1622
|
);
|
|
1342
1623
|
return result;
|
|
1343
1624
|
};
|
|
@@ -1368,13 +1649,13 @@ var reinstall = () => {
|
|
|
1368
1649
|
};
|
|
1369
1650
|
|
|
1370
1651
|
// src/actions/relint.ts
|
|
1371
|
-
import
|
|
1652
|
+
import chalk23 from "chalk";
|
|
1372
1653
|
var relintPackage = ({
|
|
1373
1654
|
pkg,
|
|
1374
1655
|
fix: fix2,
|
|
1375
1656
|
verbose
|
|
1376
1657
|
}) => {
|
|
1377
|
-
console.log(
|
|
1658
|
+
console.log(chalk23.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1378
1659
|
const start = Date.now();
|
|
1379
1660
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1380
1661
|
["yarn", [
|
|
@@ -1384,7 +1665,7 @@ var relintPackage = ({
|
|
|
1384
1665
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1385
1666
|
]]
|
|
1386
1667
|
]);
|
|
1387
|
-
console.log(
|
|
1668
|
+
console.log(chalk23.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk23.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk23.gray("seconds")}`));
|
|
1388
1669
|
return result;
|
|
1389
1670
|
};
|
|
1390
1671
|
var relint = ({
|
|
@@ -1404,13 +1685,13 @@ var relint = ({
|
|
|
1404
1685
|
});
|
|
1405
1686
|
};
|
|
1406
1687
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1407
|
-
console.log(
|
|
1688
|
+
console.log(chalk23.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1408
1689
|
const start = Date.now();
|
|
1409
1690
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1410
1691
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1411
1692
|
["yarn", ["eslint", ...fixOptions]]
|
|
1412
1693
|
]);
|
|
1413
|
-
console.log(
|
|
1694
|
+
console.log(chalk23.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk23.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk23.gray("seconds")}`));
|
|
1414
1695
|
return result;
|
|
1415
1696
|
};
|
|
1416
1697
|
|
|
@@ -1428,10 +1709,10 @@ var sonar = () => {
|
|
|
1428
1709
|
};
|
|
1429
1710
|
|
|
1430
1711
|
// src/actions/statics.ts
|
|
1431
|
-
import
|
|
1712
|
+
import chalk24 from "chalk";
|
|
1432
1713
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
1433
1714
|
var statics = () => {
|
|
1434
|
-
console.log(
|
|
1715
|
+
console.log(chalk24.green("Check Required Static Dependencies"));
|
|
1435
1716
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
1436
1717
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
1437
1718
|
};
|
|
@@ -1831,7 +2112,7 @@ var xyInstallCommands = (args) => {
|
|
|
1831
2112
|
};
|
|
1832
2113
|
|
|
1833
2114
|
// src/xy/xyLintCommands.ts
|
|
1834
|
-
import
|
|
2115
|
+
import chalk25 from "chalk";
|
|
1835
2116
|
var xyLintCommands = (args) => {
|
|
1836
2117
|
return args.command(
|
|
1837
2118
|
"cycle [package]",
|
|
@@ -1843,7 +2124,7 @@ var xyLintCommands = (args) => {
|
|
|
1843
2124
|
const start = Date.now();
|
|
1844
2125
|
if (argv.verbose) console.log("Cycle");
|
|
1845
2126
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
1846
|
-
console.log(
|
|
2127
|
+
console.log(chalk25.blue(`Finished in ${Date.now() - start}ms`));
|
|
1847
2128
|
}
|
|
1848
2129
|
).command(
|
|
1849
2130
|
"lint [package]",
|
|
@@ -1873,7 +2154,7 @@ var xyLintCommands = (args) => {
|
|
|
1873
2154
|
cache: argv.cache,
|
|
1874
2155
|
verbose: !!argv.verbose
|
|
1875
2156
|
});
|
|
1876
|
-
console.log(
|
|
2157
|
+
console.log(chalk25.blue(`Finished in ${Date.now() - start}ms`));
|
|
1877
2158
|
}
|
|
1878
2159
|
).command(
|
|
1879
2160
|
"deplint [package]",
|
|
@@ -1906,7 +2187,7 @@ var xyLintCommands = (args) => {
|
|
|
1906
2187
|
peerDeps: !!argv.peerDeps,
|
|
1907
2188
|
verbose: !!argv.verbose
|
|
1908
2189
|
});
|
|
1909
|
-
console.log(
|
|
2190
|
+
console.log(chalk25.blue(`Finished in ${Date.now() - start}ms`));
|
|
1910
2191
|
}
|
|
1911
2192
|
).command(
|
|
1912
2193
|
"fix [package]",
|
|
@@ -1918,7 +2199,7 @@ var xyLintCommands = (args) => {
|
|
|
1918
2199
|
const start = Date.now();
|
|
1919
2200
|
if (argv.verbose) console.log("Fix");
|
|
1920
2201
|
process.exitCode = fix();
|
|
1921
|
-
console.log(
|
|
2202
|
+
console.log(chalk25.blue(`Finished in ${Date.now() - start}ms`));
|
|
1922
2203
|
}
|
|
1923
2204
|
).command(
|
|
1924
2205
|
"relint [package]",
|
|
@@ -1930,7 +2211,7 @@ var xyLintCommands = (args) => {
|
|
|
1930
2211
|
if (argv.verbose) console.log("Relinting");
|
|
1931
2212
|
const start = Date.now();
|
|
1932
2213
|
process.exitCode = relint();
|
|
1933
|
-
console.log(
|
|
2214
|
+
console.log(chalk25.blue(`Finished in ${Date.now() - start}ms`));
|
|
1934
2215
|
}
|
|
1935
2216
|
).command(
|
|
1936
2217
|
"publint [package]",
|
|
@@ -1942,7 +2223,7 @@ var xyLintCommands = (args) => {
|
|
|
1942
2223
|
if (argv.verbose) console.log("Publint");
|
|
1943
2224
|
const start = Date.now();
|
|
1944
2225
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
1945
|
-
console.log(
|
|
2226
|
+
console.log(chalk25.blue(`Finished in ${Date.now() - start}ms`));
|
|
1946
2227
|
}
|
|
1947
2228
|
).command(
|
|
1948
2229
|
"knip",
|
|
@@ -1954,7 +2235,7 @@ var xyLintCommands = (args) => {
|
|
|
1954
2235
|
if (argv.verbose) console.log("Knip");
|
|
1955
2236
|
const start = Date.now();
|
|
1956
2237
|
process.exitCode = knip();
|
|
1957
|
-
console.log(
|
|
2238
|
+
console.log(chalk25.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
1958
2239
|
}
|
|
1959
2240
|
).command(
|
|
1960
2241
|
"sonar",
|
|
@@ -1966,7 +2247,7 @@ var xyLintCommands = (args) => {
|
|
|
1966
2247
|
const start = Date.now();
|
|
1967
2248
|
if (argv.verbose) console.log("Sonar Check");
|
|
1968
2249
|
process.exitCode = sonar();
|
|
1969
|
-
console.log(
|
|
2250
|
+
console.log(chalk25.blue(`Finished in ${Date.now() - start}ms`));
|
|
1970
2251
|
}
|
|
1971
2252
|
);
|
|
1972
2253
|
};
|
|
@@ -2002,8 +2283,8 @@ var xyParseOptions = () => {
|
|
|
2002
2283
|
var xy = async () => {
|
|
2003
2284
|
const options = xyParseOptions();
|
|
2004
2285
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
2005
|
-
console.error(
|
|
2006
|
-
console.log(
|
|
2286
|
+
console.error(chalk26.yellow(`Command not found [${chalk26.magenta(process.argv[2])}]`));
|
|
2287
|
+
console.log(chalk26.gray("Try 'yarn xy --help' for list of commands"));
|
|
2007
2288
|
}).version().help().argv;
|
|
2008
2289
|
};
|
|
2009
2290
|
|