-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.js
66 lines (54 loc) · 1.49 KB
/
release.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
'use strict';
require( 'shelljs/global' );
const colors = require( 'colors' );
const archiver = require( 'archiver' );
const fs = require( 'fs' );
const pluginSlug = 'payline';
// some config
const releaseFolder = 'release';
const targetFolder = 'release/' + pluginSlug;
const filesToCopy = [
'assets',
'build',
'includes',
'languages',
'vendor',
'woocommerce-payline.php',
'CHANGELOG.md',
'README.md',
];
// run npm dist
rm( '-rf', 'dist' );
// start with a clean release folder
rm( '-rf', releaseFolder );
mkdir( releaseFolder );
mkdir( targetFolder );
// remove the 'hidden' source maps; they are used to generate the POT file and are not referenced in the source files.
rm( 'build/*.map' );
// copy the directories to the release folder
cp( '-Rf', filesToCopy, targetFolder );
const output = fs.createWriteStream(
releaseFolder + '/' + pluginSlug + '.zip'
);
const archive = archiver( 'zip', { zlib: { level: 9 } } );
output.on( 'close', () => {
console.log(
colors.green(
'All done: Release is built in the ' + releaseFolder + ' folder.'
)
);
} );
archive.on( 'error', ( err ) => {
console.error(
colors.red(
'An error occured while creating the zip: ' +
err +
'\nYou can still probably create the zip manually from the ' +
targetFolder +
' folder.'
)
);
} );
archive.pipe( output );
archive.directory( targetFolder, pluginSlug );
archive.finalize();