-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
117 lines (100 loc) · 3.28 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
/*
The MIT License
Copyright (c) 2017-2022 Klaus Landsdorf (http://node-red.plus/)
All rights reserved.
node-red-contrib-bacnet
*/
'use strict'
const { series, src, dest } = require('gulp')
const htmlmin = require('gulp-htmlmin')
const jsdoc = require('gulp-jsdoc3')
const clean = require('gulp-clean')
const uglify = require('gulp-uglify')
const babel = require('gulp-babel')
const sourcemaps = require('gulp-sourcemaps')
const pump = require('pump')
const replace = require('gulp-replace')
const changelog = require('gulp-conventional-changelog')
function releaseIcons () {
return src('src/icons/**/*').pipe(dest('bacnet/icons'))
}
function docIcons () {
return src('src/icons/**/*').pipe(dest('docs/gen/icons'))
}
function docImages () {
return src('images/**/*').pipe(dest('docs/gen/images'))
}
function releaseLocal () {
return src('src/locales/**/*').pipe(dest('bacnet/locales'))
}
function releasePublicData () {
return src('src/public/**/*').pipe(dest('bacnet/public'))
}
function cleanProject () {
return src(['bacnet', 'docs/gen', 'jcoverage'], { allowEmpty: true })
.pipe(clean({ force: true }))
}
function changelogUpdate () {
return src('CHANGELOG.md')
.pipe(changelog({
// conventional-changelog options go here
preset: 'angular',
releaseCount: 0
}, {
// context goes here
}, {
// git-raw-commits options go here
}, {
// conventional-commits-parser options go here
}, {
// conventional-changelog-writer options go here
}))
.pipe(dest('./'))
}
function releaseWebContent () {
return src('src/*.htm*')
.pipe(htmlmin({
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
maxLineLength: 120,
preserveLineBreaks: false,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
conservativeCollapse: true,
processScripts: ['text/x-red'],
quoteCharacter: "'"
}))
.pipe(dest('bacnet'))
}
function releaseJSContent (cb) {
const anchor = '// SOURCE-MAP-REQUIRED'
pump([
src('src/**/*.js')
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(replace(anchor, 'require(\'source-map-support\').install()'))
.pipe(babel({ presets: ['@babel/env'] }))
.pipe(uglify())
.pipe(sourcemaps.write('maps')), dest('bacnet')],
cb)
}
function codeJSContent (cb) {
const anchor = '// SOURCE-MAP-REQUIRED'
pump([
src('src/**/*.js')
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(replace(anchor, 'require(\'source-map-support\').install()'))
.pipe(babel({ presets: ['@babel/env'] }))
.pipe(sourcemaps.write('maps')), dest('code')],
cb)
}
function doc (cb) {
src(['README.md', 'src/**/*.js'], { read: false })
.pipe(jsdoc(cb))
}
exports.default = series(cleanProject, releaseWebContent, releaseJSContent, codeJSContent, releaseLocal, releasePublicData, releaseIcons, doc, docIcons, docImages, changelogUpdate)
exports.clean = cleanProject
exports.build = series(cleanProject, releaseWebContent, releaseJSContent, releaseLocal, codeJSContent)
exports.buildDocs = series(doc, docIcons, docImages)
exports.changelog = changelogUpdate
exports.publish = series(cleanProject, releaseWebContent, releaseJSContent, releaseLocal, codeJSContent, releasePublicData, releaseIcons, doc, docIcons, docImages, changelogUpdate)