diff options
author | vantezzen <hello@vantezzen.io> | 2019-09-25 10:48:51 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2019-09-25 10:48:51 +0200 |
commit | 742a8264f1b01137d1f23eb6876b20b8c27748b7 (patch) | |
tree | 8f6e9e35023fc9bd14eea4a7c2fc0123c4c58cb5 /gulpfile.babel.js | |
parent | Shipping recipe files directly with Ferdi (diff) | |
parent | Add list of backers to README (diff) | |
download | ferdium-app-742a8264f1b01137d1f23eb6876b20b8c27748b7.tar.gz ferdium-app-742a8264f1b01137d1f23eb6876b20b8c27748b7.tar.zst ferdium-app-742a8264f1b01137d1f23eb6876b20b8c27748b7.zip |
Merge branch 'master' of https://github.com/getferdi/ferdi
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 43ebaa20a..fcdefd3d3 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 = { |
@@ -62,18 +68,22 @@ const paths = { | |||
62 | 68 | ||
63 | function _shell(cmd, cb) { | 69 | function _shell(cmd, cb) { |
64 | console.log('executing', cmd); | 70 | console.log('executing', cmd); |
65 | exec(cmd, { | 71 | exec( |
66 | cwd: paths.dest, | 72 | cmd, |
67 | }, (error, stdout, stderr) => { | 73 | { |
68 | if (error) { | 74 | cwd: paths.dest, |
69 | console.error(`exec error: ${error}`); | 75 | }, |
70 | return; | 76 | (error, stdout, stderr) => { |
71 | } | 77 | if (error) { |
72 | console.log(`stdout: ${stdout}`); | 78 | console.error(`exec error: ${error}`); |
73 | console.log(`stderr: ${stderr}`); | 79 | return; |
74 | 80 | } | |
75 | cb(); | 81 | console.log(`stdout: ${stdout}`); |
76 | }); | 82 | console.log(`stderr: ${stderr}`); |
83 | |||
84 | cb(); | ||
85 | }, | ||
86 | ); | ||
77 | } | 87 | } |
78 | 88 | ||
79 | const clean = (done) => { | 89 | const clean = (done) => { |
@@ -85,60 +95,66 @@ const clean = (done) => { | |||
85 | export { clean }; | 95 | export { clean }; |
86 | 96 | ||
87 | export function mvSrc() { | 97 | export function mvSrc() { |
88 | return gulp.src( | 98 | return gulp |
89 | [ | 99 | .src( |
90 | `${paths.src}/*`, | 100 | [ |
91 | `${paths.src}/*/**`, | 101 | `${paths.src}/*`, |
92 | `!${paths.scripts.watch[1]}`, | 102 | `${paths.src}/*/**`, |
93 | `!${paths.src}/styles/**`, | 103 | `!${paths.scripts.watch[1]}`, |
94 | `!${paths.src}/**/*.js`, | 104 | `!${paths.src}/styles/**`, |
95 | ], { since: gulp.lastRun(mvSrc) }, | 105 | `!${paths.src}/**/*.js`, |
96 | ) | 106 | ], |
107 | { since: gulp.lastRun(mvSrc) }, | ||
108 | ) | ||
97 | .pipe(gulp.dest(paths.dest)); | 109 | .pipe(gulp.dest(paths.dest)); |
98 | } | 110 | } |
99 | 111 | ||
100 | export function mvPackageJson() { | 112 | export function mvPackageJson() { |
101 | return gulp.src( | 113 | return gulp.src(['./package.json']).pipe(gulp.dest(paths.dest)); |
102 | [ | ||
103 | './package.json', | ||
104 | ], | ||
105 | ) | ||
106 | .pipe(gulp.dest(paths.dest)); | ||
107 | } | 114 | } |
108 | 115 | ||
109 | export function mvLernaPackages() { | 116 | export function mvLernaPackages() { |
110 | return gulp.src( | 117 | return gulp.src(['packages/**']).pipe(gulp.dest(`${paths.dest}/packages`)); |
111 | [ | ||
112 | 'packages/**', | ||
113 | ], | ||
114 | ) | ||
115 | .pipe(gulp.dest(`${paths.dest}/packages`)); | ||
116 | } | 118 | } |
117 | 119 | ||
118 | export function html() { | 120 | export function html() { |
119 | return gulp.src(paths.html.src, { since: gulp.lastRun(html) }) | 121 | return gulp |
122 | .src(paths.html.src, { since: gulp.lastRun(html) }) | ||
120 | .pipe(gulp.dest(paths.html.dest)); | 123 | .pipe(gulp.dest(paths.html.dest)); |
121 | } | 124 | } |
122 | 125 | ||
123 | export function styles() { | 126 | export function styles() { |
124 | return gulp.src(paths.styles.src) | 127 | return gulp |
125 | .pipe(sassVariables(Object.assign({ | 128 | .src(paths.styles.src) |
126 | $env: process.env.NODE_ENV === 'development' ? 'development' : 'production', | 129 | .pipe( |
127 | }, ...styleConfig))) | 130 | sassVariables( |
128 | .pipe(sass({ | 131 | Object.assign( |
129 | includePaths: [ | 132 | { |
130 | './node_modules', | 133 | $env: |
131 | '../node_modules', | 134 | process.env.NODE_ENV === 'development' |
132 | ], | 135 | ? 'development' |
133 | }).on('error', sass.logError)) | 136 | : 'production', |
137 | }, | ||
138 | ...styleConfig, | ||
139 | ), | ||
140 | ), | ||
141 | ) | ||
142 | .pipe( | ||
143 | sass({ | ||
144 | includePaths: ['./node_modules', '../node_modules'], | ||
145 | }).on('error', sass.logError), | ||
146 | ) | ||
134 | .pipe(gulp.dest(paths.styles.dest)); | 147 | .pipe(gulp.dest(paths.styles.dest)); |
135 | } | 148 | } |
136 | 149 | ||
137 | export function scripts() { | 150 | export function scripts() { |
138 | return gulp.src(paths.scripts.src, { since: gulp.lastRun(scripts) }) | 151 | return gulp |
139 | .pipe(babel({ | 152 | .src(paths.scripts.src, { since: gulp.lastRun(scripts) }) |
140 | comments: false, | 153 | .pipe( |
141 | })) | 154 | babel({ |
155 | comments: false, | ||
156 | }), | ||
157 | ) | ||
142 | .pipe(gulp.dest(paths.scripts.dest)); | 158 | .pipe(gulp.dest(paths.scripts.dest)); |
143 | } | 159 | } |
144 | 160 | ||
@@ -146,40 +162,40 @@ export function watch() { | |||
146 | gulp.watch(paths.packages.watch, mvLernaPackages); | 162 | gulp.watch(paths.packages.watch, mvLernaPackages); |
147 | gulp.watch(paths.styles.watch, styles); | 163 | gulp.watch(paths.styles.watch, styles); |
148 | 164 | ||
149 | gulp.watch([ | 165 | gulp.watch([paths.src, `${paths.scripts.src}`, `${paths.styles.src}`], mvSrc); |
150 | paths.src, | ||
151 | `${paths.scripts.src}`, | ||
152 | `${paths.styles.src}`, | ||
153 | ], mvSrc); | ||
154 | 166 | ||
155 | gulp.watch(paths.scripts.watch, scripts); | 167 | gulp.watch(paths.scripts.watch, scripts); |
156 | } | 168 | } |
157 | 169 | ||
158 | export function webserver() { | 170 | export function webserver() { |
159 | gulp.src([ | 171 | gulp.src([paths.dest]).pipe( |
160 | paths.dest, | 172 | server({ |
161 | ]) | ||
162 | .pipe(server({ | ||
163 | livereload: true, | 173 | livereload: true, |
164 | })); | 174 | }), |
175 | ); | ||
165 | } | 176 | } |
166 | 177 | ||
167 | export function dictionaries(done) { | 178 | export function dictionaries(done) { |
168 | const { SPELLCHECKER_LOCALES } = require('./build/i18n/languages'); | 179 | const { SPELLCHECKER_LOCALES } = require('./build/i18n/languages'); |
169 | 180 | ||
170 | let packages = ''; | 181 | let packages = ''; |
171 | Object.keys(SPELLCHECKER_LOCALES).forEach((key) => { packages = `${packages} hunspell-dict-${key}`; }); | 182 | Object.keys(SPELLCHECKER_LOCALES).forEach((key) => { |
183 | packages = `${packages} hunspell-dict-${key}`; | ||
184 | }); | ||
172 | 185 | ||
173 | _shell(`npm install --prefix "${path.join(__dirname, 'temp')}" ${packages}`, () => { | 186 | _shell( |
174 | moveSync( | 187 | `npm install --prefix "${path.join(__dirname, 'temp')}" ${packages}`, |
175 | path.join(__dirname, 'temp', 'node_modules'), | 188 | () => { |
176 | path.join(__dirname, 'build', paths.dictionaries), | 189 | moveSync( |
177 | ); | 190 | path.join(__dirname, 'temp', 'node_modules'), |
191 | path.join(__dirname, 'build', paths.dictionaries), | ||
192 | ); | ||
178 | 193 | ||
179 | removeSync(path.join(__dirname, 'temp')); | 194 | removeSync(path.join(__dirname, 'temp')); |
180 | 195 | ||
181 | done(); | 196 | done(); |
182 | }); | 197 | }, |
198 | ); | ||
183 | } | 199 | } |
184 | 200 | ||
185 | export function recipes() { | 201 | export function recipes() { |
@@ -187,10 +203,6 @@ export function recipes() { | |||
187 | .pipe(gulp.dest(paths.recipes.dest)); | 203 | .pipe(gulp.dest(paths.recipes.dest)); |
188 | } | 204 | } |
189 | 205 | ||
190 | export function sign(done) { | ||
191 | _shell(`codesign --verbose=4 --deep --strict --force --sign "${process.env.SIGNING_IDENTITY}" "${__dirname}/node_modules/electron/dist/Electron.app"`, done); | ||
192 | } | ||
193 | |||
194 | const build = gulp.series( | 206 | const build = gulp.series( |
195 | clean, | 207 | clean, |
196 | gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages), | 208 | gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages), |