highmark-cli 0.0.258 → 0.0.260

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/README.md CHANGED
@@ -51,7 +51,7 @@ Depending on your setup you may need to prepend `sudo` to the above.
51
51
  These are the commands and options:
52
52
 
53
53
  ```
54
- highmark [<command>] [<argument>]
54
+ highmark [<options>] [<command>] [<argument>]
55
55
 
56
56
  Commands:
57
57
 
@@ -71,6 +71,8 @@ Options:
71
71
 
72
72
  --watch|-w Watch for changes to the client file and in the output directory
73
73
 
74
+ --quietly|-q Run with almost no console logging
75
+
74
76
  --copy-fonts|-f Copy the fonts to a fonts folder next to the output file
75
77
 
76
78
  --start-server|-s Start a server to view the output file
@@ -3,7 +3,7 @@
3
3
  function helpAction() {
4
4
  console.log(`Usage:
5
5
 
6
- highmark [<command>] [<argument>]
6
+ highmark [<options>] [<command>] [<argument>]
7
7
 
8
8
  Commands:
9
9
 
@@ -23,6 +23,8 @@ Options:
23
23
 
24
24
  --watch|-w Watch for changes to the client file and in the output directory
25
25
 
26
+ --quietly|-q Run with almost no console logging
27
+
26
28
  --copy-fonts|-f Copy the fonts to a fonts folder next to the output file
27
29
 
