forked from plentymarkets/terra-prettier-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (73 loc) · 2.93 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 { series, src, dest } = require('gulp');
const prompt = require('gulp-prompt');
const fs = require('fs');
const semver = require('semver');
const config = require('./gulp.config.js')();
//copy package.json to dist
function copyPackageJson() {
return src(config.sources.packageJson).pipe(dest(config.destinations.dist));
}
//copy readme to dist
function copyReadme() {
return src(config.sources.readme).pipe(dest(config.destinations.dist));
}
//copy configuration to dist
function copyRules() {
return src(config.sources.configuration).pipe(dest(config.destinations.dist));
}
/**
* Copies all the files to the dedicated deploy folder
**/
const copy = series(copyPackageJson, copyReadme, copyRules);
exports.copy = copy;
/**
* changing version of package.json for new publish
* usage: 'npm run publish -- --param1 --param2 param2_value' for publishing
*
* @param increment - Possible values are
* major (1.x.x to 2.x.x),
* premajor (1.x.x to 2.x.x-0 or 2.x.x-subversion.0),
* minor (x.1.x to x.2.x),
* preminor (x.1.x to x.2.x-0 or x.2.x-subversion.0)
* patch (x.x.1 to x.x.2),
* prepatch (x.x.1 to x.x.2-0 or x.x.1 to x.x.2-subversion.0)
* or prerelease (x.x.x-0 or x.x.x-subversion.0 to x.x.x-1 or x.x.x-subversion.1)
* If not set patch is default. See VERSIONING.md for further information.
* @param preid - Sets a subversion (appends '-param_value', e.g. x.x.x-newFeature, to version in package.json) for a premajor,
* preminor or prepatch release. Use only, if really necessary!!
*
**/
function changeVersion(increment, preid) {
const json = JSON.parse(fs.readFileSync('./package.json'));
console.log('-------------------------------------------------');
console.log('--- OLD PACKAGE VERSION: ' + json.version + ' ---');
json.version = semver.inc(json.version, increment, preid);
console.log('--- NEW PACKAGE VERSION: ' + json.version + ' ---');
console.log('-------------------------------------------------');
fs.writeFileSync('./package.json', JSON.stringify(json, null, '\t'));
}
function updateVersion() {
return src('package.json')
.pipe(
prompt.prompt(
[
{
type: 'list',
name: 'increment',
message: 'What type of bump would you like to do?',
choices: ['patch', 'minor', 'major']
}
],
function (res) {
changeVersion(res.increment);
}
)
)
.pipe(
prompt.confirm({
message: 'Version correct?',
default: false
})
);
}
exports.updateVersion = updateVersion;