diff options
author | vantezzen <hello@vantezzen.io> | 2019-09-25 10:45:41 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2019-09-25 10:45:41 +0200 |
commit | 64ab9231042408a7eeb174e30e598e42d09c6c29 (patch) | |
tree | 6ddd0df2906df6fe515c87517d9b0d3931567bf1 | |
parent | 5.3.4-beta.2 (diff) | |
download | ferdium-app-64ab9231042408a7eeb174e30e598e42d09c6c29.tar.gz ferdium-app-64ab9231042408a7eeb174e30e598e42d09c6c29.tar.zst ferdium-app-64ab9231042408a7eeb174e30e598e42d09c6c29.zip |
Shipping recipe files directly with Ferdi
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | gulpfile.babel.js | 11 | ||||
m--------- | recipes | 0 | ||||
-rw-r--r-- | src/api/server/ServerApi.js | 29 |
4 files changed, 36 insertions, 7 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..5a8d15f8f --- /dev/null +++ b/.gitmodules | |||
@@ -0,0 +1,3 @@ | |||
1 | [submodule "recipes"] | ||
2 | path = recipes | ||
3 | url = https://github.com/getferdi/recipes | ||
diff --git a/gulpfile.babel.js b/gulpfile.babel.js index c0400bdac..43ebaa20a 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js | |||
@@ -28,6 +28,10 @@ const paths = { | |||
28 | tmp: '.tmp', | 28 | tmp: '.tmp', |
29 | dictionaries: 'dictionaries', | 29 | dictionaries: 'dictionaries', |
30 | package: `out/${config.version}`, | 30 | package: `out/${config.version}`, |
31 | recipes: { | ||
32 | src: 'recipes/*.tar.gz', | ||
33 | dest: 'build/recipes/', | ||
34 | }, | ||
31 | html: { | 35 | html: { |
32 | src: 'src/**/*.html', | 36 | src: 'src/**/*.html', |
33 | dest: 'build/', | 37 | dest: 'build/', |
@@ -178,6 +182,11 @@ export function dictionaries(done) { | |||
178 | }); | 182 | }); |
179 | } | 183 | } |
180 | 184 | ||
185 | export function recipes() { | ||
186 | return gulp.src(paths.recipes.src, { since: gulp.lastRun(recipes) }) | ||
187 | .pipe(gulp.dest(paths.recipes.dest)); | ||
188 | } | ||
189 | |||
181 | export function sign(done) { | 190 | export function sign(done) { |
182 | _shell(`codesign --verbose=4 --deep --strict --force --sign "${process.env.SIGNING_IDENTITY}" "${__dirname}/node_modules/electron/dist/Electron.app"`, done); | 191 | _shell(`codesign --verbose=4 --deep --strict --force --sign "${process.env.SIGNING_IDENTITY}" "${__dirname}/node_modules/electron/dist/Electron.app"`, done); |
183 | } | 192 | } |
@@ -185,7 +194,7 @@ export function sign(done) { | |||
185 | const build = gulp.series( | 194 | const build = gulp.series( |
186 | clean, | 195 | clean, |
187 | gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages), | 196 | gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages), |
188 | gulp.parallel(html, scripts, styles), | 197 | gulp.parallel(html, scripts, styles, recipes), |
189 | dictionaries, | 198 | dictionaries, |
190 | ); | 199 | ); |
191 | export { build }; | 200 | export { build }; |
diff --git a/recipes b/recipes new file mode 160000 | |||
Subproject bd8c25be7961d167d315e76276627306b2379dc | |||
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index 3d973e586..663c2716f 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js | |||
@@ -13,6 +13,7 @@ import UserModel from '../../models/User'; | |||
13 | import OrderModel from '../../models/Order'; | 13 | import OrderModel from '../../models/Order'; |
14 | 14 | ||
15 | import { sleep } from '../../helpers/async-helpers'; | 15 | import { sleep } from '../../helpers/async-helpers'; |
16 | import { asarPath } from '../../helpers/asar-helpers'; | ||
16 | 17 | ||
17 | import { API } from '../../environment'; | 18 | import { API } from '../../environment'; |
18 | import apiBase from '../apiBase'; | 19 | import apiBase from '../apiBase'; |
@@ -369,14 +370,30 @@ export default class ServerApi { | |||
369 | try { | 370 | try { |
370 | const recipesDirectory = path.join(app.getPath('userData'), 'recipes'); | 371 | const recipesDirectory = path.join(app.getPath('userData'), 'recipes'); |
371 | const recipeTempDirectory = path.join(recipesDirectory, 'temp', recipeId); | 372 | const recipeTempDirectory = path.join(recipesDirectory, 'temp', recipeId); |
372 | const archivePath = path.join(recipeTempDirectory, 'recipe.tar.gz'); | 373 | const tempArchivePath = path.join(recipeTempDirectory, 'recipe.tar.gz'); |
373 | const packageUrl = `${apiBase()}/recipes/download/${recipeId}`; | 374 | |
375 | const internalRecipesDirectory = asarPath(path.join(__dirname, '../../', 'recipes')); | ||
376 | const internalRecipeFile = path.join(internalRecipesDirectory, `${recipeId}.tar.gz`); | ||
374 | 377 | ||
375 | fs.ensureDirSync(recipeTempDirectory); | 378 | fs.ensureDirSync(recipeTempDirectory); |
376 | const res = await fetch(packageUrl); | 379 | |
377 | debug('Recipe downloaded', recipeId); | 380 | let archivePath; |
378 | const buffer = await res.buffer(); | 381 | |
379 | fs.writeFileSync(archivePath, buffer); | 382 | if (await fs.exists(internalRecipeFile)) { |
383 | console.log('[ServerApi::getRecipePackage] Using internal recipe file'); | ||
384 | archivePath = internalRecipeFile; | ||
385 | } else { | ||
386 | console.log('[ServerApi::getRecipePackage] Downloading recipe from server'); | ||
387 | archivePath = tempArchivePath; | ||
388 | |||
389 | const packageUrl = `${apiBase()}/recipes/download/${recipeId}`; | ||
390 | |||
391 | const res = await fetch(packageUrl); | ||
392 | debug('Recipe downloaded', recipeId); | ||
393 | const buffer = await res.buffer(); | ||
394 | fs.writeFileSync(archivePath, buffer); | ||
395 | } | ||
396 | console.log(archivePath); | ||
380 | 397 | ||
381 | await sleep(10); | 398 | await sleep(10); |
382 | 399 | ||