First upload version 0.0.1
This commit is contained in:
2
node_modules/ipull/dist/cli/cli.d.ts
generated
vendored
Normal file
2
node_modules/ipull/dist/cli/cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
45
node_modules/ipull/dist/cli/cli.js
generated
vendored
Normal file
45
node_modules/ipull/dist/cli/cli.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env node
|
||||
import path from "path";
|
||||
import { Command, Option } from "commander";
|
||||
import { packageJson } from "../const.js";
|
||||
import { downloadFile, downloadSequence } from "../download/node-download.js";
|
||||
import { setCommand } from "./commands/set.js";
|
||||
import findDownloadDir, { downloadToDirectory, findFileName } from "./utils/find-download-dir.js";
|
||||
const pullCommand = new Command();
|
||||
pullCommand
|
||||
.description("Pull/copy files from remote server/local directory")
|
||||
.argument("[files...]", "Files to pull/copy")
|
||||
.option("-s --save [path]", "Save location (directory/file)")
|
||||
.option("-c --connections [number]", "Number of parallel connections", "4")
|
||||
.addOption(new Option("-st --style [type]", "The style of the CLI progress bar").choices(["basic", "fancy", "ci", "summary"]))
|
||||
.addOption(new Option("-p --program [type]", "The download strategy").choices(["stream", "chunks"]))
|
||||
.option("-t --truncate-name", "Truncate file names in the CLI status to make them appear shorter")
|
||||
.action(async (files = [], { save: saveLocation, truncateName, number, program, style }) => {
|
||||
if (files.length === 0) {
|
||||
pullCommand.outputHelp();
|
||||
process.exit(0);
|
||||
}
|
||||
const fileDownloads = await Promise.all(files.map(async (file) => {
|
||||
const isDirectory = saveLocation && await downloadToDirectory(saveLocation);
|
||||
const directory = isDirectory ? saveLocation : await findDownloadDir(findFileName(file));
|
||||
const fileName = isDirectory || !saveLocation ? "" : path.basename(saveLocation);
|
||||
return await downloadFile({
|
||||
url: file,
|
||||
directory,
|
||||
fileName,
|
||||
truncateName,
|
||||
parallelStreams: Number(number) || 4,
|
||||
programType: program
|
||||
});
|
||||
}));
|
||||
const downloader = await downloadSequence({
|
||||
truncateName,
|
||||
cliProgress: true,
|
||||
cliStyle: style
|
||||
}, ...fileDownloads);
|
||||
await downloader.download();
|
||||
})
|
||||
.version(packageJson.version);
|
||||
pullCommand.addCommand(setCommand);
|
||||
pullCommand.parse();
|
||||
//# sourceMappingURL=cli.js.map
|
||||
1
node_modules/ipull/dist/cli/cli.js.map
generated
vendored
Normal file
1
node_modules/ipull/dist/cli/cli.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,eAAe,EAAE,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAIhG,MAAM,WAAW,GAAG,IAAI,OAAO,EAAE,CAAC;AAClC,WAAW;KACN,WAAW,CAAC,oDAAoD,CAAC;KACjE,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;KAC5C,MAAM,CAAC,kBAAkB,EAAE,gCAAgC,CAAC;KAC5D,MAAM,CAAC,2BAA2B,EAAE,gCAAgC,EAAE,GAAG,CAAC;KAC1E,SAAS,CAAC,IAAI,MAAM,CAAC,oBAAoB,EAAE,mCAAmC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;KAC7H,SAAS,CAAC,IAAI,MAAM,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;K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CAAC,CAAC;AAElC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACnC,WAAW,CAAC,KAAK,EAAE,CAAC"}
|
||||
2
node_modules/ipull/dist/cli/commands/set.d.ts
generated
vendored
Normal file
2
node_modules/ipull/dist/cli/commands/set.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Command } from "commander";
|
||||
export declare const setCommand: Command;
|
||||
30
node_modules/ipull/dist/cli/commands/set.js
generated
vendored
Normal file
30
node_modules/ipull/dist/cli/commands/set.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Command } from "commander";
|
||||
import { AppDB } from "../../settings/settings.js";
|
||||
const HELP_TEXT = `
|
||||
You can set that file extensions will be download to specific path.
|
||||
For example all zip files will be download to ~/Downloads/zip/:
|
||||
pull set .zip ~/Downloads/zip/
|
||||
|
||||
You can set default download path:
|
||||
pull set default ~/Downloads/
|
||||
`;
|
||||
export const setCommand = new Command("set");
|
||||
setCommand.description("Set download locations")
|
||||
.argument("[path]", "Path to the settings")
|
||||
.argument("<value>", "Value to set")
|
||||
.option("-d delete", "Delete the setting")
|
||||
.addHelpText("afterAll", HELP_TEXT)
|
||||
.action(async (path, value, { delete: deleteSetting }) => {
|
||||
if (deleteSetting) {
|
||||
await AppDB.update(data => {
|
||||
delete data[path];
|
||||
});
|
||||
console.log(`Deleted ${path}`);
|
||||
return;
|
||||
}
|
||||
await AppDB.update(data => {
|
||||
data[path] = value;
|
||||
});
|
||||
console.log(`${value} set to ${path}`);
|
||||
});
|
||||
//# sourceMappingURL=set.js.map
|
||||
1
node_modules/ipull/dist/cli/commands/set.js.map
generated
vendored
Normal file
1
node_modules/ipull/dist/cli/commands/set.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../src/cli/commands/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,KAAK,EAAC,MAAM,4BAA4B,CAAC;AAEjD,MAAM,SAAS,GACX;;;;;;;EAOF,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AAE7C,UAAU,CAAC,WAAW,CAAC,wBAAwB,CAAC;KAC3C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;KAC1C,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;KACnC,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC;KACzC,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC;KAClC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAC,MAAM,EAAE,aAAa,EAAC,EAAE,EAAE;IACnD,IAAI,aAAa,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAC/B,OAAO;IACX,CAAC;IAED,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,WAAW,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
|
||||
3
node_modules/ipull/dist/cli/utils/find-download-dir.d.ts
generated
vendored
Normal file
3
node_modules/ipull/dist/cli/utils/find-download-dir.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function findDownloadDir(fileName?: string): Promise<string>;
|
||||
export declare function findFileName(url: string): string;
|
||||
export declare function downloadToDirectory(path: string): Promise<boolean>;
|
||||
27
node_modules/ipull/dist/cli/utils/find-download-dir.js
generated
vendored
Normal file
27
node_modules/ipull/dist/cli/utils/find-download-dir.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import { AppDB } from "../../settings/settings.js";
|
||||
const DEFAULT_DOWNLOAD_DIR = process.cwd();
|
||||
export default async function findDownloadDir(fileName) {
|
||||
const downloadLocation = AppDB.data[path.extname(fileName || "")];
|
||||
const defaultLocation = AppDB.data["default"];
|
||||
return downloadLocation || defaultLocation || DEFAULT_DOWNLOAD_DIR;
|
||||
}
|
||||
export function findFileName(url) {
|
||||
try {
|
||||
return path.basename(new URL(url).pathname);
|
||||
}
|
||||
catch {
|
||||
return path.basename(url);
|
||||
}
|
||||
}
|
||||
export async function downloadToDirectory(path) {
|
||||
try {
|
||||
const stats = await fs.lstat(path);
|
||||
return stats.isDirectory();
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=find-download-dir.js.map
|
||||
1
node_modules/ipull/dist/cli/utils/find-download-dir.js.map
generated
vendored
Normal file
1
node_modules/ipull/dist/cli/utils/find-download-dir.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"find-download-dir.js","sourceRoot":"","sources":["../../../src/cli/utils/find-download-dir.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAC,MAAM,4BAA4B,CAAC;AAEjD,MAAM,oBAAoB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE3C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,eAAe,CAAC,QAAiB;IAC3D,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9C,OAAO,gBAAgB,IAAI,eAAe,IAAI,oBAAoB,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAW;IACpC,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,IAAY;IAClD,IAAI,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC"}
|
||||
Reference in New Issue
Block a user