mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
feat(material-parser): check module before install it; fix default value issue in ts parser
This commit is contained in:
parent
7cbfadee9d
commit
fc452f7166
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-material-parser",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.1-beta.3",
|
||||
"description": "material parser for Ali lowCode engine",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
@ -18,6 +18,8 @@
|
||||
"@types/prop-types": "^15.7.3",
|
||||
"copy-webpack-plugin": "^9.1.0",
|
||||
"copyfiles": "^2.4.1",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-config-ali": "^14.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"js-yaml": "^3.13.1",
|
||||
"json-schema-to-typescript": "^8.2.0",
|
||||
|
||||
@ -286,9 +286,11 @@ export function transformItem(name: string, item: any) {
|
||||
// if ('computed' in defaultValue) {
|
||||
// val = val.value;
|
||||
try {
|
||||
const value = safeEval(defaultValue.value);
|
||||
if (isEvaluable(value)) {
|
||||
if (isEvaluable(defaultValue.value)) {
|
||||
const value = safeEval(`'${defaultValue.value}'`);
|
||||
result.defaultValue = value;
|
||||
} else {
|
||||
result.defaultValue = defaultValue.value;
|
||||
}
|
||||
} catch (e) {
|
||||
log(e);
|
||||
|
||||
@ -13,6 +13,14 @@ export async function isNPMInstalled(args: {
|
||||
return pathExists(path.join(args.workDir, 'node_modules'));
|
||||
}
|
||||
|
||||
export async function isNPMModuleInstalled(
|
||||
args: { workDir: string; moduleDir: string; npmClient?: string },
|
||||
name: string,
|
||||
) {
|
||||
const modulePkgJsonPath = path.resolve(args.workDir, 'node_modules', name, 'package.json');
|
||||
return pathExists(modulePkgJsonPath);
|
||||
}
|
||||
|
||||
export async function install(args: { workDir: string; moduleDir: string; npmClient?: string }) {
|
||||
if (await isNPMInstalled(args)) return;
|
||||
const { workDir, npmClient = 'tnpm' } = args;
|
||||
@ -27,6 +35,7 @@ export async function installModule(
|
||||
args: { workDir: string; moduleDir: string; npmClient?: string },
|
||||
name: string,
|
||||
) {
|
||||
if (await isNPMModuleInstalled(args, name)) return;
|
||||
const { workDir, npmClient = 'tnpm' } = args;
|
||||
try {
|
||||
await spawn(npmClient, ['i', name], { stdio: 'inherit', cwd: workDir } as any);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user