feat(medusa-cli): added branch option (#7384)

This commit is contained in:
Shahed Nasser
2024-05-21 21:17:01 +02:00
committed by GitHub
parent c4fde7ea5c
commit 1f43290cec
3 changed files with 14 additions and 6 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ jobs:
- name: Create Medusa project - name: Create Medusa project
run: | run: |
medusa new cli-test --skip-db --v2 medusa new cli-test --skip-db --v2 --branch feat/v2-ci
working-directory: .. working-directory: ..
- name: run medusa dev - name: run medusa dev
+9 -5
View File
@@ -169,7 +169,7 @@ const copy = async (starterPath, rootPath) => {
} }
// Clones starter from URI. // Clones starter from URI.
const clone = async (hostInfo, rootPath, v2 = false) => { const clone = async (hostInfo, rootPath, v2 = false, inputBranch) => {
let url let url
// Let people use private repos accessed over SSH. // Let people use private repos accessed over SSH.
if (hostInfo.getDefaultRepresentation() === `sshurl`) { if (hostInfo.getDefaultRepresentation() === `sshurl`) {
@@ -179,8 +179,11 @@ const clone = async (hostInfo, rootPath, v2 = false) => {
url = hostInfo.https({ noCommittish: true, noGitPlus: true }) url = hostInfo.https({ noCommittish: true, noGitPlus: true })
} }
const branch = v2 ? [`-b`, "feat/v2"] : let branch = (inputBranch || hostInfo.committish ? [`-b`, inputBranch || hostInfo.committish] : [])
hostInfo.committish ? [`-b`, hostInfo.committish] : []
if (v2) {
branch = [`-b`, inputBranch || "feat/v2"]
}
const createAct = reporter.activity(`Creating new project from git: ${url}`) const createAct = reporter.activity(`Creating new project from git: ${url}`)
@@ -524,7 +527,8 @@ export const newStarter = async (args) => {
dbPass, dbPass,
dbPort, dbPort,
dbHost, dbHost,
v2 v2,
branch
} = args } = args
const dbCredentials = removeUndefined({ const dbCredentials = removeUndefined({
@@ -600,7 +604,7 @@ medusa new ${rootPath} [url-to-starter]
const hostedInfo = hostedGitInfo.fromUrl(starterPath) const hostedInfo = hostedGitInfo.fromUrl(starterPath)
if (hostedInfo) { if (hostedInfo) {
await clone(hostedInfo, rootPath, v2) await clone(hostedInfo, rootPath, v2, branch)
} else { } else {
await copy(starterPath, rootPath) await copy(starterPath, rootPath)
} }
@@ -118,6 +118,10 @@ function buildLocalCommands(cli, isLocalProject) {
type: `boolean`, 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.`, 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, default: false,
})
.option(`branch`, {
type: `string`,
describe: `The branch of the git repository to clone.`,
}), }),
desc: `Create a new Medusa project.`, desc: `Create a new Medusa project.`,
handler: handlerP(newStarter), handler: handlerP(newStarter),