@xylabs/ts-scripts-yarn3 7.0.0-rc.6 → 7.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.mjs +119 -199
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/buildEntries.mjs +4 -1
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +41 -150
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +83 -163
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +5 -2
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +29 -174
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +39 -148
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/index.mjs +101 -181
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +41 -150
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/bin/package/build-only.mjs +43 -152
- package/dist/bin/package/build-only.mjs.map +1 -1
- package/dist/bin/package/build.mjs +43 -152
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +43 -152
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +41 -150
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +43 -152
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +43 -152
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/index.d.ts +22 -3
- package/dist/index.mjs +131 -211
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/actions/index.mjs
CHANGED
|
@@ -313,8 +313,8 @@ var loadConfig = async (params) => {
|
|
|
313
313
|
|
|
314
314
|
// src/lib/parsedPackageJSON.ts
|
|
315
315
|
import { readFileSync as readFileSync2 } from "fs";
|
|
316
|
-
var parsedPackageJSON = (
|
|
317
|
-
const pathToPackageJSON =
|
|
316
|
+
var parsedPackageJSON = (path10) => {
|
|
317
|
+
const pathToPackageJSON = path10 ?? process.env.npm_package_json ?? "";
|
|
318
318
|
const packageJSON = readFileSync2(pathToPackageJSON).toString();
|
|
319
319
|
return JSON.parse(packageJSON);
|
|
320
320
|
};
|
|
@@ -681,11 +681,11 @@ function findFilesByGlob(cwd4, pattern) {
|
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
// src/actions/deplint/findFiles.ts
|
|
684
|
-
function findFiles(
|
|
684
|
+
function findFiles(path10) {
|
|
685
685
|
const allSourceInclude = ["./src/**/*.{ts,tsx}"];
|
|
686
686
|
const allDistInclude = ["./dist/**/*.d.ts", "./dist/**/*.{mjs,js,cjs}"];
|
|
687
|
-
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(
|
|
688
|
-
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(
|
|
687
|
+
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path10, pattern));
|
|
688
|
+
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path10, pattern));
|
|
689
689
|
return { srcFiles, distFiles };
|
|
690
690
|
}
|
|
691
691
|
|
|
@@ -780,11 +780,11 @@ function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
|
780
780
|
const srcImportPaths = {};
|
|
781
781
|
const distImportPaths = {};
|
|
782
782
|
const distTypeImportPaths = {};
|
|
783
|
-
for (const
|
|
783
|
+
for (const path10 of srcFiles) getImportsFromFile(path10, srcImportPaths, srcImportPaths).flat();
|
|
784
784
|
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
785
785
|
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
786
|
-
for (const
|
|
787
|
-
for (const
|
|
786
|
+
for (const path10 of distCodeFiles) getImportsFromFile(path10, distImportPaths, distImportPaths).flat();
|
|
787
|
+
for (const path10 of distTypeFiles) getImportsFromFile(path10, distTypeImportPaths, distTypeImportPaths).flat();
|
|
788
788
|
const srcImports = Object.keys(srcImportPaths);
|
|
789
789
|
const distImports = Object.keys(distImportPaths);
|
|
790
790
|
const distTypeImports = Object.keys(distTypeImportPaths);
|
|
@@ -1319,7 +1319,7 @@ var packageClean = async () => {
|
|
|
1319
1319
|
};
|
|
1320
1320
|
|
|
1321
1321
|
// src/actions/package/compile/compile.ts
|
|
1322
|
-
import
|
|
1322
|
+
import chalk26 from "chalk";
|
|
1323
1323
|
|
|
1324
1324
|
// src/actions/package/publint.ts
|
|
1325
1325
|
import { promises as fs4 } from "fs";
|
|
@@ -1375,7 +1375,7 @@ var getAllInputs = (folder) => {
|
|
|
1375
1375
|
};
|
|
1376
1376
|
|
|
1377
1377
|
// src/actions/package/compile/buildEntries.ts
|
|
1378
|
-
var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true, verbose = false) => {
|
|
1378
|
+
var buildEntries = (folder, entryMode = "single", options, excludeSpecAndStories = true, verbose = false) => {
|
|
1379
1379
|
let entries = [];
|
|
1380
1380
|
switch (entryMode) {
|
|
1381
1381
|
case "platform": {
|
|
@@ -1395,6 +1395,9 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1395
1395
|
break;
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
|
+
if (typeof options !== "boolean" && Array.isArray(options?.entry)) {
|
|
1399
|
+
entries.push(...options.entry);
|
|
1400
|
+
}
|
|
1398
1401
|
if (verbose) console.log(`buildEntries [${entryMode}] ${entries.length}`);
|
|
1399
1402
|
return entries;
|
|
1400
1403
|
};
|
|
@@ -1423,161 +1426,46 @@ function deepMergeObjects(objects) {
|
|
|
1423
1426
|
}
|
|
1424
1427
|
|
|
1425
1428
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1426
|
-
import { writeFileSync as writeFileSync2 } from "fs";
|
|
1427
|
-
import path7 from "path";
|
|
1428
1429
|
import { cwd } from "process";
|
|
1429
|
-
import {
|
|
1430
|
-
import
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
} from "typescript";
|
|
1439
|
-
|
|
1440
|
-
// src/actions/package/compile/getCompilerOptions.ts
|
|
1441
|
-
import { createRequire } from "module";
|
|
1442
|
-
import deepmerge2 from "deepmerge";
|
|
1443
|
-
import {
|
|
1444
|
-
findConfigFile,
|
|
1445
|
-
readConfigFile,
|
|
1446
|
-
sys
|
|
1447
|
-
} from "typescript";
|
|
1448
|
-
var getNested = (config2) => {
|
|
1449
|
-
if (config2.extends) {
|
|
1450
|
-
const require2 = createRequire(import.meta.url);
|
|
1451
|
-
const opts = require2(config2.extends);
|
|
1452
|
-
return deepmerge2(getNested(opts), config2.compilerOptions ?? {});
|
|
1453
|
-
}
|
|
1454
|
-
return config2.compilerOptions;
|
|
1455
|
-
};
|
|
1456
|
-
var getCompilerOptionsJSONFollowExtends = (filename3) => {
|
|
1457
|
-
const config2 = readConfigFile(filename3, sys.readFile).config;
|
|
1458
|
-
return getNested(config2);
|
|
1459
|
-
};
|
|
1460
|
-
var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
1461
|
-
const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
|
|
1462
|
-
const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0) ?? {};
|
|
1463
|
-
return deepmerge2(configFileCompilerOptions, options);
|
|
1464
|
-
};
|
|
1465
|
-
|
|
1466
|
-
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1467
|
-
var packageCompileTscTypes = (entries, outDir, folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1468
|
-
const pkg = process.env.INIT_CWD ?? cwd();
|
|
1469
|
-
const verbose = config2?.verbose ?? false;
|
|
1470
|
-
const tempRoot = `${pkg}/.xylabs`;
|
|
1471
|
-
const tempDir = `${tempRoot}/ts-scripts-yarn3/compile/tsc/types`;
|
|
1472
|
-
try {
|
|
1473
|
-
rimrafSync(tempRoot, { preserveRoot: false });
|
|
1474
|
-
} catch (ex) {
|
|
1475
|
-
console.error(chalk26.red(`Error removing temporary directory (pre): ${tempRoot}`), ex);
|
|
1476
|
-
return 1;
|
|
1477
|
-
}
|
|
1478
|
-
try {
|
|
1479
|
-
const compilerOptions = {
|
|
1480
|
-
...getCompilerOptions({
|
|
1481
|
-
emitDeclarationOnly: true,
|
|
1482
|
-
outDir: tempDir,
|
|
1483
|
-
removeComments: false,
|
|
1484
|
-
skipDefaultLibCheck: true,
|
|
1485
|
-
skipLibCheck: true,
|
|
1486
|
-
sourceMap: false
|
|
1487
|
-
}),
|
|
1488
|
-
...compilerOptionsParam,
|
|
1489
|
-
emitDeclarationOnly: true,
|
|
1490
|
-
noEmit: false
|
|
1491
|
-
};
|
|
1492
|
-
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1493
|
-
const excludes = [".stories.", ".spec.", "/stories/", "/spec/"];
|
|
1494
|
-
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
|
|
1495
|
-
console.log(chalk26.green(`Compiling Types ${pkg}: ${files.length}`));
|
|
1496
|
-
if (files.length > 0) {
|
|
1497
|
-
const program = createProgramFromConfig({
|
|
1498
|
-
basePath: pkg ?? cwd(),
|
|
1499
|
-
compilerOptions,
|
|
1500
|
-
exclude: ["build", "dist", "docs", "**/*.spec.*", "**/*.stories.*", "src/**/spec/**/*"],
|
|
1501
|
-
files
|
|
1502
|
-
});
|
|
1503
|
-
const diagnostics = getPreEmitDiagnostics(program);
|
|
1504
|
-
if (diagnostics.length > 0) {
|
|
1505
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
|
|
1506
|
-
diagnostics,
|
|
1507
|
-
{
|
|
1508
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
1509
|
-
getCurrentDirectory: () => folder,
|
|
1510
|
-
getNewLine: () => sys2.newLine
|
|
1511
|
-
}
|
|
1512
|
-
);
|
|
1513
|
-
console.error(formattedDiagnostics);
|
|
1514
|
-
}
|
|
1515
|
-
program.emit();
|
|
1516
|
-
const tscErrorCount = diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1517
|
-
if (tscErrorCount > 0) {
|
|
1518
|
-
return tscErrorCount;
|
|
1519
|
-
}
|
|
1520
|
-
const entryNameToTypeName = (entry) => {
|
|
1521
|
-
const splitEntryName = entry.split(".");
|
|
1522
|
-
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
1523
|
-
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
1524
|
-
};
|
|
1525
|
-
const entryNames = entries.map((entry) => entry.split(`${folder}/`).at(-1) ?? entry);
|
|
1526
|
-
for (const entry of entryNames) {
|
|
1527
|
-
const entryTypeName = entryNameToTypeName(entry);
|
|
1528
|
-
const configObject = {
|
|
1529
|
-
projectFolder: ".",
|
|
1530
|
-
mainEntryPointFilePath: path7.resolve([tempDir, entryTypeName].join("/")),
|
|
1531
|
-
bundledPackages: [],
|
|
1532
|
-
compiler: { tsconfigFilePath: path7.resolve(`${pkg}/tsconfig.json`) },
|
|
1533
|
-
dtsRollup: {
|
|
1534
|
-
enabled: true,
|
|
1535
|
-
untrimmedFilePath: path7.resolve(`${outDir}/${entryTypeName}`)
|
|
1536
|
-
},
|
|
1537
|
-
apiReport: { enabled: false },
|
|
1538
|
-
docModel: { enabled: false },
|
|
1539
|
-
tsdocMetadata: { enabled: false }
|
|
1540
|
-
};
|
|
1541
|
-
writeFileSync2(`${tempDir}/api-extractor.json`, JSON.stringify(configObject, null, 2));
|
|
1542
|
-
const extractorConfig = ExtractorConfig.prepare({
|
|
1543
|
-
configObject,
|
|
1544
|
-
configObjectFullPath: path7.resolve(`${tempDir}/api-extractor.json`),
|
|
1545
|
-
// just a virtual label, doesn't have to exist
|
|
1546
|
-
packageJsonFullPath: path7.resolve("package.json")
|
|
1547
|
-
});
|
|
1548
|
-
const extractorResult = Extractor.invoke(extractorConfig, {
|
|
1549
|
-
localBuild: true,
|
|
1550
|
-
showVerboseMessages: true
|
|
1551
|
-
});
|
|
1552
|
-
if (extractorResult.succeeded) {
|
|
1553
|
-
console.log("API Extractor completed successfully");
|
|
1554
|
-
process.exitCode = 0;
|
|
1555
|
-
} else {
|
|
1556
|
-
console.error(
|
|
1557
|
-
`API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings`
|
|
1558
|
-
);
|
|
1559
|
-
process.exitCode = 1;
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1430
|
+
import { rollup } from "rollup";
|
|
1431
|
+
import dts from "rollup-plugin-dts";
|
|
1432
|
+
async function bundleDts(inputPath, outputPath) {
|
|
1433
|
+
const bundle = await rollup({
|
|
1434
|
+
input: inputPath,
|
|
1435
|
+
plugins: [dts()],
|
|
1436
|
+
onwarn(warning, warn) {
|
|
1437
|
+
if (warning.code === "UNUSED_EXTERNAL_IMPORT") return;
|
|
1438
|
+
warn(warning);
|
|
1562
1439
|
}
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1440
|
+
});
|
|
1441
|
+
await bundle.write({
|
|
1442
|
+
file: outputPath,
|
|
1443
|
+
format: "es"
|
|
1444
|
+
});
|
|
1445
|
+
console.log(`Bundled declarations written to ${outputPath}`);
|
|
1446
|
+
}
|
|
1447
|
+
var packageCompileTscTypes = async (entries, outDir, folder = "src") => {
|
|
1448
|
+
const pkg = process.env.INIT_CWD ?? cwd();
|
|
1449
|
+
const srcRoot = `${pkg}/${folder}`;
|
|
1450
|
+
const entryNameToTypeName = (entry) => {
|
|
1451
|
+
const splitEntryName = entry.split(".");
|
|
1452
|
+
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
1453
|
+
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
1454
|
+
};
|
|
1455
|
+
const entryNames = entries.map((entry) => entry.split(`${folder}/`).at(-1) ?? entry);
|
|
1456
|
+
await Promise.all(entryNames.map(async (entryName) => {
|
|
1457
|
+
await bundleDts(`${srcRoot}/${entryName}`, outDir + "/" + entryNameToTypeName(entryName));
|
|
1458
|
+
}));
|
|
1459
|
+
return 0;
|
|
1572
1460
|
};
|
|
1573
1461
|
|
|
1574
1462
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1575
|
-
var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
1463
|
+
var compileFolder = async (folder, entryMode = "single", entries, options, verbose) => {
|
|
1576
1464
|
const outDir = options?.outDir ?? "dist";
|
|
1577
1465
|
if (verbose) {
|
|
1578
1466
|
console.log(`compileFolder [${folder}]`);
|
|
1579
1467
|
}
|
|
1580
|
-
const entry = buildEntries(folder, entryMode);
|
|
1468
|
+
const entry = buildEntries(folder, entryMode, options, true, verbose);
|
|
1581
1469
|
const optionsResult = defineConfig({
|
|
1582
1470
|
bundle: true,
|
|
1583
1471
|
cjsInterop: true,
|
|
@@ -1605,7 +1493,7 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
|
1605
1493
|
if (verbose) {
|
|
1606
1494
|
console.log(`TSUP:build:stop [${folder}]`);
|
|
1607
1495
|
}
|
|
1608
|
-
packageCompileTscTypes(entry, outDir);
|
|
1496
|
+
await packageCompileTscTypes(entry, outDir);
|
|
1609
1497
|
return 0;
|
|
1610
1498
|
};
|
|
1611
1499
|
var tsupOptions = (options = []) => {
|
|
@@ -1648,6 +1536,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1648
1536
|
return typeof folder === "string" ? await compileFolder(
|
|
1649
1537
|
folder,
|
|
1650
1538
|
compile2?.entryMode,
|
|
1539
|
+
buildEntries(folder, compile2?.entryMode, options, true, verbose),
|
|
1651
1540
|
tsupOptions([
|
|
1652
1541
|
inEsBuildOptions,
|
|
1653
1542
|
compile2?.tsup?.options ?? {},
|
|
@@ -1664,6 +1553,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1664
1553
|
return typeof folder === "string" ? await compileFolder(
|
|
1665
1554
|
folder,
|
|
1666
1555
|
compile2?.entryMode,
|
|
1556
|
+
buildEntries(folder, compile2?.entryMode, options, true, verbose),
|
|
1667
1557
|
tsupOptions([
|
|
1668
1558
|
inEsBuildOptions,
|
|
1669
1559
|
compile2?.tsup?.options ?? {},
|
|
@@ -1680,6 +1570,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1680
1570
|
return typeof folder === "string" ? await compileFolder(
|
|
1681
1571
|
folder,
|
|
1682
1572
|
compile2?.entryMode,
|
|
1573
|
+
buildEntries(folder, compile2?.entryMode, options, true, verbose),
|
|
1683
1574
|
tsupOptions([
|
|
1684
1575
|
inEsBuildOptions,
|
|
1685
1576
|
compile2?.tsup?.options ?? {},
|
|
@@ -1695,7 +1586,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1695
1586
|
// src/actions/package/compile/compile.ts
|
|
1696
1587
|
var packageCompile = async (inConfig = {}) => {
|
|
1697
1588
|
const pkg = process.env.INIT_CWD;
|
|
1698
|
-
console.log(
|
|
1589
|
+
console.log(chalk26.green(`Compiling ${pkg}`));
|
|
1699
1590
|
const config2 = await loadConfig(inConfig);
|
|
1700
1591
|
const publint2 = config2.publint;
|
|
1701
1592
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1707,14 +1598,42 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1707
1598
|
|
|
1708
1599
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1709
1600
|
import { cwd as cwd2 } from "process";
|
|
1710
|
-
import
|
|
1711
|
-
import { createProgramFromConfig
|
|
1601
|
+
import chalk27 from "chalk";
|
|
1602
|
+
import { createProgramFromConfig } from "tsc-prog";
|
|
1712
1603
|
import {
|
|
1713
|
-
DiagnosticCategory
|
|
1714
|
-
formatDiagnosticsWithColorAndContext
|
|
1715
|
-
getPreEmitDiagnostics
|
|
1716
|
-
sys as
|
|
1604
|
+
DiagnosticCategory,
|
|
1605
|
+
formatDiagnosticsWithColorAndContext,
|
|
1606
|
+
getPreEmitDiagnostics,
|
|
1607
|
+
sys as sys2
|
|
1608
|
+
} from "typescript";
|
|
1609
|
+
|
|
1610
|
+
// src/actions/package/compile/getCompilerOptions.ts
|
|
1611
|
+
import { createRequire } from "module";
|
|
1612
|
+
import deepmerge2 from "deepmerge";
|
|
1613
|
+
import {
|
|
1614
|
+
findConfigFile,
|
|
1615
|
+
readConfigFile,
|
|
1616
|
+
sys
|
|
1717
1617
|
} from "typescript";
|
|
1618
|
+
var getNested = (config2) => {
|
|
1619
|
+
if (config2.extends) {
|
|
1620
|
+
const require2 = createRequire(import.meta.url);
|
|
1621
|
+
const opts = require2(config2.extends);
|
|
1622
|
+
return deepmerge2(getNested(opts), config2.compilerOptions ?? {});
|
|
1623
|
+
}
|
|
1624
|
+
return config2.compilerOptions;
|
|
1625
|
+
};
|
|
1626
|
+
var getCompilerOptionsJSONFollowExtends = (filename3) => {
|
|
1627
|
+
const config2 = readConfigFile(filename3, sys.readFile).config;
|
|
1628
|
+
return getNested(config2);
|
|
1629
|
+
};
|
|
1630
|
+
var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
1631
|
+
const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
|
|
1632
|
+
const configFileCompilerOptions = (configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0) ?? {};
|
|
1633
|
+
return deepmerge2(configFileCompilerOptions, options);
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
// src/actions/package/compile/packageCompileTsc.ts
|
|
1718
1637
|
var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1719
1638
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1720
1639
|
const verbose = config2?.verbose ?? false;
|
|
@@ -1732,36 +1651,36 @@ var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) =>
|
|
|
1732
1651
|
};
|
|
1733
1652
|
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1734
1653
|
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1735
|
-
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1736
|
-
console.log(
|
|
1654
|
+
const files = buildEntries(folder, "all", {}, true, verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1655
|
+
console.log(chalk27.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1737
1656
|
if (files.length > 0) {
|
|
1738
|
-
const program =
|
|
1657
|
+
const program = createProgramFromConfig({
|
|
1739
1658
|
basePath: pkg ?? cwd2(),
|
|
1740
1659
|
compilerOptions,
|
|
1741
1660
|
exclude: ["dist", "docs"],
|
|
1742
1661
|
files
|
|
1743
1662
|
});
|
|
1744
|
-
const diagnostics =
|
|
1663
|
+
const diagnostics = getPreEmitDiagnostics(program);
|
|
1745
1664
|
if (diagnostics.length > 0) {
|
|
1746
|
-
const formattedDiagnostics =
|
|
1665
|
+
const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
|
|
1747
1666
|
diagnostics,
|
|
1748
1667
|
{
|
|
1749
1668
|
getCanonicalFileName: (fileName) => fileName,
|
|
1750
1669
|
getCurrentDirectory: () => folder,
|
|
1751
|
-
getNewLine: () =>
|
|
1670
|
+
getNewLine: () => sys2.newLine
|
|
1752
1671
|
}
|
|
1753
1672
|
);
|
|
1754
1673
|
console.error(formattedDiagnostics);
|
|
1755
1674
|
}
|
|
1756
1675
|
program.emit();
|
|
1757
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category ===
|
|
1676
|
+
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1758
1677
|
}
|
|
1759
1678
|
return 0;
|
|
1760
1679
|
};
|
|
1761
1680
|
|
|
1762
1681
|
// src/actions/package/copy-assets.ts
|
|
1763
|
-
import
|
|
1764
|
-
import
|
|
1682
|
+
import path7 from "path/posix";
|
|
1683
|
+
import chalk28 from "chalk";
|
|
1765
1684
|
import cpy2 from "cpy";
|
|
1766
1685
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
1767
1686
|
try {
|
|
@@ -1769,12 +1688,12 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1769
1688
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1770
1689
|
`../dist/${target}`,
|
|
1771
1690
|
{
|
|
1772
|
-
cwd:
|
|
1691
|
+
cwd: path7.join(location, "src"),
|
|
1773
1692
|
flat: false
|
|
1774
1693
|
}
|
|
1775
1694
|
);
|
|
1776
1695
|
if (values.length > 0) {
|
|
1777
|
-
console.log(
|
|
1696
|
+
console.log(chalk28.green(`Copying Assets [${target.toUpperCase()}] - ${name} - ${location}`));
|
|
1778
1697
|
}
|
|
1779
1698
|
for (const value of values) {
|
|
1780
1699
|
console.log(`${value.split("/").pop()} => ./dist/${target}`);
|
|
@@ -1842,8 +1761,8 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1842
1761
|
|
|
1843
1762
|
// src/actions/package/gen-docs.ts
|
|
1844
1763
|
import { existsSync as existsSync4 } from "fs";
|
|
1845
|
-
import
|
|
1846
|
-
import
|
|
1764
|
+
import path8 from "path";
|
|
1765
|
+
import chalk29 from "chalk";
|
|
1847
1766
|
import {
|
|
1848
1767
|
Application,
|
|
1849
1768
|
ArgumentsReader,
|
|
@@ -1861,7 +1780,7 @@ var ExitCodes = {
|
|
|
1861
1780
|
};
|
|
1862
1781
|
var packageGenDocs = async () => {
|
|
1863
1782
|
const pkg = process.env.INIT_CWD;
|
|
1864
|
-
if (pkg && !existsSync4(
|
|
1783
|
+
if (pkg && !existsSync4(path8.join(pkg, "typedoc.json"))) {
|
|
1865
1784
|
return;
|
|
1866
1785
|
}
|
|
1867
1786
|
const app = await Application.bootstrap({
|
|
@@ -1947,16 +1866,16 @@ var runTypeDoc = async (app) => {
|
|
|
1947
1866
|
return ExitCodes.OutputError;
|
|
1948
1867
|
}
|
|
1949
1868
|
}
|
|
1950
|
-
console.log(
|
|
1869
|
+
console.log(chalk29.green(`${pkgName} - Ok`));
|
|
1951
1870
|
return ExitCodes.Ok;
|
|
1952
1871
|
};
|
|
1953
1872
|
|
|
1954
1873
|
// src/actions/package/lint.ts
|
|
1955
1874
|
import { readdirSync } from "fs";
|
|
1956
|
-
import
|
|
1875
|
+
import path9 from "path";
|
|
1957
1876
|
import { cwd as cwd3 } from "process";
|
|
1958
1877
|
import { pathToFileURL } from "url";
|
|
1959
|
-
import
|
|
1878
|
+
import chalk30 from "chalk";
|
|
1960
1879
|
import { ESLint } from "eslint";
|
|
1961
1880
|
import { findUp } from "find-up";
|
|
1962
1881
|
import picomatch from "picomatch";
|
|
@@ -1965,14 +1884,14 @@ var dumpMessages = (lintResults) => {
|
|
|
1965
1884
|
const severity = ["none", "warning", "error"];
|
|
1966
1885
|
for (const lintResult of lintResults) {
|
|
1967
1886
|
if (lintResult.messages.length > 0) {
|
|
1968
|
-
console.log(
|
|
1887
|
+
console.log(chalk30.gray(`
|
|
1969
1888
|
${lintResult.filePath}`));
|
|
1970
1889
|
for (const message of lintResult.messages) {
|
|
1971
1890
|
console.log(
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1891
|
+
chalk30.gray(` ${message.line}:${message.column}`),
|
|
1892
|
+
chalk30[colors[message.severity]](` ${severity[message.severity]}`),
|
|
1893
|
+
chalk30.white(` ${message.message}`),
|
|
1894
|
+
chalk30.gray(` ${message.ruleId}`)
|
|
1976
1895
|
);
|
|
1977
1896
|
}
|
|
1978
1897
|
}
|
|
@@ -1990,7 +1909,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1990
1909
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1991
1910
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1992
1911
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1993
|
-
const res =
|
|
1912
|
+
const res = path9.resolve(dir, dirent.name);
|
|
1994
1913
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
1995
1914
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1996
1915
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2011,7 +1930,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2011
1930
|
});
|
|
2012
1931
|
const files = getFiles(cwd3(), ignoreFolders);
|
|
2013
1932
|
if (verbose) {
|
|
2014
|
-
console.log(
|
|
1933
|
+
console.log(chalk30.green(`Linting ${pkg} [files = ${files.length}]`));
|
|
2015
1934
|
}
|
|
2016
1935
|
const lintResults = await engine.lintFiles(files);
|
|
2017
1936
|
dumpMessages(lintResults);
|
|
@@ -2021,7 +1940,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2021
1940
|
const filesCountColor = files.length < 100 ? "green" : files.length < 1e3 ? "yellow" : "red";
|
|
2022
1941
|
const lintTime = Date.now() - start;
|
|
2023
1942
|
const lintTimeColor = lintTime < 1e3 ? "green" : lintTime < 3e3 ? "yellow" : "red";
|
|
2024
|
-
console.log(
|
|
1943
|
+
console.log(chalk30.white(`Linted ${chalk30[filesCountColor](files.length)} files in ${chalk30[lintTimeColor](lintTime)}ms`));
|
|
2025
1944
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
2026
1945
|
};
|
|
2027
1946
|
|
|
@@ -2051,7 +1970,7 @@ var rebuild = ({ target }) => {
|
|
|
2051
1970
|
};
|
|
2052
1971
|
|
|
2053
1972
|
// src/actions/recompile.ts
|
|
2054
|
-
import
|
|
1973
|
+
import chalk31 from "chalk";
|
|
2055
1974
|
var recompile = async ({
|
|
2056
1975
|
verbose,
|
|
2057
1976
|
target,
|
|
@@ -2087,7 +2006,7 @@ var recompileAll = async ({
|
|
|
2087
2006
|
const incrementalOptions = incremental ? ["--since", "-Apt", "--topological-dev"] : ["--parallel", "-Apt", "--topological-dev"];
|
|
2088
2007
|
const jobsOptions = jobs ? ["-j", `${jobs}`] : [];
|
|
2089
2008
|
if (jobs) {
|
|
2090
|
-
console.log(
|
|
2009
|
+
console.log(chalk31.blue(`Jobs set to [${jobs}]`));
|
|
2091
2010
|
}
|
|
2092
2011
|
const result = await runStepsAsync(`Recompile${incremental ? "-Incremental" : ""} [All]`, [
|
|
2093
2012
|
[
|
|
@@ -2118,7 +2037,7 @@ var recompileAll = async ({
|
|
|
2118
2037
|
]
|
|
2119
2038
|
]);
|
|
2120
2039
|
console.log(
|
|
2121
|
-
`${
|
|
2040
|
+
`${chalk31.gray("Recompiled in")} [${chalk31.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk31.gray("seconds")}`
|
|
2122
2041
|
);
|
|
2123
2042
|
return result;
|
|
2124
2043
|
};
|
|
@@ -2149,9 +2068,9 @@ var reinstall = () => {
|
|
|
2149
2068
|
};
|
|
2150
2069
|
|
|
2151
2070
|
// src/actions/relint.ts
|
|
2152
|
-
import
|
|
2071
|
+
import chalk32 from "chalk";
|
|
2153
2072
|
var relintPackage = ({ pkg }) => {
|
|
2154
|
-
console.log(
|
|
2073
|
+
console.log(chalk32.gray(`${"Relint"} [All-Packages]`));
|
|
2155
2074
|
const start = Date.now();
|
|
2156
2075
|
const result = runSteps("Relint [All-Packages]", [
|
|
2157
2076
|
["yarn", [
|
|
@@ -2161,7 +2080,7 @@ var relintPackage = ({ pkg }) => {
|
|
|
2161
2080
|
"package-relint"
|
|
2162
2081
|
]]
|
|
2163
2082
|
]);
|
|
2164
|
-
console.log(
|
|
2083
|
+
console.log(chalk32.gray(`${"Relinted in"} [${chalk32.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk32.gray("seconds")}`));
|
|
2165
2084
|
return result;
|
|
2166
2085
|
};
|
|
2167
2086
|
var relint = ({
|
|
@@ -2172,7 +2091,7 @@ var relint = ({
|
|
|
2172
2091
|
return pkg ? relintPackage({ pkg }) : relintAllPackages({ verbose, incremental });
|
|
2173
2092
|
};
|
|
2174
2093
|
var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
2175
|
-
console.log(
|
|
2094
|
+
console.log(chalk32.gray(`${"Relint"} [All-Packages]`));
|
|
2176
2095
|
const start = Date.now();
|
|
2177
2096
|
const verboseOptions = verbose ? ["--verbose"] : ["--no-verbose"];
|
|
2178
2097
|
const incrementalOptions = incremental ? ["--since", "-Ap"] : ["--parallel", "-Ap"];
|
|
@@ -2186,7 +2105,7 @@ var relintAllPackages = ({ verbose = true, incremental } = {}) => {
|
|
|
2186
2105
|
"package-relint"
|
|
2187
2106
|
]]
|
|
2188
2107
|
]);
|
|
2189
|
-
console.log(
|
|
2108
|
+
console.log(chalk32.gray(`Relinted in [${chalk32.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk32.gray("seconds")}`));
|
|
2190
2109
|
return result;
|
|
2191
2110
|
};
|
|
2192
2111
|
|
|
@@ -2204,10 +2123,10 @@ var sonar = () => {
|
|
|
2204
2123
|
};
|
|
2205
2124
|
|
|
2206
2125
|
// src/actions/statics.ts
|
|
2207
|
-
import
|
|
2126
|
+
import chalk33 from "chalk";
|
|
2208
2127
|
var DefaultDependencies = ["axios", "@xylabs/pixel", "react", "graphql", "react-router", "@mui/material", "@mui/system"];
|
|
2209
2128
|
var statics = () => {
|
|
2210
|
-
console.log(
|
|
2129
|
+
console.log(chalk33.green("Check Required Static Dependencies"));
|
|
2211
2130
|
const statics2 = parsedPackageJSON()?.xy?.deps?.statics;
|
|
2212
2131
|
return detectDuplicateDependencies(statics2, DefaultDependencies);
|
|
2213
2132
|
};
|
|
@@ -2256,6 +2175,7 @@ var yarn3Only = () => {
|
|
|
2256
2175
|
};
|
|
2257
2176
|
export {
|
|
2258
2177
|
build,
|
|
2178
|
+
bundleDts,
|
|
2259
2179
|
clean,
|
|
2260
2180
|
cleanAll,
|
|
2261
2181
|
cleanDocs,
|