@xylabs/ts-scripts-yarn3 6.5.18 → 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 +8 -27
- 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 -2
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +2 -2
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +8 -27
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +8 -27
- 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 +8 -27
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +156 -131
- 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 +8 -27
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.mjs +156 -131
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +8 -27
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +8 -27
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +8 -27
- 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 ")}`);
|
|
@@ -865,12 +847,11 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
865
847
|
import chalk15 from "chalk";
|
|
866
848
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
867
849
|
externalDistImports,
|
|
868
|
-
externalDistTypeImports,
|
|
869
850
|
externalSrcImports
|
|
870
851
|
}) {
|
|
871
852
|
let unusedDependencies = 0;
|
|
872
853
|
for (const dep of dependencies) {
|
|
873
|
-
if (!externalDistImports.includes(dep)
|
|
854
|
+
if (!externalDistImports.includes(dep)) {
|
|
874
855
|
unusedDependencies++;
|
|
875
856
|
if (externalSrcImports.includes(dep)) {
|
|
876
857
|
console.log(`[${chalk15.blue(name)}] dependency should be devDependency in package.json: ${chalk15.red(dep)}`);
|
|
@@ -889,10 +870,10 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
889
870
|
|
|
890
871
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
891
872
|
import chalk16 from "chalk";
|
|
892
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports
|
|
873
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports }) {
|
|
893
874
|
let unusedDependencies = 0;
|
|
894
875
|
for (const dep of peerDependencies) {
|
|
895
|
-
if (!externalDistImports.includes(dep)
|
|
876
|
+
if (!externalDistImports.includes(dep)) {
|
|
896
877
|
unusedDependencies++;
|
|
897
878
|
if (dependencies.includes(dep)) {
|
|
898
879
|
console.log(`[${chalk16.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk16.red(dep)}`);
|
|
@@ -1319,7 +1300,7 @@ var packageClean = async () => {
|
|
|
1319
1300
|
};
|
|
1320
1301
|
|
|
1321
1302
|
// src/actions/package/compile/compile.ts
|
|
1322
|
-
import
|
|
1303
|
+
import chalk27 from "chalk";
|
|
1323
1304
|
|
|
1324
1305
|
// src/actions/package/publint.ts
|
|
1325
1306
|
import { promises as fs4 } from "fs";
|
|
@@ -1395,8 +1376,34 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1395
1376
|
return entries;
|
|
1396
1377
|
};
|
|
1397
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
|
+
|
|
1398
1402
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1403
|
+
import { rm, writeFileSync as writeFileSync2 } from "fs";
|
|
1404
|
+
import path7 from "path";
|
|
1399
1405
|
import { cwd } from "process";
|
|
1406
|
+
import { Extractor, ExtractorConfig } from "@microsoft/api-extractor";
|
|
1400
1407
|
import chalk26 from "chalk";
|
|
1401
1408
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1402
1409
|
import {
|
|
@@ -1433,13 +1440,20 @@ var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
|
1433
1440
|
};
|
|
1434
1441
|
|
|
1435
1442
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1436
|
-
var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1443
|
+
var packageCompileTscTypes = (entries, outDir, folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1437
1444
|
const pkg = process.env.INIT_CWD ?? cwd();
|
|
1438
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
|
+
});
|
|
1439
1453
|
const compilerOptions = {
|
|
1440
1454
|
...getCompilerOptions({
|
|
1441
1455
|
emitDeclarationOnly: true,
|
|
1442
|
-
outDir:
|
|
1456
|
+
outDir: tempDir,
|
|
1443
1457
|
removeComments: false,
|
|
1444
1458
|
skipDefaultLibCheck: true,
|
|
1445
1459
|
skipLibCheck: true,
|
|
@@ -1473,90 +1487,52 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1473
1487
|
console.error(formattedDiagnostics);
|
|
1474
1488
|
}
|
|
1475
1489
|
program.emit();
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
|
-
// src/actions/package/compile/compileTypes.ts
|
|
1482
|
-
var packageCompileTypes = async (inConfig = {}) => {
|
|
1483
|
-
const config2 = await loadConfig(inConfig);
|
|
1484
|
-
return packageCompileTscTypes(void 0, config2);
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
// src/actions/package/compile/deepMerge.ts
|
|
1488
|
-
function deepMerge(target, source) {
|
|
1489
|
-
if (!source || typeof source !== "object") return target;
|
|
1490
|
-
for (const key of Object.keys(source)) {
|
|
1491
|
-
if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
1492
|
-
if (!target[key] || typeof target[key] !== "object") {
|
|
1493
|
-
target[key] = {};
|
|
1494
|
-
}
|
|
1495
|
-
deepMerge(target[key], source[key]);
|
|
1496
|
-
} else {
|
|
1497
|
-
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;
|
|
1498
1493
|
}
|
|
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
|
-
|
|
1540
|
-
const program = createProgramFromConfig2({
|
|
1541
|
-
basePath: pkg ?? cwd2(),
|
|
1542
|
-
compilerOptions,
|
|
1543
|
-
exclude: ["dist", "docs"],
|
|
1544
|
-
files
|
|
1545
|
-
});
|
|
1546
|
-
const diagnostics = getPreEmitDiagnostics2(program);
|
|
1547
|
-
if (diagnostics.length > 0) {
|
|
1548
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
|
|
1549
|
-
diagnostics,
|
|
1550
|
-
{
|
|
1551
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
1552
|
-
getCurrentDirectory: () => folder,
|
|
1553
|
-
getNewLine: () => sys3.newLine
|
|
1554
|
-
}
|
|
1555
|
-
);
|
|
1556
|
-
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
|
+
}
|
|
1557
1535
|
}
|
|
1558
|
-
program.emit();
|
|
1559
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
|
|
1560
1536
|
}
|
|
1561
1537
|
return 0;
|
|
1562
1538
|
};
|
|
@@ -1595,6 +1571,7 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
|
1595
1571
|
if (verbose) {
|
|
1596
1572
|
console.log(`TSUP:build:stop [${folder}]`);
|
|
1597
1573
|
}
|
|
1574
|
+
packageCompileTscTypes(entry, outDir);
|
|
1598
1575
|
return 0;
|
|
1599
1576
|
};
|
|
1600
1577
|
var tsupOptions = (options = []) => {
|
|
@@ -1630,11 +1607,6 @@ var packageCompileTsup = async (config2) => {
|
|
|
1630
1607
|
if (verbose) {
|
|
1631
1608
|
console.log("Calling packageCompileTscTypes");
|
|
1632
1609
|
}
|
|
1633
|
-
let errors = await packageCompileTypes(config2);
|
|
1634
|
-
errors = errors + packageCompileTsc(void 0, config2);
|
|
1635
|
-
if (errors > 0) {
|
|
1636
|
-
return errors;
|
|
1637
|
-
}
|
|
1638
1610
|
return (await Promise.all(
|
|
1639
1611
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
1640
1612
|
const optionsObject = typeof options === "object" ? options : {};
|
|
@@ -1689,7 +1661,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1689
1661
|
// src/actions/package/compile/compile.ts
|
|
1690
1662
|
var packageCompile = async (inConfig = {}) => {
|
|
1691
1663
|
const pkg = process.env.INIT_CWD;
|
|
1692
|
-
console.log(
|
|
1664
|
+
console.log(chalk27.green(`Compiling ${pkg}`));
|
|
1693
1665
|
const config2 = await loadConfig(inConfig);
|
|
1694
1666
|
const publint2 = config2.publint;
|
|
1695
1667
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1699,8 +1671,62 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1699
1671
|
return publint2 ? await packagePublint(config2) : 0;
|
|
1700
1672
|
};
|
|
1701
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
|
+
|
|
1702
1728
|
// src/actions/package/copy-assets.ts
|
|
1703
|
-
import
|
|
1729
|
+
import path8 from "path/posix";
|
|
1704
1730
|
import chalk29 from "chalk";
|
|
1705
1731
|
import cpy2 from "cpy";
|
|
1706
1732
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
@@ -1709,7 +1735,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1709
1735
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1710
1736
|
`../dist/${target}`,
|
|
1711
1737
|
{
|
|
1712
|
-
cwd:
|
|
1738
|
+
cwd: path8.join(location, "src"),
|
|
1713
1739
|
flat: false
|
|
1714
1740
|
}
|
|
1715
1741
|
);
|
|
@@ -1782,7 +1808,7 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1782
1808
|
|
|
1783
1809
|
// src/actions/package/gen-docs.ts
|
|
1784
1810
|
import { existsSync as existsSync4 } from "fs";
|
|
1785
|
-
import
|
|
1811
|
+
import path9 from "path";
|
|
1786
1812
|
import chalk30 from "chalk";
|
|
1787
1813
|
import {
|
|
1788
1814
|
Application,
|
|
@@ -1801,7 +1827,7 @@ var ExitCodes = {
|
|
|
1801
1827
|
};
|
|
1802
1828
|
var packageGenDocs = async () => {
|
|
1803
1829
|
const pkg = process.env.INIT_CWD;
|
|
1804
|
-
if (pkg && !existsSync4(
|
|
1830
|
+
if (pkg && !existsSync4(path9.join(pkg, "typedoc.json"))) {
|
|
1805
1831
|
return;
|
|
1806
1832
|
}
|
|
1807
1833
|
const app = await Application.bootstrap({
|
|
@@ -1893,7 +1919,7 @@ var runTypeDoc = async (app) => {
|
|
|
1893
1919
|
|
|
1894
1920
|
// src/actions/package/lint.ts
|
|
1895
1921
|
import { readdirSync } from "fs";
|
|
1896
|
-
import
|
|
1922
|
+
import path10 from "path";
|
|
1897
1923
|
import { cwd as cwd3 } from "process";
|
|
1898
1924
|
import { pathToFileURL } from "url";
|
|
1899
1925
|
import chalk31 from "chalk";
|
|
@@ -1930,7 +1956,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1930
1956
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1931
1957
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1932
1958
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1933
|
-
const res =
|
|
1959
|
+
const res = path10.resolve(dir, dirent.name);
|
|
1934
1960
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
1935
1961
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1936
1962
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2237,7 +2263,6 @@ export {
|
|
|
2237
2263
|
packageCompileTsc,
|
|
2238
2264
|
packageCompileTscTypes,
|
|
2239
2265
|
packageCompileTsup,
|
|
2240
|
-
packageCompileTypes,
|
|
2241
2266
|
packageCopyAssets,
|
|
2242
2267
|
packageCycle,
|
|
2243
2268
|
packageGenDocs,
|