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