Skip to content

Write code in NodeJS/NPM, compile it for AngularJS/bower.

License

Notifications You must be signed in to change notification settings

bitliner/shared-pack

Repository files navigation

shared-pack

Write code in NodeJS/NPM, compile it for AngularJS/bower.

Index

Requirements

  • npm
  • node.js

Installation

npm install -g shared-pack

Usage

  1. Create a node.js module
  2. Compile
  3. Configure properly package.json and bower.json

Create a javascript module

The module should satisfy the following 2 conditions:

  1. it should be exposed as node.js module - using module.exports
  2. the function to expose should be the angular.js function - with dependencies declared as parameters of the function

Example

  1. crete folder: mkdir shared-module && cd $_
  2. initialize bower.json and package.json bower init && npm init
  3. create module, example shared-service.js:
    'use strict';
    
    function SharedService(param1) {
    	console.log('Ola', param1);
    }
    
    module.exports = SharedService;
    

Compile

shared-pack ./shared-service.js

Results

The results fo compilation will be a foldr ./build containing 2 files

  • ./build/shared-service.angular.js

     function SharedService(param1) {
     	console.log('Ola', param1);
     }
    
     angular.module('SharedService', ['param1'])
     	.factory('SharedService', ['param1', SharedService]);
    

Configure properly main field in bower.json and package.json

bower.json

	...
	"main":"./build/shared-service.angular.js",
	...

Roadmap

  • Remove generation of node.js file
  • Create a parser module with following functions:
    • getDependenciesNames(moduleString) // extract require instructions, removing eventually user prefix
    • other methods ...
  • Fix compilation for AngularJS: the node exported object should be in a wrapping function, depednencies should be delcared in the wrapping function, and the wrapping function should return the exported object
  • Add support for semantic versioning of bower: shared-pack ./node-file.js patch|minor|major changes field "version" in bower.json.
  • Add support for updating bower.json dependencies based on modules installed via npm
  • Add support for updating bower.json with git address for private packages
  • Add support for private npm packages

About

Write code in NodeJS/NPM, compile it for AngularJS/bower.

Resources

License

Stars

Watchers

Forks

Packages