Feat/create nocobase app (#273)

* create-nocobase-app template from [develop]

* change create-nocobase-app package.json config

* feat: load configuration from directory

* feat: configuration repository toObject

* feat: create application from configuration dir

* feat: application factory with plugins options

* export type

* feat: read application config &  application with plugins options

* feat: release command

* fix: database release

* chore: workflow package.json

* feat: nocobase cli package

* feat: console command

* chore: load application in command

* fix: load packages from process.cwd

* feat: cli load env file

* feat: create-nocobase-app

* fix: gitignore create-nocobase-app lib

* fix: sqlite path

* feat: create plugin

* chore: plugin files template

* chore: move cli into application

* chore: create-nocobase-app

* fix: create plugin

* chore: app-client && app-server

* chore: package.json

* feat: create-nocobase-app download template from npm

* chore: create-nocobase-app template

* fix: config of plugin-users

* fix: yarn.lock

* fix: database build error

* fix: yarn.lock

* fix: resourcer config

* chore: cross-env

* chore: app-client dependents

* fix: env

* chore: v0.6.0-alpha.1

* chore: verdaccio

* chore(versions): 😊 publish v0.6.0

* chore(versions): 😊 publish v0.6.1-alpha.0

* chore(versions): 😊 publish v0.6.2-alpha.0

* chore(versions): 😊 publish v0.6.2-alpha.1

* chore: 0.6.2-alpha.2

* feat: workspaces

* chore(versions): 😊 publish v0.6.2-alpha.3

* chore(versions): 😊 publish v0.6.2-alpha.4

* chore: create-nocobase-app

* chore: create-nocobase-app lib

* fix: update tsconfig.jest.json

* chore: .env

* chore(versions): 😊 publish v0.6.2-alpha.5

* chore(versions): 😊 publish v0.6.2-alpha.6

* feat: improve code

* chore(versions): 😊 publish v0.6.2-alpha.7

* fix: cleanup

* chore(versions): 😊 publish v0.6.2-alpha.8

* chore: tsconfig for app server package

* fix: move files

* fix: move files

Co-authored-by: chenos <chenlinxh@gmail.com>
This commit is contained in:
ChengLei Shao 2022-04-17 10:00:42 +08:00 committed by GitHub
parent 10dedd87e6
commit 24ea83f0ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1188 changed files with 1662 additions and 566 deletions

View File

@ -1,11 +1,13 @@
NOCOBASE_ENV=development
API_PORT=3000
JWT_SECRET=09f26e402586e2faa8da4c98a35f1b20d6b033c60
SERVER_PORT=3000
# api base path endpoint for app(web)
API_BASE_PATH=/api/
SERVER_BASE_PATH=/api/
# api server access point for app(web when build)
API_BASE_URL=
SERVER_BASE_URL=
DB_DIALECT=sqlite

2
.gitignore vendored
View File

@ -1,5 +1,6 @@
node_modules/
lib/
!packages/core/create-nocobase-app/lib
esm/
.env
.DS_Store
@ -13,3 +14,4 @@ coverage
/uploads
.env.test
docs-dist/
.npmrc

123
README.md
View File

@ -0,0 +1,123 @@
English | [简体中文](./README.zh-CN.md)
![](https://nocobase.oss-cn-beijing.aliyuncs.com/bbcedd403d31cd1ccc4e9709581f5c2f.png)
What is NocoBase
----------
NocoBase is a scalability-first, open-source no-code development platform. No programming required, build your own collaboration platform, management system with NocoBase in minutes.
Homepage:
https://www.nocobase.com/
Online Demo:
https://demo.nocobase.com/new
Contact Us:
hello@nocobase.com
When to use NocoBase
----------
- **SMEs and organizations build business platforms and management systems for themselves or for their industry**
- Want the price to be low enough or even free
- Can be flexibly customized without programming knowledge
- Need full control of source code and data
- Can freely distribute and sell as their own products
- **Service providers and outsourcing teams develop collaboration platforms and management systems for their clients**
- Want to keep development costs as low as possible
- Need the most user-friendly secondary development experience
- Must be deployed privately as a standalone product for the client
- Can be freely distributed and sold by the client
Why choose NocoBase
----------
- **Open source and free**
- Unrestricted commercial use under the MIT license
- Full code ownership, private deployment, private and secure data
- Free to expand and develop for actual needs
- Good ecological support
- **Strong no-code capability**
- WYSIWYG visual configuration
- Separation of data structure configuration from interface configuration
- Rich combination of blocks and operations
- Role-based access control
- **Developer-friendly**
- Microkernel architecture, flexible and easy to extend, with a robust plug-in system
- Node.js-based, with popular frameworks and technologies, including Koa, Sequelize, React, Formily, Ant Design, etc.
- Progressive development, easy for getting-started, friendly to newcomers
- No binding, no strong dependencies, can be used in any combination or extensions, can be used in existing projects
Note
----------
NocoBase is still in early development and is for preview purposes only and is not suitable for use in a production environment. A relatively stable and well-documented public beta is expected to be released as early as the first quarter of 2022.
If you are interested in NocoBase, please join us to discuss and develop it together.
Architecture
----------
![](https://docs.nocobase.com/static/NocoBase.c9542b1f.png)
Requirements
----------
Node:
- Node.js 12.20+
Database:
- PostgreSQL 10.x+
- Mysql 8.x+
- Sqlite 3+
Installation
----------
## Create a project with `create-nocobase-app`
~~~shell
# 1. create project
yarn create nocobase-app my-nocobase-app
# 2. switch to the project directory
cd my-nocobase-app
# 3. create initialization data
yarn nocobase install --lang=en-US
# 4. start project
yarn start
~~~
Open [http://localhost:8000](http://localhost:8000) in a web browser. The initial account and password are `admin@nocobase.com` and `admin123`.
## Contributing
- Fork the source code to your own repository
- Modify source code
- Submit pull request
```bash
# Replace the following git address with your own repo
git clone https://github.com/nocobase/nocobase.git
cd nocobase
cp .env.example .env
yarn install
yarn nocobase install
yarn start
```
### Build
```bash
yarn build
```
### Test
```bash
# For all packages
yarn test
# For specific package
yarn test packages/<name>
```

View File

@ -3,6 +3,15 @@ networks:
nocobase:
driver: bridge
services:
verdaccio:
image: verdaccio/verdaccio
networks:
- nocobase
environment:
VERDACCIO_PORT: ${VERDACCIO_PORT}
restart: always
ports:
- "${VERDACCIO_PORT}:${VERDACCIO_PORT}"
adminer:
build:
context: .

View File

@ -1,8 +1,10 @@
{
"version": "0.6.0-alpha.0",
"version": "0.6.2-alpha.8",
"npmClient": "yarn",
"useWorkspaces": true,
"npmClientArgs": ["--ignore-engines"],
"npmClientArgs": [
"--ignore-engines"
],
"command": {
"version": {
"forcePublish": true,

View File

@ -2,21 +2,26 @@
"name": "root",
"private": true,
"workspaces": [
"packages/*"
"packages/app/*",
"packages/core/*",
"packages/plugins/*"
],
"scripts": {
"start": "concurrently \"npm run start-server\" \"npm run start-client\"",
"start-pm2": "yarn pm2-runtime start packages/api/lib/index.js",
"start-pm2": "yarn pm2-runtime start packages/app/server/lib/index.js",
"start-docs": "dumi dev",
"bootstrap": "lerna bootstrap",
"clean": "rimraf -rf packages/*/{lib,esm,dist} && lerna clean",
"nocobase": "ts-node-dev -r dotenv/config -r tsconfig-paths/register ./packages/api/src/index.ts",
"start-client": "cd packages/app && npm run start",
"start-server": "ts-node-dev -r dotenv/config -r tsconfig-paths/register ./packages/api/src/index.ts",
"clean": "rimraf -rf packages/{app,core,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",
"start-client": "cd packages/app/client && npm run start",
"start-server": "npm run nocobase start",
"build": "lerna run build",
"build-docs": "dumi build",
"test": "node ./jest.cli.js -i",
"lint": "eslint ."
"lint": "eslint .",
"version:alpha": "lerna version prerelease --preid alpha --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"",
"release:force": "lerna publish from-package --yes",
"release": "lerna publish"
},
"resolutions": {
"@types/react": "^17.0.0",
@ -44,7 +49,7 @@
"antd": "^4.18.9",
"classnames": "^2.3.1",
"concurrently": "^7.0.0",
"cross-env": "^5.2.0",
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"dumi": "^1.1.33",
"eslint": "^7.14.0",

View File

@ -1,22 +0,0 @@
{
"name": "@nocobase/api",
"version": "0.6.0-alpha.0",
"description": "",
"license": "MIT",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"scripts": {
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.build.json",
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
},
"dependencies": {
"@nocobase/server": "^0.6.0-alpha.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nocobase/nocobase.git",
"directory": "packages/actions"
},
"gitHead": "e7df1f93c4e23b9a666d99ee7372c02bdaec97c4"
}

View File

@ -1,94 +0,0 @@
import { Application } from '@nocobase/server';
import { resolve } from 'path';
require('dotenv').config({ path: resolve(process.cwd(), '.env') });
const start = Date.now();
const api = new Application({
database: {
storage: resolve(process.cwd(), './db.sqlite'),
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: process.env.DB_HOST,
port: process.env.DB_PORT as any,
dialect: process.env.DB_DIALECT as any,
dialectOptions: {
charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci',
},
pool: {
max: 5,
min: 0,
acquire: 60000,
idle: 10000,
},
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
define: {},
sync: {
force: false,
alter: {
drop: false,
},
},
},
resourcer: {
prefix: process.env.API_BASE_PATH || '/api/',
},
});
const plugins = [
'@nocobase/plugin-error-handler',
'@nocobase/plugin-collection-manager',
'@nocobase/plugin-ui-schema-storage',
'@nocobase/plugin-ui-routes-storage',
'@nocobase/plugin-file-manager',
'@nocobase/plugin-system-settings',
[
'@nocobase/plugin-users',
{
jwt: {
secret: process.env.JWT_SECRET || '09f26e402586e2faa8da4c98a35f1b20d6b033c60',
},
installing: {
adminNickname: 'Super Admin',
adminEmail: 'admin@nocobase.com',
adminPassword: 'admin123',
},
},
],
'@nocobase/plugin-acl',
'@nocobase/plugin-china-region',
'@nocobase/plugin-workflow',
[
'@nocobase/plugin-client',
{
dist: resolve(__dirname, '../../app/dist'),
},
],
];
for (const plugin of plugins) {
if (Array.isArray(plugin)) {
api.plugin(require(plugin.shift() as string).default, plugin.shift());
} else {
api.plugin(require(plugin).default);
}
}
// api.acl.use(async (ctx, next) => {
// ctx.permission = {
// skip: true,
// };
// await next();
// });
if (process.argv.length < 3) {
// @ts-ignore
process.argv.push('start', '--port', process.env.API_PORT || 12302);
}
api.parse(process.argv).then(() => {
console.log(`${new Date().toLocaleTimeString()} Start-up time: ${(Date.now() - start) / 1000}s`);
});

View File

@ -1,15 +0,0 @@
# umi project
## Getting Started
Install dependencies,
```bash
$ yarn
```
Start the dev server,
```bash
$ yarn start
```

View File

@ -1,10 +1,10 @@
import dotenv from 'dotenv';
import { resolve } from 'path';
import { defineConfig } from 'umi';
import { getUmiConfig } from '../utils/src/umiConfig';
import { getUmiConfig } from '../../core/utils/src/umiConfig';
dotenv.config({
path: resolve(__dirname, '../../.env'),
path: resolve(__dirname, '../../../.env'),
});
process.env.MFSU_AD = 'none';
@ -28,19 +28,11 @@ export default defineConfig({
routes: [{ path: '/', exact: false, component: '@/pages/index' }],
// fastRefresh: {},
chainWebpack(config) {
config.module.rules
.get('ts-in-node_modules')
.include.add(resolve(__dirname, '../client/src'));
config.resolve.alias.set(
'@nocobase/client',
resolve(__dirname, '../client/src'),
);
config.module.rules
.get('ts-in-node_modules')
.include.add(resolve(__dirname, '../utils/src'));
config.resolve.alias.set(
'@nocobase/utils',
resolve(__dirname, '../utils/src'),
);
const clientSrc = resolve(__dirname, '../../core/client/src');
const utilsSrc = resolve(__dirname, '../../core/utils/src');
config.module.rules.get('ts-in-node_modules').include.add(clientSrc);
config.resolve.alias.set('@nocobase/client', clientSrc);
config.module.rules.get('ts-in-node_modules').include.add(utilsSrc);
config.resolve.alias.set('@nocobase/utils', utilsSrc);
},
});

View File

@ -1,6 +1,6 @@
{
"name": "@nocobase/app",
"version": "0.6.0-alpha.0",
"name": "@nocobase/app-client",
"version": "0.6.2-alpha.8",
"scripts": {
"start": "umi dev",
"build": "umi build",
@ -8,17 +8,19 @@
"test": "umi-test",
"test:coverage": "umi-test --coverage"
},
"dependencies": {
"@nocobase/client": "^0.6.0-alpha.0",
"devDependencies": {
"@nocobase/client": "0.6.2-alpha.8",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@umijs/test": "^3.5.20",
"antd": "^4.19.5",
"react": "17.x",
"react-dom": "17.x",
"umi": "^3.5.20"
},
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@umijs/test": "^3.5.20",
"lint-staged": "^10.0.7",
"yorkie": "^2.0.0"
"repository": {
"type": "git",
"url": "git+https://github.com/nocobase/nocobase.git",
"directory": "packages/app/client"
}
}

View File

@ -1,7 +1,7 @@
import { APIClient } from '@nocobase/client';
const apiClient = new APIClient({
baseURL: process.env.API_BASE_URL,
baseURL: process.env.SERVER_BASE_URL,
});
export default apiClient;

View File

@ -0,0 +1,7 @@
#!/usr/bin/env node
try {
require('v8-compile-cache');
require('umi/lib/cli');
} catch (error) {
}

View File

@ -0,0 +1,8 @@
node_modules
*.log
docs
__tests__
jest.config.js
tsconfig.json
tsconfig.build.json
.fatherrc.ts

View File

@ -0,0 +1,33 @@
{
"name": "@nocobase/app-server",
"version": "0.6.2-alpha.8",
"description": "",
"license": "MIT",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"scripts": {
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.build.json",
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
},
"dependencies": {
"@nocobase/database": "0.6.2-alpha.8",
"@nocobase/plugin-acl": "0.6.2-alpha.8",
"@nocobase/plugin-china-region": "0.6.2-alpha.8",
"@nocobase/plugin-client": "0.6.2-alpha.8",
"@nocobase/plugin-collection-manager": "0.6.2-alpha.8",
"@nocobase/plugin-error-handler": "0.6.2-alpha.8",
"@nocobase/plugin-file-manager": "0.6.2-alpha.8",
"@nocobase/plugin-system-settings": "0.6.2-alpha.8",
"@nocobase/plugin-ui-routes-storage": "0.6.2-alpha.8",
"@nocobase/plugin-ui-schema-storage": "0.6.2-alpha.8",
"@nocobase/plugin-users": "0.6.2-alpha.8",
"@nocobase/plugin-workflow": "0.6.2-alpha.8",
"@nocobase/server": "0.6.2-alpha.8"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nocobase/nocobase.git",
"directory": "packages/app/server"
}
}

View File

@ -0,0 +1,27 @@
import { IDatabaseOptions } from '@nocobase/database';
import { resolve } from 'path';
const dialect = process.env.DB_DIALECT as any;
let databaseConfig: IDatabaseOptions = {
dialect,
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
};
if (dialect === 'sqlite') {
databaseConfig = {
...databaseConfig,
storage: resolve(process.cwd(), process.env.DB_STORAGE || 'db.sqlite'),
};
} else {
databaseConfig = {
...databaseConfig,
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: process.env.DB_HOST,
port: process.env.DB_PORT as any,
};
}
export default databaseConfig;

View File

@ -0,0 +1,23 @@
import { PluginsConfigurations } from '@nocobase/server';
import { resolve } from 'path';
export default [
'@nocobase/plugin-error-handler',
'@nocobase/plugin-collection-manager',
'@nocobase/plugin-ui-schema-storage',
'@nocobase/plugin-ui-routes-storage',
'@nocobase/plugin-file-manager',
'@nocobase/plugin-system-settings',
[
'@nocobase/plugin-users',
{
jwt: {
secret: process.env.JWT_SECRET,
},
},
],
'@nocobase/plugin-acl',
'@nocobase/plugin-china-region',
'@nocobase/plugin-workflow',
['@nocobase/plugin-client'],
] as PluginsConfigurations;

View File

@ -0,0 +1,3 @@
export default {
prefix: process.env.SERVER_BASE_PATH,
};

View File

@ -0,0 +1,8 @@
import { Application, readConfig } from '@nocobase/server';
import * as path from 'path';
(async () => {
const config = await readConfig(path.join(__dirname, './config'));
const app = new Application(config);
await app.parse();
})();

View File

@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.build.json",
"extends": "../../../tsconfig.build.json",
"compilerOptions": {
"outDir": "./lib",
"declaration": true

View File

@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["./esm/*", "./lib/*"]
}

View File

@ -1,4 +0,0 @@
#!/usr/bin/env node
require('v8-compile-cache');
require('umi/lib/cli');

View File

@ -1,6 +1,6 @@
{
"name": "@nocobase/acl",
"version": "0.6.0-alpha.0",
"version": "0.6.2-alpha.8",
"description": "",
"license": "MIT",
"main": "./lib/index.js",
@ -11,7 +11,7 @@
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
},
"dependencies": {
"@nocobase/resourcer": "0.6.0-alpha.0",
"@nocobase/resourcer": "0.6.2-alpha.8",
"json-templates": "^4.2.0"
},
"repository": {

View File

@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.build.json",
"extends": "../../../tsconfig.build.json",
"compilerOptions": {
"outDir": "./lib",
"declaration": true

View File

@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["./esm/*", "./lib/*"]
}

View File

@ -1,6 +1,6 @@
{
"name": "@nocobase/actions",
"version": "0.6.0-alpha.0",
"version": "0.6.2-alpha.8",
"description": "",
"license": "MIT",
"main": "./lib/index.js",
@ -11,8 +11,8 @@
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
},
"dependencies": {
"@nocobase/database": "^0.6.0-alpha.0",
"@nocobase/resourcer": "^0.6.0-alpha.0"
"@nocobase/database": "0.6.2-alpha.8",
"@nocobase/resourcer": "0.6.2-alpha.8"
},
"repository": {
"type": "git",

View File

@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.build.json",
"extends": "../../../tsconfig.build.json",
"compilerOptions": {
"outDir": "./lib",
"declaration": true

View File

@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.json",
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["./esm/*", "./lib/*"]
}

View File

@ -1,6 +1,6 @@
{
"name": "@nocobase/client",
"version": "0.6.0-alpha.0",
"version": "0.6.2-alpha.8",
"license": "MIT",
"main": "lib",
"module": "esm",
@ -23,7 +23,7 @@
"@formily/antd": "^2.0.15",
"@formily/core": "^2.0.15",
"@formily/react": "^2.0.15",
"@nocobase/utils": "0.6.0-alpha.0",
"@nocobase/utils": "0.6.2-alpha.8",
"ahooks": "^3.0.5",
"antd": "^4.18.9",
"axios": "^0.24.0",

Some files were not shown because too many files have changed in this diff Show More