diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..4bd9688 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,15 @@ +kind: pipeline +type: kubernetes +name: default + +clone: + pull: if-not-exists + +steps: +- name: test + image: golang:1.16.8-buster +# trigger: +# branch: +# - test +# event: +# - push \ No newline at end of file diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100644 index 0000000..cb5e38e --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,31 @@ +#!/bin/sh + +# 用 `` 可以将命令的输出结果赋值给变量 +# 获取当前提交的 commit msg +commit_msg=`cat $1` + +# 获取用户 email +email=`git config user.email` +msg_re="^(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|release|workflow)(\(.+\))?: .{1,100}" + +if [[ ! $commit_msg =~ $msg_re ]] +then + echo "\n不合法的 commit 消息提交格式,请使用正确的格式:\ + \nfeat: add comments\ + \nfix: handle events on blur (close #28)\ + \n详情请查看 git commit 提交规范:https://github.com/woai3c/Front-end-articles/blob/master/git%20commit%20style.md" + + # 异常退出 + exit 1 +fi + +# 对用户权限做判断则比较简单,只需要检查用户的邮箱或用户名就可以了 +#(假设现在只有 abc 公司的员工才有权限提交代码)。 +email_re="@abc\.com" +if [[ ! $email =~ $email_re ]] +then + echo "此用户没有权限,具有权限的用户为: xxx@abc.com" + + # 异常退出 + exit 1 +fi \ No newline at end of file diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000..07852b2 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,6 @@ +#!/bin/sh +npm run lint + +# 获取上面脚本的退出码 +exitCode="$?" +exit $exitCode \ No newline at end of file diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore index 4d29575..29b28f6 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,57 @@ npm-debug.log* yarn-debug.log* yarn-error.log* +# ---> C +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..33afc46 --- /dev/null +++ b/.releaserc @@ -0,0 +1,24 @@ +{ + "branches": ["master", "test"], + "plugins": [ + ["@semantic-release/commit-analyzer", { + "preset": "angular", + "releaseRules": [ + {"type": "docs", "scope":"README", "release": "patch"}, + {"type": "refactor", "release": "patch"}, + {"type": "style", "release": "patch"} + ], + "parserOpts": { + "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"] + } + }], + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + "@semantic-release/git", + ["@saithodev/semantic-release-gitea", { + "giteaUrl": "https://git.1000my.com", + {"path": ".", "label": "源文件代码"} + }], + ], + "tagFormat": "${process.env.GOOS}_v${version}" +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bd29e08 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base +#拷贝项目publish文件夹中的所有文件到 docker容器中的publish文件夹中 +# COPY . /publish \ No newline at end of file diff --git a/README.md b/README.md index 9c40dcd..117e01f 100644 --- a/README.md +++ b/README.md @@ -66,3 +66,32 @@ This section has moved here: https://facebook.github.io/create-react-app/docs/de ### `yarn build` fails to minify This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify + +# template_common + +基础仓库模板 + +## 项目目录 + +``` +项目目录 +├── .drone.yml CI配置文件 +├── .githooks githooks文件夹 +│ ├── commit-msg +│ ├── pre-commit +│ └── pre-push +├── .gitignore git忽略文件 +├── .releaserc semantic-release配置文件 +├── Dockerfile docker打包文件 +└── README.md 项目说明文件 +``` + +## 项目流程 + +1. web 页面 fork **common** 组织下的相应仓库并设置具体见文档 +2. `git clone` 到本地 +3. 配置 .githooks + `git config core.hooksPath .githooks` + mac 和 linux 下 + `chmod 700 .githooks/*` +4. 开发 见具体文档