@@ -7,6 +7,7 @@ import { runCoreSteps } from '@netlify/build'
7
7
import { restoreConfig , updateConfig } from '@netlify/config'
8
8
import { Option } from 'commander'
9
9
import inquirer from 'inquirer'
10
+ import isEmpty from 'lodash/isEmpty.js'
10
11
import isObject from 'lodash/isObject.js'
11
12
import prettyjson from 'prettyjson'
12
13
@@ -488,7 +489,7 @@ const printResults = ({ deployToProduction, json, results, runBuildCommand }) =>
488
489
* @param {import('../base-command.mjs').default } command
489
490
*/
490
491
const deploy = async ( options , command ) => {
491
- const { api, site } = command . netlify
492
+ const { api, site, siteInfo } = command . netlify
492
493
const alias = options . alias || options . branch
493
494
494
495
command . setAnalyticsPayload ( { open : options . open , prod : options . prod , json : options . json , alias : Boolean ( alias ) } )
@@ -503,35 +504,12 @@ const deploy = async (options, command) => {
503
504
504
505
await command . authenticate ( options . auth )
505
506
506
- let siteId = options . site || site . id
507
+ let siteId = site . id || options . site
507
508
508
509
let siteData = { }
509
- if ( siteId ) {
510
- try {
511
- const [ { siteError, siteFoundById } , sites ] = await Promise . all ( [
512
- api
513
- . getSite ( { siteId } )
514
- . then ( ( data ) => ( { siteFoundById : data } ) )
515
- . catch ( ( error_ ) => ( { siteError : error_ } ) ) ,
516
- api . listSites ( { name : options . site , filter : 'all' } ) ,
517
- ] )
518
- const siteFoundByName = sites . find ( ( filteredSite ) => filteredSite . name === options . site )
519
- if ( siteFoundById ) {
520
- siteData = siteFoundById
521
- } else if ( siteFoundByName ) {
522
- siteData = siteFoundByName
523
- siteId = siteFoundByName . id
524
- } else {
525
- throw siteError
526
- }
527
- } catch ( error_ ) {
528
- // TODO specifically handle known cases (e.g. no account access)
529
- if ( error_ . status === 404 ) {
530
- error ( 'Site not found' )
531
- } else {
532
- error ( error_ . message )
533
- }
534
- }
510
+ if ( siteId && ! isEmpty ( siteInfo ) ) {
511
+ siteData = siteInfo
512
+ siteId = siteData . id
535
513
} else {
536
514
log ( "This folder isn't linked to a site yet" )
537
515
const NEW_SITE = '+ Create & configure a new site'
0 commit comments