refactor: Stamp build information in as "defines" (#2654)
This commit is contained in:
+1
-1
@@ -65,7 +65,7 @@ import { localize } from './localize/localize.js';
|
||||
import cardStyle from './scss/card.scss';
|
||||
import type { MediaLoadedInfoEventDetail } from './types.js';
|
||||
import { hasAction } from './utils/action.js';
|
||||
import { getReleaseVersion } from './utils/diagnostics';
|
||||
import { getReleaseVersion } from './utils/build-info.js';
|
||||
|
||||
// ***************************************************************************
|
||||
// General Card-Wide Notes
|
||||
|
||||
@@ -9,7 +9,7 @@ import { customElement, property } from 'lit/decorators.js';
|
||||
|
||||
import loadingStyle from '../scss/loading.scss';
|
||||
import type { EffectName, EffectsManagerInterface } from '../types';
|
||||
import { getReleaseVersion } from '../utils/diagnostics';
|
||||
import { getReleaseVersion } from '../utils/build-info.js';
|
||||
|
||||
import './icon';
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
declare const __ADVANCED_CAMERA_CARD_RELEASE_VERSION__: string | undefined;
|
||||
declare const __ADVANCED_CAMERA_CARD_GIT_HASH__: string | undefined;
|
||||
declare const __ADVANCED_CAMERA_CARD_GIT_DATE__: string | undefined;
|
||||
declare const __ADVANCED_CAMERA_CARD_BUILD_DATE__: string | undefined;
|
||||
|
||||
const DEVELOPMENT_VERSION = 'dev';
|
||||
|
||||
/* v8 ignore start: substituted by the build -- @preserve */
|
||||
const RELEASE_VERSION =
|
||||
typeof __ADVANCED_CAMERA_CARD_RELEASE_VERSION__ === 'undefined'
|
||||
? DEVELOPMENT_VERSION
|
||||
: __ADVANCED_CAMERA_CARD_RELEASE_VERSION__;
|
||||
|
||||
const GIT_HASH =
|
||||
typeof __ADVANCED_CAMERA_CARD_GIT_HASH__ === 'undefined'
|
||||
? undefined
|
||||
: __ADVANCED_CAMERA_CARD_GIT_HASH__;
|
||||
|
||||
const GIT_DATE =
|
||||
typeof __ADVANCED_CAMERA_CARD_GIT_DATE__ === 'undefined'
|
||||
? undefined
|
||||
: __ADVANCED_CAMERA_CARD_GIT_DATE__;
|
||||
|
||||
const BUILD_DATE =
|
||||
typeof __ADVANCED_CAMERA_CARD_BUILD_DATE__ === 'undefined'
|
||||
? undefined
|
||||
: __ADVANCED_CAMERA_CARD_BUILD_DATE__;
|
||||
/* v8 ignore stop -- @preserve */
|
||||
|
||||
export interface GitInfo {
|
||||
hash?: string;
|
||||
commitDate?: string;
|
||||
buildDate?: string;
|
||||
}
|
||||
|
||||
export const getReleaseVersion = (): string => RELEASE_VERSION;
|
||||
export const getGitInfo = (): GitInfo => ({
|
||||
hash: GIT_HASH,
|
||||
commitDate: GIT_DATE,
|
||||
buildDate: BUILD_DATE,
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import pkg from '../../package.json';
|
||||
import type { IssueKey, IssuePresence } from '../card-controller/issues/types';
|
||||
import type { RawAdvancedCameraCardConfig } from '../config/types';
|
||||
import { getIntegrationManifest } from '../ha/integration';
|
||||
@@ -7,6 +6,7 @@ import type { DeviceRegistryManager } from '../ha/registry/device';
|
||||
import type { HomeAssistant } from '../ha/types';
|
||||
import { HASS_WEB_PROXY_DOMAIN } from '../ha/web-proxy';
|
||||
import { getLanguage } from '../localize/localize';
|
||||
import { getGitInfo, getReleaseVersion } from './build-info';
|
||||
|
||||
type FrigateDevices = Record<string, string>;
|
||||
|
||||
@@ -21,22 +21,6 @@ interface IntegrationDiagnostics {
|
||||
version?: string;
|
||||
}
|
||||
|
||||
export const getReleaseVersion = (): string => {
|
||||
const releaseVersion: string = '__ADVANCED_CAMERA_CARD_RELEASE_VERSION__';
|
||||
|
||||
/* v8 ignore if: depends on rollup substitution -- @preserve */
|
||||
if (releaseVersion === 'pkg') {
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
/* v8 ignore if: depends on rollup substitution -- @preserve */
|
||||
if (releaseVersion === 'dev') {
|
||||
return `dev+${pkg['gitAbbrevHash']}`;
|
||||
}
|
||||
|
||||
return releaseVersion;
|
||||
};
|
||||
|
||||
interface Diagnostics {
|
||||
card_version: string;
|
||||
browser: string;
|
||||
@@ -103,6 +87,8 @@ export const getDiagnostics = async (
|
||||
});
|
||||
});
|
||||
|
||||
const gitInfo = getGitInfo();
|
||||
|
||||
return {
|
||||
card_version: getReleaseVersion(),
|
||||
browser: navigator.userAgent,
|
||||
@@ -110,9 +96,9 @@ export const getDiagnostics = async (
|
||||
lang: getLanguage(),
|
||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
git: {
|
||||
...(pkg['gitAbbrevHash'] && { hash: pkg['gitAbbrevHash'] }),
|
||||
...(pkg['buildDate'] && { build_date: pkg['buildDate'] }),
|
||||
...(pkg['gitDate'] && { commit_date: pkg['gitDate'] }),
|
||||
...(gitInfo.hash && { hash: gitInfo.hash }),
|
||||
...(gitInfo.buildDate && { build_date: gitInfo.buildDate }),
|
||||
...(gitInfo.commitDate && { commit_date: gitInfo.commitDate }),
|
||||
},
|
||||
...(hass && { ha_version: hass.config.version }),
|
||||
custom_integrations: {
|
||||
|
||||
Reference in New Issue
Block a user