ag-awsauth 0.0.87 → 0.0.89

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.
@@ -16,9 +16,11 @@ const sleep_1 = require("ag-common/dist/common/helpers/sleep");
16
16
  const config_1 = require("../config");
17
17
  const browser_1 = require("./browser");
18
18
  const input_1 = require("./input");
19
+ const version_1 = require("./version");
19
20
  function requestMFA(p) {
20
21
  return __awaiter(this, void 0, void 0, function* () {
21
22
  const sso_oidc = new client_sso_oidc_1.SSOOIDCClient({ region: p.identityCenterRegion });
23
+ yield (0, version_1.validateVersion)();
22
24
  (0, log_1.warn)('starting MFA flow');
23
25
  const creds = (0, input_1.enterCreds)();
24
26
  const rcc = yield sso_oidc.send(new client_sso_oidc_1.RegisterClientCommand({
@@ -0,0 +1,2 @@
1
+ export declare const getVersion: () => any;
2
+ export declare const validateVersion: () => Promise<void>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.validateVersion = exports.getVersion = void 0;
16
+ const log_1 = require("ag-common/dist/common/helpers/log");
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const node_fetch_1 = __importDefault(require("node-fetch"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const getVersion = () => {
21
+ let pjpath = path_1.default.resolve(__dirname, './package.json');
22
+ if (!fs_1.default.existsSync(pjpath)) {
23
+ pjpath = path_1.default.resolve(__dirname, '../package.json');
24
+ }
25
+ if (!fs_1.default.existsSync(pjpath)) {
26
+ pjpath = path_1.default.resolve(__dirname, '../../package.json');
27
+ }
28
+ if (!fs_1.default.existsSync(pjpath)) {
29
+ return undefined;
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
32
+ const p = require(pjpath);
33
+ return p === null || p === void 0 ? void 0 : p.version;
34
+ };
35
+ exports.getVersion = getVersion;
36
+ const getUpstreamVersion = () => __awaiter(void 0, void 0, void 0, function* () {
37
+ var _a;
38
+ try {
39
+ const r = yield (0, node_fetch_1.default)('https://api.github.com/repos/andreigec/ag-awsauth/tags', { headers: { Accept: 'application/json' } });
40
+ const tags = (yield r.json());
41
+ return (_a = tags === null || tags === void 0 ? void 0 : tags[0]) === null || _a === void 0 ? void 0 : _a.name;
42
+ }
43
+ catch (e) {
44
+ (0, log_1.warn)(`error getting upstream version:` + e.message);
45
+ return undefined;
46
+ }
47
+ });
48
+ const validateVersion = () => __awaiter(void 0, void 0, void 0, function* () {
49
+ const v = (0, exports.getVersion)();
50
+ const upstream = yield getUpstreamVersion();
51
+ if (!v || !upstream) {
52
+ return;
53
+ }
54
+ if (v !== upstream) {
55
+ (0, log_1.warn)(`
56
+ ---
57
+ There is a new version of ag-awsauth available.
58
+ Your version: ${v}
59
+ Newest version: ${upstream}
60
+ Upgrade using npm i -g ag-awsauth
61
+ ---\n`);
62
+ }
63
+ });
64
+ exports.validateVersion = validateVersion;
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ const input_1 = require("./helpers/input");
24
24
  const oidc_1 = require("./helpers/oidc");
25
25
  const sso_1 = require("./helpers/sso");
26
26
  const sts_1 = require("./helpers/sts");
27
+ const version_1 = require("./helpers/version");
27
28
  if (__dirname.endsWith('dist')) {
28
29
  (0, config_1.setBasePath)(path_1.default.resolve(__dirname, '../'));
29
30
  }
@@ -46,16 +47,7 @@ function main(args) {
46
47
  }
47
48
  });
48
49
  if (args.version) {
49
- let pjpath = '../package.json';
50
- if (!fs_1.default.existsSync(pjpath)) {
51
- pjpath = '../../package.json';
52
- }
53
- if (!fs_1.default.existsSync(pjpath)) {
54
- throw new Error('package json cant be found');
55
- }
56
- // eslint-disable-next-line @typescript-eslint/no-var-requires
57
- const p = require(pjpath);
58
- (0, log_1.warn)('version=' + p.version);
50
+ (0, log_1.warn)('version=' + (0, version_1.getVersion)());
59
51
  return;
60
52
  }
61
53
  if (args.config) {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "andrei gec (andreigec@hotmail.com)",
6
6
  "license": "ISC",
7
7
  "private": false,
8
- "version": "0.0.87",
8
+ "version": "0.0.89",
9
9
  "preferGlobal": true,
10
10
  "scripts": {
11
11
  "format": "eslint --ext .ts,.tsx ./src --fix",
@@ -27,7 +27,7 @@
27
27
  "@aws-sdk/client-sso-oidc": "3.370.0",
28
28
  "@aws-sdk/client-sts": "3.370.0",
29
29
  "@aws-sdk/shared-ini-file-loader": "3.370.0",
30
- "ag-common": "0.0.450",
30
+ "ag-common": "0.0.452",
31
31
  "cli-select": "1.1.2",
32
32
  "dotenv": "16.3.1",
33
33
  "envfile": "6.18.0",