@xylabs/ts-scripts-yarn3 5.1.2 → 5.1.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.
@@ -1,112 +1,88 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/lib/checkResult.ts
4
+ // src/actions/lint.ts
5
5
  import chalk from "chalk";
6
- var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnFail = false) => {
7
- if (result) {
8
- const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
9
- const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
10
- console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
11
- if (exitOnFail) {
12
- process.exit(result);
13
- }
14
- }
15
- }, "checkResult");
16
-
17
- // src/lib/processEx.ts
18
- import chalk2 from "chalk";
19
-
20
- // src/lib/withError.ts
21
- var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
22
- return predicate(ex) ? closure(ex) : void 0;
23
- }, "withError");
24
-
25
- // src/lib/withErrnoException.ts
26
- var withErrnoException = /* @__PURE__ */ __name((ex, closure) => {
27
- return withError(ex, closure, (ex2) => ex2.errno !== void 0);
28
- }, "withErrnoException");
29
-
30
- // src/lib/processEx.ts
31
- var processEx = /* @__PURE__ */ __name((ex) => {
32
- const error = typeof ex === "string" ? new Error(ex) : ex;
33
- const exitCode = withErrnoException(error, (error2) => {
34
- if (error2.code === "ENOENT") {
35
- console.error(chalk2.red(`'${error2.path}' not found.`));
36
- } else {
37
- console.error(chalk2.red(`Errno: ${error2.code}`));
38
- }
39
- return error2.errno ?? -1;
40
- }) ?? withError(error, (error2) => {
41
- console.error(chalk2.red(`${error2.name}: ${error2.message}`));
42
- return -1;
43
- }) ?? (() => {
44
- console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
45
- return -1;
46
- })();
47
- process.exit(process.exitCode ?? exitCode);
48
- }, "processEx");
6
+ import { ESLint } from "eslint";
49
7
 
50
- // src/lib/safeExit.ts
51
- var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
52
- try {
53
- const result = func();
54
- if (result && exitOnFail) {
55
- process.exit(result);
56
- }
57
- return result;
58
- } catch (ex) {
59
- return processEx(ex);
8
+ // src/lib/yarn/workspace/yarnWorkspaces.ts
9
+ import { spawnSync } from "node:child_process";
10
+ var yarnWorkspaces = /* @__PURE__ */ __name(() => {
11
+ const result = spawnSync("yarn", [
12
+ "workspaces",
13
+ "list",
14
+ "--json",
15
+ "--recursive"
16
+ ], {
17
+ encoding: "utf8",
18
+ shell: true
19
+ });
20
+ if (result.error) {
21
+ throw result.error;
60
22
  }
61
- }, "safeExit");
23
+ return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
24
+ return JSON.parse(item);
25
+ });
26
+ }, "yarnWorkspaces");
62
27
 
