This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
/
Gruntfile.js
173 lines (158 loc) · 3.92 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
module.exports = function (grunt) {
'use strict';
var isVagrant = (process.env.PWD === '/vagrant');
if (isVagrant) {
grunt.log.writeln('-> ' + 'vagrant detected'.cyan);
}
var gtx = require('gruntfile-gtx').wrap(grunt);
gtx.loadNpm([
'grunt-contrib-jshint',
'grunt-contrib-copy',
'grunt-contrib-clean',
'grunt-tslint',
'grunt-typescript',
'grunt-execute',
'grunt-shell',
'grunt-todos',
'grunt-mocha-test'
]);
// gtx.autoNpmPkg();
// gtx.autoNpm();
// gtx.loadTasks('tasks');
//defaults and one-off tasks
gtx.addConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: grunt.util._.defaults(grunt.file.readJSON('.jshintrc'), {
reporter: './node_modules/jshint-path-reporter'
}),
support: ['Gruntfile.js', 'tasks/**/*.js', 'test/*.js', 'lib/**/*.js'],
fixtures: ['test/**/fixtures/**/*.js']
},
tslint: {
options: {
configuration: grunt.file.readJSON('tslint.json')
},
source: ['src/**/*.ts'],
helper: ['test/*.ts'],
tests: ['test/*.ts', 'test/*/.ts', 'test/**/src/**/*.ts']
},
todos: {
options: {
verbose: false,
priorities: {
low: null,
med: /(TODO|FIXME)/
},
reporter: require('./lib/grunt/todos-reporter').make(grunt)
},
all: {
options: {},
src: ['src/**/*.ts', 'test/**/src/**/*.ts']
}
},
clean: {
tmp: ['tmp/**/*', 'test/tmp/**/*'],
build: ['build/*.js', 'build/*.js.map']
},
copy: {
cli: {
src: ['src/cli.js'],
dest: 'build/cli.js'
}
},
mochaTest: {
options: {
reporter: 'mocha-unfunk-reporter',
timeout: 3000
},
integrity: ['test/integrity.js']
},
typescript: {
options: {
module: 'commonjs',
target: 'es5',
base_path: 'src/',
declaration: false,
// should be on but is buggy
sourcemap: true
},
api: {
src: ['src/api.ts'],
dest: 'build/api.js'
},
cli: {
src: ['src/cli.ts'],
dest: 'build/cli.js'
},
dev: {
src: ['src/dev.ts'],
dest: 'tmp/dev.js'
}
},
shell: {
cli: {
command: 'node ./build/cli --help',
options: {
stdout: true
}
}
},
execute: {
dev: {
before: function (grunt) {
grunt.log.writeln('devdevedvedv');
},
src: ['tmp/dev.js']
}
}
});
// module tester
gtx.define('moduleTest', function (macro, id) {
var testPath = 'test/modules/' + id + '/';
macro.newTask('clean', [testPath + 'tmp/**/*']);
macro.newTask('tslint', {
src: [testPath + 'src/**/*.ts']
});
macro.newTask('typescript', {
options: {
base_path: testPath
},
src: [testPath + 'src/**/*.ts'],
dest: testPath + 'tmp/' + id + '.test.js'
});
macro.newTask('mochaTest', {
options: {
timeout: macro.getParam('timeout', 3000)
},
src: [testPath + 'tmp/**/*.test.js']
});
macro.tag('module');
//TODO expand gruntfile-gtx to support a run-once dependency (like tslint:source)
}, {
concurrent: 3
});
// assemble!
gtx.alias('prep', ['clean:tmp', 'jshint:support', 'jshint:fixtures']);
// cli commands
gtx.alias('build', ['prep', 'clean:build', 'typescript:api', 'typescript:cli', 'copy:cli', 'tslint:source', 'mochaTest:integrity']);
gtx.alias('test', ['build', 'gtx-type:moduleTest']);
gtx.alias('default', ['build', 'test']);
var longTimer = (isVagrant ? 250000 : 5000);
// modules
gtx.create('xm', 'moduleTest', null, 'lib');
gtx.create('git', 'moduleTest', {timeout: longTimer}, 'lib');
gtx.create('tsd', 'moduleTest', {timeout: longTimer}, 'lib');
gtx.create('core,api,cli', 'moduleTest', {timeout: longTimer}, 'core');
gtx.alias('run', ['build', 'shell:cli']);
gtx.alias('dev', ['prep', 'typescript:dev', 'execute:dev']);
// additional editor toolbar mappings
gtx.alias('edit_01', 'gtx:tsd');
gtx.alias('edit_02', 'gtx:api');
//gtx.alias('edit_03', 'build', 'gtx:cli');
gtx.alias('edit_03', 'gtx:core');
gtx.alias('edit_04', 'gtx:git');
gtx.alias('edit_05', 'gtx:xm');
// build and send to grunt.initConfig();
gtx.finalise();
};