Skip to content

Commit 54729e0

Browse files
committed
add npm plugin
0 parents  commit 54729e0

File tree

5 files changed

+149
-0
lines changed

5 files changed

+149
-0
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
[*.md]
11+
insert_final_newline = false
12+
trim_trailing_whitespace = false
13+
[*.yml]
14+
indent_size = 2
15+
[*.json]
16+
indent_size = 2

plugins/npm/README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# plugins for Coding-CI
2+
3+
## Contributing
4+
5+
Q: 我有一个好插件,希望大家都可以用上,应该如何贡献到镜像插件市场中?
6+
7+
A: 恭喜你,找对地方了,这篇文章就是解释这个问题的!
8+
9+
## Step by step
10+
11+
### 前提
12+
13+
1. 已经制作好了插件。
14+
3. 有 Git 和工蜂操作的相关经验。
15+
16+
### Step 0
17+
18+
fork 本项目,在 `plugins` 目录下创建插件子目录,比如 `plugins/example/plugin`
19+
20+
### Step 1
21+
22+
添加插件的 Meta 信息`plugin-meta.json` 到子目录中,字段如下:
23+
24+
```json
25+
{
26+
"name": "npm",
27+
"description": "发布 NPM 包到仓库,支持官方仓库和私有仓库",
28+
"tags": [ "publish", "npm" ],
29+
"mark": "社区",
30+
"images": "https://hub.docker.com/r/plugins/npm/tags",
31+
"source": "https://github.com/drone-plugins/drone-npm",
32+
"bugs": "https://github.com/drone-plugins/drone-npm/issues",
33+
"logo": "logo.svg"
34+
}
35+
```
36+
- `name`: 插件名称,需要全英文,单词之间以中划线`-`分隔。
37+
- `description`: 插件描述,简单介绍插件作用。
38+
- `tags`: 标签,是一个字符串数组,填写前可以先参照已有的标签填写,收敛以便检索,若没有合适的,可以自创。
39+
- `mark`: 角标。目前只可填 `官方``社区` 两种。
40+
- `images`: 插件镜像地址。
41+
- `source`: 源码地址。
42+
- `bugs`: 问题反馈地址。
43+
- `logo`: logo 图片相对地址。如果没有,可以不填。图片规格最好为正方形,尺寸大于 200 x 200 即可。
44+
45+
### Step 2
46+
47+
提交修改,发起 PR 等待自动检查工具通过和人工审核。

plugins/npm/plugin-meta.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "npm",
3+
"description": "发布 NPM 包到仓库,支持官方仓库和私有仓库",
4+
"mark": "社区",
5+
"images": "https://hub.docker.com/r/plugins/npm/tags",
6+
"source": "https://github.com/drone-plugins/drone-npm",
7+
"bugs": "https://github.com/drone-plugins/drone-npm/issues",
8+
"tags": [
9+
"publish",
10+
"npm"
11+
],
12+
"logo": "logo.svg"
13+
}

plugins/npm/publish/README.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# npm
2+
3+
`npm publish`,支持官方仓库和私有仓库。
4+
5+
## 输入
6+
7+
- `username`: `string` 用户名
8+
- `password`: `string` 密码
9+
- `token`: `string` token方式鉴权
10+
- `email`: `string` 邮箱
11+
- `registry`: `string` registry,默认:`https://registry.npmjs.org`
12+
- `folder`: `string` 要发布的目录,默认当前目录。
13+
- `fail_on_version_conflict`: `boolean` 版本存在时报错退出
14+
- `tag`: `boolean` NPM publish tag `--tag`
15+
- `access`: `string` NPM scoped package access `--access`
16+
17+
## 在 Coding-CI 上使用
18+
19+
### 发布到私有仓库
20+
21+
```yaml
22+
master:
23+
push:
24+
- stages:
25+
- name: npm publish
26+
image: plugins/npm
27+
imports: https://your-git.com/xxx/npm-token.yml
28+
settings:
29+
username: $NPM_USER
30+
password: $NPM_PASS
31+
email: $NPM_EMAIL
32+
registry: https://your-npm-registry.com/
33+
folder: ./
34+
fail_on_version_conflict: true
35+
```
36+
37+
`package.json` 文件需要声明相同的 `registry`,以通过 npm 校验
38+
39+
```json
40+
{
41+
"name": "xxx",
42+
"version": "xxx",
43+
"publishConfig": {
44+
"registry": "https://your-npm-registry.com/"
45+
}
46+
}
47+
```
48+
49+
### 发布到 npm 官方仓库
50+
51+
```yaml
52+
master:
53+
push:
54+
- stages:
55+
- name: npm publish
56+
image: plugins/npm
57+
imports: https://your-git.com/xxx/npm-token.yml
58+
settings:
59+
username: $NPM_USER
60+
password: $NPM_PASS
61+
email: $NPM_EMAIL
62+
folder: ./
63+
fail_on_version_conflict: true
64+
```

plugins/npm/publish/logo.svg

+9
Loading

0 commit comments

Comments
 (0)