Skip to content

Commit

Permalink
chore: bump lib version to v0.10.0-alpha.2 (#364)
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <xpf6677@163.com>
  • Loading branch information
Peefy committed Aug 5, 2024
1 parent 718f888 commit 75b87d6
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 100 deletions.
4 changes: 2 additions & 2 deletions bench_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright The KCL Authors. All rights reserved.

package kclvm
package kcl

// KCLVM_GO_API_TEST_NUM_CPU=1 go test -bench=.
// KCL_GO_API_TEST_NUM_CPU=1 go test -bench=.

import (
"os"
Expand Down
139 changes: 76 additions & 63 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import "kcl-lang.io/kcl-go"
```

Package kclvm
Package kcl

KCL Go SDK

Expand Down Expand Up @@ -94,68 +94,81 @@ x1 = Person {

## Index

- [Constants](<#constants>)
- [func FormatCode\(code interface\{\}\) \(\[\]byte, error\)](<#FormatCode>)
- [func FormatPath\(path string\) \(changedPaths \[\]string, err error\)](<#FormatPath>)
- [func GetSchemaTypeMapping\(filename string, src any, schemaName string\) \(map\[string\]\*KclType, error\)](<#GetSchemaTypeMapping>)
- [func InitKclvmPath\(kclvmRoot string\)](<#InitKclvmPath>)
- [func InitKclvmRuntime\(n int\)](<#InitKclvmRuntime>)
- [func LintPath\(paths \[\]string\) \(results \[\]string, err error\)](<#LintPath>)
- [func ListDepFiles\(workDir string, opt \*ListDepFilesOption\) \(files \[\]string, err error\)](<#ListDepFiles>)
- [func ListDownStreamFiles\(workDir string, opt \*ListDepsOptions\) \(\[\]string, error\)](<#ListDownStreamFiles>)
- [func ListUpStreamFiles\(workDir string, opt \*ListDepsOptions\) \(deps \[\]string, err error\)](<#ListUpStreamFiles>)
- [func OverrideFile\(file string, specs, importPaths \[\]string\) \(bool, error\)](<#OverrideFile>)
- [func Validate\(dataFile, schemaFile string, opts \*ValidateOptions\) \(ok bool, err error\)](<#Validate>)
- [func ValidateCode\(data, code string, opts \*ValidateOptions\) \(ok bool, err error\)](<#ValidateCode>)
- [type KCLResult](<#KCLResult>)
- [type KCLResultList](<#KCLResultList>)
- [func MustRun\(path string, opts ...Option\) \*KCLResultList](<#MustRun>)
- [func Run\(path string, opts ...Option\) \(\*KCLResultList, error\)](<#Run>)
- [func RunFiles\(paths \[\]string, opts ...Option\) \(\*KCLResultList, error\)](<#RunFiles>)
- [type KclType](<#KclType>)
- [func GetSchemaType\(filename string, src any, schemaName string\) \(\[\]\*KclType, error\)](<#GetSchemaType>)
- [type ListDepFilesOption](<#ListDepFilesOption>)
- [type ListDepsOptions](<#ListDepsOptions>)
- [type ListOptionsArgs](<#ListOptionsArgs>)
- [type ListOptionsResult](<#ListOptionsResult>)
- [func ListOptions\(args \*ListOptionsArgs\) \(\*ListOptionsResult, error\)](<#ListOptions>)
- [type ListVariablesArgs](<#ListVariablesArgs>)
- [type ListVariablesResult](<#ListVariablesResult>)
- [func ListVariables\(args \*ListVariablesArgs\) \(\*ListVariablesResult, error\)](<#ListVariables>)
- [type LoadPackageArgs](<#LoadPackageArgs>)
- [type LoadPackageResult](<#LoadPackageResult>)
- [func LoadPackage\(args \*LoadPackageArgs\) \(\*LoadPackageResult, error\)](<#LoadPackage>)
- [type Option](<#Option>)
- [func NewOption\(\) \*Option](<#NewOption>)
- [func WithCode\(codes ...string\) Option](<#WithCode>)
- [func WithDisableNone\(disableNone bool\) Option](<#WithDisableNone>)
- [func WithExternalPkgAndPath\(name, path string\) Option](<#WithExternalPkgAndPath>)
- [func WithExternalPkgs\(externalPkgs ...string\) Option](<#WithExternalPkgs>)
- [func WithFullTypePath\(fullTypePath bool\) Option](<#WithFullTypePath>)
- [func WithIncludeSchemaTypePath\(includeSchemaTypePath bool\) Option](<#WithIncludeSchemaTypePath>)
- [func WithKFilenames\(filenames ...string\) Option](<#WithKFilenames>)
- [func WithLogger\(l io.Writer\) Option](<#WithLogger>)
- [func WithOptions\(key\_value\_list ...string\) Option](<#WithOptions>)
- [func WithOverrides\(override\_list ...string\) Option](<#WithOverrides>)
- [func WithPrintOverridesAST\(printOverridesAST bool\) Option](<#WithPrintOverridesAST>)
- [func WithSelectors\(selectors ...string\) Option](<#WithSelectors>)
- [func WithSettings\(filename string\) Option](<#WithSettings>)
- [func WithShowHidden\(showHidden bool\) Option](<#WithShowHidden>)
- [func WithSortKeys\(sortKeys bool\) Option](<#WithSortKeys>)
- [func WithWorkDir\(workDir string\) Option](<#WithWorkDir>)
- [type ParseProgramArgs](<#ParseProgramArgs>)
- [type ParseProgramResult](<#ParseProgramResult>)
- [func ParseProgram\(args \*ParseProgramArgs\) \(\*ParseProgramResult, error\)](<#ParseProgram>)
- [type TestCaseInfo](<#TestCaseInfo>)
- [type TestOptions](<#TestOptions>)
- [type TestResult](<#TestResult>)
- [func Test\(testOpts \*TestOptions, opts ...Option\) \(TestResult, error\)](<#Test>)
- [type UpdateDependenciesArgs](<#UpdateDependenciesArgs>)
- [type UpdateDependenciesResult](<#UpdateDependenciesResult>)
- [func UpdateDependencies\(args \*UpdateDependenciesArgs\) \(\*UpdateDependenciesResult, error\)](<#UpdateDependencies>)
- [type ValidateOptions](<#ValidateOptions>)
- [type VersionResult](<#VersionResult>)
- [func GetVersion\(\) \(\*VersionResult, error\)](<#GetVersion>)
- [kclvm](#kclvm)
- [Index](#index)
- [Constants](#constants)
- [func FormatCode](#func-formatcode)
- [Output](#output)
- [func FormatPath](#func-formatpath)
- [func GetSchemaTypeMapping](#func-getschematypemapping)
- [func InitKclvmPath](#func-initkclvmpath)
- [func InitKclvmRuntime](#func-initkclvmruntime)
- [func LintPath](#func-lintpath)
- [Output](#output-1)
- [func ListDepFiles](#func-listdepfiles)
- [func ListDownStreamFiles](#func-listdownstreamfiles)
- [func ListUpStreamFiles](#func-listupstreamfiles)
- [func OverrideFile](#func-overridefile)
- [func Validate](#func-validate)
- [func ValidateCode](#func-validatecode)
- [type KCLResult](#type-kclresult)
- [Output](#output-2)
- [Output](#output-3)
- [type KCLResultList](#type-kclresultlist)
- [func MustRun](#func-mustrun)
- [Output](#output-4)
- [Output](#output-5)
- [Output](#output-6)
- [func Run](#func-run)
- [func RunFiles](#func-runfiles)
- [type KclType](#type-kcltype)
- [func GetSchemaType](#func-getschematype)
- [type ListDepFilesOption](#type-listdepfilesoption)
- [type ListDepsOptions](#type-listdepsoptions)
- [type ListOptionsArgs](#type-listoptionsargs)
- [type ListOptionsResult](#type-listoptionsresult)
- [func ListOptions](#func-listoptions)
- [Output](#output-7)
- [type ListVariablesArgs](#type-listvariablesargs)
- [type ListVariablesResult](#type-listvariablesresult)
- [func ListVariables](#func-listvariables)
- [Output](#output-8)
- [type LoadPackageArgs](#type-loadpackageargs)
- [type LoadPackageResult](#type-loadpackageresult)
- [func LoadPackage](#func-loadpackage)
- [type Option](#type-option)
- [func NewOption](#func-newoption)
- [func WithCode](#func-withcode)
- [func WithDisableNone](#func-withdisablenone)
- [func WithExternalPkgAndPath](#func-withexternalpkgandpath)
- [func WithExternalPkgs](#func-withexternalpkgs)
- [func WithFullTypePath](#func-withfulltypepath)
- [func WithIncludeSchemaTypePath](#func-withincludeschematypepath)
- [func WithKFilenames](#func-withkfilenames)
- [func WithLogger](#func-withlogger)
- [func WithOptions](#func-withoptions)
- [Output](#output-9)
- [func WithOverrides](#func-withoverrides)
- [func WithPrintOverridesAST](#func-withprintoverridesast)
- [func WithSelectors](#func-withselectors)
- [func WithSettings](#func-withsettings)
- [func WithShowHidden](#func-withshowhidden)
- [func WithSortKeys](#func-withsortkeys)
- [func WithWorkDir](#func-withworkdir)
- [type ParseProgramArgs](#type-parseprogramargs)
- [type ParseProgramResult](#type-parseprogramresult)
- [func ParseProgram](#func-parseprogram)
- [type TestCaseInfo](#type-testcaseinfo)
- [type TestOptions](#type-testoptions)
- [type TestResult](#type-testresult)
- [func Test](#func-test)
- [type UpdateDependenciesArgs](#type-updatedependenciesargs)
- [type UpdateDependenciesResult](#type-updatedependenciesresult)
- [func UpdateDependencies](#func-updatedependencies)
- [Output](#output-10)
- [type ValidateOptions](#type-validateoptions)
- [type VersionResult](#type-versionresult)
- [func GetVersion](#func-getversion)


## Constants
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright The KCL Authors. All rights reserved.

package kclvm_test
package kcl_test

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v3 v3.0.1
kcl-lang.io/lib v0.10.0-alpha.1
kcl-lang.io/lib v0.10.0-alpha.2.0.20240805133606-f538c9780908
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
kcl-lang.io/lib v0.10.0-alpha.1 h1:GMVB75Pc1W29gcl1WlVgdgUscH6h+d9No0fzBH0rNYg=
kcl-lang.io/lib v0.10.0-alpha.1/go.mod h1:tu+tzwGgHLzYZSIxUG/ntipStrxZd6OvutWYPTxS7cs=
kcl-lang.io/lib v0.10.0-alpha.2.0.20240805133606-f538c9780908 h1:QxwzJ6jPxdlcTdcYdbUs+vk8w5uz5kirtihNQhXMm/I=
kcl-lang.io/lib v0.10.0-alpha.2.0.20240805133606-f538c9780908/go.mod h1:tu+tzwGgHLzYZSIxUG/ntipStrxZd6OvutWYPTxS7cs=
6 changes: 3 additions & 3 deletions kclvm.go → kcl.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 The KCL Authors. All rights reserved.
// Copyright The KCL Authors. All rights reserved.

// Package kclvm
// Package kcl
/*
KCL Go SDK
Expand Down Expand Up @@ -28,7 +28,7 @@ KCL Go SDK
│WithDisableNone │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
*/
package kclvm
package kcl

import (
"io"
Expand Down
8 changes: 4 additions & 4 deletions kclvm_test.go → kcl_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright The KCL Authors. All rights reserved.

package kclvm_test
package kcl_test

import (
"bytes"
Expand All @@ -21,7 +21,7 @@ import (
"kcl-lang.io/kcl-go/pkg/spec/gpyrpc"
)

const tEnvNumCpu = "KCLVM_GO_API_TEST_NUM_CPU"
const tEnvNumCpu = "KCL_GO_API_TEST_NUM_CPU"

func TestMain(m *testing.M) {
flag.Parse()
Expand Down Expand Up @@ -79,10 +79,10 @@ a2 = App {
if err != nil {
t.Fatal(err)
}
if expect, got := "__main__.App", result.First().Get("a1._type"); expect != got {
if expect, got := "App", result.First().Get("a1._type"); expect != got {
t.Fatalf("expect = %v, got = %v", expect, got)
}
if expect, got := "__main__.App", result.First().Get("a2._type"); expect != got {
if expect, got := "App", result.First().Get("a2._type"); expect != got {
t.Fatalf("expect = %v, got = %v", expect, got)
}
if expect, got := "default", result.First().Get("a1.image"); expect != got {
Expand Down
2 changes: 1 addition & 1 deletion kclvm_version.go → kcl_version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright The KCL Authors. All rights reserved.

package kclvm
package kcl

import "kcl-lang.io/kcl-go/scripts"

Expand Down
20 changes: 20 additions & 0 deletions pkg/service/kclvm_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,48 @@ package service
import "kcl-lang.io/kcl-go/pkg/spec/gpyrpc"

type KclvmService interface {
// Ping KclvmService, return the same value as the parameter
Ping(in *gpyrpc.Ping_Args) (out *gpyrpc.Ping_Result, err error)
// Execute KCL file with arguments and return the JSON/YAML result.
ExecProgram(in *gpyrpc.ExecProgram_Args) (out *gpyrpc.ExecProgram_Result, err error)
// Depreciated: Please use the env.EnableFastEvalMode() and c.ExecutProgram method and will be removed in v0.11.0.
BuildProgram(in *gpyrpc.BuildProgram_Args) (out *gpyrpc.BuildProgram_Result, err error)
// Depreciated: Please use the env.EnableFastEvalMode() and c.ExecutProgram method and will be removed in v0.11.0.
ExecArtifact(in *gpyrpc.ExecArtifact_Args) (out *gpyrpc.ExecProgram_Result, err error)
// Parse KCL single file to Module AST JSON string with import dependencies and parse errors.
ParseFile(in *gpyrpc.ParseFile_Args) (out *gpyrpc.ParseFile_Result, err error)
// Parse KCL program with entry files and return the AST JSON string.
ParseProgram(in *gpyrpc.ParseProgram_Args) (out *gpyrpc.ParseProgram_Result, err error)
// ListOptions provides users with the ability to parse KCL program and get all option information.
ListOptions(in *gpyrpc.ParseProgram_Args) (out *gpyrpc.ListOptions_Result, err error)
// ListVariables provides users with the ability to parse KCL program and get all variables by specs.
ListVariables(in *gpyrpc.ListVariables_Args) (out *gpyrpc.ListVariables_Result, err error)
// LoadPackage provides users with the ability to parse KCL program and semantic model information including symbols, types, definitions, etc.
LoadPackage(in *gpyrpc.LoadPackage_Args) (out *gpyrpc.LoadPackage_Result, err error)
// Format the code source.
FormatCode(in *gpyrpc.FormatCode_Args) (out *gpyrpc.FormatCode_Result, err error)
// Format KCL file or directory path contains KCL files and returns the changed file paths.
FormatPath(in *gpyrpc.FormatPath_Args) (out *gpyrpc.FormatPath_Result, err error)
// Lint files and return error messages including errors and warnings.
LintPath(in *gpyrpc.LintPath_Args) (out *gpyrpc.LintPath_Result, err error)
// Override KCL file with arguments. See [https://www.kcl-lang.io/docs/user_docs/guides/automation](https://www.kcl-lang.io/docs/user_docs/guides/automation) for more override spec guide.
OverrideFile(in *gpyrpc.OverrideFile_Args) (out *gpyrpc.OverrideFile_Result, err error)
// Get schema type mapping defined in the program.
GetSchemaTypeMapping(in *gpyrpc.GetSchemaTypeMapping_Args) (out *gpyrpc.GetSchemaTypeMapping_Result, err error)
// Validate code using schema and JSON/YAML data strings.
ValidateCode(in *gpyrpc.ValidateCode_Args) (out *gpyrpc.ValidateCode_Result, err error)
// List dependencies files of input paths.
ListDepFiles(in *gpyrpc.ListDepFiles_Args) (out *gpyrpc.ListDepFiles_Result, err error)
// Load the setting file config defined in `kcl.yaml`.
LoadSettingsFiles(in *gpyrpc.LoadSettingsFiles_Args) (out *gpyrpc.LoadSettingsFiles_Result, err error)
// Rename all the occurrences of the target symbol in the files. This API will rewrite files if they contain symbols to be renamed. Return the file paths that got changed.
Rename(in *gpyrpc.Rename_Args) (out *gpyrpc.Rename_Result, err error)
// Rename all the occurrences of the target symbol and return the modified code if any code has been changed. This API won't rewrite files but return the changed code.
RenameCode(in *gpyrpc.RenameCode_Args) (out *gpyrpc.RenameCode_Result, err error)
// Test KCL packages with test arguments.
Test(in *gpyrpc.Test_Args) (out *gpyrpc.Test_Result, err error)
// Download and update dependencies defined in the `kcl.mod` file and return the external package name and location list.
UpdateDependencies(in *gpyrpc.UpdateDependencies_Args) (out *gpyrpc.UpdateDependencies_Result, err error)
// GetVersion KclvmService, return the kclvm service version information
GetVersion(in *gpyrpc.GetVersion_Args) (out *gpyrpc.GetVersion_Result, err error)
}
2 changes: 1 addition & 1 deletion pkg/service/testmain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"kcl-lang.io/kcl-go/pkg/runtime"
)

const tEnvNumCpu = "KCLVM_GO_API_TEST_NUM_CPU"
const tEnvNumCpu = "KCL_GO_API_TEST_NUM_CPU"
const tRestServerAddr = "127.0.0.1:7001"

func TestMain(m *testing.M) {
Expand Down
45 changes: 23 additions & 22 deletions scripts/kclvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@ const (
)

const (
KclvmAbiVersion KclvmVersionType = KclvmVersionType_v0_9_0
KclvmVersionType_latest = KclvmVersionType_v0_9_0
KclvmAbiVersion KclvmVersionType = KclvmVersionType_v0_10_0
KclvmVersionType_latest = KclvmVersionType_v0_10_0

KclvmVersionType_v0_9_0 KclvmVersionType = "v0.9.0"
KclvmVersionType_v0_8_0 KclvmVersionType = "v0.8.0"
KclvmVersionType_v0_7_5 KclvmVersionType = "v0.7.5"
KclvmVersionType_v0_7_4 KclvmVersionType = "v0.7.4"
KclvmVersionType_v0_7_3 KclvmVersionType = "v0.7.3"
KclvmVersionType_v0_7_2 KclvmVersionType = "v0.7.2"
KclvmVersionType_v0_7_1 KclvmVersionType = "v0.7.1"
KclvmVersionType_v0_7_0 KclvmVersionType = "v0.7.0"
KclvmVersionType_v0_6_0 KclvmVersionType = "v0.6.0"
KclvmVersionType_v0_5_6 KclvmVersionType = "v0.5.6"
KclvmVersionType_v0_5_5 KclvmVersionType = "v0.5.5"
KclvmVersionType_v0_5_4 KclvmVersionType = "v0.5.4"
KclvmVersionType_v0_5_3 KclvmVersionType = "v0.5.3"
KclvmVersionType_v0_5_2 KclvmVersionType = "v0.5.2"
KclvmVersionType_v0_5_1 KclvmVersionType = "v0.5.1"
KclvmVersionType_v0_5_0 KclvmVersionType = "v0.5.0"
KclvmVersionType_v0_4_6 KclvmVersionType = "v0.4.6"
KclvmVersionType_v0_4_5 KclvmVersionType = "v0.4.5"
KclvmVersionType_v0_4_4 KclvmVersionType = "v0.4.4"
KclvmVersionType_v0_4_3 KclvmVersionType = "v0.4.3"
KclvmVersionType_v0_10_0 KclvmVersionType = "v0.10.0"
KclvmVersionType_v0_9_0 KclvmVersionType = "v0.9.0"
KclvmVersionType_v0_8_0 KclvmVersionType = "v0.8.0"
KclvmVersionType_v0_7_5 KclvmVersionType = "v0.7.5"
KclvmVersionType_v0_7_4 KclvmVersionType = "v0.7.4"
KclvmVersionType_v0_7_3 KclvmVersionType = "v0.7.3"
KclvmVersionType_v0_7_2 KclvmVersionType = "v0.7.2"
KclvmVersionType_v0_7_1 KclvmVersionType = "v0.7.1"
KclvmVersionType_v0_7_0 KclvmVersionType = "v0.7.0"
KclvmVersionType_v0_6_0 KclvmVersionType = "v0.6.0"
KclvmVersionType_v0_5_6 KclvmVersionType = "v0.5.6"
KclvmVersionType_v0_5_5 KclvmVersionType = "v0.5.5"
KclvmVersionType_v0_5_4 KclvmVersionType = "v0.5.4"
KclvmVersionType_v0_5_3 KclvmVersionType = "v0.5.3"
KclvmVersionType_v0_5_2 KclvmVersionType = "v0.5.2"
KclvmVersionType_v0_5_1 KclvmVersionType = "v0.5.1"
KclvmVersionType_v0_5_0 KclvmVersionType = "v0.5.0"
KclvmVersionType_v0_4_6 KclvmVersionType = "v0.4.6"
KclvmVersionType_v0_4_5 KclvmVersionType = "v0.4.5"
KclvmVersionType_v0_4_4 KclvmVersionType = "v0.4.4"
KclvmVersionType_v0_4_3 KclvmVersionType = "v0.4.3"
)

0 comments on commit 75b87d6

Please sign in to comment.