Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sites): clone the generated repo #4411 #4427

Merged
merged 12 commits into from
Mar 8, 2022
11 changes: 11 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
"fuzzy": "^0.1.3",
"get-port": "^5.1.0",
"gh-release-fetch": "^3.0.0",
"git-clone": "^0.2.0",
"git-repo-info": "^2.1.0",
"gitconfiglocal": "^2.1.0",
"graphql": "^16.1.0",
Expand Down
16 changes: 15 additions & 1 deletion src/commands/sites/sites-create-template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check

const clone = require('git-clone/promise')
const inquirer = require('inquirer')
const pick = require('lodash/pick')
const parseGitHubUrl = require('parse-github-url')
Expand Down Expand Up @@ -111,6 +112,7 @@ const sitesCreateTemplate = async (repository, options, command) => {
const { name: nameFlag } = options
let user
let site
let repoResp

// Allow the user to reenter site name if selected one isn't available
const inputSiteName = async (name) => {
Expand All @@ -120,7 +122,7 @@ const sitesCreateTemplate = async (repository, options, command) => {
const siteName = inputName ? inputName.trim() : siteSuggestion

// Create new repo from template
const repoResp = await createRepo(templateName, ghToken, siteName)
repoResp = await createRepo(templateName, ghToken, siteName)

if (repoResp.errors) {
if (repoResp.errors[0].includes('Name already exists on this account')) {
Expand Down Expand Up @@ -181,6 +183,18 @@ const sitesCreateTemplate = async (repository, options, command) => {
siteUrl,
})

const { cloneConfirm } = await inquirer.prompt({
type: 'confirm',
name: 'cloneConfirm',
message: `Do you want to clone the repository?`,
default: true,
})
if (cloneConfirm) {
log()
await clone(repoResp.git_url, `${repoResp.name}`)
log(`🚀 Repository cloned successfully. You can find it under the ${chalk.magenta(repoResp.name)} folder`)
}

if (options.withCi) {
log('Configuring CI')
const repoData = await getRepoData()
Expand Down