mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-13 20:27:19 +00:00
Merge pull request #8 from alibaba/test/setup-action
chore: 修改 code style 以及配置 lint & test action
This commit is contained in:
commit
d16fed25a4
36
.github/workflows/test.yml
vendored
Normal file
36
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
name: lint & test
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
|
||||||
|
- name: install
|
||||||
|
run: npm i && npm run setup:skip-build
|
||||||
|
|
||||||
|
- name: lint
|
||||||
|
run: npm run lint
|
||||||
|
|
||||||
|
test-designer:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
|
||||||
|
- name: install
|
||||||
|
run: npm i && npm run setup:skip-build
|
||||||
|
|
||||||
|
- name: lint
|
||||||
|
run: cd packages/designer && npm test
|
||||||
@ -53,7 +53,6 @@ export function flattenResult(dir: ResultDir, cwd = ''): FlattenFile[] {
|
|||||||
),
|
),
|
||||||
].concat(
|
].concat(
|
||||||
...dir.dirs.map((subDir) =>
|
...dir.dirs.map((subDir) =>
|
||||||
flattenResult(subDir, [cwd, subDir.name].filter((x) => x !== '' && x !== '.').join('/')),
|
flattenResult(subDir, [cwd, subDir.name].filter((x) => x !== '' && x !== '.').join('/'))),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ export function resolveToImport(initialPath) {
|
|||||||
}
|
}
|
||||||
pathBuffer.unshift(...paths);
|
pathBuffer.unshift(...paths);
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line no-fallthrough
|
||||||
case 'Identifier':
|
case 'Identifier':
|
||||||
case 'JSXIdentifier': {
|
case 'JSXIdentifier': {
|
||||||
const valuePath = resolveToValue(path);
|
const valuePath = resolveToValue(path);
|
||||||
|
|||||||
@ -25,6 +25,7 @@ export default function getComposedPropTypesPath(documentation, propName, p) {
|
|||||||
const ast = parser.parse(fileContent);
|
const ast = parser.parse(fileContent);
|
||||||
|
|
||||||
visit(ast, {
|
visit(ast, {
|
||||||
|
// eslint-disable-next-line no-loop-func
|
||||||
visitAssignmentExpression(path: any) {
|
visitAssignmentExpression(path: any) {
|
||||||
// Ignore anything that is not `exports.X = ...;` or
|
// Ignore anything that is not `exports.X = ...;` or
|
||||||
// `module.exports = ...;`
|
// `module.exports = ...;`
|
||||||
|
|||||||
@ -299,8 +299,7 @@ function getDocgenTypeHelper(
|
|||||||
name: 'union',
|
name: 'union',
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
value: type.types.map((t) =>
|
value: type.types.map((t) =>
|
||||||
getDocgenTypeHelper(checker, t, true, getNextParentIds(parentIds, type)),
|
getDocgenTypeHelper(checker, t, true, getNextParentIds(parentIds, type))),
|
||||||
),
|
|
||||||
});
|
});
|
||||||
} else if (isComplexType(type)) {
|
} else if (isComplexType(type)) {
|
||||||
return makeResult({
|
return makeResult({
|
||||||
@ -494,8 +493,7 @@ export default function parseTS(filePath: string, args: IParseArgs): ComponentDo
|
|||||||
|
|
||||||
log('ts config path is', tsConfigPath);
|
log('ts config path is', tsConfigPath);
|
||||||
const { config, error } = ts.readConfigFile(tsConfigPath, (filename) =>
|
const { config, error } = ts.readConfigFile(tsConfigPath, (filename) =>
|
||||||
readFileSync(filename, 'utf8'),
|
readFileSync(filename, 'utf8'));
|
||||||
);
|
|
||||||
|
|
||||||
if (error !== undefined) {
|
if (error !== undefined) {
|
||||||
const errorText = `Cannot load custom tsconfig.json from provided path: ${tsConfigPath}, with error code: ${error.code}, message: ${error.messageText}`;
|
const errorText = `Cannot load custom tsconfig.json from provided path: ${tsConfigPath}, with error code: ${error.code}, message: ${error.messageText}`;
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
"setup:test": "./scripts/setup-for-test.sh",
|
"setup:test": "./scripts/setup-for-test.sh",
|
||||||
"setup:skip-build": "./scripts/setup-skip-build.sh",
|
"setup:skip-build": "./scripts/setup-skip-build.sh",
|
||||||
"start": "./scripts/start.sh",
|
"start": "./scripts/start.sh",
|
||||||
"start:demo": "./scripts/start.sh @ali/lowcode-demo",
|
|
||||||
"test": "lerna run test --stream",
|
"test": "lerna run test --stream",
|
||||||
"test:snapshot": "lerna run test:snapshot",
|
"test:snapshot": "lerna run test:snapshot",
|
||||||
"watchdog:build": "node ./scripts/watchdog.js",
|
"watchdog:build": "node ./scripts/watchdog.js",
|
||||||
|
|||||||
@ -37,6 +37,7 @@ export declare interface Editor extends StrictEventEmitter<EventEmitter, GlobalE
|
|||||||
getPreference(): Preference;
|
getPreference(): Preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-redeclare
|
||||||
export class Editor extends (EventEmitter as any) implements IEditor {
|
export class Editor extends (EventEmitter as any) implements IEditor {
|
||||||
/**
|
/**
|
||||||
* Ioc Container
|
* Ioc Container
|
||||||
|
|||||||
@ -28,11 +28,11 @@ window.__newFunc = (funContext: string): ((...args: any[]) => any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 关闭浏览器前提醒,只有产生过交互才会生效
|
// 关闭浏览器前提醒,只有产生过交互才会生效
|
||||||
window.onbeforeunload = function (e: Event): string | void {
|
window.onbeforeunload = function (e: Event): string {
|
||||||
const ev = e || window.event;
|
const ev = e || window.event;
|
||||||
// 本地调试不生效
|
// 本地调试不生效
|
||||||
if (location.href.indexOf('localhost') > 0) {
|
if (location.href.indexOf('localhost') > 0) {
|
||||||
return;
|
return '';
|
||||||
}
|
}
|
||||||
const msg = '您确定要离开此页面吗?';
|
const msg = '您确定要离开此页面吗?';
|
||||||
ev.cancelBubble = true;
|
ev.cancelBubble = true;
|
||||||
|
|||||||
@ -2,6 +2,6 @@ import Logger, { Level } from 'zen-logger';
|
|||||||
|
|
||||||
export { Logger };
|
export { Logger };
|
||||||
|
|
||||||
export function getLogger(config: { level: Level, bizName: string }): Logger {
|
export function getLogger(config: { level: Level; bizName: string }): Logger {
|
||||||
return new Logger(config);
|
return new Logger(config);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export default class Preference {
|
|||||||
return `${STORAGE_KEY_PREFIX}_${moduleKey}.${key}`;
|
return `${STORAGE_KEY_PREFIX}_${moduleKey}.${key}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(key: string, value:any, module?: string) {
|
set(key: string, value: any, module?: string) {
|
||||||
if (!key || typeof key !== 'string' || key.length === 0) {
|
if (!key || typeof key !== 'string' || key.length === 0) {
|
||||||
logger.error('Invalid key when setting preference', key);
|
logger.error('Invalid key when setting preference', key);
|
||||||
return;
|
return;
|
||||||
@ -26,7 +26,7 @@ export default class Preference {
|
|||||||
store.set(storageKey, value);
|
store.set(storageKey, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get(key: string, module: string) : any {
|
get(key: string, module: string): any {
|
||||||
if (!key || typeof key !== 'string' || key.length === 0) {
|
if (!key || typeof key !== 'string' || key.length === 0) {
|
||||||
logger.error('Invalid key when getting from preference', key);
|
logger.error('Invalid key when getting from preference', key);
|
||||||
return;
|
return;
|
||||||
@ -44,7 +44,7 @@ export default class Preference {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
* @memberof Preference
|
* @memberof Preference
|
||||||
*/
|
*/
|
||||||
contains(key: string, module: string) : boolean {
|
contains(key: string, module: string): boolean {
|
||||||
if (!key || typeof key !== 'string' || key.length === 0) {
|
if (!key || typeof key !== 'string' || key.length === 0) {
|
||||||
logger.error('Invalid key when getting from preference', key);
|
logger.error('Invalid key when getting from preference', key);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ interface UtilsMetadata {
|
|||||||
subName?: string;
|
subName?: string;
|
||||||
destructuring?: boolean;
|
destructuring?: boolean;
|
||||||
main?: string;
|
main?: string;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LibrayMap {
|
interface LibrayMap {
|
||||||
|
|||||||
@ -126,7 +126,8 @@ function toCss(runtime) {
|
|||||||
css.push(
|
css.push(
|
||||||
`:root${pseudo === 'default' ? '' : `${prefix}${pseudo}`} {
|
`:root${pseudo === 'default' ? '' : `${prefix}${pseudo}`} {
|
||||||
${runtimeToCss(normalizeStyle(runtime[pseudo]))}
|
${runtimeToCss(normalizeStyle(runtime[pseudo]))}
|
||||||
}\n`);
|
}\n`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
return css.join('\n');
|
return css.join('\n');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
export function setPrototypeOf(target: any, proto: any) {
|
export function setPrototypeOf(target: any, proto: any) {
|
||||||
// tslint:disable-next-line
|
|
||||||
if (typeof Object.setPrototypeOf !== 'undefined') {
|
if (typeof Object.setPrototypeOf !== 'undefined') {
|
||||||
Object.setPrototypeOf(target, proto); // tslint:disable-line
|
Object.setPrototypeOf(target, proto);
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line no-proto
|
// eslint-disable-next-line no-proto
|
||||||
target.__proto__ = proto;
|
target.__proto__ = proto;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user