"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const lowcode_code_generator_1 = require("@alilc/lowcode-code-generator");
const lowcode_code_generator_2 = tslib_1.__importDefault(require("@alilc/lowcode-code-generator"));
const { buildDataSourceDependencies } = lowcode_code_generator_2.default.utils.dataSource;
const pluginFactory = (cfg) => {
    const plugin = (pre) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
        const next = Object.assign({}, pre);
        const ir = next.ir;
        const { packages } = ir;
        packages.forEach(pkg => {
            if (pkg.package === 'ElementPlus') {
                pkg.package = 'element-plus';
            }
        });
        const packageJson = {
            name: (cfg === null || cfg === void 0 ? void 0 : cfg.packageName) || 'vue3-demo-app',
            version: (cfg === null || cfg === void 0 ? void 0 : cfg.packageVersion) || '0.0.0',
            description: '浪潮软件低代码平台',
            dependencies: Object.assign({ "vue": "^3.3.4", "vue-router": "^4.2.4" }, buildDataSourceDependencies(ir, cfg === null || cfg === void 0 ? void 0 : cfg.datasourceConfig)),
            devDependencies: {
                "@rushstack/eslint-patch": "^1.3.2",
                "@vitejs/plugin-vue": "^4.2.3",
                "@vue/eslint-config-prettier": "^8.0.0",
                "eslint": "^8.45.0",
                "eslint-plugin-vue": "^9.15.1",
                "prettier": "^3.0.0",
                "vite": "^4.4.6"
            },
            scripts: {
                "dev": "vite",
                "build": "vite build",
                "preview": "vite preview",
                "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
                "format": "prettier --write src/"
            },
            private: true,
        };
        ir.packages.forEach((packageInfo) => {
            packageJson.dependencies[packageInfo.package] = packageInfo.version;
        });
        next.chunks.push({
            type: lowcode_code_generator_1.ChunkType.JSON,
            fileType: lowcode_code_generator_1.FileType.JSON,
            name: lowcode_code_generator_1.COMMON_CHUNK_NAME.FileMainContent,
            content: packageJson,
            linkAfter: [],
        });
        return next;
    });
    return plugin;
};
exports.default = pluginFactory;
//# sourceMappingURL=packageJSON.js.map