From 73b3df24ebc845d6181273e3faec577686295553 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Thu, 18 Apr 2024 08:11:47 +0100 Subject: [PATCH] mod/modfile: parse module.cue according to language.version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change makes it possible to make changes to the module.cue schema while still using a closed schema for earlier versions. We refuse module.cue files that declare a version newer than the current CUE version. The language.version field is now mandatory in modules mode because otherwise we cannot tell which schema we should be using. Also remove the unimplemented features from the schema for now: they're always there in the history and the proposal when we come to implement them, but they complicate the schema for no good reason. One unfortunate thing is that the error message when a field is defined that's explicitly unimplemented is not good. In the absence of an `error` CUE builtin, we should be able to fix that in a subsequent CL by inspecting the error to see whether any of the lines include the `unimplemented` identifier. Signed-off-by: Roger Peppe Change-Id: I7bfef3b37e5b66bdbd8fe0614c1b815c7d9f1285 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193275 TryBot-Result: CUEcueckoo Reviewed-by: Daniel Martí Unity-Result: CUE porcuepine --- cmd/cue/cmd/testdata/script/cmd_modules.txtar | 3 +- .../script/issue-2945-with-modules.txtar | 1 + cmd/cue/cmd/testdata/script/issue2955.txtar | 2 + .../cmd/testdata/script/modedit_initial.txtar | 16 ++ .../cmd/testdata/script/modget_initial.txtar | 18 ++ .../script/modget_major_version.txtar | 7 + .../script/modinit_majorversion.txtar | 6 +- .../cmd/testdata/script/modinit_noargs.txtar | 4 +- .../script/modinit_nomajorversion.txtar | 6 +- ...txtar => modinit_with_pseudoversion.txtar} | 13 +- .../script/modinit_without_version.txtar | 17 +- .../script/modpublish_no_source.txtar | 1 + .../script/modpublish_no_vcs_directory.txtar | 1 + .../script/modtidy_ambiguous_import.txtar | 3 + .../cmd/testdata/script/modtidy_check.txtar | 3 +- .../testdata/script/modtidy_check_fail.txtar | 3 +- .../cmd/testdata/script/modtidy_initial.txtar | 15 +- .../cmd/testdata/script/modtidy_logging.txtar | 2 + .../testdata/script/modtidy_non_root.txtar | 6 +- .../modtidy_with_existing_version.txtar | 7 +- .../script/modtidy_with_generated_code.txtar | 6 +- .../script/modtidy_with_version.txtar | 31 +-- .../cmd/testdata/script/registry_auth.txtar | 2 + .../script/registry_auth_logins.txtar | 4 + .../script/registry_experiment_not_set.txtar | 2 + .../registry_import_with_no_modfile.txtar | 1 + .../script/registry_lazy_config.txtar | 3 + .../registry_local_import_not_found.txtar | 2 + .../script/registry_module_not_found.txtar | 2 + .../cmd/testdata/script/registry_mux.txtar | 13 + .../testdata/script/registry_mux_auth.txtar | 13 + .../cmd/testdata/script/registry_prefix.txtar | 2 + .../testdata/script/registry_publish.txtar | 9 + .../script/registry_publish_auth.txtar | 2 + .../script/registry_publish_non_root.txtar | 1 + .../script/registry_publish_with_git.txtar | 3 +- .../cmd/testdata/script/registry_simple.txtar | 9 + .../testdata/script/registry_submodule.txtar | 3 + .../testdata/script/registry_token_auth.txtar | 2 + .../script/registry_token_auth_tidy.txtar | 2 + .../registry_with_empty_module_path.txtar | 2 + .../script/registry_with_no_modfile.txtar | 1 + .../testdata/script/registry_with_pkg.txtar | 2 + .../script/registry_with_pkg_conflict.txtar | 3 + .../script/registry_with_remote_gen.txtar | 2 + .../script/registry_wrong_prefix.txtar | 2 + cue/load/example_test.go | 1 + cue/load/testdata/testfetch/depnotfound.txtar | 1 + cue/load/testdata/testfetch/nodeps.txtar | 1 + cue/load/testdata/testfetch/simple.txtar | 10 +- .../testmod-external/cue.mod/module.cue | 2 +- cue/load/testdata/testmod/cue.mod/module.cue | 1 + .../modload/testdata/tidy/addversion.txtar | 12 +- .../modload/testdata/tidy/badimportpath.txtar | 3 +- .../testdata/tidy/canuseprerelease.txtar | 7 +- .../implied-major-version-ambiguity.txtar | 4 +- ...-major-version-with-explicit-default.txtar | 6 +- ...jor-version-without-explicit-default.txtar | 9 +- .../modload/testdata/tidy/nested-deps.txtar | 13 +- .../modload/testdata/tidy/noaddversion.txtar | 6 +- .../testdata/tidy/packagenotfound.txtar | 3 +- .../modload/testdata/tidy/preferstable.txtar | 6 +- .../testdata/tidy/stdlibpackagenotfound.txtar | 5 +- .../tidy-check-fails-with-extra-deps.txtar | 5 +- .../tidy/tidy-with-format-differences.txtar | 5 +- .../testdata/updateversions/add-latest.txtar | 6 + .../updateversions/cannot-downgrade.txtar | 7 + .../updateversions/downgrade-existing.txtar | 6 + .../updateversions/upgrade-existing.txtar | 6 + .../testdata/localpackageambiguous.txtar | 1 + .../testdata/packagegranularity.txtar | 2 + internal/mod/modpkgload/testdata/simple.txtar | 1 + .../testdata/withdefaultmajorversions.txtar | 1 + .../mod/modrequirements/requirements_test.go | 10 + internal/registrytest/testdata/simple.txtar | 7 +- mod/modcache/modcache_test.go | 2 + mod/modconfig/modconfig_test.go | 5 + mod/modfile/modfile.go | 116 +++++++-- mod/modfile/modfile_test.go | 93 ++++--- mod/modfile/schema.cue | 237 ++++++++---------- mod/modregistry/client_test.go | 9 + 81 files changed, 594 insertions(+), 273 deletions(-) rename cmd/cue/cmd/testdata/script/{modtidy_with_pseudoversion.txtar => modinit_with_pseudoversion.txtar} (67%) diff --git a/cmd/cue/cmd/testdata/script/cmd_modules.txtar b/cmd/cue/cmd/testdata/script/cmd_modules.txtar index c830616e0..7c8c4080a 100644 --- a/cmd/cue/cmd/testdata/script/cmd_modules.txtar +++ b/cmd/cue/cmd/testdata/script/cmd_modules.txtar @@ -18,7 +18,7 @@ command: print: { } -- cue.mod/module.cue -- module: "main.example" - +language: version: "v0.8.0" deps: "foo.example/text@v0": { default: true v: "v0.0.1" @@ -27,6 +27,7 @@ deps: "foo.example/text@v0": { package home -- _registry/foo.example_text_v0.0.1/cue.mod/module.cue -- module: "foo.example/text@v0" +language: version: "v0.8.0" -- _registry/foo.example_text_v0.0.1/text.cue -- package text value: "world" diff --git a/cmd/cue/cmd/testdata/script/issue-2945-with-modules.txtar b/cmd/cue/cmd/testdata/script/issue-2945-with-modules.txtar index bf388036d..7aa2b5147 100644 --- a/cmd/cue/cmd/testdata/script/issue-2945-with-modules.txtar +++ b/cmd/cue/cmd/testdata/script/issue-2945-with-modules.txtar @@ -27,6 +27,7 @@ cmp stdout p.golden -- cue.mod/module.cue -- module: "mod.example@v0" +language: version: "v0.8.0" -- x.cue -- package x diff --git a/cmd/cue/cmd/testdata/script/issue2955.txtar b/cmd/cue/cmd/testdata/script/issue2955.txtar index 2b370f111..707bce021 100644 --- a/cmd/cue/cmd/testdata/script/issue2955.txtar +++ b/cmd/cue/cmd/testdata/script/issue2955.txtar @@ -29,6 +29,7 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" -- _registry/auth.json -- { "useTokenServer": true, @@ -39,6 +40,7 @@ module: "test.org" } -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/modedit_initial.txtar b/cmd/cue/cmd/testdata/script/modedit_initial.txtar index 6dea2c4ed..f81f20339 100644 --- a/cmd/cue/cmd/testdata/script/modedit_initial.txtar +++ b/cmd/cue/cmd/testdata/script/modedit_initial.txtar @@ -19,15 +19,25 @@ cmp cue.mod/module.cue want-module-5 -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.9.0-alpha.0" -- want-module-1 -- module: "main.org@v0" +language: { + version: "v0.9.0-alpha.0" +} source: { kind: "git" } -- want-module-2 -- module: "main.org@v0" +language: { + version: "v0.9.0-alpha.0" +} -- want-module-3 -- module: "main.org@v0" +language: { + version: "v0.9.0-alpha.0" +} deps: { "foo.bar@v0": { v: "v0.2.3" @@ -37,5 +47,11 @@ deps: { invalid argument "bad-module!" for "--require" flag: invalid module path@version "bad-module!" -- want-module-4 -- module: "main.org@v0" +language: { + version: "v0.9.0-alpha.0" +} -- want-module-5 -- module: "othermain.org@v1" +language: { + version: "v0.9.0-alpha.0" +} diff --git a/cmd/cue/cmd/testdata/script/modget_initial.txtar b/cmd/cue/cmd/testdata/script/modget_initial.txtar index 3be945fda..a94ab0517 100644 --- a/cmd/cue/cmd/testdata/script/modget_initial.txtar +++ b/cmd/cue/cmd/testdata/script/modget_initial.txtar @@ -45,6 +45,9 @@ stderr 'other requirements prevent changing module baz.org@v0 to version v0.5.0 -- want-module-1 -- module: "main.org@v0" +language: { + version: "v0.8.0" +} deps: { "bar.com@v0": { v: "v0.5.0" @@ -70,6 +73,9 @@ deps: { } -- want-module-2 -- module: "main.org@v0" +language: { + version: "v0.8.0" +} deps: { "bar.com@v0": { v: "v0.5.0" @@ -95,6 +101,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": { v: "v0.5.0" @@ -119,6 +126,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -134,6 +142,7 @@ main: "main" -- _registry/example.com_v0.1.2/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.1.2/top.cue -- package main @@ -146,6 +155,7 @@ main: "main" -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -164,6 +174,7 @@ b -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry/bar.com_v0.0.2/bar/x.cue -- @@ -175,6 +186,7 @@ a -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- @@ -186,6 +198,7 @@ a -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.0.2/baz.cue -- package baz @@ -194,6 +207,7 @@ package baz -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.1.2/baz.cue -- package baz @@ -202,6 +216,7 @@ package baz -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.5.0/baz.cue -- package baz @@ -210,6 +225,7 @@ package baz -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.1/baz.cue -- package baz @@ -218,6 +234,7 @@ package baz -- _registry/baz.org_v0.10.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.2/baz.cue -- package baz @@ -225,6 +242,7 @@ package baz -- _registry/baz.org_v0.11.0-alpha/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.11.0-alpha/baz.cue -- package baz diff --git a/cmd/cue/cmd/testdata/script/modget_major_version.txtar b/cmd/cue/cmd/testdata/script/modget_major_version.txtar index cd52f517c..769e91f7e 100644 --- a/cmd/cue/cmd/testdata/script/modget_major_version.txtar +++ b/cmd/cue/cmd/testdata/script/modget_major_version.txtar @@ -8,6 +8,9 @@ cmp stdout want-stdout -- want-module -- module: "main.example@v0" +language: { + version: "v0.8.0" +} deps: { "foo.org/bar@v2": { v: "v2.0.0" @@ -19,6 +22,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.example" +language: version: "v0.8.0" -- main.cue -- package main import "foo.org/bar" @@ -26,6 +30,7 @@ bar -- _registry/foo.org_bar_v2.0.0/cue.mod/module.cue -- module: "foo.org/bar@v2" +language: version: "v0.8.0" -- _registry/foo.org_bar_v2.0.0/bar.cue -- package bar @@ -33,6 +38,7 @@ package bar -- _registry/foo.org_bar_v1.0.0/cue.mod/module.cue -- module: "foo.org/bar@v1" +language: version: "v0.8.0" -- _registry/foo.org_bar_v1.0.0/bar.cue -- package bar @@ -40,6 +46,7 @@ package bar -- _registry/foo.org_bar_v1.1.0/cue.mod/module.cue -- module: "foo.org/bar@v1" +language: version: "v0.8.0" -- _registry/foo.org_bar_v1.1.0/bar.cue -- package bar diff --git a/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar b/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar index 8e2759198..b7116e0d9 100644 --- a/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar +++ b/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar @@ -1,4 +1,4 @@ -env CUE_VERSION_OVERRIDE=v0.1.2 +env CUE_VERSION_OVERRIDE=v0.8.100 # Without the experiment, the major version is allowed, # even though it's not particularly useful. @@ -19,10 +19,10 @@ exists cue.mod/pkg -- want-module.cue -- module: "foo.com/bar@v1" language: { - version: "v0.1.2" + version: "v0.8.100" } -- want-module-experiment.cue -- module: "foo.com/bar@v1" language: { - version: "v0.1.2" + version: "v0.8.100" } diff --git a/cmd/cue/cmd/testdata/script/modinit_noargs.txtar b/cmd/cue/cmd/testdata/script/modinit_noargs.txtar index 90e6ee988..964e9c9af 100644 --- a/cmd/cue/cmd/testdata/script/modinit_noargs.txtar +++ b/cmd/cue/cmd/testdata/script/modinit_noargs.txtar @@ -1,6 +1,6 @@ # TODO we might want to deprecate or remove the ability to create # module file with an empty module directive. -env CUE_VERSION_OVERRIDE=v0.1.2 +env CUE_VERSION_OVERRIDE=v0.8.100 exec cue mod init cmp cue.mod/module.cue want-module.cue exists cue.mod/usr @@ -9,5 +9,5 @@ exists cue.mod/pkg -- want-module.cue -- module: "" language: { - version: "v0.1.2" + version: "v0.8.100" } diff --git a/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar b/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar index 25c459743..7bd129fd0 100644 --- a/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar +++ b/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar @@ -1,4 +1,4 @@ -env CUE_VERSION_OVERRIDE=v0.1.2 +env CUE_VERSION_OVERRIDE=v0.8.0 # Without the experiment, we use the module path as-is. exec cue mod init foo.com/bar @@ -17,10 +17,10 @@ exists cue.mod/pkg -- want-module.cue -- module: "foo.com/bar" language: { - version: "v0.1.2" + version: "v0.8.0" } -- want-module-experiment.cue -- module: "foo.com/bar@v0" language: { - version: "v0.1.2" + version: "v0.8.0" } diff --git a/cmd/cue/cmd/testdata/script/modtidy_with_pseudoversion.txtar b/cmd/cue/cmd/testdata/script/modinit_with_pseudoversion.txtar similarity index 67% rename from cmd/cue/cmd/testdata/script/modtidy_with_pseudoversion.txtar rename to cmd/cue/cmd/testdata/script/modinit_with_pseudoversion.txtar index ace1444ad..d21a69a81 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_with_pseudoversion.txtar +++ b/cmd/cue/cmd/testdata/script/modinit_with_pseudoversion.txtar @@ -1,8 +1,8 @@ -# Check that cue mod tidy chooses a correct base version +# Check that cue mod init chooses a correct base version # when provided with a pseudo-version. -env CUE_VERSION_OVERRIDE=v0.7.1-0.20240130142347-7855e15cb701 -exec cue mod tidy +env CUE_VERSION_OVERRIDE=v0.8.20-0.20240130142347-7855e15cb701 +exec cue mod init main.org cmp cue.mod/module.cue want-module # Check that the resulting module evaluates as expected. @@ -15,17 +15,14 @@ cmp stdout want-stdout -- want-module -- module: "main.org@v0" language: { - version: "v0.7.0" + version: "v0.8.19" } --- cue.mod/module.cue -- -module: "main.org@v0" - -- main.cue -- package main x: 1 - -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/modinit_without_version.txtar b/cmd/cue/cmd/testdata/script/modinit_without_version.txtar index 36fe508e2..85f0bf454 100644 --- a/cmd/cue/cmd/testdata/script/modinit_without_version.txtar +++ b/cmd/cue/cmd/testdata/script/modinit_without_version.txtar @@ -1,15 +1,10 @@ -# Check that cue mod init skips the language version -# when it lacks any version information at all. +# Check that cue mod init fails when it lacks any version +# information at all. # A zero pseudo-version is one such case, as there are no semver numbers. env CUE_EXPERIMENT=modules env CUE_VERSION_OVERRIDE=v0.0.0-00010101000000-000000000000 -exec cue mod init foo.example -cmp cue.mod/module.cue want-module +! exec cue mod init foo.example +cmp stderr want-stderr -# cue mod tidy should be a no-op after cue mod init -env CUE_CACHE_DIR=$WORK/.tmp/cache -exec cue mod tidy -cmp cue.mod/module.cue want-module - --- want-module -- -module: "foo.example@v0" +-- want-stderr -- +cannot round-trip module file: no language version declared in module.cue diff --git a/cmd/cue/cmd/testdata/script/modpublish_no_source.txtar b/cmd/cue/cmd/testdata/script/modpublish_no_source.txtar index 23f2c89b9..044099c35 100644 --- a/cmd/cue/cmd/testdata/script/modpublish_no_source.txtar +++ b/cmd/cue/cmd/testdata/script/modpublish_no_source.txtar @@ -9,3 +9,4 @@ cmp stderr want-stderr no source field found in cue.mod/module.cue -- cue.mod/module.cue -- module: "x.example@v1" +language: version: "v0.9.0-alpha.0" diff --git a/cmd/cue/cmd/testdata/script/modpublish_no_vcs_directory.txtar b/cmd/cue/cmd/testdata/script/modpublish_no_vcs_directory.txtar index a638d581c..c85541ab0 100644 --- a/cmd/cue/cmd/testdata/script/modpublish_no_vcs_directory.txtar +++ b/cmd/cue/cmd/testdata/script/modpublish_no_vcs_directory.txtar @@ -7,5 +7,6 @@ env CUE_EXPERIMENT=modules stderr 'git VCS not found in any parent of ".+"' -- cue.mod/module.cue -- module: "x.example@v1" +language: version: "v0.9.0-alpha.1" source: kind: "git" diff --git a/cmd/cue/cmd/testdata/script/modtidy_ambiguous_import.txtar b/cmd/cue/cmd/testdata/script/modtidy_ambiguous_import.txtar index a948a6220..4aec7bbb0 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_ambiguous_import.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_ambiguous_import.txtar @@ -11,6 +11,7 @@ failed to resolve "example.com/foo/bar@v0": ambiguous import: found package exam example.com/foo@v0 v0.1.0 (bar) -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" -- main.cue -- package main @@ -18,12 +19,14 @@ import "example.com/foo/bar@v0" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/foo/bar/x.cue -- package bar -- _registry/example.com_foo_v0.1.0/cue.mod/module.cue -- module: "example.com/foo@v0" +language: version: "v0.8.0" -- _registry/example.com_foo_v0.1.0/bar/x.cue -- package bar diff --git a/cmd/cue/cmd/testdata/script/modtidy_check.txtar b/cmd/cue/cmd/testdata/script/modtidy_check.txtar index 9c23f7d13..a6a457ec9 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_check.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_check.txtar @@ -6,7 +6,7 @@ exec cue mod tidy --check -- cue.mod/module.cue -- module: "main.org@v0" -language: version: "v0.99.99" +language: version: "v0.8.100" // A comment. deps: "example.com@v0": v: "v0.0.1" @@ -19,6 +19,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/modtidy_check_fail.txtar b/cmd/cue/cmd/testdata/script/modtidy_check_fail.txtar index 8e06f8002..18a777b93 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_check_fail.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_check_fail.txtar @@ -7,7 +7,7 @@ cmp stderr want-stderr module is not tidy: cannot find module providing package example.com@v0:main -- cue.mod/module.cue -- module: "main.org@v0" -language: version: "v0.99.99" +language: version: "v0.8.0" -- main.cue -- package main @@ -17,6 +17,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/modtidy_initial.txtar b/cmd/cue/cmd/testdata/script/modtidy_initial.txtar index d473b3627..76296ed45 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_initial.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_initial.txtar @@ -3,7 +3,7 @@ # dependencies, and that it removes dependencies that # aren't needed any more. -env CUE_VERSION_OVERRIDE=v0.1.2 +env CUE_VERSION_OVERRIDE=v0.8.100 exec cue mod tidy cmp cue.mod/module.cue want-module @@ -16,7 +16,7 @@ exec cue mod tidy --check -- want-module -- module: "main.org@v0" language: { - version: "v0.1.2" + version: "v0.8.0" } deps: { "bar.com@v0": { @@ -43,6 +43,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: "example.com@v0": v: "v0.0.1" deps: "unused.com@v0": v: "v0.2.4" @@ -55,6 +56,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -70,9 +72,11 @@ main: "main" -- _registry/unused.com_v0.2.4/cue.mod/module.cue -- module: "unused.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.1.2/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.1.2/top.cue -- package main @@ -85,6 +89,7 @@ main: "main" -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -103,6 +108,7 @@ b -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry/bar.com_v0.0.2/bar/x.cue -- @@ -114,6 +120,7 @@ a -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- @@ -125,6 +132,7 @@ a -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.0.2/baz.cue -- package baz @@ -133,6 +141,7 @@ package baz -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.1.2/baz.cue -- package baz @@ -141,6 +150,7 @@ package baz -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.5.0/baz.cue -- package baz @@ -149,6 +159,7 @@ package baz -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.1/baz.cue -- package baz diff --git a/cmd/cue/cmd/testdata/script/modtidy_logging.txtar b/cmd/cue/cmd/testdata/script/modtidy_logging.txtar index 8f6343b0f..10a205e5f 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_logging.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_logging.txtar @@ -15,6 +15,7 @@ cmp stdout want-stdout } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" -- main.cue -- package main @@ -25,6 +26,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/modtidy_non_root.txtar b/cmd/cue/cmd/testdata/script/modtidy_non_root.txtar index 03dad2b7a..8ea6f29be 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_non_root.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_non_root.txtar @@ -2,7 +2,7 @@ # run in the module's root directory. cd x/y -env CUE_VERSION_OVERRIDE=v0.1.2 +env CUE_VERSION_OVERRIDE=v0.8.100 exec cue mod tidy cd $WORK cmp cue.mod/module.cue want-module @@ -10,12 +10,14 @@ cmp cue.mod/module.cue want-module -- want-module -- module: "main.org@v0" language: { - version: "v0.1.2" + version: "v0.8.0" } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" -- x/y/z.cue -- package y -- _registry/example.com_v0.0.1/cue.mod/module.cue -- // This file is just here to ensure that CUE_REGISTRY etc is set. module: "example.com@v0" +language: version: "v0.8.0" diff --git a/cmd/cue/cmd/testdata/script/modtidy_with_existing_version.txtar b/cmd/cue/cmd/testdata/script/modtidy_with_existing_version.txtar index aabeb6200..1326c9212 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_with_existing_version.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_with_existing_version.txtar @@ -1,7 +1,7 @@ # Check that cue mod tidy won't change the language # version when the field is already present in the module.cue file. -env CUE_VERSION_OVERRIDE=v0.9.9 +env CUE_VERSION_OVERRIDE=v0.8.300 exec cue mod tidy cmp cue.mod/module.cue want-module @@ -16,12 +16,12 @@ cmp stdout want-stdout -- want-module -- module: "main.org@v0" language: { - version: "v0.1.2" + version: "v0.8.100" } -- cue.mod/module.cue -- module: "main.org@v0" language: { - version: "v0.1.2" + version: "v0.8.100" } -- main.cue -- @@ -30,6 +30,7 @@ x: 1 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/modtidy_with_generated_code.txtar b/cmd/cue/cmd/testdata/script/modtidy_with_generated_code.txtar index 40a6a0a37..03f9b3e8a 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_with_generated_code.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_with_generated_code.txtar @@ -3,7 +3,7 @@ # dependencies, and that it removes dependencies that # aren't needed any more. -env CUE_VERSION_OVERRIDE=v0.1.2 +env CUE_VERSION_OVERRIDE=v0.8.100 exec cue mod tidy cmp cue.mod/module.cue want-module @@ -13,7 +13,7 @@ cmp stdout want-stdout -- want-module -- module: "main.org@v0" language: { - version: "v0.1.2" + version: "v0.8.0" } deps: { "example.com@v0": { @@ -27,6 +27,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" -- cue.mod/gen/foo.com/bar/x.cue -- package bar bar: "local" @@ -42,6 +43,7 @@ bar -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main "example.com": "v0.0.1" diff --git a/cmd/cue/cmd/testdata/script/modtidy_with_version.txtar b/cmd/cue/cmd/testdata/script/modtidy_with_version.txtar index 23f945fc2..ae5e92466 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_with_version.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_with_version.txtar @@ -1,27 +1,12 @@ -# Check that cue mod tidy adds the language version to the -# module.cue file when there is one. Note that because -# the version is taken from the build info, we need to use -# the CUE_VERSION_OVERRIDE environment variable. -# We get confidence in the actual buildinfo logic because exactly -# the same code is used behind the scenes for the `cue version` -# implementation too. +# Check that cue mod tidy fails when there is no version +# present in the module.cue file. -env CUE_VERSION_OVERRIDE=v0.1.2 -exec cue mod tidy -cmp cue.mod/module.cue want-module +env CUE_VERSION_OVERRIDE=v0.8.100 +! exec cue mod tidy +cmp stderr want-stderr -# Check that the resulting module evaluates as expected. -exec cue export . -cmp stdout want-stdout --- want-stdout -- -{ - "x": 1 -} --- want-module -- -module: "main.org@v0" -language: { - version: "v0.1.2" -} +-- want-stderr -- +no language version declared in module.cue -- cue.mod/module.cue -- module: "main.org@v0" @@ -31,6 +16,6 @@ x: 1 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" - +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/registry_auth.txtar b/cmd/cue/cmd/testdata/script/registry_auth.txtar index d5f31f900..905d804a4 100644 --- a/cmd/cue/cmd/testdata/script/registry_auth.txtar +++ b/cmd/cue/cmd/testdata/script/registry_auth.txtar @@ -57,6 +57,7 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.1" -- _registry/auth.json -- {"username": "someone", "password": "something"} @@ -64,6 +65,7 @@ deps: "example.com/e": v: "v0.0.1" somewhere/other -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_auth_logins.txtar b/cmd/cue/cmd/testdata/script/registry_auth_logins.txtar index d964e3e44..86f8ae613 100644 --- a/cmd/cue/cmd/testdata/script/registry_auth_logins.txtar +++ b/cmd/cue/cmd/testdata/script/registry_auth_logins.txtar @@ -65,6 +65,7 @@ import "example.com/e3" -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e1": v: "v0.0.1" deps: "example.com/e2": v: "v0.0.1" deps: "example.com/e3": v: "v0.0.1" @@ -74,6 +75,7 @@ deps: "example.com/e3": v: "v0.0.1" somewhere/other -- _registry/example.com_e1_v0.0.1/cue.mod/module.cue -- module: "example.com/e1@v0" +language: version: "v0.8.0" -- _registry/example.com_e1_v0.0.1/main.cue -- package e1 @@ -81,6 +83,7 @@ package e1 foo: "ok1" -- _registry/example.com_e2_v0.0.1/cue.mod/module.cue -- module: "example.com/e2@v0" +language: version: "v0.8.0" -- _registry/example.com_e2_v0.0.1/main.cue -- package e2 @@ -88,6 +91,7 @@ package e2 foo: "ok2" -- _registry/example.com_e3_v0.0.1/cue.mod/module.cue -- module: "example.com/e3@v0" +language: version: "v0.8.0" -- _registry/example.com_e3_v0.0.1/main.cue -- package e3 diff --git a/cmd/cue/cmd/testdata/script/registry_experiment_not_set.txtar b/cmd/cue/cmd/testdata/script/registry_experiment_not_set.txtar index a98127b14..d40529b7a 100644 --- a/cmd/cue/cmd/testdata/script/registry_experiment_not_set.txtar +++ b/cmd/cue/cmd/testdata/script/registry_experiment_not_set.txtar @@ -19,12 +19,14 @@ module: "test.org" deps: "example.com/e": v: "v0.0.1" -- cue.mod/pkg/example.com/e/cue.mod/module.cue -- module: "example.com/e" +language: version: "v0.8.0" -- cue.mod/pkg/example.com/e/main.cue -- package e foo: "cue.mod/pkg source" -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_import_with_no_modfile.txtar b/cmd/cue/cmd/testdata/script/registry_import_with_no_modfile.txtar index 018d1e6d7..e77aeff1d 100644 --- a/cmd/cue/cmd/testdata/script/registry_import_with_no_modfile.txtar +++ b/cmd/cue/cmd/testdata/script/registry_import_with_no_modfile.txtar @@ -10,6 +10,7 @@ x: bar.X -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/registry_lazy_config.txtar b/cmd/cue/cmd/testdata/script/registry_lazy_config.txtar index 239555fea..bedbeb7ab 100644 --- a/cmd/cue/cmd/testdata/script/registry_lazy_config.txtar +++ b/cmd/cue/cmd/testdata/script/registry_lazy_config.txtar @@ -23,6 +23,7 @@ package main -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" -- OTHER/main.cue -- package main @@ -31,6 +32,7 @@ e.foo -- OTHER/cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.1" -- _registry/auth.json -- @@ -39,6 +41,7 @@ deps: "example.com/e": v: "v0.0.1" somewhere/other -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_local_import_not_found.txtar b/cmd/cue/cmd/testdata/script/registry_local_import_not_found.txtar index 421331def..3a18d4aba 100644 --- a/cmd/cue/cmd/testdata/script/registry_local_import_not_found.txtar +++ b/cmd/cue/cmd/testdata/script/registry_local_import_not_found.txtar @@ -5,6 +5,7 @@ cmp stdout expect-stdout x: 5 -- cue.mod/module.cue -- module: "main.org/foo@v0" +language: version: "v0.8.0" -- foo.cue -- package foo import "main.org/foo/bar" @@ -15,6 +16,7 @@ x: 5 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/registry_module_not_found.txtar b/cmd/cue/cmd/testdata/script/registry_module_not_found.txtar index 0b05fa589..19423ea61 100644 --- a/cmd/cue/cmd/testdata/script/registry_module_not_found.txtar +++ b/cmd/cue/cmd/testdata/script/registry_module_not_found.txtar @@ -15,9 +15,11 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.2" -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_mux.txtar b/cmd/cue/cmd/testdata/script/registry_mux.txtar index 9f8e5532d..70643b3ca 100644 --- a/cmd/cue/cmd/testdata/script/registry_mux.txtar +++ b/cmd/cue/cmd/testdata/script/registry_mux.txtar @@ -30,6 +30,7 @@ main: "main" "example.com@v0": "v0.0.1" -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": { v: "v0.5.0" @@ -57,6 +58,7 @@ foo/bar -- _registry1/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -74,6 +76,7 @@ main: "main" -- _registry1/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -92,6 +95,7 @@ b -- _registry1/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry1/bar.com_v0.0.2/bar/x.cue -- @@ -103,6 +107,7 @@ a -- _registry1/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry1/bar.com_v0.5.0/bar/x.cue -- @@ -114,6 +119,7 @@ a -- _registry1/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.0.2/baz.cue -- package baz @@ -121,6 +127,7 @@ package baz -- _registry1/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.1.2/baz.cue -- package baz @@ -129,6 +136,7 @@ package baz -- _registry1/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.5.0/baz.cue -- package baz @@ -136,6 +144,7 @@ package baz -- _registry1/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.10.1/baz.cue -- package baz @@ -143,6 +152,7 @@ package baz -- _registry2/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.0.2/baz.cue -- package baz @@ -150,9 +160,11 @@ package baz -- _registry2/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.5.0/baz.cue -- package baz @@ -160,6 +172,7 @@ package baz -- _registry2/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.10.1/baz.cue -- package baz diff --git a/cmd/cue/cmd/testdata/script/registry_mux_auth.txtar b/cmd/cue/cmd/testdata/script/registry_mux_auth.txtar index 9a10fc088..4d737089c 100644 --- a/cmd/cue/cmd/testdata/script/registry_mux_auth.txtar +++ b/cmd/cue/cmd/testdata/script/registry_mux_auth.txtar @@ -27,6 +27,7 @@ main: "main" } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": { v: "v0.5.0" @@ -52,6 +53,7 @@ main {"username": "registry1user", "password": "registry1password"} -- _registry1/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -69,6 +71,7 @@ main: "main" -- _registry1/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -87,6 +90,7 @@ b -- _registry1/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry1/bar.com_v0.0.2/bar/x.cue -- @@ -98,6 +102,7 @@ a -- _registry1/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry1/bar.com_v0.5.0/bar/x.cue -- @@ -109,6 +114,7 @@ a -- _registry1/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.0.2/baz.cue -- package baz @@ -116,6 +122,7 @@ package baz -- _registry1/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.1.2/baz.cue -- package baz @@ -124,6 +131,7 @@ package baz -- _registry1/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.5.0/baz.cue -- package baz @@ -131,6 +139,7 @@ package baz -- _registry1/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry1/baz.org_v0.10.1/baz.cue -- package baz @@ -141,6 +150,7 @@ package baz -- _registry2/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.0.2/baz.cue -- package baz @@ -148,9 +158,11 @@ package baz -- _registry2/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.5.0/baz.cue -- package baz @@ -158,6 +170,7 @@ package baz -- _registry2/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry2/baz.org_v0.10.1/baz.cue -- package baz diff --git a/cmd/cue/cmd/testdata/script/registry_prefix.txtar b/cmd/cue/cmd/testdata/script/registry_prefix.txtar index ee7945fe6..110f6cba2 100644 --- a/cmd/cue/cmd/testdata/script/registry_prefix.txtar +++ b/cmd/cue/cmd/testdata/script/registry_prefix.txtar @@ -11,11 +11,13 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.9.0-alpha.0" deps: "example.com/e": v: "v0.0.1" -- _registry_prefix -- somewhere/other -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.9.0-alpha.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_publish.txtar b/cmd/cue/cmd/testdata/script/registry_publish.txtar index a2da00a30..f1aa6f835 100644 --- a/cmd/cue/cmd/testdata/script/registry_publish.txtar +++ b/cmd/cue/cmd/testdata/script/registry_publish.txtar @@ -25,6 +25,7 @@ main: "main" "example.com@v0": "v0.0.1" -- main/cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.9.0-alpha.0" source: kind: "self" @@ -46,6 +47,7 @@ main -- example/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.9.0-alpha.0" source: kind: "self" deps: { "bar.com@v0": v: "v0.5.0" @@ -65,6 +67,7 @@ main: "main" -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -83,6 +86,7 @@ b -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry/bar.com_v0.0.2/bar/x.cue -- @@ -94,6 +98,7 @@ a -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- @@ -105,6 +110,7 @@ a -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.0.2/baz.cue -- package baz @@ -113,6 +119,7 @@ package baz -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.1.2/baz.cue -- package baz @@ -121,6 +128,7 @@ package baz -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.5.0/baz.cue -- package baz @@ -129,6 +137,7 @@ package baz -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.1/baz.cue -- package baz diff --git a/cmd/cue/cmd/testdata/script/registry_publish_auth.txtar b/cmd/cue/cmd/testdata/script/registry_publish_auth.txtar index 5a64504ae..3379bd751 100644 --- a/cmd/cue/cmd/testdata/script/registry_publish_auth.txtar +++ b/cmd/cue/cmd/testdata/script/registry_publish_auth.txtar @@ -32,6 +32,7 @@ main: "main" "example.com@v0": "v0.0.1" -- main/cue.mod/module.cue -- module: "main.org" +language: version: "v0.9.0-alpha.0" deps: "example.com@v0": v: "v0.0.1" -- main/main.cue -- @@ -43,6 +44,7 @@ main -- example/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.9.0-alpha.0" source: kind: "self" diff --git a/cmd/cue/cmd/testdata/script/registry_publish_non_root.txtar b/cmd/cue/cmd/testdata/script/registry_publish_non_root.txtar index ad76622ff..1ece3df8a 100644 --- a/cmd/cue/cmd/testdata/script/registry_publish_non_root.txtar +++ b/cmd/cue/cmd/testdata/script/registry_publish_non_root.txtar @@ -14,6 +14,7 @@ cmp stdout ../../expect-publish-stdout published example.com@v0.0.1 -- example/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.9.0-alpha.0" source: kind: "self" diff --git a/cmd/cue/cmd/testdata/script/registry_publish_with_git.txtar b/cmd/cue/cmd/testdata/script/registry_publish_with_git.txtar index d7537fc68..684757d07 100644 --- a/cmd/cue/cmd/testdata/script/registry_publish_with_git.txtar +++ b/cmd/cue/cmd/testdata/script/registry_publish_with_git.txtar @@ -49,7 +49,7 @@ e: true sensitive: true -- main/cue.mod/module.cue -- module: "main.org@v0" - +language: version: "v0.9.0-alpha.0" source: kind: "self" deps: "x.example/e@v0": v: "v0.0.1" @@ -62,6 +62,7 @@ e -- example/cuemodule/cue.mod/module.cue -- module: "x.example/e@v0" +language: version: "v0.9.0-alpha.0" source: kind: "git" -- example/.gitignore -- /cuemodule/ignored.cue diff --git a/cmd/cue/cmd/testdata/script/registry_simple.txtar b/cmd/cue/cmd/testdata/script/registry_simple.txtar index cf958eb5a..a8c02fd99 100644 --- a/cmd/cue/cmd/testdata/script/registry_simple.txtar +++ b/cmd/cue/cmd/testdata/script/registry_simple.txtar @@ -24,6 +24,7 @@ main: "main" } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": { v: "v0.5.0" @@ -47,6 +48,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -64,6 +66,7 @@ main: "main" -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -82,6 +85,7 @@ b -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry/bar.com_v0.0.2/bar/x.cue -- @@ -93,6 +97,7 @@ a -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- @@ -104,6 +109,7 @@ a -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.0.2/baz.cue -- package baz @@ -112,6 +118,7 @@ package baz -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.1.2/baz.cue -- package baz @@ -120,6 +127,7 @@ package baz -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.5.0/baz.cue -- package baz @@ -128,6 +136,7 @@ package baz -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.1/baz.cue -- package baz diff --git a/cmd/cue/cmd/testdata/script/registry_submodule.txtar b/cmd/cue/cmd/testdata/script/registry_submodule.txtar index fc8f0db80..55a0e7182 100644 --- a/cmd/cue/cmd/testdata/script/registry_submodule.txtar +++ b/cmd/cue/cmd/testdata/script/registry_submodule.txtar @@ -9,6 +9,7 @@ a: { } -- cue.mod/module.cue -- module: "main.org" +language: version: "v0.8.0" deps: { "example.com@v0": { @@ -32,6 +33,7 @@ a: { } -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package example @@ -39,6 +41,7 @@ package example e: true -- _registry/example.com_foo_v0.0.1/cue.mod/module.cue -- module: "example.com/foo@v0" +language: version: "v0.8.0" -- _registry/example.com_foo_v0.0.1/foo.cue -- package foo f: true diff --git a/cmd/cue/cmd/testdata/script/registry_token_auth.txtar b/cmd/cue/cmd/testdata/script/registry_token_auth.txtar index 4f8d91b92..fcbf7c913 100644 --- a/cmd/cue/cmd/testdata/script/registry_token_auth.txtar +++ b/cmd/cue/cmd/testdata/script/registry_token_auth.txtar @@ -25,6 +25,7 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.1" -- _registry/auth.json -- { @@ -34,6 +35,7 @@ deps: "example.com/e": v: "v0.0.1" somewhere/other -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_token_auth_tidy.txtar b/cmd/cue/cmd/testdata/script/registry_token_auth_tidy.txtar index 8b2fda8be..be1274e38 100644 --- a/cmd/cue/cmd/testdata/script/registry_token_auth_tidy.txtar +++ b/cmd/cue/cmd/testdata/script/registry_token_auth_tidy.txtar @@ -27,6 +27,7 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" -- _registry/auth.json -- { "useTokenServer": true, @@ -36,6 +37,7 @@ module: "test.org" } -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_with_empty_module_path.txtar b/cmd/cue/cmd/testdata/script/registry_with_empty_module_path.txtar index 5921f515a..5cd12086b 100644 --- a/cmd/cue/cmd/testdata/script/registry_with_empty_module_path.txtar +++ b/cmd/cue/cmd/testdata/script/registry_with_empty_module_path.txtar @@ -6,10 +6,12 @@ cmp stdout want-stdout } -- cue.mod/module.cue -- module: "" +language: version: "v0.8.0" -- x.cue -- a: 1 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/registry_with_no_modfile.txtar b/cmd/cue/cmd/testdata/script/registry_with_no_modfile.txtar index b40de5aa0..3753709ae 100644 --- a/cmd/cue/cmd/testdata/script/registry_with_no_modfile.txtar +++ b/cmd/cue/cmd/testdata/script/registry_with_no_modfile.txtar @@ -8,6 +8,7 @@ cmp stdout want-stdout a: 1 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/cmd/cue/cmd/testdata/script/registry_with_pkg.txtar b/cmd/cue/cmd/testdata/script/registry_with_pkg.txtar index c8352a75a..78988d24c 100644 --- a/cmd/cue/cmd/testdata/script/registry_with_pkg.txtar +++ b/cmd/cue/cmd/testdata/script/registry_with_pkg.txtar @@ -46,6 +46,7 @@ import ( -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.1" -- cue.mod/pkg/example.com/e/local_pkg/x.cue -- @@ -70,6 +71,7 @@ a: gen: true -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_with_pkg_conflict.txtar b/cmd/cue/cmd/testdata/script/registry_with_pkg_conflict.txtar index 6f1a61251..39d411eda 100644 --- a/cmd/cue/cmd/testdata/script/registry_with_pkg_conflict.txtar +++ b/cmd/cue/cmd/testdata/script/registry_with_pkg_conflict.txtar @@ -18,10 +18,12 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.1" -- cue.mod/pkg/example.com/e/cue.mod/module.cue -- module: "example.com/e" +language: version: "v0.8.0" -- cue.mod/pkg/example.com/e/main.cue -- package e @@ -29,6 +31,7 @@ foo: "cue.mod/pkg source" -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_with_remote_gen.txtar b/cmd/cue/cmd/testdata/script/registry_with_remote_gen.txtar index bb4f10659..65a5fedf0 100644 --- a/cmd/cue/cmd/testdata/script/registry_with_remote_gen.txtar +++ b/cmd/cue/cmd/testdata/script/registry_with_remote_gen.txtar @@ -26,10 +26,12 @@ import "example.com/e" -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.1" -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cmd/cue/cmd/testdata/script/registry_wrong_prefix.txtar b/cmd/cue/cmd/testdata/script/registry_wrong_prefix.txtar index 28e42e29a..81ba71d2f 100644 --- a/cmd/cue/cmd/testdata/script/registry_wrong_prefix.txtar +++ b/cmd/cue/cmd/testdata/script/registry_wrong_prefix.txtar @@ -13,9 +13,11 @@ e.foo -- cue.mod/module.cue -- module: "test.org" +language: version: "v0.8.0" deps: "example.com/e": v: "v0.0.1" -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- module: "example.com/e@v0" +language: version: "v0.8.0" -- _registry/example.com_e_v0.0.1/main.cue -- package e diff --git a/cue/load/example_test.go b/cue/load/example_test.go index ce5621e95..103bee769 100644 --- a/cue/load/example_test.go +++ b/cue/load/example_test.go @@ -127,6 +127,7 @@ func setUpModulesExample() (env []string, cleanup func()) { registryArchive := txtar.Parse([]byte(` -- foo.example_v0.0.1/cue.mod/module.cue -- module: "foo.example@v0" +language: version: "v0.8.0" -- foo.example_v0.0.1/bar/bar.cue -- package bar diff --git a/cue/load/testdata/testfetch/depnotfound.txtar b/cue/load/testdata/testfetch/depnotfound.txtar index c3154d1f6..ed1ee1416 100644 --- a/cue/load/testdata/testfetch/depnotfound.txtar +++ b/cue/load/testdata/testfetch/depnotfound.txtar @@ -3,6 +3,7 @@ import failed: cannot find package "example.com": cannot fetch example.com@v0.0. ./main.cue:2:8 -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: "example.com@v0": v: "v0.0.1" diff --git a/cue/load/testdata/testfetch/nodeps.txtar b/cue/load/testdata/testfetch/nodeps.txtar index 84e2d9f7d..7a80a1b8a 100644 --- a/cue/load/testdata/testfetch/nodeps.txtar +++ b/cue/load/testdata/testfetch/nodeps.txtar @@ -4,6 +4,7 @@ } -- cue.mod/module.cue -- module: "main.org" +language: version: "v0.8.0" -- main.cue -- package main diff --git a/cue/load/testdata/testfetch/simple.txtar b/cue/load/testdata/testfetch/simple.txtar index b043cabc5..c8f3a3aa4 100644 --- a/cue/load/testdata/testfetch/simple.txtar +++ b/cue/load/testdata/testfetch/simple.txtar @@ -8,7 +8,7 @@ } -- cue.mod/module.cue -- module: "main.org" - +language: version: "v0.8.0" deps: { "example.com@v0": v: "v0.0.1" "foo.com/bar/hello@v0": v: "v0.2.3" @@ -23,6 +23,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -40,6 +41,7 @@ main: "main" -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -58,6 +60,7 @@ b -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry/bar.com_v0.0.2/bar/x.cue -- @@ -69,6 +72,7 @@ a -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- @@ -80,6 +84,7 @@ a -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.0.2/baz.cue -- package baz @@ -88,6 +93,7 @@ package baz -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.1.2/baz.cue -- package baz @@ -96,6 +102,7 @@ package baz -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.5.0/baz.cue -- package baz @@ -104,6 +111,7 @@ package baz -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.1/baz.cue -- package baz diff --git a/cue/load/testdata/testmod-external/cue.mod/module.cue b/cue/load/testdata/testmod-external/cue.mod/module.cue index 6a765510b..f315ef0ce 100644 --- a/cue/load/testdata/testmod-external/cue.mod/module.cue +++ b/cue/load/testdata/testmod-external/cue.mod/module.cue @@ -1,3 +1,3 @@ module: "main.example@v0" - +language: version: "v0.8.0" deps: "foo.example@v0": v: "v0.0.1" diff --git a/cue/load/testdata/testmod/cue.mod/module.cue b/cue/load/testdata/testmod/cue.mod/module.cue index 12e397f64..24507e261 100644 --- a/cue/load/testdata/testmod/cue.mod/module.cue +++ b/cue/load/testdata/testmod/cue.mod/module.cue @@ -13,3 +13,4 @@ // limitations under the License. module: "mod.test/test" +language: version: "v0.8.0" diff --git a/internal/mod/modload/testdata/tidy/addversion.txtar b/internal/mod/modload/testdata/tidy/addversion.txtar index 5fb845be9..4219e5b21 100644 --- a/internal/mod/modload/testdata/tidy/addversion.txtar +++ b/internal/mod/modload/testdata/tidy/addversion.txtar @@ -1,14 +1,12 @@ -# Test that a version is added if not present +# Test that it fails if a version isn't already present. -- cue-version -- v1.2.3 --- tidy-check-error -- -no language version found in cue.mod/module.cue -- want -- -module: "main.org@v0" -language: { - version: "v1.2.3" -} +error: no language version declared in module.cue +-- tidy-check-error -- +no language version declared in module.cue -- cue.mod/module.cue -- module: "main.org@v0" + -- main.cue -- package main diff --git a/internal/mod/modload/testdata/tidy/badimportpath.txtar b/internal/mod/modload/testdata/tidy/badimportpath.txtar index ace2c73e5..e155966c9 100644 --- a/internal/mod/modload/testdata/tidy/badimportpath.txtar +++ b/internal/mod/modload/testdata/tidy/badimportpath.txtar @@ -5,7 +5,7 @@ module is not tidy: cannot find module providing package x.com/Foo--bar@v0 -- want -- error: failed to resolve "x.com/Foo--bar@v0": cannot obtain versions for module "x.com/Foo--bar@v0": module x.com/Foo--bar@v0: invalid OCI request: name invalid: invalid repository name -- cue.mod/module.cue -- -language: version: "v0.99.99" +language: version: "v0.8.0" module: "main.org@v0" -- main.cue -- @@ -14,6 +14,7 @@ import "x.com/Foo--bar@v0" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/x.cue -- package x diff --git a/internal/mod/modload/testdata/tidy/canuseprerelease.txtar b/internal/mod/modload/testdata/tidy/canuseprerelease.txtar index d45bf616c..3ab167e81 100644 --- a/internal/mod/modload/testdata/tidy/canuseprerelease.txtar +++ b/internal/mod/modload/testdata/tidy/canuseprerelease.txtar @@ -6,7 +6,7 @@ module is not tidy: cannot find module providing package example.com@v0 -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.0" } deps: { "example.com@v0": { @@ -15,7 +15,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" -language: version: "v0.99.99" +language: version: "v0.8.0" -- main.cue -- package main @@ -24,12 +24,15 @@ import "example.com@v0" -- _registry/example.com_v0.0.1-foo/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1-foo/top.cue -- package main +language: version: "v0.8.0" -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.3-alpha/top.cue -- package main diff --git a/internal/mod/modload/testdata/tidy/implied-major-version-ambiguity.txtar b/internal/mod/modload/testdata/tidy/implied-major-version-ambiguity.txtar index 2b051f9d0..69cee7602 100644 --- a/internal/mod/modload/testdata/tidy/implied-major-version-ambiguity.txtar +++ b/internal/mod/modload/testdata/tidy/implied-major-version-ambiguity.txtar @@ -10,7 +10,7 @@ error: failed to resolve "example.com/foo": cannot find module providing package module is not tidy: cannot find module providing package example.com/bar@v1 -- cue.mod/module.cue -- module: "main.org@v0" -language: version: "v0.99.99" +language: version: "v0.8.0" -- main.cue -- package main @@ -24,12 +24,14 @@ import "example.com/foo" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/foo/foo.cue -- package foo -- _registry/example.com_v1.0.0/cue.mod/module.cue -- module: "example.com@v1" +language: version: "v0.8.0" -- _registry/example.com_v1.0.0/bar/bar.cue -- package bar diff --git a/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar b/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar index 01e5c1ab1..b8f903fa4 100644 --- a/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar +++ b/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar @@ -3,7 +3,7 @@ -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.0" } deps: { "example.com@v0": { @@ -14,7 +14,7 @@ deps: { -- cue.mod/module.cue -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.0" } deps: { "example.com@v0": { @@ -30,12 +30,14 @@ import "example.com" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.3-alpha/top.cue -- package main diff --git a/internal/mod/modload/testdata/tidy/implied-major-version-without-explicit-default.txtar b/internal/mod/modload/testdata/tidy/implied-major-version-without-explicit-default.txtar index 3051768ab..05ba671f1 100644 --- a/internal/mod/modload/testdata/tidy/implied-major-version-without-explicit-default.txtar +++ b/internal/mod/modload/testdata/tidy/implied-major-version-without-explicit-default.txtar @@ -5,7 +5,7 @@ module is not tidy: cannot find module providing package .* -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.5" } deps: { "example.com@v1": { @@ -16,7 +16,7 @@ deps: { -- cue.mod/module.cue -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.5" } -- main.cue -- package main @@ -25,24 +25,27 @@ import "example.com/foo" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/foo/top.cue -- package foo -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.3-alpha/foo/top.cue -- package foo -- _registry/example.com_v1.0.0/cue.mod/module.cue -- module: "example.com@v1" +language: version: "v0.8.0" -- _registry/example.com_v1.0.0/foo/top.cue -- package foo -- _registry/example.com_v1.2.1-alpha/cue.mod/module.cue -- module: "example.com@v1" - +language: version: "v0.8.0" -- _registry/example.com_v1.2.1-alpha/foo/top.cue -- package foo diff --git a/internal/mod/modload/testdata/tidy/nested-deps.txtar b/internal/mod/modload/testdata/tidy/nested-deps.txtar index 7121d982d..ce858981d 100644 --- a/internal/mod/modload/testdata/tidy/nested-deps.txtar +++ b/internal/mod/modload/testdata/tidy/nested-deps.txtar @@ -6,7 +6,7 @@ module is not tidy: cannot find module providing package example.com.* -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } deps: { "bar.com@v0": { @@ -25,7 +25,7 @@ deps: { -- cue.mod/module.cue -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } deps: { @@ -40,11 +40,13 @@ main -- _registry/unused.org_v0.2.3/cue.mod/module.cue -- module: "unused.org@v0" +language: version: "v0.8.0" -- _registry/unused.org_v0.2.3/top.cue -- package unused -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -60,6 +62,7 @@ main: "main" -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -77,6 +80,7 @@ b -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry/bar.com_v0.0.2/bar/x.cue -- @@ -88,6 +92,7 @@ a -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- @@ -99,6 +104,7 @@ a -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.0.2/baz.cue -- package baz @@ -107,6 +113,7 @@ package baz -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.1.2/baz.cue -- package baz @@ -115,6 +122,7 @@ package baz -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.5.0/baz.cue -- package baz @@ -123,6 +131,7 @@ package baz -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.1/baz.cue -- package baz diff --git a/internal/mod/modload/testdata/tidy/noaddversion.txtar b/internal/mod/modload/testdata/tidy/noaddversion.txtar index f3b6765f9..4b427bdca 100644 --- a/internal/mod/modload/testdata/tidy/noaddversion.txtar +++ b/internal/mod/modload/testdata/tidy/noaddversion.txtar @@ -1,13 +1,13 @@ -# Test that a version is not added if present +# Test that a version is not added or changed if present -- cue-version -- v1.2.3 -- want -- module: "main.org@v0" language: { - version: "v1.0.3" + version: "v0.8.100" } -- cue.mod/module.cue -- module: "main.org@v0" -language: version: "v1.0.3" +language: version: "v0.8.100" -- main.cue -- package main diff --git a/internal/mod/modload/testdata/tidy/packagenotfound.txtar b/internal/mod/modload/testdata/tidy/packagenotfound.txtar index 736209583..57e7981bb 100644 --- a/internal/mod/modload/testdata/tidy/packagenotfound.txtar +++ b/internal/mod/modload/testdata/tidy/packagenotfound.txtar @@ -7,7 +7,7 @@ error: failed to resolve "example.com/nonexistent@v0": cannot find module provid -- cue.mod/module.cue -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } -- main.cue -- @@ -16,6 +16,7 @@ import "example.com/nonexistent@v0" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/x.cue -- package x diff --git a/internal/mod/modload/testdata/tidy/preferstable.txtar b/internal/mod/modload/testdata/tidy/preferstable.txtar index 6fcd42f64..752f39ee1 100644 --- a/internal/mod/modload/testdata/tidy/preferstable.txtar +++ b/internal/mod/modload/testdata/tidy/preferstable.txtar @@ -6,7 +6,7 @@ module is not tidy: cannot find module providing package example.com.* -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } deps: { "example.com@v0": { @@ -16,7 +16,7 @@ deps: { -- cue.mod/module.cue -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } -- main.cue -- @@ -26,12 +26,14 @@ import "example.com@v0" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.3-alpha/top.cue -- package main diff --git a/internal/mod/modload/testdata/tidy/stdlibpackagenotfound.txtar b/internal/mod/modload/testdata/tidy/stdlibpackagenotfound.txtar index 23b83b5f5..1f19ef255 100644 --- a/internal/mod/modload/testdata/tidy/stdlibpackagenotfound.txtar +++ b/internal/mod/modload/testdata/tidy/stdlibpackagenotfound.txtar @@ -4,12 +4,12 @@ -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } -- cue.mod/module.cue -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } -- main.cue -- package main @@ -17,6 +17,7 @@ import "notstdlib/package" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/x.cue -- package x diff --git a/internal/mod/modload/testdata/tidy/tidy-check-fails-with-extra-deps.txtar b/internal/mod/modload/testdata/tidy/tidy-check-fails-with-extra-deps.txtar index d26ecf236..3fcb242e0 100644 --- a/internal/mod/modload/testdata/tidy/tidy-check-fails-with-extra-deps.txtar +++ b/internal/mod/modload/testdata/tidy/tidy-check-fails-with-extra-deps.txtar @@ -6,7 +6,7 @@ module is not tidy -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } deps: { "example.com@v0": { @@ -15,7 +15,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" -language: version: "v0.99.99" +language: version: "v0.8.100" // With a comment. deps: { "example.com@v0": v: "v0.0.1" @@ -30,6 +30,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/internal/mod/modload/testdata/tidy/tidy-with-format-differences.txtar b/internal/mod/modload/testdata/tidy/tidy-with-format-differences.txtar index 324dbe2ad..f1cb3fd8e 100644 --- a/internal/mod/modload/testdata/tidy/tidy-with-format-differences.txtar +++ b/internal/mod/modload/testdata/tidy/tidy-with-format-differences.txtar @@ -4,7 +4,7 @@ -- want -- module: "main.org@v0" language: { - version: "v0.99.99" + version: "v0.8.100" } deps: { "example.com@v0": { @@ -13,7 +13,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" -language: version: "v0.99.99" +language: version: "v0.8.100" // With a comment. deps: "example.com@v0": v: "v0.0.1" @@ -25,6 +25,7 @@ main -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/top.cue -- package main diff --git a/internal/mod/modload/testdata/updateversions/add-latest.txtar b/internal/mod/modload/testdata/updateversions/add-latest.txtar index 6416f904c..685aa2a4a 100644 --- a/internal/mod/modload/testdata/updateversions/add-latest.txtar +++ b/internal/mod/modload/testdata/updateversions/add-latest.txtar @@ -3,6 +3,9 @@ bar.com -- want -- module: "main.org@v0" +language: { + version: "v0.8.0" +} deps: { "bar.com@v0": { v: "v0.5.0" @@ -10,17 +13,20 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" -- main.cue -- package main -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" -- _registry/bar.com_v0.0.2/bar/x.cue -- package bar -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- package bar diff --git a/internal/mod/modload/testdata/updateversions/cannot-downgrade.txtar b/internal/mod/modload/testdata/updateversions/cannot-downgrade.txtar index f09648457..dae1b8d6e 100644 --- a/internal/mod/modload/testdata/updateversions/cannot-downgrade.txtar +++ b/internal/mod/modload/testdata/updateversions/cannot-downgrade.txtar @@ -6,6 +6,7 @@ baz.org@v0.0.2 error: other requirements prevent changing module baz.org@v0 to version v0.0.2 (actual selected version: v0.5.0) -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.5.0" "baz.org@v0": v: "v0.5.0" @@ -15,6 +16,7 @@ package main -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- _registry/bar.com_v0.0.2/bar/x.cue -- @@ -26,6 +28,7 @@ a -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- @@ -37,6 +40,7 @@ a -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.0.2/baz.cue -- package baz @@ -45,6 +49,7 @@ package baz -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.1.2/baz.cue -- package baz @@ -53,6 +58,7 @@ package baz -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.5.0/baz.cue -- package baz @@ -61,6 +67,7 @@ package baz -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- _registry/baz.org_v0.10.1/baz.cue -- package baz diff --git a/internal/mod/modload/testdata/updateversions/downgrade-existing.txtar b/internal/mod/modload/testdata/updateversions/downgrade-existing.txtar index b1c74e1ed..1e99a8b1a 100644 --- a/internal/mod/modload/testdata/updateversions/downgrade-existing.txtar +++ b/internal/mod/modload/testdata/updateversions/downgrade-existing.txtar @@ -4,6 +4,9 @@ bar.com@v0.0.2 -- want -- module: "main.org@v0" +language: { + version: "v0.8.0" +} deps: { "bar.com@v0": { v: "v0.0.2" @@ -11,6 +14,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": { v: "v0.5.0" @@ -21,12 +25,14 @@ package main -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" -- _registry/bar.com_v0.0.2/bar/x.cue -- package bar -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- package bar diff --git a/internal/mod/modload/testdata/updateversions/upgrade-existing.txtar b/internal/mod/modload/testdata/updateversions/upgrade-existing.txtar index f232d950a..3ad85cdef 100644 --- a/internal/mod/modload/testdata/updateversions/upgrade-existing.txtar +++ b/internal/mod/modload/testdata/updateversions/upgrade-existing.txtar @@ -3,6 +3,9 @@ bar.com -- want -- module: "main.org@v0" +language: { + version: "v0.8.0" +} deps: { "bar.com@v0": { v: "v0.5.0" @@ -10,6 +13,7 @@ deps: { } -- cue.mod/module.cue -- module: "main.org@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": { v: "v0.0.2" @@ -20,12 +24,14 @@ package main -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" -- _registry/bar.com_v0.0.2/bar/x.cue -- package bar -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" -- _registry/bar.com_v0.5.0/bar/x.cue -- package bar diff --git a/internal/mod/modpkgload/testdata/localpackageambiguous.txtar b/internal/mod/modpkgload/testdata/localpackageambiguous.txtar index 64a06a769..0b29bb91f 100644 --- a/internal/mod/modpkgload/testdata/localpackageambiguous.txtar +++ b/internal/mod/modpkgload/testdata/localpackageambiguous.txtar @@ -52,5 +52,6 @@ import "example.com/blah" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" -- _registry/example.com_v0.0.1/blah/blah.cue -- package blah diff --git a/internal/mod/modpkgload/testdata/packagegranularity.txtar b/internal/mod/modpkgload/testdata/packagegranularity.txtar index 98730e99b..24b52fcee 100644 --- a/internal/mod/modpkgload/testdata/packagegranularity.txtar +++ b/internal/mod/modpkgload/testdata/packagegranularity.txtar @@ -51,6 +51,7 @@ import "example.com/blah:otherpkg" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -64,6 +65,7 @@ import _ "foo.com/bar/hello/more@v0" -- _registry/foo.com_bar_v0.0.1/cue.mod/module.cue -- module: "foo.com/bar@v0" +language: version: "v0.8.0" -- _registry/foo.com_bar_v0.0.1/hello/goodbye/hello.cue -- package goodbye -- _registry/foo.com_bar_v0.0.1/hello/more diff --git a/internal/mod/modpkgload/testdata/simple.txtar b/internal/mod/modpkgload/testdata/simple.txtar index 6a5795a71..3860c72b6 100644 --- a/internal/mod/modpkgload/testdata/simple.txtar +++ b/internal/mod/modpkgload/testdata/simple.txtar @@ -43,6 +43,7 @@ import "example.com/blah@v0" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" diff --git a/internal/mod/modpkgload/testdata/withdefaultmajorversions.txtar b/internal/mod/modpkgload/testdata/withdefaultmajorversions.txtar index 4de29151a..3b0b874a5 100644 --- a/internal/mod/modpkgload/testdata/withdefaultmajorversions.txtar +++ b/internal/mod/modpkgload/testdata/withdefaultmajorversions.txtar @@ -28,6 +28,7 @@ import "example.com/blah" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" diff --git a/internal/mod/modrequirements/requirements_test.go b/internal/mod/modrequirements/requirements_test.go index 114559a3e..b7ec52baa 100644 --- a/internal/mod/modrequirements/requirements_test.go +++ b/internal/mod/modrequirements/requirements_test.go @@ -21,6 +21,7 @@ func TestRequirements(t *testing.T) { const registryContents = ` -- example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -28,6 +29,7 @@ deps: { -- foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" "baz.org@v0": v: "v0.10.1" @@ -35,23 +37,29 @@ deps: { -- bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.0.2" -- bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.5.0" -- baz.org_v0.0.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- baz.org_v0.5.0/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" ` ctx := context.Background() @@ -98,10 +106,12 @@ func TestRequirementsErrorFromMissingModule(t *testing.T) { const registryContents = ` -- example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" +language: version: "v0.8.0" deps: "foo.com/bar/hello@v0": v: "v0.2.3" -- foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: "bar.com@v0": v: "v0.0.2" // doesn't exist ` ctx := context.Background() diff --git a/internal/registrytest/testdata/simple.txtar b/internal/registrytest/testdata/simple.txtar index 6edf20b0b..3bde89479 100644 --- a/internal/registrytest/testdata/simple.txtar +++ b/internal/registrytest/testdata/simple.txtar @@ -3,7 +3,7 @@ modfile foo.com/bar/hello@v0.2.3 foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" - +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -16,6 +16,7 @@ a main: "main" -- foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- module: "foo.com/bar/hello@v0" +language: version: "v0.8.0" deps: { "bar.com@v0": v: "v0.0.2" @@ -32,6 +33,7 @@ a b -- bar.com_v0.0.2/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" deps: "baz.org@v0": v: "v0.1.2" -- bar.com_v0.0.2/bar/x.cue -- @@ -43,13 +45,16 @@ import a "baz.org/baz" a -- baz.org_v0.10.1/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- baz.org_v0.10.1/baz.cue -- "baz.org@v0": "v0.10.1" -- baz.org_v0.1.2/cue.mod/module.cue -- module: "baz.org@v0" +language: version: "v0.8.0" -- bar.com_v0.5.0/cue.mod/module.cue -- module: "bar.com@v0" +language: version: "v0.8.0" -- bar.com_v0.5.0/bar.cue -- "bar.com@v0": "v0.5.0" diff --git a/mod/modcache/modcache_test.go b/mod/modcache/modcache_test.go index 2ef5496c1..360497ade 100644 --- a/mod/modcache/modcache_test.go +++ b/mod/modcache/modcache_test.go @@ -27,6 +27,7 @@ func TestRequirements(t *testing.T) { r := newRegistry(t, ` -- example.com_foo_v0.0.1/cue.mod/module.cue -- module: "example.com/foo@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" @@ -84,6 +85,7 @@ func TestFetch(t *testing.T) { registryContents := ` -- example.com_foo_v0.0.1/cue.mod/module.cue -- module: "example.com/foo@v0" +language: version: "v0.8.0" deps: { "foo.com/bar/hello@v0": v: "v0.2.3" "bar.com@v0": v: "v0.5.0" diff --git a/mod/modconfig/modconfig_test.go b/mod/modconfig/modconfig_test.go index 16aebb565..49ccfc736 100644 --- a/mod/modconfig/modconfig_test.go +++ b/mod/modconfig/modconfig_test.go @@ -39,11 +39,13 @@ func TestNewRegistry(t *testing.T) { modules := txtar.Parse([]byte(` -- r1/foo.example_v0.0.1/cue.mod/module.cue -- module: "foo.example@v0" +language: version: "v0.8.0" deps: "bar.example@v0": v: "v0.0.1" -- r1/foo.example_v0.0.1/bar/bar.cue -- package bar -- r1/bar.example_v0.0.1/cue.mod/module.cue -- module: "bar.example@v0" +language: version: "v0.8.0" -- r1/bar.example_v0.0.1/y/y.cue -- package y @@ -54,6 +56,7 @@ package y } -- r2/bar.example_v0.0.1/cue.mod/module.cue -- module: "bar.example@v0" +language: version: "v0.8.0" -- r2/bar.example_v0.0.1/x/x.cue -- package x `)) @@ -136,6 +139,7 @@ func TestDefaultTransportSetsUserAgent(t *testing.T) { modules := txtar.Parse([]byte(` -- bar.example_v0.0.1/cue.mod/module.cue -- module: "bar.example@v0" +language: version: "v0.8.0" -- bar.example_v0.0.1/x/x.cue -- package x `)) @@ -191,6 +195,7 @@ func TestConcurrentTokenRefresh(t *testing.T) { fsys := txtarfs.FS(txtar.Parse([]byte(fmt.Sprintf(` -- %s_v0.0.1/cue.mod/module.cue -- module: "%s@v0" +language: version: "v0.8.0" -- %s_v0.0.1/bar/bar.cue -- package bar `, reg.mod, reg.mod, reg.mod)))) diff --git a/mod/modfile/modfile.go b/mod/modfile/modfile.go index 8a1cdba3e..8a2ddbb75 100644 --- a/mod/modfile/modfile.go +++ b/mod/modfile/modfile.go @@ -35,6 +35,7 @@ import ( "cuelang.org/go/cue/format" "cuelang.org/go/cue/parser" "cuelang.org/go/cue/token" + "cuelang.org/go/internal/cueversion" "cuelang.org/go/mod/module" ) @@ -51,6 +52,19 @@ type File struct { // defaultMajorVersions maps from module base path to the // major version default for that path. defaultMajorVersions map[string]string + // actualSchemaVersion holds the actual schema version + // that was used to validate the file. This will be one of the + // entries in the versions field in schema.cue and + // is set by the Parse functions. + actualSchemaVersion string +} + +// baseFileVersion is used to decode the language version +// to decide how to decode the rest of the file. +type baseFileVersion struct { + Language struct { + Version string `json:"version"` + } `json:"language"` } // Source represents how to transform from a module's @@ -88,9 +102,18 @@ func (f *File) Format() ([]byte, error) { // Sanity check that it can be parsed. // TODO this could be more efficient by checking all the file fields // before formatting the output. - if _, err := ParseNonStrict(data, "-"); err != nil { + f1, err := ParseNonStrict(data, "-") + if err != nil { return nil, fmt.Errorf("cannot round-trip module file: %v", strings.TrimSuffix(errors.Details(err, nil), "\n")) } + if f.Language != nil && f1.actualSchemaVersion == "v0.0.0" { + // It's not a legacy module file (because the language field is present) + // but we've used the legacy schema to parse it, which means that + // it's almost certainly a bogus version because all versions + // we care about fail when there are unknown fields, but the + // original schema allowed all fields. + return nil, fmt.Errorf("language version %v is too early for module.cue (need at least %v)", f.Language.Version, earliestClosedSchemaVersion()) + } return data, err } @@ -111,29 +134,39 @@ var ( moduleSchemaOnce sync.Once // guards the creation of _moduleSchema // TODO remove this mutex when https://cuelang.org/issue/2733 is fixed. moduleSchemaMutex sync.Mutex // guards any use of _moduleSchema - _moduleSchema cue.Value + _schemas schemaInfo + _cueContext *cue.Context ) -func moduleSchemaDo[T any](f func(moduleSchema cue.Value) (T, error)) (T, error) { +type schemaInfo struct { + Versions map[string]cue.Value `json:"versions"` + EarliestClosedSchemaVersion string `json:"earliestClosedSchemaVersion"` +} + +func moduleSchemaDo[T any](f func(*cue.Context, *schemaInfo) (T, error)) (T, error) { moduleSchemaOnce.Do(func() { - ctx := cuecontext.New() - schemav := ctx.CompileBytes(moduleSchemaData, cue.Filename("cuelang.org/go/mod/modfile/schema.cue")) - schemav = lookup(schemav, cue.Def("#File")) - //schemav = schemav.Unify(lookup(schemav, cue.Hid("#Strict", "_"))) - if err := schemav.Validate(); err != nil { + _cueContext = cuecontext.New() + schemav := _cueContext.CompileBytes(moduleSchemaData, cue.Filename("cuelang.org/go/mod/modfile/schema.cue")) + if err := schemav.Decode(&_schemas); err != nil { panic(fmt.Errorf("internal error: invalid CUE module.cue schema: %v", errors.Details(err, nil))) } - _moduleSchema = schemav }) moduleSchemaMutex.Lock() defer moduleSchemaMutex.Unlock() - return f(_moduleSchema) + return f(_cueContext, &_schemas) } func lookup(v cue.Value, sels ...cue.Selector) cue.Value { return v.LookupPath(cue.MakePath(sels...)) } +func earliestClosedSchemaVersion() string { + v, _ := moduleSchemaDo(func(ctx *cue.Context, info *schemaInfo) (string, error) { + return info.EarliestClosedSchemaVersion, nil + }) + return v +} + // Parse verifies that the module file has correct syntax. // The file name is used for error messages. // All dependencies must be specified correctly: with major @@ -147,8 +180,8 @@ func Parse(modfile []byte, filename string) (*File, error) { // that only supports the single field "module" and ignores all other // fields. func ParseLegacy(modfile []byte, filename string) (*File, error) { - return moduleSchemaDo(func(schema cue.Value) (*File, error) { - v := schema.Context().CompileBytes(modfile, cue.Filename(filename)) + return moduleSchemaDo(func(ctx *cue.Context, _ *schemaInfo) (*File, error) { + v := ctx.CompileBytes(modfile, cue.Filename(filename)) if err := v.Err(); err != nil { return nil, errors.Wrapf(err, token.NoPos, "invalid module.cue file") } @@ -157,7 +190,8 @@ func ParseLegacy(modfile []byte, filename string) (*File, error) { return nil, newCUEError(err, filename) } return &File{ - Module: f.Module, + Module: f.Module, + actualSchemaVersion: "v0.0.0", }, nil }) } @@ -178,19 +212,69 @@ func parse(modfile []byte, filename string, strict bool) (*File, error) { } // TODO disallow non-data-mode CUE. - mf, err := moduleSchemaDo(func(schema cue.Value) (*File, error) { - v := schema.Context().BuildFile(file) + mf, err := moduleSchemaDo(func(ctx *cue.Context, schemas *schemaInfo) (*File, error) { + v := ctx.BuildFile(file) if err := v.Validate(cue.Concrete(true)); err != nil { return nil, errors.Wrapf(err, token.NoPos, "invalid module.cue file value") } - v = v.Unify(schema) + // First determine the declared version of the module file. + var base baseFileVersion + if err := v.Decode(&base); err != nil { + return nil, errors.Wrapf(err, token.NoPos, "cannot determine language version") + } + if base.Language.Version == "" { + // TODO is something different we could do here? + return nil, fmt.Errorf("no language version declared in module.cue") + } + if !semver.IsValid(base.Language.Version) { + return nil, fmt.Errorf("language version %q in module.cue is not valid semantic version", base.Language.Version) + } + if semver.Compare(base.Language.Version, cueversion.Version()) > 0 { + return nil, fmt.Errorf("language version %q declared in module.cue is too new for current version %q", base.Language.Version, cueversion.Version()) + } + // Now that we're happy we're within bounds, find the latest + // schema that applies to the declared version. + latest := "" + var latestSchema cue.Value + for vers, schema := range schemas.Versions { + if semver.Compare(vers, base.Language.Version) > 0 { + continue + } + if latest == "" || semver.Compare(vers, latest) > 0 { + latest = vers + latestSchema = schema + } + } + if latest == "" { + // Should never happen, because there should always + // be some applicable schema. + return nil, fmt.Errorf("cannot find schema suitable for reading module file with language version %q", base.Language.Version) + } + schema := latestSchema + v = v.Unify(lookup(schema, cue.Def("#File"))) if err := v.Validate(); err != nil { return nil, newCUEError(err, filename) } + if latest == "v0.0.0" { + // The chosen schema is the earliest schema which allowed + // all fields. We don't actually want a module.cue file with + // an old version to treat those fields as special, so don't try + // to decode into *File because that will do so. + // This mirrors the behavior of [ParseLegacy]. + var f noDepsFile + if err := v.Decode(&f); err != nil { + return nil, newCUEError(err, filename) + } + return &File{ + Module: f.Module, + actualSchemaVersion: "v0.0.0", + }, nil + } var mf File if err := v.Decode(&mf); err != nil { return nil, errors.Wrapf(err, token.NoPos, "internal error: cannot decode into modFile struct") } + mf.actualSchemaVersion = latest return &mf, nil }) if err != nil { diff --git a/mod/modfile/modfile_test.go b/mod/modfile/modfile_test.go index 7709216aa..6422b1e74 100644 --- a/mod/modfile/modfile_test.go +++ b/mod/modfile/modfile_test.go @@ -39,9 +39,13 @@ var parseTests = []struct { parse: Parse, data: ` module: "foo.com/bar@v0" +language: version: "v0.8.0" `, want: &File{ Module: "foo.com/bar@v0", + Language: &Language{ + Version: "v0.8.0", + }, }, wantDefaults: map[string]string{ "foo.com/bar": "v0", @@ -50,8 +54,8 @@ module: "foo.com/bar@v0" testName: "WithDeps", parse: Parse, data: ` -language: version: "v0.4.3" module: "foo.com/bar@v0" +language: version: "v0.8.1" deps: "example.com@v1": { default: true v: "v1.2.3" @@ -60,7 +64,7 @@ deps: "other.com/something@v0": v: "v0.2.3" `, want: &File{ Language: &Language{ - Version: "v0.4.3", + Version: "v0.8.1", }, Module: "foo.com/bar@v0", Deps: map[string]*Dep{ @@ -82,13 +86,13 @@ deps: "other.com/something@v0": v: "v0.2.3" testName: "WithSource", parse: Parse, data: ` -language: version: "v0.4.3" module: "foo.com/bar@v0" +language: version: "v0.9.0-alpha.0" source: kind: "git" `, want: &File{ Language: &Language{ - Version: "v0.4.3", + Version: "v0.9.0-alpha.0", }, Module: "foo.com/bar@v0", Source: &Source{ @@ -102,13 +106,13 @@ source: kind: "git" testName: "WithExplicitSource", parse: Parse, data: ` -language: version: "v0.4.3" module: "foo.com/bar@v0" +language: version: "v0.9.0-alpha.0" source: kind: "self" `, want: &File{ Language: &Language{ - Version: "v0.4.3", + Version: "v0.9.0-alpha.0", }, Module: "foo.com/bar@v0", Source: &Source{ @@ -122,24 +126,26 @@ source: kind: "self" testName: "WithUnknownSourceKind", parse: Parse, data: ` -language: version: "v0.4.3" module: "foo.com/bar@v0" +language: version: "v0.9.0-alpha.0" source: kind: "bad" `, - wantError: `source.kind: 2 errors in empty disjunction: -source.kind: conflicting values "git" and "bad": - cuelang.org/go/mod/modfile/schema.cue:45:11 - cuelang.org/go/mod/modfile/schema.cue:166:18 - module.cue:4:15 -source.kind: conflicting values "self" and "bad": - cuelang.org/go/mod/modfile/schema.cue:45:11 - cuelang.org/go/mod/modfile/schema.cue:166:9 - module.cue:4:15`, + wantError: `source.kind: 2 errors in empty disjunction:(.|\n)+`, +}, { + testName: "WithEarlierVersionAndSource", + parse: Parse, + data: ` +module: "foo.com/bar@v0" +language: version: "v0.8.6" +source: kind: "git" +`, + wantError: `source: conflicting values 1 and (.|\n)+`, }, { testName: "AmbiguousDefaults", parse: Parse, data: ` module: "foo.com/bar@v0" +language: version: "v0.8.0" deps: "example.com@v1": { default: true v: "v1.2.3" @@ -155,6 +161,7 @@ deps: "example.com@v2": { parse: Parse, data: ` module: "foo.com/bar@v0" +language: version: "v0.8.0" deps: "foo.com/bar@v1": { default: true v: "v1.2.3" @@ -165,27 +172,31 @@ deps: "foo.com/bar@v1": { testName: "MisspelledLanguageVersionField", parse: Parse, data: ` +module: "foo.com/bar@v0" langugage: version: "v0.4.3" +`, + wantError: `no language version declared in module.cue`, +}, { + testName: "MissingLanguageVersionField", + parse: Parse, + data: ` module: "foo.com/bar@v0" `, - wantError: `langugage: field not allowed: - cuelang.org/go/mod/modfile/schema.cue:28:8 - cuelang.org/go/mod/modfile/schema.cue:30:2 - module.cue:2:1`, + wantError: `no language version declared in module.cue`, }, { testName: "InvalidLanguageVersion", parse: Parse, data: ` language: version: "vblah" module: "foo.com/bar@v0"`, - wantError: `language version "vblah" in module.cue is not well formed`, + wantError: `language version "vblah" in module.cue is not valid semantic version`, }, { testName: "EmptyLanguageVersion", parse: Parse, data: ` language: {} module: "foo.com/bar@v0"`, - wantError: `language version "" in module.cue is not well formed`, + wantError: `no language version declared in module.cue`, }, { testName: "NonCanonicalLanguageVersion", parse: Parse, @@ -199,6 +210,7 @@ language: version: "v0.8" parse: Parse, data: ` module: "foo.com/bar@v1" +language: version: "v0.8.0" deps: "example.com@v1": v: "1.2.3" `, wantError: `invalid module.cue file module.cue: cannot make version from module "example.com@v1", version "1.2.3": version "1.2.3" \(of module "example.com@v1"\) is not well formed`, @@ -207,6 +219,7 @@ deps: "example.com@v1": v: "1.2.3" parse: Parse, data: ` module: "foo.com/bar@v1" +language: version: "v0.8.0" deps: "example.com@v1": v: "v1.2" `, wantError: `invalid module.cue file module.cue: cannot make version from module "example.com@v1", version "v1.2": version "v1.2" \(of module "example.com@v1"\) is not canonical`, @@ -215,6 +228,7 @@ deps: "example.com@v1": v: "v1.2" parse: Parse, data: ` module: "foo.com/bar" +language: version: "v0.8.0" `, wantError: `module path "foo.com/bar" in module.cue does not contain major version`, }, { @@ -222,6 +236,7 @@ module: "foo.com/bar" parse: Parse, data: ` module: "foo.com/bar@v1" +language: version: "v0.8.0" deps: "example.com": v: "v1.2.3" `, wantError: `invalid module.cue file module.cue: no major version in "example.com"`, @@ -230,6 +245,7 @@ deps: "example.com": v: "v1.2.3" parse: Parse, data: ` module: "foo.com/bar@v1" +language: version: "v0.8.0" deps: "example.com@v1": v: "v0.1.2" `, wantError: `invalid module.cue file module.cue: cannot make version from module "example.com@v1", version "v0.1.2": mismatched major version suffix in "example.com@v1" \(version v0.1.2\)`, @@ -238,10 +254,12 @@ deps: "example.com@v1": v: "v0.1.2" parse: ParseNonStrict, data: ` module: "foo.com/bar" +language: version: "v0.8.0" deps: "example.com": v: "v1.2.3" `, want: &File{ - Module: "foo.com/bar@v0", + Module: "foo.com/bar@v0", + Language: &Language{Version: "v0.8.0"}, Deps: map[string]*Dep{ "example.com": { Version: "v1.2.3", @@ -271,7 +289,7 @@ func TestParse(t *testing.T) { f, err := test.parse([]byte(test.data), "module.cue") if test.wantError != "" { gotErr := strings.TrimSuffix(errors.Details(err, nil), "\n") - qt.Assert(t, qt.Matches(gotErr, test.wantError)) + qt.Assert(t, qt.Matches(gotErr, test.wantError), qt.Commentf("error %v", err)) return } qt.Assert(t, qt.IsNil(err), qt.Commentf("details: %v", strings.TrimSuffix(errors.Details(err, nil), "\n"))) @@ -293,7 +311,7 @@ func TestFormat(t *testing.T) { name: "WithLanguage", file: &File{ Language: &Language{ - Version: "v0.4.3", + Version: "v0.8.0", }, Module: "foo.com/bar@v0", Deps: map[string]*Dep{ @@ -307,7 +325,7 @@ func TestFormat(t *testing.T) { }, want: `module: "foo.com/bar@v0" language: { - version: "v0.4.3" + version: "v0.8.0" } deps: { "example.com@v1": { @@ -322,14 +340,23 @@ deps: { file: &File{ Module: "foo.com/bar@v0", Language: &Language{ - Version: "v0.4.3", + Version: "v0.8.0", }, }, want: `module: "foo.com/bar@v0" language: { - version: "v0.4.3" + version: "v0.8.0" } `}, { + name: "WithVersionTooEarly", + file: &File{ + Module: "foo.com/bar@v0", + Language: &Language{ + Version: "v0.4.3", + }, + }, + wantError: `language version v0.4.3 is too early for module.cue \(need at least v0.8.0\)`, + }, { name: "WithInvalidModuleVersion", file: &File{ Module: "foo.com/bar@v0", @@ -337,14 +364,20 @@ language: { Version: "badversion--", }, }, - wantError: `cannot round-trip module file: language version "badversion--" in - is not well formed`, + wantError: `cannot round-trip module file: language version "badversion--" in module.cue is not valid semantic version`, }, { name: "WithNonNilEmptyDeps", file: &File{ Module: "foo.com/bar@v0", - Deps: map[string]*Dep{}, + Language: &Language{ + Version: "v0.8.0", + }, + Deps: map[string]*Dep{}, }, want: `module: "foo.com/bar@v0" +language: { + version: "v0.8.0" +} `, }} cuetest.Run(t, tests, func(t *cuetest.T, test *formatTest) { diff --git a/mod/modfile/schema.cue b/mod/modfile/schema.cue index 2e55d61a0..49f92dd6b 100644 --- a/mod/modfile/schema.cue +++ b/mod/modfile/schema.cue @@ -23,148 +23,123 @@ // to be lost. See https://github.com/cue-lang/cue/issues/2319. let unimplemented = 1&2 - -// #File represents the overarching module file schema. -#File: { - // Reserve fields that are unimplemented for now. - { - deprecated?: unimplemented - retract?: unimplemented - publish?: unimplemented - #Dep: { - exclude?: unimplemented - replace?: unimplemented - replaceAll?: unimplemented - } - } - // module indicates the module's path. - module?: #Module | "" - - // source holds information about the source of the files within the - // module. This field is mandatory at publish time. - source?: #Source - - // version indicates the language version used by the code - // in this module - the minimum version of CUE required - // to evaluate the code in this module. When a later version of CUE - // is evaluating code in this module, this will be used to - // choose version-specific behavior. If an earlier version of CUE - // is used, an error will be given. - language?: version?: #Semver - - // description describes the purpose of this module. - description?: string - - // When present, deprecated indicates that the module - // is deprecated and includes information about that deprecation, ideally - // mentioning an alternative that can be used instead. - // TODO implement this. - deprecated?: string - - // deps holds dependency information for modules, keyed by module path. - deps?: [#Module]: #Dep - - #Dep: { - // TODO use the below when mustexist is implemented. - // replace and replaceAll are mutually exclusive. - //mustexist(<=1, replace, replaceAll) - // There must be at least one field specified for a given module. - //mustexist(>=1, v, exclude, replace, replaceAll) - - // v indicates the minimum required version of the module. - // This can be null if the version is unknown and the module - // entry is only present to be replaced. - v!: #Semver | null - - // default indicates this module is used as a default in case - // more than one major version is specified for the same module - // path. Imports must specify the exact major version for a - // module path if there is more than one major version for that - // path and default is not set for exactly one of them. - // TODO implement this. - default?: bool - - // exclude excludes a set of versions of the module - // TODO implement this. - exclude?: [#Semver]: true - - // replace specifies replacements for specific versions of - // the module. This field is exclusive with replaceAll. - // TODO implement this. - replace?: [#Semver]: #Replacement - - // replaceAll specifies a replacement for all versions of the module. - // This field is exclusive with replace. - // TODO implement this. - replaceAll?: #Replacement +// versions holds an element for each supported version +// of the schema. The version key specifies that +// the schema covers all versions from then until the +// next version present in versions, or until the current CUE version, +// whichever is earlier. +versions: [string]: { + // #File represents the overarching module file schema. + #File!: { + // We always require the language version, as we use + // that to determine how to parse the file itself. + // Note that this schema is not used by [ParseLegacy] + // because legacy module.cue files did not support + // language.version field. + language!: version!: string } + // #Strict can be unified with the top level schema to enforce the strict version + // of the schema required when publishing a module. + #Strict!: _ +} - // retract specifies a set of previously published versions to retract. - // TODO implement this. - retract?: [... #RetractedVersion] - - // The publish section can be used to restrict the scope of a module to prevent - // accidental publishing. - // TODO complete the definition of this and implement it. - publish?: _ - - // #RetractedVersion specifies either a single version - // to retract, or an inclusive range of versions to retract. - #RetractedVersion: #Semver | { - from!: #Semver - // TODO constrain to to be after from? - to!: #Semver +versions: "v0.0.0": { + // Historically all fields were allowed. + #File: { + module?: string + ... } + #Strict: #File +} - // #Replacement specifies a replacement for a module. It can either - // be a reference to a local directory or an alternative module with associated - // version. - #Replacement: string | { - m!: #Module - v!: #Semver - } +// earliestClosedSchemaVersion holds the earliest module.cue schema version +// that excludes unknown fields. +earliestClosedSchemaVersion: "v0.8.0" - // #Module constrains a module path. - // The major version indicator is optional, but should always be present - // in a normalized module.cue file. - #Module: string +versions: (earliestClosedSchemaVersion): { + // Define this version in terms of the later versions + // rather than the other way around, so that + // the latest version is clearest. + versions["v0.9.0-alpha.0"] - // #Semver constrains a semantic version. - #Semver: =~"." + // The source field was added in v0.9.0, so "remove" + // it here by marking it as unimplemented. + #File: source?: unimplemented } -// _#Strict can be unified with the top level schema to enforce the strict version -// of the schema required by the registry. -#Strict: #File & { - // This regular expression is taken from https://semver.org/spec/v2.0.0.html - #Semver: =~#"^v(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"# +versions: "v0.9.0-alpha.0": { + #File: { + // module indicates the module's path. + module?: #Module | "" - // WIP: (([\-_~a-zA-Z0-9][.\-_~a-zA-Z0-9]*[\-_~a-zA-Z0-9])|([\-_~a-zA-Z0-9]))(/([\-_~a-zA-Z0-9][.\-_~a-zA-Z0-9]*[\-_~a-zA-Z0-9])|([\-_~a-zA-Z0-9]))* - #Module: =~#"^[^@]+(@v(0|[1-9]\d*))$"# + // source holds information about the source of the files within the + // module. This field is mandatory at publish time. + source?: #Source - // We don't yet implement local file replacement (specified as a string) - // so require a struct, thus allowing only replacement by some other module. - #Replacement: {...} + // version indicates the language version used by the code + // in this module - the minimum version of CUE required + // to evaluate the code in this module. When a later version of CUE + // is evaluating code in this module, this will be used to + // choose version-specific behavior. If an earlier version of CUE + // is used, an error will be given. + language?: version?: #Semver - // The module declaration is required. - module!: #Module + // description describes the purpose of this module. + description?: string - // No null versions, because no replacements yet. - #Dep: v!: #Semver + // deps holds dependency information for modules, keyed by module path. + deps?: [#Module]: #Dep - // TODO require the CUE version? - // language!: version!: _ -} + #Dep: { + // v indicates the minimum required version of the module. + // This can be null if the version is unknown and the module + // entry is only present to be replaced. + v!: #Semver | null + + // default indicates this module is used as a default in case + // more than one major version is specified for the same module + // path. Imports must specify the exact major version for a + // module path if there is more than one major version for that + // path and default is not set for exactly one of them. + // TODO implement this. + default?: bool + } -// #Source describes a source of truth for a module's content. -#Source: { - // kind specifies the kind of source. - // - // The special value "none" signifies that the module that is - // standalone, associated with no particular source other than - // the contents of the module itself. - kind!: "self" | "git" - - // TODO support for other VCSs: - // kind!: "self" | "git" | "bzr" | "hg" | "svn" -} + // #Module constrains a module path. + // The major version indicator is optional, but should always be present + // in a normalized module.cue file. + #Module: string + + // #Semver constrains a semantic version. + #Semver: =~"." + } + + // #Strict can be unified with the top level schema to enforce the strict version + // of the schema required by the registry. + #Strict: #File & { + // This regular expression is taken from https://semver.org/spec/v2.0.0.html + #Semver: =~#"^v(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"# + + // WIP: (([\-_~a-zA-Z0-9][.\-_~a-zA-Z0-9]*[\-_~a-zA-Z0-9])|([\-_~a-zA-Z0-9]))(/([\-_~a-zA-Z0-9][.\-_~a-zA-Z0-9]*[\-_~a-zA-Z0-9])|([\-_~a-zA-Z0-9]))* + #Module: =~#"^[^@]+(@v(0|[1-9]\d*))$"# + + // The module declaration is required. + module!: #Module + + // No null versions, because no replacements yet. + #Dep: v!: #Semver + } + + // #Source describes a source of truth for a module's content. + #Source: { + // kind specifies the kind of source. + // + // The special value "none" signifies that the module that is + // standalone, associated with no particular source other than + // the contents of the module itself. + kind!: "self" | "git" + + // TODO support for other VCSs: + // kind!: "self" | "git" | "bzr" | "hg" | "svn" + } +} \ No newline at end of file diff --git a/mod/modregistry/client_test.go b/mod/modregistry/client_test.go index b0d07d752..79c823d9a 100644 --- a/mod/modregistry/client_test.go +++ b/mod/modregistry/client_test.go @@ -43,6 +43,7 @@ func TestPutGetModule(t *testing.T) { const testMod = ` -- cue.mod/module.cue -- module: "example.com/module@v1" +language: version: "v0.8.0" -- x.cue -- x: 42 @@ -74,6 +75,7 @@ func TestModuleVersions(t *testing.T) { modContents := fmt.Sprintf(` -- cue.mod/module.cue -- module: %q +language: version: "v0.8.0" -- x.cue -- x: 42 @@ -93,6 +95,7 @@ func TestPutGetWithDependencies(t *testing.T) { const testMod = ` -- cue.mod/module.cue -- module: "foo.com/bar@v0" +language: version: "v0.8.0" deps: "example.com@v1": v: "v1.2.3" deps: "other.com/something@v0": v: "v0.2.3" @@ -128,6 +131,7 @@ func TestGetModuleWithManifest(t *testing.T) { const testMod = ` -- cue.mod/module.cue -- module: "foo.com/bar@v0" +language: version: "v0.8.0" deps: "example.com@v1": v: "v1.2.3" deps: "other.com/something@v0": v: "v0.2.3" @@ -172,6 +176,7 @@ func TestPutWithInvalidDependencyVersion(t *testing.T) { const testMod = ` -- cue.mod/module.cue -- module: "foo.com/bar@v0" +language: version: "v0.8.0" deps: "example.com@v1": v: "v1.2" -- x.cue -- @@ -195,6 +200,7 @@ var checkModuleTests = []struct { content: ` -- cue.mod/module.cue -- module: "foo.com/bar@v0" +language: version: "v0.8.0" `, }, { testName: "MismatchedMajorVersion", @@ -202,6 +208,7 @@ module: "foo.com/bar@v0" content: ` -- cue.mod/module.cue -- module: "foo.com/bar@v1" +language: version: "v0.8.0" `, wantError: `module.cue file check failed: module path "foo.com/bar@v1" found in cue.mod/module.cue does not match module path being published "foo.com/bar@v0"`, }, { @@ -210,6 +217,7 @@ module: "foo.com/bar@v1" content: ` -- cue.mod/module.cue -- module: "foo@v1.2.3" +language: version: "v0.8.0" `, wantError: `module.cue file check failed: module path foo@v1.2.3 in "cue.mod/module.cue" should contain the major version only`, }, { @@ -218,6 +226,7 @@ module: "foo@v1.2.3" content: ` -- cue.mod/module.cue -- module: "foo@v1" +language: version: "v0.8.0" deps: "foo.com/bar@v2": v: "invalid" `, wantError: `module.cue file check failed: invalid module.cue file cue.mod/module.cue: cannot make version from module "foo.com/bar@v2", version "invalid": version "invalid" \(of module "foo.com/bar@v2"\) is not well formed`, -- 2.51.2