@xylabs/ts-scripts-yarn3 4.0.0-rc.10 → 4.0.0-rc.11
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/cycle.mjs +32 -110
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/index.mjs +43 -28
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy-ts.mjs +39 -24
- package/dist/bin/xy-ts.mjs.map +1 -1
- package/dist/bin/xy.mjs +39 -24
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +45 -30
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +39 -24
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +39 -24
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +37 -22
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +5 -4
- package/src/actions/cycle.ts +21 -4
- package/src/types.d.ts +23 -0
- package/src/xy/xyLintCommands.ts +2 -2
package/dist/actions/cycle.mjs
CHANGED
|
@@ -1,119 +1,41 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
-
// src/
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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");
|
|
49
|
-
|
|
50
|
-
// src/lib/safeExit.ts
|
|
51
|
-
var safeExit = /* @__PURE__ */ __name((func, exitOnFail = true) => {
|
|
52
|
-
try {
|
|
53
|
-
const result = func();
|
|
54
|
-
if (result && exitOnFail) {
|
|
55
|
-
process.exit(result);
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
} catch (ex) {
|
|
59
|
-
return processEx(ex);
|
|
60
|
-
}
|
|
61
|
-
}, "safeExit");
|
|
62
|
-
|
|
63
|
-
// src/lib/runSteps.ts
|
|
64
|
-
import { spawnSync } from "node:child_process";
|
|
65
|
-
import { existsSync } from "node:fs";
|
|
66
|
-
import chalk3 from "chalk";
|
|
67
|
-
var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages) => {
|
|
68
|
-
return safeExit(() => {
|
|
69
|
-
const pkgName = process.env.npm_package_name;
|
|
70
|
-
console.log(chalk3.green(`${name} [${pkgName}]`));
|
|
71
|
-
let totalStatus = 0;
|
|
72
|
-
for (const [i, [command, args, config]] of steps.entries()) {
|
|
73
|
-
if (messages?.[i]) {
|
|
74
|
-
console.log(chalk3.gray(messages?.[i]));
|
|
75
|
-
}
|
|
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]}]`);
|
|
4
|
+
// src/actions/cycle.ts
|
|
5
|
+
import { cwd } from "node:process";
|
|
6
|
+
import { ESLint } from "eslint";
|
|
7
|
+
import importPlugin from "eslint-plugin-import";
|
|
8
|
+
var cycle = /* @__PURE__ */ __name(async () => {
|
|
9
|
+
const eslint = new ESLint({
|
|
10
|
+
fix: false,
|
|
11
|
+
overrideConfig: {
|
|
12
|
+
plugins: {
|
|
13
|
+
import: importPlugin
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
"import/no-cycle": [
|
|
17
|
+
"error",
|
|
18
|
+
{
|
|
19
|
+
maxDepth: 10
|
|
20
|
+
}
|
|
21
|
+
]
|
|
79
22
|
}
|
|
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
23
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const rules = [
|
|
100
|
-
`"'import/no-cycle': [1, { maxDepth: 6 }]"`,
|
|
101
|
-
`"'import/no-internal-modules': ['off']"`
|
|
102
|
-
];
|
|
103
|
-
return runSteps("Cycle", [
|
|
104
|
-
[
|
|
105
|
-
"yarn",
|
|
106
|
-
[
|
|
107
|
-
"eslint",
|
|
108
|
-
...rules.flatMap((rule) => [
|
|
109
|
-
"--rule",
|
|
110
|
-
rule
|
|
111
|
-
]),
|
|
112
|
-
"--cache",
|
|
113
|
-
"."
|
|
114
|
-
]
|
|
115
|
-
]
|
|
24
|
+
});
|
|
25
|
+
const configFile = await eslint.findConfigFile();
|
|
26
|
+
console.log("Config file:", configFile);
|
|
27
|
+
const results = await eslint.lintFiles([
|
|
28
|
+
"src/**/*.ts*",
|
|
29
|
+
"packages/**/src/**/*.ts*"
|
|
116
30
|
]);
|
|
31
|
+
const formatter = await eslint.loadFormatter("stylish");
|
|
32
|
+
const resultText = formatter.format(results, {
|
|
33
|
+
cwd: cwd(),
|
|
34
|
+
rulesMeta: {}
|
|
35
|
+
});
|
|
36
|
+
console.log(resultText);
|
|
37
|
+
console.log("Lint Errors:", results.length);
|
|
38
|
+
return results.length;
|
|
117
39
|
}, "cycle");
|
|
118
40
|
export {
|
|
119
41
|
cycle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/actions/cycle.ts"],"sourcesContent":["import { cwd } from 'node:process'\n\nimport { ESLint } from 'eslint'\nimport importPlugin from 'eslint-plugin-import'\n\nexport const cycle = async () => {\n const eslint = new ESLint({ fix: false, overrideConfig: {\n plugins: { import: importPlugin },\n rules: {\n 'import/no-cycle': ['error', { maxDepth: 10 }],\n },\n } })\n const configFile = await eslint.findConfigFile()\n console.log('Config file:', configFile)\n const results = await eslint.lintFiles(['src/**/*.ts*', 'packages/**/src/**/*.ts*'])\n\n const formatter = await eslint.loadFormatter('stylish')\n const resultText = formatter.format(results, { cwd: cwd(), rulesMeta: {} })\n console.log(resultText)\n\n console.log('Lint Errors:', results.length)\n return results.length\n}\n"],"mappings":";;;;AAAA,SAASA,WAAW;AAEpB,SAASC,cAAc;AACvB,OAAOC,kBAAkB;AAElB,IAAMC,QAAQ,mCAAA;AACnB,QAAMC,SAAS,IAAIC,OAAO;IAAEC,KAAK;IAAOC,gBAAgB;MACtDC,SAAS;QAAEC,QAAQC;MAAa;MAChCC,OAAO;QACL,mBAAmB;UAAC;UAAS;YAAEC,UAAU;UAAG;;MAC9C;IACF;EAAE,CAAA;AACF,QAAMC,aAAa,MAAMT,OAAOU,eAAc;AAC9CC,UAAQC,IAAI,gBAAgBH,UAAAA;AAC5B,QAAMI,UAAU,MAAMb,OAAOc,UAAU;IAAC;IAAgB;GAA2B;AAEnF,QAAMC,YAAY,MAAMf,OAAOgB,cAAc,SAAA;AAC7C,QAAMC,aAAaF,UAAUG,OAAOL,SAAS;IAAEM,KAAKA,IAAAA;IAAOC,WAAW,CAAC;EAAE,CAAA;AACzET,UAAQC,IAAIK,UAAAA;AAEZN,UAAQC,IAAI,gBAAgBC,QAAQQ,MAAM;AAC1C,SAAOR,QAAQQ;AACjB,GAjBqB;","names":["cwd","ESLint","importPlugin","cycle","eslint","ESLint","fix","overrideConfig","plugins","import","importPlugin","rules","maxDepth","configFile","findConfigFile","console","log","results","lintFiles","formatter","loadFormatter","resultText","format","cwd","rulesMeta","length"]}
|
package/dist/actions/index.mjs
CHANGED
|
@@ -292,7 +292,7 @@ var mergeEntries = /* @__PURE__ */ __name((a, b) => [
|
|
|
292
292
|
].sort(), "mergeEntries");
|
|
293
293
|
var generateIgnoreFiles = /* @__PURE__ */ __name((filename3, pkg) => {
|
|
294
294
|
console.log(chalk4.green(`Generate ${filename3} Files`));
|
|
295
|
-
const
|
|
295
|
+
const cwd4 = INIT_CWD() ?? ".";
|
|
296
296
|
const workspaces = pkg ? [
|
|
297
297
|
yarnWorkspace(pkg)
|
|
298
298
|
] : yarnWorkspaces();
|
|
@@ -300,7 +300,7 @@ var generateIgnoreFiles = /* @__PURE__ */ __name((filename3, pkg) => {
|
|
|
300
300
|
const writeEntries = /* @__PURE__ */ __name((location, entries) => writeLines(`${location}/${filename3}`, entries), "writeEntries");
|
|
301
301
|
const results = workspaces.map(({ location, name }) => {
|
|
302
302
|
try {
|
|
303
|
-
writeEntries(location, mergeEntries(readEntries(
|
|
303
|
+
writeEntries(location, mergeEntries(readEntries(cwd4), readEntries(location)));
|
|
304
304
|
return 0;
|
|
305
305
|
} catch (ex) {
|
|
306
306
|
const error = ex;
|
|
@@ -678,25 +678,40 @@ var copyAssets = /* @__PURE__ */ __name(async ({ target, pkg }) => {
|
|
|
678
678
|
}, "copyAssets");
|
|
679
679
|
|
|
680
680
|
// src/actions/cycle.ts
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
681
|
+
import { cwd } from "node:process";
|
|
682
|
+
import { ESLint } from "eslint";
|
|
683
|
+
import importPlugin from "eslint-plugin-import";
|
|
684
|
+
var cycle = /* @__PURE__ */ __name(async () => {
|
|
685
|
+
const eslint = new ESLint({
|
|
686
|
+
fix: false,
|
|
687
|
+
overrideConfig: {
|
|
688
|
+
plugins: {
|
|
689
|
+
import: importPlugin
|
|
690
|
+
},
|
|
691
|
+
rules: {
|
|
692
|
+
"import/no-cycle": [
|
|
693
|
+
"error",
|
|
694
|
+
{
|
|
695
|
+
maxDepth: 10
|
|
696
|
+
}
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
const configFile = await eslint.findConfigFile();
|
|
702
|
+
console.log("Config file:", configFile);
|
|
703
|
+
const results = await eslint.lintFiles([
|
|
704
|
+
"src/**/*.ts*",
|
|
705
|
+
"packages/**/src/**/*.ts*"
|
|
699
706
|
]);
|
|
707
|
+
const formatter = await eslint.loadFormatter("stylish");
|
|
708
|
+
const resultText = formatter.format(results, {
|
|
709
|
+
cwd: cwd(),
|
|
710
|
+
rulesMeta: {}
|
|
711
|
+
});
|
|
712
|
+
console.log(resultText);
|
|
713
|
+
console.log("Lint Errors:", results.length);
|
|
714
|
+
return results.length;
|
|
700
715
|
}, "cycle");
|
|
701
716
|
|
|
702
717
|
// src/actions/dead.ts
|
|
@@ -1109,7 +1124,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1109
1124
|
|
|
1110
1125
|
// src/actions/lint.ts
|
|
1111
1126
|
import chalk17 from "chalk";
|
|
1112
|
-
import { ESLint } from "eslint";
|
|
1127
|
+
import { ESLint as ESLint2 } from "eslint";
|
|
1113
1128
|
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
1114
1129
|
const colors = [
|
|
1115
1130
|
"white",
|
|
@@ -1136,7 +1151,7 @@ var lintPackage = /* @__PURE__ */ __name(async ({ pkg }) => {
|
|
|
1136
1151
|
console.error(chalk17.red(`Unable to locate package [${chalk17.magenta(pkg)}]`));
|
|
1137
1152
|
process.exit(1);
|
|
1138
1153
|
}
|
|
1139
|
-
const engine = new
|
|
1154
|
+
const engine = new ESLint2({
|
|
1140
1155
|
cache: true
|
|
1141
1156
|
});
|
|
1142
1157
|
const lintResults = await engine.lintFiles(workspace.location);
|
|
@@ -1144,7 +1159,7 @@ var lintPackage = /* @__PURE__ */ __name(async ({ pkg }) => {
|
|
|
1144
1159
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1145
1160
|
}, "lintPackage");
|
|
1146
1161
|
var lintAll = /* @__PURE__ */ __name(async () => {
|
|
1147
|
-
const engine = new
|
|
1162
|
+
const engine = new ESLint2({
|
|
1148
1163
|
cache: true
|
|
1149
1164
|
});
|
|
1150
1165
|
const lintResults = await engine.lintFiles("./**/*.*");
|
|
@@ -1298,7 +1313,7 @@ var packagePublint = /* @__PURE__ */ __name(async (params) => {
|
|
|
1298
1313
|
}, "packagePublint");
|
|
1299
1314
|
|
|
1300
1315
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1301
|
-
import { cwd } from "node:process";
|
|
1316
|
+
import { cwd as cwd2 } from "node:process";
|
|
1302
1317
|
import chalk21 from "chalk";
|
|
1303
1318
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1304
1319
|
import { DiagnosticCategory, formatDiagnosticsWithColorAndContext, getLineAndCharacterOfPosition, getPreEmitDiagnostics } from "typescript";
|
|
@@ -1330,7 +1345,7 @@ var getCompilerOptions = /* @__PURE__ */ __name((options, tsconfig = "tsconfig.j
|
|
|
1330
1345
|
|
|
1331
1346
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1332
1347
|
var packageCompileTsc = /* @__PURE__ */ __name(async (noEmit, config2, compilerOptionsParam) => {
|
|
1333
|
-
const pkg = process.env.INIT_CWD ??
|
|
1348
|
+
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1334
1349
|
const publint2 = config2?.publint ?? true;
|
|
1335
1350
|
const verbose = config2?.verbose ?? false;
|
|
1336
1351
|
const formatHost = {
|
|
@@ -1353,7 +1368,7 @@ var packageCompileTsc = /* @__PURE__ */ __name(async (noEmit, config2, compilerO
|
|
|
1353
1368
|
}
|
|
1354
1369
|
};
|
|
1355
1370
|
const program = createProgramFromConfig({
|
|
1356
|
-
basePath: pkg ??
|
|
1371
|
+
basePath: pkg ?? cwd2(),
|
|
1357
1372
|
compilerOptions,
|
|
1358
1373
|
exclude: [
|
|
1359
1374
|
"dist",
|
|
@@ -1606,7 +1621,7 @@ var packageCopyAssets = /* @__PURE__ */ __name(async ({ target }) => {
|
|
|
1606
1621
|
|
|
1607
1622
|
// src/actions/package/deps.ts
|
|
1608
1623
|
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
|
|
1609
|
-
import { cwd as
|
|
1624
|
+
import { cwd as cwd3 } from "node:process";
|
|
1610
1625
|
import chalk24 from "chalk";
|
|
1611
1626
|
import depcheck from "depcheck";
|
|
1612
1627
|
var special = depcheck.special;
|
|
@@ -1703,7 +1718,7 @@ var analyzeDeps = /* @__PURE__ */ __name(async (pkg, ignoreMatches) => {
|
|
|
1703
1718
|
};
|
|
1704
1719
|
}, "analyzeDeps");
|
|
1705
1720
|
var packageDeps = /* @__PURE__ */ __name(async () => {
|
|
1706
|
-
const pkg = process.env.INIT_CWD ??
|
|
1721
|
+
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1707
1722
|
const pkgName = process.env.npm_package_name;
|
|
1708
1723
|
const packageContent = existsSync4(`${pkg}/package.json`) ? JSON.parse(readFileSync3(`${pkg}/package.json`, {
|
|
1709
1724
|
encoding: "utf8"
|