@xylabs/ts-scripts-yarn3 7.4.10 → 7.4.11
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 +115 -16
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs +2 -1
- package/dist/actions/deplint/checkPackage/getUnusedDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +114 -20
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs +2 -1
- package/dist/actions/deplint/checkPackage/getUnusedPeerDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +115 -16
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +166 -38
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs +140 -0
- package/dist/actions/deplint/getCliReferencedPackagesFromFiles.mjs.map +1 -0
- package/dist/actions/deplint/getScriptReferencedPackages.mjs +3 -1
- package/dist/actions/deplint/getScriptReferencedPackages.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +166 -38
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +147 -40
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +251 -117
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +23 -2
- package/dist/index.mjs +155 -42
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +251 -117
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +251 -117
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +205 -71
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +2 -2
package/dist/actions/index.mjs
CHANGED
|
@@ -344,8 +344,8 @@ var loadConfig = async (params) => {
|
|
|
344
344
|
|
|
345
345
|
// src/lib/parsedPackageJSON.ts
|
|
346
346
|
import { readFileSync as readFileSync3 } from "fs";
|
|
347
|
-
var parsedPackageJSON = (
|
|
348
|
-
const pathToPackageJSON =
|
|
347
|
+
var parsedPackageJSON = (path14) => {
|
|
348
|
+
const pathToPackageJSON = path14 ?? process.env.npm_package_json ?? "";
|
|
349
349
|
const packageJSON = readFileSync3(pathToPackageJSON).toString();
|
|
350
350
|
return JSON.parse(packageJSON);
|
|
351
351
|
};
|
|
@@ -976,11 +976,11 @@ function getExternalImportsFromFiles({
|
|
|
976
976
|
const allImportPaths = {};
|
|
977
977
|
const distImportPaths = {};
|
|
978
978
|
const distTypeImportPaths = {};
|
|
979
|
-
for (const
|
|
979
|
+
for (const path14 of allFiles) getImportsFromFile(path14, allImportPaths, allImportPaths).flat();
|
|
980
980
|
const distTypeFiles = distFiles.filter(isDeclarationFile);
|
|
981
981
|
const distCodeFiles = distFiles.filter((file) => !isDeclarationFile(file));
|
|
982
|
-
for (const
|
|
983
|
-
for (const
|
|
982
|
+
for (const path14 of distCodeFiles) getImportsFromFile(path14, distImportPaths, distImportPaths).flat();
|
|
983
|
+
for (const path14 of distTypeFiles) getImportsFromFile(path14, distTypeImportPaths, distTypeImportPaths).flat();
|
|
984
984
|
const allImports = Object.keys(allImportPaths);
|
|
985
985
|
const distImports = Object.keys(distImportPaths);
|
|
986
986
|
const externalAllImports = removeInternalImports(allImports);
|
|
@@ -1074,9 +1074,10 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
1074
1074
|
externalDistImports,
|
|
1075
1075
|
externalDistTypeImports,
|
|
1076
1076
|
externalAllImports
|
|
1077
|
-
}) {
|
|
1077
|
+
}, exclude) {
|
|
1078
1078
|
let unusedDependencies = 0;
|
|
1079
1079
|
for (const dep of dependencies) {
|
|
1080
|
+
if (exclude?.has(dep)) continue;
|
|
1080
1081
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1081
1082
|
unusedDependencies++;
|
|
1082
1083
|
if (externalAllImports.includes(dep)) {
|
|
@@ -1097,6 +1098,15 @@ function getUnusedDependencies({ name, location }, { dependencies }, {
|
|
|
1097
1098
|
// src/actions/deplint/checkPackage/getUnusedDevDependencies.ts
|
|
1098
1099
|
import chalk17 from "chalk";
|
|
1099
1100
|
|
|
1101
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1102
|
+
import fs8 from "fs";
|
|
1103
|
+
import path7 from "path";
|
|
1104
|
+
import ts2 from "typescript";
|
|
1105
|
+
|
|
1106
|
+
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1107
|
+
import fs7 from "fs";
|
|
1108
|
+
import path6 from "path";
|
|
1109
|
+
|
|
1100
1110
|
// src/actions/deplint/getRequiredPeerDependencies.ts
|
|
1101
1111
|
import fs6 from "fs";
|
|
1102
1112
|
import path5 from "path";
|
|
@@ -1130,8 +1140,6 @@ function getRequiredPeerDependencies(location, allDeps) {
|
|
|
1130
1140
|
}
|
|
1131
1141
|
|
|
1132
1142
|
// src/actions/deplint/getScriptReferencedPackages.ts
|
|
1133
|
-
import fs7 from "fs";
|
|
1134
|
-
import path6 from "path";
|
|
1135
1143
|
function getBinNames(location, dep) {
|
|
1136
1144
|
const depPkgPath = findDepPackageJson(location, dep);
|
|
1137
1145
|
if (!depPkgPath) return [];
|
|
@@ -1181,15 +1189,101 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1181
1189
|
return referenced;
|
|
1182
1190
|
}
|
|
1183
1191
|
|
|
1192
|
+
// src/actions/deplint/getCliReferencedPackagesFromFiles.ts
|
|
1193
|
+
var shellCommandFunctions = /* @__PURE__ */ new Set(["execSync", "exec"]);
|
|
1194
|
+
var directExecFunctions = /* @__PURE__ */ new Set(["spawn", "spawnSync", "execFile", "execFileSync"]);
|
|
1195
|
+
var allExecFunctions = /* @__PURE__ */ new Set([...shellCommandFunctions, ...directExecFunctions]);
|
|
1196
|
+
function getCommandTokensFromFile(filePath) {
|
|
1197
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
1198
|
+
let sourceCode;
|
|
1199
|
+
try {
|
|
1200
|
+
sourceCode = fs8.readFileSync(filePath, "utf8");
|
|
1201
|
+
} catch {
|
|
1202
|
+
return tokens;
|
|
1203
|
+
}
|
|
1204
|
+
const isMjsFile = filePath.endsWith(".mjs");
|
|
1205
|
+
const sourceFile = ts2.createSourceFile(
|
|
1206
|
+
path7.basename(filePath),
|
|
1207
|
+
sourceCode,
|
|
1208
|
+
ts2.ScriptTarget.Latest,
|
|
1209
|
+
true,
|
|
1210
|
+
isMjsFile ? ts2.ScriptKind.JS : void 0
|
|
1211
|
+
);
|
|
1212
|
+
function visit(node) {
|
|
1213
|
+
if (ts2.isCallExpression(node) && node.arguments.length > 0) {
|
|
1214
|
+
const fnName = getFunctionName(node.expression);
|
|
1215
|
+
if (fnName && allExecFunctions.has(fnName)) {
|
|
1216
|
+
const firstArg = node.arguments[0];
|
|
1217
|
+
if (ts2.isStringLiteral(firstArg) || ts2.isNoSubstitutionTemplateLiteral(firstArg)) {
|
|
1218
|
+
const value = firstArg.text;
|
|
1219
|
+
if (shellCommandFunctions.has(fnName)) {
|
|
1220
|
+
for (const token of tokenizeScript(value)) {
|
|
1221
|
+
tokens.add(token);
|
|
1222
|
+
}
|
|
1223
|
+
} else {
|
|
1224
|
+
tokens.add(value);
|
|
1225
|
+
}
|
|
1226
|
+
} else if (ts2.isTemplateExpression(firstArg)) {
|
|
1227
|
+
const head = firstArg.head.text;
|
|
1228
|
+
if (head) {
|
|
1229
|
+
for (const token of tokenizeScript(head)) {
|
|
1230
|
+
tokens.add(token);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
ts2.forEachChild(node, visit);
|
|
1237
|
+
}
|
|
1238
|
+
visit(sourceFile);
|
|
1239
|
+
return tokens;
|
|
1240
|
+
}
|
|
1241
|
+
function getFunctionName(expr) {
|
|
1242
|
+
if (ts2.isIdentifier(expr)) {
|
|
1243
|
+
return expr.text;
|
|
1244
|
+
}
|
|
1245
|
+
if (ts2.isPropertyAccessExpression(expr) && ts2.isIdentifier(expr.name)) {
|
|
1246
|
+
return expr.name.text;
|
|
1247
|
+
}
|
|
1248
|
+
return void 0;
|
|
1249
|
+
}
|
|
1250
|
+
function getCliReferencedPackagesFromFiles(allFiles, location, allDeps) {
|
|
1251
|
+
const allTokens = /* @__PURE__ */ new Set();
|
|
1252
|
+
for (const file of allFiles) {
|
|
1253
|
+
for (const token of getCommandTokensFromFile(file)) {
|
|
1254
|
+
allTokens.add(token);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
if (allTokens.size === 0) return /* @__PURE__ */ new Set();
|
|
1258
|
+
const binToPackage = /* @__PURE__ */ new Map();
|
|
1259
|
+
for (const dep of allDeps) {
|
|
1260
|
+
for (const bin of getBinNames(location, dep)) {
|
|
1261
|
+
binToPackage.set(bin, dep);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
1265
|
+
for (const token of allTokens) {
|
|
1266
|
+
const baseName = getBasePackageName(token);
|
|
1267
|
+
if (allDeps.includes(baseName)) {
|
|
1268
|
+
referenced.add(baseName);
|
|
1269
|
+
}
|
|
1270
|
+
const pkg = binToPackage.get(token);
|
|
1271
|
+
if (pkg) {
|
|
1272
|
+
referenced.add(pkg);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return referenced;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1184
1278
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1185
|
-
import
|
|
1279
|
+
import fs9 from "fs";
|
|
1186
1280
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1187
1281
|
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1188
1282
|
var hasTypescriptFiles = ({ allFiles }) => hasFileWithExtension(allFiles, tsExtensions);
|
|
1189
1283
|
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1190
1284
|
var hasDecorators = ({ allFiles }) => allFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1191
1285
|
try {
|
|
1192
|
-
const content =
|
|
1286
|
+
const content = fs9.readFileSync(file, "utf8");
|
|
1193
1287
|
return decoratorPattern.test(content);
|
|
1194
1288
|
} catch {
|
|
1195
1289
|
return false;
|
|
@@ -1202,7 +1296,7 @@ function hasImportPlugin({ location, allDependencies }) {
|
|
|
1202
1296
|
const pkgPath = findDepPackageJson(location, dep);
|
|
1203
1297
|
if (!pkgPath) continue;
|
|
1204
1298
|
try {
|
|
1205
|
-
const pkg = JSON.parse(
|
|
1299
|
+
const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
|
|
1206
1300
|
const transitiveDeps = [
|
|
1207
1301
|
...Object.keys(pkg.dependencies ?? {}),
|
|
1208
1302
|
...Object.keys(pkg.peerDependencies ?? {})
|
|
@@ -1254,10 +1348,11 @@ var allExternalImports = ({
|
|
|
1254
1348
|
...externalDistTypeImports
|
|
1255
1349
|
]);
|
|
1256
1350
|
};
|
|
1257
|
-
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs) {
|
|
1351
|
+
function isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs) {
|
|
1258
1352
|
if (implicitDeps.has(dep)) return true;
|
|
1259
1353
|
if (requiredPeers.has(dep)) return true;
|
|
1260
1354
|
if (scriptRefs.has(dep)) return true;
|
|
1355
|
+
if (cliRefs.has(dep)) return true;
|
|
1261
1356
|
if (dep.startsWith("@types/")) {
|
|
1262
1357
|
const baseName = dep.replace(/^@types\//, "");
|
|
1263
1358
|
return allImports.has(baseName) || allImports.has(dep) || implicitDeps.has(baseName);
|
|
@@ -1268,7 +1363,7 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1268
1363
|
devDependencies,
|
|
1269
1364
|
dependencies,
|
|
1270
1365
|
peerDependencies
|
|
1271
|
-
}, sourceParams, fileContext) {
|
|
1366
|
+
}, sourceParams, fileContext, exclude) {
|
|
1272
1367
|
const allImports = allExternalImports(sourceParams);
|
|
1273
1368
|
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1274
1369
|
const implicitDeps = getImplicitDevDependencies({
|
|
@@ -1278,10 +1373,12 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1278
1373
|
});
|
|
1279
1374
|
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1280
1375
|
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1376
|
+
const cliRefs = getCliReferencedPackagesFromFiles(fileContext.allFiles, location, allDeps);
|
|
1281
1377
|
let unusedDevDependencies = 0;
|
|
1282
1378
|
for (const dep of devDependencies) {
|
|
1379
|
+
if (exclude?.has(dep)) continue;
|
|
1283
1380
|
if (dependencies.includes(dep) || peerDependencies.includes(dep)) continue;
|
|
1284
|
-
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs)) {
|
|
1381
|
+
if (!isDevDepUsed(dep, allImports, implicitDeps, requiredPeers, scriptRefs, cliRefs)) {
|
|
1285
1382
|
unusedDevDependencies++;
|
|
1286
1383
|
console.log(`[${chalk17.blue(name)}] Unused devDependency in package.json: ${chalk17.red(dep)}`);
|
|
1287
1384
|
}
|
|
@@ -1296,9 +1393,10 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1296
1393
|
|
|
1297
1394
|
// src/actions/deplint/checkPackage/getUnusedPeerDependencies.ts
|
|
1298
1395
|
import chalk18 from "chalk";
|
|
1299
|
-
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }) {
|
|
1396
|
+
function getUnusedPeerDependencies({ name, location }, { peerDependencies, dependencies }, { externalDistImports, externalDistTypeImports }, exclude) {
|
|
1300
1397
|
let unusedDependencies = 0;
|
|
1301
1398
|
for (const dep of peerDependencies) {
|
|
1399
|
+
if (exclude?.has(dep)) continue;
|
|
1302
1400
|
if (!externalDistImports.includes(dep) && !externalDistImports.includes(dep.replace(/^@types\//, "")) && !externalDistTypeImports.includes(dep) && !externalDistTypeImports.includes(dep.replace(/^@types\//, ""))) {
|
|
1303
1401
|
unusedDependencies++;
|
|
1304
1402
|
if (dependencies.includes(dep)) {
|
|
@@ -1335,6 +1433,7 @@ function checkPackage({
|
|
|
1335
1433
|
location,
|
|
1336
1434
|
deps = false,
|
|
1337
1435
|
devDeps = false,
|
|
1436
|
+
exclude,
|
|
1338
1437
|
peerDeps = false,
|
|
1339
1438
|
verbose = false
|
|
1340
1439
|
}) {
|
|
@@ -1353,23 +1452,29 @@ function checkPackage({
|
|
|
1353
1452
|
});
|
|
1354
1453
|
const packageParams = getDependenciesFromPackageJson(`${location}/package.json`);
|
|
1355
1454
|
const unlistedDependencies = checkDeps ? getUnlistedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1356
|
-
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1455
|
+
const unusedDependencies = checkDeps ? getUnusedDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1357
1456
|
const unlistedDevDependencies = checkDevDeps ? getUnlistedDevDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1358
1457
|
const fileContext = { allFiles, distFiles };
|
|
1359
|
-
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext) : 0;
|
|
1360
|
-
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams) : 0;
|
|
1458
|
+
const unusedDevDependencies = checkDevDeps ? getUnusedDevDependencies({ name, location }, packageParams, sourceParams, fileContext, exclude) : 0;
|
|
1459
|
+
const unusedPeerDependencies = checkPeerDeps ? getUnusedPeerDependencies({ name, location }, packageParams, sourceParams, exclude) : 0;
|
|
1361
1460
|
const totalErrors = unlistedDependencies + unlistedDevDependencies + unusedDependencies + unusedDevDependencies + unusedPeerDependencies;
|
|
1362
1461
|
return totalErrors;
|
|
1363
1462
|
}
|
|
1364
1463
|
|
|
1365
1464
|
// src/actions/deplint/deplint.ts
|
|
1366
|
-
var deplint = ({
|
|
1465
|
+
var deplint = async ({
|
|
1367
1466
|
pkg,
|
|
1368
1467
|
deps,
|
|
1369
1468
|
devDeps,
|
|
1370
1469
|
peerDeps,
|
|
1371
|
-
verbose
|
|
1470
|
+
verbose,
|
|
1471
|
+
cliExclude
|
|
1372
1472
|
}) => {
|
|
1473
|
+
const config2 = await loadConfig();
|
|
1474
|
+
const exclude = /* @__PURE__ */ new Set([
|
|
1475
|
+
...config2.deplint?.exclude ?? [],
|
|
1476
|
+
...cliExclude ?? []
|
|
1477
|
+
]);
|
|
1373
1478
|
let totalErrors = 0;
|
|
1374
1479
|
if (pkg === void 0) {
|
|
1375
1480
|
const workspaces = yarnWorkspaces();
|
|
@@ -1379,6 +1484,7 @@ var deplint = ({
|
|
|
1379
1484
|
...workspace,
|
|
1380
1485
|
deps,
|
|
1381
1486
|
devDeps,
|
|
1487
|
+
exclude,
|
|
1382
1488
|
peerDeps,
|
|
1383
1489
|
verbose
|
|
1384
1490
|
});
|
|
@@ -1391,6 +1497,7 @@ var deplint = ({
|
|
|
1391
1497
|
location,
|
|
1392
1498
|
devDeps,
|
|
1393
1499
|
deps,
|
|
1500
|
+
exclude,
|
|
1394
1501
|
peerDeps,
|
|
1395
1502
|
verbose
|
|
1396
1503
|
});
|
|
@@ -1724,12 +1831,12 @@ var filename2 = ".npmignore";
|
|
|
1724
1831
|
var npmignoreGen = (pkg) => generateIgnoreFiles(filename2, pkg);
|
|
1725
1832
|
|
|
1726
1833
|
// src/actions/package/clean-outputs.ts
|
|
1727
|
-
import
|
|
1834
|
+
import path8 from "path";
|
|
1728
1835
|
import chalk25 from "chalk";
|
|
1729
1836
|
var packageCleanOutputs = () => {
|
|
1730
1837
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1731
1838
|
const pkgName = process.env.npm_package_name;
|
|
1732
|
-
const folders = [
|
|
1839
|
+
const folders = [path8.join(pkg, "dist"), path8.join(pkg, "build"), path8.join(pkg, "docs")];
|
|
1733
1840
|
console.log(chalk25.green(`Cleaning Outputs [${pkgName}]`));
|
|
1734
1841
|
for (let folder of folders) {
|
|
1735
1842
|
deleteGlob(folder);
|
|
@@ -1738,13 +1845,13 @@ var packageCleanOutputs = () => {
|
|
|
1738
1845
|
};
|
|
1739
1846
|
|
|
1740
1847
|
// src/actions/package/clean-typescript.ts
|
|
1741
|
-
import
|
|
1848
|
+
import path9 from "path";
|
|
1742
1849
|
import chalk26 from "chalk";
|
|
1743
1850
|
var packageCleanTypescript = () => {
|
|
1744
1851
|
const pkg = process.env.INIT_CWD ?? ".";
|
|
1745
1852
|
const pkgName = process.env.npm_package_name;
|
|
1746
1853
|
console.log(chalk26.green(`Cleaning Typescript [${pkgName}]`));
|
|
1747
|
-
const files = [
|
|
1854
|
+
const files = [path9.join(pkg, "*.tsbuildinfo"), path9.join(pkg, ".tsconfig.*"), path9.join(pkg, ".eslintcache")];
|
|
1748
1855
|
for (let file of files) {
|
|
1749
1856
|
deleteGlob(file);
|
|
1750
1857
|
}
|
|
@@ -1837,7 +1944,7 @@ function deepMergeObjects(objects) {
|
|
|
1837
1944
|
import { cwd as cwd2 } from "process";
|
|
1838
1945
|
import chalk28 from "chalk";
|
|
1839
1946
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1840
|
-
import
|
|
1947
|
+
import ts3, {
|
|
1841
1948
|
DiagnosticCategory,
|
|
1842
1949
|
formatDiagnosticsWithColorAndContext,
|
|
1843
1950
|
getPreEmitDiagnostics,
|
|
@@ -1859,10 +1966,10 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1859
1966
|
if (verbose) {
|
|
1860
1967
|
console.log(chalk28.cyan(`Validating code START: ${entries.length} files to ${outDir} from ${srcDir}`));
|
|
1861
1968
|
}
|
|
1862
|
-
const configFilePath =
|
|
1969
|
+
const configFilePath = ts3.findConfigFile(
|
|
1863
1970
|
"./",
|
|
1864
1971
|
// search path
|
|
1865
|
-
|
|
1972
|
+
ts3.sys.fileExists,
|
|
1866
1973
|
"tsconfig.json"
|
|
1867
1974
|
);
|
|
1868
1975
|
if (configFilePath === void 0) {
|
|
@@ -1912,7 +2019,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1912
2019
|
if (nonEmitPatterns.some((pattern) => fileName.includes(pattern))) {
|
|
1913
2020
|
return;
|
|
1914
2021
|
}
|
|
1915
|
-
|
|
2022
|
+
ts3.sys.writeFile(fileName, text, writeByteOrderMark);
|
|
1916
2023
|
});
|
|
1917
2024
|
return diagnostics.reduce((acc, diag) => acc + (diag.category === DiagnosticCategory.Error ? 1 : 0), 0);
|
|
1918
2025
|
}
|
|
@@ -1925,7 +2032,7 @@ var packageCompileTsc = (platform, entries, srcDir = "src", outDir = "dist", com
|
|
|
1925
2032
|
};
|
|
1926
2033
|
|
|
1927
2034
|
// src/actions/package/compile/packageCompileTscTypes.ts
|
|
1928
|
-
import
|
|
2035
|
+
import path10 from "path";
|
|
1929
2036
|
import { cwd as cwd3 } from "process";
|
|
1930
2037
|
import chalk29 from "chalk";
|
|
1931
2038
|
import { rollup } from "rollup";
|
|
@@ -1934,7 +2041,7 @@ import nodeExternals from "rollup-plugin-node-externals";
|
|
|
1934
2041
|
var ignoredWarningCodes = /* @__PURE__ */ new Set(["EMPTY_BUNDLE", "UNRESOLVED_IMPORT"]);
|
|
1935
2042
|
async function bundleDts(inputPath, outputPath, platform, options, verbose = false) {
|
|
1936
2043
|
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1937
|
-
const tsconfigPath =
|
|
2044
|
+
const tsconfigPath = path10.resolve(pkg, "tsconfig.json");
|
|
1938
2045
|
const nodePlugIns = platform === "node" ? [nodeExternals()] : [];
|
|
1939
2046
|
try {
|
|
1940
2047
|
const bundle = await rollup({
|
|
@@ -2163,7 +2270,7 @@ var packageCompile = async (inConfig = {}) => {
|
|
|
2163
2270
|
};
|
|
2164
2271
|
|
|
2165
2272
|
// src/actions/package/copy-assets.ts
|
|
2166
|
-
import
|
|
2273
|
+
import path11 from "path/posix";
|
|
2167
2274
|
import chalk32 from "chalk";
|
|
2168
2275
|
import cpy2 from "cpy";
|
|
2169
2276
|
var copyTargetAssets2 = async (target, name, location) => {
|
|
@@ -2172,7 +2279,7 @@ var copyTargetAssets2 = async (target, name, location) => {
|
|
|
2172
2279
|
["**/*.jpg", "**/*.png", "**/*.gif", "**/*.svg", "**/*.webp", "**/*.sass", "**/*.scss", "**/*.gif", "**/*.css"],
|
|
2173
2280
|
`../dist/${target}`,
|
|
2174
2281
|
{
|
|
2175
|
-
cwd:
|
|
2282
|
+
cwd: path11.join(location, "src"),
|
|
2176
2283
|
flat: false
|
|
2177
2284
|
}
|
|
2178
2285
|
);
|
|
@@ -2243,7 +2350,7 @@ var packageCycle = async () => {
|
|
|
2243
2350
|
|
|
2244
2351
|
// src/actions/package/gen-docs.ts
|
|
2245
2352
|
import { existsSync as existsSync6 } from "fs";
|
|
2246
|
-
import
|
|
2353
|
+
import path12 from "path";
|
|
2247
2354
|
import chalk33 from "chalk";
|
|
2248
2355
|
import {
|
|
2249
2356
|
Application,
|
|
@@ -2262,7 +2369,7 @@ var ExitCodes = {
|
|
|
2262
2369
|
};
|
|
2263
2370
|
var packageGenDocs = async () => {
|
|
2264
2371
|
const pkg = process.env.INIT_CWD;
|
|
2265
|
-
if (pkg !== void 0 && !existsSync6(
|
|
2372
|
+
if (pkg !== void 0 && !existsSync6(path12.join(pkg, "typedoc.json"))) {
|
|
2266
2373
|
return;
|
|
2267
2374
|
}
|
|
2268
2375
|
const app = await Application.bootstrap({
|
|
@@ -2354,7 +2461,7 @@ var runTypeDoc = async (app) => {
|
|
|
2354
2461
|
|
|
2355
2462
|
// src/actions/package/lint.ts
|
|
2356
2463
|
import { readdirSync as readdirSync4 } from "fs";
|
|
2357
|
-
import
|
|
2464
|
+
import path13 from "path";
|
|
2358
2465
|
import { cwd as cwd4 } from "process";
|
|
2359
2466
|
import { pathToFileURL } from "url";
|
|
2360
2467
|
import chalk34 from "chalk";
|
|
@@ -2391,7 +2498,7 @@ function getFiles(dir, ignoreFolders) {
|
|
|
2391
2498
|
const subDirectory = dir.split(currentDirectory)[1]?.split("/")[1];
|
|
2392
2499
|
if (ignoreFolders.includes(subDirectory)) return [];
|
|
2393
2500
|
return readdirSync4(dir, { withFileTypes: true }).flatMap((dirent) => {
|
|
2394
|
-
const res =
|
|
2501
|
+
const res = path13.resolve(dir, dirent.name);
|
|
2395
2502
|
const relativePath = subDirectory === void 0 ? dirent.name : `${subDirectory}/${dirent.name}`;
|
|
2396
2503
|
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
2397
2504
|
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
@@ -2430,7 +2537,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2430
2537
|
};
|
|
2431
2538
|
|
|
2432
2539
|
// src/actions/package/publint.ts
|
|
2433
|
-
import { promises as
|
|
2540
|
+
import { promises as fs10 } from "fs";
|
|
2434
2541
|
import chalk35 from "chalk";
|
|
2435
2542
|
import sortPackageJson from "sort-package-json";
|
|
2436
2543
|
var customPubLint = (pkg) => {
|
|
@@ -2457,9 +2564,9 @@ var customPubLint = (pkg) => {
|
|
|
2457
2564
|
};
|
|
2458
2565
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2459
2566
|
const pkgDir = process.env.INIT_CWD;
|
|
2460
|
-
const sortedPkg = sortPackageJson(await
|
|
2461
|
-
await
|
|
2462
|
-
const pkg = JSON.parse(await
|
|
2567
|
+
const sortedPkg = sortPackageJson(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2568
|
+
await fs10.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2569
|
+
const pkg = JSON.parse(await fs10.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2463
2570
|
console.log(chalk35.green(`Publint: ${pkg.name}`));
|
|
2464
2571
|
console.log(chalk35.gray(pkgDir));
|
|
2465
2572
|
const { publint: publint2 } = await import("publint");
|