mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-10 18:03:01 +00:00
feat: add file name as the third argument which passed to module post processor
This commit is contained in:
parent
bb770b8e5a
commit
a2d857b143
26
.eslintrc.js
26
.eslintrc.js
@ -15,7 +15,6 @@ module.exports = {
|
||||
'no-prototype-builtins': 1,
|
||||
'no-useless-constructor': 1,
|
||||
'no-empty-function': 1,
|
||||
'@typescript-eslint/member-ordering': 0,
|
||||
'lines-between-class-members': 0,
|
||||
'no-await-in-loop': 0,
|
||||
'no-plusplus': 0,
|
||||
@ -35,22 +34,23 @@ module.exports = {
|
||||
'@typescript-eslint/indent': 0,
|
||||
'import/no-cycle': 0,
|
||||
'@typescript-eslint/no-shadow': 0,
|
||||
"@typescript-eslint/method-signature-style": 0,
|
||||
"@typescript-eslint/consistent-type-assertions": 0,
|
||||
"@typescript-eslint/no-useless-constructor": 0,
|
||||
'@typescript-eslint/method-signature-style': 0,
|
||||
'@typescript-eslint/consistent-type-assertions': 0,
|
||||
'@typescript-eslint/no-useless-constructor': 0,
|
||||
'@typescript-eslint/dot-notation': 0, // for lint performance
|
||||
'@typescript-eslint/restrict-plus-operands': 0, // for lint performance
|
||||
'no-unexpected-multiline': 1,
|
||||
'no-multiple-empty-lines': ['error', { "max": 1 }],
|
||||
'no-multiple-empty-lines': ['error', { max: 1 }],
|
||||
'lines-around-comment': ['error', {
|
||||
"beforeBlockComment": true,
|
||||
"afterBlockComment": false,
|
||||
"afterLineComment": false,
|
||||
"allowBlockStart": true,
|
||||
beforeBlockComment: true,
|
||||
afterBlockComment: false,
|
||||
afterLineComment: false,
|
||||
allowBlockStart: true,
|
||||
}],
|
||||
"@typescript-eslint/member-ordering": [
|
||||
"error",
|
||||
{ "default": ["signature", "field", "constructor", "method"] }
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'@typescript-eslint/member-ordering': [
|
||||
'error',
|
||||
{ default: ['signature', 'field', 'constructor', 'method'] },
|
||||
],
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -62,10 +62,9 @@ export function createModuleBuilder(
|
||||
|
||||
if (options.postProcessors.length > 0) {
|
||||
files = files.map((file) => {
|
||||
let { content } = file;
|
||||
const type = file.ext;
|
||||
let { content, ext: type, name } = file;
|
||||
options.postProcessors.forEach((processer) => {
|
||||
content = processer(content, type);
|
||||
content = processer(content, type, name);
|
||||
});
|
||||
|
||||
return createResultFile(file.name, type, content);
|
||||
|
||||
@ -1,20 +1,15 @@
|
||||
import {
|
||||
IPublicTypeJSONArray,
|
||||
IPublicTypeJSONObject,
|
||||
IPublicTypeCompositeArray,
|
||||
IPublicTypeCompositeObject,
|
||||
ResultDir,
|
||||
IPublicTypeCompositeObject, IPublicTypeJSExpression,
|
||||
IPublicTypeJSFunction, IPublicTypeJSONArray,
|
||||
IPublicTypeJSONObject, IPublicTypeJSSlot, IPublicTypeNodeDataType,
|
||||
IPublicTypeProjectSchema, ResultDir,
|
||||
ResultFile,
|
||||
IPublicTypeNodeDataType,
|
||||
IPublicTypeProjectSchema,
|
||||
IPublicTypeJSExpression,
|
||||
IPublicTypeJSFunction,
|
||||
IPublicTypeJSSlot,
|
||||
} from '@alilc/lowcode-types';
|
||||
|
||||
import { IParseResult } from './intermediate';
|
||||
import { IScopeBindings } from '../utils/ScopeBindings';
|
||||
import type { ProjectBuilderInitOptions } from '../generator/ProjectBuilder';
|
||||
import { IScopeBindings } from '../utils/ScopeBindings';
|
||||
import { IParseResult } from './intermediate';
|
||||
|
||||
export enum FileType {
|
||||
CSS = 'css',
|
||||
@ -69,16 +64,16 @@ export interface ICodeStruct extends IBaseCodeStruct {
|
||||
/** 上下文数据,用来在插件之间共享一些数据 */
|
||||
export interface IContextData extends IProjectBuilderOptions {
|
||||
|
||||
/**
|
||||
* 是否使用了 Ref 的 API (this.$/this.$$)
|
||||
* */
|
||||
useRefApi?: boolean;
|
||||
|
||||
/**
|
||||
* 其他自定义数据
|
||||
* (三方自定义插件也可以在此放一些数据,建议起个长一点的名称,用自己的插件名做前缀,以防冲突)
|
||||
*/
|
||||
[key: string]: any;
|
||||
|
||||
/**
|
||||
* 是否使用了 Ref 的 API (this.$/this.$$)
|
||||
* */
|
||||
useRefApi?: boolean;
|
||||
}
|
||||
|
||||
export type BuilderComponentPlugin = (initStruct: ICodeStruct) => Promise<ICodeStruct>;
|
||||
@ -202,7 +197,7 @@ export type ProjectPostProcessor = (
|
||||
export type PostProcessorFactory<T> = (config?: T) => PostProcessor;
|
||||
|
||||
/** 模块级别的后置处理器 */
|
||||
export type PostProcessor = (content: string, fileType: string) => string;
|
||||
export type PostProcessor = (content: string, fileType: string, name: string) => string;
|
||||
|
||||
// TODO: temp interface, need modify
|
||||
export interface IPluginOptions {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user