Compare commits

...

2 Commits

Author SHA1 Message Date
LeoYuan 袁力皓
f73dabe91c chore(release): code-generator - 1.0.7-beta.3 2022-11-28 16:41:24 +08:00
LeoYuan 袁力皓
16952d1696 fix: componentName can contain dot notation 2022-11-28 16:40:44 +08:00
3 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-code-generator",
"version": "1.0.7-beta.2",
"version": "1.0.7-beta.3",
"description": "出码引擎 for LowCode Engine",
"license": "MIT",
"main": "lib/index.js",

View File

@ -16,7 +16,7 @@ import {
IWithDependency,
} from '../../types';
import { isValidIdentifier } from '../../utils/validate';
import { isValidIdentifier, isValidComponentName } from '../../utils/validate';
// TODO: main 这个信息到底怎么用,是不是外部包不需要使用?
const DEP_MAIN_BLOCKLIST = ['lib', 'lib/index', 'es', 'es/index', 'main'];
@ -261,7 +261,7 @@ function buildPackageImport(
if (!isValidIdentifier(name)) {
throw new CodeGeneratorError(`Invalid Identifier [${name}]`);
}
if (info.nodeIdentifier && !isValidIdentifier(info.nodeIdentifier)) {
if (info.nodeIdentifier && !isValidComponentName(info.nodeIdentifier)) {
throw new CodeGeneratorError(`Invalid Identifier [${info.nodeIdentifier}]`);
}
});

View File

@ -2,6 +2,10 @@ export const isValidIdentifier = (name: string) => {
return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/.test(name);
};
export const isValidComponentName = (name: string) => {
return /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF.]*$/.test(name);
};
export const ensureValidClassName = (name: string) => {
if (!isValidIdentifier(name)) {
return `$${name.replace(/[^_$a-zA-Z0-9]/g, '')}`;