1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix how version_name manifest field is used (#13155)

The `version_name` manifest field was being used on Chrome to store the
build type. However, Chrome intended this field to be a full
representation of the version, for display purposes. This was evident
when uploading this version to the Chrome Web Store, because it used
`flask` as the entire version.

Instead the `version_name` field now includes the full SemVer version
string. The version parsing code within the build script and in the
wallet itself have been updated accordingly.
This commit is contained in:
Mark Stacey 2022-01-03 10:30:13 -03:30 committed by GitHub
parent 0cd4fb1da0
commit ae97e91443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

View File

@ -86,15 +86,12 @@ export default class ExtensionPlatform {
const versionParts = version.split('.'); const versionParts = version.split('.');
if (versionName) { if (versionName) {
// On Chrome, the build type is stored as `version_name` in the manifest, and the fourth part
// of the version is the build version.
const buildType = versionName;
if (versionParts.length < 4) { if (versionParts.length < 4) {
throw new Error(`Version missing build number: '${version}'`); throw new Error(`Version missing build number: '${version}'`);
} }
const [major, minor, patch, buildVersion] = versionParts; // On Chrome, a more descriptive representation of the version is stored
// in the `version_name` field for display purposes.
return `${major}.${minor}.${patch}-${buildType}.${buildVersion}`; return versionName;
} else if (versionParts.length === 4) { } else if (versionParts.length === 4) {
// On Firefox, the build type and build version are in the fourth part of the version. // On Firefox, the build type and build version are in the fourth part of the version.
const [major, minor, patch, prerelease] = versionParts; const [major, minor, patch, prerelease] = versionParts;

View File

@ -28,7 +28,7 @@ describe('extension platform', () => {
it('should return SemVer-formatted version for Chrome style manifest of prerelease', () => { it('should return SemVer-formatted version for Chrome style manifest of prerelease', () => {
extension.runtime.getManifest.mockReturnValue({ extension.runtime.getManifest.mockReturnValue({
version: '1.2.3.0', version: '1.2.3.0',
version_name: 'beta', version_name: '1.2.3-beta.0',
}); });
const extensionPlatform = new ExtensionPlatform(); const extensionPlatform = new ExtensionPlatform();
@ -51,7 +51,7 @@ describe('extension platform', () => {
it('should throw error if build version is missing from Chrome style prerelease manifest', () => { it('should throw error if build version is missing from Chrome style prerelease manifest', () => {
extension.runtime.getManifest.mockReturnValue({ extension.runtime.getManifest.mockReturnValue({
version: '1.2.3', version: '1.2.3',
version_name: 'beta', version_name: '1.2.3-beta.0',
}); });
const extensionPlatform = new ExtensionPlatform(); const extensionPlatform = new ExtensionPlatform();
@ -60,7 +60,7 @@ describe('extension platform', () => {
); );
}); });
it('should throw error if build type is missing from Chrome style prerelease manifest', () => { it('should throw error if version name is missing from Chrome style prerelease manifest', () => {
extension.runtime.getManifest.mockReturnValue({ extension.runtime.getManifest.mockReturnValue({
version: '1.2.3.0', version: '1.2.3.0',
}); });

View File

@ -23,7 +23,7 @@ const BuildType = {
* @param {string[]} platforms - A list of browsers to generate versions for. * @param {string[]} platforms - A list of browsers to generate versions for.
* @returns {Object} An object with the browser as the key and the browser-specific version object * @returns {Object} An object with the browser as the key and the browser-specific version object
* as the value. For example, the version `9.6.0-beta.1` would return the object * as the value. For example, the version `9.6.0-beta.1` would return the object
* `{ firefox: { version: '9.6.0.beta1' }, chrome: { version: '9.6.0.1', version_name: 'beta' } }`. * `{ firefox: { version: '9.6.0.beta1' }, chrome: { version: '9.6.0.1', version_name: '9.6.0-beta.1' } }`.
*/ */
function getBrowserVersionMap(platforms) { function getBrowserVersionMap(platforms) {
const major = semver.major(version); const major = semver.major(version);
@ -53,7 +53,7 @@ function getBrowserVersionMap(platforms) {
versionParts.push(`${buildType}${buildVersion}`); versionParts.push(`${buildType}${buildVersion}`);
} else { } else {
versionParts.push(buildVersion); versionParts.push(buildVersion);
browserSpecificVersion.version_name = buildType; browserSpecificVersion.version_name = version;
} }
} }
browserSpecificVersion.version = versionParts.join('.'); browserSpecificVersion.version = versionParts.join('.');