From 52c88f67072febee163b8a1265aadb4ce77a2359 Mon Sep 17 00:00:00 2001 From: Megan Thomas Date: Fri, 2 Feb 2024 15:56:42 -0800 Subject: [PATCH 1/2] MWPW-141282 Update UK/AU Blog Tag --- bacom-blog/article-feed/article-feed.js | 15 +++++++--- blog-migration.js | 9 ++++-- .../bacom-blog/article-feed/mocks/output.json | 29 ++++++++++++------- .../article-feed/mocks/outputUk.json | 29 ++++++++++++------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/bacom-blog/article-feed/article-feed.js b/bacom-blog/article-feed/article-feed.js index 04cb79d..65b6765 100644 --- a/bacom-blog/article-feed/article-feed.js +++ b/bacom-blog/article-feed/article-feed.js @@ -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, + }, + ], }, ], }, @@ -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, diff --git a/blog-migration.js b/blog-migration.js index 0d0df38..7b3a638 100644 --- a/blog-migration.js +++ b/blog-migration.js @@ -10,7 +10,8 @@ * governing permissions and limitations under the License. */ -import { writeFile, mkdir, access } from 'fs/promises'; +import { writeFile, 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'; @@ -90,8 +91,10 @@ async function createReport(reports, reportFile) { }); 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) { diff --git a/test/bacom-blog/article-feed/mocks/output.json b/test/bacom-blog/article-feed/mocks/output.json index c1a09e2..c96d7d7 100644 --- a/test/bacom-blog/article-feed/mocks/output.json +++ b/test/bacom-blog/article-feed/mocks/output.json @@ -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" + } ] + } + ] + } + ] } ] } @@ -127,4 +134,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/test/bacom-blog/article-feed/mocks/outputUk.json b/test/bacom-blog/article-feed/mocks/outputUk.json index 1e59e54..a62d67f 100644 --- a/test/bacom-blog/article-feed/mocks/outputUk.json +++ b/test/bacom-blog/article-feed/mocks/outputUk.json @@ -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" + } ] + } + ] + } + ] } ] } @@ -127,4 +134,4 @@ ] } ] -} \ No newline at end of file +} From 1ed2b5c2e5220a9041766cd0f291397ff9789757 Mon Sep 17 00:00:00 2001 From: Megan Thomas Date: Tue, 6 Feb 2024 11:07:51 -0800 Subject: [PATCH 2/2] update fs imports --- blog-migration.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/blog-migration.js b/blog-migration.js index 7b3a638..d4a6e95 100644 --- a/blog-migration.js +++ b/blog-migration.js @@ -10,7 +10,6 @@ * governing permissions and limitations under the License. */ -import { writeFile, access } from 'fs/promises'; import * as fs from 'fs'; import xlsx from 'xlsx'; import { getMdast, getTableMap } from './utils/mdast-utils.js'; @@ -275,7 +274,7 @@ async function handleMigration(markdown, entry, pageIndex, outputDir, entries) { async function ensureDocxFileExists(mdast, sourceDocxFile) { try { - await access(sourceDocxFile); + fs.accessSync(sourceDocxFile); } catch (e) { await saveDocx(mdast, sourceDocxFile); } @@ -323,11 +322,11 @@ export async function main(index = INDEX, source = SOURCE_CACHE, outputDir = OUT 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`);