-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add support to associate a search hub when creating a sear…
- Loading branch information
Showing
12 changed files
with
180 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {confirm, promptChoices, prompt} from '@coveo/cli-commons/utils/ux'; | ||
import PlatformClient from '@coveo/platform-client'; | ||
import inquirer from 'inquirer'; | ||
|
||
const manuallyEnterSearchHub = () => | ||
prompt('Enter the search hub you want to use', ''); | ||
|
||
export async function promptForSearchHub(client: PlatformClient) { | ||
const createSearchHub = await confirm( | ||
'An API key will be created against your organization. We strongly recommends that you associate this API key with a search hub. Would you like to do so now ? y/n', | ||
false | ||
); | ||
if (!createSearchHub) { | ||
return; | ||
} | ||
|
||
const availableHubs = await client.searchUsageMetrics.searchHubs.list(); | ||
if (availableHubs.hubs.length === 0) { | ||
return await manuallyEnterSearchHub(); | ||
} | ||
|
||
const choice = await promptChoices( | ||
'Use an existing search hub, or create a new one?', | ||
[ | ||
new inquirer.Separator(), | ||
'Create a new one', | ||
new inquirer.Separator(), | ||
...availableHubs.hubs.map((hub) => hub.name), | ||
], | ||
'' | ||
); | ||
|
||
if (choice === 'Create a new one') { | ||
return await manuallyEnterSearchHub(); | ||
} | ||
return choice; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.