-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
123 lines (102 loc) · 3.16 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
/*
yarn
*/
const gulp = require('gulp');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const replace = require('gulp-string-replace');
const gfi = require('gulp-file-insert');
const markdown = require('gulp-markdown');
const del = require('del');
const bump = require('gulp-bump');
const jsonlint = require('gulp-jsonlint');
const p = require('./package.json');
const version = p.version.replace('v', '');
// ### Version number bump routines
//
// Basic usage:
// Will patch the version
const bumpVersion = (type) => {
gulp.src('./package.json')
.pipe(bump({ type }))
.pipe(gulp.dest('./'));
};
gulp.task('bump-major', () => bumpVersion('major'));
gulp.task('bump-minor', () => bumpVersion('minor'));
gulp.task('bump-patch', () => bumpVersion('patch'));
gulp.task('bump-pre', () => bumpVersion('prepatch'));
gulp.task('bump-prerelease', () => bumpVersion('prerelease'));
gulp.task('lint', () => {
gulp.src(['./*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
gulp.src('./prep/script.json')
.pipe(jsonlint())
.pipe(jsonlint.reporter());
});
gulp.task('lintfix', () => {
gulp.src(['./*.js'])
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
.pipe(gulp.dest('./'));
});
// prepare the three readme versions
// - a html version for inline help
// - a md with converted linebreaks for the json
// - and the clean md for the publish folder
gulp.task('pub1', () => {
gulp.src('./README.md')
.pipe(markdown())
.pipe(replace(new RegExp('\n', 'g'), '')) // eslint-disable-line no-control-regex
.pipe(replace(new RegExp('"', 'g'), '\''))
.pipe(gulp.dest('./tmp/script'));
gulp.src('./README.md')
.pipe(replace(new RegExp('\n', 'g'), '\\r')) // eslint-disable-line no-control-regex
.pipe(replace(new RegExp('"', 'g'), '\''))
.pipe(gulp.dest('./tmp/package'));
gulp.src('./README.md')
.pipe(gulp.dest('./publish'));
gulp.src('./prep/script.json')
.pipe(jsonlint())
.pipe(jsonlint.reporter());
});
// Then, replace vn and readme content in Cashmaster.js
// and script.json and write everything to the publish folder
// The package.json still needs to be updated manually a bit (older versions)
gulp.task('pub2', () => {
gulp.src('./Cashmaster.js')
.pipe(replace(new RegExp('%%version%%', 'g'), version))
.pipe(gfi({
'%%README%%': 'tmp/script/README.md',
}))
.pipe(babel({
presets: ['env'],
}))
.pipe(gulp.dest('./publish'))
.pipe(gulp.dest(`./publish/${version}`));
gulp.src('./prep/script.json')
.pipe(replace(new RegExp('%%version%%', 'g'), version))
.pipe(gfi({
'%%README%%': 'tmp/package/README.md',
}))
.pipe(gulp.dest('./publish'));
gulp.src('./publish/script.json')
.pipe(jsonlint())
.pipe(jsonlint.reporter());
});
gulp.task('pub3', () => {
gulp.src('./publish/script.json')
.pipe(jsonlint())
.pipe(jsonlint.reporter());
gulp.src('./publish/*')
.pipe(gulp.dest('../roll20-api-scripts/CashMaster/'));
return del.sync('./tmp');
});
gulp.task('cleanup', () => {
del.sync('./tmp');
});
gulp.task('cleanup2', () => {
del.sync('./tmp');
del.sync('./publish');
});