npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-ftp-cli

v1.0.4

Published

ftp command line tool, based on npm 'ftp' package

Downloads

33

Readme

node-ftp-cli

A command line tool based on npm ftp package

Install

You can install globally or locally.

Global

  • Install
$ npm install -g node-ftp-cli
  • get help
$ node-ftp --help

Local

  • Install
$ npm install node-ftp-cli
  • package.json
{
  "script": {
    "node-ftp": "node node_modules/.bin/node-ftp"
  }
}
  • get help
npm run node-ftp --help

Usage

we can confirm usage help by node-ftp --help, by default node-ftp-cli will look for the ftp.config.js in your current folder.

we can use options like node-ftp --config my-ftp.config.js .... to specific the config file. Settings can we refer Here

// ftp.config.js
module.exports = {
  host: 'ftpupload.net.xxxx',
  port: 21,
  user: '12345678',
  password: 'aabbccdd12345',
  keepalive: 10000,
}

Cli Usage

  • remotepath: remote file path
  • localpath: local file path
  • remotefolder: remote folder path
  • localfolder: local folder path
  • outputpath: output folder path

--list [remotefolder]

list files name in specific remote path folder

$ node-ftp --list /htdocs

--get [remotepath] [-o [outputpath]]

download target file from ftp server, optionally to outputpath, if -o is not specific, current path will be used

$ node-ftp --get /htdocs/index.html -o ./dist

--put/--append [localpath] -t [remotepath]

upload target file to ftp server

$ node-ftp --put/--append index.html -t /htdocs

--rm [remotepath]

delete target file on ftp server

--rename [remotepath/remotefolder] -t [remotepath/remotefolder]

rename an remote path to new path

$ node-ftp --rename /htdocs/index.html -t /htdocs/index.php

--mkdir [remotefolder]

create new folder on ftp server, if the folder already exist, will do nothing

--rmdir [remotefolder] [-r]

delete remote folder on ftp server, -r for recursive

--getdir [remotefolder] [-o [outputpath]]

download target folder

$ node-ftp --getdir /htdocs -o ./myftp

--putdir [localfolder] -t [remotefolder] [--unzip]

upload target folder to ftp server, if target file already exist, will overwrite the existing file, if target folder existed, will only append new files to that folder

  1. ./dist/index.html => /htdocs/dist/index.html
$ node-ftp --putfir dist -t /htdocs

with --unzip, we can extract files from specific folder to the target folder

  1. ./dist/index.html => /htdocs/index.html
$ node-ftp --putdir dist -t /htdocs --unzip

for putdir, appenddir methods, we can set the excludes as array of string/regexp in options. value will be directly use in match method to exclude files or folder.

module.exports = {
  host: '',
  password: '',
  // ...
  excludes: [/node_modules/],
}

--appenddir [localfolder] -t [remotefolder] [--unzip]

upload target folder to ftp server, if target file already exist, will not overwrite the existing file.

Script Usage

if you need more custom usage, you can easily require the initFtp function for custom usage.

// find below usable methods
const { initFtp, listFiles } = require('node-ftp-cli');

const ftpOptions = {
  config: {
    host: 'aaaa.net',
    password: '123',
    // ...
  },
  ready: onFtpReady,
};

// ready function should be a promise
async function onFtpReady(client) {
  const { files } = await listFiles(client, '/');
  console.dir(files);
  // will auto close client once this ready promise resolved
}

// init connect
initFtp(ftpOptions);

Usable functions:

// exports of node-ftp-cli
module.exports = {
  cwd,
  listFiles,
  getFile,
  putFile,
  appendFile,
  removeFile,
  renamePath,
  mkdir,
  rmdir,
  getdir,
  putdir,
  appenddir,
  initFtp,
}

Last Updated by johnnywang in 2021/11/08