瀏覽代碼

Remove version.ts

corpglory-dev 6 年之前
父節點
當前提交
ce2209585c

+ 1 - 1
public/app/plugins/datasource/grafana-azure-monitor-datasource/config_ctrl.ts

@@ -1,6 +1,6 @@
 import AzureLogAnalyticsDatasource from './azure_log_analytics/azure_log_analytics_datasource';
 import config from 'app/core/config';
-import { isVersionGtOrEq } from './version';
+import { isVersionGtOrEq } from 'app/core/utils/version';
 
 export class AzureMonitorConfigCtrl {
   static templateUrl = 'public/app/plugins/datasource/grafana-azure-monitor-datasource/partials/config.html';

+ 0 - 53
public/app/plugins/datasource/grafana-azure-monitor-datasource/version.test.ts

@@ -1,53 +0,0 @@
-import { SemVersion, isVersionGtOrEq } from './version';
-
-describe('SemVersion', () => {
-  let version = '1.0.0-alpha.1';
-
-  describe('parsing', () => {
-    it('should parse version properly', () => {
-      const semver = new SemVersion(version);
-      expect(semver.major).toBe(1);
-      expect(semver.minor).toBe(0);
-      expect(semver.patch).toBe(0);
-      expect(semver.meta).toBe('alpha.1');
-    });
-  });
-
-  describe('comparing', () => {
-    beforeEach(() => {
-      version = '3.4.5';
-    });
-
-    it('should detect greater version properly', () => {
-      const semver = new SemVersion(version);
-      const cases = [
-        { value: '3.4.5', expected: true },
-        { value: '3.4.4', expected: true },
-        { value: '3.4.6', expected: false },
-        { value: '4', expected: false },
-        { value: '3.5', expected: false },
-      ];
-      cases.forEach(testCase => {
-        expect(semver.isGtOrEq(testCase.value)).toBe(testCase.expected);
-      });
-    });
-  });
-
-  describe('isVersionGtOrEq', () => {
-    it('should compare versions properly (a >= b)', () => {
-      const cases = [
-        { values: ['3.4.5', '3.4.5'], expected: true },
-        { values: ['3.4.5', '3.4.4'], expected: true },
-        { values: ['3.4.5', '3.4.6'], expected: false },
-        { values: ['3.4', '3.4.0'], expected: true },
-        { values: ['3', '3.0.0'], expected: true },
-        { values: ['3.1.1-beta1', '3.1'], expected: true },
-        { values: ['3.4.5', '4'], expected: false },
-        { values: ['3.4.5', '3.5'], expected: false },
-      ];
-      cases.forEach(testCase => {
-        expect(isVersionGtOrEq(testCase.values[0], testCase.values[1])).toBe(testCase.expected);
-      });
-    });
-  });
-});

+ 0 - 34
public/app/plugins/datasource/grafana-azure-monitor-datasource/version.ts

@@ -1,34 +0,0 @@
-import _ from 'lodash';
-
-const versionPattern = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z\.]+))?/;
-
-export class SemVersion {
-  major: number;
-  minor: number;
-  patch: number;
-  meta: string;
-
-  constructor(version: string) {
-    const match = versionPattern.exec(version);
-    if (match) {
-      this.major = Number(match[1]);
-      this.minor = Number(match[2] || 0);
-      this.patch = Number(match[3] || 0);
-      this.meta = match[4];
-    }
-  }
-
-  isGtOrEq(version: string): boolean {
-    const compared = new SemVersion(version);
-    return !(this.major < compared.major || this.minor < compared.minor || this.patch < compared.patch);
-  }
-
-  isValid(): boolean {
-    return _.isNumber(this.major);
-  }
-}
-
-export function isVersionGtOrEq(a: string, b: string): boolean {
-  const aSemver = new SemVersion(a);
-  return aSemver.isGtOrEq(b);
-}