UNPKG

pivotal-flow

Version:

🔀 A command-line tool that helps you manage & automate your workflow to use with PivotalTracker.

127 lines (126 loc) • 4.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const string_1 = require("../../utils/string"); const common_1 = require("../../utils/pivotal/common"); const types_1 = require("../../utils/pivotal/types"); const utils_1 = require("./utils"); const helpText_1 = require("./helpText"); exports.PickStoryWorkflowQuestions = [ { type: 'list', name: 'selection', message: 'What do you want to do?', default: 0, choices: [ { name: 'Create a new story & start working on it', value: 0 /* New */ }, { name: 'Work on a story assigned to you', value: 1 /* Owned */ }, { name: 'Work on any other story', value: 2 /* Unassigned */ }, ], }, ]; exports.getPickProjectQuestions = (projects) => { const projectChoices = projects.map(({ name, id: value }) => ({ name: `${name} [${value}]`, value, })); return [ { type: 'list', name: 'selectedProject', message: 'Choose a project to work on?', default: 0, choices: [...projectChoices], }, ]; }; exports.WorkOnNewStoryQuestions = [ { type: 'list', name: 'story_type', message: 'Story Type:', choices: common_1.getStoryTypeChoices(), default: 0, prefix: helpText_1.HelpWorkOnNewStory.story_type, }, { type: 'input', name: 'name', message: 'Story Title:', prefix: helpText_1.HelpWorkOnNewStory.name, validate: (name) => { if (name && name.length >= 9) { return true; } return 'Please enter a valid story title (min. 9 characters).'; }, }, { // TODO: fetch estimation options based on project settings later type: 'list', name: 'estimate', message: 'Story Estimate (points):', choices: types_1.PointScales.fibonacci, default: 1, when: answers => answers.story_type === types_1.StoryType.Feature, prefix: helpText_1.HelpWorkOnNewStory.estimate, }, { type: 'input', name: 'labelNames', message: 'Story Labels/Epics:', default: '', prefix: helpText_1.HelpWorkOnNewStory.labelNames, }, { type: 'confirm', name: 'promptDescription', message: 'Would you like to add a description to the story?', default: false, prefix: helpText_1.HelpWorkOnNewStory.promptDescription, }, { type: 'editor', name: 'description', message: 'Story Description', when: answers => answers.promptDescription === true, default: '', }, ]; exports.getSelectStoryFromListQuestions = (stories) => [ { type: 'autocomplete', name: 'story', prefix: helpText_1.HelpSelectStoryFromList, message: 'Pick a story to work on', source: utils_1.getSearchableStoryListSource(stories), }, ]; exports.getStartStoryQuestions = (story) => { const { story_type: type, id, name } = story; const slugifiedStoryName = string_1.slugifyName(name); const suggestedBranchName = common_1.getStoryBranchName(slugifiedStoryName, type, id); const storyTable = utils_1.getStoryDetailsAsTable(story); return [ { type: 'confirm', name: 'checkoutBranch', message: `\n\nWould you like to checkout a new branch for this story?:`, prefix: helpText_1.HelpStartStory.actions(storyTable), default: true, }, { type: 'input', name: 'branchName', message: 'Branch Name:', prefix: helpText_1.HelpStartStory.branchName(suggestedBranchName), when: answers => answers.checkoutBranch === true, default: slugifiedStoryName, validate: (input) => { if (!input || input.length < 8 || input.length > 40) { return 'Please limit the branch name (excluding story-type & story-id) to between 8-40 characters.'; } return true; }, }, ]; };