@instadapp/interop-x 0.0.0-dev.3d62ebf → 0.0.0-dev.43cb9e6

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.3d62ebf",
3
+ "version": "0.0.0-dev.43cb9e6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
package/dist/src/index.js CHANGED
@@ -37,7 +37,7 @@ if (process.argv.at(-1) === 'help') {
37
37
  printUsage();
38
38
  process.exit(0);
39
39
  }
40
- const GIT_SHORT_HASH = '3d62ebf';
40
+ const GIT_SHORT_HASH = '43cb9e6';
41
41
  if (process.argv.at(-1) === 'version') {
42
42
  console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
43
43
  process.exit(0);
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const BaseTask_1 = require("./BaseTask");
7
7
  const logger_1 = __importDefault(require("@/logger"));
8
+ const utils_1 = require("@/utils");
8
9
  const await_spawn_1 = __importDefault(require("await-spawn"));
9
10
  const config_1 = __importDefault(require("@/config"));
10
11
  const waait_1 = __importDefault(require("waait"));
11
- const package_json_1 = __importDefault(require("../../package.json"));
12
- const currentVersion = package_json_1.default.version;
13
12
  class AutoUpdateTask extends BaseTask_1.BaseTask {
14
13
  constructor() {
15
14
  super({
@@ -20,36 +19,20 @@ class AutoUpdateTask extends BaseTask_1.BaseTask {
20
19
  prePollHandler() {
21
20
  return config_1.default.autoUpdate && !config_1.default.isLeadNode();
22
21
  }
23
- async getInstalledVersion() {
24
- try {
25
- const stdout = await (0, await_spawn_1.default)('npm', ['-g', 'ls', '--depth=0', '--json']);
26
- return JSON.parse(stdout.toString()).dependencies[package_json_1.default.name].version;
27
- }
28
- catch (error) {
29
- this.logger.error(error);
30
- return currentVersion;
31
- }
32
- }
33
- async getLatestVersion() {
34
- try {
35
- const stdout = await (0, await_spawn_1.default)('npm', ['view', package_json_1.default.name, 'version']);
36
- return stdout.toString();
37
- }
38
- catch (error) {
39
- this.logger.error(error);
40
- return currentVersion;
41
- }
22
+ getCurrentVersion() {
23
+ return require('../../package.json').version;
42
24
  }
43
25
  async pollHandler() {
44
- const version = await this.getLatestVersion();
26
+ const { data } = await utils_1.http.get('https://registry.npmjs.org/@instadapp/interop-x');
27
+ const version = data['dist-tags'].latest;
28
+ const currentVersion = this.getCurrentVersion();
45
29
  if (version === currentVersion) {
46
30
  return;
47
31
  }
48
32
  this.logger.warn(`New version ${version} available.`);
49
- this.logger.info('Updating...');
50
33
  await (0, await_spawn_1.default)('npm', ['-g', 'install', '@instadapp/interop-x', '-f']);
51
34
  await (0, waait_1.default)(5000);
52
- if (version !== await this.getInstalledVersion()) {
35
+ if (currentVersion === this.getCurrentVersion()) {
53
36
  this.logger.warn(`failed to install ${version}, retrying in 5 minutes`);
54
37
  return;
55
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.3d62ebf",
3
+ "version": "0.0.0-dev.43cb9e6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -4,9 +4,6 @@ import { http } from "@/utils";
4
4
  import spawn from 'await-spawn';
5
5
  import config from "@/config";
6
6
  import wait from "waait";
7
- import packageJson from "../../package.json";
8
-
9
- const currentVersion = packageJson.version;
10
7
 
11
8
  class AutoUpdateTask extends BaseTask {
12
9
  pollIntervalMs: number = 60 * 5 * 1000
@@ -21,30 +18,15 @@ class AutoUpdateTask extends BaseTask {
21
18
  return config.autoUpdate && !config.isLeadNode();
22
19
  }
23
20
 
24
- async getInstalledVersion() {
25
- try {
26
- const stdout = await spawn('npm', ['-g', 'ls', '--depth=0', '--json'])
27
- return JSON.parse(stdout.toString()).dependencies[packageJson.name].version
28
- } catch (error) {
29
- this.logger.error(error)
30
-
31
- return currentVersion
32
- }
21
+ getCurrentVersion() {
22
+ return require('../../package.json').version
33
23
  }
24
+ async pollHandler() {
34
25
 
35
- async getLatestVersion() {
36
- try {
37
- const stdout = await spawn('npm', ['view', packageJson.name, 'version'])
38
- return stdout.toString()
39
- } catch (error) {
40
- this.logger.error(error)
41
-
42
- return currentVersion
43
- }
44
- }
26
+ const { data } = await http.get('https://registry.npmjs.org/@instadapp/interop-x')
45
27
 
46
- async pollHandler() {
47
- const version = await this.getLatestVersion()
28
+ const version = data['dist-tags'].latest
29
+ const currentVersion = this.getCurrentVersion()
48
30
 
49
31
  if (version === currentVersion) {
50
32
  return;
@@ -53,13 +35,12 @@ class AutoUpdateTask extends BaseTask {
53
35
  this.logger.warn(`New version ${version} available.`)
54
36
 
55
37
 
56
- this.logger.info('Updating...')
57
-
58
38
  await spawn('npm', ['-g', 'install', '@instadapp/interop-x', '-f']);
59
39
 
40
+
60
41
  await wait(5000)
61
42
 
62
- if (version !== await this.getInstalledVersion()) {
43
+ if (currentVersion === this.getCurrentVersion()) {
63
44
  this.logger.warn(`failed to install ${version}, retrying in 5 minutes`)
64
45
  return;
65
46
  }