From 00b4571e6fe7ecf16ffb47c3cfc01ae734e528a9 Mon Sep 17 00:00:00 2001 From: MaxGenash Date: Fri, 12 Mar 2021 22:07:18 +0200 Subject: [PATCH] feat: strf-8282 - update pull command to take into account multiple channels --- bin/stencil-pull.js | 3 ++- lib/stencil-pull.js | 2 ++ lib/stencil-push.utils.js | 11 ++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/stencil-pull.js b/bin/stencil-pull.js index 475b068e..bb6b761a 100755 --- a/bin/stencil-pull.js +++ b/bin/stencil-pull.js @@ -30,8 +30,9 @@ const cliOptions = program.opts(); const options = { apiHost: cliOptions.host || API_HOST, saveConfigName: cliOptions.filename, - channelId: cliOptions.channel_id || 1, + channelId: cliOptions.channel_id, saved: cliOptions.saved || false, + applyTheme: true, // fix to be compatible with stencil-push.utils }; stencilPull(options, (err) => { diff --git a/lib/stencil-pull.js b/lib/stencil-pull.js index b330de3c..d2a6cbdf 100644 --- a/lib/stencil-pull.js +++ b/lib/stencil-pull.js @@ -8,6 +8,8 @@ function stencilPull(options = {}, callback) { async.constant(options), stencilPushUtils.readStencilConfigFile, stencilPushUtils.getStoreHash, + stencilPushUtils.getChannels, + stencilPushUtils.promptUserForChannel, stencilPullUtils.getChannelActiveTheme, stencilPullUtils.getThemeConfiguration, stencilPullUtils.mergeThemeConfiguration, diff --git a/lib/stencil-push.utils.js b/lib/stencil-push.utils.js index 963aafd2..518d61ef 100644 --- a/lib/stencil-push.utils.js +++ b/lib/stencil-push.utils.js @@ -280,12 +280,13 @@ utils.promptUserWhetherToApplyTheme = async (options) => { utils.getChannels = async (options) => { const { config: { accessToken }, + channelId, apiHost, storeHash, applyTheme, } = options; - if (!applyTheme) { + if (!applyTheme || channelId) { return options; } @@ -344,15 +345,19 @@ utils.getVariations = async (options) => { utils.promptUserForChannel = async (options) => { const { applyTheme, channelId, channels } = options; - if (!applyTheme || channelId || channels.length < 2) { + if (!applyTheme || channelId) { return options; } + if (channels.length < 2) { + return { ...options, channelId: channels[0].id }; + } + const questions = [ { type: 'list', name: 'channelId', - message: 'Which channel would you like to apply the theme to?', + message: 'Which channel would you like to use?', choices: channels.map((channel) => ({ name: channel.name, value: channel.id,