Bug 1828563 - Convert FeatureManifest.js to ESM. r=barret
Differential Revision: https://phabricator.services.mozilla.com/D175724
This commit is contained in:
@@ -21,17 +21,11 @@ NIMBUS_FALLBACK_PREFS = (
|
||||
"NIMBUS_FALLBACK_PREFS[]{{{}}};"
|
||||
)
|
||||
|
||||
EXPORTED_SYMBOLS = 'const EXPORTED_SYMBOLS = ["{}"];'
|
||||
|
||||
|
||||
def write_fm_cpp_headers(fd):
|
||||
def write_fm_headers(fd):
|
||||
fd.write(HEADER_LINE)
|
||||
|
||||
|
||||
def write_fm_js_headers(fd):
|
||||
fd.write("\n".join([HEADER_LINE, EXPORTED_SYMBOLS.format("FeatureManifest")]))
|
||||
|
||||
|
||||
def validate_feature_manifest(schema_path, manifest_path, manifest):
|
||||
with open(schema_path, "r") as f:
|
||||
schema = json.load(f)
|
||||
@@ -97,7 +91,7 @@ def validate_feature_manifest(schema_path, manifest_path, manifest):
|
||||
|
||||
|
||||
def generate_feature_manifest(fd, input_file):
|
||||
write_fm_js_headers(fd)
|
||||
write_fm_headers(fd)
|
||||
|
||||
try:
|
||||
with open(input_file, "r", encoding="utf-8") as f:
|
||||
@@ -107,7 +101,7 @@ def generate_feature_manifest(fd, input_file):
|
||||
Path(input_file).parent / FEATURE_MANIFEST_SCHEMA, input_file, manifest
|
||||
)
|
||||
|
||||
fd.write(f"const FeatureManifest = {json.dumps(manifest)};")
|
||||
fd.write(f"export const FeatureManifest = {json.dumps(manifest)};")
|
||||
except (IOError) as e:
|
||||
print(f"{input_file}: error:\n {e}\n")
|
||||
sys.exit(1)
|
||||
@@ -131,7 +125,7 @@ def platform_feature_manifest_array(features):
|
||||
|
||||
|
||||
def generate_platform_feature_manifest(fd, input_file):
|
||||
write_fm_cpp_headers(fd)
|
||||
write_fm_headers(fd)
|
||||
|
||||
def file_structure(data):
|
||||
return "\n".join(
|
||||
|
||||
@@ -6,6 +6,6 @@ toolkit.jar:
|
||||
% resource nimbus %res/nimbus/
|
||||
res/nimbus/lib/ (./lib/*.sys.mjs)
|
||||
res/nimbus/ExperimentAPI.sys.mjs (./ExperimentAPI.sys.mjs)
|
||||
res/nimbus/FeatureManifest.js (FeatureManifest.js)
|
||||
res/nimbus/FeatureManifest.sys.mjs (FeatureManifest.sys.mjs)
|
||||
res/nimbus/schemas/NimbusEnrollment.schema.json (./schemas/NimbusEnrollment.schema.json)
|
||||
res/nimbus/schemas/NimbusExperiment.schema.json (./schemas/NimbusExperiment.schema.json)
|
||||
|
||||
@@ -33,7 +33,7 @@ TESTING_JS_MODULES += [
|
||||
]
|
||||
|
||||
GeneratedFile(
|
||||
"FeatureManifest.js",
|
||||
"FeatureManifest.sys.mjs",
|
||||
script="generate/generate_feature_manifest.py",
|
||||
entry_point="generate_feature_manifest",
|
||||
inputs=["./FeatureManifest.yaml"],
|
||||
|
||||
Reference in New Issue
Block a user