-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
181 lines (158 loc) · 4.79 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
var electronVersion = "1.0.1";
var fs = require('fs');
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var htmlmin = require('gulp-htmlmin');
var jsonminify = require('gulp-jsonminify');
var install = require("gulp-install");
var del = require('del');
var ngmin = require('gulp-ngmin');
var nodemon = require('gulp-nodemon');
var bower = require('gulp-bower');
var asar = require('asar');
var packager = require('electron-packager');
var packageJson = require('./src/package.json');
var plumber = require('gulp-plumber'); //prevent watch crash
var gulpsync = require('gulp-sync')(gulp);
var winInstaller = require('electron-winstaller');
//retreive package.json data
var pjson = require('./src/package.json');
gulp.task('sass', function () {
return gulp.src('./src/web/style/**/*.scss')
.pipe(plumber())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./dist/web/css'));
});
gulp.task('clean:dist', function() {
return del('./dist/**/*');
});
gulp.task('clean:build', function() {
return del('./build/**/*');
});
gulp.task('install-dependencies', function() {
return bower({ cwd: './src/web',interactive:true });
});
gulp.task('scripts', function() {
return gulp.src('./src/web/js/**/*.js')
.pipe(plumber())
.pipe(ngmin())
.pipe(uglify({mangle: false}))
.pipe(concat('tagifier.js'))
.pipe(gulp.dest('./dist/web/js/'));
});
gulp.task('images', function(cb) {
return gulp.src(['src/web/**/*.png','src/web/**/*.jpg','src/web/**/*.gif','src/web/**/*.jpeg','src/web/**/*.svg','src/web/**/*.ico'])
.pipe(gulp.dest('./dist/web/'));
});
gulp.task('copy-dependencies', function() {
return gulp.src('./src/web/bower_components/**/*')
.pipe(gulp.dest('./dist/web/dep/'));
});
gulp.task('html', function() {
return gulp.src('src/web/**/*.html')
.pipe(plumber())
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('./dist/web'))
});
gulp.task('locales', function () {
return gulp.src(['./src/web/locales/*.json'])
.pipe(jsonminify())
.pipe(gulp.dest('./dist/web/locales/'));
});
gulp.task('install-dist-dep',function(){
return gulp.src(['./dist/package.json'])
.pipe(install());
});
gulp.task('copy-electron-components',function(){
return gulp.src(['./src/*.js', './src/*.json'])
.pipe(gulp.dest('./dist'))
});
gulp.task('electron-build', function(callback) {
var options = {
dir: "./dist",
name: pjson.name,
asar: true,
platform: "win32",
arch: "x64",
'app-version':pjson.version,
'build-version':pjson.version,
overwrite: true,
icon: "./dist/web/img/tgf/icon_circle.png",
out: "build",
win32metadata: {
"CompanyName": pjson.author,
"OriginalFilename": pjson.name,
"ProductName": pjson.name,
"InternalName": pjson.name,
"FileDescription ": pjson.name
}
};
packager(options, function done (err, appPath) {
if(err) { return console.log(err); }
callback();
});
});
gulp.task('asar', function() {
var src = './dist/';
var dest = './dist/app.asar';
//clean asar if already exist
if(fs.existsSync(dest)){
fs.unlinkSync(dest);
}
asar.createPackage(src, dest, function() {
return console.log('App packaged !');
})
});
gulp.task('watch', function () {
gulp.watch('./src/web/style/**/*.scss', ['sass']);
gulp.watch('./src/web/**/*.html', ['html']);
gulp.watch('./src/web/**/*.js', ['scripts']);
gulp.watch('./src/*', ['copy-electron-components']);
});
gulp.task('create-windows-installer',function(){
del('./release/**/*');
return resultPromise = winInstaller.createWindowsInstaller({
appDirectory: './build/tagifier-win32-x64',
outputDirectory: './release',
title: pjson.name,
description: pjson.name,
loadingGif: './dist/web/img/updater.gif',
authors: pjson.author,
iconUrl: __dirname+'/dist/web/img/tgf/icon_circle.ico',
setupIcon : './dist/web/img/tgf/icon_setup.ico',
exe: 'Tagifier.exe',
setupExe:'Setup.exe',
noMsi : true,
title : 'Tagifier'
});
console.log(iconUrl);
resultPromise.then(() => console.log("It worked!"), (e) => console.log(`No dice: ${e.message}`));
});
gulp.task('prepare-dev-env', gulpsync.sync([
// sync
'clean:dist',
['install-dependencies'],
[
// async
'sass',
'scripts',
'html',
'copy-dependencies',
'images',
'locales',
'copy-electron-components',
],
['install-dist-dep']
]));
gulp.task('build', gulpsync.sync([
['clean:build'],
['prepare-dev-env'],
['electron-build'],
['create-windows-installer']
]));
gulp.task('default', gulpsync.sync([
['prepare-dev-env'],
['watch']
]));