@reliverse/dler 1.2.3 → 1.2.5
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/README.md +14 -30
- package/bin/app/cmds.js +6 -0
- package/bin/app/inject/README.md +20 -20
- package/bin/app/inject/cmd.js +7 -3
- package/bin/app/inject/expect/cmd.js +43 -0
- package/bin/app/inject/expect/impl.js +162 -0
- package/bin/app/relifso/cmd.js +36 -5
- package/bin/app/{rempts/cmd.txt → relifso/init/cmd.js} +93 -121
- package/bin/app/relifso/init/impl/mod.js +248 -0
- package/bin/app/rempts/{impl/index.js → init/cmd/cmd.js} +1 -1
- package/bin/app/rempts/init/cmds/cmd.js +80 -0
- package/bin/app/rempts/migrate/cmd.js +38 -0
- package/bin/app/rempts/migrate/impl/commander.js +265 -0
- package/bin/init.js +4 -0
- package/bin/libs/cfg/cfg-default.js +3 -1
- package/package.json +3 -2
- package/bin/app/auth/cmd.js +0 -0
- package/bin/app/inject/impl/arg-ts-expect-error.txt +0 -49
- package/bin/app/inject/impl/inject-mod.txt +0 -28
- package/bin/app/inject/impl/reinject.config.js +0 -4
- package/bin/app/inject/impl/ts-expect-error.txt +0 -277
- package/bin/app/relifso/impl/reinit-mod.txt +0 -395
- /package/bin/app/relifso/{impl → init/impl}/const.js +0 -0
- /package/bin/app/relifso/{impl → init/impl}/templates/t-gitignore.js +0 -0
- /package/bin/app/relifso/{impl → init/impl}/templates/t-license.js +0 -0
- /package/bin/app/relifso/{impl → init/impl}/templates/t-readme.js +0 -0
- /package/bin/app/relifso/{impl → init/impl}/types.js +0 -0
- /package/bin/app/relifso/{impl → init/impl}/utils.js +0 -0
package/README.md
CHANGED
|
@@ -66,14 +66,6 @@ bun dev # bun src/mod.ts --dev
|
|
|
66
66
|
bun update --latest
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
**or install globally**:
|
|
70
|
-
|
|
71
|
-
```sh
|
|
72
|
-
bun i -g @reliverse/dler
|
|
73
|
-
# or update as needed:
|
|
74
|
-
bun -g update --latest
|
|
75
|
-
```
|
|
76
|
-
|
|
77
69
|
2. **prepare your project**:
|
|
78
70
|
|
|
79
71
|
a. **configure `.gitignore`**:
|
|
@@ -124,7 +116,7 @@ bun dev # bun src/mod.ts --dev
|
|
|
124
116
|
|
|
125
117
|
## 🔌 plugins
|
|
126
118
|
|
|
127
|
-
dler ships with a flexible plugin system and **
|
|
119
|
+
dler ships with a flexible plugin system and **14 built-in plugins** (from [@reliverse/addons](https://reliverse.org/addons)).
|
|
128
120
|
|
|
129
121
|
feel free to create your own plugins. plugins can be implemented as built-in directly in `src/app/plugin-name/impl/*` and then imported from `src/app/plugin-name/cmd.ts`; or implemented in your own library and then imported from `src/app/plugin-name/cmd.ts`.
|
|
130
122
|
|
|
@@ -136,15 +128,7 @@ generates aggregator file with content like `import { getsomething } from "./uti
|
|
|
136
128
|
dler agg ...
|
|
137
129
|
```
|
|
138
130
|
|
|
139
|
-
### 2. `
|
|
140
|
-
|
|
141
|
-
best friend of auth+db libs like [better-auth](https://better-auth.com) and [drizzle-orm](https://orm.drizzle.team).
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
dler auth better-auth generate
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### 3. `build`
|
|
131
|
+
### 2. `build`
|
|
148
132
|
|
|
149
133
|
since dler is fully modular, build command is separated for its own build-in plugin as well.
|
|
150
134
|
|
|
@@ -152,11 +136,11 @@ since dler is fully modular, build command is separated for its own build-in plu
|
|
|
152
136
|
dler build ...
|
|
153
137
|
```
|
|
154
138
|
|
|
155
|
-
###
|
|
139
|
+
### 3. `conv`
|
|
156
140
|
|
|
157
141
|
not yet documented.
|
|
158
142
|
|
|
159
|
-
###
|
|
143
|
+
### 4. `deps`
|
|
160
144
|
|
|
161
145
|
finds missing dependencies in your project by scanning your code for imports and comparing them to your `package.json`.
|
|
162
146
|
|
|
@@ -203,11 +187,11 @@ dler deps --all --directory ./src --include-builtins
|
|
|
203
187
|
missing dependencies are shown only once, even if used in multiple files.
|
|
204
188
|
deep imports like `dep/some/file` or `@org/dep/some/thing` are always resolved to their root package.
|
|
205
189
|
|
|
206
|
-
###
|
|
190
|
+
### 5. `inject`
|
|
207
191
|
|
|
208
192
|
not yet documented.
|
|
209
193
|
|
|
210
|
-
###
|
|
194
|
+
### 6. `libs`
|
|
211
195
|
|
|
212
196
|
builds and publishes specific subdirectories of your main project as standalone packages.
|
|
213
197
|
|
|
@@ -243,15 +227,15 @@ libslist: {
|
|
|
243
227
|
|
|
244
228
|
- more magic commands coming soon...
|
|
245
229
|
|
|
246
|
-
###
|
|
230
|
+
### 7. `merge`
|
|
247
231
|
|
|
248
232
|
not yet documented.
|
|
249
233
|
|
|
250
|
-
###
|
|
234
|
+
### 8. `mono`
|
|
251
235
|
|
|
252
236
|
not yet documented.
|
|
253
237
|
|
|
254
|
-
###
|
|
238
|
+
### 9. `pub`
|
|
255
239
|
|
|
256
240
|
pub command is separated for its own build-in plugin as well.
|
|
257
241
|
|
|
@@ -261,13 +245,13 @@ it already calls build command by itself, so you don't need to run `dler build`
|
|
|
261
245
|
dler pub ...
|
|
262
246
|
```
|
|
263
247
|
|
|
264
|
-
###
|
|
248
|
+
### 10. `relifso`
|
|
265
249
|
|
|
266
250
|
```bash
|
|
267
251
|
dler relifso init ...
|
|
268
252
|
```
|
|
269
253
|
|
|
270
|
-
###
|
|
254
|
+
### 11. `relinka`
|
|
271
255
|
|
|
272
256
|
@reliverse/relinka's best friend. learn more in its [docs](https://github.com/reliverse/relinka).
|
|
273
257
|
|
|
@@ -275,7 +259,7 @@ dler relifso init ...
|
|
|
275
259
|
dler relinka --console-to-relinka
|
|
276
260
|
```
|
|
277
261
|
|
|
278
|
-
###
|
|
262
|
+
### 12. `rempts`
|
|
279
263
|
|
|
280
264
|
@reliverse/rempts's best friend. learn more in its [docs](https://github.com/reliverse/rempts).
|
|
281
265
|
|
|
@@ -284,7 +268,7 @@ dler rempts init --cmd my-cmd-1
|
|
|
284
268
|
dler rempts init --cmds
|
|
285
269
|
```
|
|
286
270
|
|
|
287
|
-
###
|
|
271
|
+
### 13. `spell`
|
|
288
272
|
|
|
289
273
|
**available spell types:**
|
|
290
274
|
|
|
@@ -342,7 +326,7 @@ await dler.spell({ spells: ["rename-file"], files: [] });
|
|
|
342
326
|
|
|
343
327
|
p.s. [see how rse cli uses hooked=true](https://github.com/reliverse/rse/blob/main/src/postbuild.ts)
|
|
344
328
|
|
|
345
|
-
###
|
|
329
|
+
### 14. `tools`
|
|
346
330
|
|
|
347
331
|
lets you run standalone dler features directly from the cli:
|
|
348
332
|
|
package/bin/app/cmds.js
CHANGED
package/bin/app/inject/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dler inject
|
|
2
2
|
|
|
3
|
-
[💖 GitHub Sponsors](https://github.com/sponsors/blefnk) • [💬 Discord](https://discord.gg/Pb8uKbwpsJ) • [📦 NPM](https://npmjs.com/@reliverse/
|
|
3
|
+
[💖 GitHub Sponsors](https://github.com/sponsors/blefnk) • [💬 Discord](https://discord.gg/Pb8uKbwpsJ) • [📦 NPM](https://npmjs.com/@reliverse/inject) • [📚 Docs](https://blefnk.reliverse.org/blog/my-products/inject)
|
|
4
4
|
|
|
5
|
-
**@reliverse/
|
|
5
|
+
**@reliverse/inject** handles the boring parts for you. For example:
|
|
6
6
|
|
|
7
|
-
- ✅ Need to insert `// @ts-expect-error` above a TypeScript error?
|
|
7
|
+
- ✅ Need to insert `// @ts-expect-error` above a TypeScript error? Inject’s got you.
|
|
8
8
|
- 🔜 Fixing repetitive warns, lint suppressions, or compiler nags? One-liner.
|
|
9
9
|
- 🔜 Even more features to come!
|
|
10
10
|
|
|
@@ -23,18 +23,18 @@ Make sure you have Git, Node.js, and bun•pnpm•yarn•npm installed.
|
|
|
23
23
|
### Installation
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
bun i -g @reliverse/
|
|
26
|
+
bun i -g @reliverse/inject
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
Or use with `bun x` (or `npx`):
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
bun x @reliverse/
|
|
32
|
+
bun x @reliverse/inject
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Basic Usage
|
|
36
36
|
|
|
37
|
-
**User config** in `
|
|
37
|
+
**User config** in `inject.config.ts`:
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
40
|
export default {
|
|
@@ -47,15 +47,15 @@ export default {
|
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
# 1) Automatic mode:
|
|
50
|
-
|
|
50
|
+
inject ts-expect-error auto
|
|
51
51
|
# => runs `tsc`, finds errors, injects comment above them.
|
|
52
52
|
|
|
53
53
|
# 2) Lines-file mode:
|
|
54
|
-
|
|
54
|
+
inject ts-expect-error linesA.txt linesB.txt
|
|
55
55
|
# => no TSC, just parses references from lines files
|
|
56
56
|
|
|
57
57
|
# 3) Mixed:
|
|
58
|
-
|
|
58
|
+
inject ts-expect-error auto lines.txt
|
|
59
59
|
# => merges TSC errors with references in lines.txt
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -63,41 +63,41 @@ reinject ts-expect-error auto lines.txt
|
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
65
|
# When you need a custom comment:
|
|
66
|
-
|
|
66
|
+
inject ts-expect-error auto --comment="// @ts-expect-error FIXME"
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
Run on a TypeScript file with tsc output:
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
|
|
72
|
+
inject ts-expect-error src
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
You can also run on a specific TypeScript file with manually generated tsc output:
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
78
|
tsc --noEmit > tsc.log
|
|
79
|
-
|
|
79
|
+
inject tsc.log
|
|
80
80
|
rm tsc.log
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
You can also run it directly on output from stdin:
|
|
84
84
|
|
|
85
85
|
```bash
|
|
86
|
-
tsc --noEmit |
|
|
86
|
+
tsc --noEmit | inject
|
|
87
87
|
```
|
|
88
88
|
|
|
89
89
|
Or use with other tools:
|
|
90
90
|
|
|
91
91
|
```bash
|
|
92
|
-
eslint . |
|
|
93
|
-
biome check . |
|
|
92
|
+
eslint . | inject
|
|
93
|
+
biome check . | inject
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
### Filter by error code or rule ID
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
inject tsc.log --code TS2322
|
|
100
|
+
inject eslint.log --rule no-unused-vars
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
## ✨ Examples
|
|
@@ -137,9 +137,9 @@ const x: string = 123;
|
|
|
137
137
|
|
|
138
138
|
## 🫶 Show some love
|
|
139
139
|
|
|
140
|
-
If `@reliverse/
|
|
140
|
+
If `@reliverse/inject` saved you time or sanity:
|
|
141
141
|
|
|
142
|
-
- ⭐ [Star the repo](https://github.com/reliverse/
|
|
142
|
+
- ⭐ [Star the repo](https://github.com/reliverse/inject)
|
|
143
143
|
- 💖 [Sponsor on GitHub](https://github.com/sponsors/blefnk)
|
|
144
144
|
- 🫶 Share it with a dev friend!
|
|
145
145
|
|
package/bin/app/inject/cmd.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { relinka } from "@reliverse/relinka";
|
|
2
|
-
import { defineCommand, selectPrompt } from "@reliverse/rempts";
|
|
2
|
+
import { defineCommand, runCmd, selectPrompt } from "@reliverse/rempts";
|
|
3
|
+
import { getCmdInjectTsExpectError } from "../cmds.js";
|
|
3
4
|
export default defineCommand({
|
|
4
5
|
meta: {
|
|
5
6
|
name: "cli",
|
|
6
|
-
description: "Runs the
|
|
7
|
+
description: "Runs the Inject command interactive menu (displays list of available commands)"
|
|
7
8
|
},
|
|
8
9
|
args: {
|
|
9
10
|
dev: {
|
|
@@ -19,7 +20,7 @@ export default defineCommand({
|
|
|
19
20
|
run: async ({ args }) => {
|
|
20
21
|
const isDev = args.dev;
|
|
21
22
|
relinka("verbose", `Running in ${isDev ? "dev" : "prod"} mode`);
|
|
22
|
-
await selectPrompt({
|
|
23
|
+
const cmd = await selectPrompt({
|
|
23
24
|
title: "Select a command",
|
|
24
25
|
options: [
|
|
25
26
|
{
|
|
@@ -28,5 +29,8 @@ export default defineCommand({
|
|
|
28
29
|
}
|
|
29
30
|
]
|
|
30
31
|
});
|
|
32
|
+
if (cmd === "ts-expect-error") {
|
|
33
|
+
await runCmd(await getCmdInjectTsExpectError(), []);
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import { defineArgs, defineCommand } from "@reliverse/rempts";
|
|
3
|
+
import { useTsExpectError } from "./impl.js";
|
|
4
|
+
export default defineCommand({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "expect",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
description: "Inject `@ts-expect-error` above lines where TS errors occur"
|
|
9
|
+
},
|
|
10
|
+
args: defineArgs({
|
|
11
|
+
dev: {
|
|
12
|
+
type: "boolean",
|
|
13
|
+
description: "Run the CLI in dev mode"
|
|
14
|
+
},
|
|
15
|
+
files: {
|
|
16
|
+
type: "positional",
|
|
17
|
+
description: `'auto' or path(s) to line references file(s)`,
|
|
18
|
+
default: "auto"
|
|
19
|
+
},
|
|
20
|
+
comment: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "Override the comment line to insert. Default is `// @ts-expect-error TODO: fix ts`"
|
|
23
|
+
},
|
|
24
|
+
tscPaths: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "Optional: specify path(s) to restrict TSC processing (only effective when using 'auto')"
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
async run({ args }) {
|
|
30
|
+
if (args.dev) {
|
|
31
|
+
relinka("verbose", "Using dev mode");
|
|
32
|
+
}
|
|
33
|
+
let pathsTsc = args.tscPaths;
|
|
34
|
+
if (pathsTsc === void 0 && args.files === "auto") {
|
|
35
|
+
pathsTsc = "./tsconfig.json";
|
|
36
|
+
}
|
|
37
|
+
await useTsExpectError({
|
|
38
|
+
files: [args.files],
|
|
39
|
+
comment: args.comment,
|
|
40
|
+
tscPaths: [pathsTsc]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import path from "pathe";
|
|
5
|
+
function parseCommand(command) {
|
|
6
|
+
const regex = /"([^"]+)"|'([^']+)'|(\S+)/g;
|
|
7
|
+
const args = [];
|
|
8
|
+
let match;
|
|
9
|
+
while (regex.exec(command) !== null) {
|
|
10
|
+
match = regex.exec(command);
|
|
11
|
+
if (match) {
|
|
12
|
+
const value = match[1] ?? match[2] ?? match[3];
|
|
13
|
+
if (value) {
|
|
14
|
+
args.push(value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const cmd = args.shift() ?? "";
|
|
19
|
+
return { cmd, args };
|
|
20
|
+
}
|
|
21
|
+
async function parseLinesFile(linesFile) {
|
|
22
|
+
const fileContents = await fs.readFile(linesFile, "utf-8");
|
|
23
|
+
const splitted = fileContents.split(/\r?\n/);
|
|
24
|
+
const results = [];
|
|
25
|
+
for (const rawLine of splitted) {
|
|
26
|
+
const trimmed = rawLine.trim();
|
|
27
|
+
if (!trimmed) continue;
|
|
28
|
+
const firstMatch = trimmed.match(/^(\d+)\s+(.+?):(\d+)$/);
|
|
29
|
+
if (firstMatch?.[2] && firstMatch?.[3]) {
|
|
30
|
+
results.push({
|
|
31
|
+
filePath: firstMatch[2],
|
|
32
|
+
lineNumber: Number.parseInt(firstMatch[3], 10)
|
|
33
|
+
});
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const secondMatch = trimmed.match(/^(.+?):(\d+)$/);
|
|
37
|
+
if (secondMatch?.[1] && secondMatch?.[2]) {
|
|
38
|
+
results.push({
|
|
39
|
+
filePath: secondMatch[1],
|
|
40
|
+
lineNumber: Number.parseInt(secondMatch[2], 10)
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
relinka("warn", `Line doesn't match expected format: ${trimmed}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return results;
|
|
47
|
+
}
|
|
48
|
+
async function runTscAndParseErrors(tscCommand, tscPaths) {
|
|
49
|
+
try {
|
|
50
|
+
const { cmd, args: cmdArgs } = parseCommand(tscCommand);
|
|
51
|
+
if (tscPaths?.length) {
|
|
52
|
+
cmdArgs.push(...tscPaths);
|
|
53
|
+
}
|
|
54
|
+
const subprocess = await execa(cmd, cmdArgs, { all: true, reject: false });
|
|
55
|
+
const combinedOutput = subprocess.all ?? "";
|
|
56
|
+
return parseErrorOutput(combinedOutput);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (error && typeof error === "object" && "all" in error) {
|
|
59
|
+
const combined = error.all ?? "";
|
|
60
|
+
if (!combined) {
|
|
61
|
+
relinka("log", "TSC returned no error lines. Possibly no TS errors?");
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
return parseErrorOutput(combined);
|
|
65
|
+
}
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function parseErrorOutput(output) {
|
|
70
|
+
const results = [];
|
|
71
|
+
const splitted = output.split(/\r?\n/);
|
|
72
|
+
const regex = /^(.+?)\((\d+),(\d+)\): error TS\d+: /;
|
|
73
|
+
for (const line of splitted) {
|
|
74
|
+
const match = line.trim().match(regex);
|
|
75
|
+
if (match?.[1] && match?.[2]) {
|
|
76
|
+
const file = match[1].replace(/\\/g, "/");
|
|
77
|
+
const row = Number.parseInt(match[2], 10);
|
|
78
|
+
if (row > 0) {
|
|
79
|
+
results.push({ filePath: file, lineNumber: row });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return results;
|
|
84
|
+
}
|
|
85
|
+
function isWithin(filePath, dirs) {
|
|
86
|
+
const absFile = path.resolve(filePath);
|
|
87
|
+
return dirs.some((dir) => {
|
|
88
|
+
const absDir = path.resolve(dir);
|
|
89
|
+
const normalizedDir = absDir.endsWith(path.sep) ? absDir : absDir + path.sep;
|
|
90
|
+
return absFile.startsWith(normalizedDir);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function injectCommentIntoFiles(linesRecords, commentText) {
|
|
94
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
95
|
+
for (const rec of linesRecords) {
|
|
96
|
+
const lines = byFile.get(rec.filePath) ?? [];
|
|
97
|
+
lines.push(rec.lineNumber);
|
|
98
|
+
byFile.set(rec.filePath, lines);
|
|
99
|
+
}
|
|
100
|
+
for (const [filePath, lineNums] of byFile.entries()) {
|
|
101
|
+
lineNums.sort((a, b) => b - a);
|
|
102
|
+
const absPath = path.resolve(filePath);
|
|
103
|
+
relinka(
|
|
104
|
+
"log",
|
|
105
|
+
`Injecting into ${absPath} at lines: ${lineNums.join(", ")}`
|
|
106
|
+
);
|
|
107
|
+
try {
|
|
108
|
+
const original = await fs.readFile(absPath, "utf-8");
|
|
109
|
+
const splitted = original.split(/\r?\n/);
|
|
110
|
+
for (const ln of lineNums) {
|
|
111
|
+
if (ln <= splitted.length) {
|
|
112
|
+
splitted.splice(ln - 1, 0, commentText);
|
|
113
|
+
} else {
|
|
114
|
+
relinka("warn", `Line ${ln} exceeds file length for ${absPath}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const newContent = splitted.join("\n");
|
|
118
|
+
await fs.writeFile(absPath, newContent, "utf-8");
|
|
119
|
+
} catch (error) {
|
|
120
|
+
relinka("error", `Failed editing ${filePath}: ${error}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export async function useTsExpectError(args) {
|
|
125
|
+
const finalComment = args.comment ?? "// @ts-expect-error TODO: fix ts";
|
|
126
|
+
const tscCommand = "tsc --project ./tsconfig.json --noEmit";
|
|
127
|
+
const lines = [];
|
|
128
|
+
const usedAuto = args.files.some((item) => item.toLowerCase() === "auto");
|
|
129
|
+
if (usedAuto) {
|
|
130
|
+
relinka("log", "Running TSC to discover error lines...");
|
|
131
|
+
try {
|
|
132
|
+
const discovered = await runTscAndParseErrors(tscCommand, args.tscPaths);
|
|
133
|
+
if (args.tscPaths?.length) {
|
|
134
|
+
const filtered = discovered.filter(
|
|
135
|
+
(rec) => args.tscPaths ? isWithin(rec.filePath, args.tscPaths) : true
|
|
136
|
+
);
|
|
137
|
+
lines.push(...filtered);
|
|
138
|
+
} else {
|
|
139
|
+
lines.push(...discovered);
|
|
140
|
+
}
|
|
141
|
+
} catch (error) {
|
|
142
|
+
relinka("error", `Failed running tsc: ${error}`);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const item of args.files) {
|
|
147
|
+
if (item.toLowerCase() === "auto") continue;
|
|
148
|
+
try {
|
|
149
|
+
const recs = await parseLinesFile(item);
|
|
150
|
+
lines.push(...recs);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
relinka("error", `Failed reading lines file ${item}: ${error}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (lines.length === 0) {
|
|
156
|
+
relinka("error", "No references found. Nothing to do.");
|
|
157
|
+
relinka("error", "Lines: ", JSON.stringify(lines));
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
160
|
+
await injectCommentIntoFiles(lines, finalComment);
|
|
161
|
+
relinka("success", "All lines processed successfully.");
|
|
162
|
+
}
|
package/bin/app/relifso/cmd.js
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import { defineCommand, runCmd, selectPrompt } from "@reliverse/rempts";
|
|
3
|
+
import { getCmdRelifsoInit } from "../cmds.js";
|
|
4
|
+
export default defineCommand({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "cli",
|
|
7
|
+
description: "Runs the Relifso helper interactive menu (displays list of available commands)"
|
|
8
|
+
},
|
|
9
|
+
args: {
|
|
10
|
+
dev: {
|
|
11
|
+
type: "boolean",
|
|
12
|
+
description: "Runs the CLI in dev mode"
|
|
13
|
+
},
|
|
14
|
+
cwd: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "The working directory to run the CLI in",
|
|
17
|
+
required: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
run: async ({ args }) => {
|
|
21
|
+
const isDev = args.dev;
|
|
22
|
+
relinka("verbose", `Running in ${isDev ? "dev" : "prod"} mode`);
|
|
23
|
+
const cmd = await selectPrompt({
|
|
24
|
+
title: "Select a command",
|
|
25
|
+
options: [
|
|
26
|
+
{
|
|
27
|
+
value: "init",
|
|
28
|
+
label: "Initialize files"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
if (cmd === "init") {
|
|
33
|
+
await runCmd(await getCmdRelifsoInit(), []);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|