highmark-cli 0.0.73 → 0.0.74

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.
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
 
3
- const readInputFileOperation = require("../operation/readInputFile"),
4
- inputFileToHTMLOperation = require("../operation/inputFileToHTML");
3
+ const markdownToHTMLOperation = require("../operation/markdownToHTML"),
4
+ markdownStylesToCSSOperation = require("../operation/markdownStylesToCSS");
5
5
 
6
6
  const { executeOperations } = require("../utilities/operation"),
7
7
  { SUCCESSFUL_PUBLISH_MESSAGE, FAILED_PUBLISH_MESSAGE } = require("../messages");
8
8
 
9
9
  function publishAction(inputFilePath, outputFilePath) {
10
- const operations = [
11
- readInputFileOperation,
12
- inputFileToHTMLOperation
10
+ const markdownFilePath = inputFilePath, ///
11
+ htmlFilePath = outputFilePath, ///
12
+ operations = [
13
+ markdownToHTMLOperation,
14
+ markdownStylesToCSSOperation
13
15
  ],
14
16
  context = {
15
- inputFilePath,
16
- outputFilePath
17
+ htmlFilePath,
18
+ markdownFilePath
17
19
  };
18
20
 
19
21
  executeOperations(operations, (completed) => {
package/bin/constants.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ const PERIOD = ".";
3
4
  const DOUBLE_SPACE = " ";
4
5
  const HIGHMARK_CLI = "Highmark-CLI";
5
6
 
6
7
  module.exports = {
8
+ PERIOD,
7
9
  DOUBLE_SPACE,
8
10
  HIGHMARK_CLI
9
11
  };
package/bin/importer.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
- const { readFile } = require("./utilities/file");
3
+ const { readFile } = require("./utilities/fileSystem");
4
4
  const { nodeFromTokens, tokensFromContent } = require("./utilities/markdown");
5
5
 
6
- function importer(filePath, indent, context) {
6
+ function importer(filePath, indent) {
7
7
  let html = null;
8
8
 
9
9
  const content = readFile(filePath);
package/bin/messages.js CHANGED
@@ -2,12 +2,18 @@
2
2
 
3
3
  const FAILED_PUBLISH_MESSAGE = "Failed to publish.",
4
4
  SUCCESSFUL_PUBLISH_MESSAGE = "Published successfully.",
5
- UNABLE_TO_READ_INPUT_FILE_MESSAGE = "Unable to read the input file.",
6
- UNABLE_TO_PARSE_INPUT_FILE_MESSAGE = "Unable to parse the input file.";
5
+ UNABLE_TO_READ_FILE_MESSAGE = "Unable to read the file.",
6
+ UNABLE_TO_READ_DIRECTORY_MESSAGE = "Unable to read the directory.",
7
+ UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE = "Unable to parse the markdown file.",
8
+ UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE = "Unable to convert Markdown to HTML.",
9
+ UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE = "Unable to convert Markdown styles to CSS.";
7
10
 
8
11
  module.exports = {
9
12
  FAILED_PUBLISH_MESSAGE,
10
13
  SUCCESSFUL_PUBLISH_MESSAGE,
11
- UNABLE_TO_READ_INPUT_FILE_MESSAGE,
12
- UNABLE_TO_PARSE_INPUT_FILE_MESSAGE
14
+ UNABLE_TO_READ_FILE_MESSAGE,
15
+ UNABLE_TO_READ_DIRECTORY_MESSAGE,
16
+ UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE,
17
+ UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE,
18
+ UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE
13
19
  };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ const { filePathUtilities } = require("occam-entities");
4
+
5
+ const { PERIOD } = require("../constants"),
6
+ { readFile, readDirectory } = require("../utilities/fileSystem");
7
+
8
+ const { isFilePathMarkdownStyleFilePath } = filePathUtilities;
9
+
10
+ function markdownStylesToCSS(proceed, abort, context) {
11
+ const directoryPath = PERIOD; ///
12
+
13
+ readDirectory(directoryPath, (filePath) => {
14
+ const filePathMarkdownStyleFilePath = isFilePathMarkdownStyleFilePath(filePath);
15
+
16
+ if (filePathMarkdownStyleFilePath) {
17
+ const markdownStyleFilePath = filePath, ///
18
+ markdownStyleContent = readFile(markdownStyleFilePath);
19
+
20
+ debugger
21
+ }
22
+ });
23
+
24
+ proceed();
25
+ }
26
+
27
+ module.exports = markdownStylesToCSS;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ const importer = require("../importer");
4
+
5
+ const { DOUBLE_SPACE } = require("../constants"),
6
+ { UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE } = require("../messages");
7
+
8
+ function markdownToHTML(proceed, abort, context) {
9
+ const { markdownFilePath } = context,
10
+ filePath = markdownFilePath, ///
11
+ indent = DOUBLE_SPACE,
12
+ html = importer(filePath, indent);
13
+
14
+ if (html === null) {
15
+ const message = UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE;
16
+
17
+ console.log(message);
18
+
19
+ abort();
20
+
21
+ return;
22
+ }
23
+
24
+ Object.assign(context, {
25
+ html
26
+ });
27
+
28
+ proceed();
29
+ }
30
+
31
+ module.exports = markdownToHTML;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ const { fileSystemUtilities } = require("necessary");
4
+
5
+ const { isEntryNameHiddenName } = require("../utilities/name"),
6
+ { UNABLE_TO_READ_FILE_MESSAGE, UNABLE_TO_READ_DIRECTORY_MESSAGE } = require("../messages");
7
+
8
+ const { isEntryFile, readFile: readFileAsync, readDirectory: readDirectoryAsync } = fileSystemUtilities;
9
+
10
+ function readFile(filePath) {
11
+ let content = null;
12
+
13
+ try {
14
+ content = readFileAsync(filePath);
15
+
16
+ console.log(`Read file '${filePath}'.`);
17
+ } catch (error) {
18
+ let message;
19
+
20
+ message = UNABLE_TO_READ_FILE_MESSAGE;
21
+
22
+ console.log(message);
23
+
24
+ ({ message } = error);
25
+
26
+ console.log(message);
27
+ }
28
+
29
+ return content;
30
+ }
31
+
32
+ function readDirectory(directoryPath, callback) {
33
+ try {
34
+ const entryNames = readDirectoryAsync(directoryPath);
35
+
36
+ entryNames.forEach((entryName) => {
37
+ const entryNameHiddenName = isEntryNameHiddenName(entryName);
38
+
39
+ if (!entryNameHiddenName) {
40
+ const entryPath = `${directoryPath}/${entryName}`, ///
41
+ entryFile = isEntryFile(entryPath);
42
+
43
+ if (entryFile) {
44
+ const filePath = entryPath; ///
45
+
46
+ callback(filePath);
47
+ } else {
48
+ const directoryPath = entryPath; ///
49
+
50
+ readDirectory(directoryPath);
51
+ }
52
+ }
53
+ });
54
+ } catch (error) {
55
+ let message;
56
+
57
+ message = UNABLE_TO_READ_DIRECTORY_MESSAGE;
58
+
59
+ console.log(message);
60
+
61
+ ({ message } = error);
62
+
63
+ console.log(message);
64
+ }
65
+ }
66
+
67
+ module.exports = {
68
+ readFile,
69
+ readDirectory
70
+ };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { MarkdownLexer, MarkdownParser } = require("highmark-markdown");
4
4
 
5
- const { UNABLE_TO_PARSE_INPUT_FILE_MESSAGE } = require("../messages");
5
+ const { UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE } = require("../messages");
6
6
 
7
7
  const markdownLexer = MarkdownLexer.fromNothing(),
8
8
  markdownParser = MarkdownParser.fromNothing();
@@ -17,7 +17,7 @@ function nodeFromTokens(tokens) {
17
17
  const node = markdownParser.parse(tokens);
18
18
 
19
19
  if (node === null) {
20
- const message = UNABLE_TO_PARSE_INPUT_FILE_MESSAGE;
20
+ const message = UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE;
21
21
 
22
22
  console.log(message);
23
23
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ function isEntryNameHiddenName(entryName) {
4
+ const nameHiddenName = /^\..+/.test(entryName);
5
+
6
+ return nameHiddenName;
7
+ }
8
+
9
+ module.exports = {
10
+ isEntryNameHiddenName
11
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "highmark-cli",
3
3
  "author": "James Smith",
4
- "version": "0.0.73",
4
+ "version": "0.0.74",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/highmark-cli",
7
7
  "description": "Extensible, styleable Markdown.",
@@ -11,9 +11,10 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "argumentative": "^2.0.28",
14
- "highmark-markdown": "^0.0.120",
15
- "highmark-markdown-style": "^0.0.164",
16
- "necessary": "^13.4.2"
14
+ "highmark-markdown": "^0.0.121",
15
+ "highmark-markdown-style": "^0.0.165",
16
+ "necessary": "^13.4.2",
17
+ "occam-entities": "^1.0.83"
17
18
  },
18
19
  "scripts": {},
19
20
  "bin": {
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- const importer = require("../importer");
4
-
5
- const { DOUBLE_SPACE } = require("../constants");
6
- const { nodeFromTokens, tokensFromContent } = require("../utilities/markdown");
7
-
8
- function inputFileHTMLOperation(proceed, abort, context) {
9
- const { inputFileContent } = context,
10
- content = inputFileContent, ///
11
- tokens = tokensFromContent(content),
12
- node = nodeFromTokens(tokens);
13
-
14
- if (node === null) {
15
- abort();
16
-
17
- return;
18
- }
19
-
20
- const indent = DOUBLE_SPACE, ///
21
- html = node.asHTML(indent, { ///
22
- tokens,
23
- importer
24
- }),
25
- inputFileHTML = html; ///
26
-
27
- Object.assign(context, {
28
- inputFileHTML
29
- });
30
-
31
- proceed();
32
- }
33
-
34
- module.exports = inputFileHTMLOperation;
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- const { readFile } = require("../utilities/file");
4
-
5
- function readInputFileOperation(proceed, abort, context) {
6
- const { inputFilePath } = context,
7
- inputFileContent = readFile(inputFilePath);
8
-
9
- if (inputFileContent === null) {
10
- abort();
11
- }
12
-
13
- Object.assign(context, {
14
- inputFileContent
15
- });
16
-
17
- proceed();
18
- }
19
-
20
- module.exports = readInputFileOperation;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- const { fileSystemUtilities } = require("necessary");
4
-
5
- const { UNABLE_TO_READ_INPUT_FILE_MESSAGE } = require("../messages");
6
-
7
- const { readFile: readFileAsync } = fileSystemUtilities;
8
-
9
- function readFile(filePath) {
10
- let content = null;
11
-
12
- try {
13
- content = readFileAsync(filePath);
14
-
15
- console.log(`Read file '${filePath}'.`);
16
- } catch (error) {
17
- let message;
18
-
19
- message = UNABLE_TO_READ_INPUT_FILE_MESSAGE;
20
-
21
- console.log(message);
22
-
23
- ({ message } = error);
24
-
25
- console.log(message);
26
- }
27
-
28
- return content;
29
- }
30
-
31
- module.exports = {
32
- readFile
33
- };