@xylabs/ts-scripts-yarn3 6.5.17 → 7.0.0-rc.1
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 +7 -25
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +2 -13
- package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +1 -1
- package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +7 -25
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +7 -25
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs +2 -9
- package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +7 -25
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +155 -129
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +82 -91
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +136 -92
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +58 -3
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +92 -120
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/index.mjs +142 -98
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +82 -91
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/bin/package/build-only.mjs +84 -93
- package/dist/bin/package/build-only.mjs.map +1 -1
- package/dist/bin/package/build.mjs +84 -93
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +84 -93
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +97 -125
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +84 -93
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +84 -93
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/xy.mjs +7 -25
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.mjs +155 -129
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +7 -25
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +7 -25
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +7 -25
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +6 -5
- package/dist/actions/package/compile/compileTypes.mjs +0 -138
- package/dist/actions/package/compile/compileTypes.mjs.map +0 -1
- package/dist/bin/package/compile-types.mjs +0 -150
- package/dist/bin/package/compile-types.mjs.map +0 -1
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 = (path11) => {
|
|
317
|
+
const pathToPackageJSON = path11 ?? 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(path11) {
|
|
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(path11, pattern));
|
|
688
|
+
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path11, pattern));
|
|
689
689
|
return { srcFiles, distFiles };
|
|
690
690
|
}
|
|
691
691
|
|
|
@@ -779,47 +779,29 @@ var removeInternalImports = (imports) => {
|
|
|
779
779
|
function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
780
780
|
const srcImportPaths = {};
|
|
781
781
|
const distImportPaths = {};
|
|
782
|
-
const
|
|
783
|
-
for (const
|
|
784
|
-
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
785
|
-
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
786
|
-
for (const path10 of distCodeFiles) getImportsFromFile(path10, distImportPaths, distImportPaths).flat();
|
|
787
|
-
for (const path10 of distTypeFiles) getImportsFromFile(path10, distTypeImportPaths, distTypeImportPaths).flat();
|
|
782
|
+
for (const path11 of srcFiles) getImportsFromFile(path11, srcImportPaths, srcImportPaths).flat();
|
|
783
|
+
for (const path11 of distFiles) getImportsFromFile(path11, distImportPaths, distImportPaths).flat();
|
|
788
784
|
const srcImports = Object.keys(srcImportPaths);
|
|
789
785
|
const distImports = Object.keys(distImportPaths);
|
|
790
|
-
const distTypeImports = Object.keys(distTypeImportPaths);
|
|
791
786
|
const externalSrcImports = removeInternalImports(srcImports);
|
|
792
787
|
const externalDistImports = removeInternalImports(distImports);
|
|
793
|
-
const externalDistTypeImports = removeInternalImports(distTypeImports);
|
|
794
788
|
return {
|
|
795
789
|
srcImports,
|
|
796
790
|
srcImportPaths,
|
|
797
791
|
externalSrcImports,
|
|
798
792
|
distImports,
|
|
799
793
|
distImportPaths,
|
|
800
|
-
externalDistImports
|
|
801
|
-
externalDistTypeImports
|
|
794
|
+
externalDistImports
|
|
802
795
|
};
|
|
803
796
|
}
|
|
804
797
|
|
|
805
798
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
806
799
|
import { builtinModules } from "module";
|
|
807
800
|
import chalk13 from "chalk";
|
|
808
|
-
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, {
|
|
809
|
-
externalDistImports,
|
|
810
|
-
externalDistTypeImports,
|
|
811
|
-
distImportPaths
|
|
812
|
-
}) {
|
|
801
|
+
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, { externalDistImports, distImportPaths }) {
|
|
813
802
|
let unlistedDependencies = 0;
|
|
814
803
|
for (const imp of externalDistImports) {
|
|
815
|
-
if (!dependencies.includes(imp) && !
|
|
816
|
-
unlistedDependencies++;
|
|
817
|
-
console.log(`[${chalk13.blue(name)}] Missing dependency in package.json: ${chalk13.red(imp)}`);
|
|
818
|
-
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
for (const imp of externalDistTypeImports) {
|
|
822
|
-
if (!dependencies.includes(imp) && dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && builtinModules.includes(`@types/${imp}`)) {
|
|
804
|
+
if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !builtinModules.includes(imp)) {
|
|
823
805
|
unlistedDependencies++;
|
|
824
806
|
console.log(`[${chalk13.blue(name)}] Missing dependency in package.json: ${chalk13.red(imp)}`);
|
|
825
807
|
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
@@ -847,7 +829,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
847
829
|
}) {
|
|
848
830
|
let unlistedDevDependencies = 0;
|
|
849
831
|
for (const imp of externalSrcImports) {
|
|
850
|
-
if (!distImports.includes(imp) && !dependencies.includes(imp) && !
|
|
832
|
+
if (!distImports.includes(imp) && !dependencies.includes(imp) && !peerDependencies.includes(imp) && !devDependencies.includes(imp) && !builtinModules2.includes(imp)) {
|
|
851
833
|
unlistedDevDependencies++;
|
|
852
834
|
console.log(`[${chalk14.blue(name)}] Missing devDependency in package.json: ${chalk14.red(imp)}`);
|
|
853
835
|
console.log(` ${srcImportPaths[imp].join("\n ")}`);
|
|
@@ -869,7 +851,7 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
869
851
|
}) {
|
|
870
852
|
let unusedDependencies = 0;
|
|
871
853
|
for (const dep of dependencies) {
|
|
872
|
-
if (!externalDistImports.includes(dep)
|
|
854
|
+
if (!externalDistImports.includes(dep)) {
|
|
873
855
|
unusedDependencies++;
|
|
874
856
|
if (externalSrcImports.includes(dep)) {
|
|
875
857
|
console.log(`[${chalk15.blue(name)}] dependency should be devDependency in package.json: ${chalk15.red(dep)}`);
|
|
@@ -891,7 +873,7 @@ import chalk16 from "chalk";
|
|
|
891
873
|
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports }) {
|
|
892
874
|
let unusedDependencies = 0;
|
|
893
875
|
for (const dep of peerDependencies) {
|
|
894
|
-
if (!externalDistImports.includes(dep)
|
|
876
|
+
if (!externalDistImports.includes(dep)) {
|
|
895
877
|
unusedDependencies++;
|
|
896
878
|
if (dependencies.includes(dep)) {
|
|
897
879
|
console.log(`[${chalk16.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk16.red(dep)}`);
|
|
@@ -1318,7 +1300,7 @@ var packageClean = async () => {
|
|
|
1318
1300
|
};
|
|
1319
1301
|
|
|
1320
1302
|
// src/actions/package/compile/compile.ts
|
|
1321
|
-
import
|
|
1303
|
+
import chalk27 from "chalk";
|
|
1322
1304
|
|
|
1323
1305
|
// src/actions/package/publint.ts
|
|
1324
1306
|
import { promises as fs4 } from "fs";
|
|
@@ -1394,8 +1376,34 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1394
1376
|
return entries;
|
|
1395
1377
|
};
|
|
1396
1378
|
|
|
1379
|
+
// src/actions/package/compile/deepMerge.ts
|
|
1380
|
+
function deepMerge(target, source) {
|
|
1381
|
+
if (!source || typeof source !== "object") return target;
|
|
1382
|
+
for (const key of Object.keys(source)) {
|
|
1383
|
+
if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
1384
|
+
if (!target[key] || typeof target[key] !== "object") {
|
|
1385
|
+
target[key] = {};
|
|
1386
|
+
}
|
|
1387
|
+
deepMerge(target[key], source[key]);
|
|
1388
|
+
} else {
|
|
1389
|
+
target[key] = source[key];
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return target;
|
|
1393
|
+
}
|
|
1394
|
+
function deepMergeObjects(objects) {
|
|
1395
|
+
const result = {};
|
|
1396
|
+
for (const obj of objects) {
|
|
1397
|
+
deepMerge(result, obj);
|
|
1398
|
+
}
|
|
1399
|
+
return result;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1397
1402
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1403
|
+
import { rm, writeFileSync as writeFileSync2 } from "fs";
|
|
1404
|
+
import path7 from "path";
|
|
1398
1405
|
import { cwd } from "process";
|
|
1406
|
+
import { Extractor, ExtractorConfig } from "@microsoft/api-extractor";
|
|
1399
1407
|
import chalk26 from "chalk";
|
|
1400
1408
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1401
1409
|
import {
|
|
@@ -1432,13 +1440,20 @@ var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
|
1432
1440
|
};
|
|
1433
1441
|
|
|
1434
1442
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1435
|
-
var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1443
|
+
var packageCompileTscTypes = (entries, outDir, folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1436
1444
|
const pkg = process.env.INIT_CWD ?? cwd();
|
|
1437
1445
|
const verbose = config2?.verbose ?? false;
|
|
1446
|
+
const tempDir = `${pkg}/.xylabs/ts-scripts-yarn3/compile/tsc/types/${Date.now()}`;
|
|
1447
|
+
rm(tempDir, { force: true, recursive: true }, (err) => {
|
|
1448
|
+
if (err) {
|
|
1449
|
+
console.error(chalk26.red(`Error removing temporary directory: ${tempDir}`), err);
|
|
1450
|
+
return 1;
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1438
1453
|
const compilerOptions = {
|
|
1439
1454
|
...getCompilerOptions({
|
|
1440
1455
|
emitDeclarationOnly: true,
|
|
1441
|
-
outDir:
|
|
1456
|
+
outDir: tempDir,
|
|
1442
1457
|
removeComments: false,
|
|
1443
1458
|
skipDefaultLibCheck: true,
|
|
1444
1459
|
skipLibCheck: true,
|
|
@@ -1472,90 +1487,52 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1472
1487
|
console.error(formattedDiagnostics);
|
|
1473
1488
|
}
|
|
1474
1489
|
program.emit();
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
};
|
|
1479
|
-
|
|
1480
|
-
// src/actions/package/compile/compileTypes.ts
|
|
1481
|
-
var packageCompileTypes = async (inConfig = {}) => {
|
|
1482
|
-
const config2 = await loadConfig(inConfig);
|
|
1483
|
-
return packageCompileTscTypes(void 0, config2);
|
|
1484
|
-
};
|
|
1485
|
-
|
|
1486
|
-
// src/actions/package/compile/deepMerge.ts
|
|
1487
|
-
function deepMerge(target, source) {
|
|
1488
|
-
if (!source || typeof source !== "object") return target;
|
|
1489
|
-
for (const key of Object.keys(source)) {
|
|
1490
|
-
if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
1491
|
-
if (!target[key] || typeof target[key] !== "object") {
|
|
1492
|
-
target[key] = {};
|
|
1493
|
-
}
|
|
1494
|
-
deepMerge(target[key], source[key]);
|
|
1495
|
-
} else {
|
|
1496
|
-
target[key] = source[key];
|
|
1490
|
+
const tscErrorCount = diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1491
|
+
if (tscErrorCount > 0) {
|
|
1492
|
+
return tscErrorCount;
|
|
1497
1493
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
const program = createProgramFromConfig2({
|
|
1540
|
-
basePath: pkg ?? cwd2(),
|
|
1541
|
-
compilerOptions,
|
|
1542
|
-
exclude: ["dist", "docs"],
|
|
1543
|
-
files
|
|
1544
|
-
});
|
|
1545
|
-
const diagnostics = getPreEmitDiagnostics2(program);
|
|
1546
|
-
if (diagnostics.length > 0) {
|
|
1547
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
|
|
1548
|
-
diagnostics,
|
|
1549
|
-
{
|
|
1550
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
1551
|
-
getCurrentDirectory: () => folder,
|
|
1552
|
-
getNewLine: () => sys3.newLine
|
|
1553
|
-
}
|
|
1554
|
-
);
|
|
1555
|
-
console.error(formattedDiagnostics);
|
|
1494
|
+
const entryNameToTypeName = (entry) => {
|
|
1495
|
+
const splitEntryName = entry.split(".");
|
|
1496
|
+
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
1497
|
+
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
1498
|
+
};
|
|
1499
|
+
const entryNames = entries.map((entry) => entry.split(`${folder}/`).at(-1) ?? entry);
|
|
1500
|
+
for (const entry of entryNames) {
|
|
1501
|
+
const entryTypeName = entryNameToTypeName(entry);
|
|
1502
|
+
const configObject = {
|
|
1503
|
+
projectFolder: ".",
|
|
1504
|
+
mainEntryPointFilePath: path7.resolve([tempDir, entryTypeName].join("/")),
|
|
1505
|
+
bundledPackages: [],
|
|
1506
|
+
compiler: { tsconfigFilePath: path7.resolve(`${pkg}/tsconfig.json`) },
|
|
1507
|
+
dtsRollup: {
|
|
1508
|
+
enabled: true,
|
|
1509
|
+
untrimmedFilePath: path7.resolve(`${outDir}/${entryTypeName}`)
|
|
1510
|
+
},
|
|
1511
|
+
apiReport: { enabled: false },
|
|
1512
|
+
docModel: { enabled: false },
|
|
1513
|
+
tsdocMetadata: { enabled: false }
|
|
1514
|
+
};
|
|
1515
|
+
writeFileSync2(`${tempDir}/api-extractor.json`, JSON.stringify(configObject, null, 2));
|
|
1516
|
+
const extractorConfig = ExtractorConfig.prepare({
|
|
1517
|
+
configObject,
|
|
1518
|
+
configObjectFullPath: path7.resolve(`${tempDir}/api-extractor.json`),
|
|
1519
|
+
// just a virtual label, doesn't have to exist
|
|
1520
|
+
packageJsonFullPath: path7.resolve("package.json")
|
|
1521
|
+
});
|
|
1522
|
+
const extractorResult = Extractor.invoke(extractorConfig, {
|
|
1523
|
+
localBuild: true,
|
|
1524
|
+
showVerboseMessages: true
|
|
1525
|
+
});
|
|
1526
|
+
if (extractorResult.succeeded) {
|
|
1527
|
+
console.log("API Extractor completed successfully");
|
|
1528
|
+
process.exitCode = 0;
|
|
1529
|
+
} else {
|
|
1530
|
+
console.error(
|
|
1531
|
+
`API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings`
|
|
1532
|
+
);
|
|
1533
|
+
process.exitCode = 1;
|
|
1534
|
+
}
|
|
1556
1535
|
}
|
|
1557
|
-
program.emit();
|
|
1558
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
|
|
1559
1536
|
}
|
|
1560
1537
|
return 0;
|
|
1561
1538
|
};
|
|
@@ -1594,6 +1571,7 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
|
1594
1571
|
if (verbose) {
|
|
1595
1572
|
console.log(`TSUP:build:stop [${folder}]`);
|
|
1596
1573
|
}
|
|
1574
|
+
packageCompileTscTypes(entry, outDir);
|
|
1597
1575
|
return 0;
|
|
1598
1576
|
};
|
|
1599
1577
|
var tsupOptions = (options = []) => {
|
|
@@ -1629,11 +1607,6 @@ var packageCompileTsup = async (config2) => {
|
|
|
1629
1607
|
if (verbose) {
|
|
1630
1608
|
console.log("Calling packageCompileTscTypes");
|
|
1631
1609
|
}
|
|
1632
|
-
let errors = await packageCompileTypes(config2);
|
|
1633
|
-
errors = errors + packageCompileTsc(void 0, config2);
|
|
1634
|
-
if (errors > 0) {
|
|
1635
|
-
return errors;
|
|
1636
|
-
}
|
|
1637
1610
|
return (await Promise.all(
|
|
1638
1611
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
1639
1612
|
const optionsObject = typeof options === "object" ? options : {};
|
|
@@ -1688,7 +1661,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1688
1661
|
// src/actions/package/compile/compile.ts
|
|
1689
1662
|
var packageCompile = async (inConfig = {}) => {
|
|
1690
1663
|
const pkg = process.env.INIT_CWD;
|
|
1691
|
-
console.log(
|
|
1664
|
+
console.log(chalk27.green(`Compiling ${pkg}`));
|
|
1692
1665
|
const config2 = await loadConfig(inConfig);
|
|
1693
1666
|
const publint2 = config2.publint;
|
|
1694
1667
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1698,8 +1671,62 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1698
1671
|
return publint2 ? await packagePublint(config2) : 0;
|
|
1699
1672
|
};
|
|
1700
1673
|
|
|
1674
|
+
// src/actions/package/compile/packageCompileTsc.ts
|
|
1675
|
+
import { cwd as cwd2 } from "process";
|
|
1676
|
+
import chalk28 from "chalk";
|
|
1677
|
+
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1678
|
+
import {
|
|
1679
|
+
DiagnosticCategory as DiagnosticCategory2,
|
|
1680
|
+
formatDiagnosticsWithColorAndContext as formatDiagnosticsWithColorAndContext2,
|
|
1681
|
+
getPreEmitDiagnostics as getPreEmitDiagnostics2,
|
|
1682
|
+
sys as sys3
|
|
1683
|
+
} from "typescript";
|
|
1684
|
+
var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1685
|
+
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1686
|
+
const verbose = config2?.verbose ?? false;
|
|
1687
|
+
const compilerOptions = {
|
|
1688
|
+
...getCompilerOptions({
|
|
1689
|
+
outDir: "dist/types",
|
|
1690
|
+
removeComments: false,
|
|
1691
|
+
skipDefaultLibCheck: true,
|
|
1692
|
+
skipLibCheck: true,
|
|
1693
|
+
sourceMap: false
|
|
1694
|
+
}),
|
|
1695
|
+
...compilerOptionsParam,
|
|
1696
|
+
emitDeclarationOnly: false,
|
|
1697
|
+
noEmit: true
|
|
1698
|
+
};
|
|
1699
|
+
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1700
|
+
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1701
|
+
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1702
|
+
console.log(chalk28.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1703
|
+
if (files.length > 0) {
|
|
1704
|
+
const program = createProgramFromConfig2({
|
|
1705
|
+
basePath: pkg ?? cwd2(),
|
|
1706
|
+
compilerOptions,
|
|
1707
|
+
exclude: ["dist", "docs"],
|
|
1708
|
+
files
|
|
1709
|
+
});
|
|
1710
|
+
const diagnostics = getPreEmitDiagnostics2(program);
|
|
1711
|
+
if (diagnostics.length > 0) {
|
|
1712
|
+
const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
|
|
1713
|
+
diagnostics,
|
|
1714
|
+
{
|
|
1715
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
1716
|
+
getCurrentDirectory: () => folder,
|
|
1717
|
+
getNewLine: () => sys3.newLine
|
|
1718
|
+
}
|
|
1719
|
+
);
|
|
1720
|
+
console.error(formattedDiagnostics);
|
|
1721
|
+
}
|
|
1722
|
+
program.emit();
|
|
1723
|
+
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
|
|
1724
|
+
}
|
|
1725
|
+
return 0;
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1701
1728
|
// src/actions/package/copy-assets.ts
|
|
1702
|
-
import
|
|
1729
|
+
import path8 from "path/posix";
|
|
1703
1730
|
import chalk29 from "chalk";
|
|
1704
1731
|
import cpy2 from "cpy";
|
|
1705
1732
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
@@ -1708,7 +1735,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1708
1735
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1709
1736
|
`../dist/${target}`,
|
|
1710
1737
|
{
|
|
1711
|
-
cwd:
|
|
1738
|
+
cwd: path8.join(location, "src"),
|
|
1712
1739
|
flat: false
|
|
1713
1740
|
}
|
|
1714
1741
|
);
|
|
@@ -1781,7 +1808,7 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1781
1808
|
|
|
1782
1809
|
// src/actions/package/gen-docs.ts
|
|
1783
1810
|
import { existsSync as existsSync4 } from "fs";
|
|
1784
|
-
import
|
|
1811
|
+
import path9 from "path";
|
|
1785
1812
|
import chalk30 from "chalk";
|
|
1786
1813
|
import {
|
|
1787
1814
|
Application,
|
|
@@ -1800,7 +1827,7 @@ var ExitCodes = {
|
|
|
1800
1827
|
};
|
|
1801
1828
|
var packageGenDocs = async () => {
|
|
1802
1829
|
const pkg = process.env.INIT_CWD;
|
|
1803
|
-
if (pkg && !existsSync4(
|
|
1830
|
+
if (pkg && !existsSync4(path9.join(pkg, "typedoc.json"))) {
|
|
1804
1831
|
return;
|
|
1805
1832
|
}
|
|
1806
1833
|
const app = await Application.bootstrap({
|
|
@@ -1892,7 +1919,7 @@ var runTypeDoc = async (app) => {
|
|
|
1892
1919
|
|
|
1893
1920
|
// src/actions/package/lint.ts
|
|
1894
1921
|
import { readdirSync } from "fs";
|
|
1895
|
-
import
|
|
1922
|
+
import path10 from "path";
|
|
1896
1923
|
import { cwd as cwd3 } from "process";
|
|
1897
1924
|
import { pathToFileURL } from "url";
|
|
1898
1925
|
import chalk31 from "chalk";
|
|
@@ -1929,7 +1956,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1929
1956
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1930
1957
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1931
1958
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1932
|
-
const res =
|
|
1959
|
+
const res = path10.resolve(dir, dirent.name);
|
|
1933
1960
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
1934
1961
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1935
1962
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2236,7 +2263,6 @@ export {
|
|
|
2236
2263
|
packageCompileTsc,
|
|
2237
2264
|
packageCompileTscTypes,
|
|
2238
2265
|
packageCompileTsup,
|
|
2239
|
-
packageCompileTypes,
|
|
2240
2266
|
packageCopyAssets,
|
|
2241
2267
|
packageCycle,
|
|
2242
2268
|
packageGenDocs,
|