change: add LICENSE & basic compile instructions

This commit is contained in:
Jordan Knott 2020-07-16 22:58:46 -05:00
parent 50ca9f7216
commit 158f574b2a
6 changed files with 87 additions and 10 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
node_modules
dist/
uploads/*
!uploads/.keep
internal/frontend/frontend_generated.go
citadel
conf/app.toml

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -21,6 +21,32 @@ Currently you can do the following to tasks:
## Installation
### From Source
You'll need [Golang](https://golang.org/dl/) installed on your machine.
Next, clone the repository:
``` bash
git clone https://github.com/JordanKnott/project-citadel && cd project-citadel
```
Next we need to build the binary. This project uses [Mage](https://magefile.org/) for its build tool.
``` bash
go run cmd/mage/main.go build
```
This will:
- Install all yarn packages for the frontend
- Build the React frontend
- Embed the React frontend in the binary
- Compile the final exectuable binary
The newly created `citadel` binary can be found in the __dist__ folder.
It contains everything neccessary to run except the config file. An example config file can be found in `conf/app.example.toml`
## Roadmap
@ -43,4 +69,5 @@ This is a list of features that will eventually be added to Citadel in no partic
## License
[MIT License](LICENSE)

10
cmd/mage/main.go Normal file
View File

@ -0,0 +1,10 @@
// +build ignore
package main
import (
"github.com/magefile/mage/mage"
"os"
)
func main() { os.Exit(mage.Main()) }

View File

@ -12,7 +12,7 @@ upload_dir_path = 'uploads'
[database]
host = '0.0.0.0'
name = 'citadel_test'
name = 'citadel'
user = 'postgres'
password = 'test'

View File

@ -4,19 +4,33 @@ package main
import (
"fmt"
"github.com/magefile/mage/sh"
"github.com/shurcooL/vfsgen"
"io/ioutil"
"net/http"
"os"
"strings"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"github.com/shurcooL/vfsgen"
)
var Aliases = map[string]interface{}{
"g": Generate,
"s": Backend.Schema,
}
func Vfs() error {
type Frontend mg.Namespace
func (Frontend) Install() error {
return sh.Run("yarn", "install", "--cwd", "frontend")
}
func (Frontend) Build() error {
return sh.Run("yarn", "build", "--cwd", "frontend")
}
type Backend mg.Namespace
func (Backend) GenFrontend() error {
var fs http.FileSystem = http.Dir("frontend/build")
err := vfsgen.Generate(fs, vfsgen.Options{
Filename: "internal/frontend/frontend_generated.go",
@ -29,9 +43,11 @@ func Vfs() error {
return nil
}
// Runs go mod download and then installs the binary.
func Generate() error {
func (Backend) Build() error {
return sh.Run("go", "build", "-o", "dist/citadel", "cmd/citadel/main.go")
}
func (Backend) Schema() error {
files, err := ioutil.ReadDir("internal/graph/schema/")
if err != nil {
panic(err)
@ -50,11 +66,13 @@ func Generate() error {
}
fmt.Fprintln(&schema, string(content))
}
// return sh.Run("go", "install", "./...")
// fmt.Println(schema.String())
err = ioutil.WriteFile("internal/graph/schema.graphqls", []byte(schema.String()), os.FileMode(0755))
if err != nil {
panic(err)
}
return sh.Run("gqlgen")
}
func Build() {
mg.SerialDeps(Frontend.Install, Frontend.Build, Backend.GenFrontend, Backend.Build)
}