scratch-l10n 4.0.0 → 4.0.2

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 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.2](https://github.com/scratchfoundation/scratch-l10n/compare/v4.0.1...v4.0.2) (2024-10-30)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * stop trying to assign an array to process.exitCode ([a4b1680](https://github.com/scratchfoundation/scratch-l10n/commit/a4b16805f4b601204415f731ca8397fb9027201e))
12
+
13
+ ## [4.0.1](https://github.com/scratchfoundation/scratch-l10n/compare/v4.0.0...v4.0.1) (2024-10-30)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * require is not allowed in mjs files ([fb47cd2](https://github.com/scratchfoundation/scratch-l10n/commit/fb47cd2c566ad4020953bd88d754eceb6b120a8f))
19
+
6
20
  # [4.0.0](https://github.com/scratchfoundation/scratch-l10n/compare/v3.18.357...v4.0.0) (2024-10-30)
7
21
 
8
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scratch-l10n",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Localization for the Scratch 3.0 components",
5
5
  "main": "./dist/l10n.js",
6
6
  "browser": "./src/index.mjs",
@@ -5,8 +5,9 @@
5
5
  * Script get Knowledge base articles from Freshdesk and push them to transifex.
6
6
  */
7
7
 
8
+ import {txPush, txCreateResource} from '../lib/transifex.js';
9
+
8
10
  const args = process.argv.slice(2);
9
- const {txPush, txCreateResource} = require('../lib/transifex.js');
10
11
 
11
12
  const usage = `
12
13
  Pull knowledge base articles from Freshdesk and push to scratch-help project on transifex. Usage:
@@ -71,22 +72,27 @@ const txPushResource = async (name, articles, type) => {
71
72
  };
72
73
 
73
74
  /**
74
- * get a flattened list of folders
75
- * @param {category} categories array of categories the folders belong to
76
- * @return {Promise} flattened list of folders
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
77
78
  */
78
79
  const getFolders = async (categories) => {
79
- let categoryFolders = await Promise.all( // eslint-disable-line no-undef
80
+ const categoryFolders = await Promise.all(
80
81
  categories.map(category => FD.listFolders(category))
81
82
  );
82
83
  return [].concat(...categoryFolders);
83
84
  };
84
85
 
85
86
  const PUBLISHED = 2; // in Freshdesk, draft status = 1, and published = 2
86
- const saveArticles = (folder) => {
87
- FD.listArticles(folder)
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)
88
94
  .then(json => {
89
- let txArticles = json.reduce((strings, current) => {
95
+ const txArticles = json.reduce((strings, current) => {
90
96
  if (current.status === PUBLISHED) {
91
97
  strings[`${current.id}`] = {
92
98
  title: {
@@ -106,13 +112,16 @@ const saveArticles = (folder) => {
106
112
  txPushResource(`${makeTxId(folder)}_json`, txArticles, 'STRUCTURED_JSON');
107
113
  });
108
114
  };
109
- const getArticles = async (folders) => {
110
- return Promise.all(folders.map(folder => saveArticles(folder))); // eslint-disable-line no-undef
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)));
111
121
  };
112
122
 
113
123
  const syncSources = async () => {
114
- let status = 0;
115
- status = await FD.listCategories()
124
+ await FD.listCategories()
116
125
  .then(json => {
117
126
  // save category names for translation
118
127
  for (let cat of json.values()) {
@@ -130,12 +139,7 @@ const syncSources = async () => {
130
139
  txPushResource('folderNames_json', folderNames, 'KEYVALUEJSON');
131
140
  return data;
132
141
  })
133
- .then(getArticles)
134
- .catch((e) => {
135
- process.stdout.write(`Error:${e.message}\n`);
136
- return 1;
137
- });
138
- process.exitCode = status;
142
+ .then(saveArticleFolders);
139
143
  };
140
144
 
141
145
  syncSources();