From 474c265e6f51b9831fd39fc8a70e2e14b6d49a3f Mon Sep 17 00:00:00 2001 From: Marcel Kloubert Date: Mon, 5 Jun 2017 18:57:26 +0200 Subject: [PATCH] improved caching in prompt plugin --- CHANGELOG.md | 2 +- package.json | 2 +- src/plugins/prompt.ts | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c91ec63..5a6a8bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log (vs-deploy) -## 9.18.0 (June 5th, 2017; prompt target) +## 9.18.1 (June 5th, 2017; prompt target) * added new [prompt](https://github.com/mkloubert/vs-deploy/wiki/target_prompt) target, which asks the user for a list of settings that will be applied to one or more other [targets](https://github.com/mkloubert/vs-deploy/wiki#targets-) diff --git a/package.json b/package.json index d559647..3feaee2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vs-deploy", "displayName": "Deploy", "description": "Commands for deploying files of your workspace to a destination.", - "version": "9.18.0", + "version": "9.18.1", "publisher": "mkloubert", "engines": { "vscode": "^1.6.0" diff --git a/src/plugins/prompt.ts b/src/plugins/prompt.ts index 01fe689..f1c169b 100644 --- a/src/plugins/prompt.ts +++ b/src/plugins/prompt.ts @@ -149,6 +149,7 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase { wf.next((wfCtx) => { wfCtx.value = { properties: {}, + propertiesToCache: [], }; }); @@ -188,6 +189,7 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase { // create action wf.next((wfCtx) => { let properties = wfCtx.value['properties']; + let propertiesToCache: any[] = wfCtx.value['propertiesToCache']; // define value converter let valueConverter: (val: string) => any; @@ -265,8 +267,10 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase { else { if ('undefined' !== typeof userValue) { if (doCache) { - me.context.targetCache() - .set(target, cacheKey, userValue); + propertiesToCache.push({ + 'key': cacheKey, + 'value': userValue, + }); } Promise.resolve( valueConverter(userValue) ).then((valueToSet) => { @@ -452,6 +456,16 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase { await wfTargets.start(); }); + // cache values + wf.next((wfCtx) => { + let propertiesToCache: any[] = wfCtx.value['propertiesToCache']; + + propertiesToCache.forEach(ptc => { + me.context.targetCache() + .set(target, ptc.key, ptc.value); + }); + }); + wf.on('action.after', afterWorkflowsAction);