Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tests for build post list script #3284

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
7ae14bd
fefewg
vishvamsinh28 Oct 22, 2024
d1cb179
added logs for debugging
vishvamsinh28 Oct 22, 2024
e5d6aab
Merge branch 'master' into buildPostTest
anshgoyalevil Oct 26, 2024
cc57d88
Merge branch 'master' into buildPostTest
anshgoyalevil Oct 31, 2024
fbcd76b
lint fix
anshgoyalevil Oct 31, 2024
17dedfe
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 4, 2024
23a5c98
feqf
vishvamsinh28 Nov 4, 2024
ec110dc
feqfeq
vishvamsinh28 Nov 4, 2024
b653ecf
ffqef
vishvamsinh28 Nov 4, 2024
accec3e
path update
vishvamsinh28 Nov 4, 2024
bb4ffe0
path update
vishvamsinh28 Nov 4, 2024
c24eb8e
logs added
vishvamsinh28 Nov 4, 2024
63edd8d
fwf
vishvamsinh28 Nov 4, 2024
b87b00d
logs added
vishvamsinh28 Nov 4, 2024
0f15784
posix
vishvamsinh28 Nov 4, 2024
8f26f50
fwqfqw
vishvamsinh28 Nov 4, 2024
10453f4
path chanegs
vishvamsinh28 Nov 4, 2024
323cdc5
fqwefe
vishvamsinh28 Nov 5, 2024
bb2d6b6
used fs extra
vishvamsinh28 Nov 5, 2024
cf53980
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 8, 2024
abfea38
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 9, 2024
a9c95d9
path fix
vishvamsinh28 Nov 9, 2024
a3a8dca
qwfeg
vishvamsinh28 Nov 9, 2024
70a0cd1
remove logs
vishvamsinh28 Nov 9, 2024
1383ea6
apply coderabbit suggetions
vishvamsinh28 Nov 9, 2024
fd129fe
fge
vishvamsinh28 Nov 9, 2024
e63203f
update tests
vishvamsinh28 Nov 9, 2024
b7e8c77
tests updated
vishvamsinh28 Nov 9, 2024
4d7b5a0
fef
vishvamsinh28 Nov 9, 2024
fa51639
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 10, 2024
09b530d
updated details.slug
vishvamsinh28 Nov 10, 2024
69ca91a
quick fix
vishvamsinh28 Nov 10, 2024
b935133
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 11, 2024
0c420ef
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 13, 2024
4615938
nkn
vishvamsinh28 Nov 13, 2024
281a8c8
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 15, 2024
5ba7c2d
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 22, 2024
a1e6a45
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 23, 2024
f7cf1b6
applied suggested changes
vishvamsinh28 Nov 23, 2024
a0fe58d
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 28, 2024
dc0998f
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 29, 2024
5357992
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 29, 2024
3c6618d
Merge branch 'master' into buildPostTest
vishvamsinh28 Nov 30, 2024
cf9920e
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 2, 2024
e2868d9
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 4, 2024
49722d0
apply nitpick
vishvamsinh28 Dec 4, 2024
ba08b4c
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 5, 2024
e0ac1e1
Merge branch 'master' into buildPostTest
akshatnema Dec 7, 2024
dc7e215
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 8, 2024
f8e7dfd
format code
vishvamsinh28 Dec 8, 2024
bb4da1d
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 9, 2024
45adee8
added helper function for setup
vishvamsinh28 Dec 9, 2024
d175e5c
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 9, 2024
98231ea
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 10, 2024
4893712
apply coderabbit suggestions
vishvamsinh28 Dec 10, 2024
10d1b72
apply coderabbit suggestion
vishvamsinh28 Dec 10, 2024
4a38f98
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 12, 2024
80b04b1
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 13, 2024
8b004d2
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 14, 2024
524a23c
Merge branch 'master' into buildPostTest
akshatnema Dec 14, 2024
5bed511
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 14, 2024
89f7fbc
apply nitpicks
vishvamsinh28 Dec 14, 2024
ccc22cb
apply nitpicks
vishvamsinh28 Dec 14, 2024
c951b91
apply nitpick 2
vishvamsinh28 Dec 14, 2024
8ffb9b9
apply nitpicks 3
vishvamsinh28 Dec 14, 2024
19f7c4f
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 16, 2024
96f821b
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 16, 2024
893ac66
apply nitpicks
vishvamsinh28 Dec 16, 2024
069128a
apply nitpicks 2
vishvamsinh28 Dec 16, 2024
778b257
apply nitpicks 3
vishvamsinh28 Dec 16, 2024
a4403bd
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 17, 2024
fcff3ed
apply nitpicks
vishvamsinh28 Dec 17, 2024
48010df
apply nitpicks again
vishvamsinh28 Dec 17, 2024
440670c
apply nitpicks
vishvamsinh28 Dec 17, 2024
b47cb4b
apply nitpicks once again
vishvamsinh28 Dec 17, 2024
5d01e26
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 18, 2024
eb0e387
apply nitpicks
vishvamsinh28 Dec 18, 2024
a795ce0
apply nitpicks
vishvamsinh28 Dec 18, 2024
8f00a15
apply actionable commet
vishvamsinh28 Dec 18, 2024
3de7141
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 19, 2024
dba34ee
Merge branch 'master' into buildPostTest
vishvamsinh28 Dec 20, 2024
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
Prev Previous commit
Next Next commit
apply nitpicks
  • Loading branch information
vishvamsinh28 committed Dec 18, 2024
commit a795ce0cf7221628d74bc195278f9a4b8109fab7
24 changes: 14 additions & 10 deletions scripts/build-post-list.js
Original file line number Diff line number Diff line change
@@ -16,12 +16,15 @@ const result = {
const releaseNotes = []

const addItem = (details) => {
if (details.slug.startsWith('/docs'))
result.docs.push(details)
else if (details.slug.startsWith('/blog'))
result.blog.push(details)
else if (details.slug.startsWith('/about'))
result.about.push(details)
const sectionMap = {
'/docs': 'docs',
'/blog': 'blog',
'/about': 'about'
};
const section = Object.keys(sectionMap).find(key => details.slug.startsWith(key));
if (section) {
result[sectionMap[section]].push(details);
}
};

function getVersionDetails(slug) {
@@ -47,14 +50,15 @@ async function buildPostList(postDirectories, basePath, writeFilePath) {
try {

if (!basePath) {
throw new Error('Error while building post list: basePath is required. Please provide a valid base path for resolving relative paths.');
throw new Error('Error while building post list: basePath is required');
}

if (!writeFilePath) {
throw new Error('Error while building post list: writeFilePath is required. Please provide a valid path where the output JSON will be written.');
throw new Error('Error while building post list: writeFilePath is required');
}

if (postDirectories.length === 0) {
throw new Error('Error while building post list: No post directories provided. Please provide an array of [directory, slug] tuples.');
throw new Error('Error while building post list: postDirectories array is empty');
}
const normalizedBasePath = normalize(basePath)
await walkDirectories(postDirectories, result, normalizedBasePath)
@@ -85,7 +89,7 @@ async function walkDirectories(
let details;
const fileName = normalize(join(directory, file));
const fileNameWithSection = normalize(join(fileName, '_section.mdx'))
const slug = '/' + normalize(relative(basePath, fileName)).replace(/\\/g, '/')
const slug = `/${normalize(relative(basePath, fileName)).replace(/\\/g, '/')}`
const slugElements = slug.split('/')

if (await isDirectory(fileName)) {
Loading