Skip to content

Commit d743e56

Browse files
authored
Merge pull request #115 from long-woo/dev
release:v2.14.1
2 parents 7cf0007 + d1acec1 commit d743e56

File tree

7 files changed

+19
-10
lines changed

7 files changed

+19
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ Create a `myPlugin.ts` file:
153153

154154
```ts
155155
// 引用模块
156-
// import { start } from 'https://deno.land/x/stc@2.14.0/mod.ts'
157-
import { start } from 'jsr:@lonu/stc@^2.14.0'
156+
// import { start } from 'https://deno.land/x/stc@2.14.1/mod.ts'
157+
import { start } from 'jsr:@lonu/stc@^2.14.1'
158158

159159
// Defining plugins
160160
const myPlugin: IPlugin = {

deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@lonu/stc",
3-
"version": "2.14.0",
3+
"version": "2.14.1",
44
"exports": "./mod.ts",
55
"tasks": {
66
"pack": "deno run -A src/pack.ts",
77
"dev": "deno task pack && deno run -A --watch=src src/main.ts --url='https://petstore3.swagger.io/api/v3/openapi.json'",
88
"serve": "deno run -A --watch=src src/service.ts",
9-
"version": "echo '2.14.0' > release/version",
9+
"version": "echo '2.14.1' > release/version",
1010
"build:npm": "deno run -A src/npm/build.ts",
1111
"build:mac": "deno compile -A --target x86_64-apple-darwin --output release/stc src/main.ts",
1212
"build:mac-m": "deno compile -A --target aarch64-apple-darwin --output release/stc-m src/main.ts",

src/app.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ const initPluginManager = (context: IPluginContext) => {
1515
const pluginManager = new PluginManager();
1616

1717
// 注册插件
18-
pluginManager.register([
19-
...(context.options.plugins ?? []),
20-
]);
18+
pluginManager.register(context.options.plugins ?? []);
2119
// 启动所有插件
2220
pluginManager.setupAll(context);
2321
};

src/i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"parserActionDone": "Parsing url data is complete.",
5656
"no_200_response": "Missing information for 200 status code.",
5757
"no_tag": "{{url}} does not specify a tag, skip parsing. Please use the --tag parameter.",
58+
"alreadyRegistered": "Plugin {{names}} is already registered.",
5859
"template": {
5960
"enumRequired": "Missing enum.eta template file.",
6061
"actionImportRequired": "Missing actionImport.eta template file.",

src/i18n/locales/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"parserActionDone": "解析接口完成。",
5656
"no_200_response": "缺少 200 状态码的信息。",
5757
"no_tag": "{{url}} 未指定 tag,跳过解析。请使用 --tag 参数。",
58+
"alreadyRegistered": "内置插件 {{names}} 不能被重复注册。",
5859
"template": {
5960
"enumRequired": "缺失 enum.eta 模板文件。",
6061
"actionImportRequired": "缺失 actionImport.eta 模板文件。",

src/npm/pkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lonu/stc",
3-
"version": "2.14.0",
3+
"version": "2.14.1",
44
"description": "A tool for converting OpenApi/Swagger/Apifox into code.",
55
"type": "module",
66
"module": "esm/mod.js",

src/plugins/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,19 @@ export class PluginManager {
1515
// SwiftPlugin,
1616
];
1717

18-
register(plugin: IPlugin | IPlugin[]) {
18+
register(plugins: IPlugin[]) {
19+
const pluginNames = plugins.map((item) => item.name).join(", ");
20+
// 如果插件已经存在,则不重复注册
21+
if (this.plugins.every((item) => pluginNames.includes(item.name))) {
22+
Logs.warn(
23+
getT("$t(plugin.alreadyRegistered)", { names: pluginNames }),
24+
);
25+
return;
26+
}
27+
1928
this.plugins = [
2029
...this.plugins,
21-
...(Array.isArray(plugin) ? plugin : [plugin]),
30+
...(Array.isArray(plugins) ? plugins : [plugins]),
2231
];
2332
}
2433

0 commit comments

Comments
 (0)