freecodecamp-cn-challenges-diff-parser
is a simple tool, primarily targeted for freeCodeCamp China developers, contributors and maintainers.
- It takes in two commits hash for comparison. By default, one is from local history, while the other one is from the latest
freecodecamp/curriculum
dev
branch.- Note that the earlier commit (i.e. the one from local history) is currently static. Will use the commit off which the latest translation is based from tag tree
- After retrieving the diff of two commits, iterate through the related
.json
challenge files, looking for id/title corresponding to the diffs. Then, generate output. - The output includes the following information:
- File path (
new
,old
or both) of modified challenges id
ortitle
of modified challenges- Line changes (old code and new cold) of modified challenges, resembles that of
git diff
(alternative)
- File path (
// TODO: Publish via npm
git clone https://github.com/FreeCodeCampChina/curriculum-cn
git clone https://github.com/FreeCodeCampChina/freecodecamp-cn-challenges-diff-parser
cd freecodecamp-cn-challenges-diff-parser
npm i
oryarn install
!important
cd ../curriculum-cn
git checkout -b dev-track-en origin/dev-track-en
- Diff parser is within the same level of curriculum-cn
.
├── curriculum-cn
| ├── challenges/
| └── index.js
├── freecodecamp-cn-challenges-diff-parser
| ├── lib/
| └── index.js
|
...
- Diff parser is within the same level of curriculum-cn parent folder
cn
(has to becn
)
.
├── cn
| ├── curriculum-cn/
| ├── challenges/
| └── index.js
| ...
├── freecodecamp-cn-challenges-diff-parser
| ├── lib/
| └── index.js
|
...
// TODO: Publish via npm
node index.js
node ${path_to_freecodecamp-cn-challenges-diff-parser}/index.js
node index.js [--type] [--path] [--debug]
- Determine output type, possible values are
title
andid
- Defaults to
title
when not passed in - Note: when type is given, detailed line changes are suppressed (consider
--type
as--type-only
)
- Determine output path type, possible values are
new
andold
- Defaults to 'both' when not passed in
- Determine whether to show line number for each hunk of code change
node index.js
will output:- Detailed line changes
- Title corresponding to the line changes
- Both new and old file path corresponding to the line changes
node index.js --type=id
will output:- ID corresponding to the line changes
- Both new and old file path corresponding to the line changes
node index.js --type=title --path=new
will output:- Title corresponding to the line changes
- New file path corresponding to the line changes
node index.js --type=title --debug
will output:- Title corresponding to the line changes
- Both new and old file path corresponding to the line changes
- Line number corresponding to the line changes of both old file path and new file path
DiffObject
object for output
newPath: String<Path>
oldPath: String<Path>
oldFile: Array<String> # The old JSON file split with \n
newFile: Array<String> # The new JSON file split with \n
diffs: Array<ParsedHunk> # Array that contains all parsed diff content
ParsedHunk
oldStart: Number # The line number (of old json file) where change happens
newStart: Number # The line number (of old json file) where change happens
data: Array<DiffContent>
DiffContent
sign: String # Possible values are ' ', '+' or '-', where ' ' denotes unchanged line of code, '+' denotes code addition and '-' denotes code subtraction
content: String # Line diff
- Add eslint
- Verify Node.js version 6.3.0
- Verify corresponding NPM version
- Generate HTML output, pug?
- Add babel
- Set up build process