@xylabs/ts-scripts-yarn3 6.0.2 → 6.0.4

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 (43) hide show
  1. package/dist/actions/fix.mjs +28 -59
  2. package/dist/actions/fix.mjs.map +1 -1
  3. package/dist/actions/index.mjs +96 -121
  4. package/dist/actions/index.mjs.map +1 -1
  5. package/dist/actions/lint.mjs +25 -65
  6. package/dist/actions/lint.mjs.map +1 -1
  7. package/dist/actions/package/index.mjs +3 -2
  8. package/dist/actions/package/index.mjs.map +1 -1
  9. package/dist/actions/package/lint.mjs +3 -2
  10. package/dist/actions/package/lint.mjs.map +1 -1
  11. package/dist/actions/relint.mjs +61 -45
  12. package/dist/actions/relint.mjs.map +1 -1
  13. package/dist/bin/package/fix.mjs +3 -2
  14. package/dist/bin/package/fix.mjs.map +1 -1
  15. package/dist/bin/package/lint.mjs +3 -2
  16. package/dist/bin/package/lint.mjs.map +1 -1
  17. package/dist/bin/package/relint.mjs +106 -0
  18. package/dist/bin/package/relint.mjs.map +1 -0
  19. package/dist/bin/xy.mjs +100 -94
  20. package/dist/bin/xy.mjs.map +1 -1
  21. package/dist/index.d.ts +29 -23
  22. package/dist/index.mjs +112 -135
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/xy/index.mjs +100 -94
  25. package/dist/xy/index.mjs.map +1 -1
  26. package/dist/xy/xy.mjs +100 -94
  27. package/dist/xy/xy.mjs.map +1 -1
  28. package/dist/xy/xyLintCommands.mjs +97 -111
  29. package/dist/xy/xyLintCommands.mjs.map +1 -1
  30. package/package.json +5 -4
  31. package/src/actions/fix.ts +3 -2
  32. package/src/actions/index.ts +0 -2
  33. package/src/actions/lint.ts +19 -42
  34. package/src/actions/package/lint.ts +2 -2
  35. package/src/actions/relint.ts +73 -18
  36. package/src/bin/package/relint.ts +16 -0
  37. package/src/xy/xyLintCommands.ts +6 -8
  38. package/dist/actions/lint-clean.mjs +0 -222
  39. package/dist/actions/lint-clean.mjs.map +0 -1
  40. package/dist/actions/lint-profile.mjs +0 -118
  41. package/dist/actions/lint-profile.mjs.map +0 -1
  42. package/src/actions/lint-clean.ts +0 -24
  43. package/src/actions/lint-profile.ts +0 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/package/lint.ts"],"sourcesContent":["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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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, verbose = false) => {\n const pkg = process.env.INIT_CWD\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', '.yarn', '.vscode', '.github']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n if (verbose) {\n console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))\n }\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n if (fix) {\n await ESLint.outputFixes(lintResults)\n }\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n"],"mappings":";;;;AAAA,SAASA,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;MAEpC;IACF;EACF;AACF,GAjBqB;AAmBrB,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AQC,IAAIC,MAAMoD,MAAM,WAAWZ,GAAAA,aAAgBW,MAAMtD,MAAM,GAAG,CAAA;EACpE;AACA,QAAML,cAAc,MAAMuD,OAAOM,UAAUF,KAAAA;AAE3C5D,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMU,OAAOM,YAAY9D,WAAAA;EAC3B;AAEA,SAAOA,YAAY+D,OAAO,CAACC,MAAM7D,eAAe6D,OAAO7D,WAAW8D,YAAY,CAAA;AAChF,GAzB2B;","names":["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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","verbose","pkg","process","env","INIT_CWD","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","green","lintFiles","outputFixes","reduce","prev","errorCount"]}
1
+ {"version":3,"sources":["../../../src/actions/package/lint.ts"],"sourcesContent":["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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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, verbose = false, cache = true) => {\n const pkg = process.env.INIT_CWD\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', '.yarn', '.vscode', '.github']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false, cache,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n if (verbose) {\n console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))\n }\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n if (fix) {\n await ESLint.outputFixes(lintResults)\n }\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n"],"mappings":";;;;AAAA,SAASA,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;AACp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AA,EAAgB,QAAO,CAAA;AAElE,WAAOL,OAAOY,YAAW,IACrBvB,SAASY,KAAKV,aAAAA,IACd;MAACU;;EACP,CAAA;AACJ;AAlBSZ;AAoBF,IAAMwB,cAAc,8BAAOC,MAAM,OAAOC,UAAU,OAAOC,QAAQ,SAAI;AAC1E,QAAMC,MAAMC,QAAQC,IAAIC;AACxB,QAAMnC,aAAa,MAAMD,oBAAAA;AACzB,QAAM,EAAEqC,SAASC,aAAY,IAAK,MAAM,OAAOrC,WAAWsC;AAG1D,QAAMhC,gBAAgB;IAAC;IAAgB;IAAQ;IAAY;IAAQ;IAAS;IAAS;IAAW;;AAEhG,QAAMiC,SAAS,IAAIC,OAAO;IACxBC,YAAY;SAAIJ;;IAAeR;IAAKa,aAAa;IAAOX;EAC1D,CAAA;AAEA,QAAMY,QAAQvC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,MAAIwB,SAAS;AACXzC,YAAQC,IAAIC,MAAMqD,MAAM,WAAWZ,GAAAA,aAAgBW,MAAMvD,MAAM,GAAG,CAAA;EACpE;AACA,QAAML,cAAc,MAAMwD,OAAOM,UAAUF,KAAAA;AAE3C7D,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMW,OAAOM,YAAY/D,WAAAA;EAC3B;AAEA,SAAOA,YAAYgE,OAAO,CAACC,MAAM9D,eAAe8D,OAAO9D,WAAW+D,YAAY,CAAA;AAChF,GAzB2B;","names":["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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","verbose","cache","pkg","process","env","INIT_CWD","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","green","lintFiles","outputFixes","reduce","prev","errorCount"]}
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/actions/relint.ts
5
- import { rmSync } from "node:fs";
5
+ import chalk4 from "chalk";
6
6
 
7
7
  // src/lib/checkResult.ts
8
8
  import chalk from "chalk";
@@ -63,28 +63,8 @@ var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
63
63
  }
