highmark-cli 0.0.96 → 0.0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,8 @@ const { HELP_OPTION,
8
8
  VERSION_OPTION,
9
9
  COPY_FONTS_OPTION,
10
10
  INPUT_FILE_PATH_OPTION,
11
- OUTPUT_FILE_PATH_OPTION } = options;
11
+ OUTPUT_FILE_PATH_OPTION,
12
+ TEMPLATE_FILE_PATH_OPTION } = options;
12
13
 
13
14
  const h = HELP_OPTION,
14
15
  p = PORT_OPTION,
@@ -16,7 +17,8 @@ const h = HELP_OPTION,
16
17
  v = VERSION_OPTION,
17
18
  f = COPY_FONTS_OPTION,
18
19
  i = INPUT_FILE_PATH_OPTION,
19
- o = OUTPUT_FILE_PATH_OPTION;
20
+ o = OUTPUT_FILE_PATH_OPTION,
21
+ t = TEMPLATE_FILE_PATH_OPTION;
20
22
 
21
23
  module.exports = {
22
24
  h,
@@ -25,5 +27,6 @@ module.exports = {
25
27
  v,
26
28
  f,
27
29
  i,
28
- o
30
+ o,
31
+ t
29
32
  };
@@ -7,14 +7,28 @@ function helpAction() {
7
7
 
8
8
  Commands:
9
9
 
10
- [help] Show this help
10
+ help Show this help
11
11
 
12
+ version Show the version
13
+
14
+ [publish] Publish the input Markdown file to the output HTML file.
15
+
12
16
  Options:
13
17
 
14
18
  --help|-h Show this help
15
19
 
16
20
  --version|-v Show the version
17
21
 
22
+ --port|-p The server port. The default is 8888.
23
+
24
+ --server|-s Start a server to view the output file
25
+
26
+ --copy-fonts|-f Copy the fonts to a fonts folder next to the output file
27
+
28
+ --input-file-path|-i The input file path. The default is 'default.md'.
29
+
30
+ --output-file-path|-o The output file path. The default is 'index.html'.
31
+
18
32
  Further information:
19
33
 
20
34
  Please see the readme file on GitHub:
@@ -9,7 +9,7 @@ const htmlOperation = require("../operation/html"),
9
9
  const { executeOperations } = require("../utilities/operation"),
10
10
  { SUCCESSFUL_PUBLISH_MESSAGE, FAILED_PUBLISH_MESSAGE } = require("../messages");
11
11
 
12
- function publishAction(port, server, copyFonts, inputFilePath, outputFilePath) {
12
+ function publishAction(port, server, copyFonts, inputFilePath, outputFilePath, templateFilePath) {
13
13
  const operations = [
14
14
  markdownStylesCSSOperation,
15
15
  markdownHTMLOperation,
@@ -22,7 +22,8 @@ function publishAction(port, server, copyFonts, inputFilePath, outputFilePath) {
22
22
  server,
23
23
  copyFonts,
24
24
  inputFilePath,
25
- outputFilePath
25
+ outputFilePath,
26
+ templateFilePath
26
27
  };
27
28
 
28
29
  executeOperations(operations, (completed) => {
package/bin/defaults.js CHANGED
@@ -4,12 +4,14 @@ const DEFAULT_PORT = 8888,
4
4
  DEFAULT_SERVER = false,
5
5
  DEFAULT_COPY_FONTS = false,
6
6
  DEFAULT_INPUT_FILE_PATH = "default.md",
7
- DEFAULT_OUTPUT_FILE_PATH = "index.html";
7
+ DEFAULT_OUTPUT_FILE_PATH = "index.html",
8
+ DEFAULT_TEMPLATE_FILE_PATH = "template/default.html";
8
9
 
9
10
  module.exports = {
10
11
  DEFAULT_PORT,
11
12
  DEFAULT_SERVER,
12
13
  DEFAULT_COPY_FONTS,
13
14
  DEFAULT_INPUT_FILE_PATH,
14
- DEFAULT_OUTPUT_FILE_PATH
15
+ DEFAULT_OUTPUT_FILE_PATH,
16
+ DEFAULT_TEMPLATE_FILE_PATH
15
17
  };
package/bin/main.js CHANGED
@@ -5,13 +5,14 @@ const helpAction = require("./action/help"),
5
5
  versionAction = require("./action/version"),
6
6
  publishAction = require("./action/publish");
7
7
 
8
- const { HELP_OPTION, SERVER_OPTION, VERSION_OPTION } = require("./options"),
9
- { HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
8
+ const { HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
9
+ { HELP_OPTION, SERVER_OPTION, VERSION_OPTION, TEMPLATE_FILE_PATH_OPTION } = require("./options"),
10
10
  { DEFAULT_PORT,
11
11
  DEFAULT_SERVER,
12
12
  DEFAULT_COPY_FONTS,
13
13
  DEFAULT_INPUT_FILE_PATH,
14
- DEFAULT_OUTPUT_FILE_PATH } = require("./defaults");
14
+ DEFAULT_OUTPUT_FILE_PATH,
15
+ DEFAULT_TEMPLATE_FILE_PATH } = require("./defaults");
15
16
 
16
17
  function main(command, argument, options) {
17
18
  const commandMissing = (command === null),
@@ -22,7 +23,8 @@ function main(command, argument, options) {
22
23
  server = DEFAULT_SERVER,
23
24
  copyFonts = DEFAULT_COPY_FONTS,
24
25
  inputFilePath = DEFAULT_INPUT_FILE_PATH,
25
- outputFilePath = DEFAULT_OUTPUT_FILE_PATH } = options;
26
+ outputFilePath = DEFAULT_OUTPUT_FILE_PATH,
27
+ templateFilePath = DEFAULT_TEMPLATE_FILE_PATH } = options;
26
28
 
27
29
  if (false) {
28
30
  ///
@@ -42,12 +44,10 @@ function main(command, argument, options) {
42
44
  case HELP_COMMAND: helpAction(); break;
43
45
  case SERVER_COMMAND: serverAction(port, server, outputFilePath); break;
44
46
  case VERSION_COMMAND: versionAction(); break;
45
- case PUBLISH_COMMAND: publishAction(port, server, copyFonts, inputFilePath, outputFilePath); break;
47
+ case PUBLISH_COMMAND: publishAction(port, server, copyFonts, inputFilePath, outputFilePath, templateFilePath); break;
46
48
 
47
49
  default :
48
- argument = command; ///
49
-
50
- publishAction(port, server, copyFonts, inputFilePath, outputFilePath);
50
+ publishAction(port, server, copyFonts, inputFilePath, outputFilePath, templateFilePath);
51
51
 
52
52
  break;
53
53
  }
package/bin/messages.js CHANGED
@@ -11,6 +11,7 @@ const FAILED_SERVER_MESSAGE = "Failed to serve.",
11
11
  UNABLE_TO_READ_DIRECTORY_MESSAGE = "Unable to read the directory.",
12
12
  UNABLE_TO_CREATE_DIRECTORY_MESSAGE = "Unable to create the directory.",
13
13
  UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE = "Unable to parse the markdown file.",
14
+ UNABLE_TO_PARSE_TEMPLATE_FILE_MESSAGE = "Unable to parse the template file.",
14
15
  UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE = "Unable to convert Markdown to HTML.",
15
16
  UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE = "Unable to convert Markdown styles to CSS.";
16
17
 
@@ -26,6 +27,7 @@ module.exports = {
26
27
  UNABLE_TO_READ_DIRECTORY_MESSAGE,
27
28
  UNABLE_TO_CREATE_DIRECTORY_MESSAGE,
28
29
  UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE,
30
+ UNABLE_TO_PARSE_TEMPLATE_FILE_MESSAGE,
29
31
  UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE,
30
32
  UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE
31
33
  };
@@ -1,75 +1,22 @@
1
1
  "use strict";
2
2
 
3
- const { computerModernStyle } = require("highmark-fonts");
3
+ const { computerModernStyle: computerModernStyleCSS } = require("highmark-fonts");
4
4
 
5
- const { writeFile } = require("../utilities/fileSystem"),
6
- { EMPTY_STRING } = require("../constants");
5
+ const { EMPTY_STRING } = require("../constants"),
6
+ { writeFile, parseTemplateFile } = require("../utilities/fileSystem");
7
7
 
8
8
  function htmlOperation(proceed, abort, context) {
9
- const { title, markdownHTML, outputFilePath, markdownStylesCSS } = context,
9
+ const { title, markdownHTML, outputFilePath, markdownStylesCSS, templateFilePath } = context,
10
10
  titleHTML = titleHTMLFromTitle(title),
11
- filePath = outputFilePath, ///
12
- content = `<!DOCTYPE html>
13
- <html>
14
- <head>
15
-
16
- ${titleHTML}
17
-
18
- <meta charset="utf-8" />
19
-
20
- <link rel="preload" href="font/cmunbbx.woff2" as="font" type="font/woff2" crossorigin />
21
- <link rel="preload" href="font/cmunbi.woff2" as="font" type="font/woff2" crossorigin />
22
- <link rel="preload" href="font/cmunbmo.woff2" as="font" type="font/woff2" crossorigin />
23
- <link rel="preload" href="font/cmunbmr.woff2" as="font" type="font/woff2" crossorigin />
24
- <link rel="preload" href="font/cmunbx.woff2" as="font" type="font/woff2" crossorigin />
25
- <link rel="preload" href="font/cmunbxo.woff2" as="font" type="font/woff2" crossorigin />
26
- <link rel="preload" href="font/cmunit.woff2" as="font" type="font/woff2" crossorigin />
27
- <link rel="preload" href="font/cmunobi.woff2" as="font" type="font/woff2" crossorigin />
28
- <link rel="preload" href="font/cmunobx.woff2" as="font" type="font/woff2" crossorigin />
29
- <link rel="preload" href="font/cmunorm.woff2" as="font" type="font/woff2" crossorigin />
30
- <link rel="preload" href="font/cmunoti.woff2" as="font" type="font/woff2" crossorigin />
31
- <link rel="preload" href="font/cmunrm.woff2" as="font" type="font/woff2" crossorigin />
32
- <link rel="preload" href="font/cmunsi.woff2" as="font" type="font/woff2" crossorigin />
33
- <link rel="preload" href="font/cmunso.woff2" as="font" type="font/woff2" crossorigin />
34
- <link rel="preload" href="font/cmunss.woff2" as="font" type="font/woff2" crossorigin />
35
- <link rel="preload" href="font/cmunsx.woff2" as="font" type="font/woff2" crossorigin />
36
- <link rel="preload" href="font/cmuntb.woff2" as="font" type="font/woff2" crossorigin />
37
- <link rel="preload" href="font/cmunti.woff2" as="font" type="font/woff2" crossorigin />
38
- <link rel="preload" href="font/cmuntt.woff2" as="font" type="font/woff2" crossorigin />
39
- <link rel="preload" href="font/cmuntx.woff2" as="font" type="font/woff2" crossorigin />
40
-
41
- <style>
42
-
43
- *,
44
- *::after,
45
- *::before {
46
- border: 0;
47
- margin: 0;
48
- padding: 0;
49
- box-sizing: border-box;
50
- }
51
-
52
- </style>
53
- <style>
54
-
55
- ${computerModernStyle}
56
-
57
- </style>
58
- <style>
59
-
60
- ${markdownStylesCSS}
61
-
62
- </style>
63
- </head>
64
- <body>
65
-
66
- ${markdownHTML}
67
-
68
- </body>
69
- </html>
70
- `;
71
-
72
- writeFile(filePath, content);
11
+ args = {
12
+ titleHTML,
13
+ markdownHTML,
14
+ markdownStylesCSS,
15
+ computerModernStyleCSS
16
+ },
17
+ content = parseTemplateFile(templateFilePath, args);
18
+
19
+ writeFile(outputFilePath, content);
73
20
 
74
21
  proceed();
75
22
  }
package/bin/options.js CHANGED
@@ -6,7 +6,8 @@ const HELP_OPTION = "help",
6
6
  VERSION_OPTION = "version",
7
7
  COPY_FONTS_OPTION = "copy-fonts",
8
8
  INPUT_FILE_PATH_OPTION = "input-file-path",
9
- OUTPUT_FILE_PATH_OPTION = "output-file-path";
9
+ OUTPUT_FILE_PATH_OPTION = "output-file-path",
10
+ TEMPLATE_FILE_PATH_OPTION = "template-file-path";
10
11
 
11
12
  module.exports = {
12
13
  HELP_OPTION,
@@ -15,5 +16,6 @@ module.exports = {
15
16
  VERSION_OPTION,
16
17
  COPY_FONTS_OPTION,
17
18
  INPUT_FILE_PATH_OPTION,
18
- OUTPUT_FILE_PATH_OPTION
19
+ OUTPUT_FILE_PATH_OPTION,
20
+ TEMPLATE_FILE_PATH_OPTION
19
21
  };
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+
5
+ ${titleHTML}
6
+
7
+ <meta charset="utf-8" />
8
+
9
+ <link rel="preload" href="font/cmunbbx.woff2" as="font" type="font/woff2" crossorigin />
10
+ <link rel="preload" href="font/cmunbi.woff2" as="font" type="font/woff2" crossorigin />
11
+ <link rel="preload" href="font/cmunbmo.woff2" as="font" type="font/woff2" crossorigin />
12
+ <link rel="preload" href="font/cmunbmr.woff2" as="font" type="font/woff2" crossorigin />
13
+ <link rel="preload" href="font/cmunbx.woff2" as="font" type="font/woff2" crossorigin />
14
+ <link rel="preload" href="font/cmunbxo.woff2" as="font" type="font/woff2" crossorigin />
15
+ <link rel="preload" href="font/cmunit.woff2" as="font" type="font/woff2" crossorigin />
16
+ <link rel="preload" href="font/cmunobi.woff2" as="font" type="font/woff2" crossorigin />
17
+ <link rel="preload" href="font/cmunobx.woff2" as="font" type="font/woff2" crossorigin />
18
+ <link rel="preload" href="font/cmunorm.woff2" as="font" type="font/woff2" crossorigin />
19
+ <link rel="preload" href="font/cmunoti.woff2" as="font" type="font/woff2" crossorigin />
20
+ <link rel="preload" href="font/cmunrm.woff2" as="font" type="font/woff2" crossorigin />
21
+ <link rel="preload" href="font/cmunsi.woff2" as="font" type="font/woff2" crossorigin />
22
+ <link rel="preload" href="font/cmunso.woff2" as="font" type="font/woff2" crossorigin />
23
+ <link rel="preload" href="font/cmunss.woff2" as="font" type="font/woff2" crossorigin />
24
+ <link rel="preload" href="font/cmunsx.woff2" as="font" type="font/woff2" crossorigin />
25
+ <link rel="preload" href="font/cmuntb.woff2" as="font" type="font/woff2" crossorigin />
26
+ <link rel="preload" href="font/cmunti.woff2" as="font" type="font/woff2" crossorigin />
27
+ <link rel="preload" href="font/cmuntt.woff2" as="font" type="font/woff2" crossorigin />
28
+ <link rel="preload" href="font/cmuntx.woff2" as="font" type="font/woff2" crossorigin />
29
+
30
+ <style>
31
+
32
+ *,
33
+ *::after,
34
+ *::before {
35
+ border: 0;
36
+ margin: 0;
37
+ padding: 0;
38
+ box-sizing: border-box;
39
+ }
40
+
41
+ </style>
42
+ <style>
43
+
44
+ ${computerModernStyle}
45
+
46
+ </style>
47
+ <style>
48
+
49
+ ${markdownStylesCSS}
50
+
51
+ </style>
52
+ </head>
53
+ <body>
54
+
55
+ ${markdownHTML}
56
+
57
+ </body>
58
+ </html>
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
 
3
- const { pathUtilities, fileSystemUtilities } = require("necessary");
3
+ const { pathUtilities, templateUtilities, fileSystemUtilities } = require("necessary");
4
4
 
5
5
  const { isEntryNameHiddenName } = require("../utilities/path"),
6
6
  { UNABLE_TO_COPY_FILE_MESSAGE,
7
7
  UNABLE_TO_READ_FILE_MESSAGE,
8
8
  UNABLE_TO_WRITE_FILE_MESSAGE,
9
9
  UNABLE_TO_READ_DIRECTORY_MESSAGE,
10
- UNABLE_TO_CREATE_DIRECTORY_MESSAGE } = require("../messages");
10
+ UNABLE_TO_CREATE_DIRECTORY_MESSAGE,
11
+ UNABLE_TO_PARSE_TEMPLATE_FILE_MESSAGE } = require("../messages");
11
12
 
12
- const { concatenatePaths } = pathUtilities,
13
+ const { parseFile } = templateUtilities,
14
+ { concatenatePaths } = pathUtilities,
13
15
  { isEntryFile,
14
16
  checkEntryExists,
15
17
  copyFile: copyFileAsync,
@@ -142,10 +144,35 @@ function createDirectory(directoryPath) {
142
144
  }
143
145
  }
144
146
 
147
+ function parseTemplateFile(templateFilePath, args) {
148
+ let content = null;
149
+
150
+ try {
151
+ const filePath = templateFilePath; ///
152
+
153
+ content = parseFile(filePath, args);
154
+
155
+ console.log(`Parse template file '${filePath}'.`);
156
+ } catch (error) {
157
+ let message;
158
+
159
+ message = UNABLE_TO_PARSE_TEMPLATE_FILE_MESSAGE;
160
+
161
+ console.log(message);
162
+
163
+ ({ message } = error);
164
+
165
+ console.log(message);
166
+ }
167
+
168
+ return content;
169
+ }
170
+
145
171
  module.exports = {
146
172
  copyFile,
147
173
  readFile,
148
174
  writeFile,
149
175
  readDirectory,
150
- createDirectory
176
+ createDirectory,
177
+ parseTemplateFile
151
178
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "highmark-cli",
3
3
  "author": "James Smith",
4
- "version": "0.0.96",
4
+ "version": "0.0.98",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/highmark-cli",
7
7
  "description": "Extensible, styleable Markdown.",
@@ -12,12 +12,12 @@
12
12
  "dependencies": {
13
13
  "argumentative": "^2.0.28",
14
14
  "express": "^4.19.2",
15
- "highmark-fonts": "^1.0.30",
16
- "highmark-markdown": "^0.0.153",
17
- "highmark-markdown-style": "^0.0.189",
15
+ "highmark-fonts": "^1.0.31",
16
+ "highmark-markdown": "^0.0.154",
17
+ "highmark-markdown-style": "^0.0.190",
18
18
  "lively-cli": "^2.0.55",
19
- "necessary": "^13.5.5",
20
- "occam-entities": "^1.0.84"
19
+ "necessary": "^13.6.1",
20
+ "occam-entities": "^1.0.85"
21
21
  },
22
22
  "scripts": {},
23
23
  "bin": {