Skip to content

Commit

Permalink
feat: strf-8282 - update pull command to take into account multiple c…
Browse files Browse the repository at this point in the history
…hannels
  • Loading branch information
MaxGenash committed Mar 12, 2021
1 parent 7582e7c commit 00b4571
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bin/stencil-pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 2 additions & 0 deletions lib/stencil-pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions lib/stencil-push.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 00b4571

Please sign in to comment.