Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod: implement replace directive #2956

Open
rogpeppe opened this issue Mar 18, 2024 · 1 comment
Open

mod: implement replace directive #2956

rogpeppe opened this issue Mar 18, 2024 · 1 comment
Labels
FeatureRequest New feature or request modules Issues related to CUE modules and the experimental implementation

Comments

@rogpeppe
Copy link
Member

Go's module system provides a replace directive to allow replacing
one module by another module or by a module that is present in a local
directory.

CUE's modules should implement that too.

@rogpeppe rogpeppe added FeatureRequest New feature or request modules Issues related to CUE modules and the experimental implementation labels Mar 18, 2024
@morlay
Copy link

morlay commented Mar 19, 2024

When replace directive supported.

We could maintain cue modules in one monorepo.

code layout:

-- a/cue.mod/module.cue --
module: "ghcr.io/morlay/a@v0"
language: {
        version: "v0.8.0"
}
-- a/x.cue --
package a

#Version: "v0.0.0"
-- b/cue.mod/module.cue --
module: "ghcr.io/morlay/b@v0"
language: {
        version: "v0.8.0"
}
deps: {
        "ghcr.io/morlay/a@v0": {
                "v":       "v0.0.0"
                "replace": "../a"
        }
}
-- b/x.cue --
package b

import (
        "ghcr.io/morlay/a"
)

deps: {
        a: "a.#Version"
}
-- c/cue.mod/module.cue --
module: "ghcr.io/morlay/c@v0"
language: {
        version: "v0.8.0"
}
deps: {
        "ghcr.io/morlay/a@v0": {
                "v":       "v0.0.0"
                "replace": "../a"
        }
}
-- c/x.cue --
package c

import (
        "ghcr.io/morlay/a"
)

deps: {
        a: "a.#Version"
}

module deps:

graph TD
a["ghcr.io/morlay/a"]
b["ghcr.io/morlay/b"]
c["ghcr.io/morlay/c"]

a --> b;
a --> c;
Loading

Now we start to publish all cue modules.

First

cue publish ghcr.io/morlay/a v0.1.0

Then

cue publish ghcr.io/morlay/b v0.1.0
cue publish ghcr.io/morlay/c v0.1.0

but version of ghcr.io/morlay/a already v0.1.0,
we have to change the version of ghcr.io/morlay/a in ghcr.io/morlay/b and ghcr.io/morlay/c, before publish.

So. may consider added optional version?: string in module.cue,
Thencue publish ./a could use the module and version form module.cue
And in the case above, cue publish ./a and cue publish ./c could resolve the correct version of ghcr.io/morlay/a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request modules Issues related to CUE modules and the experimental implementation
Projects
Status: Backlog
Development

No branches or pull requests

2 participants