Skip to content

Commit dacb737

Browse files
committed
Bug 1868838 - Move import-rollouts script into browser/components/asrouter. r=aminomancer
Differential Revision: https://phabricator.services.mozilla.com/D198996
1 parent 8f69e2b commit dacb737

12 files changed

+224
-263
lines changed

browser/components/asrouter/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
},
2626
},
2727
{
28-
files: ["./*.js", "content-src/**", "tests/unit/**"],
28+
files: ["bin/**", "./*.js", "content-src/**", "tests/unit/**"],
2929
env: {
3030
node: true,
3131
},

browser/components/newtab/bin/import-rollouts.js renamed to browser/components/asrouter/bin/import-rollouts.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/**
66
* This is a script to import Nimbus experiments from a given collection into
7-
* browser/components/newtab/test/NimbusRolloutMessageProvider.sys.mjs. By
7+
* browser/components/asrouter/tests/NimbusRolloutMessageProvider.sys.mjs. By
88
* default, it only imports messaging rollouts. This is done so that the content
99
* of off-train rollouts can be easily searched. That way, when we are cleaning
1010
* up old assets (such as Fluent strings), we don't accidentally delete strings
@@ -38,7 +38,7 @@ const DEFAULT_COLLECTION_ID = "nimbus-desktop-experiments";
3838
const BASE_URL =
3939
"https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/";
4040
const EXPERIMENTER_URL = "https://experimenter.services.mozilla.com/nimbus/";
41-
const OUTPUT_PATH = "./test/NimbusRolloutMessageProvider.sys.mjs";
41+
const OUTPUT_PATH = "./tests/NimbusRolloutMessageProvider.sys.mjs";
4242
const LICENSE_STRING = `/* This Source Code Form is subject to the terms of the Mozilla Public
4343
* License, v. 2.0. If a copy of the MPL was not distributed with this
4444
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */`;
@@ -81,7 +81,7 @@ async function getMessageValidators(skipValidation) {
8181

8282
if (common) {
8383
const commonSchema = await getSchema(
84-
"./content-src/asrouter/schemas/FxMSCommon.schema.json"
84+
"./content-src/schemas/FxMSCommon.schema.json"
8585
);
8686
validator.addSchema(commonSchema);
8787
}
@@ -90,53 +90,49 @@ async function getMessageValidators(skipValidation) {
9090
}
9191

9292
const experimentValidator = await getValidator(
93-
"./content-src/asrouter/schemas/MessagingExperiment.schema.json"
93+
"./content-src/schemas/MessagingExperiment.schema.json"
9494
);
9595

9696
const messageValidators = {
9797
cfr_doorhanger: await getValidator(
98-
"./content-src/asrouter/templates/CFR/templates/ExtensionDoorhanger.schema.json",
98+
"./content-src/templates/CFR/templates/ExtensionDoorhanger.schema.json",
9999
{ common: true }
100100
),
101101
cfr_urlbar_chiclet: await getValidator(
102-
"./content-src/asrouter/templates/CFR/templates/CFRUrlbarChiclet.schema.json",
102+
"./content-src/templates/CFR/templates/CFRUrlbarChiclet.schema.json",
103103
{ common: true }
104104
),
105105
infobar: await getValidator(
106-
"./content-src/asrouter/templates/CFR/templates/InfoBar.schema.json",
106+
"./content-src/templates/CFR/templates/InfoBar.schema.json",
107107
{ common: true }
108108
),
109109
pb_newtab: await getValidator(
110-
"./content-src/asrouter/templates/PBNewtab/NewtabPromoMessage.schema.json",
111-
{ common: true }
112-
),
113-
protections_panel: await getValidator(
114-
"./content-src/asrouter/templates/OnboardingMessage/ProtectionsPanelMessage.schema.json",
110+
"./content-src/templates/PBNewtab/NewtabPromoMessage.schema.json",
115111
{ common: true }
116112
),
117113
spotlight: await getValidator(
118-
"./content-src/asrouter/templates/OnboardingMessage/Spotlight.schema.json",
114+
"./content-src/templates/OnboardingMessage/Spotlight.schema.json",
119115
{ common: true }
120116
),
121117
toast_notification: await getValidator(
122-
"./content-src/asrouter/templates/ToastNotification/ToastNotification.schema.json",
118+
"./content-src/templates/ToastNotification/ToastNotification.schema.json",
123119
{ common: true }
124120
),
125121
toolbar_badge: await getValidator(
126-
"./content-src/asrouter/templates/OnboardingMessage/ToolbarBadgeMessage.schema.json",
122+
"./content-src/templates/OnboardingMessage/ToolbarBadgeMessage.schema.json",
127123
{ common: true }
128124
),
129125
update_action: await getValidator(
130-
"./content-src/asrouter/templates/OnboardingMessage/UpdateAction.schema.json",
126+
"./content-src/templates/OnboardingMessage/UpdateAction.schema.json",
131127
{ common: true }
132128
),
133129
whatsnew_panel_message: await getValidator(
134-
"./content-src/asrouter/templates/OnboardingMessage/WhatsNewMessage.schema.json",
130+
"./content-src/templates/OnboardingMessage/WhatsNewMessage.schema.json",
135131
{ common: true }
136132
),
137133
feature_callout: await getValidator(
138134
// For now, Feature Callout and Spotlight share a common schema
139-
"./content-src/asrouter/templates/OnboardingMessage/Spotlight.schema.json",
135+
"./content-src/templates/OnboardingMessage/Spotlight.schema.json",
140136
{ common: true }
141137
),
142138
};
@@ -182,7 +178,7 @@ async function format(content) {
182178
async function main() {
183179
const { default: meow } = await import("meow");
184180
const { MESSAGING_EXPERIMENTS_DEFAULT_FEATURES } = await import(
185-
"../lib/MessagingExperimentConstants.sys.mjs"
181+
"../modules/MessagingExperimentConstants.sys.mjs"
186182
);
187183

188184
const fileUrl = pathToFileURL(__filename);
@@ -345,9 +341,9 @@ async function main() {
345341
const content = `${LICENSE_STRING}
346342
347343
/**
348-
* This file is generated by browser/components/newtab/bin/import-rollouts.js
344+
* This file is generated by browser/components/asrouter/bin/import-rollouts.js
349345
* Run the following from the repository root to regenerate it:
350-
* ./mach npm run import-rollouts --prefix=browser/components/newtab
346+
* ./mach npm run import-rollouts --prefix=browser/components/asrouter
351347
*/
352348
353349
export const NimbusRolloutMessageProvider = {

browser/components/asrouter/modules/ASRouter.jsm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const { actionCreators: ac } = ChromeUtils.importESModule(
5656
"resource://activity-stream/common/Actions.sys.mjs"
5757
);
5858
const { MESSAGING_EXPERIMENTS_DEFAULT_FEATURES } = ChromeUtils.importESModule(
59-
"resource://activity-stream/lib/MessagingExperimentConstants.sys.mjs"
59+
"resource:///modules/asrouter/MessagingExperimentConstants.sys.mjs"
6060
);
6161
const { CFRMessageProvider } = ChromeUtils.importESModule(
6262
"resource:///modules/asrouter/CFRMessageProvider.sys.mjs"

browser/components/asrouter/moz.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ EXTRA_JS_MODULES.asrouter += [
2424
"modules/ASRouterTriggerListeners.jsm",
2525
"modules/CFRMessageProvider.sys.mjs",
2626
"modules/CFRPageActions.jsm",
27+
"modules/MessagingExperimentConstants.sys.mjs",
2728
"modules/RemoteL10n.sys.mjs",
2829
]
2930

@@ -46,6 +47,7 @@ TESTING_JS_MODULES += [
4647
"content-src/templates/OnboardingMessage/WhatsNewMessage.schema.json",
4748
"content-src/templates/PBNewtab/NewtabPromoMessage.schema.json",
4849
"content-src/templates/ToastNotification/ToastNotification.schema.json",
50+
"tests/NimbusRolloutMessageProvider.sys.mjs",
4951
]
5052

5153
SPHINX_TREES["docs"] = "docs"

browser/components/asrouter/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"fix": "npm-run-all fix:*",
7575
"fix:eslint": "npm run lint:eslint -- --fix",
7676
"fix:stylelint": "npm run lint:stylelint -- --fix",
77+
"import-rollouts": "node ./bin/import-rollouts.js",
7778
"help": "yamscripts help",
7879
"yamscripts": "yamscripts compile",
7980
"__": "# NOTE: THESE SCRIPTS ARE COMPILED!!! EDIT yamscripts.yml instead!!!"
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
/**
6+
* This file is generated by browser/components/asrouter/bin/import-rollouts.js
7+
* Run the following from the repository root to regenerate it:
8+
* ./mach npm run import-rollouts --prefix=browser/components/asrouter
9+
*/
10+
11+
export const NimbusRolloutMessageProvider = {
12+
getMessages() {
13+
return [
14+
{
15+
// Nimbus slug: fox-doodle-set-to-default-early-day-user-de-fr-it-treatment-a-rollout:treatment-a
16+
// Version range: 116+
17+
// Recipe: https://experimenter.services.mozilla.com/nimbus/fox-doodle-set-to-default-early-day-user-de-fr-it-treatment-a-rollout/summary#treatment-a
18+
id: "fox-doodle-set-to-default-early-day-user-de-fr-it:A",
19+
groups: ["eco"],
20+
content: {
21+
id: "fox-doodle-set-to-default-early-day-user-de-fr-it:A",
22+
screens: [
23+
{
24+
id: "SET_DEFAULT",
25+
content: {
26+
logo: {
27+
height: "140px",
28+
imageURL:
29+
"https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/05f5265b-d1e4-4fe1-9a46-0ea36f8afced.png",
30+
reducedMotionImageURL:
31+
"https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/05f5265b-d1e4-4fe1-9a46-0ea36f8afced.png",
32+
},
33+
title: {
34+
raw: {
35+
$l10n: {
36+
id: "fox-doodle-trackers-title",
37+
text: "Keep pesky trackers off your tail",
38+
comment:
39+
"This title is displayed together with the picture of a running fox with a long tail. In English, this is a figure of speech meaning 'stop something from following you'. If the localization of this message is challenging, consider using a simplified alternative as a reference for translation: 'Keep unwanted trackers away'.",
40+
},
41+
},
42+
fontSize: "22px",
43+
fontWeight: 590,
44+
paddingBlock: "4px 0",
45+
letterSpacing: 0,
46+
paddingInline: "24px",
47+
},
48+
subtitle: {
49+
raw: {
50+
$l10n: {
51+
id: "fox-doodle-trackers-subtitle",
52+
text: "Say goodbye to annoying ad trackers and settle into a safer, speedy internet experience.",
53+
comment: "",
54+
},
55+
},
56+
fontSize: "15px",
57+
lineHeight: "1.4",
58+
marginBlock: "8px 16px",
59+
letterSpacing: 0,
60+
paddingInline: "24px",
61+
},
62+
dismiss_button: {
63+
action: {
64+
navigate: true,
65+
},
66+
},
67+
primary_button: {
68+
label: {
69+
raw: {
70+
$l10n: {
71+
id: "fox-doodle-set-default-driving-primary-button-label",
72+
text: "Open my links with Firefox",
73+
comment: "",
74+
},
75+
},
76+
marginBlock: "4px 0",
77+
paddingBlock: "0",
78+
paddingInline: "16px",
79+
},
80+
action: {
81+
type: "SET_DEFAULT_BROWSER",
82+
navigate: true,
83+
},
84+
},
85+
secondary_button: {
86+
label: {
87+
raw: {
88+
$l10n: {
89+
id: "fox-doodle-driving-secondary-button-label",
90+
text: "Not now",
91+
comment: "",
92+
},
93+
},
94+
marginBlock: "0 -20px",
95+
},
96+
action: {
97+
navigate: true,
98+
},
99+
},
100+
},
101+
},
102+
],
103+
backdrop: "transparent",
104+
template: "multistage",
105+
transitions: true,
106+
},
107+
trigger: {
108+
id: "defaultBrowserCheck",
109+
},
110+
priority: 1,
111+
template: "spotlight",
112+
frequency: {
113+
lifetime: 1,
114+
},
115+
targeting:
116+
"source == 'startup' && !willShowDefaultPrompt && !isMajorUpgrade && !activeNotifications && (((currentDate|date) - (profileAgeCreated|date)) / 3600000 >= 6) && !isDefaultBrowser",
117+
},
118+
{
119+
// Nimbus slug: fox-doodle-set-to-default-early-day-user-en-treatment-a-rollout:treatment-a
120+
// Version range: 116+
121+
// Recipe: https://experimenter.services.mozilla.com/nimbus/fox-doodle-set-to-default-early-day-user-en-treatment-a-rollout/summary#treatment-a
122+
id: "fox-doodle-set-to-default-early-day-user:A",
123+
groups: ["eco"],
124+
content: {
125+
id: "fox-doodle-set-to-default-early-day-user:A",
126+
screens: [
127+
{
128+
id: "SET_DEFAULT",
129+
content: {
130+
logo: {
131+
height: "140px",
132+
imageURL:
133+
"https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/05f5265b-d1e4-4fe1-9a46-0ea36f8afced.png",
134+
reducedMotionImageURL:
135+
"https://firefox-settings-attachments.cdn.mozilla.net/main-workspace/ms-images/05f5265b-d1e4-4fe1-9a46-0ea36f8afced.png",
136+
},
137+
title: {
138+
raw: "Keep pesky trackers off your tail",
139+
fontSize: "22px",
140+
fontWeight: 590,
141+
paddingBlock: "4px 0",
142+
letterSpacing: 0,
143+
paddingInline: "24px",
144+
},
145+
subtitle: {
146+
raw: "Say goodbye to annoying ad trackers and settle into a safer, speedy internet experience.",
147+
fontSize: "15px",
148+
lineHeight: "1.4",
149+
marginBlock: "8px 16px",
150+
letterSpacing: 0,
151+
paddingInline: "24px",
152+
},
153+
dismiss_button: {
154+
action: {
155+
navigate: true,
156+
},
157+
},
158+
primary_button: {
159+
label: {
160+
raw: "Open my links with Firefox",
161+
marginBlock: "4px 0",
162+
paddingBlock: "0",
163+
paddingInline: "16px",
164+
},
165+
action: {
166+
type: "SET_DEFAULT_BROWSER",
167+
navigate: true,
168+
},
169+
},
170+
secondary_button: {
171+
label: {
172+
raw: "Not now",
173+
marginBlock: "0 -20px",
174+
},
175+
action: {
176+
navigate: true,
177+
},
178+
},
179+
},
180+
},
181+
],
182+
backdrop: "transparent",
183+
template: "multistage",
184+
transitions: true,
185+
},
186+
trigger: {
187+
id: "defaultBrowserCheck",
188+
},
189+
priority: 1,
190+
template: "spotlight",
191+
frequency: {
192+
lifetime: 1,
193+
},
194+
targeting:
195+
"source == 'startup' && !willShowDefaultPrompt && !isMajorUpgrade && !activeNotifications && (((currentDate|date) - (profileAgeCreated|date)) / 3600000 >= 6) && !isDefaultBrowser",
196+
},
197+
];
198+
},
199+
};

browser/components/asrouter/yamscripts.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ scripts:
4242
# running fix:eslint will also reformat changed JS files using prettier.
4343
eslint: =>lint:eslint -- --fix
4444
stylelint: =>lint:stylelint -- --fix
45+
46+
# script to import Nimbus rollouts into NimbusRolloutMessageProvider.sys.mjs
47+
import-rollouts: node ./bin/import-rollouts.js

browser/components/newtab/moz.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ BROWSER_CHROME_MANIFESTS += [
1414

1515
TESTING_JS_MODULES += [
1616
"test/InflightAssetsMessageProvider.sys.mjs",
17-
"test/NimbusRolloutMessageProvider.sys.mjs",
1817
]
1918

2019
SPHINX_TREES["docs"] = "docs"

browser/components/newtab/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
"fix": "npm-run-all fix:*",
104104
"fix:eslint": "npm run lint:eslint -- --fix",
105105
"fix:stylelint": "npm run lint:stylelint -- --fix",
106-
"import-rollouts": "node ./bin/import-rollouts.js",
107106
"help": "yamscripts help",
108107
"yamscripts": "yamscripts compile",
109108
"__": "# NOTE: THESE SCRIPTS ARE COMPILED!!! EDIT yamscripts.yml instead!!!"

0 commit comments

Comments
 (0)