63
- // src/lib/runSteps.ts
64
- import { spawnSync } from "node:child_process";
65
- import { existsSync } from "node:fs";
66
- import chalk3 from "chalk";
67
- var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
68
- return safeExit(() => {
69
- const pkgName = process.env.npm_package_name;
70
- console.log(chalk3.green(`${name} [${pkgName}]`));
71
- let totalStatus = 0;
72
- for (const [i, [command, args, config]] of steps.entries()) {
73
- if (messages?.[i]) {
74
- console.log(chalk3.gray(messages?.[i]));
28
+ // src/actions/lint.ts
29
+ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
30
+ const colors = [
31
+ "white",
32
+ "yellow",
33
+ "red"
34
+ ];
35
+ const severity = [
36
+ "none",
37
+ "warning",
38
+ "error"
39
+ ];
40
+ for (const lintResult of lintResults) {
41
+ if (lintResult.messages.length > 0) {
42
+ console.log(chalk.gray(`${lintResult.filePath}`));
43
+ for (const message of lintResult.messages) {
44
+ console.log(chalk.gray(` ${message.line}:${message.column}`), chalk[colors[message.severity]](` ${severity[message.severity]}`), chalk.white(` ${message.message}`), chalk.gray(` ${message.ruleId}`));
75
45
  }
76
- const argList = Array.isArray(args) ? args : args.split(" ");
77
- if (command === "node" && !existsSync(argList[0])) {
78
- throw new Error(`File not found [${argList[0]}]`);
79
- }
80
- const status = spawnSync(command, Array.isArray(args) ? args : args.split(" "), {
81
- ...config,
82
- encoding: "utf8",
83
- env: {
84
- FORCE_COLOR: "3",
85
- ...process.env
86
- },
87
- shell: true,
88
- stdio: "inherit"
89
- }).status ?? 0;
90
- checkResult(name, status, "error", exitOnFail);
91
- totalStatus += status ?? 0;
92
46
  }
93
- return totalStatus;
94
- }, !!exitOnFail);
95
- }, "runSteps");
47
+ }
48
+ }, "dumpMessages");
49
+ var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
50
+ const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
51
+ if (!workspace) {
52
+ console.error(chalk.red(`Unable to locate package [${chalk.magenta(pkg)}]`));
53
+ process.exit(1);
54
+ }
55
+ const engine = new ESLint({
56
+ cache: true,
57
+ fix: fix2
58
+ });
59
+ const lintResults = await engine.lintFiles(workspace.location);
60
+ dumpMessages(lintResults);
61
+ return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
62
+ }, "lintPackage");
63
+ var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
64
+ const workspace = yarnWorkspaces();
65
+ return (await Promise.all(workspace.map((ws) => lintPackage({
66
+ pkg: ws.name,
67
+ fix: fix2
68
+ })))).reduce((prev, curr) => prev + curr, 0);
69
+ }, "lintAll");
70
+ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
71
+ return pkg ? await lintPackage({
72
+ pkg,
73
+ fix: fix2
74
+ }) : lintAll({
75
+ verbose,
76
+ incremental,
77
+ fix: fix2
78
+ });
79
+ }, "lint");
96
80
 
97
81
  // src/actions/fix.ts
