@xylabs/ts-scripts-yarn3 5.1.1 → 5.1.3
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 +108 -9
- package/dist/actions/fix.mjs.map +1 -1
- package/dist/actions/index.mjs +108 -106
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/lint-clean.mjs +16 -7
- package/dist/actions/lint-clean.mjs.map +1 -1
- package/dist/actions/lint.mjs +24 -14
- package/dist/actions/lint.mjs.map +1 -1
- package/dist/bin/xy-ts.mjs +102 -101
- package/dist/bin/xy-ts.mjs.map +1 -1
- package/dist/bin/xy.mjs +102 -101
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +111 -109
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +102 -101
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +102 -101
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +26 -25
- 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 +19 -13
- package/src/xy/xyLintCommands.ts +3 -3
package/dist/actions/fix.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// src/actions/lint.ts
|
|
5
|
+
import chalk4 from "chalk";
|
|
6
|
+
import { ESLint } from "eslint";
|
|
7
|
+
|
|
4
8
|
// src/lib/checkResult.ts
|
|
5
9
|
import chalk from "chalk";
|
|
6
10
|
var checkResult = /* @__PURE__ */ __name((name, result, level = "error", exitOnFail = false) => {
|
|
@@ -60,8 +64,28 @@ var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
|
|
|
60
64
|
}
|
|
61
65
|
}, "safeExit");
|
|
62
66
|
|
|
63
|
-
// src/lib/
|
|
67
|
+
// src/lib/yarn/workspace/yarnWorkspaces.ts
|
|
64
68
|
import { spawnSync } from "node:child_process";
|
|
69
|
+
var yarnWorkspaces = /* @__PURE__ */ __name(() => {
|
|
70
|
+
const result = spawnSync("yarn", [
|
|
71
|
+
"workspaces",
|
|
72
|
+
"list",
|
|
73
|
+
"--json",
|
|
74
|
+
"--recursive"
|
|
75
|
+
], {
|
|
76
|
+
encoding: "utf8",
|
|
77
|
+
shell: true
|
|
78
|
+
});
|
|
79
|
+
if (result.error) {
|
|
80
|
+
throw result.error;
|
|
81
|
+
}
|
|
82
|
+
return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
|
|
83
|
+
return JSON.parse(item);
|
|
84
|
+
});
|
|
85
|
+
}, "yarnWorkspaces");
|
|
86
|
+
|
|
87
|
+
// src/lib/runSteps.ts
|
|
88
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
65
89
|
import { existsSync } from "node:fs";
|
|
66
90
|
import chalk3 from "chalk";
|
|
67
91
|
var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
|
|
@@ -77,7 +101,7 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
|
|
|
77
101
|
if (command === "node" && !existsSync(argList[0])) {
|
|
78
102
|
throw new Error(`File not found [${argList[0]}]`);
|
|
79
103
|
}
|
|
80
|
-
const status =
|
|
104
|
+
const status = spawnSync2(command, Array.isArray(args) ? args : args.split(" "), {
|
|
81
105
|
...config,
|
|
82
106
|
encoding: "utf8",
|
|
83
107
|
env: {
|
|
@@ -94,19 +118,94 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
|
|
|
94
118
|
}, !!exitOnFail);
|
|
95
119
|
}, "runSteps");
|
|
96
120
|
|
|
97
|
-
// src/actions/
|
|
98
|
-
var
|
|
99
|
-
|
|
121
|
+
// src/actions/lint.ts
|
|
122
|
+
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
123
|
+
const colors = [
|
|
124
|
+
"white",
|
|
125
|
+
"yellow",
|
|
126
|
+
"red"
|
|
127
|
+
];
|
|
128
|
+
const severity = [
|
|
129
|
+
"none",
|
|
130
|
+
"warning",
|
|
131
|
+
"error"
|
|
132
|
+
];
|
|
133
|
+
for (const lintResult of lintResults) {
|
|
134
|
+
if (lintResult.messages.length > 0) {
|
|
135
|
+
console.log(chalk4.gray(`${lintResult.filePath}`));
|
|
136
|
+
for (const message of lintResult.messages) {
|
|
137
|
+
console.log(chalk4.gray(` ${message.line}:${message.column}`), chalk4[colors[message.severity]](` ${severity[message.severity]}`), chalk4.white(` ${message.message}`), chalk4.gray(` ${message.ruleId}`));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, "dumpMessages");
|
|
142
|
+
var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
|
|
143
|
+
const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
|
|
144
|
+
if (!workspace) {
|
|
145
|
+
console.error(chalk4.red(`Unable to locate package [${chalk4.magenta(pkg)}]`));
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
const engine = new ESLint({
|
|
149
|
+
cache: true,
|
|
150
|
+
fix: fix2
|
|
151
|
+
});
|
|
152
|
+
const lintResults = await engine.lintFiles(workspace.location);
|
|
153
|
+
dumpMessages(lintResults);
|
|
154
|
+
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
155
|
+
}, "lintPackage");
|
|
156
|
+
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
157
|
+
return pkg ? await lintPackage({
|
|
158
|
+
pkg,
|
|
159
|
+
fix: fix2
|
|
160
|
+
}) : lintAllPackages({
|
|
161
|
+
verbose,
|
|
162
|
+
incremental,
|
|
163
|
+
fix: fix2
|
|
164
|
+
});
|
|
165
|
+
}, "lint");
|
|
166
|
+
var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
|
|
167
|
+
console.log(chalk4.gray("Linting [All-Packages]"));
|
|
168
|
+
const start = Date.now();
|
|
169
|
+
const verboseOptions = verbose ? [
|
|
170
|
+
"--verbose"
|
|
171
|
+
] : [
|
|
172
|
+
"--no-verbose"
|
|
173
|
+
];
|
|
174
|
+
const fixOptions = fix2 ? [
|
|
175
|
+
"--fix"
|
|
176
|
+
] : [
|
|
177
|
+
""
|
|
178
|
+
];
|
|
179
|
+
const incrementalOptions = incremental ? [
|
|
180
|
+
"--since",
|
|
181
|
+
"-Apt"
|
|
182
|
+
] : [
|
|
183
|
+
"--parallel",
|
|
184
|
+
"-Apt"
|
|
185
|
+
];
|
|
186
|
+
const result = runSteps("Lint [All-Packages]", [
|
|
100
187
|
[
|
|
101
188
|
"yarn",
|
|
102
189
|
[
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
190
|
+
"workspaces",
|
|
191
|
+
"foreach",
|
|
192
|
+
...verboseOptions,
|
|
193
|
+
...incrementalOptions,
|
|
194
|
+
"run",
|
|
195
|
+
"package-lint",
|
|
196
|
+
...fixOptions
|
|
107
197
|
]
|
|
108
198
|
]
|
|
109
199
|
]);
|
|
200
|
+
console.log(`${chalk4.gray("Linted in")} [${chalk4.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk4.gray("seconds")}`);
|
|
201
|
+
return result;
|
|
202
|
+
}, "lintAllPackages");
|
|
203
|
+
|
|
204
|
+
// src/actions/fix.ts
|
|
205
|
+
var fix = /* @__PURE__ */ __name(async () => {
|
|
206
|
+
return await lint({
|
|
207
|
+
fix: true
|
|
208
|
+
});
|
|
110
209
|
}, "fix");
|
|
111
210
|
export {
|
|
112
211
|
fix
|
package/dist/actions/fix.mjs.map
CHANGED
|
@@ -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,sB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3B;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/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/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 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 }, !!exitOnFail)\n}\n","import { lint } from './lint.ts'\n\nexport const fix = async () => {\n return await lint({ fix: true })\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,sBAAs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IAAED,KAAK;EAAK,CAAA;AAChC,GAFmB;","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","lint","pkg","verbose","incremental","fix","lintPackage","lintAllPackages","console","log","chalk","gray","start","Date","now","verboseOptions","fixOptions","incrementalOptions","result","runSteps","magenta","toFixed","fix","lint"]}
|
package/dist/actions/index.mjs
CHANGED
|
@@ -913,19 +913,105 @@ var dupdeps = /* @__PURE__ */ __name(() => {
|
|
|
913
913
|
return detectDuplicateDependencies(dependencies);
|
|
914
914
|
}, "dupdeps");
|
|
915
915
|
|
|
916
|
-
// src/actions/
|
|
917
|
-
|
|
918
|
-
|
|
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
|
+
for (const ws of workspace) {
|
|
956
|
+
await lintPackage({
|
|
957
|
+
pkg: ws.name,
|
|
958
|
+
fix: fix2
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
}, "lintAll");
|
|
962
|
+
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
963
|
+
return pkg ? await lintPackage({
|
|
964
|
+
pkg,
|
|
965
|
+
fix: fix2
|
|
966
|
+
}) : lintAllPackages({
|
|
967
|
+
verbose,
|
|
968
|
+
incremental,
|
|
969
|
+
fix: fix2
|
|
970
|
+
});
|
|
971
|
+
}, "lint");
|
|
972
|
+
var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
|
|
973
|
+
console.log(chalk14.gray("Linting [All-Packages]"));
|
|
974
|
+
const start = Date.now();
|
|
975
|
+
const verboseOptions = verbose ? [
|
|
976
|
+
"--verbose"
|
|
977
|
+
] : [
|
|
978
|
+
"--no-verbose"
|
|
979
|
+
];
|
|
980
|
+
const fixOptions = fix2 ? [
|
|
981
|
+
"--fix"
|
|
982
|
+
] : [
|
|
983
|
+
""
|
|
984
|
+
];
|
|
985
|
+
const incrementalOptions = incremental ? [
|
|
986
|
+
"--since",
|
|
987
|
+
"-Apt"
|
|
988
|
+
] : [
|
|
989
|
+
"--parallel",
|
|
990
|
+
"-Apt"
|
|
991
|
+
];
|
|
992
|
+
const result = runSteps("Lint [All-Packages]", [
|
|
919
993
|
[
|
|
920
994
|
"yarn",
|
|
921
995
|
[
|
|
922
|
-
"
|
|
923
|
-
"
|
|
924
|
-
|
|
925
|
-
|
|
996
|
+
"workspaces",
|
|
997
|
+
"foreach",
|
|
998
|
+
...verboseOptions,
|
|
999
|
+
...incrementalOptions,
|
|
1000
|
+
"run",
|
|
1001
|
+
"package-lint",
|
|
1002
|
+
...fixOptions
|
|
926
1003
|
]
|
|
927
1004
|
]
|
|
928
1005
|
]);
|
|
1006
|
+
console.log(`${chalk14.gray("Linted in")} [${chalk14.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk14.gray("seconds")}`);
|
|
1007
|
+
return result;
|
|
1008
|
+
}, "lintAllPackages");
|
|
1009
|
+
|
|
1010
|
+
// src/actions/fix.ts
|
|
1011
|
+
var fix = /* @__PURE__ */ __name(async () => {
|
|
1012
|
+
return await lint({
|
|
1013
|
+
fix: true
|
|
1014
|
+
});
|
|
929
1015
|
}, "fix");
|
|
930
1016
|
|
|
931
1017
|
// src/actions/gen-docs.ts
|
|
@@ -981,7 +1067,7 @@ var filename = ".gitignore";
|
|
|
981
1067
|
var gitignoreGen = /* @__PURE__ */ __name((pkg) => generateIgnoreFiles(filename, pkg), "gitignoreGen");
|
|
982
1068
|
|
|
983
1069
|
// src/actions/gitlint.ts
|
|
984
|
-
import
|
|
1070
|
+
import chalk15 from "chalk";
|
|
985
1071
|
import ParseGitConfig from "parse-git-config";
|
|
986
1072
|
var gitlint = /* @__PURE__ */ __name(() => {
|
|
987
1073
|
console.log(`
|
|
@@ -992,7 +1078,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
992
1078
|
const errors = 0;
|
|
993
1079
|
const gitConfig = ParseGitConfig.sync();
|
|
994
1080
|
const warn = /* @__PURE__ */ __name((message) => {
|
|
995
|
-
console.warn(
|
|
1081
|
+
console.warn(chalk15.yellow(`Warning: ${message}`));
|
|
996
1082
|
warnings++;
|
|
997
1083
|
}, "warn");
|
|
998
1084
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1012,13 +1098,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1012
1098
|
}
|
|
1013
1099
|
const resultMessages = [];
|
|
1014
1100
|
if (valid > 0) {
|
|
1015
|
-
resultMessages.push(
|
|
1101
|
+
resultMessages.push(chalk15.green(`Passed: ${valid}`));
|
|
1016
1102
|
}
|
|
1017
1103
|
if (warnings > 0) {
|
|
1018
|
-
resultMessages.push(
|
|
1104
|
+
resultMessages.push(chalk15.yellow(`Warnings: ${warnings}`));
|
|
1019
1105
|
}
|
|
1020
1106
|
if (errors > 0) {
|
|
1021
|
-
resultMessages.push(
|
|
1107
|
+
resultMessages.push(chalk15.red(` Errors: ${errors}`));
|
|
1022
1108
|
}
|
|
1023
1109
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1024
1110
|
`);
|
|
@@ -1027,7 +1113,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1027
1113
|
|
|
1028
1114
|
// src/actions/gitlint-fix.ts
|
|
1029
1115
|
import { execSync as execSync2 } from "node:child_process";
|
|
1030
|
-
import
|
|
1116
|
+
import chalk16 from "chalk";
|
|
1031
1117
|
import ParseGitConfig2 from "parse-git-config";
|
|
1032
1118
|
var gitlintFix = /* @__PURE__ */ __name(() => {
|
|
1033
1119
|
console.log(`
|
|
@@ -1038,25 +1124,25 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1038
1124
|
execSync2("git config core.ignorecase false", {
|
|
1039
1125
|
stdio: "inherit"
|
|
1040
1126
|
});
|
|
1041
|
-
console.warn(
|
|
1127
|
+
console.warn(chalk16.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1042
1128
|
}
|
|
1043
1129
|
if (gitConfig.core.autocrlf !== false) {
|
|
1044
1130
|
execSync2("git config core.autocrlf false", {
|
|
1045
1131
|
stdio: "inherit"
|
|
1046
1132
|
});
|
|
1047
|
-
console.warn(
|
|
1133
|
+
console.warn(chalk16.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1048
1134
|
}
|
|
1049
1135
|
if (gitConfig.core.eol !== "lf") {
|
|
1050
1136
|
execSync2("git config core.eol lf", {
|
|
1051
1137
|
stdio: "inherit"
|
|
1052
1138
|
});
|
|
1053
|
-
console.warn(
|
|
1139
|
+
console.warn(chalk16.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1054
1140
|
}
|
|
1055
1141
|
return 1;
|
|
1056
1142
|
}, "gitlintFix");
|
|
1057
1143
|
|
|
1058
1144
|
// src/actions/license.ts
|
|
1059
|
-
import
|
|
1145
|
+
import chalk17 from "chalk";
|
|
1060
1146
|
import { init } from "license-checker";
|
|
1061
1147
|
var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
1062
1148
|
const workspaces = yarnWorkspaces();
|
|
@@ -1081,7 +1167,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1081
1167
|
"LGPL-3.0-or-later",
|
|
1082
1168
|
"Python-2.0"
|
|
1083
1169
|
]);
|
|
1084
|
-
console.log(
|
|
1170
|
+
console.log(chalk17.green("License Checker"));
|
|
1085
1171
|
return (await Promise.all(workspaceList.map(({ location, name }) => {
|
|
1086
1172
|
return new Promise((resolve) => {
|
|
1087
1173
|
init({
|
|
@@ -1089,12 +1175,12 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1089
1175
|
start: location
|
|
1090
1176
|
}, (error, packages) => {
|
|
1091
1177
|
if (error) {
|
|
1092
|
-
console.error(
|
|
1093
|
-
console.error(
|
|
1178
|
+
console.error(chalk17.red(`License Checker [${name}] Error`));
|
|
1179
|
+
console.error(chalk17.gray(error));
|
|
1094
1180
|
console.log("\n");
|
|
1095
1181
|
resolve(1);
|
|
1096
1182
|
} else {
|
|
1097
|
-
console.log(
|
|
1183
|
+
console.log(chalk17.green(`License Checker [${name}]`));
|
|
1098
1184
|
let count = 0;
|
|
1099
1185
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1100
1186
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [
|
|
@@ -1112,7 +1198,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1112
1198
|
}
|
|
1113
1199
|
if (!orLicenseFound) {
|
|
1114
1200
|
count++;
|
|
1115
|
-
console.warn(
|
|
1201
|
+
console.warn(chalk17.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1116
1202
|
}
|
|
1117
1203
|
}
|
|
1118
1204
|
}
|
|
@@ -1125,90 +1211,6 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1125
1211
|
}))).reduce((prev, value) => prev || value, 0);
|
|
1126
1212
|
}, "license");
|
|
1127
1213
|
|
|
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 }) => {
|
|
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
|
-
});
|
|
1160
|
-
const lintResults = await engine.lintFiles(workspace.location);
|
|
1161
|
-
dumpMessages(lintResults);
|
|
1162
|
-
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1163
|
-
}, "lintPackage");
|
|
1164
|
-
var lintAll = /* @__PURE__ */ __name(async () => {
|
|
1165
|
-
const engine = new ESLint2({
|
|
1166
|
-
cache: true
|
|
1167
|
-
});
|
|
1168
|
-
const lintResults = await engine.lintFiles("./**/*.*");
|
|
1169
|
-
dumpMessages(lintResults);
|
|
1170
|
-
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1171
|
-
}, "lintAll");
|
|
1172
|
-
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental } = {}) => {
|
|
1173
|
-
return pkg ? await lintPackage({
|
|
1174
|
-
pkg
|
|
1175
|
-
}) : lintAllPackages({
|
|
1176
|
-
verbose,
|
|
1177
|
-
incremental
|
|
1178
|
-
});
|
|
1179
|
-
}, "lint");
|
|
1180
|
-
var lintAllPackages = /* @__PURE__ */ __name(({ verbose = true, incremental } = {}) => {
|
|
1181
|
-
console.log(chalk17.gray("Linting [All-Packages]"));
|
|
1182
|
-
const start = Date.now();
|
|
1183
|
-
const verboseOptions = verbose ? [
|
|
1184
|
-
"--verbose"
|
|
1185
|
-
] : [
|
|
1186
|
-
"--no-verbose"
|
|
1187
|
-
];
|
|
1188
|
-
const incrementalOptions = incremental ? [
|
|
1189
|
-
"--since",
|
|
1190
|
-
"-Apt"
|
|
1191
|
-
] : [
|
|
1192
|
-
"--parallel",
|
|
1193
|
-
"-Apt"
|
|
1194
|
-
];
|
|
1195
|
-
const result = runSteps("Lint [All-Packages]", [
|
|
1196
|
-
[
|
|
1197
|
-
"yarn",
|
|
1198
|
-
[
|
|
1199
|
-
"workspaces",
|
|
1200
|
-
"foreach",
|
|
1201
|
-
...verboseOptions,
|
|
1202
|
-
...incrementalOptions,
|
|
1203
|
-
"run",
|
|
1204
|
-
"package-lint"
|
|
1205
|
-
]
|
|
1206
|
-
]
|
|
1207
|
-
]);
|
|
1208
|
-
console.log(`${chalk17.gray("Linted in")} [${chalk17.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk17.gray("seconds")}`);
|
|
1209
|
-
return result;
|
|
1210
|
-
}, "lintAllPackages");
|
|
1211
|
-
|
|
1212
1214
|
// src/actions/lint-clean.ts
|
|
1213
1215
|
import { rmSync } from "node:fs";
|
|
1214
1216
|
var lintClean = /* @__PURE__ */ __name(async () => {
|