@@ -14,7 +14,10 @@ var gulp = require("gulp"),
14
14
autoprefixer = require ( 'autoprefixer-core' ) ,
15
15
pkg = require ( "./package.json" ) ,
16
16
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" ;
18
21
19
22
var banner = [
20
23
"" ,
@@ -26,7 +29,12 @@ var banner = [
26
29
" ** @see https://github.com/ZitRos/CacheClassExplorer" ,
27
30
" **/" ,
28
31
""
29
- ] . join ( "\n" ) ;
32
+ ] . join ( "\n" ) ,
33
+ context = {
34
+ context : {
35
+ package : pkg
36
+ }
37
+ } ;
30
38
31
39
var specialReplace = function ( ) {
32
40
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 () {
42
50
43
51
gulp . task ( "gatherLibs" , [ "clean" ] , function ( ) {
44
52
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"
51
59
] )
52
60
. pipe ( uglify ( {
53
61
output : {
@@ -58,18 +66,18 @@ gulp.task("gatherLibs", ["clean"], function () {
58
66
preserveComments : "some"
59
67
} ) )
60
68
. pipe ( addsrc . append ( [
61
- "web/jsLib/joint.layout.DirectedGraph.min.js"
69
+ "src/ web/jsLib/joint.layout.DirectedGraph.min.js"
62
70
] ) )
63
71
. pipe ( stripComments ( { safe : true } ) )
64
- . pipe ( concat ( "CacheClassExplorer .js" ) )
72
+ . pipe ( concat ( "index .js" ) )
65
73
. pipe ( replace ( / / g, "\\x0B" ) )
66
74
. pipe ( replace ( / \x1b / g, "\\x1B" ) )
67
75
. pipe ( gulp . dest ( "build/web/js/" ) ) ;
68
76
} ) ;
69
77
70
78
gulp . 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" ) )
73
81
. pipe ( specialReplace ( ) )
74
82
. pipe ( wrap ( "CacheClassExplorer = (function(){<%= contents %> return CacheClassExplorer;}());" ) )
75
83
. pipe ( uglify ( {
@@ -81,25 +89,25 @@ gulp.task("gatherScripts", ["clean", "gatherLibs"], function () {
81
89
preserveComments : "some"
82
90
} ) )
83
91
. 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" ) )
86
94
. pipe ( replace ( / \x1b / g, "\\x1B" ) )
87
95
. pipe ( gulp . dest ( "build/web/js/" ) ) ;
88
96
} ) ;
89
97
90
98
gulp . 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" ) )
93
101
. pipe ( postcss ( [ autoprefixer ( { browsers : [ "last 3 version" ] } ) ] ) )
94
102
. pipe ( minifyCSS ( { keepSpecialComments : 0 } ) )
95
103
. pipe ( gulp . dest ( "build/web/css/" ) ) ;
96
104
} ) ;
97
105
98
106
gulp . task ( "addHTMLFile" , [ "clean" ] , function ( ) {
99
- return gulp . src ( "web/index.html" )
107
+ return gulp . src ( "src/ web/index.html" )
100
108
. pipe ( htmlReplace ( {
101
- "css" : "css/CacheClassExplorer .css" ,
102
- "js" : "js/CacheClassExplorer .js"
109
+ "css" : "css/index .css" ,
110
+ "js" : "js/index .js"
103
111
} ) )
104
112
. pipe ( gulp . dest ( "build/web/" ) ) ;
105
113
} ) ;
@@ -114,33 +122,32 @@ gulp.task("copyREADME", ["clean"], function () {
114
122
. pipe ( gulp . dest ( "build/" ) ) ;
115
123
} ) ;
116
124
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" ) ) ;
136
142
} ) ;
137
143
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/**/*.* "] )
140
146
. pipe ( zip ( "CacheClassExplorer-v" + pkg [ "version" ] + ".zip" , {
141
147
comment : "Cache UML explorer v" + pkg [ "version" ] + " by Nikita Savchenko\n\n" +
142
148
"+ 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"
144
151
} ) )
145
152
. pipe ( gulp . dest ( "build" ) ) ;
146
153
} ) ;
@@ -150,4 +157,4 @@ gulp.task("desktop", ["default"], function () {
150
157
. pipe ( gulp . dest ( "C:/Users/ZitRo/Desktop" ) ) ;
151
158
} ) ;
152
159
153
- gulp . task ( "default" , [ "zipRelease " ] ) ;
160
+ gulp . task ( "default" , [ "cls " ] ) ;
0 commit comments