98
- var fix = /* @__PURE__ */ __name(() => {
99
- return runSteps("Fix", [
100
- [
101
- "yarn",
102
- [
103
- "eslint",
104
- ".",
105
- "--fix",
106
- "--cache"
107
- ]
108
- ]
109
- ]);
82
+ var fix = /* @__PURE__ */ __name(async () => {
83
+ return await lint({
84
+ fix: true
85
+ });
110
86
  }, "fix");
111
87
  export {
112
88
  fix
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts","../../src/actions/fix.ts"],"sourcesContent":["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, SpawnSyncOptionsWithBufferEncoding } 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","import { runSteps } from '../lib/index.ts'\n\nexport const fix = () => {\n return runSteps('Fix', [['yarn', ['eslint', '.', '--fix', '--cache']]])\n}\n"],"mappings":";;;;AAAA,OAAOA,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,OAAMS,SAAS;EACxB,CAAA,KACGC,UAAUV,OAAO,CAACA,WAAAA;AACnBK,YAAQL,MAAMM,O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AAQA,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;;;ACVjB,IAAM+B,MAAM,6BAAA;AACjB,SAAOC,SAAS,OAAO;IAAC;MAAC;MAAQ;QAAC;QAAU;QAAK;QAAS;;;GAAY;AACxE,GAFmB;","names":["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","fix","runSteps"]}
1
+ {"version":3,"sources":["../../src/actions/lint.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/actions/fix.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { ESLint } from 'eslint'\n\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nexport interface LintParams {\n fix?: boolean\n incremental?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface LintPackageParams {\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 lintPackage = async ({ pkg, fix }: LintParams) => {\n const workspace = yarnWorkspaces().find(workspace => workspace.name === pkg)\n if (!workspace) {\n console.error(chalk.red(`Unable to locate package [${chalk.magenta(pkg)}]`))\n process.exit(1)\n }\n\n const engine = new ESLint({ cache: true, fix })\n\n const lintResults = await engine.lintFiles(workspace.location)\n\n dumpMessages(lintResults)\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n\nexport const lintAll = async ({ fix }: LintParams) => {\n const workspace = yarnWorkspaces()\n return (await Promise.all(workspace.map(ws =>\n lintPackage({ pkg: ws.name, fix })))).reduce((prev, curr) => prev + curr, 0)\n}\n\nexport const lint = async ({\n pkg, verbose, incremental, fix,\n}: LintParams = {}) => {\n return pkg\n ? await lintPackage({ pkg, fix })\n : lintAll({\n verbose, incremental, fix,\n })\n}\n\nexport const lintAllPackages = ({\n fix, verbose = true, incremental,\n}: LintParams = {}) => {\n console.log(chalk.gray('Linting [All-Packages]'))\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const fixOptions = fix ? ['--fix'] : ['']\n const incrementalOptions = incremental ? ['--since', '-Apt'] : ['--parallel', '-Apt']\n\n const result = runSteps('Lint [All-Packages]', [\n ['yarn', ['workspaces',\n 'foreach',\n ...verboseOptions,\n ...incrementalOptions,\n 'run',\n 'package-lint',\n ...fixOptions,\n ]],\n ])\n console.log(`${chalk.gray('Linted in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import { spawnSync } from 'node:child_process'\n\nimport { 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 { lint } from './lint.ts'\n\nexport const fix = async () => {\n return await lint({ fix: true })\n}\n"],"mappings":";;;;AAAA,OAAOA,WAAW;AAClB,SAASC,cAAc;;;ACDvB,SAASC,iBAAiB;AAInB,IAAMC,iBAAiB,6BAAA;AAC5B,QAAMC,SAASC,UAAU,QAAQ;IAAC;IAAc;IAAQ;IAAU;KAAgB;IAAEC,UAAU;IAAQC,OAAO;EAAK,CAAA;AAClH,MAAIH,OAAOI,OAAO;AAChB,UAAMJ,OAAOI;EACf;AACA,SACEJ,OAAOK,OACJC,SAAQ,EAGRC,MAAM,IAAA,EACNC,MAAM,GAAG,EAAC,EACVC,IAAI,CAACC,SAAAA;AACJ,WAAOC,KAAKC,MAAMF,IAAAA;EACpB,CAAA;AAEN,GAhB8B;;;ADa9B,IAAMG,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,GAAGN,WAAWO,QAAQ,EAAE,CAAA;AAC/C,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,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chalk","ESLint","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","dumpMessages","lintResults","colors","severity","lintResult","messages","length","console","log","chalk","gray","filePath","message","line","column","white","ruleId","lintPackage","pkg","fix","workspace","yarnWorkspaces","find","name","error","red","magenta","process","exit","engine","ESLint","cache","lintFiles","location","reduce","prev","errorCount","lintAll","Promise","all","map","ws","curr","lint","verbose","incremental","fix","lint"]}
@@ -913,19 +913,103 @@ var dupdeps = /* @__PURE__ */ __name(() => {
913
913
  return detectDuplicateDependencies(dependencies);
914
914
  }, "dupdeps");
915
915
 
916
- // src/actions/fix.ts
917
- var fix = /* @__PURE__ */ __name(() => {
918
- return runSteps("Fix", [
916
+ // src/actions/lint.ts
917
+ import chalk14 from "chalk";
918
+ import { ESLint as ESLint2 } from "eslint";
919
+ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
920
+ const colors = [
921
+ "white",
922
+ "yellow",
923
+ "red"
924
+ ];
925
+ const severity = [
926
+ "none",
927
+ "warning",
928
+ "error"
929
+ ];
930
+ for (const lintResult of lintResults) {
931
+ if (lintResult.messages.length > 0) {
932
+ console.log(chalk14.gray(`${lintResult.filePath}`));
933
+ for (const message of lintResult.messages) {
934
+ console.log(chalk14.gray(` ${message.line}:${message.column}`), chalk14[colors[message.severity]](` ${severity[message.severity]}`), chalk14.white(` ${message.message}`), chalk14.gray(` ${message.ruleId}`));
935
+ }
936
+ }
937
+ }
938
+ }, "dumpMessages");
939
+ var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
940
+ const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
941
+ if (!workspace) {
942
+ console.error(chalk14.red(`Unable to locate package [${chalk14.magenta(pkg)}]`));
943
+ process.exit(1);
944
+ }
945
+ const engine = new ESLint2({
946
+ cache: true,
947
+ fix: fix2
948
+ });
949
+ const lintResults = await engine.lintFiles(workspace.location);
950
+ dumpMessages(lintResults);
951
+ return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
952
+ }, "lintPackage");
953
+ var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
954
+ const workspace = yarnWorkspaces();
955
+ return (await Promise.all(workspace.map((ws) => lintPackage({
956
+ pkg: ws.name,
957
+ fix: fix2
958
+ })))).reduce((prev, curr) => prev + curr, 0);
959
+ }, "lintAll");
960
+ var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
961
+ return pkg ? await lintPackage({
962
+ pkg,
963
+ fix: fix2
964
+ }) : lintAll({
965
+ verbose,
966
+ incremental,
967
+ fix: fix2
968
+ });
969
+ }, "lint");
970
+ var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
971
+ console.log(chalk14.gray("Linting [All-Packages]"));
972
+ const start = Date.now();
973
+ const verboseOptions = verbose ? [
974
+ "--verbose"
975
+ ] : [
976
+ "--no-verbose"
977
+ ];
978
+ const fixOptions = fix2 ? [
979
+ "--fix"
980
+ ] : [
981
+ ""
982
+ ];
983
+ const incrementalOptions = incremental ? [
984
+ "--since",
985
+ "-Apt"
986
+ ] : [
987
+ "--parallel",
988
+ "-Apt"
989
+ ];
990
+ const result = runSteps("Lint [All-Packages]", [
919
991
  [
920
992
  "yarn",
921
993
  [
922
- "eslint",
923
- ".",
924
- "--fix",
925
- "--cache"
994
+ "workspaces",
995
+ "foreach",
996
+ ...verboseOptions,
997
+ ...incrementalOptions,
998
+ "run",
999
+ "package-lint",
1000
+ ...fixOptions
926
1001
  ]
927
1002
  ]
928
1003
  ]);
