@xylabs/ts-scripts-yarn3 7.4.4 → 7.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/claude-rules.mjs +113 -0
- package/dist/actions/claude-rules.mjs.map +1 -0
- package/dist/actions/index.mjs +232 -129
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +201 -84
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +266 -145
- package/dist/index.mjs.map +1 -1
- package/dist/lib/claudeMdTemplate.mjs +24 -0
- package/dist/lib/claudeMdTemplate.mjs.map +1 -0
- package/dist/lib/index.mjs +31 -9
- package/dist/lib/index.mjs.map +1 -1
- package/dist/xy/index.mjs +201 -84
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +201 -84
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyCommonCommands.mjs +137 -20
- package/dist/xy/xyCommonCommands.mjs.map +1 -1
- package/package.json +4 -3
- package/templates/CLAUDE-project.md +4 -0
- package/templates/rules/xylabs-architecture.md +11 -0
- package/templates/rules/xylabs-build.md +14 -0
- package/templates/rules/xylabs-dependencies.md +24 -0
- package/templates/rules/xylabs-error-handling.md +7 -0
- package/templates/rules/xylabs-frameworks.md +8 -0
- package/templates/rules/xylabs-git-workflow.md +9 -0
- package/templates/rules/xylabs-linting.md +55 -0
- package/templates/rules/xylabs-naming.md +10 -0
- package/templates/rules/xylabs-style.md +22 -0
- package/templates/rules/xylabs-typescript.md +11 -0
package/dist/actions/index.mjs
CHANGED
|
@@ -14,6 +14,25 @@ var checkResult = (name, result, level = "error", exitOnFail = false) => {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/lib/claudeMdTemplate.ts
|
|
18
|
+
import { readdirSync, readFileSync } from "fs";
|
|
19
|
+
import { createRequire } from "module";
|
|
20
|
+
import PATH from "path";
|
|
21
|
+
var require2 = createRequire(import.meta.url);
|
|
22
|
+
var packageRoot = PATH.dirname(require2.resolve("@xylabs/ts-scripts-yarn3/package.json"));
|
|
23
|
+
var templatesDir = PATH.resolve(packageRoot, "templates");
|
|
24
|
+
var XYLABS_RULES_PREFIX = "xylabs-";
|
|
25
|
+
var claudeMdRuleTemplates = () => {
|
|
26
|
+
const rulesDir = PATH.resolve(templatesDir, "rules");
|
|
27
|
+
const files = readdirSync(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
result[file] = readFileSync(PATH.resolve(rulesDir, file), "utf8");
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
var claudeMdProjectTemplate = () => readFileSync(PATH.resolve(templatesDir, "CLAUDE-project.md"), "utf8");
|
|
35
|
+
|
|
17
36
|
// src/lib/deleteGlob.ts
|
|
18
37
|
import fs from "fs";
|
|
19
38
|
import { glob } from "glob";
|
|
@@ -203,7 +222,7 @@ var CROSS_PLATFORM_NEWLINE = "\n";
|
|
|
203
222
|
// src/lib/file/fileLines.ts
|
|
204
223
|
import {
|
|
205
224
|
existsSync,
|
|
206
|
-
readFileSync,
|
|
225
|
+
readFileSync as readFileSync2,
|
|
207
226
|
writeFileSync
|
|
208
227
|
} from "fs";
|
|
209
228
|
|
|
@@ -218,10 +237,10 @@ var union = (a, b) => /* @__PURE__ */ new Set([...new Set(a), ...new Set(b)]);
|
|
|
218
237
|
var defaultReadFileSyncOptions = { encoding: "utf8" };
|
|
219
238
|
|
|
220
239
|
// src/lib/file/fileLines.ts
|
|
221
|
-
var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync(uri) ?
|
|
240
|
+
var readLines = (uri, options = defaultReadFileSyncOptions) => existsSync(uri) ? readFileSync2(uri, options).replace(WINDOWS_NEWLINE_REGEX, CROSS_PLATFORM_NEWLINE).split(CROSS_PLATFORM_NEWLINE) : [];
|
|
222
241
|
var readNonEmptyLines = (uri, options = defaultReadFileSyncOptions) => readLines(uri, options).filter(notEmpty);
|
|
223
242
|
var writeLines = (uri, lines, options = defaultReadFileSyncOptions) => {
|
|
224
|
-
const existing = existsSync(uri) ?
|
|
243
|
+
const existing = existsSync(uri) ? readFileSync2(uri, options) : void 0;
|
|
225
244
|
const desired = lines.join(CROSS_PLATFORM_NEWLINE);
|
|
226
245
|
if (existing !== desired) writeFileSync(uri, desired, options);
|
|
227
246
|
};
|
|
@@ -314,10 +333,10 @@ var loadConfig = async (params) => {
|
|
|
314
333
|
};
|
|
315
334
|
|
|
316
335
|
// src/lib/parsedPackageJSON.ts
|
|
317
|
-
import { readFileSync as
|
|
336
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
318
337
|
var parsedPackageJSON = (path13) => {
|
|
319
338
|
const pathToPackageJSON = path13 ?? process.env.npm_package_json ?? "";
|
|
320
|
-
const packageJSON =
|
|
339
|
+
const packageJSON = readFileSync3(pathToPackageJSON).toString();
|
|
321
340
|
return JSON.parse(packageJSON);
|
|
322
341
|
};
|
|
323
342
|
|
|
@@ -427,6 +446,89 @@ var build = async ({
|
|
|
427
446
|
return result;
|
|
428
447
|
};
|
|
429
448
|
|
|
449
|
+
// src/actions/claude-rules.ts
|
|
450
|
+
import {
|
|
451
|
+
existsSync as existsSync4,
|
|
452
|
+
mkdirSync,
|
|
453
|
+
readdirSync as readdirSync2,
|
|
454
|
+
readFileSync as readFileSync4,
|
|
455
|
+
unlinkSync,
|
|
456
|
+
writeFileSync as writeFileSync2
|
|
457
|
+
} from "fs";
|
|
458
|
+
import PATH2 from "path";
|
|
459
|
+
import chalk9 from "chalk";
|
|
460
|
+
var syncRuleFiles = (rulesDir) => {
|
|
461
|
+
const templates = claudeMdRuleTemplates();
|
|
462
|
+
const templateNames = new Set(Object.keys(templates));
|
|
463
|
+
let updated = 0;
|
|
464
|
+
let created = 0;
|
|
465
|
+
for (const [filename3, content] of Object.entries(templates)) {
|
|
466
|
+
const targetPath = PATH2.resolve(rulesDir, filename3);
|
|
467
|
+
const existing = existsSync4(targetPath) ? readFileSync4(targetPath, "utf8") : void 0;
|
|
468
|
+
if (existing === content) continue;
|
|
469
|
+
writeFileSync2(targetPath, content, "utf8");
|
|
470
|
+
if (existing) {
|
|
471
|
+
updated++;
|
|
472
|
+
} else {
|
|
473
|
+
created++;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return {
|
|
477
|
+
created,
|
|
478
|
+
templateNames,
|
|
479
|
+
updated
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
var removeStaleRules = (rulesDir, templateNames) => {
|
|
483
|
+
const existingRules = readdirSync2(rulesDir).filter((f) => f.startsWith(XYLABS_RULES_PREFIX) && f.endsWith(".md"));
|
|
484
|
+
let removed = 0;
|
|
485
|
+
for (const file of existingRules) {
|
|
486
|
+
if (!templateNames.has(file)) {
|
|
487
|
+
unlinkSync(PATH2.resolve(rulesDir, file));
|
|
488
|
+
removed++;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return removed;
|
|
492
|
+
};
|
|
493
|
+
var logRulesResult = (created, updated, removed) => {
|
|
494
|
+
if (created || updated || removed) {
|
|
495
|
+
const parts = [
|
|
496
|
+
created ? `${created} created` : "",
|
|
497
|
+
updated ? `${updated} updated` : "",
|
|
498
|
+
removed ? `${removed} removed` : ""
|
|
499
|
+
].filter(Boolean);
|
|
500
|
+
console.log(chalk9.green(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: ${parts.join(", ")}`));
|
|
501
|
+
} else {
|
|
502
|
+
console.log(chalk9.gray(`.claude/rules/${XYLABS_RULES_PREFIX}*.md: already up to date`));
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
var ensureProjectClaudeMd = (cwd5, force) => {
|
|
506
|
+
const projectPath = PATH2.resolve(cwd5, "CLAUDE.md");
|
|
507
|
+
if (!existsSync4(projectPath) || force) {
|
|
508
|
+
if (force && existsSync4(projectPath)) {
|
|
509
|
+
console.log(chalk9.yellow("Overwriting existing CLAUDE.md"));
|
|
510
|
+
}
|
|
511
|
+
writeFileSync2(projectPath, claudeMdProjectTemplate(), "utf8");
|
|
512
|
+
console.log(chalk9.green("Generated CLAUDE.md"));
|
|
513
|
+
} else {
|
|
514
|
+
console.log(chalk9.gray("CLAUDE.md already exists (skipped)"));
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
var claudeRules = ({ force } = {}) => {
|
|
518
|
+
const cwd5 = INIT_CWD() ?? process.cwd();
|
|
519
|
+
const rulesDir = PATH2.resolve(cwd5, ".claude", "rules");
|
|
520
|
+
mkdirSync(rulesDir, { recursive: true });
|
|
521
|
+
const {
|
|
522
|
+
created,
|
|
523
|
+
templateNames,
|
|
524
|
+
updated
|
|
525
|
+
} = syncRuleFiles(rulesDir);
|
|
526
|
+
const removed = removeStaleRules(rulesDir, templateNames);
|
|
527
|
+
logRulesResult(created, updated, removed);
|
|
528
|
+
ensureProjectClaudeMd(cwd5, force);
|
|
529
|
+
return 0;
|
|
530
|
+
};
|
|
531
|
+
|
|
430
532
|
// src/actions/clean.ts
|
|
431
533
|
var clean = async ({ verbose, pkg }) => {
|
|
432
534
|
return pkg ? await cleanPackage({ pkg, verbose }) : cleanAll({ verbose });
|
|
@@ -441,16 +543,16 @@ var cleanAll = ({ verbose }) => {
|
|
|
441
543
|
|
|
442
544
|
// src/actions/clean-docs.ts
|
|
443
545
|
import path from "path";
|
|
444
|
-
import
|
|
546
|
+
import chalk10 from "chalk";
|
|
445
547
|
var cleanDocs = () => {
|
|
446
548
|
const pkgName = process.env.npm_package_name;
|
|
447
|
-
console.log(
|
|
549
|
+
console.log(chalk10.green(`Cleaning Docs [${pkgName}]`));
|
|
448
550
|
for (const { location } of yarnWorkspaces()) deleteGlob(path.join(location, "docs"));
|
|
449
551
|
return 0;
|
|
450
552
|
};
|
|
451
553
|
|
|
452
554
|
// src/actions/compile.ts
|
|
453
|
-
import
|
|
555
|
+
import chalk11 from "chalk";
|
|
454
556
|
var compile = ({
|
|
455
557
|
verbose,
|
|
456
558
|
target,
|
|
@@ -491,7 +593,7 @@ var compileAll = ({
|
|
|
491
593
|
const incrementalOptions = incremental ? ["--since", "-Ap", "--topological-dev"] : ["--parallel", "-Ap", "--topological-dev"];
|
|
492
594
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
493
595
|
if (jobs) {
|
|
494
|
-
console.log(
|
|
596
|
+
console.log(chalk11.blue(`Jobs set to [${jobs}]`));
|
|
495
597
|
}
|
|
496
598
|
const result = runSteps(`Compile${incremental ? "-Incremental" : ""} [All]`, [
|
|
497
599
|
["yarn", [
|
|
@@ -505,13 +607,13 @@ var compileAll = ({
|
|
|
505
607
|
...targetOptions
|
|
506
608
|
]]
|
|
507
609
|
]);
|
|
508
|
-
console.log(`${
|
|
610
|
+
console.log(`${chalk11.gray("Compiled in")} [${chalk11.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk11.gray("seconds")}`);
|
|
509
611
|
return result;
|
|
510
612
|
};
|
|
511
613
|
|
|
512
614
|
// src/actions/copy-assets.ts
|
|
513
615
|
import path2 from "path/posix";
|
|
514
|
-
import
|
|
616
|
+
import chalk12 from "chalk";
|
|
515
617
|
import cpy from "cpy";
|
|
516
618
|
var copyPackageTargetAssets = async (target, name, location) => {
|
|
517
619
|
try {
|
|
@@ -534,7 +636,7 @@ var copyPackageTargetAssets = async (target, name, location) => {
|
|
|
534
636
|
};
|
|
535
637
|
var copyTargetAssets = async (target, pkg) => {
|
|
536
638
|
const workspaces = yarnWorkspaces();
|
|
537
|
-
console.log(
|
|
639
|
+
console.log(chalk12.green(`Copying Assets [${target.toUpperCase()}]`));
|
|
538
640
|
const workspaceList = workspaces.filter(({ name }) => {
|
|
539
641
|
return pkg === void 0 || name === pkg;
|
|
540
642
|
});
|
|
@@ -618,7 +720,7 @@ var dead = () => {
|
|
|
618
720
|
};
|
|
619
721
|
|
|
620
722
|
// src/actions/deplint/deplint.ts
|
|
621
|
-
import
|
|
723
|
+
import chalk18 from "chalk";
|
|
622
724
|
|
|
623
725
|
// src/actions/deplint/findFiles.ts
|
|
624
726
|
import fs2 from "fs";
|
|
@@ -819,12 +921,12 @@ function getExternalImportsFromFiles({
|
|
|
819
921
|
|
|
820
922
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
821
923
|
import { builtinModules } from "module";
|
|
822
|
-
import
|
|
924
|
+
import chalk13 from "chalk";
|
|
823
925
|
function isListedOrBuiltin(imp, name, dependencies, peerDependencies) {
|
|
824
926
|
return dependencies.includes(imp) || imp === name || dependencies.includes(`@types/${imp}`) || peerDependencies.includes(imp) || peerDependencies.includes(`@types/${imp}`) || builtinModules.includes(imp) || builtinModules.includes(`@types/${imp}`);
|
|
825
927
|
}
|
|
826
928
|
function logMissing(name, imp, importPaths) {
|
|
827
|
-
console.log(`[${
|
|
929
|
+
console.log(`[${chalk13.blue(name)}] Missing dependency in package.json: ${chalk13.red(imp)}`);
|
|
828
930
|
if (importPaths[imp]) {
|
|
829
931
|
console.log(` ${importPaths[imp].join("\n ")}`);
|
|
830
932
|
}
|
|
@@ -849,7 +951,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
849
951
|
}
|
|
850
952
|
if (unlistedDependencies > 0) {
|
|
851
953
|
const packageLocation = `${location}/package.json`;
|
|
852
|
-
console.log(` ${
|
|
954
|
+
console.log(` ${chalk13.yellow(packageLocation)}
|
|
853
955
|
`);
|
|
854
956
|
}
|
|
855
957
|
return unlistedDependencies;
|
|
@@ -857,7 +959,7 @@ function getUnlistedDependencies({ name, location }, { dependencies, peerDepende
|
|
|
857
959
|
|
|
858
960
|
// src/actions/deplint/checkPackage/getUnlistedDevDependencies.ts
|
|
859
961
|
import { builtinModules as builtinModules2 } from "module";
|
|
860
|
-
import
|
|
962
|
+
import chalk14 from "chalk";
|
|
861
963
|
function getUnlistedDevDependencies({ name, location }, {
|
|
862
964
|
devDependencies,
|
|
863
965
|
dependencies,
|
|
@@ -871,7 +973,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
871
973
|
for (const imp of externalAllImports) {
|
|
872
974
|
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)) {
|
|
873
975
|
unlistedDevDependencies++;
|
|
874
|
-
console.log(`[${
|
|
976
|
+
console.log(`[${chalk14.blue(name)}] Missing devDependency in package.json: ${chalk14.red(imp)}`);
|
|
875
977
|
if (allImportPaths[imp]) {
|
|
876
978
|
console.log(` ${allImportPaths[imp].join("\n ")}`);
|
|
877
979
|
}
|
|
@@ -879,14 +981,14 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
879
981
|
}
|
|
880
982
|
if (unlistedDevDependencies > 0) {
|
|
881
983
|
const packageLocation = `${location}/package.json`;
|
|
882
|
-
console.log(` ${
|
|
984
|
+
console.log(` ${chalk14.yellow(packageLocation)}
|
|
883
985
|
`);
|
|
884
986
|
}
|
|
885
987
|
return unlistedDevDependencies;
|
|
886
988
|
}
|
|
887
989
|
|
|
888
990
|
// src/actions/deplint/checkPackage/getUnusedDependencies.ts
|
|
889
|
-
import
|
|
991
|
+
import chalk15 from "chalk";
|
|
890
992
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
891
993
|
externalDistImports,
|
|
892
994
|
externalDistTypeImports,
|
|
@@ -897,22 +999,22 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
897
999
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
898
1000
|
unusedDependencies++;
|
|
899
1001
|
if (externalAllImports.includes(dep)) {
|
|
900
|
-
console.log(`[${
|
|
1002
|
+
console.log(`[${chalk15.blue(name)}] dependency should be devDependency in package.json: ${chalk15.red(dep)}`);
|
|
901
1003
|
} else {
|
|
902
|
-
console.log(`[${
|
|
1004
|
+
console.log(`[${chalk15.blue(name)}] Unused dependency in package.json: ${chalk15.red(dep)}`);
|
|
903
1005
|
}
|
|
904
1006
|
}
|
|
905
1007
|
}
|
|
906
1008
|
if (unusedDependencies > 0) {
|
|
907
1009
|
const packageLocation = `${location}/package.json`;
|
|
908
|
-
console.log(` ${
|
|
1010
|
+
console.log(` ${chalk15.yellow(packageLocation)}
|
|
909
1011
|
`);
|
|
910
1012
|
}
|
|
911
1013
|
return unusedDependencies;
|
|
912
1014
|
}
|
|
913
1015
|
|
|
914
1016
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
915
|
-
import
|
|
1017
|
+
import chalk16 from "chalk";
|
|
916
1018
|
|
|
917
1019
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
918
1020
|
import fs6 from "fs";
|
|
@@ -1095,34 +1197,34 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1095
1197
|
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1096
1198
|
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1097
1199
|
unusedDevDependencies++;
|
|
1098
|
-
console.log(`[${
|
|
1200
|
+
console.log(`[${chalk16.blue(name)}] Unused devDependency in package.json: ${chalk16.red(dep)}`);
|
|
1099
1201
|
}
|
|
1100
1202
|
}
|
|
1101
1203
|
if (unusedDevDependencies > 0) {
|
|
1102
1204
|
const packageLocation = `${location}/package.json`;
|
|
1103
|
-
console.log(` ${
|
|
1205
|
+
console.log(` ${chalk16.yellow(packageLocation)}
|
|
1104
1206
|
`);
|
|
1105
1207
|
}
|
|
1106
1208
|
return unusedDevDependencies;
|
|
1107
1209
|
}
|
|
1108
1210
|
|
|
1109
1211
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1110
|
-
import
|
|
1212
|
+
import chalk17 from "chalk";
|
|
1111
1213
|
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
1112
1214
|
let unusedDependencies = 0;
|
|
1113
1215
|
for (const dep of peerDependencies) {
|
|
1114
1216
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1115
1217
|
unusedDependencies++;
|
|
1116
1218
|
if (dependencies.includes(dep)) {
|
|
1117
|
-
console.log(`[${
|
|
1219
|
+
console.log(`[${chalk17.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk17.red(dep)}`);
|
|
1118
1220
|
} else {
|
|
1119
|
-
console.log(`[${
|
|
1221
|
+
console.log(`[${chalk17.blue(name)}] Unused peerDependency in package.json: ${chalk17.red(dep)}`);
|
|
1120
1222
|
}
|
|
1121
1223
|
}
|
|
1122
1224
|
}
|
|
1123
1225
|
if (unusedDependencies > 0) {
|
|
1124
1226
|
const packageLocation = `${location}/package.json`;
|
|
1125
|
-
console.log(` ${
|
|
1227
|
+
console.log(` ${chalk17.yellow(packageLocation)}
|
|
1126
1228
|
`);
|
|
1127
1229
|
}
|
|
1128
1230
|
return unusedDependencies;
|
|
@@ -1208,19 +1310,19 @@ var deplint = ({
|
|
|
1208
1310
|
});
|
|
1209
1311
|
}
|
|
1210
1312
|
if (totalErrors > 0) {
|
|
1211
|
-
console.warn(`Deplint: Found ${
|
|
1313
|
+
console.warn(`Deplint: Found ${chalk18.red(totalErrors)} dependency problems. ${chalk18.red("\u2716")}`);
|
|
1212
1314
|
} else {
|
|
1213
|
-
console.info(`Deplint: Found no dependency problems. ${
|
|
1315
|
+
console.info(`Deplint: Found no dependency problems. ${chalk18.green("\u2714")}`);
|
|
1214
1316
|
}
|
|
1215
1317
|
return 0;
|
|
1216
1318
|
};
|
|
1217
1319
|
|
|
1218
1320
|
// src/actions/deploy.ts
|
|
1219
|
-
import { readFileSync as
|
|
1321
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
1220
1322
|
var privatePackageExcludeList = () => {
|
|
1221
1323
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1222
1324
|
workspace,
|
|
1223
|
-
JSON.parse(
|
|
1325
|
+
JSON.parse(readFileSync5(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1224
1326
|
]);
|
|
1225
1327
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1226
1328
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1240,11 +1342,11 @@ var deploy = () => {
|
|
|
1240
1342
|
};
|
|
1241
1343
|
|
|
1242
1344
|
// src/actions/deploy-major.ts
|
|
1243
|
-
import { readFileSync as
|
|
1345
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
1244
1346
|
var privatePackageExcludeList2 = () => {
|
|
1245
1347
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1246
1348
|
workspace,
|
|
1247
|
-
JSON.parse(
|
|
1349
|
+
JSON.parse(readFileSync6(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1248
1350
|
]);
|
|
1249
1351
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1250
1352
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1264,11 +1366,11 @@ var deployMajor = () => {
|
|
|
1264
1366
|
};
|
|
1265
1367
|
|
|
1266
1368
|
// src/actions/deploy-minor.ts
|
|
1267
|
-
import { readFileSync as
|
|
1369
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
1268
1370
|
var privatePackageExcludeList3 = () => {
|
|
1269
1371
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1270
1372
|
workspace,
|
|
1271
|
-
JSON.parse(
|
|
1373
|
+
JSON.parse(readFileSync7(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1272
1374
|
]);
|
|
1273
1375
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1274
1376
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1288,11 +1390,11 @@ var deployMinor = () => {
|
|
|
1288
1390
|
};
|
|
1289
1391
|
|
|
1290
1392
|
// src/actions/deploy-next.ts
|
|
1291
|
-
import { readFileSync as
|
|
1393
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
1292
1394
|
var privatePackageExcludeList4 = () => {
|
|
1293
1395
|
const possibleDeployablePackages = yarnWorkspaces().map((workspace) => [
|
|
1294
1396
|
workspace,
|
|
1295
|
-
JSON.parse(
|
|
1397
|
+
JSON.parse(readFileSync8(`${workspace.location}/package.json`, { encoding: "utf8" }))
|
|
1296
1398
|
]);
|
|
1297
1399
|
const privatePackages = possibleDeployablePackages.filter(([_, pkg]) => pkg.private).map(([workspace]) => workspace);
|
|
1298
1400
|
const excludeList = privatePackages.map((workspace) => `--exclude ${workspace.name}`);
|
|
@@ -1312,22 +1414,22 @@ var deployNext = () => {
|
|
|
1312
1414
|
};
|
|
1313
1415
|
|
|
1314
1416
|
// src/actions/dupdeps.ts
|
|
1315
|
-
import
|
|
1417
|
+
import chalk19 from "chalk";
|
|
1316
1418
|
var dupdeps = () => {
|
|
1317
|
-
console.log(
|
|
1419
|
+
console.log(chalk19.green("Checking all Dependencies for Duplicates"));
|
|
1318
1420
|
const allDependencies = parsedPackageJSON()?.dependencies;
|
|
1319
1421
|
const dependencies = Object.entries(allDependencies).map(([k]) => k);
|
|
1320
1422
|
return detectDuplicateDependencies(dependencies);
|
|
1321
1423
|
};
|
|
1322
1424
|
|
|
1323
1425
|
// src/actions/lint.ts
|
|
1324
|
-
import
|
|
1426
|
+
import chalk20 from "chalk";
|
|
1325
1427
|
var lintPackage = ({
|
|
1326
1428
|
pkg,
|
|
1327
1429
|
fix: fix2,
|
|
1328
1430
|
verbose
|
|
1329
1431
|
}) => {
|
|
1330
|
-
console.log(
|
|
1432
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
1331
1433
|
const start = Date.now();
|
|
1332
1434
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
1333
1435
|
["yarn", [
|
|
@@ -1337,7 +1439,7 @@ var lintPackage = ({
|
|
|
1337
1439
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
1338
1440
|
]]
|
|
1339
1441
|
]);
|
|
1340
|
-
console.log(
|
|
1442
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
1341
1443
|
return result;
|
|
1342
1444
|
};
|
|
1343
1445
|
var lint = ({
|
|
@@ -1357,13 +1459,13 @@ var lint = ({
|
|
|
1357
1459
|
});
|
|
1358
1460
|
};
|
|
1359
1461
|
var lintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
1360
|
-
console.log(
|
|
1462
|
+
console.log(chalk20.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
1361
1463
|
const start = Date.now();
|
|
1362
1464
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
1363
1465
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
1364
1466
|
["yarn", ["eslint", "--cache", "--cache-location", ".eslintcache", "--cache-strategy", "content", ...fixOptions]]
|
|
1365
1467
|
]);
|
|
1366
|
-
console.log(
|
|
1468
|
+
console.log(chalk20.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk20.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk20.gray("seconds")}`));
|
|
1367
1469
|
return result;
|
|
1368
1470
|
};
|
|
1369
1471
|
|
|
@@ -1391,7 +1493,7 @@ var filename = ".gitignore";
|
|
|
1391
1493
|
var gitignoreGen = (pkg) => generateIgnoreFiles(filename, pkg);
|
|
1392
1494
|
|
|
1393
1495
|
// src/actions/gitlint.ts
|
|
1394
|
-
import
|
|
1496
|
+
import chalk21 from "chalk";
|
|
1395
1497
|
import ParseGitConfig from "parse-git-config";
|
|
1396
1498
|
var gitlint = () => {
|
|
1397
1499
|
console.log(`
|
|
@@ -1402,7 +1504,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1402
1504
|
const errors = 0;
|
|
1403
1505
|
const gitConfig = ParseGitConfig.sync();
|
|
1404
1506
|
const warn = (message) => {
|
|
1405
|
-
console.warn(
|
|
1507
|
+
console.warn(chalk21.yellow(`Warning: ${message}`));
|
|
1406
1508
|
warnings++;
|
|
1407
1509
|
};
|
|
1408
1510
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1422,13 +1524,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1422
1524
|
}
|
|
1423
1525
|
const resultMessages = [];
|
|
1424
1526
|
if (valid > 0) {
|
|
1425
|
-
resultMessages.push(
|
|
1527
|
+
resultMessages.push(chalk21.green(`Passed: ${valid}`));
|
|
1426
1528
|
}
|
|
1427
1529
|
if (warnings > 0) {
|
|
1428
|
-
resultMessages.push(
|
|
1530
|
+
resultMessages.push(chalk21.yellow(`Warnings: ${warnings}`));
|
|
1429
1531
|
}
|
|
1430
1532
|
if (errors > 0) {
|
|
1431
|
-
resultMessages.push(
|
|
1533
|
+
resultMessages.push(chalk21.red(` Errors: ${errors}`));
|
|
1432
1534
|
}
|
|
1433
1535
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1434
1536
|
`);
|
|
@@ -1437,7 +1539,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1437
1539
|
|
|
1438
1540
|
// src/actions/gitlint-fix.ts
|
|
1439
1541
|
import { execSync as execSync2 } from "child_process";
|
|
1440
|
-
import
|
|
1542
|
+
import chalk22 from "chalk";
|
|
1441
1543
|
import ParseGitConfig2 from "parse-git-config";
|
|
1442
1544
|
var gitlintFix = () => {
|
|
1443
1545
|
console.log(`
|
|
@@ -1446,15 +1548,15 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1446
1548
|
const gitConfig = ParseGitConfig2.sync();
|
|
1447
1549
|
if (gitConfig.core.ignorecase) {
|
|
1448
1550
|
execSync2("git config core.ignorecase false", { stdio: "inherit" });
|
|
1449
|
-
console.warn(
|
|
1551
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1450
1552
|
}
|
|
1451
1553
|
if (gitConfig.core.autocrlf !== false) {
|
|
1452
1554
|
execSync2("git config core.autocrlf false", { stdio: "inherit" });
|
|
1453
|
-
console.warn(
|
|
1555
|
+
console.warn(chalk22.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1454
1556
|
}
|
|
1455
1557
|
if (gitConfig.core.eol !== "lf") {
|
|
1456
1558
|
execSync2("git config core.eol lf", { stdio: "inherit" });
|
|
1457
|
-
console.warn(
|
|
1559
|
+
console.warn(chalk22.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1458
1560
|
}
|
|
1459
1561
|
return 1;
|
|
1460
1562
|
};
|
|
@@ -1465,7 +1567,7 @@ var knip = () => {
|
|
|
1465
1567
|
};
|
|
1466
1568
|
|
|
1467
1569
|
// src/actions/license.ts
|
|
1468
|
-
import
|
|
1570
|
+
import chalk23 from "chalk";
|
|
1469
1571
|
import { init } from "license-checker";
|
|
1470
1572
|
var license = async (pkg) => {
|
|
1471
1573
|
const workspaces = yarnWorkspaces();
|
|
@@ -1490,18 +1592,18 @@ var license = async (pkg) => {
|
|
|
1490
1592
|
"LGPL-3.0-or-later",
|
|
1491
1593
|
"Python-2.0"
|
|
1492
1594
|
]);
|
|
1493
|
-
console.log(
|
|
1595
|
+
console.log(chalk23.green("License Checker"));
|
|
1494
1596
|
return (await Promise.all(
|
|
1495
1597
|
workspaceList.map(({ location, name }) => {
|
|
1496
1598
|
return new Promise((resolve) => {
|
|
1497
1599
|
init({ production: true, start: location }, (error, packages) => {
|
|
1498
1600
|
if (error) {
|
|
1499
|
-
console.error(
|
|
1500
|
-
console.error(
|
|
1601
|
+
console.error(chalk23.red(`License Checker [${name}] Error`));
|
|
1602
|
+
console.error(chalk23.gray(error));
|
|
1501
1603
|
console.log("\n");
|
|
1502
1604
|
resolve(1);
|
|
1503
1605
|
} else {
|
|
1504
|
-
console.log(
|
|
1606
|
+
console.log(chalk23.green(`License Checker [${name}]`));
|
|
1505
1607
|
let count = 0;
|
|
1506
1608
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1507
1609
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [info.licenses];
|
|
@@ -1517,7 +1619,7 @@ var license = async (pkg) => {
|
|
|
1517
1619
|
}
|
|
1518
1620
|
if (!orLicenseFound) {
|
|
1519
1621
|
count++;
|
|
1520
|
-
console.warn(
|
|
1622
|
+
console.warn(chalk23.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1521
1623
|
}
|
|
1522
1624
|
}
|
|
1523
1625
|
}
|
|
@@ -1537,12 +1639,12 @@ var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
|
1537
1639
|
|
|
1538
1640
|
// src/actions/package/clean-outputs.ts
|
|
1539
1641
|
import path7 from "path";
|
|
1540
|
-
import
|
|
1642
|
+
import chalk24 from "chalk";
|
|
1541
1643
|
var packageCleanOutputs = () => {
|
|
1542
1644
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1543
1645
|
const pkgName = process.env.npm_package_name;
|
|
1544
1646
|
const folders = [path7.join(pkg, "dist"), path7.join(pkg, "build"), path7.join(pkg, "docs")];
|
|
1545
|
-
console.log(
|
|
1647
|
+
console.log(chalk24.green(`Cleaning Outputs [${pkgName}]`));
|
|
1546
1648
|
for (let folder of folders) {
|
|
1547
1649
|
deleteGlob(folder);
|
|
1548
1650
|
}
|
|
@@ -1551,11 +1653,11 @@ var packageCleanOutputs = () => {
|
|
|
1551
1653
|
|
|
1552
1654
|
// src/actions/package/clean-typescript.ts
|
|
1553
1655
|
import path8 from "path";
|
|
1554
|
-
import
|
|
1656
|
+
import chalk25 from "chalk";
|
|
1555
1657
|
var packageCleanTypescript = () => {
|
|
1556
1658
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1557
1659
|
const pkgName = process.env.npm_package_name;
|
|
1558
|
-
console.log(
|
|
1660
|
+
console.log(chalk25.green(`Cleaning Typescript [${pkgName}]`));
|
|
1559
1661
|
const files = [path8.join(pkg, "*.tsbuildinfo"), path8.join(pkg, ".tsconfig.*"), path8.join(pkg, ".eslintcache")];
|
|
1560
1662
|
for (let file of files) {
|
|
1561
1663
|
deleteGlob(file);
|
|
@@ -1569,26 +1671,26 @@ var packageClean = async () => {
|
|
|
1569
1671
|
};
|
|
1570
1672
|
|
|
1571
1673
|
// src/actions/package/compile/compile.ts
|
|
1572
|
-
import
|
|
1674
|
+
import chalk30 from "chalk";
|
|
1573
1675
|
|
|
1574
1676
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1575
|
-
import
|
|
1677
|
+
import chalk29 from "chalk";
|
|
1576
1678
|
import { build as build2, defineConfig } from "tsup";
|
|
1577
1679
|
|
|
1578
1680
|
// src/actions/package/compile/inputs.ts
|
|
1579
|
-
import
|
|
1681
|
+
import chalk26 from "chalk";
|
|
1580
1682
|
import { glob as glob2 } from "glob";
|
|
1581
1683
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1582
1684
|
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1583
1685
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1584
1686
|
if (verbose) {
|
|
1585
|
-
console.log(
|
|
1687
|
+
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1586
1688
|
}
|
|
1587
1689
|
return result;
|
|
1588
1690
|
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1589
1691
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1590
1692
|
if (verbose) {
|
|
1591
|
-
console.log(
|
|
1693
|
+
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1592
1694
|
}
|
|
1593
1695
|
return result;
|
|
1594
1696
|
})];
|
|
@@ -1647,7 +1749,7 @@ function deepMergeObjects(objects) {
|
|
|
1647
1749
|
|
|
1648
1750
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1649
1751
|
import { cwd as cwd2 } from "process";
|
|
1650
|
-
import
|
|
1752
|
+
import chalk27 from "chalk";
|
|
1651
1753
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1652
1754
|
import ts2, {
|
|
1653
1755
|
DiagnosticCategory,
|
|
@@ -1669,7 +1771,7 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
1669
1771
|
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
1670
1772
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1671
1773
|
if (verbose) {
|
|
1672
|
-
console.log(
|
|
1774
|
+
console.log(chalk27.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1673
1775
|
}
|
|
1674
1776
|
const configFilePath = ts2.findConfigFile(
|
|
1675
1777
|
"./",
|
|
@@ -1692,10 +1794,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1692
1794
|
emitDeclarationOnly: true,
|
|
1693
1795
|
noEmit: false
|
|
1694
1796
|
};
|
|
1695
|
-
console.log(
|
|
1797
|
+
console.log(chalk27.cyan(`Validating Files: ${entries.length}`));
|
|
1696
1798
|
if (verbose) {
|
|
1697
1799
|
for (const entry of entries) {
|
|
1698
|
-
console.log(
|
|
1800
|
+
console.log(chalk27.grey(`Validating: ${entry}`));
|
|
1699
1801
|
}
|
|
1700
1802
|
}
|
|
1701
1803
|
try {
|
|
@@ -1725,7 +1827,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1725
1827
|
return 0;
|
|
1726
1828
|
} finally {
|
|
1727
1829
|
if (verbose) {
|
|
1728
|
-
console.log(
|
|
1830
|
+
console.log(chalk27.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1729
1831
|
}
|
|
1730
1832
|
}
|
|
1731
1833
|
};
|
|
@@ -1733,7 +1835,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1733
1835
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1734
1836
|
import path9 from "path";
|
|
1735
1837
|
import { cwd as cwd3 } from "process";
|
|
1736
|
-
import
|
|
1838
|
+
import chalk28 from "chalk";
|
|
1737
1839
|
import { rollup } from "rollup";
|
|
1738
1840
|
import dts from "rollup-plugin-dts";
|
|
1739
1841
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
@@ -1758,8 +1860,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1758
1860
|
if (ignoredWarningCodes.has(warning.code ?? "")) {
|
|
1759
1861
|
return;
|
|
1760
1862
|
}
|
|
1761
|
-
console.warn(
|
|
1762
|
-
console.warn(
|
|
1863
|
+
console.warn(chalk28.yellow(`[${warning.code}] ${warning.message}`));
|
|
1864
|
+
console.warn(chalk28.gray(inputPath));
|
|
1763
1865
|
warn(warning);
|
|
1764
1866
|
}
|
|
1765
1867
|
});
|
|
@@ -1769,8 +1871,8 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1769
1871
|
});
|
|
1770
1872
|
} catch (ex) {
|
|
1771
1873
|
const error = ex;
|
|
1772
|
-
console.warn(
|
|
1773
|
-
console.warn(
|
|
1874
|
+
console.warn(chalk28.red(error));
|
|
1875
|
+
console.warn(chalk28.gray(inputPath));
|
|
1774
1876
|
}
|
|
1775
1877
|
if (verbose) {
|
|
1776
1878
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
@@ -1778,7 +1880,7 @@ async function bundleDts(inputPath, outputPath, platform, options, verbose = fal
|
|
|
1778
1880
|
}
|
|
1779
1881
|
var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build", verbose = false) => {
|
|
1780
1882
|
if (verbose) {
|
|
1781
|
-
console.log(
|
|
1883
|
+
console.log(chalk28.cyan(`Compiling Types START [${platform}]: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1782
1884
|
console.log(`Entries: ${entries.join(", ")}`);
|
|
1783
1885
|
}
|
|
1784
1886
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
@@ -1802,7 +1904,7 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
1802
1904
|
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
1803
1905
|
}));
|
|
1804
1906
|
if (verbose) {
|
|
1805
|
-
console.log(
|
|
1907
|
+
console.log(chalk28.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1806
1908
|
}
|
|
1807
1909
|
return 0;
|
|
1808
1910
|
};
|
|
@@ -1814,15 +1916,15 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1814
1916
|
console.log(`compileFolder [${srcDir}, ${options?.outDir}]`);
|
|
1815
1917
|
}
|
|
1816
1918
|
if (entries.length === 0) {
|
|
1817
|
-
console.warn(
|
|
1919
|
+
console.warn(chalk29.yellow(`No entries found in ${srcDir} to compile`));
|
|
1818
1920
|
return 0;
|
|
1819
1921
|
}
|
|
1820
1922
|
if (verbose) {
|
|
1821
|
-
console.log(
|
|
1923
|
+
console.log(chalk29.gray(`buildDir [${buildDir}]`));
|
|
1822
1924
|
}
|
|
1823
1925
|
const validationResult = packageCompileTsc(options?.platform ?? "neutral", entries, srcDir, buildDir, void 0, verbose);
|
|
1824
1926
|
if (validationResult !== 0) {
|
|
1825
|
-
console.error(
|
|
1927
|
+
console.error(chalk29.red(`Compile:Validation had ${validationResult} errors`));
|
|
1826
1928
|
return validationResult;
|
|
1827
1929
|
}
|
|
1828
1930
|
const optionsParams = tsupOptions([{
|
|
@@ -1847,12 +1949,12 @@ var compileFolder = async (srcDir, entries, buildDir, options, bundleTypes = fal
|
|
|
1847
1949
|
})
|
|
1848
1950
|
)).flat();
|
|
1849
1951
|
if (verbose) {
|
|
1850
|
-
console.log(
|
|
1851
|
-
console.log(
|
|
1952
|
+
console.log(chalk29.cyan(`TSUP:build:start [${srcDir}]`));
|
|
1953
|
+
console.log(chalk29.gray(`TSUP:build:options [${JSON.stringify(optionsList, null, 2)}]`));
|
|
1852
1954
|
}
|
|
1853
1955
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
1854
1956
|
if (verbose) {
|
|
1855
|
-
console.log(
|
|
1957
|
+
console.log(chalk29.cyan(`TSUP:build:stop [${srcDir}]`));
|
|
1856
1958
|
}
|
|
1857
1959
|
if (bundleTypes) {
|
|
1858
1960
|
await packageCompileTscTypes(entries, outDir, options?.platform ?? "neutral", buildDir, verbose);
|
|
@@ -1963,14 +2065,14 @@ var packageCompileTsup = async (config2) => {
|
|
|
1963
2065
|
// src/actions/package/compile/compile.ts
|
|
1964
2066
|
var packageCompile = async (inConfig = {}) => {
|
|
1965
2067
|
const pkg = process.env.INIT_CWD;
|
|
1966
|
-
console.log(
|
|
2068
|
+
console.log(chalk30.green(`Compiling ${pkg}`));
|
|
1967
2069
|
const config2 = await loadConfig(inConfig);
|
|
1968
2070
|
return await packageCompileTsup(config2);
|
|
1969
2071
|
};
|
|
1970
2072
|
|
|
1971
2073
|
// src/actions/package/copy-assets.ts
|
|
1972
2074
|
import path10 from "path/posix";
|
|
1973
|
-
import
|
|
2075
|
+
import chalk31 from "chalk";
|
|
1974
2076
|
import cpy2 from "cpy";
|
|
1975
2077
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1976
2078
|
try {
|
|
@@ -1983,7 +2085,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1983
2085
|
}
|
|
1984
2086
|
);
|
|
1985
2087
|
if (values.length > 0) {
|
|
1986
|
-
console.log(
|
|
2088
|
+
console.log(chalk31.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1987
2089
|
}
|
|
1988
2090
|
for (const value of values) {
|
|
1989
2091
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -2048,9 +2150,9 @@ var packageCycle = async () => {
|
|
|
2048
2150
|
};
|
|
2049
2151
|
|
|
2050
2152
|
// src/actions/package/gen-docs.ts
|
|
2051
|
-
import { existsSync as
|
|
2153
|
+
import { existsSync as existsSync5 } from "fs";
|
|
2052
2154
|
import path11 from "path";
|
|
2053
|
-
import
|
|
2155
|
+
import chalk32 from "chalk";
|
|
2054
2156
|
import {
|
|
2055
2157
|
Application,
|
|
2056
2158
|
ArgumentsReader,
|
|
@@ -2068,7 +2170,7 @@ var ExitCodes = {
|
|
|
2068
2170
|
};
|
|
2069
2171
|
var packageGenDocs = async () => {
|
|
2070
2172
|
const pkg = process.env.INIT_CWD;
|
|
2071
|
-
if (pkg !== void 0 && !
|
|
2173
|
+
if (pkg !== void 0 && !existsSync5(path11.join(pkg, "typedoc.json"))) {
|
|
2072
2174
|
return;
|
|
2073
2175
|
}
|
|
2074
2176
|
const app = await Application.bootstrap({
|
|
@@ -2154,16 +2256,16 @@ var runTypeDoc = async (app) => {
|
|
|
2154
2256
|
return ExitCodes.OutputError;
|
|
2155
2257
|
}
|
|
2156
2258
|
}
|
|
2157
|
-
console.log(
|
|
2259
|
+
console.log(chalk32.green(`${pkgName} - Ok`));
|
|
2158
2260
|
return ExitCodes.Ok;
|
|
2159
2261
|
};
|
|
2160
2262
|
|
|
2161
2263
|
// src/actions/package/lint.ts
|
|
2162
|
-
import { readdirSync } from "fs";
|
|
2264
|
+
import { readdirSync as readdirSync3 } from "fs";
|
|
2163
2265
|
import path12 from "path";
|
|
2164
2266
|
import { cwd as cwd4 } from "process";
|
|
2165
2267
|
import { pathToFileURL } from "url";
|
|
2166
|
-
import
|
|
2268
|
+
import chalk33 from "chalk";
|
|
2167
2269
|
import { ESLint } from "eslint";
|
|
2168
2270
|
import { findUp } from "find-up";
|
|
2169
2271
|
import picomatch from "picomatch";
|
|
@@ -2172,14 +2274,14 @@ var dumpMessages = (lintResults) => {
|
|
|
2172
2274
|
const severity = ["none", "warning", "error"];
|
|
2173
2275
|
for (const lintResult of lintResults) {
|
|
2174
2276
|
if (lintResult.messages.length > 0) {
|
|
2175
|
-
console.log(
|
|
2277
|
+
console.log(chalk33.gray(`
|
|
2176
2278
|
${lintResult.filePath}`));
|
|
2177
2279
|
for (const message of lintResult.messages) {
|
|
2178
2280
|
console.log(
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2281
|
+
chalk33.gray(` ${message.line}:${message.column}`),
|
|
2282
|
+
chalk33[colors[message.severity]](` ${severity[message.severity]}`),
|
|
2283
|
+
chalk33.white(` ${message.message}`),
|
|
2284
|
+
chalk33.gray(` ${message.ruleId}`)
|
|
2183
2285
|
);
|
|
2184
2286
|
}
|
|
2185
2287
|
}
|
|
@@ -2196,7 +2298,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
2196
2298
|
const currentDirectory = cwd4();
|
|
2197
2299
|
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
2198
2300
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2199
|
-
return
|
|
2301
|
+
return readdirSync3(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2200
2302
|
const res = path12.resolve(dir, dirent.name);
|
|
2201
2303
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2202
2304
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
@@ -2217,10 +2319,10 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2217
2319
|
cache
|
|
2218
2320
|
});
|
|
2219
2321
|
const files = getFiles(cwd4(), ignoreFolders);
|
|
2220
|
-
console.log(
|
|
2322
|
+
console.log(chalk33.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2221
2323
|
if (verbose) {
|
|
2222
2324
|
for (const file of files) {
|
|
2223
|
-
console.log(
|
|
2325
|
+
console.log(chalk33.gray(` ${file}`));
|
|
2224
2326
|
}
|
|
2225
2327
|
}
|
|
2226
2328
|
const lintResults = await engine.lintFiles(files);
|
|
@@ -2231,32 +2333,32 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2231
2333
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2232
2334
|
const lintTime = Date.now() - start;
|
|
2233
2335
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2234
|
-
console.log(
|
|
2336
|
+
console.log(chalk33.white(`Linted ${chalk33[filesCountColor](files.length)} files in ${chalk33[lintTimeColor](lintTime)}ms`));
|
|
2235
2337
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2236
2338
|
};
|
|
2237
2339
|
|
|
2238
2340
|
// src/actions/package/publint.ts
|
|
2239
2341
|
import { promises as fs9 } from "fs";
|
|
2240
|
-
import
|
|
2342
|
+
import chalk34 from "chalk";
|
|
2241
2343
|
import sortPackageJson from "sort-package-json";
|
|
2242
2344
|
var customPubLint = (pkg) => {
|
|
2243
2345
|
let errorCount = 0;
|
|
2244
2346
|
let warningCount = 0;
|
|
2245
2347
|
if (pkg.files === void 0) {
|
|
2246
|
-
console.warn(
|
|
2348
|
+
console.warn(chalk34.yellow('Publint [custom]: "files" field is missing'));
|
|
2247
2349
|
warningCount++;
|
|
2248
2350
|
}
|
|
2249
2351
|
if (pkg.main !== void 0) {
|
|
2250
|
-
console.warn(
|
|
2352
|
+
console.warn(chalk34.yellow('Publint [custom]: "main" field is deprecated, use "exports" instead'));
|
|
2251
2353
|
warningCount++;
|
|
2252
2354
|
}
|
|
2253
2355
|
if (pkg.sideEffects !== false) {
|
|
2254
|
-
console.warn(
|
|
2356
|
+
console.warn(chalk34.yellow('Publint [custom]: "sideEffects" field should be set to false'));
|
|
2255
2357
|
warningCount++;
|
|
2256
2358
|
}
|
|
2257
2359
|
if (pkg.resolutions !== void 0) {
|
|
2258
|
-
console.warn(
|
|
2259
|
-
console.warn(
|
|
2360
|
+
console.warn(chalk34.yellow('Publint [custom]: "resolutions" in use'));
|
|
2361
|
+
console.warn(chalk34.gray(JSON.stringify(pkg.resolutions, null, 2)));
|
|
2260
2362
|
warningCount++;
|
|
2261
2363
|
}
|
|
2262
2364
|
return [errorCount, warningCount];
|
|
@@ -2266,8 +2368,8 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2266
2368
|
const sortedPkg = sortPackageJson(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2267
2369
|
await fs9.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2268
2370
|
const pkg = JSON.parse(await fs9.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2269
|
-
console.log(
|
|
2270
|
-
console.log(
|
|
2371
|
+
console.log(chalk34.green(`Publint: ${pkg.name}`));
|
|
2372
|
+
console.log(chalk34.gray(pkgDir));
|
|
2271
2373
|
const { publint: publint2 } = await import("publint");
|
|
2272
2374
|
const { messages } = await publint2({
|
|
2273
2375
|
level: "suggestion",
|
|
@@ -2278,22 +2380,22 @@ var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
|
2278
2380
|
for (const message of messages) {
|
|
2279
2381
|
switch (message.type) {
|
|
2280
2382
|
case "error": {
|
|
2281
|
-
console.error(
|
|
2383
|
+
console.error(chalk34.red(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2282
2384
|
break;
|
|
2283
2385
|
}
|
|
2284
2386
|
case "warning": {
|
|
2285
|
-
console.warn(
|
|
2387
|
+
console.warn(chalk34.yellow(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2286
2388
|
break;
|
|
2287
2389
|
}
|
|
2288
2390
|
default: {
|
|
2289
|
-
console.log(
|
|
2391
|
+
console.log(chalk34.white(`[${message.code}] ${formatMessage(message, pkg)}`));
|
|
2290
2392
|
break;
|
|
2291
2393
|
}
|
|
2292
2394
|
}
|
|
2293
2395
|
}
|
|
2294
2396
|
const [errorCount, warningCount] = customPubLint(pkg);
|
|
2295
2397
|
if (verbose) {
|
|
2296
|
-
console.log(
|
|
2398
|
+
console.log(chalk34.gray(`Publint [Finish]: ${pkgDir} [${messages.length + errorCount + warningCount} messages]`));
|
|
2297
2399
|
}
|
|
2298
2400
|
return messages.filter((message) => message.type === "error").length + errorCount;
|
|
2299
2401
|
};
|
|
@@ -2329,7 +2431,7 @@ var rebuild = ({ target }) => {
|
|
|
2329
2431
|
};
|
|
2330
2432
|
|
|
2331
2433
|
// src/actions/recompile.ts
|
|
2332
|
-
import
|
|
2434
|
+
import chalk35 from "chalk";
|
|
2333
2435
|
var recompile = async ({
|
|
2334
2436
|
verbose,
|
|
2335
2437
|
target,
|
|
@@ -2365,7 +2467,7 @@ var recompileAll = async ({
|
|
|
2365
2467
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2366
2468
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2367
2469
|
if (jobs) {
|
|
2368
|
-
console.log(
|
|
2470
|
+
console.log(chalk35.blue(`Jobs set to [${jobs}]`));
|
|
2369
2471
|
}
|
|
2370
2472
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2371
2473
|
[
|
|
@@ -2396,7 +2498,7 @@ var recompileAll = async ({
|
|
|
2396
2498
|
]
|
|
2397
2499
|
]);
|
|
2398
2500
|
console.log(
|
|
2399
|
-
`${
|
|
2501
|
+
`${chalk35.gray("Recompiled in")} [${chalk35.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk35.gray("seconds")}`
|
|
2400
2502
|
);
|
|
2401
2503
|
return result;
|
|
2402
2504
|
};
|
|
@@ -2427,13 +2529,13 @@ var reinstall = () => {
|
|
|
2427
2529
|
};
|
|
2428
2530
|
|
|
2429
2531
|
// src/actions/relint.ts
|
|
2430
|
-
import
|
|
2532
|
+
import chalk36 from "chalk";
|
|
2431
2533
|
var relintPackage = ({
|
|
2432
2534
|
pkg,
|
|
2433
2535
|
fix: fix2,
|
|
2434
2536
|
verbose
|
|
2435
2537
|
}) => {
|
|
2436
|
-
console.log(
|
|
2538
|
+
console.log(chalk36.gray(`${fix2 ? "Fix" : "Lint"} [${pkg}]`));
|
|
2437
2539
|
const start = Date.now();
|
|
2438
2540
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [${pkg}]`, [
|
|
2439
2541
|
["yarn", [
|
|
@@ -2443,7 +2545,7 @@ var relintPackage = ({
|
|
|
2443
2545
|
fix2 ? "package-fix" : verbose ? "package-lint-verbose" : "package-lint"
|
|
2444
2546
|
]]
|
|
2445
2547
|
]);
|
|
2446
|
-
console.log(
|
|
2548
|
+
console.log(chalk36.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`));
|
|
2447
2549
|
return result;
|
|
2448
2550
|
};
|
|
2449
2551
|
var relint = ({
|
|
@@ -2463,13 +2565,13 @@ var relint = ({
|
|
|
2463
2565
|
});
|
|
2464
2566
|
};
|
|
2465
2567
|
var relintAllPackages = ({ fix: fix2 = false } = {}) => {
|
|
2466
|
-
console.log(
|
|
2568
|
+
console.log(chalk36.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
2467
2569
|
const start = Date.now();
|
|
2468
2570
|
const fixOptions = fix2 ? ["--fix"] : [];
|
|
2469
2571
|
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
2470
2572
|
["yarn", ["eslint", ...fixOptions]]
|
|
2471
2573
|
]);
|
|
2472
|
-
console.log(
|
|
2574
|
+
console.log(chalk36.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk36.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk36.gray("seconds")}`));
|
|
2473
2575
|
return result;
|
|
2474
2576
|
};
|
|
2475
2577
|
|
|
@@ -2487,10 +2589,10 @@ var sonar = () => {
|
|
|
2487
2589
|
};
|
|
2488
2590
|
|
|
2489
2591
|
// src/actions/statics.ts
|
|
2490
|
-
import
|
|
2592
|
+
import chalk37 from "chalk";
|
|
2491
2593
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2492
2594
|
var statics = () => {
|
|
2493
|
-
console.log(
|
|
2595
|
+
console.log(chalk37.green("Check Required Static Dependencies"));
|
|
2494
2596
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2495
2597
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2496
2598
|
};
|
|
@@ -2540,6 +2642,7 @@ var yarn3Only = () => {
|
|
|
2540
2642
|
export {
|
|
2541
2643
|
build,
|
|
2542
2644
|
bundleDts,
|
|
2645
|
+
claudeRules,
|
|
2543
2646
|
clean,
|
|
2544
2647
|
cleanAll,
|
|
2545
2648
|
cleanDocs,
|