@xylabs/ts-scripts-yarn3 7.0.0-rc.21 → 7.0.0-rc.23
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/index.mjs +69 -44
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/buildEntries.mjs +9 -3
- package/dist/actions/package/compile/buildEntries.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +55 -30
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +55 -30
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/inputs.mjs +8 -2
- package/dist/actions/package/compile/inputs.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsc.mjs +15 -4
- package/dist/actions/package/compile/packageCompileTsc.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTscTypes.mjs +39 -20
- package/dist/actions/package/compile/packageCompileTscTypes.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +55 -30
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/index.mjs +61 -36
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +55 -30
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/bin/package/build-only.mjs +55 -30
- package/dist/bin/package/build-only.mjs.map +1 -1
- package/dist/bin/package/build.mjs +55 -30
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/compile-only.mjs +55 -30
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +55 -30
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +55 -30
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +55 -30
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/index.mjs +69 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -6
package/dist/actions/index.mjs
CHANGED
|
@@ -315,8 +315,8 @@ var loadConfig = async (params) => {
|
|
|
315
315
|
|
|
316
316
|
// src/lib/parsedPackageJSON.ts
|
|
317
317
|
import { readFileSync as readFileSync2 } from "fs";
|
|
318
|
-
var parsedPackageJSON = (
|
|
319
|
-
const pathToPackageJSON =
|
|
318
|
+
var parsedPackageJSON = (path11) => {
|
|
319
|
+
const pathToPackageJSON = path11 ?? process.env.npm_package_json ?? "";
|
|
320
320
|
const packageJSON = readFileSync2(pathToPackageJSON).toString();
|
|
321
321
|
return JSON.parse(packageJSON);
|
|
322
322
|
};
|
|
@@ -683,11 +683,11 @@ function findFilesByGlob(cwd5, pattern) {
|
|
|
683
683
|
}
|
|
684
684
|
|
|
685
685
|
// src/actions/deplint/findFiles.ts
|
|
686
|
-
function findFiles(
|
|
686
|
+
function findFiles(path11) {
|
|
687
687
|
const allSourceInclude = ["./src/**/*.{ts,tsx}"];
|
|
688
688
|
const allDistInclude = ["./dist/**/*.d.ts", "./dist/**/*.{mjs,js,cjs}"];
|
|
689
|
-
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(
|
|
690
|
-
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(
|
|
689
|
+
const srcFiles = allSourceInclude.flatMap((pattern) => findFilesByGlob(path11, pattern));
|
|
690
|
+
const distFiles = allDistInclude.flatMap((pattern) => findFilesByGlob(path11, pattern));
|
|
691
691
|
return { srcFiles, distFiles };
|
|
692
692
|
}
|
|
693
693
|
|
|
@@ -782,11 +782,11 @@ function getExternalImportsFromFiles({ srcFiles, distFiles }) {
|
|
|
782
782
|
const srcImportPaths = {};
|
|
783
783
|
const distImportPaths = {};
|
|
784
784
|
const distTypeImportPaths = {};
|
|
785
|
-
for (const
|
|
785
|
+
for (const path11 of srcFiles) getImportsFromFile(path11, srcImportPaths, srcImportPaths).flat();
|
|
786
786
|
const distTypeFiles = distFiles.filter((file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts"));
|
|
787
787
|
const distCodeFiles = distFiles.filter((file) => !(file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts")));
|
|
788
|
-
for (const
|
|
789
|
-
for (const
|
|
788
|
+
for (const path11 of distCodeFiles) getImportsFromFile(path11, distImportPaths, distImportPaths).flat();
|
|
789
|
+
for (const path11 of distTypeFiles) getImportsFromFile(path11, distTypeImportPaths, distTypeImportPaths).flat();
|
|
790
790
|
const srcImports = Object.keys(srcImportPaths);
|
|
791
791
|
const distImports = Object.keys(distImportPaths);
|
|
792
792
|
const distTypeImports = Object.keys(distTypeImportPaths);
|
|
@@ -1375,13 +1375,19 @@ import { build as build2, defineConfig } from "tsup";
|
|
|
1375
1375
|
import chalk26 from "chalk";
|
|
1376
1376
|
import { glob as glob2 } from "glob";
|
|
1377
1377
|
var getAllInputs = (srcDir, verbose = false) => {
|
|
1378
|
-
return glob2.sync(`${srcDir}
|
|
1378
|
+
return [...glob2.sync(`${srcDir}/**/*.ts`, { posix: true }).map((file) => {
|
|
1379
1379
|
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1380
1380
|
if (verbose) {
|
|
1381
1381
|
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1382
1382
|
}
|
|
1383
1383
|
return result;
|
|
1384
|
-
})
|
|
1384
|
+
}), ...glob2.sync(`${srcDir}/**/*.tsx`, { posix: true }).map((file) => {
|
|
1385
|
+
const result = file.slice(Math.max(0, srcDir.length + 1));
|
|
1386
|
+
if (verbose) {
|
|
1387
|
+
console.log(chalk26.gray(`getAllInputs: ${JSON.stringify(result, null, 2)}`));
|
|
1388
|
+
}
|
|
1389
|
+
return result;
|
|
1390
|
+
})];
|
|
1385
1391
|
};
|
|
1386
1392
|
|
|
1387
1393
|
// src/actions/package/compile/buildEntries.ts
|
|
@@ -1393,7 +1399,7 @@ var buildEntries = (srcDir, entryMode = "single", options, excludeSpecAndStories
|
|
|
1393
1399
|
break;
|
|
1394
1400
|
}
|
|
1395
1401
|
case "all": {
|
|
1396
|
-
entries = excludeSpecAndStories ? getAllInputs(srcDir).filter((entry) => !entry.includes(".spec.") && !entry.includes(".stories.")) : getAllInputs(srcDir);
|
|
1402
|
+
entries = (excludeSpecAndStories ? getAllInputs(srcDir).filter((entry) => !entry.includes(".spec.") && !entry.includes(".stories.")) : getAllInputs(srcDir)).filter((entry) => !entry.endsWith(".d.ts"));
|
|
1397
1403
|
break;
|
|
1398
1404
|
}
|
|
1399
1405
|
case "custom": {
|
|
@@ -1439,7 +1445,7 @@ function deepMergeObjects(objects) {
|
|
|
1439
1445
|
import { cwd as cwd2 } from "process";
|
|
1440
1446
|
import chalk27 from "chalk";
|
|
1441
1447
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1442
|
-
import {
|
|
1448
|
+
import ts2, {
|
|
1443
1449
|
DiagnosticCategory,
|
|
1444
1450
|
formatDiagnosticsWithColorAndContext,
|
|
1445
1451
|
getPreEmitDiagnostics,
|
|
@@ -1456,11 +1462,20 @@ var getCompilerOptions = (options = {}, fileName = "tsconfig.json") => {
|
|
|
1456
1462
|
};
|
|
1457
1463
|
|
|
1458
1464
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1459
|
-
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "
|
|
1465
|
+
var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", compilerOptionsParam, verbose = false) => {
|
|
1460
1466
|
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1461
1467
|
if (verbose) {
|
|
1462
1468
|
console.log(chalk27.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1463
1469
|
}
|
|
1470
|
+
const configFilePath = ts2.findConfigFile(
|
|
1471
|
+
"./",
|
|
1472
|
+
// search path
|
|
1473
|
+
ts2.sys.fileExists,
|
|
1474
|
+
"tsconfig.json"
|
|
1475
|
+
);
|
|
1476
|
+
if (configFilePath === void 0) {
|
|
1477
|
+
throw new Error("Could not find tsconfig.json");
|
|
1478
|
+
}
|
|
1464
1479
|
const compilerOptions = {
|
|
1465
1480
|
...getCompilerOptions({
|
|
1466
1481
|
removeComments: false,
|
|
@@ -1482,9 +1497,11 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "build", co
|
|
|
1482
1497
|
try {
|
|
1483
1498
|
if (entries.length > 0) {
|
|
1484
1499
|
const program = createProgramFromConfig({
|
|
1500
|
+
configFilePath,
|
|
1485
1501
|
basePath: pkg ?? cwd2(),
|
|
1486
1502
|
compilerOptions,
|
|
1487
|
-
files: entries.map((entry) => `${srcDir}/${entry}`)
|
|
1503
|
+
files: entries.map((entry) => `${srcDir}/${entry}`),
|
|
1504
|
+
include: [`${srcDir}/**/*.*`]
|
|
1488
1505
|
});
|
|
1489
1506
|
const diagnostics = getPreEmitDiagnostics(program);
|
|
1490
1507
|
if (diagnostics.length > 0) {
|
|
@@ -1504,33 +1521,42 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "build", co
|
|
|
1504
1521
|
return 0;
|
|
1505
1522
|
} finally {
|
|
1506
1523
|
if (verbose) {
|
|
1507
|
-
console.log(chalk27.cyan(`
|
|
1524
|
+
console.log(chalk27.cyan(`Validating code FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1508
1525
|
}
|
|
1509
1526
|
}
|
|
1510
1527
|
};
|
|
1511
1528
|
|
|
1512
1529
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1530
|
+
import path7 from "path";
|
|
1513
1531
|
import { cwd as cwd3 } from "process";
|
|
1514
1532
|
import chalk28 from "chalk";
|
|
1515
1533
|
import { rollup } from "rollup";
|
|
1516
1534
|
import dts from "rollup-plugin-dts";
|
|
1517
|
-
import inlineSvg from "rollup-plugin-inline-svg";
|
|
1518
1535
|
import nodeExternals from "rollup-plugin-node-externals";
|
|
1519
1536
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
1537
|
+
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1538
|
+
const tsconfigPath = path7.resolve(pkg, "tsconfig.json");
|
|
1520
1539
|
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1540
|
+
try {
|
|
1541
|
+
const bundle = await rollup({
|
|
1542
|
+
input: inputPath,
|
|
1543
|
+
plugins: [dts({
|
|
1544
|
+
...options,
|
|
1545
|
+
tsconfig: tsconfigPath,
|
|
1546
|
+
compilerOptions: { emitDeclarationOnly: true, noEmit: false }
|
|
1547
|
+
}), ...nodePlugIns],
|
|
1548
|
+
onwarn(warning, warn) {
|
|
1549
|
+
if (warning.code === "UNUSED_EXTERNAL_IMPORT") return;
|
|
1550
|
+
warn(warning);
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
await bundle.write({
|
|
1554
|
+
file: outputPath,
|
|
1555
|
+
format: "es"
|
|
1556
|
+
});
|
|
1557
|
+
} catch (ex) {
|
|
1558
|
+
console.error(ex);
|
|
1559
|
+
}
|
|
1534
1560
|
if (verbose) {
|
|
1535
1561
|
console.log(`Bundled declarations written to ${outputPath}`);
|
|
1536
1562
|
}
|
|
@@ -1547,19 +1573,18 @@ var packageCompileTscTypes = async (entries, outDir, platform, srcDir = "build",
|
|
|
1547
1573
|
const newEntryExtension = "d." + splitEntryName.at(-1);
|
|
1548
1574
|
return [...splitEntryName.slice(0, -1), newEntryExtension].join(".");
|
|
1549
1575
|
};
|
|
1550
|
-
const compilerOptions = {
|
|
1576
|
+
const compilerOptions = getCompilerOptions({
|
|
1551
1577
|
removeComments: false,
|
|
1552
1578
|
skipDefaultLibCheck: true,
|
|
1553
1579
|
skipLibCheck: true,
|
|
1554
1580
|
sourceMap: false,
|
|
1555
1581
|
emitDeclarationOnly: false,
|
|
1556
1582
|
noEmit: true
|
|
1557
|
-
};
|
|
1583
|
+
});
|
|
1558
1584
|
const entryNames = entries.map((entry) => entry.split(`${srcDir}/`).at(-1) ?? entry);
|
|
1559
1585
|
await Promise.all(entryNames.map(async (entryName) => {
|
|
1560
1586
|
const entryTypeName = entryNameToTypeName(entryName);
|
|
1561
|
-
|
|
1562
|
-
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions, tsconfig: "tsconfig.json" }, verbose);
|
|
1587
|
+
await bundleDts(`${srcRoot}/${entryTypeName}`, `${outDir}/${entryTypeName}`, platform, { compilerOptions }, verbose);
|
|
1563
1588
|
}));
|
|
1564
1589
|
if (verbose) {
|
|
1565
1590
|
console.log(chalk28.cyan(`Compiling Types FINISH: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
@@ -1577,7 +1602,7 @@ var compileFolder = async (srcDir, entries, options, verbose) => {
|
|
|
1577
1602
|
console.warn(chalk29.yellow(`No entries found in ${srcDir} to compile`));
|
|
1578
1603
|
return 0;
|
|
1579
1604
|
}
|
|
1580
|
-
const tscOutDir = "
|
|
1605
|
+
const tscOutDir = "dist";
|
|
1581
1606
|
if (verbose) {
|
|
1582
1607
|
console.log(chalk29.gray(`tscOutDir [${tscOutDir}]`));
|
|
1583
1608
|
}
|
|
@@ -1586,10 +1611,10 @@ var compileFolder = async (srcDir, entries, options, verbose) => {
|
|
|
1586
1611
|
console.error(chalk29.red(`Compile:Validation had ${validationResult} errors`));
|
|
1587
1612
|
return validationResult;
|
|
1588
1613
|
}
|
|
1589
|
-
const optionsParams = {
|
|
1614
|
+
const optionsParams = tsupOptions([{
|
|
1590
1615
|
bundle: true,
|
|
1591
1616
|
cjsInterop: true,
|
|
1592
|
-
clean:
|
|
1617
|
+
clean: false,
|
|
1593
1618
|
dts: false,
|
|
1594
1619
|
format: ["esm"],
|
|
1595
1620
|
outDir,
|
|
@@ -1599,7 +1624,7 @@ var compileFolder = async (srcDir, entries, options, verbose) => {
|
|
|
1599
1624
|
tsconfig: "tsconfig.json",
|
|
1600
1625
|
...options,
|
|
1601
1626
|
entry: entries.map((entry) => `${srcDir}/${entry}`)
|
|
1602
|
-
};
|
|
1627
|
+
}]);
|
|
1603
1628
|
const optionsResult = defineConfig(optionsParams);
|
|
1604
1629
|
const optionsList = (await Promise.all(
|
|
1605
1630
|
(Array.isArray(optionsResult) ? optionsResult : [optionsResult]).flatMap(async (options2) => {
|
|
@@ -1625,7 +1650,7 @@ var tsupOptions = (options = []) => {
|
|
|
1625
1650
|
".jpg": "copy",
|
|
1626
1651
|
".json": "json",
|
|
1627
1652
|
".png": "copy",
|
|
1628
|
-
".svg": "
|
|
1653
|
+
".svg": "text",
|
|
1629
1654
|
".webp": "copy"
|
|
1630
1655
|
};
|
|
1631
1656
|
const standardOptions = {
|
|
@@ -1716,7 +1741,7 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
1716
1741
|
};
|
|
1717
1742
|
|
|
1718
1743
|
// src/actions/package/copy-assets.ts
|
|
1719
|
-
import
|
|
1744
|
+
import path8 from "path/posix";
|
|
1720
1745
|
import chalk31 from "chalk";
|
|
1721
1746
|
import cpy2 from "cpy";
|
|
1722
1747
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
@@ -1725,7 +1750,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
1725
1750
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
1726
1751
|
`../dist/${target}`,
|
|
1727
1752
|
{
|
|
1728
|
-
cwd:
|
|
1753
|
+
cwd: path8.join(location, "src"),
|
|
1729
1754
|
flat: false
|
|
1730
1755
|
}
|
|
1731
1756
|
);
|
|
@@ -1796,7 +1821,7 @@ var packageCycle = async () => {
|
|
|
1796
1821
|
|
|
1797
1822
|
// src/actions/package/gen-docs.ts
|
|
1798
1823
|
import { existsSync as existsSync4 } from "fs";
|
|
1799
|
-
import
|
|
1824
|
+
import path9 from "path";
|
|
1800
1825
|
import chalk32 from "chalk";
|
|
1801
1826
|
import {
|
|
1802
1827
|
Application,
|
|
@@ -1815,7 +1840,7 @@ var ExitCodes = {
|
|
|
1815
1840
|
};
|
|
1816
1841
|
var packageGenDocs = async () => {
|
|
1817
1842
|
const pkg = process.env.INIT_CWD;
|
|
1818
|
-
if (pkg && !existsSync4(
|
|
1843
|
+
if (pkg && !existsSync4(path9.join(pkg, "typedoc.json"))) {
|
|
1819
1844
|
return;
|
|
1820
1845
|
}
|
|
1821
1846
|
const app = await Application.bootstrap({
|
|
@@ -1907,7 +1932,7 @@ var runTypeDoc = async (app) => {
|
|
|
1907
1932
|
|
|
1908
1933
|
// src/actions/package/lint.ts
|
|
1909
1934
|
import { readdirSync } from "fs";
|
|
1910
|
-
import
|
|
1935
|
+
import path10 from "path";
|
|
1911
1936
|
import { cwd as cwd4 } from "process";
|
|
1912
1937
|
import { pathToFileURL } from "url";
|
|
1913
1938
|
import chalk33 from "chalk";
|
|
@@ -1944,7 +1969,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
1944
1969
|
const subDirectory = dir.split(currentDirectory)[1];
|
|
1945
1970
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
1946
1971
|
return readdirSync(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
1947
|
-
const res =
|
|
1972
|
+
const res = path10.resolve(dir, dirent.name);
|
|
1948
1973
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
1949
1974
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
1950
1975
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|