28
30
  --start-server|-s Start a server to view the output file
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ const { VERSION_1_0 } = require("../versions");
4
+
5
+ function createConfiguration() {
6
+ const version = VERSION_1_0,
7
+ configuration = {
8
+ version
9
+ };
10
+
11
+ return configuration;
12
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ const { versionUtilities, configurationUtilities } = require("necessary");
4
+
5
+ const { HIGHMARK } = require("./constants"),
6
+ { VERSION_1_0 } = require("./versions"),
7
+ { createConfiguration } = require("./configuration/version_1_0"),
8
+ { CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE } = require("./messages");
9
+
10
+ const { rc } = configurationUtilities,
11
+ { migrate } = versionUtilities,
12
+ { setRCBaseExtension, checkRCFileExists, updateRCFile, writeRCFile, readRCFile } = rc;
13
+
14
+ const rcBaseExtension = HIGHMARK; ///
15
+
16
+ setRCBaseExtension(rcBaseExtension);
17
+
18
+ function createConfigurationFile() {
19
+ const configuration = createConfiguration(),
20
+ json = configuration; ///
21
+
22
+ writeRCFile(json);
23
+ }
24
+
25
+ function migrateConfigurationFile() {
26
+ assertConfigurationFileExists();
27
+
28
+ let json = readRCFile();
29
+
30
+ const migrationMap = {},
31
+ latestVersion = VERSION_1_0;
32
+
33
+ json = migrate(json, migrationMap, latestVersion);
34
+
35
+ writeRCFile(json);
36
+ }
37
+
38
+ function checkConfigurationFileExists() {
39
+ const rcFileExists = checkRCFileExists(),
40
+ configurationFileExists = rcFileExists; ///
41
+
42
+ return configurationFileExists;
43
+ }
44
+
45
+ function assertConfigurationFileExists() {
46
+ const configurationFileExists = checkConfigurationFileExists();
47
+
48
+ if (!configurationFileExists) {
49
+ console.log(CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE);
50
+
51
+ process.exit(1);
52
+ }
53
+ }
54
+
55
+ module.exports = {
56
+ createConfigurationFile,
57
+ migrateConfigurationFile,
58
+ checkConfigurationFileExists,
59
+ assertConfigurationFileExists
60
+ };
61
+
62
+ function readConfigurationFile() {
63
+ assertConfigurationFileExists();
64
+
65
+ const json = readRCFile(),
66
+ configuration = json; ///
67
+
68
+ return configuration;
69
+ }
70
+
71
+ function writeConfigurationFile(configuration) {
72
+ assertConfigurationFileExists();
73
+
74
+ const json = configuration; ///
75
+
76
+ writeRCFile(json);
77
+ }
78
+
79
+ function updateConfigurationFile(addedConfiguration, ...deleteConfigurationNames) {
80
+ assertConfigurationFileExists();
81
+
82
+ const addedProperties = addedConfiguration, ///
83
+ deletedPropertyNames = deleteConfigurationNames; ///
84
+
85
+ updateRCFile(addedProperties, ...deletedPropertyNames);
86
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ const { pathUtilities } = require("necessary");
4
+
5
+ const { DOUBLE_DOTS } = require("./constants"),
6
+ { DEFAULT_HELP, DEFAULT_VERSION } = require("./defaults"),
7
+ { HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND } = require("./commands"),
8
+ { migrateConfigurationFile, checkConfigurationFileExists } = require("./configuration");
9
+
10
+ const { bottommostNameFromPath } = pathUtilities;
11
+
12
+ function configure(command, argument, options, main) {
13
+ let configurationFileExists;
14
+
15
+ const { help = DEFAULT_HELP, version = DEFAULT_VERSION } = options;
16
+
17
+ if (false) {
18
+ ///
19
+ } else if (help) {
20
+ command = HELP_COMMAND;
21
+ } else if (version) {
22
+ command = VERSION_COMMAND;
23
+ }
24
+
25
+ if ((command === HELP_COMMAND) || (command === VERSION_COMMAND)) {
26
+ main(command, argument, options);
27
+
28
+ return;
29
+ }
30
+
31
+ configurationFileExists = checkConfigurationFileExists();
32
+
33
+ if (command === null) {
34
+ if (!configurationFileExists) {
35
+ const currentWorkingDirectoryPath = process.cwd(); ///
36
+
37
+ process.chdir(DOUBLE_DOTS);
38
+
39
+ const oldCurrentWorkingDirectoryPath = currentWorkingDirectoryPath; ///
40
+
41
+ configurationFileExists = checkConfigurationFileExists();
42
+
43
+ if (configurationFileExists) {
44
+ const bottommostOldCurrentWorkingDirectoryName = bottommostNameFromPath(oldCurrentWorkingDirectoryPath);
45
+
46
+ argument = bottommostOldCurrentWorkingDirectoryName; ///
47
+
48
+ command = PUBLISH_COMMAND; ///
49
+ }
50
+ }
51
+ }
52
+
53
+ migrateConfigurationFile();
54
+
55
+ main(command, argument, options);
56
+ }
57
+
58
+ module.exports = configure;
package/bin/constants.js CHANGED
@@ -3,6 +3,8 @@
3
3
  const FONT = "font",
4
4
  ERROR = "error",
5
5
  PERIOD = ".",
6
+ HIGHMARK = "highmark",
7
+ DOUBLE_DOTS = "..",
6
8
  HIGHMARK_CLI = "Highmark-CLI",
7
9
  LIVE_RELOAD_PATH = "/live-reload",
8
10
  DIVS_SELECTOR_STRING = "body > div",
@@ -12,6 +14,8 @@ module.exports = {
12
14
  FONT,
13
15
  ERROR,
14
16
  PERIOD,
17
+ HIGHMARK,
18
+ DOUBLE_DOTS,
15
19
  HIGHMARK_CLI,
16
20
  LIVE_RELOAD_PATH,
17
21
  DIVS_SELECTOR_STRING,
package/bin/main.js CHANGED
@@ -5,12 +5,11 @@ const helpAction = require("./action/help"),
5
5
  versionAction = require("./action/version"),
6
6
  publishAction = require("./action/publish");
7
7
 
8
- const { HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND, START_SERVER_COMMAND } = require("./commands"),
9
- { DEFAULT_HELP,
10
- DEFAULT_PORT,
8
+ const { NO_COMMAND_GIVEN_MESSAGE, COMMAND_NOT_RECOGNISED_MESSAGE } = require("./messages"),
9
+ { HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND, START_SERVER_COMMAND } = require("./commands"),
10
+ { DEFAULT_PORT,
11
11
  DEFAULT_WATCH,
12
12
  DEFAULT_QUIETLY,
13
- DEFAULT_VERSION,
14
13
  DEFAULT_COPY_FONTS,
15
14
  DEFAULT_START_SERVER,
16
15
  DEFAULT_INPUT_FILE_PATH,
@@ -18,45 +17,26 @@ const { HELP_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND, START_SERVER_COMMAND } =
18
17
  DEFAULT_OUTPUT_DIRECTORY_PATH } = require("./defaults");
19
18
 
20
19
  function main(command, argument, options) {
21
- const commandMissing = (command === null),
22
- { help = DEFAULT_HELP,
23
- port = DEFAULT_PORT,
20
+ const { port = DEFAULT_PORT,
24
21
  watch = DEFAULT_WATCH,
25
22
  quietly = DEFAULT_QUIETLY,
26
- version = DEFAULT_VERSION,
27
23
  copyFonts = DEFAULT_COPY_FONTS,
28
24
  startServer = DEFAULT_START_SERVER,
29
25
  inputFilePath = DEFAULT_INPUT_FILE_PATH,
30
26
  copyClientFiles = DEFAULT_COPY_CLIENT_FILES,
31
27
  outputDirectoryPath = DEFAULT_OUTPUT_DIRECTORY_PATH } = options;
32
28
 
33
- if (false) {
34
- ///
35
- } else if (version) {
36
- command = VERSION_COMMAND;
37
- } else if (commandMissing) {
38
- if (false) {
39
- ///
40
- } else if (help) {
41
- command = HELP_COMMAND;
42
- } else if (startServer) {
43
- command = START_SERVER_COMMAND;
44
- } else {
45
- command = PUBLISH_COMMAND;
46
- }
47
- }
48
-
49
29
  switch (command) {
50
- case HELP_COMMAND: {
51
- helpAction();
30
+ case null: {
31
+ console.log(NO_COMMAND_GIVEN_MESSAGE);
32
+
33
+ process.exit(1);
52
34
 
53
35
  break;
54
36
  }
55
37
 
56
- case START_SERVER_COMMAND: {
57
- const startServer = true;
58
-
59
- serverAction(port, watch, quietly, startServer, outputDirectoryPath);
38
+ case HELP_COMMAND: {
39
+ helpAction();
60
40
 
61
41
  break;
62
42
  }
@@ -72,6 +52,22 @@ function main(command, argument, options) {
72
52
 
73
53
  break;
74
54
  }
55
+
56
+ case START_SERVER_COMMAND: {
57
+ const startServer = true;
58
+
59
+ serverAction(port, watch, quietly, startServer, outputDirectoryPath);
60
+
61
+ break;
62
+ }
63
+
64
+ default: {
65
+ console.log(COMMAND_NOT_RECOGNISED_MESSAGE);
66
+
67
+ process.exit(1);
68
+
69
+ break;
70
+ }
75
71
  }
76
72
  }
77
73
 
package/bin/messages.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- const FAILED_SERVER_MESSAGE = "Failed to serve.",
3
+ const NO_COMMAND_GIVEN_MESSAGE = "No command has been given.",
4
+ COMMAND_NOT_RECOGNISED_MESSAGE = "The command is not recognised.",
5
+ FAILED_SERVER_MESSAGE = "Failed to serve.",
4
6
  FAILED_PUBLISH_MESSAGE = "Failed to publish.",
5
7
  SUCCESSFUL_SERVER_MESSAGE = "Served successfully.",
6
8
  SUCCESSFUL_PUBLISH_MESSAGE = "Published successfully.",
@@ -11,10 +13,13 @@ const FAILED_SERVER_MESSAGE = "Failed to serve.",
11
13
  UNABLE_TO_READ_DIRECTORY_MESSAGE = "Unable to read the directory.",
12
14
  UNABLE_TO_CREATE_DIRECTORY_MESSAGE = "Unable to create the directory.",
13
15
  UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE = "Unable to parse the markdown file.",
16
+ CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE = "There is no configuration file. Run 'highmark initialise' to create one.",
14
17
  UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE = "Unable to convert Markdown to HTML.",
15
18
  UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE = "Unable to convert Markdown styles to CSS.";
16
19
 
17
20
  module.exports = {
21
+ NO_COMMAND_GIVEN_MESSAGE,
22
+ COMMAND_NOT_RECOGNISED_MESSAGE,
18
23
  FAILED_SERVER_MESSAGE,
19
24
  FAILED_PUBLISH_MESSAGE,
20
25
  SUCCESSFUL_SERVER_MESSAGE,
@@ -26,6 +31,7 @@ module.exports = {
26
31
  UNABLE_TO_READ_DIRECTORY_MESSAGE,
27
32
  UNABLE_TO_CREATE_DIRECTORY_MESSAGE,
28
33
  UNABLE_TO_PARSE_MARKDOWN_FILE_MESSAGE,
34
+ CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE,
29
35
  UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE,
30
36
  UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE
31
37
  };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ const VERSION_1_0 = "1.0";
4
+
5
+ module.exports = {
6
+ VERSION_1_0
7
+ };
package/highmark.js CHANGED
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const necessary = require("necessary");
4
-
5
- const { parseArgv } = require("argumentative");
3
+ const { parseArgv } = require("argumentative"),
4
+ { arrayUtilities } = require("necessary");
6
5
 
7
6
  const main = require("./bin/main"),
7
+ configure = require("./bin/configure"),
8
8
  abbreviations = require("./bin/abbreviations");
9
9
 
10
10
  const { argv } = process,
11
- { arrayUtilities } = necessary,
12
11
  { first, second } = arrayUtilities;
13
12
 
14
13
  const { commands, options } = parseArgv(argv, abbreviations),
@@ -17,4 +16,4 @@ const { commands, options } = parseArgv(argv, abbreviations),
17
16
  command = firstCommand || null, ///
18
17
  argument = secondCommand || null; ///
19
18
 
20
- main(command, argument, options);
19
+ configure(command, argument, options, main);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "highmark-cli",
3
3
  "author": "James Smith",
4
- "version": "0.0.258",
4
+ "version": "0.0.260",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/highmark-cli",
7
7
  "description": "Highmark's LIC tool.",