forked from DevExpress/devextreme-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
155 lines (131 loc) · 3.82 KB
/
gulpfile.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
const mkdir = require('mkdirp');
const fs = require('fs');
const path = require('path');
const del = require('del');
const gulp = require('gulp');
const shell = require('gulp-shell');
const header = require('gulp-header');
const ts = require('gulp-typescript');
const tslint = require("gulp-tslint");
const config = require('./build.config');
const
GENERATE = 'generate',
CLEAN = 'clean',
OLD_OUTPUTDIR_CLEAN = 'output-dir.clean',
OLD_OUTPUTDIR_CREATE = 'output-dir.create',
GEN_COMPILE = 'generator.compile',
GEN_CLEAN = 'generator.clean',
GEN_RUN = 'generator.run',
LINT = 'lint',
NPM_CLEAN = 'npm.clean',
NPM_PACKAGE = 'npm.package',
NPM_LICENSE = 'npm.license',
NPM_BUILD_WITH_HEADERS = 'npm.license-headers',
NPM_README = 'npm.readme',
NPM_BUILD = 'npm.build',
NPM_PACK = 'npm.pack';
gulp.task(OLD_OUTPUTDIR_CLEAN, (c) =>
del([`${config.generatedComponentsDir}\\*`, `!${config.coreComponentsDir}`], c)
);
gulp.task(GEN_CLEAN, (c) =>
del(config.generator.binDir, c)
);
gulp.task(OLD_OUTPUTDIR_CREATE, (done) =>
mkdir(config.oldComponentsDir, {}, done)
);
gulp.task(CLEAN, gulp.parallel(OLD_OUTPUTDIR_CLEAN, GEN_CLEAN));
gulp.task(GEN_COMPILE, gulp.series(
GEN_CLEAN,
() => gulp.src([config.generator.src, `!**/*.test.ts`])
.pipe(ts({
'target': 'es6',
'module': 'commonjs'
}))
.pipe(gulp.dest(config.generator.binDir))
));
gulp.task(GEN_RUN, (done) => {
const generateSync = require(`${config.generator.binDir}generator.js`).default;
generateSync(
JSON.parse(fs.readFileSync(config.metadataPath).toString()),
config.baseComponent,
config.extensionComponent,
config.configComponent,
{
componentsDir: config.generatedComponentsDir,
oldComponentsDir: config.oldComponentsDir,
indexFileName: config.indexFileName
}
);
done();
});
gulp.task(GENERATE, gulp.series(
CLEAN,
gulp.parallel(OLD_OUTPUTDIR_CREATE, GEN_COMPILE),
GEN_RUN
));
gulp.task(NPM_CLEAN, (c) =>
del(config.npm.dist, c)
);
gulp.task(NPM_PACKAGE, gulp.series(
() => gulp.src(config.npm.package).pipe(gulp.dest(config.npm.dist))
));
gulp.task(NPM_LICENSE, gulp.series(
() => gulp.src(config.npm.license).pipe(gulp.dest(config.npm.dist))
));
gulp.task(NPM_README, gulp.series(
() => gulp.src(config.npm.readme).pipe(gulp.dest(config.npm.dist))
));
gulp.task(NPM_BUILD, gulp.series(
NPM_CLEAN,
gulp.parallel(NPM_LICENSE, NPM_PACKAGE, NPM_README),
GENERATE,
() => {
return gulp.src([
config.src,
"!" + config.testSrc
])
.pipe(ts('tsconfig.json'))
.pipe(gulp.dest(config.npm.dist))
}
));
gulp.task(NPM_BUILD_WITH_HEADERS, gulp.series(
NPM_BUILD,
() => {
const pkg = require('./package.json'),
now = new Date(),
data = {
pkg: pkg,
date: now.toDateString(),
year: now.getFullYear()
};
var banner = [
'/*!',
' * <%= pkg.name %>',
' * Version: <%= pkg.version %>',
' * Build date: <%= date %>',
' *',
' * Copyright (c) 2012 - <%= year %> Developer Express Inc. ALL RIGHTS RESERVED',
' *',
' * This software may be modified and distributed under the terms',
' * of the MIT license. See the LICENSE file in the root of the project for details.',
' *',
' * https://github.com/DevExpress/devextreme-react',
' */',
'\n'
].join('\n');
return gulp.src(`${config.npm.dist}**/*.{ts,js}`)
.pipe(header(banner, data))
.pipe(gulp.dest(config.npm.dist));
}
));
gulp.task(NPM_PACK, gulp.series(
NPM_BUILD_WITH_HEADERS,
shell.task(['npm pack'], { cwd: config.npm.dist })
));
gulp.task(LINT, () => {
return gulp.src([config.src, config.generator.src, config.example.src])
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report())
})