# Test that cue mod publish prints a note when cue.mod/local-module.cue is
# present, and that the file itself is not part of the published module.

memregistry MEMREGISTRY
env ORIG_CUE_REGISTRY=$CUE_REGISTRY
env CUE_REGISTRY=main.org=$MEMREGISTRY+insecure,$CUE_REGISTRY
cd m

exec cue mod publish v0.1.0
stdout '^published main.org@v0.1.0 to [^ ]+/main.org:v0.1.0$'
stderr '^note: cue.mod/local-module.cue is not published; it only affects local development$'

# The published module must not contain cue.mod/local-module.cue, even though
# it exists in the local module directory.
exec cue mod publish --json v0.2.0
! stdout '"cue.mod/local-module.cue"'
stdout '"cue.mod/module.cue"'

-- m/cue.mod/module.cue --
module: "main.org@v0"
language: version: "v0.17.0"
source: kind: "self"
deps: {
	"example.com/dep@v0": v: "v0.1.0"
}
-- m/cue.mod/local-module.cue --
deps: {
	"example.com/dep@v0": {
		v:       "v0.1.0"
		replaceWith: "./local_dep"
	}
}
-- m/main.cue --
package main

import "example.com/dep@v0:lib"

out: lib.value
-- m/local_dep/cue.mod/module.cue --
module: "example.com/dep@v0"
language: version: "v0.9.0"
-- m/local_dep/lib.cue --
package lib

value: "from local directory"
-- _registry/example.com_dep_v0.1.0/cue.mod/module.cue --
module: "example.com/dep@v0"
language: version: "v0.9.0"
-- _registry/example.com_dep_v0.1.0/lib.cue --
package lib

value: "from registry"
