@pollinations/cli 0.1.38 → 0.1.39
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/index.js +28 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var init_package = __esm({
|
|
|
14
14
|
"package.json"() {
|
|
15
15
|
package_default = {
|
|
16
16
|
name: "@pollinations/cli",
|
|
17
|
-
version: "0.1.
|
|
17
|
+
version: "0.1.39",
|
|
18
18
|
description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
|
|
19
19
|
type: "module",
|
|
20
20
|
bin: {
|
|
@@ -1479,10 +1479,20 @@ function createImageCommand() {
|
|
|
1479
1479
|
}
|
|
1480
1480
|
|
|
1481
1481
|
// src/commands/gen/isolate.ts
|
|
1482
|
-
import {
|
|
1482
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
1483
1483
|
import { basename, dirname as dirname3 } from "path";
|
|
1484
1484
|
import { Command as Command9 } from "commander";
|
|
1485
1485
|
|
|
1486
|
+
// src/lib/input-file.ts
|
|
1487
|
+
init_output();
|
|
1488
|
+
import { statSync } from "fs";
|
|
1489
|
+
var requireFile = (path) => {
|
|
1490
|
+
const stats = statSync(path, { throwIfNoEntry: false });
|
|
1491
|
+
if (!stats) return fail(`File not found: ${path}`);
|
|
1492
|
+
if (stats.isDirectory()) return fail(`Not a file: ${path}`);
|
|
1493
|
+
return stats.size;
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1486
1496
|
// src/lib/mime.ts
|
|
1487
1497
|
import { extname } from "path";
|
|
1488
1498
|
var MIME_BY_EXT = {
|
|
@@ -1516,9 +1526,7 @@ function createIsolateCommand() {
|
|
|
1516
1526
|
"Remove music and background noise from a local audio or video file"
|
|
1517
1527
|
).argument("<file>", "Source audio or video file path").option("--model <model>", "Voice-isolation model").option("--output <path>", "Save to file", "isolated.mp3").action(async (file, opts) => {
|
|
1518
1528
|
const isHuman = getOutputMode() === "human";
|
|
1519
|
-
|
|
1520
|
-
fail(`File not found: ${file}`);
|
|
1521
|
-
}
|
|
1529
|
+
requireFile(file);
|
|
1522
1530
|
const formData = new FormData();
|
|
1523
1531
|
formData.append(
|
|
1524
1532
|
"audio",
|
|
@@ -1791,6 +1799,7 @@ function createTranscribeCommand() {
|
|
|
1791
1799
|
"whisper"
|
|
1792
1800
|
).option("--language <lang>", "Language hint (ISO code)").action(async (file, opts) => {
|
|
1793
1801
|
const isHuman = getOutputMode() === "human";
|
|
1802
|
+
requireFile(file);
|
|
1794
1803
|
if (isHuman) printInfo("Transcribing...");
|
|
1795
1804
|
try {
|
|
1796
1805
|
const buffer = readFileSync4(file);
|
|
@@ -1863,7 +1872,7 @@ function createVideoCommand() {
|
|
|
1863
1872
|
}
|
|
1864
1873
|
|
|
1865
1874
|
// src/commands/gen/voice-change.ts
|
|
1866
|
-
import {
|
|
1875
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
1867
1876
|
import { basename as basename3, dirname as dirname7 } from "path";
|
|
1868
1877
|
import { Command as Command14 } from "commander";
|
|
1869
1878
|
init_output();
|
|
@@ -1875,9 +1884,7 @@ function createVoiceChangeCommand() {
|
|
|
1875
1884
|
).option("--model <model>", "Voice-change model").option("--format <fmt>", "mp3/opus/aac/wav/pcm", "mp3").option("--output <path>", "Save to file").action(async (file, opts) => {
|
|
1876
1885
|
const isHuman = getOutputMode() === "human";
|
|
1877
1886
|
const output = opts.output ?? `voice.${opts.format}`;
|
|
1878
|
-
|
|
1879
|
-
fail(`File not found: ${file}`);
|
|
1880
|
-
}
|
|
1887
|
+
requireFile(file);
|
|
1881
1888
|
const formData = new FormData();
|
|
1882
1889
|
formData.append(
|
|
1883
1890
|
"audio",
|
|
@@ -1926,11 +1933,11 @@ import { parseEnv } from "util";
|
|
|
1926
1933
|
import {
|
|
1927
1934
|
accessSync,
|
|
1928
1935
|
constants,
|
|
1929
|
-
existsSync as
|
|
1936
|
+
existsSync as existsSync2,
|
|
1930
1937
|
mkdirSync as mkdirSync9,
|
|
1931
1938
|
readFileSync as readFileSync6,
|
|
1932
1939
|
renameSync,
|
|
1933
|
-
statSync,
|
|
1940
|
+
statSync as statSync2,
|
|
1934
1941
|
unlinkSync as unlinkSync2,
|
|
1935
1942
|
writeFileSync as writeFileSync10
|
|
1936
1943
|
} from "fs";
|
|
@@ -1953,16 +1960,16 @@ var commandExists = (command, env, fallbacks = []) => {
|
|
|
1953
1960
|
);
|
|
1954
1961
|
return [...candidates, ...fallbacks].some(isExecutable);
|
|
1955
1962
|
};
|
|
1956
|
-
var readTextIfExists = (path) =>
|
|
1963
|
+
var readTextIfExists = (path) => existsSync2(path) ? readFileSync6(path, "utf-8") : null;
|
|
1957
1964
|
var writeTextAtomic = (path, text, mode) => {
|
|
1958
1965
|
mkdirSync9(dirname8(path), { recursive: true, mode: 448 });
|
|
1959
|
-
const fileMode = mode ?? (
|
|
1966
|
+
const fileMode = mode ?? (existsSync2(path) ? statSync2(path).mode & 511 : 384);
|
|
1960
1967
|
const tmp = join2(dirname8(path), `.${basename4(path)}.${process.pid}.tmp`);
|
|
1961
1968
|
writeFileSync10(tmp, text, { encoding: "utf-8", mode: fileMode });
|
|
1962
1969
|
renameSync(tmp, path);
|
|
1963
1970
|
};
|
|
1964
1971
|
var removeIfExists = (path) => {
|
|
1965
|
-
if (
|
|
1972
|
+
if (existsSync2(path)) unlinkSync2(path);
|
|
1966
1973
|
};
|
|
1967
1974
|
|
|
1968
1975
|
// src/harnesses/keys.ts
|
|
@@ -5642,7 +5649,7 @@ init_output();
|
|
|
5642
5649
|
import { execFileSync } from "child_process";
|
|
5643
5650
|
import {
|
|
5644
5651
|
chmodSync,
|
|
5645
|
-
existsSync as
|
|
5652
|
+
existsSync as existsSync3,
|
|
5646
5653
|
mkdirSync as mkdirSync10,
|
|
5647
5654
|
readFileSync as readFileSync7,
|
|
5648
5655
|
realpathSync,
|
|
@@ -5799,7 +5806,7 @@ async function proxy(host) {
|
|
|
5799
5806
|
}
|
|
5800
5807
|
function setupSsh() {
|
|
5801
5808
|
mkdirSync10(SSH_DIR, { recursive: true, mode: 448 });
|
|
5802
|
-
if (!
|
|
5809
|
+
if (!existsSync3(SSH_KEY)) {
|
|
5803
5810
|
execFileSync("ssh-keygen", [
|
|
5804
5811
|
"-q",
|
|
5805
5812
|
"-t",
|
|
@@ -5827,7 +5834,7 @@ function setupSsh() {
|
|
|
5827
5834
|
""
|
|
5828
5835
|
].join("\n")
|
|
5829
5836
|
);
|
|
5830
|
-
const current =
|
|
5837
|
+
const current = existsSync3(USER_SSH_CONFIG) ? readFileSync7(USER_SSH_CONFIG, "utf8") : "";
|
|
5831
5838
|
if (!current.split("\n").includes(INCLUDE)) {
|
|
5832
5839
|
mkdirSync10(join15(homedir4(), ".ssh"), { recursive: true, mode: 448 });
|
|
5833
5840
|
writeFileSync11(USER_SSH_CONFIG, `${INCLUDE}
|
|
@@ -5980,7 +5987,7 @@ var sandboxCommand = new Command22("sandbox").description("E2B sandboxes billed
|
|
|
5980
5987
|
// src/commands/update.ts
|
|
5981
5988
|
init_output();
|
|
5982
5989
|
import { execSync, spawnSync as spawnSync6 } from "child_process";
|
|
5983
|
-
import { existsSync as
|
|
5990
|
+
import { existsSync as existsSync4, readFileSync as readFileSync8 } from "fs";
|
|
5984
5991
|
import { dirname as dirname9, join as join16, resolve as resolve3, sep } from "path";
|
|
5985
5992
|
import { fileURLToPath } from "url";
|
|
5986
5993
|
import { Command as Command23 } from "commander";
|
|
@@ -5988,7 +5995,7 @@ var PACKAGE_NAME = "@pollinations/cli";
|
|
|
5988
5995
|
var REGISTRY_URL = "https://registry.npmjs.org/@pollinations%2Fcli/latest";
|
|
5989
5996
|
function findPackageRoot(fromDir) {
|
|
5990
5997
|
let dir = resolve3(fromDir);
|
|
5991
|
-
while (!
|
|
5998
|
+
while (!existsSync4(join16(dir, "package.json"))) {
|
|
5992
5999
|
const parent = dirname9(dir);
|
|
5993
6000
|
if (parent === dir) throw new Error("could not locate package.json");
|
|
5994
6001
|
dir = parent;
|
|
@@ -6095,7 +6102,7 @@ var updateCommand = new Command23("update").description(
|
|
|
6095
6102
|
// src/commands/upload.ts
|
|
6096
6103
|
init_api();
|
|
6097
6104
|
init_config();
|
|
6098
|
-
import { createReadStream
|
|
6105
|
+
import { createReadStream } from "fs";
|
|
6099
6106
|
import { basename as basename5 } from "path";
|
|
6100
6107
|
import { Command as Command24 } from "commander";
|
|
6101
6108
|
init_output();
|
|
@@ -6113,11 +6120,8 @@ var uploadCommand = new Command24("upload").description(
|
|
|
6113
6120
|
).argument("<file>", "Path to the local file to upload").action(async (file) => {
|
|
6114
6121
|
const key = requireKey();
|
|
6115
6122
|
const isHuman = getOutputMode() === "human";
|
|
6116
|
-
|
|
6117
|
-
fail(`File not found: ${file}`);
|
|
6118
|
-
}
|
|
6123
|
+
const size = requireFile(file);
|
|
6119
6124
|
const mime = mimeTypeFor(file);
|
|
6120
|
-
const size = statSync2(file).size;
|
|
6121
6125
|
const uploadRequest = {
|
|
6122
6126
|
method: "POST",
|
|
6123
6127
|
headers: {
|