Skip to content

Commit

Permalink
feat(cli): add --api-endpoint | rename --api-key (#136)
Browse files Browse the repository at this point in the history
- feat: add option `--api-endpoint` to set request OpenAI API endpoint
- refactor: rename `--openai-token` to `--api-key`
  > version compatibility has been completed
  • Loading branch information
Zhengqbbb authored Jul 8, 2023
1 parent 8af8454 commit 4bd33f5
Show file tree
Hide file tree
Showing 43 changed files with 2,406 additions and 2,348 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: ['14', '16', '18']
node_version: ['16', '18', '20']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 50

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Use Node.js ${{ matrix.node }}
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node_version }}
cache: pnpm

- name: Install dependencies
Expand Down
37 changes: 0 additions & 37 deletions .x-cmd/build

This file was deleted.

5 changes: 5 additions & 0 deletions .x-cmd/bump
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# shellcheck shell=dash

(
x bun x taze -r -I -i
)
10 changes: 7 additions & 3 deletions .x-cmd/deploy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# shellcheck shell=bash disable=SC1091,SC2034,SC2154 #xsh
# shellcheck shell=dash
(

# Section: Arg
WORK_DIR="$(x wsroot)"
Expand All @@ -13,12 +14,13 @@ type:
Type = cz brew docs all next
Realse = patch minor major prepatch
options:
--command "select target dev command" <>:Type
--cmd "select target dev command" <>:Type
--version "select realse version" <>:Realse
'
param:run
deploy_"${command}" "$version"
deploy_"${cmd}" "$version"
}

deploy_all() {
[ -z "$github_access_token" ] && printf "%s\n" "please provide token" && return 1
deploy_cz "$@"
Expand Down Expand Up @@ -79,3 +81,5 @@ case "${1}" in
all) shift; deploy_all "$@" ;;
*) deploy ;;
esac

)
8 changes: 0 additions & 8 deletions .x-cmd/dev

This file was deleted.

40 changes: 13 additions & 27 deletions .x-cmd/search
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# shellcheck shell=bash disable=SC1091,SC2034,SC2154,SC2002 #xsh
# shellcheck shell=dash

(

# Section: Arg
WORK_DIR="$(x wsroot)"
Expand All @@ -11,10 +13,10 @@ search() {
type:
Type = only_console all google baidu bing docsearch
options:
--command "select target search command" <>:Type
--cmd "select target search command" <>:Type
'
param:run
search_"${command}"
search_"${cmd}"
}

log() {
Expand Down Expand Up @@ -45,41 +47,23 @@ search_google() {
search_baidu() {
log "baidu search console collecting"
local BAIDU_TOKEN
BAIDU_TOKEN="$(cat "$WORK_DIR/.env" | grep 'BAIDU_TOKEN')"
BAIDU_TOKEN="$(grep 'BAIDU_TOKEN' < "$WORK_DIR/.env")"
local TOKEN="${BAIDU_TOKEN#*=}"
[ -z "$TOKEN" ] && return 0
curl -H 'Content-Type:text/plain' --data-binary @urls.txt "http://data.zz.baidu.com/urls?site=$WEB_SITE&token=$TOKEN"
}

gen_txt_to_json() {
local length
printf "%s%s%s" "{" \
"\"siteUrl\": \"https://$WEB_SITE$TOKEN\"," \
"\"urlList\": ["
length="$(printf "%s" "$(cat "$WORK_DIR/urls.txt")" | awk 'END{print NR}')"
printf "%s" "$(cat "$WORK_DIR/urls.txt")" | awk -v col_length="$length" '{
if (col_length == NR) {
printf("\""$0"\"")
} else {
printf("\""$0"\""",")
}
}'
printf "%s" "]}"
}

search_bing() {
log "bing search console collecting"
curl -X GET "http://www.bing.com/webmaster/ping.aspx?siteMap=https://$WEB_SITE/sitemap.xml"
# curl -X GET "http://www.bing.com/webmaster/ping.aspx?siteMap=https://$WEB_SITE/sitemap.xml"
local BING_TOKEN
local URL_JSON
URL_JSON="$(gen_txt_to_json)"
BING_TOKEN="$(cat "$WORK_DIR/.env" | grep 'BING_TOKEN')"
BING_TOKEN="$(grep 'BING_TOKEN' < "$WORK_DIR/.env")"
local TOKEN="${BING_TOKEN#*=}"
[ -z "$TOKEN" ] && [ ! -f "$WORK_DIR/urls.txt" ] && return 0
curl "https://ssl.bing.com/webmaster/api.svc/json/SubmitUrlbatch?apikey=$TOKEN" \
-X POST \
-H 'Content-Type: application/json;charset=UTF-8' \
-d "$URL_JSON"
-H 'Content-Type: application/json;charset=utf-8' \
-d "$(x jo "{siteUrl: 'https://${WEB_SITE}', urlList: [ $(awk '{ print "\"" $0 "\"" }' < "$WORK_DIR/urls.txt") ]}")"
}

search_docsearch() {
Expand All @@ -89,7 +73,7 @@ search_docsearch() {
echo 'APPLICATION_ID=your_algolia_application_id' >> "$env_file_path" && \
echo 'APPLICATION_ID=your_algolia_api_key' >> "$env_file_path" && \
return 1
docker run -it --env-file=.env -e "CONFIG=$(cat "${DOC_SEARCH_CONFIG_FILE}" | x jq -r tostring)" algolia/docsearch-scraper
docker run -it --env-file=.env -e "CONFIG=$(x jq -r tostring < "${DOC_SEARCH_CONFIG_FILE}")" algolia/docsearch-scraper
}

# Section: Main
Expand All @@ -102,3 +86,5 @@ case "${1}" in
all) search_all ;;
*) search ;;
esac

)
8 changes: 0 additions & 8 deletions .x-cmd/test

