mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:55:33 +00:00
feat(create-nocobase-app): simplify the process
This commit is contained in:
parent
2a696eeb7a
commit
73d439eb1f
12
README.md
12
README.md
@ -76,18 +76,14 @@ yarn create nocobase-app my-nocobase-app --quickstart
|
||||
~~~shell
|
||||
# 1. create project
|
||||
yarn create nocobase-app my-nocobase-app
|
||||
|
||||
# 2. switch to the project directory
|
||||
cd my-nocobase-app
|
||||
|
||||
# 2. edit configuration in .env file
|
||||
vim .env
|
||||
|
||||
# 3. start a database (optional)
|
||||
docker-compose up -d postgres
|
||||
|
||||
# 4. create initialization data
|
||||
# 3. create initialization data
|
||||
yarn nocobase init --import-demo
|
||||
|
||||
# 5. start project
|
||||
# 4. start project
|
||||
yarn start
|
||||
~~~
|
||||
|
||||
|
@ -82,18 +82,14 @@ yarn create nocobase-app my-nocobase-app --quickstart
|
||||
~~~shell
|
||||
# 1. 创建项目
|
||||
yarn create nocobase-app my-nocobase-app
|
||||
|
||||
# 2. 切换到项目根目录
|
||||
cd my-nocobase-app
|
||||
|
||||
# 2. 修改.env中对应的数据库配置
|
||||
vim .env
|
||||
|
||||
# 3. 启动预置数据库(可选)
|
||||
docker-compose up -d postgres
|
||||
|
||||
# 4. 初始化数据
|
||||
# 3. 初始化数据
|
||||
yarn nocobase init --import-demo
|
||||
|
||||
# 5. 启动项目
|
||||
# 4. 启动项目
|
||||
yarn start
|
||||
~~~
|
||||
|
||||
|
@ -12,7 +12,6 @@ export default class AppGenerator extends Generator {
|
||||
this.copyDirectory({
|
||||
context: {
|
||||
version: require('../../package').version,
|
||||
conventionRoutes: this.args.conventionRoutes,
|
||||
...this.tplContext
|
||||
},
|
||||
path: join(__dirname, '../../templates/AppGenerator'),
|
||||
|
@ -37,7 +37,7 @@ const program = new commander.Command(packageJson.name)
|
||||
console.log();
|
||||
console.log(` ${chalk.cyan('cd')} ${directory}`);
|
||||
console.log(` ${cmd} install`);
|
||||
console.log(` ${cmd} nocobase init --import-demo`);
|
||||
console.log(` ${cmd} nocobase init${hasYarn() ? '' : ' --'} --import-demo`);
|
||||
console.log(` ${cmd} start`);
|
||||
console.log();
|
||||
return;
|
||||
@ -98,7 +98,7 @@ const program = new commander.Command(packageJson.name)
|
||||
console.log('You can start by doing:');
|
||||
console.log();
|
||||
console.log(` ${chalk.cyan('cd')} ${directory}`);
|
||||
console.log(` ${cmd} nocobase init --import-demo`);
|
||||
console.log(` ${cmd} nocobase init${hasYarn() ? '' : ' --'} --import-demo`);
|
||||
console.log(` ${cmd} start`);
|
||||
console.log();
|
||||
}
|
||||
|
@ -24,5 +24,5 @@ export function runStart(path) {
|
||||
}
|
||||
|
||||
export function runInit(path) {
|
||||
return runYarn(path, ['run', 'nocobase', 'init', '--import-demo']);
|
||||
return runYarn(path, ['run', 'nocobase', 'init', hasYarn() ? '--import-demo' : '-- --import-demo']);
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
########## DOCKER COMPOSE ENV ##########
|
||||
|
||||
ADMINER_PORT=8080
|
||||
DB_MYSQL_PORT=3306
|
||||
DB_POSTGRES_PORT=5432
|
||||
@ -10,13 +9,16 @@ API_PORT=13002
|
||||
########## NOCOBASE ENV ##########
|
||||
|
||||
# DATABASE
|
||||
DB_DIALECT=sqlite
|
||||
DB_STORAGE=db.sqlite
|
||||
|
||||
# DB_DIALECT=postgres
|
||||
# DB_HOST=localhost
|
||||
# DB_PORT=5432
|
||||
# DB_DATABASE=nocobase
|
||||
# DB_USER=nocobase
|
||||
# DB_PASSWORD=nocobase
|
||||
|
||||
DB_DIALECT=postgres
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_DATABASE=nocobase
|
||||
DB_USER=nocobase
|
||||
DB_PASSWORD=nocobase
|
||||
# set to 'on' to enable log
|
||||
DB_LOG_SQL=
|
||||
|
||||
|
@ -9,18 +9,15 @@ API_PORT=13002
|
||||
########## NOCOBASE ENV ##########
|
||||
|
||||
# DATABASE
|
||||
{{#quickstart}}
|
||||
DB_DIALECT=sqlite
|
||||
DB_STORAGE=db.sqlite
|
||||
{{/quickstart}}
|
||||
{{^quickstart}}
|
||||
DB_DIALECT=postgres
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_DATABASE=nocobase
|
||||
DB_USER=nocobase
|
||||
DB_PASSWORD=nocobase
|
||||
{{/quickstart}}
|
||||
|
||||
# DB_DIALECT=postgres
|
||||
# DB_HOST=localhost
|
||||
# DB_PORT=5432
|
||||
# DB_DATABASE=nocobase
|
||||
# DB_USER=nocobase
|
||||
# DB_PASSWORD=nocobase
|
||||
|
||||
# set to 'on' to enable log
|
||||
DB_LOG_SQL=
|
||||
|
@ -0,0 +1,32 @@
|
||||
import path from 'path';
|
||||
import { DatabaseOptions } from '@nocobase/database';
|
||||
|
||||
export default {
|
||||
sqlite: {
|
||||
dialect: 'sqlite',
|
||||
dialectModule: require('sqlite3'),
|
||||
storage: process.env.DB_STORAGE || path.resolve(process.cwd(), './db.sqlite'),
|
||||
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
||||
},
|
||||
postgres: {
|
||||
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: 'postgres',
|
||||
dialectOptions: {
|
||||
charset: 'utf8mb4',
|
||||
collate: 'utf8mb4_unicode_ci',
|
||||
},
|
||||
logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
|
||||
sync: {
|
||||
force: false,
|
||||
alter: {
|
||||
drop: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
} as {
|
||||
[key: string]: DatabaseOptions,
|
||||
};
|
@ -1,36 +0,0 @@
|
||||
import { DatabaseOptions } from '@nocobase/database';
|
||||
{{#quickstart}}
|
||||
export default {
|
||||
dialect: process.env.DB_DIALECT,
|
||||
dialectModule: require('sqlite3'),
|
||||
storage: process.env.DB_STORAGE
|
||||
} as DatabaseOptions;
|
||||
{{/quickstart}}
|
||||
{{^quickstart}}
|
||||
export default {
|
||||
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,
|
||||
},
|
||||
},
|
||||
} as DatabaseOptions;
|
||||
{{/quickstart}}
|
@ -1,10 +1,11 @@
|
||||
import path from 'path';
|
||||
import Application from '@nocobase/server';
|
||||
import dbConfig from './config/db';
|
||||
|
||||
const start = Date.now();
|
||||
|
||||
const api = new Application({
|
||||
database: require('./config/db').default,
|
||||
database: dbConfig[process.env.DB_DIALECT || 'sqlite'],
|
||||
resourcer: {
|
||||
prefix: '/api',
|
||||
},
|
||||
@ -29,7 +30,7 @@ for (const plugin of plugins) {
|
||||
|
||||
api.plugin(require(`@nocobase/plugin-client/lib/server`).default, {
|
||||
dist: path.resolve(process.cwd(), './dist'),
|
||||
importDemo: true,
|
||||
// importDemo: true,
|
||||
});
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
|
Loading…
Reference in New Issue
Block a user