gulp-react-templates
Advanced tools
Comparing version 0.0.4 to 0.0.5
76
index.js
@@ -1,41 +0,51 @@ | ||
var through = require("through2"), | ||
gutil = require("gulp-util"), | ||
fs = require("fs") | ||
reactTemplates = require("react-templates"); | ||
'use strict'; | ||
// through2 is a thin wrapper around node transform streams | ||
var through = require('through2'); | ||
var gutil = require('gulp-util'); | ||
var rt = require('react-templates'); | ||
var PluginError = gutil.PluginError; | ||
var path = require('path'); | ||
var merge = require('merge'); | ||
module.exports = function (param) { | ||
"use strict"; | ||
// Consts | ||
var PLUGIN_NAME = 'gulp-react-templates'; | ||
function reactTemplatesPipe(file, enc, callback) { | ||
/*jshint validthis:true*/ | ||
module.exports = function (opt) { | ||
function replaceExtension(filePath) { | ||
return filePath + '.js'; | ||
} | ||
if (file.isNull()) { | ||
this.push(file); | ||
return callback(); | ||
} | ||
function transform(file, enc, cb) { | ||
if (file.isNull()) { | ||
return cb(null, file); | ||
} | ||
if (file.isStream()) { | ||
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported')); | ||
} | ||
if (file.isStream()) { | ||
this.emit("error", | ||
new gutil.PluginError("gulp-react-templates", "Stream content is not supported")); | ||
return callback(); | ||
} | ||
//console.log('rt ' + file.path); | ||
if (file.isBuffer()) { | ||
param = param || {}; | ||
param._ = [file.path]; | ||
var ret = reactTemplates.executeOptions(param); | ||
if (ret) { | ||
this.emit("error", | ||
new gutil.PluginError("gulp-react-templates", "rt " + file.path + " failed")); | ||
} | ||
var data; | ||
var str = file.contents.toString('utf8'); | ||
var dest = replaceExtension(file.path); | ||
file.contents = new Buffer(fs.readFileSync(file.path + ".js")); | ||
file.path = file.path + '.js'; | ||
var options = merge({ | ||
filename: file.path, | ||
sourceFiles: [file.relative], | ||
generatedFile: replaceExtension(file.relative) | ||
}, opt); | ||
this.push(file); | ||
} | ||
return callback(); | ||
} | ||
try { | ||
data = rt.convertTemplateToReact(str, options); | ||
} catch (err) { | ||
return cb(new PluginError(PLUGIN_NAME, err)); | ||
} | ||
return through.obj(reactTemplatesPipe); | ||
}; | ||
file.contents = new Buffer(data); | ||
file.path = dest; | ||
cb(null, file); | ||
} | ||
return through.obj(transform); | ||
}; |
{ | ||
"name": "gulp-react-templates", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Gulp plugin for react-templates - Light weight templates for react -> write html get valid react code", | ||
"repository": "wix/gulp-react-templates", | ||
"main": "./index.js", | ||
"keywords": [ | ||
"gulpplugin" | ||
"gulpplugin", | ||
"templates", | ||
"react-templates", | ||
"react", | ||
"reactjs", | ||
"react.js" | ||
], | ||
"author": { | ||
"name": "Yoel Zeldes", | ||
"email": "yoel.zeldes@gmail.com", | ||
"url": "https://github.com/yoel-zeldes" | ||
}, | ||
"repository": "yoel-zeldes/gulp-react-templates", | ||
"scripts": { | ||
"test": "istanbul test _mocha --report html -- test/*.js --reporter spec" | ||
"test": "mocha" | ||
}, | ||
"dependencies": { | ||
"gulp-util": "~2.2.0", | ||
"react-templates": "^0.1.7", | ||
"through2": "*" | ||
"gulp-util": "^3.0.0", | ||
"merge": "^1.2.0", | ||
"react-templates": "^0.1.8", | ||
"through2": "^0.6.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"coveralls": "*", | ||
"mocha-lcov-reporter": "*", | ||
"istanbul": "*", | ||
"event-stream": "*", | ||
"should": "~2.1.0" | ||
"mocha": "^2.0.0", | ||
"should": "^4.0.4" | ||
}, | ||
@@ -30,0 +28,0 @@ "engines": { |
# gulp-react-templates | ||
[![NPM version][npm-image]][npm-url] | ||
> [react-templates](http://wix.github.io/react-templates) plugin for [gulp](https://github.com/wearefractal/gulp) | ||
> Build react-templates | ||
## Usage | ||
## Installation | ||
First, install `react-templates` and `gulp-react-templates` as a development dependency: | ||
Install package with NPM and add it to your development dependencies: | ||
```shell | ||
npm install --save-dev react-templates gulp-react-templates | ||
``` | ||
`npm install --save-dev gulp-react-templates` | ||
Then, add it to your `gulpfile.js`: | ||
## Usage | ||
```javascript | ||
var react-templates = require("gulp-react-templates"); | ||
var gulp = require('gulp'); | ||
var rt = require('gulp-react-templates'); | ||
gulp.src("./src/*.rt") | ||
.pipe(react-templates({ | ||
modules: 'amd' | ||
})) | ||
.pipe(gulp.dest("./dist")); | ||
gulp.task('rt', function() { | ||
gulp.src('src/**/*.rt') | ||
.pipe(rt({modules: 'amd'})) | ||
.pipe(gulp.dest('src')); | ||
}); | ||
``` | ||
## API | ||
## Options | ||
### react-templates(options) | ||
The options `gulp-react-templates` can get are the same as `react-templates`'s options. Just type `rt --help` in your shell in order to learn about the available options. | ||
- `modules` | ||
Select modules system (amd|commonjs|none). | ||
## License | ||
[MIT License](http://en.wikipedia.org/wiki/MIT_License) | ||
[npm-url]: https://npmjs.org/package/gulp-react-templates | ||
[npm-image]: https://badge.fury.io/js/gulp-react-templates.png | ||
See more [here](https://github.com/wix/react-templates/blob/gh-pages/docs/cli.md) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Floating dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
7441
2
1
1
4
6
40
2
31
1
+ Addedmerge@^1.2.0
+ Addedansi-gray@0.1.1(transitive)
+ Addedansi-wrap@0.1.0(transitive)
+ Addedarray-differ@1.0.0(transitive)
+ Addedarray-uniq@1.0.3(transitive)
+ Addedbeeper@1.1.1(transitive)
+ Addedclone@1.0.4(transitive)
+ Addedcolor-support@1.1.3(transitive)
+ Addeddateformat@2.2.0(transitive)
+ Addedfancy-log@1.3.3(transitive)
+ Addedglogg@1.0.2(transitive)
+ Addedgulp-util@3.0.8(transitive)
+ Addedgulplog@1.0.0(transitive)
+ Addedhas-gulplog@0.1.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedlodash._basecopy@3.0.1(transitive)
+ Addedlodash._basetostring@3.0.1(transitive)
+ Addedlodash._basevalues@3.0.0(transitive)
+ Addedlodash._getnative@3.9.1(transitive)
+ Addedlodash._isiterateecall@3.0.9(transitive)
+ Addedlodash._reescape@3.0.0(transitive)
+ Addedlodash._reevaluate@3.0.0(transitive)
+ Addedlodash._reinterpolate@3.0.0(transitive)
+ Addedlodash._root@3.0.1(transitive)
+ Addedlodash.escape@3.2.0(transitive)
+ Addedlodash.isarguments@3.1.0(transitive)
+ Addedlodash.isarray@3.0.4(transitive)
+ Addedlodash.keys@3.1.2(transitive)
+ Addedlodash.restparam@3.6.1(transitive)
+ Addedlodash.template@3.6.2(transitive)
+ Addedlodash.templatesettings@3.1.1(transitive)
+ Addedmerge@1.2.1(transitive)
+ Addedobject-assign@3.0.0(transitive)
+ Addedparse-node-version@1.0.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedreplace-ext@0.0.1(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsparkles@1.0.1(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedthrough2@0.6.52.0.5(transitive)
+ Addedtime-stamp@1.1.0(transitive)
+ Addedvinyl@0.5.3(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedansi-regex@0.2.1(transitive)
- Removedansi-styles@1.1.0(transitive)
- Removedarray-find-index@1.0.2(transitive)
- Removedcamelcase@2.1.1(transitive)
- Removedcamelcase-keys@2.1.0(transitive)
- Removedchalk@0.5.1(transitive)
- Removedcurrently-unhandled@0.4.1(transitive)
- Removeddateformat@1.0.12(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedgulp-util@2.2.20(transitive)
- Removedhas-ansi@0.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedindent-string@2.1.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.13.1(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedlodash._escapehtmlchar@2.4.1(transitive)
- Removedlodash._escapestringchar@2.4.1(transitive)
- Removedlodash._htmlescapes@2.4.1(transitive)
- Removedlodash._isnative@2.4.1(transitive)
- Removedlodash._objecttypes@2.4.1(transitive)
- Removedlodash._reinterpolate@2.4.1(transitive)
- Removedlodash._reunescapedhtml@2.4.1(transitive)
- Removedlodash._shimkeys@2.4.1(transitive)
- Removedlodash.defaults@2.4.1(transitive)
- Removedlodash.escape@2.4.1(transitive)
- Removedlodash.isobject@2.4.1(transitive)
- Removedlodash.keys@2.4.1(transitive)
- Removedlodash.template@2.4.1(transitive)
- Removedlodash.templatesettings@2.4.1(transitive)
- Removedlodash.values@2.4.1(transitive)
- Removedloud-rejection@1.6.0(transitive)
- Removedmap-obj@1.0.1(transitive)
- Removedmeow@3.7.0(transitive)
- Removedminimist@0.2.4(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedredent@1.0.0(transitive)
- Removedrepeating@2.0.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.18(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedstrip-ansi@0.3.0(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedstrip-indent@1.0.1(transitive)
- Removedsupports-color@0.2.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedthrough2@0.5.14.0.2(transitive)
- Removedtrim-newlines@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedvinyl@0.2.3(transitive)
- Removedxtend@3.0.0(transitive)
Updatedgulp-util@^3.0.0
Updatedreact-templates@^0.1.8
Updatedthrough2@^0.6.1