This file was deleted.

10 changes: 10 additions & 0 deletions .x-cmd/tmux-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# shellcheck shell=sh disable=SC1091,SC2034 #xsh
(
# Section: Arg
WORK_DIR="$(x wsroot)"

# Section: Main
x tmux kill-serve
x tmux
)

6 changes: 4 additions & 2 deletions docs/.vitepress/components.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const npm = 'https://www.npmjs.com/package/cz-git'
export const twitter = 'https://twitter.com/zhengqbbb'

/** package info */
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
export const { version } = require('cz-git/package.json')

/* PWA runtime caching urlPattern regular expressions */
Expand Down
2 changes: 1 addition & 1 deletion docs/faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sitemap:

- Windows users are advised not to use powershell, cmd for command line use
- because they are not based on the POSIX SHELL specification, i.e. not a standard terminal environment
- It is recommended not to use gitbash, because the terminal is not an interactive terminal, and the selection up and down will be effected
- It is recommended not to use git-bash, because the terminal is not an interactive terminal, and the selection up and down will be effected
- **It is recommended to use Windows Terminal combined with WSL, you should also do the same in daily development and use**

## Cannot find command after global install
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ echo '{ "path": "cz-git", "$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/cz-g
```

#### Step 3: Add custom configuration (optional, use default configuration)
> There are ==two== configuration methods
> There are **two** configuration methods
<br>

**Method 1:** Edit the `~/.czrc` file to add configuration in the form of **json**, for example:
**Method 1:** Edit the `~/.czrc` file to add configuration in the form of `JSON`, for example:
```json{3}
{
"path": "cz-git",
"useEmoji": true
}
```

**Method 2: Cooperate with [commitlint](https://github.com/conventional-changelog/commitlint)** to create a configuration file under the path of `$HOME` <br>([↓ Configuration Template](/config/#configure-template))
**Method 2**: Cooperate with [commitlint](https://github.com/conventional-changelog/commitlint) to create a configuration file under the path of `$HOME` <br>([↓ Configuration Template](/config/#configure-template))
4 changes: 2 additions & 2 deletions docs/guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sitemap:

<p align="center">
<a target="_blank" href="https://github.com/Zhengqbbb/cz-git">
<img src="https://user-images.githubusercontent.com/40693636/154064210-964aeaa0-d9dc-4cea-9e52-2ffc3789611b.png" alt="cz-git-logo" width="400" data-width="400" data-height="400">
<img src="/images/logo.png" alt="cz-git-logo" width="400" data-width="400" data-height="400">
</a>
</p>

Expand Down Expand Up @@ -71,7 +71,7 @@ added 1 package in 0.582s

[⇒ Why cz-git](/guide/why.html)

[⇒ Why to develop this plugin:My development journey story](https://www.qbb.sh/posts/2022-12-26-cz-git-czg-journey-zh)
[⇒ Why to develop this plugin:My development journey story](https://www.qbb.sh/posts/2022-12-26-cz-git-czg-journey)

## Projects using cz-git

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hero:
text: ""
tagline: More engineered, lightweight, customizable, standard output format Commitizen adapter and Git commit CLI.
image:
src: https://user-images.githubusercontent.com/40693636/154064210-964aeaa0-d9dc-4cea-9e52-2ffc3789611b.png
src: /images/logo.png
alt: cz-git
actions:
- theme: brand
Expand Down
23 changes: 11 additions & 12 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@
"docs:serve": "vitepress serve --port 8000"
},
"dependencies": {
"@vueuse/core": "^9.12.0",
"shiki": "0.14.1",
"vue": "^3.2.47"
"@vueuse/core": "^10.2.1",
"shiki": "0.14.2",
"vue": "^3.3.4"
},
"devDependencies": {
"@iconify-json/carbon": "^1.1.15",
"@iconify-json/simple-icons": "^1.1.44",
"@iconify-json/carbon": "^1.1.18",
"@iconify-json/simple-icons": "^1.1.59",
"@types/markdown-it": "^12.2.3",
"@unocss/reset": "^0.49.4",
"@unocss/reset": "^0.51.13",
"@vite-pwa/vitepress": "^0.0.5",
"@vitejs/plugin-vue": "^4.0.0",
"markdown-it-container": "^3.0.0",
"markdown-it-mark": "^3.0.1",
"medium-zoom": "^1.0.8",
"sitemap": "^7.1.1",
"unocss": "^0.49.4",
"unplugin-vue-components": "^0.23.0",
"vite": "^4.1.1",
"vite-plugin-pwa": "^0.14.4",
"vitepress": "npm:@qbbsh/vitepress@1.0.0-alpha.46-1"
"unocss": "^0.51.13",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.4.2",
"vite-plugin-pwa": "^0.14.7",
"vitepress": "npm:@qbbsh/vitepress@1.0.0-beta.5-1"
}
}
2 changes: 1 addition & 1 deletion docs/zh/faq/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sitemap:

- Windows用户建议不要使用 powershell, cmd 进行命令行的使用
- 因为他们不是基于 POSIX SHELL 规范,即不是标准终端环境
- 建议也不要使用 gitbash,因为该终端并不是交互型终端,上下选择会受到很大的使用体验
- 建议也不要使用 git-bash,因为该终端并不是交互型终端,上下选择以及交互体验上会受到很大的使用体验
- **建议使用 Windows Terminal 结合 WSL ,你在日常的开发和使用中也应该如此**

## 全局安装后无法找到命令
Expand Down
6 changes: 3 additions & 3 deletions docs/zh/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ echo '{ "path": "cz-git", "$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/cz-g
```

