Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: configuration inject plugin and more in production environment #680

Merged
merged 35 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f12cd10
refactor: egg load and midway bootstrap
czy88840616 Oct 20, 2020
92c4cb6
feat: add container cache
czy88840616 Oct 21, 2020
692c32c
fix: web refactor case error
czy88840616 Oct 21, 2020
789cfa3
chore: clean code
czy88840616 Oct 21, 2020
1fb3ee5
chore: clean code
czy88840616 Oct 21, 2020
c344f42
fix: app.generateController
czy88840616 Oct 21, 2020
15754f8
test: complete case and enable old suit
czy88840616 Oct 21, 2020
7ca58aa
chore: add @deprecated jsdoc
czy88840616 Oct 22, 2020
1dd84bf
v2.3.17-beta.1
czy88840616 Oct 22, 2020
561ad17
Merge branch '2.x' into fix_egg_loader
czy88840616 Oct 22, 2020
297d419
refactor: use new method to resolve registry
czy88840616 Oct 23, 2020
600e1e5
chore: revert cache
czy88840616 Oct 23, 2020
626d825
v2.3.18-beta.1
czy88840616 Oct 23, 2020
f9daf1e
chore: try add definition meteadata
czy88840616 Oct 23, 2020
2754389
refactor: add cache for definition
czy88840616 Oct 24, 2020
f412a7b
chore: lint
czy88840616 Oct 24, 2020
b9e40e7
chore: update
czy88840616 Oct 24, 2020
35bf565
fix: move cache to midwayContainer
czy88840616 Oct 24, 2020
d5f8030
v2.3.18-beta.2
czy88840616 Oct 24, 2020
44896a5
fix: configuration emit twice in app
czy88840616 Oct 24, 2020
10d06b4
refactor: merge container and midwayContainer
czy88840616 Oct 25, 2020
a17f2c2
fix: lint
czy88840616 Oct 25, 2020
4814910
fix: lint
czy88840616 Oct 25, 2020
6f46753
fix: lint
czy88840616 Oct 25, 2020
bfe1926
refactor: merge loader and base framework
czy88840616 Oct 26, 2020
f7ad592
test: fix case
czy88840616 Oct 26, 2020
e2335ff
test: change lifecycle and pass case
czy88840616 Oct 26, 2020
1afb6db
fix: lifecycle trigger
czy88840616 Oct 26, 2020
595f272
v2.3.18-beta.3
czy88840616 Oct 26, 2020
df60453
fix: configuration trigger
czy88840616 Oct 26, 2020
a0948a7
v2.3.18-beta.4
czy88840616 Oct 26, 2020
92713d8
chore: update tsc
czy88840616 Oct 27, 2020
a603d23
v2.3.18-beta.5
czy88840616 Oct 27, 2020
d9de275
chore: update
czy88840616 Oct 27, 2020
8356e59
v2.3.18-beta.6
czy88840616 Oct 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: lint
  • Loading branch information
czy88840616 committed Oct 24, 2020
commit f412a7b401206ec401c941ad68e61c7c20499337
17 changes: 11 additions & 6 deletions packages/core/src/context/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ObjectDefinitionOptions,
ObjectIdentifier,
ScopeEnum,
TAGGED_PROP
TAGGED_PROP,
} from '@midwayjs/decorator';
import { IContainer, IObjectDefinitionMetadata } from '../interface';
import { ObjectDefinition } from '../definitions/objectDefinition';
Expand Down Expand Up @@ -82,7 +82,7 @@ export class Container extends BaseApplicationContext implements IContainer {
} else {
definitionMeta.constructorArgs.push({
type: 'value',
value: propertyMeta?.[0].value
value: propertyMeta?.[0].value,
});
}
}
Expand All @@ -98,7 +98,7 @@ export class Container extends BaseApplicationContext implements IContainer {
definitionMeta.properties.push({
metaKey,
args: propertyMeta.args,
value: propertyMeta.value
value: propertyMeta.value,
});
}
}
Expand Down Expand Up @@ -131,7 +131,10 @@ export class Container extends BaseApplicationContext implements IContainer {
this.debugLogger(` bind id => [${definition.id}]`);

// inject constructArgs
if(definitionMeta.constructorArgs && definitionMeta.constructorArgs.length) {
if (
definitionMeta.constructorArgs &&
definitionMeta.constructorArgs.length
) {
for (const constructorInfo of definitionMeta.constructorArgs) {
if (constructorInfo.type === 'ref') {
const refManagedIns = new ManagedReference();
Expand Down Expand Up @@ -174,7 +177,6 @@ export class Container extends BaseApplicationContext implements IContainer {
definition.scope = definitionMeta.scope;
definition.autowire = definitionMeta.autowire;


this.registerDefinition(definitionMeta.id, definition);
}

Expand All @@ -190,7 +192,10 @@ export class Container extends BaseApplicationContext implements IContainer {
return this.definitionMetadataList;
}

protected registerCustomBinding(objectDefinition: IObjectDefinitionMetadata, target: any) {
protected registerCustomBinding(
objectDefinition: IObjectDefinitionMetadata,
target: any
) {
// @async, @init, @destroy @scope
const objDefOptions: ObjectDefinitionOptions = getObjectDefProps(target);
this.convertOptionsToDefinition(objDefOptions, objectDefinition);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/context/midwayContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
ALL,
isAsyncFunction,
isClass,
isFunction
isFunction,
} from '@midwayjs/decorator';
import { ContainerConfiguration } from './configuration';
import { FUNCTION_INJECT_KEY } from '..';
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/definitions/objectCreator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { isAsyncFunction, isGeneratorFunction, isPromise } from '@midwayjs/decorator';
import {
isAsyncFunction,
isGeneratorFunction,
isPromise,
} from '@midwayjs/decorator';
import { IObjectCreator, IObjectDefinition } from '../interface';

export class ObjectCreator implements IObjectCreator {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export class ContainerLoader {
this.applicationContext = new MidwayContainer(this.baseDir, undefined);
if (ContainerLoader.parentDefinitionMetadata) {
this.duplicatedLoader = true;
this.applicationContext.restoreDefinitions(ContainerLoader.parentDefinitionMetadata);
this.applicationContext.restoreDefinitions(
ContainerLoader.parentDefinitionMetadata
);
}
this.applicationContext.disableConflictCheck = this.disableConflictCheck;
this.applicationContext.registerObject('baseDir', this.baseDir);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/util/staticConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getClassMetadata,
InjectionConfigurationOptions,
isClass,
isFunction
isFunction,
} from '@midwayjs/decorator';
import { IConfigService, safeRequire } from '..';
import { MidwayConfigService } from '../service/configService';
Expand Down
3 changes: 1 addition & 2 deletions packages/web/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ class AgentBootHook {
this.app = app;
}

async didLoad() {
}
async didLoad() {}

async willReady() {}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/app/extend/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module.exports = {

get webFramework() {
return this.loader.framework;
}
},
};
2 changes: 1 addition & 1 deletion packages/web/test/feature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('/test/feature.test.ts', () => {
await closeApp(app);
});

it('should got component config in app', async () => {
it.only('should got component config in app', async () => {
const app = await creatApp('feature/base-app-component-config');
const result = await createHttpRequest(app).get('/');
expect(result.text).toEqual('hello world1');
Expand Down