@xylabs/ts-scripts-yarn3 5.1.6 → 5.1.8
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/fix.mjs +4 -10
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/index.mjs +30 -31
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/lint-clean.mjs +4 -10
- package/dist/actions/lint-clean.mjs.map +1 -1
- package/dist/actions/lint.mjs +4 -10
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/actions/package/index.mjs +26 -21
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/lint.mjs +26 -21
- package/dist/actions/package/lint.mjs.map +1 -1
- package/dist/bin/package/fix.mjs +26 -21
- package/dist/bin/package/fix.mjs.map +1 -1
- package/dist/bin/package/lint.mjs +26 -21
- package/dist/bin/package/lint.mjs.map +1 -1
- package/dist/bin/xy-ts.mjs +4 -10
- package/dist/bin/xy-ts.mjs.map +1 -1
- package/dist/bin/xy.mjs +4 -10
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.mjs +30 -31
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +4 -10
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +4 -10
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +4 -10
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +6 -4
- package/src/actions/lint.ts +3 -5
- package/src/actions/package/lint.ts +26 -20
|
@@ -13,6 +13,7 @@ import { pathToFileURL } from "node:url";
|
|
|
13
13
|
import chalk from "chalk";
|
|
14
14
|
import { ESLint } from "eslint";
|
|
15
15
|
import { findUp } from "find-up";
|
|
16
|
+
import picomatch from "picomatch";
|
|
16
17
|
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
17
18
|
const colors = [
|
|
18
19
|
"white",
|
|
@@ -42,37 +43,41 @@ async function getRootESLintConfig() {
|
|
|
42
43
|
return pathToFileURL(configPath);
|
|
43
44
|
}
|
|
44
45
|
__name(getRootESLintConfig, "getRootESLintConfig");
|
|
46
|
+
function getFiles(dir, ignoreFolders) {
|
|
47
|
+
const currentDirectory = cwd();
|
|
48
|
+
return readdirSync(dir, {
|
|
49
|
+
withFileTypes: true
|
|
50
|
+
}).flatMap((dirent) => {
|
|
51
|
+
const res = path.resolve(dir, dirent.name);
|
|
52
|
+
const subDirectory = dir.split(currentDirectory)[1];
|
|
53
|
+
const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
|
|
54
|
+
const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
|
|
55
|
+
if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
|
|
56
|
+
return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
|
|
57
|
+
res
|
|
58
|
+
];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
__name(getFiles, "getFiles");
|
|
45
62
|
var packageLint = /* @__PURE__ */ __name(async (fix = false) => {
|
|
46
63
|
const configPath = await getRootESLintConfig();
|
|
47
64
|
const { default: eslintConfig } = await import(configPath.href);
|
|
48
|
-
const ignoreFolders =
|
|
65
|
+
const ignoreFolders = [
|
|
49
66
|
"node_modules",
|
|
50
67
|
"dist",
|
|
51
|
-
"packages"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
withFileTypes: true
|
|
56
|
-
}).flatMap((dirent) => {
|
|
57
|
-
const res = path.resolve(dir, dirent.name);
|
|
58
|
-
if (ignorePatterns2.some((pattern) => dir.includes(pattern))) return [];
|
|
59
|
-
return dirent.isDirectory() ? getFiles(res, ignorePatterns2) : res.endsWith(".ts") || res.endsWith(".tsx") || res.endsWith(".js") || res.endsWith(".jsx") ? [
|
|
60
|
-
res
|
|
61
|
-
] : [];
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
__name(getFiles, "getFiles");
|
|
68
|
+
"packages",
|
|
69
|
+
".git",
|
|
70
|
+
"build"
|
|
71
|
+
];
|
|
65
72
|
const engine = new ESLint({
|
|
66
73
|
baseConfig: [
|
|
67
74
|
...eslintConfig
|
|
68
75
|
],
|
|
69
|
-
fix
|
|
76
|
+
fix,
|
|
77
|
+
warnIgnored: false
|
|
70
78
|
});
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
...ignoreFolders
|
|
74
|
-
];
|
|
75
|
-
const lintResults = await engine.lintFiles(getFiles(cwd(), ignorePatterns));
|
|
79
|
+
const files = getFiles(cwd(), ignoreFolders);
|
|
80
|
+
const lintResults = await engine.lintFiles(files);
|
|
76
81
|
dumpMessages(lintResults);
|
|
77
82
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
78
83
|
}, "packageLint");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/package/lint.ts","../../../src/actions/package/lint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { packageLint } from '../../actions/index.ts'\n\npackageLint()\n .then((value) => {\n if (value) {\n process.exit(value)\n }\n })\n .catch((reason) => {\n console.error(chalk.red(reason))\n process.exit(-1)\n })\n","import { readdirSync } from 'node:fs'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\n\nimport chalk from 'chalk'\nimport { ESLint } from 'eslint'\nimport { findUp } from 'find-up'\n\nconst dumpMessages = (lintResults: ESLint.LintResult[]) => {\n const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']\n const severity: string[] = ['none', 'warning', 'error']\n\n for (const lintResult of lintResults) {\n if (lintResult.messages.length > 0) {\n console.log(chalk.gray(`\\n${lintResult.filePath}`))\n for (const message of lintResult.messages) {\n console.log(\n chalk.gray(`\\t${message.line}:${message.column}`),\n chalk[colors[message.severity]](`\\t${severity[message.severity]}`),\n chalk.white(`\\t${message.message}`),\n chalk.gray(`\\t${message.ruleId}`),\n )\n }\n }\n }\n}\n\nasync function getRootESLintConfig() {\n // Locate the root eslint.config.mjs\n const configPath = await findUp('eslint.config.mjs')\n\n if (!configPath) {\n throw new Error('eslint.config.mjs not found in the monorepo')\n }\n\n return pathToFileURL(configPath)\n}\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/package/lint.ts","../../../src/actions/package/lint.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport chalk from 'chalk'\n\nimport { packageLint } from '../../actions/index.ts'\n\npackageLint()\n .then((value) => {\n if (value) {\n process.exit(value)\n }\n })\n .catch((reason) => {\n console.error(chalk.red(reason))\n process.exit(-1)\n })\n","import { readdirSync } from 'node:fs'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { pathToFileURL } from 'node:url'\n\nimport chalk from 'chalk'\nimport { ESLint } from 'eslint'\nimport { findUp } from 'find-up'\nimport picomatch from 'picomatch'\n\nconst dumpMessages = (lintResults: ESLint.LintResult[]) => {\n const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']\n const severity: string[] = ['none', 'warning', 'error']\n\n for (const lintResult of lintResults) {\n if (lintResult.messages.length > 0) {\n console.log(chalk.gray(`\\n${lintResult.filePath}`))\n for (const message of lintResult.messages) {\n console.log(\n chalk.gray(`\\t${message.line}:${message.column}`),\n chalk[colors[message.severity]](`\\t${severity[message.severity]}`),\n chalk.white(`\\t${message.message}`),\n chalk.gray(`\\t${message.ruleId}`),\n )\n }\n }\n }\n}\n\nasync function getRootESLintConfig() {\n // Locate the root eslint.config.mjs\n const configPath = await findUp('eslint.config.mjs')\n\n if (!configPath) {\n throw new Error('eslint.config.mjs not found in the monorepo')\n }\n\n return pathToFileURL(configPath)\n}\n\nfunction getFiles(dir: string, ignoreFolders: string[]): string[] {\n const currentDirectory = cwd()\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\n const subDirectory = dir.split(currentDirectory)[1]\n const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name\n\n const ignoreMatchers = ignoreFolders.map(pattern => picomatch(pattern))\n\n // Exclude ignored paths\n if (ignoreMatchers.some(isMatch => isMatch(relativePath))) return []\n\n return dirent.isDirectory()\n ? getFiles(res, ignoreFolders)\n : [res]\n })\n}\n\nexport const packageLint = async (fix = false) => {\n const configPath = await getRootESLintConfig()\n const { default: eslintConfig } = await import(configPath.href)\n\n // List of folders to ignore\n const ignoreFolders = ['node_modules', 'dist', 'packages', '.git', 'build']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n"],"mappings":";;;;;AAEA,OAAOA,YAAW;;;ACFlB,SAASC,mBAAmB;AAC5B,OAAOC,UAAU;AACjB,SAASC,WAAW;AACpB,SAASC,qBAAqB;AAE9B,OAAOC,WAAW;AAClB,SAASC,cAAc;AACvB,SAASC,cAAc;AACvB,OAAOC,eAAe;AAEtB,IAAMC,eAAe,wBAACC,gBAAAA;AACpB,QAAMC,SAAyC;IAAC;IAAS;IAAU;;AACnE,QAAMC,WAAqB;IAAC;IAAQ;IAAW;;AAE/C,aAAWC,cAAcH,aAAa;AACpC,QAAIG,WAAWC,SAASC,SAAS,GAAG;AAClCC,cAAQC,IAAIC,MAAMC,KAAK;EAAKN,WAAWO,QAAQ,EAAE,CAAA;AACjD,iBAAWC,WAAWR,WAAWC,UAAU;AACzCE,gBAAQC,IACNC,MAAMC,KAAK,IAAKE,QAAQC,IAAI,IAAID,QAAQE,MAAM,EAAE,GAChDL,MAAMP,OAAOU,QAAQT,QAAQ,CAAC,EAAE,IAAKA,SAASS,QAAQT,QAAQ,CAAC,EAAE,GACjEM,MAAMM,MAAM,IAAKH,QAAQA,OAAO,EAAE,GAClCH,MAAMC,KAAK,IAAKE,QAAQI,MAAM,EAAE,CAAA;M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rD,eAAeqD,OAAOrD,WAAWsD,YAAY,CAAA;AAChF,GAjB2B;;;ADrD3BC,YAAAA,EACGC,KAAK,CAACC,UAAAA;AACL,MAAIA,OAAO;AACTC,YAAQC,KAAKF,KAAAA;EACf;AACF,CAAA,EACCG,MAAM,CAACC,WAAAA;AACNC,UAAQC,MAAMC,OAAMC,IAAIJ,MAAAA,CAAAA;AACxBH,UAAQC,KAAK,EAAC;AAChB,CAAA;","names":["chalk","readdirSync","path","cwd","pathToFileURL","chalk","ESLint","findUp","picomatch","dumpMessages","lintResults","colors","severity","lintResult","messages","length","console","log","chalk","gray","filePath","message","line","column","white","ruleId","getRootESLintConfig","configPath","findUp","Error","pathToFileURL","getFiles","dir","ignoreFolders","currentDirectory","cwd","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","subDirectory","split","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","lintFiles","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
|
package/dist/bin/xy-ts.mjs
CHANGED
|
@@ -945,18 +945,13 @@ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2
|
|
|
945
945
|
});
|
|
946
946
|
}, "lint");
|
|
947
947
|
var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
|
|
948
|
-
console.log(chalk13.gray("
|
|
948
|
+
console.log(chalk13.gray(`${fix2 ? "Fix" : "Lint"} [All-Packages]`));
|
|
949
949
|
const start = Date.now();
|
|
950
950
|
const verboseOptions = verbose ? [
|
|
951
951
|
"--verbose"
|
|
952
952
|
] : [
|
|
953
953
|
"--no-verbose"
|
|
954
954
|
];
|
|
955
|
-
const fixOptions = fix2 ? [
|
|
956
|
-
"--fix"
|
|
957
|
-
] : [
|
|
958
|
-
""
|
|
959
|
-
];
|
|
960
955
|
const incrementalOptions = incremental ? [
|
|
961
956
|
"--since",
|
|
962
957
|
"-Apt"
|
|
@@ -964,7 +959,7 @@ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incre
|
|
|
964
959
|
"--parallel",
|
|
965
960
|
"-Apt"
|
|
966
961
|
];
|
|
967
|
-
const result = runSteps("Lint
|
|
962
|
+
const result = runSteps(`${fix2 ? "Fix" : "Lint"} [All-Packages]`, [
|
|
968
963
|
[
|
|
969
964
|
"yarn",
|
|
970
965
|
[
|
|
@@ -973,12 +968,11 @@ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incre
|
|
|
973
968
|
...verboseOptions,
|
|
974
969
|
...incrementalOptions,
|
|
975
970
|
"run",
|
|
976
|
-
fix2 ? "package-fix" : "package-lint"
|
|
977
|
-
...fixOptions
|
|
971
|
+
fix2 ? "package-fix" : "package-lint"
|
|
978
972
|
]
|
|
979
973
|
]
|
|
980
974
|
]);
|
|
981
|
-
console.log(
|
|
975
|
+
console.log(chalk13.gray(`${fix2 ? "Fixed in" : "Linted in"} [${chalk13.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk13.gray("seconds")}`));
|
|
982
976
|
return result;
|
|
983
977
|
}, "lintAllPackages");
|
|
984
978
|
|