UNPKG

kui-shell

Version:

This is the monorepo for Kui, the hybrid command-line/GUI electron-based Kubernetes tool

85 lines 4.45 kB
"use strict"; 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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const debug_1 = require("debug"); const debug = debug_1.default('plugins/wskflow/subtext'); function default_1(tab, actions, activations, graphData, options) { return __awaiter(this, void 0, void 0, function* () { try { if (actions) { debug('actions', actions); const array = []; const names = Object.keys(actions); names.forEach(name => { array.push(tab.REPL.qexec(`wsk action get "${name}"`)); }); const result = yield Promise.all(array.map(p => p.catch(e => e))); const notDeployed = []; const graphChildrenStatus = (childrens, id, deployed) => { return childrens.forEach((children) => { if (children.id === id) children.deployed = deployed; else if (children.children) return graphChildrenStatus(children.children, id, deployed); }); }; result.forEach((r, index) => { if (r.type === 'actions' && r.name) { debug(`action ${r.name} is deployed`); actions[names[index]].forEach(id => { graphChildrenStatus(graphData.children, id, true); }); } else { debug(`action ${names[index]} is not deployed`, r, names); if (actions[names[index]]) { notDeployed.push(names[index]); actions[names[index]].forEach(id => { graphChildrenStatus(graphData.children, id, false); }); } } }); if (notDeployed.length > 0 && !activations) { if (!options || !options.noHeader) { const css = { message: 'wskflow-undeployed-action-warning', text: 'wskflow-undeployed-action-warning-text', examples: 'wskflow-undeployed-action-warning-examples', examplesExtra: ['deemphasize', 'deemphasize-partial', 'left-pad'] }; const message = document.createElement('div'); const warning = document.createElement('strong'); const text = document.createElement('span'); const examples = document.createElement('span'); message.className = css.message; text.className = css.text; warning.className = 'red-text'; examples.className = css.examples; css.examplesExtra.forEach(_ => examples.classList.add(_)); message.appendChild(warning); message.appendChild(text); message.appendChild(examples); warning.innerText = 'Warning: '; const actionStr = notDeployed.length === 1 ? 'component' : 'components'; text.innerText = `depends on ${notDeployed.length} undeployed ${actionStr}`; return message; } } } } catch (err) { debug('action get fetching error: ', err); } }); } exports.default = default_1; //# sourceMappingURL=subtext.js.map