this repo has no description
0
fork

Configure Feed

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

cue/load: remove support for cue.mod files

We transitioned to a cue.mod directory with a cue.mod/module.cue file
all the way back in 2019: https://cue-review.googlesource.com/c/cue/+/3880

We continued supporting cue.mod files as if they were cue.mod/module.cue
during a transition period, to not break user's modules straight away.
It has been nearly five years now, and the fix is simple enough:

mv cue.mod cue.mod-backup
mkdir cue.mod
mv cue.mod-backup cue.mod/module.cue

Remove support for the legacy file mode for good,
as well as a bit of code in `cue mod init` which did the rewrite above.
Note that a few tests still used it; update those accordingly.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I0a26f6153d58b9b60165e3060099f1d8eed2d4c0
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1188428
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+41 -89
+4 -8
cmd/cue/cmd/fix.go
··· 63 63 args = []string{"./..."} 64 64 65 65 for { 66 - if fi, err := os.Stat(filepath.Join(dir, "cue.mod")); err == nil { 67 - if fi.IsDir() { 68 - args = appendDirs(args, filepath.Join(dir, "cue.mod", "gen")) 69 - args = appendDirs(args, filepath.Join(dir, "cue.mod", "pkg")) 70 - args = appendDirs(args, filepath.Join(dir, "cue.mod", "usr")) 71 - } else { 72 - args = appendDirs(args, filepath.Join(dir, "pkg")) 73 - } 66 + if _, err := os.Stat(filepath.Join(dir, "cue.mod")); err == nil { 67 + args = appendDirs(args, filepath.Join(dir, "cue.mod", "gen")) 68 + args = appendDirs(args, filepath.Join(dir, "cue.mod", "pkg")) 69 + args = appendDirs(args, filepath.Join(dir, "cue.mod", "usr")) 74 70 break 75 71 } 76 72
+3 -47
cmd/cue/cmd/mod.go
··· 16 16 17 17 import ( 18 18 "fmt" 19 - "math/rand" 20 19 "os" 21 20 "path/filepath" 22 21 "strings" ··· 119 118 } 120 119 121 120 mod := filepath.Join(cwd, "cue.mod") 122 - 123 - info, err := os.Stat(mod) 124 - 125 - // Detect old setups and backport it if requested. 126 - if err == nil && !info.IsDir() { 127 - // This path backports 128 - if !flagForce.Bool(cmd) { 129 - return fmt.Errorf("detected old-style config file; use --force to upgrade") 121 + if info, err := os.Stat(mod); err == nil { 122 + if !info.IsDir() { 123 + return fmt.Errorf("cue.mod files are no longer supported; use cue.mod/module.cue") 130 124 } 131 - return backport(mod, cwd) 132 - } 133 - 134 - if err == nil { 135 125 return fmt.Errorf("cue.mod directory already exists") 136 126 } 137 127 mf := &modfile.File{ ··· 164 154 } 165 155 166 156 return err 167 - } 168 - 169 - // backport backports an old cue.mod setup to a new one. 170 - func backport(mod, cwd string) error { 171 - tmp := filepath.Join(cwd, fmt.Sprintf("_%x_cue.mod", rand.Int())) 172 - err := os.Rename(mod, tmp) 173 - if err != nil { 174 - return err 175 - } 176 - 177 - err = os.Mkdir(filepath.Join(cwd, "cue.mod"), 0755) 178 - if err != nil { 179 - os.Rename(tmp, mod) 180 - return err 181 - } 182 - 183 - err = os.Rename(tmp, filepath.Join(cwd, "cue.mod", "module.cue")) 184 - if err != nil { 185 - return err 186 - } 187 - 188 - err = os.Rename(filepath.Join(cwd, "pkg"), filepath.Join(cwd, "cue.mod", "gen")) 189 - if err != nil && !os.IsNotExist(err) { 190 - return err 191 - } 192 - 193 - if err = os.Mkdir(filepath.Join(mod, "usr"), 0755); err != nil { 194 - return err 195 - } 196 - if err = os.Mkdir(filepath.Join(mod, "pkg"), 0755); err != nil { 197 - return err 198 - } 199 - 200 - return nil 201 157 } 202 158 203 159 func versionForModFile() string {
+1 -1
cmd/cue/cmd/testdata/script/cmd_after.txtar
··· 48 48 -- task.cue -- 49 49 package home 50 50 51 - -- cue.mod -- 51 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_concurrent.txtar
··· 28 28 text: "foo: \(foo.stdout)\nbar: \(bar.stdout)" 29 29 } 30 30 } 31 - -- cue.mod -- 31 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_dep.txtar
··· 30 30 } 31 31 } 32 32 33 - -- cue.mod -- 33 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_dir.txtar
··· 25 25 } 26 26 } 27 27 28 - -- cue.mod -- 28 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_import.txtar
··· 15 15 } 16 16 } 17 17 18 - -- cue.mod -- 18 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_mkdirtmp.txtar
··· 17 17 success: true 18 18 } 19 19 } 20 - -- cue.mod -- 20 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_print.txtar
··· 34 34 } 35 35 -- task.cue -- 36 36 package home 37 - -- cue.mod -- 37 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_ref.txtar
··· 25 25 26 26 -- task.cue -- 27 27 package home 28 - -- cue.mod -- 28 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/cmd_stdin.txtar
··· 86 86 cmd: ["echo", "not reading any stdin"] 87 87 } 88 88 } 89 - -- cue.mod -- 89 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/def_jsonschema.txtar
··· 79 79 age: conflicting values "twenty" and int (mismatched types string and int): 80 80 ./data.yaml:1:6 81 81 ./schema.json:18:7 82 - -- cue.mod -- 82 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/def_proto.txtar
··· 218 218 int32 nanos = 2; 219 219 } 220 220 221 - -- cue.mod -- 221 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/eval_context.txtar
··· 26 26 "kind": "Service", 27 27 "@name": "elem3" 28 28 } 29 - -- cue.mod -- 29 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/export.txtar
··· 14 14 15 15 $type: "demo" 16 16 message: "Hello \(#who)!" // who declared in data.cue 17 - -- hello/cue.mod -- 17 + -- hello/cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/export_err.txtar
··· 45 45 // Issue #553 46 46 b: c: "hello" 47 47 out: "d is \(b.d)" 48 - -- exporterr/cue.mod -- 48 + -- exporterr/cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/export_list.txtar
··· 36 36 "name": "supplement\nfoo", 37 37 "json": "[1, 2]" 38 38 } 39 - -- cue.mod -- 39 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/export_yaml.txtar
··· 18 18 command: ["foo", "bar"] 19 19 } 20 20 } 21 - -- hello/cue.mod -- 21 + -- hello/cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/fmt.txtar
··· 8 8 9 9 a: 2 10 10 bb: 3 11 - -- fmt/cue.mod -- 11 + -- fmt/cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/fmt_stdin.txtar
··· 8 8 -- expect-stdout -- 9 9 foo: 2 10 10 a: {b: 3} // a comment 11 - -- fmt/cue.mod -- 11 + -- fmt/cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/get_go_types.txtar
··· 26 26 module mod.test 27 27 28 28 go 1.21 29 - -- cue.mod -- 29 + -- cue.mod/module.cue -- 30 30 module: "mod.test" 31 31 -- pkg1/alias.go -- 32 32 package pkg1
+1 -1
cmd/cue/cmd/testdata/script/help_cmd.txtar
··· 1 1 exec cue help cmd 2 2 cmp stdout expect-stdout 3 3 4 - -- cue.mod -- 4 + -- cue.mod/module.cue -- 5 5 -- task_tool.cue -- 6 6 package home 7 7
+1 -1
cmd/cue/cmd/testdata/script/help_cmd_flags.txtar
··· 4 4 exec cue cmd --help 5 5 cmp stdout expect-stdout 6 6 7 - -- cue.mod -- 7 + -- cue.mod/module.cue -- 8 8 -- task_tool.cue -- 9 9 package home 10 10
+1 -1
cmd/cue/cmd/testdata/script/help_hello.txtar
··· 1 1 exec cue help cmd hello 2 2 cmp stdout expect-stdout 3 3 4 - -- cue.mod -- 4 + -- cue.mod/module.cue -- 5 5 -- task_tool.cue -- 6 6 package home 7 7
+1 -1
cmd/cue/cmd/testdata/script/import_context.txtar
··· 28 28 "kind": "Service", 29 29 "@name": "elem3" 30 30 } 31 - -- cue.mod -- 31 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/import_files.txtar
··· 27 27 "name": "supplement\nfoo", 28 28 "json": "[1, 2]" 29 29 } 30 - -- cue.mod -- 30 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/import_list.txtar
··· 53 53 [{"b": 2}] 54 54 -- import3/data.json -- 55 55 [1] 56 - -- cue.mod -- 56 + -- cue.mod/module.cue -- 57 57 58 58 -- issue2721/empty.yaml -- 59 59 -- issue2721/empty.cue.golden --
+1 -1
cmd/cue/cmd/testdata/script/import_path.txtar
··· 36 36 "name": "supplement\nfoo", 37 37 "json": "[1, 2]" 38 38 } 39 - -- cue.mod -- 39 + -- cue.mod/module.cue --
+1 -1
cmd/cue/cmd/testdata/script/merge_interaction.txtar
··· 23 23 text: yaml.MarshalStream(objects) 24 24 } 25 25 } 26 - -- cue.mod -- 26 + -- cue.mod/module.cue -- 27 27 28 28 -- expect-stdout -- 29 29 spec: {}
+1 -1
cmd/cue/cmd/testdata/script/trim.txtar
··· 131 131 132 132 comp: baz: {} // TODO: remove: implied by comprehension above 133 133 } 134 - -- cue.mod -- 134 + -- cue.mod/module.cue --
+4 -4
cue/load/config.go
··· 16 16 17 17 import ( 18 18 "context" 19 + "fmt" 19 20 "io" 20 21 "os" 21 22 "path/filepath" ··· 407 408 if cerr != nil { 408 409 return nil 409 410 } 410 - // TODO remove support for legacy non-directory module.cue file 411 - // by returning an error if info.IsDir is false. 412 - if info.IsDir() { 413 - mod = filepath.Join(mod, moduleFile) 411 + if !info.IsDir() { 412 + return fmt.Errorf("cue.mod files are no longer supported; use cue.mod/module.cue") 414 413 } 414 + mod = filepath.Join(mod, moduleFile) 415 415 f, cerr := c.fileSystem.openFile(mod) 416 416 if cerr != nil { 417 417 return nil
+1 -1
cue/load/loader_test.go
··· 394 394 c := &Config{ 395 395 Overlay: map[string]Source{ 396 396 // Not necessary, but nice to add. 397 - abs("cue.mod"): FromString(`module: "mod.test"`), 397 + abs("cue.mod/module.cue"): FromString(`module: "mod.test"`), 398 398 399 399 abs("dir/top.cue"): FromBytes([]byte(` 400 400 package top
cue/parser/testdata/cue.mod cue/parser/testdata/cue.mod/module.cue
cue/scanner/testdata/cue.mod cue/scanner/testdata/cue.mod/module.cue
doc/tutorial/kubernetes/manual/cue.mod doc/tutorial/kubernetes/manual/cue.mod/module.cue
encoding/gocode/testdata/cue.mod encoding/gocode/testdata/cue.mod/module.cue
+1 -1
encoding/gocode/testdata/gen.go
··· 37 37 } 38 38 39 39 for _, d := range dirs { 40 - if !d.IsDir() { 40 + if !d.IsDir() || d.Name() == "cue.mod" { 41 41 continue 42 42 } 43 43 dir := filepath.Join(cwd, "testdata")
encoding/protobuf/testdata/cue.mod encoding/protobuf/testdata/cue.mod/module.cue