1004
+ console.log(`${chalk14.gray("Linted in")} [${chalk14.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk14.gray("seconds")}`);
1005
+ return result;
1006
+ }, "lintAllPackages");
1007
+
1008
+ // src/actions/fix.ts
1009
+ var fix = /* @__PURE__ */ __name(async () => {
1010
+ return await lint({
1011
+ fix: true
1012
+ });
929
1013
  }, "fix");
930
1014
 
931
1015
  // src/actions/gen-docs.ts
@@ -981,7 +1065,7 @@ var filename = ".gitignore";
981
1065
  var gitignoreGen = /* @__PURE__ */ __name((pkg) => generateIgnoreFiles(filename, pkg), "gitignoreGen");
982
1066
 
983
1067
  // src/actions/gitlint.ts
984
- import chalk14 from "chalk";
1068
+ import chalk15 from "chalk";
985
1069
  import ParseGitConfig from "parse-git-config";
986
1070
  var gitlint = /* @__PURE__ */ __name(() => {
987
1071
  console.log(`
@@ -992,7 +1076,7 @@ Gitlint Start [${process.cwd()}]
992
1076
  const errors = 0;
993
1077
  const gitConfig = ParseGitConfig.sync();
994
1078
  const warn = /* @__PURE__ */ __name((message) => {
995
- console.warn(chalk14.yellow(`Warning: ${message}`));
1079
+ console.warn(chalk15.yellow(`Warning: ${message}`));
996
1080
  warnings++;
997
1081
  }, "warn");
998
1082
  if (gitConfig.core.ignorecase) {
@@ -1012,13 +1096,13 @@ Gitlint Start [${process.cwd()}]
1012
1096
  }
1013
1097
  const resultMessages = [];
1014
1098
  if (valid > 0) {
1015
- resultMessages.push(chalk14.green(`Passed: ${valid}`));
1099
+ resultMessages.push(chalk15.green(`Passed: ${valid}`));
1016
1100
  }
1017
1101
  if (warnings > 0) {
1018
- resultMessages.push(chalk14.yellow(`Warnings: ${warnings}`));
1102
+ resultMessages.push(chalk15.yellow(`Warnings: ${warnings}`));
1019
1103
  }
1020
1104
  if (errors > 0) {
1021
- resultMessages.push(chalk14.red(` Errors: ${errors}`));
1105
+ resultMessages.push(chalk15.red(` Errors: ${errors}`));
1022
1106
  }
1023
1107
  console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
1024
1108
  `);
@@ -1027,7 +1111,7 @@ Gitlint Start [${process.cwd()}]
1027
1111
 
1028
1112
  // src/actions/gitlint-fix.ts
1029
1113
  import { execSync as execSync2 } from "node:child_process";
1030
- import chalk15 from "chalk";
1114
+ import chalk16 from "chalk";
1031
1115
  import ParseGitConfig2 from "parse-git-config";
1032
1116
  var gitlintFix = /* @__PURE__ */ __name(() => {
1033
1117
  console.log(`
@@ -1038,25 +1122,25 @@ Gitlint Fix Start [${process.cwd()}]
1038
1122
  execSync2("git config core.ignorecase false", {
1039
1123
  stdio: "inherit"
1040
1124
  });
1041
- console.warn(chalk15.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
1125
+ console.warn(chalk16.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
1042
1126
  }
1043
1127
  if (gitConfig.core.autocrlf !== false) {
1044
1128
  execSync2("git config core.autocrlf false", {
1045
1129
  stdio: "inherit"
1046
1130
  });
1047
- console.warn(chalk15.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
1131
+ console.warn(chalk16.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
1048
1132
  }
1049
1133
  if (gitConfig.core.eol !== "lf") {
1050
1134
  execSync2("git config core.eol lf", {
1051
1135
  stdio: "inherit"
1052
1136
  });
1053
- console.warn(chalk15.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
1137
+ console.warn(chalk16.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
1054
1138
  }
1055
1139
  return 1;
1056
1140
  }, "gitlintFix");
1057
1141
 
1058
1142
  // src/actions/license.ts
1059
- import chalk16 from "chalk";
1143
+ import chalk17 from "chalk";
1060
1144
  import { init } from "license-checker";
1061
1145
  var license = /* @__PURE__ */ __name(async (pkg) => {
1062
1146
  const workspaces = yarnWorkspaces();
@@ -1081,7 +1165,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1081
1165
  "LGPL-3.0-or-later",
1082
1166
  "Python-2.0"
1083
1167
  ]);
1084
- console.log(chalk16.green("License Checker"));
1168
+ console.log(chalk17.green("License Checker"));
1085
1169
  return (await Promise.all(workspaceList.map(({ location, name }) => {
1086
1170
  return new Promise((resolve) => {
1087
1171
  init({
@@ -1089,12 +1173,12 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1089
1173
  start: location
1090
1174
  }, (error, packages) => {
1091
1175
  if (error) {
1092
- console.error(chalk16.red(`License Checker [${name}] Error`));
1093
- console.error(chalk16.gray(error));
1176
+ console.error(chalk17.red(`License Checker [${name}] Error`));
1177
+ console.error(chalk17.gray(error));
1094
1178
  console.log("\n");
1095
1179
  resolve(1);
1096
1180
  } else {
1097
- console.log(chalk16.green(`License Checker [${name}]`));
1181
+ console.log(chalk17.green(`License Checker [${name}]`));
1098
1182
  let count = 0;
1099
1183
  for (const [name2, info] of Object.entries(packages)) {
1100
1184
  const licenses = Array.isArray(info.licenses) ? info.licenses : [
@@ -1112,7 +1196,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1112
1196
  }
1113
1197
  if (!orLicenseFound) {
1114
1198
  count++;
1115
- console.warn(chalk16.yellow(`${name2}: Package License not allowed [${license2}]`));
1199
+ console.warn(chalk17.yellow(`${name2}: Package License not allowed [${license2}]`));
1116
1200
  }
1117
1201
  }
1118
1202
  }
@@ -1125,100 +1209,6 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
1125
1209
  }))).reduce((prev, value) => prev || value, 0);
1126
1210
  }, "license");
1127
1211
 
1128
- // src/actions/lint.ts
1129
- import chalk17 from "chalk";
1130
- import { ESLint as ESLint2 } from "eslint";
1131
- var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
1132
- const colors = [
1133
- "white",
1134
- "yellow",
1135
- "red"
1136
- ];
1137
- const severity = [
1138
- "none",
1139
- "warning",
1140
- "error"
1141
- ];
1142
- for (const lintResult of lintResults) {
1143
- if (lintResult.messages.length > 0) {
1144
- console.log(chalk17.gray(`${lintResult.filePath}`));
1145
- for (const message of lintResult.messages) {
1146
- console.log(chalk17.gray(` ${message.line}:${message.column}`), chalk17[colors[message.severity]](` ${severity[message.severity]}`), chalk17.white(` ${message.message}`), chalk17.gray(` ${message.ruleId}`));
1147
- }
1148
- }
1149
- }
1150
- }, "dumpMessages");
1151
- var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
1152
- const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
1153
- if (!workspace) {
1154
- console.error(chalk17.red(`Unable to locate package [${chalk17.magenta(pkg)}]`));
1155
- process.exit(1);
1156
- }
1157
- const engine = new ESLint2({
1158
- cache: true,
1159
- fix: fix2
1160
- });
1161
- const lintResults = await engine.lintFiles(workspace.location);
1162
- dumpMessages(lintResults);
1163
- return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
1164
- }, "lintPackage");
1165
- var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
1166
- const workspace = yarnWorkspaces();
1167
- for (const ws of workspace) {
1168
- await lintPackage({
1169
- pkg: ws.name,
1170
- fix: fix2
1171
- });
1172
- }
1173
- }, "lintAll");
1174
- var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
1175
- return pkg ? await lintPackage({
1176
- pkg,
1177
- fix: fix2
1178
- }) : lintAllPackages({
1179
- verbose,
1180
- incremental,
1181
- fix: fix2
1182
- });
1183
- }, "lint");
1184
- var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
1185
- console.log(chalk17.gray("Linting [All-Packages]"));
1186
- const start = Date.now();
1187
- const verboseOptions = verbose ? [
1188
- "--verbose"
1189
- ] : [
1190
- "--no-verbose"
1191
- ];
1192
- const fixOptions = fix2 ? [
1193
- "--fix"
1194
- ] : [
1195
- ""
1196
- ];
1197
- const incrementalOptions = incremental ? [
1198
- "--since",
1199
- "-Apt"
1200
- ] : [
1201
- "--parallel",
1202
- "-Apt"
1203
- ];
1204
- const result = runSteps("Lint [All-Packages]", [
1205
- [
1206
- "yarn",
1207
- [
1208
- "workspaces",
1209
- "foreach",
1210
- ...verboseOptions,
1211
- ...incrementalOptions,
1212
- "run",
1213
- "package-lint",
1214
- ...fixOptions
1215
- ]
1216
- ]
1217
- ]);
1218
- console.log(`${chalk17.gray("Linted in")} [${chalk17.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk17.gray("seconds")}`);
1219
- return result;
1220
- }, "lintAllPackages");
1221
-
1222
1212
  // src/actions/lint-clean.ts
1223
1213
  import { rmSync } from "node:fs";
1224
1214
  var lintClean = /* @__PURE__ */ __name(async () => {