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