highmark-cli 0.0.94 → 0.0.96
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 +13 -1
- package/bin/action/publish.js +9 -4
- package/bin/action/server.js +28 -0
- package/bin/commands.js +2 -0
- package/bin/constants.js +5 -1
- package/bin/defaults.js +7 -1
- package/bin/main.js +49 -2
- package/bin/messages.js +11 -1
- package/bin/operation/copyFonts.js +46 -0
- package/bin/operation/html.js +29 -2
- package/bin/operation/markdownStylesCSS.js +8 -8
- package/bin/operation/server.js +53 -0
- package/bin/options.js +6 -0
- package/bin/paths.js +7 -0
- package/bin/utilities/fileSystem.js +65 -7
- package/bin/utilities/path.js +53 -0
- package/package.json +8 -5
- package/bin/actions.js +0 -40
- package/bin/utilities/name.js +0 -11
package/bin/abbreviations.js
CHANGED
|
@@ -2,16 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
const options = require("./options");
|
|
4
4
|
|
|
5
|
-
const { HELP_OPTION,
|
|
5
|
+
const { HELP_OPTION,
|
|
6
|
+
PORT_OPTION,
|
|
7
|
+
SERVER_OPTION,
|
|
8
|
+
VERSION_OPTION,
|
|
9
|
+
COPY_FONTS_OPTION,
|
|
10
|
+
INPUT_FILE_PATH_OPTION,
|
|
11
|
+
OUTPUT_FILE_PATH_OPTION } = options;
|
|
6
12
|
|
|
7
13
|
const h = HELP_OPTION,
|
|
14
|
+
p = PORT_OPTION,
|
|
15
|
+
s = SERVER_OPTION,
|
|
8
16
|
v = VERSION_OPTION,
|
|
17
|
+
f = COPY_FONTS_OPTION,
|
|
9
18
|
i = INPUT_FILE_PATH_OPTION,
|
|
10
19
|
o = OUTPUT_FILE_PATH_OPTION;
|
|
11
20
|
|
|
12
21
|
module.exports = {
|
|
13
22
|
h,
|
|
23
|
+
p,
|
|
24
|
+
s,
|
|
14
25
|
v,
|
|
26
|
+
f,
|
|
15
27
|
i,
|
|
16
28
|
o
|
|
17
29
|
};
|
package/bin/action/publish.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const htmlOperation = require("../operation/html"),
|
|
4
|
+
serverOperation = require("../operation/server"),
|
|
5
|
+
copyFontsOperation = require("../operation/copyFonts"),
|
|
4
6
|
markdownHTMLOperation = require("../operation/markdownHTML"),
|
|
5
7
|
markdownStylesCSSOperation = require("../operation/markdownStylesCSS");
|
|
6
8
|
|
|
7
9
|
const { executeOperations } = require("../utilities/operation"),
|
|
8
10
|
{ SUCCESSFUL_PUBLISH_MESSAGE, FAILED_PUBLISH_MESSAGE } = require("../messages");
|
|
9
11
|
|
|
10
|
-
function publishAction(inputFilePath, outputFilePath) {
|
|
12
|
+
function publishAction(port, server, copyFonts, inputFilePath, outputFilePath) {
|
|
11
13
|
const operations = [
|
|
12
14
|
markdownStylesCSSOperation,
|
|
13
15
|
markdownHTMLOperation,
|
|
14
|
-
|
|
16
|
+
copyFontsOperation,
|
|
17
|
+
htmlOperation,
|
|
18
|
+
serverOperation
|
|
15
19
|
],
|
|
16
20
|
context = {
|
|
21
|
+
port,
|
|
22
|
+
server,
|
|
23
|
+
copyFonts,
|
|
17
24
|
inputFilePath,
|
|
18
25
|
outputFilePath
|
|
19
26
|
};
|
|
@@ -25,8 +32,6 @@ function publishAction(inputFilePath, outputFilePath) {
|
|
|
25
32
|
FAILED_PUBLISH_MESSAGE;
|
|
26
33
|
|
|
27
34
|
console.log(message);
|
|
28
|
-
|
|
29
|
-
process.exit();
|
|
30
35
|
}, context);
|
|
31
36
|
}
|
|
32
37
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const serverOperation = require("../operation/server");
|
|
4
|
+
|
|
5
|
+
const { executeOperations } = require("../utilities/operation"),
|
|
6
|
+
{ SUCCESSFUL_SERVER_MESSAGE, FAILED_SERVER_MESSAGE } = require("../messages");
|
|
7
|
+
|
|
8
|
+
function serverAction(port, server, outputFilePath) {
|
|
9
|
+
const operations = [
|
|
10
|
+
serverOperation
|
|
11
|
+
],
|
|
12
|
+
context = {
|
|
13
|
+
port,
|
|
14
|
+
server,
|
|
15
|
+
outputFilePath
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
executeOperations(operations, (completed) => {
|
|
19
|
+
const success = completed, ///
|
|
20
|
+
message = success ?
|
|
21
|
+
SUCCESSFUL_SERVER_MESSAGE :
|
|
22
|
+
FAILED_SERVER_MESSAGE;
|
|
23
|
+
|
|
24
|
+
console.log(message);
|
|
25
|
+
}, context);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = serverAction;
|
package/bin/commands.js
CHANGED
package/bin/constants.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const FONT = "font",
|
|
4
|
+
ERROR = "error",
|
|
5
|
+
PERIOD = ".",
|
|
4
6
|
EMPTY_STRING = "",
|
|
5
7
|
DOUBLE_SPACE = " ",
|
|
6
8
|
HIGHMARK_CLI = "Highmark-CLI",
|
|
@@ -8,6 +10,8 @@ const PERIOD = ".",
|
|
|
8
10
|
DEFAULT_DIVISION_IDENTIFIER = "default";
|
|
9
11
|
|
|
10
12
|
module.exports = {
|
|
13
|
+
FONT,
|
|
14
|
+
ERROR,
|
|
11
15
|
PERIOD,
|
|
12
16
|
EMPTY_STRING,
|
|
13
17
|
DOUBLE_SPACE,
|
package/bin/defaults.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const DEFAULT_PORT = 8888,
|
|
4
|
+
DEFAULT_SERVER = false,
|
|
5
|
+
DEFAULT_COPY_FONTS = false,
|
|
6
|
+
DEFAULT_INPUT_FILE_PATH = "default.md",
|
|
4
7
|
DEFAULT_OUTPUT_FILE_PATH = "index.html";
|
|
5
8
|
|
|
6
9
|
module.exports = {
|
|
10
|
+
DEFAULT_PORT,
|
|
11
|
+
DEFAULT_SERVER,
|
|
12
|
+
DEFAULT_COPY_FONTS,
|
|
7
13
|
DEFAULT_INPUT_FILE_PATH,
|
|
8
14
|
DEFAULT_OUTPUT_FILE_PATH
|
|
9
15
|
};
|
package/bin/main.js
CHANGED
|
@@ -1,9 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const helpAction = require("./action/help"),
|
|
4
|
+
serverAction = require("./action/server"),
|
|
5
|
+
versionAction = require("./action/version"),
|
|
6
|
+
publishAction = require("./action/publish");
|
|
7
|
+
|
|
8
|
+
const { HELP_OPTION, SERVER_OPTION, VERSION_OPTION } = require("./options"),
|
|
9
|
+
{ HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
|
|
10
|
+
{ DEFAULT_PORT,
|
|
11
|
+
DEFAULT_SERVER,
|
|
12
|
+
DEFAULT_COPY_FONTS,
|
|
13
|
+
DEFAULT_INPUT_FILE_PATH,
|
|
14
|
+
DEFAULT_OUTPUT_FILE_PATH } = require("./defaults");
|
|
4
15
|
|
|
5
16
|
function main(command, argument, options) {
|
|
6
|
-
|
|
17
|
+
const commandMissing = (command === null),
|
|
18
|
+
helpOptionPresent = options.hasOwnProperty(HELP_OPTION),
|
|
19
|
+
serverOptionPresent = options.hasOwnProperty(SERVER_OPTION),
|
|
20
|
+
versionOptionPresent = options.hasOwnProperty(VERSION_OPTION),
|
|
21
|
+
{ port = DEFAULT_PORT,
|
|
22
|
+
server = DEFAULT_SERVER,
|
|
23
|
+
copyFonts = DEFAULT_COPY_FONTS,
|
|
24
|
+
inputFilePath = DEFAULT_INPUT_FILE_PATH,
|
|
25
|
+
outputFilePath = DEFAULT_OUTPUT_FILE_PATH } = options;
|
|
26
|
+
|
|
27
|
+
if (false) {
|
|
28
|
+
///
|
|
29
|
+
} else if (versionOptionPresent) {
|
|
30
|
+
command = VERSION_COMMAND;
|
|
31
|
+
} else if (commandMissing) {
|
|
32
|
+
if (false) {
|
|
33
|
+
///
|
|
34
|
+
} else if (helpOptionPresent) {
|
|
35
|
+
command = HELP_COMMAND;
|
|
36
|
+
} else if (serverOptionPresent) {
|
|
37
|
+
command = SERVER_COMMAND;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
switch (command) {
|
|
42
|
+
case HELP_COMMAND: helpAction(); break;
|
|
43
|
+
case SERVER_COMMAND: serverAction(port, server, outputFilePath); break;
|
|
44
|
+
case VERSION_COMMAND: versionAction(); break;
|
|
45
|
+
case PUBLISH_COMMAND: publishAction(port, server, copyFonts, inputFilePath, outputFilePath); break;
|
|
46
|
+
|
|
47
|
+
default :
|
|
48
|
+
argument = command; ///
|
|
49
|
+
|
|
50
|
+
publishAction(port, server, copyFonts, inputFilePath, outputFilePath);
|
|
51
|
+
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
7
54
|
}
|
|
8
55
|
|
|
9
56
|
module.exports = main;
|
package/bin/messages.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const FAILED_SERVER_MESSAGE = "Failed to serve.",
|
|
4
|
+
FAILED_PUBLISH_MESSAGE = "Failed to publish.",
|
|
5
|
+
SUCCESSFUL_SERVER_MESSAGE = "Served successfully.",
|
|
4
6
|
SUCCESSFUL_PUBLISH_MESSAGE = "Published successfully.",
|
|
7
|
+
UNABLE_TO_COPY_FILE_MESSAGE = "Unable to copy the file.",
|
|
5
8
|
UNABLE_TO_READ_FILE_MESSAGE = "Unable to read the file.",
|
|
6
9
|
UNABLE_TO_WRITE_FILE_MESSAGE = "Unable to write the file.",
|
|
10
|
+
UNABLE_TO_START_SERVER_MESSAGE = "Unable to start the server",
|
|
7
11
|
UNABLE_TO_READ_DIRECTORY_MESSAGE = "Unable to read the directory.",
|
|
12
|
+
UNABLE_TO_CREATE_DIRECTORY_MESSAGE = "Unable to create the directory.",
|
|
8
13
|
UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE = "Unable to parse the markdown file.",
|
|
9
14
|
UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE = "Unable to convert Markdown to HTML.",
|
|
10
15
|
UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE = "Unable to convert Markdown styles to CSS.";
|
|
11
16
|
|
|
12
17
|
module.exports = {
|
|
18
|
+
FAILED_SERVER_MESSAGE,
|
|
13
19
|
FAILED_PUBLISH_MESSAGE,
|
|
20
|
+
SUCCESSFUL_SERVER_MESSAGE,
|
|
14
21
|
SUCCESSFUL_PUBLISH_MESSAGE,
|
|
22
|
+
UNABLE_TO_COPY_FILE_MESSAGE,
|
|
15
23
|
UNABLE_TO_READ_FILE_MESSAGE,
|
|
16
24
|
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
25
|
+
UNABLE_TO_START_SERVER_MESSAGE,
|
|
17
26
|
UNABLE_TO_READ_DIRECTORY_MESSAGE,
|
|
27
|
+
UNABLE_TO_CREATE_DIRECTORY_MESSAGE,
|
|
18
28
|
UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE,
|
|
19
29
|
UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE,
|
|
20
30
|
UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { pathUtilities } = require("necessary"),
|
|
4
|
+
{ getFontDirectoryPath } = require("highmark-fonts");
|
|
5
|
+
|
|
6
|
+
const { FONT } = require("../constants"),
|
|
7
|
+
{ copyFile, readDirectory, createDirectory } = require("../utilities/fileSystem"),
|
|
8
|
+
{ fileNameFromFilePath, directoryPathFromFilePath } = require("../utilities/path");
|
|
9
|
+
|
|
10
|
+
const { concatenatePaths } = pathUtilities;
|
|
11
|
+
|
|
12
|
+
function copyFontsOperation(proceed, abort, context) {
|
|
13
|
+
const { copyFonts } = context;
|
|
14
|
+
|
|
15
|
+
if (!copyFonts) {
|
|
16
|
+
proceed();
|
|
17
|
+
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let fontDirectoryPath;
|
|
22
|
+
|
|
23
|
+
const { outputFilePath } = context,
|
|
24
|
+
outputDirectoryPath = directoryPathFromFilePath(outputFilePath);
|
|
25
|
+
|
|
26
|
+
fontDirectoryPath = concatenatePaths(outputDirectoryPath, FONT);
|
|
27
|
+
|
|
28
|
+
createDirectory(fontDirectoryPath);
|
|
29
|
+
|
|
30
|
+
fontDirectoryPath = getFontDirectoryPath();
|
|
31
|
+
|
|
32
|
+
const recursive = false,
|
|
33
|
+
targetDirectoryPath = concatenatePaths(outputDirectoryPath, FONT);
|
|
34
|
+
|
|
35
|
+
readDirectory(fontDirectoryPath, (filePath) => {
|
|
36
|
+
const fileName = fileNameFromFilePath(filePath),
|
|
37
|
+
sourceFilePath = filePath, ///
|
|
38
|
+
targetFilePath = concatenatePaths(targetDirectoryPath, fileName); ///
|
|
39
|
+
|
|
40
|
+
copyFile(sourceFilePath, targetFilePath);
|
|
41
|
+
}, recursive);
|
|
42
|
+
|
|
43
|
+
proceed();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = copyFontsOperation;
|
package/bin/operation/html.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { computerModernStyle } = require("highmark-fonts");
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { writeFile } = require("../utilities/fileSystem"),
|
|
6
|
+
{ EMPTY_STRING } = require("../constants");
|
|
6
7
|
|
|
7
8
|
function htmlOperation(proceed, abort, context) {
|
|
8
9
|
const { title, markdownHTML, outputFilePath, markdownStylesCSS } = context,
|
|
@@ -16,6 +17,27 @@ function htmlOperation(proceed, abort, context) {
|
|
|
16
17
|
|
|
17
18
|
<meta charset="utf-8" />
|
|
18
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
|
+
|
|
19
41
|
<style>
|
|
20
42
|
|
|
21
43
|
*,
|
|
@@ -29,6 +51,11 @@ function htmlOperation(proceed, abort, context) {
|
|
|
29
51
|
|
|
30
52
|
</style>
|
|
31
53
|
<style>
|
|
54
|
+
|
|
55
|
+
${computerModernStyle}
|
|
56
|
+
|
|
57
|
+
</style>
|
|
58
|
+
<style>
|
|
32
59
|
|
|
33
60
|
${markdownStylesCSS}
|
|
34
61
|
|
|
@@ -4,21 +4,21 @@ const { filePathUtilities } = require("occam-entities"),
|
|
|
4
4
|
{ cssUtilities, defaultMarkdownStyle } = require("highmark-markdown-style")
|
|
5
5
|
|
|
6
6
|
const { readFile, readDirectory } = require("../utilities/fileSystem"),
|
|
7
|
-
{
|
|
8
|
-
{
|
|
7
|
+
{ DEFAULT_SELECTOR_STRING } = require("../constants"),
|
|
8
|
+
{ directoryPathFromFilePath } = require("../utilities/path"),
|
|
9
|
+
{ divisionClassNameFromFilePath } = require("../utilities/division");
|
|
9
10
|
|
|
10
11
|
const { isFilePathMarkdownStyleFilePath } = filePathUtilities,
|
|
11
12
|
{ cssFromMarkdownStyleAndSelectorString } = cssUtilities;
|
|
12
13
|
|
|
13
14
|
function markdownStylesCSSOperation(proceed, abort, context) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
css = cssFromMarkdownStyleAndSelectorString(markdownStyle, selectorString);
|
|
15
|
+
const { inputFilePath } = context,
|
|
16
|
+
defaultCSS = cssFromMarkdownStyleAndSelectorString(defaultMarkdownStyle, DEFAULT_SELECTOR_STRING),
|
|
17
|
+
inputDirectoryPath = directoryPathFromFilePath(inputFilePath);
|
|
18
18
|
|
|
19
|
-
let markdownStylesCSS =
|
|
19
|
+
let markdownStylesCSS = defaultCSS; ///
|
|
20
20
|
|
|
21
|
-
readDirectory(
|
|
21
|
+
readDirectory(inputDirectoryPath, (filePath) => {
|
|
22
22
|
const filePathMarkdownStyleFilePath = isFilePathMarkdownStyleFilePath(filePath);
|
|
23
23
|
|
|
24
24
|
if (filePathMarkdownStyleFilePath) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const express = require("express");
|
|
4
|
+
|
|
5
|
+
const { createLiveReloadHandler } = require("lively-cli");
|
|
6
|
+
|
|
7
|
+
const { ERROR } = require("../constants"),
|
|
8
|
+
{ LIVE_RELOAD_PATH } = require("../paths"),
|
|
9
|
+
{ directoryPathFromFilePath } = require("../utilities/path"),
|
|
10
|
+
{ UNABLE_TO_START_SERVER_MESSAGE } = require("../messages");
|
|
11
|
+
|
|
12
|
+
function serverOperation(proceed, abort, context) {
|
|
13
|
+
let { server } = context;
|
|
14
|
+
|
|
15
|
+
if (!server) {
|
|
16
|
+
proceed();
|
|
17
|
+
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
server = express(); ///
|
|
22
|
+
|
|
23
|
+
const { port, outputFilePath } = context,
|
|
24
|
+
outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
|
|
25
|
+
liveReloadHandler = createLiveReloadHandler(outputFilePath),
|
|
26
|
+
staticRouter = express.static(outputDirectoryPath);
|
|
27
|
+
|
|
28
|
+
server.use(staticRouter);
|
|
29
|
+
|
|
30
|
+
server.get(LIVE_RELOAD_PATH, liveReloadHandler);
|
|
31
|
+
|
|
32
|
+
const listener = server.listen(port, () => {
|
|
33
|
+
console.log(`Server listening on port ${port}...`);
|
|
34
|
+
|
|
35
|
+
proceed();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
listener.on(ERROR, (error) => {
|
|
39
|
+
let message;
|
|
40
|
+
|
|
41
|
+
message = UNABLE_TO_START_SERVER_MESSAGE;
|
|
42
|
+
|
|
43
|
+
console.log(message);
|
|
44
|
+
|
|
45
|
+
({ message } = error);
|
|
46
|
+
|
|
47
|
+
console.log(message);
|
|
48
|
+
|
|
49
|
+
abort();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = serverOperation;
|
package/bin/options.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const HELP_OPTION = "help",
|
|
4
|
+
PORT_OPTION = "port",
|
|
5
|
+
SERVER_OPTION = "server",
|
|
4
6
|
VERSION_OPTION = "version",
|
|
7
|
+
COPY_FONTS_OPTION = "copy-fonts",
|
|
5
8
|
INPUT_FILE_PATH_OPTION = "input-file-path",
|
|
6
9
|
OUTPUT_FILE_PATH_OPTION = "output-file-path";
|
|
7
10
|
|
|
8
11
|
module.exports = {
|
|
9
12
|
HELP_OPTION,
|
|
13
|
+
PORT_OPTION,
|
|
14
|
+
SERVER_OPTION,
|
|
10
15
|
VERSION_OPTION,
|
|
16
|
+
COPY_FONTS_OPTION,
|
|
11
17
|
INPUT_FILE_PATH_OPTION,
|
|
12
18
|
OUTPUT_FILE_PATH_OPTION
|
|
13
19
|
};
|
package/bin/paths.js
ADDED
|
@@ -2,14 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
const { pathUtilities, fileSystemUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const { isEntryNameHiddenName } = require("../utilities/
|
|
6
|
-
{
|
|
5
|
+
const { isEntryNameHiddenName } = require("../utilities/path"),
|
|
6
|
+
{ UNABLE_TO_COPY_FILE_MESSAGE,
|
|
7
|
+
UNABLE_TO_READ_FILE_MESSAGE,
|
|
8
|
+
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
9
|
+
UNABLE_TO_READ_DIRECTORY_MESSAGE,
|
|
10
|
+
UNABLE_TO_CREATE_DIRECTORY_MESSAGE } = require("../messages");
|
|
7
11
|
|
|
8
12
|
const { concatenatePaths } = pathUtilities,
|
|
9
13
|
{ isEntryFile,
|
|
14
|
+
checkEntryExists,
|
|
15
|
+
copyFile: copyFileAsync,
|
|
10
16
|
readFile: readFileAsync,
|
|
11
17
|
writeFile: writeFileAsync,
|
|
12
|
-
readDirectory: readDirectoryAsync
|
|
18
|
+
readDirectory: readDirectoryAsync,
|
|
19
|
+
createDirectory: createDirectoryAsync } = fileSystemUtilities;
|
|
20
|
+
|
|
21
|
+
function copyFile(sourceFilePath, targetFilePath) {
|
|
22
|
+
let content = null;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
content = copyFileAsync(sourceFilePath, targetFilePath);
|
|
26
|
+
|
|
27
|
+
console.log(`Copy file '${sourceFilePath}' to '${targetFilePath}'.`);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
let message;
|
|
30
|
+
|
|
31
|
+
message = UNABLE_TO_COPY_FILE_MESSAGE;
|
|
32
|
+
|
|
33
|
+
console.log(message);
|
|
34
|
+
|
|
35
|
+
({ message } = error);
|
|
36
|
+
|
|
37
|
+
console.log(message);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return content;
|
|
41
|
+
}
|
|
13
42
|
|
|
14
43
|
function readFile(filePath) {
|
|
15
44
|
let content = null;
|
|
@@ -51,7 +80,7 @@ function writeFile(filePath, content) {
|
|
|
51
80
|
}
|
|
52
81
|
}
|
|
53
82
|
|
|
54
|
-
function readDirectory(directoryPath, callback) {
|
|
83
|
+
function readDirectory(directoryPath, callback, recursive = true) {
|
|
55
84
|
try {
|
|
56
85
|
const entryNames = readDirectoryAsync(directoryPath);
|
|
57
86
|
|
|
@@ -67,9 +96,11 @@ function readDirectory(directoryPath, callback) {
|
|
|
67
96
|
|
|
68
97
|
callback(filePath);
|
|
69
98
|
} else {
|
|
70
|
-
|
|
99
|
+
if (recursive) {
|
|
100
|
+
const directoryPath = entryPath; ///
|
|
71
101
|
|
|
72
|
-
|
|
102
|
+
readDirectory(directoryPath, callback, recursive);
|
|
103
|
+
}
|
|
73
104
|
}
|
|
74
105
|
}
|
|
75
106
|
});
|
|
@@ -86,8 +117,35 @@ function readDirectory(directoryPath, callback) {
|
|
|
86
117
|
}
|
|
87
118
|
}
|
|
88
119
|
|
|
120
|
+
function createDirectory(directoryPath) {
|
|
121
|
+
const entryPath = directoryPath, ///
|
|
122
|
+
entryExists = checkEntryExists(entryPath);
|
|
123
|
+
|
|
124
|
+
if (entryExists) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
createDirectoryAsync(directoryPath);
|
|
130
|
+
|
|
131
|
+
console.log(`Create directory '${directoryPath}'.`);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
let message;
|
|
134
|
+
|
|
135
|
+
message = UNABLE_TO_CREATE_DIRECTORY_MESSAGE;
|
|
136
|
+
|
|
137
|
+
console.log(message);
|
|
138
|
+
|
|
139
|
+
({ message } = error);
|
|
140
|
+
|
|
141
|
+
console.log(message);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
89
145
|
module.exports = {
|
|
146
|
+
copyFile,
|
|
90
147
|
readFile,
|
|
91
148
|
writeFile,
|
|
92
|
-
readDirectory
|
|
149
|
+
readDirectory,
|
|
150
|
+
createDirectory
|
|
93
151
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { pathUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { PERIOD } = require("../constants");
|
|
6
|
+
|
|
7
|
+
const { isPathName, bottommostNameFromPath, pathWithoutBottommostNameFromPath } = pathUtilities;
|
|
8
|
+
|
|
9
|
+
function isFilePathFileName(filePath) {
|
|
10
|
+
const path = filePath, ///
|
|
11
|
+
pathName = isPathName(path),
|
|
12
|
+
filePathFileName = pathName; ///
|
|
13
|
+
|
|
14
|
+
return filePathFileName;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function fileNameFromFilePath(filePath) {
|
|
18
|
+
const path = filePath, ///
|
|
19
|
+
bottommostName = bottommostNameFromPath(path),
|
|
20
|
+
fileName = bottommostName; ///
|
|
21
|
+
|
|
22
|
+
return fileName;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isEntryNameHiddenName(entryName) {
|
|
26
|
+
const nameHiddenName = /^\..+/.test(entryName);
|
|
27
|
+
|
|
28
|
+
return nameHiddenName;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function directoryPathFromFilePath(filePath) {
|
|
32
|
+
let directoryPath;
|
|
33
|
+
|
|
34
|
+
const path = filePath, ///
|
|
35
|
+
pathName = isPathName(path);
|
|
36
|
+
|
|
37
|
+
if (pathName) {
|
|
38
|
+
directoryPath = PERIOD;
|
|
39
|
+
} else {
|
|
40
|
+
const pathWithoutBottommostName = pathWithoutBottommostNameFromPath(path);
|
|
41
|
+
|
|
42
|
+
directoryPath = pathWithoutBottommostName; ///
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return directoryPath;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
isFilePathFileName,
|
|
50
|
+
fileNameFromFilePath,
|
|
51
|
+
isEntryNameHiddenName,
|
|
52
|
+
directoryPathFromFilePath
|
|
53
|
+
};
|
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.96",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/highmark-cli",
|
|
7
7
|
"description": "Extensible, styleable Markdown.",
|
|
@@ -11,10 +11,13 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.28",
|
|
14
|
-
"
|
|
15
|
-
"highmark-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
14
|
+
"express": "^4.19.2",
|
|
15
|
+
"highmark-fonts": "^1.0.30",
|
|
16
|
+
"highmark-markdown": "^0.0.153",
|
|
17
|
+
"highmark-markdown-style": "^0.0.189",
|
|
18
|
+
"lively-cli": "^2.0.55",
|
|
19
|
+
"necessary": "^13.5.5",
|
|
20
|
+
"occam-entities": "^1.0.84"
|
|
18
21
|
},
|
|
19
22
|
"scripts": {},
|
|
20
23
|
"bin": {
|
package/bin/actions.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const helpAction = require("./action/help"),
|
|
4
|
-
versionAction = require("./action/version"),
|
|
5
|
-
publishAction = require("./action/publish");
|
|
6
|
-
|
|
7
|
-
const { DEFAULT_INPUT_FILE_PATH, DEFAULT_OUTPUT_FILE_PATH } = require("./defaults"),
|
|
8
|
-
{ HELP_OPTION, VERSION_OPTION } = require("./options"),
|
|
9
|
-
{ HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands");
|
|
10
|
-
|
|
11
|
-
function actions(command, argument, options) {
|
|
12
|
-
const commandMissing = (command === null),
|
|
13
|
-
helpOptionPresent = options.hasOwnProperty(HELP_OPTION),
|
|
14
|
-
versionOptionPresent = options.hasOwnProperty(VERSION_OPTION),
|
|
15
|
-
{ inputFilePath = DEFAULT_INPUT_FILE_PATH,
|
|
16
|
-
outputFilePath = DEFAULT_OUTPUT_FILE_PATH } = options;
|
|
17
|
-
|
|
18
|
-
if (false) {
|
|
19
|
-
///
|
|
20
|
-
} else if (versionOptionPresent) {
|
|
21
|
-
command = VERSION_COMMAND;
|
|
22
|
-
} else if (commandMissing || helpOptionPresent) {
|
|
23
|
-
command = HELP_COMMAND;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
switch (command) {
|
|
27
|
-
case HELP_COMMAND: helpAction(); break;
|
|
28
|
-
case VERSION_COMMAND: versionAction(); break;
|
|
29
|
-
case PUBLISH_COMMAND: publishAction(inputFilePath, outputFilePath); break;
|
|
30
|
-
|
|
31
|
-
default :
|
|
32
|
-
argument = command; ///
|
|
33
|
-
|
|
34
|
-
publishAction(inputFilePath, outputFilePath);
|
|
35
|
-
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = actions;
|