-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathgulpfile.js
83 lines (64 loc) · 2.43 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
const gulp = require('gulp');
const del = require('del');
const sourcemaps = require('gulp-sourcemaps');
const tsc = require('gulp-typescript');
const tslint = require('gulp-tslint');
const shell = require('gulp-shell');
const bump = require('gulp-bump');
const fs = require('fs');
const tsp = tsc.createProject('tsconfig.json');
// Remove the tests include from the project
const testIndex = tsp.config.include.indexOf('tests');
if (testIndex > -1) {
tsp.config.include.splice(testIndex, 1);
}
// Tasks for bundling AppsEngineUIClient SDK
const bundle_sdk = shell.task([
`echo "window.AppsEngineUIClient = require('./AppsEngineUIClient').AppsEngineUIClient;" > client/glue.js`,
'cd client && npx browserify glue.js | npx uglifyjs > AppsEngineUIClient.min.js'
]);
function clean_generated() {
return del(['./server', './client', './definition']);
}
function lint_ts() {
return tsp.src().pipe(tslint({ formatter: 'verbose' })).pipe(tslint.report());
}
function compile_ts() {
return tsp.src().pipe(sourcemaps.init())
.pipe(tsp())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('.'));
}
function update_ts_definition_version() {
const { version } = JSON.parse(fs.readFileSync('./package.json'));
return gulp.src('src/definition/package.json')
.pipe(bump({ version }))
.pipe(gulp.dest('src/definition/'));
}
//Tasks for getting it ready and publishing
function ts_definition_module_files() {
return gulp.src(['LICENSE', 'src/definition/package.json'])
.pipe(gulp.dest('definition/'));
}
function watch() {
gulp.watch('src/**/*.ts', gulp.series(compile_ts));
}
const compile = gulp.series(clean_generated, compile_ts, update_ts_definition_version, ts_definition_module_files);
gulp.task('bundle', bundle_sdk);
gulp.task('clean', clean_generated);
gulp.task('compile', gulp.series(compile));
gulp.task('default', gulp.series(compile, watch));
gulp.task('pack', gulp.series(lint_ts, compile, shell.task([
'npm pack'
])));
gulp.task('publish', gulp.series(lint_ts, compile, bundle_sdk, shell.task([
'npm publish --access public && npm pack'
], [
'cd definition && npm publish --access public && npm pack'
])));
gulp.task('publish-beta', gulp.series(lint_ts, compile, bundle_sdk, shell.task([
'npm publish --access public --tag beta'
])));
gulp.task('publish-alpha', gulp.series(lint_ts, compile, bundle_sdk, shell.task([
'npm publish --access public --tag alpha'
])));