@boy-offi9-inc/tidepull 0.17.0 → 0.17.2
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/cli-plugin.js +6 -4
- package/dist/loader.js +17 -3
- package/dist/main.js +6 -3
- package/package.json +1 -1
package/dist/cli-plugin.js
CHANGED
|
@@ -43,12 +43,14 @@ export async function pluginInstall(pkg, pluginDir, log, env = process.env) {
|
|
|
43
43
|
}
|
|
44
44
|
const entry = pluginEntryFile(pkgDir);
|
|
45
45
|
const stagePkg = path.join(staging, safe, "package.json");
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
try {
|
|
47
|
+
const meta2 = existsSync(stagePkg) ? JSON.parse(readFileSync(stagePkg, "utf8")) : {};
|
|
48
|
+
if (meta2.type !== "module") {
|
|
49
|
+
meta2.type = "module";
|
|
50
|
+
writeFileSync(stagePkg, JSON.stringify(meta2) + "\n");
|
|
49
51
|
}
|
|
50
|
-
catch { }
|
|
51
52
|
}
|
|
53
|
+
catch { }
|
|
52
54
|
const work = path.join(staging, safe, name.split("/").pop().replace(/[^\w.-]/g, "_") + path.extname(entry));
|
|
53
55
|
copyFileSync(entry, work);
|
|
54
56
|
const dest = path.join(pluginDir, name.split("/").pop().replace(/[^.\w-]/g, "_") + path.extname(entry));
|
package/dist/loader.js
CHANGED
|
@@ -55,12 +55,26 @@ function ensureModuleType(dir) {
|
|
|
55
55
|
}
|
|
56
56
|
export async function loadPlugins(paths) {
|
|
57
57
|
const out = [];
|
|
58
|
+
const seen = new Map();
|
|
59
|
+
const warn = (msg) => { try {
|
|
60
|
+
process.stderr.write(`WARNING: ${msg}\n`);
|
|
61
|
+
}
|
|
62
|
+
catch { } };
|
|
63
|
+
const keep = (p, file) => {
|
|
64
|
+
const prev = seen.get(p.name);
|
|
65
|
+
if (prev !== undefined) {
|
|
66
|
+
warn(`duplicate plugin "${p.name}": ${file} ignored — already loaded from ${prev} (remove one of the two files)`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
seen.set(p.name, file);
|
|
70
|
+
out.push(p);
|
|
71
|
+
};
|
|
58
72
|
for (const p of paths) {
|
|
59
73
|
const s = await stat(p).catch(() => undefined);
|
|
60
74
|
if (!s)
|
|
61
75
|
throw new TidepullError(`Plugin path not found: ${p}`);
|
|
62
76
|
if (s.isFile()) {
|
|
63
|
-
|
|
77
|
+
keep(await loadPlugin(p), p);
|
|
64
78
|
continue;
|
|
65
79
|
}
|
|
66
80
|
ensureModuleType(p);
|
|
@@ -70,11 +84,11 @@ export async function loadPlugins(paths) {
|
|
|
70
84
|
const full = path.join(p, name);
|
|
71
85
|
const fs = await stat(full);
|
|
72
86
|
if (fs.isFile() && FILE_RE.test(name))
|
|
73
|
-
|
|
87
|
+
keep(await loadPlugin(full), full);
|
|
74
88
|
else if (fs.isDirectory()) {
|
|
75
89
|
const idx = (await readdir(full)).find((f) => INDEX_RE.test(f));
|
|
76
90
|
if (idx)
|
|
77
|
-
|
|
91
|
+
keep(await loadPlugin(path.join(full, idx)), path.join(full, idx));
|
|
78
92
|
}
|
|
79
93
|
}
|
|
80
94
|
}
|
package/dist/main.js
CHANGED
|
@@ -3,6 +3,7 @@ import { DEFAULT_FORMAT, selectFormats } from "./core/selector.js";
|
|
|
3
3
|
import { TidepullError, errMsg } from "./core/errors.js";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { homedir } from "node:os";
|
|
6
7
|
import { isPlaylist } from "./core/pipeline.js";
|
|
7
8
|
import { Archive, configArgs, parseRate, readUrlList } from "./cliutil.js";
|
|
8
9
|
import { cookieJar, loadCookieFile } from "./cookies.js";
|
|
@@ -323,13 +324,15 @@ export async function main(argv) {
|
|
|
323
324
|
const dim = (s) => paint(theme.dim, s);
|
|
324
325
|
const ok = (s) => paint(theme.success, s);
|
|
325
326
|
const ff = ffmpegProbe();
|
|
327
|
+
const shortDir = defDir.startsWith(homedir())
|
|
328
|
+
? `~${defDir.slice(homedir().length)}`
|
|
329
|
+
: defDir;
|
|
326
330
|
process.stderr.write([
|
|
327
331
|
"",
|
|
328
|
-
dim(
|
|
329
|
-
dim("more") + " " + dim("'tidepull --help' for every option · github.com/boy-offi9-inc/Tidepull"),
|
|
332
|
+
dim(`${ok(ff)} · ${plugins.length} plugin${plugins.length === 1 ? "" : "s"} · ${shortDir}`),
|
|
330
333
|
"",
|
|
331
334
|
].join("\n"));
|
|
332
|
-
|
|
335
|
+
process.stderr.write(dim("give it a URL: tidepull <url>\n"));
|
|
333
336
|
return 2;
|
|
334
337
|
}
|
|
335
338
|
const tp = createTidepull({
|
package/package.json
CHANGED