fix(tools): update helper scripts (#41923)
This commit is contained in:
committed by
GitHub
parent
300ff756ce
commit
17a7a84b48
@ -35,7 +35,7 @@ A one-off script that automatically adds a new step between two existing consecu
|
||||
1. Change to the directory of the project.
|
||||
2. Run the following npm command:
|
||||
```bash
|
||||
npm run create-step-between start=X end=Y # where X is the starting step number and Y is the following step number.
|
||||
npm run create-step-between start=X # where X is the starting step number
|
||||
```
|
||||
|
||||
## [delete-step.js](delete-step.js)
|
||||
|
@ -22,8 +22,8 @@ if (!num) {
|
||||
num = parseInt(num, 10);
|
||||
const stepStart = parseInt(start, 10);
|
||||
|
||||
if (num < 1 || num > 20) {
|
||||
throw `No steps created. arg 'num' must be between 1 and 20 inclusive`;
|
||||
if (num < 1 || num > 100) {
|
||||
throw `No steps created. arg 'num' must be between 1 and 100 inclusive`;
|
||||
}
|
||||
|
||||
const maxStepNum = stepStart + num - 1;
|
||||
|
@ -14,25 +14,17 @@ const allStepsExist = (steps, stepsToFind) =>
|
||||
const projectPath = getProjectPath();
|
||||
const args = getArgValues(process.argv);
|
||||
|
||||
let { start, end } = args;
|
||||
start = parseInt(start, 10);
|
||||
end = parseInt(end, 10);
|
||||
const start = parseInt(args.start, 10);
|
||||
|
||||
if (
|
||||
!Number.isInteger(start) ||
|
||||
!Number.isInteger(end) ||
|
||||
start < 1 ||
|
||||
start !== end - 1
|
||||
) {
|
||||
throw (
|
||||
'Step not created. Steps specified must be' +
|
||||
' consecutive numbers and start step must be greater than 0.'
|
||||
);
|
||||
if (!Number.isInteger(start) || start < 1) {
|
||||
throw 'Step not created. Start step must be greater than 0.';
|
||||
}
|
||||
|
||||
const end = start + 1;
|
||||
|
||||
const existingSteps = getExistingStepNums(projectPath);
|
||||
if (!allStepsExist(existingSteps, [start, end])) {
|
||||
throw 'Step not created. At least one of the steps specified does not exist.';
|
||||
throw `Step not created. Both start step, ${start}, and end step, ${end}, must exist`;
|
||||
}
|
||||
|
||||
const challengeSeeds = getChallengeSeeds(
|
||||
|
@ -85,6 +85,7 @@ ${seedTails}`
|
||||
id: ${ObjectID.generate()}
|
||||
title: Part ${stepNum}
|
||||
challengeType: 0
|
||||
dashedName: part-${stepNum}
|
||||
---
|
||||
|
||||
# --description--
|
||||
@ -176,11 +177,13 @@ const reorderSteps = () => {
|
||||
const challengeID = frontMatter.data.id || ObjectID.generate();
|
||||
const title =
|
||||
newFileName === 'final.md' ? 'Final Prototype' : `Part ${newStepNum}`;
|
||||
const dashedName = `part-${newStepNum}`;
|
||||
challengeOrder.push(['' + challengeID, title]);
|
||||
const newData = {
|
||||
...frontMatter.data,
|
||||
id: challengeID,
|
||||
title
|
||||
title,
|
||||
dashedName
|
||||
};
|
||||
fs.writeFileSync(filePath, frontMatter.stringify(newData));
|
||||
});
|
||||
|
Reference in New Issue
Block a user