Skip to content

Commit

Permalink
Merge pull request #76 from JerrysShan/refactor/export
Browse files Browse the repository at this point in the history
chore: reexport injection and pipeline
  • Loading branch information
JerrysShan authored May 20, 2022
2 parents 7cf02e9 + 7d22465 commit ca1bc40
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 18 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
"version": "1.0.0-beta.0",
"description": "Core package of Artus",
"main": "lib/index.js",
"exports": {
".": "./lib/index.js",
"./injection": "./lib/injection.js",
"./pipeline": "./lib/pipeline.js"
},
"files": [
"lib"
],
"scripts": {
"build": "tsc",
"build": "tsc -p ./tsconfig.build.json",
"test": "jest --detectOpenHandles",
"ci": "npm run test"
},
Expand Down Expand Up @@ -36,8 +41,8 @@
"typescript": "^4.6.2"
},
"dependencies": {
"@artus/injection": "^0.1.3",
"@artus/pipeline": "^0.1.6",
"@artus/injection": "^0.2.0",
"@artus/pipeline": "^0.2.1",
"deepmerge": "^4.2.2",
"js-yaml": "^4.1.0",
"minimatch": "^5.0.1"
Expand Down
1 change: 1 addition & 0 deletions src/injection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@artus/injection';
1 change: 1 addition & 0 deletions src/pipeline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@artus/pipeline';
11 changes: 5 additions & 6 deletions src/trigger/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Inject } from '@artus/injection';
import { ExecutionContainer, Inject } from '@artus/injection';
import { Input, Context, MiddlewareInput, Pipeline, Output } from '@artus/pipeline';
import { ArtusInjectEnum } from '../constraints';
import { Application } from '../types';
Expand All @@ -7,7 +7,7 @@ import { DefineTrigger } from './decorator';
@DefineTrigger()
export default class Trigger {
private pipeline: Pipeline;

@Inject(ArtusInjectEnum.Application)
// @ts-ignore
private app: Application;
Expand All @@ -22,10 +22,9 @@ export default class Trigger {
}

async initContext(input: Input): Promise<Context> {
return new Context(input, new Output(), {
// SEEME: need replace to injection provided container getter way in future.
parentContainer: this.app.getContainer()
});
const ctx = new Context(input, new Output());
ctx.container = new ExecutionContainer(ctx, this.app.getContainer())
return ctx;
}

async startPipeline(input: Input = new Input()): Promise<Context> {
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/module_with_ts/src/test_service_a.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ScopeEnum } from '@artus/injection';
import { Injectable, Inject } from '../../../../src';
import { ScopeEnum, Injectable, Inject } from '@artus/injection';
import TestServiceB from './test_service_b';

@Injectable({
Expand All @@ -11,7 +10,7 @@ export default class TestServiceA {
// @ts-ignore
testServiceB: TestServiceB;

testMethod () {
testMethod() {
return this.testServiceB.sayHello();
}
}
5 changes: 2 additions & 3 deletions test/fixtures/module_with_ts/src/test_service_b.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ScopeEnum } from '@artus/injection';
import { Injectable } from '../../../../src';
import { ScopeEnum, Injectable } from '@artus/injection';

@Injectable({
id: 'testServiceB',
scope: ScopeEnum.SINGLETON
})
export default class TestServiceB {
sayHello () {
sayHello() {
return 'Hello Artus';
}
}
7 changes: 7 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
},
"exclude": ["lib", "test", "**/*.test.ts"]
}
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"outDir": "./lib",
"rootDir": "./src",
"target": "es2017",
"module": "commonjs",
"lib": [
Expand Down Expand Up @@ -35,7 +34,5 @@
},
"exclude": [
"lib",
"test",
"**/*.test.ts"
],
}

0 comments on commit ca1bc40

Please sign in to comment.