highmark-cli 0.0.95 → 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/action/server.js +28 -0
- package/bin/commands.js +2 -0
- package/bin/main.js +13 -4
- package/bin/messages.js +7 -1
- package/bin/operation/copyFonts.js +8 -9
- package/bin/utilities/fileSystem.js +26 -1
- package/package.json +1 -1
|
@@ -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/main.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const helpAction = require("./action/help"),
|
|
4
|
+
serverAction = require("./action/server"),
|
|
4
5
|
versionAction = require("./action/version"),
|
|
5
6
|
publishAction = require("./action/publish");
|
|
6
7
|
|
|
7
|
-
const { HELP_OPTION, VERSION_OPTION } = require("./options"),
|
|
8
|
-
{ HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
|
|
8
|
+
const { HELP_OPTION, SERVER_OPTION, VERSION_OPTION } = require("./options"),
|
|
9
|
+
{ HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
|
|
9
10
|
{ DEFAULT_PORT,
|
|
10
11
|
DEFAULT_SERVER,
|
|
11
12
|
DEFAULT_COPY_FONTS,
|
|
@@ -15,6 +16,7 @@ const { HELP_OPTION, VERSION_OPTION } = require("./options"),
|
|
|
15
16
|
function main(command, argument, options) {
|
|
16
17
|
const commandMissing = (command === null),
|
|
17
18
|
helpOptionPresent = options.hasOwnProperty(HELP_OPTION),
|
|
19
|
+
serverOptionPresent = options.hasOwnProperty(SERVER_OPTION),
|
|
18
20
|
versionOptionPresent = options.hasOwnProperty(VERSION_OPTION),
|
|
19
21
|
{ port = DEFAULT_PORT,
|
|
20
22
|
server = DEFAULT_SERVER,
|
|
@@ -26,12 +28,19 @@ function main(command, argument, options) {
|
|
|
26
28
|
///
|
|
27
29
|
} else if (versionOptionPresent) {
|
|
28
30
|
command = VERSION_COMMAND;
|
|
29
|
-
} else if (commandMissing
|
|
30
|
-
|
|
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
|
+
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
switch (command) {
|
|
34
42
|
case HELP_COMMAND: helpAction(); break;
|
|
43
|
+
case SERVER_COMMAND: serverAction(port, server, outputFilePath); break;
|
|
35
44
|
case VERSION_COMMAND: versionAction(); break;
|
|
36
45
|
case PUBLISH_COMMAND: publishAction(port, server, copyFonts, inputFilePath, outputFilePath); break;
|
|
37
46
|
|
package/bin/messages.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
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.",
|
|
7
10
|
UNABLE_TO_START_SERVER_MESSAGE = "Unable to start the server",
|
|
@@ -12,8 +15,11 @@ const FAILED_PUBLISH_MESSAGE = "Failed to publish.",
|
|
|
12
15
|
UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE = "Unable to convert Markdown styles to CSS.";
|
|
13
16
|
|
|
14
17
|
module.exports = {
|
|
18
|
+
FAILED_SERVER_MESSAGE,
|
|
15
19
|
FAILED_PUBLISH_MESSAGE,
|
|
20
|
+
SUCCESSFUL_SERVER_MESSAGE,
|
|
16
21
|
SUCCESSFUL_PUBLISH_MESSAGE,
|
|
22
|
+
UNABLE_TO_COPY_FILE_MESSAGE,
|
|
17
23
|
UNABLE_TO_READ_FILE_MESSAGE,
|
|
18
24
|
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
19
25
|
UNABLE_TO_START_SERVER_MESSAGE,
|
|
@@ -4,8 +4,8 @@ const { pathUtilities } = require("necessary"),
|
|
|
4
4
|
{ getFontDirectoryPath } = require("highmark-fonts");
|
|
5
5
|
|
|
6
6
|
const { FONT } = require("../constants"),
|
|
7
|
-
{
|
|
8
|
-
{
|
|
7
|
+
{ copyFile, readDirectory, createDirectory } = require("../utilities/fileSystem"),
|
|
8
|
+
{ fileNameFromFilePath, directoryPathFromFilePath } = require("../utilities/path");
|
|
9
9
|
|
|
10
10
|
const { concatenatePaths } = pathUtilities;
|
|
11
11
|
|
|
@@ -29,16 +29,15 @@ function copyFontsOperation(proceed, abort, context) {
|
|
|
29
29
|
|
|
30
30
|
fontDirectoryPath = getFontDirectoryPath();
|
|
31
31
|
|
|
32
|
-
const recursive = false
|
|
32
|
+
const recursive = false,
|
|
33
|
+
targetDirectoryPath = concatenatePaths(outputDirectoryPath, FONT);
|
|
33
34
|
|
|
34
35
|
readDirectory(fontDirectoryPath, (filePath) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const fileName = fileNameFromFilePath(filePath),
|
|
37
|
+
sourceFilePath = filePath, ///
|
|
38
|
+
targetFilePath = concatenatePaths(targetDirectoryPath, fileName); ///
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
writeFile(filePath, content);
|
|
40
|
+
copyFile(sourceFilePath, targetFilePath);
|
|
42
41
|
}, recursive);
|
|
43
42
|
|
|
44
43
|
proceed();
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
const { pathUtilities, fileSystemUtilities } = require("necessary");
|
|
4
4
|
|
|
5
5
|
const { isEntryNameHiddenName } = require("../utilities/path"),
|
|
6
|
-
{
|
|
6
|
+
{ UNABLE_TO_COPY_FILE_MESSAGE,
|
|
7
|
+
UNABLE_TO_READ_FILE_MESSAGE,
|
|
7
8
|
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
8
9
|
UNABLE_TO_READ_DIRECTORY_MESSAGE,
|
|
9
10
|
UNABLE_TO_CREATE_DIRECTORY_MESSAGE } = require("../messages");
|
|
@@ -11,11 +12,34 @@ const { isEntryNameHiddenName } = require("../utilities/path"),
|
|
|
11
12
|
const { concatenatePaths } = pathUtilities,
|
|
12
13
|
{ isEntryFile,
|
|
13
14
|
checkEntryExists,
|
|
15
|
+
copyFile: copyFileAsync,
|
|
14
16
|
readFile: readFileAsync,
|
|
15
17
|
writeFile: writeFileAsync,
|
|
16
18
|
readDirectory: readDirectoryAsync,
|
|
17
19
|
createDirectory: createDirectoryAsync } = fileSystemUtilities;
|
|
18
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
|
+
}
|
|
42
|
+
|
|
19
43
|
function readFile(filePath) {
|
|
20
44
|
let content = null;
|
|
21
45
|
|
|
@@ -119,6 +143,7 @@ function createDirectory(directoryPath) {
|
|
|
119
143
|
}
|
|
120
144
|
|
|
121
145
|
module.exports = {
|
|
146
|
+
copyFile,
|
|
122
147
|
readFile,
|
|
123
148
|
writeFile,
|
|
124
149
|
readDirectory,
|
package/package.json
CHANGED