Skip to content

Commit e559938

Browse files
committed
Added --firefox-changelog-lang
1 parent bde0606 commit e559938

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ web-ext-deploy --env
112112
If specified and `firefox.env` exists, it will be used to provide changelog for the Firefox users
113113
New lines (`\n`) are supported
114114

115+
- `--firefox-changelog-lang` string?
116+
- If specified and `firefox.env` exists, it will be used to dictate the language of the release notes.
117+
Fallbacks to the Manifest's `default_locale` field, if applicable, or `en-US`
118+
115119
- `--firefox-dev-changelog` string?
116120
If specified and `firefox.env` exists, it will be used to provide changelog for the Firefox Add-ons reviewers
117121
New lines (`\n`) are supported
@@ -269,6 +273,10 @@ web-ext-deploy --chrome-ext-id="ExtensionID" --chrome-refresh-token="RefreshToke
269273
# A description of the changes in this version, compared to the previous one
270274
# It's recommended to use instead --firefox-changelog , so it stays up to date
271275
--firefox-changelog?: string
276+
277+
# The language of the changelog
278+
# Fallbacks to the Manifest's `default_locale` field, if applicable, or `en-US`
279+
--firefox-changelog-lang?: string
272280

273281
# A description of the technical changes made in this version, compared to the previous one
274282
# This will only be seen by the Firefox Addons reviewers
@@ -410,6 +418,10 @@ zipSource?: string;
410418
# It's recommended to use instead --firefox-changelog , so it stays up to date
411419
changelog?: string;
412420

421+
# The language of the changelog
422+
# Fallbacks to the Manifest's `default_locale` field, if applicable, or `en-US`
423+
changelogLang?: string;
424+
413425
# A description of the technical changes made in this version, compared to the previous one
414426
# This will only be seen by the Firefox Addons reviewers
415427
# It's recommended to use instead --firefox-dev-changelog , so it stays up to date
@@ -505,6 +517,7 @@ deployFirefoxSubmissionApi({
505517
zip: "dist/some-zip-v{version}.zip",
506518
zipSource: "dist/zip-source-v{version}.zip",
507519
changelog: "Some changes",
520+
changelogLang: "en-US",
508521
devChangelog: "Changes for reviewers",
509522
verbose: false
510523
}).catch(console.error);

src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const argv = yargs(process.argv.slice(2))
3030
firefoxZip: { type: "string" },
3131
firefoxZipSource: { type: "string" },
3232
firefoxChangelog: { type: "string" },
33+
firefoxChangelogLang: { default: "en-US" },
3334
firefoxDevChangelog: { type: "string" },
3435
// edge
3536
edgeClientId: { type: "string" },

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const argv = yargs(process.argv.slice(2))
1919
publishOnly: { type: "array", default: [] },
2020
getCookies: { type: "array" },
2121
firefoxChangelog: { type: "string" },
22+
firefoxChangelogLang: { default: "en-US" },
2223
firefoxDevChangelog: { type: "string" },
2324
edgeDevChangelog: { type: "string" },
2425
operaChangelog: { type: "string" },

src/stores/firefox/firefox-deploy.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ async function handleRequestWithBackOff<T>({
7070
}
7171

7272
// Some sort of client error
73+
let errorMessage = getErrorMessage({
74+
store: STORE,
75+
error: JSON.stringify(e.response.data),
76+
actionName: errorActionOnFailure,
77+
zip
78+
});
79+
if (errorMessage.match(/release_notes.+The language code.+is invalid/)) {
80+
errorMessage += " Supported language codes: https://github.com/mozilla/addons-server/blob/master/src/olympia/core/languages.py";
81+
}
7382
return [
74-
getErrorMessage({
75-
store: STORE,
76-
error: JSON.stringify(e.response.data),
77-
actionName: errorActionOnFailure,
78-
zip
79-
})
83+
errorMessage
8084
];
8185
}
8286
}
@@ -106,7 +110,7 @@ async function uploadZip({
106110
formData.append("channel", "listed");
107111

108112
const sendRequest = () =>
109-
axios.post<FirefoxUploadDetail>(`upload/`, formData, {
113+
axios.post<FirefoxUploadDetail>("upload/", formData, {
110114
headers: {
111115
"Content-Type": "multipart/form-data"
112116
}
@@ -128,25 +132,27 @@ async function createNewVersion({
128132
slug,
129133
uuid,
130134
changelog,
135+
changelogLang,
131136
devChangelog,
132137
isVerbose,
133138
zip
134139
}: {
135140
slug: string;
136141
uuid: string;
137142
changelog: string;
143+
changelogLang: string;
138144
devChangelog: string;
139145
isVerbose: boolean;
140146
zip: string;
141147
}): Promise<[undefined, FirefoxCreateNewVersion] | [string]> {
142148
// https://addons-server.readthedocs.io/en/latest/topics/api/addons.html#version-create
143-
const { default_locale = "en-US" } = getExtJson(zip);
149+
const { default_locale = changelogLang } = getExtJson(zip);
144150
const sendRequest = async () =>
145151
axios.post(`addon/${slug}/versions/`, {
146152
upload: uuid,
147153
...(changelog && {
148154
release_notes: {
149-
[default_locale]: changelog
155+
[default_locale.replaceAll("_", "-")]: changelog
150156
}
151157
}),
152158
...(devChangelog && {
@@ -266,6 +272,7 @@ export default async function deployToFirefox({
266272
zip,
267273
zipSource = "",
268274
changelog = "",
275+
changelogLang = "en-US",
269276
devChangelog = "",
270277
verbose: isVerbose
271278
}: FirefoxOptionsSubmissionApi): Promise<boolean> {
@@ -320,6 +327,7 @@ export default async function deployToFirefox({
320327
slug: extId,
321328
uuid,
322329
changelog,
330+
changelogLang,
323331
devChangelog,
324332
isVerbose,
325333
zip

src/stores/firefox/firefox-input.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ export class FirefoxOptionsSubmissionApi {
3030
*/
3131
changelog?: string;
3232

33+
/**
34+
* The language of the changelog, e.g. `en-US`<br>
35+
* Fallback: `manifest.default_locale` or `en-US`
36+
*/
37+
changelogLang = "en-US";
38+
3339
/**
3440
* A description of the technical changes made in this version, compared to the previous one<br>
3541
* This will only be seen by the Firefox Addons reviewers<br>

0 commit comments

Comments
 (0)