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

update kcl.mod package.edition with the kcl compiler version #250

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ func (c *KpmClient) Compile(kclPkg *pkg.KclPkg, kclvmCompiler *runner.Compiler)
kclvmCompiler.AddDepPath(dName, dPath)
}

kclPkg.UpdatePkgEdition(kclvmCompiler.GetKclVersion())
if err := kclPkg.ModFile.StoreModFile(); err != nil {
Peefy marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}

return kclvmCompiler.Run()
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/package/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ func (kclPkg *KclPkg) UpdateModAndLockFile() error {
return nil
}

// update compile edition of package
func (kclPkg *KclPkg) UpdatePkgEdition(newEdition string) {
kclPkg.ModFile.Pkg.Edition = newEdition
}

// LockDepsVersion locks the dependencies of the current kcl package into kcl.mod.lock.
func (kclPkg *KclPkg) LockDepsVersion() error {
fullPath := filepath.Join(kclPkg.HomePath, MOD_LOCK_FILE)
Expand Down
5 changes: 5 additions & 0 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"kcl-lang.io/kcl-go/pkg/kcl"
"kcl-lang.io/kcl-go/scripts"
"kcl-lang.io/kpm/pkg/opt"
)

Expand Down Expand Up @@ -46,6 +47,10 @@ func (compiler *Compiler) AddDepPath(depName string, depPath string) *Compiler {
return compiler
}

func (compiler *Compiler) GetKclVersion() string {
return string(scripts.KclvmVersionType_latest)
}

// Call KCL Compiler and return the result.
func (compiler *Compiler) Run() (*kcl.KCLResultList, error) {
return kcl.RunWithOpts(*compiler.opts.Option)
Expand Down
Loading