this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mod/modfile: parse module.cue according to language.version

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 <rogpeppe@gmail.com>
Change-Id: I7bfef3b37e5b66bdbd8fe0614c1b815c7d9f1285
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193275
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+587 -266
+2 -1
cmd/cue/cmd/testdata/script/cmd_modules.txtar
··· 18 18 } 19 19 -- cue.mod/module.cue -- 20 20 module: "main.example" 21 - 21 + language: version: "v0.8.0" 22 22 deps: "foo.example/text@v0": { 23 23 default: true 24 24 v: "v0.0.1" ··· 27 27 package home 28 28 -- _registry/foo.example_text_v0.0.1/cue.mod/module.cue -- 29 29 module: "foo.example/text@v0" 30 + language: version: "v0.8.0" 30 31 -- _registry/foo.example_text_v0.0.1/text.cue -- 31 32 package text 32 33 value: "world"
+1
cmd/cue/cmd/testdata/script/issue-2945-with-modules.txtar
··· 27 27 28 28 -- cue.mod/module.cue -- 29 29 module: "mod.example@v0" 30 + language: version: "v0.8.0" 30 31 -- x.cue -- 31 32 package x 32 33
+2
cmd/cue/cmd/testdata/script/issue2955.txtar
··· 29 29 30 30 -- cue.mod/module.cue -- 31 31 module: "test.org" 32 + language: version: "v0.8.0" 32 33 -- _registry/auth.json -- 33 34 { 34 35 "useTokenServer": true, ··· 39 40 } 40 41 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 41 42 module: "example.com/e@v0" 43 + language: version: "v0.8.0" 42 44 43 45 -- _registry/example.com_e_v0.0.1/main.cue -- 44 46 package e
+16
cmd/cue/cmd/testdata/script/modedit_initial.txtar
··· 19 19 20 20 -- cue.mod/module.cue -- 21 21 module: "main.org@v0" 22 + language: version: "v0.9.0-alpha.0" 22 23 -- want-module-1 -- 23 24 module: "main.org@v0" 25 + language: { 26 + version: "v0.9.0-alpha.0" 27 + } 24 28 source: { 25 29 kind: "git" 26 30 } 27 31 -- want-module-2 -- 28 32 module: "main.org@v0" 33 + language: { 34 + version: "v0.9.0-alpha.0" 35 + } 29 36 -- want-module-3 -- 30 37 module: "main.org@v0" 38 + language: { 39 + version: "v0.9.0-alpha.0" 40 + } 31 41 deps: { 32 42 "foo.bar@v0": { 33 43 v: "v0.2.3" ··· 37 47 invalid argument "bad-module!" for "--require" flag: invalid module path@version "bad-module!" 38 48 -- want-module-4 -- 39 49 module: "main.org@v0" 50 + language: { 51 + version: "v0.9.0-alpha.0" 52 + } 40 53 -- want-module-5 -- 41 54 module: "othermain.org@v1" 55 + language: { 56 + version: "v0.9.0-alpha.0" 57 + }
+18
cmd/cue/cmd/testdata/script/modget_initial.txtar
··· 45 45 46 46 -- want-module-1 -- 47 47 module: "main.org@v0" 48 + language: { 49 + version: "v0.8.0" 50 + } 48 51 deps: { 49 52 "bar.com@v0": { 50 53 v: "v0.5.0" ··· 70 73 } 71 74 -- want-module-2 -- 72 75 module: "main.org@v0" 76 + language: { 77 + version: "v0.8.0" 78 + } 73 79 deps: { 74 80 "bar.com@v0": { 75 81 v: "v0.5.0" ··· 95 101 } 96 102 -- cue.mod/module.cue -- 97 103 module: "main.org@v0" 104 + language: version: "v0.8.0" 98 105 deps: { 99 106 "bar.com@v0": { 100 107 v: "v0.5.0" ··· 119 126 120 127 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 121 128 module: "example.com@v0" 129 + language: version: "v0.8.0" 122 130 deps: { 123 131 "foo.com/bar/hello@v0": v: "v0.2.3" 124 132 "bar.com@v0": v: "v0.5.0" ··· 134 142 135 143 -- _registry/example.com_v0.1.2/cue.mod/module.cue -- 136 144 module: "example.com@v0" 145 + language: version: "v0.8.0" 137 146 138 147 -- _registry/example.com_v0.1.2/top.cue -- 139 148 package main ··· 146 155 147 156 -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 148 157 module: "foo.com/bar/hello@v0" 158 + language: version: "v0.8.0" 149 159 deps: { 150 160 "bar.com@v0": v: "v0.0.2" 151 161 "baz.org@v0": v: "v0.10.1" ··· 164 174 165 175 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 166 176 module: "bar.com@v0" 177 + language: version: "v0.8.0" 167 178 deps: "baz.org@v0": v: "v0.0.2" 168 179 169 180 -- _registry/bar.com_v0.0.2/bar/x.cue -- ··· 175 186 176 187 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 177 188 module: "bar.com@v0" 189 + language: version: "v0.8.0" 178 190 deps: "baz.org@v0": v: "v0.5.0" 179 191 180 192 -- _registry/bar.com_v0.5.0/bar/x.cue -- ··· 186 198 187 199 -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- 188 200 module: "baz.org@v0" 201 + language: version: "v0.8.0" 189 202 190 203 -- _registry/baz.org_v0.0.2/baz.cue -- 191 204 package baz ··· 194 207 195 208 -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- 196 209 module: "baz.org@v0" 210 + language: version: "v0.8.0" 197 211 198 212 -- _registry/baz.org_v0.1.2/baz.cue -- 199 213 package baz ··· 202 216 203 217 -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- 204 218 module: "baz.org@v0" 219 + language: version: "v0.8.0" 205 220 206 221 -- _registry/baz.org_v0.5.0/baz.cue -- 207 222 package baz ··· 210 225 211 226 -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- 212 227 module: "baz.org@v0" 228 + language: version: "v0.8.0" 213 229 214 230 -- _registry/baz.org_v0.10.1/baz.cue -- 215 231 package baz ··· 218 234 219 235 -- _registry/baz.org_v0.10.2/cue.mod/module.cue -- 220 236 module: "baz.org@v0" 237 + language: version: "v0.8.0" 221 238 222 239 -- _registry/baz.org_v0.10.2/baz.cue -- 223 240 package baz ··· 225 242 226 243 -- _registry/baz.org_v0.11.0-alpha/cue.mod/module.cue -- 227 244 module: "baz.org@v0" 245 + language: version: "v0.8.0" 228 246 229 247 -- _registry/baz.org_v0.11.0-alpha/baz.cue -- 230 248 package baz
+7
cmd/cue/cmd/testdata/script/modget_major_version.txtar
··· 8 8 9 9 -- want-module -- 10 10 module: "main.example@v0" 11 + language: { 12 + version: "v0.8.0" 13 + } 11 14 deps: { 12 15 "foo.org/bar@v2": { 13 16 v: "v2.0.0" ··· 19 22 } 20 23 -- cue.mod/module.cue -- 21 24 module: "main.example" 25 + language: version: "v0.8.0" 22 26 -- main.cue -- 23 27 package main 24 28 import "foo.org/bar" ··· 26 30 27 31 -- _registry/foo.org_bar_v2.0.0/cue.mod/module.cue -- 28 32 module: "foo.org/bar@v2" 33 + language: version: "v0.8.0" 29 34 30 35 -- _registry/foo.org_bar_v2.0.0/bar.cue -- 31 36 package bar ··· 33 38 34 39 -- _registry/foo.org_bar_v1.0.0/cue.mod/module.cue -- 35 40 module: "foo.org/bar@v1" 41 + language: version: "v0.8.0" 36 42 37 43 -- _registry/foo.org_bar_v1.0.0/bar.cue -- 38 44 package bar ··· 40 46 41 47 -- _registry/foo.org_bar_v1.1.0/cue.mod/module.cue -- 42 48 module: "foo.org/bar@v1" 49 + language: version: "v0.8.0" 43 50 44 51 -- _registry/foo.org_bar_v1.1.0/bar.cue -- 45 52 package bar
+3 -3
cmd/cue/cmd/testdata/script/modinit_majorversion.txtar
··· 1 - env CUE_VERSION_OVERRIDE=v0.1.2 1 + env CUE_VERSION_OVERRIDE=v0.8.100 2 2 3 3 # Without the experiment, the major version is allowed, 4 4 # even though it's not particularly useful. ··· 19 19 -- want-module.cue -- 20 20 module: "foo.com/bar@v1" 21 21 language: { 22 - version: "v0.1.2" 22 + version: "v0.8.100" 23 23 } 24 24 -- want-module-experiment.cue -- 25 25 module: "foo.com/bar@v1" 26 26 language: { 27 - version: "v0.1.2" 27 + version: "v0.8.100" 28 28 }
+2 -2
cmd/cue/cmd/testdata/script/modinit_noargs.txtar
··· 1 1 # TODO we might want to deprecate or remove the ability to create 2 2 # module file with an empty module directive. 3 - env CUE_VERSION_OVERRIDE=v0.1.2 3 + env CUE_VERSION_OVERRIDE=v0.8.100 4 4 exec cue mod init 5 5 cmp cue.mod/module.cue want-module.cue 6 6 exists cue.mod/usr ··· 9 9 -- want-module.cue -- 10 10 module: "" 11 11 language: { 12 - version: "v0.1.2" 12 + version: "v0.8.100" 13 13 }
+3 -3
cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar
··· 1 - env CUE_VERSION_OVERRIDE=v0.1.2 1 + env CUE_VERSION_OVERRIDE=v0.8.0 2 2 3 3 # Without the experiment, we use the module path as-is. 4 4 exec cue mod init foo.com/bar ··· 17 17 -- want-module.cue -- 18 18 module: "foo.com/bar" 19 19 language: { 20 - version: "v0.1.2" 20 + version: "v0.8.0" 21 21 } 22 22 -- want-module-experiment.cue -- 23 23 module: "foo.com/bar@v0" 24 24 language: { 25 - version: "v0.1.2" 25 + version: "v0.8.0" 26 26 }
+6 -11
cmd/cue/cmd/testdata/script/modinit_without_version.txtar
··· 1 - # Check that cue mod init skips the language version 2 - # when it lacks any version information at all. 1 + # Check that cue mod init fails when it lacks any version 2 + # information at all. 3 3 # A zero pseudo-version is one such case, as there are no semver numbers. 4 4 env CUE_EXPERIMENT=modules 5 5 env CUE_VERSION_OVERRIDE=v0.0.0-00010101000000-000000000000 6 - exec cue mod init foo.example 7 - cmp cue.mod/module.cue want-module 6 + ! exec cue mod init foo.example 7 + cmp stderr want-stderr 8 8 9 - # cue mod tidy should be a no-op after cue mod init 10 - env CUE_CACHE_DIR=$WORK/.tmp/cache 11 - exec cue mod tidy 12 - cmp cue.mod/module.cue want-module 13 - 14 - -- want-module -- 15 - module: "foo.example@v0" 9 + -- want-stderr -- 10 + cannot round-trip module file: no language version declared in module.cue
+1
cmd/cue/cmd/testdata/script/modpublish_no_source.txtar
··· 9 9 no source field found in cue.mod/module.cue 10 10 -- cue.mod/module.cue -- 11 11 module: "x.example@v1" 12 + language: version: "v0.9.0-alpha.0"
+1
cmd/cue/cmd/testdata/script/modpublish_no_vcs_directory.txtar
··· 7 7 stderr 'git VCS not found in any parent of ".+"' 8 8 -- cue.mod/module.cue -- 9 9 module: "x.example@v1" 10 + language: version: "v0.9.0-alpha.1" 10 11 11 12 source: kind: "git"
+3
cmd/cue/cmd/testdata/script/modtidy_ambiguous_import.txtar
··· 11 11 example.com/foo@v0 v0.1.0 (bar) 12 12 -- cue.mod/module.cue -- 13 13 module: "main.org@v0" 14 + language: version: "v0.8.0" 14 15 15 16 -- main.cue -- 16 17 package main ··· 18 19 19 20 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 20 21 module: "example.com@v0" 22 + language: version: "v0.8.0" 21 23 22 24 -- _registry/example.com_v0.0.1/foo/bar/x.cue -- 23 25 package bar 24 26 25 27 -- _registry/example.com_foo_v0.1.0/cue.mod/module.cue -- 26 28 module: "example.com/foo@v0" 29 + language: version: "v0.8.0" 27 30 28 31 -- _registry/example.com_foo_v0.1.0/bar/x.cue -- 29 32 package bar
+2 -1
cmd/cue/cmd/testdata/script/modtidy_check.txtar
··· 6 6 7 7 -- cue.mod/module.cue -- 8 8 module: "main.org@v0" 9 - language: version: "v0.99.99" 9 + language: version: "v0.8.100" 10 10 11 11 // A comment. 12 12 deps: "example.com@v0": v: "v0.0.1" ··· 19 19 20 20 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 21 21 module: "example.com@v0" 22 + language: version: "v0.8.0" 22 23 23 24 -- _registry/example.com_v0.0.1/top.cue -- 24 25 package main
+2 -1
cmd/cue/cmd/testdata/script/modtidy_check_fail.txtar
··· 7 7 module is not tidy: cannot find module providing package example.com@v0:main 8 8 -- cue.mod/module.cue -- 9 9 module: "main.org@v0" 10 - language: version: "v0.99.99" 10 + language: version: "v0.8.0" 11 11 12 12 -- main.cue -- 13 13 package main ··· 17 17 18 18 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 19 19 module: "example.com@v0" 20 + language: version: "v0.8.0" 20 21 21 22 -- _registry/example.com_v0.0.1/top.cue -- 22 23 package main
+13 -2
cmd/cue/cmd/testdata/script/modtidy_initial.txtar
··· 3 3 # dependencies, and that it removes dependencies that 4 4 # aren't needed any more. 5 5 6 - env CUE_VERSION_OVERRIDE=v0.1.2 6 + env CUE_VERSION_OVERRIDE=v0.8.100 7 7 exec cue mod tidy 8 8 cmp cue.mod/module.cue want-module 9 9 ··· 16 16 -- want-module -- 17 17 module: "main.org@v0" 18 18 language: { 19 - version: "v0.1.2" 19 + version: "v0.8.0" 20 20 } 21 21 deps: { 22 22 "bar.com@v0": { ··· 43 43 } 44 44 -- cue.mod/module.cue -- 45 45 module: "main.org@v0" 46 + language: version: "v0.8.0" 46 47 47 48 deps: "example.com@v0": v: "v0.0.1" 48 49 deps: "unused.com@v0": v: "v0.2.4" ··· 55 56 56 57 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 57 58 module: "example.com@v0" 59 + language: version: "v0.8.0" 58 60 deps: { 59 61 "foo.com/bar/hello@v0": v: "v0.2.3" 60 62 "bar.com@v0": v: "v0.5.0" ··· 70 72 71 73 -- _registry/unused.com_v0.2.4/cue.mod/module.cue -- 72 74 module: "unused.com@v0" 75 + language: version: "v0.8.0" 73 76 74 77 -- _registry/example.com_v0.1.2/cue.mod/module.cue -- 75 78 module: "example.com@v0" 79 + language: version: "v0.8.0" 76 80 77 81 -- _registry/example.com_v0.1.2/top.cue -- 78 82 package main ··· 85 89 86 90 -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 87 91 module: "foo.com/bar/hello@v0" 92 + language: version: "v0.8.0" 88 93 deps: { 89 94 "bar.com@v0": v: "v0.0.2" 90 95 "baz.org@v0": v: "v0.10.1" ··· 103 108 104 109 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 105 110 module: "bar.com@v0" 111 + language: version: "v0.8.0" 106 112 deps: "baz.org@v0": v: "v0.0.2" 107 113 108 114 -- _registry/bar.com_v0.0.2/bar/x.cue -- ··· 114 120 115 121 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 116 122 module: "bar.com@v0" 123 + language: version: "v0.8.0" 117 124 deps: "baz.org@v0": v: "v0.5.0" 118 125 119 126 -- _registry/bar.com_v0.5.0/bar/x.cue -- ··· 125 132 126 133 -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- 127 134 module: "baz.org@v0" 135 + language: version: "v0.8.0" 128 136 129 137 -- _registry/baz.org_v0.0.2/baz.cue -- 130 138 package baz ··· 133 141 134 142 -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- 135 143 module: "baz.org@v0" 144 + language: version: "v0.8.0" 136 145 137 146 -- _registry/baz.org_v0.1.2/baz.cue -- 138 147 package baz ··· 141 150 142 151 -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- 143 152 module: "baz.org@v0" 153 + language: version: "v0.8.0" 144 154 145 155 -- _registry/baz.org_v0.5.0/baz.cue -- 146 156 package baz ··· 149 159 150 160 -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- 151 161 module: "baz.org@v0" 162 + language: version: "v0.8.0" 152 163 153 164 -- _registry/baz.org_v0.10.1/baz.cue -- 154 165 package baz
+2
cmd/cue/cmd/testdata/script/modtidy_logging.txtar
··· 15 15 } 16 16 -- cue.mod/module.cue -- 17 17 module: "main.org@v0" 18 + language: version: "v0.8.0" 18 19 19 20 -- main.cue -- 20 21 package main ··· 25 26 26 27 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 27 28 module: "example.com@v0" 29 + language: version: "v0.8.0" 28 30 29 31 -- _registry/example.com_v0.0.1/top.cue -- 30 32 package main
+4 -2
cmd/cue/cmd/testdata/script/modtidy_non_root.txtar
··· 2 2 # run in the module's root directory. 3 3 4 4 cd x/y 5 - env CUE_VERSION_OVERRIDE=v0.1.2 5 + env CUE_VERSION_OVERRIDE=v0.8.100 6 6 exec cue mod tidy 7 7 cd $WORK 8 8 cmp cue.mod/module.cue want-module ··· 10 10 -- want-module -- 11 11 module: "main.org@v0" 12 12 language: { 13 - version: "v0.1.2" 13 + version: "v0.8.0" 14 14 } 15 15 -- cue.mod/module.cue -- 16 16 module: "main.org@v0" 17 + language: version: "v0.8.0" 17 18 -- x/y/z.cue -- 18 19 package y 19 20 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 20 21 // This file is just here to ensure that CUE_REGISTRY etc is set. 21 22 module: "example.com@v0" 23 + language: version: "v0.8.0"
+4 -3
cmd/cue/cmd/testdata/script/modtidy_with_existing_version.txtar
··· 1 1 # Check that cue mod tidy won't change the language 2 2 # version when the field is already present in the module.cue file. 3 3 4 - env CUE_VERSION_OVERRIDE=v0.9.9 4 + env CUE_VERSION_OVERRIDE=v0.8.300 5 5 exec cue mod tidy 6 6 cmp cue.mod/module.cue want-module 7 7 ··· 16 16 -- want-module -- 17 17 module: "main.org@v0" 18 18 language: { 19 - version: "v0.1.2" 19 + version: "v0.8.100" 20 20 } 21 21 -- cue.mod/module.cue -- 22 22 module: "main.org@v0" 23 23 language: { 24 - version: "v0.1.2" 24 + version: "v0.8.100" 25 25 } 26 26 27 27 -- main.cue -- ··· 30 30 31 31 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 32 32 module: "example.com@v0" 33 + language: version: "v0.8.0" 33 34 34 35 -- _registry/example.com_v0.0.1/top.cue -- 35 36 package main
+4 -2
cmd/cue/cmd/testdata/script/modtidy_with_generated_code.txtar
··· 3 3 # dependencies, and that it removes dependencies that 4 4 # aren't needed any more. 5 5 6 - env CUE_VERSION_OVERRIDE=v0.1.2 6 + env CUE_VERSION_OVERRIDE=v0.8.100 7 7 exec cue mod tidy 8 8 cmp cue.mod/module.cue want-module 9 9 ··· 13 13 -- want-module -- 14 14 module: "main.org@v0" 15 15 language: { 16 - version: "v0.1.2" 16 + version: "v0.8.0" 17 17 } 18 18 deps: { 19 19 "example.com@v0": { ··· 27 27 } 28 28 -- cue.mod/module.cue -- 29 29 module: "main.org@v0" 30 + language: version: "v0.8.0" 30 31 -- cue.mod/gen/foo.com/bar/x.cue -- 31 32 package bar 32 33 bar: "local" ··· 42 43 43 44 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 44 45 module: "example.com@v0" 46 + language: version: "v0.8.0" 45 47 -- _registry/example.com_v0.0.1/top.cue -- 46 48 package main 47 49 "example.com": "v0.0.1"
+5 -8
cmd/cue/cmd/testdata/script/modtidy_with_pseudoversion.txtar cmd/cue/cmd/testdata/script/modinit_with_pseudoversion.txtar
··· 1 - # Check that cue mod tidy chooses a correct base version 1 + # Check that cue mod init chooses a correct base version 2 2 # when provided with a pseudo-version. 3 3 4 - env CUE_VERSION_OVERRIDE=v0.7.1-0.20240130142347-7855e15cb701 5 - exec cue mod tidy 4 + env CUE_VERSION_OVERRIDE=v0.8.20-0.20240130142347-7855e15cb701 5 + exec cue mod init main.org 6 6 cmp cue.mod/module.cue want-module 7 7 8 8 # Check that the resulting module evaluates as expected. ··· 15 15 -- want-module -- 16 16 module: "main.org@v0" 17 17 language: { 18 - version: "v0.7.0" 18 + version: "v0.8.19" 19 19 } 20 - -- cue.mod/module.cue -- 21 - module: "main.org@v0" 22 - 23 20 -- main.cue -- 24 21 package main 25 22 x: 1 26 - 27 23 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 28 24 module: "example.com@v0" 25 + language: version: "v0.8.0" 29 26 30 27 -- _registry/example.com_v0.0.1/top.cue -- 31 28 package main
+8 -23
cmd/cue/cmd/testdata/script/modtidy_with_version.txtar
··· 1 - # Check that cue mod tidy adds the language version to the 2 - # module.cue file when there is one. Note that because 3 - # the version is taken from the build info, we need to use 4 - # the CUE_VERSION_OVERRIDE environment variable. 5 - # We get confidence in the actual buildinfo logic because exactly 6 - # the same code is used behind the scenes for the `cue version` 7 - # implementation too. 1 + # Check that cue mod tidy fails when there is no version 2 + # present in the module.cue file. 8 3 9 - env CUE_VERSION_OVERRIDE=v0.1.2 10 - exec cue mod tidy 11 - cmp cue.mod/module.cue want-module 4 + env CUE_VERSION_OVERRIDE=v0.8.100 5 + ! exec cue mod tidy 6 + cmp stderr want-stderr 12 7 13 - # Check that the resulting module evaluates as expected. 14 - exec cue export . 15 - cmp stdout want-stdout 16 - -- want-stdout -- 17 - { 18 - "x": 1 19 - } 20 - -- want-module -- 21 - module: "main.org@v0" 22 - language: { 23 - version: "v0.1.2" 24 - } 8 + -- want-stderr -- 9 + no language version declared in module.cue 25 10 -- cue.mod/module.cue -- 26 11 module: "main.org@v0" 27 12 ··· 31 16 32 17 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 33 18 module: "example.com@v0" 34 - 19 + language: version: "v0.8.0" 35 20 -- _registry/example.com_v0.0.1/top.cue -- 36 21 package main
+2
cmd/cue/cmd/testdata/script/registry_auth.txtar
··· 57 57 58 58 -- cue.mod/module.cue -- 59 59 module: "test.org" 60 + language: version: "v0.8.0" 60 61 deps: "example.com/e": v: "v0.0.1" 61 62 -- _registry/auth.json -- 62 63 {"username": "someone", "password": "something"} ··· 64 65 somewhere/other 65 66 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 66 67 module: "example.com/e@v0" 68 + language: version: "v0.8.0" 67 69 68 70 -- _registry/example.com_e_v0.0.1/main.cue -- 69 71 package e
+4
cmd/cue/cmd/testdata/script/registry_auth_logins.txtar
··· 65 65 66 66 -- cue.mod/module.cue -- 67 67 module: "test.org" 68 + language: version: "v0.8.0" 68 69 deps: "example.com/e1": v: "v0.0.1" 69 70 deps: "example.com/e2": v: "v0.0.1" 70 71 deps: "example.com/e3": v: "v0.0.1" ··· 74 75 somewhere/other 75 76 -- _registry/example.com_e1_v0.0.1/cue.mod/module.cue -- 76 77 module: "example.com/e1@v0" 78 + language: version: "v0.8.0" 77 79 78 80 -- _registry/example.com_e1_v0.0.1/main.cue -- 79 81 package e1 ··· 81 83 foo: "ok1" 82 84 -- _registry/example.com_e2_v0.0.1/cue.mod/module.cue -- 83 85 module: "example.com/e2@v0" 86 + language: version: "v0.8.0" 84 87 85 88 -- _registry/example.com_e2_v0.0.1/main.cue -- 86 89 package e2 ··· 88 91 foo: "ok2" 89 92 -- _registry/example.com_e3_v0.0.1/cue.mod/module.cue -- 90 93 module: "example.com/e3@v0" 94 + language: version: "v0.8.0" 91 95 92 96 -- _registry/example.com_e3_v0.0.1/main.cue -- 93 97 package e3
+2
cmd/cue/cmd/testdata/script/registry_experiment_not_set.txtar
··· 19 19 deps: "example.com/e": v: "v0.0.1" 20 20 -- cue.mod/pkg/example.com/e/cue.mod/module.cue -- 21 21 module: "example.com/e" 22 + language: version: "v0.8.0" 22 23 -- cue.mod/pkg/example.com/e/main.cue -- 23 24 package e 24 25 foo: "cue.mod/pkg source" 25 26 26 27 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 27 28 module: "example.com/e@v0" 29 + language: version: "v0.8.0" 28 30 29 31 -- _registry/example.com_e_v0.0.1/main.cue -- 30 32 package e
+1
cmd/cue/cmd/testdata/script/registry_import_with_no_modfile.txtar
··· 10 10 11 11 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 12 12 module: "example.com@v0" 13 + language: version: "v0.8.0" 13 14 14 15 -- _registry/example.com_v0.0.1/top.cue -- 15 16 package main
+3
cmd/cue/cmd/testdata/script/registry_lazy_config.txtar
··· 23 23 24 24 -- cue.mod/module.cue -- 25 25 module: "test.org" 26 + language: version: "v0.8.0" 26 27 27 28 -- OTHER/main.cue -- 28 29 package main ··· 31 32 32 33 -- OTHER/cue.mod/module.cue -- 33 34 module: "test.org" 35 + language: version: "v0.8.0" 34 36 deps: "example.com/e": v: "v0.0.1" 35 37 36 38 -- _registry/auth.json -- ··· 39 41 somewhere/other 40 42 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 41 43 module: "example.com/e@v0" 44 + language: version: "v0.8.0" 42 45 43 46 -- _registry/example.com_e_v0.0.1/main.cue -- 44 47 package e
+2
cmd/cue/cmd/testdata/script/registry_local_import_not_found.txtar
··· 5 5 x: 5 6 6 -- cue.mod/module.cue -- 7 7 module: "main.org/foo@v0" 8 + language: version: "v0.8.0" 8 9 -- foo.cue -- 9 10 package foo 10 11 import "main.org/foo/bar" ··· 15 16 16 17 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 17 18 module: "example.com@v0" 19 + language: version: "v0.8.0" 18 20 19 21 -- _registry/example.com_v0.0.1/top.cue -- 20 22 package main
+2
cmd/cue/cmd/testdata/script/registry_module_not_found.txtar
··· 15 15 16 16 -- cue.mod/module.cue -- 17 17 module: "test.org" 18 + language: version: "v0.8.0" 18 19 deps: "example.com/e": v: "v0.0.2" 19 20 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 20 21 module: "example.com/e@v0" 22 + language: version: "v0.8.0" 21 23 22 24 -- _registry/example.com_e_v0.0.1/main.cue -- 23 25 package e
+13
cmd/cue/cmd/testdata/script/registry_mux.txtar
··· 30 30 "example.com@v0": "v0.0.1" 31 31 -- cue.mod/module.cue -- 32 32 module: "main.org@v0" 33 + language: version: "v0.8.0" 33 34 deps: { 34 35 "bar.com@v0": { 35 36 v: "v0.5.0" ··· 57 58 58 59 -- _registry1/example.com_v0.0.1/cue.mod/module.cue -- 59 60 module: "example.com@v0" 61 + language: version: "v0.8.0" 60 62 deps: { 61 63 "foo.com/bar/hello@v0": v: "v0.2.3" 62 64 "bar.com@v0": v: "v0.5.0" ··· 74 76 75 77 -- _registry1/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 76 78 module: "foo.com/bar/hello@v0" 79 + language: version: "v0.8.0" 77 80 deps: { 78 81 "bar.com@v0": v: "v0.0.2" 79 82 "baz.org@v0": v: "v0.10.1" ··· 92 95 93 96 -- _registry1/bar.com_v0.0.2/cue.mod/module.cue -- 94 97 module: "bar.com@v0" 98 + language: version: "v0.8.0" 95 99 deps: "baz.org@v0": v: "v0.0.2" 96 100 97 101 -- _registry1/bar.com_v0.0.2/bar/x.cue -- ··· 103 107 104 108 -- _registry1/bar.com_v0.5.0/cue.mod/module.cue -- 105 109 module: "bar.com@v0" 110 + language: version: "v0.8.0" 106 111 deps: "baz.org@v0": v: "v0.5.0" 107 112 108 113 -- _registry1/bar.com_v0.5.0/bar/x.cue -- ··· 114 119 115 120 -- _registry1/baz.org_v0.0.2/cue.mod/module.cue -- 116 121 module: "baz.org@v0" 122 + language: version: "v0.8.0" 117 123 118 124 -- _registry1/baz.org_v0.0.2/baz.cue -- 119 125 package baz ··· 121 127 122 128 -- _registry1/baz.org_v0.1.2/cue.mod/module.cue -- 123 129 module: "baz.org@v0" 130 + language: version: "v0.8.0" 124 131 125 132 -- _registry1/baz.org_v0.1.2/baz.cue -- 126 133 package baz ··· 129 136 130 137 -- _registry1/baz.org_v0.5.0/cue.mod/module.cue -- 131 138 module: "baz.org@v0" 139 + language: version: "v0.8.0" 132 140 133 141 -- _registry1/baz.org_v0.5.0/baz.cue -- 134 142 package baz ··· 136 144 137 145 -- _registry1/baz.org_v0.10.1/cue.mod/module.cue -- 138 146 module: "baz.org@v0" 147 + language: version: "v0.8.0" 139 148 140 149 -- _registry1/baz.org_v0.10.1/baz.cue -- 141 150 package baz ··· 143 152 144 153 -- _registry2/baz.org_v0.0.2/cue.mod/module.cue -- 145 154 module: "baz.org@v0" 155 + language: version: "v0.8.0" 146 156 147 157 -- _registry2/baz.org_v0.0.2/baz.cue -- 148 158 package baz ··· 150 160 151 161 -- _registry2/baz.org_v0.1.2/cue.mod/module.cue -- 152 162 module: "baz.org@v0" 163 + language: version: "v0.8.0" 153 164 154 165 -- _registry2/baz.org_v0.5.0/cue.mod/module.cue -- 155 166 module: "baz.org@v0" 167 + language: version: "v0.8.0" 156 168 157 169 -- _registry2/baz.org_v0.5.0/baz.cue -- 158 170 package baz ··· 160 172 161 173 -- _registry2/baz.org_v0.10.1/cue.mod/module.cue -- 162 174 module: "baz.org@v0" 175 + language: version: "v0.8.0" 163 176 164 177 -- _registry2/baz.org_v0.10.1/baz.cue -- 165 178 package baz
+13
cmd/cue/cmd/testdata/script/registry_mux_auth.txtar
··· 27 27 } 28 28 -- cue.mod/module.cue -- 29 29 module: "main.org@v0" 30 + language: version: "v0.8.0" 30 31 deps: { 31 32 "bar.com@v0": { 32 33 v: "v0.5.0" ··· 52 53 {"username": "registry1user", "password": "registry1password"} 53 54 -- _registry1/example.com_v0.0.1/cue.mod/module.cue -- 54 55 module: "example.com@v0" 56 + language: version: "v0.8.0" 55 57 deps: { 56 58 "foo.com/bar/hello@v0": v: "v0.2.3" 57 59 "bar.com@v0": v: "v0.5.0" ··· 69 71 70 72 -- _registry1/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 71 73 module: "foo.com/bar/hello@v0" 74 + language: version: "v0.8.0" 72 75 deps: { 73 76 "bar.com@v0": v: "v0.0.2" 74 77 "baz.org@v0": v: "v0.10.1" ··· 87 90 88 91 -- _registry1/bar.com_v0.0.2/cue.mod/module.cue -- 89 92 module: "bar.com@v0" 93 + language: version: "v0.8.0" 90 94 deps: "baz.org@v0": v: "v0.0.2" 91 95 92 96 -- _registry1/bar.com_v0.0.2/bar/x.cue -- ··· 98 102 99 103 -- _registry1/bar.com_v0.5.0/cue.mod/module.cue -- 100 104 module: "bar.com@v0" 105 + language: version: "v0.8.0" 101 106 deps: "baz.org@v0": v: "v0.5.0" 102 107 103 108 -- _registry1/bar.com_v0.5.0/bar/x.cue -- ··· 109 114 110 115 -- _registry1/baz.org_v0.0.2/cue.mod/module.cue -- 111 116 module: "baz.org@v0" 117 + language: version: "v0.8.0" 112 118 113 119 -- _registry1/baz.org_v0.0.2/baz.cue -- 114 120 package baz ··· 116 122 117 123 -- _registry1/baz.org_v0.1.2/cue.mod/module.cue -- 118 124 module: "baz.org@v0" 125 + language: version: "v0.8.0" 119 126 120 127 -- _registry1/baz.org_v0.1.2/baz.cue -- 121 128 package baz ··· 124 131 125 132 -- _registry1/baz.org_v0.5.0/cue.mod/module.cue -- 126 133 module: "baz.org@v0" 134 + language: version: "v0.8.0" 127 135 128 136 -- _registry1/baz.org_v0.5.0/baz.cue -- 129 137 package baz ··· 131 139 132 140 -- _registry1/baz.org_v0.10.1/cue.mod/module.cue -- 133 141 module: "baz.org@v0" 142 + language: version: "v0.8.0" 134 143 135 144 -- _registry1/baz.org_v0.10.1/baz.cue -- 136 145 package baz ··· 141 150 142 151 -- _registry2/baz.org_v0.0.2/cue.mod/module.cue -- 143 152 module: "baz.org@v0" 153 + language: version: "v0.8.0" 144 154 145 155 -- _registry2/baz.org_v0.0.2/baz.cue -- 146 156 package baz ··· 148 158 149 159 -- _registry2/baz.org_v0.1.2/cue.mod/module.cue -- 150 160 module: "baz.org@v0" 161 + language: version: "v0.8.0" 151 162 152 163 -- _registry2/baz.org_v0.5.0/cue.mod/module.cue -- 153 164 module: "baz.org@v0" 165 + language: version: "v0.8.0" 154 166 155 167 -- _registry2/baz.org_v0.5.0/baz.cue -- 156 168 package baz ··· 158 170 159 171 -- _registry2/baz.org_v0.10.1/cue.mod/module.cue -- 160 172 module: "baz.org@v0" 173 + language: version: "v0.8.0" 161 174 162 175 -- _registry2/baz.org_v0.10.1/baz.cue -- 163 176 package baz
+2
cmd/cue/cmd/testdata/script/registry_prefix.txtar
··· 11 11 12 12 -- cue.mod/module.cue -- 13 13 module: "test.org" 14 + language: version: "v0.9.0-alpha.0" 14 15 deps: "example.com/e": v: "v0.0.1" 15 16 -- _registry_prefix -- 16 17 somewhere/other 17 18 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 18 19 module: "example.com/e@v0" 20 + language: version: "v0.9.0-alpha.0" 19 21 20 22 -- _registry/example.com_e_v0.0.1/main.cue -- 21 23 package e
+9
cmd/cue/cmd/testdata/script/registry_publish.txtar
··· 25 25 "example.com@v0": "v0.0.1" 26 26 -- main/cue.mod/module.cue -- 27 27 module: "main.org@v0" 28 + language: version: "v0.9.0-alpha.0" 28 29 29 30 source: kind: "self" 30 31 ··· 46 47 47 48 -- example/cue.mod/module.cue -- 48 49 module: "example.com@v0" 50 + language: version: "v0.9.0-alpha.0" 49 51 source: kind: "self" 50 52 deps: { 51 53 "bar.com@v0": v: "v0.5.0" ··· 65 67 66 68 -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 67 69 module: "foo.com/bar/hello@v0" 70 + language: version: "v0.8.0" 68 71 deps: { 69 72 "bar.com@v0": v: "v0.0.2" 70 73 "baz.org@v0": v: "v0.10.1" ··· 83 86 84 87 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 85 88 module: "bar.com@v0" 89 + language: version: "v0.8.0" 86 90 deps: "baz.org@v0": v: "v0.0.2" 87 91 88 92 -- _registry/bar.com_v0.0.2/bar/x.cue -- ··· 94 98 95 99 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 96 100 module: "bar.com@v0" 101 + language: version: "v0.8.0" 97 102 deps: "baz.org@v0": v: "v0.5.0" 98 103 99 104 -- _registry/bar.com_v0.5.0/bar/x.cue -- ··· 105 110 106 111 -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- 107 112 module: "baz.org@v0" 113 + language: version: "v0.8.0" 108 114 109 115 -- _registry/baz.org_v0.0.2/baz.cue -- 110 116 package baz ··· 113 119 114 120 -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- 115 121 module: "baz.org@v0" 122 + language: version: "v0.8.0" 116 123 117 124 -- _registry/baz.org_v0.1.2/baz.cue -- 118 125 package baz ··· 121 128 122 129 -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- 123 130 module: "baz.org@v0" 131 + language: version: "v0.8.0" 124 132 125 133 -- _registry/baz.org_v0.5.0/baz.cue -- 126 134 package baz ··· 129 137 130 138 -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- 131 139 module: "baz.org@v0" 140 + language: version: "v0.8.0" 132 141 133 142 -- _registry/baz.org_v0.10.1/baz.cue -- 134 143 package baz
+2
cmd/cue/cmd/testdata/script/registry_publish_auth.txtar
··· 32 32 "example.com@v0": "v0.0.1" 33 33 -- main/cue.mod/module.cue -- 34 34 module: "main.org" 35 + language: version: "v0.9.0-alpha.0" 35 36 deps: "example.com@v0": v: "v0.0.1" 36 37 37 38 -- main/main.cue -- ··· 43 44 44 45 -- example/cue.mod/module.cue -- 45 46 module: "example.com@v0" 47 + language: version: "v0.9.0-alpha.0" 46 48 47 49 source: kind: "self" 48 50
+1
cmd/cue/cmd/testdata/script/registry_publish_non_root.txtar
··· 14 14 published example.com@v0.0.1 15 15 -- example/cue.mod/module.cue -- 16 16 module: "example.com@v0" 17 + language: version: "v0.9.0-alpha.0" 17 18 18 19 source: kind: "self" 19 20
+2 -1
cmd/cue/cmd/testdata/script/registry_publish_with_git.txtar
··· 49 49 sensitive: true 50 50 -- main/cue.mod/module.cue -- 51 51 module: "main.org@v0" 52 - 52 + language: version: "v0.9.0-alpha.0" 53 53 source: kind: "self" 54 54 55 55 deps: "x.example/e@v0": v: "v0.0.1" ··· 62 62 63 63 -- example/cuemodule/cue.mod/module.cue -- 64 64 module: "x.example/e@v0" 65 + language: version: "v0.9.0-alpha.0" 65 66 source: kind: "git" 66 67 -- example/.gitignore -- 67 68 /cuemodule/ignored.cue
+9
cmd/cue/cmd/testdata/script/registry_simple.txtar
··· 24 24 } 25 25 -- cue.mod/module.cue -- 26 26 module: "main.org@v0" 27 + language: version: "v0.8.0" 27 28 deps: { 28 29 "bar.com@v0": { 29 30 v: "v0.5.0" ··· 47 48 48 49 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 49 50 module: "example.com@v0" 51 + language: version: "v0.8.0" 50 52 deps: { 51 53 "foo.com/bar/hello@v0": v: "v0.2.3" 52 54 "bar.com@v0": v: "v0.5.0" ··· 64 66 65 67 -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 66 68 module: "foo.com/bar/hello@v0" 69 + language: version: "v0.8.0" 67 70 deps: { 68 71 "bar.com@v0": v: "v0.0.2" 69 72 "baz.org@v0": v: "v0.10.1" ··· 82 85 83 86 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 84 87 module: "bar.com@v0" 88 + language: version: "v0.8.0" 85 89 deps: "baz.org@v0": v: "v0.0.2" 86 90 87 91 -- _registry/bar.com_v0.0.2/bar/x.cue -- ··· 93 97 94 98 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 95 99 module: "bar.com@v0" 100 + language: version: "v0.8.0" 96 101 deps: "baz.org@v0": v: "v0.5.0" 97 102 98 103 -- _registry/bar.com_v0.5.0/bar/x.cue -- ··· 104 109 105 110 -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- 106 111 module: "baz.org@v0" 112 + language: version: "v0.8.0" 107 113 108 114 -- _registry/baz.org_v0.0.2/baz.cue -- 109 115 package baz ··· 112 118 113 119 -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- 114 120 module: "baz.org@v0" 121 + language: version: "v0.8.0" 115 122 116 123 -- _registry/baz.org_v0.1.2/baz.cue -- 117 124 package baz ··· 120 127 121 128 -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- 122 129 module: "baz.org@v0" 130 + language: version: "v0.8.0" 123 131 124 132 -- _registry/baz.org_v0.5.0/baz.cue -- 125 133 package baz ··· 128 136 129 137 -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- 130 138 module: "baz.org@v0" 139 + language: version: "v0.8.0" 131 140 132 141 -- _registry/baz.org_v0.10.1/baz.cue -- 133 142 package baz
+3
cmd/cue/cmd/testdata/script/registry_submodule.txtar
··· 9 9 } 10 10 -- cue.mod/module.cue -- 11 11 module: "main.org" 12 + language: version: "v0.8.0" 12 13 13 14 deps: { 14 15 "example.com@v0": { ··· 32 33 } 33 34 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 34 35 module: "example.com@v0" 36 + language: version: "v0.8.0" 35 37 36 38 -- _registry/example.com_v0.0.1/top.cue -- 37 39 package example ··· 39 41 e: true 40 42 -- _registry/example.com_foo_v0.0.1/cue.mod/module.cue -- 41 43 module: "example.com/foo@v0" 44 + language: version: "v0.8.0" 42 45 -- _registry/example.com_foo_v0.0.1/foo.cue -- 43 46 package foo 44 47 f: true
+2
cmd/cue/cmd/testdata/script/registry_token_auth.txtar
··· 25 25 26 26 -- cue.mod/module.cue -- 27 27 module: "test.org" 28 + language: version: "v0.8.0" 28 29 deps: "example.com/e": v: "v0.0.1" 29 30 -- _registry/auth.json -- 30 31 { ··· 34 35 somewhere/other 35 36 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 36 37 module: "example.com/e@v0" 38 + language: version: "v0.8.0" 37 39 38 40 -- _registry/example.com_e_v0.0.1/main.cue -- 39 41 package e
+2
cmd/cue/cmd/testdata/script/registry_token_auth_tidy.txtar
··· 27 27 28 28 -- cue.mod/module.cue -- 29 29 module: "test.org" 30 + language: version: "v0.8.0" 30 31 -- _registry/auth.json -- 31 32 { 32 33 "useTokenServer": true, ··· 36 37 } 37 38 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 38 39 module: "example.com/e@v0" 40 + language: version: "v0.8.0" 39 41 40 42 -- _registry/example.com_e_v0.0.1/main.cue -- 41 43 package e
+2
cmd/cue/cmd/testdata/script/registry_with_empty_module_path.txtar
··· 6 6 } 7 7 -- cue.mod/module.cue -- 8 8 module: "" 9 + language: version: "v0.8.0" 9 10 -- x.cue -- 10 11 a: 1 11 12 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 12 13 module: "example.com@v0" 14 + language: version: "v0.8.0" 13 15 14 16 -- _registry/example.com_v0.0.1/top.cue -- 15 17 package main
+1
cmd/cue/cmd/testdata/script/registry_with_no_modfile.txtar
··· 8 8 a: 1 9 9 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 10 10 module: "example.com@v0" 11 + language: version: "v0.8.0" 11 12 12 13 -- _registry/example.com_v0.0.1/top.cue -- 13 14 package main
+2
cmd/cue/cmd/testdata/script/registry_with_pkg.txtar
··· 46 46 47 47 -- cue.mod/module.cue -- 48 48 module: "test.org" 49 + language: version: "v0.8.0" 49 50 deps: "example.com/e": v: "v0.0.1" 50 51 51 52 -- cue.mod/pkg/example.com/e/local_pkg/x.cue -- ··· 70 71 71 72 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 72 73 module: "example.com/e@v0" 74 + language: version: "v0.8.0" 73 75 74 76 -- _registry/example.com_e_v0.0.1/main.cue -- 75 77 package e
+3
cmd/cue/cmd/testdata/script/registry_with_pkg_conflict.txtar
··· 18 18 19 19 -- cue.mod/module.cue -- 20 20 module: "test.org" 21 + language: version: "v0.8.0" 21 22 deps: "example.com/e": v: "v0.0.1" 22 23 23 24 -- cue.mod/pkg/example.com/e/cue.mod/module.cue -- 24 25 module: "example.com/e" 26 + language: version: "v0.8.0" 25 27 26 28 -- cue.mod/pkg/example.com/e/main.cue -- 27 29 package e ··· 29 31 30 32 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 31 33 module: "example.com/e@v0" 34 + language: version: "v0.8.0" 32 35 33 36 -- _registry/example.com_e_v0.0.1/main.cue -- 34 37 package e
+2
cmd/cue/cmd/testdata/script/registry_with_remote_gen.txtar
··· 26 26 27 27 -- cue.mod/module.cue -- 28 28 module: "test.org" 29 + language: version: "v0.8.0" 29 30 deps: "example.com/e": v: "v0.0.1" 30 31 31 32 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 32 33 module: "example.com/e@v0" 34 + language: version: "v0.8.0" 33 35 34 36 -- _registry/example.com_e_v0.0.1/main.cue -- 35 37 package e
+2
cmd/cue/cmd/testdata/script/registry_wrong_prefix.txtar
··· 13 13 14 14 -- cue.mod/module.cue -- 15 15 module: "test.org" 16 + language: version: "v0.8.0" 16 17 deps: "example.com/e": v: "v0.0.1" 17 18 -- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- 18 19 module: "example.com/e@v0" 20 + language: version: "v0.8.0" 19 21 20 22 -- _registry/example.com_e_v0.0.1/main.cue -- 21 23 package e
+1
cue/load/example_test.go
··· 127 127 registryArchive := txtar.Parse([]byte(` 128 128 -- foo.example_v0.0.1/cue.mod/module.cue -- 129 129 module: "foo.example@v0" 130 + language: version: "v0.8.0" 130 131 -- foo.example_v0.0.1/bar/bar.cue -- 131 132 package bar 132 133
+1
cue/load/testdata/testfetch/depnotfound.txtar
··· 3 3 ./main.cue:2:8 4 4 -- cue.mod/module.cue -- 5 5 module: "main.org@v0" 6 + language: version: "v0.8.0" 6 7 7 8 deps: "example.com@v0": v: "v0.0.1" 8 9
+1
cue/load/testdata/testfetch/nodeps.txtar
··· 4 4 } 5 5 -- cue.mod/module.cue -- 6 6 module: "main.org" 7 + language: version: "v0.8.0" 7 8 8 9 -- main.cue -- 9 10 package main
+9 -1
cue/load/testdata/testfetch/simple.txtar
··· 8 8 } 9 9 -- cue.mod/module.cue -- 10 10 module: "main.org" 11 - 11 + language: version: "v0.8.0" 12 12 deps: { 13 13 "example.com@v0": v: "v0.0.1" 14 14 "foo.com/bar/hello@v0": v: "v0.2.3" ··· 23 23 24 24 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 25 25 module: "example.com@v0" 26 + language: version: "v0.8.0" 26 27 deps: { 27 28 "foo.com/bar/hello@v0": v: "v0.2.3" 28 29 "bar.com@v0": v: "v0.5.0" ··· 40 41 41 42 -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 42 43 module: "foo.com/bar/hello@v0" 44 + language: version: "v0.8.0" 43 45 deps: { 44 46 "bar.com@v0": v: "v0.0.2" 45 47 "baz.org@v0": v: "v0.10.1" ··· 58 60 59 61 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 60 62 module: "bar.com@v0" 63 + language: version: "v0.8.0" 61 64 deps: "baz.org@v0": v: "v0.0.2" 62 65 63 66 -- _registry/bar.com_v0.0.2/bar/x.cue -- ··· 69 72 70 73 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 71 74 module: "bar.com@v0" 75 + language: version: "v0.8.0" 72 76 deps: "baz.org@v0": v: "v0.5.0" 73 77 74 78 -- _registry/bar.com_v0.5.0/bar/x.cue -- ··· 80 84 81 85 -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- 82 86 module: "baz.org@v0" 87 + language: version: "v0.8.0" 83 88 84 89 -- _registry/baz.org_v0.0.2/baz.cue -- 85 90 package baz ··· 88 93 89 94 -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- 90 95 module: "baz.org@v0" 96 + language: version: "v0.8.0" 91 97 92 98 -- _registry/baz.org_v0.1.2/baz.cue -- 93 99 package baz ··· 96 102 97 103 -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- 98 104 module: "baz.org@v0" 105 + language: version: "v0.8.0" 99 106 100 107 -- _registry/baz.org_v0.5.0/baz.cue -- 101 108 package baz ··· 104 111 105 112 -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- 106 113 module: "baz.org@v0" 114 + language: version: "v0.8.0" 107 115 108 116 -- _registry/baz.org_v0.10.1/baz.cue -- 109 117 package baz
+1 -1
cue/load/testdata/testmod-external/cue.mod/module.cue
··· 1 1 module: "main.example@v0" 2 - 2 + language: version: "v0.8.0" 3 3 deps: "foo.example@v0": v: "v0.0.1"
+1
cue/load/testdata/testmod/cue.mod/module.cue
··· 13 13 // limitations under the License. 14 14 15 15 module: "mod.test/test" 16 + language: version: "v0.8.0"
+5 -7
internal/mod/modload/testdata/tidy/addversion.txtar
··· 1 - # Test that a version is added if not present 1 + # Test that it fails if a version isn't already present. 2 2 -- cue-version -- 3 3 v1.2.3 4 - -- tidy-check-error -- 5 - no language version found in cue.mod/module.cue 6 4 -- want -- 7 - module: "main.org@v0" 8 - language: { 9 - version: "v1.2.3" 10 - } 5 + error: no language version declared in module.cue 6 + -- tidy-check-error -- 7 + no language version declared in module.cue 11 8 -- cue.mod/module.cue -- 12 9 module: "main.org@v0" 10 + 13 11 -- main.cue -- 14 12 package main
+2 -1
internal/mod/modload/testdata/tidy/badimportpath.txtar
··· 5 5 -- want -- 6 6 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 7 7 -- cue.mod/module.cue -- 8 - language: version: "v0.99.99" 8 + language: version: "v0.8.0" 9 9 module: "main.org@v0" 10 10 11 11 -- main.cue -- ··· 14 14 15 15 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 16 16 module: "example.com@v0" 17 + language: version: "v0.8.0" 17 18 18 19 -- _registry/example.com_v0.0.1/x.cue -- 19 20 package x
+5 -2
internal/mod/modload/testdata/tidy/canuseprerelease.txtar
··· 6 6 -- want -- 7 7 module: "main.org@v0" 8 8 language: { 9 - version: "v0.99.99" 9 + version: "v0.8.0" 10 10 } 11 11 deps: { 12 12 "example.com@v0": { ··· 15 15 } 16 16 -- cue.mod/module.cue -- 17 17 module: "main.org@v0" 18 - language: version: "v0.99.99" 18 + language: version: "v0.8.0" 19 19 20 20 -- main.cue -- 21 21 package main ··· 24 24 25 25 -- _registry/example.com_v0.0.1-foo/cue.mod/module.cue -- 26 26 module: "example.com@v0" 27 + language: version: "v0.8.0" 27 28 28 29 -- _registry/example.com_v0.0.1-foo/top.cue -- 29 30 package main 31 + language: version: "v0.8.0" 30 32 31 33 -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- 32 34 module: "example.com@v0" 35 + language: version: "v0.8.0" 33 36 34 37 -- _registry/example.com_v0.0.3-alpha/top.cue -- 35 38 package main
+3 -1
internal/mod/modload/testdata/tidy/implied-major-version-ambiguity.txtar
··· 10 10 module is not tidy: cannot find module providing package example.com/bar@v1 11 11 -- cue.mod/module.cue -- 12 12 module: "main.org@v0" 13 - language: version: "v0.99.99" 13 + language: version: "v0.8.0" 14 14 -- main.cue -- 15 15 package main 16 16 ··· 24 24 25 25 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 26 26 module: "example.com@v0" 27 + language: version: "v0.8.0" 27 28 28 29 -- _registry/example.com_v0.0.1/foo/foo.cue -- 29 30 package foo 30 31 31 32 -- _registry/example.com_v1.0.0/cue.mod/module.cue -- 32 33 module: "example.com@v1" 34 + language: version: "v0.8.0" 33 35 34 36 -- _registry/example.com_v1.0.0/bar/bar.cue -- 35 37 package bar
+4 -2
internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar
··· 3 3 -- want -- 4 4 module: "main.org@v0" 5 5 language: { 6 - version: "v0.99.99" 6 + version: "v0.8.0" 7 7 } 8 8 deps: { 9 9 "example.com@v0": { ··· 14 14 -- cue.mod/module.cue -- 15 15 module: "main.org@v0" 16 16 language: { 17 - version: "v0.99.99" 17 + version: "v0.8.0" 18 18 } 19 19 deps: { 20 20 "example.com@v0": { ··· 30 30 31 31 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 32 32 module: "example.com@v0" 33 + language: version: "v0.8.0" 33 34 34 35 -- _registry/example.com_v0.0.1/top.cue -- 35 36 package main 36 37 37 38 -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- 38 39 module: "example.com@v0" 40 + language: version: "v0.8.0" 39 41 40 42 -- _registry/example.com_v0.0.3-alpha/top.cue -- 41 43 package main
+6 -3
internal/mod/modload/testdata/tidy/implied-major-version-without-explicit-default.txtar
··· 5 5 -- want -- 6 6 module: "main.org@v0" 7 7 language: { 8 - version: "v0.99.99" 8 + version: "v0.8.5" 9 9 } 10 10 deps: { 11 11 "example.com@v1": { ··· 16 16 -- cue.mod/module.cue -- 17 17 module: "main.org@v0" 18 18 language: { 19 - version: "v0.99.99" 19 + version: "v0.8.5" 20 20 } 21 21 -- main.cue -- 22 22 package main ··· 25 25 26 26 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 27 27 module: "example.com@v0" 28 + language: version: "v0.8.0" 28 29 29 30 -- _registry/example.com_v0.0.1/foo/top.cue -- 30 31 package foo 31 32 32 33 -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- 33 34 module: "example.com@v0" 35 + language: version: "v0.8.0" 34 36 35 37 -- _registry/example.com_v0.0.3-alpha/foo/top.cue -- 36 38 package foo 37 39 38 40 -- _registry/example.com_v1.0.0/cue.mod/module.cue -- 39 41 module: "example.com@v1" 42 + language: version: "v0.8.0" 40 43 41 44 -- _registry/example.com_v1.0.0/foo/top.cue -- 42 45 package foo 43 46 44 47 -- _registry/example.com_v1.2.1-alpha/cue.mod/module.cue -- 45 48 module: "example.com@v1" 46 - 49 + language: version: "v0.8.0" 47 50 -- _registry/example.com_v1.2.1-alpha/foo/top.cue -- 48 51 package foo
+11 -2
internal/mod/modload/testdata/tidy/nested-deps.txtar
··· 6 6 -- want -- 7 7 module: "main.org@v0" 8 8 language: { 9 - version: "v0.99.99" 9 + version: "v0.8.100" 10 10 } 11 11 deps: { 12 12 "bar.com@v0": { ··· 25 25 -- cue.mod/module.cue -- 26 26 module: "main.org@v0" 27 27 language: { 28 - version: "v0.99.99" 28 + version: "v0.8.100" 29 29 } 30 30 31 31 deps: { ··· 40 40 41 41 -- _registry/unused.org_v0.2.3/cue.mod/module.cue -- 42 42 module: "unused.org@v0" 43 + language: version: "v0.8.0" 43 44 -- _registry/unused.org_v0.2.3/top.cue -- 44 45 package unused 45 46 46 47 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 47 48 module: "example.com@v0" 49 + language: version: "v0.8.0" 48 50 deps: { 49 51 "foo.com/bar/hello@v0": v: "v0.2.3" 50 52 "bar.com@v0": v: "v0.5.0" ··· 60 62 61 63 -- _registry/foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 62 64 module: "foo.com/bar/hello@v0" 65 + language: version: "v0.8.0" 63 66 deps: { 64 67 "bar.com@v0": v: "v0.0.2" 65 68 "baz.org@v0": v: "v0.10.1" ··· 77 80 78 81 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 79 82 module: "bar.com@v0" 83 + language: version: "v0.8.0" 80 84 deps: "baz.org@v0": v: "v0.0.2" 81 85 82 86 -- _registry/bar.com_v0.0.2/bar/x.cue -- ··· 88 92 89 93 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 90 94 module: "bar.com@v0" 95 + language: version: "v0.8.0" 91 96 deps: "baz.org@v0": v: "v0.5.0" 92 97 93 98 -- _registry/bar.com_v0.5.0/bar/x.cue -- ··· 99 104 100 105 -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- 101 106 module: "baz.org@v0" 107 + language: version: "v0.8.0" 102 108 103 109 -- _registry/baz.org_v0.0.2/baz.cue -- 104 110 package baz ··· 107 113 108 114 -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- 109 115 module: "baz.org@v0" 116 + language: version: "v0.8.0" 110 117 111 118 -- _registry/baz.org_v0.1.2/baz.cue -- 112 119 package baz ··· 115 122 116 123 -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- 117 124 module: "baz.org@v0" 125 + language: version: "v0.8.0" 118 126 119 127 -- _registry/baz.org_v0.5.0/baz.cue -- 120 128 package baz ··· 123 131 124 132 -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- 125 133 module: "baz.org@v0" 134 + language: version: "v0.8.0" 126 135 127 136 -- _registry/baz.org_v0.10.1/baz.cue -- 128 137 package baz
+3 -3
internal/mod/modload/testdata/tidy/noaddversion.txtar
··· 1 - # Test that a version is not added if present 1 + # Test that a version is not added or changed if present 2 2 -- cue-version -- 3 3 v1.2.3 4 4 -- want -- 5 5 module: "main.org@v0" 6 6 language: { 7 - version: "v1.0.3" 7 + version: "v0.8.100" 8 8 } 9 9 -- cue.mod/module.cue -- 10 10 module: "main.org@v0" 11 - language: version: "v1.0.3" 11 + language: version: "v0.8.100" 12 12 -- main.cue -- 13 13 package main
+2 -1
internal/mod/modload/testdata/tidy/packagenotfound.txtar
··· 7 7 -- cue.mod/module.cue -- 8 8 module: "main.org@v0" 9 9 language: { 10 - version: "v0.99.99" 10 + version: "v0.8.100" 11 11 } 12 12 13 13 -- main.cue -- ··· 16 16 17 17 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 18 18 module: "example.com@v0" 19 + language: version: "v0.8.0" 19 20 20 21 -- _registry/example.com_v0.0.1/x.cue -- 21 22 package x
+4 -2
internal/mod/modload/testdata/tidy/preferstable.txtar
··· 6 6 -- want -- 7 7 module: "main.org@v0" 8 8 language: { 9 - version: "v0.99.99" 9 + version: "v0.8.100" 10 10 } 11 11 deps: { 12 12 "example.com@v0": { ··· 16 16 -- cue.mod/module.cue -- 17 17 module: "main.org@v0" 18 18 language: { 19 - version: "v0.99.99" 19 + version: "v0.8.100" 20 20 } 21 21 22 22 -- main.cue -- ··· 26 26 27 27 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 28 28 module: "example.com@v0" 29 + language: version: "v0.8.0" 29 30 30 31 -- _registry/example.com_v0.0.1/top.cue -- 31 32 package main 32 33 33 34 -- _registry/example.com_v0.0.3-alpha/cue.mod/module.cue -- 34 35 module: "example.com@v0" 36 + language: version: "v0.8.0" 35 37 36 38 -- _registry/example.com_v0.0.3-alpha/top.cue -- 37 39 package main
+3 -2
internal/mod/modload/testdata/tidy/stdlibpackagenotfound.txtar
··· 4 4 -- want -- 5 5 module: "main.org@v0" 6 6 language: { 7 - version: "v0.99.99" 7 + version: "v0.8.100" 8 8 } 9 9 -- cue.mod/module.cue -- 10 10 module: "main.org@v0" 11 11 language: { 12 - version: "v0.99.99" 12 + version: "v0.8.100" 13 13 } 14 14 -- main.cue -- 15 15 package main ··· 17 17 18 18 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 19 19 module: "example.com@v0" 20 + language: version: "v0.8.0" 20 21 21 22 -- _registry/example.com_v0.0.1/x.cue -- 22 23 package x
+3 -2
internal/mod/modload/testdata/tidy/tidy-check-fails-with-extra-deps.txtar
··· 6 6 -- want -- 7 7 module: "main.org@v0" 8 8 language: { 9 - version: "v0.99.99" 9 + version: "v0.8.100" 10 10 } 11 11 deps: { 12 12 "example.com@v0": { ··· 15 15 } 16 16 -- cue.mod/module.cue -- 17 17 module: "main.org@v0" 18 - language: version: "v0.99.99" 18 + language: version: "v0.8.100" 19 19 // With a comment. 20 20 deps: { 21 21 "example.com@v0": v: "v0.0.1" ··· 30 30 31 31 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 32 32 module: "example.com@v0" 33 + language: version: "v0.8.0" 33 34 34 35 -- _registry/example.com_v0.0.1/top.cue -- 35 36 package main
+3 -2
internal/mod/modload/testdata/tidy/tidy-with-format-differences.txtar
··· 4 4 -- want -- 5 5 module: "main.org@v0" 6 6 language: { 7 - version: "v0.99.99" 7 + version: "v0.8.100" 8 8 } 9 9 deps: { 10 10 "example.com@v0": { ··· 13 13 } 14 14 -- cue.mod/module.cue -- 15 15 module: "main.org@v0" 16 - language: version: "v0.99.99" 16 + language: version: "v0.8.100" 17 17 // With a comment. 18 18 deps: "example.com@v0": v: "v0.0.1" 19 19 ··· 25 25 26 26 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 27 27 module: "example.com@v0" 28 + language: version: "v0.8.0" 28 29 29 30 -- _registry/example.com_v0.0.1/top.cue -- 30 31 package main
+6
internal/mod/modload/testdata/updateversions/add-latest.txtar
··· 3 3 bar.com 4 4 -- want -- 5 5 module: "main.org@v0" 6 + language: { 7 + version: "v0.8.0" 8 + } 6 9 deps: { 7 10 "bar.com@v0": { 8 11 v: "v0.5.0" ··· 10 13 } 11 14 -- cue.mod/module.cue -- 12 15 module: "main.org@v0" 16 + language: version: "v0.8.0" 13 17 -- main.cue -- 14 18 package main 15 19 16 20 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 17 21 module: "bar.com@v0" 22 + language: version: "v0.8.0" 18 23 19 24 -- _registry/bar.com_v0.0.2/bar/x.cue -- 20 25 package bar 21 26 22 27 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 23 28 module: "bar.com@v0" 29 + language: version: "v0.8.0" 24 30 25 31 -- _registry/bar.com_v0.5.0/bar/x.cue -- 26 32 package bar
+7
internal/mod/modload/testdata/updateversions/cannot-downgrade.txtar
··· 6 6 error: other requirements prevent changing module baz.org@v0 to version v0.0.2 (actual selected version: v0.5.0) 7 7 -- cue.mod/module.cue -- 8 8 module: "main.org@v0" 9 + language: version: "v0.8.0" 9 10 deps: { 10 11 "bar.com@v0": v: "v0.5.0" 11 12 "baz.org@v0": v: "v0.5.0" ··· 15 16 16 17 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 17 18 module: "bar.com@v0" 19 + language: version: "v0.8.0" 18 20 deps: "baz.org@v0": v: "v0.0.2" 19 21 20 22 -- _registry/bar.com_v0.0.2/bar/x.cue -- ··· 26 28 27 29 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 28 30 module: "bar.com@v0" 31 + language: version: "v0.8.0" 29 32 deps: "baz.org@v0": v: "v0.5.0" 30 33 31 34 -- _registry/bar.com_v0.5.0/bar/x.cue -- ··· 37 40 38 41 -- _registry/baz.org_v0.0.2/cue.mod/module.cue -- 39 42 module: "baz.org@v0" 43 + language: version: "v0.8.0" 40 44 41 45 -- _registry/baz.org_v0.0.2/baz.cue -- 42 46 package baz ··· 45 49 46 50 -- _registry/baz.org_v0.1.2/cue.mod/module.cue -- 47 51 module: "baz.org@v0" 52 + language: version: "v0.8.0" 48 53 49 54 -- _registry/baz.org_v0.1.2/baz.cue -- 50 55 package baz ··· 53 58 54 59 -- _registry/baz.org_v0.5.0/cue.mod/module.cue -- 55 60 module: "baz.org@v0" 61 + language: version: "v0.8.0" 56 62 57 63 -- _registry/baz.org_v0.5.0/baz.cue -- 58 64 package baz ··· 61 67 62 68 -- _registry/baz.org_v0.10.1/cue.mod/module.cue -- 63 69 module: "baz.org@v0" 70 + language: version: "v0.8.0" 64 71 65 72 -- _registry/baz.org_v0.10.1/baz.cue -- 66 73 package baz
+6
internal/mod/modload/testdata/updateversions/downgrade-existing.txtar
··· 4 4 bar.com@v0.0.2 5 5 -- want -- 6 6 module: "main.org@v0" 7 + language: { 8 + version: "v0.8.0" 9 + } 7 10 deps: { 8 11 "bar.com@v0": { 9 12 v: "v0.0.2" ··· 11 14 } 12 15 -- cue.mod/module.cue -- 13 16 module: "main.org@v0" 17 + language: version: "v0.8.0" 14 18 deps: { 15 19 "bar.com@v0": { 16 20 v: "v0.5.0" ··· 21 25 22 26 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 23 27 module: "bar.com@v0" 28 + language: version: "v0.8.0" 24 29 25 30 -- _registry/bar.com_v0.0.2/bar/x.cue -- 26 31 package bar 27 32 28 33 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 29 34 module: "bar.com@v0" 35 + language: version: "v0.8.0" 30 36 31 37 -- _registry/bar.com_v0.5.0/bar/x.cue -- 32 38 package bar
+6
internal/mod/modload/testdata/updateversions/upgrade-existing.txtar
··· 3 3 bar.com 4 4 -- want -- 5 5 module: "main.org@v0" 6 + language: { 7 + version: "v0.8.0" 8 + } 6 9 deps: { 7 10 "bar.com@v0": { 8 11 v: "v0.5.0" ··· 10 13 } 11 14 -- cue.mod/module.cue -- 12 15 module: "main.org@v0" 16 + language: version: "v0.8.0" 13 17 deps: { 14 18 "bar.com@v0": { 15 19 v: "v0.0.2" ··· 20 24 21 25 -- _registry/bar.com_v0.0.2/cue.mod/module.cue -- 22 26 module: "bar.com@v0" 27 + language: version: "v0.8.0" 23 28 24 29 -- _registry/bar.com_v0.0.2/bar/x.cue -- 25 30 package bar 26 31 27 32 -- _registry/bar.com_v0.5.0/cue.mod/module.cue -- 28 33 module: "bar.com@v0" 34 + language: version: "v0.8.0" 29 35 30 36 -- _registry/bar.com_v0.5.0/bar/x.cue -- 31 37 package bar
+1
internal/mod/modpkgload/testdata/localpackageambiguous.txtar
··· 52 52 53 53 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 54 54 module: "example.com@v0" 55 + language: version: "v0.8.0" 55 56 -- _registry/example.com_v0.0.1/blah/blah.cue -- 56 57 package blah
+2
internal/mod/modpkgload/testdata/packagegranularity.txtar
··· 51 51 52 52 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 53 53 module: "example.com@v0" 54 + language: version: "v0.8.0" 54 55 deps: { 55 56 "foo.com/bar/hello@v0": v: "v0.2.3" 56 57 "bar.com@v0": v: "v0.5.0" ··· 64 65 65 66 -- _registry/foo.com_bar_v0.0.1/cue.mod/module.cue -- 66 67 module: "foo.com/bar@v0" 68 + language: version: "v0.8.0" 67 69 -- _registry/foo.com_bar_v0.0.1/hello/goodbye/hello.cue -- 68 70 package goodbye 69 71 -- _registry/foo.com_bar_v0.0.1/hello/more
+1
internal/mod/modpkgload/testdata/simple.txtar
··· 43 43 44 44 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 45 45 module: "example.com@v0" 46 + language: version: "v0.8.0" 46 47 deps: { 47 48 "foo.com/bar/hello@v0": v: "v0.2.3" 48 49 "bar.com@v0": v: "v0.5.0"
+1
internal/mod/modpkgload/testdata/withdefaultmajorversions.txtar
··· 28 28 29 29 -- _registry/example.com_v0.0.1/cue.mod/module.cue -- 30 30 module: "example.com@v0" 31 + language: version: "v0.8.0" 31 32 deps: { 32 33 "foo.com/bar/hello@v0": v: "v0.2.3" 33 34 "bar.com@v0": v: "v0.5.0"
+10
internal/mod/modrequirements/requirements_test.go
··· 21 21 const registryContents = ` 22 22 -- example.com_v0.0.1/cue.mod/module.cue -- 23 23 module: "example.com@v0" 24 + language: version: "v0.8.0" 24 25 deps: { 25 26 "foo.com/bar/hello@v0": v: "v0.2.3" 26 27 "bar.com@v0": v: "v0.5.0" ··· 28 29 29 30 -- foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 30 31 module: "foo.com/bar/hello@v0" 32 + language: version: "v0.8.0" 31 33 deps: { 32 34 "bar.com@v0": v: "v0.0.2" 33 35 "baz.org@v0": v: "v0.10.1" ··· 35 37 36 38 -- bar.com_v0.0.2/cue.mod/module.cue -- 37 39 module: "bar.com@v0" 40 + language: version: "v0.8.0" 38 41 deps: "baz.org@v0": v: "v0.0.2" 39 42 40 43 -- bar.com_v0.5.0/cue.mod/module.cue -- 41 44 module: "bar.com@v0" 45 + language: version: "v0.8.0" 42 46 deps: "baz.org@v0": v: "v0.5.0" 43 47 44 48 -- baz.org_v0.0.2/cue.mod/module.cue -- 45 49 module: "baz.org@v0" 50 + language: version: "v0.8.0" 46 51 47 52 -- baz.org_v0.1.2/cue.mod/module.cue -- 48 53 module: "baz.org@v0" 54 + language: version: "v0.8.0" 49 55 50 56 -- baz.org_v0.5.0/cue.mod/module.cue -- 51 57 module: "baz.org@v0" 58 + language: version: "v0.8.0" 52 59 53 60 -- baz.org_v0.10.1/cue.mod/module.cue -- 54 61 module: "baz.org@v0" 62 + language: version: "v0.8.0" 55 63 ` 56 64 57 65 ctx := context.Background() ··· 98 106 const registryContents = ` 99 107 -- example.com_v0.0.1/cue.mod/module.cue -- 100 108 module: "example.com@v0" 109 + language: version: "v0.8.0" 101 110 deps: "foo.com/bar/hello@v0": v: "v0.2.3" 102 111 103 112 -- foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 104 113 module: "foo.com/bar/hello@v0" 114 + language: version: "v0.8.0" 105 115 deps: "bar.com@v0": v: "v0.0.2" // doesn't exist 106 116 ` 107 117 ctx := context.Background()
+6 -1
internal/registrytest/testdata/simple.txtar
··· 3 3 4 4 -- example.com_v0.0.1/cue.mod/module.cue -- 5 5 module: "example.com@v0" 6 - 6 + language: version: "v0.8.0" 7 7 deps: { 8 8 "foo.com/bar/hello@v0": v: "v0.2.3" 9 9 "bar.com@v0": v: "v0.5.0" ··· 16 16 main: "main" 17 17 -- foo.com_bar_hello_v0.2.3/cue.mod/module.cue -- 18 18 module: "foo.com/bar/hello@v0" 19 + language: version: "v0.8.0" 19 20 20 21 deps: { 21 22 "bar.com@v0": v: "v0.0.2" ··· 32 33 b 33 34 -- bar.com_v0.0.2/cue.mod/module.cue -- 34 35 module: "bar.com@v0" 36 + language: version: "v0.8.0" 35 37 36 38 deps: "baz.org@v0": v: "v0.1.2" 37 39 -- bar.com_v0.0.2/bar/x.cue -- ··· 43 45 a 44 46 -- baz.org_v0.10.1/cue.mod/module.cue -- 45 47 module: "baz.org@v0" 48 + language: version: "v0.8.0" 46 49 -- baz.org_v0.10.1/baz.cue -- 47 50 "baz.org@v0": "v0.10.1" 48 51 49 52 -- baz.org_v0.1.2/cue.mod/module.cue -- 50 53 module: "baz.org@v0" 54 + language: version: "v0.8.0" 51 55 52 56 -- bar.com_v0.5.0/cue.mod/module.cue -- 53 57 module: "bar.com@v0" 58 + language: version: "v0.8.0" 54 59 -- bar.com_v0.5.0/bar.cue -- 55 60 "bar.com@v0": "v0.5.0"
+2
mod/modcache/modcache_test.go
··· 27 27 r := newRegistry(t, ` 28 28 -- example.com_foo_v0.0.1/cue.mod/module.cue -- 29 29 module: "example.com/foo@v0" 30 + language: version: "v0.8.0" 30 31 deps: { 31 32 "foo.com/bar/hello@v0": v: "v0.2.3" 32 33 "bar.com@v0": v: "v0.5.0" ··· 84 85 registryContents := ` 85 86 -- example.com_foo_v0.0.1/cue.mod/module.cue -- 86 87 module: "example.com/foo@v0" 88 + language: version: "v0.8.0" 87 89 deps: { 88 90 "foo.com/bar/hello@v0": v: "v0.2.3" 89 91 "bar.com@v0": v: "v0.5.0"
+5
mod/modconfig/modconfig_test.go
··· 39 39 modules := txtar.Parse([]byte(` 40 40 -- r1/foo.example_v0.0.1/cue.mod/module.cue -- 41 41 module: "foo.example@v0" 42 + language: version: "v0.8.0" 42 43 deps: "bar.example@v0": v: "v0.0.1" 43 44 -- r1/foo.example_v0.0.1/bar/bar.cue -- 44 45 package bar 45 46 -- r1/bar.example_v0.0.1/cue.mod/module.cue -- 46 47 module: "bar.example@v0" 48 + language: version: "v0.8.0" 47 49 -- r1/bar.example_v0.0.1/y/y.cue -- 48 50 package y 49 51 ··· 54 56 } 55 57 -- r2/bar.example_v0.0.1/cue.mod/module.cue -- 56 58 module: "bar.example@v0" 59 + language: version: "v0.8.0" 57 60 -- r2/bar.example_v0.0.1/x/x.cue -- 58 61 package x 59 62 `)) ··· 136 139 modules := txtar.Parse([]byte(` 137 140 -- bar.example_v0.0.1/cue.mod/module.cue -- 138 141 module: "bar.example@v0" 142 + language: version: "v0.8.0" 139 143 -- bar.example_v0.0.1/x/x.cue -- 140 144 package x 141 145 `)) ··· 191 195 fsys := txtarfs.FS(txtar.Parse([]byte(fmt.Sprintf(` 192 196 -- %s_v0.0.1/cue.mod/module.cue -- 193 197 module: "%s@v0" 198 + language: version: "v0.8.0" 194 199 -- %s_v0.0.1/bar/bar.cue -- 195 200 package bar 196 201 `, reg.mod, reg.mod, reg.mod))))
+100 -16
mod/modfile/modfile.go
··· 35 35 "cuelang.org/go/cue/format" 36 36 "cuelang.org/go/cue/parser" 37 37 "cuelang.org/go/cue/token" 38 + "cuelang.org/go/internal/cueversion" 38 39 "cuelang.org/go/mod/module" 39 40 ) 40 41 ··· 51 52 // defaultMajorVersions maps from module base path to the 52 53 // major version default for that path. 53 54 defaultMajorVersions map[string]string 55 + // actualSchemaVersion holds the actual schema version 56 + // that was used to validate the file. This will be one of the 57 + // entries in the versions field in schema.cue and 58 + // is set by the Parse functions. 59 + actualSchemaVersion string 60 + } 61 + 62 + // baseFileVersion is used to decode the language version 63 + // to decide how to decode the rest of the file. 64 + type baseFileVersion struct { 65 + Language struct { 66 + Version string `json:"version"` 67 + } `json:"language"` 54 68 } 55 69 56 70 // Source represents how to transform from a module's ··· 88 102 // Sanity check that it can be parsed. 89 103 // TODO this could be more efficient by checking all the file fields 90 104 // before formatting the output. 91 - if _, err := ParseNonStrict(data, "-"); err != nil { 105 + f1, err := ParseNonStrict(data, "-") 106 + if err != nil { 92 107 return nil, fmt.Errorf("cannot round-trip module file: %v", strings.TrimSuffix(errors.Details(err, nil), "\n")) 108 + } 109 + if f.Language != nil && f1.actualSchemaVersion == "v0.0.0" { 110 + // It's not a legacy module file (because the language field is present) 111 + // but we've used the legacy schema to parse it, which means that 112 + // it's almost certainly a bogus version because all versions 113 + // we care about fail when there are unknown fields, but the 114 + // original schema allowed all fields. 115 + return nil, fmt.Errorf("language version %v is too early for module.cue (need at least %v)", f.Language.Version, earliestClosedSchemaVersion()) 93 116 } 94 117 return data, err 95 118 } ··· 111 134 moduleSchemaOnce sync.Once // guards the creation of _moduleSchema 112 135 // TODO remove this mutex when https://cuelang.org/issue/2733 is fixed. 113 136 moduleSchemaMutex sync.Mutex // guards any use of _moduleSchema 114 - _moduleSchema cue.Value 137 + _schemas schemaInfo 138 + _cueContext *cue.Context 115 139 ) 116 140 117 - func moduleSchemaDo[T any](f func(moduleSchema cue.Value) (T, error)) (T, error) { 141 + type schemaInfo struct { 142 + Versions map[string]cue.Value `json:"versions"` 143 + EarliestClosedSchemaVersion string `json:"earliestClosedSchemaVersion"` 144 + } 145 + 146 + func moduleSchemaDo[T any](f func(*cue.Context, *schemaInfo) (T, error)) (T, error) { 118 147 moduleSchemaOnce.Do(func() { 119 - ctx := cuecontext.New() 120 - schemav := ctx.CompileBytes(moduleSchemaData, cue.Filename("cuelang.org/go/mod/modfile/schema.cue")) 121 - schemav = lookup(schemav, cue.Def("#File")) 122 - //schemav = schemav.Unify(lookup(schemav, cue.Hid("#Strict", "_"))) 123 - if err := schemav.Validate(); err != nil { 148 + _cueContext = cuecontext.New() 149 + schemav := _cueContext.CompileBytes(moduleSchemaData, cue.Filename("cuelang.org/go/mod/modfile/schema.cue")) 150 + if err := schemav.Decode(&_schemas); err != nil { 124 151 panic(fmt.Errorf("internal error: invalid CUE module.cue schema: %v", errors.Details(err, nil))) 125 152 } 126 - _moduleSchema = schemav 127 153 }) 128 154 moduleSchemaMutex.Lock() 129 155 defer moduleSchemaMutex.Unlock() 130 - return f(_moduleSchema) 156 + return f(_cueContext, &_schemas) 131 157 } 132 158 133 159 func lookup(v cue.Value, sels ...cue.Selector) cue.Value { 134 160 return v.LookupPath(cue.MakePath(sels...)) 135 161 } 136 162 163 + func earliestClosedSchemaVersion() string { 164 + v, _ := moduleSchemaDo(func(ctx *cue.Context, info *schemaInfo) (string, error) { 165 + return info.EarliestClosedSchemaVersion, nil 166 + }) 167 + return v 168 + } 169 + 137 170 // Parse verifies that the module file has correct syntax. 138 171 // The file name is used for error messages. 139 172 // All dependencies must be specified correctly: with major ··· 147 180 // that only supports the single field "module" and ignores all other 148 181 // fields. 149 182 func ParseLegacy(modfile []byte, filename string) (*File, error) { 150 - return moduleSchemaDo(func(schema cue.Value) (*File, error) { 151 - v := schema.Context().CompileBytes(modfile, cue.Filename(filename)) 183 + return moduleSchemaDo(func(ctx *cue.Context, _ *schemaInfo) (*File, error) { 184 + v := ctx.CompileBytes(modfile, cue.Filename(filename)) 152 185 if err := v.Err(); err != nil { 153 186 return nil, errors.Wrapf(err, token.NoPos, "invalid module.cue file") 154 187 } ··· 157 190 return nil, newCUEError(err, filename) 158 191 } 159 192 return &File{ 160 - Module: f.Module, 193 + Module: f.Module, 194 + actualSchemaVersion: "v0.0.0", 161 195 }, nil 162 196 }) 163 197 } ··· 178 212 } 179 213 // TODO disallow non-data-mode CUE. 180 214 181 - mf, err := moduleSchemaDo(func(schema cue.Value) (*File, error) { 182 - v := schema.Context().BuildFile(file) 215 + mf, err := moduleSchemaDo(func(ctx *cue.Context, schemas *schemaInfo) (*File, error) { 216 + v := ctx.BuildFile(file) 183 217 if err := v.Validate(cue.Concrete(true)); err != nil { 184 218 return nil, errors.Wrapf(err, token.NoPos, "invalid module.cue file value") 185 219 } 186 - v = v.Unify(schema) 220 + // First determine the declared version of the module file. 221 + var base baseFileVersion 222 + if err := v.Decode(&base); err != nil { 223 + return nil, errors.Wrapf(err, token.NoPos, "cannot determine language version") 224 + } 225 + if base.Language.Version == "" { 226 + // TODO is something different we could do here? 227 + return nil, fmt.Errorf("no language version declared in module.cue") 228 + } 229 + if !semver.IsValid(base.Language.Version) { 230 + return nil, fmt.Errorf("language version %q in module.cue is not valid semantic version", base.Language.Version) 231 + } 232 + if semver.Compare(base.Language.Version, cueversion.Version()) > 0 { 233 + return nil, fmt.Errorf("language version %q declared in module.cue is too new for current version %q", base.Language.Version, cueversion.Version()) 234 + } 235 + // Now that we're happy we're within bounds, find the latest 236 + // schema that applies to the declared version. 237 + latest := "" 238 + var latestSchema cue.Value 239 + for vers, schema := range schemas.Versions { 240 + if semver.Compare(vers, base.Language.Version) > 0 { 241 + continue 242 + } 243 + if latest == "" || semver.Compare(vers, latest) > 0 { 244 + latest = vers 245 + latestSchema = schema 246 + } 247 + } 248 + if latest == "" { 249 + // Should never happen, because there should always 250 + // be some applicable schema. 251 + return nil, fmt.Errorf("cannot find schema suitable for reading module file with language version %q", base.Language.Version) 252 + } 253 + schema := latestSchema 254 + v = v.Unify(lookup(schema, cue.Def("#File"))) 187 255 if err := v.Validate(); err != nil { 188 256 return nil, newCUEError(err, filename) 189 257 } 258 + if latest == "v0.0.0" { 259 + // The chosen schema is the earliest schema which allowed 260 + // all fields. We don't actually want a module.cue file with 261 + // an old version to treat those fields as special, so don't try 262 + // to decode into *File because that will do so. 263 + // This mirrors the behavior of [ParseLegacy]. 264 + var f noDepsFile 265 + if err := v.Decode(&f); err != nil { 266 + return nil, newCUEError(err, filename) 267 + } 268 + return &File{ 269 + Module: f.Module, 270 + actualSchemaVersion: "v0.0.0", 271 + }, nil 272 + } 190 273 var mf File 191 274 if err := v.Decode(&mf); err != nil { 192 275 return nil, errors.Wrapf(err, token.NoPos, "internal error: cannot decode into modFile struct") 193 276 } 277 + mf.actualSchemaVersion = latest 194 278 return &mf, nil 195 279 }) 196 280 if err != nil {
+63 -30
mod/modfile/modfile_test.go
··· 39 39 parse: Parse, 40 40 data: ` 41 41 module: "foo.com/bar@v0" 42 + language: version: "v0.8.0" 42 43 `, 43 44 want: &File{ 44 45 Module: "foo.com/bar@v0", 46 + Language: &Language{ 47 + Version: "v0.8.0", 48 + }, 45 49 }, 46 50 wantDefaults: map[string]string{ 47 51 "foo.com/bar": "v0", ··· 50 54 testName: "WithDeps", 51 55 parse: Parse, 52 56 data: ` 53 - language: version: "v0.4.3" 54 57 module: "foo.com/bar@v0" 58 + language: version: "v0.8.1" 55 59 deps: "example.com@v1": { 56 60 default: true 57 61 v: "v1.2.3" ··· 60 64 `, 61 65 want: &File{ 62 66 Language: &Language{ 63 - Version: "v0.4.3", 67 + Version: "v0.8.1", 64 68 }, 65 69 Module: "foo.com/bar@v0", 66 70 Deps: map[string]*Dep{ ··· 82 86 testName: "WithSource", 83 87 parse: Parse, 84 88 data: ` 85 - language: version: "v0.4.3" 86 89 module: "foo.com/bar@v0" 90 + language: version: "v0.9.0-alpha.0" 87 91 source: kind: "git" 88 92 `, 89 93 want: &File{ 90 94 Language: &Language{ 91 - Version: "v0.4.3", 95 + Version: "v0.9.0-alpha.0", 92 96 }, 93 97 Module: "foo.com/bar@v0", 94 98 Source: &Source{ ··· 102 106 testName: "WithExplicitSource", 103 107 parse: Parse, 104 108 data: ` 105 - language: version: "v0.4.3" 106 109 module: "foo.com/bar@v0" 110 + language: version: "v0.9.0-alpha.0" 107 111 source: kind: "self" 108 112 `, 109 113 want: &File{ 110 114 Language: &Language{ 111 - Version: "v0.4.3", 115 + Version: "v0.9.0-alpha.0", 112 116 }, 113 117 Module: "foo.com/bar@v0", 114 118 Source: &Source{ ··· 122 126 testName: "WithUnknownSourceKind", 123 127 parse: Parse, 124 128 data: ` 125 - language: version: "v0.4.3" 126 129 module: "foo.com/bar@v0" 130 + language: version: "v0.9.0-alpha.0" 127 131 source: kind: "bad" 128 132 `, 129 - wantError: `source.kind: 2 errors in empty disjunction: 130 - source.kind: conflicting values "git" and "bad": 131 - cuelang.org/go/mod/modfile/schema.cue:45:11 132 - cuelang.org/go/mod/modfile/schema.cue:166:18 133 - module.cue:4:15 134 - source.kind: conflicting values "self" and "bad": 135 - cuelang.org/go/mod/modfile/schema.cue:45:11 136 - cuelang.org/go/mod/modfile/schema.cue:166:9 137 - module.cue:4:15`, 133 + wantError: `source.kind: 2 errors in empty disjunction:(.|\n)+`, 134 + }, { 135 + testName: "WithEarlierVersionAndSource", 136 + parse: Parse, 137 + data: ` 138 + module: "foo.com/bar@v0" 139 + language: version: "v0.8.6" 140 + source: kind: "git" 141 + `, 142 + wantError: `source: conflicting values 1 and (.|\n)+`, 138 143 }, { 139 144 testName: "AmbiguousDefaults", 140 145 parse: Parse, 141 146 data: ` 142 147 module: "foo.com/bar@v0" 148 + language: version: "v0.8.0" 143 149 deps: "example.com@v1": { 144 150 default: true 145 151 v: "v1.2.3" ··· 155 161 parse: Parse, 156 162 data: ` 157 163 module: "foo.com/bar@v0" 164 + language: version: "v0.8.0" 158 165 deps: "foo.com/bar@v1": { 159 166 default: true 160 167 v: "v1.2.3" ··· 165 172 testName: "MisspelledLanguageVersionField", 166 173 parse: Parse, 167 174 data: ` 175 + module: "foo.com/bar@v0" 168 176 langugage: version: "v0.4.3" 177 + `, 178 + wantError: `no language version declared in module.cue`, 179 + }, { 180 + testName: "MissingLanguageVersionField", 181 + parse: Parse, 182 + data: ` 169 183 module: "foo.com/bar@v0" 170 184 `, 171 - wantError: `langugage: field not allowed: 172 - cuelang.org/go/mod/modfile/schema.cue:28:8 173 - cuelang.org/go/mod/modfile/schema.cue:30:2 174 - module.cue:2:1`, 185 + wantError: `no language version declared in module.cue`, 175 186 }, { 176 187 testName: "InvalidLanguageVersion", 177 188 parse: Parse, 178 189 data: ` 179 190 language: version: "vblah" 180 191 module: "foo.com/bar@v0"`, 181 - wantError: `language version "vblah" in module.cue is not well formed`, 192 + wantError: `language version "vblah" in module.cue is not valid semantic version`, 182 193 }, { 183 194 testName: "EmptyLanguageVersion", 184 195 parse: Parse, 185 196 data: ` 186 197 language: {} 187 198 module: "foo.com/bar@v0"`, 188 - wantError: `language version "" in module.cue is not well formed`, 199 + wantError: `no language version declared in module.cue`, 189 200 }, { 190 201 testName: "NonCanonicalLanguageVersion", 191 202 parse: Parse, ··· 199 210 parse: Parse, 200 211 data: ` 201 212 module: "foo.com/bar@v1" 213 + language: version: "v0.8.0" 202 214 deps: "example.com@v1": v: "1.2.3" 203 215 `, 204 216 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 219 parse: Parse, 208 220 data: ` 209 221 module: "foo.com/bar@v1" 222 + language: version: "v0.8.0" 210 223 deps: "example.com@v1": v: "v1.2" 211 224 `, 212 225 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 228 parse: Parse, 216 229 data: ` 217 230 module: "foo.com/bar" 231 + language: version: "v0.8.0" 218 232 `, 219 233 wantError: `module path "foo.com/bar" in module.cue does not contain major version`, 220 234 }, { ··· 222 236 parse: Parse, 223 237 data: ` 224 238 module: "foo.com/bar@v1" 239 + language: version: "v0.8.0" 225 240 deps: "example.com": v: "v1.2.3" 226 241 `, 227 242 wantError: `invalid module.cue file module.cue: no major version in "example.com"`, ··· 230 245 parse: Parse, 231 246 data: ` 232 247 module: "foo.com/bar@v1" 248 + language: version: "v0.8.0" 233 249 deps: "example.com@v1": v: "v0.1.2" 234 250 `, 235 251 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 254 parse: ParseNonStrict, 239 255 data: ` 240 256 module: "foo.com/bar" 257 + language: version: "v0.8.0" 241 258 deps: "example.com": v: "v1.2.3" 242 259 `, 243 260 want: &File{ 244 - Module: "foo.com/bar@v0", 261 + Module: "foo.com/bar@v0", 262 + Language: &Language{Version: "v0.8.0"}, 245 263 Deps: map[string]*Dep{ 246 264 "example.com": { 247 265 Version: "v1.2.3", ··· 271 289 f, err := test.parse([]byte(test.data), "module.cue") 272 290 if test.wantError != "" { 273 291 gotErr := strings.TrimSuffix(errors.Details(err, nil), "\n") 274 - qt.Assert(t, qt.Matches(gotErr, test.wantError)) 292 + qt.Assert(t, qt.Matches(gotErr, test.wantError), qt.Commentf("error %v", err)) 275 293 return 276 294 } 277 295 qt.Assert(t, qt.IsNil(err), qt.Commentf("details: %v", strings.TrimSuffix(errors.Details(err, nil), "\n"))) ··· 293 311 name: "WithLanguage", 294 312 file: &File{ 295 313 Language: &Language{ 296 - Version: "v0.4.3", 314 + Version: "v0.8.0", 297 315 }, 298 316 Module: "foo.com/bar@v0", 299 317 Deps: map[string]*Dep{ ··· 307 325 }, 308 326 want: `module: "foo.com/bar@v0" 309 327 language: { 310 - version: "v0.4.3" 328 + version: "v0.8.0" 311 329 } 312 330 deps: { 313 331 "example.com@v1": { ··· 322 340 file: &File{ 323 341 Module: "foo.com/bar@v0", 324 342 Language: &Language{ 325 - Version: "v0.4.3", 343 + Version: "v0.8.0", 326 344 }, 327 345 }, 328 346 want: `module: "foo.com/bar@v0" 329 347 language: { 330 - version: "v0.4.3" 348 + version: "v0.8.0" 331 349 } 332 350 `}, { 351 + name: "WithVersionTooEarly", 352 + file: &File{ 353 + Module: "foo.com/bar@v0", 354 + Language: &Language{ 355 + Version: "v0.4.3", 356 + }, 357 + }, 358 + wantError: `language version v0.4.3 is too early for module.cue \(need at least v0.8.0\)`, 359 + }, { 333 360 name: "WithInvalidModuleVersion", 334 361 file: &File{ 335 362 Module: "foo.com/bar@v0", ··· 337 364 Version: "badversion--", 338 365 }, 339 366 }, 340 - wantError: `cannot round-trip module file: language version "badversion--" in - is not well formed`, 367 + wantError: `cannot round-trip module file: language version "badversion--" in module.cue is not valid semantic version`, 341 368 }, { 342 369 name: "WithNonNilEmptyDeps", 343 370 file: &File{ 344 371 Module: "foo.com/bar@v0", 345 - Deps: map[string]*Dep{}, 372 + Language: &Language{ 373 + Version: "v0.8.0", 374 + }, 375 + Deps: map[string]*Dep{}, 346 376 }, 347 377 want: `module: "foo.com/bar@v0" 378 + language: { 379 + version: "v0.8.0" 380 + } 348 381 `, 349 382 }} 350 383 cuetest.Run(t, tests, func(t *cuetest.T, test *formatTest) {
+99 -124
mod/modfile/schema.cue
··· 23 23 // to be lost. See https://github.com/cue-lang/cue/issues/2319. 24 24 let unimplemented = 1&2 25 25 26 + // versions holds an element for each supported version 27 + // of the schema. The version key specifies that 28 + // the schema covers all versions from then until the 29 + // next version present in versions, or until the current CUE version, 30 + // whichever is earlier. 31 + versions: [string]: { 32 + // #File represents the overarching module file schema. 33 + #File!: { 34 + // We always require the language version, as we use 35 + // that to determine how to parse the file itself. 36 + // Note that this schema is not used by [ParseLegacy] 37 + // because legacy module.cue files did not support 38 + // language.version field. 39 + language!: version!: string 40 + } 41 + // #Strict can be unified with the top level schema to enforce the strict version 42 + // of the schema required when publishing a module. 43 + #Strict!: _ 44 + } 26 45 27 - // #File represents the overarching module file schema. 28 - #File: { 29 - // Reserve fields that are unimplemented for now. 30 - { 31 - deprecated?: unimplemented 32 - retract?: unimplemented 33 - publish?: unimplemented 34 - #Dep: { 35 - exclude?: unimplemented 36 - replace?: unimplemented 37 - replaceAll?: unimplemented 38 - } 46 + versions: "v0.0.0": { 47 + // Historically all fields were allowed. 48 + #File: { 49 + module?: string 50 + ... 39 51 } 40 - // module indicates the module's path. 41 - module?: #Module | "" 52 + #Strict: #File 53 + } 42 54 43 - // source holds information about the source of the files within the 44 - // module. This field is mandatory at publish time. 45 - source?: #Source 55 + // earliestClosedSchemaVersion holds the earliest module.cue schema version 56 + // that excludes unknown fields. 57 + earliestClosedSchemaVersion: "v0.8.0" 46 58 47 - // version indicates the language version used by the code 48 - // in this module - the minimum version of CUE required 49 - // to evaluate the code in this module. When a later version of CUE 50 - // is evaluating code in this module, this will be used to 51 - // choose version-specific behavior. If an earlier version of CUE 52 - // is used, an error will be given. 53 - language?: version?: #Semver 59 + versions: (earliestClosedSchemaVersion): { 60 + // Define this version in terms of the later versions 61 + // rather than the other way around, so that 62 + // the latest version is clearest. 63 + versions["v0.9.0-alpha.0"] 54 64 55 - // description describes the purpose of this module. 56 - description?: string 65 + // The source field was added in v0.9.0, so "remove" 66 + // it here by marking it as unimplemented. 67 + #File: source?: unimplemented 68 + } 57 69 58 - // When present, deprecated indicates that the module 59 - // is deprecated and includes information about that deprecation, ideally 60 - // mentioning an alternative that can be used instead. 61 - // TODO implement this. 62 - deprecated?: string 70 + versions: "v0.9.0-alpha.0": { 71 + #File: { 72 + // module indicates the module's path. 73 + module?: #Module | "" 63 74 64 - // deps holds dependency information for modules, keyed by module path. 65 - deps?: [#Module]: #Dep 75 + // source holds information about the source of the files within the 76 + // module. This field is mandatory at publish time. 77 + source?: #Source 66 78 67 - #Dep: { 68 - // TODO use the below when mustexist is implemented. 69 - // replace and replaceAll are mutually exclusive. 70 - //mustexist(<=1, replace, replaceAll) 71 - // There must be at least one field specified for a given module. 72 - //mustexist(>=1, v, exclude, replace, replaceAll) 79 + // version indicates the language version used by the code 80 + // in this module - the minimum version of CUE required 81 + // to evaluate the code in this module. When a later version of CUE 82 + // is evaluating code in this module, this will be used to 83 + // choose version-specific behavior. If an earlier version of CUE 84 + // is used, an error will be given. 85 + language?: version?: #Semver 73 86 74 - // v indicates the minimum required version of the module. 75 - // This can be null if the version is unknown and the module 76 - // entry is only present to be replaced. 77 - v!: #Semver | null 87 + // description describes the purpose of this module. 88 + description?: string 78 89 79 - // default indicates this module is used as a default in case 80 - // more than one major version is specified for the same module 81 - // path. Imports must specify the exact major version for a 82 - // module path if there is more than one major version for that 83 - // path and default is not set for exactly one of them. 84 - // TODO implement this. 85 - default?: bool 90 + // deps holds dependency information for modules, keyed by module path. 91 + deps?: [#Module]: #Dep 92 + 93 + #Dep: { 94 + // v indicates the minimum required version of the module. 95 + // This can be null if the version is unknown and the module 96 + // entry is only present to be replaced. 97 + v!: #Semver | null 86 98 87 - // exclude excludes a set of versions of the module 88 - // TODO implement this. 89 - exclude?: [#Semver]: true 99 + // default indicates this module is used as a default in case 100 + // more than one major version is specified for the same module 101 + // path. Imports must specify the exact major version for a 102 + // module path if there is more than one major version for that 103 + // path and default is not set for exactly one of them. 104 + // TODO implement this. 105 + default?: bool 106 + } 90 107 91 - // replace specifies replacements for specific versions of 92 - // the module. This field is exclusive with replaceAll. 93 - // TODO implement this. 94 - replace?: [#Semver]: #Replacement 108 + // #Module constrains a module path. 109 + // The major version indicator is optional, but should always be present 110 + // in a normalized module.cue file. 111 + #Module: string 95 112 96 - // replaceAll specifies a replacement for all versions of the module. 97 - // This field is exclusive with replace. 98 - // TODO implement this. 99 - replaceAll?: #Replacement 113 + // #Semver constrains a semantic version. 114 + #Semver: =~"." 100 115 } 101 116 102 - // retract specifies a set of previously published versions to retract. 103 - // TODO implement this. 104 - retract?: [... #RetractedVersion] 117 + // #Strict can be unified with the top level schema to enforce the strict version 118 + // of the schema required by the registry. 119 + #Strict: #File & { 120 + // This regular expression is taken from https://semver.org/spec/v2.0.0.html 121 + #Semver: =~#"^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?: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<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"# 105 122 106 - // The publish section can be used to restrict the scope of a module to prevent 107 - // accidental publishing. 108 - // TODO complete the definition of this and implement it. 109 - publish?: _ 123 + // 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]))* 124 + #Module: =~#"^[^@]+(@v(0|[1-9]\d*))$"# 110 125 111 - // #RetractedVersion specifies either a single version 112 - // to retract, or an inclusive range of versions to retract. 113 - #RetractedVersion: #Semver | { 114 - from!: #Semver 115 - // TODO constrain to to be after from? 116 - to!: #Semver 117 - } 126 + // The module declaration is required. 127 + module!: #Module 118 128 119 - // #Replacement specifies a replacement for a module. It can either 120 - // be a reference to a local directory or an alternative module with associated 121 - // version. 122 - #Replacement: string | { 123 - m!: #Module 124 - v!: #Semver 129 + // No null versions, because no replacements yet. 130 + #Dep: v!: #Semver 125 131 } 126 132 127 - // #Module constrains a module path. 128 - // The major version indicator is optional, but should always be present 129 - // in a normalized module.cue file. 130 - #Module: string 131 - 132 - // #Semver constrains a semantic version. 133 - #Semver: =~"." 134 - } 135 - 136 - // _#Strict can be unified with the top level schema to enforce the strict version 137 - // of the schema required by the registry. 138 - #Strict: #File & { 139 - // This regular expression is taken from https://semver.org/spec/v2.0.0.html 140 - #Semver: =~#"^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?: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<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"# 133 + // #Source describes a source of truth for a module's content. 134 + #Source: { 135 + // kind specifies the kind of source. 136 + // 137 + // The special value "none" signifies that the module that is 138 + // standalone, associated with no particular source other than 139 + // the contents of the module itself. 140 + kind!: "self" | "git" 141 141 142 - // 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]))* 143 - #Module: =~#"^[^@]+(@v(0|[1-9]\d*))$"# 144 - 145 - // We don't yet implement local file replacement (specified as a string) 146 - // so require a struct, thus allowing only replacement by some other module. 147 - #Replacement: {...} 148 - 149 - // The module declaration is required. 150 - module!: #Module 151 - 152 - // No null versions, because no replacements yet. 153 - #Dep: v!: #Semver 154 - 155 - // TODO require the CUE version? 156 - // language!: version!: _ 157 - } 158 - 159 - // #Source describes a source of truth for a module's content. 160 - #Source: { 161 - // kind specifies the kind of source. 162 - // 163 - // The special value "none" signifies that the module that is 164 - // standalone, associated with no particular source other than 165 - // the contents of the module itself. 166 - kind!: "self" | "git" 167 - 168 - // TODO support for other VCSs: 169 - // kind!: "self" | "git" | "bzr" | "hg" | "svn" 170 - } 142 + // TODO support for other VCSs: 143 + // kind!: "self" | "git" | "bzr" | "hg" | "svn" 144 + } 145 + }
+9
mod/modregistry/client_test.go
··· 43 43 const testMod = ` 44 44 -- cue.mod/module.cue -- 45 45 module: "example.com/module@v1" 46 + language: version: "v0.8.0" 46 47 47 48 -- x.cue -- 48 49 x: 42 ··· 74 75 modContents := fmt.Sprintf(` 75 76 -- cue.mod/module.cue -- 76 77 module: %q 78 + language: version: "v0.8.0" 77 79 78 80 -- x.cue -- 79 81 x: 42 ··· 93 95 const testMod = ` 94 96 -- cue.mod/module.cue -- 95 97 module: "foo.com/bar@v0" 98 + language: version: "v0.8.0" 96 99 deps: "example.com@v1": v: "v1.2.3" 97 100 deps: "other.com/something@v0": v: "v0.2.3" 98 101 ··· 128 131 const testMod = ` 129 132 -- cue.mod/module.cue -- 130 133 module: "foo.com/bar@v0" 134 + language: version: "v0.8.0" 131 135 deps: "example.com@v1": v: "v1.2.3" 132 136 deps: "other.com/something@v0": v: "v0.2.3" 133 137 ··· 172 176 const testMod = ` 173 177 -- cue.mod/module.cue -- 174 178 module: "foo.com/bar@v0" 179 + language: version: "v0.8.0" 175 180 deps: "example.com@v1": v: "v1.2" 176 181 177 182 -- x.cue -- ··· 195 200 content: ` 196 201 -- cue.mod/module.cue -- 197 202 module: "foo.com/bar@v0" 203 + language: version: "v0.8.0" 198 204 `, 199 205 }, { 200 206 testName: "MismatchedMajorVersion", ··· 202 208 content: ` 203 209 -- cue.mod/module.cue -- 204 210 module: "foo.com/bar@v1" 211 + language: version: "v0.8.0" 205 212 `, 206 213 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"`, 207 214 }, { ··· 210 217 content: ` 211 218 -- cue.mod/module.cue -- 212 219 module: "foo@v1.2.3" 220 + language: version: "v0.8.0" 213 221 `, 214 222 wantError: `module.cue file check failed: module path foo@v1.2.3 in "cue.mod/module.cue" should contain the major version only`, 215 223 }, { ··· 218 226 content: ` 219 227 -- cue.mod/module.cue -- 220 228 module: "foo@v1" 229 + language: version: "v0.8.0" 221 230 deps: "foo.com/bar@v2": v: "invalid" 222 231 `, 223 232 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`,