Skip to content
Permalink
Browse files

A few init improvements

This makes init work when you made a deploy to a site manually and want to upgrade to using CI.  It also adds a force flag so you can re-init a site that is already using CI.
  • Loading branch information...
bcomnes committed Dec 4, 2018
1 parent 8ffb2c4 commit fdf072343f9cb9dd3b6b3b28d99c6bc158897545
Showing with 27 additions and 22 deletions.
  1. +27 −22 src/commands/init.js
@@ -29,7 +29,7 @@ class InitCommand extends Command {
// silent api error
}

if (siteId && siteData) {
if (siteId && siteData && get(siteData, 'build_settings.repo_url') && !flags.force) {
const repoUrl = get(siteData, 'build_settings.repo_url')
this.log()
this.log(`${chalk.yellow('Warning:')} It looks like this site has already been initialized.`)
@@ -140,30 +140,32 @@ git remote add origin https://github.com/YourUserName/RepoName.git
this.error(repo.error)
}

const NEW_SITE = '+ Create & configure a new site'
const EXISTING_SITE = '⇄ Link this directory to an existing site'
if (!siteData) {
const NEW_SITE = '+ Create & configure a new site'
const EXISTING_SITE = '⇄ Link this directory to an existing site'

const initializeOpts = [EXISTING_SITE, NEW_SITE]
const initializeOpts = [EXISTING_SITE, NEW_SITE]

const { initChoice } = await inquirer.prompt([
{
type: 'list',
name: 'initChoice',
message: 'What would you like to do?',
choices: initializeOpts
const { initChoice } = await inquirer.prompt([
{
type: 'list',
name: 'initChoice',
message: 'What would you like to do?',
choices: initializeOpts
}
])

// create site or search for one
if (initChoice === NEW_SITE) {
await track('sites_initStarted', {
type: 'new site'
})
// run site:create command
siteData = await SitesCreateCommand.run([])
} else if (initChoice === EXISTING_SITE) {
// run link command
siteData = await LinkCommand.run([], false)
}
])

// create site or search for one
if (initChoice === NEW_SITE) {
await track('sites_initStarted', {
type: 'new site'
})
// run site:create command
siteData = await SitesCreateCommand.run([])
} else if (initChoice === EXISTING_SITE) {
// run link command
siteData = await LinkCommand.run([], false)
}

// Check for existing CI setup
@@ -239,6 +241,9 @@ InitCommand.flags = {
watch: flags.boolean({
char: 'w',
description: 'Make the CLI wait for the first deploy to complete after setting up CI'
}),
force: flags.boolean({
description: 'Reinitialize CI hooks if the linked site is already configured to use CI'
})
}

0 comments on commit fdf0723

Please sign in to comment.
You can’t perform that action at this time.