stopping for now
This commit is contained in:
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
50
.npmignore
Normal file
50
.npmignore
Normal file
@@ -0,0 +1,50 @@
|
||||
# Automatically ignored per:
|
||||
# https://www.npmjs.org/doc/developers.html#Keeping-files-out-of-your-package
|
||||
#
|
||||
# .*.swp
|
||||
# ._*
|
||||
# .DS_Store
|
||||
# .git
|
||||
# .hg
|
||||
# .lock-wscript
|
||||
# .svn
|
||||
# .wafpickle-*
|
||||
# CVS
|
||||
# npm-debug.log
|
||||
# node_modules
|
||||
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
*.orig
|
||||
|
||||
work
|
||||
build
|
||||
src
|
||||
test
|
||||
pids
|
||||
logs
|
||||
results
|
||||
coverage
|
||||
lib-cov
|
||||
html-report
|
||||
xunit.xml
|
||||
|
||||
.project
|
||||
.idea
|
||||
.settings
|
||||
.iml
|
||||
*.sublime-workspace
|
||||
*.sublime-project
|
||||
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- stable
|
||||
- 4
|
||||
@@ -9,5 +9,5 @@ gulp.task('download', function () {
|
||||
gulp.task('getwix',['download'], function(){
|
||||
return gulp.src("wixToolset.zip")
|
||||
.pipe(unzip())
|
||||
.pipe(gulp.dest('./wixFiles'));
|
||||
.pipe(gulp.dest('./lib/wixFiles'));
|
||||
});
|
||||
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Tommy Parnel
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
86
README.md
86
README.md
@@ -2,3 +2,89 @@
|
||||
|
||||
|
||||
simple wrapper over wix. You can see a working demo [here](https://github.com/tparnell8/GulpBuildForDotNet)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save-dev HydroCarbon
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var HydroCarbon = require('HydroCarbon');
|
||||
|
||||
HydroCarbon.exec({
|
||||
heatFiles: ["installers/heat-web.rsp"],
|
||||
candleFiles: ["installers/candle.rsp"],
|
||||
lightFiles: ["installers/light.rsp"]
|
||||
}, mycallbackFunction);
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### HydroCarbon.Exec(options, callback)
|
||||
|
||||
#### options
|
||||
|
||||
##### heatFiles
|
||||
|
||||
Type: `array`
|
||||
Default: `undefined`
|
||||
|
||||
Array of heat response file paths
|
||||
|
||||
##### candleFiles
|
||||
|
||||
Type: `array`
|
||||
Default: `undefined`
|
||||
|
||||
Array of candle response file paths
|
||||
|
||||
##### lightFiles
|
||||
|
||||
Type: `array`
|
||||
Default: `undefined`
|
||||
|
||||
Array of light response file paths
|
||||
|
||||
#### heatCommands
|
||||
|
||||
Type: 'array'
|
||||
Default: `undefined`
|
||||
|
||||
Array of command line args to pass to heat overrides heatFiles
|
||||
|
||||
#### candleCommands
|
||||
|
||||
Type: 'array'
|
||||
Default: `undefined`
|
||||
|
||||
Array of command line args to pass to candle overrides candleFiles
|
||||
|
||||
#### lightCommands
|
||||
|
||||
Type: 'array'
|
||||
Default: `undefined`
|
||||
|
||||
Array of command line args to pass to light overrides lightFiles
|
||||
|
||||
#### version
|
||||
|
||||
Type: 'string'
|
||||
Default: `undefined`
|
||||
|
||||
Sets the BUILD_VERSION environment variable to version before calling heat, candle, and light
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Tommy Parnell](https://github.com/tparnell8)
|
||||
|
||||
4
app.js
4
app.js
@@ -1,4 +0,0 @@
|
||||
module.exports = {
|
||||
exec: require('./exec.js'),
|
||||
generator: require('./generator.js')
|
||||
}
|
||||
125
exec.js
125
exec.js
@@ -1,125 +0,0 @@
|
||||
/*jslint node: true */
|
||||
/*jshint esversion: 6 */
|
||||
/* jshint -W097 */
|
||||
'use strict';
|
||||
var fs = require('fs'),
|
||||
when = require('when'),
|
||||
nodefn = require('when/node'),
|
||||
_ = require('underscore'),
|
||||
path = require('path'),
|
||||
child_process = require('child_process');
|
||||
var logger = function(log){
|
||||
if(log){
|
||||
console.log(log);
|
||||
}
|
||||
}
|
||||
var main = function (options) {
|
||||
var heatFiles = options.heatFiles;
|
||||
var candleFiles = options.candleFiles;
|
||||
var lightFiles = options.lightFiles;
|
||||
var heatCommands = options.heatCommands || null;
|
||||
var candleCommands = options.candleCommands || null;
|
||||
var lightCommands = options.lightCommands || null;
|
||||
var heatPath = options.heatPath || __dirname + "/wixFiles/heat.exe";
|
||||
var lightPath = options.lightPath || __dirname + "/wixFiles/light.exe";
|
||||
var candlePath = options.candlePath || __dirname + "/wixFiles/candle.exe";
|
||||
var cb = options.callback || function(){};
|
||||
var version = options.version;
|
||||
if(version){
|
||||
process.env.BUILD_VERSION = version;
|
||||
}
|
||||
if(!heatCommands){
|
||||
if(!heatFiles || !_.isArray(heatFiles) || heatFiles.length < 1 ){
|
||||
throw "heat files are required if no commands are passed";
|
||||
}
|
||||
// checkFiles(heatFiles);
|
||||
}
|
||||
|
||||
if(!candleCommands){
|
||||
|
||||
if(!candleFiles || !_.isArray(candleFiles) || candleFiles.length < 1 ){
|
||||
throw "candle files are required";
|
||||
}
|
||||
|
||||
//checkFiles(candleCommands);
|
||||
|
||||
}
|
||||
|
||||
if(!lightCommands){
|
||||
|
||||
if(!lightFiles || !_.isArray(lightFiles) || lightFiles.length < 1 ){
|
||||
throw "light files are required";
|
||||
}
|
||||
|
||||
//checkFiles(lightFiles);
|
||||
|
||||
}
|
||||
child_process.execFile(path.normalize(heatPath), heatCommands? heatCommands: _.map(heatFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
|
||||
logger(stdout);
|
||||
logger(stderr);
|
||||
if(err){
|
||||
throw err;
|
||||
}
|
||||
|
||||
child_process.execFile(path.normalize(candlePath), candleCommands? candleCommands: _.map(candleFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
|
||||
logger(stdout);
|
||||
logger(stderr);
|
||||
if(err){
|
||||
throw err;
|
||||
}
|
||||
|
||||
child_process.execFile(path.normalize(lightPath), lightCommands? lightCommands: _.map(lightFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
|
||||
logger(stdout);
|
||||
logger(stderr);
|
||||
if(err){
|
||||
throw err;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
//todo: figure out how to use promises while capturing stderr on the catch
|
||||
/*
|
||||
var liftedChild = nodefn.lift(child_process.execFile);
|
||||
liftedChild(heatPath, heatCommands? heatCommands: _.map(heatFiles, (file)=>`@${path.normalize(file)}`))
|
||||
.then((stdin, stderror)=>{
|
||||
console.log(stdin);
|
||||
console.log(stderror);
|
||||
return liftedChild(candlePath, candleCommands? candleCommands: _.map(candleFiles, (file)=>`@${path.normalize(file)}`));
|
||||
})
|
||||
|
||||
.then((stdin, stderror)=>{
|
||||
console.log(stdin);
|
||||
console.log(stderror);
|
||||
return liftedChild(lightPath, lightCommands? lightCommands: _.map(lightFiles, (file)=>`@${path.normalize(file)}`));
|
||||
})
|
||||
.catch((a,b,c)=>{
|
||||
console.log(a);
|
||||
console.log(b);
|
||||
console.log(c);
|
||||
})*/
|
||||
};
|
||||
|
||||
var checkFiles = function(files){
|
||||
_.each(files, (file)=>{
|
||||
if(!checkFile(file)){
|
||||
throw "error finding file" + file;
|
||||
}
|
||||
});
|
||||
};
|
||||
var checkFile = function (file) {
|
||||
if (file || file.length < 1) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
fs.access(path.normalize(file), fs.R_OK); //will error if doesnt exist
|
||||
//todo async?
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = main;
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
4
index.js
Normal file
4
index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
exec: require('./lib/exec.js'),
|
||||
generator: require('./lib/generator.js')
|
||||
}
|
||||
29
package.json
29
package.json
@@ -1,17 +1,28 @@
|
||||
{
|
||||
"name": "HydroCarbon",
|
||||
"version": "0.0.0",
|
||||
"description": "HydroCarbon",
|
||||
"main": "app.js",
|
||||
"author": {
|
||||
"name": "parne",
|
||||
"email": ""
|
||||
"description": "making windows installers great again",
|
||||
"version": "0.1.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "tparnell8",
|
||||
"repository": "tparnell8/HydroCarbon",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"compile": "babel src --out-dir lib",
|
||||
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
||||
"prepublish": "npm run compile",
|
||||
"test": "babel-node ./node_modules/.bin/isparta cover _mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"underscore": "^1.8.3",
|
||||
"when": "^3.7.7"
|
||||
"dependencies": {
|
||||
"underscore": "^1.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "*",
|
||||
"babel-preset-es2015-node4": "*",
|
||||
"coveralls": "*",
|
||||
"chai": "*",
|
||||
"isparta": "*",
|
||||
"mocha": "*",
|
||||
"sinon": "*",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-unzip": "^0.1.3",
|
||||
"request": "^2.69.0"
|
||||
|
||||
127
src/exec.js
Normal file
127
src/exec.js
Normal file
@@ -0,0 +1,127 @@
|
||||
/*jslint node: true */
|
||||
/*jshint esversion: 6 */
|
||||
/* jshint -W097 */
|
||||
'use strict';
|
||||
var fs = require('fs'),
|
||||
_ = require('underscore'),
|
||||
path = require('path'),
|
||||
child_process = require('child_process');
|
||||
|
||||
var processResults = function (stdout, stderr) {
|
||||
if(stdout && _.isArray(stdout)){
|
||||
_.chain(stdout)
|
||||
.filter((item)=>item && item.length > 0)
|
||||
.each((item)=>console.log(item))
|
||||
.value();
|
||||
}
|
||||
else if(stdout && _.isString(stdout) && stdout.length > 0){
|
||||
console.log(stdout);
|
||||
}
|
||||
if(stderr && _.isString(stderr) && stderr.length > 0){
|
||||
console.log(stderr);
|
||||
}
|
||||
|
||||
};
|
||||
var main = function (options, callback) {
|
||||
var heatFiles = options.heatFiles;
|
||||
var candleFiles = options.candleFiles;
|
||||
var lightFiles = options.lightFiles;
|
||||
var heatCommands = options.heatCommands || null;
|
||||
var candleCommands = options.candleCommands || null;
|
||||
var lightCommands = options.lightCommands || null;
|
||||
var heatPath = options.heatPath || __dirname + "/wixFiles/heat.exe";
|
||||
var lightPath = options.lightPath || __dirname + "/wixFiles/light.exe";
|
||||
var candlePath = options.candlePath || __dirname + "/wixFiles/candle.exe";
|
||||
var cb = callback;
|
||||
var version = options.version;
|
||||
if(version){
|
||||
process.env.BUILD_VERSION = version;
|
||||
}
|
||||
if(!heatCommands){
|
||||
if(!heatFiles || !_.isArray(heatFiles) || heatFiles.length < 1 ){
|
||||
throw "heat files are required if no commands are passed";
|
||||
}
|
||||
checkFiles(heatFiles);
|
||||
}
|
||||
|
||||
if(!candleCommands){
|
||||
|
||||
if(!candleFiles || !_.isArray(candleFiles) || candleFiles.length < 1 ){
|
||||
throw "candle files are required";
|
||||
}
|
||||
|
||||
checkFiles(candleCommands);
|
||||
|
||||
}
|
||||
|
||||
if(!lightCommands){
|
||||
|
||||
if(!lightFiles || !_.isArray(lightFiles) || lightFiles.length < 1 ){
|
||||
throw "light files are required";
|
||||
}
|
||||
|
||||
checkFiles(lightFiles);
|
||||
|
||||
}
|
||||
|
||||
return child_process.execFile(path.normalize(heatPath), heatCommands? heatCommands: _.map(heatFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
|
||||
processResults(stdout, stderr);
|
||||
if(err){
|
||||
if(cb){
|
||||
return cb(err);
|
||||
}else{
|
||||
throw err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
child_process.execFile(path.normalize(candlePath), candleCommands? candleCommands: _.map(candleFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
|
||||
processResults(stdout, stderr);
|
||||
if(err){
|
||||
if(cb){
|
||||
return cb(err);
|
||||
}else{
|
||||
throw err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
child_process.execFile(path.normalize(lightPath), lightCommands? lightCommands: _.map(lightFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
|
||||
processResults(stdout, stderr);
|
||||
if(err){
|
||||
if(cb){
|
||||
return cb(err);
|
||||
}else{
|
||||
throw err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
var checkFiles = function(files){
|
||||
_.each(files, (file)=>{
|
||||
if(!checkFile(file)){
|
||||
throw "error finding file" + file;
|
||||
}
|
||||
});
|
||||
};
|
||||
var checkFile = function (file) {
|
||||
if (!file || file.length < 1) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
fs.accessSync(path.normalize(file), fs.R_OK); //will error if doesnt exist
|
||||
//todo async?
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = main;
|
||||
3
src/generator.js
Normal file
3
src/generator.js
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
|
||||
module.exports=function(){};
|
||||
3
test/mocha.opts
Normal file
3
test/mocha.opts
Normal file
@@ -0,0 +1,3 @@
|
||||
./test/unit/**/*.test.js
|
||||
--reporter spec
|
||||
--recursive
|
||||
1
test/unit/index.test.js
Normal file
1
test/unit/index.test.js
Normal file
@@ -0,0 +1 @@
|
||||
import { assert } from 'chai';
|
||||
Reference in New Issue
Block a user