my-first-ssg-1 v1.0.4
My-First-SSG
A Static Site Generator(SSG) for OSD600
This repo introduces a JavaScript program that convert .txt file into a HTML file
Installation
npm i yargs
After installation of yargs. Make sure you have your js file to run.
If you don't have it, you can create a js file by using the command: touch test.js
Commands
server.js --input 'filename'
For Example: You can simply run the program by the command:
node test.js -i 'Silver Blaze.txt'
Which will generate a HTML file for the 'Silver Blaze.txt' file into the /dist folder.
Or
node test.js -i .\Sherlock-Holmes-Selected-Stories\
Which will generate a few of HTML files for the Sherlock-Holmes-Selected-Stories directory into the /dist folder.
Options
Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
-o, --output [string] [required] [default: "./dist"]
-l, --lang generate the lang attribute [string] [required] [default: "."]
-i, --input convert .txt file to html file [string] [required]Optional Features
Get the title of the .txt file and put the name of the title into
title, also put it intoh1that insidebodyPersonal
footerConvert a
MDfile to aHTMLfileA feature for
languagein<html>
Prettier
npm run prettieris the command to run the prettier command with the mainjsfile --server.js.npm run prettier-checkis the command to check if the mainjsfile --server.jsrun the prettier or not.
Eslint
npm run eslintis the command to run the eslint command with mainjsfile --server.jsto check the coding syntax.npm run eslint-fixis the command to fix some command or basic error for theserver.js, and return warnings for what can't be fixed automatically.
.Vscode
extensions.jsonSpecify the static extensions. For helping the cooperator to install servals recommended extensions.settings.jsonSpecify settings for the editor. Ensure that whenever the cooperator saves a file, the program would format the code using the prettier extension.
Testing
npm run testis the command to run all testing files of the program(currently only have 1 test file).npm run test .\htmlGenerator.test.jsis the command to run the specific testing functions in the htmlGenerator.test.js.
Watch
npm run test:watchis the command to run the test runner watch. It will show a list of options for testing:
No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.
Watch Usage
› Press a to run all tests.
› Press f to run only failed tests.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press q to quit watch mode.
› Press Enter to trigger a test run.And you can type in 'a' or 'f' or 'p' or 't' or 'q' to selection an option. Also, you can press to trigger a test run.
Coverage
npm run coverageis the command to run the Code Coverage Analysis, it will run the tests generate a coverage report to the user. It will have a table similar to this:
------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
htmlGenerator.js | 100 | 100 | 100 | 100 |
------------------|---------|----------|---------|---------|-------------------