![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
The JavaScript API to the "Swiss army knife of cloud storage" rclone.
Besides providing a way to install rclone on different platforms, a CLI and a JavaScript API are included.
npm install rclone.js
After installation, the latest binary of rclone
is also fetched based on
your system environment.
If a custom version of rclone
binary is needed, use RCLONE_EXECUTABLE
environment variable to set the path to that custom binary.
Except update
(which is used to update rclone
binary), all API functions
return a child process whose events we can listen to. Optional flags can be
passed as an object to the last argument of the function call. Except removing
the --
prefix, there is no other conversion to the flag name.
const rclone = require("rclone.js");
const ls = rclone.ls("source:", {
"max-depth": 1,
});
ls.stdout.on("data", (data) => {
console.log(data.toString());
});
ls.stderr.on("data", (data) => {
console.error(data.toString());
});
There is also a Promise-based API:
const rclone = require("rclone.js").promises;
(async function() {
const results = await rclone.ls("source:", {
"max-depth": 1,
});
console.log(results);
})();
When the official rclone
adds new command that has not been provided here,
we can still use the command through the default exported functions, passing
the command name as first argument:
const rclone = require("rclone.js");
rclone("newcommand", "source:", "target:", {
"flag": true,
});
(async function() {
const results = await rclone.promises("newcommand", "source:", "target:", {
"flag": true,
});
console.log(results);
})();
This simple CLI calls the JS API above and outputs stdout
and stderr
.
$ npx rclone --version
rclone v1.54.0
- os/arch: darwin/amd64
- go version: go1.15.7
$ npx rclone ls source: --max-depth 1
-1 2020-12-12 10:01:44 -1 Documents
-1 2020-12-11 16:24:20 -1 Pictures
The CLI also supports executing a custom JS-based command to further extend
usage outside of what the official rclone
offers:
$ npx rclone echo.js arg1 --string value arg2 --boolean
The custom JS file just needs to export a function that takes the arguments and
flags parsed from the CLI. It can either return a child process, or a Promise
.
For a child process, its stdout
and stderr
are piped to the caller process.
Inside the function, this
is set to rclone.js
module.
const { spawn } = require("child_process");
module.exports = function echo(arg1, arg2, flags = {}) {
return spawn("echo", [arg1, arg2, JSON.stringify(flags)]);
}
The custom module is loaded through require
, so it has some nice advantages
when locating module:
.js
extension, custom
is same as custom.js
.foobar.js
and foobar/index.js
.NODE_PATH
environment variable.node_modules
by its name.With that, there are a few things custom commands can be used:
archive
.For a "real-life" example, check out selfupdate, which
overrides the built-in selfupdate
command to download rclone executable if it
has not been downloaded yet. Consecutive runs just call selfupdate
API.
For publishing a custom rclone
command as NPM package, consider prefixing the
package name with rclone-
so it's clearer and not conflicting.
FAQs
JavaScript API for rclone
The npm package rclone.js receives a total of 732 weekly downloads. As such, rclone.js popularity was classified as not popular.
We found that rclone.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.