-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: component get config and merge egg config (#649)
- Loading branch information
1 parent
0e996a9
commit aa95a3e
Showing
17 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
preset: 'ts-jest', | ||
testPathIgnorePatterns: ['<rootDir>/test/fixtures'], | ||
coveragePathIgnorePatterns: ['<rootDir>/test/'], | ||
setupFilesAfterEnv: [path.join(__dirname, 'test/.setup.js')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const path = require('path'); | ||
|
||
process.env.MIDWAY_TS_MODE = 'true'; | ||
process.env.MIDWAY_EGG_PLUGIN_PATH = path.join(__dirname, '../../../'); | ||
jest.setTimeout(30000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/web/test/fixtures/feature/base-app-component-config/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "ali-demo" | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/web/test/fixtures/feature/base-app-component-config/src/component/sql/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@component/sql", | ||
"main": "src/index" | ||
} |
3 changes: 3 additions & 0 deletions
3
...fixtures/feature/base-app-component-config/src/component/sql/src/config/config.default.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const mock = { | ||
bbb: 1 | ||
} |
17 changes: 17 additions & 0 deletions
17
...eb/test/fixtures/feature/base-app-component-config/src/component/sql/src/configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// src/configuration.ts | ||
import { Configuration, Config } from '@midwayjs/decorator'; | ||
|
||
@Configuration({ | ||
importConfigs: [ | ||
'./config/' | ||
], | ||
}) | ||
export class ContainerLifeCycle { | ||
|
||
@Config() | ||
mock; | ||
|
||
onReady() { | ||
console.log(this.mock); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../test/fixtures/feature/base-app-component-config/src/component/sql/src/controller/home.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Config, Controller, Get, Provide } from '@midwayjs/decorator'; | ||
|
||
@Provide() | ||
@Controller('/') | ||
export class HomeController { | ||
@Config() | ||
mock; | ||
|
||
@Get() | ||
async home() { | ||
return 'hello world' + this.mock.bbb; | ||
} | ||
} |
Empty file.
9 changes: 9 additions & 0 deletions
9
packages/web/test/fixtures/feature/base-app-component-config/src/config/config.default.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
export const keys = 'key'; | ||
|
||
export const hello = { | ||
a: 1, | ||
b: 2, | ||
d: [1, 2, 3], | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/web/test/fixtures/feature/base-app-component-config/src/config/config.unittest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
exports.hello = { | ||
b: 4, | ||
c: 3, | ||
}; |
6 changes: 6 additions & 0 deletions
6
packages/web/test/fixtures/feature/base-app-component-config/src/configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Configuration } from '@midwayjs/decorator'; | ||
|
||
@Configuration({ | ||
imports: ['./component/sql/src'], | ||
}) | ||
export class ContainerConfiguration {} |