chore: rename "part" to "step" (#43934)

* chore: rename part to step

* chore: update metas

* chore: more renaming

* chore: update tooling

* chore: update frontmatter

* chore(tools): title testing
This commit is contained in:
Nicholas Carrigan (he/him)
2021-10-21 10:07:52 -07:00
committed by GitHub
parent 6dbe68eb2f
commit b36cdbafd1
2194 changed files with 237701 additions and 237701 deletions

View File

@ -151,7 +151,7 @@ async function createMetaJson(
newMeta.order = order;
newMeta.superOrder = superBlocks.indexOf(superBlock) + 1;
newMeta.superBlock = superBlock;
newMeta.challengeOrder = [[challengeId, 'Part 1']];
newMeta.challengeOrder = [[challengeId, 'Step 1']];
const newMetaDir = path.resolve(metaDir, block);
if (!existsSync(newMetaDir)) {
await fs.mkdir(newMetaDir);

View File

@ -24,7 +24,7 @@ if (!allStepsExist(existingSteps, [start, end])) {
}
const challengeSeeds = getChallengeSeeds(
`${projectPath}part-${padWithLeadingZeros(start)}.md`
`${projectPath}step-${padWithLeadingZeros(start)}.md`
);
createStepFile({
stepNum: start,

View File

@ -22,7 +22,7 @@ if (!stepExists(existingSteps, num)) {
throw `Step # ${num} not deleted because it does not exist.`;
}
const stepFileToDelete = `${projectPath}part-${padWithLeadingZeros(num)}.md`;
const stepFileToDelete = `${projectPath}step-${padWithLeadingZeros(num)}.md`;
try {
fs.unlinkSync(stepFileToDelete);
console.log(`Sucessfully deleted step #${num}`);

View File

@ -2,8 +2,8 @@ const fs = require('fs');
const path = require('path');
// Generates an array with the output of processing filenames with an expected
// format (`part-###.md`).
// ['part-001.md', 'part-002.md'] => [1, 2]
// format (`step-###.md`).
// ['step-001.md', 'step-002.md'] => [1, 2]
function getExistingStepNums(projectPath) {
return fs.readdirSync(projectPath).reduce((stepNums, fileName) => {
if (

View File

@ -10,8 +10,8 @@ describe('getExistingStepNums helper', () => {
it('should return the number portion of the project paths', () => {
mock({
'mock-project': {
'part-001.md': 'Lorem ipsum...',
'part-002.md': 'Lorem ipsum...'
'step-001.md': 'Lorem ipsum...',
'step-002.md': 'Lorem ipsum...'
}
});
@ -26,7 +26,7 @@ describe('getExistingStepNums helper', () => {
mock({
'mock-project': {
'final.md': 'Lorem ipsum...',
'part-001.md': 'Lorem ipsum...'
'step-001.md': 'Lorem ipsum...'
}
});
@ -40,9 +40,9 @@ describe('getExistingStepNums helper', () => {
it('should throw if file names do not follow naming convention', () => {
mock({
'mock-project': {
'part-001.md': 'Lorem ipsum...',
'part-002.md': 'Lorem ipsum...',
'part002.md': 'Lorem ipsum...'
'step-001.md': 'Lorem ipsum...',
'step-002.md': 'Lorem ipsum...',
'step002.md': 'Lorem ipsum...'
}
});
@ -56,8 +56,8 @@ describe('getExistingStepNums helper', () => {
it('should return empty array if there are no markdown files', () => {
mock({
'mock-project': {
'part-001.js': 'Lorem ipsum...',
'part-002.css': 'Lorem ipsum...'
'step-001.js': 'Lorem ipsum...',
'step-002.css': 'Lorem ipsum...'
}
});

View File

@ -3,7 +3,7 @@ const path = require('path');
const { getChallengeSeeds } = require('../utils');
const { getProjectPath } = require('./get-project-path');
// Looks up the last file found with format `part-###.md` in a directory and
// Looks up the last file found with format `step-###.md` in a directory and
// returns associated information to it. At the same time validates that the
// number of files match the names used to name these.
function getLastStepFileContent() {

View File

@ -21,8 +21,8 @@ describe('getLastStepFileContent helper', () => {
it('should throw if last step count does not match with numbers of steps', () => {
mock({
'mock-project/': {
'part-001.md': 'Lorem ipsum...',
'part-004.md': 'Lorem ipsum...',
'step-001.md': 'Lorem ipsum...',
'step-004.md': 'Lorem ipsum...',
'final.md': 'Lorem ipsum...'
}
});
@ -37,8 +37,8 @@ describe('getLastStepFileContent helper', () => {
it('should return information if steps count is correct', () => {
mock({
'mock-project': {
'part-001.md': 'Lorem ipsum...',
'part-002.md': 'Lorem ipsum...',
'step-001.md': 'Lorem ipsum...',
'step-002.md': 'Lorem ipsum...',
'final.md': 'Lorem ipsum...'
}
});

View File

@ -58,9 +58,9 @@ function getStepTemplate({
return (
`---
id: ${challengeId}
title: Part ${stepNum}
title: Step ${stepNum}
challengeType: 0
dashedName: part-${stepNum}
dashedName: step-${stepNum}
---
# --description--

View File

@ -6,9 +6,9 @@ describe('getStepTemplate util', () => {
it('should be able to create a markdown', () => {
const baseOutput = `---
id: 60d4ebe4801158d1abe1b18f
title: Part 5
title: Step 5
challengeType: 0
dashedName: part-5
dashedName: step-5
---
# --description--

View File

@ -29,7 +29,7 @@ const createStepFile = ({
stepNum
});
fs.writeFileSync(`${projectPath}part-${finalStepNum}.md`, template);
fs.writeFileSync(`${projectPath}step-${finalStepNum}.md`, template);
return challengeId;
};
@ -69,7 +69,7 @@ const reorderSteps = () => {
const newStepNum = i + 1;
const newFileName =
fileName !== 'final.md'
? `part-${padWithLeadingZeros(newStepNum)}.md`
? `step-${padWithLeadingZeros(newStepNum)}.md`
: 'final.md';
return {
oldFileName: fileName,
@ -89,8 +89,8 @@ const reorderSteps = () => {
const frontMatter = matter.read(filePath);
const challengeID = frontMatter.data.id || ObjectID();
const title =
newFileName === 'final.md' ? 'Final Prototype' : `Part ${newStepNum}`;
const dashedName = `part-${newStepNum}`;
newFileName === 'final.md' ? 'Final Prototype' : `Step ${newStepNum}`;
const dashedName = `step-${newStepNum}`;
challengeOrder.push(['' + challengeID, title]);
const newData = {
...frontMatter.data,

View File

@ -57,8 +57,8 @@ describe('Challenge utils helper scripts', () => {
it('should create next step and return its identifier', () => {
mock({
'project/': {
'part-001.md': 'Lorem ipsum...',
'part-002.md': 'Lorem ipsum...'
'step-001.md': 'Lorem ipsum...',
'step-002.md': 'Lorem ipsum...'
}
});
@ -78,9 +78,9 @@ describe('Challenge utils helper scripts', () => {
const files = glob.sync(`project/*.md`);
expect(files).toEqual([
`project/part-001.md`,
`project/part-002.md`,
`project/part-003.md`
`project/step-001.md`,
`project/step-002.md`,
`project/step-003.md`
]);
mock.restore();
@ -94,9 +94,9 @@ describe('Challenge utils helper scripts', () => {
'meta.json': 'Lorem ipsum meta content...'
},
'project/': {
'part-001.md': 'Lorem ipsum 1...',
'part-002.md': 'Lorem ipsum 2...',
'part-002b.md': 'Lorem ipsum 3...'
'step-001.md': 'Lorem ipsum 1...',
'step-002.md': 'Lorem ipsum 2...',
'step-002b.md': 'Lorem ipsum 3...'
}
});
@ -106,9 +106,9 @@ describe('Challenge utils helper scripts', () => {
const files = glob.sync(`project/*.md`);
expect(files).toEqual([
'project/part-001.md',
'project/part-002.md',
'project/part-003.md'
'project/step-001.md',
'project/step-002.md',
'project/step-003.md'
]);
const result = fs.readFileSync('_meta/project/meta.json', 'utf8');
@ -118,15 +118,15 @@ describe('Challenge utils helper scripts', () => {
"challengeOrder": [
[
"60d35cf3fe32df2ce8e31b03",
"Part 1"
"Step 1"
],
[
"60d35cf3fe32df2ce8e31b03",
"Part 2"
"Step 2"
],
[
"60d35cf3fe32df2ce8e31b03",
"Part 3"
"Step 3"
]
]
}`;