Skip to content

Commit

Permalink
fix: cli opts
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Feb 11, 2022
1 parent 122daaa commit 923d61c
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions @core/cli/program.ts
Expand Up @@ -195,7 +195,12 @@ const wrapCommand = async (settings: {
try {
await cb(opts)
} catch (error) {
logger.log({ level: "error", description: "cli error", data: error })
logger.log({
level: "error",
context: "wrapCommand",
description: "command execution error",
data: error,
})
done(1)
}
if (exit) done(0)
Expand All @@ -208,25 +213,24 @@ export const execute = (): void => {
commander
.version(pkg.version)
.description("Factor CLI")
.option("--SERVICE <SERVICE>", "Which module to run")
.option("--STAGE_ENV <string>", "how should the things be built")
.option("--NODE_ENV <string>", "environment (development/production)")
.option("--exit", "exit after successful setup")
.option("--inspector", "run the node inspector")
.option("-a, --port-app <number>", "primary service port")
.option("-p, --port <number>", "server specific port")
.option("-s, --serve", "serve static site after build")

.option(
"--NODE_ENV <NODE_ENV>",
"node environment (development or production)",
)

commander
.command("start")
.option("--SERVICE <SERVICE>", "Which module to run")
.action(async () => {
const opts = commander.opts() as CliOptions
await wrapCommand({ cb: (_) => runService(_), opts })
})
commander.command("start").action(async () => {
const opts = commander.opts() as CliOptions
await wrapCommand({ cb: (_) => runService(_), opts })
})

commander.command("server").action(async () => {
await wrapCommand({
Expand Down Expand Up @@ -313,11 +317,11 @@ export const execute = (): void => {

commander
.command("release")
.description("publish a new version")
.option("--patch", "patch release")
.option("--skip-tests", "patch release")
.action(() => {
const opts = commander.opts() as CliOptions
.option("-pa, --patch", "patch release")
.option("-st, --skip-tests", "skip tests")
.action((o) => {
const opts = { ...commander.opts(), ...o } as CliOptions

process.env.STAGE_ENV = "prod"
return wrapCommand({
cb: async (opts) => {
Expand All @@ -341,8 +345,8 @@ export const execute = (): void => {
.option("--NODE_ENV <NODE_ENV>", "development or production bundling")
.option("--commit <commit>", "git commit id")
.option("--outFile <outFile>", "name of output file")
.action(async () => {
const opts = commander.opts() as CliOptions
.action(async (o) => {
const opts = { ...commander.opts(), ...o } as CliOptions
const { bundleAll } = await import("@factor/build/bundle")
await wrapCommand({ cb: (_) => bundleAll(_), opts, exit: true })
})
Expand Down

0 comments on commit 923d61c

Please sign in to comment.