#### 步骤 3: 添加自定义配置(可选,使用默认配置)
>==两种== 配置方式
>**两种** 配置方式
<br>

**方式一:** 编辑 `~/.czrc` 文件以 ==json== 形式添加配置, 例如:
**方式一** : 编辑 `~/.czrc` 文件以 `JSON` 格式添加配置, 例如:

```json{3}
{
Expand All @@ -138,4 +138,4 @@ echo '{ "path": "cz-git", "$schema": "https://cdn.jsdelivr.net/gh/Zhengqbbb/cz-g
}
```

**方式二: 与 [commitlint](https://github.com/conventional-changelog/commitlint) 配合**,在 `$HOME` 路径下创建配置文件 <br>([↓ 配置模板](/zh/config/))
**方式二** : 与 [commitlint](https://github.com/conventional-changelog/commitlint) 配合,在 `$HOME` 路径下创建配置文件 <br>([↓ 配置模板](/zh/config/))
2 changes: 1 addition & 1 deletion docs/zh/guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sitemap:

<p align="center">
<a target="_blank" href="https://github.com/Zhengqbbb/cz-git">
<img src="https://user-images.githubusercontent.com/40693636/154064210-964aeaa0-d9dc-4cea-9e52-2ffc3789611b.png" alt="cz-git-logo" width="400" data-width="400" data-height="400">
<img src="/images/logo.png" alt="cz-git-logo" width="400" data-width="400" data-height="400">
</a>
</p>

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hero:
工程性更强,轻量级,高度自定义,
输出标准格式的 Commitizen 适配器和 CLI
image:
src: https://user-images.githubusercontent.com/40693636/154064210-964aeaa0-d9dc-4cea-9e52-2ffc3789611b.png
src: /images/logo.png
alt: cz-git
actions:
- theme: brand
Expand Down
Loading

0 comments on commit 4bd33f5

Please sign in to comment.