scratch-l10n 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/scripts/tx-push-help.mjs +20 -17
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,20 @@
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [4.0.3](https://github.com/scratchfoundation/scratch-l10n/compare/v4.0.2...v4.0.3) (2024-10-31)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **deps:** lock file maintenance ([b166836](https://github.com/scratchfoundation/scratch-l10n/commit/b16683692f2d7bc3d9d10a046ef611bbba496a29))
|
12
|
+
|
13
|
+
## [4.0.2](https://github.com/scratchfoundation/scratch-l10n/compare/v4.0.1...v4.0.2) (2024-10-30)
|
14
|
+
|
15
|
+
|
16
|
+
### Bug Fixes
|
17
|
+
|
18
|
+
* stop trying to assign an array to process.exitCode ([a4b1680](https://github.com/scratchfoundation/scratch-l10n/commit/a4b16805f4b601204415f731ca8397fb9027201e))
|
19
|
+
|
6
20
|
## [4.0.1](https://github.com/scratchfoundation/scratch-l10n/compare/v4.0.0...v4.0.1) (2024-10-30)
|
7
21
|
|
8
22
|
|
package/package.json
CHANGED
package/scripts/tx-push-help.mjs
CHANGED
@@ -72,22 +72,27 @@ const txPushResource = async (name, articles, type) => {
|
|
72
72
|
};
|
73
73
|
|
74
74
|
/**
|
75
|
-
* get a flattened list of folders
|
76
|
-
* @param {
|
77
|
-
* @return {Promise}
|
75
|
+
* get a flattened list of folders associated with the specified categories
|
76
|
+
* @param {object[]} categories array of categories the folders belong to
|
77
|
+
* @return {Promise<object[]>} flattened list of folders from all requested categories
|
78
78
|
*/
|
79
79
|
const getFolders = async (categories) => {
|
80
|
-
|
80
|
+
const categoryFolders = await Promise.all(
|
81
81
|
categories.map(category => FD.listFolders(category))
|
82
82
|
);
|
83
83
|
return [].concat(...categoryFolders);
|
84
84
|
};
|
85
85
|
|
86
86
|
const PUBLISHED = 2; // in Freshdesk, draft status = 1, and published = 2
|
87
|
-
|
88
|
-
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Save articles in a particular folder
|
90
|
+
* @param {object} folder The folder object
|
91
|
+
*/
|
92
|
+
const saveArticles = async folder => {
|
93
|
+
await FD.listArticles(folder)
|
89
94
|
.then(json => {
|
90
|
-
|
95
|
+
const txArticles = json.reduce((strings, current) => {
|
91
96
|
if (current.status === PUBLISHED) {
|
92
97
|
strings[`${current.id}`] = {
|
93
98
|
title: {
|
@@ -107,13 +112,16 @@ const saveArticles = (folder) => {
|
|
107
112
|
txPushResource(`${makeTxId(folder)}_json`, txArticles, 'STRUCTURED_JSON');
|
108
113
|
});
|
109
114
|
};
|
110
|
-
|
111
|
-
|
115
|
+
|
116
|
+
/**
|
117
|
+
* @param {object[]} folders Array of folders containing articles to be saved
|
118
|
+
*/
|
119
|
+
const saveArticleFolders = async (folders) => {
|
120
|
+
await Promise.all(folders.map(folder => saveArticles(folder)));
|
112
121
|
};
|
113
122
|
|
114
123
|
const syncSources = async () => {
|
115
|
-
|
116
|
-
status = await FD.listCategories()
|
124
|
+
await FD.listCategories()
|
117
125
|
.then(json => {
|
118
126
|
// save category names for translation
|
119
127
|
for (let cat of json.values()) {
|
@@ -131,12 +139,7 @@ const syncSources = async () => {
|
|
131
139
|
txPushResource('folderNames_json', folderNames, 'KEYVALUEJSON');
|
132
140
|
return data;
|
133
141
|
})
|
134
|
-
.then(
|
135
|
-
.catch((e) => {
|
136
|
-
process.stdout.write(`Error:${e.message}\n`);
|
137
|
-
return 1;
|
138
|
-
});
|
139
|
-
process.exitCode = status;
|
142
|
+
.then(saveArticleFolders);
|
140
143
|
};
|
141
144
|
|
142
145
|
syncSources();
|