cue mod upgrade
CUE v0.19.0
upgrade the module to a new language version
Usage
cue mod upgrade [flags] <version>Upgrade moves the module to language version <version>: it rewrites the module's files for the syntax and semantics of that version, and then records the version in cue.mod/module.cue.
The files rewritten are the CUE files of the module's own tree, those of the packages ./... denotes from the module root and of _ and testdata directories, which can still be imported, plus every CUE file under cue.mod/gen, cue.mod/pkg and cue.mod/usr, which the module evaluates at its own language version. They are found by walking the module and rewritten one package at a time, without loading: a package whose import cannot be resolved is rewritten all the same. A nested module, a directory with its own cue.mod, is left alone and upgrades on its own.
A symbolic link to a file is read through: a target inside the module is converted once, under its own path. A link to a directory is not followed, and a link to a file outside the module or inside a nested module is not written through; the loader still reads such files, so they fail the upgrade like a file that cannot be converted. A link that does not resolve is skipped. cue.mod itself may be a link; it is read through, as the loader reads it.
A file the parser rejects at the module's current version is skipped and reported, and does not stop the upgrade; the module could not evaluate it before either. A file that parses but cannot be rewritten, or whose rewritten form the new version does not accept, is a failure: nothing is then written and the version is left as it is, so the module never claims a version its files do not satisfy. The report names the files and the way through, which takes two steps:
cue fix -f --exp=<experiments>converts every file that converts and leaves the version alone, so the module keeps evaluating as it is; the files it reports are then fixed by hand, and running the upgrade again finds nothing left to convert and records the version. --force is the shortcut that skips the second step: it writes the files that converted and bumps the version anyway, leaving the files it reports invalid at the new version until they are fixed.
A TODO(cue-fix) comment marks a construct whose rewritten form does not mean what it did: the rewrite could not keep its behavior, and someone must decide what the file should say. A NOTE(cue-fix) comment marks a rewrite which keeps the behavior but may do more than needed, such as a spread on an embedded reference the rewrite cannot see to be open or closed; the file is correct as written, and the NOTE says what can go. The summary names the files with a TODO for review.
Fixes are applied on a best-effort basis; check the result, for instance by comparing the output of cue export before and after. A module whose cue.mod/module.cue has no language version must run cue mod fix first.
Flags
-f, --force write the files that converted and bump the version even when some file could not be convertedGlobal flags
-E, --all-errors print all available errors
-C, --chdir string change working directory before running command (must be the first flag)
-i, --ignore proceed in the presence of errors