Permalink
Browse files

Merge pull request #520 from amazeeio/autocomplete-for-customers-and-…

…openshifts

lagu project create: Autocomplete for customers and openshifts
  • Loading branch information...
Schnitzel committed Jul 31, 2018
2 parents 61f3b2b + d5af51b commit dcaa6e659764e436a4ff55529b258a97caee581d
Showing with 34 additions and 8 deletions.
  1. +3 −1 cli/package.json
  2. +17 −6 cli/src/commands/projectCommands/create.js
  3. +14 −1 yarn.lock
View
@@ -1,6 +1,6 @@
{
"name": "@lagoon/lagu",
"version": "1.1.0",
"version": "1.2.0",
"description": "Lagoon Command Line Interface",
"main": "./bin/lagu.js",
"bin": {
@@ -63,11 +63,13 @@
"chalk": "^2.4.1",
"exit": "^0.1.2",
"findup-sync": "^2.0.0",
"fuzzysearch": "^1.0.3",
"graphql": "^0.13.2",
"hosted-git-info": "^2.6.0",
"import-local": "^1.0.0",
"in-publish": "^2.0.0",
"inquirer": "^6.0.0",
"inquirer-autocomplete-prompt": "^1.0.1",
"js-yaml": "^3.11.0",
"ramda": "^0.25.0",
"ssh2": "^0.6.0",
@@ -1,8 +1,10 @@
// @flow
import { green, blue } from 'chalk';
import fuzzysearch from 'fuzzysearch';
import { fromUrl as hostedGitInfoFromUrl } from 'hosted-git-info';
import inquirer from 'inquirer';
import autocompletePrompt from 'inquirer-autocomplete-prompt';
import R from 'ramda';
import { table } from 'table';
@@ -20,6 +22,9 @@ import typeof Yargs from 'yargs';
import type { inquirer$Question } from 'inquirer';
import type { BaseHandlerArgs } from '..';
// $FlowFixMe inquirer$PromptModule interface doesn't match autocompletePrompt module
inquirer.registerPrompt('autocomplete', autocompletePrompt);
export const command = 'create';
export const description = 'Create new project';
@@ -186,11 +191,14 @@ export async function promptForProjectInput(
): Promise<Options> {
const questions: Array<Question> = [
{
type: 'list',
type: 'autocomplete',
name: CUSTOMER,
message: 'Customer:',
// $FlowFixMe Inquirer can also take values of numbers
choices: allCustomers,
source: async (answers, input) =>
R.filter(
customer => fuzzysearch(input || '', R.prop('name', customer)),
allCustomers,
),
// Using the `when` method of the question object, decide where to get the customer based on conditions
// https://github.com/SBoudrias/Inquirer.js/issues/517#issuecomment-288964496
when(answers) {
@@ -264,11 +272,14 @@ export async function promptForProjectInput(
}),
},
{
type: 'list',
type: 'autocomplete',
name: OPENSHIFT,
message: 'Openshift:',
// $FlowFixMe Inquirer can also take values of numbers
choices: allOpenshifts,
source: async (answers, input) =>
R.filter(
openshift => fuzzysearch(input || '', R.prop('name', openshift)),
allOpenshifts,
),
// Using the `when` method of the question object, decide where to get the openshift based on conditions
// https://github.com/SBoudrias/Inquirer.js/issues/517#issuecomment-288964496
when(answers) {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit dcaa6e6

Please sign in to comment.