feat: CLI + local linking (#313)
* fix: allow local cmd without exiting process * fix: improves cli experience * fix: allow running link with --develop * test: adds snapshot testing of error logs * chore: cleanup * feat(medusa-cli): new command (#320) * adds: new command * fix: creates command for easy project setup * chore: deps * chore: deps * fix: loggin * fix: logging * fix: adds cli as dependency in core * fix: consolidates CLI in medusa * fix: use project deps medusa bin * fix: use project deps medusa bin * fix: use cli path * fix: new command setup db + env vars * fix: new command with db seed * fix: cleanup
This commit is contained in:
@@ -6,6 +6,7 @@ const existsSync = require(`fs-exists-cached`).sync
|
||||
const { getLocalMedusaVersion } = require(`./util/version`)
|
||||
const { didYouMean } = require(`./did-you-mean`)
|
||||
|
||||
const { newStarter } = require("./commands/new")
|
||||
const { whoami } = require("./commands/whoami")
|
||||
const { login } = require("./commands/login")
|
||||
const { link } = require("./commands/link")
|
||||
@@ -66,6 +67,57 @@ function buildLocalCommands(cli, isLocalProject) {
|
||||
}
|
||||
|
||||
cli
|
||||
.command({
|
||||
command: `new [root] [starter]`,
|
||||
builder: _ =>
|
||||
_.option(`seed`, {
|
||||
type: `boolean`,
|
||||
describe: `If flag is set the command will attempt to seed the database after setup.`,
|
||||
default: false,
|
||||
})
|
||||
.option(`skip-db`, {
|
||||
type: `boolean`,
|
||||
describe: `If flag is set the command will not attempt to complete database setup`,
|
||||
default: false,
|
||||
})
|
||||
.option(`skip-migrations`, {
|
||||
type: `boolean`,
|
||||
describe: `If flag is set the command will not attempt to complete database migration`,
|
||||
default: false,
|
||||
})
|
||||
.option(`skip-env`, {
|
||||
type: `boolean`,
|
||||
describe: `If flag is set the command will not attempt to populate .env`,
|
||||
default: false,
|
||||
})
|
||||
.option(`db-user`, {
|
||||
type: `string`,
|
||||
describe: `The database user to use for database setup and migrations.`,
|
||||
default: `postgres`,
|
||||
})
|
||||
.option(`db-database`, {
|
||||
type: `string`,
|
||||
describe: `The database use for database setup and migrations.`,
|
||||
default: `postgres`,
|
||||
})
|
||||
.option(`db-pass`, {
|
||||
type: `string`,
|
||||
describe: `The database password to use for database setup and migrations.`,
|
||||
default: ``,
|
||||
})
|
||||
.option(`db-port`, {
|
||||
type: `number`,
|
||||
describe: `The database port to use for database setup and migrations.`,
|
||||
default: 5432,
|
||||
})
|
||||
.option(`db-host`, {
|
||||
type: `string`,
|
||||
describe: `The database host to use for database setup and migrations.`,
|
||||
default: `localhost`,
|
||||
}),
|
||||
desc: `Create a new Medusa project.`,
|
||||
handler: handlerP(newStarter),
|
||||
})
|
||||
.command({
|
||||
command: `seed`,
|
||||
desc: `Migrates and populates the database with the provided file.`,
|
||||
@@ -112,11 +164,15 @@ function buildLocalCommands(cli, isLocalProject) {
|
||||
command: `link`,
|
||||
desc: `Creates your Medusa Cloud user in your local database for local testing.`,
|
||||
builder: _ =>
|
||||
_.option(`skip-local-user`, {
|
||||
alias: `skipLocalUser`,
|
||||
_.option(`su`, {
|
||||
alias: `skip-local-user`,
|
||||
type: `boolean`,
|
||||
default: false,
|
||||
describe: `If set a user will not be created in the database.`,
|
||||
}).option(`develop`, {
|
||||
type: `boolean`,
|
||||
default: false,
|
||||
describe: `If set medusa develop will be run after successful linking.`,
|
||||
}),
|
||||
handler: handlerP(argv => {
|
||||
if (!isLocalProject) {
|
||||
@@ -198,11 +254,17 @@ function buildLocalCommands(cli, isLocalProject) {
|
||||
alias: `email`,
|
||||
type: `string`,
|
||||
describe: `User's email.`,
|
||||
}).option(`p`, {
|
||||
alias: `password`,
|
||||
type: `string`,
|
||||
describe: `User's password.`,
|
||||
}),
|
||||
})
|
||||
.option(`p`, {
|
||||
alias: `password`,
|
||||
type: `string`,
|
||||
describe: `User's password.`,
|
||||
})
|
||||
.option(`i`, {
|
||||
alias: `id`,
|
||||
type: `string`,
|
||||
describe: `User's id.`,
|
||||
}),
|
||||
handler: handlerP(
|
||||
getCommandHandler(`user`, (args, cmd) => {
|
||||
cmd(args)
|
||||
|
||||
Reference in New Issue
Block a user