Commit graph

26 commits

Author SHA1 Message Date
d655269156
feat: add gitlab source for gitlab package registry
cleanup http source
2023-09-25 14:40:39 +02:00
428608f190
feat: add http source with support for environment variables 2022-11-29 16:07:42 +01:00
Matthew Huxtable
fe0eca6e7a Correct path resolution to nested local dependencies
The tool failed to properly resolve nested local dependencies to jsonnet
bundles in different directory trees. This arises because the
installation command resolves and installs nested jsonnet local
dependencies relative to the root jsonnetfile, rather than track and
evaluate the installation path relative to the nested library's
jsonnetfile.

Consider a repository with multiple local jsonnet bundles in various
directory trees, organised as follows (lockfiles elided for brevity):

  /top/of/tree
   |- lib/module_A
     |- jsonnetfile.json
   |- lib/module_B
     |- jsonnetfile.json
   |- src/root_module
     |- jsonnetfile.json

The modules depend on each other as follows:

  ┌───────────────────┐   ┌───────────────────┐   ┌───────────────────┐
  │                   │   │                   │   │                   │
  │  src/root_module  │──>│   lib/module_A    │──>│   lib/module_B    │
  │                   │   │                   │   │                   │
  └───────────────────┘   └───────────────────┘   └───────────────────┘

where X ──> Y indicates bundle X depends on bundle Y, expressed by
adding a dependency of type local in bundle X's jsonnetfile.json, whose
path is the relative path from bundle X to bundle Y in the directory
structure. For example, src/root_module will express a local dependency
on path ../lib/module_A to depend on library module A.

Invoking jb install in src/root_module will result in an error:

  jb: error: failed to install packages: downloading: symlink destination path does not exist: %w:
    stat /top/of/tree/src/module_B: no such file or directory

This occurs because jsonnet-bundler improperly attempts to resolve the
nested dependency on library module B relative to the root module path,
i.e. src/root_module.  The correct behaviour is to perform such
resolution relative to the depending module's jsonnetfile.json, i.e.
relative to lib/module_A.
2021-12-28 19:38:39 +00:00
coffee coder
15c0828a2f
Bug fix: for compare known, on windows, use "\" instead of "/" (#115)
* Enhancement: Subdir detect runtime os. If windows changes "\" to "/"

* Bug fix: for compare known, on windows, use "\" instead of "/"

* Bug fix: for compare known, on windows, use "\" instead of "/"

