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

le-ftp

v1.0.5

Published

Watch local directory and upload changes to ftp

Downloads

2

Readme

le-ftp

Watch local directory (and its sub-directories) for changes and uploads changed files via ftp - node.js

This is not fully tested and should not be used in any critical applications.

Usage

  1. Make sure you have node.js installed
  2. In the directory where le-ftp is installed, create file testftp.js
  3. Copy and paste into the new file the following:
LEftp = require('le-ftp');

var x = new LEftp({
	"host"		: "",		// ftp host address, eg. my.server.com
	"port"		: 21,
	"user"		: '',		// Your ftp username
	"password"	: '',		// Your ftp password
	
	"watchList":	[
				{
					"localRootDir"	: "C:/local/folder1",
					"remoteRootDir"	: 'public_html/remote/dir1'
				},
				{
					"localRootDir"	: "C:/my/local/folder2",
					"remoteRootDir"	: 'public_html/remote/dir2'
				}
			],
	// The following two parameters are depricated. Use watchList array instead
	// "localRootDir" : "C:/my/local/folder",	// Depricated, use watchList array instead
	// "remoteRootDir": 'public_html/remote/dir',	// Depricated, use watchList array instead

	"frequency"	: 1,		// Number of seconds between each scan
	"ext"		: ['.css','.js','.html','txt','jpg'],
    "onStartUploadAll"  : true  // On start, upload all files (that match the "watch criteria").
});
  1. Edit the settings you just pasted (see Configuration Parameters below)
  2. From command line in the directory where le-ftp resides, run node le-ftp
  3. Current files (that match your criteria) will be uploaded and program will keep running
  4. To stop watching
  5. from command line, use [Ctrl]+[c]
  6. from script, call .stop() method on the le-ftp object. So, in the above example it would be x.stop()
  7. If you want to modify the testftp.js so that watching is stopped after, say, 100seconds, add the following code to testftp.js:
// Schedule to stop watching in 100 seconds (100,000 milliseconds)
setTimeout(
    function() {x.stop();} ,
    100 * 1000                    // Schedule stop after 100 seconds (100,000 milliseconds)
);

Configuration Parameters

  • host: 'myftpserver.domain.com' - address of the ftp server

  • port: 21 - ftp server port

  • remoteRootDir: '' - Remote root directory: Local files will be copied to this directory

  • localRootDir: '' - Local root directory: Local directory to watch

  • user: '' - Ftp username

  • password: '' - Ftp password

  • watchList: [ - Array of folders to watch and corresponding upload target directories

    • { - Beging first object describing the pair of folder to watch and its upload target directory
    • localRootDir: 'C:/my/local/folder1', - first local folder to watch
    • remoteRootDir: 'public_html/remote/dir1' - first remote upload target directory
    • }, - End first object
    • { - Beging second object describing the pair of folder to watch and its upload target directory
    • localRootDir: 'C:/my/local/folder2', - second local folder to watch
    • remoteRootDir: 'public_html/remote/dir2' - second remote upload target directory
    • }, - End Second object
  • ], - End of array of folders to watch

  • localRootDir : "C:/dir" - Depricated. Full path to local folder to be copied to the FTP server. Use Unix backslash "/"

  • remoteRootDir : 'public_html/dev.clubfinance.uk/angular', - Depricated Remote folder, starting from your FTP root

  • frequency: 1 - number of seconds between each scan. Decimals (e.g. 0.1) are acceptable

  • ext: ['css','js','html','txt'] - if you want to only include files with certain extensions, list the extensions here as an array of strings: ['css','js','html']. No need to prefix extensions with '.', so .css and css will both work.

Important if you receive ECONNREFUSED error

  • On some networks the node.js ftp module cannot connect and returns ECONNREFUSED error
  • This is not an issue with le-ftp itself, but node.js ftp module, on which le-ftp depends
  • This issue could be resolved by setting keep alive option to false inside node.js ftp module
    • editing file node_modules/ftp/lib/connections.js
    • Open the file and go to line 106, which says
    • socket.setKeepAlive(true);
    • Change true to false, so that it now says
    • socket.setKeepAlive(false);