@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
package/dist/actions/fix.mjs
CHANGED
|
@@ -1,112 +1,88 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
-
// src/
|
|
4
|
+
// src/actions/lint.ts
|
|
5
5
|
import chalk from "chalk";
|
|
6
|
-
|
|
7
|
-
if (result) {
|
|
8
|
-
const exiting = exitOnFail ? "[Exiting Process]" : "[Continuing]";
|
|
9
|
-
const chalkFunc = level === "error" ? chalk.red : chalk.yellow;
|
|
10
|
-
console[level](chalkFunc(`${name} had ${result} failures ${exiting}`));
|
|
11
|
-
if (exitOnFail) {
|
|
12
|
-
process.exit(result);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}, "checkResult");
|
|
16
|
-
|
|
17
|
-
// src/lib/processEx.ts
|
|
18
|
-
import chalk2 from "chalk";
|
|
19
|
-
|
|
20
|
-
// src/lib/withError.ts
|
|
21
|
-
var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => !!ex2.name && !!ex2.message) => {
|
|
22
|
-
return predicate(ex) ? closure(ex) : void 0;
|
|
23
|
-
}, "withError");
|
|
24
|
-
|
|
25
|
-
// src/lib/withErrnoException.ts
|
|
26
|
-
var withErrnoException = /* @__PURE__ */ __name((ex, closure) => {
|
|
27
|
-
return withError(ex, closure, (ex2) => ex2.errno !== void 0);
|
|
28
|
-
}, "withErrnoException");
|
|
29
|
-
|
|
30
|
-
// src/lib/processEx.ts
|
|
31
|
-
var processEx = /* @__PURE__ */ __name((ex) => {
|
|
32
|
-
const error = typeof ex === "string" ? new Error(ex) : ex;
|
|
33
|
-
const exitCode = withErrnoException(error, (error2) => {
|
|
34
|
-
if (error2.code === "ENOENT") {
|
|
35
|
-
console.error(chalk2.red(`'${error2.path}' not found.`));
|
|
36
|
-
} else {
|
|
37
|
-
console.error(chalk2.red(`Errno: ${error2.code}`));
|
|
38
|
-
}
|
|
39
|
-
return error2.errno ?? -1;
|
|
40
|
-
}) ?? withError(error, (error2) => {
|
|
41
|
-
console.error(chalk2.red(`${error2.name}: ${error2.message}`));
|
|
42
|
-
return -1;
|
|
43
|
-
}) ?? (() => {
|
|
44
|
-
console.error(chalk2.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`));
|
|
45
|
-
return -1;
|
|
46
|
-
})();
|
|
47
|
-
process.exit(process.exitCode ?? exitCode);
|
|
48
|
-
}, "processEx");
|
|
6
|
+
import { ESLint } from "eslint";
|
|
49
7
|
|
|
50
|
-
// src/lib/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
8
|
+
// src/lib/yarn/workspace/yarnWorkspaces.ts
|
|
9
|
+
import { spawnSync } from "node:child_process";
|
|
10
|
+
var yarnWorkspaces = /* @__PURE__ */ __name(() => {
|
|
11
|
+
const result = spawnSync("yarn", [
|
|
12
|
+
"workspaces",
|
|
13
|
+
"list",
|
|
14
|
+
"--json",
|
|
15
|
+
"--recursive"
|
|
16
|
+
], {
|
|
17
|
+
encoding: "utf8",
|
|
18
|
+
shell: true
|
|
19
|
+
});
|
|
20
|
+
if (result.error) {
|
|
21
|
+
throw result.error;
|
|
60
22
|
}
|
|
61
|
-
|
|
23
|
+
return result.stdout.toString().split("\n").slice(0, -1).map((item) => {
|
|
24
|
+
return JSON.parse(item);
|
|
25
|
+
});
|
|
26
|
+
}, "yarnWorkspaces");
|
|
62
27
|
|
|
63
|
-
// src/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
28
|
+
// src/actions/lint.ts
|
|
29
|
+
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
30
|
+
const colors = [
|
|
31
|
+
"white",
|
|
32
|
+
"yellow",
|
|
33
|
+
"red"
|
|
34
|
+
];
|
|
35
|
+
const severity = [
|
|
36
|
+
"none",
|
|
37
|
+
"warning",
|
|
38
|
+
"error"
|
|
39
|
+
];
|
|
40
|
+
for (const lintResult of lintResults) {
|
|
41
|
+
if (lintResult.messages.length > 0) {
|
|
42
|
+
console.log(chalk.gray(`${lintResult.filePath}`));
|
|
43
|
+
for (const message of lintResult.messages) {
|
|
44
|
+
console.log(chalk.gray(` ${message.line}:${message.column}`), chalk[colors[message.severity]](` ${severity[message.severity]}`), chalk.white(` ${message.message}`), chalk.gray(` ${message.ruleId}`));
|
|
75
45
|
}
|
|
76
|
-
const argList = Array.isArray(args) ? args : args.split(" ");
|
|
77
|
-
if (command === "node" && !existsSync(argList[0])) {
|
|
78
|
-
throw new Error(`File not found [${argList[0]}]`);
|
|
79
|
-
}
|
|
80
|
-
const status = spawnSync(command, Array.isArray(args) ? args : args.split(" "), {
|
|
81
|
-
...config,
|
|
82
|
-
encoding: "utf8",
|
|
83
|
-
env: {
|
|
84
|
-
FORCE_COLOR: "3",
|
|
85
|
-
...process.env
|
|
86
|
-
},
|
|
87
|
-
shell: true,
|
|
88
|
-
stdio: "inherit"
|
|
89
|
-
}).status ?? 0;
|
|
90
|
-
checkResult(name, status, "error", exitOnFail);
|
|
91
|
-
totalStatus += status ?? 0;
|
|
92
46
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
47
|
+
}
|
|
48
|
+
}, "dumpMessages");
|
|
49
|
+
var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
|
|
50
|
+
const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
|
|
51
|
+
if (!workspace) {
|
|
52
|
+
console.error(chalk.red(`Unable to locate package [${chalk.magenta(pkg)}]`));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
const engine = new ESLint({
|
|
56
|
+
cache: true,
|
|
57
|
+
fix: fix2
|
|
58
|
+
});
|
|
59
|
+
const lintResults = await engine.lintFiles(workspace.location);
|
|
60
|
+
dumpMessages(lintResults);
|
|
61
|
+
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
62
|
+
}, "lintPackage");
|
|
63
|
+
var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
|
|
64
|
+
const workspace = yarnWorkspaces();
|
|
65
|
+
return (await Promise.all(workspace.map((ws) => lintPackage({
|
|
66
|
+
pkg: ws.name,
|
|
67
|
+
fix: fix2
|
|
68
|
+
})))).reduce((prev, curr) => prev + curr, 0);
|
|
69
|
+
}, "lintAll");
|
|
70
|
+
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
71
|
+
return pkg ? await lintPackage({
|
|
72
|
+
pkg,
|
|
73
|
+
fix: fix2
|
|
74
|
+
}) : lintAll({
|
|
75
|
+
verbose,
|
|
76
|
+
incremental,
|
|
77
|
+
fix: fix2
|
|
78
|
+
});
|
|
79
|
+
}, "lint");
|
|
96
80
|
|
|
97
81
|
// src/actions/fix.ts
|
|
98
|
-
var fix = /* @__PURE__ */ __name(() => {
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
[
|
|
103
|
-
"eslint",
|
|
104
|
-
".",
|
|
105
|
-
"--fix",
|
|
106
|
-
"--cache"
|
|
107
|
-
]
|
|
108
|
-
]
|
|
109
|
-
]);
|
|
82
|
+
var fix = /* @__PURE__ */ __name(async () => {
|
|
83
|
+
return await lint({
|
|
84
|
+
fix: true
|
|
85
|
+
});
|
|
110
86
|
}, "fix");
|
|
111
87
|
export {
|
|
112
88
|
fix
|
package/dist/actions/fix.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/actions/lint.ts","../../src/lib/yarn/workspace/yarnWorkspaces.ts","../../src/actions/fix.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { ESLint } from 'eslint'\n\nimport { runSteps, yarnWorkspaces } from '../lib/index.ts'\n\nexport interface LintParams {\n fix?: boolean\n incremental?: boolean\n pkg?: string\n verbose?: boolean\n}\n\nexport interface LintPackageParams {\n pkg: string\n verbose?: boolean\n}\n\nconst dumpMessages = (lintResults: ESLint.LintResult[]) => {\n const colors: ('white' | 'red' | 'yellow')[] = ['white', 'yellow', 'red']\n const severity: string[] = ['none', 'warning', 'error']\n\n for (const lintResult of lintResults) {\n if (lintResult.messages.length > 0) {\n console.log(chalk.gray(`${lintResult.filePath}`))\n for (const message of lintResult.messages) {\n console.log(\n chalk.gray(`\\t${message.line}:${message.column}`),\n chalk[colors[message.severity]](`\\t${severity[message.severity]}`),\n chalk.white(`\\t${message.message}`),\n chalk.gray(`\\t${message.ruleId}`),\n )\n }\n }\n }\n}\n\nexport const lintPackage = async ({ pkg, fix }: LintParams) => {\n const workspace = yarnWorkspaces().find(workspace => workspace.name === pkg)\n if (!workspace) {\n console.error(chalk.red(`Unable to locate package [${chalk.magenta(pkg)}]`))\n process.exit(1)\n }\n\n const engine = new ESLint({ cache: true, fix })\n\n const lintResults = await engine.lintFiles(workspace.location)\n\n dumpMessages(lintResults)\n\n return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0)\n}\n\nexport const lintAll = async ({ fix }: LintParams) => {\n const workspace = yarnWorkspaces()\n return (await Promise.all(workspace.map(ws =>\n lintPackage({ pkg: ws.name, fix })))).reduce((prev, curr) => prev + curr, 0)\n}\n\nexport const lint = async ({\n pkg, verbose, incremental, fix,\n}: LintParams = {}) => {\n return pkg\n ? await lintPackage({ pkg, fix })\n : lintAll({\n verbose, incremental, fix,\n })\n}\n\nexport const lintAllPackages = ({\n fix, verbose = true, incremental,\n}: LintParams = {}) => {\n console.log(chalk.gray('Linting [All-Packages]'))\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const fixOptions = fix ? ['--fix'] : ['']\n const incrementalOptions = incremental ? ['--since', '-Apt'] : ['--parallel', '-Apt']\n\n const result = runSteps('Lint [All-Packages]', [\n ['yarn', ['workspaces',\n 'foreach',\n ...verboseOptions,\n ...incrementalOptions,\n 'run',\n 'package-lint',\n ...fixOptions,\n ]],\n ])\n console.log(`${chalk.gray('Linted in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import { spawnSync } from 'node:child_process'\n\nimport { Workspace } from './Workspace.ts'\n\nexport const yarnWorkspaces = (): Workspace[] => {\n const result = spawnSync('yarn', ['workspaces', 'list', '--json', '--recursive'], { encoding: 'utf8', shell: true })\n if (result.error) {\n throw result.error\n }\n return (\n result.stdout\n .toString()\n // NOTE: This probably doesn't work on Windows\n // TODO: Replace /r/n with /n first\n .split('\\n')\n .slice(0, -1)\n .map((item) => {\n return JSON.parse(item)\n })\n )\n}\n","import { lint } from './lint.ts'\n\nexport const fix = async () => {\n return await lint({ fix: true })\n}\n"],"mappings":";;;;AAAA,OAAOA,WAAW;AAClB,SAASC,cAAc;;;ACDvB,SAASC,iBAAiB;AAInB,IAAMC,iBAAiB,6BAAA;AAC5B,QAAMC,SAASC,UAAU,QAAQ;IAAC;IAAc;IAAQ;IAAU;KAAgB;IAAEC,UAAU;IAAQC,OAAO;EAAK,CAAA;AAClH,MAAIH,OAAOI,OAAO;AAChB,UAAMJ,OAAOI;EACf;AACA,SACEJ,OAAOK,OACJC,SAAQ,EAGRC,MAAM,IAAA,EACNC,MAAM,GAAG,EAAC,EACVC,IAAI,CAACC,SAAAA;AACJ,WAAOC,KAAKC,MAAMF,IAAAA;EACpB,CAAA;AAEN,GAhB8B;;;ADa9B,IAAMG,eAAe,wBAACC,gBAAAA;AACpB,QAAMC,SAAyC;IAAC;IAAS;IAAU;;AACnE,QAAMC,WAAqB;IAAC;IAAQ;IAAW;;AAE/C,aAAWC,cAAcH,aAAa;AACpC,QAAIG,WAAWC,SAASC,SAAS,GAAG;AAClCC,cAAQC,IAAIC,MAAMC,KAAK,GAAGN,WAAWO,QAAQ,EAAE,CAAA;AAC/C,iBAAWC,WAAWR,WAAWC,UAAU;AACzCE,gBAAQC,IACNC,MAAMC,KAAK,IAAKE,QAAQC,IAAI,IAAID,QAAQE,MAAM,EAAE,GAChDL,MAAMP,OAAOU,QAAQT,QAAQ,CAAC,EAAE,IAAKA,SAASS,QAAQT,QAAQ,CAAC,EAAE,GACjEM,MAAMM,MAAM,IAAKH,QAAQA,OAAO,EAAE,GAClCH,MAAMC,KAAK,IAAKE,QAAQI,MAAM,EAAE,CAAA;MAEpC;IACF;EACF;AACF,GAjBqB;AAmBd,IAAMC,cAAc,8BAAO,EAAEC,KAAKC,KAAAA,KAAG,MAAc;AACxD,QAAMC,YAAYC,eAAAA,EAAiBC,KAAKF,CAAAA,eAAaA,WAAUG,SAASL,GAAAA;AACxE,MAAI,CAACE,WAAW;AACdb,YAAQiB,MAAMf,MAAMgB,IAAI,6BAA6BhB,MAAMiB,QAAQR,GAAAA,CAAAA,GAAO,CAAA;AAC1ES,YAAQC,KAAK,CAAA;EACf;AAEA,QAAMC,SAAS,IAAIC,OAAO;IAAEC,OAAO;IAAMZ,KAAAA;EAAI,CAAA;AAE7C,QAAMlB,cAAc,MAAM4B,OAAOG,UAAUZ,UAAUa,QAAQ;AAE7DjC,eAAaC,WAAAA;AAEb,SAAOA,YAAYiC,OAAO,CAACC,MAAM/B,eAAe+B,OAAO/B,WAAWgC,YAAY,CAAA;AAChF,GAd2B;AAgBpB,IAAMC,UAAU,8BAAO,EAAElB,KAAAA,KAAG,MAAc;AAC/C,QAAMC,YAAYC,eAAAA;AAClB,UAAQ,MAAMiB,QAAQC,IAAInB,UAAUoB,IAAIC,CAAAA,OACtCxB,YAAY;IAAEC,KAAKuB,GAAGlB;IAAMJ,KAAAA;EAAI,CAAA,CAAA,CAAA,GAAMe,OAAO,CAACC,MAAMO,SAASP,OAAOO,MAAM,CAAA;AAC9E,GAJuB;AAMhB,IAAMC,OAAO,8BAAO,EACzBzB,KAAK0B,SAASC,aAAa1B,KAAAA,KAAG,IAChB,CAAC,MAAC;AAChB,SAAOD,MACH,MAAMD,YAAY;IAAEC;IAAKC,KAAAA;EAAI,CAAA,IAC7BkB,QAAQ;IACNO;IAASC;IAAa1B,KAAAA;EACxB,CAAA;AACN,GARoB;;;AExDb,IAAM2B,MAAM,mCAAA;AACjB,SAAO,MAAMC,KAAK;IAAED,KAAK;EAAK,CAAA;AAChC,GAFmB;","names":["chalk","ESLint","spawnSync","yarnWorkspaces","result","spawnSync","encoding","shell","error","stdout","toString","split","slice","map","item","JSON","parse","dumpMessages","lintResults","colors","severity","lintResult","messages","length","console","log","chalk","gray","filePath","message","line","column","white","ruleId","lintPackage","pkg","fix","workspace","yarnWorkspaces","find","name","error","red","magenta","process","exit","engine","ESLint","cache","lintFiles","location","reduce","prev","errorCount","lintAll","Promise","all","map","ws","curr","lint","verbose","incremental","fix","lint"]}
|
package/dist/actions/index.mjs
CHANGED
|
@@ -913,19 +913,103 @@ 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
|
+
return (await Promise.all(workspace.map((ws) => lintPackage({
|
|
956
|
+
pkg: ws.name,
|
|
957
|
+
fix: fix2
|
|
958
|
+
})))).reduce((prev, curr) => prev + curr, 0);
|
|
959
|
+
}, "lintAll");
|
|
960
|
+
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
961
|
+
return pkg ? await lintPackage({
|
|
962
|
+
pkg,
|
|
963
|
+
fix: fix2
|
|
964
|
+
}) : lintAll({
|
|
965
|
+
verbose,
|
|
966
|
+
incremental,
|
|
967
|
+
fix: fix2
|
|
968
|
+
});
|
|
969
|
+
}, "lint");
|
|
970
|
+
var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
|
|
971
|
+
console.log(chalk14.gray("Linting [All-Packages]"));
|
|
972
|
+
const start = Date.now();
|
|
973
|
+
const verboseOptions = verbose ? [
|
|
974
|
+
"--verbose"
|
|
975
|
+
] : [
|
|
976
|
+
"--no-verbose"
|
|
977
|
+
];
|
|
978
|
+
const fixOptions = fix2 ? [
|
|
979
|
+
"--fix"
|
|
980
|
+
] : [
|
|
981
|
+
""
|
|
982
|
+
];
|
|
983
|
+
const incrementalOptions = incremental ? [
|
|
984
|
+
"--since",
|
|
985
|
+
"-Apt"
|
|
986
|
+
] : [
|
|
987
|
+
"--parallel",
|
|
988
|
+
"-Apt"
|
|
989
|
+
];
|
|
990
|
+
const result = runSteps("Lint [All-Packages]", [
|
|
919
991
|
[
|
|
920
992
|
"yarn",
|
|
921
993
|
[
|
|
922
|
-
"
|
|
923
|
-
"
|
|
924
|
-
|
|
925
|
-
|
|
994
|
+
"workspaces",
|
|
995
|
+
"foreach",
|
|
996
|
+
...verboseOptions,
|
|
997
|
+
...incrementalOptions,
|
|
998
|
+
"run",
|
|
999
|
+
"package-lint",
|
|
1000
|
+
...fixOptions
|
|
926
1001
|
]
|
|
927
1002
|
]
|
|
928
1003
|
]);
|
|
1004
|
+
console.log(`${chalk14.gray("Linted in")} [${chalk14.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk14.gray("seconds")}`);
|
|
1005
|
+
return result;
|
|
1006
|
+
}, "lintAllPackages");
|
|
1007
|
+
|
|
1008
|
+
// src/actions/fix.ts
|
|
1009
|
+
var fix = /* @__PURE__ */ __name(async () => {
|
|
1010
|
+
return await lint({
|
|
1011
|
+
fix: true
|
|
1012
|
+
});
|
|
929
1013
|
}, "fix");
|
|
930
1014
|
|
|
931
1015
|
// src/actions/gen-docs.ts
|
|
@@ -981,7 +1065,7 @@ var filename = ".gitignore";
|
|
|
981
1065
|
var gitignoreGen = /* @__PURE__ */ __name((pkg) => generateIgnoreFiles(filename, pkg), "gitignoreGen");
|
|
982
1066
|
|
|
983
1067
|
// src/actions/gitlint.ts
|
|
984
|
-
import
|
|
1068
|
+
import chalk15 from "chalk";
|
|
985
1069
|
import ParseGitConfig from "parse-git-config";
|
|
986
1070
|
var gitlint = /* @__PURE__ */ __name(() => {
|
|
987
1071
|
console.log(`
|
|
@@ -992,7 +1076,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
992
1076
|
const errors = 0;
|
|
993
1077
|
const gitConfig = ParseGitConfig.sync();
|
|
994
1078
|
const warn = /* @__PURE__ */ __name((message) => {
|
|
995
|
-
console.warn(
|
|
1079
|
+
console.warn(chalk15.yellow(`Warning: ${message}`));
|
|
996
1080
|
warnings++;
|
|
997
1081
|
}, "warn");
|
|
998
1082
|
if (gitConfig.core.ignorecase) {
|
|
@@ -1012,13 +1096,13 @@ Gitlint Start [${process.cwd()}]
|
|
|
1012
1096
|
}
|
|
1013
1097
|
const resultMessages = [];
|
|
1014
1098
|
if (valid > 0) {
|
|
1015
|
-
resultMessages.push(
|
|
1099
|
+
resultMessages.push(chalk15.green(`Passed: ${valid}`));
|
|
1016
1100
|
}
|
|
1017
1101
|
if (warnings > 0) {
|
|
1018
|
-
resultMessages.push(
|
|
1102
|
+
resultMessages.push(chalk15.yellow(`Warnings: ${warnings}`));
|
|
1019
1103
|
}
|
|
1020
1104
|
if (errors > 0) {
|
|
1021
|
-
resultMessages.push(
|
|
1105
|
+
resultMessages.push(chalk15.red(` Errors: ${errors}`));
|
|
1022
1106
|
}
|
|
1023
1107
|
console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
|
|
1024
1108
|
`);
|
|
@@ -1027,7 +1111,7 @@ Gitlint Start [${process.cwd()}]
|
|
|
1027
1111
|
|
|
1028
1112
|
// src/actions/gitlint-fix.ts
|
|
1029
1113
|
import { execSync as execSync2 } from "node:child_process";
|
|
1030
|
-
import
|
|
1114
|
+
import chalk16 from "chalk";
|
|
1031
1115
|
import ParseGitConfig2 from "parse-git-config";
|
|
1032
1116
|
var gitlintFix = /* @__PURE__ */ __name(() => {
|
|
1033
1117
|
console.log(`
|
|
@@ -1038,25 +1122,25 @@ Gitlint Fix Start [${process.cwd()}]
|
|
|
1038
1122
|
execSync2("git config core.ignorecase false", {
|
|
1039
1123
|
stdio: "inherit"
|
|
1040
1124
|
});
|
|
1041
|
-
console.warn(
|
|
1125
|
+
console.warn(chalk16.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
|
|
1042
1126
|
}
|
|
1043
1127
|
if (gitConfig.core.autocrlf !== false) {
|
|
1044
1128
|
execSync2("git config core.autocrlf false", {
|
|
1045
1129
|
stdio: "inherit"
|
|
1046
1130
|
});
|
|
1047
|
-
console.warn(
|
|
1131
|
+
console.warn(chalk16.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
|
|
1048
1132
|
}
|
|
1049
1133
|
if (gitConfig.core.eol !== "lf") {
|
|
1050
1134
|
execSync2("git config core.eol lf", {
|
|
1051
1135
|
stdio: "inherit"
|
|
1052
1136
|
});
|
|
1053
|
-
console.warn(
|
|
1137
|
+
console.warn(chalk16.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
|
|
1054
1138
|
}
|
|
1055
1139
|
return 1;
|
|
1056
1140
|
}, "gitlintFix");
|
|
1057
1141
|
|
|
1058
1142
|
// src/actions/license.ts
|
|
1059
|
-
import
|
|
1143
|
+
import chalk17 from "chalk";
|
|
1060
1144
|
import { init } from "license-checker";
|
|
1061
1145
|
var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
1062
1146
|
const workspaces = yarnWorkspaces();
|
|
@@ -1081,7 +1165,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1081
1165
|
"LGPL-3.0-or-later",
|
|
1082
1166
|
"Python-2.0"
|
|
1083
1167
|
]);
|
|
1084
|
-
console.log(
|
|
1168
|
+
console.log(chalk17.green("License Checker"));
|
|
1085
1169
|
return (await Promise.all(workspaceList.map(({ location, name }) => {
|
|
1086
1170
|
return new Promise((resolve) => {
|
|
1087
1171
|
init({
|
|
@@ -1089,12 +1173,12 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1089
1173
|
start: location
|
|
1090
1174
|
}, (error, packages) => {
|
|
1091
1175
|
if (error) {
|
|
1092
|
-
console.error(
|
|
1093
|
-
console.error(
|
|
1176
|
+
console.error(chalk17.red(`License Checker [${name}] Error`));
|
|
1177
|
+
console.error(chalk17.gray(error));
|
|
1094
1178
|
console.log("\n");
|
|
1095
1179
|
resolve(1);
|
|
1096
1180
|
} else {
|
|
1097
|
-
console.log(
|
|
1181
|
+
console.log(chalk17.green(`License Checker [${name}]`));
|
|
1098
1182
|
let count = 0;
|
|
1099
1183
|
for (const [name2, info] of Object.entries(packages)) {
|
|
1100
1184
|
const licenses = Array.isArray(info.licenses) ? info.licenses : [
|
|
@@ -1112,7 +1196,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1112
1196
|
}
|
|
1113
1197
|
if (!orLicenseFound) {
|
|
1114
1198
|
count++;
|
|
1115
|
-
console.warn(
|
|
1199
|
+
console.warn(chalk17.yellow(`${name2}: Package License not allowed [${license2}]`));
|
|
1116
1200
|
}
|
|
1117
1201
|
}
|
|
1118
1202
|
}
|
|
@@ -1125,100 +1209,6 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1125
1209
|
}))).reduce((prev, value) => prev || value, 0);
|
|
1126
1210
|
}, "license");
|
|
1127
1211
|
|
|
1128
|
-
// src/actions/lint.ts
|
|
1129
|
-
import chalk17 from "chalk";
|
|
1130
|
-
import { ESLint as ESLint2 } from "eslint";
|
|
1131
|
-
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
1132
|
-
const colors = [
|
|
1133
|
-
"white",
|
|
1134
|
-
"yellow",
|
|
1135
|
-
"red"
|
|
1136
|
-
];
|
|
1137
|
-
const severity = [
|
|
1138
|
-
"none",
|
|
1139
|
-
"warning",
|
|
1140
|
-
"error"
|
|
1141
|
-
];
|
|
1142
|
-
for (const lintResult of lintResults) {
|
|
1143
|
-
if (lintResult.messages.length > 0) {
|
|
1144
|
-
console.log(chalk17.gray(`${lintResult.filePath}`));
|
|
1145
|
-
for (const message of lintResult.messages) {
|
|
1146
|
-
console.log(chalk17.gray(` ${message.line}:${message.column}`), chalk17[colors[message.severity]](` ${severity[message.severity]}`), chalk17.white(` ${message.message}`), chalk17.gray(` ${message.ruleId}`));
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
}, "dumpMessages");
|
|
1151
|
-
var lintPackage = /* @__PURE__ */ __name(async ({ pkg, fix: fix2 }) => {
|
|
1152
|
-
const workspace = yarnWorkspaces().find((workspace2) => workspace2.name === pkg);
|
|
1153
|
-
if (!workspace) {
|
|
1154
|
-
console.error(chalk17.red(`Unable to locate package [${chalk17.magenta(pkg)}]`));
|
|
1155
|
-
process.exit(1);
|
|
1156
|
-
}
|
|
1157
|
-
const engine = new ESLint2({
|
|
1158
|
-
cache: true,
|
|
1159
|
-
fix: fix2
|
|
1160
|
-
});
|
|
1161
|
-
const lintResults = await engine.lintFiles(workspace.location);
|
|
1162
|
-
dumpMessages(lintResults);
|
|
1163
|
-
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1164
|
-
}, "lintPackage");
|
|
1165
|
-
var lintAll = /* @__PURE__ */ __name(async ({ fix: fix2 }) => {
|
|
1166
|
-
const workspace = yarnWorkspaces();
|
|
1167
|
-
for (const ws of workspace) {
|
|
1168
|
-
await lintPackage({
|
|
1169
|
-
pkg: ws.name,
|
|
1170
|
-
fix: fix2
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
}, "lintAll");
|
|
1174
|
-
var lint = /* @__PURE__ */ __name(async ({ pkg, verbose, incremental, fix: fix2 } = {}) => {
|
|
1175
|
-
return pkg ? await lintPackage({
|
|
1176
|
-
pkg,
|
|
1177
|
-
fix: fix2
|
|
1178
|
-
}) : lintAllPackages({
|
|
1179
|
-
verbose,
|
|
1180
|
-
incremental,
|
|
1181
|
-
fix: fix2
|
|
1182
|
-
});
|
|
1183
|
-
}, "lint");
|
|
1184
|
-
var lintAllPackages = /* @__PURE__ */ __name(({ fix: fix2, verbose = true, incremental } = {}) => {
|
|
1185
|
-
console.log(chalk17.gray("Linting [All-Packages]"));
|
|
1186
|
-
const start = Date.now();
|
|
1187
|
-
const verboseOptions = verbose ? [
|
|
1188
|
-
"--verbose"
|
|
1189
|
-
] : [
|
|
1190
|
-
"--no-verbose"
|
|
1191
|
-
];
|
|
1192
|
-
const fixOptions = fix2 ? [
|
|
1193
|
-
"--fix"
|
|
1194
|
-
] : [
|
|
1195
|
-
""
|
|
1196
|
-
];
|
|
1197
|
-
const incrementalOptions = incremental ? [
|
|
1198
|
-
"--since",
|
|
1199
|
-
"-Apt"
|
|
1200
|
-
] : [
|
|
1201
|
-
"--parallel",
|
|
1202
|
-
"-Apt"
|
|
1203
|
-
];
|
|
1204
|
-
const result = runSteps("Lint [All-Packages]", [
|
|
1205
|
-
[
|
|
1206
|
-
"yarn",
|
|
1207
|
-
[
|
|
1208
|
-
"workspaces",
|
|
1209
|
-
"foreach",
|
|
1210
|
-
...verboseOptions,
|
|
1211
|
-
...incrementalOptions,
|
|
1212
|
-
"run",
|
|
1213
|
-
"package-lint",
|
|
1214
|
-
...fixOptions
|
|
1215
|
-
]
|
|
1216
|
-
]
|
|
1217
|
-
]);
|
|
1218
|
-
console.log(`${chalk17.gray("Linted in")} [${chalk17.magenta(((Date.now() - start) / 1e3).toFixed(2))}] ${chalk17.gray("seconds")}`);
|
|
1219
|
-
return result;
|
|
1220
|
-
}, "lintAllPackages");
|
|
1221
|
-
|
|
1222
1212
|
// src/actions/lint-clean.ts
|
|
1223
1213
|
import { rmSync } from "node:fs";
|
|
1224
1214
|
var lintClean = /* @__PURE__ */ __name(async () => {
|