Skip to content

Commit

Permalink
normalized export task for building project
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Apr 21, 2015
1 parent efcaf8d commit 37ec372
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
13 changes: 12 additions & 1 deletion cache/projectTemplate.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2015.2 (Build 540)" ts="2015-04-12 16:26:04">

<CSP name="CacheUMLExplorer.css" application="">
<![CDATA[{{replace:css}}]]>
</CSP>

<CSP name="CacheUMLExplorer.js" application="">
<![CDATA[{{replace:js}}]]>
</CSP>

<Class name="UMLExplorer.ClassView">
<Description>
Class contains methods that return structured class data.</Description>
Expand Down Expand Up @@ -184,7 +193,9 @@ Method returns user application.</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
&html<{{replace:HTML}}>
&html<
{{replace:HTML}}
>
return $$$OK
]]></Implementation>
</Method>
Expand Down
54 changes: 20 additions & 34 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var gulp = require("gulp"),
concat = require("gulp-concat"),
uglify = require("gulp-uglify"),
wrap = require("gulp-wrap"),
addsrc = require('gulp-add-src'),
minifyCSS = require("gulp-minify-css"),
htmlReplace = require("gulp-html-replace"),
header = require("gulp-header"),
Expand All @@ -29,15 +30,10 @@ gulp.task("clean", function () {
});

gulp.task("gatherScripts", ["clean"], function () {
return gulp.src([
"web/jsLib/joint.min.js",
"web/jsLib/joint.shapes.uml.js",
"web/jsLib/joint.layout.DirectedGraph.min.js",
"web/js/*.js"
])
return gulp.src("web/js/*.js")
.pipe(concat("CacheUMLExplorer.js"))
.pipe(replace(/\/\*\{\{replace:version}}\*\//, "\"" + pkg["version"] + "\""))
//.pipe(wrap("CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());"))
.pipe(wrap("CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());"))
.pipe(uglify({
output: {
ascii_only: true,
Expand All @@ -46,24 +42,19 @@ gulp.task("gatherScripts", ["clean"], function () {
}
}))
.pipe(header(banner, { pkg: pkg }))
.pipe(addsrc.prepend([
"web/jsLib/joint.min.js",
"web/jsLib/joint.shapes.uml.js",
"web/jsLib/joint.layout.DirectedGraph.min.js"
]))
.pipe(concat("CacheUMLExplorer.js"))
.pipe(gulp.dest("build/web/js/"));
});

//gulp.task("concatScripts", ["gatherScripts"], function () {
// return gulp.src([
// "web/jsLib/joint.min.js",
// "web/jsLib/joint.layout.DirectedGraph.min.js",
// "web/jsLib/joint.shapes.uml.js",
// "build/web/js/CacheUMLExplorer.js"
// ])
// .pipe(concat("CacheUMLExplorer.js"))
// .pipe(gulp.dest("build/web/js/"));
//});

gulp.task("gatherCSS", ["clean"], function () {
return gulp.src("web/css/*.css")
.pipe(concat("CacheUMLExplorer.css"))
.pipe(minifyCSS())
.pipe(minifyCSS({ keepSpecialComments: 0 }))
.pipe(gulp.dest("build/web/css/"));
});

Expand All @@ -76,16 +67,6 @@ gulp.task("addHTMLFile", ["clean"], function () {
.pipe(gulp.dest("build/web/"));
});

gulp.task("addHTMLZIPFile", ["clean", "gatherScripts", "gatherCSS"], function () {
var jsRepl = "<script type='text/javascript'>" + fs.readFileSync("build/web/js/CacheUMLExplorer.js", "utf-8") + "</script>",
cssRepl = "<style type='text/css'>" + fs.readFileSync("build/web/css/CacheUMLExplorer.css") + "</style>";
return gulp.src("web/index.html")
.pipe(concat("ZIPindex.html"))
.pipe(replace(/<!\-\- build:js \-\->(.|\r|\n)*<!\-\- endbuild \-\->/, function () { return jsRepl; }))
.pipe(replace(/<!\-\- build:css \-\->(.|\r|\n)*<!\-\- endbuild \-\->/, function () { return cssRepl; }))
.pipe(gulp.dest("build/web"));
});

gulp.task("copyLICENSE", ["clean"], function (){
return gulp.src("LICENSE")
.pipe(gulp.dest("build/"));
Expand All @@ -97,13 +78,18 @@ gulp.task("copyREADME", ["clean"], function (){
});

gulp.task("exportCacheXML", [
"clean", "gatherCSS", "addHTMLFile", "addHTMLZIPFile", "copyLICENSE", "copyREADME"
"clean", "gatherCSS", "gatherScripts", "addHTMLFile", "copyLICENSE", "copyREADME"
], function () {
return gulp.src("cache/projectTemplate.xml")
.pipe(
replace(/\{\{replace:HTML}}/,
fs.readFileSync("build/web/ZIPindex.html", "utf-8"))
)
.pipe(replace(/\{\{replace:HTML}}/, fs.readFileSync("build/web/index.html", "utf-8")))
.pipe(replace(
/\{\{replace:css}}/,
fs.readFileSync("build/web/css/CacheUMLExplorer.css", "utf-8")
))
.pipe(replace(
/\{\{replace:js}}/,
fs.readFileSync("build/web/js/CacheUMLExplorer.js", "utf-8")
))
.pipe(rename(function (path) { path.basename += "-v" + pkg["version"]; }))
.pipe(gulp.dest("build/Cache"));
});
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
"directories": {
"test": "test"
},
"dependencies": {

},
"dependencies": {},
"devDependencies": {
"express": "^5.0.0-alpha.1",
"gulp": "^3.8.11",
"gulp-header": "^1.2.2",
"gulp-add-src": "^0.2.0",
"gulp-clean": "^0.3.1",
"gulp-concat": "^2.4.1",
"gulp-header": "^1.2.2",
"gulp-html-replace": "^1.4.1",
"gulp-minify-css": "^0.3.11",
"gulp-rename": "^1.2.0",
Expand Down

0 comments on commit 37ec372

Please sign in to comment.