-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): experimental go frontend CLI
- Loading branch information
Showing
22 changed files
with
1,045 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/mitchellh/go-homedir" | ||
version = "1.0.0" | ||
|
||
[[constraint]] | ||
name = "gopkg.in/yaml.v2" | ||
version = "2.2.1" | ||
|
||
# [[constraint]] | ||
# branch = "master" | ||
# name = "k8s.io/api" | ||
|
||
# [[constraint]] | ||
# name = "k8s.io/client-go" | ||
# branch = "release-8.0" | ||
|
||
# [[constraint]] | ||
# name = "k8s.io/apimachinery" | ||
# revision = "488889b0007f63ffee90b66a34a2deca9ec58774" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"path" | ||
"strings" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// Config type must be public for the yaml parser (for some reason). We only need the project key and the name. | ||
type Config struct { | ||
Project struct { | ||
Name *string | ||
} | ||
} | ||
|
||
func findProject(cwd string) (string, string) { | ||
projectDir := cwd | ||
|
||
for { | ||
configPath := path.Join(projectDir, "garden.yml") | ||
|
||
if _, err := os.Stat(configPath); !os.IsNotExist(err) { | ||
configYaml, err := ioutil.ReadFile(configPath) | ||
check(err) | ||
|
||
config := Config{} | ||
|
||
err = yaml.Unmarshal(configYaml, &config) | ||
if err != nil { | ||
log.Fatalf("Unable to parse %s as a valid garden configuration file", configPath) | ||
} | ||
|
||
if config.Project.Name != nil { | ||
// found project config | ||
return projectDir, *config.Project.Name | ||
} | ||
} | ||
|
||
// move up one level | ||
projectDir = path.Dir(projectDir) | ||
|
||
if projectDir == "/" { | ||
log.Fatalf("Not a project directory (or any of the parent directories): %s", cwd) | ||
} | ||
} | ||
} | ||
|
||
// Get or set the ID of this project (stored in PROJECT_ROOT/.garden/id). | ||
// TODO: might wanna use a lockfile for concurrency here | ||
func getProjectID(projectDir string) string { | ||
gardenDir := path.Join(projectDir, ".garden") | ||
ensureDir(gardenDir) | ||
|
||
idPath := path.Join(gardenDir, "id") | ||
|
||
var projectID string | ||
|
||
if _, err := os.Stat(idPath); !os.IsNotExist(err) { | ||
idData, err := ioutil.ReadFile(idPath) | ||
check(err) | ||
projectID = strings.TrimSpace(string(idData)) | ||
} else { | ||
projectID = randSeq(8) | ||
} | ||
|
||
return projectID | ||
} | ||
|
||
func getGardenHomeDir() string { | ||
// TODO: allow override via env var | ||
homeDir := getHomeDir() | ||
gardenHome := path.Join(homeDir, ".garden") | ||
|
||
ensureDir(gardenHome) | ||
|
||
return gardenHome | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2018 Garden Technologies, Inc. <info@garden.io> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { join } from "path" | ||
import { spawn } from "../support/support-util" | ||
|
||
const sources = join(__dirname, "**", "*.go") | ||
|
||
module.exports = (gulp) => { | ||
gulp.task("build", () => spawn("go", ["build", "-o", join("build", "garden")], __dirname)) | ||
gulp.task("watch", () => gulp.watch([sources], gulp.parallel("build"))) | ||
} | ||
|
||
if (process.cwd() === __dirname) { | ||
module.exports(require("gulp")) | ||
} |
Oops, something went wrong.