feat(medusa-cli): added v2 flag (#7211)
This commit is contained in:
5
.changeset/olive-tigers-mate.md
Normal file
5
.changeset/olive-tigers-mate.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa-cli": patch
|
||||
---
|
||||
|
||||
feat(medusa-cli): added v2 flag
|
||||
@@ -169,7 +169,7 @@ const copy = async (starterPath, rootPath) => {
|
||||
}
|
||||
|
||||
// Clones starter from URI.
|
||||
const clone = async (hostInfo, rootPath) => {
|
||||
const clone = async (hostInfo, rootPath, v2 = false) => {
|
||||
let url
|
||||
// Let people use private repos accessed over SSH.
|
||||
if (hostInfo.getDefaultRepresentation() === `sshurl`) {
|
||||
@@ -179,7 +179,8 @@ const clone = async (hostInfo, rootPath) => {
|
||||
url = hostInfo.https({ noCommittish: true, noGitPlus: true })
|
||||
}
|
||||
|
||||
const branch = hostInfo.committish ? [`-b`, hostInfo.committish] : []
|
||||
const branch = v2 ? [`-b`, "feat/v2"] :
|
||||
hostInfo.committish ? [`-b`, hostInfo.committish] : []
|
||||
|
||||
const createAct = reporter.activity(`Creating new project from git: ${url}`)
|
||||
|
||||
@@ -228,7 +229,7 @@ const getMedusaConfig = (rootPath) => {
|
||||
return {}
|
||||
}
|
||||
|
||||
const getPaths = async (starterPath, rootPath) => {
|
||||
const getPaths = async (starterPath, rootPath, v2 = false) => {
|
||||
let selectedOtherStarter = false
|
||||
|
||||
// if no args are passed, prompt user for path and starter
|
||||
@@ -240,7 +241,7 @@ const getPaths = async (starterPath, rootPath) => {
|
||||
message: `What is your project called?`,
|
||||
initial: `my-medusa-store`,
|
||||
},
|
||||
{
|
||||
!v2 && {
|
||||
type: `select`,
|
||||
name: `starter`,
|
||||
message: `What starter would you like to use?`,
|
||||
@@ -253,14 +254,14 @@ const getPaths = async (starterPath, rootPath) => {
|
||||
])
|
||||
|
||||
// exit gracefully if responses aren't provided
|
||||
if (!response.starter || !response.path.trim()) {
|
||||
if ((!v2 && !response.starter) || !response.path.trim()) {
|
||||
throw new Error(
|
||||
`Please mention both starter package and project name along with path(if its not in the root)`
|
||||
)
|
||||
}
|
||||
|
||||
selectedOtherStarter = response.starter === `different`
|
||||
starterPath = `medusajs/${response.starter}`
|
||||
starterPath = `medusajs/${v2 ? "medusa-starter-default" : response.starter}`
|
||||
rootPath = response.path
|
||||
}
|
||||
|
||||
@@ -523,6 +524,7 @@ export const newStarter = async (args) => {
|
||||
dbPass,
|
||||
dbPort,
|
||||
dbHost,
|
||||
v2
|
||||
} = args
|
||||
|
||||
const dbCredentials = removeUndefined({
|
||||
@@ -535,7 +537,8 @@ export const newStarter = async (args) => {
|
||||
|
||||
const { starterPath, rootPath, selectedOtherStarter } = await getPaths(
|
||||
starter,
|
||||
root
|
||||
root,
|
||||
v2
|
||||
)
|
||||
|
||||
const urlObject = url.parse(rootPath)
|
||||
@@ -597,7 +600,7 @@ medusa new ${rootPath} [url-to-starter]
|
||||
|
||||
const hostedInfo = hostedGitInfo.fromUrl(starterPath)
|
||||
if (hostedInfo) {
|
||||
await clone(hostedInfo, rootPath)
|
||||
await clone(hostedInfo, rootPath, v2)
|
||||
} else {
|
||||
await copy(starterPath, rootPath)
|
||||
}
|
||||
|
||||
@@ -113,6 +113,11 @@ function buildLocalCommands(cli, isLocalProject) {
|
||||
.option(`db-host`, {
|
||||
type: `string`,
|
||||
describe: `The database host to use for database setup and migrations.`,
|
||||
})
|
||||
.option(`v2`, {
|
||||
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
|
||||
}),
|
||||
desc: `Create a new Medusa project.`,
|
||||
handler: handlerP(newStarter),
|
||||
|
||||
Reference in New Issue
Block a user