X Tutup
Skip to content

Commit a2d857b

Browse files
committed
feat: add file name as the third argument which passed to module post processor
1 parent bb770b8 commit a2d857b

File tree

3 files changed

+27
-33
lines changed

3 files changed

+27
-33
lines changed

.eslintrc.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module.exports = {
1515
'no-prototype-builtins': 1,
1616
'no-useless-constructor': 1,
1717
'no-empty-function': 1,
18-
'@typescript-eslint/member-ordering': 0,
1918
'lines-between-class-members': 0,
2019
'no-await-in-loop': 0,
2120
'no-plusplus': 0,
@@ -35,22 +34,23 @@ module.exports = {
3534
'@typescript-eslint/indent': 0,
3635
'import/no-cycle': 0,
3736
'@typescript-eslint/no-shadow': 0,
38-
"@typescript-eslint/method-signature-style": 0,
39-
"@typescript-eslint/consistent-type-assertions": 0,
40-
"@typescript-eslint/no-useless-constructor": 0,
37+
'@typescript-eslint/method-signature-style': 0,
38+
'@typescript-eslint/consistent-type-assertions': 0,
39+
'@typescript-eslint/no-useless-constructor': 0,
4140
'@typescript-eslint/dot-notation': 0, // for lint performance
4241
'@typescript-eslint/restrict-plus-operands': 0, // for lint performance
4342
'no-unexpected-multiline': 1,
44-
'no-multiple-empty-lines': ['error', { "max": 1 }],
43+
'no-multiple-empty-lines': ['error', { max: 1 }],
4544
'lines-around-comment': ['error', {
46-
"beforeBlockComment": true,
47-
"afterBlockComment": false,
48-
"afterLineComment": false,
49-
"allowBlockStart": true,
45+
beforeBlockComment: true,
46+
afterBlockComment: false,
47+
afterLineComment: false,
48+
allowBlockStart: true,
5049
}],
51-
"@typescript-eslint/member-ordering": [
52-
"error",
53-
{ "default": ["signature", "field", "constructor", "method"] }
50+
'comma-dangle': ['error', 'always-multiline'],
51+
'@typescript-eslint/member-ordering': [
52+
'error',
53+
{ default: ['signature', 'field', 'constructor', 'method'] },
5454
],
55-
}
55+
},
5656
};

modules/code-generator/src/generator/ModuleBuilder.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ export function createModuleBuilder(
6262

6363
if (options.postProcessors.length > 0) {
6464
files = files.map((file) => {
65-
let { content } = file;
66-
const type = file.ext;
65+
let { content, ext: type, name } = file;
6766
options.postProcessors.forEach((processer) => {
68-
content = processer(content, type);
67+
content = processer(content, type, name);
6968
});
7069

7170
return createResultFile(file.name, type, content);

modules/code-generator/src/types/core.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import {
2-
IPublicTypeJSONArray,
3-
IPublicTypeJSONObject,
42
IPublicTypeCompositeArray,
5-
IPublicTypeCompositeObject,
6-
ResultDir,
3+
IPublicTypeCompositeObject, IPublicTypeJSExpression,
4+
IPublicTypeJSFunction, IPublicTypeJSONArray,
5+
IPublicTypeJSONObject, IPublicTypeJSSlot, IPublicTypeNodeDataType,
6+
IPublicTypeProjectSchema, ResultDir,
77
ResultFile,
8-
IPublicTypeNodeDataType,
9-
IPublicTypeProjectSchema,
10-
IPublicTypeJSExpression,
11-
IPublicTypeJSFunction,
12-
IPublicTypeJSSlot,
138
} from '@alilc/lowcode-types';
149

15-
import { IParseResult } from './intermediate';
16-
import { IScopeBindings } from '../utils/ScopeBindings';
1710
import type { ProjectBuilderInitOptions } from '../generator/ProjectBuilder';
11+
import { IScopeBindings } from '../utils/ScopeBindings';
12+
import { IParseResult } from './intermediate';
1813

1914
export enum FileType {
2015
CSS = 'css',
@@ -69,16 +64,16 @@ export interface ICodeStruct extends IBaseCodeStruct {
6964
/** 上下文数据,用来在插件之间共享一些数据 */
7065
export interface IContextData extends IProjectBuilderOptions {
7166

72-
/**
73-
* 是否使用了 Ref 的 API (this.$/this.$$)
74-
* */
75-
useRefApi?: boolean;
76-
7767
/**
7868
* 其他自定义数据
7969
* (三方自定义插件也可以在此放一些数据,建议起个长一点的名称,用自己的插件名做前缀,以防冲突)
8070
*/
8171
[key: string]: any;
72+
73+
/**
74+
* 是否使用了 Ref 的 API (this.$/this.$$)
75+
* */
76+
useRefApi?: boolean;
8277
}
8378

8479
export type BuilderComponentPlugin = (initStruct: ICodeStruct) => Promise<ICodeStruct>;
@@ -202,7 +197,7 @@ export type ProjectPostProcessor = (
202197
export type PostProcessorFactory<T> = (config?: T) => PostProcessor;
203198

204199
/** 模块级别的后置处理器 */
205-
export type PostProcessor = (content: string, fileType: string) => string;
200+
export type PostProcessor = (content: string, fileType: string, name: string) => string;
206201

207202
// TODO: temp interface, need modify
208203
export interface IPluginOptions {

0 commit comments

Comments
 (0)
X Tutup