@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/index.d.ts
CHANGED
|
@@ -190,11 +190,9 @@ type XyConfig = XyTsupConfig | XyTscConfig;
|
|
|
190
190
|
|
|
191
191
|
declare const packageCompile: (inConfig?: XyConfig) => Promise<number>;
|
|
192
192
|
|
|
193
|
-
declare const packageCompileTypes: (inConfig?: XyConfig) => Promise<number>;
|
|
194
|
-
|
|
195
193
|
declare const packageCompileTsc: (folder?: string, config?: XyConfig, compilerOptionsParam?: CompilerOptions) => number;
|
|
196
194
|
|
|
197
|
-
declare const packageCompileTscTypes: (folder?: string, config?: XyConfig, compilerOptionsParam?: CompilerOptions) => number;
|
|
195
|
+
declare const packageCompileTscTypes: (entries: string[], outDir: string, folder?: string, config?: XyConfig, compilerOptionsParam?: CompilerOptions) => number;
|
|
198
196
|
|
|
199
197
|
declare const tsupOptions: (options?: Options[]) => Options;
|
|
200
198
|
declare const packageCompileTsup: (config?: XyTsupConfig) => Promise<number>;
|
|
@@ -399,4 +397,4 @@ declare const xyLintCommands: (args: Argv) => Argv<{}>;
|
|
|
399
397
|
|
|
400
398
|
declare const xyParseOptions: () => Argv;
|
|
401
399
|
|
|
402
|
-
export { type BuildParams, CROSS_PLATFORM_NEWLINE, type CleanPackageParams, type CleanParams, type CompileConfig, type CompileParams, type CompileTypesParams, type CopyAssetsParams, type CycleParams, DuplicateDetector, type DynamicShareConfig, type EntryMode, type GenDocsPackageParams, type GenDocsParams, INIT_CWD, type LintPackageParams, type LintParams, type LiveShareConfig, type PackageCompileTscConfig, type PackageCompileTsupConfig, type PackageCopyAssetsParams, type PackageJsonEx, type PackagePublintParams, type PathConfig, type PublintPackageParams, type PublintParams, type ReadFileSyncOptions, type RebuildParams, type RecompilePackageParams, type RecompileParams, type RelintPackageParams, type RelintParams, type ScriptStep, WINDOWS_NEWLINE_REGEX, type Workspace, type XyConfig, type XyConfigBase, type XyTscConfig, type XyTsupConfig, build, checkResult, clean, cleanAll, cleanDocs, cleanPackage, compile, compileAll, compilePackage, compileTypes, compileTypesAll, compileTypesPackage, copyAssets, createBuildConfig, cycle, cycleAll, cyclePackage, dead, defaultBuildConfig, defaultReadFileSyncOptions, deleteGlob, deplint, deploy, deployMajor, deployMinor, deployNext, detectDuplicateDependencies, dupdeps, empty, fix, genDocs, genDocsAll, genDocsPackage, generateIgnoreFiles, gitignoreGen, gitlint, gitlintFix, isYarnVersionOrGreater, knip, license, lint, lintAllPackages, lintPackage, loadConfig, loadPackageConfig, multiLineToJSONArray, notEmpty, npmignoreGen, packageClean, packageCleanOutputs, packageCleanTypescript, packageCompile, packageCompileTsc, packageCompileTscTypes, packageCompileTsup,
|
|
400
|
+
export { type BuildParams, CROSS_PLATFORM_NEWLINE, type CleanPackageParams, type CleanParams, type CompileConfig, type CompileParams, type CompileTypesParams, type CopyAssetsParams, type CycleParams, DuplicateDetector, type DynamicShareConfig, type EntryMode, type GenDocsPackageParams, type GenDocsParams, INIT_CWD, type LintPackageParams, type LintParams, type LiveShareConfig, type PackageCompileTscConfig, type PackageCompileTsupConfig, type PackageCopyAssetsParams, type PackageJsonEx, type PackagePublintParams, type PathConfig, type PublintPackageParams, type PublintParams, type ReadFileSyncOptions, type RebuildParams, type RecompilePackageParams, type RecompileParams, type RelintPackageParams, type RelintParams, type ScriptStep, WINDOWS_NEWLINE_REGEX, type Workspace, type XyConfig, type XyConfigBase, type XyTscConfig, type XyTsupConfig, build, checkResult, clean, cleanAll, cleanDocs, cleanPackage, compile, compileAll, compilePackage, compileTypes, compileTypesAll, compileTypesPackage, copyAssets, createBuildConfig, cycle, cycleAll, cyclePackage, dead, defaultBuildConfig, defaultReadFileSyncOptions, deleteGlob, deplint, deploy, deployMajor, deployMinor, deployNext, detectDuplicateDependencies, dupdeps, empty, fix, genDocs, genDocsAll, genDocsPackage, generateIgnoreFiles, gitignoreGen, gitlint, gitlintFix, isYarnVersionOrGreater, knip, license, lint, lintAllPackages, lintPackage, loadConfig, loadPackageConfig, multiLineToJSONArray, notEmpty, npmignoreGen, packageClean, packageCleanOutputs, packageCleanTypescript, packageCompile, packageCompileTsc, packageCompileTscTypes, packageCompileTsup, packageCopyAssets, packageCycle, packageGenDocs, packageLint, packagePublint, packageRecompile, parsedPackageJSON, processEx, publint, publintAll, publintPackage, readLines, readNonEmptyLines, rebuild, recompile, recompileAll, recompilePackage, reinstall, relint, relintAllPackages, relintPackage, retest, runStepAsync, runSteps, runStepsAsync, runXy, runXyWithWarning, safeExit, safeExitAsync, sonar, statics, test, tryReadFileSync, tsupOptions, union, up, updateYarnPlugins, updateYarnVersion, updo, withErrnoException, withError, writeLines, xy, xyBuildCommands, xyCommonCommands, xyDeployCommands, xyInstallCommands, xyLintCommands, xyParseOptions, yarn3Only, yarnWorkspace, yarnWorkspaces };
|
package/dist/index.mjs
CHANGED
|
@@ -371,8 +371,8 @@ var loadConfig = async (params) => {
|
|
|
371
371
|
|
|
372
372
|
// src/lib/parsedPackageJSON.ts
|
|
373
373
|
import { readFileSync as readFileSync4 } from "fs";
|
|
374
|
-
var parsedPackageJSON = (
|
|
375
|
-
const pathToPackageJSON =
|
|
374
|
+
var parsedPackageJSON = (path11) => {
|
|
375
|
+
const pathToPackageJSON = path11 ?? process.env.npm_package_json ?? "";
|
|
376
376
|
const packageJSON = readFileSync4(pathToPackageJSON).toString();
|
|
377
377
|
return JSON.parse(packageJSON);
|
|
378
378
|
};
|
|
@@ -757,11 +757,11 @@ function findFilesByGlob(cwd4, pattern) {
|
|
|
757
757
|
}
|
|
758
758
|
|
|
759
759
|
// src/actions/deplint/findFiles.ts
|
|
760
|
-
function findFiles(
|
|
760
|
+
function findFiles(path11) {
|
|
761
761
|
const allSourceInclude = ["./src/**/*.{ts,tsx}"];
|
|
762
762
|
const allDistInclude = ["./dist/**/*.d.ts", "./dist/**/*.{mjs,js,cjs}"];
|
|
763
|
-
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(
|
|
764
|
-
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(
|
|
763
|
+
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path11, pattern));
|
|
764
|
+
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path11, pattern));
|
|
765
765
|
return { srcFiles, distFiles };
|
|
766
766
|
}
|
|
767
767
|
|
|
@@ -855,47 +855,29 @@ var removeInternalImports = (imports) => {
|
|
|
855
855
|
function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
856
856
|
const srcImportPaths = {};
|
|
857
857
|
const distImportPaths = {};
|
|
858
|
-
const
|
|
859
|
-
for (const
|
|
860
|
-
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
861
|
-
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
862
|
-
for (const path10 of distCodeFiles) getImportsFromFile(path10, distImportPaths, distImportPaths).flat();
|
|
863
|
-
for (const path10 of distTypeFiles) getImportsFromFile(path10, distTypeImportPaths, distTypeImportPaths).flat();
|
|
858
|
+
for (const path11 of srcFiles) getImportsFromFile(path11, srcImportPaths, srcImportPaths).flat();
|
|
859
|
+
for (const path11 of distFiles) getImportsFromFile(path11, distImportPaths, distImportPaths).flat();
|
|
864
860
|
const srcImports = Object.keys(srcImportPaths);
|
|
865
861
|
const distImports = Object.keys(distImportPaths);
|
|
866
|
-
const distTypeImports = Object.keys(distTypeImportPaths);
|
|
867
862
|
const externalSrcImports = removeInternalImports(srcImports);
|
|
868
863
|
const externalDistImports = removeInternalImports(distImports);
|
|
869
|
-
const externalDistTypeImports = removeInternalImports(distTypeImports);
|
|
870
864
|
return {
|
|
871
865
|
srcImports,
|
|
872
866
|
srcImportPaths,
|
|
873
867
|
externalSrcImports,
|
|
874
868
|
distImports,
|
|
875
869
|
distImportPaths,
|
|
876
|
-
externalDistImports
|
|
877
|
-
externalDistTypeImports
|
|
870
|
+
externalDistImports
|
|
878
871
|
};
|
|
879
872
|
}
|
|
880
873
|
|
|
881
874
|
// src/actions/deplint/checkPackage/getUnlistedDependencies.ts
|
|
882
875
|
import { builtinModules } from "module";
|
|
883
876
|
import chalk14 from "chalk";
|
|
884
|
-
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, {
|
|
885
|
-
externalDistImports,
|
|
886
|
-
externalDistTypeImports,
|
|
887
|
-
distImportPaths
|
|
888
|
-
}) {
|
|
877
|
+
function getUnlistedDependencies({ name, location }, { dependencies, peerDependencies }, { externalDistImports, distImportPaths }) {
|
|
889
878
|
let unlistedDependencies = 0;
|
|
890
879
|
for (const imp of externalDistImports) {
|
|
891
|
-
if (!dependencies.includes(imp) && !
|
|
892
|
-
unlistedDependencies++;
|
|
893
|
-
console.log(`[${chalk14.blue(name)}] Missing dependency in package.json: ${chalk14.red(imp)}`);
|
|
894
|
-
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
for (const imp of externalDistTypeImports) {
|
|
898
|
-
if (!dependencies.includes(imp) && dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && builtinModules.includes(`@types/${imp}`)) {
|
|
880
|
+
if (!dependencies.includes(imp) && !peerDependencies.includes(imp) && !builtinModules.includes(imp)) {
|
|
899
881
|
unlistedDependencies++;
|
|
900
882
|
console.log(`[${chalk14.blue(name)}] Missing dependency in package.json: ${chalk14.red(imp)}`);
|
|
901
883
|
console.log(` ${distImportPaths[imp].join("\n ")}`);
|
|
@@ -923,7 +905,7 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
923
905
|
}) {
|
|
924
906
|
let unlistedDevDependencies = 0;
|
|
925
907
|
for (const imp of externalSrcImports) {
|
|
926
|
-
if (!distImports.includes(imp) && !dependencies.includes(imp) && !
|
|
908
|
+
if (!distImports.includes(imp) && !dependencies.includes(imp) && !peerDependencies.includes(imp) && !devDependencies.includes(imp) && !builtinModules2.includes(imp)) {
|
|
927
909
|
unlistedDevDependencies++;
|
|
928
910
|
console.log(`[${chalk15.blue(name)}] Missing devDependency in package.json: ${chalk15.red(imp)}`);
|
|
929
911
|
console.log(` ${srcImportPaths[imp].join("\n ")}`);
|
|
@@ -941,12 +923,11 @@ function getUnlistedDevDependencies({ name, location }, {
|
|
|
941
923
|
import chalk16 from "chalk";
|
|
942
924
|
function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
943
925
|
externalDistImports,
|
|
944
|
-
externalDistTypeImports,
|
|
945
926
|
externalSrcImports
|
|
946
927
|
}) {
|
|
947
928
|
let unusedDependencies = 0;
|
|
948
929
|
for (const dep of dependencies) {
|
|
949
|
-
if (!externalDistImports.includes(dep)
|
|
930
|
+
if (!externalDistImports.includes(dep)) {
|
|
950
931
|
unusedDependencies++;
|
|
951
932
|
if (externalSrcImports.includes(dep)) {
|
|
952
933
|
console.log(`[${chalk16.blue(name)}] dependency should be devDependency in package.json: ${chalk16.red(dep)}`);
|
|
@@ -965,10 +946,10 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
965
946
|
|
|
966
947
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
967
948
|
import chalk17 from "chalk";
|
|
968
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports
|
|
949
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports }) {
|
|
969
950
|
let unusedDependencies = 0;
|
|
970
951
|
for (const dep of peerDependencies) {
|
|
971
|
-
if (!externalDistImports.includes(dep)
|
|
952
|
+
if (!externalDistImports.includes(dep)) {
|
|
972
953
|
unusedDependencies++;
|
|
973
954
|
if (dependencies.includes(dep)) {
|
|
974
955
|
console.log(`[${chalk17.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk17.red(dep)}`);
|
|
@@ -1395,7 +1376,7 @@ var packageClean = async () => {
|
|
|
1395
1376
|
};
|
|
1396
1377
|
|
|
1397
1378
|
// src/actions/package/compile/compile.ts
|
|
1398
|
-
import
|
|
1379
|
+
import chalk28 from "chalk";
|
|
1399
1380
|
|
|
1400
1381
|
// src/actions/package/publint.ts
|
|
1401
1382
|
import { promises as fs4 } from "fs";
|
|
@@ -1471,8 +1452,34 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1471
1452
|
return entries;
|
|
1472
1453
|
};
|
|
1473
1454
|
|
|
1455
|
+
// src/actions/package/compile/deepMerge.ts
|
|
1456
|
+
function deepMerge(target, source) {
|
|
1457
|
+
if (!source || typeof source !== "object") return target;
|
|
1458
|
+
for (const key of Object.keys(source)) {
|
|
1459
|
+
if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
|
|
1460
|
+
if (!target[key] || typeof target[key] !== "object") {
|
|
1461
|
+
target[key] = {};
|
|
1462
|
+
}
|
|
1463
|
+
deepMerge(target[key], source[key]);
|
|
1464
|
+
} else {
|
|
1465
|
+
target[key] = source[key];
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
return target;
|
|
1469
|
+
}
|
|
1470
|
+
function deepMergeObjects(objects) {
|
|
1471
|
+
const result = {};
|
|
1472
|
+
for (const obj of objects) {
|
|
1473
|
+
deepMerge(result, obj);
|
|
1474
|
+
}
|
|
1475
|
+
return result;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1474
1478
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1479
|
+
import { rm, writeFileSync as writeFileSync2 } from "fs";
|
|
1480
|
+
import path7 from "path";
|
|
1475
1481
|
import { cwd } from "process";
|
|
1482
|
+
import { Extractor, ExtractorConfig } from "@microsoft/api-extractor";
|
|
1476
1483
|
import chalk27 from "chalk";
|
|
1477
1484
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1478
1485
|
import {
|
|
@@ -1509,13 +1516,20 @@ var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
|
1509
1516
|
};
|
|
1510
1517
|
|
|
1511
1518
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1512
|
-
var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1519
|
+
var packageCompileTscTypes = (entries, outDir, folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1513
1520
|
const pkg = process.env.INIT_CWD ?? cwd();
|
|
1514
1521
|
const verbose = config2?.verbose ?? false;
|
|
1522
|
+
const tempDir = `${pkg}/.xylabs/ts-scripts-yarn3/compile/tsc/types/${Date.now()}`;
|
|
1523
|
+
rm(tempDir, { force: true, recursive: true }, (err) => {
|
|
1524
|
+
if (err) {
|
|
1525
|
+
console.error(chalk27.red(`Error removing temporary directory: ${tempDir}`), err);
|
|
1526
|
+
return 1;
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1515
1529
|
const compilerOptions = {
|
|
1516
1530
|
...getCompilerOptions({
|
|
1517
1531
|
emitDeclarationOnly: true,
|
|
1518
|
-
outDir:
|
|
1532
|
+
outDir: tempDir,
|
|
1519
1533
|
removeComments: false,
|
|
1520
1534
|
skipDefaultLibCheck: true,
|
|
1521
1535
|
skipLibCheck: true,
|
|
@@ -1549,91 +1563,53 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1549
1563
|
console.error(formattedDiagnostics);
|
|
1550
1564
|
}
|
|
1551
1565
|
program.emit();
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
};
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1566
|
+
const tscErrorCount = diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1567
|
+
if (tscErrorCount > 0) {
|
|
1568
|
+
return tscErrorCount;
|
|
1569
|
+
}
|
|
1570
|
+
const entryNameToTypeName = (entry) => {
|
|
1571
|
+
const splitEntryName = entry.split(".");
|
|
1572
|
+
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
1573
|
+
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
1574
|
+
};
|
|
1575
|
+
const entryNames = entries.map((entry) => entry.split(`${folder}/`).at(-1) ?? entry);
|
|
1576
|
+
for (const entry of entryNames) {
|
|
1577
|
+
const entryTypeName = entryNameToTypeName(entry);
|
|
1578
|
+
const configObject = {
|
|
1579
|
+
projectFolder: ".",
|
|
1580
|
+
mainEntryPointFilePath: path7.resolve([tempDir, entryTypeName].join("/")),
|
|
1581
|
+
bundledPackages: [],
|
|
1582
|
+
compiler: { tsconfigFilePath: path7.resolve(`${pkg}/tsconfig.json`) },
|
|
1583
|
+
dtsRollup: {
|
|
1584
|
+
enabled: true,
|
|
1585
|
+
untrimmedFilePath: path7.resolve(`${outDir}/${entryTypeName}`)
|
|
1586
|
+
},
|
|
1587
|
+
apiReport: { enabled: false },
|
|
1588
|
+
docModel: { enabled: false },
|
|
1589
|
+
tsdocMetadata: { enabled: false }
|
|
1590
|
+
};
|
|
1591
|
+
writeFileSync2(`${tempDir}/api-extractor.json`, JSON.stringify(configObject, null, 2));
|
|
1592
|
+
const extractorConfig = ExtractorConfig.prepare({
|
|
1593
|
+
configObject,
|
|
1594
|
+
configObjectFullPath: path7.resolve(`${tempDir}/api-extractor.json`),
|
|
1595
|
+
// just a virtual label, doesn't have to exist
|
|
1596
|
+
packageJsonFullPath: path7.resolve("package.json")
|
|
1597
|
+
});
|
|
1598
|
+
const extractorResult = Extractor.invoke(extractorConfig, {
|
|
1599
|
+
localBuild: true,
|
|
1600
|
+
showVerboseMessages: true
|
|
1601
|
+
});
|
|
1602
|
+
if (extractorResult.succeeded) {
|
|
1603
|
+
console.log("API Extractor completed successfully");
|
|
1604
|
+
process.exitCode = 0;
|
|
1605
|
+
} else {
|
|
1606
|
+
console.error(
|
|
1607
|
+
`API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings`
|
|
1608
|
+
);
|
|
1609
|
+
process.exitCode = 1;
|
|
1570
1610
|
}
|
|
1571
|
-
deepMerge(target[key], source[key]);
|
|
1572
|
-
} else {
|
|
1573
|
-
target[key] = source[key];
|
|
1574
1611
|
}
|
|
1575
1612
|
}
|
|
1576
|
-
return target;
|
|
1577
|
-
}
|
|
1578
|
-
function deepMergeObjects(objects) {
|
|
1579
|
-
const result = {};
|
|
1580
|
-
for (const obj of objects) {
|
|
1581
|
-
deepMerge(result, obj);
|
|
1582
|
-
}
|
|
1583
|
-
return result;
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
1587
|
-
import { cwd as cwd2 } from "process";
|
|
1588
|
-
import chalk28 from "chalk";
|
|
1589
|
-
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1590
|
-
import {
|
|
1591
|
-
DiagnosticCategory as DiagnosticCategory2,
|
|
1592
|
-
formatDiagnosticsWithColorAndContext as formatDiagnosticsWithColorAndContext2,
|
|
1593
|
-
getPreEmitDiagnostics as getPreEmitDiagnostics2,
|
|
1594
|
-
sys as sys3
|
|
1595
|
-
} from "typescript";
|
|
1596
|
-
var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1597
|
-
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1598
|
-
const verbose = config2?.verbose ?? false;
|
|
1599
|
-
const compilerOptions = {
|
|
1600
|
-
...getCompilerOptions({
|
|
1601
|
-
outDir: "dist/types",
|
|
1602
|
-
removeComments: false,
|
|
1603
|
-
skipDefaultLibCheck: true,
|
|
1604
|
-
skipLibCheck: true,
|
|
1605
|
-
sourceMap: false
|
|
1606
|
-
}),
|
|
1607
|
-
...compilerOptionsParam,
|
|
1608
|
-
emitDeclarationOnly: false,
|
|
1609
|
-
noEmit: true
|
|
1610
|
-
};
|
|
1611
|
-
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1612
|
-
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1613
|
-
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1614
|
-
console.log(chalk28.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1615
|
-
if (files.length > 0) {
|
|
1616
|
-
const program = createProgramFromConfig2({
|
|
1617
|
-
basePath: pkg ?? cwd2(),
|
|
1618
|
-
compilerOptions,
|
|
1619
|
-
exclude: ["dist", "docs"],
|
|
1620
|
-
files
|
|
1621
|
-
});
|
|
1622
|
-
const diagnostics = getPreEmitDiagnostics2(program);
|
|
1623
|
-
if (diagnostics.length > 0) {
|
|
1624
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
|
|
1625
|
-
diagnostics,
|
|
1626
|
-
{
|
|
1627
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
1628
|
-
getCurrentDirectory: () => folder,
|
|
1629
|
-
getNewLine: () => sys3.newLine
|
|
1630
|
-
}
|
|
1631
|
-
);
|
|
1632
|
-
console.error(formattedDiagnostics);
|
|
1633
|
-
}
|
|
1634
|
-
program.emit();
|
|
1635
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
|
|
1636
|
-
}
|
|
1637
1613
|
return 0;
|
|
1638
1614
|
};
|
|
1639
1615
|
|
|
@@ -1671,6 +1647,7 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
|
1671
1647
|
if (verbose) {
|
|
1672
1648
|
console.log(`TSUP:build:stop [${folder}]`);
|
|
1673
1649
|
}
|
|
1650
|
+
packageCompileTscTypes(entry, outDir);
|
|
1674
1651
|
return 0;
|
|
1675
1652
|
};
|
|
1676
1653
|
var tsupOptions = (options = []) => {
|
|
@@ -1706,11 +1683,6 @@ var packageCompileTsup = async (config2) => {
|
|
|
1706
1683
|
if (verbose) {
|
|
1707
1684
|
console.log("Calling packageCompileTscTypes");
|
|
1708
1685
|
}
|
|
1709
|
-
let errors = await packageCompileTypes(config2);
|
|
1710
|
-
errors = errors + packageCompileTsc(void 0, config2);
|
|
1711
|
-
if (errors > 0) {
|
|
1712
|
-
return errors;
|
|
1713
|
-
}
|
|
1714
1686
|
return (await Promise.all(
|
|
1715
1687
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
1716
1688
|
const optionsObject = typeof options === "object" ? options : {};
|
|
@@ -1765,7 +1737,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1765
1737
|
// src/actions/package/compile/compile.ts
|
|
1766
1738
|
var packageCompile = async (inConfig = {}) => {
|
|
1767
1739
|
const pkg = process.env.INIT_CWD;
|
|
1768
|
-
console.log(
|
|
1740
|
+
console.log(chalk28.green(`Compiling ${pkg}`));
|
|
1769
1741
|
const config2 = await loadConfig(inConfig);
|
|
1770
1742
|
const publint2 = config2.publint;
|
|
1771
1743
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1775,8 +1747,62 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1775
1747
|
return publint2 ? await packagePublint(config2) : 0;
|
|
1776
1748
|
};
|
|
1777
1749
|
|
|
1750
|
+
// src/actions/package/compile/packageCompileTsc.ts
|
|
1751
|
+
import { cwd as cwd2 } from "process";
|
|
1752
|
+
import chalk29 from "chalk";
|
|
1753
|
+
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1754
|
+
import {
|
|
1755
|
+
DiagnosticCategory as DiagnosticCategory2,
|
|
1756
|
+
formatDiagnosticsWithColorAndContext as formatDiagnosticsWithColorAndContext2,
|
|
1757
|
+
getPreEmitDiagnostics as getPreEmitDiagnostics2,
|
|
1758
|
+
sys as sys3
|
|
1759
|
+
} from "typescript";
|
|
1760
|
+
var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1761
|
+
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1762
|
+
const verbose = config2?.verbose ?? false;
|
|
1763
|
+
const compilerOptions = {
|
|
1764
|
+
...getCompilerOptions({
|
|
1765
|
+
outDir: "dist/types",
|
|
1766
|
+
removeComments: false,
|
|
1767
|
+
skipDefaultLibCheck: true,
|
|
1768
|
+
skipLibCheck: true,
|
|
1769
|
+
sourceMap: false
|
|
1770
|
+
}),
|
|
1771
|
+
...compilerOptionsParam,
|
|
1772
|
+
emitDeclarationOnly: false,
|
|
1773
|
+
noEmit: true
|
|
1774
|
+
};
|
|
1775
|
+
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1776
|
+
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1777
|
+
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1778
|
+
console.log(chalk29.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1779
|
+
if (files.length > 0) {
|
|
1780
|
+
const program = createProgramFromConfig2({
|
|
1781
|
+
basePath: pkg ?? cwd2(),
|
|
1782
|
+
compilerOptions,
|
|
1783
|
+
exclude: ["dist", "docs"],
|
|
1784
|
+
files
|
|
1785
|
+
});
|
|
1786
|
+
const diagnostics = getPreEmitDiagnostics2(program);
|
|
1787
|
+
if (diagnostics.length > 0) {
|
|
1788
|
+
const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
|
|
1789
|
+
diagnostics,
|
|
1790
|
+
{
|
|
1791
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
1792
|
+
getCurrentDirectory: () => folder,
|
|
1793
|
+
getNewLine: () => sys3.newLine
|
|
1794
|
+
}
|
|
1795
|
+
);
|
|
1796
|
+
console.error(formattedDiagnostics);
|
|
1797
|
+
}
|
|
1798
|
+
program.emit();
|
|
1799
|
+
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
|
|
1800
|
+
}
|
|
1801
|
+
return 0;
|
|
1802
|
+
};
|
|
1803
|
+
|
|
1778
1804
|
// src/actions/package/copy-assets.ts
|
|
1779
|
-
import
|
|
1805
|
+
import path8 from "path/posix";
|
|
1780
1806
|
import chalk30 from "chalk";
|
|
1781
1807
|
import cpy2 from "cpy";
|
|
1782
1808
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
@@ -1785,7 +1811,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1785
1811
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1786
1812
|
`../dist/${target}`,
|
|
1787
1813
|
{
|
|
1788
|
-
cwd:
|
|
1814
|
+
cwd: path8.join(location, "src"),
|
|
1789
1815
|
flat: false
|
|
1790
1816
|
}
|
|
1791
1817
|
);
|
|
@@ -1858,7 +1884,7 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1858
1884
|
|
|
1859
1885
|
// src/actions/package/gen-docs.ts
|
|
1860
1886
|
import { existsSync as existsSync5 } from "fs";
|
|
1861
|
-
import
|
|
1887
|
+
import path9 from "path";
|
|
1862
1888
|
import chalk31 from "chalk";
|
|
1863
1889
|
import {
|
|
1864
1890
|
Application,
|
|
@@ -1877,7 +1903,7 @@ var ExitCodes = {
|
|
|
1877
1903
|
};
|
|
1878
1904
|
var packageGenDocs = async () => {
|
|
1879
1905
|
const pkg = process.env.INIT_CWD;
|
|
1880
|
-
if (pkg && !existsSync5(
|
|
1906
|
+
if (pkg && !existsSync5(path9.join(pkg, "typedoc.json"))) {
|
|
1881
1907
|
return;
|
|
1882
1908
|
}
|
|
1883
1909
|
const app = await Application.bootstrap({
|
|
@@ -1969,7 +1995,7 @@ var runTypeDoc = async (app) => {
|
|
|
1969
1995
|
|
|
1970
1996
|
// src/actions/package/lint.ts
|
|
1971
1997
|
import { readdirSync } from "fs";
|
|
1972
|
-
import
|
|
1998
|
+
import path10 from "path";
|
|
1973
1999
|
import { cwd as cwd3 } from "process";
|
|
1974
2000
|
import { pathToFileURL } from "url";
|
|
1975
2001
|
import chalk32 from "chalk";
|
|
@@ -2006,7 +2032,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
2006
2032
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
2007
2033
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2008
2034
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2009
|
-
const res =
|
|
2035
|
+
const res = path10.resolve(dir, dirent.name);
|
|
2010
2036
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2011
2037
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2012
2038
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2867,7 +2893,6 @@ export {
|
|
|
2867
2893
|
packageCompileTsc,
|
|
2868
2894
|
packageCompileTscTypes,
|
|
2869
2895
|
packageCompileTsup,
|
|
2870
|
-
packageCompileTypes,
|
|
2871
2896
|
packageCopyAssets,
|
|
2872
2897
|
packageCycle,
|
|
2873
2898
|
packageGenDocs,
|