@xylabs/ts-scripts-yarn3 7.4.11 → 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/index.mjs +294 -148
- 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 +275 -107
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.mjs +335 -165
- 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 +275 -107
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +275 -107
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +210 -42
- package/dist/xy/xyCommonCommands.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
|
}
|
|
@@ -411,15 +541,15 @@ var parsedPackageJSON = (path14) => {
|
|
|
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";
|
|
@@ -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,14 +1268,14 @@ 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,
|
|
@@ -1157,22 +1287,22 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
1157
1287
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1158
1288
|
unusedDependencies++;
|
|
1159
1289
|
if (externalAllImports.includes(dep)) {
|
|
1160
|
-
console.log(`[${
|
|
1290
|
+
console.log(`[${chalk18.blue(name)}] dependency should be devDependency in package.json: ${chalk18.red(dep)}`);
|
|
1161
1291
|
} else {
|
|
1162
|
-
console.log(`[${
|
|
1292
|
+
console.log(`[${chalk18.blue(name)}] Unused dependency in package.json: ${chalk18.red(dep)}`);
|
|
1163
1293
|
}
|
|
1164
1294
|
}
|
|
1165
1295
|
}
|
|
1166
1296
|
if (unusedDependencies > 0) {
|
|
1167
1297
|
const packageLocation = `${location}/package.json`;
|
|
1168
|
-
console.log(` ${
|
|
1298
|
+
console.log(` ${chalk18.yellow(packageLocation)}
|
|
1169
1299
|
`);
|
|
1170
1300
|
}
|
|
1171
1301
|
return unusedDependencies;
|
|
1172
1302
|
}
|
|
1173
1303
|
|
|
1174
1304
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1175
|
-
import
|
|
1305
|
+
import chalk19 from "chalk";
|
|
1176
1306
|
|
|
1177
1307
|
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1178
1308
|
import fs8 from "fs";
|
|
@@ -1456,19 +1586,19 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1456
1586
|
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1457
1587
|
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
|
|
1458
1588
|
unusedDevDependencies++;
|
|
1459
|
-
console.log(`[${
|
|
1589
|
+
console.log(`[${chalk19.blue(name)}] Unused devDependency in package.json: ${chalk19.red(dep)}`);
|
|
1460
1590
|
}
|
|
1461
1591
|
}
|
|
1462
1592
|
if (unusedDevDependencies > 0) {
|
|
1463
1593
|
const packageLocation = `${location}/package.json`;
|
|
1464
|
-
console.log(` ${
|
|
1594
|
+
console.log(` ${chalk19.yellow(packageLocation)}
|
|
1465
1595
|
`);
|
|
1466
1596
|
}
|
|
1467
1597
|
return unusedDevDependencies;
|
|
1468
1598
|
}
|
|
1469
1599
|
|
|
1470
1600
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1471
|
-
import
|
|
1601
|
+
import chalk20 from "chalk";
|
|
1472
1602
|
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
|
|
1473
1603
|
let unusedDependencies = 0;
|
|
1474
1604
|
for (const dep of peerDependencies) {
|
|
@@ -1476,15 +1606,15 @@ function getUnusedPeerDependencies({ name, location }, { peerDependencies, depen
|
|
|
1476
1606
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1477
1607
|
unusedDependencies++;
|
|
1478
1608
|
if (dependencies.includes(dep)) {
|
|
1479
|
-
console.log(`[${
|
|
1609
|
+
console.log(`[${chalk20.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk20.red(dep)}`);
|
|
1480
1610
|
} else {
|
|
1481
|
-
console.log(`[${
|
|
1611
|
+
console.log(`[${chalk20.blue(name)}] Unused peerDependency in package.json: ${chalk20.red(dep)}`);
|
|
1482
1612
|
}
|
|
1483
1613
|
}
|
|
1484
1614
|
}
|
|
1485
1615
|
if (unusedDependencies > 0) {
|
|
1486
1616
|
const packageLocation = `${location}/package.json`;
|
|
1487
|
-
console.log(` ${
|
|
1617
|
+
console.log(` ${chalk20.yellow(packageLocation)}
|
|
1488
1618
|
`);
|
|
1489
1619
|
}
|
|
1490
1620
|
return unusedDependencies;
|
|
@@ -1579,9 +1709,9 @@ var deplint = async ({
|
|
|
1579
1709
|
});
|
|
1580
1710
|
}
|
|
1581
1711
|
if (totalErrors > 0) {
|
|
1582
|
-
console.warn(`Deplint: Found ${
|
|
1712
|
+
console.warn(`Deplint: Found ${chalk21.red(totalErrors)} dependency problems. ${chalk21.red("\u2716")}`);
|
|
1583
1713
|
} else {
|
|
1584
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1714
|
+
console.info(`Deplint: Found no dependency problems. ${chalk21.green("\u2714")}`);
|
|
1585
1715
|
}
|
|
1586
1716
|
return 0;
|
|
1587
1717
|
};
|
|
@@ -1683,22 +1813,22 @@ var deployNext = () => {
|
|
|
1683
1813
|
};
|
|
1684
1814
|
|
|
1685
1815
|
// src/actions/dupdeps.ts
|
|
1686
|
-
import
|
|
1816
|
+
import chalk22 from "chalk";
|
|
1687
1817
|
var dupdeps = () => {
|
|
1688
|
-
console.log(
|
|
1818
|
+
console.log(chalk22.green("Checking all Dependencies for Duplicates"));
|
|
1689
1819
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1690
1820
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1691
1821
|
return detectDuplicateDependencies(dependencies);
|
|
1692
1822
|
};
|
|
1693
1823
|
|
|
1694
1824
|
// src/actions/lint.ts
|
|
1695
|
-
import
|
|
1825
|
+
import chalk23 from "chalk";
|
|
1696
1826
|
var lintPackage = ({
|
|
1697
1827
|
pkg,
|
|
1698
1828
|
fix: fix2,
|
|
1699
1829
|
verbose
|
|
1700
1830
|
}) => {
|
|
1701
|
-
console.log(
|
|
1831
|
+
console.log(chalk23.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1702
1832
|
const start = Date.now();
|
|
1703
1833
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1704
1834
|
["yarn", [
|
|
@@ -1708,7 +1838,7 @@ var lintPackage = ({
|
|
|
1708
1838
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1709
1839
|
]]
|
|
1710
1840
|
]);
|
|
1711
|
-
console.log(
|
|
1841
|
+
console.log(chalk23.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk23.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk23.gray("seconds")}`));
|
|
1712
1842
|
return result;
|
|
1713
1843
|
};
|
|
1714
1844
|
var lint = ({
|
|
@@ -1728,13 +1858,13 @@ var lint = ({
|
|
|
1728
1858
|
});
|
|
1729
1859
|
};
|
|
1730
1860
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1731
|
-
console.log(
|
|
1861
|
+
console.log(chalk23.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1732
1862
|
const start = Date.now();
|
|
1733
1863
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1734
1864
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1735
1865
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1736
1866
|
]);
|
|
1737
|
-
console.log(
|
|
1867
|
+
console.log(chalk23.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk23.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk23.gray("seconds")}`));
|
|
1738
1868
|
return result;
|
|
1739
1869
|
};
|
|
1740
1870
|
|
|
@@ -1762,7 +1892,7 @@ var filename = ".gitignore";
|
|
|
1762
1892
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1763
1893
|
|
|
1764
1894
|
// src/actions/gitlint.ts
|
|
1765
|
-
import
|
|
1895
|
+
import chalk24 from "chalk";
|
|
1766
1896
|
import ParseGitConfig from "parse-git-config";
|
|
1767
1897
|
var gitlint = () => {
|
|
1768
1898
|
console.log(`
|
|
@@ -1773,7 +1903,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1773
1903
|
const errors = 0;
|
|
1774
1904
|
const gitConfig = ParseGitConfig.sync();
|
|
1775
1905
|
const warn = (message) => {
|
|
1776
|
-
console.warn(
|
|
1906
|
+
console.warn(chalk24.yellow(`Warning: ${message}`));
|
|
1777
1907
|
warnings++;
|
|
1778
1908
|
};
|
|
1779
1909
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1793,13 +1923,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1793
1923
|
}
|
|
1794
1924
|
const resultMessages = [];
|
|
1795
1925
|
if (valid > 0) {
|
|
1796
|
-
resultMessages.push(
|
|
1926
|
+
resultMessages.push(chalk24.green(`Passed: ${valid}`));
|
|
1797
1927
|
}
|
|
1798
1928
|
if (warnings > 0) {
|
|
1799
|
-
resultMessages.push(
|
|
1929
|
+
resultMessages.push(chalk24.yellow(`Warnings: ${warnings}`));
|
|
1800
1930
|
}
|
|
1801
1931
|
if (errors > 0) {
|
|
1802
|
-
resultMessages.push(
|
|
1932
|
+
resultMessages.push(chalk24.red(` Errors: ${errors}`));
|
|
1803
1933
|
}
|
|
1804
1934
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1805
1935
|
`);
|
|
@@ -1807,8 +1937,8 @@ Gitlint Start [${process.cwd()}]
|
|
|
1807
1937
|
};
|
|
1808
1938
|
|
|
1809
1939
|
// src/actions/gitlint-fix.ts
|
|
1810
|
-
import { execSync as
|
|
1811
|
-
import
|
|
1940
|
+
import { execSync as execSync3 } from "child_process";
|
|
1941
|
+
import chalk25 from "chalk";
|
|
1812
1942
|
import ParseGitConfig2 from "parse-git-config";
|
|
1813
1943
|
var gitlintFix = () => {
|
|
1814
1944
|
console.log(`
|
|
@@ -1816,16 +1946,16 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1816
1946
|
`);
|
|
1817
1947
|
const gitConfig = ParseGitConfig2.sync();
|
|
1818
1948
|
if (gitConfig.core.ignorecase) {
|
|
1819
|
-
|
|
1820
|
-
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"));
|
|
1821
1951
|
}
|
|
1822
1952
|
if (gitConfig.core.autocrlf !== false) {
|
|
1823
|
-
|
|
1824
|
-
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"));
|
|
1825
1955
|
}
|
|
1826
1956
|
if (gitConfig.core.eol !== "lf") {
|
|
1827
|
-
|
|
1828
|
-
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'));
|
|
1829
1959
|
}
|
|
1830
1960
|
return 1;
|
|
1831
1961
|
};
|
|
@@ -1836,7 +1966,7 @@ var knip = () => {
|
|
|
1836
1966
|
};
|
|
1837
1967
|
|
|
1838
1968
|
// src/actions/license.ts
|
|
1839
|
-
import
|
|
1969
|
+
import chalk26 from "chalk";
|
|
1840
1970
|
import { init } from "license-checker";
|
|
1841
1971
|
var license = async (pkg) => {
|
|
1842
1972
|
const workspaces = yarnWorkspaces();
|
|
@@ -1861,18 +1991,18 @@ var license = async (pkg) => {
|
|
|
1861
1991
|
"LGPL-3.0-or-later",
|
|
1862
1992
|
"Python-2.0"
|
|
1863
1993
|
]);
|
|
1864
|
-
console.log(
|
|
1994
|
+
console.log(chalk26.green("License Checker"));
|
|
1865
1995
|
return (await Promise.all(
|
|
1866
1996
|
workspaceList.map(({ location, name }) => {
|
|
1867
1997
|
return new Promise((resolve) => {
|
|
1868
1998
|
init({ production: true, start: location }, (error, packages) => {
|
|
1869
1999
|
if (error) {
|
|
1870
|
-
console.error(
|
|
1871
|
-
console.error(
|
|
2000
|
+
console.error(chalk26.red(`License Checker [${name}] Error`));
|
|
2001
|
+
console.error(chalk26.gray(error));
|
|
1872
2002
|
console.log("\n");
|
|
1873
2003
|
resolve(1);
|
|
1874
2004
|
} else {
|
|
1875
|
-
console.log(
|
|
2005
|
+
console.log(chalk26.green(`License Checker [${name}]`));
|
|
1876
2006
|
let count = 0;
|
|
1877
2007
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1878
2008
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1888,7 +2018,7 @@ var license = async (pkg) => {
|
|
|
1888
2018
|
}
|
|
1889
2019
|
if (!orLicenseFound) {
|
|
1890
2020
|
count++;
|
|
1891
|
-
console.warn(
|
|
2021
|
+
console.warn(chalk26.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1892
2022
|
}
|
|
1893
2023
|
}
|
|
1894
2024
|
}
|
|
@@ -1908,12 +2038,12 @@ var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
|
1908
2038
|
|
|
1909
2039
|
// src/actions/package/clean-outputs.ts
|
|
1910
2040
|
import path8 from "path";
|
|
1911
|
-
import
|
|
2041
|
+
import chalk27 from "chalk";
|
|
1912
2042
|
var packageCleanOutputs = () => {
|
|
1913
2043
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1914
2044
|
const pkgName = process.env.npm_package_name;
|
|
1915
2045
|
const folders = [path8.join(pkg, "dist"), path8.join(pkg, "build"), path8.join(pkg, "docs")];
|
|
1916
|
-
console.log(
|
|
2046
|
+
console.log(chalk27.green(`Cleaning Outputs [${pkgName}]`));
|
|
1917
2047
|
for (let folder of folders) {
|
|
1918
2048
|
deleteGlob(folder);
|
|
1919
2049
|
}
|
|
@@ -1922,11 +2052,11 @@ var packageCleanOutputs = () => {
|
|
|
1922
2052
|
|
|
1923
2053
|
// src/actions/package/clean-typescript.ts
|
|
1924
2054
|
import path9 from "path";
|
|
1925
|
-
import
|
|
2055
|
+
import chalk28 from "chalk";
|
|
1926
2056
|
var packageCleanTypescript = () => {
|
|
1927
2057
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1928
2058
|
const pkgName = process.env.npm_package_name;
|
|
1929
|
-
console.log(
|
|
2059
|
+
console.log(chalk28.green(`Cleaning Typescript [${pkgName}]`));
|
|
1930
2060
|
const files = [path9.join(pkg, "*.tsbuildinfo"), path9.join(pkg, ".tsconfig.*"), path9.join(pkg, ".eslintcache")];
|
|
1931
2061
|
for (let file of files) {
|
|
1932
2062
|
deleteGlob(file);
|
|
@@ -1940,26 +2070,26 @@ var packageClean = async () => {
|
|
|
1940
2070
|
};
|
|
1941
2071
|
|
|
1942
2072
|
// src/actions/package/compile/compile.ts
|
|
1943
|
-
import
|
|
2073
|
+
import chalk33 from "chalk";
|
|
1944
2074
|
|
|
1945
2075
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1946
|
-
import
|
|
2076
|
+
import chalk32 from "chalk";
|
|
1947
2077
|
import { build as build2, defineConfig } from "tsup";
|
|
1948
2078
|
|
|
1949
2079
|
// src/actions/package/compile/inputs.ts
|
|
1950
|
-
import
|
|
2080
|
+
import chalk29 from "chalk";
|
|
1951
2081
|
import { glob as glob2 } from "glob";
|
|
1952
2082
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1953
2083
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1954
2084
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1955
2085
|
if (verbose) {
|
|
1956
|
-
console.log(
|
|
2086
|
+
console.log(chalk29.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1957
2087
|
}
|
|
1958
2088
|
return result;
|
|
1959
2089
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1960
2090
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1961
2091
|
if (verbose) {
|
|
1962
|
-
console.log(
|
|
2092
|
+
console.log(chalk29.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1963
2093
|
}
|
|
1964
2094
|
return result;
|
|
1965
2095
|
})];
|
|
@@ -2018,7 +2148,7 @@ function deepMergeObjects(objects) {
|
|
|
2018
2148
|
|
|
2019
2149
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
2020
2150
|
import { cwd as cwd2 } from "process";
|
|
2021
|
-
import
|
|
2151
|
+
import chalk30 from "chalk";
|
|
2022
2152
|
import { createProgramFromConfig } from "tsc-prog";
|
|
2023
2153
|
import ts3, {
|
|
2024
2154
|
DiagnosticCategory,
|
|
@@ -2040,7 +2170,7 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
2040
2170
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
2041
2171
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
2042
2172
|
if (verbose) {
|
|
2043
|
-
console.log(
|
|
2173
|
+
console.log(chalk30.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2044
2174
|
}
|
|
2045
2175
|
const configFilePath = ts3.findConfigFile(
|
|
2046
2176
|
"./",
|
|
@@ -2063,10 +2193,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
2063
2193
|
emitDeclarationOnly: true,
|
|
2064
2194
|
noEmit: false
|
|
2065
2195
|
};
|
|
2066
|
-
console.log(
|
|
2196
|
+
console.log(chalk30.cyan(`Validating Files: ${entries.length}`));
|
|
2067
2197
|
if (verbose) {
|
|
2068
2198
|
for (const entry of entries) {
|
|
2069
|
-
console.log(
|
|
2199
|
+
console.log(chalk30.grey(`Validating: ${entry}`));
|
|
2070
2200
|
}
|
|
2071
2201
|
}
|
|
2072
2202
|
try {
|
|
@@ -2102,7 +2232,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
2102
2232
|
return 0;
|
|
2103
2233
|
} finally {
|
|
2104
2234
|
if (verbose) {
|
|
2105
|
-
console.log(
|
|
2235
|
+
console.log(chalk30.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2106
2236
|
}
|
|
2107
2237
|
}
|
|
2108
2238
|
};
|
|
@@ -2110,7 +2240,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
2110
2240
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
2111
2241
|
import path10 from "path";
|
|
2112
2242
|
import { cwd as cwd3 } from "process";
|
|
2113
|
-
import
|
|
2243
|
+
import chalk31 from "chalk";
|
|
2114
2244
|
import { rollup } from "rollup";
|
|
2115
2245
|
import dts from "rollup-plugin-dts";
|
|
2116
2246
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
@@ -2135,8 +2265,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2135
2265
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
2136
2266
|
return;
|
|
2137
2267
|
}
|
|
2138
|
-
console.warn(
|
|
2139
|
-
console.warn(
|
|
2268
|
+
console.warn(chalk31.yellow(`[${warning.code}] ${warning.message}`));
|
|
2269
|
+
console.warn(chalk31.gray(inputPath));
|
|
2140
2270
|
warn(warning);
|
|
2141
2271
|
}
|
|
2142
2272
|
});
|
|
@@ -2146,8 +2276,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2146
2276
|
});
|
|
2147
2277
|
} catch (ex) {
|
|
2148
2278
|
const error = ex;
|
|
2149
|
-
console.warn(
|
|
2150
|
-
console.warn(
|
|
2279
|
+
console.warn(chalk31.red(error));
|
|
2280
|
+
console.warn(chalk31.gray(inputPath));
|
|
2151
2281
|
}
|
|
2152
2282
|
if (verbose) {
|
|
2153
2283
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -2155,7 +2285,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
2155
2285
|
}
|
|
2156
2286
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
2157
2287
|
if (verbose) {
|
|
2158
|
-
console.log(
|
|
2288
|
+
console.log(chalk31.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2159
2289
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
2160
2290
|
}
|
|
2161
2291
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -2179,7 +2309,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
2179
2309
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
2180
2310
|
}));
|
|
2181
2311
|
if (verbose) {
|
|
2182
|
-
console.log(
|
|
2312
|
+
console.log(chalk31.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2183
2313
|
}
|
|
2184
2314
|
return 0;
|
|
2185
2315
|
};
|
|
@@ -2191,15 +2321,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2191
2321
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
2192
2322
|
}
|
|
2193
2323
|
if (entries.length === 0) {
|
|
2194
|
-
console.warn(
|
|
2324
|
+
console.warn(chalk32.yellow(`No entries found in ${srcDir} to compile`));
|
|
2195
2325
|
return 0;
|
|
2196
2326
|
}
|
|
2197
2327
|
if (verbose) {
|
|
2198
|
-
console.log(
|
|
2328
|
+
console.log(chalk32.gray(`buildDir [${buildDir}]`));
|
|
2199
2329
|
}
|
|
2200
2330
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
2201
2331
|
if (validationResult !== 0) {
|
|
2202
|
-
console.error(
|
|
2332
|
+
console.error(chalk32.red(`Compile:Validation had ${validationResult} errors`));
|
|
2203
2333
|
return validationResult;
|
|
2204
2334
|
}
|
|
2205
2335
|
const optionsParams = tsupOptions([{
|
|
@@ -2224,12 +2354,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2224
2354
|
})
|
|
2225
2355
|
)).flat();
|
|
2226
2356
|
if (verbose) {
|
|
2227
|
-
console.log(
|
|
2228
|
-
console.log(
|
|
2357
|
+
console.log(chalk32.cyan(`TSUP:build:start [${srcDir}]`));
|
|
2358
|
+
console.log(chalk32.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
2229
2359
|
}
|
|
2230
2360
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
2231
2361
|
if (verbose) {
|
|
2232
|
-
console.log(
|
|
2362
|
+
console.log(chalk32.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
2233
2363
|
}
|
|
2234
2364
|
if (bundleTypes) {
|
|
2235
2365
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -2340,14 +2470,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
2340
2470
|
// src/actions/package/compile/compile.ts
|
|
2341
2471
|
var packageCompile = async (inConfig = {}) => {
|
|
2342
2472
|
const pkg = process.env.INIT_CWD;
|
|
2343
|
-
console.log(
|
|
2473
|
+
console.log(chalk33.green(`Compiling ${pkg}`));
|
|
2344
2474
|
const config2 = await loadConfig(inConfig);
|
|
2345
2475
|
return await packageCompileTsup(config2);
|
|
2346
2476
|
};
|
|
2347
2477
|
|
|
2348
2478
|
// src/actions/package/copy-assets.ts
|
|
2349
2479
|
import path11 from "path/posix";
|
|
2350
|
-
import
|
|
2480
|
+
import chalk34 from "chalk";
|
|
2351
2481
|
import cpy2 from "cpy";
|
|
2352
2482
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
2353
2483
|
try {
|
|
@@ -2360,7 +2490,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
2360
2490
|
}
|
|
2361
2491
|
);
|
|
2362
2492
|
if (values.length > 0) {
|
|
2363
|
-
console.log(
|
|
2493
|
+
console.log(chalk34.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
2364
2494
|
}
|
|
2365
2495
|
for (const value of values) {
|
|
2366
2496
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -2427,7 +2557,7 @@ var packageCycle = async () => {
|
|
|
2427
2557
|
// src/actions/package/gen-docs.ts
|
|
2428
2558
|
import { existsSync as existsSync7 } from "fs";
|
|
2429
2559
|
import path12 from "path";
|
|
2430
|
-
import
|
|
2560
|
+
import chalk35 from "chalk";
|
|
2431
2561
|
import {
|
|
2432
2562
|
Application,
|
|
2433
2563
|
ArgumentsReader,
|
|
@@ -2531,7 +2661,7 @@ var runTypeDoc = async (app) => {
|
|
|
2531
2661
|
return ExitCodes.OutputError;
|
|
2532
2662
|
}
|
|
2533
2663
|
}
|
|
2534
|
-
console.log(
|
|
2664
|
+
console.log(chalk35.green(`${pkgName} - Ok`));
|
|
2535
2665
|
return ExitCodes.Ok;
|
|
2536
2666
|
};
|
|
2537
2667
|
|
|
@@ -2540,7 +2670,7 @@ import { readdirSync as readdirSync4 } from "fs";
|
|
|
2540
2670
|
import path13 from "path";
|
|
2541
2671
|
import { cwd as cwd4 } from "process";
|
|
2542
2672
|
import { pathToFileURL } from "url";
|
|
2543
|
-
import
|
|
2673
|
+
import chalk36 from "chalk";
|
|
2544
2674
|
import { ESLint } from "eslint";
|
|
2545
2675
|
import { findUp } from "find-up";
|
|
2546
2676
|
import picomatch from "picomatch";
|
|
@@ -2549,14 +2679,14 @@ var dumpMessages = (lintResults) => {
|
|
|
2549
2679
|
const severity = ["none", "warning", "error"];
|
|
2550
2680
|
for (const lintResult of lintResults) {
|
|
2551
2681
|
if (lintResult.messages.length > 0) {
|
|
2552
|
-
console.log(
|
|
2682
|
+
console.log(chalk36.gray(`
|
|
2553
2683
|
${lintResult.filePath}`));
|
|
2554
2684
|
for (const message of lintResult.messages) {
|
|
2555
2685
|
console.log(
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
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}`)
|
|
2560
2690
|
);
|
|
2561
2691
|
}
|
|
2562
2692
|
}
|
|
@@ -2594,10 +2724,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2594
2724
|
cache
|
|
2595
2725
|
});
|
|
2596
2726
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
2597
|
-
console.log(
|
|
2727
|
+
console.log(chalk36.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2598
2728
|
if (verbose) {
|
|
2599
2729
|
for (const file of files) {
|
|
2600
|
-
console.log(
|
|
2730
|
+
console.log(chalk36.gray(` ${file}`));
|
|
2601
2731
|
}
|
|
2602
2732
|
}
|
|
2603
2733
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -2608,32 +2738,32 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2608
2738
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2609
2739
|
const lintTime = Date.now() - start;
|
|
2610
2740
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2611
|
-
console.log(
|
|
2741
|
+
console.log(chalk36.white(`Linted ${chalk36[filesCountColor](files.length)} files in ${chalk36[lintTimeColor](lintTime)}ms`));
|
|
2612
2742
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2613
2743
|
};
|
|
2614
2744
|
|
|
2615
2745
|
// src/actions/package/publint.ts
|
|
2616
2746
|
import { promises as fs10 } from "fs";
|
|
2617
|
-
import
|
|
2747
|
+
import chalk37 from "chalk";
|
|
2618
2748
|
import sortPackageJson from "sort-package-json";
|
|
2619
2749
|
var customPubLint = (pkg) => {
|
|
2620
2750
|
let errorCount = 0;
|
|
2621
2751
|
let warningCount = 0;
|
|
2622
2752
|
if (pkg.files === void 0) {
|
|
2623
|
-
console.warn(
|
|
2753
|
+
console.warn(chalk37.yellow('Publint [custom]: "files" field is missing'));
|
|
2624
2754
|
warningCount++;
|
|
2625
2755
|
}
|
|
2626
2756
|
if (pkg.main !== void 0) {
|
|
2627
|
-
console.warn(
|
|
2757
|
+
console.warn(chalk37.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
2628
2758
|
warningCount++;
|
|
2629
2759
|
}
|
|
2630
2760
|
if (pkg.sideEffects !== false) {
|
|
2631
|
-
console.warn(
|
|
2761
|
+
console.warn(chalk37.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
2632
2762
|
warningCount++;
|
|
2633
2763
|
}
|
|
2634
2764
|
if (pkg.resolutions !== void 0) {
|
|
2635
|
-
console.warn(
|
|
2636
|
-
console.warn(
|
|
2765
|
+
console.warn(chalk37.yellow('Publint [custom]: "resolutions" in use'));
|
|
2766
|
+
console.warn(chalk37.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
2637
2767
|
warningCount++;
|
|
2638
2768
|
}
|
|
2639
2769
|
return [errorCount, warningCount];
|
|
@@ -2643,8 +2773,8 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2643
2773
|
const sortedPkg = sortPackageJson(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2644
2774
|
await fs10.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2645
2775
|
const pkg = JSON.parse(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2646
|
-
console.log(
|
|
2647
|
-
console.log(
|
|
2776
|
+
console.log(chalk37.green(`Publint: ${pkg.name}`));
|
|
2777
|
+
console.log(chalk37.gray(pkgDir));
|
|
2648
2778
|
const { publint: publint2 } = await import("publint");
|
|
2649
2779
|
const { messages } = await publint2({
|
|
2650
2780
|
level: "suggestion",
|
|
@@ -2655,22 +2785,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2655
2785
|
for (const message of messages) {
|
|
2656
2786
|
switch (message.type) {
|
|
2657
2787
|
case "error": {
|
|
2658
|
-
console.error(
|
|
2788
|
+
console.error(chalk37.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2659
2789
|
break;
|
|
2660
2790
|
}
|
|
2661
2791
|
case "warning": {
|
|
2662
|
-
console.warn(
|
|
2792
|
+
console.warn(chalk37.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2663
2793
|
break;
|
|
2664
2794
|
}
|
|
2665
2795
|
default: {
|
|
2666
|
-
console.log(
|
|
2796
|
+
console.log(chalk37.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2667
2797
|
break;
|
|
2668
2798
|
}
|
|
2669
2799
|
}
|
|
2670
2800
|
}
|
|
2671
2801
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
2672
2802
|
if (verbose) {
|
|
2673
|
-
console.log(
|
|
2803
|
+
console.log(chalk37.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
2674
2804
|
}
|
|
2675
2805
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
2676
2806
|
};
|
|
@@ -2697,6 +2827,21 @@ var publish = () => {
|
|
|
2697
2827
|
return runSteps("Publish", [["npm", ["publish", "--workspaces"]]]);
|
|
2698
2828
|
};
|
|
2699
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
|
+
|
|
2700
2845
|
// src/actions/rebuild.ts
|
|
2701
2846
|
var rebuild = ({ target }) => {
|
|
2702
2847
|
return runSteps("Rebuild", [
|
|
@@ -2706,7 +2851,7 @@ var rebuild = ({ target }) => {
|
|
|
2706
2851
|
};
|
|
2707
2852
|
|
|
2708
2853
|
// src/actions/recompile.ts
|
|
2709
|
-
import
|
|
2854
|
+
import chalk38 from "chalk";
|
|
2710
2855
|
var recompile = async ({
|
|
2711
2856
|
verbose,
|
|
2712
2857
|
target,
|
|
@@ -2742,7 +2887,7 @@ var recompileAll = async ({
|
|
|
2742
2887
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2743
2888
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2744
2889
|
if (jobs) {
|
|
2745
|
-
console.log(
|
|
2890
|
+
console.log(chalk38.blue(`Jobs set to [${jobs}]`));
|
|
2746
2891
|
}
|
|
2747
2892
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2748
2893
|
[
|
|
@@ -2773,7 +2918,7 @@ var recompileAll = async ({
|
|
|
2773
2918
|
]
|
|
2774
2919
|
]);
|
|
2775
2920
|
console.log(
|
|
2776
|
-
`${
|
|
2921
|
+
`${chalk38.gray("Recompiled in")} [${chalk38.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk38.gray("seconds")}`
|
|
2777
2922
|
);
|
|
2778
2923
|
return result;
|
|
2779
2924
|
};
|
|
@@ -2804,13 +2949,13 @@ var reinstall = () => {
|
|
|
2804
2949
|
};
|
|
2805
2950
|
|
|
2806
2951
|
// src/actions/relint.ts
|
|
2807
|
-
import
|
|
2952
|
+
import chalk39 from "chalk";
|
|
2808
2953
|
var relintPackage = ({
|
|
2809
2954
|
pkg,
|
|
2810
2955
|
fix: fix2,
|
|
2811
2956
|
verbose
|
|
2812
2957
|
}) => {
|
|
2813
|
-
console.log(
|
|
2958
|
+
console.log(chalk39.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2814
2959
|
const start = Date.now();
|
|
2815
2960
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2816
2961
|
["yarn", [
|
|
@@ -2820,7 +2965,7 @@ var relintPackage = ({
|
|
|
2820
2965
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2821
2966
|
]]
|
|
2822
2967
|
]);
|
|
2823
|
-
console.log(
|
|
2968
|
+
console.log(chalk39.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk39.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk39.gray("seconds")}`));
|
|
2824
2969
|
return result;
|
|
2825
2970
|
};
|
|
2826
2971
|
var relint = ({
|
|
@@ -2840,13 +2985,13 @@ var relint = ({
|
|
|
2840
2985
|
});
|
|
2841
2986
|
};
|
|
2842
2987
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2843
|
-
console.log(
|
|
2988
|
+
console.log(chalk39.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2844
2989
|
const start = Date.now();
|
|
2845
2990
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2846
2991
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2847
2992
|
["yarn", ["eslint", ...fixOptions]]
|
|
2848
2993
|
]);
|
|
2849
|
-
console.log(
|
|
2994
|
+
console.log(chalk39.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk39.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk39.gray("seconds")}`));
|
|
2850
2995
|
return result;
|
|
2851
2996
|
};
|
|
2852
2997
|
|
|
@@ -2864,10 +3009,10 @@ var sonar = () => {
|
|
|
2864
3009
|
};
|
|
2865
3010
|
|
|
2866
3011
|
// src/actions/statics.ts
|
|
2867
|
-
import
|
|
3012
|
+
import chalk40 from "chalk";
|
|
2868
3013
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2869
3014
|
var statics = () => {
|
|
2870
|
-
console.log(
|
|
3015
|
+
console.log(chalk40.green("Check Required Static Dependencies"));
|
|
2871
3016
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2872
3017
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2873
3018
|
};
|
|
@@ -2916,15 +3061,15 @@ var yarn3Only = () => {
|
|
|
2916
3061
|
};
|
|
2917
3062
|
|
|
2918
3063
|
// src/loadPackageConfig.ts
|
|
2919
|
-
import { readFile } from "fs/promises";
|
|
3064
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
2920
3065
|
var loadPackageConfig = async () => {
|
|
2921
3066
|
const pkg = process.env.INIT_CWD;
|
|
2922
|
-
const pkgConfig = await
|
|
3067
|
+
const pkgConfig = await readFile2(`${pkg}/package.json`, { encoding: "utf8" });
|
|
2923
3068
|
return JSON.parse(pkgConfig);
|
|
2924
3069
|
};
|
|
2925
3070
|
|
|
2926
3071
|
// src/xy/xy.ts
|
|
2927
|
-
import
|
|
3072
|
+
import chalk42 from "chalk";
|
|
2928
3073
|
|
|
2929
3074
|
// src/xy/xyBuildCommands.ts
|
|
2930
3075
|
var xyBuildCommands = (args) => {
|
|
@@ -3122,6 +3267,29 @@ var xyCommonCommands = (args) => {
|
|
|
3122
3267
|
if (argv.verbose) console.log("NpmIgnore Gen");
|
|
3123
3268
|
process.exitCode = npmignoreGen();
|
|
3124
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
|
+
}
|
|
3125
3293
|
).command(
|
|
3126
3294
|
"retest",
|
|
3127
3295
|
"Re-Test - Run Jest Tests with cleaned cache",
|
|
@@ -3301,7 +3469,7 @@ var xyInstallCommands = (args) => {
|
|
|
3301
3469
|
};
|
|
3302
3470
|
|
|
3303
3471
|
// src/xy/xyLintCommands.ts
|
|
3304
|
-
import
|
|
3472
|
+
import chalk41 from "chalk";
|
|
3305
3473
|
var xyLintCommands = (args) => {
|
|
3306
3474
|
return args.command(
|
|
3307
3475
|
"cycle [package]",
|
|
@@ -3313,7 +3481,7 @@ var xyLintCommands = (args) => {
|
|
|
3313
3481
|
const start = Date.now();
|
|
3314
3482
|
if (argv.verbose) console.log("Cycle");
|
|
3315
3483
|
process.exitCode = await cycle({ pkg: argv.package });
|
|
3316
|
-
console.log(
|
|
3484
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3317
3485
|
}
|
|
3318
3486
|
).command(
|
|
3319
3487
|
"lint [package]",
|
|
@@ -3343,7 +3511,7 @@ var xyLintCommands = (args) => {
|
|
|
3343
3511
|
cache: argv.cache,
|
|
3344
3512
|
verbose: !!argv.verbose
|
|
3345
3513
|
});
|
|
3346
|
-
console.log(
|
|
3514
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3347
3515
|
}
|
|
3348
3516
|
).command(
|
|
3349
3517
|
"deplint [package]",
|
|
@@ -3382,7 +3550,7 @@ var xyLintCommands = (args) => {
|
|
|
3382
3550
|
peerDeps: !!argv.peerDeps,
|
|
3383
3551
|
verbose: !!argv.verbose
|
|
3384
3552
|
});
|
|
3385
|
-
console.log(
|
|
3553
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3386
3554
|
}
|
|
3387
3555
|
).command(
|
|
3388
3556
|
"fix [package]",
|
|
@@ -3394,7 +3562,7 @@ var xyLintCommands = (args) => {
|
|
|
3394
3562
|
const start = Date.now();
|
|
3395
3563
|
if (argv.verbose) console.log("Fix");
|
|
3396
3564
|
process.exitCode = fix();
|
|
3397
|
-
console.log(
|
|
3565
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3398
3566
|
}
|
|
3399
3567
|
).command(
|
|
3400
3568
|
"relint [package]",
|
|
@@ -3406,7 +3574,7 @@ var xyLintCommands = (args) => {
|
|
|
3406
3574
|
if (argv.verbose) console.log("Relinting");
|
|
3407
3575
|
const start = Date.now();
|
|
3408
3576
|
process.exitCode = relint();
|
|
3409
|
-
console.log(
|
|
3577
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3410
3578
|
}
|
|
3411
3579
|
).command(
|
|
3412
3580
|
"publint [package]",
|
|
@@ -3418,7 +3586,7 @@ var xyLintCommands = (args) => {
|
|
|
3418
3586
|
if (argv.verbose) console.log("Publint");
|
|
3419
3587
|
const start = Date.now();
|
|
3420
3588
|
process.exitCode = await publint({ pkg: argv.package, verbose: !!argv.verbose });
|
|
3421
|
-
console.log(
|
|
3589
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3422
3590
|
}
|
|
3423
3591
|
).command(
|
|
3424
3592
|
"knip",
|
|
@@ -3430,7 +3598,7 @@ var xyLintCommands = (args) => {
|
|
|
3430
3598
|
if (argv.verbose) console.log("Knip");
|
|
3431
3599
|
const start = Date.now();
|
|
3432
3600
|
process.exitCode = knip();
|
|
3433
|
-
console.log(
|
|
3601
|
+
console.log(chalk41.blue(`Knip finished in ${Date.now() - start}ms`));
|
|
3434
3602
|
}
|
|
3435
3603
|
).command(
|
|
3436
3604
|
"sonar",
|
|
@@ -3442,7 +3610,7 @@ var xyLintCommands = (args) => {
|
|
|
3442
3610
|
const start = Date.now();
|
|
3443
3611
|
if (argv.verbose) console.log("Sonar Check");
|
|
3444
3612
|
process.exitCode = sonar();
|
|
3445
|
-
console.log(
|
|
3613
|
+
console.log(chalk41.blue(`Finished in ${Date.now() - start}ms`));
|
|
3446
3614
|
}
|
|
3447
3615
|
);
|
|
3448
3616
|
};
|
|
@@ -3478,8 +3646,8 @@ var xyParseOptions = () => {
|
|
|
3478
3646
|
var xy = async () => {
|
|
3479
3647
|
const options = xyParseOptions();
|
|
3480
3648
|
return await xyBuildCommands(xyCommonCommands(xyInstallCommands(xyDeployCommands(xyLintCommands(options))))).demandCommand(1).command("*", "", () => {
|
|
3481
|
-
console.error(
|
|
3482
|
-
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"));
|
|
3483
3651
|
}).version().help().argv;
|
|
3484
3652
|
};
|
|
3485
3653
|
export {
|
|
@@ -3526,6 +3694,7 @@ export {
|
|
|
3526
3694
|
genDocsAll,
|
|
3527
3695
|
genDocsPackage,
|
|
3528
3696
|
generateIgnoreFiles,
|
|
3697
|
+
generateReadmeFiles,
|
|
3529
3698
|
gitignoreGen,
|
|
3530
3699
|
gitlint,
|
|
3531
3700
|
gitlintFix,
|
|
@@ -3561,6 +3730,7 @@ export {
|
|
|
3561
3730
|
publish,
|
|
3562
3731
|
readLines,
|
|
3563
3732
|
readNonEmptyLines,
|
|
3733
|
+
readmeGen,
|
|
3564
3734
|
rebuild,
|
|
3565
3735
|
recompile,
|
|
3566
3736
|
recompileAll,
|