@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.
- package/dist/actions/fix.mjs +74 -98
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/index.mjs +106 -116
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/lint-clean.mjs +12 -135
- package/dist/actions/lint-clean.mjs.map +1 -1
- package/dist/actions/lint.mjs +5 -7
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/bin/xy-ts.mjs +77 -115
- package/dist/bin/xy-ts.mjs.map +1 -1
- package/dist/bin/xy.mjs +77 -115
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +109 -119
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +77 -115
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +77 -115
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +18 -56
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +4 -4
- package/src/actions/fix.ts +3 -3
- package/src/actions/lint.ts +3 -4
- package/src/xy/xyLintCommands.ts +3 -3
|
@@ -4,65 +4,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
4
4
|
// src/actions/lint-clean.ts
|
|
5
5
|
import { rmSync } from "node:fs";
|
|
6
6
|
|
|
7
|
-
// src/lib/checkResult.ts
|
|
8
|
-
import chalk from "chalk";
|
|
9
|
-
var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnFail = false) => {
|
|
10
|
-
if (result) {
|
|
11
|
-
const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
|
|
12
|
-
const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
|
|
13
|
-
console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
|
|
14
|
-
if (exitOnFail) {
|
|
15
|
-
process.exit(result);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}, "checkResult");
|
|
19
|
-
|
|
20
|
-
// src/lib/processEx.ts
|
|
21
|
-
import chalk2 from "chalk";
|
|
22
|
-
|
|
23
|
-
// src/lib/withError.ts
|
|
24
|
-
var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
|
|
25
|
-
return predicate(ex) ? closure(ex) : void 0;
|
|
26
|
-
}, "withError");
|
|
27
|
-
|
|
28
|
-
// src/lib/withErrnoException.ts
|
|
29
|
-
var withErrnoException = /* @__PURE__ */ __name((ex, closure) => {
|
|
30
|
-
return withError(ex, closure, (ex2) => ex2.errno !== void 0);
|
|
31
|
-
}, "withErrnoException");
|
|
32
|
-
|
|
33
|
-
// src/lib/processEx.ts
|
|
34
|
-
var processEx = /* @__PURE__ */ __name((ex) => {
|
|
35
|
-
const error = typeof ex === "string" ? new Error(ex) : ex;
|
|
36
|
-
const exitCode = withErrnoException(error, (error2) => {
|
|
37
|
-
if (error2.code === "ENOENT") {
|
|
38
|
-
console.error(chalk2.red(`'${error2.path}' not found.`));
|
|
39
|
-
} else {
|
|
40
|
-
console.error(chalk2.red(`Errno: ${error2.code}`));
|
|
41
|
-
}
|
|
42
|
-
return error2.errno ?? -1;
|
|
43
|
-
}) ?? withError(error, (error2) => {
|
|
44
|
-
console.error(chalk2.red(`${error2.name}: ${error2.message}`));
|
|
45
|
-
return -1;
|
|
46
|
-
}) ?? (() => {
|
|
47
|
-
console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
|
|
48
|
-
return -1;
|
|
49
|
-
})();
|
|
50
|
-
process.exit(process.exitCode ?? exitCode);
|
|
51
|
-
}, "processEx");
|
|
52
|
-
|
|
53
|
-
// src/lib/safeExit.ts
|
|
54
|
-
var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
|
|
55
|
-
try {
|
|
56
|
-
const result = func();
|
|
57
|
-
if (result && exitOnFail) {
|
|
58
|
-
process.exit(result);
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
} catch (ex) {
|
|
62
|
-
return processEx(ex);
|
|
63
|
-
}
|
|
64
|
-
}, "safeExit");
|
|
65
|
-
|
|
66
7
|
// src/lib/yarn/workspace/yarnWorkspaces.ts
|
|
67
8
|
import { spawnSync } from "node:child_process";
|
|
68
9
|
var yarnWorkspaces = /* @__PURE__ */ __name(() => {
|
|
@@ -83,42 +24,8 @@ var yarnWorkspaces = /* @__PURE__ */ __name(() => {
|
|
|
83
24
|
});
|
|
84
25
|
}, "yarnWorkspaces");
|
|
85
26
|
|
|
86
|
-
// src/lib/runSteps.ts
|
|
87
|
-
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
88
|
-
import { existsSync } from "node:fs";
|
|
89
|
-
import chalk3 from "chalk";
|
|
90
|
-
var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
|
|
91
|
-
return safeExit(() => {
|
|
92
|
-
const pkgName = process.env.npm_package_name;
|
|
93
|
-
console.log(chalk3.green(`${name} [${pkgName}]`));
|
|
94
|
-
let totalStatus = 0;
|
|
95
|
-
for (const [i, [command, args, config]] of steps.entries()) {
|
|
96
|
-
if (messages?.[i]) {
|
|
97
|
-
console.log(chalk3.gray(messages?.[i]));
|
|
98
|
-
}
|
|
99
|
-
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
100
|
-
if (command === "node" && !existsSync(argList[0])) {
|
|
101
|
-
throw new Error(`File not found [${argList[0]}]`);
|
|
102
|
-
}
|
|
103
|
-
const status = spawnSync2(command, Array.isArray(args) ? args : args.split(" "), {
|
|
104
|
-
...config,
|
|
105
|
-
encoding: "utf8",
|
|
106
|
-
env: {
|
|
107
|
-
FORCE_COLOR: "3",
|
|
108
|
-
...process.env
|
|
109
|
-
},
|
|
110
|
-
shell: true,
|
|
111
|
-
stdio: "inherit"
|
|
112
|
-
}).status ?? 0;
|
|
113
|
-
checkResult(name, status, "error", exitOnFail);
|
|
114
|
-
totalStatus += status ?? 0;
|
|
115
|
-
}
|
|
116
|
-
return totalStatus;
|
|
117
|
-
}, !!exitOnFail);
|
|
118
|
-
}, "runSteps");
|
|
119
|
-
|
|
120
27
|
// src/actions/lint.ts
|
|
121
|
-
import
|
|
28
|
+
import chalk from "chalk";
|
|
122
29
|
import { ESLint } from "eslint";
|
|
123
30
|
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
124
31
|
const colors = [
|
|
@@ -133,9 +40,9 @@ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
|
133
40
|
];
|
|
134
41
|
for (const lintResult of lintResults) {
|
|
135
42
|
if (lintResult.messages.length > 0) {
|
|
136
|
-
console.log(
|
|
43
|
+
console.log(chalk.gray(`${lintResult.filePath}`));
|
|
137
44
|
for (const message of lintResult.messages) {
|
|
138
|
-
console.log(
|
|
45
|
+
console.log(chalk.gray(` ${message.line}:${message.column}`), chalk[colors[message.severity]](` ${severity[message.severity]}`), chalk.white(` ${message.message}`), chalk.gray(` ${message.ruleId}`));
|
|
139
46
|
}
|
|
140
47
|
}
|
|
141
48
|
}
|
|
@@ -143,7 +50,7 @@ var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
|
143
50
|
var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix }) => {
|
|
144
51
|
const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
|
|
145
52
|
if (!workspace) {
|
|
146
|
-
console.error(
|
|
53
|
+
console.error(chalk.red(`Unable to locate package [${chalk.magenta(pkg)}]`));
|
|
147
54
|
process.exit(1);
|
|
148
55
|
}
|
|
149
56
|
const engine = new ESLint({
|
|
@@ -154,53 +61,23 @@ var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix }) => {
|
|
|
154
61
|
dumpMessages(lintResults);
|
|
155
62
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
156
63
|
}, "lintPackage");
|
|
64
|
+
var lintAll = /* @__PURE__ */ __name(async ({ fix }) => {
|
|
65
|
+
const workspace = yarnWorkspaces();
|
|
66
|
+
return (await Promise.all(workspace.map((ws) => lintPackage({
|
|
67
|
+
pkg: ws.name,
|
|
68
|
+
fix
|
|
69
|
+
})))).reduce((prev, curr) => prev + curr, 0);
|
|
70
|
+
}, "lintAll");
|
|
157
71
|
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix } = {}) => {
|
|
158
72
|
return pkg ? await lintPackage({
|
|
159
73
|
pkg,
|
|
160
74
|
fix
|
|
161
|
-
}) :
|
|
75
|
+
}) : lintAll({
|
|
162
76
|
verbose,
|
|
163
77
|
incremental,
|
|
164
78
|
fix
|
|
165
79
|
});
|
|
166
80
|
}, "lint");
|
|
167
|
-
var lintAllPackages = /* @__PURE__ */ __name(({ fix, verbose = true, incremental } = {}) => {
|
|
168
|
-
console.log(chalk4.gray("Linting [All-Packages]"));
|
|
169
|
-
const start = Date.now();
|
|
170
|
-
const verboseOptions = verbose ? [
|
|
171
|
-
"--verbose"
|
|
172
|
-
] : [
|
|
173
|
-
"--no-verbose"
|
|
174
|
-
];
|
|
175
|
-
const fixOptions = fix ? [
|
|
176
|
-
"--fix"
|
|
177
|
-
] : [
|
|
178
|
-
""
|
|
179
|
-
];
|
|
180
|
-
const incrementalOptions = incremental ? [
|
|
181
|
-
"--since",
|
|
182
|
-
"-Apt"
|
|
183
|
-
] : [
|
|
184
|
-
"--parallel",
|
|
185
|
-
"-Apt"
|
|
186
|
-
];
|
|
187
|
-
const result = runSteps("Lint [All-Packages]", [
|
|
188
|
-
[
|
|
189
|
-
"yarn",
|
|
190
|
-
[
|
|
191
|
-
"workspaces",
|
|
192
|
-
"foreach",
|
|
193
|
-
...verboseOptions,
|
|
194
|
-
...incrementalOptions,
|
|
195
|
-
"run",
|
|
196
|
-
"package-lint",
|
|
197
|
-
...fixOptions
|
|
198
|
-
]
|
|
199
|
-
]
|
|
200
|
-
]);
|
|
201
|
-
console.log(`${chalk4.gray("Linted in")} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`);
|
|
202
|
-
return result;
|
|
203
|
-
}, "lintAllPackages");
|
|
204
81
|
|
|
205
82
|
// src/actions/lint-clean.ts
|
|
206
83
|
var lintClean = /* @__PURE__ */ __name(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/lint-clean.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","../../src/actions/lint.ts"],"sourcesContent":["import { rmSync } from 'node:fs'\n\nimport { yarnWorkspaces } from '../lib/index.ts'\nimport { lint } from './lint.ts'\n\nexport const lintClean = async () => {\n console.log('Lint Clean [.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(`Lint Clean [.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 || await lint()\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 { 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 { 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 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 for (const ws of workspace) {\n await lintPackage({ pkg: ws.name, fix })\n }\n}\n\nexport const lint = async ({\n pkg, verbose, incremental, fix,\n}: LintParams = {}) => {\n return pkg\n ? await lintPackage({ pkg, fix })\n : lintAllPackages({\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"],"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,YA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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,qCAAqCN,IAAAA,KAASM,MAAMC,OAAO,GAAG;AAC5E,aAAO;IACT;EACF,CAAA,EAECC,OAAO,CAACC,MAAMZ,YAAWY,QAAQZ,SAAQ,CAAA;AAC5C,SAAOA,UAAU,MAAMa,KAAAA;AACzB,GAlByB;","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","chalk","ESLint","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","lint","pkg","verbose","incremental","fix","lintPackage","lintAllPackages","console","log","chalk","gray","start","Date","now","verboseOptions","fixOptions","incrementalOptions","result","runSteps","magenta","toFixed","lintClean","console","log","workspaces","yarnWorkspaces","result","map","location","name","dist","rmSync","force","recursive","ex","error","message","reduce","prev","lint"]}
|
|
1
|
+
{"version":3,"sources":["../../src/actions/lint-clean.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/actions/lint.ts"],"sourcesContent":["import { rmSync } from 'node:fs'\n\nimport { yarnWorkspaces } from '../lib/index.ts'\nimport { lint } from './lint.ts'\n\nexport const lintClean = async () => {\n console.log('Lint Clean [.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(`Lint Clean [.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 || await lint()\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 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"],"mappings":";;;;AAAA,SAASA,cAAc;;;ACAvB,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,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,WAAAA;AAEb,SAAOA,YAAYiC,OAAO,CAACC,MAAM/B,eAAe+B,OAAO/B,WAAWgC,YAAY,CAAA;AAChF,GAd2B;AAgBpB,IAAMC,UAAU,8BAAO,EAAElB,IAAG,MAAc;AAC/C,QAAMC,YAAYC,eAAAA;AAClB,UAAQ,MAAMiB,QAAQC,IAAInB,UAAUoB,IAAIC,CAAAA,OACtCxB,YAAY;IAAEC,KAAKuB,GAAGlB;IAAMJ;EAAI,CAAA,CAAA,CAAA,GAAMe,OAAO,CAACC,MAAMO,SAASP,OAAOO,MAAM,CAAA;AAC9E,GAJuB;AAMhB,IAAMC,OAAO,8BAAO,EACzBzB,KAAK0B,SAASC,aAAa1B,IAAG,IAChB,CAAC,MAAC;AAChB,SAAOD,MACH,MAAMD,YAAY;IAAEC;IAAKC;EAAI,CAAA,IAC7BkB,QAAQ;IACNO;IAASC;IAAa1B;EACxB,CAAA;AACN,GARoB;;;AFrDb,IAAM2B,YAAY,mCAAA;AACvBC,UAAQC,IAAI,2BAAA;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,qCAAqCN,IAAAA,KAASM,MAAMC,OAAO,GAAG;AAC5E,aAAO;IACT;EACF,CAAA,EAECC,OAAO,CAACC,MAAMZ,YAAWY,QAAQZ,SAAQ,CAAA;AAC5C,SAAOA,UAAU,MAAMa,KAAAA;AACzB,GAlByB;","names":["rmSync","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","chalk","ESLint","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","lintClean","console","log","workspaces","yarnWorkspaces","result","map","location","name","dist","rmSync","force","recursive","ex","error","message","reduce","prev","lint"]}
|
package/dist/actions/lint.mjs
CHANGED
|
@@ -155,18 +155,16 @@ var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix }) => {
|
|
|
155
155
|
}, "lintPackage");
|
|
156
156
|
var lintAll = /* @__PURE__ */ __name(async ({ fix }) => {
|
|
157
157
|
const workspace = yarnWorkspaces();
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
}
|
|
158
|
+
return (await Promise.all(workspace.map((ws) => lintPackage({
|
|
159
|
+
pkg: ws.name,
|
|
160
|
+
fix
|
|
161
|
+
})))).reduce((prev, curr) => prev + curr, 0);
|
|
164
162
|
}, "lintAll");
|
|
165
163
|
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix } = {}) => {
|
|
166
164
|
return pkg ? await lintPackage({
|
|
167
165
|
pkg,
|
|
168
166
|
fix
|
|
169
|
-
}) :
|
|
167
|
+
}) : lintAll({
|
|
170
168
|
verbose,
|
|
171
169
|
incremental,
|
|
172
170
|
fix
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/lint.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 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 for (const ws of workspace) {\n await lintPackage({ pkg: ws.name, fix })\n }\n}\n\nexport const lint = async ({\n pkg, verbose, incremental, fix,\n}: LintParams = {}) => {\n return pkg\n ? await lintPackage({ pkg, fix })\n : lintAllPackages({\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 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 { 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 { 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 }, !!ex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;;AAE9E,QAAMQ,SAASC,SAAS,uBAAuB;IAC7C;MAAC;MAAQ;QAAC;QACR;WACGJ;WACAE;QACH;QACA;WACGD;;;GAEN;AACDxC,UAAQC,IAAI,GAAGC,OAAMC,KAAK,WAAA,CAAA,KAAiBD,OAAMiB,UAAUkB,KAAKC,IAAG,IAAKF,SAAS,KAAMQ,QAAQ,CAAA,CAAA,CAAA,KAAQ1C,OAAMC,KAAK,SAAA,CAAA,EAAY;AAC9H,SAAOuC;AACT,GArB+B;","names":["chalk","ESLint","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","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","ws","lint","verbose","incremental","lintAllPackages","start","Date","now","verboseOptions","fixOptions","incrementalOptions","result","runSteps","toFixed"]}
|
|
1
|
+
{"version":3,"sources":["../../src/actions/lint.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 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 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 { 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 { 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"],"mappings":";;;;AAAA,OAAOA,YAAW;AAClB,SAASC,cAAc;;;ACDvB,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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,UAAU,MAAMC,YAAW,IAClB,CAAC,MAAC;AAChBtC,UAAQC,IAAIC,OAAMC,KAAK,wBAAA,CAAA;AACvB,QAAMqC,QAAQC,KAAKC,IAAG;AACtB,QAAMC,iBAAiBN,UAAU;IAAC;MAAe;IAAC;;AAClD,QAAMO,aAAahC,MAAM;IAAC;MAAW;IAAC;;AACtC,QAAMiC,qBAAqBP,cAAc;IAAC;IAAW;MAAU;IAAC;IAAc;;AAE9E,QAAMQ,SAASC,SAAS,uBAAuB;IAC7C;MAAC;MAAQ;QAAC;QACR;WACGJ;WACAE;QACH;QACA;WACGD;;;GAEN;AACD5C,UAAQC,IAAI,GAAGC,OAAMC,KAAK,WAAA,CAAA,KAAiBD,OAAMiB,UAAUsB,KAAKC,IAAG,IAAKF,SAAS,KAAMQ,QAAQ,CAAA,CAAA,CAAA,KAAQ9C,OAAMC,KAAK,SAAA,CAAA,EAAY;AAC9H,SAAO2C;AACT,GArB+B;","names":["chalk","ESLint","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","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","lintAllPackages","start","Date","now","verboseOptions","fixOptions","incrementalOptions","result","runSteps","toFixed"]}
|
package/dist/bin/xy-ts.mjs
CHANGED
|
@@ -897,19 +897,66 @@ var dupdeps = /* @__PURE__ */ __name(() => {
|
|
|
897
897
|
return detectDuplicateDependencies(dependencies);
|
|
898
898
|
}, "dupdeps");
|
|
899
899
|
|
|
900
|
+
// src/actions/lint.ts
|
|
901
|
+
import chalk13 from "chalk";
|
|
902
|
+
import { ESLint as ESLint2 } from "eslint";
|
|
903
|
+
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
904
|
+
const colors = [
|
|
905
|
+
"white",
|
|
906
|
+
"yellow",
|
|
907
|
+
"red"
|
|
908
|
+
];
|
|
909
|
+
const severity = [
|
|
910
|
+
"none",
|
|
911
|
+
"warning",
|
|
912
|
+
"error"
|
|
913
|
+
];
|
|
914
|
+
for (const lintResult of lintResults) {
|
|
915
|
+
if (lintResult.messages.length > 0) {
|
|
916
|
+
console.log(chalk13.gray(`${lintResult.filePath}`));
|
|
917
|
+
for (const message of lintResult.messages) {
|
|
918
|
+
console.log(chalk13.gray(` ${message.line}:${message.column}`), chalk13[colors[message.severity]](` ${severity[message.severity]}`), chalk13.white(` ${message.message}`), chalk13.gray(` ${message.ruleId}`));
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}, "dumpMessages");
|
|
923
|
+
var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
|
|
924
|
+
const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
|
|
925
|
+
if (!workspace) {
|
|
926
|
+
console.error(chalk13.red(`Unable to locate package [${chalk13.magenta(pkg)}]`));
|
|
927
|
+
process.exit(1);
|
|
928
|
+
}
|
|
929
|
+
const engine = new ESLint2({
|
|
930
|
+
cache: true,
|
|
931
|
+
fix: fix2
|
|
932
|
+
});
|
|
933
|
+
const lintResults = await engine.lintFiles(workspace.location);
|
|
934
|
+
dumpMessages(lintResults);
|
|
935
|
+
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
936
|
+
}, "lintPackage");
|
|
937
|
+
var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
|
|
938
|
+
const workspace = yarnWorkspaces();
|
|
939
|
+
return (await Promise.all(workspace.map((ws) => lintPackage({
|
|
940
|
+
pkg: ws.name,
|
|
941
|
+
fix: fix2
|
|
942
|
+
})))).reduce((prev, curr) => prev + curr, 0);
|
|
943
|
+
}, "lintAll");
|
|
944
|
+
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
945
|
+
return pkg ? await lintPackage({
|
|
946
|
+
pkg,
|
|
947
|
+
fix: fix2
|
|
948
|
+
}) : lintAll({
|
|
949
|
+
verbose,
|
|
950
|
+
incremental,
|
|
951
|
+
fix: fix2
|
|
952
|
+
});
|
|
953
|
+
}, "lint");
|
|
954
|
+
|
|
900
955
|
// src/actions/fix.ts
|
|
901
|
-
var fix = /* @__PURE__ */ __name(() => {
|
|
902
|
-
return
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
[
|
|
906
|
-
"eslint",
|
|
907
|
-
".",
|
|
908
|
-
"--fix",
|
|
909
|
-
"--cache"
|
|
910
|
-
]
|
|
911
|
-
]
|
|
912
|
-
]);
|
|
956
|
+
var fix = /* @__PURE__ */ __name(async () => {
|
|
957
|
+
return await lint({
|
|
958
|
+
fix: true
|
|
959
|
+
});
|
|
913
960
|
}, "fix");
|
|
914
961
|
|
|
915
962
|
// src/actions/gen-docs.ts
|
|
@@ -965,7 +1012,7 @@ var filename = ".gitignore";
|
|
|
965
1012
|
var gitignoreGen = /* @__PURE__ */ __name((pkg) => generateIgnoreFiles(filename, pkg), "gitignoreGen");
|
|
966
1013
|
|
|
967
1014
|
// src/actions/gitlint.ts
|
|
968
|
-
import
|
|
1015
|
+
import chalk14 from "chalk";
|
|
969
1016
|
import ParseGitConfig from "parse-git-config";
|
|
970
1017
|
var gitlint = /* @__PURE__ */ __name(() => {
|
|
971
1018
|
console.log(`
|
|
@@ -976,7 +1023,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
976
1023
|
const errors = 0;
|
|
977
1024
|
const gitConfig = ParseGitConfig.sync();
|
|
978
1025
|
const warn = /* @__PURE__ */ __name((message) => {
|
|
979
|
-
console.warn(
|
|
1026
|
+
console.warn(chalk14.yellow(`Warning: ${message}`));
|
|
980
1027
|
warnings++;
|
|
981
1028
|
}, "warn");
|
|
982
1029
|
if (gitConfig.core.ignorecase) {
|
|
@@ -996,13 +1043,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
996
1043
|
}
|
|
997
1044
|
const resultMessages = [];
|
|
998
1045
|
if (valid > 0) {
|
|
999
|
-
resultMessages.push(
|
|
1046
|
+
resultMessages.push(chalk14.green(`Passed: ${valid}`));
|
|
1000
1047
|
}
|
|
1001
1048
|
if (warnings > 0) {
|
|
1002
|
-
resultMessages.push(
|
|
1049
|
+
resultMessages.push(chalk14.yellow(`Warnings: ${warnings}`));
|
|
1003
1050
|
}
|
|
1004
1051
|
if (errors > 0) {
|
|
1005
|
-
resultMessages.push(
|
|
1052
|
+
resultMessages.push(chalk14.red(` Errors: ${errors}`));
|
|
1006
1053
|
}
|
|
1007
1054
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1008
1055
|
`);
|
|
@@ -1011,7 +1058,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1011
1058
|
|
|
1012
1059
|
// src/actions/gitlint-fix.ts
|
|
1013
1060
|
import { execSync as execSync2 } from "node:child_process";
|
|
1014
|
-
import
|
|
1061
|
+
import chalk15 from "chalk";
|
|
1015
1062
|
import ParseGitConfig2 from "parse-git-config";
|
|
1016
1063
|
var gitlintFix = /* @__PURE__ */ __name(() => {
|
|
1017
1064
|
console.log(`
|
|
@@ -1022,25 +1069,25 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1022
1069
|
execSync2("git config core.ignorecase false", {
|
|
1023
1070
|
stdio: "inherit"
|
|
1024
1071
|
});
|
|
1025
|
-
console.warn(
|
|
1072
|
+
console.warn(chalk15.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1026
1073
|
}
|
|
1027
1074
|
if (gitConfig.core.autocrlf !== false) {
|
|
1028
1075
|
execSync2("git config core.autocrlf false", {
|
|
1029
1076
|
stdio: "inherit"
|
|
1030
1077
|
});
|
|
1031
|
-
console.warn(
|
|
1078
|
+
console.warn(chalk15.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1032
1079
|
}
|
|
1033
1080
|
if (gitConfig.core.eol !== "lf") {
|
|
1034
1081
|
execSync2("git config core.eol lf", {
|
|
1035
1082
|
stdio: "inherit"
|
|
1036
1083
|
});
|
|
1037
|
-
console.warn(
|
|
1084
|
+
console.warn(chalk15.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1038
1085
|
}
|
|
1039
1086
|
return 1;
|
|
1040
1087
|
}, "gitlintFix");
|
|
1041
1088
|
|
|
1042
1089
|
// src/actions/license.ts
|
|
1043
|
-
import
|
|
1090
|
+
import chalk16 from "chalk";
|
|
1044
1091
|
import { init } from "license-checker";
|
|
1045
1092
|
var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
1046
1093
|
const workspaces = yarnWorkspaces();
|
|
@@ -1065,7 +1112,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1065
1112
|
"LGPL-3.0-or-later",
|
|
1066
1113
|
"Python-2.0"
|
|
1067
1114
|
]);
|
|
1068
|
-
console.log(
|
|
1115
|
+
console.log(chalk16.green("License Checker"));
|
|
1069
1116
|
return (await Promise.all(workspaceList.map(({ location, name }) => {
|
|
1070
1117
|
return new Promise((resolve) => {
|
|
1071
1118
|
init({
|
|
@@ -1073,12 +1120,12 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1073
1120
|
start: location
|
|
1074
1121
|
}, (error, packages) => {
|
|
1075
1122
|
if (error) {
|
|
1076
|
-
console.error(
|
|
1077
|
-
console.error(
|
|
1123
|
+
console.error(chalk16.red(`License Checker [${name}] Error`));
|
|
1124
|
+
console.error(chalk16.gray(error));
|
|
1078
1125
|
console.log("\n");
|
|
1079
1126
|
resolve(1);
|
|
1080
1127
|
} else {
|
|
1081
|
-
console.log(
|
|
1128
|
+
console.log(chalk16.green(`License Checker [${name}]`));
|
|
1082
1129
|
let count = 0;
|
|
1083
1130
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1084
1131
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [
|
|
@@ -1096,7 +1143,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1096
1143
|
}
|
|
1097
1144
|
if (!orLicenseFound) {
|
|
1098
1145
|
count++;
|
|
1099
|
-
console.warn(
|
|
1146
|
+
console.warn(chalk16.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1100
1147
|
}
|
|
1101
1148
|
}
|
|
1102
1149
|
}
|
|
@@ -1109,91 +1156,6 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1109
1156
|
}))).reduce((prev, value) => prev || value, 0);
|
|
1110
1157
|
}, "license");
|
|
1111
1158
|
|
|
1112
|
-
// src/actions/lint.ts
|
|
1113
|
-
import chalk16 from "chalk";
|
|
1114
|
-
import { ESLint as ESLint2 } from "eslint";
|
|
1115
|
-
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
1116
|
-
const colors = [
|
|
1117
|
-
"white",
|
|
1118
|
-
"yellow",
|
|
1119
|
-
"red"
|
|
1120
|
-
];
|
|
1121
|
-
const severity = [
|
|
1122
|
-
"none",
|
|
1123
|
-
"warning",
|
|
1124
|
-
"error"
|
|
1125
|
-
];
|
|
1126
|
-
for (const lintResult of lintResults) {
|
|
1127
|
-
if (lintResult.messages.length > 0) {
|
|
1128
|
-
console.log(chalk16.gray(`${lintResult.filePath}`));
|
|
1129
|
-
for (const message of lintResult.messages) {
|
|
1130
|
-
console.log(chalk16.gray(` ${message.line}:${message.column}`), chalk16[colors[message.severity]](` ${severity[message.severity]}`), chalk16.white(` ${message.message}`), chalk16.gray(` ${message.ruleId}`));
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
}, "dumpMessages");
|
|
1135
|
-
var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
|
|
1136
|
-
const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
|
|
1137
|
-
if (!workspace) {
|
|
1138
|
-
console.error(chalk16.red(`Unable to locate package [${chalk16.magenta(pkg)}]`));
|
|
1139
|
-
process.exit(1);
|
|
1140
|
-
}
|
|
1141
|
-
const engine = new ESLint2({
|
|
1142
|
-
cache: true,
|
|
1143
|
-
fix: fix2
|
|
1144
|
-
});
|
|
1145
|
-
const lintResults = await engine.lintFiles(workspace.location);
|
|
1146
|
-
dumpMessages(lintResults);
|
|
1147
|
-
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1148
|
-
}, "lintPackage");
|
|
1149
|
-
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
1150
|
-
return pkg ? await lintPackage({
|
|
1151
|
-
pkg,
|
|
1152
|
-
fix: fix2
|
|
1153
|
-
}) : lintAllPackages({
|
|
1154
|
-
verbose,
|
|
1155
|
-
incremental,
|
|
1156
|
-
fix: fix2
|
|
1157
|
-
});
|
|
1158
|
-
}, "lint");
|
|
1159
|
-
var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
|
|
1160
|
-
console.log(chalk16.gray("Linting [All-Packages]"));
|
|
1161
|
-
const start = Date.now();
|
|
1162
|
-
const verboseOptions = verbose ? [
|
|
1163
|
-
"--verbose"
|
|
1164
|
-
] : [
|
|
1165
|
-
"--no-verbose"
|
|
1166
|
-
];
|
|
1167
|
-
const fixOptions = fix2 ? [
|
|
1168
|
-
"--fix"
|
|
1169
|
-
] : [
|
|
1170
|
-
""
|
|
1171
|
-
];
|
|
1172
|
-
const incrementalOptions = incremental ? [
|
|
1173
|
-
"--since",
|
|
1174
|
-
"-Apt"
|
|
1175
|
-
] : [
|
|
1176
|
-
"--parallel",
|
|
1177
|
-
"-Apt"
|
|
1178
|
-
];
|
|
1179
|
-
const result = runSteps("Lint [All-Packages]", [
|
|
1180
|
-
[
|
|
1181
|
-
"yarn",
|
|
1182
|
-
[
|
|
1183
|
-
"workspaces",
|
|
1184
|
-
"foreach",
|
|
1185
|
-
...verboseOptions,
|
|
1186
|
-
...incrementalOptions,
|
|
1187
|
-
"run",
|
|
1188
|
-
"package-lint",
|
|
1189
|
-
...fixOptions
|
|
1190
|
-
]
|
|
1191
|
-
]
|
|
1192
|
-
]);
|
|
1193
|
-
console.log(`${chalk16.gray("Linted in")} [${chalk16.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk16.gray("seconds")}`);
|
|
1194
|
-
return result;
|
|
1195
|
-
}, "lintAllPackages");
|
|
1196
|
-
|
|
1197
1159
|
// src/actions/lint-profile.ts
|
|
1198
1160
|
var lintProfile = /* @__PURE__ */ __name(() => {
|
|
1199
1161
|
return runSteps("Lint Profile", [
|
|
@@ -1833,16 +1795,16 @@ var xyLintCommands = /* @__PURE__ */ __name((args) => {
|
|
|
1833
1795
|
}, async (argv) => {
|
|
1834
1796
|
if (argv.verbose) console.log("Lint");
|
|
1835
1797
|
const start = Date.now();
|
|
1836
|
-
process.exitCode = argv.fix ? fix() : argv.profile ? lintProfile() : await lint({
|
|
1798
|
+
process.exitCode = argv.fix ? await fix() : argv.profile ? lintProfile() : await lint({
|
|
1837
1799
|
pkg: argv.package
|
|
1838
1800
|
});
|
|
1839
1801
|
console.log(chalk19.blue(`Finished in ${Date.now() - start}ms`));
|
|
1840
1802
|
}).command("fix [package]", "Fix - Run Eslint w/fix", (yargs2) => {
|
|
1841
1803
|
return packagePositionalParam(yargs2);
|
|
1842
|
-
}, (argv) => {
|
|
1804
|
+
}, async (argv) => {
|
|
1843
1805
|
const start = Date.now();
|
|
1844
1806
|
if (argv.verbose) console.log("Fix");
|
|
1845
|
-
process.exitCode = fix();
|
|
1807
|
+
process.exitCode = await fix();
|
|
1846
1808
|
console.log(chalk19.blue(`Finished in ${Date.now() - start}ms`));
|
|
1847
1809
|
}).command("relint [package]", "Relint - Clean & Lint", (yargs2) => {
|
|
1848
1810
|
return packagePositionalParam(yargs2);
|