mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-01-17 14:18:17 +01:00
Automate the title creation in new roadmap content
This commit is contained in:
parent
907f820778
commit
66bdbd7458
81
bin/roadmap-content.cjs
Normal file
81
bin/roadmap-content.cjs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const OPEN_AI_API_KEY = process.env.OPEN_AI_API_KEY;
|
||||||
|
const ALL_ROADMAPS_DIR = path.join(__dirname, '../src/data/roadmaps');
|
||||||
|
const ROADMAP_JSON_DIR = path.join(__dirname, '../public/jsons/roadmaps');
|
||||||
|
|
||||||
|
const roadmapId = process.argv[2];
|
||||||
|
|
||||||
|
const allowedRoadmapIds = fs.readdirSync(ALL_ROADMAPS_DIR);
|
||||||
|
if (!roadmapId) {
|
||||||
|
console.error('roadmapId is required');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allowedRoadmapIds.includes(roadmapId)) {
|
||||||
|
console.error(`Invalid roadmap key ${roadmapId}`);
|
||||||
|
console.error(`Allowed keys are ${allowedRoadmapIds.join(', ')}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ROADMAP_CONTENT_DIR = path.join(ALL_ROADMAPS_DIR, roadmapId, 'content');
|
||||||
|
|
||||||
|
function getFilesInFolder(folderPath, fileList = {}) {
|
||||||
|
const files = fs.readdirSync(folderPath);
|
||||||
|
|
||||||
|
files.forEach((file) => {
|
||||||
|
const filePath = path.join(folderPath, file);
|
||||||
|
const stats = fs.statSync(filePath);
|
||||||
|
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
getFilesInFolder(filePath, fileList);
|
||||||
|
} else if (stats.isFile()) {
|
||||||
|
const fileUrl = filePath
|
||||||
|
.replace(ROADMAP_CONTENT_DIR, '') // Remove the content folder
|
||||||
|
.replace(/\/\d+-/g, '/') // Remove ordering info `/101-ecosystem`
|
||||||
|
.replace(/\/index\.md$/, '') // Make the `/index.md` to become the parent folder only
|
||||||
|
.replace(/\.md$/, ''); // Remove `.md` from the end of file
|
||||||
|
|
||||||
|
fileList[fileUrl] = filePath;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return fileList;
|
||||||
|
}
|
||||||
|
|
||||||
|
const topicUrlToPathMapping = getFilesInFolder(ROADMAP_CONTENT_DIR);
|
||||||
|
|
||||||
|
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')
|
||||||
|
);
|
||||||
|
|
||||||
|
groups.forEach((group) => {
|
||||||
|
const topicId = group?.properties?.controlName;
|
||||||
|
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];
|
||||||
|
|
||||||
|
const currentFileContent = fs.readFileSync(contentFilePath, 'utf8');
|
||||||
|
const isFileEmpty = currentFileContent.replace(/^#.+/, ``).trim() == '';
|
||||||
|
|
||||||
|
if (!isFileEmpty) {
|
||||||
|
console.log(`${topicId} not empty. Ignoring...`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let newFileContent = `# ${topicTitle}`;
|
||||||
|
|
||||||
|
if (!OPEN_AI_API_KEY) {
|
||||||
|
console.log(`OPEN_AI_API_KEY not set. Only adding title to ${topicId}..`);
|
||||||
|
fs.writeFileSync(contentFilePath, newFileContent, 'utf8');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(currentFileContent);
|
||||||
|
// console.log(currTopicUrl);
|
||||||
|
// console.log(topicTitle);
|
||||||
|
// console.log(topicUrlToPathMapping[currTopicUrl]);
|
||||||
|
});
|
@ -14,6 +14,7 @@
|
|||||||
"upgrade": "ncu -u",
|
"upgrade": "ncu -u",
|
||||||
"roadmap-links": "node bin/roadmap-links.cjs",
|
"roadmap-links": "node bin/roadmap-links.cjs",
|
||||||
"roadmap-dirs": "node bin/roadmap-dirs.cjs",
|
"roadmap-dirs": "node bin/roadmap-dirs.cjs",
|
||||||
|
"roadmap-content": "node bin/roadmap-content.cjs",
|
||||||
"best-practice-dirs": "node bin/best-practice-dirs.cjs",
|
"best-practice-dirs": "node bin/best-practice-dirs.cjs",
|
||||||
"test:e2e": "playwright test"
|
"test:e2e": "playwright test"
|
||||||
},
|
},
|
||||||
|
@ -1 +1 @@
|
|||||||
# Help user think about their action
|
# Help User think about Their Action
|
@ -1 +1 @@
|
|||||||
# Educate and encourage user
|
# Educate and Encourage User
|
@ -1 +1 @@
|
|||||||
# Changing user behavior
|
# Support Conscious Action
|
@ -1 +1 @@
|
|||||||
# Make it incidental
|
# Make it Incidental
|
@ -1 +1 @@
|
|||||||
# Automate act of repition
|
# Automate the Act of Repetition
|
@ -1 +1 @@
|
|||||||
# Help user avoiding the cue
|
# Help User Avoiding the Cue
|
@ -1 +1 @@
|
|||||||
# Replace the routine
|
# Replace the Routine
|
@ -1 +1 @@
|
|||||||
# Use consciousness to interfere
|
# Use Consciousness to Interfere
|
@ -1 +1 @@
|
|||||||
# Mindfulness to avoid acting on the cue
|
# Mindfulness to Avoid Acting on the Cue
|
@ -1 +1 @@
|
|||||||
# Crowd out old habit with new behavior
|
# Crowd Out Old Habit with New Behavior
|
@ -1 +1 @@
|
|||||||
# Make or change habbits
|
# Make or Change Habbits
|
@ -1 +1 @@
|
|||||||
# BJ Fogg's Behavior Model
|
# BJ Fogg’s Behavior Grid
|
@ -1 +1 @@
|
|||||||
# Nir eyal hook model
|
# Nir Eyal’s Hook Model
|
@ -1 +1 @@
|
|||||||
# Cue routine reward model
|
# Cue Routine Reward Model
|
@ -1 +1 @@
|
|||||||
# Target outcome
|
# Target Outcome
|
@ -1 +1 @@
|
|||||||
# Target actor
|
# Target Actor
|
@ -1 +1 @@
|
|||||||
# Target action
|
# Target Action
|
@ -1 +1 @@
|
|||||||
# Create user personas
|
# Create User Personas
|
@ -1 +1 @@
|
|||||||
# Business model canvas
|
# Business Model Canvas
|
@ -1 +1 @@
|
|||||||
# Lean canvas
|
# Lean Canvas
|
@ -1 +1 @@
|
|||||||
# Understand the product
|
# Understanding the Product
|
@ -1 +1 @@
|
|||||||
# Business model inspirator
|
# Business Model Inspirator
|
@ -1 +1 @@
|
|||||||
# Competitor analysis
|
# Competitor Analysis
|
@ -1 +1 @@
|
|||||||
# Five forces model
|
# Five Forces Model
|
@ -1 +1 @@
|
|||||||
# Swot analysis
|
# SWOT Analysis
|
@ -1 +1 @@
|
|||||||
# User stories
|
# User Stories
|
@ -1 +1 @@
|
|||||||
# Custom experience map
|
# Customer Experience Map by Mel Edwards
|
@ -1 +1 @@
|
|||||||
# Simple flowchart
|
# Simple Flowchart
|
@ -1 +1 @@
|
|||||||
# Event driven process chain model
|
# Event-Driven Process Chain Model (EPC)
|
@ -1 +1 @@
|
|||||||
# Business process model and notation
|
# Business Process Model and Notation (BPMN)
|
@ -1 +1 @@
|
|||||||
# Conceptual design
|
# Conceptual Design
|
@ -1 +1 @@
|
|||||||
# Keep it short simple
|
# In general, Keep it Short and Simple
|
@ -1 +1 @@
|
|||||||
# Make it easy
|
# Make it Easy to Understand, Easy to Complete
|
@ -1 +1 @@
|
|||||||
# Make progress visible
|
# Make Progress Visible to User
|
@ -1 +1 @@
|
|||||||
# Make progress meaningful reward user
|
# Make Progress Meaningful in order to Reward User
|
@ -1 +1 @@
|
|||||||
# Make successful completion clearly visible
|
# Make Successful Completion Clearly Visible
|
@ -1 +1 @@
|
|||||||
# Good layout rules
|
# Good Layout Rules
|
@ -1 +1 @@
|
|||||||
# Prototyping
|
# ProtoTyping
|
@ -1 +1 @@
|
|||||||
# Call to action
|
# Call to Action
|
@ -1 +1 @@
|
|||||||
# Status reports
|
# Status Reports
|
@ -1 +1 @@
|
|||||||
# How to tips
|
# How-to-Tips
|
@ -1 +1 @@
|
|||||||
# Reminders planning prompts
|
# Simple Reminders and Planning Prompts
|
@ -1 +1 @@
|
|||||||
# Decision making support
|
# Decision-Making Support
|
@ -1 +1 @@
|
|||||||
# Behavior change games
|
# Behavior Change Games
|
@ -1 +1 @@
|
|||||||
# Social sharing
|
# Social Sharing
|
@ -1 +1 @@
|
|||||||
# Goal trackers
|
# Goal Trackers
|
@ -1 +1 @@
|
|||||||
# Adobe xd
|
# Adobe XD
|
@ -1 +1 @@
|
|||||||
# Avoid temporal myopia
|
# Frame Text to Avoid Temporal Myopia
|
@ -1 +1 @@
|
|||||||
# Remind of prior commitment to act
|
# Remind of Prior Commitment to Act
|
@ -1 +1 @@
|
|||||||
# Make commitment to friends
|
# Make Commitment to Friends
|
@ -1 +1 @@
|
|||||||
# Make reward scarce
|
# Make Reward Scarce
|
@ -1 +1 @@
|
|||||||
# Tell user and ask
|
# Tell User What the Action is and Ask for it
|
@ -1 +1 @@
|
|||||||
# Make it clear where to act
|
# Make it Clear, Where to Act
|
@ -1 +1 @@
|
|||||||
# Clear the page of distractions
|
# Clear the Page of Distractions
|
@ -1 +1 @@
|
|||||||
# Prime user relevant associations
|
# Prime User-Relevant Associations
|
@ -1 +1 @@
|
|||||||
# Leverage loss aversion
|
# Leverage Loss Aversion
|
@ -1 +1 @@
|
|||||||
# Use peer comparisons
|
# Use Peer Comparisons
|
@ -1 +1 @@
|
|||||||
# Use competition
|
# Use Competition
|
@ -1 +1 @@
|
|||||||
# Avoid cognitive overhead
|
# Avoid Cognitive Overhead
|
@ -1 +1 @@
|
|||||||
# Avoid choice overload
|
# Avoid Choice Overload
|
@ -1 +1 @@
|
|||||||
# Avoid direct payments
|
# Avoid Direct Payments
|
@ -1 +1 @@
|
|||||||
# Ux best practices
|
# UX Best Practices
|
@ -1 +1 @@
|
|||||||
# Elicit implementation intentions
|
# Elicit Implementation Intentions
|
@ -1 +1 @@
|
|||||||
# Default everything
|
# Default Everything
|
@ -1 +1 @@
|
|||||||
# Lessen the burden of action info
|
# Lessen the Burden of Action/Info.
|
@ -1 +1 @@
|
|||||||
# Deploy peer comparisons
|
# Deploy Peer Comparisons
|
@ -1 +1 @@
|
|||||||
# Make ui professional and beautiful
|
# Make UI Professional and Beautiful
|
@ -1 +1 @@
|
|||||||
# Deploy social proof
|
# Deploy Social Proof
|
@ -1 +1 @@
|
|||||||
# Deploy strong subject authority
|
# Deploy Strong Authority on Subject
|
@ -1 +1 @@
|
|||||||
# Be authentic and personal
|
# Be Authentic and Personal
|
@ -1 +1 @@
|
|||||||
# Gather lessons prioritize integrate
|
# Gather Lessons Learned,
|
@ -1 +1 @@
|
|||||||
# Measuring the impact
|
# Measuring the Impact
|
@ -1 +1 @@
|
|||||||
# Incremental ab testing
|
# Incremental A/B Testing
|
@ -1 +1 @@
|
|||||||
# Multivariate testing
|
# Multivariate Testing
|
Loading…
x
Reference in New Issue
Block a user