As we're adding some actions to the starter, it doesn't make sense to keep them in the cloned projects with `create-medusa-app`. This PR removes the `.github` directory from the project after cloning it
81 lines
1.6 KiB
TypeScript
81 lines
1.6 KiB
TypeScript
import execute from "./execute.js"
|
|
import { Ora } from "ora"
|
|
import { isAbortError } from "./create-abort-controller.js"
|
|
import logMessage from "./log-message.js"
|
|
import fs from "fs"
|
|
import path from "path"
|
|
|
|
type CloneRepoOptions = {
|
|
directoryName?: string
|
|
repoUrl?: string
|
|
abortController?: AbortController
|
|
verbose?: boolean
|
|
}
|
|
|
|
const DEFAULT_REPO = "https://github.com/medusajs/medusa-starter-default"
|
|
const V2_BRANCH = "feat/v2"
|
|
|
|
export default async function cloneRepo({
|
|
directoryName = "",
|
|
repoUrl,
|
|
abortController,
|
|
verbose = false,
|
|
}: CloneRepoOptions) {
|
|
await execute(
|
|
[
|
|
`git clone ${repoUrl || DEFAULT_REPO} -b ${V2_BRANCH} ${directoryName}`,
|
|
{
|
|
signal: abortController?.signal,
|
|
},
|
|
],
|
|
{ verbose }
|
|
)
|
|
}
|
|
|
|
export async function runCloneRepo({
|
|
projectName,
|
|
repoUrl,
|
|
abortController,
|
|
spinner,
|
|
verbose = false,
|
|
}: {
|
|
projectName: string
|
|
repoUrl: string
|
|
abortController: AbortController
|
|
spinner: Ora
|
|
verbose?: boolean
|
|
}) {
|
|
try {
|
|
await cloneRepo({
|
|
directoryName: projectName,
|
|
repoUrl,
|
|
abortController,
|
|
verbose,
|
|
})
|
|
|
|
deleteGitDirectory(projectName)
|
|
} catch (e) {
|
|
if (isAbortError(e)) {
|
|
process.exit()
|
|
}
|
|
|
|
spinner.stop()
|
|
logMessage({
|
|
message: `An error occurred while setting up your project: ${e}`,
|
|
type: "error",
|
|
})
|
|
}
|
|
}
|
|
|
|
function deleteGitDirectory(projectDirectory: string) {
|
|
fs.rmSync(path.join(projectDirectory, ".git"), {
|
|
recursive: true,
|
|
force: true,
|
|
})
|
|
|
|
fs.rmSync(path.join(projectDirectory, ".github"), {
|
|
recursive: true,
|
|
force: true,
|
|
})
|
|
}
|