From 28427f8940f238185ba1717680da2eb262a607bf Mon Sep 17 00:00:00 2001 From: Jelle Siderius Date: Thu, 15 Jul 2021 10:45:46 +0200 Subject: [PATCH] - wip --- dist/controllers/selfUpdateController.js | 15 +++++-------- dist/controllers/selfUpdateController.js.map | 2 +- dist/mage-db-sync.js | 13 ++++++++--- dist/mage-db-sync.js.map | 2 +- dist/utils/versionCheck.js | 23 ++++++++++++++++++++ dist/utils/versionCheck.js.map | 1 + package-lock.json | 2 +- package.json | 2 +- src/controllers/selfUpdateController.ts | 18 +++++++-------- src/mage-db-sync.ts | 15 +++++++++---- src/utils/versionCheck.ts | 20 +++++++++++++++++ 11 files changed, 82 insertions(+), 31 deletions(-) create mode 100644 dist/utils/versionCheck.js create mode 100644 dist/utils/versionCheck.js.map create mode 100644 src/utils/versionCheck.ts diff --git a/dist/controllers/selfUpdateController.js b/dist/controllers/selfUpdateController.js index e9b3712..8b1e402 100644 --- a/dist/controllers/selfUpdateController.js +++ b/dist/controllers/selfUpdateController.js @@ -6,26 +6,21 @@ const download_git_repo_1 = tslib_1.__importDefault(require("download-git-repo") // @ts-ignore const get_installed_path_1 = require("get-installed-path"); const console_1 = require("../utils/console"); -// @ts-ignore -const fetch = tslib_1.__importStar(require("node-fetch")); -// @ts-ignore -const package_json_1 = tslib_1.__importDefault(require("../../package.json")); +const versionCheck_1 = tslib_1.__importDefault(require("../utils/versionCheck")); class SelfUpdateController { constructor() { + this.versionCheck = new versionCheck_1.default(); this.executeStart = (serviceName) => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield this.versionCheck.getToolVersions(); let self = this; let config = { 'npmPath': '', - 'latestVersion': '', - 'currentVersion': package_json_1.default.version + 'currentVersion': this.versionCheck.config.currentVersion, + 'latestVersion': this.versionCheck.config.latestVersion }; yield get_installed_path_1.getInstalledPath('mage-db-sync').then((path) => { config.npmPath = path; }); - // @ts-ignore - yield fetch('https://raw.githubusercontent.com/jellesiderius/mage-db-sync/master/package.json') - .then((res) => res.json()) - .then((json) => config.latestVersion = json.version); if (config.currentVersion < config.latestVersion) { yield download_git_repo_1.default('jellesiderius/mage-db-sync#master', config.npmPath, function (err) { return tslib_1.__awaiter(this, void 0, void 0, function* () { diff --git a/dist/controllers/selfUpdateController.js.map b/dist/controllers/selfUpdateController.js.map index 67787d4..4beae7d 100644 --- a/dist/controllers/selfUpdateController.js.map +++ b/dist/controllers/selfUpdateController.js.map @@ -1 +1 @@ -{"version":3,"file":"selfUpdateController.js","sourceRoot":"","sources":["../../src/controllers/selfUpdateController.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,kFAAwC;AACxC,aAAa;AACb,2DAAmD;AACnD,8CAAyC;AAEzC,aAAa;AACb,0DAAmC;AACnC,aAAa;AACb,8EAA6C;AAE7C,MAAM,oBAAoB;IAA1B;QACI,iBAAY,GAAG,CAAO,WAA+B,EAAoB,EAAE;YACvE,IAAI,IAAI,GAAG,IAAI,CAAC;YAChB,IAAI,MAAM,GAAG;gBACT,SAAS,EAAE,EAAE;gBACb,eAAe,EAAE,EAAE;gBACnB,gBAAgB,EAAE,sBAAW,CAAC,OAAO;aACxC,CAAA;YAED,MAAM,qCAAgB,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE;gBACzD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,aAAa;YACb,MAAM,KAAK,CAAC,kFAAkF,CAAC;iBAC1F,IAAI,CAAC,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;iBAC/C,IAAI,CAAC,CAAC,IAA0B,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;YAE/E,IAAI,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,EAAE;gBAC9C,MAAM,2BAAQ,CAAC,mCAAmC,EAAE,MAAM,CAAC,OAAO,EAAE,UAAgB,GAAQ;;wBACxF,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;wBACjE,iBAAO,CAAC,6BAA6B,MAAM,CAAC,cAAc,OAAO,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;oBAC7F,CAAC;iBAAA,CAAC,CAAC;aACN;iBAAM;gBACH,iBAAO,CAAC,oCAAoC,CAAC,CAAC;aACjD;YAED,OAAO,IAAI,CAAC;QAChB,CAAC,CAAA,CAAA;QAED,uCAAuC;QACvC,qBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE;YAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC;YAC3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACnC,IAAI,CAAC,GAAG,EAAE,CAAC,KAA2B,EAAE,MAAc,EAAE,MAAc,EAAE,EAAE;oBACtE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;QACP,CAAC,CAAA;IACL,CAAC;CAAA;AAED,kBAAe,oBAAoB,CAAA"} \ No newline at end of file +{"version":3,"file":"selfUpdateController.js","sourceRoot":"","sources":["../../src/controllers/selfUpdateController.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,kFAAwC;AACxC,aAAa;AACb,2DAAmD;AACnD,8CAAyC;AAIzC,iFAAiD;AAEjD,MAAM,oBAAoB;IAA1B;QACY,iBAAY,GAAG,IAAI,sBAAY,EAAE,CAAC;QAE1C,iBAAY,GAAG,CAAO,WAA+B,EAAoB,EAAE;YACvE,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAC;YAE1C,IAAI,IAAI,GAAG,IAAI,CAAC;YAChB,IAAI,MAAM,GAAG;gBACT,SAAS,EAAE,EAAE;gBACb,gBAAgB,EAAE,IAAI,CAA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101..390085d 100644 --- a/dist/mage-db-sync.js +++ b/dist/mage-db-sync.js @@ -7,7 +7,8 @@ const fs_1 = tslib_1.__importDefault(require("fs")); // @ts-ignore const get_installed_path_1 = require("get-installed-path"); const console_1 = require("./utils/console"); -get_installed_path_1.getInstalledPath('mage-db-sync').then((path) => { +const versionCheck_1 = tslib_1.__importDefault(require("./utils/versionCheck")); +get_installed_path_1.getInstalledPath('mage-db-sync').then((path) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { // Lets make sure all required files are in place before running the tool let npmPath = path; let missingFiles = false; @@ -32,10 +33,16 @@ get_installed_path_1.getInstalledPath('mage-db-sync').then((path) => { index_1.default(commander_1.default); // eslint-disable-next-line @typescript-eslint/no-var-requires const packageJson = require('../package.json'); + let versionCheck = new versionCheck_1.default(); + yield versionCheck.getToolVersions(); + let description = `Magento Database Synchronizer, based on Magerun - ${packageJson.version}`; + if (versionCheck.config.currentVersion < versionCheck.config.latestVersion) { + description = `${description}\nRun 'mage-db-sync self-update' to download the newest version: ${versionCheck.config.latestVersion}`; + } commander_1.default .version(packageJson.version) .usage(' [options]') - .description(`Magento Database Synchronizer, based on Magerun - ${packageJson.version}`); + .description(description); commander_1.default.on('command:*', () => { commander_1.default.help(); }); @@ -44,5 +51,5 @@ get_installed_path_1.getInstalledPath('mage-db-sync').then((path) => { commander_1.default.outputHelp(); process.exit(); } -}); +})); //# sourceMappingURL=mage-db-sync.js.map \ No newline at end of file diff --git a/dist/mage-db-sync.js.map b/dist/mage-db-sync.js.map index 6582335..57d1d4b 100644 --- a/dist/mage-db-sync.js.map +++ b/dist/mage-db-sync.js.map @@ -1 +1 @@ -{"version":3,"file":"mage-db-sync.js","sourceRoot":"","sources":["../src/mage-db-sync.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,qEAA4C;AAC5C,oDAAoB;AACpB,aAAa;AACb,2DAAmD;AACnD,6CAA+C;AAE/C,qCAAgB,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC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WAAW,GAAG,GAAG,WAAW,oEAAoE,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;KACvI;IAED,mBAAO;SACF,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;SAC5B,KAAK,CAAC,qBAAqB,CAAC;SAC5B,WAAW,CAAC,WAAW,CAAC,CAAA;IAE7B,mBAAO,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,mBAAO,CAAC,IAAI,EAAE,CAAA;IAClB,CAAC,CAAC,CAAA;IAEF,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;QAC/B,mBAAO,CAAC,UAAU,EAAE,CAAA;QACpB,OAAO,CAAC,IAAI,EAAE,CAAA;KACjB;AACL,CAAC,CAAA,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/utils/versionCheck.js b/dist/utils/versionCheck.js new file mode 100644 index 0000000..5745bca --- /dev/null +++ b/dist/utils/versionCheck.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +// @ts-ignore +const package_json_1 = tslib_1.__importDefault(require("../../package.json")); +// @ts-ignore +const fetch = tslib_1.__importStar(require("node-fetch")); +class VersionCheck { + constructor() { + this.config = { + 'latestVersion': '', + 'currentVersion': package_json_1.default.version + }; + // versions + this.getToolVersions = () => tslib_1.__awaiter(this, void 0, void 0, function* () { + yield fetch('https://raw.githubusercontent.com/jellesiderius/mage-db-sync/master/package.json') + .then((res) => res.json()) + .then((json) => this.config.latestVersion = json.version); + }); + } +} +exports.default = VersionCheck; +//# sourceMappingURL=versionCheck.js.map \ No newline at end of file diff --git a/dist/utils/versionCheck.js.map b/dist/utils/versionCheck.js.map new file mode 100644 index 0000000..410d35d --- /dev/null +++ b/dist/utils/versionCheck.js.map @@ -0,0 +1 @@ +{"version":3,"file":"versionCheck.js","sourceRoot":"","sources":["../../src/utils/versionCheck.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,8EAA6C;AAC7C,aAAa;AACb,0DAAmC;AAEnC,MAAM,YAAY;IAAlB;QACQ,WAAM,GAAG;YACf,eAAe,EAAE,EAAE;YACnB,gBAAgB,EAAE,sBAAW,CAAC,OAAO;SACrC,CAAA;QAED,WAAW;QACX,oBAAe,GAAG,GAAS,EAAE;YAC5B,MAAM,KAAK,CAAC,kFAAkF,CAAC;iBAC7F,IAAI,CAAC,CAAC,GAAyB,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;iBAC/C,IAAI,CAAC,CAAC,IAA0B,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QAClF,CAAC,CAAA,CAAA;IACF,CAAC;CAAA;AAED,kBAAe,YAAY,CAAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8013dab..85f2df7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mage-db-sync", - "version": "0.1.6", + "version": "0.1.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4e1a2a4..79bf442 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mage-db-sync", - "version": "0.1.7", + "version": "0.1.6", "description": "Database synchronizer for Magento, based on Magerun", "author": { "name": "Jelle Siderius" diff --git a/src/controllers/selfUpdateController.ts b/src/controllers/selfUpdateController.ts index bd82e89..880d2f5 100644 --- a/src/controllers/selfUpdateController.ts +++ b/src/controllers/selfUpdateController.ts @@ -5,28 +5,26 @@ import {getInstalledPath} from 'get-installed-path' import {success} from "../utils/console"; import {ExecException} from "child_process"; // @ts-ignore -import * as fetch from 'node-fetch' -// @ts-ignore import packageFile from '../../package.json'; +import VersionCheck from "../utils/versionCheck"; class SelfUpdateController { + private versionCheck = new VersionCheck(); + executeStart = async (serviceName: string | undefined): Promise => { + await this.versionCheck.getToolVersions(); + let self = this; let config = { 'npmPath': '', - 'latestVersion': '', - 'currentVersion': packageFile.version - } + 'currentVersion': this.versionCheck.config.currentVersion, + 'latestVersion': this.versionCheck.config.latestVersion + }; await getInstalledPath('mage-db-sync').then((path: string) => { config.npmPath = path; }); - // @ts-ignore - await fetch('https://raw.githubusercontent.com/jellesiderius/mage-db-sync/master/package.json') - .then((res: { json: () => any; }) => res.json()) - .then((json: { version: string; }) => config.latestVersion = json.version); - if (config.currentVersion < config.latestVersion) { await download('jellesiderius/mage-db-sync#master', config.npmPath, async function (err: any) { await self.execShellCommand(`cd ${config.npmPath}; npm install`); diff --git a/src/mage-db-sync.ts b/src/mage-db-sync.ts index d7da2e8..ce27f1a 100644 --- a/src/mage-db-sync.ts +++ b/src/mage-db-sync.ts @@ -3,9 +3,10 @@ import commandLoader from './commands/index' import fs from 'fs'; // @ts-ignore import {getInstalledPath} from 'get-installed-path' -import {success, error} from "./utils/console"; +import {error} from "./utils/console"; +import VersionCheck from "./utils/versionCheck"; -getInstalledPath('mage-db-sync').then((path: any) => { +getInstalledPath('mage-db-sync').then(async (path: any) => { // Lets make sure all required files are in place before running the tool let npmPath = path; let missingFiles = false; @@ -30,15 +31,21 @@ getInstalledPath('mage-db-sync').then((path: any) => { return; } - commandLoader(program) + commandLoader(program); // eslint-disable-next-line @typescript-eslint/no-var-requires const packageJson = require('../package.json') + let versionCheck = new VersionCheck(); + await versionCheck.getToolVersions(); + let description = `Magento Database Synchronizer, based on Magerun - ${packageJson.version}`; + if (versionCheck.config.currentVersion < versionCheck.config.latestVersion) { + description = `${description}\nRun 'mage-db-sync self-update' to download the newest version: ${versionCheck.config.latestVersion}`; + } program .version(packageJson.version) .usage(' [options]') - .description(`Magento Database Synchronizer, based on Magerun - ${packageJson.version}`) + .description(description) program.on('command:*', () => { program.help() diff --git a/src/utils/versionCheck.ts b/src/utils/versionCheck.ts new file mode 100644 index 0000000..1f9525b --- /dev/null +++ b/src/utils/versionCheck.ts @@ -0,0 +1,20 @@ +// @ts-ignore +import packageFile from "../../package.json"; +// @ts-ignore +import * as fetch from 'node-fetch' + +class VersionCheck { + public config = { + 'latestVersion': '', + 'currentVersion': packageFile.version + } + + // versions + getToolVersions = async () => { + await fetch('https://raw.githubusercontent.com/jellesiderius/mage-db-sync/master/package.json') + .then((res: { json: () => any; }) => res.json()) + .then((json: { version: string; }) => this.config.latestVersion = json.version); + } +} + +export default VersionCheck; \ No newline at end of file