From 4914faadbdc5f728b9e4f57ddee89b48e57271d7 Mon Sep 17 00:00:00 2001 From: Jordan GAZEAU Date: Sun, 8 May 2022 20:52:51 +0200 Subject: [PATCH] fix: stat results not showing version before update --- README.md | 16 ++++++++++++++++ src/model/configurationFile/asset.ts | 12 ++++++++++++ src/utils/stats.ts | 4 +++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ef63b75..c81c122 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,26 @@ Additional information: Issues: https://github.com/jgazeau/bmyc/issues ``` +### How to hold a version? + +To hold a version, set the `hold` parameter for the specific asset to `true`: +```json +{ + ... + "name": "asset1", + "hold": true, + ... +} +``` + # Examples ```json [ { + "package": "asset1Package", "name": "asset1", + "hold": false, "localPath": "path/asset1.min.js", "assetManager": { "name": "cdnjs", @@ -69,7 +83,9 @@ Additional information: "currentVersion": "0.0.1" }, { + "package": "asset2Package", "name": "asset2", + "hold": false, "localPath": "./path/asset2.min.js", "assetManager": { "name": "github", diff --git a/src/model/configurationFile/asset.ts b/src/model/configurationFile/asset.ts index 3596c5b..a7e8b72 100644 --- a/src/model/configurationFile/asset.ts +++ b/src/model/configurationFile/asset.ts @@ -108,6 +108,17 @@ export class Asset { } /* c8 ignore stop */ + @Exclude() + private beforeUpdateVersion?: string | undefined; + /* c8 ignore start */ + public get _beforeUpdateVersion(): string | undefined { + return this.beforeUpdateVersion; + } + public set _beforeUpdateVersion(value: string | undefined) { + this.beforeUpdateVersion = value; + } + /* c8 ignore stop */ + @Exclude() private isUpdated = false; /* c8 ignore start */ @@ -153,6 +164,7 @@ export class Asset { .getLatestVersion() .then((latestVersion: string) => { this.latestVersion = latestVersion; + this.beforeUpdateVersion = this.currentVersion; this.isNewVersion = latestVersion !== this.currentVersion; if ((!this.isNewVersion && !force) || this.hold) { return Promise.resolve(this); diff --git a/src/utils/stats.ts b/src/utils/stats.ts index d180c5c..52aaf98 100644 --- a/src/utils/stats.ts +++ b/src/utils/stats.ts @@ -150,7 +150,9 @@ export function getStatus(asset: Asset, error?: Error): PrintEntry { export function getAssetVersion(asset: Asset): string { return asset._latestVersion - ? `${asset._currentVersion}\n(${asset._latestVersion})` + ? asset._isUpdated || asset._hold + ? `${asset._beforeUpdateVersion}\n(${asset._latestVersion})` + : asset._latestVersion : asset._currentVersion || 'N/A'; }