update cli commands

This commit is contained in:
Ryan Haskell-Glatz 2021-04-24 14:00:31 -05:00
parent 19df55bd85
commit e375596d30
5 changed files with 15 additions and 8 deletions

View File

@ -8,8 +8,9 @@ import Help from './cli/help'
export default {
new: New.run,
add: Add.run,
build: Build.run,
watch: Watch.run,
build: Build.build,
server: Server.run,
gen: Build.gen,
watch: Watch.run,
help: Help.run
}

View File

@ -17,7 +17,7 @@ const pink = (str: string) => '\x1b[35m' + str + '\x1b[0m'
export default {
run: async () => {
let [ url, template ] = process.argv.slice(3)
if (!url) {
if (!url || url === '--help') {
return Promise.reject(example)
}
const page = urlArgumentToPages(url)

View File

@ -12,13 +12,13 @@ import { bold, underline, colors, reset, check, dim, dot } from "../terminal"
import { isStandardPage, isStaticPage, isStaticView, options, PageKind } from "../templates/utils"
import { createMissingAddTemplates } from "./_common"
export const build = (env : Environment) => () =>
export const build = ({ env, runElmMake } : { env : Environment, runElmMake: boolean }) => () =>
Promise.all([
createMissingDefaultFiles(),
createMissingAddTemplates()
])
.then(createGeneratedFiles)
.then(compileMainElm(env))
.then(runElmMake ? compileMainElm(env): identity)
const createMissingDefaultFiles = async () => {
type Action
@ -60,6 +60,8 @@ const createMissingDefaultFiles = async () => {
return Promise.all(actions.map(performDefaultFileAction))
}
const identity = <T>(value : T) => value
type FilepathSegments = {
kind: PageKind,
entry: PageEntry
@ -245,5 +247,6 @@ const compileMainElm = (env : Environment) => async () => {
}
export default {
run: build('production')
build: build({ env: 'production', runElmMake: true }),
gen: build({ env: 'production', runElmMake: false })
}

View File

@ -16,8 +16,11 @@ Commands:
${bold(`elm-spa ${cyan(`new`)}`)} . . . . . . . . . create a new project
${bold(`elm-spa ${cyan(`add`)}`)} <url> . . . . . . . . create a new page
${bold(`elm-spa ${cyan(`build`)}`)} . . . . . . one-time production build
${bold(`elm-spa ${cyan(`watch`)}`)} . . . . . . . runs build as you code
${bold(`elm-spa ${cyan(`server`)}`)} . . . . . . start a live dev server
Other commands:
${bold(`elm-spa ${cyan(`gen`)}`)} . . . . generates code without elm make
${bold(`elm-spa ${cyan(`watch`)}`)} . . . . runs elm-spa gen as you code
Visit ${green(`https://next.elm-spa.dev`)} for more!
`

View File

@ -3,7 +3,7 @@ import chokidar from 'chokidar'
import config from '../config'
export const watch = () => {
const runBuild = build('development')
const runBuild = build({ env: 'development', runElmMake: false })
chokidar
.watch(config.folders.src, { ignoreInitial: true })