64
64
  }, "safeExit");
65
65
 
66
- // src/lib/yarn/workspace/yarnWorkspaces.ts
67
- import { spawnSync } from "node:child_process";
68
- var yarnWorkspaces = /* @__PURE__ */ __name(() => {
69
- const result = spawnSync("yarn", [
70
- "workspaces",
71
- "list",
72
- "--json",
73
- "--recursive"
74
- ], {
75
- encoding: "utf8",
76
- shell: true
77
- });
78
- if (result.error) {
79
- throw result.error;
80
- }
81
- return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
82
- return JSON.parse(item);
83
- });
84
- }, "yarnWorkspaces");
85
-
86
66
  // src/lib/runSteps.ts
87
- import { spawnSync as spawnSync2 } from "node:child_process";
67
+ import { spawnSync } from "node:child_process";
88
68
  import { existsSync } from "node:fs";
89
69
  import chalk3 from "chalk";
90
70
  var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
@@ -100,7 +80,7 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
100
80
  if (command === "node" && !existsSync(argList[0])) {
101
81
  throw new Error(`File not found [${argList[0]}]`);
102
82
  }
103
- const status = spawnSync2(command, Array.isArray(args) ? args : args.split(" "), {
83
+ const status = spawnSync(command, Array.isArray(args) ? args : args.split(" "), {
104
84
  ...config,
105
85
  encoding: "utf8",
106
86
  env: {
@@ -118,35 +98,71 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
118
98
  }, "runSteps");
119
99
 
120
100
  // src/actions/relint.ts
121
- var relint = /* @__PURE__ */ __name(() => {
122
- console.log("Relint - Cleaning [.eslintcache]");
123
- const workspaces = yarnWorkspaces();
124
- const result = workspaces.map(({ location, name }) => {
125
- const dist = `${location}/.eslintcache`;
126
- try {
127
- rmSync(dist, {
128
- force: true,
129
- recursive: true
130
- });
131
- return 0;
132
- } catch (ex) {
133
- const error = ex;
134
- console.error(`Relint - Cleaning [.eslintcache] Failed [${name}, ${error.message}]`);
135
- return 1;
136
- }
137
- }).reduce((prev, result2) => prev || result2, 0);
138
- return result || runSteps("Relint", [
101
+ var relintPackage = /* @__PURE__ */ __name(({ pkg, verbose }) => {
102
+ console.log(chalk4.gray(`${"Relint"} [All-Packages]`));
103
+ const start = Date.now();
104
+ const verboseOptions = verbose ? [
105
+ "--verbose"
106
+ ] : [
107
+ "--no-verbose"
108
+ ];
109
+ const result = runSteps("Relint [All-Packages]", [
139
110
  [
140
111
  "yarn",
141
112
  [
142
- "eslint",
143
- ".",
144
- "--cache"
113
+ "workspace",
114
+ pkg,
115
+ ...verboseOptions,
116
+ "run",
117
+ "package-relint"
145
118
  ]
146
119
  ]
147
120
  ]);
121
+ console.log(chalk4.gray(`${"Relinted in"} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`));
122
+ return result;
123
+ }, "relintPackage");
124
+ var relint = /* @__PURE__ */ __name(({ pkg, verbose, incremental } = {}) => {
125
+ return pkg ? relintPackage({
126
+ pkg
127
+ }) : relintAllPackages({
128
+ verbose,
129
+ incremental
130
+ });
148
131
  }, "relint");
132
+ var relintAllPackages = /* @__PURE__ */ __name(({ verbose = true, incremental } = {}) => {
133
+ console.log(chalk4.gray(`${"Relint"} [All-Packages]`));
134
+ const start = Date.now();
135
+ const verboseOptions = verbose ? [
136
+ "--verbose"
137
+ ] : [
138
+ "--no-verbose"
139
+ ];
140
+ const incrementalOptions = incremental ? [
141
+ "--since",
142
+ "-Ap"
143
+ ] : [
144
+ "--parallel",
145
+ "-Ap"
146
+ ];
147
+ const result = runSteps(`${"Relint"} [All-Packages]`, [
148
+ [
149
+ "yarn",
150
+ [
151
+ "workspaces",
152
+ "foreach",
153
+ ...verboseOptions,
154
+ ...incrementalOptions,
155
+ "run",
156
+ "package-relint"
157
+ ]
158
+ ]
159
+ ]);
160
+ console.log(chalk4.gray(`Relinted in [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`));
161
+ return result;
162
+ }, "relintAllPackages");
149
163
  export {
150
- relint
164
+ relint,
165
+ relintAllPackages,
166
+ relintPackage
151
167
  };
152
168
  //# sourceMappingURL=relint.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/actions/relint.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import { rmSync } from 'node:fs'\n\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nexport const relint = () => {\n console.log('Relint - Cleaning [.eslintcache]')\n const workspaces = yarnWorkspaces()\n const result = workspaces\n .map(({ location, name }) => {\n const dist = `${location}/.eslintcache`\n try {\n rmSync(dist, { force: true, recursive: true })\n return 0\n } catch (ex) {\n const error = ex as Error\n console.error(`Relint - Cleaning [.eslintcache] Failed [${name}, ${error.message}]`)\n return 1\n }\n })\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce((prev, result) => prev || result, 0)\n return result || runSteps('Relint', [['yarn', ['eslint', '.', '--cache']]])\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import { spawnSync } from 'node:child_process'\n\nimport type { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep =\n | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";;;;AAAA,SAASA,cAAc;;;ACAvB,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa,UAAK;AAC7G,MAAIF,QAAQ;AACV,UAAMG,UAAUD,aAAa,sBAAsB;AACnD,UAAME,YAAYH,UAAU,UAAUI,MAAMC,MAAMD,MAAME;AACxDC,YAAQP,KAAAA,EAAOG,UAAU,GAAGL,IAAAA,Q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,SAASM,MAAMC,QAAQN,IAAAA,IAAQA,OAAOA,KAAKO,MAAM,GAAA,GAAM;QACjE,GAAGN;QACHW,UAAU;QACVrB,KAAK;UAAEsB,aAAa;UAAK,GAAGvB,QAAQC;QAAI;QACxCuB,OAAO;QACPC,OAAO;MACT,CAAA,EAAGL,UAAU;AACfM,kBAAYhC,MAAM0B,QAAQ,SAASxB,UAAAA;AACnCW,qBAAea,UAAU;IAC3B;AACA,WAAOb;EACT,GAAG,CAAC,CAACX,UAAAA;AACP,GA1BwB;;;APTjB,IAAM+B,SAAS,6BAAA;AACpBC,UAAQC,IAAI,kCAAA;AACZ,QAAMC,aAAaC,eAAAA;AACnB,QAAMC,SAASF,WACZG,IAAI,CAAC,EAAEC,UAAUC,KAAI,MAAE;AACtB,UAAMC,OAAO,GAAGF,QAAAA;AAChB,QAAI;AACFG,aAAOD,MAAM;QAAEE,OAAO;QAAMC,WAAW;MAAK,CAAA;AAC5C,aAAO;IACT,SAASC,IAAI;AACX,YAAMC,QAAQD;AACdZ,cAAQa,MAAM,4CAA4CN,IAAAA,KAASM,MAAMC,OAAO,GAAG;AACnF,aAAO;IACT;EACF,CAAA,EAECC,OAAO,CAACC,MAAMZ,YAAWY,QAAQZ,SAAQ,CAAA;AAC5C,SAAOA,UAAUa,SAAS,UAAU;IAAC;MAAC;MAAQ;QAAC;QAAU;QAAK;;;GAAY;AAC5E,GAlBsB;","names":["rmSync","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","message","undefined","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExit","func","exitOnFail","result","process","exit","ex","processEx","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","spawnSync","existsSync","chalk","runSteps","name","steps","exitOnFail","messages","safeExit","pkgName","process","env","npm_package_name","console","log","chalk","green","totalStatus","i","command","args","config","entries","gray","argList","Array","isArray","split","existsSync","Error","status","spawnSync","encoding","FORCE_COLOR","shell","stdio","checkResult","relint","console","log","workspaces","yarnWorkspaces","result","map","location","name","dist","rmSync","force","recursive","ex","error","message","reduce","prev","runSteps"]}
1
+ {"version":3,"sources":["../../src/actions/relint.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import chalk from 'chalk'\nimport type { ESLint } from 'eslint'\n\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nexport interface RelintParams {\n incremental?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface RelintPackageParams {\n pkg: string\n verbose?: boolean\n}\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(`${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\nexport const relintPackage = ({ pkg, verbose }: RelintParams & Required<Pick<RelintParams, 'pkg'>>) => {\n console.log(chalk.gray(`${'Relint'} [All-Packages]`))\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n\n const result = runSteps('Relint [All-Packages]', [\n ['yarn', ['workspace',\n pkg,\n ...verboseOptions,\n 'run',\n 'package-relint',\n ]],\n ])\n console.log(chalk.gray(`${'Relinted in'} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`))\n return result\n}\n\nexport const relint = ({\n pkg, verbose, incremental,\n}: RelintParams = {}) => {\n return pkg\n ? relintPackage({ pkg })\n : relintAllPackages({ verbose, incremental })\n}\n\nexport const relintAllPackages = ({ verbose = true, incremental }: RelintParams = {}) => {\n console.log(chalk.gray(`${'Relint'} [All-Packages]`))\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const incrementalOptions = incremental ? ['--since', '-Ap'] : ['--parallel', '-Ap']\n\n const result = runSteps(`${'Relint'} [All-Packages]`, [\n ['yarn', ['workspaces',\n 'foreach',\n ...verboseOptions,\n ...incrementalOptions,\n 'run',\n 'package-relint',\n ]],\n ])\n console.log(chalk.gray(`Relinted in [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`))\n return result\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => (!!ex.name && !!ex.message),\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep =\n | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa,UAAK;AAC7G,MAAIF,QAAQ;AACV,UAAMG,UAAUD,aAAa,sBAAsB;AACnD,UAAME,YAAYH,UAAU,UAAUI,MAAMC,MAAMD,MAAME;AACxDC,YAAQP,KAAAA,EAAOG,UAAU,GAAGL,IAAAA,QAAYC,MAAAA,aAAmBG,OAAAA,EAAS,CAAA;AACpE,QAAID,YAAY;AACdO,cAAQC,KAAKV,MAAAA;IACf;EACF;AACF,GAT2B;;;ACF3B,OAAOW,YAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAW,CAAC,CAACA,IAAGG,QAAQ,CAAC,CAACH,IAAGI,YAAQ;AAElD,SAAOF,UAAUF,EAAAA,IAAWC,QAAQD,EAAAA,IAAWK;AACjD,GAPyB;;;ACElB,IAAMC,qBAAqB,wBAChCC,IAAaC,YAAAA;AAEb,SAAOC,UAAaF,IAAIC,SAAS,CAACD,QAAiBA,IAA6BG,UAAUC,MAAAA;AAC5F,GAJkC;;;AFG3B,IAAMC,YAAY,wBAACC,OAAAA;AACxB,QAAMC,QAAQ,OAAOD,OAAO,WAAW,IAAIE,MAAMF,EAAAA,IAAMA;AACvD,QAAMG,WACFC,mBAAmBH,OAAO,CAACA,WAAAA;AAC3B,QAAIA,OAAMI,SAAS,UAAU;AAC3BC,cAAQL,MAAMM,OAAMC,IAAI,IAAIP,OAAMQ,IAAI,cAAc,CAAA;IACtD,OAAO;AACLH,cAAQL,MAAMM,OAAMC,IAAI,UAAUP,OAAMI,IAAI,EAAE,CAAA;IAChD;AACA,WAAOJ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BAAiBR,UAAU;IAAC;MAAe;IAAC;;AAClD,QAAMgB,qBAAqBF,cAAc;IAAC;IAAW;MAAS;IAAC;IAAc;;AAE7E,QAAML,SAASC,SAAS,GAAG,QAAA,oBAA4B;IACrD;MAAC;MAAQ;QAAC;QACR;WACGF;WACAQ;QACH;QACA;;;GAEH;AACDf,UAAQC,IAAIC,OAAMC,KAAK,gBAAgBD,OAAMQ,UAAUL,KAAKC,IAAG,IAAKF,SAAS,KAAMO,QAAQ,CAAA,CAAA,CAAA,KAAQT,OAAMC,KAAK,SAAA,CAAA,EAAY,CAAA;AAC1H,SAAOK;AACT,GAjBiC;","names":["chalk","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","message","undefined","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExit","func","exitOnFail","result","process","exit","ex","processEx","spawnSync","existsSync","chalk","runSteps","name","steps","exitOnFail","messages","safeExit","pkgName","process","env","npm_package_name","console","log","chalk","green","totalStatus","i","command","args","config","entries","gray","argList","Array","isArray","split","existsSync","Error","status","spawnSync","encoding","FORCE_COLOR","shell","stdio","checkResult","relintPackage","pkg","verbose","console","log","chalk","gray","start","Date","now","verboseOptions","result","runSteps","magenta","toFixed","relint","incremental","relintAllPackages","incrementalOptions"]}
@@ -60,7 +60,7 @@ function getFiles(dir, ignoreFolders) {
60
60
  });
61
61
  }
62
62
  __name(getFiles, "getFiles");
63
- var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false) => {
63
+ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, cache = true) => {
64
64
  const pkg = process.env.INIT_CWD;
65
65
  const configPath = await getRootESLintConfig();
66
66
  const { default: eslintConfig } = await import(configPath.href);
@@ -79,7 +79,8 @@ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false) =>
79
79
  ...eslintConfig
80
80
  ],
81
81
  fix,
82
- warnIgnored: false
82
+ warnIgnored: false,
83
+ cache
83
84
  });
84
85
  const files = getFiles(cwd(), ignoreFolders);
85
86
  if (verbose) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/bin/package/fix.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(true)\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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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, verbose = false) => {\n const pkg = process.env.INIT_CWD\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', '.yarn', '.vscode', '.github']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n if (verbose) {\n console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))\n }\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n if (fix) {\n await ESLint.outputFixes(lintResults)\n }\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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;IAAS;IAAW;;AAEhG,QAAMgC,SAAS,IAAIC,OAAO;IACxBC,YAAY;SAAIJ;;IAAeP;IAAKY,aAAa;EACnD,CAAA;AAEA,QAAMC,QAAQtC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,MAAIwB,SAAS;AACXzC,YAAQC,IAAIC,MAAMoD,MAAM,WAAWZ,GAAAA,aAAgBW,MAAMtD,MAAM,GAAG,CAAA;EACpE;AACA,QAAML,cAAc,MAAMuD,OAAOM,UAAUF,KAAAA;AAE3C5D,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMU,OAAOM,YAAY9D,WAAAA;EAC3B;AAEA,SAAOA,YAAY+D,OAAO,CAACC,MAAM7D,eAAe6D,OAAO7D,WAAW8D,YAAY,CAAA;AAChF,GAzB2B;;;ADtD3BC,YAAY,IAAA,EACTC,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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","verbose","pkg","process","env","INIT_CWD","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","green","lintFiles","outputFixes","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
1
+ {"version":3,"sources":["../../../src/bin/package/fix.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(true)\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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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, verbose = false, cache = true) => {\n const pkg = process.env.INIT_CWD\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', '.yarn', '.vscode', '.github']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false, cache,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n if (verbose) {\n console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))\n }\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n if (fix) {\n await ESLint.outputFixes(lintResults)\n }\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;MAEpC;IACF;EACF;AACF,GAjBqB;AAmBrB,eAAeC,sBAAAA;AAEb,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AAQC,IAAIC,MAAMqD,MAAM,WAAWZ,GAAAA,aAAgBW,MAAMvD,MAAM,GAAG,CAAA;EACpE;AACA,QAAML,cAAc,MAAMwD,OAAOM,UAAUF,KAAAA;AAE3C7D,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMW,OAAOM,YAAY/D,WAAAA;EAC3B;AAEA,SAAOA,YAAYgE,OAAO,CAACC,MAAM9D,eAAe8D,OAAO9D,WAAW+D,YAAY,CAAA;AAChF,GAzB2B;;;ADtD3BC,YAAY,IAAA,EACTC,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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","verbose","cache","pkg","process","env","INIT_CWD","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","green","lintFiles","outputFixes","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
@@ -60,7 +60,7 @@ function getFiles(dir, ignoreFolders) {
60
60
  });
61
61
  }
62
62
  __name(getFiles, "getFiles");
63
- var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false) => {
63
+ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, cache = true) => {
64
64
  const pkg = process.env.INIT_CWD;
65
65
  const configPath = await getRootESLintConfig();
66
66
  const { default: eslintConfig } = await import(configPath.href);
@@ -79,7 +79,8 @@ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false) =>
79
79
  ...eslintConfig
80
80
  ],
