From b876796cdfd311670a8137e412f931c02723a546 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 28 Nov 2021 21:01:08 +0800 Subject: [PATCH] docs: update doc --- .github/workflows/vercel.yml | 7 +- .gitignore | 1 + .../kernel-principle/installation-startup.md | 73 +++--------------- .../installation-startup.zh-CN.md | 74 +++---------------- docs/reference/collection.md | 6 +- docs/reference/database.md | 3 +- 6 files changed, 33 insertions(+), 131 deletions(-) diff --git a/.github/workflows/vercel.yml b/.github/workflows/vercel.yml index 39f019e76..1f14796f2 100644 --- a/.github/workflows/vercel.yml +++ b/.github/workflows/vercel.yml @@ -4,7 +4,6 @@ on: push: branches: - develop - - feature/docs jobs: deploy: @@ -25,10 +24,10 @@ jobs: restore-keys: | ${{ runner.os }}-node- - - run: npm install - - run: npm run bootstrap + - run: yarn install + - run: yarn bootstrap - run: echo "API_URL=${{ secrets.API_URL }}" >> .env - - run: npm run build-docs + - run: yarn build-docs - name: Deploy uses: amondnet/vercel-action@v19 diff --git a/.gitignore b/.gitignore index c84fdf1e4..ce24c4229 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules/ lib/ +esm/ .env .DS_Store package-lock.json diff --git a/docs/guide/kernel-principle/installation-startup.md b/docs/guide/kernel-principle/installation-startup.md index ea3980e3e..b64bccc46 100644 --- a/docs/guide/kernel-principle/installation-startup.md +++ b/docs/guide/kernel-principle/installation-startup.md @@ -4,68 +4,17 @@ order: 3 # Installation and Startup Process -## Installation +## app.init -```bash -yarn nocobase init -``` +- app.load() +- db.sync() +- db.emitAsync('init') -- app.constructor() -- app.parse() - - yarn nocobase init - Initialize the installation - - app.load() - Load the configuration - - app.exitAsync('beforeLoad') - Hook before all configurations are loaded - - app.pluginManager.load() - Load the configurations of all active plugins in order - - Load the configuration of plugin-collections - - Add app.on('init') listener - - db.getModel('collections').load() - Import the collections table configuration into db.table() - - app.db.sync({force: false}) - Execute sync again to create the data table configured in the collections table - - app.exitAsync('afterLoad') - All hooks after the configuration is loaded - - app.db.sync({force: true}) - Generate data tables, fields, indexes, etc. according to the configuration - - app.emitAsync('init') - Perform all init listeners, generally initialized data operations - - trigger the init event of plugin-collections and the data table is created - - app.stop() - End +## app.start -## Startup - -```bash -yarn nocobase start --init --sync -# --init for quick installation at startup -# --sync to quickly build or update tables when app.collection() is updated in the development environment -``` - -- app.constructor() -- app.parse() - - yarn nocobase start - Initialize the installation - - app.load() - Load the configuration - - app.exitAsync('beforeLoad') - Hook before all configurations are loaded - - app.pluginManager.load() - Load the configurations of all active plugins in order - - Load the configuration of plugin-collections - - Add app.on('start') listener - - db.getModel('collections').load() - Import the collections table configuration into db.table(), no need for db.sync in the start process - - app.exitAsync('afterLoad') - All hooks after configuration loading - - app.db.sync({force: false}) - yarn nocobase start --sync to quickly build or update tables when there are updates - yarn nocobase start --init quick init - - app.emitAsync('init') - yarn nocobase start --init shortcut init - - app.exitAsync('start') - Execute all start listeners, usually reading some necessary data from the data table - - app.listen() - Start the http server +- app.load() +- db.emitAsync('start') + - Load the collections configuration in the database + - Load the pm configuration in the database + - Start the activated plugin +- app.listen() diff --git a/docs/guide/kernel-principle/installation-startup.zh-CN.md b/docs/guide/kernel-principle/installation-startup.zh-CN.md index f7027f630..1b4a8fbcd 100644 --- a/docs/guide/kernel-principle/installation-startup.zh-CN.md +++ b/docs/guide/kernel-principle/installation-startup.zh-CN.md @@ -4,70 +4,18 @@ order: 3 # 项目安装和启动流程 -## 项目安装 +## app.init -```bash -yarn nocobase init -``` +- app.load() +- db.sync() +- db.emitAsync('init') -- app.constructor() -- app.parse() - - yarn nocobase init - 初始化安装 - - app.load() - 加载配置 - - app.emitAsync('beforeLoad') - 所有配置加载之前的钩子 - - app.pluginManager.load() - 按顺序载入所有激活的插件的配置 - - 加载 plugin-collections 的配置 - - 添加 app.on('init') 监听 - - db.getModel('collections').load() - 把 collections 表的配置都导入 db.table() - - app.db.sync({force: false}) - 再执行 sync,创建 collections 表里配置的数据表 - - app.emitAsync('afterLoad') - 所有配置加载之后的钩子 - - app.db.sync({force: true}) - 根据配置生成数据表、字段、索引等 - - app.emitAsync('init') - 执行所有 init listeners,一般是初始化的数据操作 - - 触发 plugin-collections 的 init 事件,数据表就创建好了 - - app.stop() - 结束 +## app.start -## 项目启动 +- app.load() +- db.emitAsync('start') + - 加载数据库里的 collections 配置 + - 加载数据库里的 pm 配置 + - 启动激活的插件 +- app.listen() -```bash -yarn nocobase start --init --sync -# --init 用于启动时快捷安装 -# --sync 开发环境时,当 app.collection() 有更新时快速建表或更新表 -``` - - - -- app.constructor() -- app.parse() - - yarn nocobase start - 初始化安装 - - app.load() - 加载配置 - - app.emitAsync('beforeLoad') - 所有配置加载之前的钩子 - - app.pluginManager.load() - 按顺序载入所有激活的插件的配置 - - 加载 plugin-collections 的配置 - - 添加 app.on('start') 监听 - - db.getModel('collections').load() - 把 collections 表的配置都导入 db.table(),在 start 流程里不需要再 db.sync - - app.emitAsync('afterLoad') - 所有配置加载之后的钩子 - - app.db.sync({force: false}) - yarn nocobase start --sync 有更新时快速建表或更新表 - yarn nocobase start --init 快捷 init - - app.emitAsync('init') - yarn nocobase start --init 快捷 init - - app.emitAsync('start') - 执行所有 start listeners,一般是从数据表里读取一些必要的数据 - - app.listen() - 启动 http server diff --git a/docs/reference/collection.md b/docs/reference/collection.md index 46f9f1882..df5dc6115 100644 --- a/docs/reference/collection.md +++ b/docs/reference/collection.md @@ -194,7 +194,11 @@ await db.sequelize.models.posts_tags.sync(); ```ts interface updateField { - (name: string, options: FieldOptions): Field; + (name: string, data: FieldOptions, options?: UpdateFieldOptions): Field; +} + +interface UpdateFieldOptions { + force?: boolean; } ``` diff --git a/docs/reference/database.md b/docs/reference/database.md index d8cef8a12..1d26fbfca 100644 --- a/docs/reference/database.md +++ b/docs/reference/database.md @@ -222,7 +222,8 @@ collection 的事件(都是同步的) model 的事件(异步的) -- `.` +- `` +- `.` ##### Examples