@tacone/prosey 0.2.1 → 0.2.3
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/bin/prosey +113110 -6813
- package/package.json +3 -3
- package/src/config.test.ts +3 -3
- package/src/index.ts +19 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tacone/prosey",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Download YouTube video transcripts from the CLI",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/bun": "latest",
|
|
53
53
|
"husky": "^9.1.7",
|
|
54
|
-
"lint-staged": "^17.0.7"
|
|
55
|
-
"prettier": "^3.8.4"
|
|
54
|
+
"lint-staged": "^17.0.7"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
57
|
"typescript": "^5"
|
|
59
58
|
},
|
|
60
59
|
"dependencies": {
|
|
61
60
|
"js-toml": "^1.1.2",
|
|
61
|
+
"prettier": "^3.8.4",
|
|
62
62
|
"youtube-transcript-plus": "^2.0.0"
|
|
63
63
|
}
|
|
64
64
|
}
|
package/src/config.test.ts
CHANGED
|
@@ -54,7 +54,7 @@ describe("loadConfig", () => {
|
|
|
54
54
|
|
|
55
55
|
const content = await readFile(tmpConfig, "utf8");
|
|
56
56
|
expect(content).toContain("[summarize]");
|
|
57
|
-
expect(content).toContain(
|
|
57
|
+
expect(content).toContain("command = ");
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
test("reads existing config file", async () => {
|
|
@@ -63,7 +63,7 @@ describe("loadConfig", () => {
|
|
|
63
63
|
await loadConfig();
|
|
64
64
|
const config = await loadConfig();
|
|
65
65
|
expect(config.summarize?.prompt).toBeString();
|
|
66
|
-
expect(config.summarize?.command).
|
|
66
|
+
expect(config.summarize?.command).toBeString();
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
test("handles invalid TOML gracefully", async () => {
|
|
@@ -93,6 +93,6 @@ describe("resetConfig", () => {
|
|
|
93
93
|
|
|
94
94
|
const content = await readFile(tmpConfig, "utf8");
|
|
95
95
|
expect(content).toContain("[summarize]");
|
|
96
|
-
expect(content).toContain(
|
|
96
|
+
expect(content).toContain("command = ");
|
|
97
97
|
});
|
|
98
98
|
});
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,11 @@ import type { ProseyConfig } from "./config";
|
|
|
9
9
|
import { summarize } from "./summarize";
|
|
10
10
|
import { cacheDir, readCache, writeCache, extractVideoId } from "./cache";
|
|
11
11
|
import { enableDebug, debug } from "./debug";
|
|
12
|
+
import pkg from "../package.json";
|
|
13
|
+
import prettier from "prettier";
|
|
12
14
|
|
|
13
15
|
const NAME = "prosey";
|
|
14
|
-
const VERSION =
|
|
16
|
+
const VERSION = pkg.version;
|
|
15
17
|
|
|
16
18
|
function help(): string {
|
|
17
19
|
return `${NAME} v${VERSION}
|
|
@@ -41,6 +43,7 @@ Options:
|
|
|
41
43
|
--no-decode-entities Preserve HTML entities (decoded by default).
|
|
42
44
|
--reset-config Reset config file to defaults and exit.
|
|
43
45
|
--no-cache Skip cache and overwrite cache files.
|
|
46
|
+
--no-format Skip prettier formatting.
|
|
44
47
|
--debug Print debug information to stderr.
|
|
45
48
|
--help Show this help message.
|
|
46
49
|
--version Show version.
|
|
@@ -119,6 +122,14 @@ function printLanguages(languages: CaptionTrackInfo[]): void {
|
|
|
119
122
|
console.log(`Available transcripts (${languages.length}):\n${rows.join("\n")}`);
|
|
120
123
|
}
|
|
121
124
|
|
|
125
|
+
async function formatMd(text: string): Promise<string> {
|
|
126
|
+
try {
|
|
127
|
+
return await prettier.format(text, { parser: "markdown" });
|
|
128
|
+
} catch {
|
|
129
|
+
return text;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
122
133
|
const args = process.argv.slice(2);
|
|
123
134
|
|
|
124
135
|
if (args.length === 0 || args.includes("--help")) {
|
|
@@ -155,6 +166,7 @@ let outputJson = false;
|
|
|
155
166
|
let noDecode = false;
|
|
156
167
|
let showDetails = true;
|
|
157
168
|
let noCache = false;
|
|
169
|
+
let noFormat = false;
|
|
158
170
|
let debugMode = false;
|
|
159
171
|
|
|
160
172
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -186,6 +198,8 @@ for (let i = 0; i < args.length; i++) {
|
|
|
186
198
|
showDetails = false;
|
|
187
199
|
} else if (arg === "--no-cache") {
|
|
188
200
|
noCache = true;
|
|
201
|
+
} else if (arg === "--no-format") {
|
|
202
|
+
noFormat = true;
|
|
189
203
|
} else if (arg === "--debug") {
|
|
190
204
|
debugMode = true;
|
|
191
205
|
} else if (arg === "--no-decode-entities") {
|
|
@@ -279,10 +293,12 @@ try {
|
|
|
279
293
|
debug("Cache written: summary.md");
|
|
280
294
|
}
|
|
281
295
|
|
|
296
|
+
const formatted = noFormat ? summary : await formatMd(summary);
|
|
297
|
+
|
|
282
298
|
if (outputPath) {
|
|
283
|
-
await writeFile(outputPath,
|
|
299
|
+
await writeFile(outputPath, formatted, "utf8");
|
|
284
300
|
} else {
|
|
285
|
-
console.log(
|
|
301
|
+
console.log(formatted);
|
|
286
302
|
}
|
|
287
303
|
process.exit(0);
|
|
288
304
|
} else if (listOnly) {
|