Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranahmedse committed Mar 30, 2023
1 parent d081ecf commit 7434ff7
Show file tree
Hide file tree
Showing 2,129 changed files with 10,502 additions and 7,966 deletions.
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app-dist
dist
.idea
.github
public
node_modules
pnpm-lock.yaml
2 changes: 1 addition & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineConfig({
'https://github.com/kamranahmedse',
'https://thenewstack.io',
'https://cs.fyi',
'https://roadmap.sh'
'https://roadmap.sh',
];

if (whiteListedStarts.some((start) => href.startsWith(start))) {
Expand Down
33 changes: 22 additions & 11 deletions bin/best-practice-dirs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const path = require('path');

const CONTENT_DIR = path.join(__dirname, '../content');
// Directory containing the best-practices
const BEST_PRACTICE_CONTENT_DIR = path.join(__dirname, '../src/data/best-practices');
const BEST_PRACTICE_CONTENT_DIR = path.join(
__dirname,
'../src/data/best-practices'
);
const bestPracticeId = process.argv[2];

const allowedBestPracticeId = fs.readdirSync(BEST_PRACTICE_CONTENT_DIR);
Expand All @@ -28,7 +31,10 @@ if (!bestPracticeDirName) {
process.exit(1);
}

const bestPracticeDirPath = path.join(BEST_PRACTICE_CONTENT_DIR, bestPracticeDirName);
const bestPracticeDirPath = path.join(
BEST_PRACTICE_CONTENT_DIR,
bestPracticeDirName
);
const bestPracticeContentDirPath = path.join(
BEST_PRACTICE_CONTENT_DIR,
bestPracticeDirName,
Expand All @@ -37,7 +43,9 @@ const bestPracticeContentDirPath = path.join(

// If best practice content already exists do not proceed as it would override the files
if (fs.existsSync(bestPracticeContentDirPath)) {
console.error(`Best Practice content already exists @ ${bestPracticeContentDirPath}`);
console.error(
`Best Practice content already exists @ ${bestPracticeContentDirPath}`
);
process.exit(1);
}

Expand All @@ -51,7 +59,11 @@ function prepareDirTree(control, dirTree) {
const controlName = control?.properties?.controlName || '';

// No directory for a group without control name
if (!controlName || controlName.startsWith('check:') || controlName.startsWith('ext_link:')) {
if (
!controlName ||
controlName.startsWith('check:') ||
controlName.startsWith('ext_link:')
) {
return;
}

Expand All @@ -76,7 +88,10 @@ function prepareDirTree(control, dirTree) {
return { dirTree };
}

const bestPractice = require(path.join(__dirname, `../public/jsons/best-practices/${bestPracticeId}`));
const bestPractice = require(path.join(
__dirname,
`../public/jsons/best-practices/${bestPracticeId}`
));
const controls = bestPractice.mockup.controls.control;

// Prepare the dir tree that we will be creating
Expand Down Expand Up @@ -129,16 +144,12 @@ function createDirTree(parentDir, dirTree, filePaths = {}) {
// For each of the directory names, create a
// directory inside the given directory
childrenDirNames.forEach((dirName) => {
createDirTree(
path.join(parentDir, dirName),
dirTree[dirName],
filePaths
);
createDirTree(path.join(parentDir, dirName), dirTree[dirName], filePaths);
});

return filePaths;
}

// Create directories and get back the paths for created directories
createDirTree(bestPracticeContentDirPath, dirTree);
console.log('Created best practice content directory structure');
console.log('Created best practice content directory structure');
3 changes: 1 addition & 2 deletions bin/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## CLI Tools

> A bunch of CLI scripts to make the development easier
## `roadmap-links.cjs`
Expand Down Expand Up @@ -34,5 +35,3 @@ For the content skeleton to be generated, we should have proper grouping, and th
- Assign the name to the groups.
- Group names have the format of `[sort]-[slug]` e.g. `100-internet`. Each group name should start with a number starting from 100 which helps with sorting of the directories and the files. Groups at the same level have the sequential sorting information.
- Each groups children have a separate group and have the name similar to `[sort]-[parent-slug]:[child-slug]` where sort refers to the sorting of the `child-slug` and not the parent. Also parent-slug does not need to have the sorting information as a part of slug e.g. if parent was `100-internet` the children would be `100-internet:how-does-the-internet-work`, `101-internet:what-is-http`, `102-internet:browsers`.


9 changes: 6 additions & 3 deletions bin/roadmap-content.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ async function run() {

const roadmapJson = require(path.join(ROADMAP_JSON_DIR, `${roadmapId}.json`));
const groups = roadmapJson?.mockup?.controls?.control?.filter(
(control) => control.typeID === '__group__' && !control.properties?.controlName?.startsWith('ext_link')
(control) =>
control.typeID === '__group__' &&
!control.properties?.controlName?.startsWith('ext_link')
);

if (!OPEN_AI_API_KEY) {
Expand All @@ -106,8 +108,9 @@ async function run() {

for (let group of groups) {
const topicId = group?.properties?.controlName;
const topicTitle = group?.children?.controls?.control?.find((control) => control?.typeID === 'Label')?.properties
?.text;
const topicTitle = group?.children?.controls?.control?.find(
(control) => control?.typeID === 'Label'
)?.properties?.text;
const currTopicUrl = topicId.replace(/^\d+-/g, '/').replace(/:/g, '/');
const contentFilePath = topicUrlToPathMapping[currTopicUrl];

Expand Down
5 changes: 4 additions & 1 deletion bin/roadmap-dirs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ function prepareDirTree(control, dirTree, dirSortOrders) {
return { dirTree, dirSortOrders };
}

const roadmap = require(path.join(__dirname, `../public/jsons/roadmaps/${roadmapId}`));
const roadmap = require(path.join(
__dirname,
`../public/jsons/roadmaps/${roadmapId}`
));
const controls = roadmap.mockup.controls.control;

// Prepare the dir tree that we will be creating and also calculate the sort orders
Expand Down
27 changes: 21 additions & 6 deletions bin/update-sponsors.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,24 @@ function populatePageAds({
const isConfiguredActive = isActive.toLowerCase() === 'yes';

const currentDate = new Date();
const isDateInRange = currentDate >= new Date(startDate) && currentDate <= new Date(endDate);
const isDateInRange =
currentDate >= new Date(startDate) && currentDate <= new Date(endDate);
const shouldShowAd = isConfiguredActive && isDateInRange;

const urlPart = pageUrl.replace('https://roadmap.sh/', '').replace(/\?.+?$/, '');
const urlPart = pageUrl
.replace('https://roadmap.sh/', '')
.replace(/\?.+?$/, '');

const parentDir = urlPart.startsWith('best-practices/') ? 'best-practices' : 'roadmaps';
const parentDir = urlPart.startsWith('best-practices/')
? 'best-practices'
: 'roadmaps';
const pageId = urlPart.replace(`${parentDir}/`, '');

const pageFilePath = path.join(__dirname, `../src/data/${parentDir}`, `${pageId}/${pageId}.md`);
const pageFilePath = path.join(
__dirname,
`../src/data/${parentDir}`,
`${pageId}/${pageId}.md`
);

if (!fs.existsSync(pageFilePath)) {
console.error(`Page file not found: ${pageFilePath}`);
Expand All @@ -48,7 +57,9 @@ function populatePageAds({
const frontMatterRegex = /---\n([\s\S]*?)\n---/;

const existingFrontmatter = pageFileContent.match(frontMatterRegex)[1];
const contentWithoutFrontmatter = pageFileContent.replace(frontMatterRegex, ``).trim();
const contentWithoutFrontmatter = pageFileContent
.replace(frontMatterRegex, ``)
.trim();

let frontmatterObj = yaml.load(existingFrontmatter);
delete frontmatterObj.sponsor;
Expand Down Expand Up @@ -77,7 +88,11 @@ function populatePageAds({
frontmatterObj = Object.fromEntries(frontmatterValues);
}

const newFrontmatter = yaml.dump(frontmatterObj, { lineWidth: 10000, forceQuotes: true, quotingType: '"' });
const newFrontmatter = yaml.dump(frontmatterObj, {
lineWidth: 10000,
forceQuotes: true,
quotingType: '"',
});
const newContent = `---\n${newFrontmatter}---\n\n${contentWithoutFrontmatter}`;

fs.writeFileSync(pageFilePath, newContent, 'utf8');
Expand Down
20 changes: 10 additions & 10 deletions code_of_conduct.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"format": "prettier --write .",
"astro": "astro",
"deploy": "NODE_DEBUG=gh-pages gh-pages -d dist -t",
"compress:jsons": "node bin/compress-jsons.cjs",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const config: PlaywrightTestConfig = {
/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run dev',
url: "http://localhost:3000",
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
};
Expand Down
Loading

0 comments on commit 7434ff7

Please sign in to comment.