@extrahorizon/exh-cli 1.5.1-dev-36-6147e31 → 1.5.1-dev-37-eb0dd86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  ### [Unreleased]
4
4
  * Removed the update notifier. The version of the package we used had security vulnerabilities and we're unable to migrate to the latest version right now. We'll look into this again in the future.
5
+ * Added the `exh whoami` command, showing the currently logged in user
5
6
 
6
7
  ### v1.5.1
7
8
  * Now also publishing to the NPM registry, no longer needing to authenticate with GitHub Packages to install the CLI
@@ -0,0 +1,8 @@
1
+ /// <reference types="yargs" />
2
+ import type { OAuth1Client } from '@extrahorizon/javascript-sdk';
3
+ export declare const command = "whoami";
4
+ export declare const desc = "Shows the currently logged in user";
5
+ export declare const builder: (yargs: any) => import("yargs").Argv<{}>;
6
+ export declare const handler: ({ sdk }: {
7
+ sdk: OAuth1Client;
8
+ }) => Promise<void>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.desc = exports.command = void 0;
4
+ const util_1 = require("../helpers/util");
5
+ const authRepository = require("../repositories/auth");
6
+ exports.command = 'whoami';
7
+ exports.desc = 'Shows the currently logged in user';
8
+ const builder = (yargs) => (0, util_1.epilogue)(yargs);
9
+ exports.builder = builder;
10
+ const handler = async function list({ sdk }) {
11
+ const host = authRepository.getHost(sdk);
12
+ if (!host) {
13
+ console.log('No ExH cluster host was found in the configuration.');
14
+ return;
15
+ }
16
+ console.log('You are targeting:', host);
17
+ const currentUser = await authRepository.fetchMe(sdk);
18
+ console.log('You are logged in as:', currentUser.email);
19
+ };
20
+ exports.handler = handler;
@@ -0,0 +1,3 @@
1
+ import { OAuth1Client } from '@extrahorizon/javascript-sdk';
2
+ export declare function getHost(sdk: OAuth1Client): string;
3
+ export declare function fetchMe(sdk: OAuth1Client): Promise<import("@extrahorizon/javascript-sdk").UserData>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchMe = exports.getHost = void 0;
4
+ function getHost(sdk) {
5
+ return sdk?.raw?.defaults?.baseURL;
6
+ }
7
+ exports.getHost = getHost;
8
+ async function fetchMe(sdk) {
9
+ return await sdk?.users.me();
10
+ }
11
+ exports.fetchMe = fetchMe;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.5.1-dev-36-6147e31",
3
+ "version": "1.5.1-dev-37-eb0dd86",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",