@opentermsarchive/engine 10.3.1 → 10.3.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/package.json
CHANGED
|
@@ -30,7 +30,7 @@ export default async function publish({ archivePath, releaseDate, stats }) {
|
|
|
30
30
|
logger.info('Uploading release asset…');
|
|
31
31
|
|
|
32
32
|
await octokit.rest.repos.uploadReleaseAsset({
|
|
33
|
-
data: fsApi.
|
|
33
|
+
data: fsApi.createReadStream(archivePath),
|
|
34
34
|
headers: {
|
|
35
35
|
'content-type': 'application/zip',
|
|
36
36
|
'content-length': fsApi.statSync(archivePath).size,
|
|
@@ -22,26 +22,29 @@ export default async function publishRelease({ archivePath, releaseDate, stats }
|
|
|
22
22
|
throw new Error('No publishing platform configured. Please configure at least one of: GitHub (OTA_ENGINE_GITHUB_TOKEN), GitLab (OTA_ENGINE_GITLAB_TOKEN), or data.gouv.fr (OTA_ENGINE_DATAGOUV_API_KEY + datasetId or organizationIdOrSlug in config).');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const succeeded = [];
|
|
26
|
+
const failed = [];
|
|
27
|
+
|
|
28
|
+
// Execute publications sequentially to avoid memory issues with large file uploads
|
|
29
|
+
for (const platform of platforms) {
|
|
30
|
+
try {
|
|
31
|
+
const url = await platform.publish();
|
|
32
|
+
|
|
33
|
+
succeeded.push({ platform: platform.name, url });
|
|
34
|
+
} catch (error) {
|
|
35
|
+
failed.push({ platform: platform.name, error });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
33
38
|
|
|
34
39
|
if (failed.length) {
|
|
35
40
|
let errorMessage = !succeeded.length ? 'All platforms failed to publish:' : 'Some platforms failed to publish:';
|
|
36
41
|
|
|
37
|
-
failed.forEach(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
errorMessage += `\n - ${platforms[index].name}: ${rejectedResult.reason.message}`;
|
|
42
|
+
failed.forEach(({ platform, error }) => {
|
|
43
|
+
errorMessage += `\n - ${platform}: ${error.message}`;
|
|
41
44
|
});
|
|
42
45
|
|
|
43
46
|
logger.error(errorMessage);
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
return succeeded
|
|
49
|
+
return succeeded;
|
|
47
50
|
}
|
|
@@ -35,15 +35,16 @@ export async function extractFromHTML(sourceDocument) {
|
|
|
35
35
|
const filteredDOM = await filter(webPageDOM, sourceDocument);
|
|
36
36
|
const cleanedDOM = filteredDOM.remove(insignificantContentSelectors);
|
|
37
37
|
const selectedDOM = cleanedDOM.select(contentSelectors);
|
|
38
|
+
const contentSelectorsDisplay = typeof contentSelectors === 'object' ? JSON.stringify(contentSelectors) : contentSelectors;
|
|
38
39
|
|
|
39
40
|
if (!selectedDOM?.children.length) {
|
|
40
|
-
throw new Error(`The provided selector "${
|
|
41
|
+
throw new Error(`The provided selector "${contentSelectorsDisplay}" has no match in the web page at '${location}'. This could be due to elements being removed before content selection if "remove" and "select" selectors match the same content.`);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
const markdownContent = transformFromHTML(selectedDOM);
|
|
44
45
|
|
|
45
46
|
if (!markdownContent) {
|
|
46
|
-
throw new Error(`The provided selector "${
|
|
47
|
+
throw new Error(`The provided selector "${contentSelectorsDisplay}" matches an empty content in the web page at '${location}'`);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
return markdownContent;
|