Skip to content

Commit

Permalink
feat(sites): clone the generated repo #4411 (#4427)
Browse files Browse the repository at this point in the history
* feat(sites): clone the generated repo #4411

* chore: shrinkwarp

* chore: use git_url

* chore: use clone/promise

* fix: liny

* chore: clone at root

* chore: git-clones removal

* refactor: clone after site information is logged

Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
  • Loading branch information
iib0011 and erezrokah committed Mar 8, 2022
1 parent ca43189 commit 63c74f5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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
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
@@ -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

1 comment on commit 63c74f5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 380 MB

Please sign in to comment.