@xylabs/ts-scripts-yarn3 7.4.10 → 7.4.12
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 +441 -188
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/readme-gen.mjs +173 -0
- package/dist/actions/readme-gen.mjs.map +1 -0
- package/dist/bin/xy.mjs +432 -130
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +39 -2
- package/dist/index.mjs +490 -207
- package/dist/index.mjs.map +1 -1
- package/dist/lib/generateReadmeFiles.mjs +160 -0
- package/dist/lib/generateReadmeFiles.mjs.map +1 -0
- package/dist/lib/index.mjs +145 -14
- package/dist/lib/index.mjs.map +1 -1
- package/dist/xy/index.mjs +432 -130
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +432 -130
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +210 -42
- 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/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/actions/build.ts
|
|
2
|
-
import
|
|
2
|
+
import chalk10 from "chalk";
|
|
3
3
|
|
|
4
4
|
// src/lib/checkResult.ts
|
|
5
5
|
import chalk from "chalk";
|
|
@@ -379,8 +379,138 @@ var generateIgnoreFiles = (filename3, pkg) => {
|
|
|
379
379
|
return succeeded ? 0 : 1;
|
|
380
380
|
};
|
|
381
381
|
|
|
382
|
-
// src/lib/
|
|
382
|
+
// src/lib/generateReadmeFiles.ts
|
|
383
|
+
import { execSync as execSync2 } from "child_process";
|
|
384
|
+
import FS from "fs";
|
|
385
|
+
import { readFile, writeFile } from "fs/promises";
|
|
386
|
+
import PATH2 from "path";
|
|
383
387
|
import chalk5 from "chalk";
|
|
388
|
+
function fillTemplate(template, data) {
|
|
389
|
+
const additionalData = { ...data, safeName: data.name.replaceAll("/", "__").replaceAll("@", "") };
|
|
390
|
+
return template.replaceAll(/\{\{(.*?)\}\}/g, (_, key) => additionalData[key.trim()] ?? "");
|
|
391
|
+
}
|
|
392
|
+
function generateTypedoc(packageLocation, entryPoints) {
|
|
393
|
+
const tempDir = PATH2.join(packageLocation, ".temp-typedoc");
|
|
394
|
+
try {
|
|
395
|
+
if (!FS.existsSync(tempDir)) {
|
|
396
|
+
FS.mkdirSync(tempDir, { recursive: true });
|
|
397
|
+
}
|
|
398
|
+
const typedocConfig = {
|
|
399
|
+
disableSources: true,
|
|
400
|
+
entryPointStrategy: "expand",
|
|
401
|
+
entryPoints: entryPoints.map((ep) => PATH2.resolve(packageLocation, ep)),
|
|
402
|
+
excludeExternals: true,
|
|
403
|
+
excludeInternal: true,
|
|
404
|
+
excludePrivate: true,
|
|
405
|
+
githubPages: false,
|
|
406
|
+
hideBreadcrumbs: true,
|
|
407
|
+
hideGenerator: true,
|
|
408
|
+
hidePageTitle: true,
|
|
409
|
+
out: tempDir,
|
|
410
|
+
plugin: ["typedoc-plugin-markdown"],
|
|
411
|
+
readme: "none",
|
|
412
|
+
skipErrorChecking: true,
|
|
413
|
+
sort: ["source-order"],
|
|
414
|
+
theme: "markdown",
|
|
415
|
+
useCodeBlocks: true
|
|
416
|
+
};
|
|
417
|
+
const typedocJsonPath = PATH2.join(tempDir, "typedoc.json");
|
|
418
|
+
FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2));
|
|
419
|
+
try {
|
|
420
|
+
execSync2(`npx typedoc --options ${typedocJsonPath}`, {
|
|
421
|
+
cwd: process.cwd(),
|
|
422
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
423
|
+
});
|
|
424
|
+
} catch {
|
|
425
|
+
return "";
|
|
426
|
+
}
|
|
427
|
+
return consolidateMarkdown(tempDir);
|
|
428
|
+
} catch {
|
|
429
|
+
return "";
|
|
430
|
+
} finally {
|
|
431
|
+
try {
|
|
432
|
+
FS.rmSync(tempDir, { force: true, recursive: true });
|
|
433
|
+
} catch {
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function consolidateMarkdown(tempDir) {
|
|
438
|
+
let consolidated = "## Reference\n\n";
|
|
439
|
+
const mainReadmePath = PATH2.join(tempDir, "README.md");
|
|
440
|
+
if (FS.existsSync(mainReadmePath)) {
|
|
441
|
+
const mainContent = FS.readFileSync(mainReadmePath, "utf8").replace(/^---(.|\n)*?---\n/, "").replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
442
|
+
consolidated += mainContent + "\n\n";
|
|
443
|
+
}
|
|
444
|
+
consolidated += processDirectory(tempDir);
|
|
445
|
+
return consolidated.replaceAll(/\n\n\n+/g, "\n\n").replaceAll(/^#### /gm, "### ").replaceAll(/^##### /gm, "#### ").replaceAll(/^###### /gm, "##### ");
|
|
446
|
+
}
|
|
447
|
+
function processDirectory(dir, level = 0) {
|
|
448
|
+
const indent = " ".repeat(level);
|
|
449
|
+
let content = "";
|
|
450
|
+
try {
|
|
451
|
+
const items = FS.readdirSync(dir, { withFileTypes: true });
|
|
452
|
+
for (const item of items) {
|
|
453
|
+
if (item.isDirectory()) continue;
|
|
454
|
+
if (item.name === "README.md" || !item.name.endsWith(".md")) continue;
|
|
455
|
+
const fileContent = FS.readFileSync(PATH2.join(dir, item.name), "utf8").replace(/^---(.|\n)*?---\n/, "");
|
|
456
|
+
const moduleName = item.name.replace(".md", "");
|
|
457
|
+
content += `
|
|
458
|
+
|
|
459
|
+
${indent}### <a id="${moduleName}"></a>${moduleName}
|
|
460
|
+
|
|
461
|
+
`;
|
|
462
|
+
content += fileContent.replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
463
|
+
}
|
|
464
|
+
for (const item of items) {
|
|
465
|
+
if (!item.isDirectory()) continue;
|
|
466
|
+
if (item.name === "spec" || item.name.includes(".spec")) continue;
|
|
467
|
+
content += `
|
|
468
|
+
|
|
469
|
+
${indent}### ${item.name}
|
|
470
|
+
`;
|
|
471
|
+
content += processDirectory(PATH2.join(dir, item.name), level + 1);
|
|
472
|
+
}
|
|
473
|
+
} catch {
|
|
474
|
+
}
|
|
475
|
+
return content;
|
|
476
|
+
}
|
|
477
|
+
async function generateReadmeFiles({
|
|
478
|
+
pkg,
|
|
479
|
+
templatePath,
|
|
480
|
+
typedoc = false,
|
|
481
|
+
verbose
|
|
482
|
+
}) {
|
|
483
|
+
console.log(chalk5.green("Generate README Files"));
|
|
484
|
+
const cwd5 = INIT_CWD() ?? ".";
|
|
485
|
+
const resolvedTemplatePath = templatePath ?? PATH2.join(cwd5, "scripts", "README.template.md");
|
|
486
|
+
let template;
|
|
487
|
+
try {
|
|
488
|
+
template = await readFile(resolvedTemplatePath, "utf8");
|
|
489
|
+
} catch {
|
|
490
|
+
console.error(chalk5.red(`Template not found: ${resolvedTemplatePath}`));
|
|
491
|
+
return 1;
|
|
492
|
+
}
|
|
493
|
+
const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces();
|
|
494
|
+
let failed = false;
|
|
495
|
+
for (const { location, name } of workspaces) {
|
|
496
|
+
try {
|
|
497
|
+
const pkgJsonPath = PATH2.join(location, "package.json");
|
|
498
|
+
const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
|
|
499
|
+
const typedocContent = typedoc ? generateTypedoc(location, ["src/index*.ts"]) : "";
|
|
500
|
+
const readmeContent = fillTemplate(template, { ...pkgJson, typedoc: typedocContent });
|
|
501
|
+
await writeFile(PATH2.join(location, "README.md"), readmeContent);
|
|
502
|
+
if (verbose) console.log(chalk5.green(` ${name}`));
|
|
503
|
+
} catch (ex) {
|
|
504
|
+
const error = ex;
|
|
505
|
+
console.warn(chalk5.yellow(` Skipped ${location}: ${error.message}`));
|
|
506
|
+
failed = true;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return failed ? 1 : 0;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// src/lib/loadConfig.ts
|
|
513
|
+
import chalk6 from "chalk";
|
|
384
514
|
import { cosmiconfig } from "cosmiconfig";
|
|
385
515
|
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
386
516
|
import deepmerge from "deepmerge";
|
|
@@ -391,9 +521,9 @@ var loadConfig = async (params) => {
|
|
|
391
521
|
config = cosmicConfigResult?.config;
|
|
392
522
|
const configFilePath = cosmicConfigResult?.filepath;
|
|
393
523
|
if (configFilePath !== void 0) {
|
|
394
|
-
console.log(
|
|
524
|
+
console.log(chalk6.green(`Loaded config from ${configFilePath}`));
|
|
395
525
|
if (config.verbose) {
|
|
396
|
-
console.log(
|
|
526
|
+
console.log(chalk6.gray(`${JSON.stringify(config, null, 2)}`));
|
|
397
527
|
}
|
|
398
528
|
}
|
|
399
529
|
}
|
|
@@ -402,8 +532,8 @@ var loadConfig = async (params) => {
|
|
|
402
532
|
|
|
403
533
|
// src/lib/parsedPackageJSON.ts
|
|
404
534
|
import { readFileSync as readFileSync5 } from "fs";
|
|
405
|
-
var parsedPackageJSON = (
|
|
406
|
-
const pathToPackageJSON =
|
|
535
|
+
var parsedPackageJSON = (path14) => {
|
|
536
|
+
const pathToPackageJSON = path14 ?? process.env.npm_package_json ?? "";
|
|
407
537
|
const packageJSON = readFileSync5(pathToPackageJSON).toString();
|
|
408
538
|
return JSON.parse(packageJSON);
|
|
409
539
|
};
|
|
@@ -411,15 +541,15 @@ var parsedPackageJSON = (path13) => {
|
|
|
411
541
|
// src/lib/runSteps.ts
|
|
412
542
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
413
543
|
import { existsSync as existsSync3 } from "fs";
|
|
414
|
-
import
|
|
544
|
+
import chalk7 from "chalk";
|
|
415
545
|
var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
416
546
|
return safeExit(() => {
|
|
417
547
|
const pkgName = process.env.npm_package_name;
|
|
418
|
-
console.log(
|
|
548
|
+
console.log(chalk7.green(`${name} [${pkgName}]`));
|
|
419
549
|
let totalStatus = 0;
|
|
420
550
|
for (const [i, [command, args, config2]] of steps.entries()) {
|
|
421
551
|
if (messages?.[i]) {
|
|
422
|
-
console.log(
|
|
552
|
+
console.log(chalk7.gray(messages?.[i]));
|
|
423
553
|
}
|
|
424
554
|
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
425
555
|
if (command === "node" && !existsSync3(argList[0])) {
|
|
@@ -442,12 +572,12 @@ var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
|
442
572
|
// src/lib/runStepsAsync.ts
|
|
443
573
|
import { spawn } from "child_process";
|
|
444
574
|
import { existsSync as existsSync4 } from "fs";
|
|
445
|
-
import
|
|
575
|
+
import chalk8 from "chalk";
|
|
446
576
|
var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
447
577
|
return new Promise((resolve) => {
|
|
448
578
|
const [command, args, config2] = step;
|
|
449
579
|
if (message) {
|
|
450
|
-
console.log(
|
|
580
|
+
console.log(chalk8.gray(message));
|
|
451
581
|
}
|
|
452
582
|
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
453
583
|
if (command === "node" && !existsSync4(argList[0])) {
|
|
@@ -461,8 +591,8 @@ var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
|
461
591
|
}).on("close", (code) => {
|
|
462
592
|
if (code) {
|
|
463
593
|
console.error(
|
|
464
|
-
|
|
465
|
-
`Command Exited With Non-Zero Result [${
|
|
594
|
+
chalk8.red(
|
|
595
|
+
`Command Exited With Non-Zero Result [${chalk8.gray(code)}] | ${chalk8.yellow(command)} ${chalk8.white(
|
|
466
596
|
Array.isArray(args) ? args.join(" ") : args
|
|
467
597
|
)}`
|
|
468
598
|
)
|
|
@@ -478,7 +608,7 @@ var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
|
478
608
|
var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
|
|
479
609
|
return await safeExitAsync(async () => {
|
|
480
610
|
const pkgName = process.env.npm_package_name;
|
|
481
|
-
console.log(
|
|
611
|
+
console.log(chalk8.green(`${name} [${pkgName}]`));
|
|
482
612
|
let result = 0;
|
|
483
613
|
for (const [i, step] of steps.entries()) {
|
|
484
614
|
result += await runStepAsync(name, step, exitOnFail, messages?.[i]);
|
|
@@ -496,12 +626,12 @@ var runXy = (command) => {
|
|
|
496
626
|
};
|
|
497
627
|
|
|
498
628
|
// src/lib/runXyWithWarning.ts
|
|
499
|
-
import
|
|
629
|
+
import chalk9 from "chalk";
|
|
500
630
|
var runXyWithWarning = (command) => {
|
|
501
631
|
const commandString = `yarn ${command}`;
|
|
502
632
|
const commandXyString = `yarn xy ${command}`;
|
|
503
|
-
console.warn(
|
|
504
|
-
console.warn(
|
|
633
|
+
console.warn(chalk9.yellow(`WARNING: [${chalk9.white(commandString)}] is deprecated for XY Labs Scripts.`));
|
|
634
|
+
console.warn(chalk9.gray(`Did you mean [${chalk9.magenta(commandXyString)}]?`));
|
|
505
635
|
return 1;
|
|
506
636
|
};
|
|
507
637
|
|
|
@@ -520,7 +650,7 @@ var build = async ({
|
|
|
520
650
|
const targetOptions = target === void 0 ? [] : ["-t", target];
|
|
521
651
|
const jobsOptions = jobs === void 0 ? [] : ["-j", `${jobs}`];
|
|
522
652
|
if (jobs !== void 0) {
|
|
523
|
-
console.log(
|
|
653
|
+
console.log(chalk10.blue(`Jobs set to [${jobs}]`));
|
|
524
654
|
}
|
|
525
655
|
const result = await runStepsAsync(`Build${incremental ? "-Incremental" : ""} [${pkg ?? "All"}]`, [
|
|
526
656
|
["yarn", ["xy", "compile", ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, "--types", "tsup"]],
|
|
@@ -528,7 +658,7 @@ var build = async ({
|
|
|
528
658
|
["yarn", ["xy", "deplint", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
|
|
529
659
|
["yarn", ["xy", "lint", ...pkgOptions, ...verboseOptions, ...incrementalOptions]]
|
|
530
660
|
]);
|
|
531
|
-
console.log(`${
|
|
661
|
+
console.log(`${chalk10.gray("Built in")} [${chalk10.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk10.gray("seconds")}`);
|
|
532
662
|
return result;
|
|
533
663
|
};
|
|
534
664
|
|
|
@@ -541,15 +671,15 @@ import {
|
|
|
541
671
|
unlinkSync,
|
|
542
672
|
writeFileSync as writeFileSync2
|
|
543
673
|
} from "fs";
|
|
544
|
-
import
|
|
545
|
-
import
|
|
674
|
+
import PATH3 from "path";
|
|
675
|
+
import chalk11 from "chalk";
|
|
546
676
|
var syncCommandFiles = (commandsDir) => {
|
|
547
677
|
const templates = claudeCommandTemplates();
|
|
548
678
|
const templateNames = new Set(Object.keys(templates));
|
|
549
679
|
let updated = 0;
|
|
550
680
|
let created = 0;
|
|
551
681
|
for (const [filename3, content] of Object.entries(templates)) {
|
|
552
|
-
const targetPath =
|
|
682
|
+
const targetPath = PATH3.resolve(commandsDir, filename3);
|
|
553
683
|
const existing = existsSync5(targetPath) ? readFileSync6(targetPath, "utf8") : void 0;
|
|
554
684
|
if (existing === content) continue;
|
|
555
685
|
writeFileSync2(targetPath, content, "utf8");
|
|
@@ -570,7 +700,7 @@ var removeStaleCommands = (commandsDir, templateNames) => {
|
|
|
570
700
|
let removed = 0;
|
|
571
701
|
for (const file of existingCommands) {
|
|
572
702
|
if (!templateNames.has(file)) {
|
|
573
|
-
unlinkSync(
|
|
703
|
+
unlinkSync(PATH3.resolve(commandsDir, file));
|
|
574
704
|
removed++;
|
|
575
705
|
}
|
|
576
706
|
}
|
|
@@ -583,14 +713,14 @@ var logCommandsResult = (created, updated, removed) => {
|
|
|
583
713
|
updated ? `${updated} updated` : "",
|
|
584
714
|
removed ? `${removed} removed` : ""
|
|
585
715
|
].filter(Boolean);
|
|
586
|
-
console.log(
|
|
716
|
+
console.log(chalk11.green(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: ${parts.join(", ")}`));
|
|
587
717
|
} else {
|
|
588
|
-
console.log(
|
|
718
|
+
console.log(chalk11.gray(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: already up to date`));
|
|
589
719
|
}
|
|
590
720
|
};
|
|
591
721
|
var claudeCommands = () => {
|
|
592
722
|
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
593
|
-
const commandsDir =
|
|
723
|
+
const commandsDir = PATH3.resolve(cwd5, ".claude", "commands");
|
|
594
724
|
mkdirSync(commandsDir, { recursive: true });
|
|
595
725
|
const {
|
|
596
726
|
created,
|
|
@@ -611,15 +741,15 @@ import {
|
|
|
611
741
|
unlinkSync as unlinkSync2,
|
|
612
742
|
writeFileSync as writeFileSync3
|
|
613
743
|
} from "fs";
|
|
614
|
-
import
|
|
615
|
-
import
|
|
744
|
+
import PATH4 from "path";
|
|
745
|
+
import chalk12 from "chalk";
|
|
616
746
|
var syncRuleFiles = (rulesDir) => {
|
|
617
747
|
const templates = claudeMdRuleTemplates();
|
|
618
748
|
const templateNames = new Set(Object.keys(templates));
|
|
619
749
|
let updated = 0;
|
|
620
750
|
let created = 0;
|
|
621
751
|
for (const [filename3, content] of Object.entries(templates)) {
|
|
622
|
-
const targetPath =
|
|
752
|
+
const targetPath = PATH4.resolve(rulesDir, filename3);
|
|
623
753
|
const existing = existsSync6(targetPath) ? readFileSync7(targetPath, "utf8") : void 0;
|
|
624
754
|
if (existing === content) continue;
|
|
625
755
|
writeFileSync3(targetPath, content, "utf8");
|
|
@@ -640,7 +770,7 @@ var removeStaleRules = (rulesDir, templateNames) => {
|
|
|
640
770
|
let removed = 0;
|
|
641
771
|
for (const file of existingRules) {
|
|
642
772
|
if (!templateNames.has(file)) {
|
|
643
|
-
unlinkSync2(
|
|
773
|
+
unlinkSync2(PATH4.resolve(rulesDir, file));
|
|
644
774
|
removed++;
|
|
645
775
|
}
|
|
646
776
|
}
|
|
@@ -653,26 +783,26 @@ var logRulesResult = (created, updated, removed) => {
|
|
|
653
783
|
updated ? `${updated} updated` : "",
|
|
654
784
|
removed ? `${removed} removed` : ""
|
|
655
785
|
].filter(Boolean);
|
|
656
|
-
console.log(
|
|
786
|
+
console.log(chalk12.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
|
|
657
787
|
} else {
|
|
658
|
-
console.log(
|
|
788
|
+
console.log(chalk12.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
|
|
659
789
|
}
|
|
660
790
|
};
|
|
661
791
|
var ensureProjectClaudeMd = (cwd5, force) => {
|
|
662
|
-
const projectPath =
|
|
792
|
+
const projectPath = PATH4.resolve(cwd5, "CLAUDE.md");
|
|
663
793
|
if (!existsSync6(projectPath) || force) {
|
|
664
794
|
if (force && existsSync6(projectPath)) {
|
|
665
|
-
console.log(
|
|
795
|
+
console.log(chalk12.yellow("Overwriting existing CLAUDE.md"));
|
|
666
796
|
}
|
|
667
797
|
writeFileSync3(projectPath, claudeMdProjectTemplate(), "utf8");
|
|
668
|
-
console.log(
|
|
798
|
+
console.log(chalk12.green("Generated CLAUDE.md"));
|
|
669
799
|
} else {
|
|
670
|
-
console.log(
|
|
800
|
+
console.log(chalk12.gray("CLAUDE.md already exists (skipped)"));
|
|
671
801
|
}
|
|
672
802
|
};
|
|
673
803
|
var claudeRules = ({ force } = {}) => {
|
|
674
804
|
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
675
|
-
const rulesDir =
|
|
805
|
+
const rulesDir = PATH4.resolve(cwd5, ".claude", "rules");
|
|
676
806
|
mkdirSync2(rulesDir, { recursive: true });
|
|
677
807
|
const {
|
|
678
808
|
created,
|
|
@@ -699,16 +829,16 @@ var cleanAll = ({ verbose }) => {
|
|
|
699
829
|
|
|
700
830
|
// src/actions/clean-docs.ts
|
|
701
831
|
import path from "path";
|
|
702
|
-
import
|
|
832
|
+
import chalk13 from "chalk";
|
|
703
833
|
var cleanDocs = () => {
|
|
704
834
|
const pkgName = process.env.npm_package_name;
|
|
705
|
-
console.log(
|
|
835
|
+
console.log(chalk13.green(`Cleaning Docs [${pkgName}]`));
|
|
706
836
|
for (const { location } of yarnWorkspaces()) deleteGlob(path.join(location, "docs"));
|
|
707
837
|
return 0;
|
|
708
838
|
};
|
|
709
839
|
|
|
710
840
|
// src/actions/compile.ts
|
|
711
|
-
import
|
|
841
|
+
import chalk14 from "chalk";
|
|
712
842
|
var compile = ({
|
|
713
843
|
verbose,
|
|
714
844
|
target,
|
|
@@ -749,7 +879,7 @@ var compileAll = ({
|
|
|
749
879
|
const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
|
|
750
880
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
751
881
|
if (jobs) {
|
|
752
|
-
console.log(
|
|
882
|
+
console.log(chalk14.blue(`Jobs set to [${jobs}]`));
|
|
753
883
|
}
|
|
754
884
|
const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
|
|
755
885
|
["yarn", [
|
|
@@ -763,13 +893,13 @@ var compileAll = ({
|
|
|
763
893
|
...targetOptions
|
|
764
894
|
]]
|
|
765
895
|
]);
|
|
766
|
-
console.log(`${
|
|
896
|
+
console.log(`${chalk14.gray("Compiled in")} [${chalk14.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk14.gray("seconds")}`);
|
|
767
897
|
return result;
|
|
768
898
|
};
|
|
769
899
|
|
|
770
900
|
// src/actions/copy-assets.ts
|
|
771
901
|
import path2 from "path/posix";
|
|
772
|
-
import
|
|
902
|
+
import chalk15 from "chalk";
|
|
773
903
|
import cpy from "cpy";
|
|
774
904
|
var copyPackageTargetAssets = async (target, name, location) => {
|
|
775
905
|
try {
|
|
@@ -792,7 +922,7 @@ var copyPackageTargetAssets = async (target, name, location) => {
|
|
|
792
922
|
};
|
|
793
923
|
var copyTargetAssets = async (target, pkg) => {
|
|
794
924
|
const workspaces = yarnWorkspaces();
|
|
795
|
-
console.log(
|
|
925
|
+
console.log(chalk15.green(`Copying Assets [${target.toUpperCase()}]`));
|
|
796
926
|
const workspaceList = workspaces.filter(({ name }) => {
|
|
797
927
|
return pkg === void 0 || name === pkg;
|
|
798
928
|
});
|
|
@@ -876,7 +1006,7 @@ var dead = () => {
|
|
|
876
1006
|
};
|
|
877
1007
|
|
|
878
1008
|
// src/actions/deplint/deplint.ts
|
|
879
|
-
import
|
|
1009
|
+
import chalk21 from "chalk";
|
|
880
1010
|
|
|
881
1011
|
// src/actions/deplint/findFiles.ts
|
|
882
1012
|
import fs2 from "fs";
|
|
@@ -1052,11 +1182,11 @@ function getExternalImportsFromFiles({
|
|
|
1052
1182
|
const allImportPaths = {};
|
|
1053
1183
|
const distImportPaths = {};
|
|
1054
1184
|
const distTypeImportPaths = {};
|
|
1055
|
-
for (const
|
|
1185
|
+
for (const path14 of allFiles) getImportsFromFile(path14, allImportPaths, allImportPaths).flat();
|
|
1056
1186
|
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
1057
1187
|
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
1058
|
-
for (const
|
|
1059
|
-
for (const
|
|
1188
|
+
for (const path14 of distCodeFiles) getImportsFromFile(path14, distImportPaths, distImportPaths).flat();
|
|
1189
|
+
for (const path14 of distTypeFiles) getImportsFromFile(path14, distTypeImportPaths, distTypeImportPaths).flat();
|
|
1060
1190
|
const allImports = Object.keys(allImportPaths);
|
|
1061
1191
|
const distImports = Object.keys(distImportPaths);
|
|
1062
1192
|
const externalAllImports = removeInternalImports(allImports);
|
|
@@ -1078,12 +1208,12 @@ function getExternalImportsFromFiles({
|
|
|
1078
1208
|
|
|
1079
1209
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
1080
1210
|
import { builtinModules } from "module";
|
|
1081
|
-
import
|
|
1211
|
+
import chalk16 from "chalk";
|
|
1082
1212
|
function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
|
|
1083
1213
|
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
|
|
1084
1214
|
}
|
|
1085
1215
|
function logMissing(name, imp, importPaths) {
|
|
1086
|
-
console.log(`[${
|
|
1216
|
+
console.log(`[${chalk16.blue(name)}] Missing dependency in package.json: ${chalk16.red(imp)}`);
|
|
1087
1217
|
if (importPaths[imp]) {
|
|
1088
1218
|
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
1089
1219
|
}
|
|
@@ -1108,7 +1238,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
1108
1238
|
}
|
|
1109
1239
|
if (unlistedDependencies > 0) {
|
|
1110
1240
|
const packageLocation = `${location}/package.json`;
|
|
1111
|
-
console.log(` ${
|
|
1241
|
+
console.log(` ${chalk16.yellow(packageLocation)}
|
|
1112
1242
|
`);
|
|
1113
1243
|
}
|
|
1114
1244
|
return unlistedDependencies;
|
|
@@ -1116,7 +1246,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
1116
1246
|
|
|
1117
1247
|
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
1118
1248
|
import { builtinModules as builtinModules2 } from "module";
|
|
1119
|
-
import
|
|
1249
|
+
import chalk17 from "chalk";
|
|
1120
1250
|
function getUnlistedDevDependencies({ name, location }, {
|
|
1121
1251
|
devDependencies,
|
|
1122
1252
|
dependencies,
|
|
@@ -1130,7 +1260,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
1130
1260
|
for (const imp of externalAllImports) {
|
|
1131
1261
|
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)) {
|
|
1132
1262
|
unlistedDevDependencies++;
|
|
1133
|
-
console.log(`[${
|
|
1263
|
+
console.log(`[${chalk17.blue(name)}] Missing devDependency in package.json: ${chalk17.red(imp)}`);
|
|
1134
1264
|
if (allImportPaths[imp]) {
|
|
1135
1265
|
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
1136
1266
|
}
|
|
@@ -1138,40 +1268,50 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
1138
1268
|
}
|
|
1139
1269
|
if (unlistedDevDependencies > 0) {
|
|
1140
1270
|
const packageLocation = `${location}/package.json`;
|
|
1141
|
-
console.log(` ${
|
|
1271
|
+
console.log(` ${chalk17.yellow(packageLocation)}
|
|
1142
1272
|
`);
|
|
1143
1273
|
}
|
|
1144
1274
|
return unlistedDevDependencies;
|
|
1145
1275
|
}
|
|
1146
1276
|
|
|
1147
1277
|
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
1148
|
-
import
|
|
1278
|
+
import chalk18 from "chalk";
|
|
1149
1279
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
1150
1280
|
externalDistImports,
|
|
1151
1281
|
externalDistTypeImports,
|
|
1152
1282
|
externalAllImports
|
|
1153
|
-
}) {
|
|
1283
|
+
}, exclude) {
|
|
1154
1284
|
let unusedDependencies = 0;
|
|
1155
1285
|
for (const dep of dependencies) {
|
|
1286
|
+
if (exclude?.has(dep)) continue;
|
|
1156
1287
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1157
1288
|
unusedDependencies++;
|
|
1158
1289
|
if (externalAllImports.includes(dep)) {
|
|
1159
|
-
console.log(`[${
|
|
1290
|
+
console.log(`[${chalk18.blue(name)}] dependency should be devDependency in package.json: ${chalk18.red(dep)}`);
|
|
1160
1291
|
} else {
|
|
1161
|
-
console.log(`[${
|
|
1292
|
+
console.log(`[${chalk18.blue(name)}] Unused dependency in package.json: ${chalk18.red(dep)}`);
|
|
1162
1293
|
}
|
|
1163
1294
|
}
|
|
1164
1295
|
}
|
|
1165
1296
|
if (unusedDependencies > 0) {
|
|
1166
1297
|
const packageLocation = `${location}/package.json`;
|
|
1167
|
-
console.log(` ${
|
|
1298
|
+
console.log(` ${chalk18.yellow(packageLocation)}
|
|
1168
1299
|
`);
|
|
1169
1300
|
}
|
|
1170
1301
|
return unusedDependencies;
|
|
1171
1302
|
}
|
|
1172
1303
|
|
|
1173
1304
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1174
|
-
import
|
|
1305
|
+
import chalk19 from "chalk";
|
|
1306
|
+
|
|
1307
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1308
|
+
import fs8 from "fs";
|
|
1309
|
+
import path7 from "path";
|
|
1310
|
+
import ts2 from "typescript";
|
|
1311
|
+
|
|
1312
|
+
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1313
|
+
import fs7 from "fs";
|
|
1314
|
+
import path6 from "path";
|
|
1175
1315
|
|
|
1176
1316
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
1177
1317
|
import fs6 from "fs";
|
|
@@ -1206,8 +1346,6 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1206
1346
|
}
|
|
1207
1347
|
|
|
1208
1348
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1209
|
-
import fs7 from "fs";
|
|
1210
|
-
import path6 from "path";
|
|
1211
1349
|
function getBinNames(location, dep) {
|
|
1212
1350
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1213
1351
|
if (!depPkgPath) return [];
|
|
@@ -1257,15 +1395,101 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1257
1395
|
return referenced;
|
|
1258
1396
|
}
|
|
1259
1397
|
|
|
1398
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1399
|
+
var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
|
|
1400
|
+
var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
|
|
1401
|
+
var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
|
|
1402
|
+
function getCommandTokensFromFile(filePath) {
|
|
1403
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
1404
|
+
let sourceCode;
|
|
1405
|
+
try {
|
|
1406
|
+
sourceCode = fs8.readFileSync(filePath, "utf8");
|
|
1407
|
+
} catch {
|
|
1408
|
+
return tokens;
|
|
1409
|
+
}
|
|
1410
|
+
const isMjsFile = filePath.endsWith(".mjs");
|
|
1411
|
+
const sourceFile = ts2.createSourceFile(
|
|
1412
|
+
path7.basename(filePath),
|
|
1413
|
+
sourceCode,
|
|
1414
|
+
ts2.ScriptTarget.Latest,
|
|
1415
|
+
true,
|
|
1416
|
+
isMjsFile ? ts2.ScriptKind.JS : void 0
|
|
1417
|
+
);
|
|
1418
|
+
function visit(node) {
|
|
1419
|
+
if (ts2.isCallExpression(node) && node.arguments.length > 0) {
|
|
1420
|
+
const fnName = getFunctionName(node.expression);
|
|
1421
|
+
if (fnName && allExecFunctions.has(fnName)) {
|
|
1422
|
+
const firstArg = node.arguments[0];
|
|
1423
|
+
if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
|
|
1424
|
+
const value = firstArg.text;
|
|
1425
|
+
if (shellCommandFunctions.has(fnName)) {
|
|
1426
|
+
for (const token of tokenizeScript(value)) {
|
|
1427
|
+
tokens.add(token);
|
|
1428
|
+
}
|
|
1429
|
+
} else {
|
|
1430
|
+
tokens.add(value);
|
|
1431
|
+
}
|
|
1432
|
+
} else if (ts2.isTemplateExpression(firstArg)) {
|
|
1433
|
+
const head = firstArg.head.text;
|
|
1434
|
+
if (head) {
|
|
1435
|
+
for (const token of tokenizeScript(head)) {
|
|
1436
|
+
tokens.add(token);
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
ts2.forEachChild(node, visit);
|
|
1443
|
+
}
|
|
1444
|
+
visit(sourceFile);
|
|
1445
|
+
return tokens;
|
|
1446
|
+
}
|
|
1447
|
+
function getFunctionName(expr) {
|
|
1448
|
+
if (ts2.isIdentifier(expr)) {
|
|
1449
|
+
return expr.text;
|
|
1450
|
+
}
|
|
1451
|
+
if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
|
|
1452
|
+
return expr.name.text;
|
|
1453
|
+
}
|
|
1454
|
+
return void 0;
|
|
1455
|
+
}
|
|
1456
|
+
function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
|
|
1457
|
+
const allTokens = /* @__PURE__ */ new Set();
|
|
1458
|
+
for (const file of allFiles) {
|
|
1459
|
+
for (const token of getCommandTokensFromFile(file)) {
|
|
1460
|
+
allTokens.add(token);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
if (allTokens.size === 0) return /* @__PURE__ */ new Set();
|
|
1464
|
+
const binToPackage = /* @__PURE__ */ new Map();
|
|
1465
|
+
for (const dep of allDeps) {
|
|
1466
|
+
for (const bin of getBinNames(location, dep)) {
|
|
1467
|
+
binToPackage.set(bin, dep);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1471
|
+
for (const token of allTokens) {
|
|
1472
|
+
const baseName = getBasePackageName(token);
|
|
1473
|
+
if (allDeps.includes(baseName)) {
|
|
1474
|
+
referenced.add(baseName);
|
|
1475
|
+
}
|
|
1476
|
+
const pkg = binToPackage.get(token);
|
|
1477
|
+
if (pkg) {
|
|
1478
|
+
referenced.add(pkg);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
return referenced;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1260
1484
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1261
|
-
import
|
|
1485
|
+
import fs9 from "fs";
|
|
1262
1486
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1263
1487
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1264
1488
|
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1265
1489
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1266
1490
|
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1267
1491
|
try {
|
|
1268
|
-
const content =
|
|
1492
|
+
const content = fs9.readFileSync(file, "utf8");
|
|
1269
1493
|
return decoratorPattern.test(content);
|
|
1270
1494
|
} catch {
|
|
1271
1495
|
return false;
|
|
@@ -1278,7 +1502,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1278
1502
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1279
1503
|
if (!pkgPath) continue;
|
|
1280
1504
|
try {
|
|
1281
|
-
const pkg = JSON.parse(
|
|
1505
|
+
const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
|
|
1282
1506
|
const transitiveDeps = [
|
|
1283
1507
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1284
1508
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1330,10 +1554,11 @@ var allExternalImports = ({
|
|
|
1330
1554
|
...externalDistTypeImports
|
|
1331
1555
|
]);
|
|
1332
1556
|
};
|
|
1333
|
-
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1557
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
|
|
1334
1558
|
if (implicitDeps.has(dep)) return true;
|
|
1335
1559
|
if (requiredPeers.has(dep)) return true;
|
|
1336
1560
|
if (scriptRefs.has(dep)) return true;
|
|
1561
|
+
if (cliRefs.has(dep)) return true;
|
|
1337
1562
|
if (dep.startsWith("@types/")) {
|
|
1338
1563
|
const baseName = dep.replace(/^@types\//, "");
|
|
1339
1564
|
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
@@ -1344,7 +1569,7 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1344
1569
|
devDependencies,
|
|
1345
1570
|
dependencies,
|
|
1346
1571
|
peerDependencies
|
|
1347
|
-
}, sourceParams, fileContext) {
|
|
1572
|
+
}, sourceParams, fileContext, exclude) {
|
|
1348
1573
|
const allImports = allExternalImports(sourceParams);
|
|
1349
1574
|
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1350
1575
|
const implicitDeps = getImplicitDevDependencies({
|
|
@@ -1354,39 +1579,42 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1354
1579
|
});
|
|
1355
1580
|
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1356
1581
|
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1582
|
+
const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
|
|
1357
1583
|
let unusedDevDependencies = 0;
|
|
1358
1584
|
for (const dep of devDependencies) {
|
|
1585
|
+
if (exclude?.has(dep)) continue;
|
|
1359
1586
|
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1360
|
-
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1587
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
|
|
1361
1588
|
unusedDevDependencies++;
|
|
1362
|
-
console.log(`[${
|
|
1589
|
+
console.log(`[${chalk19.blue(name)}] Unused devDependency in package.json: ${chalk19.red(dep)}`);
|
|
1363
1590
|
}
|
|
1364
1591
|
}
|
|
1365
1592
|
if (unusedDevDependencies > 0) {
|
|
1366
1593
|
const packageLocation = `${location}/package.json`;
|
|
1367
|
-
console.log(` ${
|
|
1594
|
+
console.log(` ${chalk19.yellow(packageLocation)}
|
|
1368
1595
|
`);
|
|
1369
1596
|
}
|
|
1370
1597
|
return unusedDevDependencies;
|
|
1371
1598
|
}
|
|
1372
1599
|
|
|
1373
1600
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1374
|
-
import
|
|
1375
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
1601
|
+
import chalk20 from "chalk";
|
|
1602
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
|
|
1376
1603
|
let unusedDependencies = 0;
|
|
1377
1604
|
for (const dep of peerDependencies) {
|
|
1605
|
+
if (exclude?.has(dep)) continue;
|
|
1378
1606
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1379
1607
|
unusedDependencies++;
|
|
1380
1608
|
if (dependencies.includes(dep)) {
|
|
1381
|
-
console.log(`[${
|
|
1609
|
+
console.log(`[${chalk20.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk20.red(dep)}`);
|
|
1382
1610
|
} else {
|
|
1383
|
-
console.log(`[${
|
|
1611
|
+
console.log(`[${chalk20.blue(name)}] Unused peerDependency in package.json: ${chalk20.red(dep)}`);
|
|
1384
1612
|
}
|
|
1385
1613
|
}
|
|
1386
1614
|
}
|
|
1387
1615
|
if (unusedDependencies > 0) {
|
|
1388
1616
|
const packageLocation = `${location}/package.json`;
|
|
1389
|
-
console.log(` ${
|
|
1617
|
+
console.log(` ${chalk20.yellow(packageLocation)}
|
|
1390
1618
|
`);
|
|
1391
1619
|
}
|
|
1392
1620
|
return unusedDependencies;
|
|
@@ -1411,6 +1639,7 @@ function checkPackage({
|
|
|
1411
1639
|
location,
|
|
1412
1640
|
deps = false,
|
|
1413
1641
|
devDeps = false,
|
|
1642
|
+
exclude,
|
|
1414
1643
|
peerDeps = false,
|
|
1415
1644
|
verbose = false
|
|
1416
1645
|
}) {
|
|
@@ -1429,23 +1658,29 @@ function checkPackage({
|
|
|
1429
1658
|
});
|
|
1430
1659
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1431
1660
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1432
|
-
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1661
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1433
1662
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1434
1663
|
const fileContext = { allFiles, distFiles };
|
|
1435
|
-
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1436
|
-
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1664
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
|
|
1665
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1437
1666
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
1438
1667
|
return totalErrors;
|
|
1439
1668
|
}
|
|
1440
1669
|
|
|
1441
1670
|
// src/actions/deplint/deplint.ts
|
|
1442
|
-
var deplint = ({
|
|
1671
|
+
var deplint = async ({
|
|
1443
1672
|
pkg,
|
|
1444
1673
|
deps,
|
|
1445
1674
|
devDeps,
|
|
1446
1675
|
peerDeps,
|
|
1447
|
-
verbose
|
|
1676
|
+
verbose,
|
|
1677
|
+
cliExclude
|
|
1448
1678
|
}) => {
|
|
1679
|
+
const config2 = await loadConfig();
|
|
1680
|
+
const exclude = /* @__PURE__ */ new Set([
|
|
1681
|
+
...config2.deplint?.exclude ?? [],
|
|
1682
|
+
...cliExclude ?? []
|
|
1683
|
+
]);
|
|
1449
1684
|
let totalErrors = 0;
|
|
1450
1685
|
if (pkg === void 0) {
|
|
1451
1686
|
const workspaces = yarnWorkspaces();
|
|
@@ -1455,6 +1690,7 @@ var deplint = ({
|
|
|
1455
1690
|
...workspace,
|
|
1456
1691
|
deps,
|
|
1457
1692
|
devDeps,
|
|
1693
|
+
exclude,
|
|
1458
1694
|
peerDeps,
|
|
1459
1695
|
verbose
|
|
1460
1696
|
});
|
|
@@ -1467,14 +1703,15 @@ var deplint = ({
|
|
|
1467
1703
|
location,
|
|
1468
1704
|
devDeps,
|
|
1469
1705
|
deps,
|
|
1706
|
+
exclude,
|
|
1470
1707
|
peerDeps,
|
|
1471
1708
|
verbose
|
|
1472
1709
|
});
|
|
1473
1710
|
}
|
|
1474
1711
|
if (totalErrors > 0) {
|
|
1475
|
-
console.warn(`Deplint: Found ${
|
|
1712
|
+
console.warn(`Deplint: Found ${chalk21.red(totalErrors)} dependency problems. ${chalk21.red("\u2716")}`);
|
|
1476
1713
|
} else {
|
|
1477
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1714
|
+
console.info(`Deplint: Found no dependency problems. ${chalk21.green("\u2714")}`);
|
|
1478
1715
|
}
|
|
1479
1716
|
return 0;
|
|
1480
1717
|
};
|
|
@@ -1576,22 +1813,22 @@ var deployNext = () => {
|
|
|
1576
1813
|
};
|
|
1577
1814
|
|
|
1578
1815
|
// src/actions/dupdeps.ts
|
|
1579
|
-
import
|
|
1816
|
+
import chalk22 from "chalk";
|
|
1580
1817
|
var dupdeps = () => {
|
|
1581
|
-
console.log(
|
|
1818
|
+
console.log(chalk22.green("Checking all Dependencies for Duplicates"));
|
|
1582
1819
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1583
1820
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1584
1821
|
return detectDuplicateDependencies(dependencies);
|
|
1585
1822
|
};
|
|
1586
1823
|
|
|
1587
1824
|
// src/actions/lint.ts
|
|
1588
|
-
import
|
|
1825
|
+
import chalk23 from "chalk";
|
|
1589
1826
|
var lintPackage = ({
|
|
1590
1827
|
pkg,
|
|
1591
1828
|
fix: fix2,
|
|
1592
1829
|
verbose
|
|
1593
1830
|
}) => {
|
|
1594
|
-
console.log(
|
|
1831
|
+
console.log(chalk23.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1595
1832
|
const start = Date.now();
|
|
1596
1833
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1597
1834
|
["yarn", [
|
|
@@ -1601,7 +1838,7 @@ var lintPackage = ({
|
|
|
1601
1838
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1602
1839
|
]]
|
|
1603
1840
|
]);
|
|
1604
|
-
console.log(
|
|
1841
|
+
console.log(chalk23.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk23.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk23.gray("seconds")}`));
|
|
1605
1842
|
return result;
|
|
1606
1843
|
};
|
|
1607
1844
|
var lint = ({
|
|
@@ -1621,13 +1858,13 @@ var lint = ({
|
|
|
1621
1858
|
});
|
|
1622
1859
|
};
|
|
1623
1860
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1624
|
-
console.log(
|
|
1861
|
+
console.log(chalk23.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1625
1862
|
const start = Date.now();
|
|
1626
1863
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1627
1864
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1628
1865
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1629
1866
|
]);
|
|
1630
|
-
console.log(
|
|
1867
|
+
console.log(chalk23.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk23.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk23.gray("seconds")}`));
|
|
1631
1868
|
return result;
|
|
1632
1869
|
};
|
|
1633
1870
|
|
|
@@ -1655,7 +1892,7 @@ var filename = ".gitignore";
|
|
|
1655
1892
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1656
1893
|
|
|
1657
1894
|
// src/actions/gitlint.ts
|
|
1658
|
-
import
|
|
1895
|
+
import chalk24 from "chalk";
|
|
1659
1896
|
import ParseGitConfig from "parse-git-config";
|
|
1660
1897
|
var gitlint = () => {
|
|
1661
1898
|
console.log(`
|
|
@@ -1666,7 +1903,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1666
1903
|
const errors = 0;
|
|
1667
1904
|
const gitConfig = ParseGitConfig.sync();
|
|
1668
1905
|
const warn = (message) => {
|
|
1669
|
-
console.warn(
|
|
1906
|
+
console.warn(chalk24.yellow(`Warning: ${message}`));
|
|
1670
1907
|
warnings++;
|
|
1671
1908
|
};
|
|
1672
1909
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1686,13 +1923,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1686
1923
|
}
|
|
1687
1924
|
const resultMessages = [];
|
|
1688
1925
|
if (valid > 0) {
|
|
1689
|
-
resultMessages.push(
|
|
1926
|
+
resultMessages.push(chalk24.green(`Passed: ${valid}`));
|
|
1690
1927
|
}
|
|
1691
1928
|
if (warnings > 0) {
|
|
1692
|
-
resultMessages.push(
|
|
1929
|
+
resultMessages.push(chalk24.yellow(`Warnings: ${warnings}`));
|
|
1693
1930
|
}
|
|
1694
1931
|
if (errors > 0) {
|
|
1695
|
-
resultMessages.push(
|
|
1932
|
+
resultMessages.push(chalk24.red(` Errors: ${errors}`));
|
|
1696
1933
|
}
|
|
1697
1934
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1698
1935
|
`);
|
|
@@ -1700,8 +1937,8 @@ Gitlint Start [${process.cwd()}]
|
|
|
1700
1937
|
};
|
|
1701
1938
|
|
|
1702
1939
|
// src/actions/gitlint-fix.ts
|
|
1703
|
-
import { execSync as
|
|
1704
|
-
import
|
|
1940
|
+
import { execSync as execSync3 } from "child_process";
|
|
1941
|
+
import chalk25 from "chalk";
|
|
1705
1942
|
import ParseGitConfig2 from "parse-git-config";
|
|
1706
1943
|
var gitlintFix = () => {
|
|
1707
1944
|
console.log(`
|
|
@@ -1709,16 +1946,16 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1709
1946
|
`);
|
|
1710
1947
|
const gitConfig = ParseGitConfig2.sync();
|
|
1711
1948
|
if (gitConfig.core.ignorecase) {
|
|
1712
|
-
|
|
1713
|
-
console.warn(
|
|
1949
|
+
execSync3("git config core.ignorecase false", { stdio: "inherit" });
|
|
1950
|
+
console.warn(chalk25.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1714
1951
|
}
|
|
1715
1952
|
if (gitConfig.core.autocrlf !== false) {
|
|
1716
|
-
|
|
1717
|
-
console.warn(
|
|
1953
|
+
execSync3("git config core.autocrlf false", { stdio: "inherit" });
|
|
1954
|
+
console.warn(chalk25.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1718
1955
|
}
|
|
1719
1956
|
if (gitConfig.core.eol !== "lf") {
|
|
1720
|
-
|
|
1721
|
-
console.warn(
|
|
1957
|
+
execSync3("git config core.eol lf", { stdio: "inherit" });
|
|
1958
|
+
console.warn(chalk25.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1722
1959
|
}
|
|
1723
1960
|
return 1;
|
|
1724
1961
|
};
|
|
@@ -1729,7 +1966,7 @@ var knip = () => {
|
|
|
1729
1966
|
};
|
|
1730
1967
|
|
|
1731
1968
|
// src/actions/license.ts
|
|
1732
|
-
import
|
|
1969
|
+
import chalk26 from "chalk";
|
|
1733
1970
|
import { init } from "license-checker";
|
|
1734
1971
|
var license = async (pkg) => {
|
|
1735
1972
|
const workspaces = yarnWorkspaces();
|
|
@@ -1754,18 +1991,18 @@ var license = async (pkg) => {
|
|
|
1754
1991
|
"LGPL-3.0-or-later",
|
|
1755
1992
|
"Python-2.0"
|
|
1756
1993
|
]);
|
|
1757
|
-
console.log(
|
|
1994
|
+
console.log(chalk26.green("License Checker"));
|
|
1758
1995
|
return (await Promise.all(
|
|
1759
1996
|
workspaceList.map(({ location, name }) => {
|
|
1760
1997
|
return new Promise((resolve) => {
|
|
1761
1998
|
init({ production: true, start: location }, (error, packages) => {
|
|
1762
1999
|
if (error) {
|
|
1763
|
-
console.error(
|
|
1764
|
-
console.error(
|
|
2000
|
+
console.error(chalk26.red(`License Checker [${name}] Error`));
|
|
2001
|
+
console.error(chalk26.gray(error));
|
|
1765
2002
|
console.log("\n");
|
|
1766
2003
|
resolve(1);
|
|
1767
2004
|
} else {
|
|
1768
|
-
console.log(
|
|
2005
|
+
console.log(chalk26.green(`License Checker [${name}]`));
|
|
1769
2006
|
let count = 0;
|
|
1770
2007
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1771
2008
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1781,7 +2018,7 @@ var license = async (pkg) => {
|
|
|
1781
2018
|
}
|
|
1782
2019
|
if (!orLicenseFound) {
|
|
1783
2020
|
count++;
|
|
1784
|
-
console.warn(
|
|
2021
|
+
console.warn(chalk26.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1785
2022
|
}
|
|
1786
2023
|
}
|
|
1787
2024
|
}
|
|
@@ -1800,13 +2037,13 @@ var filename2 = ".npmignore";
|
|
|
1800
2037
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1801
2038
|
|
|
1802
2039
|
// src/actions/package/clean-outputs.ts
|
|
1803
|
-
import
|
|
1804
|
-
import
|
|
2040
|
+
import path8 from "path";
|
|
2041
|
+
import chalk27 from "chalk";
|
|
1805
2042
|
var packageCleanOutputs = () => {
|
|
1806
2043
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1807
2044
|
const pkgName = process.env.npm_package_name;
|
|
1808
|
-
const folders = [
|
|
1809
|
-
console.log(
|
|
2045
|
+
const folders = [path8.join(pkg, "dist"), path8.join(pkg, "build"), path8.join(pkg, "docs")];
|
|
2046
|
+
console.log(chalk27.green(`Cleaning Outputs [${pkgName}]`));
|
|
1810
2047
|
for (let folder of folders) {
|
|
1811
2048
|
deleteGlob(folder);
|
|
1812
2049
|
}
|
|
@@ -1814,13 +2051,13 @@ var packageCleanOutputs = () => {
|
|
|
1814
2051
|
};
|
|
1815
2052
|
|
|
1816
2053
|
// src/actions/package/clean-typescript.ts
|
|
1817
|
-
import
|
|
1818
|
-
import
|
|
2054
|
+
import path9 from "path";
|
|
2055
|
+
import chalk28 from "chalk";
|
|
1819
2056
|
var packageCleanTypescript = () => {
|
|
1820
2057
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1821
2058
|
const pkgName = process.env.npm_package_name;
|
|
1822
|
-
console.log(
|
|
1823
|
-
const files = [
|
|
2059
|
+
console.log(chalk28.green(`Cleaning Typescript [${pkgName}]`));
|
|
2060
|
+
const files = [path9.join(pkg, "*.tsbuildinfo"), path9.join(pkg, ".tsconfig.*"), path9.join(pkg, ".eslintcache")];
|
|
1824
2061
|
for (let file of files) {
|
|
1825
2062
|
deleteGlob(file);
|
|
1826
2063
|
}
|
|
@@ -1833,26 +2070,26 @@ var packageClean = async () => {
|
|
|
1833
2070
|
};
|
|
1834
2071
|
|
|
1835
2072
|
// src/actions/package/compile/compile.ts
|
|
1836
|
-
import
|
|
2073
|
+
import chalk33 from "chalk";
|
|
1837
2074
|
|
|
1838
2075
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1839
|
-
import
|
|
2076
|
+
import chalk32 from "chalk";
|
|
1840
2077
|
import { build as build2, defineConfig } from "tsup";
|
|
1841
2078
|
|
|
1842
2079
|
// src/actions/package/compile/inputs.ts
|
|
1843
|
-
import
|
|
2080
|
+
import chalk29 from "chalk";
|
|
1844
2081
|
import { glob as glob2 } from "glob";
|
|
1845
2082
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1846
2083
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1847
2084
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1848
2085
|
if (verbose) {
|
|
1849
|
-
console.log(
|
|
2086
|
+
console.log(chalk29.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1850
2087
|
}
|
|
1851
2088
|
return result;
|
|
1852
2089
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1853
2090
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1854
2091
|
if (verbose) {
|
|
1855
|
-
console.log(
|
|
2092
|
+
console.log(chalk29.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1856
2093
|
}
|
|
1857
2094
|
return result;
|
|
1858
2095
|
})];
|
|
@@ -1911,9 +2148,9 @@ function deepMergeObjects(objects) {
|
|
|
1911
2148
|
|
|
1912
2149
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1913
2150
|
import { cwd as cwd2 } from "process";
|
|
1914
|
-
import
|
|
2151
|
+
import chalk30 from "chalk";
|
|
1915
2152
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1916
|
-
import
|
|
2153
|
+
import ts3, {
|
|
1917
2154
|
DiagnosticCategory,
|
|
1918
2155
|
formatDiagnosticsWithColorAndContext,
|
|
1919
2156
|
getPreEmitDiagnostics,
|
|
@@ -1933,12 +2170,12 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
1933
2170
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
1934
2171
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1935
2172
|
if (verbose) {
|
|
1936
|
-
console.log(
|
|
2173
|
+
console.log(chalk30.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1937
2174
|
}
|
|
1938
|
-
const configFilePath =
|
|
2175
|
+
const configFilePath = ts3.findConfigFile(
|
|
1939
2176
|
"./",
|
|
1940
2177
|
// search path
|
|
1941
|
-
|
|
2178
|
+
ts3.sys.fileExists,
|
|
1942
2179
|
"tsconfig.json"
|
|
1943
2180
|
);
|
|
1944
2181
|
if (configFilePath === void 0) {
|
|
@@ -1956,10 +2193,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1956
2193
|
emitDeclarationOnly: true,
|
|
1957
2194
|
noEmit: false
|
|
1958
2195
|
};
|
|
1959
|
-
console.log(
|
|
2196
|
+
console.log(chalk30.cyan(`Validating Files: ${entries.length}`));
|
|
1960
2197
|
if (verbose) {
|
|
1961
2198
|
for (const entry of entries) {
|
|
1962
|
-
console.log(
|
|
2199
|
+
console.log(chalk30.grey(`Validating: ${entry}`));
|
|
1963
2200
|
}
|
|
1964
2201
|
}
|
|
1965
2202
|
try {
|
|
@@ -1988,29 +2225,29 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1988
2225
|
if (nonEmitPatterns.some((pattern) => fileName.includes(pattern))) {
|
|
1989
2226
|
return;
|
|
1990
2227
|
}
|
|
1991
|
-
|
|
2228
|
+
ts3.sys.writeFile(fileName, text, writeByteOrderMark);
|
|
1992
2229
|
});
|
|
1993
2230
|
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1994
2231
|
}
|
|
1995
2232
|
return 0;
|
|
1996
2233
|
} finally {
|
|
1997
2234
|
if (verbose) {
|
|
1998
|
-
console.log(
|
|
2235
|
+
console.log(chalk30.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1999
2236
|
}
|
|
2000
2237
|
}
|
|
2001
2238
|
};
|
|
2002
2239
|
|
|
2003
2240
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
2004
|
-
import
|
|
2241
|
+
import path10 from "path";
|
|
2005
2242
|
import { cwd as cwd3 } from "process";
|
|
2006
|
-
import
|
|
2243
|
+
import chalk31 from "chalk";
|
|
2007
2244
|
import { rollup } from "rollup";
|
|
2008
2245
|
import dts from "rollup-plugin-dts";
|
|
2009
2246
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
2010
2247
|
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
2011
2248
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
2012
2249
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
2013
|
-
const tsconfigPath =
|
|
2250
|
+
const tsconfigPath = path10.resolve(pkg, "tsconfig.json");
|
|
2014
2251
|
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
2015
2252
|
try {
|
|
2016
2253
|
const bundle = await rollup({
|
|
@@ -2028,8 +2265,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2028
2265
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
2029
2266
|
return;
|
|
2030
2267
|
}
|
|
2031
|
-
console.warn(
|
|
2032
|
-
console.warn(
|
|
2268
|
+
console.warn(chalk31.yellow(`[${warning.code}] ${warning.message}`));
|
|
2269
|
+
console.warn(chalk31.gray(inputPath));
|
|
2033
2270
|
warn(warning);
|
|
2034
2271
|
}
|
|
2035
2272
|
});
|
|
@@ -2039,8 +2276,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2039
2276
|
});
|
|
2040
2277
|
} catch (ex) {
|
|
2041
2278
|
const error = ex;
|
|
2042
|
-
console.warn(
|
|
2043
|
-
console.warn(
|
|
2279
|
+
console.warn(chalk31.red(error));
|
|
2280
|
+
console.warn(chalk31.gray(inputPath));
|
|
2044
2281
|
}
|
|
2045
2282
|
if (verbose) {
|
|
2046
2283
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -2048,7 +2285,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2048
2285
|
}
|
|
2049
2286
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
2050
2287
|
if (verbose) {
|
|
2051
|
-
console.log(
|
|
2288
|
+
console.log(chalk31.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2052
2289
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
2053
2290
|
}
|
|
2054
2291
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -2072,7 +2309,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
2072
2309
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
2073
2310
|
}));
|
|
2074
2311
|
if (verbose) {
|
|
2075
|
-
console.log(
|
|
2312
|
+
console.log(chalk31.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2076
2313
|
}
|
|
2077
2314
|
return 0;
|
|
2078
2315
|
};
|
|
@@ -2084,15 +2321,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2084
2321
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
2085
2322
|
}
|
|
2086
2323
|
if (entries.length === 0) {
|
|
2087
|
-
console.warn(
|
|
2324
|
+
console.warn(chalk32.yellow(`No entries found in ${srcDir} to compile`));
|
|
2088
2325
|
return 0;
|
|
2089
2326
|
}
|
|
2090
2327
|
if (verbose) {
|
|
2091
|
-
console.log(
|
|
2328
|
+
console.log(chalk32.gray(`buildDir [${buildDir}]`));
|
|
2092
2329
|
}
|
|
2093
2330
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
2094
2331
|
if (validationResult !== 0) {
|
|
2095
|
-
console.error(
|
|
2332
|
+
console.error(chalk32.red(`Compile:Validation had ${validationResult} errors`));
|
|
2096
2333
|
return validationResult;
|
|
2097
2334
|
}
|
|
2098
2335
|
const optionsParams = tsupOptions([{
|
|
@@ -2117,12 +2354,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2117
2354
|
})
|
|
2118
2355
|
)).flat();
|
|
2119
2356
|
if (verbose) {
|
|
2120
|
-
console.log(
|
|
2121
|
-
console.log(
|
|
2357
|
+
console.log(chalk32.cyan(`TSUP:build:start [${srcDir}]`));
|
|
2358
|
+
console.log(chalk32.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
2122
2359
|
}
|
|
2123
2360
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
2124
2361
|
if (verbose) {
|
|
2125
|
-
console.log(
|
|
2362
|
+
console.log(chalk32.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
2126
2363
|
}
|
|
2127
2364
|
if (bundleTypes) {
|
|
2128
2365
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -2233,14 +2470,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
2233
2470
|
// src/actions/package/compile/compile.ts
|
|
2234
2471
|
var packageCompile = async (inConfig = {}) => {
|
|
2235
2472
|
const pkg = process.env.INIT_CWD;
|
|
2236
|
-
console.log(
|
|
2473
|
+
console.log(chalk33.green(`Compiling ${pkg}`));
|
|
2237
2474
|
const config2 = await loadConfig(inConfig);
|
|
2238
2475
|
return await packageCompileTsup(config2);
|
|
2239
2476
|
};
|
|
2240
2477
|
|
|
2241
2478
|
// src/actions/package/copy-assets.ts
|
|
2242
|
-
import
|
|
2243
|
-
import
|
|
2479
|
+
import path11 from "path/posix";
|
|
2480
|
+
import chalk34 from "chalk";
|
|
2244
2481
|
import cpy2 from "cpy";
|
|
2245
2482
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
2246
2483
|
try {
|
|
@@ -2248,12 +2485,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
2248
2485
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
2249
2486
|
`../dist/${target}`,
|
|
2250
2487
|
{
|
|
2251
|
-
cwd:
|
|
2488
|
+
cwd: path11.join(location, "src"),
|
|
2252
2489
|
flat: false
|
|
2253
2490
|
}
|
|
2254
2491
|
);
|
|
2255
2492
|
if (values.length > 0) {
|
|
2256
|
-
console.log(
|
|
2493
|
+
console.log(chalk34.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
2257
2494
|
}
|
|
2258
2495
|
for (const value of values) {
|
|
2259
2496
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -2319,8 +2556,8 @@ var packageCycle = async () => {
|
|
|
2319
2556
|
|
|
2320
2557
|
// src/actions/package/gen-docs.ts
|
|
2321
2558
|
import { existsSync as existsSync7 } from "fs";
|
|
2322
|
-
import
|
|
2323
|
-
import
|
|
2559
|
+
import path12 from "path";
|
|
2560
|
+
import chalk35 from "chalk";
|
|
2324
2561
|
import {
|
|
2325
2562
|
Application,
|
|
2326
2563
|
ArgumentsReader,
|
|
@@ -2338,7 +2575,7 @@ var ExitCodes = {
|
|
|
2338
2575
|
};
|
|
2339
2576
|
var packageGenDocs = async () => {
|
|
2340
2577
|
const pkg = process.env.INIT_CWD;
|
|
2341
|
-
if (pkg !== void 0 && !existsSync7(
|
|
2578
|
+
if (pkg !== void 0 && !existsSync7(path12.join(pkg, "typedoc.json"))) {
|
|
2342
2579
|
return;
|
|
2343
2580
|
}
|
|
2344
2581
|
const app = await Application.bootstrap({
|
|
@@ -2424,16 +2661,16 @@ var runTypeDoc = async (app) => {
|
|
|
2424
2661
|
return ExitCodes.OutputError;
|
|
2425
2662
|
}
|
|
2426
2663
|
}
|
|
2427
|
-
console.log(
|
|
2664
|
+
console.log(chalk35.green(`${pkgName} - Ok`));
|
|
2428
2665
|
return ExitCodes.Ok;
|
|
2429
2666
|
};
|
|
2430
2667
|
|
|
2431
2668
|
// src/actions/package/lint.ts
|
|
2432
2669
|
import { readdirSync as readdirSync4 } from "fs";
|
|
2433
|
-
import
|
|
2670
|
+
import path13 from "path";
|
|
2434
2671
|
import { cwd as cwd4 } from "process";
|
|
2435
2672
|
import { pathToFileURL } from "url";
|
|
2436
|
-
import
|
|
2673
|
+
import chalk36 from "chalk";
|
|
2437
2674
|
import { ESLint } from "eslint";
|
|
2438
2675
|
import { findUp } from "find-up";
|
|
2439
2676
|
import picomatch from "picomatch";
|
|
@@ -2442,14 +2679,14 @@ var dumpMessages = (lintResults) => {
|
|
|
2442
2679
|
const severity = ["none", "warning", "error"];
|
|
2443
2680
|
for (const lintResult of lintResults) {
|
|
2444
2681
|
if (lintResult.messages.length > 0) {
|
|
2445
|
-
console.log(
|
|
2682
|
+
console.log(chalk36.gray(`
|
|
2446
2683
|
${lintResult.filePath}`));
|
|
2447
2684
|
for (const message of lintResult.messages) {
|
|
2448
2685
|
console.log(
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2686
|
+
chalk36.gray(` ${message.line}:${message.column}`),
|
|
2687
|
+
chalk36[colors[message.severity]](` ${severity[message.severity]}`),
|
|
2688
|
+
chalk36.white(` ${message.message}`),
|
|
2689
|
+
chalk36.gray(` ${message.ruleId}`)
|
|
2453
2690
|
);
|
|
2454
2691
|
}
|
|
2455
2692
|
}
|
|
@@ -2467,7 +2704,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
2467
2704
|
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
2468
2705
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2469
2706
|
return readdirSync4(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2470
|
-
const res =
|
|
2707
|
+
const res = path13.resolve(dir, dirent.name);
|
|
2471
2708
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2472
2709
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2473
2710
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2487,10 +2724,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2487
2724
|
cache
|
|
2488
2725
|
});
|
|
2489
2726
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
2490
|
-
console.log(
|
|
2727
|
+
console.log(chalk36.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2491
2728
|
if (verbose) {
|
|
2492
2729
|
for (const file of files) {
|
|
2493
|
-
console.log(
|
|
2730
|
+
console.log(chalk36.gray(` ${file}`));
|
|
2494
2731
|
}
|
|
2495
2732
|
}
|
|
2496
2733
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -2501,43 +2738,43 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2501
2738
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2502
2739
|
const lintTime = Date.now() - start;
|
|
2503
2740
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2504
|
-
console.log(
|
|
2741
|
+
console.log(chalk36.white(`Linted ${chalk36[filesCountColor](files.length)} files in ${chalk36[lintTimeColor](lintTime)}ms`));
|
|
2505
2742
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2506
2743
|
};
|
|
2507
2744
|
|
|
2508
2745
|
// src/actions/package/publint.ts
|
|
2509
|
-
import { promises as
|
|
2510
|
-
import
|
|
2746
|
+
import { promises as fs10 } from "fs";
|
|
2747
|
+
import chalk37 from "chalk";
|
|
2511
2748
|
import sortPackageJson from "sort-package-json";
|
|
2512
2749
|
var customPubLint = (pkg) => {
|
|
2513
2750
|
let errorCount = 0;
|
|
2514
2751
|
let warningCount = 0;
|
|
2515
2752
|
if (pkg.files === void 0) {
|
|
2516
|
-
console.warn(
|
|
2753
|
+
console.warn(chalk37.yellow('Publint [custom]: "files" field is missing'));
|
|
2517
2754
|
warningCount++;
|
|
2518
2755
|
}
|
|
2519
2756
|
if (pkg.main !== void 0) {
|
|
2520
|
-
console.warn(
|
|
2757
|
+
console.warn(chalk37.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
2521
2758
|
warningCount++;
|
|
2522
2759
|
}
|
|
2523
2760
|
if (pkg.sideEffects !== false) {
|
|
2524
|
-
console.warn(
|
|
2761
|
+
console.warn(chalk37.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
2525
2762
|
warningCount++;
|
|
2526
2763
|
}
|
|
2527
2764
|
if (pkg.resolutions !== void 0) {
|
|
2528
|
-
console.warn(
|
|
2529
|
-
console.warn(
|
|
2765
|
+
console.warn(chalk37.yellow('Publint [custom]: "resolutions" in use'));
|
|
2766
|
+
console.warn(chalk37.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
2530
2767
|
warningCount++;
|
|
2531
2768
|
}
|
|
2532
2769
|
return [errorCount, warningCount];
|
|
2533
2770
|
};
|
|
2534
2771
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2535
2772
|
const pkgDir = process.env.INIT_CWD;
|
|
2536
|
-
const sortedPkg = sortPackageJson(await
|
|
2537
|
-
await
|
|
2538
|
-
const pkg = JSON.parse(await
|
|
2539
|
-
console.log(
|
|
2540
|
-
console.log(
|
|
2773
|
+
const sortedPkg = sortPackageJson(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2774
|
+
await fs10.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2775
|
+
const pkg = JSON.parse(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2776
|
+
console.log(chalk37.green(`Publint: ${pkg.name}`));
|
|
2777
|
+
console.log(chalk37.gray(pkgDir));
|
|
2541
2778
|
const { publint: publint2 } = await import("publint");
|
|
2542
2779
|
const { messages } = await publint2({
|
|
2543
2780
|
level: "suggestion",
|
|
@@ -2548,22 +2785,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2548
2785
|
for (const message of messages) {
|
|
2549
2786
|
switch (message.type) {
|
|
2550
2787
|
case "error": {
|
|
2551
|
-
console.error(
|
|
2788
|
+
console.error(chalk37.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2552
2789
|
break;
|
|
2553
2790
|
}
|
|
2554
2791
|
case "warning": {
|
|
2555
|
-
console.warn(
|
|
2792
|
+
console.warn(chalk37.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2556
2793
|
break;
|
|
2557
2794
|
}
|
|
2558
2795
|
default: {
|
|
2559
|
-
console.log(
|
|
2796
|
+
console.log(chalk37.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2560
2797
|
break;
|
|
2561
2798
|
}
|
|
2562
2799
|
}
|
|
2563
2800
|
}
|
|
2564
2801
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
2565
2802
|
if (verbose) {
|
|
2566
|
-
console.log(
|
|
2803
|
+
console.log(chalk37.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
2567
2804
|
}
|
|
2568
2805
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
2569
2806
|
};
|
|
@@ -2590,6 +2827,21 @@ var publish = () => {
|
|
|
2590
2827
|
return runSteps("Publish", [["npm", ["publish", "--workspaces"]]]);
|
|
2591
2828
|
};
|
|
2592
2829
|
|
|
2830
|
+
// src/actions/readme-gen.ts
|
|
2831
|
+
async function readmeGen({
|
|
2832
|
+
pkg,
|
|
2833
|
+
templatePath,
|
|
2834
|
+
typedoc,
|
|
2835
|
+
verbose
|
|
2836
|
+
}) {
|
|
2837
|
+
return await generateReadmeFiles({
|
|
2838
|
+
pkg,
|
|
2839
|
+
templatePath,
|
|
2840
|
+
typedoc,
|
|
2841
|
+
verbose
|
|
2842
|
+
});
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2593
2845
|
// src/actions/rebuild.ts
|
|
2594
2846
|
var rebuild = ({ target }) => {
|
|
2595
2847
|
return runSteps("Rebuild", [
|
|
@@ -2599,7 +2851,7 @@ var rebuild = ({ target }) => {
|
|
|
2599
2851
|
};
|
|
2600
2852
|
|
|
2601
2853
|
// src/actions/recompile.ts
|
|
2602
|
-
import
|
|
2854
|
+
import chalk38 from "chalk";
|
|
2603
2855
|
var recompile = async ({
|
|
2604
2856
|
verbose,
|
|
2605
2857
|
target,
|
|
@@ -2635,7 +2887,7 @@ var recompileAll = async ({
|
|
|
2635
2887
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2636
2888
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2637
2889
|
if (jobs) {
|
|
2638
|
-
console.log(
|
|
2890
|
+
console.log(chalk38.blue(`Jobs set to [${jobs}]`));
|
|
2639
2891
|
}
|
|
2640
2892
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2641
2893
|
[
|
|
@@ -2666,7 +2918,7 @@ var recompileAll = async ({
|
|
|
2666
2918
|
]
|
|
2667
2919
|
]);
|
|
2668
2920
|
console.log(
|
|
2669
|
-
`${
|
|
2921
|
+
`${chalk38.gray("Recompiled in")} [${chalk38.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk38.gray("seconds")}`
|
|
2670
2922
|
);
|
|
2671
2923
|
return result;
|
|
2672
2924
|
};
|
|
@@ -2697,13 +2949,13 @@ var reinstall = () => {
|
|
|
2697
2949
|
};
|
|
2698
2950
|
|
|
2699
2951
|
// src/actions/relint.ts
|
|
2700
|
-
import
|
|
2952
|
+
import chalk39 from "chalk";
|
|
2701
2953
|
var relintPackage = ({
|
|
2702
2954
|
pkg,
|
|
2703
2955
|
fix: fix2,
|
|
2704
2956
|
verbose
|
|
2705
2957
|
}) => {
|
|
2706
|
-
console.log(
|
|
2958
|
+
console.log(chalk39.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2707
2959
|
const start = Date.now();
|
|
2708
2960
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2709
2961
|
["yarn", [
|
|
@@ -2713,7 +2965,7 @@ var relintPackage = ({
|
|
|
2713
2965
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2714
2966
|
]]
|
|
2715
2967
|
]);
|
|
2716
|
-
console.log(
|
|
2968
|
+
console.log(chalk39.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk39.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk39.gray("seconds")}`));
|
|
2717
2969
|
return result;
|
|
2718
2970
|
};
|
|
2719
2971
|
var relint = ({
|
|
@@ -2733,13 +2985,13 @@ var relint = ({
|
|
|
2733
2985
|
});
|
|
2734
2986
|
};
|
|
2735
2987
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2736
|
-
console.log(
|
|
2988
|
+
console.log(chalk39.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2737
2989
|
const start = Date.now();
|
|
2738
2990
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2739
2991
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2740
2992
|
["yarn", ["eslint", ...fixOptions]]
|
|
2741
2993
|
]);
|
|
2742
|
-
console.log(
|
|
2994
|
+
console.log(chalk39.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk39.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk39.gray("seconds")}`));
|
|
2743
2995
|
return result;
|
|
2744
2996
|
};
|
|
2745
2997
|
|
|
@@ -2757,10 +3009,10 @@ var sonar = () => {
|
|
|
2757
3009
|
};
|
|
2758
3010
|
|
|
2759
3011
|
// src/actions/statics.ts
|
|
2760
|
-
import
|
|
3012
|
+
import chalk40 from "chalk";
|
|
2761
3013
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2762
3014
|
var statics = () => {
|
|
2763
|
-
console.log(
|
|
3015
|
+
console.log(chalk40.green("Check Required Static Dependencies"));
|
|
2764
3016
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2765
3017
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2766
3018
|
};
|
|
@@ -2809,15 +3061,15 @@ var yarn3Only = () => {
|
|
|
2809
3061
|
};
|
|
2810
3062
|
|
|
2811
3063
|
// src/loadPackageConfig.ts
|
|
2812
|
-
import { readFile } from "fs/promises";
|
|
3064
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
2813
3065
|
var loadPackageConfig = async () => {
|
|
2814
3066
|
const pkg = process.env.INIT_CWD;
|
|
2815
|
-
const pkgConfig = await
|
|
3067
|
+
const pkgConfig = await readFile2(`${pkg}/package.json`, { encoding: "utf8" });
|
|
2816
3068
|
return JSON.parse(pkgConfig);
|
|
2817
3069
|
};
|
|
2818
3070
|
|
|
2819
3071
|
// src/xy/xy.ts
|
|
2820
|
-
import
|
|
3072
|
+
import chalk42 from "chalk";
|
|
2821
3073
|
|
|
2822
3074
|
// src/xy/xyBuildCommands.ts
|
|
2823
3075
|
var xyBuildCommands = (args) => {
|
|
@@ -3015,6 +3267,29 @@ var xyCommonCommands = (args) => {
|
|
|
3015
3267
|
if (argv.verbose) console.log("NpmIgnore Gen");
|
|
3016
3268
|
process.exitCode = npmignoreGen();
|
|
3017
3269
|
}
|
|
3270
|
+
).command(
|
|
3271
|
+
"readme-gen [package]",
|
|
3272
|
+
"Readme Gen - Generate README.md files from template",
|
|
3273
|
+
(yargs2) => {
|
|
3274
|
+
return packagePositionalParam(yargs2).option("template", {
|
|
3275
|
+
alias: "t",
|
|
3276
|
+
description: "Path to README.template.md",
|
|
3277
|
+
type: "string"
|
|
3278
|
+
}).option("typedoc", {
|
|
3279
|
+
default: false,
|
|
3280
|
+
description: "Generate TypeDoc reference sections",
|
|
3281
|
+
type: "boolean"
|
|
3282
|
+
});
|
|
3283
|
+
},
|
|
3284
|
+
async (argv) => {
|
|
3285
|
+
if (argv.verbose) console.log("Readme Gen");
|
|
3286
|
+
process.exitCode = await readmeGen({
|
|
3287
|
+
pkg: argv.package,
|
|
3288
|
+
templatePath: argv.template,
|
|
3289
|
+
typedoc: argv.typedoc,
|
|
3290
|
+
verbose: !!argv.verbose
|
|
3291
|
+
});
|
|
3292
|
+
}
|
|
3018
3293
|
).command(
|
|
3019
3294
|
"retest",
|
|
3020
3295
|
"Re-Test - Run Jest Tests with cleaned cache",
|
|
@@ -3194,7 +3469,7 @@ var xyInstallCommands = (args) => {
|
|
|
3194
3469
|
};
|
|
3195
3470
|
|
|
3196
3471
|
// src/xy/xyLintCommands.ts
|
|
3197
|
-
import
|
|
3472
|
+
import chalk41 from "chalk";
|
|
3198
3473
|
var xyLintCommands = (args) => {
|
|
3199
3474
|
return args.command(
|
|
3200
3475
|
"cycle [package]",
|
|
@@ -3206,7 +3481,7 @@ var xyLintCommands = (args) => {
|
|
|
3206
3481
|
const start = Date.now();
|
|
3207
3482
|
if (argv.verbose) console.log("Cycle");
|
|
3208
3483
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
3209
|
-
console.log(
|
|
3484
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3210
3485
|
}
|
|
3211
3486
|
).command(
|
|
3212
3487
|
"lint [package]",
|
|
@@ -3236,7 +3511,7 @@ var xyLintCommands = (args) => {
|
|
|
3236
3511
|
cache: argv.cache,
|
|
3237
3512
|
verbose: !!argv.verbose
|
|
3238
3513
|
});
|
|
3239
|
-
console.log(
|
|
3514
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3240
3515
|
}
|
|
3241
3516
|
).command(
|
|
3242
3517
|
"deplint [package]",
|
|
@@ -3257,19 +3532,25 @@ var xyLintCommands = (args) => {
|
|
|
3257
3532
|
default: false,
|
|
3258
3533
|
description: "Check peerDependencies",
|
|
3259
3534
|
type: "boolean"
|
|
3535
|
+
}).option("exclude", {
|
|
3536
|
+
alias: "e",
|
|
3537
|
+
description: "Package names to exclude from unused checks (comma-separated or repeated)",
|
|
3538
|
+
type: "array"
|
|
3260
3539
|
});
|
|
3261
3540
|
},
|
|
3262
|
-
(argv) => {
|
|
3541
|
+
async (argv) => {
|
|
3263
3542
|
if (argv.verbose) console.log("Deplint");
|
|
3264
3543
|
const start = Date.now();
|
|
3265
|
-
|
|
3544
|
+
const cliExclude = argv.exclude?.flatMap((v) => String(v).split(",")).map((v) => v.trim()).filter(Boolean);
|
|
3545
|
+
process.exitCode = await deplint({
|
|
3546
|
+
cliExclude,
|
|
3266
3547
|
pkg: argv.package,
|
|
3267
3548
|
deps: !!argv.deps,
|
|
3268
3549
|
devDeps: !!argv.devDeps,
|
|
3269
3550
|
peerDeps: !!argv.peerDeps,
|
|
3270
3551
|
verbose: !!argv.verbose
|
|
3271
3552
|
});
|
|
3272
|
-
console.log(
|
|
3553
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3273
3554
|
}
|
|
3274
3555
|
).command(
|
|
3275
3556
|
"fix [package]",
|
|
@@ -3281,7 +3562,7 @@ var xyLintCommands = (args) => {
|
|
|
3281
3562
|
const start = Date.now();
|
|
3282
3563
|
if (argv.verbose) console.log("Fix");
|
|
3283
3564
|
process.exitCode = fix();
|
|
3284
|
-
console.log(
|
|
3565
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3285
3566
|
}
|
|
3286
3567
|
).command(
|
|
3287
3568
|
"relint [package]",
|
|
@@ -3293,7 +3574,7 @@ var xyLintCommands = (args) => {
|
|
|
3293
3574
|
if (argv.verbose) console.log("Relinting");
|
|
3294
3575
|
const start = Date.now();
|
|
3295
3576
|
process.exitCode = relint();
|
|
3296
|
-
console.log(
|
|
3577
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3297
3578
|
}
|
|
3298
3579
|
).command(
|
|
3299
3580
|
"publint [package]",
|
|
@@ -3305,7 +3586,7 @@ var xyLintCommands = (args) => {
|
|
|
3305
3586
|
if (argv.verbose) console.log("Publint");
|
|
3306
3587
|
const start = Date.now();
|
|
3307
3588
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
3308
|
-
console.log(
|
|
3589
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3309
3590
|
}
|
|
3310
3591
|
).command(
|
|
3311
3592
|
"knip",
|
|
@@ -3317,7 +3598,7 @@ var xyLintCommands = (args) => {
|
|
|
3317
3598
|
if (argv.verbose) console.log("Knip");
|
|
3318
3599
|
const start = Date.now();
|
|
3319
3600
|
process.exitCode = knip();
|
|
3320
|
-
console.log(
|
|
3601
|
+
console.log(chalk41.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
3321
3602
|
}
|
|
3322
3603
|
).command(
|
|
3323
3604
|
"sonar",
|
|
@@ -3329,7 +3610,7 @@ var xyLintCommands = (args) => {
|
|
|
3329
3610
|
const start = Date.now();
|
|
3330
3611
|
if (argv.verbose) console.log("Sonar Check");
|
|
3331
3612
|
process.exitCode = sonar();
|
|
3332
|
-
console.log(
|
|
3613
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3333
3614
|
}
|
|
3334
3615
|
);
|
|
3335
3616
|
};
|
|
@@ -3365,8 +3646,8 @@ var xyParseOptions = () => {
|
|
|
3365
3646
|
var xy = async () => {
|
|
3366
3647
|
const options = xyParseOptions();
|
|
3367
3648
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
3368
|
-
console.error(
|
|
3369
|
-
console.log(
|
|
3649
|
+
console.error(chalk42.yellow(`Command not found [${chalk42.magenta(process.argv[2])}]`));
|
|
3650
|
+
console.log(chalk42.gray("Try 'yarn xy --help' for list of commands"));
|
|
3370
3651
|
}).version().help().argv;
|
|
3371
3652
|
};
|
|
3372
3653
|
export {
|
|
@@ -3413,6 +3694,7 @@ export {
|
|
|
3413
3694
|
genDocsAll,
|
|
3414
3695
|
genDocsPackage,
|
|
3415
3696
|
generateIgnoreFiles,
|
|
3697
|
+
generateReadmeFiles,
|
|
3416
3698
|
gitignoreGen,
|
|
3417
3699
|
gitlint,
|
|
3418
3700
|
gitlintFix,
|
|
@@ -3448,6 +3730,7 @@ export {
|
|
|
3448
3730
|
publish,
|
|
3449
3731
|
readLines,
|
|
3450
3732
|
readNonEmptyLines,
|
|
3733
|
+
readmeGen,
|
|
3451
3734
|
rebuild,
|
|
3452
3735
|
recompile,
|
|
3453
3736
|
recompileAll,
|