@xylabs/ts-scripts-yarn3 6.5.18 → 7.0.0-rc.2

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.
Files changed (60) hide show
  1. package/dist/actions/deplint/checkPackage/checkPackage.mjs +8 -27
  2. package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
  3. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs +2 -13
  4. package/dist/actions/deplint/checkPackage/getUnlistedDependencies.mjs.map +1 -1
  5. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs +1 -1
  6. package/dist/actions/deplint/checkPackage/getUnlistedDevDependencies.mjs.map +1 -1
  7. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +1 -2
  8. package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
  9. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +2 -2
  10. package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
  11. package/dist/actions/deplint/checkPackage/index.mjs +8 -27
  12. package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
  13. package/dist/actions/deplint/deplint.mjs +8 -27
  14. package/dist/actions/deplint/deplint.mjs.map +1 -1
  15. package/dist/actions/deplint/getExternalImportsFromFiles.mjs +2 -9
  16. package/dist/actions/deplint/getExternalImportsFromFiles.mjs.map +1 -1
  17. package/dist/actions/deplint/index.mjs +8 -27
  18. package/dist/actions/deplint/index.mjs.map +1 -1
  19. package/dist/actions/index.mjs +202 -165
  20. package/dist/actions/index.mjs.map +1 -1
  21. package/dist/actions/package/compile/compile.mjs +128 -125
  22. package/dist/actions/package/compile/compile.mjs.map +1 -1
  23. package/dist/actions/package/compile/index.mjs +182 -126
  24. package/dist/actions/package/compile/index.mjs.map +1 -1
  25. package/dist/actions/package/compile/packageCompileTscTypes.mjs +104 -37
  26. package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
  27. package/dist/actions/package/compile/packageCompileTsup.mjs +137 -153
  28. package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
  29. package/dist/actions/package/index.mjs +188 -132
  30. package/dist/actions/package/index.mjs.map +1 -1
  31. package/dist/actions/package/recompile.mjs +128 -125
  32. package/dist/actions/package/recompile.mjs.map +1 -1
  33. package/dist/bin/package/build-only.mjs +130 -127
  34. package/dist/bin/package/build-only.mjs.map +1 -1
  35. package/dist/bin/package/build.mjs +130 -127
  36. package/dist/bin/package/build.mjs.map +1 -1
  37. package/dist/bin/package/compile-only.mjs +130 -127
  38. package/dist/bin/package/compile-only.mjs.map +1 -1
  39. package/dist/bin/package/compile-tsup.mjs +142 -158
  40. package/dist/bin/package/compile-tsup.mjs.map +1 -1
  41. package/dist/bin/package/compile.mjs +130 -127
  42. package/dist/bin/package/compile.mjs.map +1 -1
  43. package/dist/bin/package/recompile.mjs +130 -127
  44. package/dist/bin/package/recompile.mjs.map +1 -1
  45. package/dist/bin/xy.mjs +8 -27
  46. package/dist/bin/xy.mjs.map +1 -1
  47. package/dist/index.d.ts +2 -4
  48. package/dist/index.mjs +202 -165
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/xy/index.mjs +8 -27
  51. package/dist/xy/index.mjs.map +1 -1
  52. package/dist/xy/xy.mjs +8 -27
  53. package/dist/xy/xy.mjs.map +1 -1
  54. package/dist/xy/xyLintCommands.mjs +8 -27
  55. package/dist/xy/xyLintCommands.mjs.map +1 -1
  56. package/package.json +6 -5
  57. package/dist/actions/package/compile/compileTypes.mjs +0 -138
  58. package/dist/actions/package/compile/compileTypes.mjs.map +0 -1
  59. package/dist/bin/package/compile-types.mjs +0 -150
  60. 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, packageCompileTypes, 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 };
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 = (path10) => {
375
- const pathToPackageJSON = path10 ?? process.env.npm_package_json ?? "";
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(path10) {
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(path10, pattern));
764
- const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path10, pattern));
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 distTypeImportPaths = {};
859
- for (const path10 of srcFiles) getImportsFromFile(path10, srcImportPaths, srcImportPaths).flat();
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) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !builtinModules.includes(imp) && !builtinModules.includes(`@types/${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) && !dependencies.includes(`@types/${imp}`) && !peerDependencies.includes(imp) && !peerDependencies.includes(`@types/${imp}`) && !devDependencies.includes(imp) && !devDependencies.includes(`@types/${imp}`) && !builtinModules2.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) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
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, externalDistTypeImports }) {
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) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
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 chalk29 from "chalk";
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,132 +1516,113 @@ 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;
1515
- const compilerOptions = {
1516
- ...getCompilerOptions({
1517
- emitDeclarationOnly: true,
1518
- outDir: config2.compile?.tsup?.options?.outDir ?? "dist/types",
1519
- removeComments: false,
1520
- skipDefaultLibCheck: true,
1521
- skipLibCheck: true,
1522
- sourceMap: false
1523
- }),
1524
- ...compilerOptionsParam,
1525
- emitDeclarationOnly: true,
1526
- noEmit: false
1527
- };
1528
- const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
1529
- const excludes = [".stories.", ".spec.", "/stories/", "/spec/"];
1530
- const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
1531
- console.log(chalk27.green(`Compiling Types ${pkg}: ${files.length}`));
1532
- if (files.length > 0) {
1533
- const program = createProgramFromConfig({
1534
- basePath: pkg ?? cwd(),
1535
- compilerOptions,
1536
- exclude: ["build", "dist", "docs", "**/*.spec.*", "**/*.stories.*", "src/**/spec/**/*"],
1537
- files
1522
+ const tempDir = `${pkg}/.xylabs/ts-scripts-yarn3/compile/tsc/types}`;
1523
+ try {
1524
+ rm(tempDir, { force: true, recursive: true }, (err) => {
1525
+ if (err) {
1526
+ console.error(chalk27.red(`Error removing temporary directory: ${tempDir}`), err);
1527
+ return 1;
1528
+ }
1538
1529
  });
1539
- const diagnostics = getPreEmitDiagnostics(program);
1540
- if (diagnostics.length > 0) {
1541
- const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
1542
- diagnostics,
1543
- {
1544
- getCanonicalFileName: (fileName) => fileName,
1545
- getCurrentDirectory: () => folder,
1546
- getNewLine: () => sys2.newLine
1547
- }
1548
- );
1549
- console.error(formattedDiagnostics);
1550
- }
1551
- program.emit();
1552
- return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
1530
+ } catch {
1553
1531
  }
1554
- return 0;
1555
- };
1556
-
1557
- // src/actions/package/compile/compileTypes.ts
1558
- var packageCompileTypes = async (inConfig = {}) => {
1559
- const config2 = await loadConfig(inConfig);
1560
- return packageCompileTscTypes(void 0, config2);
1561
- };
1562
-
1563
- // src/actions/package/compile/deepMerge.ts
1564
- function deepMerge(target, source) {
1565
- if (!source || typeof source !== "object") return target;
1566
- for (const key of Object.keys(source)) {
1567
- if (typeof source[key] === "object" && source[key] !== null && !Array.isArray(source[key])) {
1568
- if (!target[key] || typeof target[key] !== "object") {
1569
- target[key] = {};
1532
+ try {
1533
+ const compilerOptions = {
1534
+ ...getCompilerOptions({
1535
+ emitDeclarationOnly: true,
1536
+ outDir: tempDir,
1537
+ removeComments: false,
1538
+ skipDefaultLibCheck: true,
1539
+ skipLibCheck: true,
1540
+ sourceMap: false
1541
+ }),
1542
+ ...compilerOptionsParam,
1543
+ emitDeclarationOnly: true,
1544
+ noEmit: false
1545
+ };
1546
+ const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
1547
+ const excludes = [".stories.", ".spec.", "/stories/", "/spec/"];
1548
+ const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && !excludes.some((exclude) => file.includes(exclude)));
1549
+ console.log(chalk27.green(`Compiling Types ${pkg}: ${files.length}`));
1550
+ if (files.length > 0) {
1551
+ const program = createProgramFromConfig({
1552
+ basePath: pkg ?? cwd(),
1553
+ compilerOptions,
1554
+ exclude: ["build", "dist", "docs", "**/*.spec.*", "**/*.stories.*", "src/**/spec/**/*"],
1555
+ files
1556
+ });
1557
+ const diagnostics = getPreEmitDiagnostics(program);
1558
+ if (diagnostics.length > 0) {
1559
+ const formattedDiagnostics = formatDiagnosticsWithColorAndContext(
1560
+ diagnostics,
1561
+ {
1562
+ getCanonicalFileName: (fileName) => fileName,
1563
+ getCurrentDirectory: () => folder,
1564
+ getNewLine: () => sys2.newLine
1565
+ }
1566
+ );
1567
+ console.error(formattedDiagnostics);
1570
1568
  }
1571
- deepMerge(target[key], source[key]);
1572
- } else {
1573
- target[key] = source[key];
1574
- }
1575
- }
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
1569
+ program.emit();
1570
+ const tscErrorCount = diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
1571
+ if (tscErrorCount > 0) {
1572
+ return tscErrorCount;
1573
+ }
1574
+ const entryNameToTypeName = (entry) => {
1575
+ const splitEntryName = entry.split(".");
1576
+ const newEntryExtension = "d." + splitEntryName.at(-1);
1577
+ return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
1578
+ };
1579
+ const entryNames = entries.map((entry) => entry.split(`${folder}/`).at(-1) ?? entry);
1580
+ for (const entry of entryNames) {
1581
+ const entryTypeName = entryNameToTypeName(entry);
1582
+ const configObject = {
1583
+ projectFolder: ".",
1584
+ mainEntryPointFilePath: path7.resolve([tempDir, entryTypeName].join("/")),
1585
+ bundledPackages: [],
1586
+ compiler: { tsconfigFilePath: path7.resolve(`${pkg}/tsconfig.json`) },
1587
+ dtsRollup: {
1588
+ enabled: true,
1589
+ untrimmedFilePath: path7.resolve(`${outDir}/${entryTypeName}`)
1590
+ },
1591
+ apiReport: { enabled: false },
1592
+ docModel: { enabled: false },
1593
+ tsdocMetadata: { enabled: false }
1594
+ };
1595
+ writeFileSync2(`${tempDir}/api-extractor.json`, JSON.stringify(configObject, null, 2));
1596
+ const extractorConfig = ExtractorConfig.prepare({
1597
+ configObject,
1598
+ configObjectFullPath: path7.resolve(`${tempDir}/api-extractor.json`),
1599
+ // just a virtual label, doesn't have to exist
1600
+ packageJsonFullPath: path7.resolve("package.json")
1601
+ });
1602
+ const extractorResult = Extractor.invoke(extractorConfig, {
1603
+ localBuild: true,
1604
+ showVerboseMessages: true
1605
+ });
1606
+ if (extractorResult.succeeded) {
1607
+ console.log("API Extractor completed successfully");
1608
+ process.exitCode = 0;
1609
+ } else {
1610
+ console.error(
1611
+ `API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings`
1612
+ );
1613
+ process.exitCode = 1;
1630
1614
  }
1631
- );
1632
- console.error(formattedDiagnostics);
1615
+ }
1633
1616
  }
1634
- program.emit();
1635
- return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
1617
+ return 0;
1618
+ } finally {
1619
+ rm(tempDir, { force: true, recursive: true }, (err) => {
1620
+ if (err) {
1621
+ console.error(chalk27.red(`Error removing temporary directory (finally): ${tempDir}`), err);
1622
+ return 1;
1623
+ }
1624
+ });
1636
1625
  }
1637
- return 0;
1638
1626
  };
1639
1627
 
1640
1628
  // src/actions/package/compile/packageCompileTsup.ts
@@ -1671,6 +1659,7 @@ var compileFolder = async (folder, entryMode = "single", options, verbose) => {
1671
1659
  if (verbose) {
1672
1660
  console.log(`TSUP:build:stop [${folder}]`);
1673
1661
  }
1662
+ packageCompileTscTypes(entry, outDir);
1674
1663
  return 0;
1675
1664
  };
1676
1665
  var tsupOptions = (options = []) => {
@@ -1706,11 +1695,6 @@ var packageCompileTsup = async (config2) => {
1706
1695
  if (verbose) {
1707
1696
  console.log("Calling packageCompileTscTypes");
1708
1697
  }
1709
- let errors = await packageCompileTypes(config2);
1710
- errors = errors + packageCompileTsc(void 0, config2);
1711
- if (errors > 0) {
1712
- return errors;
1713
- }
1714
1698
  return (await Promise.all(
1715
1699
  Object.entries(compileForNode).map(async ([folder, options]) => {
1716
1700
  const optionsObject = typeof options === "object" ? options : {};
@@ -1765,7 +1749,7 @@ var packageCompileTsup = async (config2) => {
1765
1749
  // src/actions/package/compile/compile.ts
1766
1750
  var packageCompile = async (inConfig = {}) => {
1767
1751
  const pkg = process.env.INIT_CWD;
1768
- console.log(chalk29.green(`Compiling ${pkg}`));
1752
+ console.log(chalk28.green(`Compiling ${pkg}`));
1769
1753
  const config2 = await loadConfig(inConfig);
1770
1754
  const publint2 = config2.publint;
1771
1755
  const tsupResults = await packageCompileTsup(config2);
@@ -1775,8 +1759,62 @@ var packageCompile = async (inConfig = {}) => {
1775
1759
  return publint2 ? await packagePublint(config2) : 0;
1776
1760
  };
1777
1761
 
1762
+ // src/actions/package/compile/packageCompileTsc.ts
1763
+ import { cwd as cwd2 } from "process";
1764
+ import chalk29 from "chalk";
1765
+ import { createProgramFromConfig as createProgramFromConfig2 } from "tsc-prog";
1766
+ import {
1767
+ DiagnosticCategory as DiagnosticCategory2,
1768
+ formatDiagnosticsWithColorAndContext as formatDiagnosticsWithColorAndContext2,
1769
+ getPreEmitDiagnostics as getPreEmitDiagnostics2,
1770
+ sys as sys3
1771
+ } from "typescript";
1772
+ var packageCompileTsc = (folder = "src", config2 = {}, compilerOptionsParam) => {
1773
+ const pkg = process.env.INIT_CWD ?? cwd2();
1774
+ const verbose = config2?.verbose ?? false;
1775
+ const compilerOptions = {
1776
+ ...getCompilerOptions({
1777
+ outDir: "dist/types",
1778
+ removeComments: false,
1779
+ skipDefaultLibCheck: true,
1780
+ skipLibCheck: true,
1781
+ sourceMap: false
1782
+ }),
1783
+ ...compilerOptionsParam,
1784
+ emitDeclarationOnly: false,
1785
+ noEmit: true
1786
+ };
1787
+ const validTsExt = [".ts", ".tsx", ".d.ts", ".cts", ".d.cts", ".mts", ".d.mts"];
1788
+ const includes = [".stories.", ".spec.", ".d.ts", ".d.cts", ".d.mts"];
1789
+ const files = buildEntries(folder, "all", verbose).filter((file) => validTsExt.find((ext) => file.endsWith(ext)) && includes.find((include) => file.includes(include)));
1790
+ console.log(chalk29.green(`Compiling Files ${pkg}: ${files.length}`));
1791
+ if (files.length > 0) {
1792
+ const program = createProgramFromConfig2({
1793
+ basePath: pkg ?? cwd2(),
1794
+ compilerOptions,
1795
+ exclude: ["dist", "docs"],
1796
+ files
1797
+ });
1798
+ const diagnostics = getPreEmitDiagnostics2(program);
1799
+ if (diagnostics.length > 0) {
1800
+ const formattedDiagnostics = formatDiagnosticsWithColorAndContext2(
1801
+ diagnostics,
1802
+ {
1803
+ getCanonicalFileName: (fileName) => fileName,
1804
+ getCurrentDirectory: () => folder,
1805
+ getNewLine: () => sys3.newLine
1806
+ }
1807
+ );
1808
+ console.error(formattedDiagnostics);
1809
+ }
1810
+ program.emit();
1811
+ return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory2.Error ? 1 : 0), 0);
1812
+ }
1813
+ return 0;
1814
+ };
1815
+
1778
1816
  // src/actions/package/copy-assets.ts
1779
- import path7 from "path/posix";
1817
+ import path8 from "path/posix";
1780
1818
  import chalk30 from "chalk";
1781
1819
  import cpy2 from "cpy";
1782
1820
  var copyTargetAssets2 = async (target, name, location) => {
@@ -1785,7 +1823,7 @@ var copyTargetAssets2 = async (target, name, location) => {
1785
1823
  ["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
1786
1824
  `../dist/${target}`,
1787
1825
  {
1788
- cwd: path7.join(location, "src"),
1826
+ cwd: path8.join(location, "src"),
1789
1827
  flat: false
1790
1828
  }
1791
1829
  );
@@ -1858,7 +1896,7 @@ var packageCycle = async ({ verbose = false }) => {
1858
1896
 
1859
1897
  // src/actions/package/gen-docs.ts
1860
1898
  import { existsSync as existsSync5 } from "fs";
1861
- import path8 from "path";
1899
+ import path9 from "path";
1862
1900
  import chalk31 from "chalk";
1863
1901
  import {
1864
1902
  Application,
@@ -1877,7 +1915,7 @@ var ExitCodes = {
1877
1915
  };
1878
1916
  var packageGenDocs = async () => {
1879
1917
  const pkg = process.env.INIT_CWD;
1880
- if (pkg && !existsSync5(path8.join(pkg, "typedoc.json"))) {
1918
+ if (pkg && !existsSync5(path9.join(pkg, "typedoc.json"))) {
1881
1919
  return;
1882
1920
  }
1883
1921
  const app = await Application.bootstrap({
@@ -1969,7 +2007,7 @@ var runTypeDoc = async (app) => {
1969
2007
 
1970
2008
  // src/actions/package/lint.ts
1971
2009
  import { readdirSync } from "fs";
1972
- import path9 from "path";
2010
+ import path10 from "path";
1973
2011
  import { cwd as cwd3 } from "process";
1974
2012
  import { pathToFileURL } from "url";
1975
2013
  import chalk32 from "chalk";
@@ -2006,7 +2044,7 @@ function getFiles(dir, ignoreFolders) {
2006
2044
  const subDirectory = dir.split(currentDirectory)[1];
2007
2045
  if (ignoreFolders.includes(subDirectory)) return [];
2008
2046
  return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
2009
- const res = path9.resolve(dir, dirent.name);
2047
+ const res = path10.resolve(dir, dirent.name);
2010
2048
  const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
2011
2049
  const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
2012
2050
  if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
@@ -2867,7 +2905,6 @@ export {
2867
2905
  packageCompileTsc,
2868
2906
  packageCompileTscTypes,
2869
2907
  packageCompileTsup,
2870
- packageCompileTypes,
2871
2908
  packageCopyAssets,
2872
2909
  packageCycle,
2873
2910
  packageGenDocs,