-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
153 lines (140 loc) · 3.55 KB
/
Copy pathgulpfile.js
File metadata and controls
153 lines (140 loc) · 3.55 KB
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
'use strict'
var utils = require('./utils.js')
var path = require('path')
var gulp = require('gulp')
var runSequence = require('run-sequence')
var jeditor = require('gulp-json-editor')
var NWB = require('nwjs-builder')
/*
* This task install src npm dependencies
*/
gulp.task('install-dependencies', function (cb) {
utils.pass()
//.then(utils.execute('npm cache clean'))
.then(utils.execute('npm --no-optional --production --prefix src install src'))
.then(function() {
cb()
})
.catch(cb)
})
/*
* This task adds "*://localhost/*" to the extension allowed domains
*/
gulp.task('patch-extension', function () {
return gulp.src(
path.resolve( 'src', 'extension', 'manifest.json' )
)
.pipe(
jeditor(function (json) {
var matches = json.externally_connectable.matches
if( matches.indexOf( '*://localhost/*' ) == -1 ) {
matches.push('*://localhost/*')
}
return json
})
)
.pipe(
gulp.dest( path.resolve( 'src', 'extension' ) )
)
})
/*
* This task moves CODE's polymer build from lite environment to the app root
*/
gulp.task('move-code', function () {
return gulp.src(
path.resolve('src', 'node_modules', 'quirkbot-code-static', 'dist', 'lite', 'dist_polymer', '**')
)
.pipe(gulp.dest(path.resolve('src', 'code')))
})
/*
* This task moves extensions's build to the app root
*/
gulp.task('move-extension', function () {
return gulp.src(
path.resolve('src', 'node_modules', 'quirkbot-chrome-app', 'dist', '**')
)
.pipe(gulp.dest(path.resolve('src', 'extension')))
})
/*
* This task moves all needed files around
*/
gulp.task('move-files', ['move-code', 'move-extension'])
/*
* This task makes the app ready to execute
*/
gulp.task('compose', function(cb) {
runSequence(
'pre-clean',
'pre-clean',
'install-dependencies',
'move-files',
'patch-extension',
'post-clean',
cb
)
})
/*
* This task builds the app as a platform specified executable program
*/
gulp.task('build', ['compose'], function (cb) {
var pkg = require(path.resolve('src','package.json'))
// Build the app
NWB.commands.nwbuild(
'src',
{
outputDir: 'build',
version: '0.31.5-sdk',
outputName: `${pkg.name}-${pkg.version}-{target}`,
executableName: `${pkg['executable-name']}`,
sideBySide: true
},
cb
)
})
gulp.task('build-multi', ['compose'], function (cb) {
var pkg = require(path.resolve('src','package.json'))
// Build the app
NWB.commands.nwbuild(
'src',
{
outputDir: 'build',
version: '0.31.5-sdk',
platforms: 'win32,osx64',
outputName: `${pkg.name}-${pkg.version}-{target}`,
executableName: `${pkg['executable-name']}`,
sideBySide: true
},
cb
)
})
/*
* This task clean everything produced by the builds
*/
gulp.task('pre-clean', function (cb) {
utils.pass()
.then(utils.deleteDir(path.resolve('build')))
.then(utils.deleteDir(path.resolve('src', 'node_modules')))
.then(utils.deleteDir(path.resolve('src', 'code')))
.then(utils.deleteDir(path.resolve('src', 'uuids')))
.then(utils.mkdir(path.resolve('src', 'uuids')))
.then(utils.deleteDir(path.resolve('src', 'extension')))
.then(utils.deleteDir(path.resolve('src', 'etc')))
.then(function() {
cb()
})
.catch(cb)
})
/*
* This task cleans the app so it doesn't contains unused big source files
*/
gulp.task('post-clean', function (cb) {
utils.pass()
.then(utils.execute('npm --prefix src uninstall quirkbot-code-static --save false'))
.then(utils.execute('npm --prefix src uninstall quirkbot-chrome-app --save false'))
.then(utils.deleteDir(path.resolve('src', 'etc')))
.then(function() {
cb()
})
.catch(cb)
})
module.exports = gulp