highmark-cli 1.2.12 → 1.3.1
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/setOptions.js +39 -0
- package/bin/commands.js +4 -2
- package/bin/configuration/version_1_2.js +1 -17
- package/bin/configuration/version_1_3.js +50 -0
- package/bin/configuration.js +39 -27
- package/bin/constants.js +10 -0
- package/bin/defaults.js +1 -1
- package/bin/descriptions.js +11 -0
- package/bin/jsonTypes.js +13 -0
- package/bin/main.js +9 -2
- package/bin/messages.js +10 -0
- package/bin/operation/markdownHTML.js +6 -5
- package/bin/operation/markdownStylesCSS.js +4 -7
- package/bin/operation/prompt/charactersPerLine.js +45 -0
- package/bin/operation/prompt/contentsDepth.js +45 -0
- package/bin/operation/prompt/linesPerPage.js +51 -0
- package/bin/operation/setOptions.js +18 -0
- package/bin/utilities/json.js +162 -0
- package/bin/utilities/type.js +83 -0
- package/bin/utilities/validate.js +13 -0
- package/bin/versions.js +4 -2
- package/package.json +3 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const setOptionsOperation = require("../operation/setOptions"),
|
|
4
|
+
linesPerPagePromptOperation = require("../operation/prompt/linesPerPage"),
|
|
5
|
+
contentsDepthPromptOperation = require("../operation/prompt/contentsDepth"),
|
|
6
|
+
charactersPerLinePromptOperation = require("../operation/prompt/charactersPerLine");
|
|
7
|
+
|
|
8
|
+
const { retrieveOptions } = require("../configuration"),
|
|
9
|
+
{ executeOperations } = require("../utilities/operation"),
|
|
10
|
+
{ SUCCESSFUL_SET_OPTIONS_MESSAGE, FAILED_SET_OPTIONS_MESSAGE } = require("../messages");
|
|
11
|
+
|
|
12
|
+
function setOptionsAction() {
|
|
13
|
+
const options = retrieveOptions(),
|
|
14
|
+
{ linesPerPage,
|
|
15
|
+
contentsDepth,
|
|
16
|
+
charactersPerLine } = options,
|
|
17
|
+
operations = [
|
|
18
|
+
contentsDepthPromptOperation,
|
|
19
|
+
linesPerPagePromptOperation,
|
|
20
|
+
charactersPerLinePromptOperation,
|
|
21
|
+
setOptionsOperation
|
|
22
|
+
],
|
|
23
|
+
context = {
|
|
24
|
+
linesPerPage,
|
|
25
|
+
contentsDepth,
|
|
26
|
+
charactersPerLine
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
executeOperations(operations, (completed) => {
|
|
30
|
+
const success = completed, ///
|
|
31
|
+
message = success ?
|
|
32
|
+
SUCCESSFUL_SET_OPTIONS_MESSAGE :
|
|
33
|
+
FAILED_SET_OPTIONS_MESSAGE;
|
|
34
|
+
|
|
35
|
+
console.log(message);
|
|
36
|
+
}, context);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = setOptionsAction;
|
package/bin/commands.js
CHANGED
|
@@ -4,12 +4,14 @@ const HELP_COMMAND = "help",
|
|
|
4
4
|
SERVER_COMMAND = "server",
|
|
5
5
|
VERSION_COMMAND = "version",
|
|
6
6
|
PUBLISH_COMMAND = 'publish',
|
|
7
|
-
INITIALISE_COMMAND = 'initialise'
|
|
7
|
+
INITIALISE_COMMAND = 'initialise',
|
|
8
|
+
SET_OPTIONS_COMMAND = "set-options";
|
|
8
9
|
|
|
9
10
|
module.exports = {
|
|
10
11
|
HELP_COMMAND,
|
|
11
12
|
SERVER_COMMAND,
|
|
12
13
|
VERSION_COMMAND,
|
|
13
14
|
PUBLISH_COMMAND,
|
|
14
|
-
INITIALISE_COMMAND
|
|
15
|
+
INITIALISE_COMMAND,
|
|
16
|
+
SET_OPTIONS_COMMAND
|
|
15
17
|
};
|
|
@@ -2,22 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { VERSION_1_2 } = require("../versions");
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
function createConfiguration() {
|
|
8
|
-
const version = VERSION_1_2,
|
|
9
|
-
linesPerPage = DEFAULT_LINES_PER_PAGE,
|
|
10
|
-
contentsDepth = DEFAULT_CONTENTS_DEPTH,
|
|
11
|
-
charactersPerLine = DEFAULT_CHARACTERS_PER_LINE,
|
|
12
|
-
configuration = {
|
|
13
|
-
version,
|
|
14
|
-
linesPerPage,
|
|
15
|
-
contentsDepth,
|
|
16
|
-
charactersPerLine
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return configuration;
|
|
20
|
-
}
|
|
5
|
+
const { DEFAULT_LINES_PER_PAGE, DEFAULT_CHARACTERS_PER_LINE } = require("../defaults");
|
|
21
6
|
|
|
22
7
|
function migrateToVersion1_2(json) {
|
|
23
8
|
const version = VERSION_1_2,
|
|
@@ -33,6 +18,5 @@ function migrateToVersion1_2(json) {
|
|
|
33
18
|
return json;
|
|
34
19
|
}
|
|
35
20
|
module.exports = {
|
|
36
|
-
createConfiguration,
|
|
37
21
|
migrateToVersion1_2
|
|
38
22
|
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { VERSION_1_3 } = require("../versions");
|
|
4
|
+
|
|
5
|
+
const { DEFAULT_CONTENTS_DEPTH, DEFAULT_LINES_PER_PAGE, DEFAULT_CHARACTERS_PER_LINE } = require("../defaults");
|
|
6
|
+
|
|
7
|
+
function createConfiguration() {
|
|
8
|
+
const version = VERSION_1_3,
|
|
9
|
+
linesPerPage = DEFAULT_LINES_PER_PAGE,
|
|
10
|
+
contentsDepth = DEFAULT_CONTENTS_DEPTH,
|
|
11
|
+
charactersPerLine = DEFAULT_CHARACTERS_PER_LINE,
|
|
12
|
+
options = {
|
|
13
|
+
linesPerPage,
|
|
14
|
+
contentsDepth,
|
|
15
|
+
charactersPerLine
|
|
16
|
+
},
|
|
17
|
+
configuration = {
|
|
18
|
+
version,
|
|
19
|
+
options
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return configuration;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function migrateToVersion1_3(json) {
|
|
26
|
+
const { linesPerPage,
|
|
27
|
+
contentsDepth,
|
|
28
|
+
charactersPerLine } = json,
|
|
29
|
+
version = VERSION_1_3,
|
|
30
|
+
options = {
|
|
31
|
+
linesPerPage,
|
|
32
|
+
contentsDepth,
|
|
33
|
+
charactersPerLine
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
delete json.linesPerPage;
|
|
37
|
+
delete json.contentsDepth;
|
|
38
|
+
delete json.charactersPerLine;
|
|
39
|
+
|
|
40
|
+
json = Object.assign({}, json, {
|
|
41
|
+
version,
|
|
42
|
+
options
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return json;
|
|
46
|
+
}
|
|
47
|
+
module.exports = {
|
|
48
|
+
createConfiguration,
|
|
49
|
+
migrateToVersion1_3
|
|
50
|
+
};
|
package/bin/configuration.js
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
const { versionUtilities, configurationUtilities } = require("necessary");
|
|
4
4
|
|
|
5
5
|
const { HIGHMARK } = require("./constants"),
|
|
6
|
-
{ VERSION_1_0, VERSION_1_1, VERSION_1_2 } = require("./versions"),
|
|
7
6
|
{ migrateToVersion1_1 } = require("./configuration/version_1_1"),
|
|
8
|
-
{
|
|
9
|
-
{
|
|
7
|
+
{ migrateToVersion1_2 } = require("./configuration/version_1_2"),
|
|
8
|
+
{ serialiseJSON, unserialiseJSON } = require("./utilities/json"),
|
|
9
|
+
{ createConfiguration, migrateToVersion1_3 } = require("./configuration/version_1_3"),
|
|
10
|
+
{ CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE } = require("./messages"),
|
|
11
|
+
{ VERSION_1_0, VERSION_1_1, VERSION_1_2, VERSION_1_3 } = require("./versions");
|
|
10
12
|
|
|
11
13
|
const { rc } = configurationUtilities,
|
|
12
14
|
{ migrate } = versionUtilities,
|
|
@@ -16,30 +18,25 @@ const rcBaseExtension = HIGHMARK; ///
|
|
|
16
18
|
|
|
17
19
|
setRCBaseExtension(rcBaseExtension);
|
|
18
20
|
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return linesPerPage;
|
|
21
|
+
function updateOptions(options) {
|
|
22
|
+
updateConfigurationFile({
|
|
23
|
+
options
|
|
24
|
+
});
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
function
|
|
27
|
+
function retrieveOptions() {
|
|
27
28
|
const configuration = readConfigurationFile(),
|
|
28
|
-
{
|
|
29
|
+
{ options } = configuration;
|
|
29
30
|
|
|
30
|
-
return
|
|
31
|
+
return options;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
function
|
|
34
|
-
const configuration =
|
|
35
|
-
{ charactersPerLine } = configuration;
|
|
34
|
+
function createConfigurationFile() {
|
|
35
|
+
const configuration = createConfiguration();
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
}
|
|
37
|
+
let json = configuration; ///
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
const configuration = createConfiguration(),
|
|
42
|
-
json = configuration; ///
|
|
39
|
+
json = serialiseJSON(json); ///
|
|
43
40
|
|
|
44
41
|
writeRCFile(json);
|
|
45
42
|
}
|
|
@@ -49,14 +46,19 @@ function migrateConfigurationFile() {
|
|
|
49
46
|
|
|
50
47
|
let json = readRCFile();
|
|
51
48
|
|
|
49
|
+
json = unserialiseJSON(json); ///
|
|
50
|
+
|
|
52
51
|
const migrationMap = {
|
|
53
52
|
[VERSION_1_0]: migrateToVersion1_1,
|
|
54
|
-
[VERSION_1_1]: migrateToVersion1_2
|
|
53
|
+
[VERSION_1_1]: migrateToVersion1_2,
|
|
54
|
+
[VERSION_1_2]: migrateToVersion1_3
|
|
55
55
|
},
|
|
56
|
-
latestVersion =
|
|
56
|
+
latestVersion = VERSION_1_3;
|
|
57
57
|
|
|
58
58
|
json = migrate(json, migrationMap, latestVersion);
|
|
59
59
|
|
|
60
|
+
json = serialiseJSON(json); ///
|
|
61
|
+
|
|
60
62
|
writeRCFile(json);
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -78,9 +80,8 @@ function assertConfigurationFileExists() {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
module.exports = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
getCharactersPerLine,
|
|
83
|
+
updateOptions,
|
|
84
|
+
retrieveOptions,
|
|
84
85
|
createConfigurationFile,
|
|
85
86
|
migrateConfigurationFile,
|
|
86
87
|
checkConfigurationFileExists,
|
|
@@ -90,8 +91,11 @@ module.exports = {
|
|
|
90
91
|
function readConfigurationFile() {
|
|
91
92
|
assertConfigurationFileExists();
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
let json = readRCFile();
|
|
95
|
+
|
|
96
|
+
json = unserialiseJSON(json); ///
|
|
97
|
+
|
|
98
|
+
const configuration = json; ///
|
|
95
99
|
|
|
96
100
|
return configuration;
|
|
97
101
|
}
|
|
@@ -99,7 +103,9 @@ function readConfigurationFile() {
|
|
|
99
103
|
function writeConfigurationFile(configuration) {
|
|
100
104
|
assertConfigurationFileExists();
|
|
101
105
|
|
|
102
|
-
|
|
106
|
+
let json = configuration; ///
|
|
107
|
+
|
|
108
|
+
json = serialiseJSON(json); ///
|
|
103
109
|
|
|
104
110
|
writeRCFile(json);
|
|
105
111
|
}
|
|
@@ -107,6 +113,12 @@ function writeConfigurationFile(configuration) {
|
|
|
107
113
|
function updateConfigurationFile(addedConfiguration, ...deleteConfigurationNames) {
|
|
108
114
|
assertConfigurationFileExists();
|
|
109
115
|
|
|
116
|
+
let json = addedConfiguration; ///
|
|
117
|
+
|
|
118
|
+
json = serialiseJSON(json); ///
|
|
119
|
+
|
|
120
|
+
addedConfiguration = json; ///
|
|
121
|
+
|
|
110
122
|
const addedProperties = addedConfiguration, ///
|
|
111
123
|
deletedPropertyNames = deleteConfigurationNames; ///
|
|
112
124
|
|
package/bin/constants.js
CHANGED
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
const FONT = "font",
|
|
4
4
|
ERROR = "error",
|
|
5
|
+
STRING = "string",
|
|
6
|
+
NUMBER = "number",
|
|
7
|
+
BOOLEAN = "boolean",
|
|
5
8
|
HIGHMARK = "highmark",
|
|
9
|
+
INFINITY = "Infinity",
|
|
6
10
|
DOUBLE_DOTS = "..",
|
|
11
|
+
EMPTY_STRING = "",
|
|
7
12
|
HIGHMARK_CLI = "Highmark-CLI",
|
|
8
13
|
LIVE_RELOAD_PATH = "/live-reload",
|
|
9
14
|
DIVS_SELECTOR_STRING = "body > div",
|
|
@@ -12,8 +17,13 @@ const FONT = "font",
|
|
|
12
17
|
module.exports = {
|
|
13
18
|
FONT,
|
|
14
19
|
ERROR,
|
|
20
|
+
STRING,
|
|
21
|
+
NUMBER,
|
|
22
|
+
BOOLEAN,
|
|
15
23
|
HIGHMARK,
|
|
24
|
+
INFINITY,
|
|
16
25
|
DOUBLE_DOTS,
|
|
26
|
+
EMPTY_STRING,
|
|
17
27
|
HIGHMARK_CLI,
|
|
18
28
|
LIVE_RELOAD_PATH,
|
|
19
29
|
DIVS_SELECTOR_STRING,
|
package/bin/defaults.js
CHANGED
|
@@ -8,7 +8,7 @@ const DEFAULT_HELP = false,
|
|
|
8
8
|
DEFAULT_VERSION = false,
|
|
9
9
|
DEFAULT_NO_CLIENT = false,
|
|
10
10
|
DEFAULT_COPY_FONTS = false,
|
|
11
|
-
DEFAULT_LINES_PER_PAGE =
|
|
11
|
+
DEFAULT_LINES_PER_PAGE = Infinity,
|
|
12
12
|
DEFAULT_CONTENTS_DEPTH = 2,
|
|
13
13
|
DEFAULT_INPUT_FILE_NAME = "default.md",
|
|
14
14
|
DEFAULT_COPY_CLIENT_FILES = false,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const LINES_PER_PAGE_DESCRIPTION = "Lines per page (leave blank for default of Infinity): ",
|
|
4
|
+
CONTENTS_DEPTH_DESCRIPTION = "Contents depth (from 1 to 4): ",
|
|
5
|
+
CHARACTERS_PER_LINE_DESCRIPTION = "Characters per line: "
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
LINES_PER_PAGE_DESCRIPTION,
|
|
9
|
+
CONTENTS_DEPTH_DESCRIPTION,
|
|
10
|
+
CHARACTERS_PER_LINE_DESCRIPTION
|
|
11
|
+
};
|
package/bin/jsonTypes.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const NULL_JSON_TYPE = "null",
|
|
4
|
+
ARRAY_JSON_TYPE = "array",
|
|
5
|
+
OBJECT_JSON_TYPE = "object",
|
|
6
|
+
PRIMITIVE_JSON_TYPE = "primitive";
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
NULL_JSON_TYPE,
|
|
10
|
+
ARRAY_JSON_TYPE,
|
|
11
|
+
OBJECT_JSON_TYPE,
|
|
12
|
+
PRIMITIVE_JSON_TYPE
|
|
13
|
+
};
|
package/bin/main.js
CHANGED
|
@@ -4,10 +4,11 @@ const helpAction = require("./action/help"),
|
|
|
4
4
|
serverAction = require("./action/server"),
|
|
5
5
|
versionAction = require("./action/version"),
|
|
6
6
|
publishAction = require("./action/publish"),
|
|
7
|
-
initialiseAction = require("./action/initialise")
|
|
7
|
+
initialiseAction = require("./action/initialise"),
|
|
8
|
+
setOptionsAction = require("./action/setOptions");
|
|
8
9
|
|
|
9
10
|
const { NO_COMMAND_GIVEN_MESSAGE, COMMAND_NOT_RECOGNISED_MESSAGE } = require("./messages"),
|
|
10
|
-
{ HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND, INITIALISE_COMMAND } = require("./commands"),
|
|
11
|
+
{ HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND, INITIALISE_COMMAND, SET_OPTIONS_COMMAND } = require("./commands"),
|
|
11
12
|
{ DEFAULT_PORT,
|
|
12
13
|
DEFAULT_WATCH,
|
|
13
14
|
DEFAULT_QUIETLY,
|
|
@@ -66,6 +67,12 @@ function main(command, argument, options) {
|
|
|
66
67
|
break;
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
case SET_OPTIONS_COMMAND: {
|
|
71
|
+
setOptionsAction();
|
|
72
|
+
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
default: {
|
|
70
77
|
console.log(COMMAND_NOT_RECOGNISED_MESSAGE);
|
|
71
78
|
|
package/bin/messages.js
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
const NO_COMMAND_GIVEN_MESSAGE = "No command has been given.",
|
|
4
4
|
COMMAND_NOT_RECOGNISED_MESSAGE = "The command is not recognised.",
|
|
5
|
+
INVALID_LINES_PER_PAGE_MESSAGE = "The lines per page must either be a number or left blank for the default of Infinity, which effectively suppresses pagination.",
|
|
6
|
+
INVALID_CONTENTS_DEPTH_MESSAGE = "The contents depth must be a number between 1 and 4 inclusive, with 1 being primary headings only, 4 down to quaternary headings.",
|
|
7
|
+
INVALID_CHARACTERS_PER_LINE_MESSAGE = "The characters per line must a number.",
|
|
5
8
|
FAILED_SERVER_MESSAGE = "Failed to serve.",
|
|
6
9
|
FAILED_PUBLISH_MESSAGE = "Failed to publish.",
|
|
7
10
|
FAILED_INITIALISE_MESSAGE = "Failed to create a configuration file because one is already present.",
|
|
11
|
+
FAILED_SET_OPTIONS_MESSAGE = "Failed to set the options.",
|
|
8
12
|
SUCCESSFUL_SERVER_MESSAGE = "Served successfully.",
|
|
9
13
|
SUCCESSFUL_PUBLISH_MESSAGE = "Published successfully.",
|
|
10
14
|
SUCCESSFUL_INITIALISE_MESSAGE = "The configuration file has been created successfully.",
|
|
15
|
+
SUCCESSFUL_SET_OPTIONS_MESSAGE = "The options have been set successfully.",
|
|
11
16
|
UNABLE_TO_COPY_FILE_MESSAGE = "Unable to copy the file.",
|
|
12
17
|
UNABLE_TO_READ_FILE_MESSAGE = "Unable to read the file.",
|
|
13
18
|
UNABLE_TO_WRITE_FILE_MESSAGE = "Unable to write the file.",
|
|
@@ -22,12 +27,17 @@ const NO_COMMAND_GIVEN_MESSAGE = "No command has been given.",
|
|
|
22
27
|
module.exports = {
|
|
23
28
|
NO_COMMAND_GIVEN_MESSAGE,
|
|
24
29
|
COMMAND_NOT_RECOGNISED_MESSAGE,
|
|
30
|
+
INVALID_LINES_PER_PAGE_MESSAGE,
|
|
31
|
+
INVALID_CONTENTS_DEPTH_MESSAGE,
|
|
32
|
+
INVALID_CHARACTERS_PER_LINE_MESSAGE,
|
|
25
33
|
FAILED_SERVER_MESSAGE,
|
|
26
34
|
FAILED_PUBLISH_MESSAGE,
|
|
27
35
|
FAILED_INITIALISE_MESSAGE,
|
|
36
|
+
FAILED_SET_OPTIONS_MESSAGE,
|
|
28
37
|
SUCCESSFUL_SERVER_MESSAGE,
|
|
29
38
|
SUCCESSFUL_PUBLISH_MESSAGE,
|
|
30
39
|
SUCCESSFUL_INITIALISE_MESSAGE,
|
|
40
|
+
SUCCESSFUL_SET_OPTIONS_MESSAGE,
|
|
31
41
|
UNABLE_TO_COPY_FILE_MESSAGE,
|
|
32
42
|
UNABLE_TO_READ_FILE_MESSAGE,
|
|
33
43
|
UNABLE_TO_WRITE_FILE_MESSAGE,
|
|
@@ -6,10 +6,10 @@ const { processingUtilities } = require("highmark-markdown");
|
|
|
6
6
|
const importer = require("../importer");
|
|
7
7
|
|
|
8
8
|
const { readFile } = require("../utilities/fileSystem"),
|
|
9
|
+
{ retrieveOptions } = require("../configuration"),
|
|
9
10
|
{ classNameFromFilePath } = require("../utilities/division"),
|
|
10
11
|
{ nodeFromTokens, tokensFromContent } = require("../utilities/markdown"),
|
|
11
|
-
{ UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE } = require("../messages")
|
|
12
|
-
{ getLinesPerPage, getContentsDepth, getCharactersPerLine } = require("../configuration");
|
|
12
|
+
{ UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE } = require("../messages");
|
|
13
13
|
|
|
14
14
|
const { postprocess } = processingUtilities,
|
|
15
15
|
{ concatenatePaths } = pathUtilities;
|
|
@@ -44,9 +44,10 @@ function markdownHTMLOperation(proceed, abort, context) {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const options = retrieveOptions(),
|
|
48
|
+
{ linesPerPage,
|
|
49
|
+
contentsDepth,
|
|
50
|
+
charactersPerLine } = options,
|
|
50
51
|
divisionClassName = className, ///
|
|
51
52
|
divisionMarkdownNode = node; ///
|
|
52
53
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const { constants } = require("highmark-client"),
|
|
4
|
-
{ mediaTypeNames } = require("highmark-markdown"),
|
|
5
4
|
{ filePathUtilities } = require("occam-entities"),
|
|
6
5
|
{ cssUtilities, defaultMarkdownStyle } = require("highmark-markdown")
|
|
7
6
|
|
|
@@ -9,9 +8,8 @@ const { DIVS_SELECTOR_STRING } = require("../constants"),
|
|
|
9
8
|
{ classNameFromFilePath } = require("../utilities/division"),
|
|
10
9
|
{ readFile, readDirectory } = require("../utilities/fileSystem");
|
|
11
10
|
|
|
12
|
-
const {
|
|
13
|
-
{
|
|
14
|
-
{ cssFromMarkdownStyleMediaTypeNameAndSelectorString } = cssUtilities,
|
|
11
|
+
const { DIVS_SELECTOR_STRING: CLIENT_DIVS_SELECTOR_STRING } = constants,
|
|
12
|
+
{ cssFromMarkdownStyleAndSelectorString } = cssUtilities,
|
|
15
13
|
{ isFilePathMarkdownStyleFilePath, isFilePathDefaultMarkdownStyleFilePath } = filePathUtilities;
|
|
16
14
|
|
|
17
15
|
function markdownStylesCSSOperation(proceed, abort, context) {
|
|
@@ -36,15 +34,14 @@ function markdownStylesCSSOperation(proceed, abort, context) {
|
|
|
36
34
|
CLIENT_DIVS_SELECTOR_STRING :
|
|
37
35
|
DIVS_SELECTOR_STRING,
|
|
38
36
|
markdownStyle = defaultMarkdownStyle, ///
|
|
39
|
-
|
|
40
|
-
defaultCSS = cssFromMarkdownStyleMediaTypeNameAndSelectorString(markdownStyle, mediaTypeName, selectorString);
|
|
37
|
+
defaultCSS = cssFromMarkdownStyleAndSelectorString(markdownStyle, selectorString);
|
|
41
38
|
|
|
42
39
|
let markdownStylesCSS = defaultCSS; ///
|
|
43
40
|
|
|
44
41
|
markdownStyleFilePaths.forEach((markdownStyleFilePath) => {
|
|
45
42
|
const selectorString = selectorStringFromMarkdownStyleFilePathAndCopyClientFiles(markdownStyleFilePath, copyClientFiles),
|
|
46
43
|
markdownStyle = markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath),
|
|
47
|
-
css =
|
|
44
|
+
css = cssFromMarkdownStyleAndSelectorString(markdownStyle, selectorString, markdownStylesCSS); ///
|
|
48
45
|
|
|
49
46
|
markdownStylesCSS = `${markdownStylesCSS}${css}`;
|
|
50
47
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { shellUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { validateCharactersPerLine } = require("../../utilities/validate"),
|
|
6
|
+
{ CHARACTERS_PER_LINE_DESCRIPTION } = require("../../descriptions"),
|
|
7
|
+
{ INVALID_CHARACTERS_PER_LINE_MESSAGE } = require("../../messages");
|
|
8
|
+
|
|
9
|
+
const { prompt } = shellUtilities;
|
|
10
|
+
|
|
11
|
+
function contentsDepthPromptOperation(proceed, abort, context) {
|
|
12
|
+
const { charactersPerLine } = context,
|
|
13
|
+
description = CHARACTERS_PER_LINE_DESCRIPTION,
|
|
14
|
+
errorMessage = INVALID_CHARACTERS_PER_LINE_MESSAGE,
|
|
15
|
+
initialAnswer = `${charactersPerLine}`,
|
|
16
|
+
validationFunction = validateCharactersPerLine, ///
|
|
17
|
+
options = {
|
|
18
|
+
description,
|
|
19
|
+
errorMessage,
|
|
20
|
+
initialAnswer,
|
|
21
|
+
validationFunction
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
prompt(options, (answer) => {
|
|
25
|
+
let charactersPerLine = answer; ///
|
|
26
|
+
|
|
27
|
+
const valid = (charactersPerLine !== null);
|
|
28
|
+
|
|
29
|
+
if (valid) {
|
|
30
|
+
charactersPerLine = Number(charactersPerLine);
|
|
31
|
+
|
|
32
|
+
Object.assign(context, {
|
|
33
|
+
charactersPerLine
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
proceed();
|
|
37
|
+
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
abort();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = contentsDepthPromptOperation;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { shellUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { validateContentsDepth } = require("../../utilities/validate"),
|
|
6
|
+
{ CONTENTS_DEPTH_DESCRIPTION } = require("../../descriptions"),
|
|
7
|
+
{ INVALID_CONTENTS_DEPTH_MESSAGE } = require("../../messages");
|
|
8
|
+
|
|
9
|
+
const { prompt } = shellUtilities;
|
|
10
|
+
|
|
11
|
+
function contentsDepthPromptOperation(proceed, abort, context) {
|
|
12
|
+
const { contentsDepth } = context,
|
|
13
|
+
description = CONTENTS_DEPTH_DESCRIPTION,
|
|
14
|
+
errorMessage = INVALID_CONTENTS_DEPTH_MESSAGE,
|
|
15
|
+
initialAnswer = `${contentsDepth}`,
|
|
16
|
+
validationFunction = validateContentsDepth, ///
|
|
17
|
+
options = {
|
|
18
|
+
description,
|
|
19
|
+
errorMessage,
|
|
20
|
+
initialAnswer,
|
|
21
|
+
validationFunction
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
prompt(options, (answer) => {
|
|
25
|
+
let contentsDepth = answer; ///
|
|
26
|
+
|
|
27
|
+
const valid = (contentsDepth !== null);
|
|
28
|
+
|
|
29
|
+
if (valid) {
|
|
30
|
+
contentsDepth = Number(contentsDepth);
|
|
31
|
+
|
|
32
|
+
Object.assign(context, {
|
|
33
|
+
contentsDepth
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
proceed();
|
|
37
|
+
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
abort();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = contentsDepthPromptOperation;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { shellUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { validateLinesPerPage } = require("../../utilities/validate"),
|
|
6
|
+
{ EMPTY_STRING } = require("../../constants"),
|
|
7
|
+
{ DEFAULT_LINES_PER_PAGE } = require("../../defaults"),
|
|
8
|
+
{ LINES_PER_PAGE_DESCRIPTION } = require("../../descriptions"),
|
|
9
|
+
{ INVALID_LINES_PER_PAGE_MESSAGE } = require("../../messages");
|
|
10
|
+
|
|
11
|
+
const { prompt } = shellUtilities;
|
|
12
|
+
|
|
13
|
+
function linesPerPagePromptOperation(proceed, abort, context) {
|
|
14
|
+
const { linesPerPage } = context,
|
|
15
|
+
description = LINES_PER_PAGE_DESCRIPTION,
|
|
16
|
+
errorMessage = INVALID_LINES_PER_PAGE_MESSAGE,
|
|
17
|
+
initialAnswer = (linesPerPage === Infinity) ?
|
|
18
|
+
EMPTY_STRING :
|
|
19
|
+
`${linesPerPage}`,
|
|
20
|
+
validationFunction = validateLinesPerPage, ///
|
|
21
|
+
options = {
|
|
22
|
+
description,
|
|
23
|
+
errorMessage,
|
|
24
|
+
initialAnswer,
|
|
25
|
+
validationFunction
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
prompt(options, (answer) => {
|
|
29
|
+
let linesPerPage = answer; ///
|
|
30
|
+
|
|
31
|
+
const valid = (linesPerPage !== null);
|
|
32
|
+
|
|
33
|
+
if (valid) {
|
|
34
|
+
linesPerPage = (linesPerPage === EMPTY_STRING) ?
|
|
35
|
+
DEFAULT_LINES_PER_PAGE :
|
|
36
|
+
Number(linesPerPage);
|
|
37
|
+
|
|
38
|
+
Object.assign(context, {
|
|
39
|
+
linesPerPage
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
proceed();
|
|
43
|
+
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
abort();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = linesPerPagePromptOperation;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { updateOptions } = require("../configuration");
|
|
4
|
+
|
|
5
|
+
function setOptionsOperation(proceed, abort, context) {
|
|
6
|
+
const { linesPerPage, contentsDepth, charactersPerLine } = context,
|
|
7
|
+
options = {
|
|
8
|
+
linesPerPage,
|
|
9
|
+
contentsDepth,
|
|
10
|
+
charactersPerLine
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
updateOptions(options);
|
|
14
|
+
|
|
15
|
+
proceed();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = setOptionsOperation;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { typeOf } = require("../utilities/type"),
|
|
4
|
+
{ INFINITY } = require("../constants"),
|
|
5
|
+
{ ARRAY_JSON_TYPE, OBJECT_JSON_TYPE, PRIMITIVE_JSON_TYPE } = require("../jsonTypes");
|
|
6
|
+
|
|
7
|
+
function serialiseJSON(json) {
|
|
8
|
+
const type = typeOf(json);
|
|
9
|
+
|
|
10
|
+
switch (type) {
|
|
11
|
+
case ARRAY_JSON_TYPE: {
|
|
12
|
+
let array = json; ///
|
|
13
|
+
|
|
14
|
+
array = serialiseArray(array); ///
|
|
15
|
+
|
|
16
|
+
json = array; ///
|
|
17
|
+
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
case OBJECT_JSON_TYPE: {
|
|
22
|
+
let object = json; ///
|
|
23
|
+
|
|
24
|
+
object = serialiseObject(object); ///
|
|
25
|
+
|
|
26
|
+
json = object; ///
|
|
27
|
+
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
case PRIMITIVE_JSON_TYPE: {
|
|
32
|
+
let primitive = json; ///
|
|
33
|
+
|
|
34
|
+
primitive = serialisePrimitive(primitive); ///
|
|
35
|
+
|
|
36
|
+
json = primitive; ///
|
|
37
|
+
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return json;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function unserialiseJSON(json) {
|
|
46
|
+
const type = typeOf(json);
|
|
47
|
+
|
|
48
|
+
switch (type) {
|
|
49
|
+
case ARRAY_JSON_TYPE: {
|
|
50
|
+
let array = json; ///
|
|
51
|
+
|
|
52
|
+
array = unserialiseArray(array); ///
|
|
53
|
+
|
|
54
|
+
json = array; ///
|
|
55
|
+
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case OBJECT_JSON_TYPE: {
|
|
60
|
+
let object = json; ///
|
|
61
|
+
|
|
62
|
+
object = unserialiseObject(object); ///
|
|
63
|
+
|
|
64
|
+
json = object; ///
|
|
65
|
+
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
case PRIMITIVE_JSON_TYPE: {
|
|
70
|
+
let primitive = json; ///
|
|
71
|
+
|
|
72
|
+
primitive = unserialisePrimitive(primitive); ///
|
|
73
|
+
|
|
74
|
+
json = primitive; ///
|
|
75
|
+
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return json;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = {
|
|
84
|
+
serialiseJSON,
|
|
85
|
+
unserialiseJSON
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
function serialiseArray(array) {
|
|
89
|
+
array = array.map((json) => {
|
|
90
|
+
json = serialiseJSON(json); ///
|
|
91
|
+
|
|
92
|
+
return json;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return array;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function unserialiseArray(array) {
|
|
99
|
+
array = array.map((json) => {
|
|
100
|
+
json = unserialiseJSON(json); ///
|
|
101
|
+
|
|
102
|
+
return json;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return array;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function serialiseObject(object) {
|
|
109
|
+
const keys = Object.keys(object),
|
|
110
|
+
values = Object.values(object);
|
|
111
|
+
|
|
112
|
+
object = keys.reduce((object, key, index) => {
|
|
113
|
+
let value = values[index],
|
|
114
|
+
json = value; //
|
|
115
|
+
|
|
116
|
+
json = serialiseJSON(json); ///
|
|
117
|
+
|
|
118
|
+
value = json; ///
|
|
119
|
+
|
|
120
|
+
object[key] = value;
|
|
121
|
+
|
|
122
|
+
return object;
|
|
123
|
+
}, {});
|
|
124
|
+
|
|
125
|
+
return object;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function unserialiseObject(object) {
|
|
129
|
+
const keys = Object.keys(object),
|
|
130
|
+
values = Object.values(object);
|
|
131
|
+
|
|
132
|
+
object = keys.reduce((object, key, index) => {
|
|
133
|
+
let value = values[index],
|
|
134
|
+
json = value; //
|
|
135
|
+
|
|
136
|
+
json = unserialiseJSON(json); ///
|
|
137
|
+
|
|
138
|
+
value = json; ///
|
|
139
|
+
|
|
140
|
+
object[key] = value;
|
|
141
|
+
|
|
142
|
+
return object;
|
|
143
|
+
}, {});
|
|
144
|
+
|
|
145
|
+
return object;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function serialisePrimitive(primitive) {
|
|
149
|
+
if (primitive === Infinity) {
|
|
150
|
+
primitive = INFINITY;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return primitive;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function unserialisePrimitive(primitive) {
|
|
157
|
+
if (primitive === INFINITY) {
|
|
158
|
+
primitive = Infinity;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return primitive;
|
|
162
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { STRING, NUMBER, BOOLEAN } = require("../constants"),
|
|
4
|
+
{ NULL_JSON_TYPE, ARRAY_JSON_TYPE, OBJECT_JSON_TYPE, PRIMITIVE_JSON_TYPE } = require("../jsonTypes");
|
|
5
|
+
|
|
6
|
+
function typeOf(json) {
|
|
7
|
+
let type;
|
|
8
|
+
|
|
9
|
+
const _null = isNull(json),
|
|
10
|
+
array = isArray(json),
|
|
11
|
+
object = isObject(json),
|
|
12
|
+
primitive = isPrimitive(json);
|
|
13
|
+
|
|
14
|
+
if (_null) {
|
|
15
|
+
type = NULL_JSON_TYPE;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (array) {
|
|
19
|
+
type = ARRAY_JSON_TYPE;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (object) {
|
|
23
|
+
type = OBJECT_JSON_TYPE;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (primitive) {
|
|
27
|
+
type = PRIMITIVE_JSON_TYPE;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return type;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
typeOf
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function isNull(json) {
|
|
38
|
+
const _null = (json === null);
|
|
39
|
+
|
|
40
|
+
return _null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isArray(json) {
|
|
44
|
+
const array = Array.isArray(json);
|
|
45
|
+
|
|
46
|
+
return array;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isObject(json) {
|
|
50
|
+
const array = isArray(json),
|
|
51
|
+
primitive = isPrimitive(json),
|
|
52
|
+
object = (!array && !primitive);
|
|
53
|
+
|
|
54
|
+
return object;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isString(json) {
|
|
58
|
+
const string = ((typeof json) === STRING);
|
|
59
|
+
|
|
60
|
+
return string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isNumber(json) {
|
|
64
|
+
const number = ((typeof json) === NUMBER);
|
|
65
|
+
|
|
66
|
+
return number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isBoolean(json) {
|
|
70
|
+
const boolean = ((typeof json) === BOOLEAN);
|
|
71
|
+
|
|
72
|
+
return boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isPrimitive(json) {
|
|
76
|
+
const _null = isNull(json),
|
|
77
|
+
string = isString(json),
|
|
78
|
+
number = isNumber(json),
|
|
79
|
+
boolean = isBoolean(json),
|
|
80
|
+
primitive = (_null || string || number || boolean);
|
|
81
|
+
|
|
82
|
+
return primitive;
|
|
83
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function validateLinesPerPage(linesPerPage) { return /^\d*$/.test(linesPerPage); }
|
|
4
|
+
|
|
5
|
+
function validateContentsDepth(contentsDepth) { return /^1|2|3|4$/.test(contentsDepth); }
|
|
6
|
+
|
|
7
|
+
function validateCharactersPerLine(charactersPerLine) { return /^\d+$/.test(charactersPerLine); }
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
validateLinesPerPage,
|
|
11
|
+
validateContentsDepth,
|
|
12
|
+
validateCharactersPerLine
|
|
13
|
+
};
|
package/bin/versions.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "highmark-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/highmark-cli",
|
|
7
7
|
"description": "Highmark's LIC tool.",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"argumentative": "^2.0.28",
|
|
14
14
|
"express": "^4.19.2",
|
|
15
15
|
"highmark-client": "^0.0.98",
|
|
16
|
-
"highmark-markdown": "^0.0.
|
|
16
|
+
"highmark-markdown": "^0.0.430",
|
|
17
17
|
"lively-cli": "^2.0.65",
|
|
18
18
|
"necessary": "^14.0.1",
|
|
19
|
-
"occam-entities": "^1.0.
|
|
19
|
+
"occam-entities": "^1.0.112"
|
|
20
20
|
},
|
|
21
21
|
"bin": {
|
|
22
22
|
"highmark": "./highmark.js"
|