mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 08:00:05 +01:00
Use URI as name for packages location paths
This commit is contained in:
parent
6ed6c3f3ec
commit
d3bb1f4ea4
4 changed files with 16 additions and 16 deletions
|
|
@ -95,7 +95,7 @@ Commands:
|
||||||
init
|
init
|
||||||
Initialize a new empty jsonnetfile
|
Initialize a new empty jsonnetfile
|
||||||
|
|
||||||
install [<paths>...]
|
install [<uris>...]
|
||||||
Install all dependencies or install specific ones
|
Install all dependencies or install specific ones
|
||||||
|
|
||||||
update
|
update
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"gopkg.in/alecthomas/kingpin.v2"
|
"gopkg.in/alecthomas/kingpin.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func installCommand(dir, jsonnetHome string, paths ...string) int {
|
func installCommand(dir, jsonnetHome string, uris ...string) int {
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
dir = "."
|
dir = "."
|
||||||
}
|
}
|
||||||
|
|
@ -44,11 +44,11 @@ func installCommand(dir, jsonnetHome string, paths ...string) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(paths) > 0 {
|
if len(uris) > 0 {
|
||||||
for _, path := range paths {
|
for _, uri := range uris {
|
||||||
newDep := parseDependency(dir, path)
|
newDep := parseDependency(dir, uri)
|
||||||
if newDep == nil {
|
if newDep == nil {
|
||||||
kingpin.Errorf("ignoring unrecognized path: %s", path)
|
kingpin.Errorf("ignoring unrecognized uri: %s", uri)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import (
|
||||||
func TestInstallCommand(t *testing.T) {
|
func TestInstallCommand(t *testing.T) {
|
||||||
testcases := []struct {
|
testcases := []struct {
|
||||||
Name string
|
Name string
|
||||||
URLs []string
|
URIs []string
|
||||||
ExpectedCode int
|
ExpectedCode int
|
||||||
ExpectedJsonnetFile []byte
|
ExpectedJsonnetFile []byte
|
||||||
ExpectedJsonnetLockFile []byte
|
ExpectedJsonnetLockFile []byte
|
||||||
|
|
@ -41,13 +41,13 @@ func TestInstallCommand(t *testing.T) {
|
||||||
ExpectedJsonnetLockFile: []byte(`{"dependencies":null}`),
|
ExpectedJsonnetLockFile: []byte(`{"dependencies":null}`),
|
||||||
}, {
|
}, {
|
||||||
Name: "OneURL",
|
Name: "OneURL",
|
||||||
URLs: []string{"github.com/jsonnet-bundler/jsonnet-bundler@v0.1.0"},
|
URIs: []string{"github.com/jsonnet-bundler/jsonnet-bundler@v0.1.0"},
|
||||||
ExpectedCode: 0,
|
ExpectedCode: 0,
|
||||||
ExpectedJsonnetFile: []byte(`{"dependencies": [{"name": "jsonnet-bundler", "source": {"git": {"remote": "https://github.com/jsonnet-bundler/jsonnet-bundler", "subdir": ""}}, "version": "v0.1.0"}]}`),
|
ExpectedJsonnetFile: []byte(`{"dependencies": [{"name": "jsonnet-bundler", "source": {"git": {"remote": "https://github.com/jsonnet-bundler/jsonnet-bundler", "subdir": ""}}, "version": "v0.1.0"}]}`),
|
||||||
ExpectedJsonnetLockFile: []byte(`{"dependencies": [{"name": "jsonnet-bundler", "source": {"git": {"remote": "https://github.com/jsonnet-bundler/jsonnet-bundler", "subdir": ""}}, "version": "080f157c7fb85ad0281ea78f6c641eaa570a582f"}]}`),
|
ExpectedJsonnetLockFile: []byte(`{"dependencies": [{"name": "jsonnet-bundler", "source": {"git": {"remote": "https://github.com/jsonnet-bundler/jsonnet-bundler", "subdir": ""}}, "version": "080f157c7fb85ad0281ea78f6c641eaa570a582f"}]}`),
|
||||||
}, {
|
}, {
|
||||||
Name: "Relative",
|
Name: "Relative",
|
||||||
URLs: []string{"test/jsonnet/foobar"},
|
URIs: []string{"test/jsonnet/foobar"},
|
||||||
ExpectedCode: 0,
|
ExpectedCode: 0,
|
||||||
ExpectedJsonnetFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "test/jsonnet/foobar"}}, "version": ""}]}`),
|
ExpectedJsonnetFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "test/jsonnet/foobar"}}, "version": ""}]}`),
|
||||||
ExpectedJsonnetLockFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "test/jsonnet/foobar"}}, "version": ""}]}`),
|
ExpectedJsonnetLockFile: []byte(`{"dependencies": [{"name": "foobar", "source": {"local": {"directory": "test/jsonnet/foobar"}}, "version": ""}]}`),
|
||||||
|
|
@ -71,7 +71,7 @@ func TestInstallCommand(t *testing.T) {
|
||||||
|
|
||||||
jsonnetFileContent(t, jsonnetFile, []byte(`{}`))
|
jsonnetFileContent(t, jsonnetFile, []byte(`{}`))
|
||||||
|
|
||||||
code = installCommand(tempDir, "vendor", tc.URLs...)
|
code = installCommand(tempDir, "vendor", tc.URIs...)
|
||||||
assert.Equal(t, tc.ExpectedCode, code)
|
assert.Equal(t, tc.ExpectedCode, code)
|
||||||
|
|
||||||
jsonnetFileContent(t, jsonnetFile, tc.ExpectedJsonnetFile)
|
jsonnetFileContent(t, jsonnetFile, tc.ExpectedJsonnetFile)
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ func Main() int {
|
||||||
initCmd := a.Command(initActionName, "Initialize a new empty jsonnetfile")
|
initCmd := a.Command(initActionName, "Initialize a new empty jsonnetfile")
|
||||||
|
|
||||||
installCmd := a.Command(installActionName, "Install all dependencies or install specific ones")
|
installCmd := a.Command(installActionName, "Install all dependencies or install specific ones")
|
||||||
installCmdPaths := installCmd.Arg("paths", "paths to packages to install, URLs or file paths").Strings()
|
installCmdURIs := installCmd.Arg("uris", "URIs to packages to install, URLs or file paths").Strings()
|
||||||
|
|
||||||
updateCmd := a.Command(updateActionName, "Update all dependencies.")
|
updateCmd := a.Command(updateActionName, "Update all dependencies.")
|
||||||
|
|
||||||
|
|
@ -83,7 +83,7 @@ func Main() int {
|
||||||
case initCmd.FullCommand():
|
case initCmd.FullCommand():
|
||||||
return initCommand(workdir)
|
return initCommand(workdir)
|
||||||
case installCmd.FullCommand():
|
case installCmd.FullCommand():
|
||||||
return installCommand(workdir, cfg.JsonnetHome, *installCmdPaths...)
|
return installCommand(workdir, cfg.JsonnetHome, *installCmdURIs...)
|
||||||
case updateCmd.FullCommand():
|
case updateCmd.FullCommand():
|
||||||
return updateCommand(cfg.JsonnetHome)
|
return updateCommand(cfg.JsonnetHome)
|
||||||
default:
|
default:
|
||||||
|
|
@ -93,16 +93,16 @@ func Main() int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseDependency(dir, path string) *spec.Dependency {
|
func parseDependency(dir, uri string) *spec.Dependency {
|
||||||
if d := parseGitSSHDependency(path); d != nil {
|
if d := parseGitSSHDependency(uri); d != nil {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
if d := parseGithubDependency(path); d != nil {
|
if d := parseGithubDependency(uri); d != nil {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
if d := parseLocalDependency(dir, path); d != nil {
|
if d := parseLocalDependency(dir, uri); d != nil {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue