From 3447dbc8f54a97fd118d068ee6aaee4b4cb9b459 Mon Sep 17 00:00:00 2001 From: JerrysShan <1670303003@qq.com> Date: Thu, 19 May 2022 15:19:50 +0800 Subject: [PATCH 1/6] chore: reexport injection and pipeline --- src/index.ts | 7 ------- src/injection.ts | 1 + src/pipeline.ts | 1 + 3 files changed, 2 insertions(+), 7 deletions(-) create mode 100644 src/injection.ts create mode 100644 src/pipeline.ts diff --git a/src/index.ts b/src/index.ts index 00c3d54..defdf1f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,3 @@ - - -export { - Inject, - Injectable -} from '@artus/injection'; - export { ArtusInjectEnum } from './constraints'; diff --git a/src/injection.ts b/src/injection.ts new file mode 100644 index 0000000..da1d31b --- /dev/null +++ b/src/injection.ts @@ -0,0 +1 @@ +export * from '@artus/injection'; \ No newline at end of file diff --git a/src/pipeline.ts b/src/pipeline.ts new file mode 100644 index 0000000..499e1b6 --- /dev/null +++ b/src/pipeline.ts @@ -0,0 +1 @@ +export * from '@artus/pipeline'; \ No newline at end of file From bd8e4882e2a94c6d1d8127f99cc7e08f79c18d95 Mon Sep 17 00:00:00 2001 From: JerrysShan <1670303003@qq.com> Date: Thu, 19 May 2022 16:15:54 +0800 Subject: [PATCH 2/6] test: fix import --- test/fixtures/module_with_ts/src/test_service_a.ts | 5 ++--- test/fixtures/module_with_ts/src/test_service_b.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/fixtures/module_with_ts/src/test_service_a.ts b/test/fixtures/module_with_ts/src/test_service_a.ts index 8d7522e..6467d25 100644 --- a/test/fixtures/module_with_ts/src/test_service_a.ts +++ b/test/fixtures/module_with_ts/src/test_service_a.ts @@ -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({ @@ -11,7 +10,7 @@ export default class TestServiceA { // @ts-ignore testServiceB: TestServiceB; - testMethod () { + testMethod() { return this.testServiceB.sayHello(); } } diff --git a/test/fixtures/module_with_ts/src/test_service_b.ts b/test/fixtures/module_with_ts/src/test_service_b.ts index 16c5e60..5754d15 100644 --- a/test/fixtures/module_with_ts/src/test_service_b.ts +++ b/test/fixtures/module_with_ts/src/test_service_b.ts @@ -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'; } } From a3a4c10d30ae45b83a182e4243c0a4765920ae91 Mon Sep 17 00:00:00 2001 From: JerrysShan <1670303003@qq.com> Date: Thu, 19 May 2022 16:35:35 +0800 Subject: [PATCH 3/6] feat: add exports field --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 211d01f..c1a0517 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,11 @@ "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" ], From c7d28a31f514077b758578ba0e4bfa177965d104 Mon Sep 17 00:00:00 2001 From: JerrysShan <1670303003@qq.com> Date: Thu, 19 May 2022 19:21:18 +0800 Subject: [PATCH 4/6] chore: restore main export --- package.json | 2 +- src/index.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c1a0517..ceb199f 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "typescript": "^4.6.2" }, "dependencies": { - "@artus/injection": "^0.1.3", + "@artus/injection": "^0.2.0", "@artus/pipeline": "^0.1.6", "deepmerge": "^4.2.2", "js-yaml": "^4.1.0", diff --git a/src/index.ts b/src/index.ts index defdf1f..00c3d54 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,10 @@ + + +export { + Inject, + Injectable +} from '@artus/injection'; + export { ArtusInjectEnum } from './constraints'; From 19408da72c0cfa0ef2219c3e94ff24a6a0eee731 Mon Sep 17 00:00:00 2001 From: JerrysShan <1670303003@qq.com> Date: Thu, 19 May 2022 19:48:49 +0800 Subject: [PATCH 5/6] chore: upgrade pipeline version --- package.json | 2 +- src/trigger/index.ts | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index ceb199f..3cb5c35 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@artus/injection": "^0.2.0", - "@artus/pipeline": "^0.1.6", + "@artus/pipeline": "^0.2.0", "deepmerge": "^4.2.2", "js-yaml": "^4.1.0", "minimatch": "^5.0.1" diff --git a/src/trigger/index.ts b/src/trigger/index.ts index f661b74..8eb3da6 100644 --- a/src/trigger/index.ts +++ b/src/trigger/index.ts @@ -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'; @@ -7,7 +7,7 @@ import { DefineTrigger } from './decorator'; @DefineTrigger() export default class Trigger { private pipeline: Pipeline; - + @Inject(ArtusInjectEnum.Application) // @ts-ignore private app: Application; @@ -22,10 +22,9 @@ export default class Trigger { } async initContext(input: Input): Promise { - 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 { From 4542c53a0c75316f95ae860994cf465e76a9bbbf Mon Sep 17 00:00:00 2001 From: JerrysShan <1670303003@qq.com> Date: Fri, 20 May 2022 17:03:27 +0800 Subject: [PATCH 6/6] chore: add ts build config --- package.json | 4 ++-- tsconfig.build.json | 7 +++++++ tsconfig.json | 3 --- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 tsconfig.build.json diff --git a/package.json b/package.json index 3cb5c35..c56c6fb 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "lib" ], "scripts": { - "build": "tsc", + "build": "tsc -p ./tsconfig.build.json", "test": "jest --detectOpenHandles", "ci": "npm run test" }, @@ -42,7 +42,7 @@ }, "dependencies": { "@artus/injection": "^0.2.0", - "@artus/pipeline": "^0.2.0", + "@artus/pipeline": "^0.2.1", "deepmerge": "^4.2.2", "js-yaml": "^4.1.0", "minimatch": "^5.0.1" diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..21d10a3 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "rootDir": "./src" + }, + "exclude": ["lib", "test", "**/*.test.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index c0b8355..3dda78f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "outDir": "./lib", - "rootDir": "./src", "target": "es2017", "module": "commonjs", "lib": [ @@ -35,7 +34,5 @@ }, "exclude": [ "lib", - "test", - "**/*.test.ts" ], }