Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

MWPW-141282 Update UK/AU Blog Tag #31

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions bacom-blog/article-feed/article-feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ function getFeedRow(feedURL) {
type: 'paragraph',
children: [
{
type: 'text',
value: feedURL,
type: 'link',
title: null,
url: feedURL,
children: [
{
type: 'text',
value: feedURL,
},
],
},
],
},
Expand All @@ -49,8 +56,8 @@ export default function updateArticleFeed(mdast, entry) {
const UK_PATH = '/uk/blog/';
let feedURL;

if (entry.includes(AU_PATH)) feedURL = 'https://main--bacom-blog--adobecom.hlx.page/au/us-au-query-index.json';
if (entry.includes(UK_PATH)) feedURL = 'https://main--bacom-blog--adobecom.hlx.page/uk/us-uk-query-index.json';
if (entry.includes(AU_PATH)) feedURL = 'https://main--bacom-blog--adobecom.hlx.page/au/blog/us-au-query-index.json';
if (entry.includes(UK_PATH)) feedURL = 'https://main--bacom-blog--adobecom.hlx.page/uk/blog/us-uk-query-index.json';
if (!feedURL) {
return {
status: STATUS_SKIPPED,
Expand Down
14 changes: 8 additions & 6 deletions blog-migration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check warning on line 1 in blog-migration.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 File ignored because of a matching ignore pattern. Use "--no-ignore" to override. Raw Output: {"ruleId":null,"fatal":false,"severity":1,"message":"File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override.","nodeType":null}
* Copyright 2023 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
Expand All @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import { writeFile, mkdir, access } from 'fs/promises';
import * as fs from 'fs';
import xlsx from 'xlsx';
import { getMdast, getTableMap } from './utils/mdast-utils.js';
import { saveDocx } from './utils/docx-utils.js';
Expand Down Expand Up @@ -90,8 +90,10 @@
});

const reportDir = reportFile.substring(0, reportFile.lastIndexOf('/'));
await mkdir(reportDir, { recursive: true });
await xlsx.writeFile(workbook, reportFile);

fs.mkdirSync(reportDir, { recursive: true });
xlsx.set_fs(fs);
xlsx.writeFile(workbook, reportFile);
}

function formatReportData(reports) {
Expand Down Expand Up @@ -272,7 +274,7 @@

async function ensureDocxFileExists(mdast, sourceDocxFile) {
try {
await access(sourceDocxFile);
fs.accessSync(sourceDocxFile);
} catch (e) {
await saveDocx(mdast, sourceDocxFile);
}
Expand Down Expand Up @@ -320,11 +322,11 @@

const dateStr = getDateString();
const migrationReportFile = `${REPORT_DIR}/${PROJECT}/Migration ${dateStr}`;
await writeFile(`${migrationReportFile}.json`, JSON.stringify({ reports }, null, 2));
fs.writeFileSync(`${migrationReportFile}.json`, JSON.stringify({ reports }, null, 2));
console.log(`Report written to ${migrationReportFile}.json`);

const linkReportFile = `${REPORT_DIR}/${PROJECT}/Links ${dateStr}`;
await writeFile(`${linkReportFile}.json`, JSON.stringify({ totalLinksReport }, null, 2));
fs.writeFileSync(`${linkReportFile}.json`, JSON.stringify({ totalLinksReport }, null, 2));
console.log(`Report written to ${linkReportFile}.json`);

await createReport(reports, `${migrationReportFile}.xlsx`);
Expand Down
29 changes: 18 additions & 11 deletions test/bacom-blog/article-feed/mocks/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,25 @@
]
},
{
"type": "gtCell",
"type": "gtCell",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "https://main--bacom-blog--adobecom.hlx.page/au/blog/us-au-query-index.json",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "https://main--bacom-blog--adobecom.hlx.page/au/us-au-query-index.json"
}
]
}
{
"type": "text",
"value": "https://main--bacom-blog--adobecom.hlx.page/au/blog/us-au-query-index.json"
}
]
}
]
}
]
}
]
}
Expand All @@ -127,4 +134,4 @@
]
}
]
}
}
29 changes: 18 additions & 11 deletions test/bacom-blog/article-feed/mocks/outputUk.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,25 @@
]
},
{
"type": "gtCell",
"type": "gtCell",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "link",
"title": null,
"url": "https://main--bacom-blog--adobecom.hlx.page/uk/blog/us-uk-query-index.json",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "https://main--bacom-blog--adobecom.hlx.page/uk/us-uk-query-index.json"
}
]
}
{
"type": "text",
"value": "https://main--bacom-blog--adobecom.hlx.page/uk/blog/us-uk-query-index.json"
}
]
}
]
}
]
}
]
}
Expand All @@ -127,4 +134,4 @@
]
}
]
}
}
Loading