mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-11 23:50:05 +01:00
Accept paths instead of URLs
This commit is contained in:
parent
3e85357934
commit
9110b1417d
4 changed files with 11 additions and 13 deletions
|
|
@ -18,7 +18,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
|
@ -28,7 +27,7 @@ import (
|
|||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
func installCommand(dir, jsonnetHome string, urls ...*url.URL) int {
|
||||
func installCommand(dir, jsonnetHome string, paths ...string) int {
|
||||
if dir == "" {
|
||||
dir = "."
|
||||
}
|
||||
|
|
@ -45,8 +44,8 @@ func installCommand(dir, jsonnetHome string, urls ...*url.URL) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
if len(urls) > 0 {
|
||||
for _, url := range urls {
|
||||
if len(paths) > 0 {
|
||||
for _, path := range paths {
|
||||
// install package specified in command
|
||||
// $ jsonnetpkg install ksonnet git@github.com:ksonnet/ksonnet-lib
|
||||
// $ jsonnetpkg install grafonnet git@github.com:grafana/grafonnet-lib grafonnet
|
||||
|
|
@ -54,10 +53,9 @@ func installCommand(dir, jsonnetHome string, urls ...*url.URL) int {
|
|||
//
|
||||
// github.com/(slug)/(dir)
|
||||
|
||||
urlString := url.String()
|
||||
newDep := parseDepedency(urlString)
|
||||
newDep := parseDepedency(path)
|
||||
if newDep == nil {
|
||||
kingpin.Errorf("ignoring unrecognized url: %s", url)
|
||||
kingpin.Errorf("ignoring unrecognized path: %s", path)
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package main
|
|||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
|
@ -30,7 +29,7 @@ import (
|
|||
func TestInstallCommand(t *testing.T) {
|
||||
testcases := []struct {
|
||||
Name string
|
||||
URLs []*url.URL
|
||||
URLs []string
|
||||
ExpectedCode int
|
||||
ExpectedJsonnetFile []byte
|
||||
ExpectedJsonnetLockFile []byte
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ func Main() int {
|
|||
initCmd := a.Command(initActionName, "Initialize a new empty jsonnetfile")
|
||||
|
||||
installCmd := a.Command(installActionName, "Install all dependencies or install specific ones")
|
||||
installCmdURLs := installCmd.Arg("packages", "URLs to package to install").URLList()
|
||||
installCmdPaths := installCmd.Arg("paths", "paths to packages to install, URLs or file paths").Strings()
|
||||
|
||||
updateCmd := a.Command(updateActionName, "Update all dependencies.")
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ func Main() int {
|
|||
case initCmd.FullCommand():
|
||||
return initCommand(workdir)
|
||||
case installCmd.FullCommand():
|
||||
return installCommand(workdir, cfg.JsonnetHome, *installCmdURLs...)
|
||||
return installCommand(workdir, cfg.JsonnetHome, *installCmdPaths...)
|
||||
case updateCmd.FullCommand():
|
||||
return updateCommand(cfg.JsonnetHome)
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue