Documentation ¶
Index ¶
- Constants
- type KclPkg
- func (kclPkg *KclPkg) AddDeps(opt *opt.AddOptions) error
- func (kclPkg *KclPkg) Compile(kpmHome string, kclvmCompiler *runner.Compiler) (*kcl.KCLResultList, error)
- func (kclPkg *KclPkg) CreateDefaultKclProgram() error
- func (kclPkg *KclPkg) DefaultTarPath() string
- func (kclPkg *KclPkg) DownloadDep(d *modfile.Dependency, localPath string) error
- func (kclPkg *KclPkg) GetEntryKclFilesFromModFile() []string
- func (kclPkg *KclPkg) GetKclOpts() *kcl.Option
- func (kclPkg *KclPkg) GetLockFilePath() string
- func (kclPkg *KclPkg) GetPkgFullName() string
- func (kclPkg *KclPkg) GetPkgName() string
- func (kclPkg *KclPkg) GetPkgTag() string
- func (kclPkg *KclPkg) GetPkgTarName() string
- func (kclPkg *KclPkg) InitEmptyPkg() error
- func (kclPkg *KclPkg) IsVendorMode() bool
- func (kclPkg *KclPkg) LocalVendorPath() string
- func (kclPkg *KclPkg) LockDepsVersion() error
- func (kclPkg *KclPkg) PackageCurrentPkgPath() (string, error)
- func (kclPkg *KclPkg) PackageKclPkg(kpmHome string, tarPath string) error
- func (kclPkg *KclPkg) PackageToTarball(tarPath string) error
- func (kclPkg *KclPkg) ResolveDeps(kpmHome string) (map[string]string, error)
- func (kclPkg *KclPkg) ResolveDepsMetadata(kpmHome string, update bool) error
- func (kclPkg *KclPkg) ResolveDepsMetadataInJsonStr(kpmHome string, update bool) (string, error)
- func (kclPkg *KclPkg) SetVendorMode(vendorMode bool)
- func (kclPkg *KclPkg) UpdateModAndLockFile() error
- func (kclPkg *KclPkg) ValidateKpmHome(kpmHome string) error
- func (kclPkg *KclPkg) VendorDeps(cachePath string) error
Constants ¶
const DEFAULT_KCL_FILE_CONTENT = "The_first_kcl_program = 'Hello World!'"
const DEFAULT_KCL_FILE_NAME = "main.k"
const LOCK_FILE_NAME = "kcl.mod.lock"
const TAR_SUFFIX = ".tar"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KclPkg ¶
type KclPkg struct { HomePath string // The dependencies in the current kcl package are the dependencies of kcl.mod.lock, // not the dependencies in kcl.mod. modfile.Dependencies // contains filtered or unexported fields }
func LoadKclPkg ¶
Load the kcl package from directory containing kcl.mod and kcl.mod.lock file.
func LoadKclPkgFromTar ¶
LoadKclPkgFromTar will load a kcl package from a tar path.
func NewKclPkg ¶
func NewKclPkg(opts *opt.InitOptions) KclPkg
func (*KclPkg) AddDeps ¶
func (kclPkg *KclPkg) AddDeps(opt *opt.AddOptions) error
AddDeps will add the dependencies to current kcl package and update kcl.mod and kcl.mod.lock.
func (*KclPkg) Compile ¶
func (kclPkg *KclPkg) Compile(kpmHome string, kclvmCompiler *runner.Compiler) (*kcl.KCLResultList, error)
CompileWithEntryFile will call kcl compiler to compile the current kcl package and its dependent packages.
func (*KclPkg) CreateDefaultKclProgram ¶
CreateDefaultKclProgram will create a default kcl program "The_first_kcl_program = 'Hello World!'" in 'main.k'.
func (*KclPkg) DefaultTarPath ¶
DefaultTarPath will return "<kcl_package_path>/<package_name>-<package_version>.tar"
func (*KclPkg) DownloadDep ¶
func (kclPkg *KclPkg) DownloadDep(d *modfile.Dependency, localPath string) error
DownloadDep will download the corresponding dependency.
func (*KclPkg) GetEntryKclFilesFromModFile ¶
GetEntryKclFilesFromModFile will return the entry kcl files from kcl.mod.
func (*KclPkg) GetKclOpts ¶
GetKclOpts will return the kcl options from kcl.mod.
func (*KclPkg) GetLockFilePath ¶
GetLockFilePath returns the abs path of kcl.mod.lock.
func (*KclPkg) GetPkgFullName ¶
GetPkgFullName returns the full name of package. The full name is "<pkg_name>-<pkg_version>", <pkg_name> is the name of package. <pkg_version> is the version of package
func (*KclPkg) GetPkgName ¶
GetPkgName returns name of package.
func (*KclPkg) GetPkgTarName ¶
GetPkgTarName returns the kcl package tar name "<package_name>-v<package_version>.tar"
func (*KclPkg) InitEmptyPkg ¶
InitEmptyModule inits an empty kcl module and create a default kcl.modfile.
func (*KclPkg) IsVendorMode ¶
func (*KclPkg) LocalVendorPath ¶
Return the full vendor path.
func (*KclPkg) LockDepsVersion ¶
LockDepsVersion locks the dependencies of the current kcl package into kcl.mod.lock.
func (*KclPkg) PackageCurrentPkgPath ¶
PackageCurrentPkg will package the current kcl package into the current path and return the tar path. And the tar will be named "<package_name>-<package_version>.tar" <package_name> is the package name specified in kcl.mod. <package_version> is the package version specified in kcl.mod.
func (*KclPkg) PackageKclPkg ¶
PackageKclPkg will save all dependencies to the 'vendor' in current pacakge and package the current package into tar
func (*KclPkg) PackageToTarball ¶
PkgCurrentPackageIntoTarPath will package the current kcl package into 'tarPath'.
func (*KclPkg) ResolveDeps ¶
ResolveDeps will return a map between dependency name and its local path, and analyze the dependencies of the current kcl package, look for the package in the $KCL_PKG_PATH or kcl package vendor subdirectory, if find it, ResolveDeps will remember the local path of the dependency, if can’t find it, re-download the dependency and remember the local path.
func (*KclPkg) ResolveDepsMetadata ¶
ResolveDepsMetadata will calculate the local storage path of the external package, and check whether the package exists locally. If the package does not exist, it will re-download to the local.
func (*KclPkg) ResolveDepsMetadataInJsonStr ¶
ResolveDepsMetadataInJsonStr will calculate the local storage path of the external package, and check whether the package exists locally. If the package does not exist, it will re-download to the local. Finally, the calculated metadata of the dependent packages is serialized into a json string and returned.
func (*KclPkg) SetVendorMode ¶
func (*KclPkg) UpdateModAndLockFile ¶
updateModAndLockFile will update kcl.mod and kcl.mod.lock
func (*KclPkg) ValidateKpmHome ¶
Verify that the environment variable KPM HOME is set correctly
func (*KclPkg) VendorDeps ¶
Vendor all dependencies to the 'vendor' in current pacakge.