Co-authored-by: c0feec0der <>
2020-06-09 00:19:31 +02:00
Dominik Süß
9e88f6d38d
fix: windows enhancements (#110)
* use filepath to check for known packages

this fixes an issue using windows. without this patch, jb would delete
the folder after installation since the path is not known

* reduce temp directory length by hashing

using this hash it is harder to reach the windows limit for filenames
and directories

* further reduce temp dir length

* do not build binaries for windows/amd*
2020-05-20 15:51:58 +02:00
sh0rez
fd5f7f108a
feat(install): skip dependencies
Allows `installing` a package without pulling dependencies of that
package. This comes in handy when having multiple directories on
`JPATH`, which overlay each other.

Because dependencies may be already present at lesser ranked import
paths, it's not required to pull them, when only needing to bump a
single one.
2020-04-22 22:34:02 +02:00
Matthias Loibl
bcd89fd33d
feat(spec): version field (#85)
Adds a `version` field to the `jsonnetfile.json`, so that `jb` can automatically recognize too old / too new schema versions, instead of panicking.
2020-02-28 17:41:49 +01:00
Hang Xie
1d729c9517
fix: allow other dirs than vendor (#80) 2020-02-08 14:46:51 +01:00
Tom
7b8a7836a4
feat: absolute imports (#63)
* feat: go-like import style

jb now creates a directory structure inside of vendor/ that is similar to how go
does (github.com/grafana/jsonnet-libs). This is reflected in the final import
paths, which means they will be go-like

* refactor(spec/deps): named regexs

* feat: make goImportStyle configurable

Defaults to off, can be enabled in `jsonnetfile.json`

* fix: integration test

* doc: license headers

* fix(deps): remove GO_IMPORT_STYLE

not an option anymore, will always do so and symlink

* feat: symlink to legacy location

* feat: allow to disable legacy links

* fix(test): legacyImports in integration tests

* fix(spec): test

* fix: respect legacyName aliases

It was possible to alias packages by changing `name` previously.

While names are now absolute (and computed), legacy links should still respect
old aliases to avoid breaking code.

* fix(test): integration

* fix(init): keep legacyImports enabled for now

* feat: rewrite imports

adds a command to automatically rewrite imports from legacy to absolute style

* fix(tool): rewrite confused by prefixing packages

When a package was a prefix of another one, it broke.
Fixed that by using a proper regular expression. Added a test to make sure it
works as expected

* Update cmd/jb/init.go

* fix: exclude local packages from legacy linking

They actually still use the old style, which is fine. LegacyLinking
messed them up, but from now on it just ignores symlinks that match a localPackage.
2020-01-24 08:02:34 +01:00
sh0rez
db1aae9b08
fix: disable sha256 for local packages 2019-10-30 17:40:08 +01:00
sh0rez
0588b89c07
feat: minor improvements
- allow to install pkg that is already locked
- clean unknown files from vendor
- correctly handle checksums and locked versions (was accidentally ignoring
- these before)
2019-10-29 21:44:49 +01:00
sh0rez
6e3e7b2fdd
refactor: use a map instead of a slice
Packages are unique anyways so it makes sense to use a map to avoid having
duplicates.

For compatibility reasons custom json (un)marshallers hide this change from the
end user
2019-10-29 21:44:38 +01:00
sh0rez
4b6e2d89e9
feat: check sum after download
To see if we actually got what we expected
2019-10-29 21:44:34 +01:00
sh0rez
36311f1601
feat: rewrite install procedure
rewrites the installation of packages from scratch to solve several issues with
the existing implementation:

- does not need to choose between lockfile and jsonnetfile anymore. The
jsonnetfile what to be installed, while the lockfile also has versions and
checksums of all packages, even nested ones.
- the lockfile is regenerated on every run, preserving the locked values
- downloaded packages are hashed using sha256 to make sure we receive what we
expect. If files on the local disk are modified, they are downloaded again.
2019-10-29 21:44:30 +01:00
sh0rez
71938456ae
refactor: switch to pkg/jsonnetfile
So far, `pkg` and `pkg/jsonnetfile` had overlapping functionality when it came
to choosing and loading jsonnetfiles.

This fully switches to the separate package `pkg/jsonnetfile` that seems to be
created for exactly this purpose
2019-10-29 21:44:27 +01:00
Matthias Loibl
e4dcc3e116
Refactor git deps install and make local deps install work 2019-07-23 15:07:35 -07:00
Matthias Loibl
07801936c0
Create LocalSource as type for local dependencies 2019-07-23 14:01:25 -07:00
Matthias Loibl
30a3cde870
Make use of File and LockFile constants of jsonnetfile package 2019-07-23 13:59:47 -07:00
Matthias Loibl
27c36f6160
pkg: Write tests for TestInsertDependency, TestFileExists, TestLoadJsonnetfile 2019-07-23 13:36:18 -07:00
Matthias Loibl
c2599b641f
Print colored output for fetched package 2019-03-11 14:21:49 +01:00
Matthias Loibl
eddfcec0f5
Check for existing jsonnetfile.json before init 2018-08-08 10:35:20 +02:00
Frederic Branczyk
086d95926d
pkg: Correctly move locked dependencies 2018-08-02 08:47:43 +02:00
Frederic Branczyk
993f7564f9
Fix install from lock-file
Previously even when installing dependencies from a lockfile,
jsonnet-bundler would attempt to resolve versions of transitive
dependencies to their latest floating version. Instead when a lock-file
is specified jsonnet-bundler should just install the specified versions.
2018-08-01 14:02:59 +02:00
Frederic Branczyk
74c4caa0cf
Add correct lockfile handling 2018-07-25 13:57:37 +02:00
Frederic Branczyk
51388f041b
Fix no dependency inserted when previous array is empty 2018-04-25 09:22:17 +01:00
Frederic Branczyk
f69df626e3
Add ability to resolve and install transitive dependencies 2018-04-25 09:01:00 +01:00