@ton-actions/tondev-contest
Version:
TON Dev Environment
153 lines • 5.5 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.seSetCommand = exports.seUpdateCommand = exports.seResetCommand = exports.seRestartCommand = exports.seStopCommand = exports.seStartCommand = exports.seVersionCommand = exports.seInfoCommand = void 0;
const utils_1 = require("../../core/utils");
const tonosTondev = __importStar(require("@ton-actions/tonos-se-tondev"));
const utils_2 = require("../../core/utils");
exports.seInfoCommand = {
name: "info",
title: "Show SE Info",
args: [],
async run(terminal) {
const table = [[
"State",
"Version",
"GraphQL Port",
"ArangoDB Port",
]];
utils_2.progress(terminal, 'Initialization...');
const info = await tonosTondev.seInfoCommand();
utils_2.progressDone(terminal);
table.push([
info.state,
info.version,
info.port,
info.dbPort
]);
terminal.log(utils_1.formatTable(table, { headerSeparator: true }));
},
};
exports.seVersionCommand = {
name: "version",
title: "Show SE Versions",
async run(terminal, _args) {
utils_2.progress(terminal, 'Initialization...');
const current = await tonosTondev.seVersionCommand();
const availableVersions = await tonosTondev.getAvailableVersions();
utils_2.progressDone(terminal);
terminal.log(`Current version: ${current}`);
terminal.log(`Available Versions: ${(availableVersions).sort(utils_2.compareVersions).join(", ")}`);
},
};
exports.seStartCommand = {
name: "start",
title: "Start SE Instance",
args: [],
async run(terminal) {
utils_2.progress(terminal, 'Starting...');
await tonosTondev.seStartCommand();
utils_2.progressDone(terminal);
},
};
exports.seStopCommand = {
name: "stop",
title: "Stop SE Instance",
args: [],
async run(terminal) {
utils_2.progress(terminal, 'Stoping...');
await tonosTondev.seStopCommand();
utils_2.progressDone(terminal);
},
};
exports.seRestartCommand = {
name: "restart",
title: "Restart SE Instance",
args: [],
async run(terminal) {
utils_2.progress(terminal, 'Resarting...');
await tonosTondev.seStopCommand();
await tonosTondev.seStartCommand();
utils_2.progressDone(terminal);
},
};
exports.seResetCommand = {
name: "reset",
title: "Reset SE Instance",
args: [],
async run(terminal) {
utils_2.progress(terminal, 'Reseting...');
await tonosTondev.seResetCommand();
utils_2.progressDone(terminal);
},
};
exports.seUpdateCommand = {
name: "update",
title: "Update SE Instance Version",
args: [],
async run(terminal) {
utils_2.progress(terminal, 'Updating...');
await tonosTondev.seSetCommand('latest', "", "");
utils_2.progressDone(terminal);
},
};
exports.seSetCommand = {
name: "set",
title: "Update SE Instance Config",
args: [
{
name: "version",
title: "SE version (version number or `latest`)",
type: "string",
defaultValue: "",
},
{
name: "port",
title: "Port on localhost used to expose GraphQL API",
type: "string",
defaultValue: "",
},
{
name: "db-port",
title: "Port on localhost used to expose ArangoDB API",
type: "string",
defaultValue: "",
}
],
async run(terminal, args) {
var _a;
utils_2.progress(terminal, 'Updating config...');
// workaround for VSCode plugin, so it pass db-port property...
(_a = args.dbPort) !== null && _a !== void 0 ? _a : (args.dbPort = args['db-port']);
if (!args.version && !args.port && !args.dbPort) {
return;
}
if (args.version) {
const availableVersions = await tonosTondev.getAvailableVersions();
if (!availableVersions.includes(args.version)) {
throw new Error(`Invalid version: ${args.version} Available versions: ${(availableVersions).sort(utils_2.compareVersions).join(", ")}`);
}
}
await tonosTondev.seSetCommand(args.version, args.port, args.dbPort);
utils_2.progressDone(terminal);
},
};
//# sourceMappingURL=commands.js.map