Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
66 lines (56 loc) · 1.93 KB
/
Copy pathgulpfile.js
File metadata and controls
66 lines (56 loc) · 1.93 KB
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
var gulp = require('gulp');
const newLocal = 'gulp-bump';
var bump = require(newLocal);
var replace = require('gulp-replace');
var fs = require('fs');
var zip = require('gulp-zip');
var clean = require('gulp-clean');
var shell = require('gulp-shell');
var gulpsync = require('gulp-sync')(gulp);
gulp.task('bump', function () {
var bumpType = 'minor';
console.log(process.argv)
for (var i = 0; i < process.argv.length; i++) {
if (process.argv[i].substring(0, '-bump:'.length) == '-bump:') {
console.log(process.argv[i])
bumpType = process.argv[i].substring('-bump:'.length);
console.log(bumpType)
}
}
return gulp.src('./package.json')
.pipe(bump({ type: bumpType }))
.pipe(gulp.dest('./'));
});
//------------------------------------------------------------------------------
gulp.task('setManifestVersion', function () {
var getPackageJson = function () {
return JSON.parse(fs.readFileSync('./package.json', 'utf8'));
};
var newVer = getPackageJson().version;
return gulp.src(['./build/manifest.json'])
.pipe(replace('99.9999.999', newVer))
.pipe(gulp.dest('build/'));
});
//------------------------------------------------------------------------------
gulp.task('clean', async function (done) {
await gulp.src(['./dist/'], { allowEmpty: true })
.pipe(clean({ force: true}));
done();
});
//------------------------------------------------------------------------------
gulp.task('createOpk', function () {
var newVer = JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
return gulp.src('build/**')
.pipe(zip('game-events-simulator-' + newVer + '.opk'))
.pipe(gulp.dest('dist'));
});
//------------------------------------------------------------------------------
gulp.task('buildReactApp', shell.task('react-scripts build'));
//------------------------------------------------------------------------------
gulp.task(
'build', gulp.series([
'clean',
'buildReactApp',
'bump',
'setManifestVersion'
]));