Skip to content

Commit

Permalink
feat(27255): allow local modification for remote feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
DDDDDanica committed Jan 14, 2025
1 parent bbe8143 commit ced7bf4
Show file tree
Hide file tree
Showing 27 changed files with 588 additions and 127 deletions.
12 changes: 12 additions & 0 deletions app/scripts/lib/manifestFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ export type ManifestFlags = {
*/
forceEnable?: boolean;
};
/**
* Feature flags to control business logic behavior
*/
remoteFeatureFlags?: {
/**
* A test remote featureflag for threshold
*/
testFlagForThreshold: {
name: string;
value: string;
};
};
};

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- you can't extend a type, we want this to be an interface
Expand Down
5 changes: 4 additions & 1 deletion development/build/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const baradDurManifest = isManifestV3
? require('../../app/manifest/v3/_barad_dur.json')
: require('../../app/manifest/v2/_barad_dur.json');
const { loadBuildTypesConfig } = require('../lib/build-type');
const manifestFlags = require('../../manifest-flags.json');

const { TASKS, ENVIRONMENT } = require('./constants');
const { createTask, composeSeries } = require('./task');
Expand Down Expand Up @@ -47,8 +48,10 @@ function createManifestTasks({
browserVersionMap[platform],
await getBuildModifications(buildType, platform),
customArrayMerge,
{
_flags: manifestFlags,
},
);

modifyNameAndDescForNonProd(result);

const dir = path.join('.', 'dist', platform);
Expand Down
13 changes: 13 additions & 0 deletions development/webpack/utils/plugins/ManifestPlugin/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import manifestFlags from '../../../../../manifest-flags.json';

/**
* Returns a function that will transform a manifest JSON object based on the
* given build args.
Expand All @@ -24,6 +26,17 @@ export function transformManifest(args: { lockdown: boolean; test: boolean }) {
}
}

/**
* This function sets predefined flags in the manifest's _flags property.
*
* @param browserManifest - The Chrome extension manifest object to modify
*/
function addManifestFlags(browserManifest: chrome.runtime.Manifest) {
browserManifest._flags = manifestFlags;
}

transforms.push(addManifestFlags);

if (!args.lockdown) {
// remove lockdown scripts from content_scripts
transforms.push(removeLockdown);
Expand Down
2 changes: 1 addition & 1 deletion lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5650,4 +5650,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5650,4 +5650,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5650,4 +5650,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -5742,4 +5742,4 @@
}
}
}
}
}
Loading

0 comments on commit ced7bf4

Please sign in to comment.