q-koa 11.0.1 → 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 +4 -36
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -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`
|
|
@@ -454,9 +457,6 @@ class APP {
|
|
|
454
457
|
|
|
455
458
|
await this.initModel(appName)
|
|
456
459
|
// const models = Object.keys(this.app[appName].model).join(' / ')
|
|
457
|
-
// if (taskConfig.is_available) {
|
|
458
|
-
// this.initTask(appName)
|
|
459
|
-
// }
|
|
460
460
|
} catch (e) {
|
|
461
461
|
console.log(`${appName}数据库连接失败`)
|
|
462
462
|
console.log(e)
|
|
@@ -508,38 +508,6 @@ class APP {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
-
async initTask(appName) {
|
|
512
|
-
console.log(chalk.red(`启动任务${appName}`))
|
|
513
|
-
const taskDir = path.resolve(
|
|
514
|
-
__dirname,
|
|
515
|
-
`${rootDirectory}/${APP_DIR}/${appName}/task`
|
|
516
|
-
)
|
|
517
|
-
const publicExist = fs.existsSync(taskDir)
|
|
518
|
-
if (!publicExist) await fsPromise.mkdir(taskDir)
|
|
519
|
-
const list = await fsPromise.readdir(taskDir)
|
|
520
|
-
for (let i = 0; i < list.length; i++) {
|
|
521
|
-
const folder = list[i]
|
|
522
|
-
const isFolder = fs.lstatSync(path.resolve(taskDir, folder)).isDirectory()
|
|
523
|
-
if (isFolder) {
|
|
524
|
-
const folderDir = await fsPromise.readdir(path.resolve(taskDir, folder))
|
|
525
|
-
folderDir.forEach((filename) => {
|
|
526
|
-
if (filename === 'index.js') {
|
|
527
|
-
const task = require(path.resolve(
|
|
528
|
-
__dirname,
|
|
529
|
-
`${rootDirectory}/${APP_DIR}/${appName}/task/${folder}`
|
|
530
|
-
))
|
|
531
|
-
this.app[appName] = _.defaultsDeep(
|
|
532
|
-
{
|
|
533
|
-
task,
|
|
534
|
-
},
|
|
535
|
-
this.app[appName]
|
|
536
|
-
)
|
|
537
|
-
}
|
|
538
|
-
})
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
|
|
543
511
|
async initPlugin(appName) {
|
|
544
512
|
const pluginDir = path.resolve(
|
|
545
513
|
__dirname,
|