@@ -8,10 +8,10 @@ const { track } = require('../telemetry')
8
8
module . exports = async function linkPrompts ( context ) {
9
9
const { api, state } = context . netlify
10
10
11
- const SITE_NAME_PROMPT = 'Site Name '
12
- const SITE_ID_PROMPT = 'Site ID'
11
+ const SITE_NAME_PROMPT = 'Choose from a list of your sites '
12
+ const SITE_ID_PROMPT = `Use a site ID`
13
13
14
- let GIT_REMOTE_PROMPT = `Use current git remote URL`
14
+ let GIT_REMOTE_PROMPT = `Use a current git remote URL`
15
15
let site
16
16
// Get git remote data if exists
17
17
const repoInfo = await getRepoData ( )
@@ -110,47 +110,28 @@ Run ${chalk.cyanBright('`git remote -v`')} to see a list of your git remotes.`)
110
110
}
111
111
case SITE_NAME_PROMPT : {
112
112
kind = 'byName'
113
- const { siteName } = await inquirer . prompt ( [
114
- {
115
- type : 'input' ,
116
- name : 'siteName' ,
117
- message : 'What is the name of the site?'
118
- }
119
- ] )
113
+
120
114
let sites
121
115
try {
122
- sites = await api . listSites ( {
123
- name : siteName ,
124
- filter : 'all'
125
- } )
116
+ sites = await api . listSites ( )
126
117
} catch ( e ) {
127
- if ( e . status === 404 ) {
128
- context . error ( `${ siteName } not found` )
129
- } else {
130
- context . error ( e )
131
- }
118
+ context . error ( e )
132
119
}
133
120
134
121
if ( sites . length === 0 ) {
135
- context . error ( `No sites found named ${ siteName } ` )
122
+ context . error ( `You don't have any sites. Use netlify 'sites:create' to create a site. ` )
136
123
}
137
124
138
- if ( sites . length > 1 ) {
139
- const { selectedSite } = await inquirer . prompt ( [
140
- {
141
- type : 'list' ,
142
- name : 'selectedSite' ,
143
- paginated : true ,
144
- choices : sites . map ( site => ( { name : site . name , value : site } ) )
145
- }
146
- ] )
147
- if ( ! selectedSite ) {
148
- context . error ( 'No site selected' )
125
+ const siteSelection = await inquirer . prompt ( [
126
+ {
127
+ type : 'list' ,
128
+ name : 'siteName' ,
129
+ message : 'What is the name of the site?' ,
130
+ paginated : true ,
131
+ choices : sites . map ( site => ( { name : site . name , value : site } ) )
149
132
}
150
- site = selectedSite
151
- } else {
152
- site = sites [ 0 ]
153
- }
133
+ ] )
134
+ site = siteSelection . siteName
154
135
break
155
136
}
156
137
case SITE_ID_PROMPT : {
0 commit comments