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

gulpsi

v1.1.0

Published

Gulp based build system which supports the packages and dependency aggregation. Designed for AngularJS

Downloads

10

Readme

GulPsi

Gulp based build system (for angular):

  • packages (local or installed via npm / bower)
  • angular-module dependency aggregation
  • bower dependency aggregation
  • full sourcemap support
  • workarounds for common gulp/sourcemap/watch problems
  • easy configurable and customizable

Tasks

  • app: Generate the angular.module("appName", [...deps...]) definition and combines your angular code
  • assets: Copy the assets
  • bower: Update the bower.json with aggregated package dependencies
  • clean: Cleanup your build directory
  • jshint: Lint your code
  • less: Compile LESS and combine CSS
  • livereload: Livereload :)
  • ngTemplates: Concat all html templates into a templates.js. Supports overwriting of templates comming from npm_modules
  • processIndexHtml: Copy and rewrite the index.html to use the minified files and set the ng-app name
  • watch: A helper-task to react on filechanges

Installation

Theres no npm package yet

npm install gulp
npm install psi-4ward/gulpsi

Usage

  • gulp -h show the help
  • gulp build builds your app (into public folder)
  • gulp dev build, start watchers and livereload
  • gulp serve start builtin webserver
  • gulp bower aggregate the bower dependencies and update bower.json

Configuration

Module's gulpsi.json

{

  // define dependencies
  "dependencies": {

    // this gets merged into the angular.module("app", [ ...dependcies... ]);
    "angular": ["ui-router"],

    // your bower dependencies
    "bower": {
      "angular": {
        "version": "~1.3.9",
        // files gets merged into your lib.js
        "js": "angular/angular.js"
      },
      "bootstrap": {
        "version": "~3.3.0",
        
        // could be an array with many files
        "js": [
          "bootstrap/js/affix.js",
          "bootstrap/js/dropdown.js",
          "bootstrap/js/tooltip.js"
        ],
        
        // @import this less file
        // "less": "bootstrap/less/bootstrap.less"
        
        // @import (inline) this css files
        "css": [
          "bootstrap/dist/css/bootstrap.css",
          "bootstrap/dist/css/bootstrap-theme.css"
        ]
      }      
    }
  },

  // @import this less file(s)
  "less": "less/test.less",
  
  // "css": [ ... ]

  // tells the processIndexHtml task that this module
  // has the entrypoint file "index.html"
  "indexHtml": true

}

Buildsystem config

You can configure the buildsystem using the gulpfile.js see defaults.js for possible values. Or configure a localTask folder for your local task files.

You have some global variables to make the life easier:

  • gulp: reference to gulp
  • runSequence: run-sequence
  • gutil: gulp-util
  • _: lodash
  • $config: the configuration
  • $packages: all module configurations

gulpfile.js example

global['gulp'] = require('gulp');
var $config = require('gulpsi');

// define particular apps
var common = ['angular/base', 'angular/theme', 'angular/psi-notify'];
var apps = {
  admin: ['angular/angular-psi-csv', 'angular/admin'],
  editor: ['angular/editor', 'angular/chat'],
  visitor: ['angular/visitor', 'angular/visitor'],
};

// add "--app" cli argument support
$config.commanderOpts.push(['--app <app>', 'Build a particular app']);

// packages containing only angular files, no subfolder necessary 
$config.subfolder.angular = '';

// the beforeLoad Hook is triggered after cli-argument parse but before config parsing 
$config.beforeLoad = function() {
  if(['clean', 'bower', 'jshint', 'serve'].indexOf($config.argv.args[0]) > -1) {
    // use every package for this common tasks
    $config.localPackages = ['angular/*'];
  } else {
    // some --app argument validation
    if(!$config.argv.app) {
      gutil.log(gutil.colors.red('Error') + ': --app argument missing');
      $config.help(); process.exit(1);
    } else if (Object.keys(apps).indexOf($config.argv.app) === -1) {
      gutil.log(gutil.colors.red('Error') + ': invalid app name! Use one of: ' + Object.keys(apps).join(', '));
      $config.help(); process.exit(1);
    }

    // use only defined package directories
    $config.localPackages = common.concat(apps[$config.argv.app]);

    // build to app subfolder
    $config.dest = 'public/' + $config.argv.app;
  }
};

// Add haml support to ngTemplates using the getSources and pipe Hooks 
var haml = require('gulp-haml');
$config.taskHooks.ngTemplates = {
  getSources: function() {
    var sources = [];
    // create globbing pattern for each module
    $packages.forEach(function(cfg) {
      sources.push($config.basePath + cfg.folder + $config.subfolder.angular + '/**/*.html');
      sources.push($config.basePath + cfg.folder + $config.subfolder.angular + '/**/*.haml');
      // exclude the index.html using a negative-globbing pattern
      if(cfg.indexHtml) sources.push('!' + $config.basePath + cfg.folder + $config.subfolder.angular + '/index.html');
    });
    return sources;
  },
  pipe: function(stream) {
    var h = haml({compiler: 'creationix'});
    h.on('error', function(e) {
      gutil.log(
        gutil.colors.red('Error')
        + "    '" + gutil.colors.cyan('haml') + "' "
        + gutil.colors.red(e.toString())
      );
    });
    return stream.pipe(h);
  }
};

// Deploy Task
gulp.task('deploy', function() {
 // .... 
});

TODO:

  • Create a task to inject config into app (like api-url for dev-systems)