diff options
author | Amine Mouafik <amine@mouafik.fr> | 2019-09-19 17:57:53 +0700 |
---|---|---|
committer | Amine Mouafik <amine@mouafik.fr> | 2019-09-19 17:57:53 +0700 |
commit | 997867f59dd4bdea62bceb0231a330d58ec1de27 (patch) | |
tree | cd1453988ce497732b776342a583258020dc80ae /gulpfile.babel.js | |
parent | Merge branch 'master' into feat/macos-signing (diff) | |
download | ferdium-app-997867f59dd4bdea62bceb0231a330d58ec1de27.tar.gz ferdium-app-997867f59dd4bdea62bceb0231a330d58ec1de27.tar.zst ferdium-app-997867f59dd4bdea62bceb0231a330d58ec1de27.zip |
Remove deprecated sign npm/gulp script
In favor of the built-in signing capability of electron-builder
Diffstat (limited to 'gulpfile.babel.js')
-rw-r--r-- | gulpfile.babel.js | 156 |
1 files changed, 84 insertions, 72 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 06e995d07..919ddca9f 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js | |||
@@ -19,7 +19,13 @@ dotenv.config(); | |||
19 | 19 | ||
20 | const styleConfig = Object.keys(rawStyleConfig).map((key) => { | 20 | const styleConfig = Object.keys(rawStyleConfig).map((key) => { |
21 | const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]); | 21 | const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]); |
22 | return ({ [`$raw_${kebabCase(key)}`]: isHex ? hexRgb(rawStyleConfig[key], { format: 'array' }).splice(0, 3).join(',') : rawStyleConfig[key] }); | 22 | return { |
23 | [`$raw_${kebabCase(key)}`]: isHex | ||
24 | ? hexRgb(rawStyleConfig[key], { format: 'array' }) | ||
25 | .splice(0, 3) | ||
26 | .join(',') | ||
27 | : rawStyleConfig[key], | ||
28 | }; | ||
23 | }); | 29 | }); |
24 | 30 | ||
25 | const paths = { | 31 | const paths = { |
@@ -58,18 +64,22 @@ const paths = { | |||
58 | 64 | ||
59 | function _shell(cmd, cb) { | 65 | function _shell(cmd, cb) { |
60 | console.log('executing', cmd); | 66 | console.log('executing', cmd); |
61 | exec(cmd, { | 67 | exec( |
62 | cwd: paths.dest, | 68 | cmd, |
63 | }, (error, stdout, stderr) => { | 69 | { |
64 | if (error) { | 70 | cwd: paths.dest, |
65 | console.error(`exec error: ${error}`); | 71 | }, |
66 | return; | 72 | (error, stdout, stderr) => { |
67 | } | 73 | if (error) { |
68 | console.log(`stdout: ${stdout}`); | 74 | console.error(`exec error: ${error}`); |
69 | console.log(`stderr: ${stderr}`); | 75 | return; |
70 | 76 | } | |
71 | cb(); | 77 | console.log(`stdout: ${stdout}`); |
72 | }); | 78 | console.log(`stderr: ${stderr}`); |
79 | |||
80 | cb(); | ||
81 | }, | ||
82 | ); | ||
73 | } | 83 | } |
74 | 84 | ||
75 | const clean = (done) => { | 85 | const clean = (done) => { |
@@ -81,60 +91,66 @@ const clean = (done) => { | |||
81 | export { clean }; | 91 | export { clean }; |
82 | 92 | ||
83 | export function mvSrc() { | 93 | export function mvSrc() { |
84 | return gulp.src( | 94 | return gulp |
85 | [ | 95 | .src( |
86 | `${paths.src}/*`, | 96 | [ |
87 | `${paths.src}/*/**`, | 97 | `${paths.src}/*`, |
88 | `!${paths.scripts.watch[1]}`, | 98 | `${paths.src}/*/**`, |
89 | `!${paths.src}/styles/**`, | 99 | `!${paths.scripts.watch[1]}`, |
90 | `!${paths.src}/**/*.js`, | 100 | `!${paths.src}/styles/**`, |
91 | ], { since: gulp.lastRun(mvSrc) }, | 101 | `!${paths.src}/**/*.js`, |
92 | ) | 102 | ], |
103 | { since: gulp.lastRun(mvSrc) }, | ||
104 | ) | ||
93 | .pipe(gulp.dest(paths.dest)); | 105 | .pipe(gulp.dest(paths.dest)); |
94 | } | 106 | } |
95 | 107 | ||
96 | export function mvPackageJson() { | 108 | export function mvPackageJson() { |
97 | return gulp.src( | 109 | return gulp.src(['./package.json']).pipe(gulp.dest(paths.dest)); |
98 | [ | ||
99 | './package.json', | ||
100 | ], | ||
101 | ) | ||
102 | .pipe(gulp.dest(paths.dest)); | ||
103 | } | 110 | } |
104 | 111 | ||
105 | export function mvLernaPackages() { | 112 | export function mvLernaPackages() { |
106 | return gulp.src( | 113 | return gulp.src(['packages/**']).pipe(gulp.dest(`${paths.dest}/packages`)); |
107 | [ | ||
108 | 'packages/**', | ||
109 | ], | ||
110 | ) | ||
111 | .pipe(gulp.dest(`${paths.dest}/packages`)); | ||
112 | } | 114 | } |
113 | 115 | ||
114 | export function html() { | 116 | export function html() { |
115 | return gulp.src(paths.html.src, { since: gulp.lastRun(html) }) | 117 | return gulp |
118 | .src(paths.html.src, { since: gulp.lastRun(html) }) | ||
116 | .pipe(gulp.dest(paths.html.dest)); | 119 | .pipe(gulp.dest(paths.html.dest)); |
117 | } | 120 | } |
118 | 121 | ||
119 | export function styles() { | 122 | export function styles() { |
120 | return gulp.src(paths.styles.src) | 123 | return gulp |
121 | .pipe(sassVariables(Object.assign({ | 124 | .src(paths.styles.src) |
122 | $env: process.env.NODE_ENV === 'development' ? 'development' : 'production', | 125 | .pipe( |
123 | }, ...styleConfig))) | 126 | sassVariables( |
124 | .pipe(sass({ | 127 | Object.assign( |
125 | includePaths: [ | 128 | { |
126 | './node_modules', | 129 | $env: |
127 | '../node_modules', | 130 | process.env.NODE_ENV === 'development' |
128 | ], | 131 | ? 'development' |
129 | }).on('error', sass.logError)) | 132 | : 'production', |
133 | }, | ||
134 | ...styleConfig, | ||
135 | ), | ||
136 | ), | ||
137 | ) | ||
138 | .pipe( | ||
139 | sass({ | ||
140 | includePaths: ['./node_modules', '../node_modules'], | ||
141 | }).on('error', sass.logError), | ||
142 | ) | ||
130 | .pipe(gulp.dest(paths.styles.dest)); | 143 | .pipe(gulp.dest(paths.styles.dest)); |
131 | } | 144 | } |
132 | 145 | ||
133 | export function scripts() { | 146 | export function scripts() { |
134 | return gulp.src(paths.scripts.src, { since: gulp.lastRun(scripts) }) | 147 | return gulp |
135 | .pipe(babel({ | 148 | .src(paths.scripts.src, { since: gulp.lastRun(scripts) }) |
136 | comments: false, | 149 | .pipe( |
137 | })) | 150 | babel({ |
151 | comments: false, | ||
152 | }), | ||
153 | ) | ||
138 | .pipe(gulp.dest(paths.scripts.dest)); | 154 | .pipe(gulp.dest(paths.scripts.dest)); |
139 | } | 155 | } |
140 | 156 | ||
@@ -142,44 +158,40 @@ export function watch() { | |||
142 | gulp.watch(paths.packages.watch, mvLernaPackages); | 158 | gulp.watch(paths.packages.watch, mvLernaPackages); |
143 | gulp.watch(paths.styles.watch, styles); | 159 | gulp.watch(paths.styles.watch, styles); |
144 | 160 | ||
145 | gulp.watch([ | 161 | gulp.watch([paths.src, `${paths.scripts.src}`, `${paths.styles.src}`], mvSrc); |
146 | paths.src, | ||
147 | `${paths.scripts.src}`, | ||
148 | `${paths.styles.src}`, | ||
149 | ], mvSrc); | ||
150 | 162 | ||
151 | gulp.watch(paths.scripts.watch, scripts); | 163 | gulp.watch(paths.scripts.watch, scripts); |
152 | } | 164 | } |
153 | 165 | ||
154 | export function webserver() { | 166 | export function webserver() { |
155 | gulp.src([ | 167 | gulp.src([paths.dest]).pipe( |
156 | paths.dest, | 168 | server({ |
157 | ]) | ||
158 | .pipe(server({ | ||
159 | livereload: true, | 169 | livereload: true, |
160 | })); | 170 | }), |
171 | ); | ||
161 | } | 172 | } |
162 | 173 | ||
163 | export function dictionaries(done) { | 174 | export function dictionaries(done) { |
164 | const { SPELLCHECKER_LOCALES } = require('./build/i18n/languages'); | 175 | const { SPELLCHECKER_LOCALES } = require('./build/i18n/languages'); |
165 | 176 | ||
166 | let packages = ''; | 177 | let packages = ''; |
167 | Object.keys(SPELLCHECKER_LOCALES).forEach((key) => { packages = `${packages} hunspell-dict-${key}`; }); | 178 | Object.keys(SPELLCHECKER_LOCALES).forEach((key) => { |
168 | 179 | packages = `${packages} hunspell-dict-${key}`; | |
169 | _shell(`npm install --prefix ${path.join(__dirname, 'temp')} ${packages}`, () => { | 180 | }); |
170 | moveSync( | ||
171 | path.join(__dirname, 'temp', 'node_modules'), | ||
172 | path.join(__dirname, 'build', paths.dictionaries), | ||
173 | ); | ||
174 | 181 | ||
175 | removeSync(path.join(__dirname, 'temp')); | 182 | _shell( |
183 | `npm install --prefix ${path.join(__dirname, 'temp')} ${packages}`, | ||
184 | () => { | ||
185 | moveSync( | ||
186 | path.join(__dirname, 'temp', 'node_modules'), | ||
187 | path.join(__dirname, 'build', paths.dictionaries), | ||
188 | ); | ||
176 | 189 | ||
177 | done(); | 190 | removeSync(path.join(__dirname, 'temp')); |
178 | }); | ||
179 | } | ||
180 | 191 | ||
181 | export function sign(done) { | 192 | done(); |
182 | _shell(`codesign --verbose=4 --deep --strict --force --sign "${process.env.SIGNING_IDENTITY}" "${__dirname}/node_modules/electron/dist/Electron.app"`, done); | 193 | }, |
194 | ); | ||
183 | } | 195 | } |
184 | 196 | ||
185 | const build = gulp.series( | 197 | const build = gulp.series( |