Skip to content

Commit

Permalink
chore: bump modules repo and use kcl mod instead of kpm
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Nov 13, 2023
1 parent 722f449 commit 1f54f3c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 33 deletions.
41 changes: 24 additions & 17 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

### 准备工作

- 安装 [kpm](https://kcl-lang.io/zh-CN/docs/user_docs/guides/package-management/installation/)
- 安装 [KCL](https://kcl-lang.io/docs/user_docs/getting-started/install)
- 安装 [git](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)
- [注册一个 Github 账户(可选)](https://docs.github.com/zh/get-started/signing-up-for-github/signing-up-for-a-new-github-account)

Expand All @@ -21,7 +21,7 @@

### 准备您的 KCL 包

通过 `kpm init <module_name>` 命令, 您可以创建一个合法的 KCL 程序模块。
通过 `kcl mod init <module_name>` 命令, 您可以创建一个合法的 KCL 程序模块。

目前,仓库能够识别的合法的程序的目录结构如下:

Expand All @@ -44,10 +44,10 @@

#### 1. 下载代码仓库

首先,您需要使用 git 将仓库 https://github.com/kcl-lang/artifacthub 下载到您的本地
首先,您需要使用 git 将仓库 https://github.com/kcl-lang/modules 下载到您的本地

```
git clone https://github.com/kcl-lang/artifacthub --depth=1
```shell
git clone https://github.com/kcl-lang/modules --depth=1
```

#### 2. 为您的包创建一个分支
Expand All @@ -56,25 +56,29 @@ git clone https://github.com/kcl-lang/artifacthub --depth=1

以包 helloworld 为例

进入您下载的artifacthub目录中
```
cd artifacthub
进入您下载的 modules 目录中

```shell
cd modules
```

为包 helloworld 创建一个分支 `publish-pkg-helloworld`
```

```shell
git checkout -b publish-pkg-helloworld
```

#### 3. 添加您的包

您需要将您的包移动到当前目录下,在我们的例子中,我们使用 kpm init 命令创建包 helloworld
您需要将您的包移动到当前目录下,在我们的例子中,我们使用 `kcl mod init` 命令创建包 helloworld

```
kpm init helloworld
```shell
kcl mod init helloworld
```

您可以为 helloworld 包增加一个 README.md 文件保存在包的根目录下,用来展示在 AH 的首页中。
```

```shell
echo "## Introduction" >> helloworld/README.md
echo "This is a kcl module named helloworld." >> helloworld/README.md
```
Expand All @@ -85,17 +89,19 @@ echo "This is a kcl module named helloworld." >> helloworld/README.md

使用 `git add .` 命令将您的包添加到 git 的暂存区中

```
```shell
git add .
```

使用 `git commit -s` 命令提交您的包, 我们推荐您的 commit message 遵循 “publish module <module_name>” 的格式。
```

```shell
git commit -m "publish module helloworld" -s
```

使用 `git push` 命令将您的包提交到您的分支 publish-pkg-<module_name> 中
```

```shell
git push
```

Expand All @@ -109,7 +115,8 @@ git push
完成包的内容上传后,您可以通过 PR 升级您的包。

注意:**我们没有提供任何改变包的内容但是不改变版本号的升级策略。** 如果您想要升级您的包,并希望您升级后的包被展示在 AH 上,您需要修改您的包的版本号。即在 kcl.mod 文件的 module 章节中的 version 字段。
```

```toml
[package]
name = "my_module"
edition = "*"
Expand Down
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In the next section, we will show you how to publish your module with a `hellowo

### Prerequisites

- Install [kpm](https://kcl-lang.io/docs/user_docs/guides/package-management/installation/)
- Install [KCL](https://kcl-lang.io/docs/user_docs/getting-started/install)
- Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Register a GitHub account (optional)](https://docs.github.com/en/get-started/signing-up-for-github/signing-up-for-a-new-github-account)

Expand All @@ -21,7 +21,7 @@ NOTE: If you want to publish your KCL module to the `kcl-lang` official registry

### Prepare your KCL Module

By the `kpm init <module_name>` command, you can create a valid KCL module.
By the `kcl mod init <module_name>` command, you can create a valid KCL module.

Currently, the directory structure of a valid KCL module that the repository can recognize is as follows:

Expand Down Expand Up @@ -50,8 +50,8 @@ Currently, the directory structure of a valid KCL module that the repository can

First, you need to clone the repository

```
git clone https://github.com/kcl-lang/artifacthub --depth=1
```shell
git clone https://github.com/kcl-lang/modules --depth=1
```

#### 2. Create a branch for your module
Expand All @@ -60,26 +60,29 @@ We recommend that your branch name be: `publish-pkg-<module_name>`, `<module_nam

Take the module `helloworld` as an example

Enter the artifacthub directory you downloaded
```
cd artifacthub
Enter the `modules` directory you downloaded

```shell
cd modules
```

Create a branch `publish-pkg-helloworld` for the module `helloworld`
```

```shell
git checkout -b publish-pkg-helloworld
```

#### 3. Add your KCL module

You need to move your module to the current directory. In our example, we use the `kpm init` command to create the module `helloworld`
You need to move your module to the current directory. In our example, we use the `kcl mod init` command to create the module `helloworld`

```
kpm init helloworld
```shell
kcl mod init helloworld
```

You can add a `README.md` file to the root directory of the module to display on the homepage of AH.
```

```shell
echo "## Introduction" >> helloworld/README.md
echo "This is a kcl module named helloworld." >> helloworld/README.md
```
Expand All @@ -90,18 +93,19 @@ You can use the following command to commit your module

Use `git add .` command to add your module to the staging area of git

```
```shell
git add .
```

Use `git commit -s` command to commit your module, we recommend that your commit message follow the format "publish module <module_name>".
```

```shell
git commit -m "publish module helloworld" -s
```

Use `git push` command to submit your module to your branch `publish-pkg-<module_name>`

```
```shell
git push
```

Expand All @@ -117,7 +121,7 @@ After completing the upload of the module content, you can upgrade your module b

NOTE: **We do not provide any upgrade strategy that changes the content of the module but does not change the version number.** If you want to upgrade your module and want your upgraded module to be displayed on AH, you need to modify the version number of your module. That is, the version field in the module section of the kcl.mod file.

```
```toml
[package]
name = "my_module"
edition = "*"
Expand Down

0 comments on commit 1f54f3c

Please sign in to comment.