highmark-cli 1.3.43 → 1.3.44

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.
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ const { pathUtilities } = require("necessary");
4
+
5
+ const { DOUBLE_DOTS } = require("./constants"),
6
+ { migrateConfigurationFile, checkConfigurationFileExists } = require("./configuration");
7
+
8
+ const { bottommostNameFromPath } = pathUtilities;
9
+
10
+ function changeDirectory() {
11
+ let directoryName = null,
12
+ configurationFileExists = checkConfigurationFileExists();
13
+
14
+ if (!configurationFileExists) {
15
+ const currentWorkingDirectoryPath = process.cwd(); ///
16
+
17
+ process.chdir(DOUBLE_DOTS);
18
+
19
+ const oldCurrentWorkingDirectoryPath = currentWorkingDirectoryPath; ///
20
+
21
+ configurationFileExists = checkConfigurationFileExists();
22
+
23
+ if (configurationFileExists) {
24
+ const bottommostOldCurrentWorkingDirectoryName = bottommostNameFromPath(oldCurrentWorkingDirectoryPath);
25
+
26
+ directoryName = bottommostOldCurrentWorkingDirectoryName; ///
27
+ } else {
28
+ process.chdir(oldCurrentWorkingDirectoryPath);
29
+ }
30
+ }
31
+
32
+ migrateConfigurationFile();
33
+
34
+ return directoryName;
35
+ }
36
+
37
+ module.exports = changeDirectory;
package/bin/main.js CHANGED
@@ -7,7 +7,7 @@ const helpAction = require("./action/help"),
7
7
  initialiseAction = require("./action/initialise"),
8
8
  setOptionsAction = require("./action/setOptions");
9
9
 
10
- const { NO_COMMAND_GIVEN_MESSAGE, COMMAND_NOT_RECOGNISED_MESSAGE } = require("./messages"),
10
+ const { NO_ARGUMENT_GIVEN_MESSAGE, COMMAND_NOT_RECOGNISED_MESSAGE } = require("./messages"),
11
11
  { HELP_COMMAND, SERVER_COMMAND, VERSION_COMMAND, PUBLISH_COMMAND, INITIALISE_COMMAND, SET_OPTIONS_COMMAND } = require("./commands"),
