highmark-cli 0.0.124 → 0.0.126
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/.swcrc +11 -0
- package/bin/abbreviations.js +9 -0
- package/bin/action/help.js +8 -4
- package/bin/action/publish.js +6 -1
- package/bin/action/server.js +3 -1
- package/bin/constants.js +10 -2
- package/bin/defaults.js +6 -0
- package/bin/main.js +11 -5
- package/bin/operation/copyClient.js +60 -0
- package/bin/operation/html.js +27 -12
- package/bin/operation/server.js +9 -7
- package/bin/options.js +7 -1
- package/client.js +32441 -0
- package/lib/client.js +19 -0
- package/lib/view.js +178 -0
- package/package.json +25 -4
- package/src/client.js +21 -0
- package/src/view.js +15 -0
- package/template/client.html +4 -0
- package/template/default.html +1 -18
- package/bin/paths.js +0 -7
package/.swcrc
ADDED
package/bin/abbreviations.js
CHANGED
|
@@ -4,18 +4,24 @@ const options = require("./options");
|
|
|
4
4
|
|
|
5
5
|
const { HELP_OPTION,
|
|
6
6
|
PORT_OPTION,
|
|
7
|
+
WATCH_OPTION,
|
|
7
8
|
SERVER_OPTION,
|
|
8
9
|
VERSION_OPTION,
|
|
10
|
+
QUIETLY_OPTION,
|
|
9
11
|
COPY_FONTS_OPTION,
|
|
12
|
+
COPY_CLIENT_OPTION,
|
|
10
13
|
INPUT_FILE_PATH_OPTION,
|
|
11
14
|
OUTPUT_FILE_PATH_OPTION,
|
|
12
15
|
TEMPLATE_FILE_PATH_OPTION } = options;
|
|
13
16
|
|
|
14
17
|
const h = HELP_OPTION,
|
|
15
18
|
p = PORT_OPTION,
|
|
19
|
+
w = WATCH_OPTION,
|
|
16
20
|
s = SERVER_OPTION,
|
|
17
21
|
v = VERSION_OPTION,
|
|
22
|
+
q = QUIETLY_OPTION,
|
|
18
23
|
f = COPY_FONTS_OPTION,
|
|
24
|
+
c = COPY_CLIENT_OPTION,
|
|
19
25
|
i = INPUT_FILE_PATH_OPTION,
|
|
20
26
|
o = OUTPUT_FILE_PATH_OPTION,
|
|
21
27
|
t = TEMPLATE_FILE_PATH_OPTION;
|
|
@@ -23,9 +29,12 @@ const h = HELP_OPTION,
|
|
|
23
29
|
module.exports = {
|
|
24
30
|
h,
|
|
25
31
|
p,
|
|
32
|
+
w,
|
|
26
33
|
s,
|
|
27
34
|
v,
|
|
35
|
+
q,
|
|
28
36
|
f,
|
|
37
|
+
c,
|
|
29
38
|
i,
|
|
30
39
|
o,
|
|
31
40
|
t
|
package/bin/action/help.js
CHANGED
|
@@ -11,7 +11,7 @@ Commands:
|
|
|
11
11
|
|
|
12
12
|
version Show the version
|
|
13
13
|
|
|
14
|
-
[publish] Publish the input Markdown file to the output HTML file
|
|
14
|
+
[publish] Publish the input Markdown file to the output HTML file
|
|
15
15
|
|
|
16
16
|
Options:
|
|
17
17
|
|
|
@@ -19,15 +19,19 @@ Options:
|
|
|
19
19
|
|
|
20
20
|
--version|-v Show the version
|
|
21
21
|
|
|
22
|
-
--port|-p The server port
|
|
22
|
+
--port|-p The server port, the default being 8888
|
|
23
|
+
|
|
24
|
+
--watch|-w Watch for changes to the client file and in the output directory
|
|
23
25
|
|
|
24
26
|
--server|-s Start a server to view the output file
|
|
25
27
|
|
|
26
28
|
--copy-fonts|-f Copy the fonts to a fonts folder next to the output file
|
|
27
29
|
|
|
28
|
-
--
|
|
30
|
+
--copy-client|-c Copy the bundled client file next to the output file
|
|
31
|
+
|
|
32
|
+
--input-file-path|-i The input file path, the default being 'default.md'
|
|
29
33
|
|
|
30
|
-
--output-file-path|-o The output file path
|
|
34
|
+
--output-file-path|-o The output file path, the default being 'index.html'
|
|
31
35
|
|
|
32
36
|
Further information:
|
|
33
37
|
|
package/bin/action/publish.js
CHANGED
|
@@ -3,24 +3,29 @@
|
|
|
3
3
|
const htmlOperation = require("../operation/html"),
|
|
4
4
|
serverOperation = require("../operation/server"),
|
|
5
5
|
copyFontsOperation = require("../operation/copyFonts"),
|
|
6
|
+
copyClientOperation = require("../operation/copyClient"),
|
|
6
7
|
markdownHTMLOperation = require("../operation/markdownHTML"),
|
|
7
8
|
markdownStylesCSSOperation = require("../operation/markdownStylesCSS");
|
|
8
9
|
|
|
9
10
|
const { executeOperations } = require("../utilities/operation"),
|
|
10
11
|
{ SUCCESSFUL_PUBLISH_MESSAGE, FAILED_PUBLISH_MESSAGE } = require("../messages");
|
|
11
12
|
|
|
12
|
-
function publishAction(port, server, copyFonts, inputFilePath, outputFilePath, templateFilePath) {
|
|
13
|
+
function publishAction(port, watch, server, quietly, copyFonts, copyClient, inputFilePath, outputFilePath, templateFilePath) {
|
|
13
14
|
const operations = [
|
|
14
15
|
markdownStylesCSSOperation,
|
|
15
16
|
markdownHTMLOperation,
|
|
17
|
+
copyClientOperation,
|
|
16
18
|
copyFontsOperation,
|
|
17
19
|
htmlOperation,
|
|
18
20
|
serverOperation
|
|
19
21
|
],
|
|
20
22
|
context = {
|
|
21
23
|
port,
|
|
24
|
+
watch,
|
|
22
25
|
server,
|
|
26
|
+
quietly,
|
|
23
27
|
copyFonts,
|
|
28
|
+
copyClient,
|
|
24
29
|
inputFilePath,
|
|
25
30
|
outputFilePath,
|
|
26
31
|
templateFilePath
|
package/bin/action/server.js
CHANGED
|
@@ -5,13 +5,15 @@ const serverOperation = require("../operation/server");
|
|
|
5
5
|
const { executeOperations } = require("../utilities/operation"),
|
|
6
6
|
{ SUCCESSFUL_SERVER_MESSAGE, FAILED_SERVER_MESSAGE } = require("../messages");
|
|
7
7
|
|
|
8
|
-
function serverAction(port, server, outputFilePath) {
|
|
8
|
+
function serverAction(port, watch, server, quietly, outputFilePath) {
|
|
9
9
|
const operations = [
|
|
10
10
|
serverOperation
|
|
11
11
|
],
|
|
12
12
|
context = {
|
|
13
13
|
port,
|
|
14
|
+
watch,
|
|
14
15
|
server,
|
|
16
|
+
quietly,
|
|
15
17
|
outputFilePath
|
|
16
18
|
};
|
|
17
19
|
|
package/bin/constants.js
CHANGED
|
@@ -3,19 +3,27 @@
|
|
|
3
3
|
const FONT = "font",
|
|
4
4
|
ERROR = "error",
|
|
5
5
|
PERIOD = ".",
|
|
6
|
+
DEFER_DELAY = 100,
|
|
6
7
|
EMPTY_STRING = "",
|
|
7
8
|
HIGHMARK_CLI = "Highmark-CLI",
|
|
8
|
-
|
|
9
|
+
CLIENT_FILE_NAME = "client.js",
|
|
10
|
+
LIVE_RELOAD_PATH = "/live-reload",
|
|
9
11
|
DEFAULT_SELECTOR_STRING = "div",
|
|
12
|
+
CLIENT_TEMPLATE_FILE_PATH = "template/client.html",
|
|
13
|
+
DEFAULT_TEMPLATE_FILE_PATH = "template/default.html",
|
|
10
14
|
DEFAULT_DIVISION_IDENTIFIER = "default";
|
|
11
15
|
|
|
12
16
|
module.exports = {
|
|
13
17
|
FONT,
|
|
14
18
|
ERROR,
|
|
15
19
|
PERIOD,
|
|
20
|
+
DEFER_DELAY,
|
|
16
21
|
EMPTY_STRING,
|
|
17
22
|
HIGHMARK_CLI,
|
|
18
|
-
|
|
23
|
+
CLIENT_FILE_NAME,
|
|
24
|
+
LIVE_RELOAD_PATH,
|
|
19
25
|
DEFAULT_SELECTOR_STRING,
|
|
26
|
+
CLIENT_TEMPLATE_FILE_PATH,
|
|
27
|
+
DEFAULT_TEMPLATE_FILE_PATH,
|
|
20
28
|
DEFAULT_DIVISION_IDENTIFIER
|
|
21
29
|
};
|
package/bin/defaults.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const DEFAULT_PORT = 8888,
|
|
4
|
+
DEFAULT_WATCH = false,
|
|
4
5
|
DEFAULT_SERVER = false,
|
|
6
|
+
DEFAULT_QUIETLY = false,
|
|
5
7
|
DEFAULT_COPY_FONTS = false,
|
|
8
|
+
DEFAULT_COPY_CLIENT = false,
|
|
6
9
|
DEFAULT_INPUT_FILE_PATH = "default.md",
|
|
7
10
|
DEFAULT_OUTPUT_FILE_PATH = "index.html",
|
|
8
11
|
DEFAULT_TEMPLATE_FILE_PATH = null;
|
|
9
12
|
|
|
10
13
|
module.exports = {
|
|
11
14
|
DEFAULT_PORT,
|
|
15
|
+
DEFAULT_WATCH,
|
|
12
16
|
DEFAULT_SERVER,
|
|
17
|
+
DEFAULT_QUIETLY,
|
|
13
18
|
DEFAULT_COPY_FONTS,
|
|
19
|
+
DEFAULT_COPY_CLIENT,
|
|
14
20
|
DEFAULT_INPUT_FILE_PATH,
|
|
15
21
|
DEFAULT_OUTPUT_FILE_PATH,
|
|
16
22
|
DEFAULT_TEMPLATE_FILE_PATH
|
package/bin/main.js
CHANGED
|
@@ -5,11 +5,14 @@ const helpAction = require("./action/help"),
|
|
|
5
5
|
versionAction = require("./action/version"),
|
|
6
6
|
publishAction = require("./action/publish");
|
|
7
7
|
|
|
8
|
-
const {
|
|
9
|
-
{
|
|
8
|
+
const { HELP_OPTION, SERVER_OPTION, VERSION_OPTION } = require("./options"),
|
|
9
|
+
{ HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
|
|
10
10
|
{ DEFAULT_PORT,
|
|
11
|
+
DEFAULT_WATCH,
|
|
11
12
|
DEFAULT_SERVER,
|
|
13
|
+
DEFAULT_QUIETLY,
|
|
12
14
|
DEFAULT_COPY_FONTS,
|
|
15
|
+
DEFAULT_COPY_CLIENT,
|
|
13
16
|
DEFAULT_INPUT_FILE_PATH,
|
|
14
17
|
DEFAULT_OUTPUT_FILE_PATH,
|
|
15
18
|
DEFAULT_TEMPLATE_FILE_PATH } = require("./defaults");
|
|
@@ -20,8 +23,11 @@ function main(command, argument, options) {
|
|
|
20
23
|
serverOptionPresent = options.hasOwnProperty(SERVER_OPTION),
|
|
21
24
|
versionOptionPresent = options.hasOwnProperty(VERSION_OPTION),
|
|
22
25
|
{ port = DEFAULT_PORT,
|
|
26
|
+
watch = DEFAULT_WATCH,
|
|
23
27
|
server = DEFAULT_SERVER,
|
|
28
|
+
quietly = DEFAULT_QUIETLY,
|
|
24
29
|
copyFonts = DEFAULT_COPY_FONTS,
|
|
30
|
+
copyClient = DEFAULT_COPY_CLIENT,
|
|
25
31
|
inputFilePath = DEFAULT_INPUT_FILE_PATH,
|
|
26
32
|
outputFilePath = DEFAULT_OUTPUT_FILE_PATH,
|
|
27
33
|
templateFilePath = DEFAULT_TEMPLATE_FILE_PATH } = options;
|
|
@@ -42,12 +48,12 @@ function main(command, argument, options) {
|
|
|
42
48
|
|
|
43
49
|
switch (command) {
|
|
44
50
|
case HELP_COMMAND: helpAction(); break;
|
|
45
|
-
case SERVER_COMMAND: serverAction(port, server, outputFilePath); break;
|
|
51
|
+
case SERVER_COMMAND: serverAction(port, watch, server, quietly, outputFilePath); break;
|
|
46
52
|
case VERSION_COMMAND: versionAction(); break;
|
|
47
|
-
case PUBLISH_COMMAND: publishAction(port, server, copyFonts, inputFilePath, outputFilePath, templateFilePath); break;
|
|
53
|
+
case PUBLISH_COMMAND: publishAction(port, watch, server, quietly, copyFonts, copyClient, inputFilePath, outputFilePath, templateFilePath); break;
|
|
48
54
|
|
|
49
55
|
default :
|
|
50
|
-
publishAction(port, server, copyFonts, inputFilePath, outputFilePath, templateFilePath);
|
|
56
|
+
publishAction(port, watch, server, quietly, copyFonts, copyClient, inputFilePath, outputFilePath, templateFilePath);
|
|
51
57
|
|
|
52
58
|
break;
|
|
53
59
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { watch: watchFile } = require("lively-cli"),
|
|
4
|
+
{ pathUtilities, packageUtilities } = require("necessary");
|
|
5
|
+
|
|
6
|
+
const { copyFile } = require("../utilities/fileSystem"),
|
|
7
|
+
{ directoryPathFromFilePath } = require("../utilities/path"),
|
|
8
|
+
{ DEFER_DELAY, CLIENT_FILE_NAME } = require("../constants");
|
|
9
|
+
|
|
10
|
+
const { getPackagePath } = packageUtilities,
|
|
11
|
+
{ concatenatePaths } = pathUtilities;
|
|
12
|
+
|
|
13
|
+
function copyClientOperation(proceed, abort, context) {
|
|
14
|
+
const { copyClient } = context;
|
|
15
|
+
|
|
16
|
+
if (!copyClient) {
|
|
17
|
+
proceed();
|
|
18
|
+
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { outputFilePath } = context,
|
|
23
|
+
packagePath = getPackagePath(),
|
|
24
|
+
outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
|
|
25
|
+
sourceClientFilePath = concatenatePaths(packagePath, CLIENT_FILE_NAME),
|
|
26
|
+
targetClientFilePath = concatenatePaths(outputDirectoryPath, CLIENT_FILE_NAME);
|
|
27
|
+
|
|
28
|
+
copyFile(sourceClientFilePath, targetClientFilePath);
|
|
29
|
+
|
|
30
|
+
const { watch } = context;
|
|
31
|
+
|
|
32
|
+
if (!watch) {
|
|
33
|
+
proceed();
|
|
34
|
+
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const watchPattern = sourceClientFilePath, ///
|
|
39
|
+
registerHandler = watchFile(watchPattern);
|
|
40
|
+
|
|
41
|
+
registerHandler(copyClientFile);
|
|
42
|
+
|
|
43
|
+
proceed();
|
|
44
|
+
|
|
45
|
+
function copyClientFile() {
|
|
46
|
+
copyFile(sourceClientFilePath, targetClientFilePath);
|
|
47
|
+
|
|
48
|
+
defer(() => {
|
|
49
|
+
registerHandler(copyClientFile);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = copyClientOperation;
|
|
55
|
+
|
|
56
|
+
function defer(func) {
|
|
57
|
+
const delay = DEFER_DELAY;
|
|
58
|
+
|
|
59
|
+
setTimeout(func, delay);
|
|
60
|
+
}
|
package/bin/operation/html.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { liveReloadSnippet } = require("lively-cli"),
|
|
4
|
+
{ pathUtilities, packageUtilities } = require("necessary"),
|
|
4
5
|
{ computerModernStyle: computerModernStyleCSS } = require("highmark-fonts");
|
|
5
6
|
|
|
6
7
|
const { directoryPathFromFilePath } = require("../utilities/path"),
|
|
7
8
|
{ writeFile, parseTemplateFile } = require("../utilities/fileSystem"),
|
|
8
|
-
{
|
|
9
|
+
{ CLIENT_TEMPLATE_FILE_PATH, DEFAULT_TEMPLATE_FILE_PATH, EMPTY_STRING } = require("../constants");
|
|
9
10
|
|
|
10
11
|
const { getPackagePath } = packageUtilities,
|
|
11
12
|
{ concatenatePaths } = pathUtilities;
|
|
12
13
|
|
|
13
14
|
function htmlOperation(proceed, abort, context) {
|
|
14
|
-
const {
|
|
15
|
-
|
|
15
|
+
const { markdownHTML, outputFilePath, markdownStylesCSS } = context,
|
|
16
|
+
clientHTML = getClientHTML(context),
|
|
16
17
|
templateFilePath = getTemplateFilePath(context),
|
|
17
18
|
args = {
|
|
18
|
-
|
|
19
|
+
clientHTML,
|
|
19
20
|
markdownHTML,
|
|
20
21
|
markdownStylesCSS,
|
|
21
22
|
computerModernStyleCSS
|
|
@@ -29,12 +30,25 @@ function htmlOperation(proceed, abort, context) {
|
|
|
29
30
|
|
|
30
31
|
module.exports = htmlOperation;
|
|
31
32
|
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
EMPTY_STRING :
|
|
35
|
-
`<title>${title}</title>`;
|
|
33
|
+
function getClientHTML(context) {
|
|
34
|
+
let clientHTML;
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
const { copyClient } = context;
|
|
37
|
+
|
|
38
|
+
if (copyClient) {
|
|
39
|
+
const packagePath = getPackagePath(),
|
|
40
|
+
clientTemplateFilePath = concatenatePaths(packagePath, CLIENT_TEMPLATE_FILE_PATH),
|
|
41
|
+
args = {
|
|
42
|
+
liveReloadSnippet
|
|
43
|
+
},
|
|
44
|
+
clientContent = parseTemplateFile(clientTemplateFilePath, args);
|
|
45
|
+
|
|
46
|
+
clientHTML = clientContent; ///
|
|
47
|
+
} else {
|
|
48
|
+
clientHTML = EMPTY_STRING;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return clientHTML;
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
function getTemplateFilePath(context) {
|
|
@@ -43,9 +57,10 @@ function getTemplateFilePath(context) {
|
|
|
43
57
|
({templateFilePath} = context);
|
|
44
58
|
|
|
45
59
|
if (templateFilePath === null) {
|
|
46
|
-
const packagePath = getPackagePath()
|
|
60
|
+
const packagePath = getPackagePath(),
|
|
61
|
+
defaultTemplateFilePath = templateFilePath = concatenatePaths(packagePath, DEFAULT_TEMPLATE_FILE_PATH);
|
|
47
62
|
|
|
48
|
-
templateFilePath =
|
|
63
|
+
templateFilePath = defaultTemplateFilePath; ///
|
|
49
64
|
} else {
|
|
50
65
|
const { inputFilePath } = context,
|
|
51
66
|
inputDirectoryPath = directoryPathFromFilePath(inputFilePath);
|
package/bin/operation/server.js
CHANGED
|
@@ -4,8 +4,7 @@ const express = require("express");
|
|
|
4
4
|
|
|
5
5
|
const { createLiveReloadHandler } = require("lively-cli");
|
|
6
6
|
|
|
7
|
-
const { ERROR } = require("../constants"),
|
|
8
|
-
{ LIVE_RELOAD_PATH } = require("../paths"),
|
|
7
|
+
const { ERROR, LIVE_RELOAD_PATH } = require("../constants"),
|
|
9
8
|
{ directoryPathFromFilePath } = require("../utilities/path"),
|
|
10
9
|
{ UNABLE_TO_START_SERVER_MESSAGE } = require("../messages");
|
|
11
10
|
|
|
@@ -18,17 +17,20 @@ function serverOperation(proceed, abort, context) {
|
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
const { port, outputFilePath } = context,
|
|
20
|
+
const { port, watch, quietly, outputFilePath } = context,
|
|
22
21
|
outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
|
|
23
|
-
|
|
24
|
-
staticRouter = express.static(outputDirectoryPath),
|
|
25
|
-
liveReloadHandler = createLiveReloadHandler(watchPattern);
|
|
22
|
+
staticRouter = express.static(outputDirectoryPath);
|
|
26
23
|
|
|
27
24
|
server = express(); ///
|
|
28
25
|
|
|
29
26
|
server.use(staticRouter);
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
if (watch) {
|
|
29
|
+
const watchPattern = outputDirectoryPath, ///
|
|
30
|
+
liveReloadHandler = createLiveReloadHandler(watchPattern, quietly);
|
|
31
|
+
|
|
32
|
+
server.get(LIVE_RELOAD_PATH, liveReloadHandler);
|
|
33
|
+
}
|
|
32
34
|
|
|
33
35
|
const listener = server.listen(port, () => {
|
|
34
36
|
console.log(`Server listening on port ${port}...`);
|
package/bin/options.js
CHANGED
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
const HELP_OPTION = "help",
|
|
4
4
|
PORT_OPTION = "port",
|
|
5
|
+
WATCH_OPTION = "watch",
|
|
5
6
|
SERVER_OPTION = "server",
|
|
6
7
|
VERSION_OPTION = "version",
|
|
8
|
+
QUIETLY_OPTION = "quietly",
|
|
7
9
|
COPY_FONTS_OPTION = "copy-fonts",
|
|
10
|
+
COPY_CLIENT_OPTION = "copy-client",
|
|
8
11
|
INPUT_FILE_PATH_OPTION = "input-file-path",
|
|
9
12
|
OUTPUT_FILE_PATH_OPTION = "output-file-path",
|
|
10
|
-
TEMPLATE_FILE_PATH_OPTION = "
|
|
13
|
+
TEMPLATE_FILE_PATH_OPTION = "output-file-path";
|
|
11
14
|
|
|
12
15
|
module.exports = {
|
|
13
16
|
HELP_OPTION,
|
|
14
17
|
PORT_OPTION,
|
|
18
|
+
WATCH_OPTION,
|
|
15
19
|
SERVER_OPTION,
|
|
16
20
|
VERSION_OPTION,
|
|
21
|
+
QUIETLY_OPTION,
|
|
17
22
|
COPY_FONTS_OPTION,
|
|
23
|
+
COPY_CLIENT_OPTION,
|
|
18
24
|
INPUT_FILE_PATH_OPTION,
|
|
19
25
|
OUTPUT_FILE_PATH_OPTION,
|
|
20
26
|
TEMPLATE_FILE_PATH_OPTION
|