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 intoh1
that insidebody
Personal
footer
Convert a
MD
file to aHTML
fileA feature for
language
in<html>
Prettier
npm run prettier
is the command to run the prettier command with the mainjs
file --server.js
.npm run prettier-check
is the command to check if the mainjs
file --server.js
run the prettier or not.
Eslint
npm run eslint
is the command to run the eslint command with mainjs
file --server.js
to check the coding syntax.npm run eslint-fix
is the command to fix some command or basic error for theserver.js
, and return warnings for what can't be fixed automatically.
.Vscode
extensions.json
Specify the static extensions. For helping the cooperator to install servals recommended extensions.settings.json
Specify 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 test
is the command to run all testing files of the program(currently only have 1 test file).npm run test .\htmlGenerator.test.js
is the command to run the specific testing functions in the htmlGenerator.test.js.
Watch
npm run test:watch
is 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 coverage
is 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 |
------------------|---------|----------|---------|---------|-------------------