@@ -14,7 +14,10 @@ var gulp = require("gulp"),
1414 autoprefixer = require ( 'autoprefixer-core' ) ,
1515 pkg = require ( "./package.json" ) ,
1616 zip = require ( "gulp-zip" ) ,
17- rename = require ( "gulp-rename" ) ;
17+ rename = require ( "gulp-rename" ) ,
18+ preprocess = require ( "gulp-preprocess" ) ;
19+
20+ var INSTALLER_CLASS_NAME = "ClassExplorer.Installer" ;
1821
1922var banner = [
2023 "" ,
@@ -26,7 +29,12 @@ var banner = [
2629 " ** @see https://github.com/ZitRos/CacheClassExplorer" ,
2730 " **/" ,
2831 ""
29- ] . join ( "\n" ) ;
32+ ] . join ( "\n" ) ,
33+ context = {
34+ context : {
35+ package : pkg
36+ }
37+ } ;
3038
3139var specialReplace = function ( ) {
3240 return replace ( / [ ^ \s ] + \/ \* b u i l d \. r e p l a c e : ( .* ) \* \/ / g, function ( part , match ) {
@@ -42,12 +50,12 @@ gulp.task("clean", function () {
4250
4351gulp . task ( "gatherLibs" , [ "clean" ] , function ( ) {
4452 return gulp . src ( [
45- "web/jsLib/jquery.min.js" ,
46- "web/jsLib/lodash.min.js" ,
47- "web/jsLib/backbone-min.js" ,
48- "web/jsLib/joint.js" ,
49- "web/jsLib/joint.shapes.uml.js" ,
50- "web/jsLib/ImageExporter.js"
53+ "src/ web/jsLib/jquery.min.js" ,
54+ "src/ web/jsLib/lodash.min.js" ,
55+ "src/ web/jsLib/backbone-min.js" ,
56+ "src/ web/jsLib/joint.js" ,
57+ "src/ web/jsLib/joint.shapes.uml.js" ,
58+ "src/ web/jsLib/ImageExporter.js"
5159 ] )
5260 . pipe ( uglify ( {
5361 output : {
@@ -58,18 +66,18 @@ gulp.task("gatherLibs", ["clean"], function () {
5866 preserveComments : "some"
5967 } ) )
6068 . pipe ( addsrc . append ( [
61- "web/jsLib/joint.layout.DirectedGraph.min.js"
69+ "src/ web/jsLib/joint.layout.DirectedGraph.min.js"
6270 ] ) )
6371 . pipe ( stripComments ( { safe : true } ) )
64- . pipe ( concat ( "CacheClassExplorer .js" ) )
72+ . pipe ( concat ( "index .js" ) )
6573 . pipe ( replace ( / / g, "\\x0B" ) )
6674 . pipe ( replace ( / \x1b / g, "\\x1B" ) )
6775 . pipe ( gulp . dest ( "build/web/js/" ) ) ;
6876} ) ;
6977
7078gulp . task ( "gatherScripts" , [ "clean" , "gatherLibs" ] , function ( ) {
71- return gulp . src ( "web/js/*.js" )
72- . pipe ( concat ( "CacheClassExplorer .js" ) )
79+ return gulp . src ( "src/ web/js/*.js" )
80+ . pipe ( concat ( "index .js" ) )
7381 . pipe ( specialReplace ( ) )
7482 . pipe ( wrap ( "CacheClassExplorer = (function(){<%= contents %> return CacheClassExplorer;}());" ) )
7583 . pipe ( uglify ( {
@@ -81,25 +89,25 @@ gulp.task("gatherScripts", ["clean", "gatherLibs"], function () {
8189 preserveComments : "some"
8290 } ) )
8391 . pipe ( header ( banner , { pkg : pkg } ) )
84- . pipe ( addsrc . prepend ( "build/web/js/CacheClassExplorer .js" ) )
85- . pipe ( concat ( "CacheClassExplorer .js" ) )
92+ . pipe ( addsrc . prepend ( "build/web/js/index .js" ) )
93+ . pipe ( concat ( "index .js" ) )
8694 . pipe ( replace ( / \x1b / g, "\\x1B" ) )
8795 . pipe ( gulp . dest ( "build/web/js/" ) ) ;
8896} ) ;
8997
9098gulp . task ( "gatherCSS" , [ "clean" ] , function ( ) {
91- return gulp . src ( "web/css/*.css" )
92- . pipe ( concat ( "CacheClassExplorer .css" ) )
99+ return gulp . src ( "src/ web/css/*.css" )
100+ . pipe ( concat ( "index .css" ) )
93101 . pipe ( postcss ( [ autoprefixer ( { browsers : [ "last 3 version" ] } ) ] ) )
94102 . pipe ( minifyCSS ( { keepSpecialComments : 0 } ) )
95103 . pipe ( gulp . dest ( "build/web/css/" ) ) ;
96104} ) ;
97105
98106gulp . task ( "addHTMLFile" , [ "clean" ] , function ( ) {
99- return gulp . src ( "web/index.html" )
107+ return gulp . src ( "src/ web/index.html" )
100108 . pipe ( htmlReplace ( {
101- "css" : "css/CacheClassExplorer .css" ,
102- "js" : "js/CacheClassExplorer .js"
109+ "css" : "css/index .css" ,
110+ "js" : "js/index .js"
103111 } ) )
104112 . pipe ( gulp . dest ( "build/web/" ) ) ;
105113} ) ;
@@ -114,33 +122,32 @@ gulp.task("copyREADME", ["clean"], function () {
114122 . pipe ( gulp . dest ( "build/" ) ) ;
115123} ) ;
116124
117- gulp . task ( "exportCacheXML" , [
118- "clean" , "gatherCSS" , "gatherScripts" , "addHTMLFile" , "copyLICENSE" , "copyREADME"
119- ] , function ( ) {
120- return gulp . src ( "cache/projectTemplate.xml" )
121- . pipe ( specialReplace ( ) )
122- . pipe ( replace (
123- / \{ \{ r e p l a c e : c s s } } / ,
124- function ( ) { return fs . readFileSync ( "build/web/css/CacheClassExplorer.css" , "utf-8" ) ; }
125- ) )
126- . pipe ( replace (
127- / \{ \{ r e p l a c e : j s } } / ,
128- function ( ) { return fs . readFileSync ( "build/web/js/CacheClassExplorer.js" , "utf-8" ) ; }
129- ) )
130- . pipe ( replace (
131- / \{ \{ r e p l a c e : h t m l } } / ,
132- function ( ) { return fs . readFileSync ( "build/web/index.html" , "utf-8" ) ; }
133- ) )
134- . pipe ( rename ( function ( path ) { path . basename = "CacheClassExplorer-v" + pkg [ "version" ] ; } ) )
135- . pipe ( gulp . dest ( "build/Cache" ) ) ;
125+ gulp . task ( "pre-cls" , [ "clean" ] , function ( ) {
126+ return gulp . src ( [ "src/cls/**/*.cls" ] )
127+ . pipe ( rename ( function ( f ) {
128+ f . basename = ( f . dirname === "." ? "" : f . dirname + "." ) + f . basename ;
129+ f . dirname = "." ;
130+ if ( f . basename !== INSTALLER_CLASS_NAME )
131+ context . context . compileAfter +=
132+ ( context . context . compileAfter ? "," : "" ) + f . basename ;
133+ } ) )
134+ . pipe ( gulp . dest ( "build/cls/" ) ) ;
135+ } ) ;
136+
137+ gulp . task ( "cls" , [ "pre-cls" , "copyLICENSE" , "copyREADME" , "addHTMLFile" , "gatherScripts" ,
138+ "gatherCSS" ] , function ( ) {
139+ return gulp . src ( [ "build/cls/**/*.cls" ] )
140+ . pipe ( preprocess ( context ) )
141+ . pipe ( gulp . dest ( "build/cls" ) ) ;
136142} ) ;
137143
138- gulp . task ( "zipRelease" , [ "exportCacheXML" ] , function ( ) {
139- return gulp . src ( [ "build/**/*" , "!build/web/**/*" ] )
144+ gulp . task ( "zipRelease" , function ( ) {
145+ return gulp . src ( [ "build/**/*" , "!build/web/**/*.*" , "!build/cls/**/*.* "] )
140146 . pipe ( zip ( "CacheClassExplorer-v" + pkg [ "version" ] + ".zip" , {
141147 comment : "Cache UML explorer v" + pkg [ "version" ] + " by Nikita Savchenko\n\n" +
142148 "+ Cache folder holds XML file to import to InterSystems Cache.\n\n" +
143- "For further information about installation and information, check README.md file."
149+ "For further information about installation and information, check README.md file.\n\n"
150+ + "See https://github.com/intersystems-ru/UMLExplorer"
144151 } ) )
145152 . pipe ( gulp . dest ( "build" ) ) ;
146153} ) ;
@@ -150,4 +157,4 @@ gulp.task("desktop", ["default"], function () {
150157 . pipe ( gulp . dest ( "C:/Users/ZitRo/Desktop" ) ) ;
151158} ) ;
152159
153- gulp . task ( "default" , [ "zipRelease " ] ) ;
160+ gulp . task ( "default" , [ "cls " ] ) ;
0 commit comments