@ -9,7 +9,6 @@ const replace = require("gulp-replace");
const manifest = require ( "./src/manifest.json" ) ;
const manifestVersion = parseInt ( process . env . MANIFEST _VERSION || manifest . version ) ;
const betaBuild = process . env . BETA _BUILD === "1" ;
const paths = {
build : "./build/" ,
@ -17,27 +16,11 @@ const paths = {
safari : "./src/safari/" ,
} ;
/ * *
* Converts a number to a tuple containing two Uint16 ' s
* @ param num { number } This number is expected to be a integer style number with no decimals
*
* @ returns { number [ ] } A tuple containing two elements that are both numbers .
* /
function numToUint16s ( num ) {
var arr = new ArrayBuffer ( 4 ) ;
var view = new DataView ( arr ) ;
view . setUint32 ( 0 , num , false ) ;
return [ view . getUint16 ( 0 ) , view . getUint16 ( 2 ) ] ;
}
function buildString ( ) {
var build = "" ;
if ( process . env . MANIFEST _VERSION ) {
build = ` -mv ${ process . env . MANIFEST _VERSION } ` ;
}
if ( betaBuild ) {
build += "-beta" ;
}
if ( process . env . BUILD _NUMBER && process . env . BUILD _NUMBER !== "" ) {
build = ` - ${ process . env . BUILD _NUMBER } ` ;
}
@ -71,9 +54,6 @@ function distFirefox() {
manifest . optional _permissions = manifest . optional _permissions . filter (
( permission ) => permission !== "privacy" ,
) ;
if ( betaBuild ) {
manifest = applyBetaLabels ( manifest ) ;
}
return manifest ;
} ) ;
}
@ -90,9 +70,6 @@ function distOpera() {
delete manifest . commands . _execute _sidebar _action ;
}
if ( betaBuild ) {
manifest = applyBetaLabels ( manifest ) ;
}
return manifest ;
} ) ;
}
@ -102,9 +79,6 @@ function distChrome() {
delete manifest . applications ;
delete manifest . sidebar _action ;
delete manifest . commands . _execute _sidebar _action ;
if ( betaBuild ) {
manifest = applyBetaLabels ( manifest ) ;
}
return manifest ;
} ) ;
}
@ -114,9 +88,6 @@ function distEdge() {
delete manifest . applications ;
delete manifest . sidebar _action ;
delete manifest . commands . _execute _sidebar _action ;
if ( betaBuild ) {
manifest = applyBetaLabels ( manifest ) ;
}
return manifest ;
} ) ;
}
@ -237,9 +208,6 @@ async function safariCopyBuild(source, dest) {
delete manifest . commands . _execute _sidebar _action ;
delete manifest . optional _permissions ;
manifest . permissions . push ( "nativeMessaging" ) ;
if ( betaBuild ) {
manifest = applyBetaLabels ( manifest ) ;
}
return manifest ;
} ) ,
) ,
@ -254,30 +222,6 @@ function stdOutProc(proc) {
proc . stderr . on ( "data" , ( data ) => console . error ( data . toString ( ) ) ) ;
}
function applyBetaLabels ( manifest ) {
manifest . name = "Bitwarden Password Manager BETA" ;
manifest . short _name = "Bitwarden BETA" ;
manifest . description = "THIS EXTENSION IS FOR BETA TESTING BITWARDEN." ;
if ( process . env . GITHUB _RUN _ID ) {
const existingVersionParts = manifest . version . split ( "." ) ; // 3 parts expected 2024.4.0
// GITHUB_RUN_ID is a number like: 8853654662
// which will convert to [ 4024, 3206 ]
// and a single incremented id of 8853654663 will become [ 4024, 3207 ]
const runIdParts = numToUint16s ( parseInt ( process . env . GITHUB _RUN _ID ) ) ;
// Only use the first 2 parts from the given version number and base the other 2 numbers from the GITHUB_RUN_ID
// Example: 2024.4.4024.3206
const betaVersion = ` ${ existingVersionParts [ 0 ] } . ${ existingVersionParts [ 1 ] } . ${ runIdParts [ 0 ] } . ${ runIdParts [ 1 ] } ` ;
manifest . version _name = ` ${ betaVersion } beta - ${ process . env . GITHUB _SHA . slice ( 0 , 8 ) } ` ;
manifest . version = betaVersion ;
} else {
manifest . version = ` ${ manifest . version } .0 ` ;
}
return manifest ;
}
exports [ "dist:firefox" ] = distFirefox ;
exports [ "dist:chrome" ] = distChrome ;
exports [ "dist:opera" ] = distOpera ;