Skip to content

Command line tool we use to parse content written in markdown for our LMS @Laboratoria

Notifications You must be signed in to change notification settings

Laboratoria/curriculum-parser

Repository files navigation

@laboratoria/curriculum-parser

Command line tool used to parse content written in markdown at @Laboratoria (See Laboratoria/curriculum).

Node.js CI Coverage Status

Installation

Install as a development dependency in your project:

npm i --save-dev @laboratoria/curriculum-parser

You should now be able to run it with npx:

npx curriculum-parser # when already installed in project

# or alternatively using full package name (with org)
# this works even if not previously installed.
npx @laboratoria/curriculum-parser

You can also install curriculum-parser globally using npm like this:

npm i -g @laboratoria/curriculum-parser

If you get a permission error please try using sudo (you may need admin permissions depending on your node installation).

# using `sudo` (only if previous step failed)
sudo npm i -g @laboratoria/curriculum-parser

Alternatively you can install using a local clone.

# clone from your own fork
git clone [email protected]:<your-username>/curriculum-parser.git
cd curriculum-parser
npm install
npm link

If the above command fails, try using sudo:

sudo npm link

Upgrade

If you installed globally using npm you can simply re-install like so:

npm i -g @laboratoria/curriculum-parser

If you chose to install using a local clone, you can update your clone to upstream main:

# go into local copy of repo
cd curriculum-parser
# if not yet added a reference to upstream remote we add it
git remote add upstream [email protected]:Laboratoria/curriculum-parser.git
# fetch changes and merge upstream/main into local main
git fetch upstream
git merge upstream/main
# you may also want to push changes to your fork
git push origin main

Usage

After installing globally (or linking with npm link) you should have the curriculum-parser command available in your PATH.

curriculum-parser --help
Usage: curriculum-parser [options] [command]

Options:
  -V                         output the version number
  -h, --help                 display help for command

Commands:
  project [options] <dir>    Parse a project
  topic [options] <dir>               Parse a topic
  part [options] <dir>                Parse a part
  challenge [options] <dir>           Parse a challenge
  learning-objectives [options] <dir> Parse learning objectives
  help [command]                      Display help for command

You can also access usage (help) info for individual commands like so:

curriculum-parser project --help
Usage: curriculum-parser project [options] <dir>

Parse a project

Arguments:
  dir                 path to project directory

Options:
  --repo <string>     Repository
  --version <string>  Project version
  --lo <string>       Path to yml file with reference learning objectives
  --debug             Show error stack traces
  -h, --help          display help for command

Examples

Parse a topic within the Laboratoria/curriculum repo

Parsing a topic and printing the resulting JSON output to stdout.

curriculum-parser topic topics/javascript/ \
  --repo Laboratoria/curriculum \
  --version 5.5.0

Parsing a topic and writing the parser's output (stdout) to a file (using output redirection in the shell).

curriculum-parser topic topics/javascript/ \
  --repo Laboratoria/curriculum \
  --version 5.5.0 \
  > "build/topics/javascript.json"

Parse a specific part of a topic within the Laboratoria/curriculum repo

curriculum-parser part topics/intro-ux/00-que-es-uxd/00-que-es-uxd/ \
  --repo Laboratoria/curriculum \
  --version 5.5.0

Parse a challenge within the Laboratoria/curriculum repo

curriculum-parser challenge topics/javascript/01-basics/06-exercises/01-coin-convert/ \
  --repo Laboratoria/curriculum \
  --version 5.5.0

Parse a project within the Laboratoria/curriculum repo

curriculum-parser project projects/01-cipher/ \
  --repo Laboratoria/curriculum \
  --version 5.5.0 \
  --lo=./learning-objectives

Parse learning objectives within Laboratoria/curriculum

Usage: curriculum-parser learning-objectives [options] <dir>

Parse learning objectives

Arguments:
  dir                 path to learning-objectives directory

Options:
  --validate          Validate and throw errors for objectives missing intl or without title
  --strict            Used with validate option to only throw error if an objective is missing in
                      all supported languages
  --debug             Show error stack traces
  -h, --help          display help for command
curriculum-parser learning-objectives learning-objectives \
  --repo Laboratoria/curriculum \
  --validate \
  --strict \
  > "dist/learning-objectives.json"

## Known tracks

This project contains an array in [`lib/common.js`](./lib/common.js) called
`knownTracks` which contains the list of tracks that are known by the parser.

If a new track is ever going to be added to the curriculum, it must be
added to this array or else it'd throw the corresponding _Invalid track_ error.