commit b2e3c34b0d8df15fe19032faa6dbd8e10ca15346 Author: 前道 Date: Wed Oct 30 10:36:02 2019 +0800 Init project diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..8fef25970 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..cfb30e46b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "semi": true, + "singleQuote": true, + "trailingComma": "es5" +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 000000000..2867acfe4 --- /dev/null +++ b/README.md @@ -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 ` + +#### 跑起来: + + - `tnpm i` + - `npm run boot` + - `npm run build` + +#### Link & unlink + + - `cd packages/ && tnpm link -g` + - `tnpm link @ali/` + + - `tnpm unlink @ali/` + +#### 开发过程中: + + - `git add ` + - `git cz` + +## 发布 + + - `npm run pub` + +## 注意 + + - Commit 动作尽量使用 `git cz`,方便按语义化版本自动递增,以及自动生成 `CHANGELOG.md` + - `packages` 工程里一些开发时公共依赖(比如:`typescript`、`ava` 等)会放到工程顶层 + - 工程里的 `.md`、`test/` 等文件修改不会产生新的发布 + - 当工程里存在多个 ts 文件的目录时,最终产生的文件会按文件夹形式放到 `lib` 下 + +## 包权限管理 + + - `npm owner ls @ali/ --registry http://registry.npm.alibaba-inc.com` + - `npm owner add @ali/ --registry http://registry.npm.alibaba-inc.com` + - `npm owner rm @ali/ --registry http://registry.npm.alibaba-inc.com ` diff --git a/create.sh b/create.sh new file mode 100755 index 000000000..621cb5e01 --- /dev/null +++ b/create.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +DIR_NAME=$1 + +if [ -z $DIR_NAME ];then + echo 'Usage: ./create.sh ' + 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.' diff --git a/docs/code-specification.md b/docs/code-specification.md new file mode 100644 index 000000000..4c42cd0c7 --- /dev/null +++ b/docs/code-specification.md @@ -0,0 +1,37 @@ +编码规约 +--- + +### 命名 + + - 使用 `PascalCase` 为类型命名 + - 使用 `I` 做为接口名前缀 + - 使用 `PascalCase` 为枚举值命名 + - 使用 `camelCase` 为函数命名 + - 使用 `camelCase` 为属性或本地变量命名 + - 不要为私有属性名添加 `_` 前缀 + - 尽可能使用完整的单词拼写命名 + - 文件夹命名统一使用小写 + +### 组件 + + - 一个文件对应一个组件或类 + +### 类型 + + - 不要随意导出类型/函数,除非你要在不同的组件中共享它 + - 不要在全局命名空间内定义类型/值 + - 共享的类型应该在 `types.ts` 里定义 + - 在一个文件里,类型定义应该出现在顶部 + - interface 和 type 很类似,原则上能用 interface 实现,就用 interface , 如果不能才用 type + +### 注释 + + - 为函数,接口,枚举类型和类使用 JSDoc 风格的注释 + +### 字符串 + + - 使用单引号 `''` + +### 单元测试 + + - 单元测试文件根据文件目录结构来放置 diff --git a/lerna.json b/lerna.json new file mode 100644 index 000000000..43deefa0f --- /dev/null +++ b/lerna.json @@ -0,0 +1,17 @@ +{ + "lerna": "2.11.0", + "version": "independent", + "npmClient": "tnpm", + "command": { + "publish": { + "ignoreChanges": [ + "**/*.md", + "**/test/**" + ], + "conventionalCommits": true + } + }, + "packages": [ + "packages/*" + ] +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..556aca8c7 --- /dev/null +++ b/package.json @@ -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" + } + } +} diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 000000000..8a19be8bd --- /dev/null +++ b/templates/README.md @@ -0,0 +1,2 @@ +TODO +--- diff --git a/templates/_tsconfig.json b/templates/_tsconfig.json new file mode 100644 index 000000000..70a9c6a64 --- /dev/null +++ b/templates/_tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib" + } +} \ No newline at end of file diff --git a/templates/package.json b/templates/package.json new file mode 100644 index 000000000..4a796fc8a --- /dev/null +++ b/templates/package.json @@ -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" +} diff --git a/templates/src/index.ts b/templates/src/index.ts new file mode 100644 index 000000000..8337712ea --- /dev/null +++ b/templates/src/index.ts @@ -0,0 +1 @@ +// diff --git a/templates/test/foobar.ts b/templates/test/foobar.ts new file mode 100644 index 000000000..7a14c4b2d --- /dev/null +++ b/templates/test/foobar.ts @@ -0,0 +1,5 @@ +import test from 'ava'; + +test('foobar', t => { + t.pass(); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..4719291d5 --- /dev/null +++ b/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/tslint.json b/tslint.json new file mode 100644 index 000000000..7ad2bb75a --- /dev/null +++ b/tslint.json @@ -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 + } +} \ No newline at end of file