mirror of
https://github.com/ryan-haskell/elm-spa.git
synced 2024-11-22 03:12:01 +03:00
update cli commands
This commit is contained in:
parent
19df55bd85
commit
e375596d30
@ -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
|
||||
}
|
@ -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)
|
||||
|
@ -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 })
|
||||
}
|
@ -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!
|
||||
`
|
@ -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 })
|
||||
|
Loading…
Reference in New Issue
Block a user