const transformer = require('./dist/index');
const path = require("path");
const fs = require("fs");

const start = transformer.transformDSL;
const projectPath = path.join(process.argv[2], '..');
const childModuleFlag = process.argv[3];
const ENV_CODE = process.argv[4];
const APPLICATION_CODE = process.argv[5];
const antPrefixCls = process.argv[6];

(async () => {
    const res = await start({
        projectPath,
        jwtToken: '',
        childModuleFlag,
        envCode: ENV_CODE,
        appCode: APPLICATION_CODE,
        microInfo: childModuleFlag === 'microApp' ? { microId: 'fakeId' } : null,
        antPrefixCls,
    });
    if (res.success) {
        console.log('转换成功!');
        fs.writeFileSync('result.txt', 'success');
    } else {
        console.log('dsl 转换失败：', res.errorInfo);
        fs.writeFileSync('result.txt', 'fail');
    }
})()