create-nocobase-app 0.5.0-alpha.18 → 0.5.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,20 +37,34 @@ function _path() {
37
37
 
38
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
39
 
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
41
+
42
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
43
+
44
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45
+
40
46
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
41
47
 
42
48
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
43
49
 
44
50
  class AppGenerator extends _utils().Generator {
51
+ constructor(...args) {
52
+ super(...args);
53
+ this.tplContext = {};
54
+ }
55
+
56
+ setTplContext(context) {
57
+ this.tplContext = context;
58
+ }
59
+
45
60
  writing() {
46
61
  var _this = this;
47
62
 
48
63
  return _asyncToGenerator(function* () {
49
64
  _this.copyDirectory({
50
- context: {
51
- version: require('../../package').version,
52
- conventionRoutes: _this.args.conventionRoutes
53
- },
65
+ context: _objectSpread({
66
+ version: require('../../package').version
67
+ }, _this.tplContext),
54
68
  path: (0, _path().join)(__dirname, '../../templates/AppGenerator'),
55
69
  target: _this.cwd
56
70
  });
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["AppGenerator/AppGenerator.ts"],"sourcesContent":["import { Generator } from '@umijs/utils';\nimport { join } from 'path';\n\nexport default class AppGenerator extends Generator {\n async writing() {\n this.copyDirectory({\n context: {\n version: require('../../package').version,\n conventionRoutes: this.args.conventionRoutes,\n },\n path: join(__dirname, '../../templates/AppGenerator'),\n target: this.cwd,\n });\n }\n}\n"],"file":"AppGenerator.js"}
1
+ {"version":3,"names":[],"mappings":"","sources":["AppGenerator/AppGenerator.ts"],"sourcesContent":["import { Generator } from '@umijs/utils';\nimport { join } from 'path';\n\nexport default class AppGenerator extends Generator {\n private tplContext = {};\n\n setTplContext(context) {\n this.tplContext = context;\n }\n\n async writing() {\n this.copyDirectory({\n context: {\n version: require('../../package').version,\n ...this.tplContext\n },\n path: join(__dirname, '../../templates/AppGenerator'),\n target: this.cwd,\n });\n }\n}\n"],"file":"AppGenerator.js"}
package/lib/cli.js CHANGED
@@ -20,10 +20,10 @@ function _utils() {
20
20
  return data;
21
21
  }
22
22
 
23
- function _fs() {
24
- const data = require("fs");
23
+ function _commander() {
24
+ const data = _interopRequireDefault(require("commander"));
25
25
 
26
- _fs = function _fs() {
26
+ _commander = function _commander() {
27
27
  return data;
28
28
  };
29
29
 
@@ -31,7 +31,7 @@ function _fs() {
31
31
  }
32
32
 
33
33
  function _path() {
34
- const data = require("path");
34
+ const data = _interopRequireDefault(require("path"));
35
35
 
36
36
  _path = function _path() {
37
37
  return data;
@@ -40,32 +40,127 @@ function _path() {
40
40
  return data;
41
41
  }
42
42
 
43
+ function _ora() {
44
+ const data = _interopRequireDefault(require("ora"));
45
+
46
+ _ora = function _ora() {
47
+ return data;
48
+ };
49
+
50
+ return data;
51
+ }
52
+
53
+ var _utils2 = require("./utils");
54
+
55
+ function _execa() {
56
+ const data = _interopRequireDefault(require("execa"));
57
+
58
+ _execa = function _execa() {
59
+ return data;
60
+ };
61
+
62
+ return data;
63
+ }
64
+
43
65
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44
66
 
45
- const args = (0, _utils().yParser)(process.argv.slice(2), {
46
- alias: {
47
- version: ['v'],
48
- help: ['h']
49
- },
50
- boolean: ['version']
51
- });
52
-
53
- if (args.version && !args._[0]) {
54
- args._[0] = 'version';
55
- const local = (0, _fs().existsSync)((0, _path().join)(__dirname, '../.local')) ? _utils().chalk.cyan('@local') : '';
56
-
57
- const _require = require('../package.json'),
58
- name = _require.name,
59
- version = _require.version;
60
-
61
- console.log(`${name}@${version}${local}`);
62
- } else {
63
- require('./').default({
64
- cwd: process.cwd(),
65
- args
66
- }).catch(err => {
67
- console.error(`Create failed, ${err.message}`);
68
- console.error(err);
67
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
68
+
69
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
70
+
71
+ const packageJson = require('../package.json');
72
+
73
+ const program = new (_commander().default.Command)(packageJson.name).version(packageJson.version).option('--simple', 'create nocobase app without install dependencies').option('--quickstart', 'create quickstart nocobase app').arguments('<project-directory>').usage(`${_utils().chalk.green('<project-directory>')}`).action( /*#__PURE__*/function () {
74
+ var _ref = _asyncToGenerator(function* (directory, options) {
75
+ var _runner$stdout, _runner$stderr;
76
+
77
+ console.log(`Creating a new Nocobase application at ${_utils().chalk.green(directory)}.`);
78
+ console.log('Creating files.');
79
+
80
+ const fullPath = _path().default.join(process.cwd(), directory);
81
+
82
+ yield require('./index').default({
83
+ cwd: fullPath,
84
+ args: {},
85
+ tplContext: options.quickstart ? {
86
+ quickstart: true
87
+ } : {
88
+ quickstart: false
89
+ }
90
+ });
91
+
92
+ const cmd = _utils().chalk.cyan((0, _utils2.hasYarn)() ? 'yarn' : 'npm run');
93
+
94
+ if (options.simple) {
95
+ console.log();
96
+ console.log('Done. You can start by doing:');
97
+ console.log();
98
+ console.log(` ${_utils().chalk.cyan('cd')} ${directory}`);
99
+ console.log(` ${cmd} install`);
100
+ console.log(` ${cmd} nocobase init${(0, _utils2.hasYarn)() ? '' : ' --'} --import-demo`);
101
+ console.log(` ${cmd} start`);
102
+ console.log();
103
+ return;
104
+ }
105
+
106
+ const installPrefix = _utils().chalk.yellow('Installing dependencies:');
107
+
108
+ const loader = (0, _ora().default)(installPrefix).start();
109
+
110
+ const logInstall = (chunk = '') => {
111
+ loader.text = `${installPrefix} ${chunk.toString().split('\n').join(' ')}`;
112
+ };
113
+
114
+ const runner = (0, _utils2.runInstall)(fullPath);
115
+ runner === null || runner === void 0 ? void 0 : (_runner$stdout = runner.stdout) === null || _runner$stdout === void 0 ? void 0 : _runner$stdout.on('data', logInstall);
116
+ runner === null || runner === void 0 ? void 0 : (_runner$stderr = runner.stderr) === null || _runner$stderr === void 0 ? void 0 : _runner$stderr.on('data', logInstall);
117
+ yield runner;
118
+ loader.stop();
119
+ console.log(`Dependencies installed ${_utils().chalk.green('successfully')}.`);
120
+ console.log();
121
+ console.log(`Your application was created at ${_utils().chalk.green(directory)}.\n`);
122
+
123
+ if (options.quickstart) {
124
+ // Using Sqlite as Database
125
+ const prefix = _utils().chalk.yellow('Nocobase init');
126
+
127
+ const initLoader = (0, _ora().default)(prefix).start();
128
+
129
+ try {
130
+ const initLog = (chunk = '') => {
131
+ initLoader.text = `${prefix} ${chunk.toString().split('\n').join(' ')}`;
132
+ };
133
+
134
+ const init = (0, _utils2.runInit)(fullPath);
135
+ init.stderr.on('data', initLog);
136
+ init.stdout.on('data', initLog);
137
+ yield init;
138
+ initLoader.stop();
139
+ } catch (e) {
140
+ initLoader.stop();
141
+ console.log();
142
+ console.log(e.message);
143
+ process.exit(1);
144
+ }
145
+
146
+ console.log(`Running your application.`);
147
+ yield (0, _execa().default)('npm', ['run', 'start'], {
148
+ stdio: 'inherit',
149
+ cwd: fullPath
150
+ });
151
+ } else {
152
+ console.log();
153
+ console.log('You can start by doing:');
154
+ console.log();
155
+ console.log(` ${_utils().chalk.cyan('cd')} ${directory}`);
156
+ console.log(` ${cmd} nocobase init${(0, _utils2.hasYarn)() ? '' : ' --'} --import-demo`);
157
+ console.log(` ${cmd} start`);
158
+ console.log();
159
+ }
69
160
  });
70
- }
161
+
162
+ return function (_x, _x2) {
163
+ return _ref.apply(this, arguments);
164
+ };
165
+ }()).showHelpAfterError().parse(process.argv);
71
166
  //# sourceMappingURL=cli.js.map
package/lib/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["cli.ts"],"sourcesContent":["import { chalk, yParser } from '@umijs/utils';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\n\nconst args = yParser(process.argv.slice(2), {\n alias: {\n version: ['v'],\n help: ['h'],\n },\n boolean: ['version'],\n});\n\nif (args.version && !args._[0]) {\n args._[0] = 'version';\n const local = existsSync(join(__dirname, '../.local'))\n ? chalk.cyan('@local')\n : '';\n const { name, version } = require('../package.json');\n console.log(`${name}@${version}${local}`);\n} else {\n require('./')\n .default({\n cwd: process.cwd(),\n args,\n })\n .catch((err: Error) => {\n console.error(`Create failed, ${err.message}`);\n console.error(err);\n });\n}\n"],"file":"cli.js"}
1
+ {"version":3,"names":[],"mappings":"","sources":["cli.ts"],"sourcesContent":["import { chalk } from '@umijs/utils';\nimport commander from 'commander';\nimport path from 'path';\nimport ora from 'ora';\nimport { hasYarn, runInit, runInstall, runStart } from './utils';\nimport execa from 'execa';\n\nconst packageJson = require('../package.json');\n\nconst program = new commander.Command(packageJson.name)\n .version(packageJson.version)\n .option('--simple', 'create nocobase app without install dependencies')\n .option('--quickstart', 'create quickstart nocobase app')\n .arguments('<project-directory>')\n .usage(`${chalk.green('<project-directory>')}`)\n .action(async (directory, options) => {\n console.log(\n `Creating a new Nocobase application at ${chalk.green(directory)}.`,\n );\n console.log('Creating files.');\n\n const fullPath = path.join(process.cwd(), directory);\n\n await require('./index').default({\n cwd: fullPath,\n args: {},\n tplContext: options.quickstart\n ? { quickstart: true }\n : { quickstart: false },\n });\n\n const cmd = chalk.cyan(hasYarn() ? 'yarn' : 'npm run');\n\n if (options.simple) {\n console.log();\n console.log('Done. You can start by doing:');\n console.log();\n console.log(` ${chalk.cyan('cd')} ${directory}`);\n console.log(` ${cmd} install`);\n console.log(` ${cmd} nocobase init${hasYarn() ? '' : ' --'} --import-demo`);\n console.log(` ${cmd} start`);\n console.log();\n return;\n }\n\n const installPrefix = chalk.yellow('Installing dependencies:');\n const loader = ora(installPrefix).start();\n const logInstall = (chunk = '') => {\n loader.text = `${installPrefix} ${chunk\n .toString()\n .split('\\n')\n .join(' ')}`;\n };\n\n const runner = runInstall(fullPath);\n\n runner?.stdout?.on('data', logInstall);\n runner?.stderr?.on('data', logInstall);\n\n await runner;\n loader.stop();\n console.log(`Dependencies installed ${chalk.green('successfully')}.`);\n console.log();\n console.log(`Your application was created at ${chalk.green(directory)}.\\n`);\n\n if (options.quickstart) {\n // Using Sqlite as Database\n const prefix = chalk.yellow('Nocobase init');\n const initLoader = ora(prefix).start();\n\n try {\n const initLog = (chunk = '') => {\n initLoader.text = `${prefix} ${chunk\n .toString()\n .split('\\n')\n .join(' ')}`;\n };\n\n const init = runInit(fullPath);\n init.stderr.on('data', initLog);\n init.stdout.on('data', initLog);\n await init;\n initLoader.stop();\n } catch (e) {\n initLoader.stop();\n console.log();\n console.log(e.message);\n process.exit(1);\n }\n\n console.log(`Running your application.`);\n await execa('npm', ['run', 'start'], {\n stdio: 'inherit',\n cwd: fullPath,\n });\n } else {\n console.log();\n console.log('You can start by doing:');\n console.log();\n console.log(` ${chalk.cyan('cd')} ${directory}`);\n console.log(` ${cmd} nocobase init${hasYarn() ? '' : ' --'} --import-demo`);\n console.log(` ${cmd} start`);\n console.log();\n }\n })\n .showHelpAfterError()\n .parse(process.argv);\n"],"file":"cli.js"}
package/lib/index.js CHANGED
@@ -26,12 +26,14 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
26
26
  var _default = /*#__PURE__*/function () {
27
27
  var _ref = _asyncToGenerator(function* ({
28
28
  cwd,
29
- args
29
+ args,
30
+ tplContext
30
31
  }) {
31
32
  const generator = new _AppGenerator.default({
32
33
  cwd,
33
34
  args
34
35
  });
36
+ generator.setTplContext(tplContext);
35
37
  yield generator.run();
36
38
  });
37
39
 
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"mappings":"","sources":["index.ts"],"sourcesContent":["import { yargs } from '@umijs/utils';\nimport AppGenerator from './AppGenerator/AppGenerator';\n\nexport default async ({\n cwd,\n args,\n}: {\n cwd: string;\n args: yargs.Arguments;\n}) => {\n const generator = new AppGenerator({\n cwd,\n args,\n });\n await generator.run();\n};\n"],"file":"index.js"}
1
+ {"version":3,"names":[],"mappings":"","sources":["index.ts"],"sourcesContent":["import { yargs } from '@umijs/utils';\nimport AppGenerator from './AppGenerator/AppGenerator';\n\nexport default async ({\n cwd,\n args,\n tplContext\n}: {\n cwd: string;\n args: yargs.Arguments;\n tplContext: object\n}) => {\n const generator = new AppGenerator({\n cwd,\n args,\n });\n\n generator.setTplContext(tplContext);\n await generator.run();\n};\n"],"file":"index.js"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasYarn = hasYarn;
7
+ exports.runInstall = runInstall;
8
+ exports.runStart = runStart;
9
+ exports.runInit = runInit;
10
+
11
+ function _react() {
12
+ const data = _interopRequireDefault(require("react"));
13
+
14
+ _react = function _react() {
15
+ return data;
16
+ };
17
+
18
+ return data;
19
+ }
20
+
21
+ function _execa() {
22
+ const data = _interopRequireDefault(require("execa"));
23
+
24
+ _execa = function _execa() {
25
+ return data;
26
+ };
27
+
28
+ return data;
29
+ }
30
+
31
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
+
33
+ function hasYarn() {
34
+ return (process.env.npm_config_user_agent || '').indexOf('yarn') === 0;
35
+ }
36
+
37
+ function runYarn(path, args) {
38
+ if (hasYarn()) {
39
+ return (0, _execa().default)('yarn', args, {
40
+ cwd: path,
41
+ stdin: 'ignore'
42
+ });
43
+ }
44
+
45
+ return (0, _execa().default)('npm', args, {
46
+ cwd: path,
47
+ stdin: 'ignore'
48
+ });
49
+ }
50
+
51
+ function runInstall(path) {
52
+ return runYarn(path, ['install']);
53
+ }
54
+
55
+ function runStart(path) {
56
+ return runYarn(path, ['run', 'start']);
57
+ }
58
+
59
+ function runInit(path) {
60
+ return runYarn(path, ['run', 'nocobase', 'init', hasYarn() ? '--import-demo' : '-- --import-demo']);
61
+ }
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"mappings":"","sources":["utils/index.ts"],"sourcesContent":["import execa from 'execa';\n\nexport function hasYarn() {\n return (process.env.npm_config_user_agent || '').indexOf('yarn') === 0;\n}\n\nfunction runYarn(path: string, args: string[]) {\n if (hasYarn()) {\n return execa('yarn', args, {\n cwd: path,\n stdin: 'ignore',\n });\n }\n\n return execa('npm', args, { cwd: path, stdin: 'ignore' });\n}\n\nexport function runInstall(path) {\n return runYarn(path, ['install']);\n}\n\nexport function runStart(path) {\n return runYarn(path, ['run', 'start']);\n}\n\nexport function runInit(path) {\n return runYarn(path, ['run', 'nocobase', 'init', hasYarn() ? '--import-demo' : '-- --import-demo']);\n}\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nocobase-app",
3
- "version": "0.5.0-alpha.18",
3
+ "version": "0.5.0-alpha.22",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -15,10 +15,13 @@
15
15
  },
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@umijs/utils": "3.5.17"
18
+ "@umijs/utils": "3.5.17",
19
+ "commander": "^8.2.0",
20
+ "execa": "^5.1.1",
21
+ "ora": "^5.4.1"
19
22
  },
20
23
  "bin": {
21
24
  "create-nocobase-app": "bin/create-nocobase-app.js"
22
25
  },
23
- "gitHead": "516c1be50dbe548be18a1433ea6e0a59e28bb8b8"
26
+ "gitHead": "22534716700c4ade1727b6e04543725c5e4f14f2"
24
27
  }
Binary file
@@ -1,33 +1,26 @@
1
1
  ########## DOCKER COMPOSE ENV ##########
2
-
3
- DB_POSTGRES_PORT=15432
4
- APP_PORT=13000
5
- ADMINER_PORT=18080
2
+ ADMINER_PORT=8080
3
+ DB_MYSQL_PORT=3306
4
+ DB_POSTGRES_PORT=5432
5
+ VERDACCIO_PORT=4873
6
+ APP_PORT=13001
7
+ API_PORT=13002
6
8
 
7
9
  ########## NOCOBASE ENV ##########
8
10
 
9
11
  # DATABASE
12
+ DB_DIALECT=sqlite
13
+ DB_STORAGE=db.sqlite
10
14
 
11
- DB_DIALECT=postgres
12
- DB_DATABASE=nocobase
13
- DB_USER=nocobase
14
- DB_PASSWORD=nocobase
15
- # set to 'on' to enable log
16
- DB_LOG_SQL=
17
-
18
- # for localhost
19
- DB_PORT=15432
20
- DB_HOST=localhost
21
-
22
- # for docker
15
+ # DB_DIALECT=postgres
16
+ # DB_HOST=localhost
23
17
  # DB_PORT=5432
24
- # DB_HOST=postgres
25
-
26
- # API & APP
18
+ # DB_DATABASE=nocobase
19
+ # DB_USER=nocobase
20
+ # DB_PASSWORD=nocobase
27
21
 
28
- NOCOBASE_ENV=
29
- API_PORT=13001
30
- API_URL=/api/
22
+ # set to 'on' to enable log
23
+ DB_LOG_SQL=
31
24
 
32
25
  # ADMIN USER (Initialization only)
33
26
 
@@ -41,4 +34,11 @@ STORAGE_TYPE=local
41
34
 
42
35
  # LOCAL STORAGE
43
36
  LOCAL_STORAGE_USE_STATIC_SERVER=true
44
- LOCAL_STORAGE_BASE_URL=http://localhost:23000
37
+ LOCAL_STORAGE_BASE_URL=http://localhost:13002
38
+
39
+ # ALI OSS STORAGE
40
+ ALI_OSS_STORAGE_BASE_URL=
41
+ ALI_OSS_REGION=oss-cn-beijing
42
+ ALI_OSS_ACCESS_KEY_ID=
43
+ ALI_OSS_ACCESS_KEY_SECRET=
44
+ ALI_OSS_BUCKET=
@@ -0,0 +1,44 @@
1
+ ########## DOCKER COMPOSE ENV ##########
2
+ ADMINER_PORT=8080
3
+ DB_MYSQL_PORT=3306
4
+ DB_POSTGRES_PORT=5432
5
+ VERDACCIO_PORT=4873
6
+ APP_PORT=13001
7
+ API_PORT=13002
8
+
9
+ ########## NOCOBASE ENV ##########
10
+
11
+ # DATABASE
12
+ DB_DIALECT=sqlite
13
+ DB_STORAGE=db.sqlite
14
+
15
+ # DB_DIALECT=postgres
16
+ # DB_HOST=localhost
17
+ # DB_PORT=5432
18
+ # DB_DATABASE=nocobase
19
+ # DB_USER=nocobase
20
+ # DB_PASSWORD=nocobase
21
+
22
+ # set to 'on' to enable log
23
+ DB_LOG_SQL=
24
+
25
+ # ADMIN USER (Initialization only)
26
+
27
+ ADMIN_EMAIL=admin@nocobase.com
28
+ ADMIN_PASSWORD=admin
29
+
30
+ # STORAGE (Initialization only)
31
+
32
+ # local or ali-oss
33
+ STORAGE_TYPE=local
34
+
35
+ # LOCAL STORAGE
36
+ LOCAL_STORAGE_USE_STATIC_SERVER=true
37
+ LOCAL_STORAGE_BASE_URL=http://localhost:13002
38
+
39
+ # ALI OSS STORAGE
40
+ ALI_OSS_STORAGE_BASE_URL=
41
+ ALI_OSS_REGION=oss-cn-beijing
42
+ ALI_OSS_ACCESS_KEY_ID=
43
+ ALI_OSS_ACCESS_KEY_SECRET=
44
+ ALI_OSS_BUCKET=
@@ -7,23 +7,22 @@ dotenv.config({
7
7
  });
8
8
 
9
9
  export default defineConfig({
10
+ favicon: '/favicon.png',
10
11
  nodeModulesTransform: {
11
12
  type: 'none',
12
13
  },
13
14
  define: {
14
- 'process.env.API_URL': process.env.API_URL,
15
- 'process.env.API_PORT': process.env.API_PORT,
15
+ 'process.env.API_URL': process.env.API_URL || 'http://127.0.0.1',
16
+ 'process.env.API_PORT': process.env.API_PORT || '13001',
16
17
  },
17
18
  proxy: {
18
19
  '/api': {
19
- 'target': `http://localhost:${process.env.API_PORT}/`,
20
- 'changeOrigin': true,
21
- 'pathRewrite': { '^/api': '/api' },
20
+ target: `http://localhost:${process.env.API_PORT || '13001'}/`,
21
+ changeOrigin: true,
22
+ pathRewrite: { '^/api': '/api' },
22
23
  },
23
24
  },
24
- routes: [
25
- { path: '/', exact: false, component: '@/pages/index' },
26
- ],
25
+ routes: [{ path: '/', exact: false, component: '@/pages/index' }],
27
26
  fastRefresh: {},
28
27
  locale: {
29
28
  default: 'zh-CN',
@@ -5,7 +5,7 @@
5
5
  "start": "concurrently \"npm run start-server\" \"umi dev\"",
6
6
  "start-client": "umi dev",
7
7
  "start-server": "ts-node-dev -r dotenv/config --project tsconfig.apis.json ./src/apis/index.ts",
8
- "nocobase": "ts-node-dev -r dotenv/config --project tsconfig.apis.json ./src/apis/index.ts",
8
+ "nocobase": "ts-node -r dotenv/config --project tsconfig.apis.json ./src/apis/index.ts",
9
9
  "serve": "node -r dotenv/config ./lib/apis/index.js",
10
10
  "build": "npm run build-server && npm run build-client",
11
11
  "build-client": "umi build",
@@ -27,7 +27,8 @@
27
27
  ]
28
28
  },
29
29
  "dependencies": {
30
- "@nocobase/plugin-action-logs": "^{{{ version }}}",
30
+ {{#quickstart}}"sqlite3": "https://github.com/mapbox/node-sqlite3/tarball/master",
31
+ {{/quickstart}}"@nocobase/plugin-action-logs": "^{{{ version }}}",
31
32
  "@nocobase/plugin-china-region": "^{{{ version }}}",
32
33
  "@nocobase/plugin-client": "^{{{ version }}}",
33
34
  "@nocobase/plugin-collections": "^{{{ version }}}",
@@ -0,0 +1,32 @@
1
+ import path from 'path';
2
+ import { DatabaseOptions } from '@nocobase/database';
3
+
4
+ export default {
5
+ sqlite: {
6
+ dialect: 'sqlite',
7
+ dialectModule: require('sqlite3'),
8
+ storage: process.env.DB_STORAGE || path.resolve(process.cwd(), './db.sqlite'),
9
+ logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
10
+ },
11
+ postgres: {
12
+ username: process.env.DB_USER,
13
+ password: process.env.DB_PASSWORD,
14
+ database: process.env.DB_DATABASE,
15
+ host: process.env.DB_HOST,
16
+ port: process.env.DB_PORT as any,
17
+ dialect: 'postgres',
18
+ dialectOptions: {
19
+ charset: 'utf8mb4',
20
+ collate: 'utf8mb4_unicode_ci',
21
+ },
22
+ logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
23
+ sync: {
24
+ force: false,
25
+ alter: {
26
+ drop: false,
27
+ },
28
+ },
29
+ },
30
+ } as {
31
+ [key: string]: DatabaseOptions,
32
+ };
@@ -1,35 +1,11 @@
1
- import Server from '@nocobase/server';
2
1
  import path from 'path';
2
+ import Application from '@nocobase/server';
3
+ import dbConfig from './config/db';
3
4
 
4
5
  const start = Date.now();
5
6
 
6
- const api = new Server({
7
- database: {
8
- username: process.env.DB_USER,
9
- password: process.env.DB_PASSWORD,
10
- database: process.env.DB_DATABASE,
11
- host: process.env.DB_HOST,
12
- port: process.env.DB_PORT as any,
13
- dialect: process.env.DB_DIALECT as any,
14
- dialectOptions: {
15
- charset: 'utf8mb4',
16
- collate: 'utf8mb4_unicode_ci',
17
- },
18
- pool: {
19
- max: 5,
20
- min: 0,
21
- acquire: 60000,
22
- idle: 10000,
23
- },
24
- logging: process.env.DB_LOG_SQL === 'on' ? console.log : false,
25
- define: {},
26
- sync: {
27
- force: false,
28
- alter: {
29
- drop: false,
30
- },
31
- },
32
- },
7
+ const api = new Application({
8
+ database: dbConfig[process.env.DB_DIALECT || 'sqlite'],
33
9
  resourcer: {
34
10
  prefix: '/api',
35
11
  },
@@ -49,24 +25,19 @@ const plugins = [
49
25
  ];
50
26
 
51
27
  for (const plugin of plugins) {
52
- api.plugin(
53
- require(`${plugin}/lib/server`).default,
54
- );
28
+ api.plugin(require(`${plugin}/lib/server`).default);
55
29
  }
56
30
 
57
- api.plugin(
58
- require(`@nocobase/plugin-client/lib/server`).default, {
31
+ api.plugin(require(`@nocobase/plugin-client/lib/server`).default, {
59
32
  dist: path.resolve(process.cwd(), './dist'),
60
- importDemo: true,
33
+ // importDemo: true,
61
34
  });
62
35
 
63
36
  if (process.argv.length < 3) {
64
37
  // @ts-ignore
65
- process.argv.push('start', '--port', process.env.API_PORT);
38
+ process.argv.push('start', '--port', process.env.API_PORT || '13001');
66
39
  }
67
40
 
68
- console.log(process.argv);
69
-
70
41
  api.parse(process.argv).then(() => {
71
42
  console.log(`Start-up time: ${(Date.now() - start) / 1000}s`);
72
43
  });