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

divshot-upload

v0.3.1

Published

Upload app files to Divshot

Downloads

53

Readme

divshot-upload

Upload app files to Divshot

Install

Server and Browserify

npm install divshot-upload --save

Browser/Angular

bower install divshot-upload --save

Usage

Server or Browserify

var fs = require('fs');
var upload = require('divshot-upload');
var fileStream = fs.creatReadStream('some-file.tar');
var uploadOptions = {
  token: 'user-token',
  environment: 'production',
  type: 'tar',
  config: {
    name: 'uploadapp',
    root: './'
  },
  files: {}
};

fileStream
  .pipe(upload(uploadOptions))
  .on('message', function (msg) {})
  .on('released', function (filepath) {})
  .on('releasing', function () {})
  .on('pushed', function () {})
  .on('unreleased', function (unreleasedFiles) {})
  .on('error', function (err) {});

Angular

<script src="/bower_components/divshot-upload/dist/upload.directive.js"></script>

Inject into app

angular.modules('myApp', ['divshot.upload']);

Use as directive

HTML

The <ds-upload/> element becomes a drag and drop zone OR you can click on it to upload a file

<div ng-controller="AppController">
  <ds-upload class="divshot-upload"
    ds-config="appConfig"
    ds-environment="environment"
    ds-token="token"
    ds-enter="onEnter()"
    ds-leave="onLeave()"
    ds-drop="onDrop()"
    ds-progress="onProgress(type, message)"
    ds-done="onDone()"
    ds-start="onStart()"
    ds-unreleased="onUnreleased(files)"
    ds-error="onError(message)"
    ds-host="host">
    
    Drop Here or Click Here to Upload File
    
  </ds-upload>
</div>

Controller

angular.modules('myApp')
  .controller('AppController', function ($scope) {
    $scope.environment = 'production';
    $scope.token = 'some-user-token';
    $scope.host = 'http://dev.host'; // OPTIONAL
    $scope.appConfig = {
      name: 'uploadapp',
      clean_urls: true
    };
    
    $scope.onEnter = function () {
      console.log('enter');
    };
    $scope.onLeave = function () {
      console.log('leave');
    };
    $scope.onDrop = function () {
      console.log('drop');
    };
    $scope.onProgress = function (type, message) {
      console.log(type + ':', message);
    };
    $scope.onDone = function () {
      console.log('Application deployed!');
    };
    $scope.onStart = function () {
      console.log('Upload started');
    };
    $scope.onUnreleased = function (files) {
      console.error('Not all files released.');
      
      Object.keys(files).forEach(function (filename) {
        console.error(filename + ' unreleased');
      });
    };
    $scope.onError = function (message) {
      console.error('ERROR:', message);
    };
  });

API

upload(options)

  • options
    • token - user authentication token
    • environment - environment to push to
    • type - type of file to upload (tar or zip only for now)
    • config - application configuration (taken from the divshot.json file)
    • host - OPTIONAL - the divshot api endpoint (Used for dev, test, and production environments). Defaults to production api.
    • files - OPTIONAL. an object of files where the key of each item is the relative path to the file and the value is an empty object. This is used to track unreleased files.

Events

The upload stream emits the following events

  • message - generic message from upload stream
    • callback should look like function (message) {}
  • releasing - started the releasing stage of the push
    • callbacked should look like function () {}
  • released - individual file has been released
    • callbacked should look like function (file) {}
  • pushed - build has been fully pushed and deployed
    • callbacked should look like function () {}
  • unreleased - only fired if there were unreleased files
    • calback should look like function (unreleasedFiles) {}
  • error - an error occured in the process
    • callbacked should look like function (err) {}

Run Tests

Runs server side tests and browser tests. Browser tests require that Phantomjs is installed

npm install
npm test