add build; make serve work

This commit is contained in:
Chris Sexton 2019-10-18 08:46:20 -04:00
parent f010818c30
commit 0e5d056922
16 changed files with 38 additions and 66 deletions

2
.gitignore vendored
View File

@ -258,3 +258,5 @@ $RECYCLE.BIN/
.idea/inspectionProfiles/ .idea/inspectionProfiles/
.idea .idea
happy
frontend/dist

13
Makefile Normal file
View File

@ -0,0 +1,13 @@
build: *.go frontend
go build
frontend:
cd frontend && yarn build
frontend-watch:
cd frontend && yarn build --watch
run: build
./happy
.PHONY: run frontend frontend-watch

View File

@ -1,10 +0,0 @@
{
"name": "happy",
"version": "0.1.0",
"private": true,
"devDependencies": {
"@vue/cli-plugin-babel": "^3.9.0",
"@vue/cli-plugin-typescript": "^3.9.0",
"@vue/cli-service": "^3.9.0"
}
}

View File

@ -1,36 +0,0 @@
Arguments:
/usr/local/Cellar/node/12.8.0/bin/node /Users/cws/.yarn/bin/yarn.js
PATH:
/Users/cws/src/github.com/chrissexton/happy/pub/happy/node_modules/.bin:/Users/cws/src/github.com/chrissexton/happy/pub/node_modules/.bin:/Users/cws/src/github.com/chrissexton/happy/node_modules/.bin:/Users/cws/src/github.com/chrissexton/node_modules/.bin:/Users/cws/src/github.com/node_modules/.bin:/Users/cws/src/node_modules/.bin:/Users/cws/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/Cellar/node/12.8.0/bin:/Users/cws/.yarn/bin:/Users/cws/.config/yarn/global/node_modules/.bin:/usr/local/opt/icu4c/sbin:/usr/local/opt/icu4c/bin:/Users/cws/Library/Python/3.6/bin:/Users/cws/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/Library/TeX/texbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/opt/python/libexec/bin:/Users/cws/.rbenv/shims:/Users/cws/bin:/Users/cws/go/bin:/usr/local/games:/usr/local/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/qt4/bin:/Users/cws/src/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/bin:/Users/cws/.rvm/bin:/Library/TeX/texbin/:/Users/cws/.please:/Users/cws/.rvm/bin:/Users/cws/.fzf/bin:/Users/cws/go/bin
Yarn version:
1.15.2
Node version:
12.8.0
Platform:
darwin x64
Trace:
Error: getaddrinfo ENOTFOUND registry.yarnpkg.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
npm manifest:
{
"name": "happy",
"version": "0.1.0",
"private": true,
"devDependencies": {
"@vue/cli-plugin-babel": "^3.9.0",
"@vue/cli-plugin-typescript": "^3.9.0",
"@vue/cli-service": "^3.9.0"
}
}
yarn manifest:
No manifest
Lockfile:
No lockfile

1
dist/index.html vendored
View File

@ -1 +0,0 @@
hello

View File

