Skip to content
Browse files

merged

  • Loading branch information...
2 parents 394dae6 + bb90adb commit f8e70ca7a743383ccdbb28bd091c90d2f560243e @bahmutov committed Dec 30, 2013
Showing with 88 additions and 57 deletions.
  1. +8 −0 .travis.yml
  2. +4 −2 Gruntfile.js
  3. +7 −0 History.md
  4. +39 −37 README.md
  5. +16 −11 package.json
  6. +14 −7 tasks/sync.js
View
8 .travis.yml
@@ -0,0 +1,8 @@
+language: node_js
+node_js:
+ - "0.10"
+branches:
+ only:
+ - master
+before_script:
+ - npm install -g grunt-cli
View
6 Gruntfile.js
@@ -35,7 +35,9 @@ module.exports = function (grunt) {
sync: {
all: {
options: {
- sync: ['author', 'name', 'version', 'private']
+ from: './package.json',
+ to: './bower.json',
+ sync: ['author', 'name', 'version', 'private', 'license']
}
}
}
@@ -45,6 +47,6 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
// By default, lint and run all tests.
- grunt.registerTask('default', ['jshint']);
+ grunt.registerTask('default', ['jshint', 'sync']);
};
View
7 History.md
@@ -1,4 +1,11 @@
+0.3.0 / 2013-12-10
+==================
+
+ * added from, to filename options
+ * if syncing author, removing bower's authors field, fixes #3
+ * syncing license by default, fixes #2
+
0.2.1 / 2013-09-27
==================
View
76 README.md
@@ -1,54 +1,56 @@
-# grunt-sync-pkg [![NPM version](https://badge.fury.io/js/grunt-sync-pkg.png)](http://badge.fury.io/js/grunt-sync-pkg) [![Build Status](true.png)](true)
+# grunt-npm2bower-sync
-> Minimalist Grunt plugin to sync only basic properties between package.json and bower.json
+> Syncs specified properties from package.json to bower.json
-This plugin syncs the following properties between `package.json` and `bower.json`:
+[![NPM info][nodei.co]][npm-url]
-* `name`
-* `version`
-* `main`
-* `dependencies`
-* `devDependencies`
-
-Also, if a `bower.json` file does not exist, the plugin creates on first. There is no option to turn this off, since there is no reason to use the plugin if you aren't syncing with anything :-).
-
-
-## Getting Started
-_If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide._
-
-From the same directory as your project's [Gruntfile][Getting Started] and [package.json][], install this plugin with the following command:
+[![Build status][ci-image]][ci-url]
+[![dependencies][dependencies-image]][dependencies-url]
+[![devdependencies][devdependencies-image] ][devdependencies-url]
+[![endorse][endorse-image]][endorse-url]
```bash
-npm install grunt-sync-pkg --save-dev
+npm install grunt-npm2bower-sync --save-dev
```
-Once that's done, add this line to your project's Gruntfile:
+Once that's done, add this line to your project's Gruntfile.js:
```js
-grunt.loadNpmTasks('grunt-sync-pkg');
+grunt.initConfig({
+
+ sync: {
+ all: {
+ options: {
+ // sync specific options
+ sync: ['author', 'name', 'version', 'private'],
+ // optional: specify source and destination filenames
+ from: '../package.json',
+ to: 'dist/bower.json'
+ }
+ }
+ }
+
+ grunt.loadNpmTasks('grunt-npm2bower-sync');
+ grunt.registerTask('default', ['sync']);
+});
```
-
-If the plugin has been installed correctly, you should now be able to run `grunt sync` at the command line to run the `sync` task.
-
-[grunt]: http://gruntjs.com/
-[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
-[package.json]: https://npmjs.org/doc/json.html
+You can also sync properties from the command line using command `grunt sync`
-## Contributing
-In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt][].
-
-
-## Release History
- * 2013-09-09   v0.1.0   First commit
+## License
+This repo was forked from [grunt-sync-pkg](https://github.com/jonschlinkert/grunt-sync-pkg) by Jon Schlinkert.
-## License
Copyright (c) 2013-09-09 Jon Schlinkert
Licensed under the [MIT LICENSE](LICENSE-MIT).
-***
-
-Project created by [Jon Schlinkert](http://github.com/jonschlinkert).
-
-_This file was generated on 9/9/2013._
+[ci-image]: https://travis-ci.org/bahmutov/grunt-npm2bower-sync.png?branch=master
+[ci-url]: https://travis-ci.org/bahmutov/grunt-npm2bower-sync
+[nodei.co]: https://nodei.co/npm/grunt-npm2bower-sync.png?downloads=true
+[npm-url]: https://npmjs.org/package/grunt-npm2bower-sync
+[dependencies-image]: https://david-dm.org/bahmutov/grunt-npm2bower-sync.png
+[dependencies-url]: https://david-dm.org/bahmutov/grunt-npm2bower-sync
+[devdependencies-image]: https://david-dm.org/bahmutov/grunt-npm2bower-sync/dev-status.png
+[devdependencies-url]: https://david-dm.org/bahmutov/grunt-npm2bower-sync#info=devDependencies
+[endorse-image]: https://api.coderwall.com/bahmutov/endorsecount.png
+[endorse-url]: https://coderwall.com/bahmutov
View
27 package.json
@@ -1,23 +1,23 @@
{
- "name": "grunt-sync-pkg",
- "description": "Minimalist Grunt plugin to sync only basic properties between package.json and bower.json",
- "version": "0.2.1",
- "homepage": "https://github.com/jonschlinkert/grunt-sync-pkg",
+ "name": "grunt-npm2bower-sync",
+ "description": "Grunt plugin syncing properties from package.json to bower.json",
+ "version": "0.3.0",
+ "homepage": "https://github.com/bahmutov/grunt-npm2bower-sync",
"author": {
- "name": "Jon Schlinkert",
- "url": "https://github.com/jonschlinkert"
+ "name": "Gleb Bahmutov",
+ "url": "https://github.com/bahmutov"
},
"repository": {
"type": "git",
- "url": "https://github.com/jonschlinkert/grunt-sync-pkg.git"
+ "url": "https://github.com/bahmutov/grunt-npm2bower-sync"
},
"bugs": {
- "url": "https://github.com/jonschlinkert/grunt-sync-pkg/issues"
+ "url": "https://github.com/bahmutov/grunt-npm2bower-sync/issues"
},
"licenses": [
{
"type": "MIT",
- "url": "https://github.com/jonschlinkert/grunt-sync-pkg/blob/master/LICENSE-MIT"
+ "url": "https://github.com/bahmutov/grunt-npm2bower-syn/blob/master/LICENSE-MIT"
}
],
"main": "Gruntfile.js",
@@ -29,9 +29,14 @@
},
"devDependencies": {
"grunt-contrib-jshint": "~0.8.0",
- "grunt": "~0.4.1"
+ "grunt": "~0.4.2",
+ "pre-git": "0.0.14"
},
"keywords": [
"gruntplugin"
- ]
+ ],
+ "scripts": {
+ "test": "grunt"
+ },
+ "pre-commit": "grunt"
}
View
21 tasks/sync.js
@@ -30,33 +30,40 @@ module.exports = function (grunt) {
function sync() {
/*jshint validthis:true */
var configValues = (this.data && this.data.options) || {};
+ var sourceFilename = configValues.from || 'package.json';
+ var destinationFilename = configValues.to || 'bower.json';
var propertiesToSync = configValues.sync || [
'name',
'author',
'version',
'description',
- 'private'
+ 'private',
+ 'license'
];
- grunt.verbose.writeln('syncing', propertiesToSync);
+ grunt.verbose.writeln('syncing', propertiesToSync, 'from', sourceFilename,
+ 'to', destinationFilename);
- var pkg = grunt.file.readJSON('package.json');
+ var pkg = grunt.file.readJSON(sourceFilename);
verifyPackage(pkg);
// If bower.json doesn't exist yet, add one.
- if (!grunt.file.exists('bower.json')) {
- grunt.file.write('bower.json', "{}");
+ if (!grunt.file.exists(destinationFilename)) {
+ grunt.file.write(destinationFilename, "{}");
}
- var bower = grunt.file.readJSON('bower.json');
+ var bower = grunt.file.readJSON(destinationFilename);
var options = {};
propertiesToSync.forEach(function (propertyToSync) {
+ if (propertyToSync === 'author') {
+ delete bower.authors;
+ }
options[propertyToSync] = pkg[propertyToSync] || configValues[propertyToSync];
}, this);
grunt.verbose.writeln('options added to bower', JSON.stringify(options, null, 2));
bower = JSON.stringify(_.extend(bower, options), null, 2);
- grunt.file.write('bower.json', bower);
+ grunt.file.write(destinationFilename, bower);
}
grunt.registerMultiTask('sync', 'Sync package.json -> bower.json', sync);

0 comments on commit f8e70ca

Please sign in to comment.
Something went wrong with that request. Please try again.