@xylabs/ts-scripts-yarn3 7.4.9 → 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/claude-commands.mjs +99 -0
- package/dist/actions/claude-commands.mjs.map +1 -0
- package/dist/actions/claude-rules.mjs.map +1 -1
- 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 +368 -180
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +356 -134
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +27 -2
- package/dist/index.mjs +398 -194
- package/dist/index.mjs.map +1 -1
- package/dist/lib/claudeMdTemplate.mjs +12 -0
- package/dist/lib/claudeMdTemplate.mjs.map +1 -1
- package/dist/lib/index.mjs +12 -0
- package/dist/lib/index.mjs.map +1 -1
- package/dist/xy/index.mjs +356 -134
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +356 -134
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +122 -34
- package/dist/xy/xyCommonCommands.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/templates/commands/xylabs-build.md +5 -0
- package/templates/commands/xylabs-clean.md +5 -0
- package/templates/commands/xylabs-compile.md +5 -0
- package/templates/commands/xylabs-cycle.md +5 -0
- package/templates/commands/xylabs-deplint.md +5 -0
- package/templates/commands/xylabs-deploy-major.md +7 -0
- package/templates/commands/xylabs-deploy-minor.md +7 -0
- package/templates/commands/xylabs-deploy.md +7 -0
- package/templates/commands/xylabs-fix.md +5 -0
- package/templates/commands/xylabs-knip.md +5 -0
- package/templates/commands/xylabs-lint.md +5 -0
- package/templates/commands/xylabs-publint.md +5 -0
- package/templates/commands/xylabs-rebuild.md +5 -0
- package/templates/commands/xylabs-test.md +5 -0
package/dist/actions/index.mjs
CHANGED
|
@@ -22,6 +22,7 @@ var require2 = createRequire(import.meta.url);
|
|
|
22
22
|
var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-yarn3/package.json"));
|
|
23
23
|
var templatesDir = PATH.resolve(packageRoot, "templates");
|
|
24
24
|
var XYLABS_RULES_PREFIX = "xylabs-";
|
|
25
|
+
var XYLABS_COMMANDS_PREFIX = "xylabs-";
|
|
25
26
|
var claudeMdRuleTemplates = () => {
|
|
26
27
|
const rulesDir = PATH.resolve(templatesDir, "rules");
|
|
27
28
|
const files = readdirSync(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
@@ -31,6 +32,15 @@ var claudeMdRuleTemplates = () => {
|
|
|
31
32
|
}
|
|
32
33
|
return result;
|
|
33
34
|
};
|
|
35
|
+
var claudeCommandTemplates = () => {
|
|
36
|
+
const commandsDir = PATH.resolve(templatesDir, "commands");
|
|
37
|
+
const files = readdirSync(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
38
|
+
const result = {};
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
result[file] = readFileSync(PATH.resolve(commandsDir, file), "utf8");
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
34
44
|
var claudeMdProjectTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-project.md"), "utf8");
|
|
35
45
|
|
|
36
46
|
// src/lib/deleteGlob.ts
|
|
@@ -334,8 +344,8 @@ var loadConfig = async (params) => {
|
|
|
334
344
|
|
|
335
345
|
// src/lib/parsedPackageJSON.ts
|
|
336
346
|
import { readFileSync as readFileSync3 } from "fs";
|
|
337
|
-
var parsedPackageJSON = (
|
|
338
|
-
const pathToPackageJSON =
|
|
347
|
+
var parsedPackageJSON = (path14) => {
|
|
348
|
+
const pathToPackageJSON = path14 ?? process.env.npm_package_json ?? "";
|
|
339
349
|
const packageJSON = readFileSync3(pathToPackageJSON).toString();
|
|
340
350
|
return JSON.parse(packageJSON);
|
|
341
351
|
};
|
|
@@ -446,7 +456,7 @@ var build = async ({
|
|
|
446
456
|
return result;
|
|
447
457
|
};
|
|
448
458
|
|
|
449
|
-
// src/actions/claude-
|
|
459
|
+
// src/actions/claude-commands.ts
|
|
450
460
|
import {
|
|
451
461
|
existsSync as existsSync4,
|
|
452
462
|
mkdirSync,
|
|
@@ -457,13 +467,13 @@ import {
|
|
|
457
467
|
} from "fs";
|
|
458
468
|
import PATH2 from "path";
|
|
459
469
|
import chalk9 from "chalk";
|
|
460
|
-
var
|
|
461
|
-
const templates =
|
|
470
|
+
var syncCommandFiles = (commandsDir) => {
|
|
471
|
+
const templates = claudeCommandTemplates();
|
|
462
472
|
const templateNames = new Set(Object.keys(templates));
|
|
463
473
|
let updated = 0;
|
|
464
474
|
let created = 0;
|
|
465
475
|
for (const [filename3, content] of Object.entries(templates)) {
|
|
466
|
-
const targetPath = PATH2.resolve(
|
|
476
|
+
const targetPath = PATH2.resolve(commandsDir, filename3);
|
|
467
477
|
const existing = existsSync4(targetPath) ? readFileSync4(targetPath, "utf8") : void 0;
|
|
468
478
|
if (existing === content) continue;
|
|
469
479
|
writeFileSync2(targetPath, content, "utf8");
|
|
@@ -479,12 +489,82 @@ var syncRuleFiles = (rulesDir) => {
|
|
|
479
489
|
updated
|
|
480
490
|
};
|
|
481
491
|
};
|
|
492
|
+
var removeStaleCommands = (commandsDir, templateNames) => {
|
|
493
|
+
const existingCommands = readdirSync2(commandsDir).filter((f) => f.startsWith(XYLABS_COMMANDS_PREFIX) && f.endsWith(".md"));
|
|
494
|
+
let removed = 0;
|
|
495
|
+
for (const file of existingCommands) {
|
|
496
|
+
if (!templateNames.has(file)) {
|
|
497
|
+
unlinkSync(PATH2.resolve(commandsDir, file));
|
|
498
|
+
removed++;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return removed;
|
|
502
|
+
};
|
|
503
|
+
var logCommandsResult = (created, updated, removed) => {
|
|
504
|
+
if (created || updated || removed) {
|
|
505
|
+
const parts = [
|
|
506
|
+
created ? `${created} created` : "",
|
|
507
|
+
updated ? `${updated} updated` : "",
|
|
508
|
+
removed ? `${removed} removed` : ""
|
|
509
|
+
].filter(Boolean);
|
|
510
|
+
console.log(chalk9.green(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: ${parts.join(", ")}`));
|
|
511
|
+
} else {
|
|
512
|
+
console.log(chalk9.gray(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: already up to date`));
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
var claudeCommands = () => {
|
|
516
|
+
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
517
|
+
const commandsDir = PATH2.resolve(cwd5, ".claude", "commands");
|
|
518
|
+
mkdirSync(commandsDir, { recursive: true });
|
|
519
|
+
const {
|
|
520
|
+
created,
|
|
521
|
+
templateNames,
|
|
522
|
+
updated
|
|
523
|
+
} = syncCommandFiles(commandsDir);
|
|
524
|
+
const removed = removeStaleCommands(commandsDir, templateNames);
|
|
525
|
+
logCommandsResult(created, updated, removed);
|
|
526
|
+
return 0;
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
// src/actions/claude-rules.ts
|
|
530
|
+
import {
|
|
531
|
+
existsSync as existsSync5,
|
|
532
|
+
mkdirSync as mkdirSync2,
|
|
533
|
+
readdirSync as readdirSync3,
|
|
534
|
+
readFileSync as readFileSync5,
|
|
535
|
+
unlinkSync as unlinkSync2,
|
|
536
|
+
writeFileSync as writeFileSync3
|
|
537
|
+
} from "fs";
|
|
538
|
+
import PATH3 from "path";
|
|
539
|
+
import chalk10 from "chalk";
|
|
540
|
+
var syncRuleFiles = (rulesDir) => {
|
|
541
|
+
const templates = claudeMdRuleTemplates();
|
|
542
|
+
const templateNames = new Set(Object.keys(templates));
|
|
543
|
+
let updated = 0;
|
|
544
|
+
let created = 0;
|
|
545
|
+
for (const [filename3, content] of Object.entries(templates)) {
|
|
546
|
+
const targetPath = PATH3.resolve(rulesDir, filename3);
|
|
547
|
+
const existing = existsSync5(targetPath) ? readFileSync5(targetPath, "utf8") : void 0;
|
|
548
|
+
if (existing === content) continue;
|
|
549
|
+
writeFileSync3(targetPath, content, "utf8");
|
|
550
|
+
if (existing) {
|
|
551
|
+
updated++;
|
|
552
|
+
} else {
|
|
553
|
+
created++;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
created,
|
|
558
|
+
templateNames,
|
|
559
|
+
updated
|
|
560
|
+
};
|
|
561
|
+
};
|
|
482
562
|
var removeStaleRules = (rulesDir, templateNames) => {
|
|
483
|
-
const existingRules =
|
|
563
|
+
const existingRules = readdirSync3(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
484
564
|
let removed = 0;
|
|
485
565
|
for (const file of existingRules) {
|
|
486
566
|
if (!templateNames.has(file)) {
|
|
487
|
-
|
|
567
|
+
unlinkSync2(PATH3.resolve(rulesDir, file));
|
|
488
568
|
removed++;
|
|
489
569
|
}
|
|
490
570
|
}
|
|
@@ -497,27 +577,27 @@ var logRulesResult = (created, updated, removed) => {
|
|
|
497
577
|
updated ? `${updated} updated` : "",
|
|
498
578
|
removed ? `${removed} removed` : ""
|
|
499
579
|
].filter(Boolean);
|
|
500
|
-
console.log(
|
|
580
|
+
console.log(chalk10.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
|
|
501
581
|
} else {
|
|
502
|
-
console.log(
|
|
582
|
+
console.log(chalk10.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
|
|
503
583
|
}
|
|
504
584
|
};
|
|
505
585
|
var ensureProjectClaudeMd = (cwd5, force) => {
|
|
506
|
-
const projectPath =
|
|
507
|
-
if (!
|
|
508
|
-
if (force &&
|
|
509
|
-
console.log(
|
|
586
|
+
const projectPath = PATH3.resolve(cwd5, "CLAUDE.md");
|
|
587
|
+
if (!existsSync5(projectPath) || force) {
|
|
588
|
+
if (force && existsSync5(projectPath)) {
|
|
589
|
+
console.log(chalk10.yellow("Overwriting existing CLAUDE.md"));
|
|
510
590
|
}
|
|
511
|
-
|
|
512
|
-
console.log(
|
|
591
|
+
writeFileSync3(projectPath, claudeMdProjectTemplate(), "utf8");
|
|
592
|
+
console.log(chalk10.green("Generated CLAUDE.md"));
|
|
513
593
|
} else {
|
|
514
|
-
console.log(
|
|
594
|
+
console.log(chalk10.gray("CLAUDE.md already exists (skipped)"));
|
|
515
595
|
}
|
|
516
596
|
};
|
|
517
597
|
var claudeRules = ({ force } = {}) => {
|
|
518
598
|
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
519
|
-
const rulesDir =
|
|
520
|
-
|
|
599
|
+
const rulesDir = PATH3.resolve(cwd5, ".claude", "rules");
|
|
600
|
+
mkdirSync2(rulesDir, { recursive: true });
|
|
521
601
|
const {
|
|
522
602
|
created,
|
|
523
603
|
templateNames,
|
|
@@ -543,16 +623,16 @@ var cleanAll = ({ verbose }) => {
|
|
|
543
623
|
|
|
544
624
|
// src/actions/clean-docs.ts
|
|
545
625
|
import path from "path";
|
|
546
|
-
import
|
|
626
|
+
import chalk11 from "chalk";
|
|
547
627
|
var cleanDocs = () => {
|
|
548
628
|
const pkgName = process.env.npm_package_name;
|
|
549
|
-
console.log(
|
|
629
|
+
console.log(chalk11.green(`Cleaning Docs [${pkgName}]`));
|
|
550
630
|
for (const { location } of yarnWorkspaces()) deleteGlob(path.join(location, "docs"));
|
|
551
631
|
return 0;
|
|
552
632
|
};
|
|
553
633
|
|
|
554
634
|
// src/actions/compile.ts
|
|
555
|
-
import
|
|
635
|
+
import chalk12 from "chalk";
|
|
556
636
|
var compile = ({
|
|
557
637
|
verbose,
|
|
558
638
|
target,
|
|
@@ -593,7 +673,7 @@ var compileAll = ({
|
|
|
593
673
|
const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
|
|
594
674
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
595
675
|
if (jobs) {
|
|
596
|
-
console.log(
|
|
676
|
+
console.log(chalk12.blue(`Jobs set to [${jobs}]`));
|
|
597
677
|
}
|
|
598
678
|
const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
|
|
599
679
|
["yarn", [
|
|
@@ -607,13 +687,13 @@ var compileAll = ({
|
|
|
607
687
|
...targetOptions
|
|
608
688
|
]]
|
|
609
689
|
]);
|
|
610
|
-
console.log(`${
|
|
690
|
+
console.log(`${chalk12.gray("Compiled in")} [${chalk12.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk12.gray("seconds")}`);
|
|
611
691
|
return result;
|
|
612
692
|
};
|
|
613
693
|
|
|
614
694
|
// src/actions/copy-assets.ts
|
|
615
695
|
import path2 from "path/posix";
|
|
616
|
-
import
|
|
696
|
+
import chalk13 from "chalk";
|
|
617
697
|
import cpy from "cpy";
|
|
618
698
|
var copyPackageTargetAssets = async (target, name, location) => {
|
|
619
699
|
try {
|
|
@@ -636,7 +716,7 @@ var copyPackageTargetAssets = async (target, name, location) => {
|
|
|
636
716
|
};
|
|
637
717
|
var copyTargetAssets = async (target, pkg) => {
|
|
638
718
|
const workspaces = yarnWorkspaces();
|
|
639
|
-
console.log(
|
|
719
|
+
console.log(chalk13.green(`Copying Assets [${target.toUpperCase()}]`));
|
|
640
720
|
const workspaceList = workspaces.filter(({ name }) => {
|
|
641
721
|
return pkg === void 0 || name === pkg;
|
|
642
722
|
});
|
|
@@ -720,7 +800,7 @@ var dead = () => {
|
|
|
720
800
|
};
|
|
721
801
|
|
|
722
802
|
// src/actions/deplint/deplint.ts
|
|
723
|
-
import
|
|
803
|
+
import chalk19 from "chalk";
|
|
724
804
|
|
|
725
805
|
// src/actions/deplint/findFiles.ts
|
|
726
806
|
import fs2 from "fs";
|
|
@@ -896,11 +976,11 @@ function getExternalImportsFromFiles({
|
|
|
896
976
|
const allImportPaths = {};
|
|
897
977
|
const distImportPaths = {};
|
|
898
978
|
const distTypeImportPaths = {};
|
|
899
|
-
for (const
|
|
979
|
+
for (const path14 of allFiles) getImportsFromFile(path14, allImportPaths, allImportPaths).flat();
|
|
900
980
|
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
901
981
|
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
902
|
-
for (const
|
|
903
|
-
for (const
|
|
982
|
+
for (const path14 of distCodeFiles) getImportsFromFile(path14, distImportPaths, distImportPaths).flat();
|
|
983
|
+
for (const path14 of distTypeFiles) getImportsFromFile(path14, distTypeImportPaths, distTypeImportPaths).flat();
|
|
904
984
|
const allImports = Object.keys(allImportPaths);
|
|
905
985
|
const distImports = Object.keys(distImportPaths);
|
|
906
986
|
const externalAllImports = removeInternalImports(allImports);
|
|
@@ -922,12 +1002,12 @@ function getExternalImportsFromFiles({
|
|
|
922
1002
|
|
|
923
1003
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
924
1004
|
import { builtinModules } from "module";
|
|
925
|
-
import
|
|
1005
|
+
import chalk14 from "chalk";
|
|
926
1006
|
function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
|
|
927
1007
|
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
|
|
928
1008
|
}
|
|
929
1009
|
function logMissing(name, imp, importPaths) {
|
|
930
|
-
console.log(`[${
|
|
1010
|
+
console.log(`[${chalk14.blue(name)}] Missing dependency in package.json: ${chalk14.red(imp)}`);
|
|
931
1011
|
if (importPaths[imp]) {
|
|
932
1012
|
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
933
1013
|
}
|
|
@@ -952,7 +1032,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
952
1032
|
}
|
|
953
1033
|
if (unlistedDependencies > 0) {
|
|
954
1034
|
const packageLocation = `${location}/package.json`;
|
|
955
|
-
console.log(` ${
|
|
1035
|
+
console.log(` ${chalk14.yellow(packageLocation)}
|
|
956
1036
|
`);
|
|
957
1037
|
}
|
|
958
1038
|
return unlistedDependencies;
|
|
@@ -960,7 +1040,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
960
1040
|
|
|
961
1041
|
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
962
1042
|
import { builtinModules as builtinModules2 } from "module";
|
|
963
|
-
import
|
|
1043
|
+
import chalk15 from "chalk";
|
|
964
1044
|
function getUnlistedDevDependencies({ name, location }, {
|
|
965
1045
|
devDependencies,
|
|
966
1046
|
dependencies,
|
|
@@ -974,7 +1054,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
974
1054
|
for (const imp of externalAllImports) {
|
|
975
1055
|
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)) {
|
|
976
1056
|
unlistedDevDependencies++;
|
|
977
|
-
console.log(`[${
|
|
1057
|
+
console.log(`[${chalk15.blue(name)}] Missing devDependency in package.json: ${chalk15.red(imp)}`);
|
|
978
1058
|
if (allImportPaths[imp]) {
|
|
979
1059
|
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
980
1060
|
}
|
|
@@ -982,40 +1062,50 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
982
1062
|
}
|
|
983
1063
|
if (unlistedDevDependencies > 0) {
|
|
984
1064
|
const packageLocation = `${location}/package.json`;
|
|
985
|
-
console.log(` ${
|
|
1065
|
+
console.log(` ${chalk15.yellow(packageLocation)}
|
|
986
1066
|
`);
|
|
987
1067
|
}
|
|
988
1068
|
return unlistedDevDependencies;
|
|
989
1069
|
}
|
|
990
1070
|
|
|
991
1071
|
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
992
|
-
import
|
|
1072
|
+
import chalk16 from "chalk";
|
|
993
1073
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
994
1074
|
externalDistImports,
|
|
995
1075
|
externalDistTypeImports,
|
|
996
1076
|
externalAllImports
|
|
997
|
-
}) {
|
|
1077
|
+
}, exclude) {
|
|
998
1078
|
let unusedDependencies = 0;
|
|
999
1079
|
for (const dep of dependencies) {
|
|
1080
|
+
if (exclude?.has(dep)) continue;
|
|
1000
1081
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1001
1082
|
unusedDependencies++;
|
|
1002
1083
|
if (externalAllImports.includes(dep)) {
|
|
1003
|
-
console.log(`[${
|
|
1084
|
+
console.log(`[${chalk16.blue(name)}] dependency should be devDependency in package.json: ${chalk16.red(dep)}`);
|
|
1004
1085
|
} else {
|
|
1005
|
-
console.log(`[${
|
|
1086
|
+
console.log(`[${chalk16.blue(name)}] Unused dependency in package.json: ${chalk16.red(dep)}`);
|
|
1006
1087
|
}
|
|
1007
1088
|
}
|
|
1008
1089
|
}
|
|
1009
1090
|
if (unusedDependencies > 0) {
|
|
1010
1091
|
const packageLocation = `${location}/package.json`;
|
|
1011
|
-
console.log(` ${
|
|
1092
|
+
console.log(` ${chalk16.yellow(packageLocation)}
|
|
1012
1093
|
`);
|
|
1013
1094
|
}
|
|
1014
1095
|
return unusedDependencies;
|
|
1015
1096
|
}
|
|
1016
1097
|
|
|
1017
1098
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1018
|
-
import
|
|
1099
|
+
import chalk17 from "chalk";
|
|
1100
|
+
|
|
1101
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1102
|
+
import fs8 from "fs";
|
|
1103
|
+
import path7 from "path";
|
|
1104
|
+
import ts2 from "typescript";
|
|
1105
|
+
|
|
1106
|
+
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1107
|
+
import fs7 from "fs";
|
|
1108
|
+
import path6 from "path";
|
|
1019
1109
|
|
|
1020
1110
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
1021
1111
|
import fs6 from "fs";
|
|
@@ -1050,8 +1140,6 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1050
1140
|
}
|
|
1051
1141
|
|
|
1052
1142
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1053
|
-
import fs7 from "fs";
|
|
1054
|
-
import path6 from "path";
|
|
1055
1143
|
function getBinNames(location, dep) {
|
|
1056
1144
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1057
1145
|
if (!depPkgPath) return [];
|
|
@@ -1101,15 +1189,101 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1101
1189
|
return referenced;
|
|
1102
1190
|
}
|
|
1103
1191
|
|
|
1192
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1193
|
+
var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
|
|
1194
|
+
var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
|
|
1195
|
+
var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
|
|
1196
|
+
function getCommandTokensFromFile(filePath) {
|
|
1197
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
1198
|
+
let sourceCode;
|
|
1199
|
+
try {
|
|
1200
|
+
sourceCode = fs8.readFileSync(filePath, "utf8");
|
|
1201
|
+
} catch {
|
|
1202
|
+
return tokens;
|
|
1203
|
+
}
|
|
1204
|
+
const isMjsFile = filePath.endsWith(".mjs");
|
|
1205
|
+
const sourceFile = ts2.createSourceFile(
|
|
1206
|
+
path7.basename(filePath),
|
|
1207
|
+
sourceCode,
|
|
1208
|
+
ts2.ScriptTarget.Latest,
|
|
1209
|
+
true,
|
|
1210
|
+
isMjsFile ? ts2.ScriptKind.JS : void 0
|
|
1211
|
+
);
|
|
1212
|
+
function visit(node) {
|
|
1213
|
+
if (ts2.isCallExpression(node) && node.arguments.length > 0) {
|
|
1214
|
+
const fnName = getFunctionName(node.expression);
|
|
1215
|
+
if (fnName && allExecFunctions.has(fnName)) {
|
|
1216
|
+
const firstArg = node.arguments[0];
|
|
1217
|
+
if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
|
|
1218
|
+
const value = firstArg.text;
|
|
1219
|
+
if (shellCommandFunctions.has(fnName)) {
|
|
1220
|
+
for (const token of tokenizeScript(value)) {
|
|
1221
|
+
tokens.add(token);
|
|
1222
|
+
}
|
|
1223
|
+
} else {
|
|
1224
|
+
tokens.add(value);
|
|
1225
|
+
}
|
|
1226
|
+
} else if (ts2.isTemplateExpression(firstArg)) {
|
|
1227
|
+
const head = firstArg.head.text;
|
|
1228
|
+
if (head) {
|
|
1229
|
+
for (const token of tokenizeScript(head)) {
|
|
1230
|
+
tokens.add(token);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
ts2.forEachChild(node, visit);
|
|
1237
|
+
}
|
|
1238
|
+
visit(sourceFile);
|
|
1239
|
+
return tokens;
|
|
1240
|
+
}
|
|
1241
|
+
function getFunctionName(expr) {
|
|
1242
|
+
if (ts2.isIdentifier(expr)) {
|
|
1243
|
+
return expr.text;
|
|
1244
|
+
}
|
|
1245
|
+
if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
|
|
1246
|
+
return expr.name.text;
|
|
1247
|
+
}
|
|
1248
|
+
return void 0;
|
|
1249
|
+
}
|
|
1250
|
+
function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
|
|
1251
|
+
const allTokens = /* @__PURE__ */ new Set();
|
|
1252
|
+
for (const file of allFiles) {
|
|
1253
|
+
for (const token of getCommandTokensFromFile(file)) {
|
|
1254
|
+
allTokens.add(token);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
if (allTokens.size === 0) return /* @__PURE__ */ new Set();
|
|
1258
|
+
const binToPackage = /* @__PURE__ */ new Map();
|
|
1259
|
+
for (const dep of allDeps) {
|
|
1260
|
+
for (const bin of getBinNames(location, dep)) {
|
|
1261
|
+
binToPackage.set(bin, dep);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1265
|
+
for (const token of allTokens) {
|
|
1266
|
+
const baseName = getBasePackageName(token);
|
|
1267
|
+
if (allDeps.includes(baseName)) {
|
|
1268
|
+
referenced.add(baseName);
|
|
1269
|
+
}
|
|
1270
|
+
const pkg = binToPackage.get(token);
|
|
1271
|
+
if (pkg) {
|
|
1272
|
+
referenced.add(pkg);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return referenced;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1104
1278
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1105
|
-
import
|
|
1279
|
+
import fs9 from "fs";
|
|
1106
1280
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1107
1281
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1108
1282
|
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1109
1283
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1110
1284
|
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1111
1285
|
try {
|
|
1112
|
-
const content =
|
|
1286
|
+
const content = fs9.readFileSync(file, "utf8");
|
|
1113
1287
|
return decoratorPattern.test(content);
|
|
1114
1288
|
} catch {
|
|
1115
1289
|
return false;
|
|
@@ -1122,7 +1296,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1122
1296
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1123
1297
|
if (!pkgPath) continue;
|
|
1124
1298
|
try {
|
|
1125
|
-
const pkg = JSON.parse(
|
|
1299
|
+
const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
|
|
1126
1300
|
const transitiveDeps = [
|
|
1127
1301
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1128
1302
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1174,10 +1348,11 @@ var allExternalImports = ({
|
|
|
1174
1348
|
...externalDistTypeImports
|
|
1175
1349
|
]);
|
|
1176
1350
|
};
|
|
1177
|
-
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1351
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
|
|
1178
1352
|
if (implicitDeps.has(dep)) return true;
|
|
1179
1353
|
if (requiredPeers.has(dep)) return true;
|
|
1180
1354
|
if (scriptRefs.has(dep)) return true;
|
|
1355
|
+
if (cliRefs.has(dep)) return true;
|
|
1181
1356
|
if (dep.startsWith("@types/")) {
|
|
1182
1357
|
const baseName = dep.replace(/^@types\//, "");
|
|
1183
1358
|
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
@@ -1188,7 +1363,7 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1188
1363
|
devDependencies,
|
|
1189
1364
|
dependencies,
|
|
1190
1365
|
peerDependencies
|
|
1191
|
-
}, sourceParams, fileContext) {
|
|
1366
|
+
}, sourceParams, fileContext, exclude) {
|
|
1192
1367
|
const allImports = allExternalImports(sourceParams);
|
|
1193
1368
|
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1194
1369
|
const implicitDeps = getImplicitDevDependencies({
|
|
@@ -1198,39 +1373,42 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1198
1373
|
});
|
|
1199
1374
|
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1200
1375
|
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1376
|
+
const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
|
|
1201
1377
|
let unusedDevDependencies = 0;
|
|
1202
1378
|
for (const dep of devDependencies) {
|
|
1379
|
+
if (exclude?.has(dep)) continue;
|
|
1203
1380
|
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1204
|
-
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1381
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
|
|
1205
1382
|
unusedDevDependencies++;
|
|
1206
|
-
console.log(`[${
|
|
1383
|
+
console.log(`[${chalk17.blue(name)}] Unused devDependency in package.json: ${chalk17.red(dep)}`);
|
|
1207
1384
|
}
|
|
1208
1385
|
}
|
|
1209
1386
|
if (unusedDevDependencies > 0) {
|
|
1210
1387
|
const packageLocation = `${location}/package.json`;
|
|
1211
|
-
console.log(` ${
|
|
1388
|
+
console.log(` ${chalk17.yellow(packageLocation)}
|
|
1212
1389
|
`);
|
|
1213
1390
|
}
|
|
1214
1391
|
return unusedDevDependencies;
|
|
1215
1392
|
}
|
|
1216
1393
|
|
|
1217
1394
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1218
|
-
import
|
|
1219
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
1395
|
+
import chalk18 from "chalk";
|
|
1396
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
|
|
1220
1397
|
let unusedDependencies = 0;
|
|
1221
1398
|
for (const dep of peerDependencies) {
|
|
1399
|
+
if (exclude?.has(dep)) continue;
|
|
1222
1400
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1223
1401
|
unusedDependencies++;
|
|
1224
1402
|
if (dependencies.includes(dep)) {
|
|
1225
|
-
console.log(`[${
|
|
1403
|
+
console.log(`[${chalk18.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk18.red(dep)}`);
|
|
1226
1404
|
} else {
|
|
1227
|
-
console.log(`[${
|
|
1405
|
+
console.log(`[${chalk18.blue(name)}] Unused peerDependency in package.json: ${chalk18.red(dep)}`);
|
|
1228
1406
|
}
|
|
1229
1407
|
}
|
|
1230
1408
|
}
|
|
1231
1409
|
if (unusedDependencies > 0) {
|
|
1232
1410
|
const packageLocation = `${location}/package.json`;
|
|
1233
|
-
console.log(` ${
|
|
1411
|
+
console.log(` ${chalk18.yellow(packageLocation)}
|
|
1234
1412
|
`);
|
|
1235
1413
|
}
|
|
1236
1414
|
return unusedDependencies;
|
|
@@ -1255,6 +1433,7 @@ function checkPackage({
|
|
|
1255
1433
|
location,
|
|
1256
1434
|
deps = false,
|
|
1257
1435
|
devDeps = false,
|
|
1436
|
+
exclude,
|
|
1258
1437
|
peerDeps = false,
|
|
1259
1438
|
verbose = false
|
|
1260
1439
|
}) {
|
|
@@ -1273,23 +1452,29 @@ function checkPackage({
|
|
|
1273
1452
|
});
|
|
1274
1453
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1275
1454
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1276
|
-
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1455
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1277
1456
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1278
1457
|
const fileContext = { allFiles, distFiles };
|
|
1279
|
-
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1280
|
-
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1458
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
|
|
1459
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1281
1460
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
1282
1461
|
return totalErrors;
|
|
1283
1462
|
}
|
|
1284
1463
|
|
|
1285
1464
|
// src/actions/deplint/deplint.ts
|
|
1286
|
-
var deplint = ({
|
|
1465
|
+
var deplint = async ({
|
|
1287
1466
|
pkg,
|
|
1288
1467
|
deps,
|
|
1289
1468
|
devDeps,
|
|
1290
1469
|
peerDeps,
|
|
1291
|
-
verbose
|
|
1470
|
+
verbose,
|
|
1471
|
+
cliExclude
|
|
1292
1472
|
}) => {
|
|
1473
|
+
const config2 = await loadConfig();
|
|
1474
|
+
const exclude = /* @__PURE__ */ new Set([
|
|
1475
|
+
...config2.deplint?.exclude ?? [],
|
|
1476
|
+
...cliExclude ?? []
|
|
1477
|
+
]);
|
|
1293
1478
|
let totalErrors = 0;
|
|
1294
1479
|
if (pkg === void 0) {
|
|
1295
1480
|
const workspaces = yarnWorkspaces();
|
|
@@ -1299,6 +1484,7 @@ var deplint = ({
|
|
|
1299
1484
|
...workspace,
|
|
1300
1485
|
deps,
|
|
1301
1486
|
devDeps,
|
|
1487
|
+
exclude,
|
|
1302
1488
|
peerDeps,
|
|
1303
1489
|
verbose
|
|
1304
1490
|
});
|
|
@@ -1311,24 +1497,25 @@ var deplint = ({
|
|
|
1311
1497
|
location,
|
|
1312
1498
|
devDeps,
|
|
1313
1499
|
deps,
|
|
1500
|
+
exclude,
|
|
1314
1501
|
peerDeps,
|
|
1315
1502
|
verbose
|
|
1316
1503
|
});
|
|
1317
1504
|
}
|
|
1318
1505
|
if (totalErrors > 0) {
|
|
1319
|
-
console.warn(`Deplint: Found ${
|
|
1506
|
+
console.warn(`Deplint: Found ${chalk19.red(totalErrors)} dependency problems. ${chalk19.red("\u2716")}`);
|
|
1320
1507
|
} else {
|
|
1321
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1508
|
+
console.info(`Deplint: Found no dependency problems. ${chalk19.green("\u2714")}`);
|
|
1322
1509
|
}
|
|
1323
1510
|
return 0;
|
|
1324
1511
|
};
|
|
1325
1512
|
|
|
1326
1513
|
// src/actions/deploy.ts
|
|
1327
|
-
import { readFileSync as
|
|
1514
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
1328
1515
|
var privatePackageExcludeList = () => {
|
|
1329
1516
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1330
1517
|
workspace,
|
|
1331
|
-
JSON.parse(
|
|
1518
|
+
JSON.parse(readFileSync6(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1332
1519
|
]);
|
|
1333
1520
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1334
1521
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1348,11 +1535,11 @@ var deploy = () => {
|
|
|
1348
1535
|
};
|
|
1349
1536
|
|
|
1350
1537
|
// src/actions/deploy-major.ts
|
|
1351
|
-
import { readFileSync as
|
|
1538
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
1352
1539
|
var privatePackageExcludeList2 = () => {
|
|
1353
1540
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1354
1541
|
workspace,
|
|
1355
|
-
JSON.parse(
|
|
1542
|
+
JSON.parse(readFileSync7(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1356
1543
|
]);
|
|
1357
1544
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1358
1545
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1372,11 +1559,11 @@ var deployMajor = () => {
|
|
|
1372
1559
|
};
|
|
1373
1560
|
|
|
1374
1561
|
// src/actions/deploy-minor.ts
|
|
1375
|
-
import { readFileSync as
|
|
1562
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
1376
1563
|
var privatePackageExcludeList3 = () => {
|
|
1377
1564
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1378
1565
|
workspace,
|
|
1379
|
-
JSON.parse(
|
|
1566
|
+
JSON.parse(readFileSync8(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1380
1567
|
]);
|
|
1381
1568
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1382
1569
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1396,11 +1583,11 @@ var deployMinor = () => {
|
|
|
1396
1583
|
};
|
|
1397
1584
|
|
|
1398
1585
|
// src/actions/deploy-next.ts
|
|
1399
|
-
import { readFileSync as
|
|
1586
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
1400
1587
|
var privatePackageExcludeList4 = () => {
|
|
1401
1588
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1402
1589
|
workspace,
|
|
1403
|
-
JSON.parse(
|
|
1590
|
+
JSON.parse(readFileSync9(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1404
1591
|
]);
|
|
1405
1592
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1406
1593
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1420,22 +1607,22 @@ var deployNext = () => {
|
|
|
1420
1607
|
};
|
|
1421
1608
|
|
|
1422
1609
|
// src/actions/dupdeps.ts
|
|
1423
|
-
import
|
|
1610
|
+
import chalk20 from "chalk";
|
|
1424
1611
|
var dupdeps = () => {
|
|
1425
|
-
console.log(
|
|
1612
|
+
console.log(chalk20.green("Checking all Dependencies for Duplicates"));
|
|
1426
1613
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1427
1614
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1428
1615
|
return detectDuplicateDependencies(dependencies);
|
|
1429
1616
|
};
|
|
1430
1617
|
|
|
1431
1618
|
// src/actions/lint.ts
|
|
1432
|
-
import
|
|
1619
|
+
import chalk21 from "chalk";
|
|
1433
1620
|
var lintPackage = ({
|
|
1434
1621
|
pkg,
|
|
1435
1622
|
fix: fix2,
|
|
1436
1623
|
verbose
|
|
1437
1624
|
}) => {
|
|
1438
|
-
console.log(
|
|
1625
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1439
1626
|
const start = Date.now();
|
|
1440
1627
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1441
1628
|
["yarn", [
|
|
@@ -1445,7 +1632,7 @@ var lintPackage = ({
|
|
|
1445
1632
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1446
1633
|
]]
|
|
1447
1634
|
]);
|
|
1448
|
-
console.log(
|
|
1635
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1449
1636
|
return result;
|
|
1450
1637
|
};
|
|
1451
1638
|
var lint = ({
|
|
@@ -1465,13 +1652,13 @@ var lint = ({
|
|
|
1465
1652
|
});
|
|
1466
1653
|
};
|
|
1467
1654
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1468
|
-
console.log(
|
|
1655
|
+
console.log(chalk21.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1469
1656
|
const start = Date.now();
|
|
1470
1657
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1471
1658
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1472
1659
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1473
1660
|
]);
|
|
1474
|
-
console.log(
|
|
1661
|
+
console.log(chalk21.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk21.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk21.gray("seconds")}`));
|
|
1475
1662
|
return result;
|
|
1476
1663
|
};
|
|
1477
1664
|
|
|
@@ -1499,7 +1686,7 @@ var filename = ".gitignore";
|
|
|
1499
1686
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1500
1687
|
|
|
1501
1688
|
// src/actions/gitlint.ts
|
|
1502
|
-
import
|
|
1689
|
+
import chalk22 from "chalk";
|
|
1503
1690
|
import ParseGitConfig from "parse-git-config";
|
|
1504
1691
|
var gitlint = () => {
|
|
1505
1692
|
console.log(`
|
|
@@ -1510,7 +1697,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1510
1697
|
const errors = 0;
|
|
1511
1698
|
const gitConfig = ParseGitConfig.sync();
|
|
1512
1699
|
const warn = (message) => {
|
|
1513
|
-
console.warn(
|
|
1700
|
+
console.warn(chalk22.yellow(`Warning: ${message}`));
|
|
1514
1701
|
warnings++;
|
|
1515
1702
|
};
|
|
1516
1703
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1530,13 +1717,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1530
1717
|
}
|
|
1531
1718
|
const resultMessages = [];
|
|
1532
1719
|
if (valid > 0) {
|
|
1533
|
-
resultMessages.push(
|
|
1720
|
+
resultMessages.push(chalk22.green(`Passed: ${valid}`));
|
|
1534
1721
|
}
|
|
1535
1722
|
if (warnings > 0) {
|
|
1536
|
-
resultMessages.push(
|
|
1723
|
+
resultMessages.push(chalk22.yellow(`Warnings: ${warnings}`));
|
|
1537
1724
|
}
|
|
1538
1725
|
if (errors > 0) {
|
|
1539
|
-
resultMessages.push(
|
|
1726
|
+
resultMessages.push(chalk22.red(` Errors: ${errors}`));
|
|
1540
1727
|
}
|
|
1541
1728
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1542
1729
|
`);
|
|
@@ -1545,7 +1732,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1545
1732
|
|
|
1546
1733
|
// src/actions/gitlint-fix.ts
|
|
1547
1734
|
import { execSync as execSync2 } from "child_process";
|
|
1548
|
-
import
|
|
1735
|
+
import chalk23 from "chalk";
|
|
1549
1736
|
import ParseGitConfig2 from "parse-git-config";
|
|
1550
1737
|
var gitlintFix = () => {
|
|
1551
1738
|
console.log(`
|
|
@@ -1554,15 +1741,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1554
1741
|
const gitConfig = ParseGitConfig2.sync();
|
|
1555
1742
|
if (gitConfig.core.ignorecase) {
|
|
1556
1743
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1557
|
-
console.warn(
|
|
1744
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1558
1745
|
}
|
|
1559
1746
|
if (gitConfig.core.autocrlf !== false) {
|
|
1560
1747
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1561
|
-
console.warn(
|
|
1748
|
+
console.warn(chalk23.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1562
1749
|
}
|
|
1563
1750
|
if (gitConfig.core.eol !== "lf") {
|
|
1564
1751
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1565
|
-
console.warn(
|
|
1752
|
+
console.warn(chalk23.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1566
1753
|
}
|
|
1567
1754
|
return 1;
|
|
1568
1755
|
};
|
|
@@ -1573,7 +1760,7 @@ var knip = () => {
|
|
|
1573
1760
|
};
|
|
1574
1761
|
|
|
1575
1762
|
// src/actions/license.ts
|
|
1576
|
-
import
|
|
1763
|
+
import chalk24 from "chalk";
|
|
1577
1764
|
import { init } from "license-checker";
|
|
1578
1765
|
var license = async (pkg) => {
|
|
1579
1766
|
const workspaces = yarnWorkspaces();
|
|
@@ -1598,18 +1785,18 @@ var license = async (pkg) => {
|
|
|
1598
1785
|
"LGPL-3.0-or-later",
|
|
1599
1786
|
"Python-2.0"
|
|
1600
1787
|
]);
|
|
1601
|
-
console.log(
|
|
1788
|
+
console.log(chalk24.green("License Checker"));
|
|
1602
1789
|
return (await Promise.all(
|
|
1603
1790
|
workspaceList.map(({ location, name }) => {
|
|
1604
1791
|
return new Promise((resolve) => {
|
|
1605
1792
|
init({ production: true, start: location }, (error, packages) => {
|
|
1606
1793
|
if (error) {
|
|
1607
|
-
console.error(
|
|
1608
|
-
console.error(
|
|
1794
|
+
console.error(chalk24.red(`License Checker [${name}] Error`));
|
|
1795
|
+
console.error(chalk24.gray(error));
|
|
1609
1796
|
console.log("\n");
|
|
1610
1797
|
resolve(1);
|
|
1611
1798
|
} else {
|
|
1612
|
-
console.log(
|
|
1799
|
+
console.log(chalk24.green(`License Checker [${name}]`));
|
|
1613
1800
|
let count = 0;
|
|
1614
1801
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1615
1802
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1625,7 +1812,7 @@ var license = async (pkg) => {
|
|
|
1625
1812
|
}
|
|
1626
1813
|
if (!orLicenseFound) {
|
|
1627
1814
|
count++;
|
|
1628
|
-
console.warn(
|
|
1815
|
+
console.warn(chalk24.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1629
1816
|
}
|
|
1630
1817
|
}
|
|
1631
1818
|
}
|
|
@@ -1644,13 +1831,13 @@ var filename2 = ".npmignore";
|
|
|
1644
1831
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1645
1832
|
|
|
1646
1833
|
// src/actions/package/clean-outputs.ts
|
|
1647
|
-
import
|
|
1648
|
-
import
|
|
1834
|
+
import path8 from "path";
|
|
1835
|
+
import chalk25 from "chalk";
|
|
1649
1836
|
var packageCleanOutputs = () => {
|
|
1650
1837
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1651
1838
|
const pkgName = process.env.npm_package_name;
|
|
1652
|
-
const folders = [
|
|
1653
|
-
console.log(
|
|
1839
|
+
const folders = [path8.join(pkg, "dist"), path8.join(pkg, "build"), path8.join(pkg, "docs")];
|
|
1840
|
+
console.log(chalk25.green(`Cleaning Outputs [${pkgName}]`));
|
|
1654
1841
|
for (let folder of folders) {
|
|
1655
1842
|
deleteGlob(folder);
|
|
1656
1843
|
}
|
|
@@ -1658,13 +1845,13 @@ var packageCleanOutputs = () => {
|
|
|
1658
1845
|
};
|
|
1659
1846
|
|
|
1660
1847
|
// src/actions/package/clean-typescript.ts
|
|
1661
|
-
import
|
|
1662
|
-
import
|
|
1848
|
+
import path9 from "path";
|
|
1849
|
+
import chalk26 from "chalk";
|
|
1663
1850
|
var packageCleanTypescript = () => {
|
|
1664
1851
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1665
1852
|
const pkgName = process.env.npm_package_name;
|
|
1666
|
-
console.log(
|
|
1667
|
-
const files = [
|
|
1853
|
+
console.log(chalk26.green(`Cleaning Typescript [${pkgName}]`));
|
|
1854
|
+
const files = [path9.join(pkg, "*.tsbuildinfo"), path9.join(pkg, ".tsconfig.*"), path9.join(pkg, ".eslintcache")];
|
|
1668
1855
|
for (let file of files) {
|
|
1669
1856
|
deleteGlob(file);
|
|
1670
1857
|
}
|
|
@@ -1677,26 +1864,26 @@ var packageClean = async () => {
|
|
|
1677
1864
|
};
|
|
1678
1865
|
|
|
1679
1866
|
// src/actions/package/compile/compile.ts
|
|
1680
|
-
import
|
|
1867
|
+
import chalk31 from "chalk";
|
|
1681
1868
|
|
|
1682
1869
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1683
|
-
import
|
|
1870
|
+
import chalk30 from "chalk";
|
|
1684
1871
|
import { build as build2, defineConfig } from "tsup";
|
|
1685
1872
|
|
|
1686
1873
|
// src/actions/package/compile/inputs.ts
|
|
1687
|
-
import
|
|
1874
|
+
import chalk27 from "chalk";
|
|
1688
1875
|
import { glob as glob2 } from "glob";
|
|
1689
1876
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1690
1877
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1691
1878
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1692
1879
|
if (verbose) {
|
|
1693
|
-
console.log(
|
|
1880
|
+
console.log(chalk27.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1694
1881
|
}
|
|
1695
1882
|
return result;
|
|
1696
1883
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1697
1884
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1698
1885
|
if (verbose) {
|
|
1699
|
-
console.log(
|
|
1886
|
+
console.log(chalk27.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1700
1887
|
}
|
|
1701
1888
|
return result;
|
|
1702
1889
|
})];
|
|
@@ -1755,9 +1942,9 @@ function deepMergeObjects(objects) {
|
|
|
1755
1942
|
|
|
1756
1943
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1757
1944
|
import { cwd as cwd2 } from "process";
|
|
1758
|
-
import
|
|
1945
|
+
import chalk28 from "chalk";
|
|
1759
1946
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1760
|
-
import
|
|
1947
|
+
import ts3, {
|
|
1761
1948
|
DiagnosticCategory,
|
|
1762
1949
|
formatDiagnosticsWithColorAndContext,
|
|
1763
1950
|
getPreEmitDiagnostics,
|
|
@@ -1777,12 +1964,12 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
1777
1964
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
1778
1965
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1779
1966
|
if (verbose) {
|
|
1780
|
-
console.log(
|
|
1967
|
+
console.log(chalk28.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1781
1968
|
}
|
|
1782
|
-
const configFilePath =
|
|
1969
|
+
const configFilePath = ts3.findConfigFile(
|
|
1783
1970
|
"./",
|
|
1784
1971
|
// search path
|
|
1785
|
-
|
|
1972
|
+
ts3.sys.fileExists,
|
|
1786
1973
|
"tsconfig.json"
|
|
1787
1974
|
);
|
|
1788
1975
|
if (configFilePath === void 0) {
|
|
@@ -1800,10 +1987,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1800
1987
|
emitDeclarationOnly: true,
|
|
1801
1988
|
noEmit: false
|
|
1802
1989
|
};
|
|
1803
|
-
console.log(
|
|
1990
|
+
console.log(chalk28.cyan(`Validating Files: ${entries.length}`));
|
|
1804
1991
|
if (verbose) {
|
|
1805
1992
|
for (const entry of entries) {
|
|
1806
|
-
console.log(
|
|
1993
|
+
console.log(chalk28.grey(`Validating: ${entry}`));
|
|
1807
1994
|
}
|
|
1808
1995
|
}
|
|
1809
1996
|
try {
|
|
@@ -1832,29 +2019,29 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1832
2019
|
if (nonEmitPatterns.some((pattern) => fileName.includes(pattern))) {
|
|
1833
2020
|
return;
|
|
1834
2021
|
}
|
|
1835
|
-
|
|
2022
|
+
ts3.sys.writeFile(fileName, text, writeByteOrderMark);
|
|
1836
2023
|
});
|
|
1837
2024
|
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1838
2025
|
}
|
|
1839
2026
|
return 0;
|
|
1840
2027
|
} finally {
|
|
1841
2028
|
if (verbose) {
|
|
1842
|
-
console.log(
|
|
2029
|
+
console.log(chalk28.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1843
2030
|
}
|
|
1844
2031
|
}
|
|
1845
2032
|
};
|
|
1846
2033
|
|
|
1847
2034
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1848
|
-
import
|
|
2035
|
+
import path10 from "path";
|
|
1849
2036
|
import { cwd as cwd3 } from "process";
|
|
1850
|
-
import
|
|
2037
|
+
import chalk29 from "chalk";
|
|
1851
2038
|
import { rollup } from "rollup";
|
|
1852
2039
|
import dts from "rollup-plugin-dts";
|
|
1853
2040
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
1854
2041
|
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
1855
2042
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
1856
2043
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1857
|
-
const tsconfigPath =
|
|
2044
|
+
const tsconfigPath = path10.resolve(pkg, "tsconfig.json");
|
|
1858
2045
|
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
1859
2046
|
try {
|
|
1860
2047
|
const bundle = await rollup({
|
|
@@ -1872,8 +2059,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1872
2059
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
1873
2060
|
return;
|
|
1874
2061
|
}
|
|
1875
|
-
console.warn(
|
|
1876
|
-
console.warn(
|
|
2062
|
+
console.warn(chalk29.yellow(`[${warning.code}] ${warning.message}`));
|
|
2063
|
+
console.warn(chalk29.gray(inputPath));
|
|
1877
2064
|
warn(warning);
|
|
1878
2065
|
}
|
|
1879
2066
|
});
|
|
@@ -1883,8 +2070,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1883
2070
|
});
|
|
1884
2071
|
} catch (ex) {
|
|
1885
2072
|
const error = ex;
|
|
1886
|
-
console.warn(
|
|
1887
|
-
console.warn(
|
|
2073
|
+
console.warn(chalk29.red(error));
|
|
2074
|
+
console.warn(chalk29.gray(inputPath));
|
|
1888
2075
|
}
|
|
1889
2076
|
if (verbose) {
|
|
1890
2077
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -1892,7 +2079,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1892
2079
|
}
|
|
1893
2080
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
1894
2081
|
if (verbose) {
|
|
1895
|
-
console.log(
|
|
2082
|
+
console.log(chalk29.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1896
2083
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
1897
2084
|
}
|
|
1898
2085
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -1916,7 +2103,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
1916
2103
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
1917
2104
|
}));
|
|
1918
2105
|
if (verbose) {
|
|
1919
|
-
console.log(
|
|
2106
|
+
console.log(chalk29.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1920
2107
|
}
|
|
1921
2108
|
return 0;
|
|
1922
2109
|
};
|
|
@@ -1928,15 +2115,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1928
2115
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
1929
2116
|
}
|
|
1930
2117
|
if (entries.length === 0) {
|
|
1931
|
-
console.warn(
|
|
2118
|
+
console.warn(chalk30.yellow(`No entries found in ${srcDir} to compile`));
|
|
1932
2119
|
return 0;
|
|
1933
2120
|
}
|
|
1934
2121
|
if (verbose) {
|
|
1935
|
-
console.log(
|
|
2122
|
+
console.log(chalk30.gray(`buildDir [${buildDir}]`));
|
|
1936
2123
|
}
|
|
1937
2124
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
1938
2125
|
if (validationResult !== 0) {
|
|
1939
|
-
console.error(
|
|
2126
|
+
console.error(chalk30.red(`Compile:Validation had ${validationResult} errors`));
|
|
1940
2127
|
return validationResult;
|
|
1941
2128
|
}
|
|
1942
2129
|
const optionsParams = tsupOptions([{
|
|
@@ -1961,12 +2148,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1961
2148
|
})
|
|
1962
2149
|
)).flat();
|
|
1963
2150
|
if (verbose) {
|
|
1964
|
-
console.log(
|
|
1965
|
-
console.log(
|
|
2151
|
+
console.log(chalk30.cyan(`TSUP:build:start [${srcDir}]`));
|
|
2152
|
+
console.log(chalk30.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
1966
2153
|
}
|
|
1967
2154
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
1968
2155
|
if (verbose) {
|
|
1969
|
-
console.log(
|
|
2156
|
+
console.log(chalk30.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
1970
2157
|
}
|
|
1971
2158
|
if (bundleTypes) {
|
|
1972
2159
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -2077,14 +2264,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
2077
2264
|
// src/actions/package/compile/compile.ts
|
|
2078
2265
|
var packageCompile = async (inConfig = {}) => {
|
|
2079
2266
|
const pkg = process.env.INIT_CWD;
|
|
2080
|
-
console.log(
|
|
2267
|
+
console.log(chalk31.green(`Compiling ${pkg}`));
|
|
2081
2268
|
const config2 = await loadConfig(inConfig);
|
|
2082
2269
|
return await packageCompileTsup(config2);
|
|
2083
2270
|
};
|
|
2084
2271
|
|
|
2085
2272
|
// src/actions/package/copy-assets.ts
|
|
2086
|
-
import
|
|
2087
|
-
import
|
|
2273
|
+
import path11 from "path/posix";
|
|
2274
|
+
import chalk32 from "chalk";
|
|
2088
2275
|
import cpy2 from "cpy";
|
|
2089
2276
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
2090
2277
|
try {
|
|
@@ -2092,12 +2279,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
2092
2279
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
2093
2280
|
`../dist/${target}`,
|
|
2094
2281
|
{
|
|
2095
|
-
cwd:
|
|
2282
|
+
cwd: path11.join(location, "src"),
|
|
2096
2283
|
flat: false
|
|
2097
2284
|
}
|
|
2098
2285
|
);
|
|
2099
2286
|
if (values.length > 0) {
|
|
2100
|
-
console.log(
|
|
2287
|
+
console.log(chalk32.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
2101
2288
|
}
|
|
2102
2289
|
for (const value of values) {
|
|
2103
2290
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -2162,9 +2349,9 @@ var packageCycle = async () => {
|
|
|
2162
2349
|
};
|
|
2163
2350
|
|
|
2164
2351
|
// src/actions/package/gen-docs.ts
|
|
2165
|
-
import { existsSync as
|
|
2166
|
-
import
|
|
2167
|
-
import
|
|
2352
|
+
import { existsSync as existsSync6 } from "fs";
|
|
2353
|
+
import path12 from "path";
|
|
2354
|
+
import chalk33 from "chalk";
|
|
2168
2355
|
import {
|
|
2169
2356
|
Application,
|
|
2170
2357
|
ArgumentsReader,
|
|
@@ -2182,7 +2369,7 @@ var ExitCodes = {
|
|
|
2182
2369
|
};
|
|
2183
2370
|
var packageGenDocs = async () => {
|
|
2184
2371
|
const pkg = process.env.INIT_CWD;
|
|
2185
|
-
if (pkg !== void 0 && !
|
|
2372
|
+
if (pkg !== void 0 && !existsSync6(path12.join(pkg, "typedoc.json"))) {
|
|
2186
2373
|
return;
|
|
2187
2374
|
}
|
|
2188
2375
|
const app = await Application.bootstrap({
|
|
@@ -2268,16 +2455,16 @@ var runTypeDoc = async (app) => {
|
|
|
2268
2455
|
return ExitCodes.OutputError;
|
|
2269
2456
|
}
|
|
2270
2457
|
}
|
|
2271
|
-
console.log(
|
|
2458
|
+
console.log(chalk33.green(`${pkgName} - Ok`));
|
|
2272
2459
|
return ExitCodes.Ok;
|
|
2273
2460
|
};
|
|
2274
2461
|
|
|
2275
2462
|
// src/actions/package/lint.ts
|
|
2276
|
-
import { readdirSync as
|
|
2277
|
-
import
|
|
2463
|
+
import { readdirSync as readdirSync4 } from "fs";
|
|
2464
|
+
import path13 from "path";
|
|
2278
2465
|
import { cwd as cwd4 } from "process";
|
|
2279
2466
|
import { pathToFileURL } from "url";
|
|
2280
|
-
import
|
|
2467
|
+
import chalk34 from "chalk";
|
|
2281
2468
|
import { ESLint } from "eslint";
|
|
2282
2469
|
import { findUp } from "find-up";
|
|
2283
2470
|
import picomatch from "picomatch";
|
|
@@ -2286,14 +2473,14 @@ var dumpMessages = (lintResults) => {
|
|
|
2286
2473
|
const severity = ["none", "warning", "error"];
|
|
2287
2474
|
for (const lintResult of lintResults) {
|
|
2288
2475
|
if (lintResult.messages.length > 0) {
|
|
2289
|
-
console.log(
|
|
2476
|
+
console.log(chalk34.gray(`
|
|
2290
2477
|
${lintResult.filePath}`));
|
|
2291
2478
|
for (const message of lintResult.messages) {
|
|
2292
2479
|
console.log(
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2480
|
+
chalk34.gray(` ${message.line}:${message.column}`),
|
|
2481
|
+
chalk34[colors[message.severity]](` ${severity[message.severity]}`),
|
|
2482
|
+
chalk34.white(` ${message.message}`),
|
|
2483
|
+
chalk34.gray(` ${message.ruleId}`)
|
|
2297
2484
|
);
|
|
2298
2485
|
}
|
|
2299
2486
|
}
|
|
@@ -2310,8 +2497,8 @@ function getFiles(dir, ignoreFolders) {
|
|
|
2310
2497
|
const currentDirectory = cwd4();
|
|
2311
2498
|
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
2312
2499
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2313
|
-
return
|
|
2314
|
-
const res =
|
|
2500
|
+
return readdirSync4(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2501
|
+
const res = path13.resolve(dir, dirent.name);
|
|
2315
2502
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2316
2503
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2317
2504
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2331,10 +2518,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2331
2518
|
cache
|
|
2332
2519
|
});
|
|
2333
2520
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
2334
|
-
console.log(
|
|
2521
|
+
console.log(chalk34.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2335
2522
|
if (verbose) {
|
|
2336
2523
|
for (const file of files) {
|
|
2337
|
-
console.log(
|
|
2524
|
+
console.log(chalk34.gray(` ${file}`));
|
|
2338
2525
|
}
|
|
2339
2526
|
}
|
|
2340
2527
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -2345,43 +2532,43 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2345
2532
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2346
2533
|
const lintTime = Date.now() - start;
|
|
2347
2534
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2348
|
-
console.log(
|
|
2535
|
+
console.log(chalk34.white(`Linted ${chalk34[filesCountColor](files.length)} files in ${chalk34[lintTimeColor](lintTime)}ms`));
|
|
2349
2536
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2350
2537
|
};
|
|
2351
2538
|
|
|
2352
2539
|
// src/actions/package/publint.ts
|
|
2353
|
-
import { promises as
|
|
2354
|
-
import
|
|
2540
|
+
import { promises as fs10 } from "fs";
|
|
2541
|
+
import chalk35 from "chalk";
|
|
2355
2542
|
import sortPackageJson from "sort-package-json";
|
|
2356
2543
|
var customPubLint = (pkg) => {
|
|
2357
2544
|
let errorCount = 0;
|
|
2358
2545
|
let warningCount = 0;
|
|
2359
2546
|
if (pkg.files === void 0) {
|
|
2360
|
-
console.warn(
|
|
2547
|
+
console.warn(chalk35.yellow('Publint [custom]: "files" field is missing'));
|
|
2361
2548
|
warningCount++;
|
|
2362
2549
|
}
|
|
2363
2550
|
if (pkg.main !== void 0) {
|
|
2364
|
-
console.warn(
|
|
2551
|
+
console.warn(chalk35.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
2365
2552
|
warningCount++;
|
|
2366
2553
|
}
|
|
2367
2554
|
if (pkg.sideEffects !== false) {
|
|
2368
|
-
console.warn(
|
|
2555
|
+
console.warn(chalk35.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
2369
2556
|
warningCount++;
|
|
2370
2557
|
}
|
|
2371
2558
|
if (pkg.resolutions !== void 0) {
|
|
2372
|
-
console.warn(
|
|
2373
|
-
console.warn(
|
|
2559
|
+
console.warn(chalk35.yellow('Publint [custom]: "resolutions" in use'));
|
|
2560
|
+
console.warn(chalk35.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
2374
2561
|
warningCount++;
|
|
2375
2562
|
}
|
|
2376
2563
|
return [errorCount, warningCount];
|
|
2377
2564
|
};
|
|
2378
2565
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2379
2566
|
const pkgDir = process.env.INIT_CWD;
|
|
2380
|
-
const sortedPkg = sortPackageJson(await
|
|
2381
|
-
await
|
|
2382
|
-
const pkg = JSON.parse(await
|
|
2383
|
-
console.log(
|
|
2384
|
-
console.log(
|
|
2567
|
+
const sortedPkg = sortPackageJson(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2568
|
+
await fs10.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2569
|
+
const pkg = JSON.parse(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2570
|
+
console.log(chalk35.green(`Publint: ${pkg.name}`));
|
|
2571
|
+
console.log(chalk35.gray(pkgDir));
|
|
2385
2572
|
const { publint: publint2 } = await import("publint");
|
|
2386
2573
|
const { messages } = await publint2({
|
|
2387
2574
|
level: "suggestion",
|
|
@@ -2392,22 +2579,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2392
2579
|
for (const message of messages) {
|
|
2393
2580
|
switch (message.type) {
|
|
2394
2581
|
case "error": {
|
|
2395
|
-
console.error(
|
|
2582
|
+
console.error(chalk35.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2396
2583
|
break;
|
|
2397
2584
|
}
|
|
2398
2585
|
case "warning": {
|
|
2399
|
-
console.warn(
|
|
2586
|
+
console.warn(chalk35.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2400
2587
|
break;
|
|
2401
2588
|
}
|
|
2402
2589
|
default: {
|
|
2403
|
-
console.log(
|
|
2590
|
+
console.log(chalk35.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2404
2591
|
break;
|
|
2405
2592
|
}
|
|
2406
2593
|
}
|
|
2407
2594
|
}
|
|
2408
2595
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
2409
2596
|
if (verbose) {
|
|
2410
|
-
console.log(
|
|
2597
|
+
console.log(chalk35.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
2411
2598
|
}
|
|
2412
2599
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
2413
2600
|
};
|
|
@@ -2443,7 +2630,7 @@ var rebuild = ({ target }) => {
|
|
|
2443
2630
|
};
|
|
2444
2631
|
|
|
2445
2632
|
// src/actions/recompile.ts
|
|
2446
|
-
import
|
|
2633
|
+
import chalk36 from "chalk";
|
|
2447
2634
|
var recompile = async ({
|
|
2448
2635
|
verbose,
|
|
2449
2636
|
target,
|
|
@@ -2479,7 +2666,7 @@ var recompileAll = async ({
|
|
|
2479
2666
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2480
2667
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2481
2668
|
if (jobs) {
|
|
2482
|
-
console.log(
|
|
2669
|
+
console.log(chalk36.blue(`Jobs set to [${jobs}]`));
|
|
2483
2670
|
}
|
|
2484
2671
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2485
2672
|
[
|
|
@@ -2510,7 +2697,7 @@ var recompileAll = async ({
|
|
|
2510
2697
|
]
|
|
2511
2698
|
]);
|
|
2512
2699
|
console.log(
|
|
2513
|
-
`${
|
|
2700
|
+
`${chalk36.gray("Recompiled in")} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`
|
|
2514
2701
|
);
|
|
2515
2702
|
return result;
|
|
2516
2703
|
};
|
|
@@ -2541,13 +2728,13 @@ var reinstall = () => {
|
|
|
2541
2728
|
};
|
|
2542
2729
|
|
|
2543
2730
|
// src/actions/relint.ts
|
|
2544
|
-
import
|
|
2731
|
+
import chalk37 from "chalk";
|
|
2545
2732
|
var relintPackage = ({
|
|
2546
2733
|
pkg,
|
|
2547
2734
|
fix: fix2,
|
|
2548
2735
|
verbose
|
|
2549
2736
|
}) => {
|
|
2550
|
-
console.log(
|
|
2737
|
+
console.log(chalk37.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2551
2738
|
const start = Date.now();
|
|
2552
2739
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2553
2740
|
["yarn", [
|
|
@@ -2557,7 +2744,7 @@ var relintPackage = ({
|
|
|
2557
2744
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2558
2745
|
]]
|
|
2559
2746
|
]);
|
|
2560
|
-
console.log(
|
|
2747
|
+
console.log(chalk37.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk37.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk37.gray("seconds")}`));
|
|
2561
2748
|
return result;
|
|
2562
2749
|
};
|
|
2563
2750
|
var relint = ({
|
|
@@ -2577,13 +2764,13 @@ var relint = ({
|
|
|
2577
2764
|
});
|
|
2578
2765
|
};
|
|
2579
2766
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2580
|
-
console.log(
|
|
2767
|
+
console.log(chalk37.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2581
2768
|
const start = Date.now();
|
|
2582
2769
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2583
2770
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2584
2771
|
["yarn", ["eslint", ...fixOptions]]
|
|
2585
2772
|
]);
|
|
2586
|
-
console.log(
|
|
2773
|
+
console.log(chalk37.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk37.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk37.gray("seconds")}`));
|
|
2587
2774
|
return result;
|
|
2588
2775
|
};
|
|
2589
2776
|
|
|
@@ -2601,10 +2788,10 @@ var sonar = () => {
|
|
|
2601
2788
|
};
|
|
2602
2789
|
|
|
2603
2790
|
// src/actions/statics.ts
|
|
2604
|
-
import
|
|
2791
|
+
import chalk38 from "chalk";
|
|
2605
2792
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2606
2793
|
var statics = () => {
|
|
2607
|
-
console.log(
|
|
2794
|
+
console.log(chalk38.green("Check Required Static Dependencies"));
|
|
2608
2795
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2609
2796
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2610
2797
|
};
|
|
@@ -2654,6 +2841,7 @@ var yarn3Only = () => {
|
|
|
2654
2841
|
export {
|
|
2655
2842
|
build,
|
|
2656
2843
|
bundleDts,
|
|
2844
|
+
claudeCommands,
|
|
2657
2845
|
claudeRules,
|
|
2658
2846
|
clean,
|
|
2659
2847
|
cleanAll,
|