Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metlo

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metlo - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

1

dist/index.d.ts

@@ -0,1 +1,2 @@

#!/usr/bin/env node
export {};

@@ -0,1 +1,2 @@

#!/usr/bin/env node
"use strict";

@@ -8,4 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });

commander_1.program.name("metlo").description("Metlo's command line tool.").version("0.0.0");
commander_1.program.command("init").description("Initialize the Metlo CLI.").action(init_1.default);
commander_1.program
.command("init")
.description("Initialize the Metlo CLI.")
.option("-b, --backend_url <string>", "The backend address for Metlo")
.action(init_1.default);
commander_1.program
.command("test")

@@ -12,0 +17,0 @@ .description("Run Metlo API tests against a specified host.")

4

dist/init.d.ts

@@ -1,2 +0,4 @@

declare const init: () => void;
declare const init: ({ backend_url }: {
backend_url: any;
}) => Promise<void>;
export default init;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var fs_1 = tslib_1.__importDefault(require("fs"));
var fs_1 = tslib_1.__importStar(require("fs"));
var os_1 = tslib_1.__importDefault(require("os"));
var path_1 = tslib_1.__importDefault(require("path"));
var utils_1 = require("./utils");
var init = function () {
var homeDir = os_1.default.homedir();
var creditialFileExists = fs_1.default.existsSync(path_1.default.join(homeDir, utils_1.CREDENTIAL_FILE));
if (creditialFileExists) {
console.log("Credentials already exist at ~/".concat(utils_1.CREDENTIAL_FILE, ". Are you sure you want to replace them? [Y/n]"));
}
var enquirer_1 = require("enquirer");
var valid_url_1 = require("valid-url");
var get_host_from_cli = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var resp;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, enquirer_1.prompt)([
{
type: "input",
name: "host",
message: "Host address of metlo backend :",
},
])];
case 1:
resp = _a.sent();
return [2 /*return*/, resp["host"]];
}
});
}); };
var should_replace_credentials = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, enquirer_1.prompt)({
type: "confirm",
name: "replace",
message: "Credentials already exist at ~/".concat(utils_1.CREDENTIAL_FILE, ". Are you sure you want to replace them?"),
})];
case 1:
// Function returns string, is marked as void for some reason.
return [2 /*return*/, (_a.sent())["replace"]];
}
});
}); };
var setup_new_cred = function (host) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var homeDir, backend_host;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
homeDir = os_1.default.homedir();
if (!(host && !(host instanceof Object))) return [3 /*break*/, 1];
backend_host = host;
return [3 /*break*/, 3];
case 1: return [4 /*yield*/, get_host_from_cli()];
case 2:
backend_host = _a.sent();
_a.label = 3;
case 3:
if ((0, valid_url_1.isUri)(backend_host)) {
(0, fs_1.writeFileSync)(path_1.default.join(homeDir, utils_1.CREDENTIAL_FILE), "METLO_HOST=".concat(backend_host));
}
else {
console.log("Invalid url passed for backend host : ".concat(backend_host));
}
return [2 /*return*/];
}
});
}); };
var init = function (_a) {
var host = _a.backend_url;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var homeDir, creditialFileExists, shouldReplace;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
homeDir = os_1.default.homedir();
creditialFileExists = fs_1.default.existsSync(path_1.default.join(homeDir, utils_1.CREDENTIAL_FILE));
if (!creditialFileExists) return [3 /*break*/, 2];
return [4 /*yield*/, should_replace_credentials()];
case 1:
shouldReplace = _b.sent();
if (shouldReplace) {
setup_new_cred(host);
}
else {
console.log("Leaving credentials file untouched");
}
return [3 /*break*/, 3];
case 2:
setup_new_cred(host);
_b.label = 3;
case 3: return [2 /*return*/];
}
});
});
};
exports.default = init;
//# sourceMappingURL=init.js.map
{
"name": "metlo",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc