Init project

This commit is contained in:
前道 2019-10-30 10:36:02 +08:00
commit b2e3c34b0d
14 changed files with 337 additions and 0 deletions

86
.gitignore vendored Normal file
View File

@ -0,0 +1,86 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
lib
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# mac config files
.DS_Store

5
.prettierrc Normal file
View File

@ -0,0 +1,5 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
}

55
README.md Normal file
View File

@ -0,0 +1,55 @@
Ali Lowcode Engine阿里低代码引擎
---
[Lerna](https://github.com/lerna/lerna) + [TS](https://www.typescriptlang.org/)
## 准备
```bash
npm login --registry http://registry.npm.alibaba-inc.com --scope @ali
```
```bash
tnpm i -g git-cz
```
## 开发
#### 创建新包:
- `./create.sh <package-name>`
#### 跑起来:
- `tnpm i`
- `npm run boot`
- `npm run build`
#### Link & unlink
- `cd packages/<package-name> && tnpm link -g`
- `tnpm link @ali/<package-name>`
- `tnpm unlink @ali/<package-name>`
#### 开发过程中:
- `git add <your-files>`
- `git cz`
## 发布
- `npm run pub`
## 注意
- Commit 动作尽量使用 `git cz`,方便按语义化版本自动递增,以及自动生成 `CHANGELOG.md`
- `packages` 工程里一些开发时公共依赖(比如:`typescript``ava` 等)会放到工程顶层
- 工程里的 `.md``test/` 等文件修改不会产生新的发布
- 当工程里存在多个 ts 文件的目录时,最终产生的文件会按文件夹形式放到 `lib`
## 包权限管理
- `npm owner ls @ali/<pkg> --registry http://registry.npm.alibaba-inc.com`
- `npm owner add <user> @ali/<pkg> --registry http://registry.npm.alibaba-inc.com`
- `npm owner rm <user> @ali/<pkg> --registry http://registry.npm.alibaba-inc.com `

21
create.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
DIR_NAME=$1
if [ -z $DIR_NAME ];then
echo 'Usage: ./create.sh <folder-name>'
exit 0
fi
if [ -d packages/$DIR_NAME ];then
echo 'Folder is existing!'
exit 0
fi
mkdir packages/$DIR_NAME
cp -r templates/* packages/$DIR_NAME
mv packages/$DIR_NAME/_tsconfig.json packages/$DIR_NAME/tsconfig.json
echo 'Add package successfully.'

View File

@ -0,0 +1,37 @@
编码规约
---
### 命名
- 使用 `PascalCase` 为类型命名
- 使用 `I` 做为接口名前缀
- 使用 `PascalCase` 为枚举值命名
- 使用 `camelCase` 为函数命名
- 使用 `camelCase` 为属性或本地变量命名
- 不要为私有属性名添加 `_` 前缀
- 尽可能使用完整的单词拼写命名
- 文件夹命名统一使用小写
### 组件
- 一个文件对应一个组件或类
### 类型
- 不要随意导出类型/函数,除非你要在不同的组件中共享它
- 不要在全局命名空间内定义类型/值
- 共享的类型应该在 `types.ts` 里定义
- 在一个文件里,类型定义应该出现在顶部
- interface 和 type 很类似,原则上能用 interface 实现,就用 interface , 如果不能才用 type
### 注释
- 为函数,接口,枚举类型和类使用 JSDoc 风格的注释
### 字符串
- 使用单引号 `''`
### 单元测试
- 单元测试文件根据文件目录结构来放置

17
lerna.json Normal file
View File

@ -0,0 +1,17 @@
{
"lerna": "2.11.0",
"version": "independent",
"npmClient": "tnpm",
"command": {
"publish": {
"ignoreChanges": [
"**/*.md",
"**/test/**"
],
"conventionalCommits": true
}
},
"packages": [
"packages/*"
]
}

49
package.json Normal file
View File

@ -0,0 +1,49 @@
{
"name": "ali-lowcode-engine",
"private": true,
"scripts": {
"boot": "lerna bootstrap --registry http://registry.npm.alibaba-inc.com",
"clean": "rimraf ./packages/*/lib ./packages/*/node_modules",
"pub": "npm run test && lerna publish --registry http://registry.npm.alibaba-inc.com",
"lint": "tslint -p tsconfig.json",
"lint:fix": "tslint --fix -p tsconfig.json",
"build": "lerna run build",
"test": "lerna run test"
},
"devDependencies": {
"@types/node": "^10.12.18",
"ava": "^1.0.1",
"commitizen": "^3.0.5",
"cz-conventional-changelog": "^2.1.0",
"husky": "^1.3.1",
"lerna": "^2.11.0",
"lint-staged": "^8.1.0",
"prettier": "^1.15.3",
"rimraf": "^2.6.3",
"ts-node": "^7.0.1",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.2.2"
},
"engines": {
"node": "^8 || ^10"
},
"lint-staged": {
"*.ts": [
"prettier --write",
"tslint --fix -p tsconfig.json",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
}
}
}

2
templates/README.md Normal file
View File

@ -0,0 +1,2 @@
TODO
---

6
templates/_tsconfig.json Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib"
}
}

23
templates/package.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "@ali/lowcode-engine-",
"version": "0.0.0",
"description": "xxx for Ali lowCode engine",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"build": "tsc",
"test": "ava"
},
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
},
"license": "MIT"
}

1
templates/src/index.ts Normal file
View File

@ -0,0 +1 @@
//

5
templates/test/foobar.ts Normal file
View File

@ -0,0 +1,5 @@
import test from 'ava';
test('foobar', t => {
t.pass();
});

16
tsconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es6",
"lib": ["esnext", "dom"],
"module": "commonjs",
"strict": true,
"declaration": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"sourceMap": true
},
"exclude": [
"**/test",
"**/lib"
]
}

14
tslint.json Normal file
View File

@ -0,0 +1,14 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended",
"tslint-config-prettier"
],
"rulesDirectory": ["tslint-plugin-prettier"],
"rules": {
"prettier": true,
"object-literal-sort-keys": false,
"no-var-requires": false,
"no-console": false
}
}