0.1.0 • Published 3 years ago

sftp-cache v0.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

SFTP-CACHE

npm npm

Maintainability Contributor Covenant

Use a directory on any ssh/sftp enabled server as a cache directory.

The main goal is to allow caching of heavy project assets like videos to avoid unnecessary reconversions while deploying.

Features

  • Download from cache directory and refill it again
  • Compare file by missing on other end, modification date, file size and md5 hash
  • Keeps file modification date
  • Client: Windows, Linux, OSX
  • Server: Any host supporting sftp. MD5 hash comparision also needs md5 or md5sum installed on the server.

Installation

npm i sftp-cache

Usage

const { join } = require('path')

const sftpCache = require('sftp-cache')

;(async () => {
  try {
    await sftpCache({
      connection: {
        // All options: https://github.com/mscdex/ssh2#client-methods
        host: 'your.host.io',
        username: 'your-sft-user',
        password: '5up3r53cr37Pa$$w0rd'
        // Please do not store your credentials in your code. You can use environment variables & https://www.npmjs.com/package/dotenv
      },
      localDir: join(__dirname, 'assets'),
      remoteDir: '/home/your-sftp-user/sftp-cache-storage/assets',
      dirsToCache: [
        // Make sure paths are relative to localDir
        join('public', 'assets', 'videos'),
        join('node_modules', '.cache')
      ],
      // Tell it what to do:
      // cache: Uploads changed files from local to remote
      // download: Download changed files from remote to local
      syncDirection: 'cache'
    })
    console.log('success!')
  } catch (err) {
    console.log('failed!')
    console.error(err)
    process.exit(1)
  }
})()
0.1.0

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.9

4 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago