(_method)
| 34 | } |
| 35 | |
| 36 | async function execComponent(_method) { |
| 37 | const credentials = await getCurentCredential(access); |
| 38 | let tempProp = {}; |
| 39 | try { |
| 40 | const p = argvData.props || argvData.p; |
| 41 | tempProp = p ? JSON.parse(p) : {}; |
| 42 | } catch (e) { |
| 43 | throw new Error('-p/--props parameter format error'); |
| 44 | } |
| 45 | const argsObj = rawData |
| 46 | .slice(3) |
| 47 | .filter(o => !includes(argvData._argsObj, o)) |
| 48 | .concat(argvData._argsObj); |
| 49 | const inputs = { |
| 50 | props: tempProp, |
| 51 | credentials: credentials || {}, |
| 52 | appName: 'default', |
| 53 | project: { |
| 54 | component: componentName, |
| 55 | access, |
| 56 | projectName: 'default', |
| 57 | provider: undefined, |
| 58 | }, |
| 59 | command: _method, |
| 60 | args: argsObj.join(' '), |
| 61 | argsObj, |
| 62 | path: { |
| 63 | configPath: process.cwd(), |
| 64 | }, |
| 65 | }; |
| 66 | const reportData = { uid: await getUid(access), argv, command: _method, component: componentName, userAgent: getUserAgent({ component: componentName }) }; |
| 67 | try { |
| 68 | const res = await instance[_method](inputs); |
| 69 | if (isEmpty(res)) { |
| 70 | return logger.write(chalk.green(`End of method: ${_method}`)); |
| 71 | } |
| 72 | const argv = process.argv.slice(2); |
| 73 | const argvData = parseArgv(argv); |
| 74 | const outputFile = get(argvData, 'output-file'); |
| 75 | outputFile ? writeOutput(res) : showOutput(res); |
| 76 | execDaemon('report.js', { ...reportData, type: EReportType.command }); |
| 77 | } catch (error) { |
| 78 | handleError( |
| 79 | new DevsError(error.message, { |
| 80 | stack: error.stack, |
| 81 | exitCode: 101, |
| 82 | trackerType: ETrackerType.runtimeException, |
| 83 | }), |
| 84 | reportData, |
| 85 | ); |
| 86 | return; |
| 87 | } |
| 88 | } |
| 89 | // s cli fc -h |
| 90 | if (rawData.length === 2) { |
| 91 | if (instance['index']) { |
no test coverage detected