diff --git a/.env.example b/.env.example index eeabcc873..1aadcc4d5 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,13 @@ +################# DOCKER ################# + +ADMINER_PORT=10101 +DB_MYSQL_PORT=10102 +DB_POSTGRES_PORT=10103 +VERDACCIO_PORT=10104 + +################# NOCOBASE APPLICATION ################# + NOCOBASE_ENV=development -JWT_SECRET=09f26e402586e2faa8da4c98a35f1b20d6b033c60 SERVER_PORT=3000 @@ -9,9 +17,12 @@ SERVER_BASE_PATH=/api/ # api server access point for app(web when build) SERVER_BASE_URL= -DB_DIALECT=sqlite -DB_STORAGE=db.sqlite +JWT_SECRET=09f26e402586e2faa8da4c98a35f1b20d6b033c60 +################# DATABASE ################# + +DB_DIALECT=sqlite +DB_STORAGE=storage/db/nocobase.sqlite # DB_HOST=localhost # DB_PORT=5432 # DB_DATABASE=postgres @@ -19,15 +30,15 @@ DB_STORAGE=db.sqlite # DB_PASSWORD=nocobase # DB_LOG_SQL=on -# STORAGE (Initialization only) +################# STORAGE (Initialization only) ################# # local or ali-oss DEFAULT_STORAGE_TYPE=local -STORAGE_TYPE=local # LOCAL STORAGE LOCAL_STORAGE_USE_STATIC_SERVER=true LOCAL_STORAGE_BASE_URL= +LOCAL_STORAGE_DEST=storage/uploads # ALI OSS STORAGE ALI_OSS_STORAGE_BASE_URL= diff --git a/README.md b/README.md index 9fcad5f2f..4a7d8974c 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,138 @@ Database: Installation ---------- +## Create a project with [Docker](https://docs.docker.com/get-docker/) (Recommended) + +### 1. Create an empty project directory + +```bash +mkdir my-nocobase-app && cd my-nocobase-app/ +``` + +### 2. Create a docker-compose.yml file + +#### SQLite + +```yml +version: "3" +networks: + nocobase: + driver: bridge +services: + app: + image: nocobase/nocobase:latest + networks: + - nocobase + environment: + - LOCAL_STORAGE_BASE_URL=http://localhost:13000/storage/uploads + volumes: + - ./storage:/app/nocobase/storage + ports: + - "13000:80" +``` + +#### MySQL + +```yml +version: "3" +networks: + nocobase: + driver: bridge +services: + app: + image: nocobase/nocobase:latest + networks: + - nocobase + environment: + - DB_DIALECT=mysql + - DB_HOST=mysql + - DB_DATABASE=nocobase + - DB_USER=nocobase + - DB_PASSWORD=nocobase + - LOCAL_STORAGE_BASE_URL=http://localhost:13000/storage/uploads + volumes: + - ./storage:/app/nocobase/storage + ports: + - "13000:80" + mysql: + image: mysql:8 + environment: + MYSQL_DATABASE: nocobase + MYSQL_USER: nocobase + MYSQL_PASSWORD: nocobase + MYSQL_ROOT_PASSWORD: nocobase + restart: always + networks: + - nocobase +``` + +#### PostgreSQL + +```yml +version: "3" +networks: + nocobase: + driver: bridge +services: + app: + image: nocobase/nocobase:latest + networks: + - nocobase + environment: + - DB_DIALECT=postgres + - DB_HOST=postgres + - DB_DATABASE=nocobase + - DB_USER=nocobase + - DB_PASSWORD=nocobase + - LOCAL_STORAGE_BASE_URL=http://localhost:13000/storage/uploads + volumes: + - ./storage:/app/nocobase/storage + ports: + - "13000:80" + postgres: + image: postgres:10 + restart: always + networks: + - nocobase + command: postgres -c wal_level=logical + environment: + POSTGRES_USER: nocobase + POSTGRES_DB: nocobase + POSTGRES_PASSWORD: nocobase +``` + +### 3. Install and start NocoBase + +安装过程可能需要等待几十秒钟 + +```bash +$ docker-compose up + +app-sqlite-app-1 | nginx started +app-sqlite-app-1 | yarn run v1.22.15 +app-sqlite-app-1 | $ cross-env DOTENV_CONFIG_PATH=.env node -r dotenv/config packages/app/server/lib/index.js install -s +app-sqlite-app-1 | Done in 2.72s. +app-sqlite-app-1 | yarn run v1.22.15 +app-sqlite-app-1 | $ pm2-runtime start --node-args="-r dotenv/config" packages/app/server/lib/index.js -- start +app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: Launching in no daemon mode +app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] starting in -fork mode- +app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] online +app-sqlite-app-1 | 🚀 NocoBase server running at: http://localhost:13000/ +``` + +你也可以使用 `docker-compose up -d` 在后台运行,如: + +```bash +# 在后台运行 +$ docker-compose up -d +# 查看 app 进程的情况 +$ docker-compose logs app +``` + +### 4. Log in to NocoBase + +使用浏览器打开 http://localhost:13000/ 初始化账号和密码是 `admin@nocobase.com` 和 `admin123`。 + ## Create a project with `create-nocobase-app` ~~~shell diff --git a/README.zh-CN.md b/README.zh-CN.md index f82045daf..f2f408449 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -60,6 +60,138 @@ Database: 安装 & 运行 ---------- +## 使用 [Docker](https://docs.docker.com/get-docker/) 创建项目(推荐) + +### 1. 创建项目文件夹 + +```bash +mkdir my-nocobase-app && cd my-nocobase-app/ +``` + +### 2. 创建 `docker-compose.yml` 文件 + +#### SQLite + +```yml +version: "3" +networks: + nocobase: + driver: bridge +services: + app: + image: nocobase/nocobase:latest + networks: + - nocobase + environment: + - LOCAL_STORAGE_BASE_URL=http://localhost:13000/storage/uploads + volumes: + - ./storage:/app/nocobase/storage + ports: + - "13000:80" +``` + +#### MySQL + +```yml +version: "3" +networks: + nocobase: + driver: bridge +services: + app: + image: nocobase/nocobase:latest + networks: + - nocobase + environment: + - DB_DIALECT=mysql + - DB_HOST=mysql + - DB_DATABASE=nocobase + - DB_USER=nocobase + - DB_PASSWORD=nocobase + - LOCAL_STORAGE_BASE_URL=http://localhost:13000/storage/uploads + volumes: + - ./storage:/app/nocobase/storage + ports: + - "13000:80" + mysql: + image: mysql:8 + environment: + MYSQL_DATABASE: nocobase + MYSQL_USER: nocobase + MYSQL_PASSWORD: nocobase + MYSQL_ROOT_PASSWORD: nocobase + restart: always + networks: + - nocobase +``` + +#### PostgreSQL + +```yml +version: "3" +networks: + nocobase: + driver: bridge +services: + app: + image: nocobase/nocobase:latest + networks: + - nocobase + environment: + - DB_DIALECT=postgres + - DB_HOST=postgres + - DB_DATABASE=nocobase + - DB_USER=nocobase + - DB_PASSWORD=nocobase + - LOCAL_STORAGE_BASE_URL=http://localhost:13000/storage/uploads + volumes: + - ./storage:/app/nocobase/storage + ports: + - "13000:80" + postgres: + image: postgres:10 + restart: always + networks: + - nocobase + command: postgres -c wal_level=logical + environment: + POSTGRES_USER: nocobase + POSTGRES_DB: nocobase + POSTGRES_PASSWORD: nocobase +``` + +### 3. 安装并启动 NocoBase + +安装过程可能需要等待几十秒钟 + +```bash +$ docker-compose up + +app-sqlite-app-1 | nginx started +app-sqlite-app-1 | yarn run v1.22.15 +app-sqlite-app-1 | $ cross-env DOTENV_CONFIG_PATH=.env node -r dotenv/config packages/app/server/lib/index.js install -s +app-sqlite-app-1 | Done in 2.72s. +app-sqlite-app-1 | yarn run v1.22.15 +app-sqlite-app-1 | $ pm2-runtime start --node-args="-r dotenv/config" packages/app/server/lib/index.js -- start +app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: Launching in no daemon mode +app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] starting in -fork mode- +app-sqlite-app-1 | 2022-04-28T15:45:38: PM2 log: App [index:0] online +app-sqlite-app-1 | 🚀 NocoBase server running at: http://localhost:13000/ +``` + +你也可以使用 `docker-compose up -d` 在后台运行,如: + +```bash +# 在后台运行 +$ docker-compose up -d +# 查看 app 进程的情况 +$ docker-compose logs app +``` + +### 4. 登录 NocoBase + +使用浏览器打开 http://localhost:13000/ 初始化账号和密码是 `admin@nocobase.com` 和 `admin123`。 + ## 通过 `create-nocobase-app` 创建项目 ~~~shell @@ -98,7 +230,7 @@ yarn nocobase install --lang=zh-CN yarn start ~~~ -使用浏览器打开 http://localhost:8000,初始化账号和密码是 `admin@nocobase.com` 和 `admin123`。 +使用浏览器打开 http://localhost:8000/ 初始化账号和密码是 `admin@nocobase.com` 和 `admin123`。 ## 参与贡献 diff --git a/docker-compose.yml b/docker-compose.yml index fcaf2875b..85922c7ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,30 +12,39 @@ services: restart: always ports: - "${VERDACCIO_PORT}:${VERDACCIO_PORT}" + mysql: + image: mysql:8 + environment: + MYSQL_DATABASE: ${DB_DATABASE} + MYSQL_USER: ${DB_USER} + MYSQL_PASSWORD: ${DB_PASSWORD} + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + restart: always + ports: + - "${DB_MYSQL_PORT}:3306" + networks: + - nocobase + postgres: + image: postgres:10 + restart: always + networks: + - nocobase + command: postgres -c wal_level=logical + ports: + - "${DB_POSTGRES_PORT}:5432" + environment: + POSTGRES_USER: ${DB_USER} + POSTGRES_DB: ${DB_DATABASE} + POSTGRES_PASSWORD: ${DB_PASSWORD} adminer: - build: - context: . - dockerfile: ./docker/adminer/Dockerfile + image: nocobase/adminer restart: always networks: - nocobase ports: - ${ADMINER_PORT}:8080 volumes: - - ./docker/adminer/login-sqlite-plugin.php:/var/www/html/plugins-enabled/login-sqlite-plugin.php - ./:/var/www/app - postgres: - image: postgres:10 - restart: always - ports: - - "${DB_POSTGRES_PORT}:5432" - networks: - - nocobase - command: postgres -c wal_level=logical - environment: - POSTGRES_USER: ${DB_USER} - POSTGRES_DB: ${DB_DATABASE} - POSTGRES_PASSWORD: ${DB_PASSWORD} nocobase: build: context: . diff --git a/docker/adminer/Dockerfile b/docker/adminer/Dockerfile deleted file mode 100644 index 4d6f300a2..000000000 --- a/docker/adminer/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM adminer - -USER root -CMD [ "php", "-S", "[::]:8080", "-t", "/var/www/html" ] - -EXPOSE 8080 \ No newline at end of file diff --git a/docker/adminer/login-sqlite-plugin.php b/docker/adminer/login-sqlite-plugin.php deleted file mode 100644 index 4090bce0f..000000000 --- a/docker/adminer/login-sqlite-plugin.php +++ /dev/null @@ -1,31 +0,0 @@ - - > - addEventListener('load', function () { - var driver = document.getElementsByName('auth[driver]')[0]; - if (isTag(driver, 'select')) { - driver.onchange = function () { - var trs = parentTag(driver, 'table').rows; - for (var i=1; i < trs.length - 1; i++) { var disabled=/sqlite/.test(driver.value); alterClass(trs[i], 'hidden' , disabled); trs[i].getElementsByTagName('input')[0].disabled=disabled; } }; } driver.onchange(); }); - { if (!commandOptions.dbDialect || commandOptions.dbDialect === 'sqlite' || envs['DB_STORAGE']) { return { dialect: 'sqlite', - storage: envs['DB_STORAGE'] || 'db.sqlite', + storage: envs['DB_STORAGE'] || 'storage/db/nocobase.sqlite', }; } diff --git a/packages/core/create-nocobase-app/src/resources/files/storage/.gitignore b/packages/core/create-nocobase-app/src/resources/files/storage/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/packages/core/create-nocobase-app/src/resources/files/storage/db/.gitignore b/packages/core/create-nocobase-app/src/resources/files/storage/db/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/packages/core/create-nocobase-app/src/resources/files/storage/db/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/packages/core/create-nocobase-app/src/resources/files/storage/uploads/.gitignore b/packages/core/create-nocobase-app/src/resources/files/storage/uploads/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/packages/core/create-nocobase-app/src/resources/files/storage/uploads/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/packages/core/create-nocobase-app/src/resources/templates/env.template b/packages/core/create-nocobase-app/src/resources/templates/env.template index f6652e992..a098e41e0 100644 --- a/packages/core/create-nocobase-app/src/resources/templates/env.template +++ b/packages/core/create-nocobase-app/src/resources/templates/env.template @@ -1,26 +1,31 @@ +################# NOCOBASE APPLICATION ################# + NOCOBASE_ENV=development +JWT_SECRET=<%= jwtSecret %> SERVER_HOST=0.0.0.0 SERVER_PORT=3000 -JWT_SECRET=<%= jwtSecret %> - # api base path endpoint for app(web) SERVER_BASE_PATH=/api/ # api server access point for app(web when build) SERVER_BASE_URL= +################# DATABASE ################# + DB_LOG_SQL=off <%= dbEnvs %> +################# STORAGE (Initialization only) ################# + # local or ali-oss DEFAULT_STORAGE_TYPE=local -STORAGE_TYPE=local # LOCAL STORAGE LOCAL_STORAGE_USE_STATIC_SERVER=true LOCAL_STORAGE_BASE_URL= +LOCAL_STORAGE_DEST=storage/uploads # ALI OSS STORAGE ALI_OSS_STORAGE_BASE_URL= diff --git a/packages/core/create-nocobase-app/src/resources/templates/package.json.js b/packages/core/create-nocobase-app/src/resources/templates/package.json.js index 21e6c23d5..a99fecbfd 100644 --- a/packages/core/create-nocobase-app/src/resources/templates/package.json.js +++ b/packages/core/create-nocobase-app/src/resources/templates/package.json.js @@ -7,14 +7,14 @@ module.exports = (opts) => { workspaces: ['packages/app/*', 'packages/plugins/*'], license: 'MIT', scripts: { - start: 'concurrently --kill-others "npm run start-server" "npm run start-client"', + start: 'concurrently --kill-others "yarn start-server -s" "yarn start-client"', bootstrap: 'lerna bootstrap', clean: 'rimraf -rf packages/{app,plugins}/*/{lib,esm,dist} && lerna clean', nocobase: 'cross-env DOTENV_CONFIG_PATH=.env ts-node-dev -r dotenv/config -r tsconfig-paths/register ./packages/app/server/src/index.ts', 'nocobase-prod': 'cross-env DOTENV_CONFIG_PATH=.env node -r dotenv/config packages/app/server/lib/index.js', - 'start-client': 'cd packages/app/client && npm run start', - 'start-server': 'npm run nocobase start', + 'start-client': 'cd packages/app/client && yarn start', + 'start-server': 'yarn nocobase start', 'start-pm2': 'pm2-runtime start --node-args="-r dotenv/config" packages/app/server/lib/index.js -- start', build: 'lerna run build', 'build-docs': 'dumi build', diff --git a/packages/core/database/package.json b/packages/core/database/package.json index c5b30c131..4c7fe9327 100644 --- a/packages/core/database/package.json +++ b/packages/core/database/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/database", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "description": "", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -17,7 +17,7 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "dependencies": { - "@nocobase/utils": "0.7.0-alpha.16", + "@nocobase/utils": "0.7.0-alpha.23", "async-mutex": "^0.3.2", "deepmerge": "^4.2.2", "flat": "^5.0.2", diff --git a/packages/core/resourcer/package.json b/packages/core/resourcer/package.json index bc870ac0e..fc4e4f4f4 100644 --- a/packages/core/resourcer/package.json +++ b/packages/core/resourcer/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/resourcer", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "description": "", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/packages/core/server/package.json b/packages/core/server/package.json index 8f0d45b22..6164c50de 100644 --- a/packages/core/server/package.json +++ b/packages/core/server/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/server", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "types": "./lib/index.d.ts", "license": "Apache-2.0", @@ -18,10 +18,11 @@ "dependencies": { "@koa/cors": "^3.1.0", "@koa/router": "^9.4.0", - "@nocobase/acl": "0.7.0-alpha.16", - "@nocobase/actions": "0.7.0-alpha.16", - "@nocobase/database": "0.7.0-alpha.16", - "@nocobase/resourcer": "0.7.0-alpha.16", + "@nocobase/acl": "0.7.0-alpha.23", + "@nocobase/actions": "0.7.0-alpha.23", + "@nocobase/database": "0.7.0-alpha.23", + "@nocobase/resourcer": "0.7.0-alpha.23", + "chalk": "^4.1.1", "commander": "^8.1.0", "dotenv": "^8.2.0", "find-package-json": "^1.2.0", diff --git a/packages/core/server/src/app-manager.ts b/packages/core/server/src/app-manager.ts index 26f3c7194..31b4def7f 100644 --- a/packages/core/server/src/app-manager.ts +++ b/packages/core/server/src/app-manager.ts @@ -1,7 +1,7 @@ -import Application, { ApplicationOptions } from './application'; -import http, { IncomingMessage } from 'http'; -import EventEmitter from 'events'; import { applyMixins, AsyncEmitter } from '@nocobase/utils'; +import EventEmitter from 'events'; +import http, { IncomingMessage } from 'http'; +import Application, { ApplicationOptions } from './application'; type AppSelector = (req: IncomingMessage) => Application | string | undefined | null; diff --git a/packages/core/server/src/commands/index.ts b/packages/core/server/src/commands/index.ts index a271fbf19..033db6bca 100644 --- a/packages/core/server/src/commands/index.ts +++ b/packages/core/server/src/commands/index.ts @@ -1,5 +1,5 @@ -import Application from '../application'; import { Command } from 'commander'; +import Application from '../application'; export function createCli(app: Application) { const program = new Command(); @@ -19,8 +19,8 @@ export function createCli(app: Application) { }); }; - program.command('start').description('start NocoBase application').action(runSubCommand('start')); - program.command('install').option('-f, --force').option('-c, --clean').action(runSubCommand('install')); + program.command('start').description('start NocoBase application').option('-s, --silent').action(runSubCommand('start')); + program.command('install').option('-f, --force').option('-c, --clean').option('-s, --silent').action(runSubCommand('install')); program.command('db:sync').option('-f, --force').action(runSubCommand('db-sync')); program.command('console').action(runSubCommand('console')); diff --git a/packages/core/server/src/commands/install.ts b/packages/core/server/src/commands/install.ts index d10ff649e..6da9307d7 100644 --- a/packages/core/server/src/commands/install.ts +++ b/packages/core/server/src/commands/install.ts @@ -1,5 +1,29 @@ +import chalk from 'chalk'; + export default async ({ app, cliArgs }) => { const [opts] = cliArgs; + + if (!opts?.clean && !opts?.force) { + const tables = await app.db.sequelize.getQueryInterface().showAllTables(); + if (tables.includes('collections')) { + if (!opts.silent) { + console.log(); + console.log(); + console.log(chalk.yellow('NocoBase is already installed. To reinstall, please execute:')); + console.log(); + let command = 'yarn nocobase install -f'; + console.log(chalk.yellow(command)); + console.log(); + console.log(); + } + return; + } + } + + if (!opts.silent) { + console.log(`NocoBase installing`); + } + await app.install({ cliArgs, clean: opts.clean, @@ -7,7 +31,12 @@ export default async ({ app, cliArgs }) => { force: opts.force, }, }); + await app.stop({ cliArgs, }); + + if (!opts.silent) { + console.log(`NocoBase installed`); + } }; diff --git a/packages/core/server/src/commands/start.ts b/packages/core/server/src/commands/start.ts index bb3a61de6..5cf100ba2 100644 --- a/packages/core/server/src/commands/start.ts +++ b/packages/core/server/src/commands/start.ts @@ -11,5 +11,7 @@ export default async ({ app, cliArgs }) => { }, }); - console.log(`🚀 nocobase server had started at http://${host}:${port}`); + if (!opts.silent) { + console.log(`🚀 NocoBase server running at: http://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`); + } }; diff --git a/packages/core/test/package.json b/packages/core/test/package.json index 160a11161..28b26075d 100644 --- a/packages/core/test/package.json +++ b/packages/core/test/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/test", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "types": "./lib/index.d.ts", "license": "Apache-2.0", @@ -16,7 +16,7 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "dependencies": { - "@nocobase/server": "0.7.0-alpha.16", + "@nocobase/server": "0.7.0-alpha.23", "@types/supertest": "^2.0.11", "mockjs": "^1.1.0", "mysql2": "^2.1.0", diff --git a/packages/core/utils/package.json b/packages/core/utils/package.json index f7a7ea6c9..d4dd89142 100644 --- a/packages/core/utils/package.json +++ b/packages/core/utils/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/utils", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "types": "./lib/index.d.ts", "license": "Apache-2.0", diff --git a/packages/plugins/acl/package.json b/packages/plugins/acl/package.json index e360e186d..cae010244 100644 --- a/packages/plugins/acl/package.json +++ b/packages/plugins/acl/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-acl", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "description": "", "license": "Apache-2.0", "licenses": [ @@ -17,9 +17,9 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "dependencies": { - "@nocobase/acl": "0.7.0-alpha.16", - "@nocobase/database": "0.7.0-alpha.16", - "@nocobase/server": "0.7.0-alpha.16" + "@nocobase/acl": "0.7.0-alpha.23", + "@nocobase/database": "0.7.0-alpha.23", + "@nocobase/server": "0.7.0-alpha.23" }, "repository": { "type": "git", diff --git a/packages/plugins/action-logs/package.json b/packages/plugins/action-logs/package.json index 02ce4f546..7f9e8076b 100644 --- a/packages/plugins/action-logs/package.json +++ b/packages/plugins/action-logs/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-action-logs", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -15,7 +15,7 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/china-region/package.json b/packages/plugins/china-region/package.json index 39b1b1f4d..44b536f42 100644 --- a/packages/plugins/china-region/package.json +++ b/packages/plugins/china-region/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-china-region", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -18,7 +18,7 @@ "china-division": "^2.4.0" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/china-region/src/server.ts b/packages/plugins/china-region/src/server.ts index 367c98037..35610eb6b 100644 --- a/packages/plugins/china-region/src/server.ts +++ b/packages/plugins/china-region/src/server.ts @@ -1,5 +1,5 @@ -import { Database } from '@nocobase/database'; import { Plugin } from '@nocobase/server'; +import { areas, cities, provinces } from 'china-division'; import { resolve } from 'path'; export class ChinaRegionPlugin extends Plugin { @@ -18,15 +18,6 @@ export class ChinaRegionPlugin extends Plugin { const timer = Date.now(); const ChinaRegion = this.db.getModel('chinaRegions'); - const db = new Database({ - dialect: 'sqlite', - storage: resolve(process.cwd(), 'node_modules/china-division/dist/data.sqlite'), - }); - - const [provinces] = await db.sequelize.query('SELECT `code`, `name` FROM `province`') as any; - const [cities] = await db.sequelize.query('SELECT `code`, `name`, `provinceCode` FROM `city`') as any; - const [areas] = await db.sequelize.query('SELECT `code`, `name`, `cityCode` FROM `area`') as any; - await ChinaRegion.bulkCreate( provinces.map((item) => ({ code: item.code, @@ -70,7 +61,7 @@ export class ChinaRegionPlugin extends Plugin { // }))); const count = await ChinaRegion.count(); - console.log(`${count} rows of region data imported in ${(Date.now() - timer) / 1000}s`); + // console.log(`${count} rows of region data imported in ${(Date.now() - timer) / 1000}s`); } getName(): string { diff --git a/packages/plugins/client/package.json b/packages/plugins/client/package.json index fb5a09391..026ec5e13 100644 --- a/packages/plugins/client/package.json +++ b/packages/plugins/client/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-client", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -15,10 +15,10 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "dependencies": { - "@nocobase/server": "0.7.0-alpha.16" + "@nocobase/server": "0.7.0-alpha.23" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/collection-manager/package.json b/packages/plugins/collection-manager/package.json index 9f6f4f732..66586b765 100644 --- a/packages/plugins/collection-manager/package.json +++ b/packages/plugins/collection-manager/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-collection-manager", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -15,7 +15,7 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/error-handler/package.json b/packages/plugins/error-handler/package.json index d093e8185..0c1d3f970 100644 --- a/packages/plugins/error-handler/package.json +++ b/packages/plugins/error-handler/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-error-handler", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "description": "", "license": "Apache-2.0", "licenses": [ @@ -18,7 +18,7 @@ }, "dependencies": { "@formily/json-schema": "^2.0.15", - "@nocobase/server": "0.7.0-alpha.16" + "@nocobase/server": "0.7.0-alpha.23" }, "repository": { "type": "git", diff --git a/packages/plugins/file-manager/package.json b/packages/plugins/file-manager/package.json index 301a28e5d..d2c57b870 100644 --- a/packages/plugins/file-manager/package.json +++ b/packages/plugins/file-manager/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-file-manager", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -16,7 +16,7 @@ }, "dependencies": { "@koa/multer": "^3.0.0", - "@nocobase/server": "0.7.0-alpha.16", + "@nocobase/server": "0.7.0-alpha.23", "aws-sdk": "^2.2.32", "koa-static": "^5.0.0", "mime-match": "^1.0.2", @@ -26,7 +26,7 @@ "multer-s3": "^2.10.0" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16", + "@nocobase/test": "0.7.0-alpha.23", "@types/koa-multer": "^1.0.1", "@types/multer": "^1.4.5" }, diff --git a/packages/plugins/file-manager/src/storages/local.ts b/packages/plugins/file-manager/src/storages/local.ts index 089cdfa98..44dc2e17d 100644 --- a/packages/plugins/file-manager/src/storages/local.ts +++ b/packages/plugins/file-manager/src/storages/local.ts @@ -119,11 +119,16 @@ export default { }); }, defaults() { + const { LOCAL_STORAGE_DEST, LOCAL_STORAGE_BASE_URL, SERVER_PORT } = process.env; + const documentRoot = LOCAL_STORAGE_DEST || 'uploads'; return { title: '本地存储', type: STORAGE_TYPE_LOCAL, name: `local`, - baseUrl: process.env.LOCAL_STORAGE_BASE_URL || `http://localhost:${process.env.SERVER_PORT || '13002'}/uploads`, + baseUrl: LOCAL_STORAGE_BASE_URL || `http://localhost:${SERVER_PORT || '13002'}/${documentRoot}`, + options: { + documentRoot, + }, }; }, }; diff --git a/packages/plugins/multi-app-manager/package.json b/packages/plugins/multi-app-manager/package.json index 27b01b62f..0e7e666d7 100644 --- a/packages/plugins/multi-app-manager/package.json +++ b/packages/plugins/multi-app-manager/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-multi-app-manager", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -15,7 +15,7 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "dependencies": { - "@nocobase/server": "0.7.0-alpha.16" + "@nocobase/server": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/notifications/package.json b/packages/plugins/notifications/package.json index 6aacddd0b..0a09ec5e9 100644 --- a/packages/plugins/notifications/package.json +++ b/packages/plugins/notifications/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-notifications", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -18,7 +18,7 @@ "nodemailer": "^6.6.1" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16", + "@nocobase/test": "0.7.0-alpha.23", "@types/nodemailer": "6.4.4", "nodemailer-mock": "^1.5.11" }, diff --git a/packages/plugins/system-settings/package.json b/packages/plugins/system-settings/package.json index 7d222d7d6..bcfa7c1e6 100644 --- a/packages/plugins/system-settings/package.json +++ b/packages/plugins/system-settings/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-system-settings", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -15,7 +15,7 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/ui-routes-storage/package.json b/packages/plugins/ui-routes-storage/package.json index 75ce5ead8..2baa7a582 100644 --- a/packages/plugins/ui-routes-storage/package.json +++ b/packages/plugins/ui-routes-storage/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-ui-routes-storage", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -18,7 +18,7 @@ "flat-to-nested": "^1.1.1" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/ui-schema-storage/package.json b/packages/plugins/ui-schema-storage/package.json index 1fe18494f..2df916e31 100644 --- a/packages/plugins/ui-schema-storage/package.json +++ b/packages/plugins/ui-schema-storage/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-ui-schema-storage", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -16,7 +16,7 @@ }, "devDependencies": { "@formily/json-schema": "^2.0.15", - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/packages/plugins/users/package.json b/packages/plugins/users/package.json index d6b650c14..d38df9bcd 100644 --- a/packages/plugins/users/package.json +++ b/packages/plugins/users/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-users", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -18,7 +18,7 @@ "jsonwebtoken": "^8.5.1" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16", + "@nocobase/test": "0.7.0-alpha.23", "@types/jsonwebtoken": "^8.5.8" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" diff --git a/packages/plugins/users/src/middlewares/parseToken.ts b/packages/plugins/users/src/middlewares/parseToken.ts index 8c5828203..608ed012f 100644 --- a/packages/plugins/users/src/middlewares/parseToken.ts +++ b/packages/plugins/users/src/middlewares/parseToken.ts @@ -52,6 +52,6 @@ async function findUserByToken(ctx: Context, plugin: UsersPlugin) { appends: ['roles'], }); } catch (error) { - console.warn(error); + return null; } } diff --git a/packages/plugins/workflow/package.json b/packages/plugins/workflow/package.json index eb49716fa..c3e674be7 100644 --- a/packages/plugins/workflow/package.json +++ b/packages/plugins/workflow/package.json @@ -1,6 +1,6 @@ { "name": "@nocobase/plugin-workflow", - "version": "0.7.0-alpha.16", + "version": "0.7.0-alpha.23", "main": "lib/index.js", "license": "Apache-2.0", "licenses": [ @@ -15,14 +15,14 @@ "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm" }, "dependencies": { - "@nocobase/actions": "0.7.0-alpha.16", - "@nocobase/database": "0.7.0-alpha.16", - "@nocobase/server": "0.7.0-alpha.16", - "@nocobase/utils": "0.7.0-alpha.16", + "@nocobase/actions": "0.7.0-alpha.23", + "@nocobase/database": "0.7.0-alpha.23", + "@nocobase/server": "0.7.0-alpha.23", + "@nocobase/utils": "0.7.0-alpha.23", "json-templates": "^4.2.0" }, "devDependencies": { - "@nocobase/test": "0.7.0-alpha.16" + "@nocobase/test": "0.7.0-alpha.23" }, "gitHead": "a00b45a2686695c5f4824d074ac5e1aff210793a" } diff --git a/storage/.gitignore b/storage/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/storage/db/.gitignore b/storage/db/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/storage/db/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/storage/uploads/.gitignore b/storage/uploads/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/storage/uploads/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file