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

Commit

Permalink
fix(parser): readme parser fixes (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
r4zendev authored Dec 21, 2023
1 parent 9910402 commit 63ac82d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion readme-parser/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ f_verified-codemod: true
f_author: cms/authors/intuita.md
layout: "[automations].html"
slug: msw-2-imports
title: Do the thing
title: msw V2 - Do the thing
f_slug-name: msw-2-imports
f_codemod-engine: cms/codemod-engines/ts-morph.md
f_change-mode-2: Assistive
Expand Down
18 changes: 15 additions & 3 deletions readme-parser/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,13 @@ export const convertToYaml = (

let slug: string | null = null;
let framework: string | null = null;
let frameworkVersion: string | null = null;
let cliCommand: string | null = null;
let cleanPath: string | null = null;
let codemodName: string | null = null;
if (path) {
cleanPath = path.split('/').slice(0, -1).join('/');
const splitPath = path.split('/');
cleanPath = splitPath.slice(0, -1).join('/');

const parts = __dirname.split('/');
const pivot = parts.indexOf('readme-parser');
Expand All @@ -376,7 +378,8 @@ export const convertToYaml = (
cleanPath,
);

framework = path.split('/').at(1) ?? null;
framework = splitPath.at(1) ?? null;
frameworkVersion = splitPath.at(2) ?? null;

try {
const config = readFileSync(
Expand All @@ -401,6 +404,15 @@ export const convertToYaml = (
.digest('base64url');
}

let titleWithVersion = title;
if (framework) {
if (frameworkVersion) {
titleWithVersion = `${framework} V${frameworkVersion} - ${title}`;
} else {
titleWithVersion = `${framework} - ${title}`;
}
}

const res = `
created-on: ${new Date().toISOString()}
f_long-description: >-
Expand Down Expand Up @@ -431,7 +443,7 @@ f_author: ${
}
layout: "[automations].html"
slug: ${slug ?? 'n/a'}
title: ${title}
title: ${titleWithVersion}
f_slug-name: ${slug ?? 'n/a'}
f_codemod-engine: cms/codemod-engines/${engine}.md
f_change-mode-2: ${capitalize(changeMode)}
Expand Down
2 changes: 1 addition & 1 deletion readme-parser/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const sync = async () => {
}

try {
oldFile = await git.catFile(['-p', `origin/main:${path}`]);
oldFile = await git.catFile(['-p', `HEAD~1:${path}`]);
} catch (err) {
oldFile = null;
}
Expand Down

0 comments on commit 63ac82d

Please sign in to comment.