@lidhium/cli
Version:
micro-frontend cli packed with webpack
49 lines (48 loc) • 2.55 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = bindActions;
const chalk_1 = __importDefault(require("chalk"));
const config_1 = require("../config");
const fs_1 = __importDefault(require("fs"));
const common_1 = require("../utils/common");
const common_2 = require("../utils/common");
const inquirer_1 = __importDefault(require("inquirer"));
function bindActions() {
return () => __awaiter(this, void 0, void 0, function* () {
const configJsonPath = "./../../lidhium.config.json";
const configFile = (0, common_2.getConfigFile)(configJsonPath, true);
const appName = (0, common_1.getAppName)();
if (!configFile) {
console.log(chalk_1.default.red("Please run this command from the app directory"));
console.log(chalk_1.default.green(`For more details visit ${chalk_1.default.magenta(`${config_1.config.docs.webUrl}/docs/getting-started#bind-micro-app`)}`));
return;
}
const apps = configFile.apps;
const { selectedDestinationApp } = yield inquirer_1.default.prompt([
{
type: "list", // Works like a radio button
name: "selectedDestinationApp",
message: "Select Destination App:",
choices: Object.keys(apps).filter((app) => app !== appName),
},
]);
console.log(selectedDestinationApp);
const currentRemotes = configFile.apps[appName].remotes || [];
configFile.apps[appName].remotes = [
...new Set(currentRemotes).add(selectedDestinationApp),
];
fs_1.default.writeFileSync(configJsonPath, JSON.stringify(configFile, null, 2));
});
}