Skip to content

Commit 7c1554c

Browse files
author
Pavel Strashkin
committed
Simplify integration and building
1 parent 4ec098c commit 7c1554c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+65915
-65753
lines changed

.bowerrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"interactive": false,
3-
"directory": "vendor/bower_components"
2+
"interactive": false
43
}

Gruntfile.js

Lines changed: 104 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,52 @@
11
'use strict';
22

3-
var resolve = function (dir) {
4-
return require('path').resolve(__dirname, dir);
5-
};
6-
73
module.exports = function (grunt) {
84
require('load-grunt-tasks')(grunt);
95

106
grunt.registerTask('default', ['build', 'connect:livereload', 'open:server', 'watch']);
11-
grunt.registerTask('server', ['release', 'connect:server']);
127
grunt.registerTask('regression', ['build', 'protractor:local']);
138
grunt.registerTask('build', [
14-
'env:build',
159
'jshint',
1610
'clean',
1711
'ngtemplates',
1812
'concat:app',
13+
'concat:vendor',
1914
'concat:index',
20-
'preprocess:index',
2115
'copy:assets',
22-
'copy:vendor',
23-
// 'clean:styles',
2416
'sass:build',
2517
'css_prefix:prefix',
2618
'concat:darkTheme',
27-
'concat:lightTheme',
28-
'cssmin',
29-
'clean:templates',
30-
'clean:temp'
31-
]);
32-
grunt.registerTask('release', [
33-
'env:release',
34-
'jshint',
35-
'clean',
36-
'ngtemplates',
37-
'concat:index',
38-
'concat:vendor',
39-
'preprocess:index',
40-
'uglify',
41-
'copy:assets',
42-
'clean:styles',
43-
'sass:min',
44-
'css_prefix:prefix',
45-
'concat:darkTheme',
46-
'concat:lightTheme',
47-
'cssmin',
48-
'clean:templates',
49-
'clean:temp'
19+
'concat:lightTheme'
5020
]);
5121

5222
grunt.initConfig({
23+
tempdir: '.tmp',
5324
distdir: 'dist',
5425
pkg: grunt.file.readJSON('package.json'),
5526
src: {
5627
js: ['src/**/*.js'],
57-
jsTpl: ['<%= distdir %>/templates/**/*.js'],
28+
jsVendor: [
29+
'bower_components/marked/lib/marked.js',
30+
'bower_components/raml-js-parser/dist/raml-parser.js',
31+
'bower_components/highlightjs/highlight.pack.js',
32+
'bower_components/vkbeautify/vkbeautify.js',
33+
'bower_components/jquery/dist/jquery.js',
34+
'bower_components/velocity/velocity.js',
35+
'bower_components/crypto-js/rollups/hmac-sha1.js',
36+
'bower_components/crypto-js/components/enc-base64.js',
37+
'bower_components/codemirror/lib/codemirror.js',
38+
'bower_components/codemirror/mode/javascript/javascript.js',
39+
'bower_components/codemirror/mode/xml/xml.js',
40+
'bower_components/codemirror/mode/yaml/yaml.js',
41+
'bower_components/codemirror/addon/dialog/dialog.js',
42+
'bower_components/codemirror/addon/search/search.js',
43+
'bower_components/codemirror/addon/search/searchcursor.js',
44+
'bower_components/codemirror/addon/lint/lint.js',
45+
'bower_components/angular/angular.js',
46+
'bower_components/angular-ui-codemirror/ui-codemirror.js',
47+
'bower_components/angular-marked/angular-marked.js',
48+
'bower_components/angular-highlightjs/angular-highlightjs.js'
49+
],
5850
html: ['src/index.html'],
5951
scss: ['src/scss/light-theme.scss', 'src/scss/dark-theme.scss'],
6052
scssWatch: ['src/scss/**/*.scss'],
@@ -64,25 +56,18 @@ module.exports = function (grunt) {
6456
connect: {
6557
options: {
6658
hostname: '0.0.0.0',
67-
port: 9000
59+
port: 9000
6860
},
61+
6962
livereload: {
7063
options: {
7164
middleware: function (connect) {
7265
return [
7366
require('connect-livereload')(),
74-
connect.static(resolve('dist'))
67+
connect.static('dist')
7568
];
7669
}
7770
}
78-
},
79-
server: {
80-
options: {
81-
keepalive: true,
82-
middleware: function (connect) {
83-
return [ connect.static(resolve('dist')) ];
84-
}
85-
}
8671
}
8772
},
8873

@@ -93,58 +78,23 @@ module.exports = function (grunt) {
9378
},
9479

9580
clean: {
96-
build: ['<%= distdir %>/*'],
97-
styles: ['<%= distdir %>/styles/*'],
98-
templates: ['<%= distdir %>/templates'],
99-
temp: ['<%= distdir %>/temp']
81+
build: [
82+
'<%= tempdir %>',
83+
'<%= distdir %>'
84+
]
10085
},
10186

10287
copy: {
10388
assets: {
104-
files: [{ dest: '<%= distdir %>', src : '**', expand: true, cwd: 'src/assets/' }]
105-
},
106-
vendor: {
107-
files: [
108-
{ dest: '<%= distdir %>/scripts/vendor', src : 'marked.js', expand: true, cwd: 'vendor/bower_components/marked/lib/' },
109-
{ dest: '<%= distdir %>/scripts/vendor', src : 'client-oauth2.js', expand: true, cwd: 'vendor/client-oauth2/' },
110-
{ dest: '<%= distdir %>/scripts/vendor/highlightjs', src : 'highlight.pack.js', expand: true, cwd: 'vendor/bower_components/highlightjs/' },
111-
{ dest: '<%= distdir %>/scripts/vendor/vkbeautify', src : 'vkbeautify.js', expand: true, cwd: 'vendor/bower_components/vkbeautify/' },
112-
{ dest: '<%= distdir %>/scripts/vendor/raml', src : 'raml-parser.js', expand: true, cwd: 'vendor/bower_components/raml-js-parser/dist/' },
113-
{ dest: '<%= distdir %>/scripts/vendor/raml', src : 'raml-sanitize.js', expand: true, cwd: 'vendor/raml-sanitize/' },
114-
{ dest: '<%= distdir %>/scripts/vendor/raml', src : 'raml-validate.js', expand: true, cwd: 'vendor/raml-validate/' },
115-
{ dest: '<%= distdir %>/scripts/vendor/jquery', src : 'jquery.js', expand: true, cwd: 'vendor/bower_components/jquery/dist/' },
116-
{ dest: '<%= distdir %>/scripts/vendor/jquery', src : 'velocity.js', expand: true, cwd: 'vendor/bower_components/velocity/' },
117-
{ dest: '<%= distdir %>/scripts/vendor/crypto-js', src : 'hmac-sha1.js', expand: true, cwd: 'vendor/bower_components/crypto-js/rollups/' },
118-
{ dest: '<%= distdir %>/scripts/vendor/crypto-js', src : 'enc-base64.js', expand: true, cwd: 'vendor/bower_components/crypto-js/components/' },
119-
{ dest: '<%= distdir %>/scripts/vendor/codemirror', src : 'codemirror.js', expand: true, cwd: 'vendor/bower_components/codemirror/lib/' },
120-
{ dest: '<%= distdir %>/scripts/vendor/codemirror/mode', src : 'javascript.js', expand: true, cwd: 'vendor/bower_components/codemirror/mode/javascript/' },
121-
{ dest: '<%= distdir %>/scripts/vendor/codemirror/mode', src : 'xml.js', expand: true, cwd: 'vendor/bower_components/codemirror/mode/xml/' },
122-
{ dest: '<%= distdir %>/scripts/vendor/codemirror/mode', src : 'yaml.js', expand: true, cwd: 'vendor/bower_components/codemirror/mode/yaml/' },
123-
{ dest: '<%= distdir %>/scripts/vendor/codemirror/addon', src : 'dialog.js', expand: true, cwd: 'vendor/bower_components/codemirror/addon/dialog/' },
124-
{ dest: '<%= distdir %>/scripts/vendor/codemirror/addon', src : 'search.js', expand: true, cwd: 'vendor/bower_components/codemirror/addon/search/' },
125-
{ dest: '<%= distdir %>/scripts/vendor/codemirror/addon', src : 'searchcursor.js', expand: true, cwd: 'vendor/bower_components/codemirror/addon/search/' },
126-
{ dest: '<%= distdir %>/scripts/vendor/codemirror/addon', src : 'lint.js', expand: true, cwd: 'vendor/bower_components/codemirror/addon/lint/' },
127-
{ dest: '<%= distdir %>/scripts/vendor/angular', src : 'angular.js', expand: true, cwd: 'vendor/bower_components/angular/' },
128-
{ dest: '<%= distdir %>/scripts/vendor/angular', src : 'ui-codemirror.js', expand: true, cwd: 'vendor/bower_components/angular-ui-codemirror/' },
129-
{ dest: '<%= distdir %>/scripts/vendor/angular', src : 'angular-marked.js', expand: true, cwd: 'vendor/bower_components/angular-marked/' },
130-
{ dest: '<%= distdir %>/scripts/vendor/angular', src : 'angular-highlightjs.js', expand: true, cwd: 'vendor/bower_components/angular-highlightjs/' }
131-
]
132-
}
133-
},
134-
135-
env: {
136-
build: {
137-
NODE_ENV: 'DEVELOPMENT'
138-
},
139-
release: {
140-
NODE_ENV: 'PRODUCTION'
141-
}
142-
},
143-
144-
preprocess: {
145-
index: {
146-
src: '<%= distdir %>/index.html',
147-
dest: '<%= distdir %>/index.html'
89+
files: [{
90+
dest: '<%= distdir %>',
91+
cwd: 'src/assets/',
92+
expand: true,
93+
src: [
94+
'**',
95+
'!styles/**/*'
96+
]
97+
}]
14898
}
14999
},
150100

@@ -153,103 +103,91 @@ module.exports = function (grunt) {
153103
options: {
154104
module: 'ramlConsoleApp'
155105
},
156-
cwd: 'src/app',
157-
src: '**/*.tpl.html',
158-
dest: '<%= distdir %>/templates/app.js'
106+
107+
cwd: 'src/app',
108+
src: '**/*.tpl.html',
109+
dest: '<%= tempdir %>/templates/app.js'
159110
}
160111
},
161112

162-
concat:{
163-
app:{
164-
src:['<%= src.js %>', '<%= src.jsTpl %>'],
165-
dest:'<%= distdir %>/scripts/<%= pkg.name %>.js'
113+
concat: {
114+
app: {
115+
dest: '<%= distdir %>/scripts/<%= pkg.name %>.js',
116+
src: [
117+
'<%= src.js %>',
118+
'<%= ngtemplates.ramlConsole.dest %>'
119+
]
166120
},
121+
167122
index: {
168-
src: 'src/index.html',
169-
dest: '<%= distdir %>/index.html',
170123
options: {
171124
process: true
172-
}
125+
},
126+
127+
dest: '<%= distdir %>/index.html',
128+
src: 'src/index.html'
173129
},
130+
174131
darkTheme: {
175-
src: ['<%= distdir %>/styles/dark-theme.css', 'src/assets/styles/vendor/codemirror-dark.css'],
176-
dest: '<%= distdir %>/styles/dark-theme.css'
132+
dest: '<%= distdir %>/styles/<%= pkg.name %>-dark-theme.css',
133+
src: [
134+
'src/assets/styles/vendor/codemirror.css',
135+
'src/assets/styles/fonts.css',
136+
'src/assets/styles/error.css',
137+
'<%= distdir %>/styles/<%= pkg.name %>-dark-theme.css',
138+
'src/assets/styles/vendor/codemirror-dark.css'
139+
]
177140
},
141+
178142
lightTheme: {
179-
src: ['<%= distdir %>/styles/light-theme.css', 'src/assets/styles/vendor/codemirror-light.css'],
180-
dest: '<%= distdir %>/styles/light-theme.css'
143+
dest: '<%= distdir %>/styles/<%= pkg.name %>-light-theme.css',
144+
src: [
145+
'src/assets/styles/vendor/codemirror.css',
146+
'src/assets/styles/fonts.css',
147+
'src/assets/styles/error.css',
148+
'<%= distdir %>/styles/<%= pkg.name %>-light-theme.css',
149+
'src/assets/styles/vendor/codemirror-light.css'
150+
]
181151
},
182-
vendor: {
183-
src: [
184-
'vendor/bower_components/marked/lib/marked.js',
185-
'vendor/client-oauth2/client-oauth2.js',
186-
'vendor/bower_components/highlightjs/highlight.pack.js',
187-
'vendor/bower_components/vkbeautify/vkbeautify.js',
188-
'vendor/bower_components/raml-js-parser/dist/raml-parser.js',
189-
'vendor/raml-validate/raml-validate.js',
190-
'vendor/raml-sanitize/raml-sanitize.js',
191-
'vendor/bower_components/jquery/dist/jquery.min.js',
192-
'vendor/bower_components/velocity/velocity.min.js',
193-
'vendor/bower_components/crypto-js/rollups/hmac-sha1.js',
194-
'vendor/bower_components/crypto-js/components/enc-base64-min.js',
195-
'vendor/codemirror/codemirror.min.js',
196-
'vendor/bower_components/angular/angular.min.js',
197-
'vendor/bower_components/angular-ui-codemirror/ui-codemirror.min.js',
198-
'vendor/bower_components/angular-marked/angular-marked.min.js',
199-
'vendor/bower_components/angular-highlightjs/angular-highlightjs.min.js'
200-
],
201-
dest:'<%= distdir %>/scripts/vendor.js'
202-
}
203-
},
204152

205-
uglify: {
206-
app:{
207-
src: ['<%= src.js %>' ,'<%= src.jsTpl %>'],
208-
dest: '<%= distdir %>/scripts/<%= pkg.name %>.js',
209-
options: {
210-
wrap: true,
211-
mangle: false
212-
}
213-
},
214153
vendor: {
215-
src: '<%= distdir %>/scripts/vendor.js',
216-
dest: '<%= distdir %>/scripts/vendor.js',
217-
options: {
218-
mangle: true
219-
}
154+
src: '<%= src.jsVendor %>',
155+
dest: '<%= distdir %>/scripts/<%= pkg.name %>-vendor.js'
220156
}
221157
},
222158

223159
sass: {
224160
build: {
225-
files: {
226-
'<%= distdir %>/temp/styles/light-theme.css': 'src/scss/light-theme.scss',
227-
'<%= distdir %>/temp/styles/dark-theme.css': 'src/scss/dark-theme.scss'
228-
},
229161
options: {
230162
sourcemap: 'none',
231-
style: 'expanded'
163+
style: 'expanded'
164+
},
165+
166+
files: {
167+
'<%= distdir %>/styles/<%= pkg.name %>-light-theme.css': 'src/scss/light-theme.scss',
168+
'<%= distdir %>/styles/<%= pkg.name %>-dark-theme.css': 'src/scss/dark-theme.scss'
232169
}
233170
},
234171
min: {
235-
files: {
236-
'<%= distdir %>/temp/styles/light-theme.css': 'src/scss/light-theme.scss',
237-
'<%= distdir %>/temp/styles/dark-theme.css': 'src/scss/dark-theme.scss'
238-
},
239172
options: {
240173
sourcemap: 'none',
241-
style: 'compressed'
174+
style: 'compressed'
175+
},
176+
177+
files: {
178+
'<%= distdir %>/styles/<%= pkg.name %>-light-theme.css': 'src/scss/light-theme.scss',
179+
'<%= distdir %>/styles/<%= pkg.name %>-dark-theme.css': 'src/scss/dark-theme.scss'
242180
}
243181
}
244182
},
245183

246-
watch:{
184+
watch: {
247185
build: {
248186
options: {
249187
livereload: true
250188
},
251-
tasks:['build'],
252-
files:[
189+
tasks: ['build'],
190+
files: [
253191
'<%= src.js %>',
254192
'<%= src.scssWatch %>',
255193
'src/app/**/*.tpl.html',
@@ -258,33 +196,32 @@ module.exports = function (grunt) {
258196
}
259197
},
260198

261-
cssmin: {
262-
vendor: {
263-
files: {
264-
'<%= distdir %>/styles/vendor.css': ['src/assets/styles/vendor/codemirror.css', 'src/assets/styles/fonts.css', 'src/assets/styles/error.css']
265-
}
266-
}
267-
},
268-
269199
/*jshint camelcase: false */
270200
css_prefix: {
271201
prefix: {
272202
options: {
273203
prefix: 'raml-console-'
274204
},
205+
275206
files: {
276-
'<%= distdir %>/styles/light-theme.css': '<%= distdir %>/temp/styles/light-theme.css',
277-
'<%= distdir %>/styles/dark-theme.css': '<%= distdir %>/temp/styles/dark-theme.css'
207+
'<%= distdir %>/styles/<%= pkg.name %>-light-theme.css': '<%= distdir %>/styles/<%= pkg.name %>-light-theme.css',
208+
'<%= distdir %>/styles/<%= pkg.name %>-dark-theme.css': '<%= distdir %>/styles/<%= pkg.name %>-dark-theme.css'
278209
}
279210
}
280211
},
281212
/*jshint camelcase: true */
282213

283-
jshint:{
284-
files:['gruntFile.js', '<%= src.js %>', '<%= src.test %>'],
214+
jshint: {
285215
options: {
286216
jshintrc: '.jshintrc'
287-
}
217+
},
218+
219+
files: [
220+
'Gruntfile.js',
221+
'<%= src.js %>',
222+
'<%= src.test %>',
223+
'!src/vendor/**/*.js'
224+
]
288225
},
289226

290227
protractor: {

0 commit comments

Comments
 (0)