@xylabs/ts-scripts-yarn3 4.0.0-rc.10 → 4.0.0-rc.12
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 +25 -110
- package/dist/actions/cycle.mjs.map +1 -1
- package/dist/actions/index.mjs +36 -28
- package/dist/actions/index.mjs.map +1 -1
- package/dist/bin/xy-ts.mjs +32 -24
- package/dist/bin/xy-ts.mjs.map +1 -1
- package/dist/bin/xy.mjs +32 -24
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +38 -30
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +32 -24
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +32 -24
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyLintCommands.mjs +30 -22
- package/dist/xy/xyLintCommands.mjs.map +1 -1
- package/package.json +5 -4
- package/src/actions/cycle.ts +16 -4
- package/src/types.d.ts +23 -0
- package/src/xy/xyLintCommands.ts +2 -2
package/dist/actions/cycle.mjs
CHANGED
|
@@ -1,119 +1,34 @@
|
|
|
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
|
-
import chalk2 from "chalk";
|
|
19
|
-
|
|
20
|
-
// src/lib/withError.ts
|
|
21
|
-
var withError = /* @__PURE__ */ __name((ex, closure, predicate = (ex2) => ex2.name !== void 0 && ex2.message !== void 0) => {
|
|
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
|
+
var cycle = /* @__PURE__ */ __name(async () => {
|
|
8
|
+
const eslint = new ESLint({
|
|
9
|
+
fix: false,
|
|
10
|
+
overrideConfig: {
|
|
11
|
+
rules: {
|
|
12
|
+
"import/no-cycle": [
|
|
13
|
+
"error",
|
|
14
|
+
{
|
|
15
|
+
maxDepth: 10
|
|
16
|
+
}
|
|
17
|
+
]
|
|
79
18
|
}
|
|
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
19
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// src/actions/cycle.ts
|
|
98
|
-
var cycle = /* @__PURE__ */ __name(() => {
|
|
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
|
-
]
|
|
20
|
+
});
|
|
21
|
+
const results = await eslint.lintFiles([
|
|
22
|
+
"src/**/*.ts*",
|
|
23
|
+
"packages/**/src/**/*.ts*"
|
|
116
24
|
]);
|
|
25
|
+
const formatter = await eslint.loadFormatter("stylish");
|
|
26
|
+
const resultText = formatter.format(results, {
|
|
27
|
+
cwd: cwd(),
|
|
28
|
+
rulesMeta: {}
|
|
29
|
+
});
|
|
30
|
+
console.log(resultText);
|
|
31
|
+
return results.length;
|
|
117
32
|
}, "cycle");
|
|
118
33
|
export {
|
|
119
34
|
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'\n\nexport const cycle = async () => {\n const eslint = new ESLint({ fix: false, overrideConfig: {\n rules: {\n 'import/no-cycle': ['error', { maxDepth: 10 }],\n },\n } })\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 return results.length\n}\n"],"mappings":";;;;AAAA,SAASA,WAAW;AAEpB,SAASC,cAAc;AAEhB,IAAMC,QAAQ,mCAAA;AACnB,QAAMC,SAAS,IAAIC,OAAO;IAAEC,KAAK;IAAOC,gBAAgB;MACtDC,OAAO;QACL,mBAAmB;UAAC;UAAS;YAAEC,UAAU;UAAG;;MAC9C;IACF;EAAE,CAAA;AACF,QAAMC,UAAU,MAAMN,OAAOO,UAAU;IAAC;IAAgB;GAA2B;AAEnF,QAAMC,YAAY,MAAMR,OAAOS,cAAc,SAAA;AAC7C,QAAMC,aAAaF,UAAUG,OAAOL,SAAS;IAAEM,KAAKA,IAAAA;IAAOC,WAAW,CAAC;EAAE,CAAA;AACzEC,UAAQC,IAAIL,UAAAA;AAEZ,SAAOJ,QAAQU;AACjB,GAbqB;","names":["cwd","ESLint","cycle","eslint","ESLint","fix","overrideConfig","rules","maxDepth","results","lintFiles","formatter","loadFormatter","resultText","format","cwd","rulesMeta","console","log","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,33 @@ 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
|
+
var cycle = /* @__PURE__ */ __name(async () => {
|
|
684
|
+
const eslint = new ESLint({
|
|
685
|
+
fix: false,
|
|
686
|
+
overrideConfig: {
|
|
687
|
+
rules: {
|
|
688
|
+
"import/no-cycle": [
|
|
689
|
+
"error",
|
|
690
|
+
{
|
|
691
|
+
maxDepth: 10
|
|
692
|
+
}
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
const results = await eslint.lintFiles([
|
|
698
|
+
"src/**/*.ts*",
|
|
699
|
+
"packages/**/src/**/*.ts*"
|
|
699
700
|
]);
|
|
701
|
+
const formatter = await eslint.loadFormatter("stylish");
|
|
702
|
+
const resultText = formatter.format(results, {
|
|
703
|
+
cwd: cwd(),
|
|
704
|
+
rulesMeta: {}
|
|
705
|
+
});
|
|
706
|
+
console.log(resultText);
|
|
707
|
+
return results.length;
|
|
700
708
|
}, "cycle");
|
|
701
709
|
|
|
702
710
|
// src/actions/dead.ts
|
|
@@ -1109,7 +1117,7 @@ var license = /* @__PURE__ */ __name(async (pkg) => {
|
|
|
1109
1117
|
|
|
1110
1118
|
// src/actions/lint.ts
|
|
1111
1119
|
import chalk17 from "chalk";
|
|
1112
|
-
import { ESLint } from "eslint";
|
|
1120
|
+
import { ESLint as ESLint2 } from "eslint";
|
|
1113
1121
|
var dumpMessages = /* @__PURE__ */ __name((lintResults) => {
|
|
1114
1122
|
const colors = [
|
|
1115
1123
|
"white",
|
|
@@ -1136,7 +1144,7 @@ var lintPackage = /* @__PURE__ */ __name(async ({ pkg }) => {
|
|
|
1136
1144
|
console.error(chalk17.red(`Unable to locate package [${chalk17.magenta(pkg)}]`));
|
|
1137
1145
|
process.exit(1);
|
|
1138
1146
|
}
|
|
1139
|
-
const engine = new
|
|
1147
|
+
const engine = new ESLint2({
|
|
1140
1148
|
cache: true
|
|
1141
1149
|
});
|
|
1142
1150
|
const lintResults = await engine.lintFiles(workspace.location);
|
|
@@ -1144,7 +1152,7 @@ var lintPackage = /* @__PURE__ */ __name(async ({ pkg }) => {
|
|
|
1144
1152
|
return lintResults.reduce((prev, lintResult) => prev + lintResult.errorCount, 0);
|
|
1145
1153
|
}, "lintPackage");
|
|
1146
1154
|
var lintAll = /* @__PURE__ */ __name(async () => {
|
|
1147
|
-
const engine = new
|
|
1155
|
+
const engine = new ESLint2({
|
|
1148
1156
|
cache: true
|
|
1149
1157
|
});
|
|
1150
1158
|
const lintResults = await engine.lintFiles("./**/*.*");
|
|
@@ -1298,7 +1306,7 @@ var packagePublint = /* @__PURE__ */ __name(async (params) => {
|
|
|
1298
1306
|
}, "packagePublint");
|
|
1299
1307
|
|
|
1300
1308
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1301
|
-
import { cwd } from "node:process";
|
|
1309
|
+
import { cwd as cwd2 } from "node:process";
|
|
1302
1310
|
import chalk21 from "chalk";
|
|
1303
1311
|
import { createProgramFromConfig } from "tsc-prog";
|
|
1304
1312
|
import { DiagnosticCategory, formatDiagnosticsWithColorAndContext, getLineAndCharacterOfPosition, getPreEmitDiagnostics } from "typescript";
|
|
@@ -1330,7 +1338,7 @@ var getCompilerOptions = /* @__PURE__ */ __name((options, tsconfig = "tsconfig.j
|
|
|
1330
1338
|
|
|
1331
1339
|
// src/actions/package/compile/packageCompileTsc.ts
|
|
1332
1340
|
var packageCompileTsc = /* @__PURE__ */ __name(async (noEmit, config2, compilerOptionsParam) => {
|
|
1333
|
-
const pkg = process.env.INIT_CWD ??
|
|
1341
|
+
const pkg = process.env.INIT_CWD ?? cwd2();
|
|
1334
1342
|
const publint2 = config2?.publint ?? true;
|
|
1335
1343
|
const verbose = config2?.verbose ?? false;
|
|
1336
1344
|
const formatHost = {
|
|
@@ -1353,7 +1361,7 @@ var packageCompileTsc = /* @__PURE__ */ __name(async (noEmit, config2, compilerO
|
|
|
1353
1361
|
}
|
|
1354
1362
|
};
|
|
1355
1363
|
const program = createProgramFromConfig({
|
|
1356
|
-
basePath: pkg ??
|
|
1364
|
+
basePath: pkg ?? cwd2(),
|
|
1357
1365
|
compilerOptions,
|
|
1358
1366
|
exclude: [
|
|
1359
1367
|
"dist",
|
|
@@ -1606,7 +1614,7 @@ var packageCopyAssets = /* @__PURE__ */ __name(async ({ target }) => {
|
|
|
1606
1614
|
|
|
1607
1615
|
// src/actions/package/deps.ts
|
|
1608
1616
|
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
|
|
1609
|
-
import { cwd as
|
|
1617
|
+
import { cwd as cwd3 } from "node:process";
|
|
1610
1618
|
import chalk24 from "chalk";
|
|
1611
1619
|
import depcheck from "depcheck";
|
|
1612
1620
|
var special = depcheck.special;
|
|
@@ -1703,7 +1711,7 @@ var analyzeDeps = /* @__PURE__ */ __name(async (pkg, ignoreMatches) => {
|
|
|
1703
1711
|
};
|
|
1704
1712
|
}, "analyzeDeps");
|
|
1705
1713
|
var packageDeps = /* @__PURE__ */ __name(async () => {
|
|
1706
|
-
const pkg = process.env.INIT_CWD ??
|
|
1714
|
+
const pkg = process.env.INIT_CWD ?? cwd3();
|
|
1707
1715
|
const pkgName = process.env.npm_package_name;
|
|
1708
1716
|
const packageContent = existsSync4(`${pkg}/package.json`) ? JSON.parse(readFileSync3(`${pkg}/package.json`, {
|
|
1709
1717
|
encoding: "utf8"
|