@xylabs/ts-scripts-yarn3 7.4.0 → 7.4.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.
- package/dist/actions/deplint/checkPackage/checkPackage.mjs +41 -3
- package/dist/actions/deplint/checkPackage/checkPackage.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs +41 -3
- package/dist/actions/deplint/checkPackage/getUnusedDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/checkPackage/index.mjs +41 -3
- package/dist/actions/deplint/checkPackage/index.mjs.map +1 -1
- package/dist/actions/deplint/deplint.mjs +41 -3
- package/dist/actions/deplint/deplint.mjs.map +1 -1
- package/dist/actions/deplint/implicitDevDependencies.mjs +52 -2
- package/dist/actions/deplint/implicitDevDependencies.mjs.map +1 -1
- package/dist/actions/deplint/index.mjs +41 -3
- package/dist/actions/deplint/index.mjs.map +1 -1
- package/dist/actions/index.mjs +45 -7
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy.mjs +41 -3
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +45 -7
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +41 -3
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +41 -3
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +41 -3
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1066,15 +1066,49 @@ function getScriptReferencedPackages(location, allDeps) {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
1068
|
// src/actions/deplint/implicitDevDependencies.ts
|
|
1069
|
+
import fs7 from "fs";
|
|
1069
1070
|
var hasFileWithExtension = (files, extensions) => files.some((f) => extensions.some((ext) => f.endsWith(ext)));
|
|
1071
|
+
var tsExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
|
1072
|
+
var hasTypescriptFiles = ({ srcFiles, configFiles }) => hasFileWithExtension([...srcFiles, ...configFiles], tsExtensions);
|
|
1073
|
+
var decoratorPattern = /^\s*@[a-zA-Z]\w*/m;
|
|
1074
|
+
var hasDecorators = ({ srcFiles }) => srcFiles.filter((f) => tsExtensions.some((ext) => f.endsWith(ext))).some((file) => {
|
|
1075
|
+
try {
|
|
1076
|
+
const content = fs7.readFileSync(file, "utf8");
|
|
1077
|
+
return decoratorPattern.test(content);
|
|
1078
|
+
} catch {
|
|
1079
|
+
return false;
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
var importPlugins = /* @__PURE__ */ new Set(["eslint-plugin-import-x", "eslint-plugin-import"]);
|
|
1083
|
+
function hasImportPlugin({ location, allDependencies }) {
|
|
1084
|
+
if (allDependencies.some((d) => importPlugins.has(d))) return true;
|
|
1085
|
+
for (const dep of allDependencies) {
|
|
1086
|
+
const pkgPath = findDepPackageJson(location, dep);
|
|
1087
|
+
if (!pkgPath) continue;
|
|
1088
|
+
try {
|
|
1089
|
+
const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf8"));
|
|
1090
|
+
const transitiveDeps = [
|
|
1091
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
1092
|
+
...Object.keys(pkg.peerDependencies ?? {})
|
|
1093
|
+
];
|
|
1094
|
+
if (transitiveDeps.some((d) => importPlugins.has(d))) return true;
|
|
1095
|
+
} catch {
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return false;
|
|
1099
|
+
}
|
|
1070
1100
|
var rules = [
|
|
1071
1101
|
{
|
|
1072
1102
|
package: "typescript",
|
|
1073
|
-
isNeeded:
|
|
1103
|
+
isNeeded: hasTypescriptFiles
|
|
1074
1104
|
},
|
|
1075
1105
|
{
|
|
1076
1106
|
package: "eslint-import-resolver-typescript",
|
|
1077
|
-
isNeeded: (
|
|
1107
|
+
isNeeded: (context) => hasTypescriptFiles(context) && context.allDependencies.includes("eslint") && hasImportPlugin(context)
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
package: "tslib",
|
|
1111
|
+
isNeeded: hasDecorators
|
|
1078
1112
|
}
|
|
1079
1113
|
];
|
|
1080
1114
|
function getImplicitDevDependencies(context) {
|
|
@@ -1118,8 +1152,12 @@ function getUnusedDevDependencies({ name, location }, {
|
|
|
1118
1152
|
peerDependencies
|
|
1119
1153
|
}, sourceParams, fileContext) {
|
|
1120
1154
|
const allImports = allExternalImports(sourceParams);
|
|
1121
|
-
const implicitDeps = getImplicitDevDependencies(fileContext);
|
|
1122
1155
|
const allDeps = [...dependencies, ...devDependencies, ...peerDependencies];
|
|
1156
|
+
const implicitDeps = getImplicitDevDependencies({
|
|
1157
|
+
...fileContext,
|
|
1158
|
+
allDependencies: allDeps,
|
|
1159
|
+
location
|
|
1160
|
+
});
|
|
1123
1161
|
const requiredPeers = getRequiredPeerDependencies(location, allDeps);
|
|
1124
1162
|
const scriptRefs = getScriptReferencedPackages(location, allDeps);
|
|
1125
1163
|
let unusedDevDependencies = 0;
|
|
@@ -2280,7 +2318,7 @@ var packageLint = async (fix2 = false, verbose = false, cache = true) => {
|
|
|
2280
2318
|
};
|
|
2281
2319
|
|
|
2282
2320
|
// src/actions/package/publint.ts
|
|
2283
|
-
import { promises as
|
|
2321
|
+
import { promises as fs8 } from "fs";
|
|
2284
2322
|
import chalk34 from "chalk";
|
|
2285
2323
|
import sortPackageJson from "sort-package-json";
|
|
2286
2324
|
var customPubLint = (pkg) => {
|
|
@@ -2307,9 +2345,9 @@ var customPubLint = (pkg) => {
|
|
|
2307
2345
|
};
|
|
2308
2346
|
var packagePublint = async ({ strict = true, verbose = false } = {}) => {
|
|
2309
2347
|
const pkgDir = process.env.INIT_CWD;
|
|
2310
|
-
const sortedPkg = sortPackageJson(await
|
|
2311
|
-
await
|
|
2312
|
-
const pkg = JSON.parse(await
|
|
2348
|
+
const sortedPkg = sortPackageJson(await fs8.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2349
|
+
await fs8.writeFile(`${pkgDir}/package.json`, sortedPkg);
|
|
2350
|
+
const pkg = JSON.parse(await fs8.readFile(`${pkgDir}/package.json`, "utf8"));
|
|
2313
2351
|
console.log(chalk34.green(`Publint: ${pkg.name}`));
|
|
2314
2352
|
console.log(chalk34.gray(pkgDir));
|
|
2315
2353
|
const { publint: publint2 } = await import("publint");
|