@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/actions/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/actions/build.ts
|
|
2
|
-
import
|
|
2
|
+
import chalk9 from "chalk";
|
|
3
3
|
|
|
4
4
|
// src/lib/checkResult.ts
|
|
5
5
|
import chalk from "chalk";
|
|
@@ -321,8 +321,138 @@ var generateIgnoreFiles = (filename3, pkg) => {
|
|
|
321
321
|
return succeeded ? 0 : 1;
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
-
// src/lib/
|
|
324
|
+
// src/lib/generateReadmeFiles.ts
|
|
325
|
+
import { execSync as execSync2 } from "child_process";
|
|
326
|
+
import FS from "fs";
|
|
327
|
+
import { readFile, writeFile } from "fs/promises";
|
|
328
|
+
import PATH2 from "path";
|
|
325
329
|
import chalk5 from "chalk";
|
|
330
|
+
function fillTemplate(template, data) {
|
|
331
|
+
const additionalData = { ...data, safeName: data.name.replaceAll("/", "__").replaceAll("@", "") };
|
|
332
|
+
return template.replaceAll(/\{\{(.*?)\}\}/g, (_, key) => additionalData[key.trim()] ?? "");
|
|
333
|
+
}
|
|
334
|
+
function generateTypedoc(packageLocation, entryPoints) {
|
|
335
|
+
const tempDir = PATH2.join(packageLocation, ".temp-typedoc");
|
|
336
|
+
try {
|
|
337
|
+
if (!FS.existsSync(tempDir)) {
|
|
338
|
+
FS.mkdirSync(tempDir, { recursive: true });
|
|
339
|
+
}
|
|
340
|
+
const typedocConfig = {
|
|
341
|
+
disableSources: true,
|
|
342
|
+
entryPointStrategy: "expand",
|
|
343
|
+
entryPoints: entryPoints.map((ep) => PATH2.resolve(packageLocation, ep)),
|
|
344
|
+
excludeExternals: true,
|
|
345
|
+
excludeInternal: true,
|
|
346
|
+
excludePrivate: true,
|
|
347
|
+
githubPages: false,
|
|
348
|
+
hideBreadcrumbs: true,
|
|
349
|
+
hideGenerator: true,
|
|
350
|
+
hidePageTitle: true,
|
|
351
|
+
out: tempDir,
|
|
352
|
+
plugin: ["typedoc-plugin-markdown"],
|
|
353
|
+
readme: "none",
|
|
354
|
+
skipErrorChecking: true,
|
|
355
|
+
sort: ["source-order"],
|
|
356
|
+
theme: "markdown",
|
|
357
|
+
useCodeBlocks: true
|
|
358
|
+
};
|
|
359
|
+
const typedocJsonPath = PATH2.join(tempDir, "typedoc.json");
|
|
360
|
+
FS.writeFileSync(typedocJsonPath, JSON.stringify(typedocConfig, null, 2));
|
|
361
|
+
try {
|
|
362
|
+
execSync2(`npx typedoc --options ${typedocJsonPath}`, {
|
|
363
|
+
cwd: process.cwd(),
|
|
364
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
365
|
+
});
|
|
366
|
+
} catch {
|
|
367
|
+
return "";
|
|
368
|
+
}
|
|
369
|
+
return consolidateMarkdown(tempDir);
|
|
370
|
+
} catch {
|
|
371
|
+
return "";
|
|
372
|
+
} finally {
|
|
373
|
+
try {
|
|
374
|
+
FS.rmSync(tempDir, { force: true, recursive: true });
|
|
375
|
+
} catch {
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function consolidateMarkdown(tempDir) {
|
|
380
|
+
let consolidated = "## Reference\n\n";
|
|
381
|
+
const mainReadmePath = PATH2.join(tempDir, "README.md");
|
|
382
|
+
if (FS.existsSync(mainReadmePath)) {
|
|
383
|
+
const mainContent = FS.readFileSync(mainReadmePath, "utf8").replace(/^---(.|\n)*?---\n/, "").replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
384
|
+
consolidated += mainContent + "\n\n";
|
|
385
|
+
}
|
|
386
|
+
consolidated += processDirectory(tempDir);
|
|
387
|
+
return consolidated.replaceAll(/\n\n\n+/g, "\n\n").replaceAll(/^#### /gm, "### ").replaceAll(/^##### /gm, "#### ").replaceAll(/^###### /gm, "##### ");
|
|
388
|
+
}
|
|
389
|
+
function processDirectory(dir, level = 0) {
|
|
390
|
+
const indent = " ".repeat(level);
|
|
391
|
+
let content = "";
|
|
392
|
+
try {
|
|
393
|
+
const items = FS.readdirSync(dir, { withFileTypes: true });
|
|
394
|
+
for (const item of items) {
|
|
395
|
+
if (item.isDirectory()) continue;
|
|
396
|
+
if (item.name === "README.md" || !item.name.endsWith(".md")) continue;
|
|
397
|
+
const fileContent = FS.readFileSync(PATH2.join(dir, item.name), "utf8").replace(/^---(.|\n)*?---\n/, "");
|
|
398
|
+
const moduleName = item.name.replace(".md", "");
|
|
399
|
+
content += `
|
|
400
|
+
|
|
401
|
+
${indent}### <a id="${moduleName}"></a>${moduleName}
|
|
402
|
+
|
|
403
|
+
`;
|
|
404
|
+
content += fileContent.replace(/^# .+\n/, "").replaceAll(/\]\((.+?)\.md\)/g, "](#$1)");
|
|
405
|
+
}
|
|
406
|
+
for (const item of items) {
|
|
407
|
+
if (!item.isDirectory()) continue;
|
|
408
|
+
if (item.name === "spec" || item.name.includes(".spec")) continue;
|
|
409
|
+
content += `
|
|
410
|
+
|
|
411
|
+
${indent}### ${item.name}
|
|
412
|
+
`;
|
|
413
|
+
content += processDirectory(PATH2.join(dir, item.name), level + 1);
|
|
414
|
+
}
|
|
415
|
+
} catch {
|
|
416
|
+
}
|
|
417
|
+
return content;
|
|
418
|
+
}
|
|
419
|
+
async function generateReadmeFiles({
|
|
420
|
+
pkg,
|
|
421
|
+
templatePath,
|
|
422
|
+
typedoc = false,
|
|
423
|
+
verbose
|
|
424
|
+
}) {
|
|
425
|
+
console.log(chalk5.green("Generate README Files"));
|
|
426
|
+
const cwd5 = INIT_CWD() ?? ".";
|
|
427
|
+
const resolvedTemplatePath = templatePath ?? PATH2.join(cwd5, "scripts", "README.template.md");
|
|
428
|
+
let template;
|
|
429
|
+
try {
|
|
430
|
+
template = await readFile(resolvedTemplatePath, "utf8");
|
|
431
|
+
} catch {
|
|
432
|
+
console.error(chalk5.red(`Template not found: ${resolvedTemplatePath}`));
|
|
433
|
+
return 1;
|
|
434
|
+
}
|
|
435
|
+
const workspaces = pkg ? [yarnWorkspace(pkg)] : yarnWorkspaces();
|
|
436
|
+
let failed = false;
|
|
437
|
+
for (const { location, name } of workspaces) {
|
|
438
|
+
try {
|
|
439
|
+
const pkgJsonPath = PATH2.join(location, "package.json");
|
|
440
|
+
const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
|
|
441
|
+
const typedocContent = typedoc ? generateTypedoc(location, ["src/index*.ts"]) : "";
|
|
442
|
+
const readmeContent = fillTemplate(template, { ...pkgJson, typedoc: typedocContent });
|
|
443
|
+
await writeFile(PATH2.join(location, "README.md"), readmeContent);
|
|
444
|
+
if (verbose) console.log(chalk5.green(` ${name}`));
|
|
445
|
+
} catch (ex) {
|
|
446
|
+
const error = ex;
|
|
447
|
+
console.warn(chalk5.yellow(` Skipped ${location}: ${error.message}`));
|
|
448
|
+
failed = true;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return failed ? 1 : 0;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// src/lib/loadConfig.ts
|
|
455
|
+
import chalk6 from "chalk";
|
|
326
456
|
import { cosmiconfig } from "cosmiconfig";
|
|
327
457
|
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
328
458
|
import deepmerge from "deepmerge";
|
|
@@ -333,9 +463,9 @@ var loadConfig = async (params) => {
|
|
|
333
463
|
config = cosmicConfigResult?.config;
|
|
334
464
|
const configFilePath = cosmicConfigResult?.filepath;
|
|
335
465
|
if (configFilePath !== void 0) {
|
|
336
|
-
console.log(
|
|
466
|
+
console.log(chalk6.green(`Loaded config from ${configFilePath}`));
|
|
337
467
|
if (config.verbose) {
|
|
338
|
-
console.log(
|
|
468
|
+
console.log(chalk6.gray(`${JSON.stringify(config, null, 2)}`));
|
|
339
469
|
}
|
|
340
470
|
}
|
|
341
471
|
}
|
|
@@ -344,8 +474,8 @@ var loadConfig = async (params) => {
|
|
|
344
474
|
|
|
345
475
|
// src/lib/parsedPackageJSON.ts
|
|
346
476
|
import { readFileSync as readFileSync3 } from "fs";
|
|
347
|
-
var parsedPackageJSON = (
|
|
348
|
-
const pathToPackageJSON =
|
|
477
|
+
var parsedPackageJSON = (path14) => {
|
|
478
|
+
const pathToPackageJSON = path14 ?? process.env.npm_package_json ?? "";
|
|
349
479
|
const packageJSON = readFileSync3(pathToPackageJSON).toString();
|
|
350
480
|
return JSON.parse(packageJSON);
|
|
351
481
|
};
|
|
@@ -353,15 +483,15 @@ var parsedPackageJSON = (path13) => {
|
|
|
353
483
|
// src/lib/runSteps.ts
|
|
354
484
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
355
485
|
import { existsSync as existsSync2 } from "fs";
|
|
356
|
-
import
|
|
486
|
+
import chalk7 from "chalk";
|
|
357
487
|
var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
358
488
|
return safeExit(() => {
|
|
359
489
|
const pkgName = process.env.npm_package_name;
|
|
360
|
-
console.log(
|
|
490
|
+
console.log(chalk7.green(`${name} [${pkgName}]`));
|
|
361
491
|
let totalStatus = 0;
|
|
362
492
|
for (const [i, [command, args, config2]] of steps.entries()) {
|
|
363
493
|
if (messages?.[i]) {
|
|
364
|
-
console.log(
|
|
494
|
+
console.log(chalk7.gray(messages?.[i]));
|
|
365
495
|
}
|
|
366
496
|
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
367
497
|
if (command === "node" && !existsSync2(argList[0])) {
|
|
@@ -384,12 +514,12 @@ var runSteps = (name, steps, exitOnFail = true, messages) => {
|
|
|
384
514
|
// src/lib/runStepsAsync.ts
|
|
385
515
|
import { spawn } from "child_process";
|
|
386
516
|
import { existsSync as existsSync3 } from "fs";
|
|
387
|
-
import
|
|
517
|
+
import chalk8 from "chalk";
|
|
388
518
|
var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
389
519
|
return new Promise((resolve) => {
|
|
390
520
|
const [command, args, config2] = step;
|
|
391
521
|
if (message) {
|
|
392
|
-
console.log(
|
|
522
|
+
console.log(chalk8.gray(message));
|
|
393
523
|
}
|
|
394
524
|
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
395
525
|
if (command === "node" && !existsSync3(argList[0])) {
|
|
@@ -403,8 +533,8 @@ var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
|
403
533
|
}).on("close", (code) => {
|
|
404
534
|
if (code) {
|
|
405
535
|
console.error(
|
|
406
|
-
|
|
407
|
-
`Command Exited With Non-Zero Result [${
|
|
536
|
+
chalk8.red(
|
|
537
|
+
`Command Exited With Non-Zero Result [${chalk8.gray(code)}] | ${chalk8.yellow(command)} ${chalk8.white(
|
|
408
538
|
Array.isArray(args) ? args.join(" ") : args
|
|
409
539
|
)}`
|
|
410
540
|
)
|
|
@@ -420,7 +550,7 @@ var runStepAsync = (name, step, exitOnFail = true, message) => {
|
|
|
420
550
|
var runStepsAsync = async (name, steps, exitOnFail = true, messages) => {
|
|
421
551
|
return await safeExitAsync(async () => {
|
|
422
552
|
const pkgName = process.env.npm_package_name;
|
|
423
|
-
console.log(
|
|
553
|
+
console.log(chalk8.green(`${name} [${pkgName}]`));
|
|
424
554
|
let result = 0;
|
|
425
555
|
for (const [i, step] of steps.entries()) {
|
|
426
556
|
result += await runStepAsync(name, step, exitOnFail, messages?.[i]);
|
|
@@ -444,7 +574,7 @@ var build = async ({
|
|
|
444
574
|
const targetOptions = target === void 0 ? [] : ["-t", target];
|
|
445
575
|
const jobsOptions = jobs === void 0 ? [] : ["-j", `${jobs}`];
|
|
446
576
|
if (jobs !== void 0) {
|
|
447
|
-
console.log(
|
|
577
|
+
console.log(chalk9.blue(`Jobs set to [${jobs}]`));
|
|
448
578
|
}
|
|
449
579
|
const result = await runStepsAsync(`Build${incremental ? "-Incremental" : ""} [${pkg ?? "All"}]`, [
|
|
450
580
|
["yarn", ["xy", "compile", ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, "--types", "tsup"]],
|
|
@@ -452,7 +582,7 @@ var build = async ({
|
|
|
452
582
|
["yarn", ["xy", "deplint", ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],
|
|
453
583
|
["yarn", ["xy", "lint", ...pkgOptions, ...verboseOptions, ...incrementalOptions]]
|
|
454
584
|
]);
|
|
455
|
-
console.log(`${
|
|
585
|
+
console.log(`${chalk9.gray("Built in")} [${chalk9.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk9.gray("seconds")}`);
|
|
456
586
|
return result;
|
|
457
587
|
};
|
|
458
588
|
|
|
@@ -465,15 +595,15 @@ import {
|
|
|
465
595
|
unlinkSync,
|
|
466
596
|
writeFileSync as writeFileSync2
|
|
467
597
|
} from "fs";
|
|
468
|
-
import
|
|
469
|
-
import
|
|
598
|
+
import PATH3 from "path";
|
|
599
|
+
import chalk10 from "chalk";
|
|
470
600
|
var syncCommandFiles = (commandsDir) => {
|
|
471
601
|
const templates = claudeCommandTemplates();
|
|
472
602
|
const templateNames = new Set(Object.keys(templates));
|
|
473
603
|
let updated = 0;
|
|
474
604
|
let created = 0;
|
|
475
605
|
for (const [filename3, content] of Object.entries(templates)) {
|
|
476
|
-
const targetPath =
|
|
606
|
+
const targetPath = PATH3.resolve(commandsDir, filename3);
|
|
477
607
|
const existing = existsSync4(targetPath) ? readFileSync4(targetPath, "utf8") : void 0;
|
|
478
608
|
if (existing === content) continue;
|
|
479
609
|
writeFileSync2(targetPath, content, "utf8");
|
|
@@ -494,7 +624,7 @@ var removeStaleCommands = (commandsDir, templateNames) => {
|
|
|
494
624
|
let removed = 0;
|
|
495
625
|
for (const file of existingCommands) {
|
|
496
626
|
if (!templateNames.has(file)) {
|
|
497
|
-
unlinkSync(
|
|
627
|
+
unlinkSync(PATH3.resolve(commandsDir, file));
|
|
498
628
|
removed++;
|
|
499
629
|
}
|
|
500
630
|
}
|
|
@@ -507,14 +637,14 @@ var logCommandsResult = (created, updated, removed) => {
|
|
|
507
637
|
updated ? `${updated} updated` : "",
|
|
508
638
|
removed ? `${removed} removed` : ""
|
|
509
639
|
].filter(Boolean);
|
|
510
|
-
console.log(
|
|
640
|
+
console.log(chalk10.green(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: ${parts.join(", ")}`));
|
|
511
641
|
} else {
|
|
512
|
-
console.log(
|
|
642
|
+
console.log(chalk10.gray(`.claude/commands/${XYLABS_COMMANDS_PREFIX}*.md: already up to date`));
|
|
513
643
|
}
|
|
514
644
|
};
|
|
515
645
|
var claudeCommands = () => {
|
|
516
646
|
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
517
|
-
const commandsDir =
|
|
647
|
+
const commandsDir = PATH3.resolve(cwd5, ".claude", "commands");
|
|
518
648
|
mkdirSync(commandsDir, { recursive: true });
|
|
519
649
|
const {
|
|
520
650
|
created,
|
|
@@ -535,15 +665,15 @@ import {
|
|
|
535
665
|
unlinkSync as unlinkSync2,
|
|
536
666
|
writeFileSync as writeFileSync3
|
|
537
667
|
} from "fs";
|
|
538
|
-
import
|
|
539
|
-
import
|
|
668
|
+
import PATH4 from "path";
|
|
669
|
+
import chalk11 from "chalk";
|
|
540
670
|
var syncRuleFiles = (rulesDir) => {
|
|
541
671
|
const templates = claudeMdRuleTemplates();
|
|
542
672
|
const templateNames = new Set(Object.keys(templates));
|
|
543
673
|
let updated = 0;
|
|
544
674
|
let created = 0;
|
|
545
675
|
for (const [filename3, content] of Object.entries(templates)) {
|
|
546
|
-
const targetPath =
|
|
676
|
+
const targetPath = PATH4.resolve(rulesDir, filename3);
|
|
547
677
|
const existing = existsSync5(targetPath) ? readFileSync5(targetPath, "utf8") : void 0;
|
|
548
678
|
if (existing === content) continue;
|
|
549
679
|
writeFileSync3(targetPath, content, "utf8");
|
|
@@ -564,7 +694,7 @@ var removeStaleRules = (rulesDir, templateNames) => {
|
|
|
564
694
|
let removed = 0;
|
|
565
695
|
for (const file of existingRules) {
|
|
566
696
|
if (!templateNames.has(file)) {
|
|
567
|
-
unlinkSync2(
|
|
697
|
+
unlinkSync2(PATH4.resolve(rulesDir, file));
|
|
568
698
|
removed++;
|
|
569
699
|
}
|
|
570
700
|
}
|
|
@@ -577,26 +707,26 @@ var logRulesResult = (created, updated, removed) => {
|
|
|
577
707
|
updated ? `${updated} updated` : "",
|
|
578
708
|
removed ? `${removed} removed` : ""
|
|
579
709
|
].filter(Boolean);
|
|
580
|
-
console.log(
|
|
710
|
+
console.log(chalk11.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
|
|
581
711
|
} else {
|
|
582
|
-
console.log(
|
|
712
|
+
console.log(chalk11.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
|
|
583
713
|
}
|
|
584
714
|
};
|
|
585
715
|
var ensureProjectClaudeMd = (cwd5, force) => {
|
|
586
|
-
const projectPath =
|
|
716
|
+
const projectPath = PATH4.resolve(cwd5, "CLAUDE.md");
|
|
587
717
|
if (!existsSync5(projectPath) || force) {
|
|
588
718
|
if (force && existsSync5(projectPath)) {
|
|
589
|
-
console.log(
|
|
719
|
+
console.log(chalk11.yellow("Overwriting existing CLAUDE.md"));
|
|
590
720
|
}
|
|
591
721
|
writeFileSync3(projectPath, claudeMdProjectTemplate(), "utf8");
|
|
592
|
-
console.log(
|
|
722
|
+
console.log(chalk11.green("Generated CLAUDE.md"));
|
|
593
723
|
} else {
|
|
594
|
-
console.log(
|
|
724
|
+
console.log(chalk11.gray("CLAUDE.md already exists (skipped)"));
|
|
595
725
|
}
|
|
596
726
|
};
|
|
597
727
|
var claudeRules = ({ force } = {}) => {
|
|
598
728
|
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
599
|
-
const rulesDir =
|
|
729
|
+
const rulesDir = PATH4.resolve(cwd5, ".claude", "rules");
|
|
600
730
|
mkdirSync2(rulesDir, { recursive: true });
|
|
601
731
|
const {
|
|
602
732
|
created,
|
|
@@ -623,16 +753,16 @@ var cleanAll = ({ verbose }) => {
|
|
|
623
753
|
|
|
624
754
|
// src/actions/clean-docs.ts
|
|
625
755
|
import path from "path";
|
|
626
|
-
import
|
|
756
|
+
import chalk12 from "chalk";
|
|
627
757
|
var cleanDocs = () => {
|
|
628
758
|
const pkgName = process.env.npm_package_name;
|
|
629
|
-
console.log(
|
|
759
|
+
console.log(chalk12.green(`Cleaning Docs [${pkgName}]`));
|
|
630
760
|
for (const { location } of yarnWorkspaces()) deleteGlob(path.join(location, "docs"));
|
|
631
761
|
return 0;
|
|
632
762
|
};
|
|
633
763
|
|
|
634
764
|
// src/actions/compile.ts
|
|
635
|
-
import
|
|
765
|
+
import chalk13 from "chalk";
|
|
636
766
|
var compile = ({
|
|
637
767
|
verbose,
|
|
638
768
|
target,
|
|
@@ -673,7 +803,7 @@ var compileAll = ({
|
|
|
673
803
|
const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
|
|
674
804
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
675
805
|
if (jobs) {
|
|
676
|
-
console.log(
|
|
806
|
+
console.log(chalk13.blue(`Jobs set to [${jobs}]`));
|
|
677
807
|
}
|
|
678
808
|
const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
|
|
679
809
|
["yarn", [
|
|
@@ -687,13 +817,13 @@ var compileAll = ({
|
|
|
687
817
|
...targetOptions
|
|
688
818
|
]]
|
|
689
819
|
]);
|
|
690
|
-
console.log(`${
|
|
820
|
+
console.log(`${chalk13.gray("Compiled in")} [${chalk13.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk13.gray("seconds")}`);
|
|
691
821
|
return result;
|
|
692
822
|
};
|
|
693
823
|
|
|
694
824
|
// src/actions/copy-assets.ts
|
|
695
825
|
import path2 from "path/posix";
|
|
696
|
-
import
|
|
826
|
+
import chalk14 from "chalk";
|
|
697
827
|
import cpy from "cpy";
|
|
698
828
|
var copyPackageTargetAssets = async (target, name, location) => {
|
|
699
829
|
try {
|
|
@@ -716,7 +846,7 @@ var copyPackageTargetAssets = async (target, name, location) => {
|
|
|
716
846
|
};
|
|
717
847
|
var copyTargetAssets = async (target, pkg) => {
|
|
718
848
|
const workspaces = yarnWorkspaces();
|
|
719
|
-
console.log(
|
|
849
|
+
console.log(chalk14.green(`Copying Assets [${target.toUpperCase()}]`));
|
|
720
850
|
const workspaceList = workspaces.filter(({ name }) => {
|
|
721
851
|
return pkg === void 0 || name === pkg;
|
|
722
852
|
});
|
|
@@ -800,7 +930,7 @@ var dead = () => {
|
|
|
800
930
|
};
|
|
801
931
|
|
|
802
932
|
// src/actions/deplint/deplint.ts
|
|
803
|
-
import
|
|
933
|
+
import chalk20 from "chalk";
|
|
804
934
|
|
|
805
935
|
// src/actions/deplint/findFiles.ts
|
|
806
936
|
import fs2 from "fs";
|
|
@@ -976,11 +1106,11 @@ function getExternalImportsFromFiles({
|
|
|
976
1106
|
const allImportPaths = {};
|
|
977
1107
|
const distImportPaths = {};
|
|
978
1108
|
const distTypeImportPaths = {};
|
|
979
|
-
for (const
|
|
1109
|
+
for (const path14 of allFiles) getImportsFromFile(path14, allImportPaths, allImportPaths).flat();
|
|
980
1110
|
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
981
1111
|
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
982
|
-
for (const
|
|
983
|
-
for (const
|
|
1112
|
+
for (const path14 of distCodeFiles) getImportsFromFile(path14, distImportPaths, distImportPaths).flat();
|
|
1113
|
+
for (const path14 of distTypeFiles) getImportsFromFile(path14, distTypeImportPaths, distTypeImportPaths).flat();
|
|
984
1114
|
const allImports = Object.keys(allImportPaths);
|
|
985
1115
|
const distImports = Object.keys(distImportPaths);
|
|
986
1116
|
const externalAllImports = removeInternalImports(allImports);
|
|
@@ -1002,12 +1132,12 @@ function getExternalImportsFromFiles({
|
|
|
1002
1132
|
|
|
1003
1133
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
1004
1134
|
import { builtinModules } from "module";
|
|
1005
|
-
import
|
|
1135
|
+
import chalk15 from "chalk";
|
|
1006
1136
|
function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
|
|
1007
1137
|
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
|
|
1008
1138
|
}
|
|
1009
1139
|
function logMissing(name, imp, importPaths) {
|
|
1010
|
-
console.log(`[${
|
|
1140
|
+
console.log(`[${chalk15.blue(name)}] Missing dependency in package.json: ${chalk15.red(imp)}`);
|
|
1011
1141
|
if (importPaths[imp]) {
|
|
1012
1142
|
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
1013
1143
|
}
|
|
@@ -1032,7 +1162,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
1032
1162
|
}
|
|
1033
1163
|
if (unlistedDependencies > 0) {
|
|
1034
1164
|
const packageLocation = `${location}/package.json`;
|
|
1035
|
-
console.log(` ${
|
|
1165
|
+
console.log(` ${chalk15.yellow(packageLocation)}
|
|
1036
1166
|
`);
|
|
1037
1167
|
}
|
|
1038
1168
|
return unlistedDependencies;
|
|
@@ -1040,7 +1170,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
1040
1170
|
|
|
1041
1171
|
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
1042
1172
|
import { builtinModules as builtinModules2 } from "module";
|
|
1043
|
-
import
|
|
1173
|
+
import chalk16 from "chalk";
|
|
1044
1174
|
function getUnlistedDevDependencies({ name, location }, {
|
|
1045
1175
|
devDependencies,
|
|
1046
1176
|
dependencies,
|
|
@@ -1054,7 +1184,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
1054
1184
|
for (const imp of externalAllImports) {
|
|
1055
1185
|
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)) {
|
|
1056
1186
|
unlistedDevDependencies++;
|
|
1057
|
-
console.log(`[${
|
|
1187
|
+
console.log(`[${chalk16.blue(name)}] Missing devDependency in package.json: ${chalk16.red(imp)}`);
|
|
1058
1188
|
if (allImportPaths[imp]) {
|
|
1059
1189
|
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
1060
1190
|
}
|
|
@@ -1062,40 +1192,50 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
1062
1192
|
}
|
|
1063
1193
|
if (unlistedDevDependencies > 0) {
|
|
1064
1194
|
const packageLocation = `${location}/package.json`;
|
|
1065
|
-
console.log(` ${
|
|
1195
|
+
console.log(` ${chalk16.yellow(packageLocation)}
|
|
1066
1196
|
`);
|
|
1067
1197
|
}
|
|
1068
1198
|
return unlistedDevDependencies;
|
|
1069
1199
|
}
|
|
1070
1200
|
|
|
1071
1201
|
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
1072
|
-
import
|
|
1202
|
+
import chalk17 from "chalk";
|
|
1073
1203
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
1074
1204
|
externalDistImports,
|
|
1075
1205
|
externalDistTypeImports,
|
|
1076
1206
|
externalAllImports
|
|
1077
|
-
}) {
|
|
1207
|
+
}, exclude) {
|
|
1078
1208
|
let unusedDependencies = 0;
|
|
1079
1209
|
for (const dep of dependencies) {
|
|
1210
|
+
if (exclude?.has(dep)) continue;
|
|
1080
1211
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1081
1212
|
unusedDependencies++;
|
|
1082
1213
|
if (externalAllImports.includes(dep)) {
|
|
1083
|
-
console.log(`[${
|
|
1214
|
+
console.log(`[${chalk17.blue(name)}] dependency should be devDependency in package.json: ${chalk17.red(dep)}`);
|
|
1084
1215
|
} else {
|
|
1085
|
-
console.log(`[${
|
|
1216
|
+
console.log(`[${chalk17.blue(name)}] Unused dependency in package.json: ${chalk17.red(dep)}`);
|
|
1086
1217
|
}
|
|
1087
1218
|
}
|
|
1088
1219
|
}
|
|
1089
1220
|
if (unusedDependencies > 0) {
|
|
1090
1221
|
const packageLocation = `${location}/package.json`;
|
|
1091
|
-
console.log(` ${
|
|
1222
|
+
console.log(` ${chalk17.yellow(packageLocation)}
|
|
1092
1223
|
`);
|
|
1093
1224
|
}
|
|
1094
1225
|
return unusedDependencies;
|
|
1095
1226
|
}
|
|
1096
1227
|
|
|
1097
1228
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1098
|
-
import
|
|
1229
|
+
import chalk18 from "chalk";
|
|
1230
|
+
|
|
1231
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1232
|
+
import fs8 from "fs";
|
|
1233
|
+
import path7 from "path";
|
|
1234
|
+
import ts2 from "typescript";
|
|
1235
|
+
|
|
1236
|
+
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1237
|
+
import fs7 from "fs";
|
|
1238
|
+
import path6 from "path";
|
|
1099
1239
|
|
|
1100
1240
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
1101
1241
|
import fs6 from "fs";
|
|
@@ -1130,8 +1270,6 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1130
1270
|
}
|
|
1131
1271
|
|
|
1132
1272
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1133
|
-
import fs7 from "fs";
|
|
1134
|
-
import path6 from "path";
|
|
1135
1273
|
function getBinNames(location, dep) {
|
|
1136
1274
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1137
1275
|
if (!depPkgPath) return [];
|
|
@@ -1181,15 +1319,101 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1181
1319
|
return referenced;
|
|
1182
1320
|
}
|
|
1183
1321
|
|
|
1322
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1323
|
+
var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
|
|
1324
|
+
var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
|
|
1325
|
+
var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
|
|
1326
|
+
function getCommandTokensFromFile(filePath) {
|
|
1327
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
1328
|
+
let sourceCode;
|
|
1329
|
+
try {
|
|
1330
|
+
sourceCode = fs8.readFileSync(filePath, "utf8");
|
|
1331
|
+
} catch {
|
|
1332
|
+
return tokens;
|
|
1333
|
+
}
|
|
1334
|
+
const isMjsFile = filePath.endsWith(".mjs");
|
|
1335
|
+
const sourceFile = ts2.createSourceFile(
|
|
1336
|
+
path7.basename(filePath),
|
|
1337
|
+
sourceCode,
|
|
1338
|
+
ts2.ScriptTarget.Latest,
|
|
1339
|
+
true,
|
|
1340
|
+
isMjsFile ? ts2.ScriptKind.JS : void 0
|
|
1341
|
+
);
|
|
1342
|
+
function visit(node) {
|
|
1343
|
+
if (ts2.isCallExpression(node) && node.arguments.length > 0) {
|
|
1344
|
+
const fnName = getFunctionName(node.expression);
|
|
1345
|
+
if (fnName && allExecFunctions.has(fnName)) {
|
|
1346
|
+
const firstArg = node.arguments[0];
|
|
1347
|
+
if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
|
|
1348
|
+
const value = firstArg.text;
|
|
1349
|
+
if (shellCommandFunctions.has(fnName)) {
|
|
1350
|
+
for (const token of tokenizeScript(value)) {
|
|
1351
|
+
tokens.add(token);
|
|
1352
|
+
}
|
|
1353
|
+
} else {
|
|
1354
|
+
tokens.add(value);
|
|
1355
|
+
}
|
|
1356
|
+
} else if (ts2.isTemplateExpression(firstArg)) {
|
|
1357
|
+
const head = firstArg.head.text;
|
|
1358
|
+
if (head) {
|
|
1359
|
+
for (const token of tokenizeScript(head)) {
|
|
1360
|
+
tokens.add(token);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
ts2.forEachChild(node, visit);
|
|
1367
|
+
}
|
|
1368
|
+
visit(sourceFile);
|
|
1369
|
+
return tokens;
|
|
1370
|
+
}
|
|
1371
|
+
function getFunctionName(expr) {
|
|
1372
|
+
if (ts2.isIdentifier(expr)) {
|
|
1373
|
+
return expr.text;
|
|
1374
|
+
}
|
|
1375
|
+
if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
|
|
1376
|
+
return expr.name.text;
|
|
1377
|
+
}
|
|
1378
|
+
return void 0;
|
|
1379
|
+
}
|
|
1380
|
+
function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
|
|
1381
|
+
const allTokens = /* @__PURE__ */ new Set();
|
|
1382
|
+
for (const file of allFiles) {
|
|
1383
|
+
for (const token of getCommandTokensFromFile(file)) {
|
|
1384
|
+
allTokens.add(token);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
if (allTokens.size === 0) return /* @__PURE__ */ new Set();
|
|
1388
|
+
const binToPackage = /* @__PURE__ */ new Map();
|
|
1389
|
+
for (const dep of allDeps) {
|
|
1390
|
+
for (const bin of getBinNames(location, dep)) {
|
|
1391
|
+
binToPackage.set(bin, dep);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1395
|
+
for (const token of allTokens) {
|
|
1396
|
+
const baseName = getBasePackageName(token);
|
|
1397
|
+
if (allDeps.includes(baseName)) {
|
|
1398
|
+
referenced.add(baseName);
|
|
1399
|
+
}
|
|
1400
|
+
const pkg = binToPackage.get(token);
|
|
1401
|
+
if (pkg) {
|
|
1402
|
+
referenced.add(pkg);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
return referenced;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1184
1408
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1185
|
-
import
|
|
1409
|
+
import fs9 from "fs";
|
|
1186
1410
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1187
1411
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1188
1412
|
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1189
1413
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1190
1414
|
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1191
1415
|
try {
|
|
1192
|
-
const content =
|
|
1416
|
+
const content = fs9.readFileSync(file, "utf8");
|
|
1193
1417
|
return decoratorPattern.test(content);
|
|
1194
1418
|
} catch {
|
|
1195
1419
|
return false;
|
|
@@ -1202,7 +1426,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1202
1426
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1203
1427
|
if (!pkgPath) continue;
|
|
1204
1428
|
try {
|
|
1205
|
-
const pkg = JSON.parse(
|
|
1429
|
+
const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
|
|
1206
1430
|
const transitiveDeps = [
|
|
1207
1431
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1208
1432
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1254,10 +1478,11 @@ var allExternalImports = ({
|
|
|
1254
1478
|
...externalDistTypeImports
|
|
1255
1479
|
]);
|
|
1256
1480
|
};
|
|
1257
|
-
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1481
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
|
|
1258
1482
|
if (implicitDeps.has(dep)) return true;
|
|
1259
1483
|
if (requiredPeers.has(dep)) return true;
|
|
1260
1484
|
if (scriptRefs.has(dep)) return true;
|
|
1485
|
+
if (cliRefs.has(dep)) return true;
|
|
1261
1486
|
if (dep.startsWith("@types/")) {
|
|
1262
1487
|
const baseName = dep.replace(/^@types\//, "");
|
|
1263
1488
|
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
@@ -1268,7 +1493,7 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1268
1493
|
devDependencies,
|
|
1269
1494
|
dependencies,
|
|
1270
1495
|
peerDependencies
|
|
1271
|
-
}, sourceParams, fileContext) {
|
|
1496
|
+
}, sourceParams, fileContext, exclude) {
|
|
1272
1497
|
const allImports = allExternalImports(sourceParams);
|
|
1273
1498
|
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1274
1499
|
const implicitDeps = getImplicitDevDependencies({
|
|
@@ -1278,39 +1503,42 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1278
1503
|
});
|
|
1279
1504
|
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1280
1505
|
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1506
|
+
const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
|
|
1281
1507
|
let unusedDevDependencies = 0;
|
|
1282
1508
|
for (const dep of devDependencies) {
|
|
1509
|
+
if (exclude?.has(dep)) continue;
|
|
1283
1510
|
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1284
|
-
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1511
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
|
|
1285
1512
|
unusedDevDependencies++;
|
|
1286
|
-
console.log(`[${
|
|
1513
|
+
console.log(`[${chalk18.blue(name)}] Unused devDependency in package.json: ${chalk18.red(dep)}`);
|
|
1287
1514
|
}
|
|
1288
1515
|
}
|
|
1289
1516
|
if (unusedDevDependencies > 0) {
|
|
1290
1517
|
const packageLocation = `${location}/package.json`;
|
|
1291
|
-
console.log(` ${
|
|
1518
|
+
console.log(` ${chalk18.yellow(packageLocation)}
|
|
1292
1519
|
`);
|
|
1293
1520
|
}
|
|
1294
1521
|
return unusedDevDependencies;
|
|
1295
1522
|
}
|
|
1296
1523
|
|
|
1297
1524
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1298
|
-
import
|
|
1299
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
1525
|
+
import chalk19 from "chalk";
|
|
1526
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
|
|
1300
1527
|
let unusedDependencies = 0;
|
|
1301
1528
|
for (const dep of peerDependencies) {
|
|
1529
|
+
if (exclude?.has(dep)) continue;
|
|
1302
1530
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1303
1531
|
unusedDependencies++;
|
|
1304
1532
|
if (dependencies.includes(dep)) {
|
|
1305
|
-
console.log(`[${
|
|
1533
|
+
console.log(`[${chalk19.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk19.red(dep)}`);
|
|
1306
1534
|
} else {
|
|
1307
|
-
console.log(`[${
|
|
1535
|
+
console.log(`[${chalk19.blue(name)}] Unused peerDependency in package.json: ${chalk19.red(dep)}`);
|
|
1308
1536
|
}
|
|
1309
1537
|
}
|
|
1310
1538
|
}
|
|
1311
1539
|
if (unusedDependencies > 0) {
|
|
1312
1540
|
const packageLocation = `${location}/package.json`;
|
|
1313
|
-
console.log(` ${
|
|
1541
|
+
console.log(` ${chalk19.yellow(packageLocation)}
|
|
1314
1542
|
`);
|
|
1315
1543
|
}
|
|
1316
1544
|
return unusedDependencies;
|
|
@@ -1335,6 +1563,7 @@ function checkPackage({
|
|
|
1335
1563
|
location,
|
|
1336
1564
|
deps = false,
|
|
1337
1565
|
devDeps = false,
|
|
1566
|
+
exclude,
|
|
1338
1567
|
peerDeps = false,
|
|
1339
1568
|
verbose = false
|
|
1340
1569
|
}) {
|
|
@@ -1353,23 +1582,29 @@ function checkPackage({
|
|
|
1353
1582
|
});
|
|
1354
1583
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1355
1584
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1356
|
-
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1585
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1357
1586
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1358
1587
|
const fileContext = { allFiles, distFiles };
|
|
1359
|
-
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1360
|
-
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1588
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
|
|
1589
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1361
1590
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
1362
1591
|
return totalErrors;
|
|
1363
1592
|
}
|
|
1364
1593
|
|
|
1365
1594
|
// src/actions/deplint/deplint.ts
|
|
1366
|
-
var deplint = ({
|
|
1595
|
+
var deplint = async ({
|
|
1367
1596
|
pkg,
|
|
1368
1597
|
deps,
|
|
1369
1598
|
devDeps,
|
|
1370
1599
|
peerDeps,
|
|
1371
|
-
verbose
|
|
1600
|
+
verbose,
|
|
1601
|
+
cliExclude
|
|
1372
1602
|
}) => {
|
|
1603
|
+
const config2 = await loadConfig();
|
|
1604
|
+
const exclude = /* @__PURE__ */ new Set([
|
|
1605
|
+
...config2.deplint?.exclude ?? [],
|
|
1606
|
+
...cliExclude ?? []
|
|
1607
|
+
]);
|
|
1373
1608
|
let totalErrors = 0;
|
|
1374
1609
|
if (pkg === void 0) {
|
|
1375
1610
|
const workspaces = yarnWorkspaces();
|
|
@@ -1379,6 +1614,7 @@ var deplint = ({
|
|
|
1379
1614
|
...workspace,
|
|
1380
1615
|
deps,
|
|
1381
1616
|
devDeps,
|
|
1617
|
+
exclude,
|
|
1382
1618
|
peerDeps,
|
|
1383
1619
|
verbose
|
|
1384
1620
|
});
|
|
@@ -1391,14 +1627,15 @@ var deplint = ({
|
|
|
1391
1627
|
location,
|
|
1392
1628
|
devDeps,
|
|
1393
1629
|
deps,
|
|
1630
|
+
exclude,
|
|
1394
1631
|
peerDeps,
|
|
1395
1632
|
verbose
|
|
1396
1633
|
});
|
|
1397
1634
|
}
|
|
1398
1635
|
if (totalErrors > 0) {
|
|
1399
|
-
console.warn(`Deplint: Found ${
|
|
1636
|
+
console.warn(`Deplint: Found ${chalk20.red(totalErrors)} dependency problems. ${chalk20.red("\u2716")}`);
|
|
1400
1637
|
} else {
|
|
1401
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1638
|
+
console.info(`Deplint: Found no dependency problems. ${chalk20.green("\u2714")}`);
|
|
1402
1639
|
}
|
|
1403
1640
|
return 0;
|
|
1404
1641
|
};
|
|
@@ -1500,22 +1737,22 @@ var deployNext = () => {
|
|
|
1500
1737
|
};
|
|
1501
1738
|
|
|
1502
1739
|
// src/actions/dupdeps.ts
|
|
1503
|
-
import
|
|
1740
|
+
import chalk21 from "chalk";
|
|
1504
1741
|
var dupdeps = () => {
|
|
1505
|
-
console.log(
|
|
1742
|
+
console.log(chalk21.green("Checking all Dependencies for Duplicates"));
|
|
1506
1743
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1507
1744
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1508
1745
|
return detectDuplicateDependencies(dependencies);
|
|
1509
1746
|
};
|
|
1510
1747
|
|
|
1511
1748
|
// src/actions/lint.ts
|
|
1512
|
-
import
|
|
1749
|
+
import chalk22 from "chalk";
|
|
1513
1750
|
var lintPackage = ({
|
|
1514
1751
|
pkg,
|
|
1515
1752
|
fix: fix2,
|
|
1516
1753
|
verbose
|
|
1517
1754
|
}) => {
|
|
1518
|
-
console.log(
|
|
1755
|
+
console.log(chalk22.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1519
1756
|
const start = Date.now();
|
|
1520
1757
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1521
1758
|
["yarn", [
|
|
@@ -1525,7 +1762,7 @@ var lintPackage = ({
|
|
|
1525
1762
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1526
1763
|
]]
|
|
1527
1764
|
]);
|
|
1528
|
-
console.log(
|
|
1765
|
+
console.log(chalk22.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk22.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk22.gray("seconds")}`));
|
|
1529
1766
|
return result;
|
|
1530
1767
|
};
|
|
1531
1768
|
var lint = ({
|
|
@@ -1545,13 +1782,13 @@ var lint = ({
|
|
|
1545
1782
|
});
|
|
1546
1783
|
};
|
|
1547
1784
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1548
|
-
console.log(
|
|
1785
|
+
console.log(chalk22.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1549
1786
|
const start = Date.now();
|
|
1550
1787
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1551
1788
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1552
1789
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1553
1790
|
]);
|
|
1554
|
-
console.log(
|
|
1791
|
+
console.log(chalk22.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk22.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk22.gray("seconds")}`));
|
|
1555
1792
|
return result;
|
|
1556
1793
|
};
|
|
1557
1794
|
|
|
@@ -1579,7 +1816,7 @@ var filename = ".gitignore";
|
|
|
1579
1816
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1580
1817
|
|
|
1581
1818
|
// src/actions/gitlint.ts
|
|
1582
|
-
import
|
|
1819
|
+
import chalk23 from "chalk";
|
|
1583
1820
|
import ParseGitConfig from "parse-git-config";
|
|
1584
1821
|
var gitlint = () => {
|
|
1585
1822
|
console.log(`
|
|
@@ -1590,7 +1827,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1590
1827
|
const errors = 0;
|
|
1591
1828
|
const gitConfig = ParseGitConfig.sync();
|
|
1592
1829
|
const warn = (message) => {
|
|
1593
|
-
console.warn(
|
|
1830
|
+
console.warn(chalk23.yellow(`Warning: ${message}`));
|
|
1594
1831
|
warnings++;
|
|
1595
1832
|
};
|
|
1596
1833
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1610,13 +1847,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1610
1847
|
}
|
|
1611
1848
|
const resultMessages = [];
|
|
1612
1849
|
if (valid > 0) {
|
|
1613
|
-
resultMessages.push(
|
|
1850
|
+
resultMessages.push(chalk23.green(`Passed: ${valid}`));
|
|
1614
1851
|
}
|
|
1615
1852
|
if (warnings > 0) {
|
|
1616
|
-
resultMessages.push(
|
|
1853
|
+
resultMessages.push(chalk23.yellow(`Warnings: ${warnings}`));
|
|
1617
1854
|
}
|
|
1618
1855
|
if (errors > 0) {
|
|
1619
|
-
resultMessages.push(
|
|
1856
|
+
resultMessages.push(chalk23.red(` Errors: ${errors}`));
|
|
1620
1857
|
}
|
|
1621
1858
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1622
1859
|
`);
|
|
@@ -1624,8 +1861,8 @@ Gitlint Start [${process.cwd()}]
|
|
|
1624
1861
|
};
|
|
1625
1862
|
|
|
1626
1863
|
// src/actions/gitlint-fix.ts
|
|
1627
|
-
import { execSync as
|
|
1628
|
-
import
|
|
1864
|
+
import { execSync as execSync3 } from "child_process";
|
|
1865
|
+
import chalk24 from "chalk";
|
|
1629
1866
|
import ParseGitConfig2 from "parse-git-config";
|
|
1630
1867
|
var gitlintFix = () => {
|
|
1631
1868
|
console.log(`
|
|
@@ -1633,16 +1870,16 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1633
1870
|
`);
|
|
1634
1871
|
const gitConfig = ParseGitConfig2.sync();
|
|
1635
1872
|
if (gitConfig.core.ignorecase) {
|
|
1636
|
-
|
|
1637
|
-
console.warn(
|
|
1873
|
+
execSync3("git config core.ignorecase false", { stdio: "inherit" });
|
|
1874
|
+
console.warn(chalk24.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1638
1875
|
}
|
|
1639
1876
|
if (gitConfig.core.autocrlf !== false) {
|
|
1640
|
-
|
|
1641
|
-
console.warn(
|
|
1877
|
+
execSync3("git config core.autocrlf false", { stdio: "inherit" });
|
|
1878
|
+
console.warn(chalk24.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1642
1879
|
}
|
|
1643
1880
|
if (gitConfig.core.eol !== "lf") {
|
|
1644
|
-
|
|
1645
|
-
console.warn(
|
|
1881
|
+
execSync3("git config core.eol lf", { stdio: "inherit" });
|
|
1882
|
+
console.warn(chalk24.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1646
1883
|
}
|
|
1647
1884
|
return 1;
|
|
1648
1885
|
};
|
|
@@ -1653,7 +1890,7 @@ var knip = () => {
|
|
|
1653
1890
|
};
|
|
1654
1891
|
|
|
1655
1892
|
// src/actions/license.ts
|
|
1656
|
-
import
|
|
1893
|
+
import chalk25 from "chalk";
|
|
1657
1894
|
import { init } from "license-checker";
|
|
1658
1895
|
var license = async (pkg) => {
|
|
1659
1896
|
const workspaces = yarnWorkspaces();
|
|
@@ -1678,18 +1915,18 @@ var license = async (pkg) => {
|
|
|
1678
1915
|
"LGPL-3.0-or-later",
|
|
1679
1916
|
"Python-2.0"
|
|
1680
1917
|
]);
|
|
1681
|
-
console.log(
|
|
1918
|
+
console.log(chalk25.green("License Checker"));
|
|
1682
1919
|
return (await Promise.all(
|
|
1683
1920
|
workspaceList.map(({ location, name }) => {
|
|
1684
1921
|
return new Promise((resolve) => {
|
|
1685
1922
|
init({ production: true, start: location }, (error, packages) => {
|
|
1686
1923
|
if (error) {
|
|
1687
|
-
console.error(
|
|
1688
|
-
console.error(
|
|
1924
|
+
console.error(chalk25.red(`License Checker [${name}] Error`));
|
|
1925
|
+
console.error(chalk25.gray(error));
|
|
1689
1926
|
console.log("\n");
|
|
1690
1927
|
resolve(1);
|
|
1691
1928
|
} else {
|
|
1692
|
-
console.log(
|
|
1929
|
+
console.log(chalk25.green(`License Checker [${name}]`));
|
|
1693
1930
|
let count = 0;
|
|
1694
1931
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1695
1932
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1705,7 +1942,7 @@ var license = async (pkg) => {
|
|
|
1705
1942
|
}
|
|
1706
1943
|
if (!orLicenseFound) {
|
|
1707
1944
|
count++;
|
|
1708
|
-
console.warn(
|
|
1945
|
+
console.warn(chalk25.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1709
1946
|
}
|
|
1710
1947
|
}
|
|
1711
1948
|
}
|
|
@@ -1724,13 +1961,13 @@ var filename2 = ".npmignore";
|
|
|
1724
1961
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1725
1962
|
|
|
1726
1963
|
// src/actions/package/clean-outputs.ts
|
|
1727
|
-
import
|
|
1728
|
-
import
|
|
1964
|
+
import path8 from "path";
|
|
1965
|
+
import chalk26 from "chalk";
|
|
1729
1966
|
var packageCleanOutputs = () => {
|
|
1730
1967
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1731
1968
|
const pkgName = process.env.npm_package_name;
|
|
1732
|
-
const folders = [
|
|
1733
|
-
console.log(
|
|
1969
|
+
const folders = [path8.join(pkg, "dist"), path8.join(pkg, "build"), path8.join(pkg, "docs")];
|
|
1970
|
+
console.log(chalk26.green(`Cleaning Outputs [${pkgName}]`));
|
|
1734
1971
|
for (let folder of folders) {
|
|
1735
1972
|
deleteGlob(folder);
|
|
1736
1973
|
}
|
|
@@ -1738,13 +1975,13 @@ var packageCleanOutputs = () => {
|
|
|
1738
1975
|
};
|
|
1739
1976
|
|
|
1740
1977
|
// src/actions/package/clean-typescript.ts
|
|
1741
|
-
import
|
|
1742
|
-
import
|
|
1978
|
+
import path9 from "path";
|
|
1979
|
+
import chalk27 from "chalk";
|
|
1743
1980
|
var packageCleanTypescript = () => {
|
|
1744
1981
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1745
1982
|
const pkgName = process.env.npm_package_name;
|
|
1746
|
-
console.log(
|
|
1747
|
-
const files = [
|
|
1983
|
+
console.log(chalk27.green(`Cleaning Typescript [${pkgName}]`));
|
|
1984
|
+
const files = [path9.join(pkg, "*.tsbuildinfo"), path9.join(pkg, ".tsconfig.*"), path9.join(pkg, ".eslintcache")];
|
|
1748
1985
|
for (let file of files) {
|
|
1749
1986
|
deleteGlob(file);
|
|
1750
1987
|
}
|
|
@@ -1757,26 +1994,26 @@ var packageClean = async () => {
|
|
|
1757
1994
|
};
|
|
1758
1995
|
|
|
1759
1996
|
// src/actions/package/compile/compile.ts
|
|
1760
|
-
import
|
|
1997
|
+
import chalk32 from "chalk";
|
|
1761
1998
|
|
|
1762
1999
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1763
|
-
import
|
|
2000
|
+
import chalk31 from "chalk";
|
|
1764
2001
|
import { build as build2, defineConfig } from "tsup";
|
|
1765
2002
|
|
|
1766
2003
|
// src/actions/package/compile/inputs.ts
|
|
1767
|
-
import
|
|
2004
|
+
import chalk28 from "chalk";
|
|
1768
2005
|
import { glob as glob2 } from "glob";
|
|
1769
2006
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1770
2007
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1771
2008
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1772
2009
|
if (verbose) {
|
|
1773
|
-
console.log(
|
|
2010
|
+
console.log(chalk28.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1774
2011
|
}
|
|
1775
2012
|
return result;
|
|
1776
2013
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1777
2014
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1778
2015
|
if (verbose) {
|
|
1779
|
-
console.log(
|
|
2016
|
+
console.log(chalk28.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1780
2017
|
}
|
|
1781
2018
|
return result;
|
|
1782
2019
|
})];
|
|
@@ -1835,9 +2072,9 @@ function deepMergeObjects(objects) {
|
|
|
1835
2072
|
|
|
1836
2073
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1837
2074
|
import { cwd as cwd2 } from "process";
|
|
1838
|
-
import
|
|
2075
|
+
import chalk29 from "chalk";
|
|
1839
2076
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1840
|
-
import
|
|
2077
|
+
import ts3, {
|
|
1841
2078
|
DiagnosticCategory,
|
|
1842
2079
|
formatDiagnosticsWithColorAndContext,
|
|
1843
2080
|
getPreEmitDiagnostics,
|
|
@@ -1857,12 +2094,12 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
1857
2094
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
1858
2095
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1859
2096
|
if (verbose) {
|
|
1860
|
-
console.log(
|
|
2097
|
+
console.log(chalk29.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1861
2098
|
}
|
|
1862
|
-
const configFilePath =
|
|
2099
|
+
const configFilePath = ts3.findConfigFile(
|
|
1863
2100
|
"./",
|
|
1864
2101
|
// search path
|
|
1865
|
-
|
|
2102
|
+
ts3.sys.fileExists,
|
|
1866
2103
|
"tsconfig.json"
|
|
1867
2104
|
);
|
|
1868
2105
|
if (configFilePath === void 0) {
|
|
@@ -1880,10 +2117,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1880
2117
|
emitDeclarationOnly: true,
|
|
1881
2118
|
noEmit: false
|
|
1882
2119
|
};
|
|
1883
|
-
console.log(
|
|
2120
|
+
console.log(chalk29.cyan(`Validating Files: ${entries.length}`));
|
|
1884
2121
|
if (verbose) {
|
|
1885
2122
|
for (const entry of entries) {
|
|
1886
|
-
console.log(
|
|
2123
|
+
console.log(chalk29.grey(`Validating: ${entry}`));
|
|
1887
2124
|
}
|
|
1888
2125
|
}
|
|
1889
2126
|
try {
|
|
@@ -1912,29 +2149,29 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1912
2149
|
if (nonEmitPatterns.some((pattern) => fileName.includes(pattern))) {
|
|
1913
2150
|
return;
|
|
1914
2151
|
}
|
|
1915
|
-
|
|
2152
|
+
ts3.sys.writeFile(fileName, text, writeByteOrderMark);
|
|
1916
2153
|
});
|
|
1917
2154
|
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1918
2155
|
}
|
|
1919
2156
|
return 0;
|
|
1920
2157
|
} finally {
|
|
1921
2158
|
if (verbose) {
|
|
1922
|
-
console.log(
|
|
2159
|
+
console.log(chalk29.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1923
2160
|
}
|
|
1924
2161
|
}
|
|
1925
2162
|
};
|
|
1926
2163
|
|
|
1927
2164
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1928
|
-
import
|
|
2165
|
+
import path10 from "path";
|
|
1929
2166
|
import { cwd as cwd3 } from "process";
|
|
1930
|
-
import
|
|
2167
|
+
import chalk30 from "chalk";
|
|
1931
2168
|
import { rollup } from "rollup";
|
|
1932
2169
|
import dts from "rollup-plugin-dts";
|
|
1933
2170
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
1934
2171
|
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
1935
2172
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
1936
2173
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1937
|
-
const tsconfigPath =
|
|
2174
|
+
const tsconfigPath = path10.resolve(pkg, "tsconfig.json");
|
|
1938
2175
|
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
1939
2176
|
try {
|
|
1940
2177
|
const bundle = await rollup({
|
|
@@ -1952,8 +2189,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1952
2189
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
1953
2190
|
return;
|
|
1954
2191
|
}
|
|
1955
|
-
console.warn(
|
|
1956
|
-
console.warn(
|
|
2192
|
+
console.warn(chalk30.yellow(`[${warning.code}] ${warning.message}`));
|
|
2193
|
+
console.warn(chalk30.gray(inputPath));
|
|
1957
2194
|
warn(warning);
|
|
1958
2195
|
}
|
|
1959
2196
|
});
|
|
@@ -1963,8 +2200,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1963
2200
|
});
|
|
1964
2201
|
} catch (ex) {
|
|
1965
2202
|
const error = ex;
|
|
1966
|
-
console.warn(
|
|
1967
|
-
console.warn(
|
|
2203
|
+
console.warn(chalk30.red(error));
|
|
2204
|
+
console.warn(chalk30.gray(inputPath));
|
|
1968
2205
|
}
|
|
1969
2206
|
if (verbose) {
|
|
1970
2207
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -1972,7 +2209,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1972
2209
|
}
|
|
1973
2210
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
1974
2211
|
if (verbose) {
|
|
1975
|
-
console.log(
|
|
2212
|
+
console.log(chalk30.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1976
2213
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
1977
2214
|
}
|
|
1978
2215
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -1996,7 +2233,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
1996
2233
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
1997
2234
|
}));
|
|
1998
2235
|
if (verbose) {
|
|
1999
|
-
console.log(
|
|
2236
|
+
console.log(chalk30.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
2000
2237
|
}
|
|
2001
2238
|
return 0;
|
|
2002
2239
|
};
|
|
@@ -2008,15 +2245,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2008
2245
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
2009
2246
|
}
|
|
2010
2247
|
if (entries.length === 0) {
|
|
2011
|
-
console.warn(
|
|
2248
|
+
console.warn(chalk31.yellow(`No entries found in ${srcDir} to compile`));
|
|
2012
2249
|
return 0;
|
|
2013
2250
|
}
|
|
2014
2251
|
if (verbose) {
|
|
2015
|
-
console.log(
|
|
2252
|
+
console.log(chalk31.gray(`buildDir [${buildDir}]`));
|
|
2016
2253
|
}
|
|
2017
2254
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
2018
2255
|
if (validationResult !== 0) {
|
|
2019
|
-
console.error(
|
|
2256
|
+
console.error(chalk31.red(`Compile:Validation had ${validationResult} errors`));
|
|
2020
2257
|
return validationResult;
|
|
2021
2258
|
}
|
|
2022
2259
|
const optionsParams = tsupOptions([{
|
|
@@ -2041,12 +2278,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
2041
2278
|
})
|
|
2042
2279
|
)).flat();
|
|
2043
2280
|
if (verbose) {
|
|
2044
|
-
console.log(
|
|
2045
|
-
console.log(
|
|
2281
|
+
console.log(chalk31.cyan(`TSUP:build:start [${srcDir}]`));
|
|
2282
|
+
console.log(chalk31.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
2046
2283
|
}
|
|
2047
2284
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
2048
2285
|
if (verbose) {
|
|
2049
|
-
console.log(
|
|
2286
|
+
console.log(chalk31.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
2050
2287
|
}
|
|
2051
2288
|
if (bundleTypes) {
|
|
2052
2289
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -2157,14 +2394,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
2157
2394
|
// src/actions/package/compile/compile.ts
|
|
2158
2395
|
var packageCompile = async (inConfig = {}) => {
|
|
2159
2396
|
const pkg = process.env.INIT_CWD;
|
|
2160
|
-
console.log(
|
|
2397
|
+
console.log(chalk32.green(`Compiling ${pkg}`));
|
|
2161
2398
|
const config2 = await loadConfig(inConfig);
|
|
2162
2399
|
return await packageCompileTsup(config2);
|
|
2163
2400
|
};
|
|
2164
2401
|
|
|
2165
2402
|
// src/actions/package/copy-assets.ts
|
|
2166
|
-
import
|
|
2167
|
-
import
|
|
2403
|
+
import path11 from "path/posix";
|
|
2404
|
+
import chalk33 from "chalk";
|
|
2168
2405
|
import cpy2 from "cpy";
|
|
2169
2406
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
2170
2407
|
try {
|
|
@@ -2172,12 +2409,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
2172
2409
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
2173
2410
|
`../dist/${target}`,
|
|
2174
2411
|
{
|
|
2175
|
-
cwd:
|
|
2412
|
+
cwd: path11.join(location, "src"),
|
|
2176
2413
|
flat: false
|
|
2177
2414
|
}
|
|
2178
2415
|
);
|
|
2179
2416
|
if (values.length > 0) {
|
|
2180
|
-
console.log(
|
|
2417
|
+
console.log(chalk33.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
2181
2418
|
}
|
|
2182
2419
|
for (const value of values) {
|
|
2183
2420
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -2243,8 +2480,8 @@ var packageCycle = async () => {
|
|
|
2243
2480
|
|
|
2244
2481
|
// src/actions/package/gen-docs.ts
|
|
2245
2482
|
import { existsSync as existsSync6 } from "fs";
|
|
2246
|
-
import
|
|
2247
|
-
import
|
|
2483
|
+
import path12 from "path";
|
|
2484
|
+
import chalk34 from "chalk";
|
|
2248
2485
|
import {
|
|
2249
2486
|
Application,
|
|
2250
2487
|
ArgumentsReader,
|
|
@@ -2262,7 +2499,7 @@ var ExitCodes = {
|
|
|
2262
2499
|
};
|
|
2263
2500
|
var packageGenDocs = async () => {
|
|
2264
2501
|
const pkg = process.env.INIT_CWD;
|
|
2265
|
-
if (pkg !== void 0 && !existsSync6(
|
|
2502
|
+
if (pkg !== void 0 && !existsSync6(path12.join(pkg, "typedoc.json"))) {
|
|
2266
2503
|
return;
|
|
2267
2504
|
}
|
|
2268
2505
|
const app = await Application.bootstrap({
|
|
@@ -2348,16 +2585,16 @@ var runTypeDoc = async (app) => {
|
|
|
2348
2585
|
return ExitCodes.OutputError;
|
|
2349
2586
|
}
|
|
2350
2587
|
}
|
|
2351
|
-
console.log(
|
|
2588
|
+
console.log(chalk34.green(`${pkgName} - Ok`));
|
|
2352
2589
|
return ExitCodes.Ok;
|
|
2353
2590
|
};
|
|
2354
2591
|
|
|
2355
2592
|
// src/actions/package/lint.ts
|
|
2356
2593
|
import { readdirSync as readdirSync4 } from "fs";
|
|
2357
|
-
import
|
|
2594
|
+
import path13 from "path";
|
|
2358
2595
|
import { cwd as cwd4 } from "process";
|
|
2359
2596
|
import { pathToFileURL } from "url";
|
|
2360
|
-
import
|
|
2597
|
+
import chalk35 from "chalk";
|
|
2361
2598
|
import { ESLint } from "eslint";
|
|
2362
2599
|
import { findUp } from "find-up";
|
|
2363
2600
|
import picomatch from "picomatch";
|
|
@@ -2366,14 +2603,14 @@ var dumpMessages = (lintResults) => {
|
|
|
2366
2603
|
const severity = ["none", "warning", "error"];
|
|
2367
2604
|
for (const lintResult of lintResults) {
|
|
2368
2605
|
if (lintResult.messages.length > 0) {
|
|
2369
|
-
console.log(
|
|
2606
|
+
console.log(chalk35.gray(`
|
|
2370
2607
|
${lintResult.filePath}`));
|
|
2371
2608
|
for (const message of lintResult.messages) {
|
|
2372
2609
|
console.log(
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2610
|
+
chalk35.gray(` ${message.line}:${message.column}`),
|
|
2611
|
+
chalk35[colors[message.severity]](` ${severity[message.severity]}`),
|
|
2612
|
+
chalk35.white(` ${message.message}`),
|
|
2613
|
+
chalk35.gray(` ${message.ruleId}`)
|
|
2377
2614
|
);
|
|
2378
2615
|
}
|
|
2379
2616
|
}
|
|
@@ -2391,7 +2628,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
2391
2628
|
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
2392
2629
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2393
2630
|
return readdirSync4(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2394
|
-
const res =
|
|
2631
|
+
const res = path13.resolve(dir, dirent.name);
|
|
2395
2632
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2396
2633
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2397
2634
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2411,10 +2648,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2411
2648
|
cache
|
|
2412
2649
|
});
|
|
2413
2650
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
2414
|
-
console.log(
|
|
2651
|
+
console.log(chalk35.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2415
2652
|
if (verbose) {
|
|
2416
2653
|
for (const file of files) {
|
|
2417
|
-
console.log(
|
|
2654
|
+
console.log(chalk35.gray(` ${file}`));
|
|
2418
2655
|
}
|
|
2419
2656
|
}
|
|
2420
2657
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -2425,43 +2662,43 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2425
2662
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2426
2663
|
const lintTime = Date.now() - start;
|
|
2427
2664
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2428
|
-
console.log(
|
|
2665
|
+
console.log(chalk35.white(`Linted ${chalk35[filesCountColor](files.length)} files in ${chalk35[lintTimeColor](lintTime)}ms`));
|
|
2429
2666
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2430
2667
|
};
|
|
2431
2668
|
|
|
2432
2669
|
// src/actions/package/publint.ts
|
|
2433
|
-
import { promises as
|
|
2434
|
-
import
|
|
2670
|
+
import { promises as fs10 } from "fs";
|
|
2671
|
+
import chalk36 from "chalk";
|
|
2435
2672
|
import sortPackageJson from "sort-package-json";
|
|
2436
2673
|
var customPubLint = (pkg) => {
|
|
2437
2674
|
let errorCount = 0;
|
|
2438
2675
|
let warningCount = 0;
|
|
2439
2676
|
if (pkg.files === void 0) {
|
|
2440
|
-
console.warn(
|
|
2677
|
+
console.warn(chalk36.yellow('Publint [custom]: "files" field is missing'));
|
|
2441
2678
|
warningCount++;
|
|
2442
2679
|
}
|
|
2443
2680
|
if (pkg.main !== void 0) {
|
|
2444
|
-
console.warn(
|
|
2681
|
+
console.warn(chalk36.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
2445
2682
|
warningCount++;
|
|
2446
2683
|
}
|
|
2447
2684
|
if (pkg.sideEffects !== false) {
|
|
2448
|
-
console.warn(
|
|
2685
|
+
console.warn(chalk36.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
2449
2686
|
warningCount++;
|
|
2450
2687
|
}
|
|
2451
2688
|
if (pkg.resolutions !== void 0) {
|
|
2452
|
-
console.warn(
|
|
2453
|
-
console.warn(
|
|
2689
|
+
console.warn(chalk36.yellow('Publint [custom]: "resolutions" in use'));
|
|
2690
|
+
console.warn(chalk36.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
2454
2691
|
warningCount++;
|
|
2455
2692
|
}
|
|
2456
2693
|
return [errorCount, warningCount];
|
|
2457
2694
|
};
|
|
2458
2695
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2459
2696
|
const pkgDir = process.env.INIT_CWD;
|
|
2460
|
-
const sortedPkg = sortPackageJson(await
|
|
2461
|
-
await
|
|
2462
|
-
const pkg = JSON.parse(await
|
|
2463
|
-
console.log(
|
|
2464
|
-
console.log(
|
|
2697
|
+
const sortedPkg = sortPackageJson(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2698
|
+
await fs10.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2699
|
+
const pkg = JSON.parse(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2700
|
+
console.log(chalk36.green(`Publint: ${pkg.name}`));
|
|
2701
|
+
console.log(chalk36.gray(pkgDir));
|
|
2465
2702
|
const { publint: publint2 } = await import("publint");
|
|
2466
2703
|
const { messages } = await publint2({
|
|
2467
2704
|
level: "suggestion",
|
|
@@ -2472,22 +2709,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2472
2709
|
for (const message of messages) {
|
|
2473
2710
|
switch (message.type) {
|
|
2474
2711
|
case "error": {
|
|
2475
|
-
console.error(
|
|
2712
|
+
console.error(chalk36.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2476
2713
|
break;
|
|
2477
2714
|
}
|
|
2478
2715
|
case "warning": {
|
|
2479
|
-
console.warn(
|
|
2716
|
+
console.warn(chalk36.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2480
2717
|
break;
|
|
2481
2718
|
}
|
|
2482
2719
|
default: {
|
|
2483
|
-
console.log(
|
|
2720
|
+
console.log(chalk36.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2484
2721
|
break;
|
|
2485
2722
|
}
|
|
2486
2723
|
}
|
|
2487
2724
|
}
|
|
2488
2725
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
2489
2726
|
if (verbose) {
|
|
2490
|
-
console.log(
|
|
2727
|
+
console.log(chalk36.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
2491
2728
|
}
|
|
2492
2729
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
2493
2730
|
};
|
|
@@ -2514,6 +2751,21 @@ var publish = () => {
|
|
|
2514
2751
|
return runSteps("Publish", [["npm", ["publish", "--workspaces"]]]);
|
|
2515
2752
|
};
|
|
2516
2753
|
|
|
2754
|
+
// src/actions/readme-gen.ts
|
|
2755
|
+
async function readmeGen({
|
|
2756
|
+
pkg,
|
|
2757
|
+
templatePath,
|
|
2758
|
+
typedoc,
|
|
2759
|
+
verbose
|
|
2760
|
+
}) {
|
|
2761
|
+
return await generateReadmeFiles({
|
|
2762
|
+
pkg,
|
|
2763
|
+
templatePath,
|
|
2764
|
+
typedoc,
|
|
2765
|
+
verbose
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2517
2769
|
// src/actions/rebuild.ts
|
|
2518
2770
|
var rebuild = ({ target }) => {
|
|
2519
2771
|
return runSteps("Rebuild", [
|
|
@@ -2523,7 +2775,7 @@ var rebuild = ({ target }) => {
|
|
|
2523
2775
|
};
|
|
2524
2776
|
|
|
2525
2777
|
// src/actions/recompile.ts
|
|
2526
|
-
import
|
|
2778
|
+
import chalk37 from "chalk";
|
|
2527
2779
|
var recompile = async ({
|
|
2528
2780
|
verbose,
|
|
2529
2781
|
target,
|
|
@@ -2559,7 +2811,7 @@ var recompileAll = async ({
|
|
|
2559
2811
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2560
2812
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2561
2813
|
if (jobs) {
|
|
2562
|
-
console.log(
|
|
2814
|
+
console.log(chalk37.blue(`Jobs set to [${jobs}]`));
|
|
2563
2815
|
}
|
|
2564
2816
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2565
2817
|
[
|
|
@@ -2590,7 +2842,7 @@ var recompileAll = async ({
|
|
|
2590
2842
|
]
|
|
2591
2843
|
]);
|
|
2592
2844
|
console.log(
|
|
2593
|
-
`${
|
|
2845
|
+
`${chalk37.gray("Recompiled in")} [${chalk37.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk37.gray("seconds")}`
|
|
2594
2846
|
);
|
|
2595
2847
|
return result;
|
|
2596
2848
|
};
|
|
@@ -2621,13 +2873,13 @@ var reinstall = () => {
|
|
|
2621
2873
|
};
|
|
2622
2874
|
|
|
2623
2875
|
// src/actions/relint.ts
|
|
2624
|
-
import
|
|
2876
|
+
import chalk38 from "chalk";
|
|
2625
2877
|
var relintPackage = ({
|
|
2626
2878
|
pkg,
|
|
2627
2879
|
fix: fix2,
|
|
2628
2880
|
verbose
|
|
2629
2881
|
}) => {
|
|
2630
|
-
console.log(
|
|
2882
|
+
console.log(chalk38.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2631
2883
|
const start = Date.now();
|
|
2632
2884
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2633
2885
|
["yarn", [
|
|
@@ -2637,7 +2889,7 @@ var relintPackage = ({
|
|
|
2637
2889
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2638
2890
|
]]
|
|
2639
2891
|
]);
|
|
2640
|
-
console.log(
|
|
2892
|
+
console.log(chalk38.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk38.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk38.gray("seconds")}`));
|
|
2641
2893
|
return result;
|
|
2642
2894
|
};
|
|
2643
2895
|
var relint = ({
|
|
@@ -2657,13 +2909,13 @@ var relint = ({
|
|
|
2657
2909
|
});
|
|
2658
2910
|
};
|
|
2659
2911
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2660
|
-
console.log(
|
|
2912
|
+
console.log(chalk38.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2661
2913
|
const start = Date.now();
|
|
2662
2914
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2663
2915
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2664
2916
|
["yarn", ["eslint", ...fixOptions]]
|
|
2665
2917
|
]);
|
|
2666
|
-
console.log(
|
|
2918
|
+
console.log(chalk38.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk38.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk38.gray("seconds")}`));
|
|
2667
2919
|
return result;
|
|
2668
2920
|
};
|
|
2669
2921
|
|
|
@@ -2681,10 +2933,10 @@ var sonar = () => {
|
|
|
2681
2933
|
};
|
|
2682
2934
|
|
|
2683
2935
|
// src/actions/statics.ts
|
|
2684
|
-
import
|
|
2936
|
+
import chalk39 from "chalk";
|
|
2685
2937
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2686
2938
|
var statics = () => {
|
|
2687
|
-
console.log(
|
|
2939
|
+
console.log(chalk39.green("Check Required Static Dependencies"));
|
|
2688
2940
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2689
2941
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2690
2942
|
};
|
|
@@ -2784,6 +3036,7 @@ export {
|
|
|
2784
3036
|
publintAll,
|
|
2785
3037
|
publintPackage,
|
|
2786
3038
|
publish,
|
|
3039
|
+
readmeGen,
|
|
2787
3040
|
rebuild,
|
|
2788
3041
|
recompile,
|
|
2789
3042
|
recompileAll,
|