@samitouri / QOS-React-2 / commits / 5c85f33184

Custom readme for react-tools

Of course this means I can no longer just npm publish from the project root, but I haven't been anyway.

Paul O’Shannessy committed Jul 3, 2014 at 17:39 UTC 5c85f3318461531995f0ab3d321d95dc9087b6ee
4 files changed +69 -8
Gruntfile.js
+3 -1
@@ -66,7 +66,8 @@ module.exports = function(grunt) {
66
67 grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);
68 grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
69 - grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.pack);
69 + grunt.registerTask('npm-react-tools:release', npmReactToolsTasks.buildRelease);
70 + grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.packRelease);
71
72 grunt.registerTask('version-check', versionCheckTask);
73
@@ -220,6 +221,7 @@ module.exports = function(grunt) {
221 'browserify:addonsMin',
222 'npm-react:release',
223 'npm-react:pack',
224 + 'npm-react-tools:release',
225 'npm-react-tools:pack',
226 'copy:react_docs',
227 'compare_size'
grunt/tasks/npm-react-tools.js
+42 -4
@@ -3,20 +3,58 @@
3 var fs = require('fs');
4 var grunt = require('grunt');
5
6 -function pack() {
6 +var src = 'npm-react-tools';
7 +var dest = 'build/npm-react-tools/';
8 +
9 +function buildRelease() {
10 + grunt.file.exists(dest) && grunt.file.delete(dest);
11 +
12 + // read our required files from package.json
13 + var pkgFiles = grunt.config.data.pkg.files;
14 +
15 + // copy all files from src first, includes custom README
16 + var mappings = grunt.file.expandMapping('**/*', dest, {cwd: src});
17 +
18 + // make sure we also get package.json
19 + pkgFiles.push('package.json');
20 +
21 + pkgFiles.map(function(file) {
22 + if (grunt.file.isDir(file)) {
23 + mappings = mappings.concat(grunt.file.expandMapping(file + '**/*', dest))
24 + } else {
25 + mappings.push({src: [file], dest: dest + file})
26 + }
27 + });
28 +
29 + mappings.forEach(function(mapping) {
30 + var src = mapping.src[0];
31 + var dest = mapping.dest;
32 + if (grunt.file.isDir(src)) {
33 + grunt.file.mkdir(dest);
34 + } else {
35 + grunt.file.copy(src, dest);
36 + }
37 + });
38 +}
39 +
40 +function packRelease() {
41 /*jshint validthis:true */
42 var done = this.async();
43 var spawnCmd = {
44 cmd: 'npm',
11 - args: ['pack']
45 + args: ['pack', 'npm-react-tools'],
46 + opts: {
47 + cwd: 'build/'
48 + }
49 };
50 grunt.util.spawn(spawnCmd, function() {
14 - var src = 'react-tools-' + grunt.config.data.pkg.version + '.tgz';
51 + var src = 'build/react-tools-' + grunt.config.data.pkg.version + '.tgz';
52 var dest = 'build/react-tools.tgz';
53 fs.rename(src, dest, done);
54 });
55 }
56
57 module.exports = {
21 - pack: pack
58 + buildRelease: buildRelease,
59 + packRelease: packRelease
60 };
npm-react-tools/README.md new
+23
@@ -0,0 +1,23 @@
1 +# react-tools
2 +
3 +This package compliments the usage of React. It ships with tools that are often used in conjunction.
4 +
5 +## JSX
6 +
7 +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.
8 +
9 +## Usage
10 +
11 +### Command Line
12 +
13 +```sh
14 +jsx input > output
15 +```
16 +
17 +### API
18 +
19 +```js
20 +var reactTools = require('react-tools');
21 +
22 +reactTools.transform(string, options);
23 +```
package.json
+1 -3
@@ -17,12 +17,10 @@
17 }
18 ],
19 "files": [
20 - "README.md",
20 "main.js",
21 "bin/jsx",
22 "src/",
24 - "vendor/fbtransform/",
25 - "vendor/constants.js"
23 + "vendor/fbtransform/"
24 ],
25 "main": "main.js",
26 "bin": {