diff --git a/pkg/client/client.go b/pkg/client/client.go index 7cc86f14..7d334a0d 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -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() } diff --git a/pkg/client/test_data/test_run_no_sum_check/kcl.mod b/pkg/client/test_data/test_run_no_sum_check/kcl.mod index 27e24ba4..8aaa28a0 100644 --- a/pkg/client/test_data/test_run_no_sum_check/kcl.mod +++ b/pkg/client/test_data/test_run_no_sum_check/kcl.mod @@ -1,6 +1,6 @@ [package] name = "test_run_no_sum_check" -edition = "0.0.1" +edition = "v0.7.0" version = "0.0.1" [dependencies] diff --git a/pkg/package/package.go b/pkg/package/package.go index bd16ebfb..33469ed6 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -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) diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 170af36b..4abc732e 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -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" ) @@ -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)