Skip to content

Commit

Permalink
Custom readme for react-tools
Browse files Browse the repository at this point in the history
Of course this means I can no longer just npm publish from the project
root, but I haven't been anyway.
  • Loading branch information
zpao committed Jul 4, 2014
1 parent e10d10e commit 5c85f33
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ module.exports = function(grunt) {

grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);
grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.pack);
grunt.registerTask('npm-react-tools:release', npmReactToolsTasks.buildRelease);
grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.packRelease);

grunt.registerTask('version-check', versionCheckTask);

Expand Down Expand Up @@ -220,6 +221,7 @@ module.exports = function(grunt) {
'browserify:addonsMin',
'npm-react:release',
'npm-react:pack',
'npm-react-tools:release',
'npm-react-tools:pack',
'copy:react_docs',
'compare_size'
Expand Down
46 changes: 42 additions & 4 deletions grunt/tasks/npm-react-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,58 @@
var fs = require('fs');
var grunt = require('grunt');

function pack() {
var src = 'npm-react-tools';
var dest = 'build/npm-react-tools/';

function buildRelease() {
grunt.file.exists(dest) && grunt.file.delete(dest);

// read our required files from package.json
var pkgFiles = grunt.config.data.pkg.files;

// copy all files from src first, includes custom README
var mappings = grunt.file.expandMapping('**/*', dest, {cwd: src});

// make sure we also get package.json
pkgFiles.push('package.json');

pkgFiles.map(function(file) {
if (grunt.file.isDir(file)) {
mappings = mappings.concat(grunt.file.expandMapping(file + '**/*', dest))
} else {
mappings.push({src: [file], dest: dest + file})
}
});

mappings.forEach(function(mapping) {
var src = mapping.src[0];
var dest = mapping.dest;
if (grunt.file.isDir(src)) {
grunt.file.mkdir(dest);
} else {
grunt.file.copy(src, dest);
}
});
}

function packRelease() {
/*jshint validthis:true */
var done = this.async();
var spawnCmd = {
cmd: 'npm',
args: ['pack']
args: ['pack', 'npm-react-tools'],
opts: {
cwd: 'build/'
}
};
grunt.util.spawn(spawnCmd, function() {
var src = 'react-tools-' + grunt.config.data.pkg.version + '.tgz';
var src = 'build/react-tools-' + grunt.config.data.pkg.version + '.tgz';
var dest = 'build/react-tools.tgz';
fs.rename(src, dest, done);
});
}

module.exports = {
pack: pack
buildRelease: buildRelease,
packRelease: packRelease
};
23 changes: 23 additions & 0 deletions npm-react-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# react-tools

This package compliments the usage of React. It ships with tools that are often used in conjunction.

## JSX

This package installs a `jsx` executable that can be used to transform JSX into vanilla JS. This is often used as part of a build step. This transform is also exposed as an API.

## Usage

### Command Line

```sh
jsx input > output
```

### API

```js
var reactTools = require('react-tools');

reactTools.transform(string, options);
```
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
}
],
"files": [
"README.md",
"main.js",
"bin/jsx",
"src/",
"vendor/fbtransform/",
"vendor/constants.js"
"vendor/fbtransform/"
],
"main": "main.js",
"bin": {
Expand Down

0 comments on commit 5c85f33

Please sign in to comment.