Skip to content

Commit fcddc53

Browse files
authored
Merge pull request #4 from edurbrito/dev-v1.0.1
Dev v1.0.1
2 parents 0e80077 + 2a414bf commit fcddc53

4 files changed

Lines changed: 52 additions & 6 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For the CLI interface, [*inquirer*](https://github.com/SBoudrias/Inquirer.js) an
2222

2323
> Not tested with Windows or Mac. Some (directory) changes may be needed in order to work on these systems.
2424
25-
To install this CLI tool, run these commands:
25+
To install **revdown-cli**, follow this:
2626

2727
1. Install [Node.js](https://nodejs.org/en/)
2828
2. Clone this repository
@@ -45,6 +45,12 @@ To install this CLI tool, run these commands:
4545

4646
6. Follow all the instructions until it finishes the presentation generation
4747

48+
1. If it is the first time or no configurations were previously saved, it will ask you to choose the theme, the plugins, the highlight theme, the markdown configs, etc...
49+
![Initial configurations](images/init.gif)
50+
51+
2. If the last configurations were saved a first prompt will ask if you want to use them again
52+
![Cached configurations](images/cached.gif)
53+
4854
7. Open in your favorite browser the `yourmarkdownfile.html` file that was created
4955

5056
## Test

images/cached.gif

232 KB
Loading

images/init.gif

437 KB
Loading

src/index.ts

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ let user_config = {
2424
highlight_theme: ""
2525
}
2626

27-
async function download_files(files, tree) {
27+
/**
28+
* Downloads a list of files from the GitHub repo
29+
* @param files Array of files' names
30+
* @param tree Array of repo nodes containing the files' paths/names and urls
31+
*/
32+
async function download_files(files: Array<string>, tree: Array<any>) {
2833
for (const node of tree) {
2934
for (const g of files) {
3035
if (node.path.includes(g)) {
@@ -42,6 +47,9 @@ async function download_files(files, tree) {
4247
}
4348
}
4449

50+
/**
51+
* Saves the current GitHub repo structure tree for later consulting
52+
*/
4553
async function create_cache() {
4654
return fetch(url, { method: "Get" })
4755
.then((response) => {
@@ -56,6 +64,11 @@ async function create_cache() {
5664
})
5765
}
5866

67+
/**
68+
* Gets the list of themes currently available in the GitHub repo
69+
* @param tree Array of repo nodes containing the files' paths/names and urls
70+
* @returns The list of themes' names
71+
*/
5972
function get_themes(tree): Array<string> {
6073

6174
let themes = []
@@ -69,6 +82,11 @@ function get_themes(tree): Array<string> {
6982
return themes
7083
}
7184

85+
/**
86+
* Gets the list of fonts currently available in the GitHub repo
87+
* @param tree Array of repo nodes containing the files' paths/names and urls
88+
* @returns The list of fonts' names
89+
*/
7290
function get_fonts(tree): Array<string> {
7391

7492
let fonts = []
@@ -82,6 +100,11 @@ function get_fonts(tree): Array<string> {
82100
return fonts
83101
}
84102

103+
/**
104+
* Gets the list of plugins currently available in the GitHub repo
105+
* @param tree Array of repo nodes containing the files' paths/names and urls
106+
* @returns The list of plugins' names
107+
*/
85108
function get_plugins(tree): Array<string> {
86109

87110
let plugins = []
@@ -95,6 +118,11 @@ function get_plugins(tree): Array<string> {
95118
return plugins
96119
}
97120

121+
/**
122+
* Gets the list of highlight themes currently available in the GitHub repo
123+
* @param tree Array of repo nodes containing the files' paths/names and urls
124+
* @returns The list of highlight themes' names
125+
*/
98126
function get_highlight_themes(tree): Array<string> {
99127

100128
let highlight_themes = []
@@ -108,6 +136,11 @@ function get_highlight_themes(tree): Array<string> {
108136
return highlight_themes
109137
}
110138

139+
/**
140+
* Guides the user with a set of questions in order to build the presentation
141+
* and saves the last chosen configuration
142+
* @param markdown_file The name of the markdown file to be used in the presentation generation
143+
*/
111144
function ask_user(markdown_file: string) {
112145
if (!fs.existsSync(cache_dir))
113146
fs.mkdirSync(cache_dir, { recursive: true })
@@ -129,9 +162,12 @@ function ask_user(markdown_file: string) {
129162

130163
download_files(fonts, tree)
131164

132-
let plugins = get_plugins(tree)
165+
let plugins = get_plugins(tree).filter(item => item != "markdown.js")
133166

134-
new MultipleChoiceQuestion("plugins", "Which plugins do you want to include?", plugins).create_question((a) => {
167+
new MultipleChoiceQuestion("plugins", "Which plugins do you want to include (besides markdown.js)?", plugins).create_question((a) => {
168+
169+
a.plugins.push("markdown.js")
170+
135171
user_config.plugins = a.plugins
136172
download_files(a.plugins, tree)
137173

@@ -157,6 +193,10 @@ function ask_user(markdown_file: string) {
157193
})
158194
}
159195

196+
/**
197+
* Asks the user for the markdown configuration questions and builds the presentation
198+
* @param markdown_file The name of the markdown file to be used in the presentation generation
199+
*/
160200
function generate_slides(markdown_file: string) {
161201

162202
new MultipleInputQuestions(
@@ -224,7 +264,7 @@ function main(): number {
224264
| |
225265
| revdown-cli |
226266
| |
227-
| v1.0.0 |
267+
| v1.0.1 |
228268
---------------------------------`))
229269

230270
if (!fs.existsSync(user_dir + "user.json")) {
@@ -253,7 +293,7 @@ function main(): number {
253293
return 0
254294
}
255295

256-
err("Usage: revdown mymarkdownfile.md", process.argv.length)
296+
err("Usage: revdown mymarkdownfile.md")
257297

258298
return 1
259299
}

0 commit comments

Comments
 (0)