@travetto/lint 8.0.0-alpha.27 → 8.0.0-alpha.28
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/package.json +1 -1
- package/support/cli.lint_register.ts +20 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
2
|
|
|
3
|
-
import { CliCommand, type CliCommandShape } from
|
|
4
|
-
import { Runtime } from
|
|
3
|
+
import { CliCommand, type CliCommandShape } from "@travetto/cli";
|
|
4
|
+
import { Runtime, RuntimeIndex } from "@travetto/runtime";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Generate the workspace oxlint, oxfmt, and cspell configuration entry files.
|
|
@@ -11,43 +11,48 @@ import { Runtime } from '@travetto/runtime';
|
|
|
11
11
|
@CliCommand({})
|
|
12
12
|
export class LintRegisterCommand implements CliCommandShape {
|
|
13
13
|
async main(): Promise<void> {
|
|
14
|
+
const PREAMBLE = `process.env.TRV_MANIFEST= '${Runtime.stripWorkspacePath(Runtime.workspaceRelative(RuntimeIndex.outputRoot, "node_modules", Runtime.workspace.name))}';`;
|
|
15
|
+
|
|
14
16
|
// Bootstrap oxlint configuration
|
|
15
|
-
const oxlintOutput = Runtime.workspaceRelative(
|
|
17
|
+
const oxlintOutput = Runtime.workspaceRelative("oxlint.config.js");
|
|
16
18
|
if (!(await fs.stat(oxlintOutput, { throwIfNoEntry: false }))) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
+
const entry = RuntimeIndex.getFromImport("@travetto/lint/support/oxlint");
|
|
20
|
+
const content = `${PREAMBLE}
|
|
21
|
+
const { oxlintConfig } = await import('${Runtime.stripWorkspacePath(entry!.outputFile)}');
|
|
19
22
|
export default oxlintConfig();
|
|
20
23
|
`;
|
|
21
|
-
await fs.writeFile(oxlintOutput,
|
|
24
|
+
await fs.writeFile(oxlintOutput, content);
|
|
22
25
|
console.log(`Wrote lint config to ${oxlintOutput}`);
|
|
23
26
|
} else {
|
|
24
27
|
console.log(`Lint config already present ${oxlintOutput}`);
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
// Bootstrap oxfmt configuration
|
|
28
|
-
const oxfmtOutput = Runtime.workspaceRelative(
|
|
31
|
+
const oxfmtOutput = Runtime.workspaceRelative("oxfmt.config.js");
|
|
29
32
|
if (!(await fs.stat(oxfmtOutput, { throwIfNoEntry: false }))) {
|
|
30
|
-
const
|
|
31
|
-
|
|
33
|
+
const entry = RuntimeIndex.getFromImport("@travetto/lint/support/oxfmt");
|
|
34
|
+
const content = `${PREAMBLE}
|
|
35
|
+
const { oxfmtConfig } = await import('${Runtime.stripWorkspacePath(entry!.outputFile)}');
|
|
32
36
|
export default oxfmtConfig();
|
|
33
37
|
`;
|
|
34
|
-
|
|
38
|
+
|
|
39
|
+
await fs.writeFile(oxfmtOutput, content);
|
|
35
40
|
console.log(`Wrote format config to ${oxfmtOutput}`);
|
|
36
41
|
} else {
|
|
37
42
|
console.log(`Format config already present ${oxfmtOutput}`);
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
// Bootstrap cspell configuration
|
|
41
|
-
const cspellOutput = Runtime.workspaceRelative(
|
|
46
|
+
const cspellOutput = Runtime.workspaceRelative("cspell.json");
|
|
42
47
|
if (!(await fs.stat(cspellOutput, { throwIfNoEntry: false }))) {
|
|
43
48
|
const cspellContent =
|
|
44
49
|
JSON.stringify(
|
|
45
50
|
{
|
|
46
|
-
import: [
|
|
51
|
+
import: ["@travetto/lint/resources/cspell.json"],
|
|
47
52
|
},
|
|
48
53
|
null,
|
|
49
|
-
2
|
|
50
|
-
) +
|
|
54
|
+
2,
|
|
55
|
+
) + "\n";
|
|
51
56
|
await fs.writeFile(cspellOutput, cspellContent);
|
|
52
57
|
console.log(`Wrote cspell config to ${cspellOutput}`);
|
|
53
58
|
} else {
|