12
12
  { DEFAULT_PORT,
13
13
  DEFAULT_FONTS,
@@ -25,42 +25,44 @@ function main(command, argument, options) {
25
25
  inputFileName = DEFAULT_INPUT_FILE_NAME } = options;
26
26
 
27
27
  switch (command) {
28
- case null: {
29
- console.log(NO_COMMAND_GIVEN_MESSAGE);
30
-
31
- break;
32
- }
33
-
34
28
  case HELP_COMMAND: {
35
29
  helpAction();
36
30
 
37
31
  break;
38
32
  }
39
33
 
40
- case SERVER_COMMAND: {
41
- const projectDirectoryName = argument; ///
42
-
43
- serverAction(port, watch, quietly, projectDirectoryName);
34
+ case VERSION_COMMAND: {
35
+ versionAction();
44
36
 
45
37
  break;
46
38
  }
47
39
 
48
- case VERSION_COMMAND: {
49
- versionAction();
40
+ case INITIALISE_COMMAND: {
41
+ initialiseAction();
50
42
 
51
43
  break;
52
44
  }
53
45
 
54
- case PUBLISH_COMMAND: {
55
- const projectDirectoryName = argument; ///
46
+ case SERVER_COMMAND: {
47
+ if (argument === null) {
48
+ console.log(NO_ARGUMENT_GIVEN_MESSAGE);
49
+ } else {
50
+ const projectDirectoryName = argument; ///
56
51
 
57
- publishAction(port, fonts, watch, client, quietly, inputFileName, projectDirectoryName);
52
+ serverAction(port, watch, quietly, projectDirectoryName);
53
+ }
58
54
 
59
55
  break;
60
56
  }
61
57
 
62
- case INITIALISE_COMMAND: {
63
- initialiseAction();
58
+ case PUBLISH_COMMAND: {
59
+ if (argument === null) {
60
+ console.log(NO_ARGUMENT_GIVEN_MESSAGE);
61
+ } else {
62
+ const projectDirectoryName = argument; ///
63
+
64
+ publishAction(port, fonts, watch, client, quietly, inputFileName, projectDirectoryName);
65
+ }
64
66
 
65
67
  break;
66
68
  }
package/bin/messages.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const NO_COMMAND_GIVEN_MESSAGE = "No command has been given.",
3
+ const NO_ARGUMENT_GIVEN_MESSAGE = "No argument has been given.",
4
4
  COMMAND_NOT_RECOGNISED_MESSAGE = "The command is not recognised.",
5
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
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.",
@@ -25,7 +25,7 @@ const NO_COMMAND_GIVEN_MESSAGE = "No command has been given.",
25
25
  UNABLE_TO_CONVERT_MARKDOWN_STYLES_TO_CSS_MESSAGE = "Unable to convert Markdown styles to CSS.";
26
26
 
27
27
  module.exports = {
28
- NO_COMMAND_GIVEN_MESSAGE,
28
+ NO_ARGUMENT_GIVEN_MESSAGE,
29
29
  COMMAND_NOT_RECOGNISED_MESSAGE,
30
30
  INVALID_LINES_PER_PAGE_MESSAGE,
31
31
  INVALID_CONTENTS_DEPTH_MESSAGE,
package/bin/prepare.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ const changeDirectory = require("./changeDirectory");
4
+
5
+ const { DEFAULT_HELP, DEFAULT_VERSION, DEFAULT_SERVER } = require("./defaults"),
6
+ { HELP_COMMAND, VERSION_COMMAND, INITIALISE_COMMAND, PUBLISH_COMMAND, SERVER_COMMAND } = require("./commands");
7
+
8
+ function prepare(command, argument, options, main) {
9
+ const { help = DEFAULT_HELP, version = DEFAULT_VERSION } = options;
10
+
11
+ if (false) {
12
+ ///
13
+ } else if (help) {
14
+ command = HELP_COMMAND;
15
+ } else if (version) {
16
+ command = VERSION_COMMAND;
17
+ }
18
+
19
+ if ((command === HELP_COMMAND) || (command === VERSION_COMMAND) || (command === INITIALISE_COMMAND)) {
20
+ main(command, argument, options);
21
+
22
+ return;
23
+ }
24
+
25
+ const { server = DEFAULT_SERVER } = options;
26
+
27
+ if (server) {
28
+ command = SERVER_COMMAND;
29
+ }
30
+
31
+ const directoryName = changeDirectory();
32
+
33
+ if (directoryName !== null) {
34
+ argument = directoryName; ///
35
+ }
36
+
37
+ if (argument === null) {
38
+ argument = command; ///
39
+
40
+ command = PUBLISH_COMMAND;
41
+ }
42
+
43
+ if (command === null) {
44
+ command = PUBLISH_COMMAND;
45
+ }
46
+
47
+ main(command, argument, options);
48
+ }
49
+
50
+ module.exports = prepare;
package/highmark.js CHANGED
@@ -4,7 +4,7 @@ const { parseArgv } = require("argumentative"),
4
4
  { arrayUtilities } = require("necessary");
5
5
 
6
6
  const main = require("./bin/main"),
7
- configure = require("./bin/configure"),
7
+ prepare = require("./bin/prepare"),
8
8
  abbreviations = require("./bin/abbreviations");
9
9
 
10
10
  const { argv } = process,
@@ -16,4 +16,4 @@ const { commands, options } = parseArgv(argv, abbreviations),
16
16
  command = firstCommand || null, ///
17
17
  argument = secondCommand || null; ///
18
18
 
19
- configure(command, argument, options, main);
19
+ prepare(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": "1.3.43",
4
+ "version": "1.3.44",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/highmark-cli",
7
7
  "description": "Highmark's LIC tool.",
package/bin/configure.js DELETED
@@ -1,83 +0,0 @@
1
- "use strict";
2
-
3
- const { pathUtilities } = require("necessary");
4
-
5
- const { DOUBLE_DOTS } = require("./constants"),
6
- { DEFAULT_HELP, DEFAULT_VERSION, DEFAULT_SERVER } = require("./defaults"),
7
- { migrateConfigurationFile, checkConfigurationFileExists } = require("./configuration"),
8
- { HELP_COMMAND, VERSION_COMMAND, INITIALISE_COMMAND, PUBLISH_COMMAND, SERVER_COMMAND } = require("./commands");
9
-
10
- const { bottommostNameFromPath } = pathUtilities;
11
-
12
- function configure(command, argument, options, main) {
13
- const { help = DEFAULT_HELP, version = DEFAULT_VERSION } = options;
14
-
15
- if (false) {
16
- ///
17
- } else if (help) {
18
- command = HELP_COMMAND;
19
- } else if (version) {
20
- command = VERSION_COMMAND;
21
- }
22
-
23
- if ((command === HELP_COMMAND) || (command === VERSION_COMMAND)) {
24
- main(command, argument, options);
25
-
26
- return;
27
- }
28
-
29
- const directoryName = changeDirectory(command);
30
-
31
- const { server = DEFAULT_SERVER } = options;
32
-
33
- if (server) {
34
- command = SERVER_COMMAND;
35
- }
36
-
37
- if (directoryName !== null) {
38
- if (command === null) {
39
- command = PUBLISH_COMMAND;
40
- }
41
-
42
- argument = directoryName; ///
43
- }
44
-
45
- if (argument === null) {
46
- argument = command; ///
47
-
48
- command = PUBLISH_COMMAND;
49
- }
50
-
51
- main(command, argument, options);
52
- }
53
-
54
- module.exports = configure;
55
-
56
- function changeDirectory(command) {
57
- let directoryName = null,
58
- configurationFileExists = checkConfigurationFileExists();
59
-
60
- if (!configurationFileExists) {
61
- const currentWorkingDirectoryPath = process.cwd(); ///
62
-
63
- process.chdir(DOUBLE_DOTS);
64
-
65
- const oldCurrentWorkingDirectoryPath = currentWorkingDirectoryPath; ///
66
-
67
- configurationFileExists = checkConfigurationFileExists();
68
-
69
- if (configurationFileExists) {
70
- const bottommostOldCurrentWorkingDirectoryName = bottommostNameFromPath(oldCurrentWorkingDirectoryPath);
71
-
72
- directoryName = bottommostOldCurrentWorkingDirectoryName; ///
73
- } else {
74
- process.chdir(oldCurrentWorkingDirectoryPath);
75
- }
76
- }
77
-
78
- if (command !== INITIALISE_COMMAND) {
79
- migrateConfigurationFile();
80
- }
81
-
82
- return directoryName;
83
- }