highmark-cli 0.0.73 → 0.0.75
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.
- package/bin/action/publish.js +9 -7
- package/bin/constants.js +2 -0
- package/bin/importer.js +2 -2
- package/bin/messages.js +10 -4
- package/bin/operation/markdownStylesToCSS.js +30 -0
- package/bin/operation/markdownToHTML.js +31 -0
- package/bin/utilities/fileSystem.js +70 -0
- package/bin/utilities/markdown.js +2 -2
- package/bin/utilities/name.js +11 -0
- package/package.json +5 -4
- package/bin/operation/inputFileToHTML.js +0 -34
- package/bin/operation/readInputFile.js +0 -20
- package/bin/utilities/file.js +0 -33
package/bin/action/publish.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const markdownFilePath = inputFilePath, ///
|
|
11
|
+
htmlFilePath = outputFilePath, ///
|
|
12
|
+
operations = [
|
|
13
|
+
markdownToHTMLOperation,
|
|
14
|
+
markdownStylesToCSSOperation
|
|
13
15
|
],
|
|
14
16
|
context = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
htmlFilePath,
|
|
18
|
+
markdownFilePath
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
executeOperations(operations, (completed) => {
|
package/bin/constants.js
CHANGED
package/bin/importer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { readFile } = require("./utilities/
|
|
3
|
+
const { readFile } = require("./utilities/fileSystem");
|
|
4
4
|
const { nodeFromTokens, tokensFromContent } = require("./utilities/markdown");
|
|
5
5
|
|
|
6
|
-
function importer(filePath, indent
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { cssUtilities } = require("highmark-markdown-style"),
|
|
4
|
+
{ filePathUtilities } = require("occam-entities");
|
|
5
|
+
|
|
6
|
+
const { PERIOD } = require("../constants"),
|
|
7
|
+
{ readFile, readDirectory } = require("../utilities/fileSystem");
|
|
8
|
+
|
|
9
|
+
const { isFilePathMarkdownStyleFilePath } = filePathUtilities,
|
|
10
|
+
{ cssFromMarkdownStyleAndSelectorsList } = cssUtilities;
|
|
11
|
+
|
|
12
|
+
function markdownStylesToCSS(proceed, abort, context) {
|
|
13
|
+
const directoryPath = PERIOD; ///
|
|
14
|
+
|
|
15
|
+
readDirectory(directoryPath, (filePath) => {
|
|
16
|
+
const filePathMarkdownStyleFilePath = isFilePathMarkdownStyleFilePath(filePath);
|
|
17
|
+
|
|
18
|
+
if (filePathMarkdownStyleFilePath) {
|
|
19
|
+
const content = readFile(filePath),
|
|
20
|
+
markdownStyle = content, ///
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
debugger
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
proceed();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
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 {
|
|
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 =
|
|
20
|
+
const message = UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE;
|
|
21
21
|
|
|
22
22
|
console.log(message);
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "highmark-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.75",
|
|
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.
|
|
15
|
-
"highmark-markdown-style": "^0.0.
|
|
16
|
-
"necessary": "^13.4.2"
|
|
14
|
+
"highmark-markdown": "^0.0.121",
|
|
15
|
+
"highmark-markdown-style": "^0.0.166",
|
|
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;
|
package/bin/utilities/file.js
DELETED
|
@@ -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
|
-
};
|