@alova/wormhole
Version:
More modern openAPI generating solution for alova.js
36 lines (35 loc) • 1.48 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_path_1 = __importDefault(require("node:path"));
const getAlovaVersion_1 = __importDefault(require("./functions/getAlovaVersion"));
const getAutoTemplateType_1 = __importDefault(require("./functions/getAutoTemplateType"));
const helper_1 = require("./helper");
/**
* Create a templated configuration file.
* @param options - Configuration file creation options
* @param options.projectPath - The root path of the project (optional)
* @param options.type - The template type to use (optional)
* @returns A promise that resolves when the config is created
*/
function createConfig({ projectPath = '', type } = {}) {
projectPath = node_path_1.default.isAbsolute(projectPath) ? projectPath : node_path_1.default.resolve(process.cwd(), projectPath);
type = type || (0, getAutoTemplateType_1.default)(projectPath);
helper_1.templateHelper.load({
type,
version: (0, getAlovaVersion_1.default)(projectPath),
});
return helper_1.templateHelper.outputFile({
fileName: 'alova.config',
data: {
type,
moduleType: helper_1.templateHelper.getModuleType(),
},
output: projectPath,
root: true,
hasVersion: false,
});
}
exports.default = createConfig;