q-koa 11.0.0 → 11.0.2
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.
- package/core/app.js +14 -44
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -254,7 +254,7 @@ class APP {
|
|
|
254
254
|
) {
|
|
255
255
|
this.app[appName].model.log.upsert(errorData)
|
|
256
256
|
}
|
|
257
|
-
if (
|
|
257
|
+
if (is_dev) {
|
|
258
258
|
console.log(err.stack)
|
|
259
259
|
}
|
|
260
260
|
throw new Error(err.message)
|
|
@@ -265,7 +265,10 @@ class APP {
|
|
|
265
265
|
// });
|
|
266
266
|
|
|
267
267
|
starter.on('loadAll', async () => {
|
|
268
|
-
const appName =
|
|
268
|
+
const appName =
|
|
269
|
+
typeof this.config.includes[0] === 'string'
|
|
270
|
+
? this.config.includes[0]
|
|
271
|
+
: this.config.includes[0].app
|
|
269
272
|
if (!this.app[appName])
|
|
270
273
|
throw new Error(
|
|
271
274
|
`没有生成应用${this.config.includes[0]},请检查config includes`
|
|
@@ -276,12 +279,17 @@ class APP {
|
|
|
276
279
|
'HH:mm:ss'
|
|
277
280
|
)} server is running at http://localhost:${this.port}`
|
|
278
281
|
)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
+
if (is_dev) {
|
|
283
|
+
console.log(
|
|
284
|
+
`first app is http://localhost:3001/${appName}/setting/findOne`
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const version = require('q-koa/package.json').version
|
|
289
|
+
console.log(chalk.green(`version: ${version}`))
|
|
282
290
|
})
|
|
283
291
|
|
|
284
|
-
if (
|
|
292
|
+
if (is_dev) {
|
|
285
293
|
if (
|
|
286
294
|
this.app[appName].service.model &&
|
|
287
295
|
this.app[appName].service.model.loadModel
|
|
@@ -337,9 +345,6 @@ class APP {
|
|
|
337
345
|
}
|
|
338
346
|
|
|
339
347
|
async initApp() {
|
|
340
|
-
const version = require('q-koa/package.json').version
|
|
341
|
-
console.log(chalk.green(`version: ${version}`))
|
|
342
|
-
|
|
343
348
|
let dirList = await fsPromise.readdir(
|
|
344
349
|
path.resolve(__dirname, `${rootDirectory}/${APP_DIR}`)
|
|
345
350
|
)
|
|
@@ -452,9 +457,6 @@ class APP {
|
|
|
452
457
|
|
|
453
458
|
await this.initModel(appName)
|
|
454
459
|
// const models = Object.keys(this.app[appName].model).join(' / ')
|
|
455
|
-
// if (taskConfig.is_available) {
|
|
456
|
-
// this.initTask(appName)
|
|
457
|
-
// }
|
|
458
460
|
} catch (e) {
|
|
459
461
|
console.log(`${appName}数据库连接失败`)
|
|
460
462
|
console.log(e)
|
|
@@ -506,38 +508,6 @@ class APP {
|
|
|
506
508
|
}
|
|
507
509
|
}
|
|
508
510
|
|
|
509
|
-
async initTask(appName) {
|
|
510
|
-
console.log(chalk.red(`启动任务${appName}`))
|
|
511
|
-
const taskDir = path.resolve(
|
|
512
|
-
__dirname,
|
|
513
|
-
`${rootDirectory}/${APP_DIR}/${appName}/task`
|
|
514
|
-
)
|
|
515
|
-
const publicExist = fs.existsSync(taskDir)
|
|
516
|
-
if (!publicExist) await fsPromise.mkdir(taskDir)
|
|
517
|
-
const list = await fsPromise.readdir(taskDir)
|
|
518
|
-
for (let i = 0; i < list.length; i++) {
|
|
519
|
-
const folder = list[i]
|
|
520
|
-
const isFolder = fs.lstatSync(path.resolve(taskDir, folder)).isDirectory()
|
|
521
|
-
if (isFolder) {
|
|
522
|
-
const folderDir = await fsPromise.readdir(path.resolve(taskDir, folder))
|
|
523
|
-
folderDir.forEach((filename) => {
|
|
524
|
-
if (filename === 'index.js') {
|
|
525
|
-
const task = require(path.resolve(
|
|
526
|
-
__dirname,
|
|
527
|
-
`${rootDirectory}/${APP_DIR}/${appName}/task/${folder}`
|
|
528
|
-
))
|
|
529
|
-
this.app[appName] = _.defaultsDeep(
|
|
530
|
-
{
|
|
531
|
-
task,
|
|
532
|
-
},
|
|
533
|
-
this.app[appName]
|
|
534
|
-
)
|
|
535
|
-
}
|
|
536
|
-
})
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
511
|
async initPlugin(appName) {
|
|
542
512
|
const pluginDir = path.resolve(
|
|
543
513
|
__dirname,
|