mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-31 13:01:43 +02:00
Add roadmap migrator command
This commit is contained in:
1
bin/developer-roadmap
Submodule
1
bin/developer-roadmap
Submodule
Submodule bin/developer-roadmap added at e0685ea2ea
116
bin/roadmap-metas.cjs
Normal file
116
bin/roadmap-metas.cjs
Normal file
@@ -0,0 +1,116 @@
|
||||
module.exports = {
|
||||
angular: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2277.8,
|
||||
},
|
||||
},
|
||||
'aspnet-core': {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2773.45,
|
||||
},
|
||||
},
|
||||
backend: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2840.4,
|
||||
},
|
||||
},
|
||||
blockchain: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2173.87,
|
||||
},
|
||||
},
|
||||
'computer-science': {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 3009.05,
|
||||
},
|
||||
},
|
||||
'design-system': {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2309.7,
|
||||
},
|
||||
},
|
||||
devops: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2527.46,
|
||||
},
|
||||
},
|
||||
flutter: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2042.2,
|
||||
},
|
||||
},
|
||||
frontend: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2734.48,
|
||||
},
|
||||
},
|
||||
golang: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 1495.21,
|
||||
},
|
||||
},
|
||||
java: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 1167.29,
|
||||
},
|
||||
},
|
||||
javascript: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2438.9,
|
||||
},
|
||||
},
|
||||
nodejs: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2474.06,
|
||||
},
|
||||
},
|
||||
python: {
|
||||
dimensions: {
|
||||
width: 992,
|
||||
height: 1259.03,
|
||||
},
|
||||
},
|
||||
qa: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2107.75,
|
||||
},
|
||||
},
|
||||
react: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 2570.26,
|
||||
},
|
||||
},
|
||||
'software-architect': {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 1882.18,
|
||||
},
|
||||
},
|
||||
'software-design-architecture': {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 1764.66,
|
||||
},
|
||||
},
|
||||
vue: {
|
||||
dimensions: {
|
||||
width: 968,
|
||||
height: 1657.07,
|
||||
},
|
||||
},
|
||||
};
|
132
bin/roadmap-migrator.cjs
Normal file
132
bin/roadmap-migrator.cjs
Normal file
@@ -0,0 +1,132 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const yaml = require('json-to-pretty-yaml');
|
||||
const roadmapMetas = require('./roadmap-metas.cjs');
|
||||
|
||||
const oldAssetsPath = path.join(__dirname, 'developer-roadmap/public');
|
||||
const newAssetsPath = path.join(__dirname, '../public/');
|
||||
|
||||
// Create JSONs dir
|
||||
const newJsonsPath = path.join(newAssetsPath, 'jsons');
|
||||
if (fs.existsSync(newJsonsPath)) {
|
||||
fs.rmSync(newJsonsPath, { recursive: true });
|
||||
}
|
||||
|
||||
fs.mkdirSync(newJsonsPath);
|
||||
|
||||
// Create PDFs dir
|
||||
const newPdfsPath = path.join(newAssetsPath, 'pdfs');
|
||||
if (fs.existsSync(newPdfsPath)) {
|
||||
fs.rmSync(newPdfsPath, { recursive: true });
|
||||
}
|
||||
|
||||
fs.mkdirSync(newPdfsPath);
|
||||
|
||||
const oldRoadmapsDirPath = path.join(__dirname, 'developer-roadmap/content/roadmaps');
|
||||
const newRoadmapsDirPath = path.join(__dirname, '../src/roadmaps');
|
||||
|
||||
if (fs.existsSync(newRoadmapsDirPath)) {
|
||||
fs.rmSync(newRoadmapsDirPath, { recursive: true });
|
||||
}
|
||||
|
||||
fs.mkdirSync(newRoadmapsDirPath);
|
||||
|
||||
const oldRoadmaps = fs
|
||||
.readdirSync(oldRoadmapsDirPath)
|
||||
.map((roadmapDirName) => path.join(oldRoadmapsDirPath, roadmapDirName));
|
||||
|
||||
const orderInfo = {};
|
||||
const typeCounter = {
|
||||
role: 1,
|
||||
tool: 1,
|
||||
};
|
||||
|
||||
// Calculate the sorting information for the roadmaps
|
||||
oldRoadmaps.forEach((oldRoadmapPath) => {
|
||||
const roadmapId = path.basename(oldRoadmapPath).replace(/\d+-/g, '').toLowerCase();
|
||||
const oldRoadmapMeta = require(path.join(oldRoadmapPath, 'meta.json'));
|
||||
|
||||
orderInfo[roadmapId] = typeCounter[oldRoadmapMeta.type];
|
||||
typeCounter[oldRoadmapMeta.type] += 1;
|
||||
});
|
||||
|
||||
// Iterate and create new roadmaps
|
||||
oldRoadmaps.forEach((oldRoadmapPath) => {
|
||||
const roadmapId = path.basename(oldRoadmapPath).replace(/\d+-/g, '').toLowerCase();
|
||||
|
||||
const metaToMerge = roadmapMetas[roadmapId] ?? {};
|
||||
const oldRoadmapMeta = require(path.join(oldRoadmapPath, 'meta.json'));
|
||||
const isTextual = oldRoadmapMeta?.landingPath?.endsWith('.md');
|
||||
|
||||
const hasContentDir = fs.existsSync(path.join(oldRoadmapPath, 'content'));
|
||||
|
||||
const roadmapFileContent = isTextual
|
||||
? fs.readFileSync(path.join(oldRoadmapPath, oldRoadmapMeta.landingPath), 'utf8')
|
||||
: '';
|
||||
|
||||
const roadmapFileContentWithUpdatedUrls = roadmapFileContent
|
||||
.replace(/\[\!\[\]\((.+?\.png)\)\]\((.+?\.png)\)/g, '[](/assets$2)')
|
||||
.replace(/\[\!\[\]\((.+?\.svg)\)\]\((.+?\.svg)\)/g, '[](/assets$2)')
|
||||
.replace(/\[\!\[\]\((.+?\.svg)\)\]\((.+?\.png)\)/g, '[](/assets$2)')
|
||||
.replace(/assetshttp\//g, 'http')
|
||||
.replace(/assetshttps:\/\//g, 'https://')
|
||||
.replace(/\/http/g, 'http')
|
||||
.replace(/]\(\/roadmaps\/(.+?)\.png\)/g, '](/assets/roadmaps/$1.png)')
|
||||
.replace(/]\(\/roadmaps\/(.+?)\.svg\)/g, '](/assets/roadmaps/$1.svg)')
|
||||
.replace(/<iframe/g, '<iframe class="w-full aspect-video mb-5"')
|
||||
.replace(/<iframe(.+?)\s?\/>/g, '<iframe$1></iframe>');
|
||||
|
||||
const hasJson = fs.existsSync(path.join(newAssetsPath, `/${roadmapId}.json`));
|
||||
|
||||
const newRoadmapMeta = {
|
||||
...( hasJson ? { jsonUrl: `/jsons/${roadmapId}.json`} : {}),
|
||||
pdfUrl: `/pdfs/${roadmapId}.pdf`,
|
||||
order: orderInfo[roadmapId],
|
||||
featuredTitle:
|
||||
oldRoadmapMeta.featuredTitle === 'Software Design and Architecture'
|
||||
? 'Software Design'
|
||||
: oldRoadmapMeta.featuredTitle,
|
||||
featuredDescription: oldRoadmapMeta.featuredDescription,
|
||||
title: oldRoadmapMeta.title,
|
||||
description: oldRoadmapMeta.description,
|
||||
isNew: oldRoadmapMeta.isNew,
|
||||
hasTopics: hasContentDir,
|
||||
...metaToMerge,
|
||||
seo: oldRoadmapMeta.seo,
|
||||
relatedRoadmaps: oldRoadmapMeta.relatedRoadmaps,
|
||||
sitemap: {
|
||||
priority: 1,
|
||||
changefreq: 'monthly',
|
||||
},
|
||||
tags: ['roadmap', 'main-sitemap', `${oldRoadmapMeta.type === 'tool' ? 'skill' : oldRoadmapMeta.type}-roadmap`],
|
||||
};
|
||||
|
||||
const frontmatter = yaml.stringify(newRoadmapMeta);
|
||||
const newRoadmapDirPath = path.join(newRoadmapsDirPath, roadmapId);
|
||||
const newRoadmapFilePath = path.join(newRoadmapDirPath, `/${roadmapId}.md`);
|
||||
|
||||
fs.mkdirSync(newRoadmapDirPath);
|
||||
fs.writeFileSync(newRoadmapFilePath, `---\n${frontmatter}---\n\n${roadmapFileContentWithUpdatedUrls}`);
|
||||
|
||||
const jsonFile = path.join(oldAssetsPath, oldRoadmapMeta.jsonUrl || '/unknown');
|
||||
const pdfFile = path.join(oldAssetsPath, oldRoadmapMeta.pdfUrl || '/unknown');
|
||||
|
||||
if (fs.existsSync(jsonFile)) {
|
||||
fs.copyFileSync(jsonFile, path.join(newJsonsPath, `${roadmapId}.json`));
|
||||
}
|
||||
|
||||
if (fs.existsSync(pdfFile)) {
|
||||
fs.copyFileSync(pdfFile, path.join(newPdfsPath, `${roadmapId}.pdf`));
|
||||
}
|
||||
|
||||
// Copy the content directory
|
||||
const oldRoadmapContentDir = path.join(oldRoadmapPath, 'content');
|
||||
if (fs.existsSync(oldRoadmapContentDir)) {
|
||||
fs.cpSync(oldRoadmapContentDir, path.join(newRoadmapDirPath, 'content'), { recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
const roadmapAssets = path.join(oldAssetsPath, 'roadmaps');
|
||||
if (fs.existsSync(roadmapAssets)) {
|
||||
fs.cpSync(roadmapAssets, path.join(newAssetsPath, 'roadmaps'), { recursive: true });
|
||||
}
|
30
bin/sync-content.sh
Normal file
30
bin/sync-content.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Change working directory to the directory of this script
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
if [ ! -d "./developer-roadmap" ]; then
|
||||
git clone --depth 1 -b master git@github.com:kamranahmedse/developer-roadmap.git
|
||||
fi
|
||||
|
||||
echo "Removing old directories"
|
||||
rm -rf ../src/videos
|
||||
rm -rf ../src/guides
|
||||
rm -rf ../src/roadmaps
|
||||
|
||||
rm -rf ../public/jsons
|
||||
rm -rf ../public/pdfs
|
||||
|
||||
echo "=== Migrating Roadmaps ==="
|
||||
node roadmap-migrator.cjs
|
||||
|
||||
echo "=== Migrating Content ==="
|
||||
# node content-migrator.cjs
|
||||
|
||||
echo "=== Migrating Guides ==="
|
||||
# node guide-migrator.cjs
|
||||
|
||||
echo "=== Migrating Videos ==="
|
||||
# node video-migrator.cjs
|
Reference in New Issue
Block a user