highmark-cli 0.0.67 → 0.0.68
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/abbreviations.js +7 -3
- package/bin/action/help.js +2 -2
- package/bin/action/publish.js +31 -0
- package/bin/actions.js +13 -9
- package/bin/commands.js +4 -2
- package/bin/defaults.js +7 -0
- package/bin/importer.js +10 -0
- package/bin/messages.js +13 -0
- package/bin/operation/inputFileContentToHTML.js +29 -0
- package/bin/operation/readInputFile.js +20 -0
- package/bin/options.js +6 -2
- package/bin/utilities/file.js +33 -0
- package/bin/utilities/markdown.js +25 -0
- package/bin/utilities/operation.js +58 -0
- package/package.json +3 -1
package/bin/abbreviations.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
const options = require("./options");
|
|
4
4
|
|
|
5
|
-
const { HELP_OPTION, VERSION_OPTION } = options;
|
|
5
|
+
const { HELP_OPTION, VERSION_OPTION, INPUT_FILE_PATH_OPTION, OUTPUT_FILE_PATH_OPTION } = options;
|
|
6
6
|
|
|
7
7
|
const h = HELP_OPTION,
|
|
8
|
-
v = VERSION_OPTION
|
|
8
|
+
v = VERSION_OPTION,
|
|
9
|
+
i = INPUT_FILE_PATH_OPTION,
|
|
10
|
+
o = OUTPUT_FILE_PATH_OPTION;
|
|
9
11
|
|
|
10
12
|
module.exports = {
|
|
11
13
|
h,
|
|
12
|
-
v
|
|
14
|
+
v,
|
|
15
|
+
i,
|
|
16
|
+
o
|
|
13
17
|
};
|
package/bin/action/help.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const readInputFileOperation = require("../operation/readInputFile"),
|
|
4
|
+
inputFileContentToHTMLOperation = require("../operation/inputFileContentToHTML");
|
|
5
|
+
|
|
6
|
+
const { executeOperations } = require("../utilities/operation"),
|
|
7
|
+
{ SUCCESSFUL_PUBLISH_MESSAGE, FAILED_PUBLISH_MESSAGE } = require("../messages");
|
|
8
|
+
|
|
9
|
+
function publishAction(inputFilePath, outputFilePath) {
|
|
10
|
+
const operations = [
|
|
11
|
+
readInputFileOperation,
|
|
12
|
+
inputFileContentToHTMLOperation
|
|
13
|
+
],
|
|
14
|
+
context = {
|
|
15
|
+
inputFilePath,
|
|
16
|
+
outputFilePath
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
executeOperations(operations, (completed) => {
|
|
20
|
+
const success = completed, ///
|
|
21
|
+
message = success ?
|
|
22
|
+
SUCCESSFUL_PUBLISH_MESSAGE :
|
|
23
|
+
FAILED_PUBLISH_MESSAGE;
|
|
24
|
+
|
|
25
|
+
console.log(message);
|
|
26
|
+
|
|
27
|
+
process.exit();
|
|
28
|
+
}, context);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = publishAction;
|
package/bin/actions.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const helpAction = require("./action/help"),
|
|
4
|
+
versionAction = require("./action/version"),
|
|
5
|
+
publishAction = require("./action/publish");
|
|
5
6
|
|
|
6
|
-
const {
|
|
7
|
-
{
|
|
8
|
-
|
|
7
|
+
const { DEFAULT_INPUT_FILE_PATH } = require("./defaults"),
|
|
8
|
+
{ HELP_OPTION, VERSION_OPTION } = require("./options"),
|
|
9
|
+
{ HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands");
|
|
9
10
|
|
|
10
11
|
function actions(command, argument, options) {
|
|
11
12
|
const commandMissing = (command === null),
|
|
12
13
|
helpOptionPresent = options.hasOwnProperty(HELP_OPTION),
|
|
13
|
-
versionOptionPresent = options.hasOwnProperty(VERSION_OPTION)
|
|
14
|
+
versionOptionPresent = options.hasOwnProperty(VERSION_OPTION),
|
|
15
|
+
{ inputFilePath = DEFAULT_INPUT_FILE_PATH,
|
|
16
|
+
outputFilePath = null } = options;
|
|
14
17
|
|
|
15
18
|
if (false) {
|
|
16
19
|
///
|
|
@@ -21,13 +24,14 @@ function actions(command, argument, options) {
|
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
switch (command) {
|
|
24
|
-
case HELP_COMMAND:
|
|
25
|
-
case VERSION_COMMAND:
|
|
27
|
+
case HELP_COMMAND: helpAction(); break;
|
|
28
|
+
case VERSION_COMMAND: versionAction(); break;
|
|
29
|
+
case PUBLISH_COMMAND: publishAction(inputFilePath, outputFilePath); break;
|
|
26
30
|
|
|
27
31
|
default :
|
|
28
32
|
argument = command; ///
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
publishAction(inputFilePath, outputFilePath);
|
|
31
35
|
|
|
32
36
|
break;
|
|
33
37
|
}
|
package/bin/commands.js
CHANGED
package/bin/defaults.js
ADDED
package/bin/importer.js
ADDED
package/bin/messages.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const FAILED_PUBLISH_MESSAGE = "Failed to publish.",
|
|
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.";
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
FAILED_PUBLISH_MESSAGE,
|
|
10
|
+
SUCCESSFUL_PUBLISH_MESSAGE,
|
|
11
|
+
UNABLE_TO_READ_INPUT_FILE_MESSAGE,
|
|
12
|
+
UNABLE_TO_PARSE_INPUT_FILE_MESSAGE
|
|
13
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const importer = require("../importer");
|
|
4
|
+
|
|
5
|
+
const { nodeFromContent } = require("../utilities/markdown");
|
|
6
|
+
|
|
7
|
+
function inputFileContentToHTMLOperation(proceed, abort, context) {
|
|
8
|
+
const { inputFileContent } = context,
|
|
9
|
+
content = inputFileContent, ///
|
|
10
|
+
node = nodeFromContent(content);
|
|
11
|
+
|
|
12
|
+
if (node === null) {
|
|
13
|
+
abort();
|
|
14
|
+
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const html = node.asHTML({ ///
|
|
19
|
+
importer
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
Object.assign(context, {
|
|
23
|
+
html
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
proceed();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = inputFileContentToHTMLOperation;
|
|
@@ -0,0 +1,20 @@
|
|
|
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/options.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const HELP_OPTION = "help",
|
|
4
|
-
VERSION_OPTION = "version"
|
|
4
|
+
VERSION_OPTION = "version",
|
|
5
|
+
INPUT_FILE_PATH_OPTION = "input-file-path",
|
|
6
|
+
OUTPUT_FILE_PATH_OPTION = "output-file-path";
|
|
5
7
|
|
|
6
8
|
module.exports = {
|
|
7
9
|
HELP_OPTION,
|
|
8
|
-
VERSION_OPTION
|
|
10
|
+
VERSION_OPTION,
|
|
11
|
+
INPUT_FILE_PATH_OPTION,
|
|
12
|
+
OUTPUT_FILE_PATH_OPTION
|
|
9
13
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { MarkdownLexer, MarkdownParser } = require("highmark-markdown");
|
|
4
|
+
|
|
5
|
+
const { UNABLE_TO_PARSE_INPUT_FILE_MESSAGE } = require("../messages");
|
|
6
|
+
|
|
7
|
+
const markdownLexer = MarkdownLexer.fromNothing(),
|
|
8
|
+
markdownParser = MarkdownParser.fromNothing();
|
|
9
|
+
|
|
10
|
+
function nodeFromContent(content) {
|
|
11
|
+
const tokens = markdownLexer.tokenise(content),
|
|
12
|
+
node = markdownParser.parse(tokens);
|
|
13
|
+
|
|
14
|
+
if (node === null) {
|
|
15
|
+
const message = UNABLE_TO_PARSE_INPUT_FILE_MESSAGE;
|
|
16
|
+
|
|
17
|
+
console.log(message);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return node;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
nodeFromContent
|
|
25
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { asynchronousUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { whilst } = asynchronousUtilities;
|
|
6
|
+
|
|
7
|
+
function executeOperations(operations, callback, context) {
|
|
8
|
+
const completed = true;
|
|
9
|
+
|
|
10
|
+
Object.assign(context, {
|
|
11
|
+
operations,
|
|
12
|
+
completed
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
whilst(executeOperation, () => {
|
|
16
|
+
const { completed } = context;
|
|
17
|
+
|
|
18
|
+
delete context.operations;
|
|
19
|
+
|
|
20
|
+
delete context.completed;
|
|
21
|
+
|
|
22
|
+
callback(completed);
|
|
23
|
+
}, context);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
executeOperations
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function executeOperation(next, done, context, index) {
|
|
31
|
+
const { operations } = context,
|
|
32
|
+
operationsLength = operations.length,
|
|
33
|
+
lastIndex = operationsLength - 1;
|
|
34
|
+
|
|
35
|
+
if (index > lastIndex) {
|
|
36
|
+
done();
|
|
37
|
+
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const operation = operations[index];
|
|
42
|
+
|
|
43
|
+
operation(proceed, abort, context);
|
|
44
|
+
|
|
45
|
+
function proceed() {
|
|
46
|
+
next();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function abort() {
|
|
50
|
+
const completed = false;
|
|
51
|
+
|
|
52
|
+
Object.assign(context, {
|
|
53
|
+
completed
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
done();
|
|
57
|
+
}
|
|
58
|
+
}
|
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.68",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/highmark-cli",
|
|
7
7
|
"description": "Extensible, styleable Markdown.",
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.28",
|
|
14
|
+
"highmark-markdown": "^0.0.114",
|
|
15
|
+
"highmark-markdown-style": "^0.0.153",
|
|
14
16
|
"necessary": "^13.4.2"
|
|
15
17
|
},
|
|
16
18
|
"scripts": {},
|