-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from thomashaenig/master
npm ready
- Loading branch information
Showing
23 changed files
with
3,675 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
node_modules/ | ||
src/ | ||
test/ | ||
|
||
*.yml | ||
gulpfile.js | ||
tsconfig.build.json | ||
tsconfig.test.json | ||
package-lock.json | ||
.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
var exec = require('child_process').exec | ||
|
||
const packageJson = require("./package.json"); | ||
|
||
function execCommand (cmd) { | ||
return new Promise((resolve, reject) => { | ||
try { | ||
exec(cmd, { cwd: __dirname }, (err, stdout, stderr) => { | ||
resolve(stdout.split("commit")); | ||
}); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
|
||
}); | ||
} | ||
|
||
function getVersionNumber () { | ||
return new Promise((resolve, reject) => { | ||
execCommand("git log") | ||
.then((logs) => { | ||
logs.forEach((log) => { | ||
let pos = log.indexOf("v:"); | ||
if (pos >= 0) { | ||
resolve(log.substring(pos+2,pos + 8).trim()); | ||
} | ||
}); | ||
}) | ||
.catch((error) => { | ||
console.error("Error in getVersionNumber", error); | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
|
||
function getNumberOfCommits () { | ||
return new Promise((resolve, reject) => { | ||
execCommand("git log") | ||
.then((logs) => { | ||
let counter = 0; | ||
logs.shift(); | ||
for (var log of logs) { | ||
let pos = log.indexOf("v:"); | ||
if (pos >= 0) { | ||
resolve(counter); | ||
return; | ||
} | ||
counter ++; | ||
} | ||
resolve(counter); | ||
}) | ||
.catch((error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
|
||
function getFullVersionString() { | ||
return new Promise((resolve, reject) => { | ||
let str = ""; | ||
getVersionNumber() | ||
.then((res) => { | ||
str += res + "+"; | ||
return getNumberOfCommits(); | ||
}) | ||
.then((res) => { | ||
str += res + "+"; | ||
return execCommand("git rev-parse --abbrev-ref HEAD"); | ||
}) | ||
.then((res) => { | ||
str += res[0].trim() + "+"; | ||
return execCommand("git rev-parse HEAD"); | ||
}) | ||
.then((res) => { | ||
resolve(str += res[0].trim()); | ||
}) | ||
.catch((error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
getVersionNumber : function () { return getVersionNumber()}, | ||
getNumberOfCommits: function () { return getNumberOfCommits()}, | ||
getFullVersionString: function () { return getFullVersionString()} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var gulp = require('gulp'); | ||
var less = require('gulp-less'); | ||
var path = require('path'); | ||
var rename = require('gulp-rename'); | ||
let mod = require("gulp-json-modify"); | ||
var replace = require('gulp-string-replace'); | ||
|
||
var package = require("./package.json"); | ||
|
||
var gitVersion = require("./gulpGitPlugin"); | ||
|
||
gulp.task('less', function () { | ||
return gulp.src('./src/**/*.less') | ||
.pipe(less({ | ||
paths: [ path.join(__dirname, 'less', 'includes') ] | ||
})) | ||
// .pipe(rename({dirname: ''})) | ||
.pipe(gulp.dest('./dist')); | ||
}); | ||
|
||
gulp.task('html', function () { | ||
return gulp.src('./src/**/*.html') | ||
// .pipe(rename({dirname: ''})) | ||
.pipe(gulp.dest('./dist')); | ||
}) | ||
|
||
gulp.task("gitversionPackage", () => { | ||
gitVersion.getVersionNumber() | ||
.then((versionnumber) => { | ||
return gulp.src("./package.json") | ||
.pipe(mod({ | ||
key: "version", | ||
value: versionnumber | ||
})) | ||
.pipe(gulp.dest("./")); | ||
}) | ||
.catch((error) => { | ||
console.error("Error in gitversionPackage gulp task", error); | ||
}); | ||
}); | ||
|
||
gulp.task("addVersionNumber", () => { | ||
gitVersion.getFullVersionString() | ||
.then((res) => { | ||
return gulp.src('./dist/daVinci.js') | ||
.pipe(replace(/\|GitVersionNumber\|/, res)) | ||
.pipe(gulp.dest('./dist')); | ||
}) | ||
.catch((error) => { | ||
console.log("Error in addVersionNumber gulp task", error); | ||
}); | ||
}); |
Oops, something went wrong.