feat(medusa-cli): added branch option (#7384)
This commit is contained in:
2
.github/workflows/test-cli-with-database.yml
vendored
2
.github/workflows/test-cli-with-database.yml
vendored
@@ -52,7 +52,7 @@ jobs:
|
||||
|
||||
- name: Create Medusa project
|
||||
run: |
|
||||
medusa new cli-test --skip-db --v2
|
||||
medusa new cli-test --skip-db --v2 --branch feat/v2-ci
|
||||
working-directory: ..
|
||||
|
||||
- name: run medusa dev
|
||||
|
||||
@@ -169,7 +169,7 @@ const copy = async (starterPath, rootPath) => {
|
||||
}
|
||||
|
||||
// Clones starter from URI.
|
||||
const clone = async (hostInfo, rootPath, v2 = false) => {
|
||||
const clone = async (hostInfo, rootPath, v2 = false, inputBranch) => {
|
||||
let url
|
||||
// Let people use private repos accessed over SSH.
|
||||
if (hostInfo.getDefaultRepresentation() === `sshurl`) {
|
||||
@@ -179,8 +179,11 @@ const clone = async (hostInfo, rootPath, v2 = false) => {
|
||||
url = hostInfo.https({ noCommittish: true, noGitPlus: true })
|
||||
}
|
||||
|
||||
const branch = v2 ? [`-b`, "feat/v2"] :
|
||||
hostInfo.committish ? [`-b`, hostInfo.committish] : []
|
||||
let branch = (inputBranch || hostInfo.committish ? [`-b`, inputBranch || hostInfo.committish] : [])
|
||||
|
||||
if (v2) {
|
||||
branch = [`-b`, inputBranch || "feat/v2"]
|
||||
}
|
||||
|
||||
const createAct = reporter.activity(`Creating new project from git: ${url}`)
|
||||
|
||||
@@ -524,7 +527,8 @@ export const newStarter = async (args) => {
|
||||
dbPass,
|
||||
dbPort,
|
||||
dbHost,
|
||||
v2
|
||||
v2,
|
||||
branch
|
||||
} = args
|
||||
|
||||
const dbCredentials = removeUndefined({
|
||||
@@ -600,7 +604,7 @@ medusa new ${rootPath} [url-to-starter]
|
||||
|
||||
const hostedInfo = hostedGitInfo.fromUrl(starterPath)
|
||||
if (hostedInfo) {
|
||||
await clone(hostedInfo, rootPath, v2)
|
||||
await clone(hostedInfo, rootPath, v2, branch)
|
||||
} else {
|
||||
await copy(starterPath, rootPath)
|
||||
}
|
||||
|
||||
@@ -118,6 +118,10 @@ function buildLocalCommands(cli, isLocalProject) {
|
||||
type: `boolean`,
|
||||
describe: `Install Medusa with the V2 feature flag enabled. WARNING: Medusa V2 is still in development and shouldn't be used in production.`,
|
||||
default: false,
|
||||
})
|
||||
.option(`branch`, {
|
||||
type: `string`,
|
||||
describe: `The branch of the git repository to clone.`,
|
||||
}),
|
||||
desc: `Create a new Medusa project.`,
|
||||
handler: handlerP(newStarter),
|
||||
|
||||
Reference in New Issue
Block a user