highmark-cli 0.0.77 → 0.0.79
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 -9
- package/bin/constants.js +6 -6
- package/bin/messages.js +4 -0
- package/bin/operation/html.js +44 -0
- package/bin/operation/{markdownToHTML.js → markdownHTML.js} +7 -5
- package/bin/operation/{markdownStylesToCSS.js → markdownStylesCSS.js} +17 -14
- package/bin/utilities/division.js +2 -2
- package/bin/utilities/fileSystem.js +25 -3
- package/package.json +3 -3
package/bin/action/publish.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const htmlOperation = require("../operation/html"),
|
|
4
|
+
markdownHTMLOperation = require("../operation/markdownHTML"),
|
|
5
|
+
markdownStylesCSSOperation = require("../operation/markdownStylesCSS");
|
|
5
6
|
|
|
6
7
|
const { executeOperations } = require("../utilities/operation"),
|
|
7
8
|
{ SUCCESSFUL_PUBLISH_MESSAGE, FAILED_PUBLISH_MESSAGE } = require("../messages");
|
|
8
9
|
|
|
9
10
|
function publishAction(inputFilePath, outputFilePath) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
markdownStylesToCSSOperation
|
|
11
|
+
const operations = [
|
|
12
|
+
markdownStylesCSSOperation,
|
|
13
|
+
markdownHTMLOperation,
|
|
14
|
+
htmlOperation
|
|
15
15
|
],
|
|
16
16
|
context = {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
inputFilePath,
|
|
18
|
+
outputFilePath
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
executeOperations(operations, (completed) => {
|
package/bin/constants.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const PERIOD = ".",
|
|
4
|
-
DEFAULT = "default",
|
|
5
|
-
EMPTY_STRING = "",
|
|
6
4
|
DOUBLE_SPACE = " ",
|
|
7
|
-
HIGHMARK_CLI = "Highmark-CLI"
|
|
5
|
+
HIGHMARK_CLI = "Highmark-CLI",
|
|
6
|
+
DEFAULT_SELECTOR_STRING = "div",
|
|
7
|
+
DEFAULT_DIVISION_IDENTIFIER = "default";
|
|
8
8
|
|
|
9
9
|
module.exports = {
|
|
10
10
|
PERIOD,
|
|
11
|
-
DEFAULT,
|
|
12
|
-
EMPTY_STRING,
|
|
13
11
|
DOUBLE_SPACE,
|
|
14
|
-
HIGHMARK_CLI
|
|
12
|
+
HIGHMARK_CLI,
|
|
13
|
+
DEFAULT_SELECTOR_STRING,
|
|
14
|
+
DEFAULT_DIVISION_IDENTIFIER
|
|
15
15
|
};
|
package/bin/messages.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const FAILED_PUBLISH_MESSAGE = "Failed to publish.",
|
|
4
4
|
SUCCESSFUL_PUBLISH_MESSAGE = "Published successfully.",
|
|
5
|
+
NO_OUTPUT_FILE_PATH_MESSAGE = "No output file path has been specified.",
|
|
5
6
|
UNABLE_TO_READ_FILE_MESSAGE = "Unable to read the file.",
|
|
7
|
+
UNABLE_TO_WRITE_FILE_MESSAGE = "Unable to write the file.",
|
|
6
8
|
UNABLE_TO_READ_DIRECTORY_MESSAGE = "Unable to read the directory.",
|
|
7
9
|
UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE = "Unable to parse the markdown file.",
|
|
8
10
|
UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE = "Unable to convert Markdown to HTML.",
|
|
@@ -11,7 +13,9 @@ const FAILED_PUBLISH_MESSAGE = "Failed to publish.",
|
|
|
11
13
|
module.exports = {
|
|
12
14
|
FAILED_PUBLISH_MESSAGE,
|
|
13
15
|
SUCCESSFUL_PUBLISH_MESSAGE,
|
|
16
|
+
NO_OUTPUT_FILE_PATH_MESSAGE,
|
|
14
17
|
UNABLE_TO_READ_FILE_MESSAGE,
|
|
18
|
+
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
15
19
|
UNABLE_TO_READ_DIRECTORY_MESSAGE,
|
|
16
20
|
UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE,
|
|
17
21
|
UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { writeFile } = require("../utilities/fileSystem"),
|
|
4
|
+
{ NO_OUTPUT_FILE_PATH_MESSAGE } = require("../messages");
|
|
5
|
+
|
|
6
|
+
function htmlOperation(proceed, abort, context) {
|
|
7
|
+
const { outputFilePath } = context;
|
|
8
|
+
|
|
9
|
+
if (outputFilePath === null) {
|
|
10
|
+
const message = NO_OUTPUT_FILE_PATH_MESSAGE;
|
|
11
|
+
|
|
12
|
+
console.log(message);
|
|
13
|
+
|
|
14
|
+
abort();
|
|
15
|
+
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { markdownHTML, markdownStylesCSS } = context,
|
|
20
|
+
filePath = outputFilePath, ///
|
|
21
|
+
content = `<!DOCTYPE html>
|
|
22
|
+
<html>
|
|
23
|
+
<head>
|
|
24
|
+
<title>The Foundations of Symbolic Reasoning</title>
|
|
25
|
+
<style>
|
|
26
|
+
|
|
27
|
+
${markdownStylesCSS}
|
|
28
|
+
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
|
|
33
|
+
${markdownHTML}
|
|
34
|
+
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
writeFile(filePath, content);
|
|
40
|
+
|
|
41
|
+
proceed();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = htmlOperation;
|
|
@@ -5,9 +5,9 @@ const importer = require("../importer");
|
|
|
5
5
|
const { DOUBLE_SPACE } = require("../constants"),
|
|
6
6
|
{ UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE } = require("../messages");
|
|
7
7
|
|
|
8
|
-
function
|
|
9
|
-
const {
|
|
10
|
-
filePath =
|
|
8
|
+
function markdownHTMLOperation(proceed, abort, context) {
|
|
9
|
+
const { inputFilePath } = context,
|
|
10
|
+
filePath = inputFilePath, ///
|
|
11
11
|
indent = DOUBLE_SPACE,
|
|
12
12
|
html = importer(filePath, indent);
|
|
13
13
|
|
|
@@ -21,11 +21,13 @@ function markdownToHTML(proceed, abort, context) {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
const markdownHTML = html; ///
|
|
25
|
+
|
|
24
26
|
Object.assign(context, {
|
|
25
|
-
|
|
27
|
+
markdownHTML
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
proceed();
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
module.exports =
|
|
33
|
+
module.exports = markdownHTMLOperation;
|
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
{
|
|
3
|
+
const { filePathUtilities } = require("occam-entities"),
|
|
4
|
+
{ cssUtilities, defaultMarkdownStyle } = require("highmark-markdown-style")
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
{
|
|
8
|
-
{
|
|
6
|
+
const { readFile, readDirectory } = require("../utilities/fileSystem"),
|
|
7
|
+
{ divisionIdentifierFromFilePath } = require("../utilities/division"),
|
|
8
|
+
{ PERIOD, DEFAULT_SELECTOR_STRING } = require("../constants");
|
|
9
9
|
|
|
10
10
|
const { isFilePathMarkdownStyleFilePath } = filePathUtilities,
|
|
11
|
-
{
|
|
11
|
+
{ cssFromMarkdownStyleAndSelectorString } = cssUtilities;
|
|
12
12
|
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
function markdownStylesCSSOperation(proceed, abort, context) {
|
|
14
|
+
const selectorString = DEFAULT_SELECTOR_STRING,
|
|
15
|
+
markdownStyle = defaultMarkdownStyle, ///
|
|
16
|
+
directoryPath = PERIOD, ///
|
|
17
|
+
css = cssFromMarkdownStyleAndSelectorString(markdownStyle, selectorString);
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
let markdownStylesCSS = css; ///
|
|
17
20
|
|
|
18
21
|
readDirectory(directoryPath, (filePath) => {
|
|
19
22
|
const filePathMarkdownStyleFilePath = isFilePathMarkdownStyleFilePath(filePath);
|
|
20
23
|
|
|
21
24
|
if (filePathMarkdownStyleFilePath) {
|
|
22
25
|
const markdownStyleFilePath = filePath, ///
|
|
23
|
-
markdownStyle = markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath),
|
|
24
26
|
selectorString = selectorStringFromMarkdownStyleFilePath(markdownStyleFilePath),
|
|
25
|
-
|
|
27
|
+
markdownStyle = markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath),
|
|
28
|
+
css = cssFromMarkdownStyleAndSelectorString(markdownStyle, selectorString, markdownStylesCSS); ///
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
markdownStylesCSS = `${markdownStylesCSS}${css}`;
|
|
28
31
|
}
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
Object.assign(context, {
|
|
32
|
-
|
|
35
|
+
markdownStylesCSS
|
|
33
36
|
});
|
|
34
37
|
|
|
35
38
|
proceed();
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
module.exports =
|
|
41
|
+
module.exports = markdownStylesCSSOperation;
|
|
39
42
|
|
|
40
43
|
function markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath) {
|
|
41
44
|
const filePath = markdownStyleFilePath, ///
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { pathUtilities, arrayUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { DEFAULT_DIVISION_IDENTIFIER } = require("../constants");
|
|
6
6
|
|
|
7
7
|
const { second } = arrayUtilities,
|
|
8
8
|
{ isPathName, bottommostNameFromPath } = pathUtilities;
|
|
@@ -18,7 +18,7 @@ function divisionIdentifierFromFilePath(filePath) {
|
|
|
18
18
|
matches = name.match(/^([^.]+)\..+$/),
|
|
19
19
|
secondMatch = second(matches);
|
|
20
20
|
|
|
21
|
-
if (secondMatch !==
|
|
21
|
+
if (secondMatch !== DEFAULT_DIVISION_IDENTIFIER) {
|
|
22
22
|
divisionIdentifier = secondMatch; ///
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
const { pathUtilities, fileSystemUtilities } = require("necessary");
|
|
4
4
|
|
|
5
5
|
const { isEntryNameHiddenName } = require("../utilities/name"),
|
|
6
|
-
{ UNABLE_TO_READ_FILE_MESSAGE, UNABLE_TO_READ_DIRECTORY_MESSAGE } = require("../messages");
|
|
6
|
+
{ UNABLE_TO_READ_FILE_MESSAGE, UNABLE_TO_WRITE_FILE_MESSAGE, UNABLE_TO_READ_DIRECTORY_MESSAGE } = require("../messages");
|
|
7
7
|
|
|
8
8
|
const { concatenatePaths } = pathUtilities,
|
|
9
|
-
{ isEntryFile,
|
|
9
|
+
{ isEntryFile,
|
|
10
|
+
readFile: readFileAsync,
|
|
11
|
+
writeFile: writeFileAsync,
|
|
12
|
+
readDirectory: readDirectoryAsync } = fileSystemUtilities;
|
|
10
13
|
|
|
11
14
|
function readFile(filePath) {
|
|
12
15
|
let content = null;
|
|
@@ -30,6 +33,24 @@ function readFile(filePath) {
|
|
|
30
33
|
return content;
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
function writeFile(filePath, content) {
|
|
37
|
+
try {
|
|
38
|
+
writeFileAsync(filePath, content);
|
|
39
|
+
|
|
40
|
+
console.log(`Write file '${filePath}'.`);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
let message;
|
|
43
|
+
|
|
44
|
+
message = UNABLE_TO_WRITE_FILE_MESSAGE;
|
|
45
|
+
|
|
46
|
+
console.log(message);
|
|
47
|
+
|
|
48
|
+
({ message } = error);
|
|
49
|
+
|
|
50
|
+
console.log(message);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
33
54
|
function readDirectory(directoryPath, callback) {
|
|
34
55
|
try {
|
|
35
56
|
const entryNames = readDirectoryAsync(directoryPath);
|
|
@@ -48,7 +69,7 @@ function readDirectory(directoryPath, callback) {
|
|
|
48
69
|
} else {
|
|
49
70
|
const directoryPath = entryPath; ///
|
|
50
71
|
|
|
51
|
-
readDirectory(directoryPath);
|
|
72
|
+
readDirectory(directoryPath, callback);
|
|
52
73
|
}
|
|
53
74
|
}
|
|
54
75
|
});
|
|
@@ -67,5 +88,6 @@ function readDirectory(directoryPath, callback) {
|
|
|
67
88
|
|
|
68
89
|
module.exports = {
|
|
69
90
|
readFile,
|
|
91
|
+
writeFile,
|
|
70
92
|
readDirectory
|
|
71
93
|
};
|
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.79",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/highmark-cli",
|
|
7
7
|
"description": "Extensible, styleable Markdown.",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.28",
|
|
14
|
-
"highmark-markdown": "^0.0.
|
|
15
|
-
"highmark-markdown-style": "^0.0.
|
|
14
|
+
"highmark-markdown": "^0.0.122",
|
|
15
|
+
"highmark-markdown-style": "^0.0.173",
|
|
16
16
|
"necessary": "^13.4.2",
|
|
17
17
|
"occam-entities": "^1.0.83"
|
|
18
18
|
},
|