https://github.com/bitliner/shared-pack
Write code in NodeJS/NPM, compile it for AngularJS/bower.
https://github.com/bitliner/shared-pack
Last synced: 11 months ago
JSON representation
Write code in NodeJS/NPM, compile it for AngularJS/bower.
- Host: GitHub
- URL: https://github.com/bitliner/shared-pack
- Owner: bitliner
- License: apache-2.0
- Created: 2016-02-20T15:55:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-27T21:42:24.000Z (almost 10 years ago)
- Last Synced: 2025-03-17T05:32:20.854Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 30.6 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# shared-pack
Write code in [NodeJS](https://nodejs.org/en/)/[NPM](https://www.npmjs.com/), compile it for [AngularJS](https://angularjs.org/)/[bower](https://bower.io/).

# Index
* [`Requirements`](#requirements)
* [`Installation`](#installation)
* [`Usage`](#usage)
* npm
* node.js
`npm install -g shared-pack`
1. [Create a node.js module](#createModule)
2. [Compile](#compile)
3. [Configure properly package.json and bower.json](#setMain)
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;
```
```
shared-pack ./shared-service.js
```
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