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

cloud-shepherd

v0.2.2

Published

An NPM module that abstracts away the complexities of cloud storage services (Object Storage (AWS s3) as well as File Storage(Dropbox) to easily interface between multiple clouds with a unified interface. Also enables you to quickly perform data migration

Downloads

6

Readme

cloud-shepherd :ox: :dromedary_camel: :cow2: :water_buffalo: :ram:

[STILL IN ALPHA DEVELOPMENT] A promise based, multi-cloud POISIX style client wrapper that abstracts away the complexities of Object Storage services, such as AWS s3, as well as File Storage services, such as Dropbox, in order to easily interact with and move files between multiple clouds using an intuitive, familiar, and simple interface.

Amaze your friends and family as you enter the multi-cloud future and leave behind the days of having to research provider specific documentation, write complicated (and dangerous :scream:) cloud 2 cloud migration scripts, or spend time thinking about the esoteric semantics of blobs vs keys.

Supported Services

s3: supported

raskspace: supported

azure: supported

hp: supported

openstack: supported

gDrive: in-progress

ftp: planned

box: planned

dropbox: planned

onedrive: planned

Installing

npm install cloud-shepherd --save

Getting Started

Require the library.

const shepherd = require('cloud-shepherd');

Call '.herd' with the name of your respective cloud provider, as well as a JSON object containing your unique access credentials to instantiate your client.

const credentials = {
    secretAccessKey : 'yourSecret',
    accessKey : 'yourAccessKey'
};

const service = 's3';

const source = shepherd.herd(service, credentials);

Methods

#####migrate(srcPath, destHerd, destPath)

Migrate a file or a directory from one Cloud to another.

    const sourceCloud = shepherd.herd('s3', srcCredentials);
    const destinationCloud = shepherd.herd('rackspace', destCredentials);

    sourceCloud.migrateFile('/sourcebucket/fileToMigrate.txt',
                            destinationCloud, 
                            '/destbucket/fileToMigrate.txt');
    
    sourceCloud.migrateDir('/cloudshepherdtesting/mydir/',
                            destinationCloud,
                            '/destinationcloudtest/testagain/');

#####ls(path)

List all files and directories in your Cloud from a given path context.

    cloud.ls('/')
        .then( data => {
            console.log(data);
        })
        .catch( err => {
            console.log(data);
        });
    
    cloud.ls('/sourcebucket/')
        .then( data => {
            console.log(data);
        })
        .catch( err => {
            console.log(data);
        });
    
    cloud.ls('/sourcebucket/dir/sub-dir/')
        .then( data => {
            console.log(data);
        })
        .catch( err => {
            console.log(data);
        });                  

#####stat(path)

List detailed information about files and/or directories from a given path context.

    cloud.stat('/sourcebucket/fileToMigrate.txt')
        .then( data => {
            console.log(data);
        })
        .catch( err => {
            console.log(data);
        });

####mkdir(path)

Create a directory at the given path.

    cloud.mkdir('/sourcebucket/')
        .then( data => {
            console.log(data);
        })
        .catch( err => {
            console.log(err);
        });

####uploadFile(writePath,readStream)

Upload a file to the given write path context, from a given Readable stream.

        const Readable = require('stream').Readable;
        const readStream = Readable({objectMode: true});
        
        readStream._read = () => {};
        readStream.push('buffalo');
        readStream.push('yaks');
        readStream.push(null);
        
        cloud.uploadFile( '/testingdirs/fileToWrite.txt', readStream)
            .then(data => {
                console.log('Successfully placed file');
            })
            .catch(err => {
                console.log(err);
            });
        
       

####downloadFile(readPath,writeStream)

Read the data from a given path, and write that data to a given Writable stream.

    cloud.downloadFile( '/testingdirs/fileToWrite.txt', process.stdout)
        .then(data => {
            console.log('Successfully placed file');
        });

####unlink(path)

Delete a file or dir from a given path context.

    cloud.unlink('/container/dir/subdirtodelete/')
             .then(item => {
                 console.log(item);
             });

####destroy(path)

A destroy file and destroy dir method have been implemented, to give you peice of mind while removing items. These methods will throw an error if you accidentally delete a file instead of a dir and vice versa.

    cloud.destroyFile('/testingdirs/fileToWrite3.txt')
        .then((file) => {
            console.log('Successfully destroyed file:' + file);
        });
            
    cloud.destroyDir('/testingdirs/')
        .then((dir) => {
            console.log('Successfully destroyed file:' + dir);
        });

NOT YET IMPLEMENTED:: empty(path)

Will delete all items from a supplied directory context, but will not delete the directory.

    cloud.emptyDir('/container/dir/')
        .then(data => {
            console.log(data);
        })
        .catch((err) => {
            console.log(err);
        });
    
    cloud.emptyRootDir('/container/')
        .then(data => {
            console.log(data);
        })
        .catch((err) => {
            console.log(err);
        });

####itemExists(path)

Resolves to true or false if a given item exists.

    cloud.fileExists('/gigofbuffalos/buffalo.jpg')
        .then(doesFileExist => {
            console.log('Does file exist? : ', doesFileExist );
        })
        .catch((err) => {
            console.log(err);
        });
    cloud.dirExists('/containertodelete/dir/subdir/')
        .then(doesFileExist => {
            console.log('Does dir exist? : ', doesFileExist );
        })
        .catch((err) => {
            console.log(err);
        });
    cloud.rootDirExists('/containertodelete/')
        .then(doesFileExist => {
            console.log('Does root dir exist? : ', doesFileExist );
        })
        .catch((err) => {
            console.log(err);
        });

####copy(srcPath,dstPath)

Copys a file or directory from a given path, to a given path. Will overwrite by default

    cloud.copyFile('/cloudshepherdtesting/fileToWrite.txt', 
                    '/cloudshepherdtesting/copytest/fileToCopy.txt')
        .then(data => {
            console.log(data);
            console.log('Successfully copied file');
        })
        .catch((err) => {
            console.log(err);
        });
        
    cloud.copyDir('/cloudshepherdtesting/copytest/', 
                    '/cloudshepherdtesting/')
        .then(data => {
            console.log(data);
            console.log('Successfully copied file');
        })
        .catch((err) => {
            console.log(err);
        });
        

####move(srcPath,dstPath)

Moves a file or directory from a given path, to a given path and then deletes the source path. Will overwrite by default

    cloud.moveFile('/cloudshepherdtesting/fileToWrite.txt', 
                    '/cloudshepherdtesting/copytest/fileToCopy.txt')
        .then(data => {
            console.log(data);
            console.log('Successfully copied file');
        })
        .catch((err) => {
            console.log(err);
        });
        
    ccloud.moveDir('/cloudshepherdtesting/copytest/', 
                    '/cloudshepherdtesting/')
        .then(data => {
            console.log(data);
            console.log('Successfully copied file');
        })
        .catch((err) => {
            console.log(err);
        });
        

Credential Format

  amazon: {
    secretAccessKey: 'myKey',
    accessKey: 'myAccessKey',
  }

  rackspace: {
    username: 'myUsername',
    apiKey: 'myApiKey',
    service: 'storage',
    region: 'myRegion',
  }

  azure: {
    storageAccount: 'myAccount',
    storageAccessKey: 'myStorageAccessKey'
  }
  
  hp: {
    username: 'myUsername',
    apiKey: 'myApiKey',
    region: 'myRegion',
    authUrl: 'myAuthUrl',
  },
  
  openstack: {
    provider: 'openstack',
    username: 'myUsername',
    password: 'myPassword',
    authUrl: 'myAuthUrl',
  },

Tests

npm test

Contributing

Roadmap still being worked out. Hop onto this discord server if you want to reach me: https://discord.gg/PPpWSdb or email me at [email protected]