UNPKG

@areslabs/alita-core

Version:

alita-core

83 lines (72 loc) 2.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = geneWXConfigFile; var path = _interopRequireWildcard(require("path")); var fse = _interopRequireWildcard(require("fs-extra")); var _configure = _interopRequireDefault(require("../configure")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /** * Copyright (c) Areslabs. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ function geneWXConfigFile(targetpath) { const pcjPath = path.resolve(targetpath, 'project.config.json'); if (fse.existsSync(pcjPath)) { // 不要覆盖已有project.config.json, 因为开发者可能手动修改过这个文件 return; } // 生成 project.config.json 文件 const { name, appid } = _configure.default.configObj; const pcjStr = `{ "description": "项目配置文件。", "packOptions": { "ignore": [] }, "setting": { "urlCheck": false, "es6": false, "postcss": false, "minified": true, "newFeature": true, "coverView": true, "autoAudits": false, "checkInvalidKey": true, "checkSiteMap": true, "uploadWithSourceMap": true }, "compileType": "miniprogram", "libVersion": "", "appid": "${appid}", "projectname": "${name}", "isGameTourist": false, "condition": { "search": { "current": -1, "list": [] }, "conversation": { "current": -1, "list": [] }, "game": { "currentL": -1, "list": [] }, "miniprogram": { "current": -1, "list": [] } } } `; fse.outputFileSync(pcjPath, pcjStr); }