pivotal-flow
Version:
🔀 A command-line tool that helps you manage & automate your workflow to use with PivotalTracker.
52 lines (51 loc) • 2.44 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const console_1 = require("../../utils/console");
const utils_1 = require("../init/utils");
const client_1 = __importDefault(require("../../utils/pivotal/client"));
const utils_2 = require("./utils");
(() => __awaiter(void 0, void 0, void 0, function* () {
const program = new commander_1.Command();
program.name('start');
program.option('-n, --new-story', 'create a new story & start working on it', false);
program.option('--debug', 'Debug the start command', false);
// parse at the end & then use options
program.parse(process.argv);
if (program.debug)
console.log(program.opts());
yield utils_1.abortIfNotSetup();
const { newStory = false, debug = false } = program;
try {
const { projectId, apiToken } = yield utils_2.selectProjectToCreateStory();
const client = new client_1.default({ apiToken, projectId });
const workflow = yield utils_2.getWorkflow({ newStory: newStory });
const profile = yield client.getProfile();
const story = yield utils_2.getStoryToWorkOn(client, profile, workflow);
yield utils_2.startWorkingOnStory(story);
}
catch (e) {
if (e instanceof Error) {
console_1.error(e.valueOf().toString());
}
else {
console_1.warning('An unknown error occurred. Use the --debug option to get more details.`');
}
debug && console_1.error(e);
process.exit(1);
}
process.exit(0);
}))();