added support for current branch, and some cleanup
This commit is contained in:
@@ -3,7 +3,7 @@ const chalk = require('chalk');
|
||||
const { AutoComplete, Input, Confirm } = require('enquirer');
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { GluegunPrint } from 'gluegun';
|
||||
import { defaultMenuSettings } from '../../../../globals';
|
||||
import { defaultMenuSettings, getCurrentBranch, getSettings } from '../../../../globals';
|
||||
const os = require("os");
|
||||
|
||||
const STACK_DEFAULTS = {
|
||||
@@ -68,11 +68,14 @@ const getUpdateStackCommand = (stackName: string, branch: string, templateFile:
|
||||
return cmd.join(' ');
|
||||
}
|
||||
|
||||
const getBranchName = async (print: GluegunPrint, token: string) => {
|
||||
const getBranchName = async (toolbox: GluegunMenuToolbox, token: string, repoPath: string) => {
|
||||
const {print} = toolbox;
|
||||
const currentBranch = await getCurrentBranch(repoPath, toolbox);
|
||||
const input = new Input({
|
||||
type: 'input',
|
||||
name: 'branch',
|
||||
message: 'What github branch should be deployed?'
|
||||
message: 'What github branch should be deployed?',
|
||||
initial: currentBranch,
|
||||
});
|
||||
const responseBranch = await input.run();
|
||||
|
||||
@@ -114,26 +117,18 @@ module.exports = {
|
||||
description: 'Update stack with different branch (u)',
|
||||
hidden: false,
|
||||
run: async (toolbox: GluegunMenuToolbox) => {
|
||||
const { system, strings, print, filesystem } = toolbox;
|
||||
const { system, strings, print } = toolbox;
|
||||
|
||||
// Load settings
|
||||
const config = await filesystem.readAsync(`${os.homedir()}/.pwcli_settings`, "json");
|
||||
const config = await getSettings(toolbox);
|
||||
if (!config) {
|
||||
print.error(`
|
||||
|
||||
No config found, please run [ ${chalk.cyan('pwcli s')} ] or setup from the menu.
|
||||
|
||||
`);
|
||||
if (toolbox.fromMenu()) {
|
||||
await toolbox.menu.showMenu(null, defaultMenuSettings)
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
await toolbox.menu.showMenu('setup', defaultMenuSettings);
|
||||
return;
|
||||
}
|
||||
|
||||
let branchName = null;
|
||||
while (!branchName) {
|
||||
branchName = await getBranchName(print, config.gh_token);
|
||||
branchName = await getBranchName(toolbox, config.gh_token, config.photowall_repo);
|
||||
}
|
||||
|
||||
const stacks = JSON.parse(
|
||||
|
||||
Reference in New Issue
Block a user