aboutsummaryrefslogtreecommitdiffstats
path: root/app/Controllers/Http/RecipeController.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controllers/Http/RecipeController.js')
-rw-r--r--app/Controllers/Http/RecipeController.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js
index a2b129d..07cd430 100644
--- a/app/Controllers/Http/RecipeController.js
+++ b/app/Controllers/Http/RecipeController.js
@@ -9,6 +9,7 @@ const Env = use('Env');
9const targz = require('targz'); 9const targz = require('targz');
10const path = require('path'); 10const path = require('path');
11const fs = require('fs-extra'); 11const fs = require('fs-extra');
12const semver = require('semver');
12 13
13const compress = (src, dest) => new Promise((resolve, reject) => { 14const compress = (src, dest) => new Promise((resolve, reject) => {
14 targz.compress({ 15 targz.compress({
@@ -166,8 +167,24 @@ class RecipeController {
166 ); 167 );
167 } 168 }
168 169
169 update({ response }) { 170 update({ request, response }) {
170 return response.send([]); 171 const updates = [];
172 const recipes = request.all();
173 const allJson = fs.readJsonSync(path.join(
174 Helpers.appRoot(), 'recipes', 'all.json',
175 ));
176
177 for (const recipe of Object.keys(recipes)) {
178 const version = recipes[recipe];
179
180 // Find recipe in local recipe repository
181 const localRecipe = allJson.find(r => r.id === recipe);
182 if (localRecipe && semver.lt(version, localRecipe.version)) {
183 updates.push(recipe);
184 }
185 }
186
187 return response.send(updates);
171 } 188 }
172 189
173 // Download a recipe 190 // Download a recipe