UNPKG

@godspeedsystems/godspeed

Version:

Godspeed CLI

55 lines 3.19 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fsExtras = require("fs-extra"); const interactiveMode_1 = __importDefault(require("../../utils/interactiveMode")); const dockerUtility_1 = require("../../utils/dockerUtility"); const path_1 = __importDefault(require("path")); const utils_1 = require("../../utils"); const checkPrerequisite_1 = __importDefault(require("../../utils/checkPrerequisite")); const chalk_1 = __importDefault(require("chalk")); const signale_1 = require("../../utils/signale"); const ifValidGodspeedRoot = async () => { signale_1.log.wait("Checking if, on a valid project root."); if (fsExtras.existsSync(path_1.default.resolve(process.cwd(), ".godspeed"))) { signale_1.log.success(`${chalk_1.default.yellow(process.cwd())} is a valid project root.`); } else { signale_1.log.fatal(`${chalk_1.default.yellow(process.cwd())} ${chalk_1.default.red("is not a valid godspeed project root.\nIf you are trying to run this command from any sub-directory, Please run this from the root of the godspeed project.")}`); process.exit(1); } }; exports.default = async (options, clieVersion) => { try { // prerequisite // Step 1: Read the .godspeed file // Step 2: generate project from .godspeed options // Step 3: Stop already running containers // Step 4: Start new containers // check if where the command is executed, it should have valid .godspeed file await ifValidGodspeedRoot(); await (0, checkPrerequisite_1.default)(); // check if the command is running in projectRootFolder let godspeedOptions; godspeedOptions = await (0, interactiveMode_1.default)(await (0, utils_1.readDotGodspeed)(process.cwd()), true); let { projectName } = godspeedOptions; await (0, utils_1.generateProjectFromDotGodspeed)(projectName, process.cwd(), godspeedOptions, "hello-world", true); const composeOptions = await (0, dockerUtility_1.getComposeOptions)(); if (composeOptions.composeOptions) { composeOptions.composeOptions.push(`${projectName}_devcontainer`); } composeOptions.cwd = path_1.default.resolve(process.cwd(), ".devcontainer"); composeOptions.log = process.env.DEBUG ? Boolean(process.env.DEBUG) : false; // check if there are already running resources await (0, dockerUtility_1.prepareToStartContainers)(projectName, composeOptions); // await buildContainers(projectName, godspeedOptions, composeOptions, ""); signale_1.log.success(`\n\n${chalk_1.default.green("Successfully updated the project")} ${chalk_1.default.yellow(projectName)}.`); console.log(`${chalk_1.default.green("Open the project in Visual Studio Code,")} ${chalk_1.default.yellow("Happy building microservices with Godspeed!")}.`); } catch (error) { console.log("error", error); } }; //# sourceMappingURL=index.js.map