Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/infra/idl/idl2ts-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"homepage": "",
"license": "Apache-2.0",
"author": "fanwenjie.fe@bytedance.com",
"main": "./src/index.ts",
"bin": {
"idl2ts": "./src/cli.js"
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/infra/idl/idl2ts-cli/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const gen = (projectRoot: string, options: GenOptions) => {
commonCodePath,
aggregationExport,
formatter,
banner,
} = config;
const aliasMap = new Map();
const idlRoot = path.resolve(projectRoot, config.idlRoot);
Expand Down Expand Up @@ -53,6 +54,7 @@ export const gen = (projectRoot: string, options: GenOptions) => {
new LocalConfigPlugin({ outputDir: output, projectRoot, idlRoot }),
...plugins,
],
banner,
entryName: aggregationExport || 'index',
outputDir: output,
commonCodePath,
Expand Down
1 change: 1 addition & 0 deletions frontend/infra/idl/idl2ts-cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { ApiConfig, ApiTypeConfig } from './types';
26 changes: 14 additions & 12 deletions frontend/infra/idl/idl2ts-cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import { type IPlugin } from '@coze-arch/idl2ts-generator';

export interface ApiConfig {
// idl 入口
/** idl 入口 */
entries: Record<string, string>;
// idl 根目录
/** idl 根目录 */
idlRoot: string;
// 服务别名
// 自定义 api 方法
/** 服务别名 */
/** 自定义 api 方法 */
commonCodePath: string;
// api 产物目录
/** api 产物目录 */
output: string;
// 仓库信息设置
/** 仓库信息设置 */
repository?: {
// 仓库地址
/** 仓库地址 */
url: string;
// clone 到本地的位置
/** clone 到本地的位置 */
dest: string;
};
// 插件
/** 插件 */
plugins?: IPlugin[];
// 聚合导出的文件名
/** 聚合导出的文件名 */
aggregationExport?: string;
// 格式化文件
/** 格式化文件 */
formatter: (name: string, content: string) => string;
/** banner */
banner?: string;
idlFetchConfig?: {
source: string;
branch?: string;
Expand All @@ -32,6 +34,6 @@ export interface ApiConfig {
}

export interface ApiTypeConfig extends ApiConfig {
// 需要过滤的方法
/** 需要过滤的方法 */
filters: Record<string, string[]>;
}
5 changes: 5 additions & 0 deletions frontend/infra/idl/idl2ts-generator/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import {
AutoFixPathPlugin,
IgnoreStructFiledPlugin,
AutoFixDuplicateIncludesPlugin,
AutoFixDuplicateNamespacePlugin,
CommentFormatPlugin,
BannerPlugin,
} from './plugin';
import { type Contexts, HOOK } from './context';

Expand All @@ -41,6 +43,7 @@ export class ClientGenerator {
private output: IGentsRes = new Map();
static PLUGIN_PRIORITY = 0;
private processFile = new Set<string>();

constructor(options: Options) {
this.entries = options.entries.map(i => path.resolve(options.idlRoot, i));
this.options = options;
Expand All @@ -50,6 +53,8 @@ export class ClientGenerator {
new AutoFixPathPlugin(),
new CommentFormatPlugin(),
new AutoFixDuplicateIncludesPlugin(),
new AutoFixDuplicateNamespacePlugin(),
new BannerPlugin({ banner: options.banner }),
new AdapterPlugin(options),
new MetaPlugin(options),
new IgnoreStructFiledPlugin({ filter: ignoreField }),
Expand Down
Loading
Loading