mirror of
https://github.com/TECHNOFAB11/jsonnet-bundler.git
synced 2025-12-12 08:00:05 +01:00
feat(install): add --legacy-name flag
This commit is contained in:
parent
3aec759b6a
commit
9e45e0a43d
2 changed files with 13 additions and 3 deletions
|
|
@ -17,6 +17,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
@ -30,7 +31,7 @@ import (
|
||||||
"github.com/jsonnet-bundler/jsonnet-bundler/spec/v1/deps"
|
"github.com/jsonnet-bundler/jsonnet-bundler/spec/v1/deps"
|
||||||
)
|
)
|
||||||
|
|
||||||
func installCommand(dir, jsonnetHome string, uris []string, single bool) int {
|
func installCommand(dir, jsonnetHome string, uris []string, single bool, legacyName string) int {
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
dir = "."
|
dir = "."
|
||||||
}
|
}
|
||||||
|
|
@ -53,6 +54,10 @@ func installCommand(dir, jsonnetHome string, uris []string, single bool) int {
|
||||||
os.MkdirAll(filepath.Join(dir, jsonnetHome, ".tmp"), os.ModePerm),
|
os.MkdirAll(filepath.Join(dir, jsonnetHome, ".tmp"), os.ModePerm),
|
||||||
"creating vendor folder")
|
"creating vendor folder")
|
||||||
|
|
||||||
|
if len(uris) > 1 && legacyName != "" {
|
||||||
|
log.Fatal("Cannot use --legacy-name with mutliple uris")
|
||||||
|
}
|
||||||
|
|
||||||
for _, u := range uris {
|
for _, u := range uris {
|
||||||
d := deps.Parse(dir, u)
|
d := deps.Parse(dir, u)
|
||||||
if d == nil {
|
if d == nil {
|
||||||
|
|
@ -63,6 +68,10 @@ func installCommand(dir, jsonnetHome string, uris []string, single bool) int {
|
||||||
d.Single = true
|
d.Single = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if legacyName != "" {
|
||||||
|
d.LegacyNameCompat = legacyName
|
||||||
|
}
|
||||||
|
|
||||||
if !depEqual(jsonnetFile.Dependencies[d.Name()], *d) {
|
if !depEqual(jsonnetFile.Dependencies[d.Name()], *d) {
|
||||||
// the dep passed on the cli is different from the jsonnetFile
|
// the dep passed on the cli is different from the jsonnetFile
|
||||||
jsonnetFile.Dependencies[d.Name()] = *d
|
jsonnetFile.Dependencies[d.Name()] = *d
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ func Main() int {
|
||||||
installCmd := a.Command(installActionName, "Install new dependencies. Existing ones are silently skipped")
|
installCmd := a.Command(installActionName, "Install new dependencies. Existing ones are silently skipped")
|
||||||
installCmdURIs := installCmd.Arg("uris", "URIs to packages to install, URLs or file paths").Strings()
|
installCmdURIs := installCmd.Arg("uris", "URIs to packages to install, URLs or file paths").Strings()
|
||||||
installCmdSingle := installCmd.Flag("single", "install package without dependencies").Short('1').Bool()
|
installCmdSingle := installCmd.Flag("single", "install package without dependencies").Short('1').Bool()
|
||||||
|
installCmdLegacyName := installCmd.Flag("legacy-name", "set legacy name").String()
|
||||||
|
|
||||||
updateCmd := a.Command(updateActionName, "Update all or specific dependencies.")
|
updateCmd := a.Command(updateActionName, "Update all or specific dependencies.")
|
||||||
updateCmdURIs := updateCmd.Arg("uris", "URIs to packages to update, URLs or file paths").Strings()
|
updateCmdURIs := updateCmd.Arg("uris", "URIs to packages to update, URLs or file paths").Strings()
|
||||||
|
|
@ -83,13 +84,13 @@ 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, *installCmdURIs, *installCmdSingle)
|
return installCommand(workdir, cfg.JsonnetHome, *installCmdURIs, *installCmdSingle, *installCmdLegacyName)
|
||||||
case updateCmd.FullCommand():
|
case updateCmd.FullCommand():
|
||||||
return updateCommand(workdir, cfg.JsonnetHome, *updateCmdURIs)
|
return updateCommand(workdir, cfg.JsonnetHome, *updateCmdURIs)
|
||||||
case rewriteCmd.FullCommand():
|
case rewriteCmd.FullCommand():
|
||||||
return rewriteCommand(workdir, cfg.JsonnetHome)
|
return rewriteCommand(workdir, cfg.JsonnetHome)
|
||||||
default:
|
default:
|
||||||
installCommand(workdir, cfg.JsonnetHome, []string{}, false)
|
installCommand(workdir, cfg.JsonnetHome, []string{}, false, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue