draaft
Version:
A CLI to pull content from https://pilot.pm content collaboration platform and feed your static site generator with markdown files
84 lines (83 loc) • 2.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const inquirer_1 = require("inquirer");
const _ = require("lodash");
inquirer_1.registerPrompt("fuzzypath", require("inquirer-fuzzy-path"));
function askToken() {
return inquirer_1.prompt({
type: "password",
name: "apiToken",
message: "What is your API token?",
mask: "*",
});
}
exports.askToken = askToken;
/**
* Ask user which channel to pull content from
* @param {string} channelsList - Channels list
* @returns {*}
*/
function askChannels(channelsList) {
let choices = _.map(channelsList, (channel) => {
return {
name: channel.name,
value: channel.id,
};
});
return inquirer_1.prompt([
{
name: "channel",
message: "Select channels to pull content from\n",
type: "checkbox",
choices: choices,
},
]);
}
exports.askChannels = askChannels;
/**
* Ask user which workflow states should define a content as published ( draft = false )
* @param {string} statesList - WorkflowState list
* @returns {*}
*/
function askPublicationStates(statesList) {
let choices = _.map(statesList, (state) => {
return {
name: state.label,
value: state.id,
};
});
return inquirer_1.prompt([
{
name: "workflowState",
message: "Select which workflow state to use for publication\n",
type: "checkbox",
choices: choices,
},
]);
}
exports.askPublicationStates = askPublicationStates;
exports.askDestDir = () => {
return inquirer_1.prompt([
{
type: "fuzzypath",
name: "path",
// @ts-ignore
excludePath: (nodePath) => nodePath.startsWith(".git") ||
nodePath.startsWith("node_modules") ||
nodePath.startsWith(".draaft"),
// excludePath :: (String) -> Bool
// excludePath to exclude some paths from the file-system scan
itemType: "directory",
// itemType :: 'any' | 'directory' | 'file'
// specify the type of nodes to display
// default value: 'any'
// example: itemType: 'file' - hides directories from the item list
rootPath: "./",
// rootPath :: String
// Root search directory
message: "Select a destination directory where we will download your content to :",
default: "./",
suggestOnly: false,
},
]);
};