GeezerVison is showing github.com — feat(material-parser): check module before install it; fix default va… · shenjo/lowcode-engine@fc452f7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: modules/material-parser/package.json +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "name": "@alilc/lowcode-material-parser", | 3 | | - "version": "1.0.1", | | 3 | + "version": "1.0.1-beta.3", | 4 | 4 | "description": "material parser for Ali lowCode engine", | 5 | 5 | "main": "lib/index.js", | 6 | 6 | "files": [ | | 18 | 18 | "@types/prop-types": "^15.7.3", | 19 | 19 | "copy-webpack-plugin": "^9.1.0", | 20 | 20 | "copyfiles": "^2.4.1", | | 21 | + "eslint": "^8.12.0", | | 22 | + "eslint-config-ali": "^14.0.0", | 21 | 23 | "jest": "^26.6.3", | 22 | 24 | "js-yaml": "^3.13.1", | 23 | 25 | "json-schema-to-typescript": "^8.2.0", | |
Collapse file Copy file name to clipboardExpand all lines: modules/material-parser/src/parse/transform.ts +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -286,9 +286,11 @@ export function transformItem(name: string, item: any) { | 286 | 286 | // if ('computed' in defaultValue) { | 287 | 287 | // val = val.value; | 288 | 288 | try { | 289 | | - const value = safeEval(defaultValue.value); | 290 | | - if (isEvaluable(value)) { | | 289 | + if (isEvaluable(defaultValue.value)) { | | 290 | + const value = safeEval(`'${defaultValue.value}'`); | 291 | 291 | result.defaultValue = value; | | 292 | + } else { | | 293 | + result.defaultValue = defaultValue.value; | 292 | 294 | } | 293 | 295 | } catch (e) { | 294 | 296 | log(e); | |
Collapse file Copy file name to clipboardExpand all lines: modules/material-parser/src/utils.ts +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,6 +13,14 @@ export async function isNPMInstalled(args: { | 13 | 13 | return pathExists(path.join(args.workDir, 'node_modules')); | 14 | 14 | } | 15 | 15 |
| | 16 | +export async function isNPMModuleInstalled( | | 17 | + args: { workDir: string; moduleDir: string; npmClient?: string }, | | 18 | + name: string, | | 19 | +) { | | 20 | + const modulePkgJsonPath = path.resolve(args.workDir, 'node_modules', name, 'package.json'); | | 21 | + return pathExists(modulePkgJsonPath); | | 22 | +} | | 23 | + | 16 | 24 | export async function install(args: { workDir: string; moduleDir: string; npmClient?: string }) { | 17 | 25 | if (await isNPMInstalled(args)) return; | 18 | 26 | const { workDir, npmClient = 'tnpm' } = args; | @@ -27,6 +35,7 @@ export async function installModule( | 27 | 35 | args: { workDir: string; moduleDir: string; npmClient?: string }, | 28 | 36 | name: string, | 29 | 37 | ) { | | 38 | + if (await isNPMModuleInstalled(args, name)) return; | 30 | 39 | const { workDir, npmClient = 'tnpm' } = args; | 31 | 40 | try { | 32 | 41 | await spawn(npmClient, ['i', name], { stdio: 'inherit', cwd: workDir } as any); | |
|