2017-11-17 08:00:07 +03:00
|
|
|
var del = require('del');
|
2017-11-17 07:34:13 +03:00
|
|
|
var gulp = require('gulp');
|
2018-07-31 15:37:07 +03:00
|
|
|
var imagemin = require('gulp-imagemin');
|
2018-08-31 12:15:30 +03:00
|
|
|
var rename = require('gulp-rename');
|
2017-11-17 07:34:13 +03:00
|
|
|
var gulpTslint = require('gulp-tslint');
|
2019-02-18 09:08:35 +03:00
|
|
|
var ts = require('gulp-typescript');
|
2017-11-17 07:34:13 +03:00
|
|
|
var tslint = require('tslint');
|
|
|
|
|
2019-02-18 09:08:35 +03:00
|
|
|
var tsProject = ts.createProject('tsconfig.json');
|
2017-11-17 07:34:13 +03:00
|
|
|
|
|
|
|
var path = {
|
|
|
|
src: './src/',
|
|
|
|
dist: './dist/',
|
2018-07-31 15:37:07 +03:00
|
|
|
example: './examples/AdaptiveCards/',
|
2018-08-31 12:15:30 +03:00
|
|
|
tool: './tool/src/assets/AdaptiveCards/',
|
2017-11-17 07:34:13 +03:00
|
|
|
};
|
2019-02-18 09:08:35 +03:00
|
|
|
function clean() {
|
2018-08-31 12:15:30 +03:00
|
|
|
return del([path.dist, path.example, path.tool]);
|
2019-02-18 09:08:35 +03:00
|
|
|
}
|
2017-11-17 07:34:13 +03:00
|
|
|
|
2019-02-18 09:08:35 +03:00
|
|
|
function minifyImage() {
|
2018-07-31 15:37:07 +03:00
|
|
|
return gulp.src(path.src + 'Assets/**/*.png')
|
|
|
|
.pipe(imagemin())
|
|
|
|
.pipe(gulp.dest(path.dist + 'Assets'))
|
2018-08-31 12:15:30 +03:00
|
|
|
.pipe(gulp.dest(path.example + 'Assets'))
|
2019-02-18 09:08:35 +03:00
|
|
|
.pipe(gulp.dest(path.tool + 'Assets'))
|
|
|
|
.pipe(rename(function (opt) {
|
2018-08-31 12:15:30 +03:00
|
|
|
opt.basename = opt.basename.replace(/@[^.]*/, '');
|
|
|
|
return opt;
|
2019-02-18 09:08:35 +03:00
|
|
|
}));
|
|
|
|
}
|
2018-07-31 15:37:07 +03:00
|
|
|
|
2019-02-18 09:08:35 +03:00
|
|
|
function lintTs() {
|
2017-11-17 07:34:13 +03:00
|
|
|
var program = tslint.Linter.createProgram('./tsconfig.json');
|
|
|
|
return gulp.src([path.src + '**/*.ts', path.src + '**/*.tsx'])
|
|
|
|
.pipe(gulpTslint({
|
|
|
|
formatter: 'stylish',
|
|
|
|
program: program
|
|
|
|
}))
|
|
|
|
.pipe(gulpTslint.report({
|
|
|
|
emitError: true
|
|
|
|
}));
|
2019-02-18 09:08:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function copyJson() {
|
|
|
|
return gulp.src(path.src + '**/*.json')
|
|
|
|
.pipe(gulp.dest(path.dist))
|
|
|
|
.pipe(gulp.dest(path.example))
|
|
|
|
.pipe(gulp.dest(path.tool));
|
|
|
|
}
|
2017-11-17 07:34:13 +03:00
|
|
|
|
2019-02-18 09:08:35 +03:00
|
|
|
function copyDefinition() {
|
|
|
|
return gulp.src(path.src + '**/*.d.ts')
|
2017-11-17 07:34:13 +03:00
|
|
|
.pipe(gulp.dest(path.dist))
|
2018-08-31 12:15:30 +03:00
|
|
|
.pipe(gulp.dest(path.example))
|
|
|
|
.pipe(gulp.dest(path.tool));
|
2019-02-18 09:08:35 +03:00
|
|
|
}
|
2017-11-17 07:34:13 +03:00
|
|
|
|
2019-02-18 09:08:35 +03:00
|
|
|
function compileTs() {
|
2017-11-17 07:34:13 +03:00
|
|
|
var tsResult = tsProject.src()
|
|
|
|
.pipe(tsProject());
|
2019-02-18 09:08:35 +03:00
|
|
|
return tsResult
|
2017-11-17 07:34:13 +03:00
|
|
|
.pipe(gulp.dest(path.dist))
|
2018-08-31 12:15:30 +03:00
|
|
|
.pipe(gulp.dest(path.example))
|
|
|
|
.pipe(gulp.dest(path.tool));
|
2019-02-18 09:08:35 +03:00
|
|
|
}
|
2018-08-31 12:15:30 +03:00
|
|
|
|
2019-02-18 09:08:35 +03:00
|
|
|
exports.clean = clean;
|
|
|
|
exports.minifyImage = minifyImage;
|
|
|
|
exports.lintTs = lintTs;
|
|
|
|
exports.copyJson = copyJson;
|
|
|
|
exports.compileTs = compileTs;
|
|
|
|
exports.copyDefinition = copyDefinition;
|
|
|
|
exports.build = gulp.series(
|
|
|
|
lintTs,
|
|
|
|
clean,
|
|
|
|
compileTs,
|
|
|
|
gulp.parallel(minifyImage, copyJson),
|
|
|
|
);
|
|
|
|
exports.default = exports.build;
|