-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGruntfile.js
206 lines (181 loc) · 5.08 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
require('grunt-karma')(grunt);
//cant load this with require
grunt.loadNpmTasks('grunt-contrib-jshint');
if (grunt.option('target') && !grunt.file.isDir(grunt.option('target'))) {
grunt.fail.warn('The --target option specified is not a valid directory');
}
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dest: grunt.option('target') || 'dist',
basePath: 'App_Plugins/<%= pkg.name %>',
concat: {
dist: {
src: [
'app/scripts/controllers/*.js'
],
dest: '<%= dest %>/<%= basePath %>/js/svg.icon.picker.js',
nonull: true
}
},
less: {
dist: {
options: {
paths: ['app/styles'],
},
files: {
'<%= dest %>/<%= basePath %>/css/svg.icon.picker.css': 'app/styles/svg.icon.picker.less',
}
}
},
watch: {
options: {
atBegin: true
},
less: {
files: ['app/styles/**/*.less'],
tasks: ['less:dist']
},
js: {
files: ['app/scripts/**/*.js'],
tasks: ['concat:dist']
},
testControllers: {
files: ['app/scripts/**/*.controller.js', 'test/specs/**/*.spec.js'],
tasks: ['jshint', 'test']
},
html: {
files: ['app/views/**/*.html'],
tasks: ['copy:views']
},
config: {
files: ['config/package.manifest'],
tasks: ['copy:config']
}
},
copy: {
config: {
src: 'config/package.manifest',
dest: '<%= dest %>/<%= basePath %>/package.manifest',
},
views: {
expand: true,
cwd: 'app/views/',
src: '**',
dest: '<%= dest %>/<%= basePath %>/views/'
},
nuget: {
expand: true,
cwd: '<%= dest %>',
src: '**',
dest: 'tmp/nuget/content/'
},
umbraco: {
expand: true,
cwd: '<%= dest %>/',
src: '**',
dest: 'tmp/umbraco/'
},
testAssets: {
expand: true,
cwd: '<%= dest %>',
src: ['js/umbraco.*.js', 'lib/**/*.js'],
dest: 'test/assets/'
}
},
template: {
nuspec: {
options: {
data: {
name: '<%= pkg.name %>',
version: '<%= pkg.version %>',
author: '<%= pkg.author.name %>',
description: '<%= pkg.description %>'
}
},
files: {
'tmp/nuget/<%= pkg.name %>.nuspec': 'config/package.nuspec'
}
}
},
mkdir: {
pkg: {
options: {
create: ['pkg/nuget', 'pkg/umbraco']
},
},
},
nugetpack: {
dist: {
src: 'tmp/nuget/<%= pkg.name %>.nuspec',
dest: 'pkg/nuget/'
}
},
umbracoPackage: {
options: {
name: '<%= pkg.name %>',
version: '<%= pkg.version %>',
url: '<%= pkg.url %>',
license: '<%= pkg.license %>',
licenseUrl: '<%= pkg.licenseUrl %>',
author: '<%= pkg.author.name %>',
authorUrl: '<%= pkg.author.url %>',
manifest: 'config/package.xml',
readme: 'config/readme.txt',
sourceDir: 'tmp/umbraco',
outputDir: 'pkg/umbraco',
}
},
clean: {
dist: '[object Object]',
test: 'test/assets'
},
karma: {
unit: {
configFile: 'test/karma.conf.js'
}
},
jshint: {
dev: {
files: {
src: ['app/scripts/**/*.js']
},
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
boss: true,
eqnull: true,
//NOTE: we need to use eval sometimes so ignore it
evil: true,
//NOTE: we need to check for strings such as "javascript:" so don't throw errors regarding those
scripturl: true,
//NOTE: we ignore tabs vs spaces because enforcing that causes lots of errors depending on the text editor being used
smarttabs: true,
globals: {}
}
}
}
});
grunt.registerTask('default', ['jshint', 'concat', 'less', 'copy:config', 'copy:views']);
grunt.registerTask('nuget', ['clean', 'default', 'copy:nuget', 'template:nuspec', 'mkdir:pkg', 'nugetpack']);
grunt.registerTask('package', ['clean', 'default', 'copy:umbraco', 'mkdir:pkg', 'umbracoPackage']);
grunt.registerTask('test', 'Clean, copy test assets, test', function () {
var assetsDir = grunt.config.get('dest');
//copies over umbraco assets from --target, this must point at the /umbraco/ directory
if (assetsDir !== 'dist') {
grunt.task.run(['clean:test', 'copy:testAssets', 'karma']);
} else if (grunt.file.isDir('test/assets/js/')) {
grunt.log.oklns('Test assets found, running tests');
grunt.task.run(['karma']);
} else {
grunt.log.errorlns('Tests assets not found, skipping tests');
}
});
};