UNPKG

@ordino.ai/cli

Version:
65 lines (63 loc) 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.copyWorkflowFile = copyWorkflowFile; var _path = _interopRequireDefault(require("path")); var _fs = _interopRequireDefault(require("fs")); var _models = require("../../models/models"); var _templateProcessor = require("./templateProcessor"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } function getRepositoryTypeFolder(repositoryType) { switch (repositoryType) { case _models.CItype.GITHUB: return "github"; case _models.CItype.DEVOPS: return "azure"; case _models.CItype.GITLAB: return "gitlab"; default: return null; } } function copyWorkflowFile(appPath, platformtype, repositoryType, baseURL) { var repositoryFolderName = getRepositoryTypeFolder(repositoryType); if (!repositoryFolderName) { console.log("Repository type not supported for git action generation."); return; } console.log("repositoryType : " + repositoryType); var sourceFile = _path["default"].join(__dirname, "../../../templates/repository/".concat(repositoryFolderName, "/").concat(platformtype, "/config.yaml")); if (!_fs["default"].existsSync(sourceFile)) { console.log("Workflow file not found for ".concat(platformtype, " and ").concat(repositoryFolderName)); return; } var destDir; var destFile; switch (repositoryType) { case _models.CItype.GITHUB: destDir = _path["default"].join(appPath, ".github", "workflows"); _fs["default"].mkdirSync(destDir, { recursive: true }); destFile = _path["default"].join(destDir, "config.yaml"); break; case _models.CItype.DEVOPS: destDir = _path["default"].join(appPath, "pipeline"); _fs["default"].mkdirSync(destDir, { recursive: true }); destFile = _path["default"].join(destDir, "pipeline.yaml"); break; case _models.CItype.GITLAB: destFile = _path["default"].join(appPath, ".gitlab-ci.yml"); break; default: console.log("Unsupported repository type for workflow file placement: ".concat(repositoryType)); return; } _fs["default"].copyFileSync(sourceFile, destFile); // Process the template file to replace placeholders (0, _templateProcessor.replaceTemplatePlaceholders)(destFile, baseURL); console.log("Workflow file copied for ".concat(platformtype, " and ").concat(repositoryFolderName)); }