81
81
  fix,
82
- warnIgnored: false
82
+ warnIgnored: false,
83
+ cache
83
84
  });
84
85
  const files = getFiles(cwd(), ignoreFolders);
85
86
  if (verbose) {
@@ -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'\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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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, verbose = false) => {\n const pkg = process.env.INIT_CWD\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', '.yarn', '.vscode', '.github']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n if (verbose) {\n console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))\n }\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n if (fix) {\n await ESLint.outputFixes(lintResults)\n }\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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,OAAOpC,WAAWqC;AAG1D,QAAM/B,gBAAgB;IAAC;IAAgB;IAAQ;IAAY;IAAQ;IAAS;IAAS;IAAW;;AAEhG,QAAMgC,SAAS,IAAIC,OAAO;IACxBC,YAAY;SAAIJ;;IAAeP;IAAKY,aAAa;EACnD,CAAA;AAEA,QAAMC,QAAQtC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,MAAIwB,SAAS;AACXzC,YAAQC,IAAIC,MAAMoD,MAAM,WAAWZ,GAAAA,aAAgBW,MAAMtD,MAAM,GAAG,CAAA;EACpE;AACA,QAAML,cAAc,MAAMuD,OAAOM,UAAUF,KAAAA;AAE3C5D,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMU,OAAOM,YAAY9D,WAAAA;EAC3B;AAEA,SAAOA,YAAY+D,OAAO,CAACC,MAAM7D,eAAe6D,OAAO7D,WAAW8D,YAAY,CAAA;AAChF,GAzB2B;;;ADtD3BC,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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","verbose","pkg","process","env","INIT_CWD","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","green","lintFiles","outputFixes","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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, verbose = false, cache = true) => {\n const pkg = process.env.INIT_CWD\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', '.yarn', '.vscode', '.github']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false, cache,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n if (verbose) {\n console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))\n }\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n if (fix) {\n await ESLint.outputFixes(lintResults)\n }\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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QAAMY,QAAQvC,SAASI,IAAAA,GAAOF,aAAAA;AAC9B,MAAIwB,SAAS;AACXzC,YAAQC,IAAIC,MAAMqD,MAAM,WAAWZ,GAAAA,aAAgBW,MAAMvD,MAAM,GAAG,CAAA;EACpE;AACA,QAAML,cAAc,MAAMwD,OAAOM,UAAUF,KAAAA;AAE3C7D,eAAaC,WAAAA;AAEb,MAAI8C,KAAK;AACP,UAAMW,OAAOM,YAAY/D,WAAAA;EAC3B;AAEA,SAAOA,YAAYgE,OAAO,CAACC,MAAM9D,eAAe8D,OAAO9D,WAAW+D,YAAY,CAAA;AAChF,GAzB2B;;;ADtD3BC,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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","verbose","cache","pkg","process","env","INIT_CWD","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","green","lintFiles","outputFixes","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+
5
+ // src/bin/package/relint.ts
6
+ import chalk2 from "chalk";
7
+
8
+ // src/actions/package/lint.ts
9
+ import { readdirSync } from "node:fs";
10
+ import path from "node:path";
11
+ import { cwd } from "node:process";
12
+ import { pathToFileURL } from "node:url";
13
+ import chalk from "chalk";
14
+ import { ESLint } from "eslint";
15
+ import { findUp } from "find-up";
16
+ import picomatch from "picomatch";
17
+ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
18
+ const colors = [
19
+ "white",
20
+ "yellow",
21
+ "red"
22
+ ];
23
+ const severity = [
24
+ "none",
25
+ "warning",
26
+ "error"
27
+ ];
28
+ for (const lintResult of lintResults) {
29
+ if (lintResult.messages.length > 0) {
30
+ console.log(chalk.gray(`
31
+ ${lintResult.filePath}`));
32
+ for (const message of lintResult.messages) {
33
+ console.log(chalk.gray(` ${message.line}:${message.column}`), chalk[colors[message.severity]](` ${severity[message.severity]}`), chalk.white(` ${message.message}`), chalk.gray(` ${message.ruleId}`));
34
+ }
35
+ }
36
+ }
37
+ }, "dumpMessages");
38
+ async function getRootESLintConfig() {
39
+ const configPath = await findUp("eslint.config.mjs");
40
+ if (!configPath) {
41
+ throw new Error("eslint.config.mjs not found in the monorepo");
42
+ }
43
+ return pathToFileURL(configPath);
44
+ }
45
+ __name(getRootESLintConfig, "getRootESLintConfig");
46
+ function getFiles(dir, ignoreFolders) {
47
+ const currentDirectory = cwd();
48
+ const subDirectory = dir.split(currentDirectory)[1];
49
+ if (ignoreFolders.includes(subDirectory)) return [];
50
+ return readdirSync(dir, {
51
+ withFileTypes: true
52
+ }).flatMap((dirent) => {
53
+ const res = path.resolve(dir, dirent.name);
54
+ const relativePath = subDirectory ? `${subDirectory}/${dirent.name}` : dirent.name;
55
+ const ignoreMatchers = ignoreFolders.map((pattern) => picomatch(pattern));
56
+ if (ignoreMatchers.some((isMatch) => isMatch(relativePath))) return [];
57
+ return dirent.isDirectory() ? getFiles(res, ignoreFolders) : [
58
+ res
59
+ ];
60
+ });
61
+ }
62
+ __name(getFiles, "getFiles");
63
+ var packageLint = /* @__PURE__ */ __name(async (fix = false, verbose = false, cache = true) => {
64
+ const pkg = process.env.INIT_CWD;
65
+ const configPath = await getRootESLintConfig();
66
+ const { default: eslintConfig } = await import(configPath.href);
67
+ const ignoreFolders = [
68
+ "node_modules",
69
+ "dist",
70
+ "packages",
71
+ ".git",
72
+ "build",
73
+ ".yarn",
74
+ ".vscode",
75
+ ".github"
76
+ ];
77
+ const engine = new ESLint({
78
+ baseConfig: [
79
+ ...eslintConfig
80
+ ],
81
+ fix,
82
+ warnIgnored: false,
83
+ cache
84
+ });
85
+ const files = getFiles(cwd(), ignoreFolders);
86
+ if (verbose) {
87
+ console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`));
88
+ }
89
+ const lintResults = await engine.lintFiles(files);
90
+ dumpMessages(lintResults);
91
+ if (fix) {
92
+ await ESLint.outputFixes(lintResults);
93
+ }
94
+ return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
95
+ }, "packageLint");
96
+
97
+ // src/bin/package/relint.ts
98
+ packageLint(false, false, true).then((value) => {
99
+ if (value) {
100
+ process.exit(value);
101
+ }
102
+ }).catch((reason) => {
103
+ console.error(chalk2.red(reason));
104
+ process.exit(-1);
105
+ });
106
+ //# sourceMappingURL=relint.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/bin/package/relint.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(false, false, true)\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 const subDirectory = dir.split(currentDirectory)[1]\n if (ignoreFolders.includes(subDirectory)) return []\n return readdirSync(dir, { withFileTypes: true })\n .flatMap((dirent) => {\n const res = path.resolve(dir, dirent.name)\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, verbose = false, cache = true) => {\n const pkg = process.env.INIT_CWD\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', '.yarn', '.vscode', '.github']\n\n const engine = new ESLint({\n baseConfig: [...eslintConfig], fix, warnIgnored: false, cache,\n })\n\n const files = getFiles(cwd(), ignoreFolders)\n if (verbose) {\n console.log(chalk.green(`Linting ${pkg} [files = ${files.length}]`))\n }\n const lintResults = await engine.lintFiles(files)\n\n dumpMessages(lintResults)\n\n if (fix) {\n await ESLint.outputFixes(lintResults)\n }\n\n return lintResults.reduce((prev, lintResult) => prev + l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,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","subDirectory","split","includes","readdirSync","withFileTypes","flatMap","dirent","res","path","resolve","name","relativePath","ignoreMatchers","map","pattern","picomatch","some","isMatch","isDirectory","packageLint","fix","verbose","cache","pkg","process","env","INIT_CWD","default","eslintConfig","href","engine","ESLint","baseConfig","warnIgnored","files","green","lintFiles","outputFixes","reduce","prev","errorCount","packageLint","then","value","process","exit","catch","reason","console","error","chalk","red"]}