highmark-cli 0.0.93 → 0.0.95
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/constants.js +5 -1
- package/bin/defaults.js +7 -1
- package/bin/main.js +40 -2
- package/bin/messages.js +4 -0
- package/bin/operation/copyFonts.js +47 -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 +40 -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
|
|
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,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const helpAction = require("./action/help"),
|
|
4
|
+
versionAction = require("./action/version"),
|
|
5
|
+
publishAction = require("./action/publish");
|
|
6
|
+
|
|
7
|
+
const { HELP_OPTION, VERSION_OPTION } = require("./options"),
|
|
8
|
+
{ HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
|
|
9
|
+
{ DEFAULT_PORT,
|
|
10
|
+
DEFAULT_SERVER,
|
|
11
|
+
DEFAULT_COPY_FONTS,
|
|
12
|
+
DEFAULT_INPUT_FILE_PATH,
|
|
13
|
+
DEFAULT_OUTPUT_FILE_PATH } = require("./defaults");
|
|
4
14
|
|
|
5
15
|
function main(command, argument, options) {
|
|
6
|
-
|
|
16
|
+
const commandMissing = (command === null),
|
|
17
|
+
helpOptionPresent = options.hasOwnProperty(HELP_OPTION),
|
|
18
|
+
versionOptionPresent = options.hasOwnProperty(VERSION_OPTION),
|
|
19
|
+
{ port = DEFAULT_PORT,
|
|
20
|
+
server = DEFAULT_SERVER,
|
|
21
|
+
copyFonts = DEFAULT_COPY_FONTS,
|
|
22
|
+
inputFilePath = DEFAULT_INPUT_FILE_PATH,
|
|
23
|
+
outputFilePath = DEFAULT_OUTPUT_FILE_PATH } = options;
|
|
24
|
+
|
|
25
|
+
if (false) {
|
|
26
|
+
///
|
|
27
|
+
} else if (versionOptionPresent) {
|
|
28
|
+
command = VERSION_COMMAND;
|
|
29
|
+
} else if (commandMissing || helpOptionPresent) {
|
|
30
|
+
command = HELP_COMMAND;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
switch (command) {
|
|
34
|
+
case HELP_COMMAND: helpAction(); break;
|
|
35
|
+
case VERSION_COMMAND: versionAction(); break;
|
|
36
|
+
case PUBLISH_COMMAND: publishAction(port, server, copyFonts, inputFilePath, outputFilePath); break;
|
|
37
|
+
|
|
38
|
+
default :
|
|
39
|
+
argument = command; ///
|
|
40
|
+
|
|
41
|
+
publishAction(port, server, copyFonts, inputFilePath, outputFilePath);
|
|
42
|
+
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
7
45
|
}
|
|
8
46
|
|
|
9
47
|
module.exports = main;
|
package/bin/messages.js
CHANGED
|
@@ -4,7 +4,9 @@ const FAILED_PUBLISH_MESSAGE = "Failed to publish.",
|
|
|
4
4
|
SUCCESSFUL_PUBLISH_MESSAGE = "Published successfully.",
|
|
5
5
|
UNABLE_TO_READ_FILE_MESSAGE = "Unable to read the file.",
|
|
6
6
|
UNABLE_TO_WRITE_FILE_MESSAGE = "Unable to write the file.",
|
|
7
|
+
UNABLE_TO_START_SERVER_MESSAGE = "Unable to start the server",
|
|
7
8
|
UNABLE_TO_READ_DIRECTORY_MESSAGE = "Unable to read the directory.",
|
|
9
|
+
UNABLE_TO_CREATE_DIRECTORY_MESSAGE = "Unable to create the directory.",
|
|
8
10
|
UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE = "Unable to parse the markdown file.",
|
|
9
11
|
UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE = "Unable to convert Markdown to HTML.",
|
|
10
12
|
UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE = "Unable to convert Markdown styles to CSS.";
|
|
@@ -14,7 +16,9 @@ module.exports = {
|
|
|
14
16
|
SUCCESSFUL_PUBLISH_MESSAGE,
|
|
15
17
|
UNABLE_TO_READ_FILE_MESSAGE,
|
|
16
18
|
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
19
|
+
UNABLE_TO_START_SERVER_MESSAGE,
|
|
17
20
|
UNABLE_TO_READ_DIRECTORY_MESSAGE,
|
|
21
|
+
UNABLE_TO_CREATE_DIRECTORY_MESSAGE,
|
|
18
22
|
UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE,
|
|
19
23
|
UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE,
|
|
20
24
|
UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { pathUtilities } = require("necessary"),
|
|
4
|
+
{ getFontDirectoryPath } = require("highmark-fonts");
|
|
5
|
+
|
|
6
|
+
const { FONT } = require("../constants"),
|
|
7
|
+
{ fileNameFromFilePath, directoryPathFromFilePath } = require("../utilities/path"),
|
|
8
|
+
{ readFile, writeFile, readDirectory, createDirectory } = require("../utilities/fileSystem");
|
|
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
|
+
|
|
34
|
+
readDirectory(fontDirectoryPath, (filePath) => {
|
|
35
|
+
const content = readFile(filePath),
|
|
36
|
+
fileName = fileNameFromFilePath(filePath),
|
|
37
|
+
directoryPath = concatenatePaths(outputDirectoryPath, FONT);
|
|
38
|
+
|
|
39
|
+
filePath = concatenatePaths(directoryPath, fileName); ///
|
|
40
|
+
|
|
41
|
+
writeFile(filePath, content);
|
|
42
|
+
}, recursive);
|
|
43
|
+
|
|
44
|
+
proceed();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
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,19 @@
|
|
|
2
2
|
|
|
3
3
|
const { pathUtilities, fileSystemUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const { isEntryNameHiddenName } = require("../utilities/
|
|
6
|
-
{ UNABLE_TO_READ_FILE_MESSAGE,
|
|
5
|
+
const { isEntryNameHiddenName } = require("../utilities/path"),
|
|
6
|
+
{ UNABLE_TO_READ_FILE_MESSAGE,
|
|
7
|
+
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
8
|
+
UNABLE_TO_READ_DIRECTORY_MESSAGE,
|
|
9
|
+
UNABLE_TO_CREATE_DIRECTORY_MESSAGE } = require("../messages");
|
|
7
10
|
|
|
8
11
|
const { concatenatePaths } = pathUtilities,
|
|
9
12
|
{ isEntryFile,
|
|
13
|
+
checkEntryExists,
|
|
10
14
|
readFile: readFileAsync,
|
|
11
15
|
writeFile: writeFileAsync,
|
|
12
|
-
readDirectory: readDirectoryAsync
|
|
16
|
+
readDirectory: readDirectoryAsync,
|
|
17
|
+
createDirectory: createDirectoryAsync } = fileSystemUtilities;
|
|
13
18
|
|
|
14
19
|
function readFile(filePath) {
|
|
15
20
|
let content = null;
|
|
@@ -51,7 +56,7 @@ function writeFile(filePath, content) {
|
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
function readDirectory(directoryPath, callback) {
|
|
59
|
+
function readDirectory(directoryPath, callback, recursive = true) {
|
|
55
60
|
try {
|
|
56
61
|
const entryNames = readDirectoryAsync(directoryPath);
|
|
57
62
|
|
|
@@ -67,9 +72,11 @@ function readDirectory(directoryPath, callback) {
|
|
|
67
72
|
|
|
68
73
|
callback(filePath);
|
|
69
74
|
} else {
|
|
70
|
-
|
|
75
|
+
if (recursive) {
|
|
76
|
+
const directoryPath = entryPath; ///
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
readDirectory(directoryPath, callback, recursive);
|
|
79
|
+
}
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
});
|
|
@@ -86,8 +93,34 @@ function readDirectory(directoryPath, callback) {
|
|
|
86
93
|
}
|
|
87
94
|
}
|
|
88
95
|
|
|
96
|
+
function createDirectory(directoryPath) {
|
|
97
|
+
const entryPath = directoryPath, ///
|
|
98
|
+
entryExists = checkEntryExists(entryPath);
|
|
99
|
+
|
|
100
|
+
if (entryExists) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
createDirectoryAsync(directoryPath);
|
|
106
|
+
|
|
107
|
+
console.log(`Create directory '${directoryPath}'.`);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
let message;
|
|
110
|
+
|
|
111
|
+
message = UNABLE_TO_CREATE_DIRECTORY_MESSAGE;
|
|
112
|
+
|
|
113
|
+
console.log(message);
|
|
114
|
+
|
|
115
|
+
({ message } = error);
|
|
116
|
+
|
|
117
|
+
console.log(message);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
89
121
|
module.exports = {
|
|
90
122
|
readFile,
|
|
91
123
|
writeFile,
|
|
92
|
-
readDirectory
|
|
124
|
+
readDirectory,
|
|
125
|
+
createDirectory
|
|
93
126
|
};
|
|
@@ -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.95",
|
|
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;
|