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

angular-ui-publisher

v1.2.8

Published

Helper component for building and publishing your angular modules as bower components

Downloads

46

Readme

Angular UI Publisher Build Status NPM version

Helper component for building and publishing your angular modules as bower components

Goal

The goal of all this is to automatize the construction of this type of repo tree.

+ git repo
  + master (src) branch // build directory is ignored
    - tag: src1.0.x
    - tag: src1.1.x
  + gh-pages (doc) branch
  + bower (build) branch // build directory is committed
    - tag: v1.0.x
    - tag: v1.1.x
  + bower-subcomponent-a (like angular-ui-event) branch
    - tag: subcomponent-a-1.0.x
    - tag: subcomponent-a-1.1.x
  + bower-subcomponent-b (like angular-ui-event) branch
    - tag: subcomponent-b-1.0.x
    - tag: subcomponent-b-1.1.x

So the master branch is free of builds files, the gh-pages branch is free of source files and the bower branches are only containing the vital part of a component. This way if a repo produces separate components, I could simply create multiple bower-branches for each produced component. Like for the component subcomponent-a, the branch bower-subcomponent-a with the specific version tags prefixed with bower-subcomponent-a-

Like so, throw bower you can install

# All the repo
bower install <package>#master

# The latest bower build
bower install <package>#bower

# A specific bower build
bower install <package>#v0.0.8

# The latest bower build of a sub component
bower install <package>#bower-subcomponent-a

# A specific bower build of a sub component
bower install <package>#subcomponent-a-0.0.8

Usage

Add it as a npm component:

npm install angular-ui-publisher --save-dev

You have now access to the gulp build system in :
./node_modules/angular-ui-publisher/node_modules/.bin/gulp.
Like it's pretty far and you're current path must be in the /node_modules/angular-ui-publisher it's safer to use it in another build system to do the thing.

Play nice with Gulp

This project is itself made with Gulp :)
Still, here is some handy functions to do the work.

//
// ACCESS TO THE ANGULAR-UI-PUBLISHER
function targetTask(task){
  return function(done){

    var spawn = require('child_process').spawn;
    var path = require('path');

    spawn(path.resolve(process.cwd(), './node_modules/.bin/gulp'), process.argv.slice(2), {
      cwd : './node_modules/angular-ui-publisher',
      stdio: 'inherit'
    }).on('close', done);
  }
}


gulp.task('build', targetTask('build'));
gulp.task('publish', targetTask('publish'));

and use

./node_modules/.bin/gulp build --branch=bower
# or
./node_modules/.bin/gulp build --branch=gh-pages
# or
./node_modules/.bin/gulp publish --branch=bower
# or
./node_modules/.bin/gulp publish --branch=gh-pages

Hack nice with Grunt

For Grunt you can do this :

//
// HACK TO ACCESS TO THE ANGULAR-UI-PUBLISHER
function fakeTargetTask(prefix){
  return function(){

    if (this.args.length !== 1) return grunt.log.fail('Just give the name of the ' + prefix + ' you want like :\ngrunt ' + prefix + ':bower');

    var done = this.async();
    var spawn = require('child_process').spawn;
    spawn('./node_modules/.bin/gulp', [ prefix, '--branch='+this.args[0] ].concat(grunt.option.flags()), {
      cwd : './node_modules/angular-ui-publisher',
      stdio: 'inherit'
    }).on('close', done);
  };
}

grunt.registerTask('build', fakeTargetTask('build'));
grunt.registerTask('publish', fakeTargetTask('publish'));
//

and use

grunt build:bower
# or
grunt build:gh-pages
# or
grunt publish:bower
# or
grunt publish:gh-pages

Tasks

build

It's just coping or processing template files to the out/built/<branch_name> with <branch_name> given by the flag --branch.

publish

It's acting in out/clones/<branch_name>.

  • Clones the given <branch_name>.
  • Copy the built files into it.
  • Commits the result (with the current build number on TravisCI)
  • Tags it with the current version (given by the package.json)
  • Push it (only on TravisCI for now)

Building configuration

The component publisher can use a configuration file named publish.js to specify various thing to use while building the branches.
This file must return a object with the configuration like so :

module.exports = function() {
  return {
    // ...
  };
};

This config object can content the following key:

{
  humaName : String,
  // the name used as title in the gh-pages (ex: 'UI.Utils')

  repoName : String,
  // the repo name used in github links in the gh-pages (ex: 'ui-utils')

  inlineHTML : String,
  // The html to inline in the index.html file in the gh-pages
  // (ex: 'Hello World' or fs.readFileSync(__dirname + '/demo/demo.html'))

  inlineJS : String,
  // The javascript to inline at the end of the index.html file in the gh-pages

  js : Array.of(String) | Function,
  // The js files to use in the gh-pages, loaded after angular by default (ex: ['dist/ui-utils.js'])
  // or
  // function that returns the final array of files to load 
  // (ex: function(defaultJsFiles) { return ['beforeFile.js'].concat(defaultJsFiles); })

  css : Array.of(String),
  // The css files to use in the gh-pages

  tocopy : Array.of(String),
  // Additional files to copy in the vendor directory in the gh-pages



  main_dist_dir : String,
  // directory used to store the main sources in the './dist' directory (ex: 'main')

  sub_dist_dir : String,
  // directory used to store the sub component sources in the './dist' directory (ex: 'sub')

  bowerData : {
    // Bower data to overwrite.
    // (ex: { name: 'my-component', main: './my-component.js' })
  }

  subcomponents : {  // Collection of sub component
    "<sub component name>" : {
      // Bower data to overwrite.
      // (ex: { name: 'my-component', main: './my-component.js' })
    }
  }

}

CLI flags

--branch Allows you to specify the branch to take care of.

  • build --branch=gh-pages or build --branch=bower
    will build the gh-pages or the bower files in ./out/built
  • publish --branch=gh-pages or publish --branch=bower
    will publish the gh-pages or the bower files in ./out/clones

Made for Travis-CI

It's working with ssh deploy key ! (so even organization can make Travis commit on them repos.
You can find a quick tuto here.

After you added your deploy key to GitHub and Travis (in .travis.yml).
Add a global value with your repo name, like :

env:
  global:
  - REPO="[email protected]:<org>/<repo>.git"
  - secure: ! 'MR37oFN+bprRlI1/YS3...etc...

Then add the authentication script that will automatically decode your deploy key (passed encoded in your .travis.yml). And try SSH to Github.

after_success:
- "./node_modules/angular-ui-publisher/travis/authentication.sh || exit 0"
- "grunt dist build:gh-pages publish:gh-pages build:bower publish:bower"

I recommend adding a || exit 0 after the authentication script to make sure that if your access is denied no building and publishing will be made.
If you need to change the restriction to another branch that master by default, use the environment variable MAIN_BRANCH like below :

env:
  global:
  - MAIN_BRANCH=develop
  - REPO="[email protected]:<org>/<repo>.git"
  - secure: ! 'MR37oFN+bprRlI1/YS3...etc...