|
1 | 1 | /// <reference path="../types/types.js" /> |
2 | 2 | import { checkIsOnline, checkSshConnection } from '../utils/check.js' |
3 | 3 | import { checkGithubTokenEnv, checkGithubToken, getGithubOrgs } from '../github/auth.js' |
4 | | -import { githubRepoFromTemplatePrompts, localRepoFromTemplatePrompts, initType } from './init/prompts.js' |
| 4 | +import { githubRepoFromTemplatePrompts, localRepoFromTemplatePrompts, initType, confirmClone } from './init/prompts.js' |
5 | 5 | import { createGithubRepoWithTemplate, updateGithubRepoSettings, updateGithubBranchProtection } from '../github/repo.js' |
6 | 6 | import { addRepositorySecrets } from '../github/secrets.js' |
7 | 7 | import { updateAndCommit } from '../github/commit.js' |
8 | 8 | import { confirmNextSteps } from '../utils/prompts.js' |
9 | | -import { gitCloneDepth1, gitInit, gitAddAll, gitCommit } from '../git/git.js' |
10 | | -import { parseJson, removePath, writeJson } from '../utils/fs.js' |
| 9 | +import { gitCloneDepth1, gitInit, gitAddAll, gitCommit, gitClone } from '../git/git.js' |
| 10 | +import { parseJson, removePath, writeJson, addDotEnvFile } from '../utils/fs.js' |
11 | 11 | import chalk from 'chalk' |
12 | 12 |
|
13 | 13 | /** |
@@ -85,6 +85,18 @@ async function initGithubRepoBasedOnTemplate (data) { |
85 | 85 | label: `${data.prompts?.githubRepoFromTmpl?.newRepoLabel.charAt(0).toUpperCase()}${data.prompts?.githubRepoFromTmpl?.newRepoLabel.slice(1)}` |
86 | 86 | } |
87 | 87 | ) |
| 88 | + if (await confirmClone()) { |
| 89 | + if (data.git?.isRepo) { |
| 90 | + console.warn('Better to clone the new repository to a simple folder rather than a git repository') |
| 91 | + console.log('You can do it manually with the following command:') |
| 92 | + console.log(chalk.yellow(`git clone git@github.com:${data?.prompts?.githubRepoFromTmpl?.newRepoOwner}/${data.prompts?.githubRepoFromTmpl?.newRepoName}.git`)) |
| 93 | + process.exit(1) |
| 94 | + } |
| 95 | + if (data.prompts?.githubRepoFromTmpl?.newRepoName && data.prompts?.githubRepoFromTmpl?.newRepoOwner && data.prompts?.githubRepoFromTmpl.projectName) { |
| 96 | + await gitClone(data.prompts.githubRepoFromTmpl.newRepoOwner, data.prompts.githubRepoFromTmpl.newRepoName) |
| 97 | + await addDotEnvFile(data.cwd.path, data.prompts.githubRepoFromTmpl.newRepoName, data.prompts.githubRepoFromTmpl.projectName) |
| 98 | + } |
| 99 | + } |
88 | 100 | } |
89 | 101 |
|
90 | 102 | /** |
@@ -127,6 +139,9 @@ async function initLocalRepoBasedOnTemplate (data) { |
127 | 139 | await writeJson(`${data?.cwd.path}/${data.prompts?.localRepoFromTmpl?.newRepoName}/theme/theme.json`, themeJson) |
128 | 140 | await gitAddAll({ cwd: `${data?.cwd.path}/${data.prompts?.localRepoFromTmpl?.newRepoName}` }) |
129 | 141 | await gitCommit('[TASK] update package.json and theme.json with new project info', { cwd: `${data?.cwd.path}/${data.prompts?.localRepoFromTmpl?.newRepoName}` }) |
| 142 | + if (data.prompts?.localRepoFromTmpl?.newRepoName && data.prompts?.localRepoFromTmpl.projectName) { |
| 143 | + await addDotEnvFile(data.cwd.path, data.prompts.localRepoFromTmpl.newRepoName, data.prompts.localRepoFromTmpl.projectName) |
| 144 | + } |
130 | 145 | } |
131 | 146 | } |
132 | 147 |
|
|
0 commit comments