@xylabs/ts-scripts-yarn3 7.4.10 → 7.4.11
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 +115 -16
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +2 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +114 -20
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +2 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +115 -16
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +166 -38
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs +140 -0
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs.map +1 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs +3 -1
- package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +166 -38
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +147 -40
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +251 -117
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +23 -2
- package/dist/index.mjs +155 -42
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +251 -117
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +251 -117
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +205 -71
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +2 -2
package/dist/bin/xy.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/xy/xy.ts
|
|
4
|
-
import
|
|
4
|
+
import chalk29 from "chalk";
|
|
5
5
|
|
|
6
6
|
// src/actions/build.ts
|
|
7
|
-
import
|
|
7
|
+
import chalk8 from "chalk";
|
|
8
8
|
|
|
9
9
|
// src/lib/checkResult.ts
|
|
10
10
|
import chalk from "chalk";
|
|
@@ -326,10 +326,31 @@ var generateIgnoreFiles = (filename3, pkg) => {
|
|
|
326
326
|
return succeeded ? 0 : 1;
|
|
327
327
|
};
|
|
328
328
|
|
|
329
|
+
// src/lib/loadConfig.ts
|
|
330
|
+
import chalk5 from "chalk";
|
|
331
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
332
|
+
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
333
|
+
import deepmerge from "deepmerge";
|
|
334
|
+
var config;
|
|
335
|
+
var loadConfig = async (params) => {
|
|
336
|
+
if (config === void 0) {
|
|
337
|
+
const cosmicConfigResult = await cosmiconfig("xy", { cache: true, loaders: { ".ts": TypeScriptLoader() } }).search();
|
|
338
|
+
config = cosmicConfigResult?.config;
|
|
339
|
+
const configFilePath = cosmicConfigResult?.filepath;
|
|
340
|
+
if (configFilePath !== void 0) {
|
|
341
|
+
console.log(chalk5.green(`Loaded config from ${configFilePath}`));
|
|
342
|
+
if (config.verbose) {
|
|
343
|
+
console.log(chalk5.gray(`${JSON.stringify(config, null, 2)}`));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return deepmerge(config, params ?? {});
|
|
348
|
+
};
|
|
349
|
+
|
|
329
350
|
// src/lib/parsedPackageJSON.ts
|
|
330
351
|
import { readFileSync as readFileSync3 } from "fs";
|
|
331
|
-
var parsedPackageJSON = (
|
|
332
|
-
const pathToPackageJSON =
|
|
352
|
+
var parsedPackageJSON = (path8) => {
|
|
353
|
+
const pathToPackageJSON = path8 ?? process.env.npm_package_json ?? "";
|
|
333
354
|
const packageJSON = readFileSync3(pathToPackageJSON).toString();
|
|
334
355
|
return JSON.parse(packageJSON);
|
|
335
356
|
};
|
|
@@ -337,22 +358,22 @@ var parsedPackageJSON = (path7) => {
|
|
|
337
358
|
// src/lib/runSteps.ts
|
|
338
359
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
339
360
|
import { existsSync as existsSync2 } from "fs";
|
|
340
|
-
import
|
|
361
|
+
import chalk6 from "chalk";
|
|
341
362
|
var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
342
363
|
return safeExit(() => {
|
|
343
364
|
const pkgName = process.env.npm_package_name;
|
|
344
|
-
console.log(
|
|
365
|
+
console.log(chalk6.green(`${name} [${pkgName}]`));
|
|
345
366
|
let totalStatus = 0;
|
|
346
|
-
for (const [i, [command, args,
|
|
367
|
+
for (const [i, [command, args, config2]] of steps.entries()) {
|
|
347
368
|
if (messages?.[i]) {
|
|
348
|
-
console.log(
|
|
369
|
+
console.log(chalk6.gray(messages?.[i]));
|
|
349
370
|
}
|
|
350
371
|
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
351
372
|
if (command === "node" && !existsSync2(argList[0])) {
|
|
352
373
|
throw new Error(`File not found [${argList[0]}]`);
|
|
353
374
|
}
|
|
354
375
|
const status = spawnSync3(command, Array.isArray(args) ? args : args.split(" "), {
|
|
355
|
-
...
|
|
376
|
+
...config2,
|
|
356
377
|
encoding: "utf8",
|
|
357
378
|
env: { FORCE_COLOR: "3", ...process.env },
|
|
358
379
|
shell: true,
|
|
@@ -368,27 +389,27 @@ var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
|
368
389
|
// src/lib/runStepsAsync.ts
|
|
369
390
|
import { spawn } from "child_process";
|
|
370
391
|
import { existsSync as existsSync3 } from "fs";
|
|
371
|
-
import
|
|
392
|
+
import chalk7 from "chalk";
|
|
372
393
|
var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
373
394
|
return new Promise((resolve) => {
|
|
374
|
-
const [command, args,
|
|
395
|
+
const [command, args, config2] = step;
|
|
375
396
|
if (message) {
|
|
376
|
-
console.log(
|
|
397
|
+
console.log(chalk7.gray(message));
|
|
377
398
|
}
|
|
378
399
|
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
379
400
|
if (command === "node" && !existsSync3(argList[0])) {
|
|
380
401
|
throw new Error(`File not found [${argList[0]}]`);
|
|
381
402
|
}
|
|
382
403
|
spawn(command, Array.isArray(args) ? args : args.split(" "), {
|
|
383
|
-
...
|
|
404
|
+
...config2,
|
|
384
405
|
env: { FORCE_COLOR: "3", ...process.env },
|
|
385
406
|
shell: true,
|
|
386
407
|
stdio: "inherit"
|
|
387
408
|
}).on("close", (code) => {
|
|
388
409
|
if (code) {
|
|
389
410
|
console.error(
|
|
390
|
-
|
|
391
|
-
`Command Exited With Non-Zero Result [${
|
|
411
|
+
chalk7.red(
|
|
412
|
+
`Command Exited With Non-Zero Result [${chalk7.gray(code)}] | ${chalk7.yellow(command)} ${chalk7.white(
|
|
392
413
|
Array.isArray(args) ? args.join(" ") : args
|
|
393
414
|
)}`
|
|
394
415
|
)
|
|
@@ -404,7 +425,7 @@ var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
|
404
425
|
var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
|
|
405
426
|
return await safeExitAsync(async () => {
|
|
406
427
|
const pkgName = process.env.npm_package_name;
|
|
407
|
-
console.log(
|
|
428
|
+
console.log(chalk7.green(`${name} [${pkgName}]`));
|
|
408
429
|
let result = 0;
|
|
409
430
|
for (const [i, step] of steps.entries()) {
|
|
410
431
|
result += await runStepAsync(name, step, exitOnFail, messages?.[i]);
|
|
@@ -428,7 +449,7 @@ var build = async ({
|
|
|
428
449
|
const targetOptions = target === void 0 ? [] : ["-t", target];
|
|
429
450
|
const jobsOptions = jobs === void 0 ? [] : ["-j", `${jobs}`];
|
|
430
451
|
if (jobs !== void 0) {
|
|
431
|
-
console.log(
|
|
452
|
+
console.log(chalk8.blue(`Jobs set to [${jobs}]`));
|
|
432
453
|
}
|
|
433
454
|
const result = await runStepsAsync(`Build${incremental ? "-Incremental" : ""} [${pkg ?? "All"}]`, [
|
|
434
455
|
["yarn", ["xy", "compile", ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, "--types", "tsup"]],
|
|
@@ -436,7 +457,7 @@ var build = async ({
|
|
|
436
457
|
["yarn", ["xy", "deplint", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
|
|
437
458
|
["yarn", ["xy", "lint", ...pkgOptions, ...verboseOptions, ...incrementalOptions]]
|
|
438
459
|
]);
|
|
439
|
-
console.log(`${
|
|
460
|
+
console.log(`${chalk8.gray("Built in")} [${chalk8.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk8.gray("seconds")}`);
|
|
440
461
|
return result;
|
|
441
462
|
};
|
|
442
463
|
|
|
@@ -450,7 +471,7 @@ import {
|
|
|
450
471
|
writeFileSync as writeFileSync2
|
|
451
472
|
} from "fs";
|
|
452
473
|
import PATH2 from "path";
|
|
453
|
-
import
|
|
474
|
+
import chalk9 from "chalk";
|
|
454
475
|
var syncCommandFiles = (commandsDir) => {
|
|
455
476
|
const templates = claudeCommandTemplates();
|
|
456
477
|
const templateNames = new Set(Object.keys(templates));
|
|
@@ -491,9 +512,9 @@ var logCommandsResult = (created, updated, removed) => {
|
|
|
491
512
|
updated ? `${updated} updated` : "",
|
|
492
513
|
removed ? `${removed} removed` : ""
|
|
493
514
|
].filter(Boolean);
|
|
494
|
-
console.log(
|
|
515
|
+
console.log(chalk9.green(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: ${parts.join(", ")}`));
|
|
495
516
|
} else {
|
|
496
|
-
console.log(
|
|
517
|
+
console.log(chalk9.gray(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: already up to date`));
|
|
497
518
|
}
|
|
498
519
|
};
|
|
499
520
|
var claudeCommands = () => {
|
|
@@ -520,7 +541,7 @@ import {
|
|
|
520
541
|
writeFileSync as writeFileSync3
|
|
521
542
|
} from "fs";
|
|
522
543
|
import PATH3 from "path";
|
|
523
|
-
import
|
|
544
|
+
import chalk10 from "chalk";
|
|
524
545
|
var syncRuleFiles = (rulesDir) => {
|
|
525
546
|
const templates = claudeMdRuleTemplates();
|
|
526
547
|
const templateNames = new Set(Object.keys(templates));
|
|
@@ -561,21 +582,21 @@ var logRulesResult = (created, updated, removed) => {
|
|
|
561
582
|
updated ? `${updated} updated` : "",
|
|
562
583
|
removed ? `${removed} removed` : ""
|
|
563
584
|
].filter(Boolean);
|
|
564
|
-
console.log(
|
|
585
|
+
console.log(chalk10.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
|
|
565
586
|
} else {
|
|
566
|
-
console.log(
|
|
587
|
+
console.log(chalk10.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
|
|
567
588
|
}
|
|
568
589
|
};
|
|
569
590
|
var ensureProjectClaudeMd = (cwd, force) => {
|
|
570
591
|
const projectPath = PATH3.resolve(cwd, "CLAUDE.md");
|
|
571
592
|
if (!existsSync5(projectPath) || force) {
|
|
572
593
|
if (force && existsSync5(projectPath)) {
|
|
573
|
-
console.log(
|
|
594
|
+
console.log(chalk10.yellow("Overwriting existing CLAUDE.md"));
|
|
574
595
|
}
|
|
575
596
|
writeFileSync3(projectPath, claudeMdProjectTemplate(), "utf8");
|
|
576
|
-
console.log(
|
|
597
|
+
console.log(chalk10.green("Generated CLAUDE.md"));
|
|
577
598
|
} else {
|
|
578
|
-
console.log(
|
|
599
|
+
console.log(chalk10.gray("CLAUDE.md already exists (skipped)"));
|
|
579
600
|
}
|
|
580
601
|
};
|
|
581
602
|
var claudeRules = ({ force } = {}) => {
|
|
@@ -607,16 +628,16 @@ var cleanAll = ({ verbose }) => {
|
|
|
607
628
|
|
|
608
629
|
// src/actions/clean-docs.ts
|
|
609
630
|
import path from "path";
|
|
610
|
-
import
|
|
631
|
+
import chalk11 from "chalk";
|
|
611
632
|
var cleanDocs = () => {
|
|
612
633
|
const pkgName = process.env.npm_package_name;
|
|
613
|
-
console.log(
|
|
634
|
+
console.log(chalk11.green(`Cleaning Docs [${pkgName}]`));
|
|
614
635
|
for (const { location } of yarnWorkspaces()) deleteGlob(path.join(location, "docs"));
|
|
615
636
|
return 0;
|
|
616
637
|
};
|
|
617
638
|
|
|
618
639
|
// src/actions/compile.ts
|
|
619
|
-
import
|
|
640
|
+
import chalk12 from "chalk";
|
|
620
641
|
var compile = ({
|
|
621
642
|
verbose,
|
|
622
643
|
target,
|
|
@@ -657,7 +678,7 @@ var compileAll = ({
|
|
|
657
678
|
const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
|
|
658
679
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
659
680
|
if (jobs) {
|
|
660
|
-
console.log(
|
|
681
|
+
console.log(chalk12.blue(`Jobs set to [${jobs}]`));
|
|
661
682
|
}
|
|
662
683
|
const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
|
|
663
684
|
["yarn", [
|
|
@@ -671,13 +692,13 @@ var compileAll = ({
|
|
|
671
692
|
...targetOptions
|
|
672
693
|
]]
|
|
673
694
|
]);
|
|
674
|
-
console.log(`${
|
|
695
|
+
console.log(`${chalk12.gray("Compiled in")} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`);
|
|
675
696
|
return result;
|
|
676
697
|
};
|
|
677
698
|
|
|
678
699
|
// src/actions/copy-assets.ts
|
|
679
700
|
import path2 from "path/posix";
|
|
680
|
-
import
|
|
701
|
+
import chalk13 from "chalk";
|
|
681
702
|
import cpy from "cpy";
|
|
682
703
|
var copyPackageTargetAssets = async (target, name, location) => {
|
|
683
704
|
try {
|
|
@@ -700,7 +721,7 @@ var copyPackageTargetAssets = async (target, name, location) => {
|
|
|
700
721
|
};
|
|
701
722
|
var copyTargetAssets = async (target, pkg) => {
|
|
702
723
|
const workspaces = yarnWorkspaces();
|
|
703
|
-
console.log(
|
|
724
|
+
console.log(chalk13.green(`Copying Assets [${target.toUpperCase()}]`));
|
|
704
725
|
const workspaceList = workspaces.filter(({ name }) => {
|
|
705
726
|
return pkg === void 0 || name === pkg;
|
|
706
727
|
});
|
|
@@ -784,7 +805,7 @@ var dead = () => {
|
|
|
784
805
|
};
|
|
785
806
|
|
|
786
807
|
// src/actions/deplint/deplint.ts
|
|
787
|
-
import
|
|
808
|
+
import chalk19 from "chalk";
|
|
788
809
|
|
|
789
810
|
// src/actions/deplint/findFiles.ts
|
|
790
811
|
import fs2 from "fs";
|
|
@@ -960,11 +981,11 @@ function getExternalImportsFromFiles({
|
|
|
960
981
|
const allImportPaths = {};
|
|
961
982
|
const distImportPaths = {};
|
|
962
983
|
const distTypeImportPaths = {};
|
|
963
|
-
for (const
|
|
984
|
+
for (const path8 of allFiles) getImportsFromFile(path8, allImportPaths, allImportPaths).flat();
|
|
964
985
|
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
965
986
|
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
966
|
-
for (const
|
|
967
|
-
for (const
|
|
987
|
+
for (const path8 of distCodeFiles) getImportsFromFile(path8, distImportPaths, distImportPaths).flat();
|
|
988
|
+
for (const path8 of distTypeFiles) getImportsFromFile(path8, distTypeImportPaths, distTypeImportPaths).flat();
|
|
968
989
|
const allImports = Object.keys(allImportPaths);
|
|
969
990
|
const distImports = Object.keys(distImportPaths);
|
|
970
991
|
const externalAllImports = removeInternalImports(allImports);
|
|
@@ -986,12 +1007,12 @@ function getExternalImportsFromFiles({
|
|
|
986
1007
|
|
|
987
1008
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
988
1009
|
import { builtinModules } from "module";
|
|
989
|
-
import
|
|
1010
|
+
import chalk14 from "chalk";
|
|
990
1011
|
function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
|
|
991
1012
|
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
|
|
992
1013
|
}
|
|
993
1014
|
function logMissing(name, imp, importPaths) {
|
|
994
|
-
console.log(`[${
|
|
1015
|
+
console.log(`[${chalk14.blue(name)}] Missing dependency in package.json: ${chalk14.red(imp)}`);
|
|
995
1016
|
if (importPaths[imp]) {
|
|
996
1017
|
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
997
1018
|
}
|
|
@@ -1016,7 +1037,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
1016
1037
|
}
|
|
1017
1038
|
if (unlistedDependencies > 0) {
|
|
1018
1039
|
const packageLocation = `${location}/package.json`;
|
|
1019
|
-
console.log(` ${
|
|
1040
|
+
console.log(` ${chalk14.yellow(packageLocation)}
|
|
1020
1041
|
`);
|
|
1021
1042
|
}
|
|
1022
1043
|
return unlistedDependencies;
|
|
@@ -1024,7 +1045,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
1024
1045
|
|
|
1025
1046
|
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
1026
1047
|
import { builtinModules as builtinModules2 } from "module";
|
|
1027
|
-
import
|
|
1048
|
+
import chalk15 from "chalk";
|
|
1028
1049
|
function getUnlistedDevDependencies({ name, location }, {
|
|
1029
1050
|
devDependencies,
|
|
1030
1051
|
dependencies,
|
|
@@ -1038,7 +1059,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
1038
1059
|
for (const imp of externalAllImports) {
|
|
1039
1060
|
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)) {
|
|
1040
1061
|
unlistedDevDependencies++;
|
|
1041
|
-
console.log(`[${
|
|
1062
|
+
console.log(`[${chalk15.blue(name)}] Missing devDependency in package.json: ${chalk15.red(imp)}`);
|
|
1042
1063
|
if (allImportPaths[imp]) {
|
|
1043
1064
|
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
1044
1065
|
}
|
|
@@ -1046,40 +1067,50 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
1046
1067
|
}
|
|
1047
1068
|
if (unlistedDevDependencies > 0) {
|
|
1048
1069
|
const packageLocation = `${location}/package.json`;
|
|
1049
|
-
console.log(` ${
|
|
1070
|
+
console.log(` ${chalk15.yellow(packageLocation)}
|
|
1050
1071
|
`);
|
|
1051
1072
|
}
|
|
1052
1073
|
return unlistedDevDependencies;
|
|
1053
1074
|
}
|
|
1054
1075
|
|
|
1055
1076
|
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
1056
|
-
import
|
|
1077
|
+
import chalk16 from "chalk";
|
|
1057
1078
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
1058
1079
|
externalDistImports,
|
|
1059
1080
|
externalDistTypeImports,
|
|
1060
1081
|
externalAllImports
|
|
1061
|
-
}) {
|
|
1082
|
+
}, exclude) {
|
|
1062
1083
|
let unusedDependencies = 0;
|
|
1063
1084
|
for (const dep of dependencies) {
|
|
1085
|
+
if (exclude?.has(dep)) continue;
|
|
1064
1086
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1065
1087
|
unusedDependencies++;
|
|
1066
1088
|
if (externalAllImports.includes(dep)) {
|
|
1067
|
-
console.log(`[${
|
|
1089
|
+
console.log(`[${chalk16.blue(name)}] dependency should be devDependency in package.json: ${chalk16.red(dep)}`);
|
|
1068
1090
|
} else {
|
|
1069
|
-
console.log(`[${
|
|
1091
|
+
console.log(`[${chalk16.blue(name)}] Unused dependency in package.json: ${chalk16.red(dep)}`);
|
|
1070
1092
|
}
|
|
1071
1093
|
}
|
|
1072
1094
|
}
|
|
1073
1095
|
if (unusedDependencies > 0) {
|
|
1074
1096
|
const packageLocation = `${location}/package.json`;
|
|
1075
|
-
console.log(` ${
|
|
1097
|
+
console.log(` ${chalk16.yellow(packageLocation)}
|
|
1076
1098
|
`);
|
|
1077
1099
|
}
|
|
1078
1100
|
return unusedDependencies;
|
|
1079
1101
|
}
|
|
1080
1102
|
|
|
1081
1103
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1082
|
-
import
|
|
1104
|
+
import chalk17 from "chalk";
|
|
1105
|
+
|
|
1106
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1107
|
+
import fs8 from "fs";
|
|
1108
|
+
import path7 from "path";
|
|
1109
|
+
import ts2 from "typescript";
|
|
1110
|
+
|
|
1111
|
+
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1112
|
+
import fs7 from "fs";
|
|
1113
|
+
import path6 from "path";
|
|
1083
1114
|
|
|
1084
1115
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
1085
1116
|
import fs6 from "fs";
|
|
@@ -1114,8 +1145,6 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1114
1145
|
}
|
|
1115
1146
|
|
|
1116
1147
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1117
|
-
import fs7 from "fs";
|
|
1118
|
-
import path6 from "path";
|
|
1119
1148
|
function getBinNames(location, dep) {
|
|
1120
1149
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1121
1150
|
if (!depPkgPath) return [];
|
|
@@ -1165,15 +1194,101 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1165
1194
|
return referenced;
|
|
1166
1195
|
}
|
|
1167
1196
|
|
|
1197
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1198
|
+
var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
|
|
1199
|
+
var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
|
|
1200
|
+
var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
|
|
1201
|
+
function getCommandTokensFromFile(filePath) {
|
|
1202
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
1203
|
+
let sourceCode;
|
|
1204
|
+
try {
|
|
1205
|
+
sourceCode = fs8.readFileSync(filePath, "utf8");
|
|
1206
|
+
} catch {
|
|
1207
|
+
return tokens;
|
|
1208
|
+
}
|
|
1209
|
+
const isMjsFile = filePath.endsWith(".mjs");
|
|
1210
|
+
const sourceFile = ts2.createSourceFile(
|
|
1211
|
+
path7.basename(filePath),
|
|
1212
|
+
sourceCode,
|
|
1213
|
+
ts2.ScriptTarget.Latest,
|
|
1214
|
+
true,
|
|
1215
|
+
isMjsFile ? ts2.ScriptKind.JS : void 0
|
|
1216
|
+
);
|
|
1217
|
+
function visit(node) {
|
|
1218
|
+
if (ts2.isCallExpression(node) && node.arguments.length > 0) {
|
|
1219
|
+
const fnName = getFunctionName(node.expression);
|
|
1220
|
+
if (fnName && allExecFunctions.has(fnName)) {
|
|
1221
|
+
const firstArg = node.arguments[0];
|
|
1222
|
+
if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
|
|
1223
|
+
const value = firstArg.text;
|
|
1224
|
+
if (shellCommandFunctions.has(fnName)) {
|
|
1225
|
+
for (const token of tokenizeScript(value)) {
|
|
1226
|
+
tokens.add(token);
|
|
1227
|
+
}
|
|
1228
|
+
} else {
|
|
1229
|
+
tokens.add(value);
|
|
1230
|
+
}
|
|
1231
|
+
} else if (ts2.isTemplateExpression(firstArg)) {
|
|
1232
|
+
const head = firstArg.head.text;
|
|
1233
|
+
if (head) {
|
|
1234
|
+
for (const token of tokenizeScript(head)) {
|
|
1235
|
+
tokens.add(token);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
ts2.forEachChild(node, visit);
|
|
1242
|
+
}
|
|
1243
|
+
visit(sourceFile);
|
|
1244
|
+
return tokens;
|
|
1245
|
+
}
|
|
1246
|
+
function getFunctionName(expr) {
|
|
1247
|
+
if (ts2.isIdentifier(expr)) {
|
|
1248
|
+
return expr.text;
|
|
1249
|
+
}
|
|
1250
|
+
if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
|
|
1251
|
+
return expr.name.text;
|
|
1252
|
+
}
|
|
1253
|
+
return void 0;
|
|
1254
|
+
}
|
|
1255
|
+
function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
|
|
1256
|
+
const allTokens = /* @__PURE__ */ new Set();
|
|
1257
|
+
for (const file of allFiles) {
|
|
1258
|
+
for (const token of getCommandTokensFromFile(file)) {
|
|
1259
|
+
allTokens.add(token);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
if (allTokens.size === 0) return /* @__PURE__ */ new Set();
|
|
1263
|
+
const binToPackage = /* @__PURE__ */ new Map();
|
|
1264
|
+
for (const dep of allDeps) {
|
|
1265
|
+
for (const bin of getBinNames(location, dep)) {
|
|
1266
|
+
binToPackage.set(bin, dep);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1270
|
+
for (const token of allTokens) {
|
|
1271
|
+
const baseName = getBasePackageName(token);
|
|
1272
|
+
if (allDeps.includes(baseName)) {
|
|
1273
|
+
referenced.add(baseName);
|
|
1274
|
+
}
|
|
1275
|
+
const pkg = binToPackage.get(token);
|
|
1276
|
+
if (pkg) {
|
|
1277
|
+
referenced.add(pkg);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return referenced;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1168
1283
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1169
|
-
import
|
|
1284
|
+
import fs9 from "fs";
|
|
1170
1285
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1171
1286
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1172
1287
|
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1173
1288
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1174
1289
|
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1175
1290
|
try {
|
|
1176
|
-
const content =
|
|
1291
|
+
const content = fs9.readFileSync(file, "utf8");
|
|
1177
1292
|
return decoratorPattern.test(content);
|
|
1178
1293
|
} catch {
|
|
1179
1294
|
return false;
|
|
@@ -1186,7 +1301,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1186
1301
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1187
1302
|
if (!pkgPath) continue;
|
|
1188
1303
|
try {
|
|
1189
|
-
const pkg = JSON.parse(
|
|
1304
|
+
const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
|
|
1190
1305
|
const transitiveDeps = [
|
|
1191
1306
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1192
1307
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1238,10 +1353,11 @@ var allExternalImports = ({
|
|
|
1238
1353
|
...externalDistTypeImports
|
|
1239
1354
|
]);
|
|
1240
1355
|
};
|
|
1241
|
-
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1356
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
|
|
1242
1357
|
if (implicitDeps.has(dep)) return true;
|
|
1243
1358
|
if (requiredPeers.has(dep)) return true;
|
|
1244
1359
|
if (scriptRefs.has(dep)) return true;
|
|
1360
|
+
if (cliRefs.has(dep)) return true;
|
|
1245
1361
|
if (dep.startsWith("@types/")) {
|
|
1246
1362
|
const baseName = dep.replace(/^@types\//, "");
|
|
1247
1363
|
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
@@ -1252,7 +1368,7 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1252
1368
|
devDependencies,
|
|
1253
1369
|
dependencies,
|
|
1254
1370
|
peerDependencies
|
|
1255
|
-
}, sourceParams, fileContext) {
|
|
1371
|
+
}, sourceParams, fileContext, exclude) {
|
|
1256
1372
|
const allImports = allExternalImports(sourceParams);
|
|
1257
1373
|
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1258
1374
|
const implicitDeps = getImplicitDevDependencies({
|
|
@@ -1262,39 +1378,42 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1262
1378
|
});
|
|
1263
1379
|
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1264
1380
|
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1381
|
+
const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
|
|
1265
1382
|
let unusedDevDependencies = 0;
|
|
1266
1383
|
for (const dep of devDependencies) {
|
|
1384
|
+
if (exclude?.has(dep)) continue;
|
|
1267
1385
|
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1268
|
-
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1386
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
|
|
1269
1387
|
unusedDevDependencies++;
|
|
1270
|
-
console.log(`[${
|
|
1388
|
+
console.log(`[${chalk17.blue(name)}] Unused devDependency in package.json: ${chalk17.red(dep)}`);
|
|
1271
1389
|
}
|
|
1272
1390
|
}
|
|
1273
1391
|
if (unusedDevDependencies > 0) {
|
|
1274
1392
|
const packageLocation = `${location}/package.json`;
|
|
1275
|
-
console.log(` ${
|
|
1393
|
+
console.log(` ${chalk17.yellow(packageLocation)}
|
|
1276
1394
|
`);
|
|
1277
1395
|
}
|
|
1278
1396
|
return unusedDevDependencies;
|
|
1279
1397
|
}
|
|
1280
1398
|
|
|
1281
1399
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1282
|
-
import
|
|
1283
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
1400
|
+
import chalk18 from "chalk";
|
|
1401
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
|
|
1284
1402
|
let unusedDependencies = 0;
|
|
1285
1403
|
for (const dep of peerDependencies) {
|
|
1404
|
+
if (exclude?.has(dep)) continue;
|
|
1286
1405
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1287
1406
|
unusedDependencies++;
|
|
1288
1407
|
if (dependencies.includes(dep)) {
|
|
1289
|
-
console.log(`[${
|
|
1408
|
+
console.log(`[${chalk18.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk18.red(dep)}`);
|
|
1290
1409
|
} else {
|
|
1291
|
-
console.log(`[${
|
|
1410
|
+
console.log(`[${chalk18.blue(name)}] Unused peerDependency in package.json: ${chalk18.red(dep)}`);
|
|
1292
1411
|
}
|
|
1293
1412
|
}
|
|
1294
1413
|
}
|
|
1295
1414
|
if (unusedDependencies > 0) {
|
|
1296
1415
|
const packageLocation = `${location}/package.json`;
|
|
1297
|
-
console.log(` ${
|
|
1416
|
+
console.log(` ${chalk18.yellow(packageLocation)}
|
|
1298
1417
|
`);
|
|
1299
1418
|
}
|
|
1300
1419
|
return unusedDependencies;
|
|
@@ -1319,6 +1438,7 @@ function checkPackage({
|
|
|
1319
1438
|
location,
|
|
1320
1439
|
deps = false,
|
|
1321
1440
|
devDeps = false,
|
|
1441
|
+
exclude,
|
|
1322
1442
|
peerDeps = false,
|
|
1323
1443
|
verbose = false
|
|
1324
1444
|
}) {
|
|
@@ -1337,23 +1457,29 @@ function checkPackage({
|
|
|
1337
1457
|
});
|
|
1338
1458
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1339
1459
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1340
|
-
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1460
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1341
1461
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1342
1462
|
const fileContext = { allFiles, distFiles };
|
|
1343
|
-
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1344
|
-
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1463
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
|
|
1464
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1345
1465
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
1346
1466
|
return totalErrors;
|
|
1347
1467
|
}
|
|
1348
1468
|
|
|
1349
1469
|
// src/actions/deplint/deplint.ts
|
|
1350
|
-
var deplint = ({
|
|
1470
|
+
var deplint = async ({
|
|
1351
1471
|
pkg,
|
|
1352
1472
|
deps,
|
|
1353
1473
|
devDeps,
|
|
1354
1474
|
peerDeps,
|
|
1355
|
-
verbose
|
|
1475
|
+
verbose,
|
|
1476
|
+
cliExclude
|
|
1356
1477
|
}) => {
|
|
1478
|
+
const config2 = await loadConfig();
|
|
1479
|
+
const exclude = /* @__PURE__ */ new Set([
|
|
1480
|
+
...config2.deplint?.exclude ?? [],
|
|
1481
|
+
...cliExclude ?? []
|
|
1482
|
+
]);
|
|
1357
1483
|
let totalErrors = 0;
|
|
1358
1484
|
if (pkg === void 0) {
|
|
1359
1485
|
const workspaces = yarnWorkspaces();
|
|
@@ -1363,6 +1489,7 @@ var deplint = ({
|
|
|
1363
1489
|
...workspace,
|
|
1364
1490
|
deps,
|
|
1365
1491
|
devDeps,
|
|
1492
|
+
exclude,
|
|
1366
1493
|
peerDeps,
|
|
1367
1494
|
verbose
|
|
1368
1495
|
});
|
|
@@ -1375,14 +1502,15 @@ var deplint = ({
|
|
|
1375
1502
|
location,
|
|
1376
1503
|
devDeps,
|
|
1377
1504
|
deps,
|
|
1505
|
+
exclude,
|
|
1378
1506
|
peerDeps,
|
|
1379
1507
|
verbose
|
|
1380
1508
|
});
|
|
1381
1509
|
}
|
|
1382
1510
|
if (totalErrors > 0) {
|
|
1383
|
-
console.warn(`Deplint: Found ${
|
|
1511
|
+
console.warn(`Deplint: Found ${chalk19.red(totalErrors)} dependency problems. ${chalk19.red("\u2716")}`);
|
|
1384
1512
|
} else {
|
|
1385
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1513
|
+
console.info(`Deplint: Found no dependency problems. ${chalk19.green("\u2714")}`);
|
|
1386
1514
|
}
|
|
1387
1515
|
return 0;
|
|
1388
1516
|
};
|
|
@@ -1484,22 +1612,22 @@ var deployNext = () => {
|
|
|
1484
1612
|
};
|
|
1485
1613
|
|
|
1486
1614
|
// src/actions/dupdeps.ts
|
|
1487
|
-
import
|
|
1615
|
+
import chalk20 from "chalk";
|
|
1488
1616
|
var dupdeps = () => {
|
|
1489
|
-
console.log(
|
|
1617
|
+
console.log(chalk20.green("Checking all Dependencies for Duplicates"));
|
|
1490
1618
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1491
1619
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1492
1620
|
return detectDuplicateDependencies(dependencies);
|
|
1493
1621
|
};
|
|
1494
1622
|
|
|
1495
1623
|
// src/actions/lint.ts
|
|
1496
|
-
import
|
|
1624
|
+
import chalk21 from "chalk";
|
|
1497
1625
|
var lintPackage = ({
|
|
1498
1626
|
pkg,
|
|
1499
1627
|
fix: fix2,
|
|
1500
1628
|
verbose
|
|
1501
1629
|
}) => {
|
|
1502
|
-
console.log(
|
|
1630
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1503
1631
|
const start = Date.now();
|
|
1504
1632
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1505
1633
|
["yarn", [
|
|
@@ -1509,7 +1637,7 @@ var lintPackage = ({
|
|
|
1509
1637
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1510
1638
|
]]
|
|
1511
1639
|
]);
|
|
1512
|
-
console.log(
|
|
1640
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1513
1641
|
return result;
|
|
1514
1642
|
};
|
|
1515
1643
|
var lint = ({
|
|
@@ -1529,13 +1657,13 @@ var lint = ({
|
|
|
1529
1657
|
});
|
|
1530
1658
|
};
|
|
1531
1659
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1532
|
-
console.log(
|
|
1660
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1533
1661
|
const start = Date.now();
|
|
1534
1662
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1535
1663
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1536
1664
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1537
1665
|
]);
|
|
1538
|
-
console.log(
|
|
1666
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1539
1667
|
return result;
|
|
1540
1668
|
};
|
|
1541
1669
|
|
|
@@ -1563,7 +1691,7 @@ var filename = ".gitignore";
|
|
|
1563
1691
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1564
1692
|
|
|
1565
1693
|
// src/actions/gitlint.ts
|
|
1566
|
-
import
|
|
1694
|
+
import chalk22 from "chalk";
|
|
1567
1695
|
import ParseGitConfig from "parse-git-config";
|
|
1568
1696
|
var gitlint = () => {
|
|
1569
1697
|
console.log(`
|
|
@@ -1574,7 +1702,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1574
1702
|
const errors = 0;
|
|
1575
1703
|
const gitConfig = ParseGitConfig.sync();
|
|
1576
1704
|
const warn = (message) => {
|
|
1577
|
-
console.warn(
|
|
1705
|
+
console.warn(chalk22.yellow(`Warning: ${message}`));
|
|
1578
1706
|
warnings++;
|
|
1579
1707
|
};
|
|
1580
1708
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1594,13 +1722,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1594
1722
|
}
|
|
1595
1723
|
const resultMessages = [];
|
|
1596
1724
|
if (valid > 0) {
|
|
1597
|
-
resultMessages.push(
|
|
1725
|
+
resultMessages.push(chalk22.green(`Passed: ${valid}`));
|
|
1598
1726
|
}
|
|
1599
1727
|
if (warnings > 0) {
|
|
1600
|
-
resultMessages.push(
|
|
1728
|
+
resultMessages.push(chalk22.yellow(`Warnings: ${warnings}`));
|
|
1601
1729
|
}
|
|
1602
1730
|
if (errors > 0) {
|
|
1603
|
-
resultMessages.push(
|
|
1731
|
+
resultMessages.push(chalk22.red(` Errors: ${errors}`));
|
|
1604
1732
|
}
|
|
1605
1733
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1606
1734
|
`);
|
|
@@ -1609,7 +1737,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1609
1737
|
|
|
1610
1738
|
// src/actions/gitlint-fix.ts
|
|
1611
1739
|
import { execSync as execSync2 } from "child_process";
|
|
1612
|
-
import
|
|
1740
|
+
import chalk23 from "chalk";
|
|
1613
1741
|
import ParseGitConfig2 from "parse-git-config";
|
|
1614
1742
|
var gitlintFix = () => {
|
|
1615
1743
|
console.log(`
|
|
@@ -1618,15 +1746,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1618
1746
|
const gitConfig = ParseGitConfig2.sync();
|
|
1619
1747
|
if (gitConfig.core.ignorecase) {
|
|
1620
1748
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1621
|
-
console.warn(
|
|
1749
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1622
1750
|
}
|
|
1623
1751
|
if (gitConfig.core.autocrlf !== false) {
|
|
1624
1752
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1625
|
-
console.warn(
|
|
1753
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1626
1754
|
}
|
|
1627
1755
|
if (gitConfig.core.eol !== "lf") {
|
|
1628
1756
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1629
|
-
console.warn(
|
|
1757
|
+
console.warn(chalk23.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1630
1758
|
}
|
|
1631
1759
|
return 1;
|
|
1632
1760
|
};
|
|
@@ -1637,7 +1765,7 @@ var knip = () => {
|
|
|
1637
1765
|
};
|
|
1638
1766
|
|
|
1639
1767
|
// src/actions/license.ts
|
|
1640
|
-
import
|
|
1768
|
+
import chalk24 from "chalk";
|
|
1641
1769
|
import { init } from "license-checker";
|
|
1642
1770
|
var license = async (pkg) => {
|
|
1643
1771
|
const workspaces = yarnWorkspaces();
|
|
@@ -1662,18 +1790,18 @@ var license = async (pkg) => {
|
|
|
1662
1790
|
"LGPL-3.0-or-later",
|
|
1663
1791
|
"Python-2.0"
|
|
1664
1792
|
]);
|
|
1665
|
-
console.log(
|
|
1793
|
+
console.log(chalk24.green("License Checker"));
|
|
1666
1794
|
return (await Promise.all(
|
|
1667
1795
|
workspaceList.map(({ location, name }) => {
|
|
1668
1796
|
return new Promise((resolve) => {
|
|
1669
1797
|
init({ production: true, start: location }, (error, packages) => {
|
|
1670
1798
|
if (error) {
|
|
1671
|
-
console.error(
|
|
1672
|
-
console.error(
|
|
1799
|
+
console.error(chalk24.red(`License Checker [${name}] Error`));
|
|
1800
|
+
console.error(chalk24.gray(error));
|
|
1673
1801
|
console.log("\n");
|
|
1674
1802
|
resolve(1);
|
|
1675
1803
|
} else {
|
|
1676
|
-
console.log(
|
|
1804
|
+
console.log(chalk24.green(`License Checker [${name}]`));
|
|
1677
1805
|
let count = 0;
|
|
1678
1806
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1679
1807
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1689,7 +1817,7 @@ var license = async (pkg) => {
|
|
|
1689
1817
|
}
|
|
1690
1818
|
if (!orLicenseFound) {
|
|
1691
1819
|
count++;
|
|
1692
|
-
console.warn(
|
|
1820
|
+
console.warn(chalk24.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1693
1821
|
}
|
|
1694
1822
|
}
|
|
1695
1823
|
}
|
|
@@ -1733,7 +1861,7 @@ var rebuild = ({ target }) => {
|
|
|
1733
1861
|
};
|
|
1734
1862
|
|
|
1735
1863
|
// src/actions/recompile.ts
|
|
1736
|
-
import
|
|
1864
|
+
import chalk25 from "chalk";
|
|
1737
1865
|
var recompile = async ({
|
|
1738
1866
|
verbose,
|
|
1739
1867
|
target,
|
|
@@ -1769,7 +1897,7 @@ var recompileAll = async ({
|
|
|
1769
1897
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
1770
1898
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
1771
1899
|
if (jobs) {
|
|
1772
|
-
console.log(
|
|
1900
|
+
console.log(chalk25.blue(`Jobs set to [${jobs}]`));
|
|
1773
1901
|
}
|
|
1774
1902
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
1775
1903
|
[
|
|
@@ -1800,7 +1928,7 @@ var recompileAll = async ({
|
|
|
1800
1928
|
]
|
|
1801
1929
|
]);
|
|
1802
1930
|
console.log(
|
|
1803
|
-
`${
|
|
1931
|
+
`${chalk25.gray("Recompiled in")} [${chalk25.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk25.gray("seconds")}`
|
|
1804
1932
|
);
|
|
1805
1933
|
return result;
|
|
1806
1934
|
};
|
|
@@ -1831,13 +1959,13 @@ var reinstall = () => {
|
|
|
1831
1959
|
};
|
|
1832
1960
|
|
|
1833
1961
|
// src/actions/relint.ts
|
|
1834
|
-
import
|
|
1962
|
+
import chalk26 from "chalk";
|
|
1835
1963
|
var relintPackage = ({
|
|
1836
1964
|
pkg,
|
|
1837
1965
|
fix: fix2,
|
|
1838
1966
|
verbose
|
|
1839
1967
|
}) => {
|
|
1840
|
-
console.log(
|
|
1968
|
+
console.log(chalk26.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1841
1969
|
const start = Date.now();
|
|
1842
1970
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1843
1971
|
["yarn", [
|
|
@@ -1847,7 +1975,7 @@ var relintPackage = ({
|
|
|
1847
1975
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1848
1976
|
]]
|
|
1849
1977
|
]);
|
|
1850
|
-
console.log(
|
|
1978
|
+
console.log(chalk26.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk26.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk26.gray("seconds")}`));
|
|
1851
1979
|
return result;
|
|
1852
1980
|
};
|
|
1853
1981
|
var relint = ({
|
|
@@ -1867,13 +1995,13 @@ var relint = ({
|
|
|
1867
1995
|
});
|
|
1868
1996
|
};
|
|
1869
1997
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1870
|
-
console.log(
|
|
1998
|
+
console.log(chalk26.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1871
1999
|
const start = Date.now();
|
|
1872
2000
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1873
2001
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1874
2002
|
["yarn", ["eslint", ...fixOptions]]
|
|
1875
2003
|
]);
|
|
1876
|
-
console.log(
|
|
2004
|
+
console.log(chalk26.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk26.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk26.gray("seconds")}`));
|
|
1877
2005
|
return result;
|
|
1878
2006
|
};
|
|
1879
2007
|
|
|
@@ -1891,10 +2019,10 @@ var sonar = () => {
|
|
|
1891
2019
|
};
|
|
1892
2020
|
|
|
1893
2021
|
// src/actions/statics.ts
|
|
1894
|
-
import
|
|
2022
|
+
import chalk27 from "chalk";
|
|
1895
2023
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
1896
2024
|
var statics = () => {
|
|
1897
|
-
console.log(
|
|
2025
|
+
console.log(chalk27.green("Check Required Static Dependencies"));
|
|
1898
2026
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
1899
2027
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
1900
2028
|
};
|
|
@@ -2317,7 +2445,7 @@ var xyInstallCommands = (args) => {
|
|
|
2317
2445
|
};
|
|
2318
2446
|
|
|
2319
2447
|
// src/xy/xyLintCommands.ts
|
|
2320
|
-
import
|
|
2448
|
+
import chalk28 from "chalk";
|
|
2321
2449
|
var xyLintCommands = (args) => {
|
|
2322
2450
|
return args.command(
|
|
2323
2451
|
"cycle [package]",
|
|
@@ -2329,7 +2457,7 @@ var xyLintCommands = (args) => {
|
|
|
2329
2457
|
const start = Date.now();
|
|
2330
2458
|
if (argv.verbose) console.log("Cycle");
|
|
2331
2459
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
2332
|
-
console.log(
|
|
2460
|
+
console.log(chalk28.blue(`Finished in ${Date.now() - start}ms`));
|
|
2333
2461
|
}
|
|
2334
2462
|
).command(
|
|
2335
2463
|
"lint [package]",
|
|
@@ -2359,7 +2487,7 @@ var xyLintCommands = (args) => {
|
|
|
2359
2487
|
cache: argv.cache,
|
|
2360
2488
|
verbose: !!argv.verbose
|
|
2361
2489
|
});
|
|
2362
|
-
console.log(
|
|
2490
|
+
console.log(chalk28.blue(`Finished in ${Date.now() - start}ms`));
|
|
2363
2491
|
}
|
|
2364
2492
|
).command(
|
|
2365
2493
|
"deplint [package]",
|
|
@@ -2380,19 +2508,25 @@ var xyLintCommands = (args) => {
|
|
|
2380
2508
|
default: false,
|
|
2381
2509
|
description: "Check peerDependencies",
|
|
2382
2510
|
type: "boolean"
|
|
2511
|
+
}).option("exclude", {
|
|
2512
|
+
alias: "e",
|
|
2513
|
+
description: "Package names to exclude from unused checks (comma-separated or repeated)",
|
|
2514
|
+
type: "array"
|
|
2383
2515
|
});
|
|
2384
2516
|
},
|
|
2385
|
-
(argv) => {
|
|
2517
|
+
async (argv) => {
|
|
2386
2518
|
if (argv.verbose) console.log("Deplint");
|
|
2387
2519
|
const start = Date.now();
|
|
2388
|
-
|
|
2520
|
+
const cliExclude = argv.exclude?.flatMap((v) => String(v).split(",")).map((v) => v.trim()).filter(Boolean);
|
|
2521
|
+
process.exitCode = await deplint({
|
|
2522
|
+
cliExclude,
|
|
2389
2523
|
pkg: argv.package,
|
|
2390
2524
|
deps: !!argv.deps,
|
|
2391
2525
|
devDeps: !!argv.devDeps,
|
|
2392
2526
|
peerDeps: !!argv.peerDeps,
|
|
2393
2527
|
verbose: !!argv.verbose
|
|
2394
2528
|
});
|
|
2395
|
-
console.log(
|
|
2529
|
+
console.log(chalk28.blue(`Finished in ${Date.now() - start}ms`));
|
|
2396
2530
|
}
|
|
2397
2531
|
).command(
|
|
2398
2532
|
"fix [package]",
|
|
@@ -2404,7 +2538,7 @@ var xyLintCommands = (args) => {
|
|
|
2404
2538
|
const start = Date.now();
|
|
2405
2539
|
if (argv.verbose) console.log("Fix");
|
|
2406
2540
|
process.exitCode = fix();
|
|
2407
|
-
console.log(
|
|
2541
|
+
console.log(chalk28.blue(`Finished in ${Date.now() - start}ms`));
|
|
2408
2542
|
}
|
|
2409
2543
|
).command(
|
|
2410
2544
|
"relint [package]",
|
|
@@ -2416,7 +2550,7 @@ var xyLintCommands = (args) => {
|
|
|
2416
2550
|
if (argv.verbose) console.log("Relinting");
|
|
2417
2551
|
const start = Date.now();
|
|
2418
2552
|
process.exitCode = relint();
|
|
2419
|
-
console.log(
|
|
2553
|
+
console.log(chalk28.blue(`Finished in ${Date.now() - start}ms`));
|
|
2420
2554
|
}
|
|
2421
2555
|
).command(
|
|
2422
2556
|
"publint [package]",
|
|
@@ -2428,7 +2562,7 @@ var xyLintCommands = (args) => {
|
|
|
2428
2562
|
if (argv.verbose) console.log("Publint");
|
|
2429
2563
|
const start = Date.now();
|
|
2430
2564
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
2431
|
-
console.log(
|
|
2565
|
+
console.log(chalk28.blue(`Finished in ${Date.now() - start}ms`));
|
|
2432
2566
|
}
|
|
2433
2567
|
).command(
|
|
2434
2568
|
"knip",
|
|
@@ -2440,7 +2574,7 @@ var xyLintCommands = (args) => {
|
|
|
2440
2574
|
if (argv.verbose) console.log("Knip");
|
|
2441
2575
|
const start = Date.now();
|
|
2442
2576
|
process.exitCode = knip();
|
|
2443
|
-
console.log(
|
|
2577
|
+
console.log(chalk28.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
2444
2578
|
}
|
|
2445
2579
|
).command(
|
|
2446
2580
|
"sonar",
|
|
@@ -2452,7 +2586,7 @@ var xyLintCommands = (args) => {
|
|
|
2452
2586
|
const start = Date.now();
|
|
2453
2587
|
if (argv.verbose) console.log("Sonar Check");
|
|
2454
2588
|
process.exitCode = sonar();
|
|
2455
|
-
console.log(
|
|
2589
|
+
console.log(chalk28.blue(`Finished in ${Date.now() - start}ms`));
|
|
2456
2590
|
}
|
|
2457
2591
|
);
|
|
2458
2592
|
};
|
|
@@ -2488,8 +2622,8 @@ var xyParseOptions = () => {
|
|
|
2488
2622
|
var xy = async () => {
|
|
2489
2623
|
const options = xyParseOptions();
|
|
2490
2624
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
2491
|
-
console.error(
|
|
2492
|
-
console.log(
|
|
2625
|
+
console.error(chalk29.yellow(`Command not found [${chalk29.magenta(process.argv[2])}]`));
|
|
2626
|
+
console.log(chalk29.gray("Try 'yarn xy --help' for list of commands"));
|
|
2493
2627
|
}).version().help().argv;
|
|
2494
2628
|
};
|
|
2495
2629
|
|