Skip to content

Commit

Permalink
Merge pull request #7 from elm-land/feature/build-command
Browse files Browse the repository at this point in the history
✨ Feature – elm-land build
  • Loading branch information
ryan-haskell committed Jun 9, 2022
2 parents 68cdb46 + 36673d1 commit 4ca4890
Show file tree
Hide file tree
Showing 18 changed files with 622 additions and 56 deletions.
195 changes: 193 additions & 2 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cli/package.json
@@ -1,6 +1,6 @@
{
"name": "elm-land",
"version": "0.14.1",
"version": "0.15.0",
"description": "Reliable web apps for everyone",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -39,6 +39,7 @@
"elm": "0.19.1-5",
"elm-esm": "1.1.4",
"node-elm-compiler": "5.0.6",
"terser": "5.14.0",
"vite": "2.9.8"
}
}
7 changes: 6 additions & 1 deletion cli/src/cli.js
@@ -1,6 +1,7 @@
const { Init } = require('./commands/init')
const { Add } = require('./commands/add')
const { Server } = require('./commands/server')
const { Build } = require('./commands/build')
const { Utils } = require('./commands/_utils')

let { version } = require('../package.json')
Expand All @@ -10,8 +11,9 @@ let subcommandList = [
'Here are the commands:',
'✨ elm-land init <folder-name> ...... create a new project',
'🚀 elm-land server ................ run a local dev server',
'📦 elm-land build .......... build your app for production',
'📄 elm-land add page <url> ................ add a new page',
'🪆 elm-land add layout <name> ........... add a new layout',
'🪆 elm-land add layout <name> ........... add a new layout',
''
]

Expand All @@ -30,6 +32,9 @@ let run = async (commandFromCli) => {
'server': (args) => {
return Server.run({})
},
'build': (args) => {
return Build.run({})
},
'add': (args) => {
return Add.run({ arguments: args })
},
Expand Down
34 changes: 34 additions & 0 deletions cli/src/commands/build.js
@@ -0,0 +1,34 @@
const { Files } = require("../files")
const { Utils } = require("./_utils")

let run = async () => {

let rawTextConfig = undefined
try {
rawTextConfig = await Files.readFromUserFolder('elm-land.json')
} catch (_) {
return Promise.reject(Utils.notInElmLandProject)
}

let config = {}
try {
config = JSON.parse(rawTextConfig)
} catch (err) {
// TODO: Warn user about invalid config JSON
}

return {
message: `🌈 Build was successful!`,
files: [],
effects: [
{ kind: 'generateHtml', config },
{ kind: 'build', config }
]
}
}

module.exports = {
Build: {
run
}
}
2 changes: 1 addition & 1 deletion cli/src/commands/server.js
Expand Up @@ -18,7 +18,7 @@ let run = async () => {
}

return {
message: '🌈 Server ready at http://localhost:1234',
message: ({ port }) => `🌈 Server ready at http://localhost:${port}`,
files: [],
effects: [
{ kind: 'generateHtml', config },
Expand Down

0 comments on commit 4ca4890

Please sign in to comment.