@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/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 ")}`);
|
|
@@ -945,7 +927,7 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
945
927
|
}) {
|
|
946
928
|
let unusedDependencies = 0;
|
|
947
929
|
for (const dep of dependencies) {
|
|
948
|
-
if (!externalDistImports.includes(dep)
|
|
930
|
+
if (!externalDistImports.includes(dep)) {
|
|
949
931
|
unusedDependencies++;
|
|
950
932
|
if (externalSrcImports.includes(dep)) {
|
|
951
933
|
console.log(`[${chalk16.blue(name)}] dependency should be devDependency in package.json: ${chalk16.red(dep)}`);
|
|
@@ -967,7 +949,7 @@ import chalk17 from "chalk";
|
|
|
967
949
|
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports }) {
|
|
968
950
|
let unusedDependencies = 0;
|
|
969
951
|
for (const dep of peerDependencies) {
|
|
970
|
-
if (!externalDistImports.includes(dep)
|
|
952
|
+
if (!externalDistImports.includes(dep)) {
|
|
971
953
|
unusedDependencies++;
|
|
972
954
|
if (dependencies.includes(dep)) {
|
|
973
955
|
console.log(`[${chalk17.blue(name)}] Unused peerDependency [already a dependency] in package.json: ${chalk17.red(dep)}`);
|
|
@@ -1394,7 +1376,7 @@ var packageClean = async () => {
|
|
|
1394
1376
|
};
|
|
1395
1377
|
|
|
1396
1378
|
// src/actions/package/compile/compile.ts
|
|
1397
|
-
import
|
|
1379
|
+
import chalk28 from "chalk";
|
|
1398
1380
|
|
|
1399
1381
|
// src/actions/package/publint.ts
|
|
1400
1382
|
import { promises as fs4 } from "fs";
|
|
@@ -1470,8 +1452,34 @@ var buildEntries = (folder, entryMode = "single", excludeSpecAndStories = true,
|
|
|
1470
1452
|
return entries;
|
|
1471
1453
|
};
|
|
1472
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
|
+
|
|
1473
1478
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1479
|
+
import { rm, writeFileSync as writeFileSync2 } from "fs";
|
|
1480
|
+
import path7 from "path";
|
|
1474
1481
|
import { cwd } from "process";
|
|
1482
|
+
import { Extractor, ExtractorConfig } from "@microsoft/api-extractor";
|
|
1475
1483
|
import chalk27 from "chalk";
|
|
1476
1484
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1477
1485
|
import {
|
|
@@ -1508,13 +1516,20 @@ var getCompilerOptions = (options = {}, tsconfig = "tsconfig.json") => {
|
|
|
1508
1516
|
};
|
|
1509
1517
|
|
|
1510
1518
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1511
|
-
var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1519
|
+
var packageCompileTscTypes = (entries, outDir, folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1512
1520
|
const pkg = process.env.INIT_CWD ?? cwd();
|
|
1513
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
|
+
});
|
|
1514
1529
|
const compilerOptions = {
|
|
1515
1530
|
...getCompilerOptions({
|
|
1516
1531
|
emitDeclarationOnly: true,
|
|
1517
|
-
outDir:
|
|
1532
|
+
outDir: tempDir,
|
|
1518
1533
|
removeComments: false,
|
|
1519
1534
|
skipDefaultLibCheck: true,
|
|
1520
1535
|
skipLibCheck: true,
|
|
@@ -1548,91 +1563,53 @@ var packageCompileTscTypes = (folder = "src", config2 = {}, compilerOptionsParam
|
|
|
1548
1563
|
console.error(formattedDiagnostics);
|
|
1549
1564
|
}
|
|
1550
1565
|
program.emit();
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
};
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
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;
|
|
1569
1610
|
}
|
|
1570
|
-
deepMerge(target[key], source[key]);
|
|
1571
|
-
} else {
|
|
1572
|
-
target[key] = source[key];
|
|
1573
1611
|
}
|
|
1574
1612
|
}
|
|
1575
|
-
return target;
|
|
1576
|
-
}
|
|
1577
|
-
function deepMergeObjects(objects) {
|
|
1578
|
-
const result = {};
|
|
1579
|
-
for (const obj of objects) {
|
|
1580
|
-
deepMerge(result, obj);
|
|
1581
|
-
}
|
|
1582
|
-
return result;
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
// src/actions/package/compile/packageCompileTsc.ts
|
|
1586
|
-
import { cwd as cwd2 } from "process";
|
|
1587
|
-
import chalk28 from "chalk";
|
|
1588
|
-
import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
|
|
1589
|
-
import {
|
|
1590
|
-
DiagnosticCategory as DiagnosticCategory2,
|
|
1591
|
-
formatDiagnosticsWithColorAndContext as formatDiagnosticsWithColorAndContext2,
|
|
1592
|
-
getPreEmitDiagnostics as getPreEmitDiagnostics2,
|
|
1593
|
-
sys as sys3
|
|
1594
|
-
} from "typescript";
|
|
1595
|
-
var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
|
|
1596
|
-
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1597
|
-
const verbose = config2?.verbose ?? false;
|
|
1598
|
-
const compilerOptions = {
|
|
1599
|
-
...getCompilerOptions({
|
|
1600
|
-
outDir: "dist/types",
|
|
1601
|
-
removeComments: false,
|
|
1602
|
-
skipDefaultLibCheck: true,
|
|
1603
|
-
skipLibCheck: true,
|
|
1604
|
-
sourceMap: false
|
|
1605
|
-
}),
|
|
1606
|
-
...compilerOptionsParam,
|
|
1607
|
-
emitDeclarationOnly: false,
|
|
1608
|
-
noEmit: true
|
|
1609
|
-
};
|
|
1610
|
-
const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
|
|
1611
|
-
const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
|
|
1612
|
-
const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
|
|
1613
|
-
console.log(chalk28.green(`Compiling Files ${pkg}: ${files.length}`));
|
|
1614
|
-
if (files.length > 0) {
|
|
1615
|
-
const program = createProgramFromConfig2({
|
|
1616
|
-
basePath: pkg ?? cwd2(),
|
|
1617
|
-
compilerOptions,
|
|
1618
|
-
exclude: ["dist", "docs"],
|
|
1619
|
-
files
|
|
1620
|
-
});
|
|
1621
|
-
const diagnostics = getPreEmitDiagnostics2(program);
|
|
1622
|
-
if (diagnostics.length > 0) {
|
|
1623
|
-
const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
|
|
1624
|
-
diagnostics,
|
|
1625
|
-
{
|
|
1626
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
1627
|
-
getCurrentDirectory: () => folder,
|
|
1628
|
-
getNewLine: () => sys3.newLine
|
|
1629
|
-
}
|
|
1630
|
-
);
|
|
1631
|
-
console.error(formattedDiagnostics);
|
|
1632
|
-
}
|
|
1633
|
-
program.emit();
|
|
1634
|
-
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
|
|
1635
|
-
}
|
|
1636
1613
|
return 0;
|
|
1637
1614
|
};
|
|
1638
1615
|
|
|
@@ -1670,6 +1647,7 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
|
|
|
1670
1647
|
if (verbose) {
|
|
1671
1648
|
console.log(`TSUP:build:stop [${folder}]`);
|
|
1672
1649
|
}
|
|
1650
|
+
packageCompileTscTypes(entry, outDir);
|
|
1673
1651
|
return 0;
|
|
1674
1652
|
};
|
|
1675
1653
|
var tsupOptions = (options = []) => {
|
|
@@ -1705,11 +1683,6 @@ var packageCompileTsup = async (config2) => {
|
|
|
1705
1683
|
if (verbose) {
|
|
1706
1684
|
console.log("Calling packageCompileTscTypes");
|
|
1707
1685
|
}
|
|
1708
|
-
let errors = await packageCompileTypes(config2);
|
|
1709
|
-
errors = errors + packageCompileTsc(void 0, config2);
|
|
1710
|
-
if (errors > 0) {
|
|
1711
|
-
return errors;
|
|
1712
|
-
}
|
|
1713
1686
|
return (await Promise.all(
|
|
1714
1687
|
Object.entries(compileForNode).map(async ([folder, options]) => {
|
|
1715
1688
|
const optionsObject = typeof options === "object" ? options : {};
|
|
@@ -1764,7 +1737,7 @@ var packageCompileTsup = async (config2) => {
|
|
|
1764
1737
|
// src/actions/package/compile/compile.ts
|
|
1765
1738
|
var packageCompile = async (inConfig = {}) => {
|
|
1766
1739
|
const pkg = process.env.INIT_CWD;
|
|
1767
|
-
console.log(
|
|
1740
|
+
console.log(chalk28.green(`Compiling ${pkg}`));
|
|
1768
1741
|
const config2 = await loadConfig(inConfig);
|
|
1769
1742
|
const publint2 = config2.publint;
|
|
1770
1743
|
const tsupResults = await packageCompileTsup(config2);
|
|
@@ -1774,8 +1747,62 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1774
1747
|
return publint2 ? await packagePublint(config2) : 0;
|
|
1775
1748
|
};
|
|
1776
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
|
+
|
|
1777
1804
|
// src/actions/package/copy-assets.ts
|
|
1778
|
-
import
|
|
1805
|
+
import path8 from "path/posix";
|
|
1779
1806
|
import chalk30 from "chalk";
|
|
1780
1807
|
import cpy2 from "cpy";
|
|
1781
1808
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
@@ -1784,7 +1811,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1784
1811
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1785
1812
|
`../dist/${target}`,
|
|
1786
1813
|
{
|
|
1787
|
-
cwd:
|
|
1814
|
+
cwd: path8.join(location, "src"),
|
|
1788
1815
|
flat: false
|
|
1789
1816
|
}
|
|
1790
1817
|
);
|
|
@@ -1857,7 +1884,7 @@ var packageCycle = async ({ verbose = false }) => {
|
|
|
1857
1884
|
|
|
1858
1885
|
// src/actions/package/gen-docs.ts
|
|
1859
1886
|
import { existsSync as existsSync5 } from "fs";
|
|
1860
|
-
import
|
|
1887
|
+
import path9 from "path";
|
|
1861
1888
|
import chalk31 from "chalk";
|
|
1862
1889
|
import {
|
|
1863
1890
|
Application,
|
|
@@ -1876,7 +1903,7 @@ var ExitCodes = {
|
|
|
1876
1903
|
};
|
|
1877
1904
|
var packageGenDocs = async () => {
|
|
1878
1905
|
const pkg = process.env.INIT_CWD;
|
|
1879
|
-
if (pkg && !existsSync5(
|
|
1906
|
+
if (pkg && !existsSync5(path9.join(pkg, "typedoc.json"))) {
|
|
1880
1907
|
return;
|
|
1881
1908
|
}
|
|
1882
1909
|
const app = await Application.bootstrap({
|
|
@@ -1968,7 +1995,7 @@ var runTypeDoc = async (app) => {
|
|
|
1968
1995
|
|
|
1969
1996
|
// src/actions/package/lint.ts
|
|
1970
1997
|
import { readdirSync } from "fs";
|
|
1971
|
-
import
|
|
1998
|
+
import path10 from "path";
|
|
1972
1999
|
import { cwd as cwd3 } from "process";
|
|
1973
2000
|
import { pathToFileURL } from "url";
|
|
1974
2001
|
import chalk32 from "chalk";
|
|
@@ -2005,7 +2032,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
2005
2032
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
2006
2033
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2007
2034
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2008
|
-
const res =
|
|
2035
|
+
const res = path10.resolve(dir, dirent.name);
|
|
2009
2036
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2010
2037
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2011
2038
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2866,7 +2893,6 @@ export {
|
|
|
2866
2893
|
packageCompileTsc,
|
|
2867
2894
|
packageCompileTscTypes,
|
|
2868
2895
|
packageCompileTsup,
|
|
2869
|
-
packageCompileTypes,
|
|
2870
2896
|
packageCopyAssets,
|
|
2871
2897
|
packageCycle,
|
|
2872
2898
|
packageGenDocs,
|