-
Notifications
You must be signed in to change notification settings - Fork 16
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
chore: plugin has own excluded #129
Conversation
背景: 因此,这里做下调整,尊重插件的excluded:
|
还有一种策略:
这种情况下,完全尊重plugin的设置,隔离用户设置带来的污染 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
这个逻辑会阻断 excluded 参数在扫描插件时的传递,可能带来 Breaking Change,请 @hyj1991 注意下
这个策略下用户的 exclude 还是会带来问题吧?exclude 其实不同于 |
用户只要关注应用代码需要忽略哪些即可 |
下面的策略,是不是你的意思:
|
对,我在想 |
另外是,现在的 |
确实对于 这些在 DEFAULT_EXCLUDE 中可能很难彻底覆盖,对于扫描参数中的
这个事情我没理解,貌似现在的格式是 glob,此例应该是 |
目前看这个能力是有的,现在走的是minimatch方式来判断 |
不是,按现在的规则,比如 |
应该算一个bug 吧 ,是否把 |
如果改成了方案二,其实这种场景可以当做“特性”来处理,而非bug,是可以接受的。 |
这样其实也讲得通,譬如 至于本 issue 的 fix 方案,我个人比较倾向方案二,plugin 的编写和 app 是分离的,用户的 exclude 配置不应该影响到 plugin 的文件。 |
最新改动:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试 case 没有体现 plugin 在 meta 中自定义 exclude
的例子
src/scanner/scan.ts
Outdated
@@ -32,8 +33,8 @@ export class Scanner { | |||
configDir: DEFAULT_CONFIG_DIR, | |||
loaderListGenerator: (defaultLoaderList: string[]) => defaultLoaderList, | |||
...options, | |||
excluded: DEFAULT_EXCLUDES.concat(options.excluded ?? []), | |||
extensions: [...new Set(this.moduleExtensions.concat(options.extensions ?? [], ['.yaml']))], | |||
excluded: [...new Set(DEFAULT_EXCLUDES.concat(options.excluded ?? []))], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个叫 excluded
其实比较奇怪,比如 tsconfig 中一般都是只命名为 exclude
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exclude +1,和 TS 维持一致好一点,@wengeezhang 要不一块改下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
样例和单测我补一下 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@@ -33,4 +34,40 @@ export class FrameworkHandler { | |||
throw new Error(`load framework faild: ${err}, framework config: ${JSON.stringify(config)}`); | |||
} | |||
} | |||
static async checkAndLoadMetadata(frameworkDir: string): Promise<Metadata>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和 Plugin 的好像重复实现了?
} | ||
|
||
if (!find) { | ||
throw new Error(`load framework import path ${frameworkDir} can't find meta file.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个应该会造成无 meta.yaml 的 Framework 直接报错,会是 Breaking Change cc @hyj1991
@@ -35,5 +35,11 @@ export interface TriggerType { | |||
initContext(...args): Promise<BaseContext>; | |||
startPipeline(...args): Promise<void>; | |||
} | |||
export interface Metadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名太泛了?
walkOptions.exclude = DEFAULT_EXCLUDES; | ||
} | ||
|
||
// plugin/framework extensions take priority over user app's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
先去掉吧,这是社区项目,留太多无用注释不好
return result; | ||
} | ||
|
||
private amendOptions(walkOptions: WalkOptions, metadata): WalkOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
昨天不是说把这个逻辑直接放在 formatWalkOptions
里?增加 “amend” 的意义在哪,这就是 formatWalkOptions
的职责吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是啊,这不是在formatWalkOptions里面调用的嘛
plugin.importPath, | ||
this.formatWalkOptions('plugin', plugin.importPath, plugin.name, plugin.metadata.configDir) | ||
); | ||
const pluginOpts = this.formatWalkOptions('plugin', plugin.importPath, plugin.name, plugin.metadata as Metadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是 extends 的 interface,不需要 as 吧
@@ -1 +1,2 @@ | |||
name: redis | |||
exclude: ['not_to_be_scanned_file.ts', 'not_to_be_scanned_dir'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺 glob 形式的验证,可以后续补充
No description provided.