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

cloudfiles-mirror

v0.1.7

Published

Mirrors local files to a Cloud Files account

Downloads

8

Readme

cloudfiles-mirror

Utility for keeping directories in sync with Rackspace Cloud Files

Installation

  $ npm install cloudfiles-mirror -g

Getting Rackspace Account

Usage

Command line usage

  cloudfiles-mirror --help
  Usage: cloudfiles-mirror [options]

  Options:

  -h, --help            output usage information
  -V, --version         output the version number
  -c, --config [value]  Configuration file
  -l --local [value]    Local directory to mirror
  -r --remote [value]   Remote container
  -b --base [value]     Remote base directory
  -u --user [value]     Rackspace username
  -k --key [value]      Rackspace API key
  --cdn                 Enable CDN support when creating the container
  -m --monitor          Enable monitor the local directory
  -s --servicenet       Enable ServiceNet (unmetered, double throughput) Only within Rackpace servers
  -w --workers <n>      Number of symultaneous parallel workers interacting with the Cloud Servers API
  --show_config         Show current configuration and exits
  --sync_all            Pushes all local files on the first run.

Programmatically

Require the module

    var CloudfilesMirror = require("cloudfiles-mirror");

Create a mirror instance

    var mirror = CloudfilesMirror({
      localPath: './test/fixtures/source_files',
      remoteBase: 'fixtures/',
      container: 'test_mirror',
      auth : {
        username: 'user',
        apiKey: 'key'
      },
      cdnEnabled: true,
      monitor: false,
      pushOnBoot: false,
      servicenet: false // only when running from the same datacenter
    });

Events

Once a cloudfiles-mirror instance is created, you can listen for these events:

    // You will probably want to wait for this event
    // before interacting with the remote Cloud Files account
    mirror.on("ready", function (container_name) {
        console.log(container_name, " is ready for accepting content");
    });

    mirror.on("remote.authenticated");

    // When received remote files
    mirror.on("remote.container.files", function (remote_files) { });

    // Triggered whenever a remote file is added
    mirror.on("remote.added", function (remote, local) { });

    // Triggered whenever a remote file is removed
    mirror.on("remote.removed", remote, local);


    // Triggered when scanning the directory when options.pushOnBoot is true
    mirror.on("local.file.found", file, mime, extension, stats);

    // File watcher events
    mirror.on("local.file.created", function (file, mime, extension, stats) {});
    mirror.on("local.file.changed", function (file, mime, extension, stats) {});
    mirror.on("local.file.removed", function (file, mime, extension, stats) {});

API Methods

mirror.pushDirectory();

Pushes all the files on .localPath to the remote cloud

mirror.enableMonitor();

Starts monitoring the .localPath and mirroring changes on the Cloud container

Bonus

You can define new mime types with

    mirror.mime.define({'text/markdown': ['md', 'markdown']});

Roadmap

  1. Compare local and remote files before pushing them.
  2. Enable deleting files not found on source.
  3. Pre-processor support for optimizing or compiling assets.

Run Tests

All of the cloudservers-mirror tests are written in vows, and cover all of the use cases described above. You will need to add your Rackspace API username and API key to test/fixtures/test-config.json before running tests:

  {
    "auth": {
      "username": "your-username",
      "apiKey": "your-apikey"
    }
  }

Once you have valid Rackspace credentials you can run tests with vows:

  vows test/*-test.js --spec

Author: Bermi Ferrer