@ -1 +0,0 @@
h3[data-v-b9167eee]{margin:40px 0 0}ul[data-v-b9167eee]{list-style-type:none;padding:0}li[data-v-b9167eee]{display:inline-block;margin:0 10px}a[data-v-b9167eee]{color:#42b983}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -1 +0,0 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>frontend</title><link href=/css/app.e2713bb0.css rel=preload as=style><link href=/js/app.280bb8aa.js rel=preload as=script><link href=/js/chunk-vendors.14900559.js rel=preload as=script><link href=/css/app.e2713bb0.css rel=stylesheet></head><body><noscript><strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.14900559.js></script><script src=/js/app.280bb8aa.js></script></body></html>

View File

@ -1,2 +0,0 @@
(function(e){function t(t){for(var n,l,u=t[0],s=t[1],i=t[2],p=0,v=[];p<u.length;p++)l=u[p],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&v.push(o[l][0]),o[l]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);c&&c(t);while(v.length)v.shift()();return a.push.apply(a,i||[]),r()}function r(){for(var e,t=0;t<a.length;t++){for(var r=a[t],n=!0,u=1;u<r.length;u++){var s=r[u];0!==o[s]&&(n=!1)}n&&(a.splice(t--,1),e=l(l.s=r[0]))}return e}var n={},o={app:0},a=[];function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="/";var u=window["webpackJsonp"]=window["webpackJsonp"]||[],s=u.push.bind(u);u.push=t,u=u.slice();for(var i=0;i<u.length;i++)t(u[i]);var c=s;a.push([0,"chunk-vendors"]),r()})({0:function(e,t,r){e.exports=r("56d7")},"034f":function(e,t,r){"use strict";var n=r("85ec"),o=r.n(n);o.a},4805:function(e,t,r){"use strict";var n=r("8ce0"),o=r.n(n);o.a},"56d7":function(e,t,r){"use strict";r.r(t);r("e260"),r("e6cf"),r("cca6"),r("a79d");var n=r("2b0e"),o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("img",{attrs:{alt:"Vue logo",src:r("cf05")}}),n("HelloWorld",{attrs:{msg:"Welcome to Your Vue.js App"}})],1)},a=[],l=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"hello"},[r("h1",[e._v(e._s(e.msg))]),e._m(0),r("h3",[e._v("Installed CLI Plugins")]),e._m(1),r("h3",[e._v("Essential Links")]),e._m(2),r("h3",[e._v("Ecosystem")]),e._m(3)])},u=[function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("p",[e._v(" For a guide and recipes on how to configure / customize this project,"),r("br"),e._v(" check out the "),r("a",{attrs:{href:"https://cli.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-cli documentation")]),e._v(". ")])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel",target:"_blank",rel:"noopener"}},[e._v("babel")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint",target:"_blank",rel:"noopener"}},[e._v("eslint")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Core Docs")])]),r("li",[r("a",{attrs:{href:"https://forum.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Forum")])]),r("li",[r("a",{attrs:{href:"https://chat.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Community Chat")])]),r("li",[r("a",{attrs:{href:"https://twitter.com/vuejs",target:"_blank",rel:"noopener"}},[e._v("Twitter")])]),r("li",[r("a",{attrs:{href:"https://news.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("News")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://router.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-router")])]),r("li",[r("a",{attrs:{href:"https://vuex.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vuex")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-devtools#vue-devtools",target:"_blank",rel:"noopener"}},[e._v("vue-devtools")])]),r("li",[r("a",{attrs:{href:"https://vue-loader.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-loader")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/awesome-vue",target:"_blank",rel:"noopener"}},[e._v("awesome-vue")])])])}],s={name:"HelloWorld",props:{msg:String}},i=s,c=(r("4805"),r("2877")),p=Object(c["a"])(i,l,u,!1,null,"b9167eee",null),v=p.exports,f={name:"app",components:{HelloWorld:v}},h=f,_=(r("034f"),Object(c["a"])(h,o,a,!1,null,null,null)),g=_.exports;n["a"].config.productionTip=!1,new n["a"]({render:function(e){return e(g)}}).$mount("#app")},"85ec":function(e,t,r){},"8ce0":function(e,t,r){},cf05:function(e,t,r){e.exports=r.p+"img/logo.82b9c7a5.png"}});
//# sourceMappingURL=app.280bb8aa.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>frontend</title> <title>Happy</title>
</head> </head>
<body> <body>
<noscript> <noscript>

View File

@ -32,7 +32,7 @@
<script> <script>
export default { export default {
name: 'HelloWorld', name: 'Happy',
props: { props: {
msg: String msg: String
} }

View File

@ -1,9 +1,11 @@
package main package main
import ( import (
"flag"
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
"path"
"time" "time"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -12,7 +14,12 @@ import (
"github.com/stretchr/graceful" "github.com/stretchr/graceful"
) )
var (
distPath = flag.String("dist", "frontend/dist", "path to dist files")
)
func main() { func main() {
flag.Parse()
log.Logger = log.Logger.Output(zerolog.ConsoleWriter{Out: os.Stderr}) log.Logger = log.Logger.Output(zerolog.ConsoleWriter{Out: os.Stderr})
zerolog.SetGlobalLevel(zerolog.DebugLevel) zerolog.SetGlobalLevel(zerolog.DebugLevel)
s := server{"0.0.0.0:8080", "pub"} s := server{"0.0.0.0:8080", "pub"}
@ -39,16 +46,27 @@ func (s *server) handleMood(w http.ResponseWriter, r *http.Request) {
func (s *server) indexHandler(entryPoint string) func(w http.ResponseWriter, r *http.Request) { func (s *server) indexHandler(entryPoint string) func(w http.ResponseWriter, r *http.Request) {
fn := func(w http.ResponseWriter, r *http.Request) { fn := func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, entryPoint) p := path.Join(*distPath, path.Clean(r.URL.Path))
f, err := os.Stat(p)
if !os.IsNotExist(err) && !f.IsDir() {
http.ServeFile(w, r, p)
return
}
p = path.Join(p, "index.html")
if f, err := os.Stat(p); !os.IsNotExist(err) && !f.IsDir() {
http.ServeFile(w, r, p)
return
}
http.ServeFile(w, r, path.Join(*distPath, entryPoint))
} }
return http.HandlerFunc(fn) return fn
} }
func (s *server) routeSetup() *mux.Router { func (s *server) routeSetup() *mux.Router {
r := mux.NewRouter() r := mux.NewRouter()
api := r.PathPrefix("/v1/").Subrouter() api := r.PathPrefix("/v1/").Subrouter()
api.HandleFunc("/mood", s.handleMood).Methods("POST") api.HandleFunc("/mood", s.handleMood).Methods("POST")
r.PathPrefix("/").HandlerFunc(s.indexHandler("dist/index.html")) r.PathPrefix("/").HandlerFunc(s.indexHandler("/index.html"))
return r return r
} }