Skip to content

Commit

Permalink
update kcl.mod package.edition with the kcl compiler version
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
  • Loading branch information
AkashKumar7902 committed Jan 23, 2024
1 parent 194168a commit 09ba1ca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
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 {
return nil, err
}

return kclvmCompiler.Run()
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/test_data/test_run_no_sum_check/kcl.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "test_run_no_sum_check"
edition = "0.0.1"
edition = "v0.7.0"
version = "0.0.1"

[dependencies]
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

0 comments on commit 09ba1ca

Please sign in to comment.