occam-open-cli 6.0.172 → 6.0.174

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.
@@ -8,9 +8,8 @@ const cloneOperation = require("../operation/clone"),
8
8
  const { executeOperations } = require("../utilities/operation"),
9
9
  { SUCCESSFUL_CLONE_MESSAGE, FAILED_CLONE_MESSAGE } = require("../messages");
10
10
 
11
- function cloneAction(argument, quietly, yes, no) {
12
- const releaseName = argument, ///
13
- operations = [
11
+ function cloneAction(releaseName, quietly, yes, no) {
12
+ const operations = [
14
13
  releaseNamePromptOperation,
15
14
  cloneDependenciesPromptOperation,
16
15
  cloneOperation,
@@ -3,21 +3,20 @@
3
3
  const createAccountOperation = require("../operation/createAccount"),
4
4
  passwordPromptOperation = require("../operation/prompt/password"),
5
5
  usernamePromptOperation = require("../operation/prompt/username"),
6
- setIdentityTokenOperation = require("../operation/setIdentityToken"),
7
- emailAddressPromptOperation = require("../operation/prompt/emailAddress");
6
+ emailAddressPromptOperation = require("../operation/prompt/emailAddress"),
7
+ updateIdentityTokenOperation = require("../operation/updateIdentityToken");
8
8
 
9
9
  const { executeOperations } = require("../utilities/operation");
10
10
 
11
- function createAccountAction(argument) {
12
- const emailAddress = argument, ///
13
- username = null,
11
+ function createAccountAction(emailAddress) {
12
+ const username = null,
14
13
  password = null,
15
14
  operations = [
16
15
  emailAddressPromptOperation,
17
16
  usernamePromptOperation,
18
17
  passwordPromptOperation,
19
18
  createAccountOperation,
20
- setIdentityTokenOperation
19
+ updateIdentityTokenOperation
21
20
  ],
22
21
  context = {
23
22
  emailAddress,
@@ -7,9 +7,8 @@ const openOperation = require("../operation/open"),
7
7
  const { executeOperations } = require("../utilities/operation"),
8
8
  { SUCCESSFUL_OPEN_MESSAGE, FAILED_OPEN_MESSAGE } = require("../messages");
9
9
 
10
- function openAction(argument, quietly, yes, no) {
11
- const releaseName = argument, ///
12
- operations = [
10
+ function openAction(releaseName, quietly, yes, no) {
11
+ const operations = [
13
12
  releaseNamePromptOperation,
14
13
  openOperation,
15
14
  openReleasesOperation
@@ -9,13 +9,11 @@ const publishOperation = require("../operation/publish"),
9
9
  updateMetaJSONFileVersionOperation = require("../operation/updateMetaJSONFileVersion");
10
10
 
11
11
  const { DOUBLE_DASH } = require("../constants"),
12
- { trimTrailingSlash } = require("../utilities/string"),
13
12
  { executeOperations } = require("../utilities/operation"),
14
13
  { FAILED_PUBLISH_MESSAGE, SUCCESSFUL_PUBLISH_MESSAGE } = require("../messages");
15
14
 
16
- function publishAction(argument, tail, follow, dryRun, logLevel) {
17
- const releaseName = trimTrailingSlash(argument), ///
18
- operations = [
15
+ function publishAction(releaseName, tail, follow, dryRun, logLevel) {
16
+ const operations = [
19
17
  getIdentityTokenOperation,
20
18
  releaseNamePromptOperation,
21
19
  loadProjectOperation,
@@ -5,9 +5,8 @@ const resetPasswordOperation = require("../operation/resetPassword"),
5
5
 
6
6
  const { executeOperations } = require("../utilities/operation");
7
7
 
8
- function resetPasswordAction(argument) {
9
- const emailAddress = argument, ///
10
- operations = [
8
+ function resetPasswordAction(emailAddress) {
9
+ const operations = [
11
10
  emailAddressPromptOperation,
12
11
  resetPasswordOperation
13
12
  ],
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- const setOptionsOperation = require("../operation/setOptions"),
4
- useSSHPromptOperation = require("../operation/prompt/useSSH"),
3
+ const useSSHPromptOperation = require("../operation/prompt/useSSH"),
4
+ updateOptionsOperation = require("../operation/updateOptions"),
5
5
  gitHubHostNamePromptOperation = require("../operation/prompt/gitHubHostName");
6
6
 
7
7
  const { executeOperations } = require("../utilities/operation"),
@@ -11,7 +11,7 @@ function setOptionsAction() {
11
11
  const operations = [
12
12
  useSSHPromptOperation,
13
13
  gitHubHostNamePromptOperation,
14
- setOptionsOperation
14
+ updateOptionsOperation
15
15
  ],
16
16
  context = {};
17
17
 
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
 
3
- const setShellCommandsPromptOperation = require("../operation/prompt/setShellCommands");
3
+ const updateShellCommandsOperation = require("../operation/updateShellCommands"),
4
+ setShellCommandsPromptOperation = require("../operation/prompt/setShellCommands");
4
5
 
5
6
  const { executeOperations } = require("../utilities/operation"),
6
- { retrieveShellCommands, updateShellCommands } = require("../configuration"),
7
+ { retrieveShellCommands } = require("../configuration"),
7
8
  { FAILED_SET_SHELL_COMMANDS_MESSAGE, SUCCESSFUL_SET_SHELL_COMMANDS_MESSAGE } = require("../messages");
8
9
 
9
10
  function setShellCommandsAction() {
10
11
  const operations = [
11
- setShellCommandsPromptOperation
12
+ setShellCommandsPromptOperation,
13
+ updateShellCommandsOperation
12
14
  ],
13
15
  shellCommands = retrieveShellCommands(),
14
16
  context = {
@@ -22,10 +24,6 @@ function setShellCommandsAction() {
22
24
  return;
23
25
  }
24
26
 
25
- const { shellCommands } = context;
26
-
27
- updateShellCommands(shellCommands);
28
-
29
27
  console.log(SUCCESSFUL_SET_SHELL_COMMANDS_MESSAGE);
30
28
  }, context);
31
29
  }
@@ -2,19 +2,18 @@
2
2
 
3
3
  const signInOperation = require("../operation/signIn"),
4
4
  passwordPromptOperation = require("../operation/prompt/password"),
5
- setIdentityTokenOperation = require("../operation/setIdentityToken"),
5
+ updateIdentityTokenOperation = require("../operation/updateIdentityToken"),
6
6
  emailAddressOrUsernamePromptOperation = require("../operation/prompt/emailAddressOrUsername");
7
7
 
8
8
  const { executeOperations } = require("../utilities/operation");
9
9
 
10
- function signInAction(argument) {
11
- const emailAddressOrUsername = argument, ///
12
- password = null,
10
+ function signInAction(emailAddressOrUsername) {
11
+ const password = null,
13
12
  operations = [
14
13
  emailAddressOrUsernamePromptOperation,
15
14
  passwordPromptOperation,
16
15
  signInOperation,
17
- setIdentityTokenOperation
16
+ updateIdentityTokenOperation
18
17
  ],
19
18
  context = {
20
19
  emailAddressOrUsername,
@@ -8,9 +8,8 @@ const withdrawOperation = require("../operation/withdraw"),
8
8
  const { executeOperations } = require("../utilities/operation"),
9
9
  { FAILED_WITHDRAW_MESSAGE, SUCCESSFUL_WITHDRAW_MESSAGE } = require("../messages");
10
10
 
11
- function withdrawAction(argument) {
12
- const releaseName = argument, ///
13
- password = null,
11
+ function withdrawAction(releaseName) {
12
+ const password = null,
14
13
  operations = [
15
14
  getIdentityTokenOperation,
16
15
  releaseNamePromptOperation,
@@ -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;
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  const { VERSION_5_1 } = require("../versions"),
4
- { DEFAULT_HOST, DEFAULT_SHELL_COMMANDS } = require("../defaults");
4
+ { DEFAULT_HOST, DEFAULT_USE_SSH, DEFAULT_SHELL_COMMANDS } = require("../defaults");
5
5
 
6
6
  function createConfiguration() {
7
7
  const version = VERSION_5_1,
8
8
  host = DEFAULT_HOST,
9
- options = {},
9
+ useSSH = DEFAULT_USE_SSH,
10
+ options = {
11
+ useSSH,
12
+ },
10
13
  shellCommands = DEFAULT_SHELL_COMMANDS,
11
14
  identityToken = null,
12
15
  configuration = {
package/bin/defaults.js CHANGED
@@ -15,6 +15,7 @@ const DEFAULT_NO = false,
15
15
  DEFAULT_DRY_RUN = false,
16
16
  DEFAULT_VERSION = false,
17
17
  DEFAULT_QUIETLY = false,
18
+ DEFAULT_USE_SSH = false,
18
19
  DEFAULT_LOG_LEVEL = INFO_LEVEL,
19
20
  DEFAULT_SHELL_COMMANDS = EMPTY_STRING,
20
21
  DEFAULT_GITHUB_HOST_NAME = "github.com";
@@ -29,6 +30,7 @@ module.exports = {
29
30
  DEFAULT_DRY_RUN,
30
31
  DEFAULT_VERSION,
31
32
  DEFAULT_QUIETLY,
33
+ DEFAULT_USE_SSH,
32
34
  DEFAULT_LOG_LEVEL,
33
35
  DEFAULT_SHELL_COMMANDS,
34
36
  DEFAULT_GITHUB_HOST_NAME
package/bin/main.js CHANGED
@@ -14,7 +14,7 @@ const helpAction = require("./action/help"),
14
14
  resetPasswordAction = require("./action/resetPassword"),
15
15
  setShellCommandsAction = require("./action/setShellCommands");
16
16
 
17
- const { NO_COMMAND_GIVEN_MESSAGE } = require("./messages"),
17
+ const { NO_ARGUMENT_GIVEN_MESSAGE, COMMAND_NOT_RECOGNISED_MESSAGE } = require("./messages"),
18
18
  { DEFAULT_NO, DEFAULT_YES, DEFAULT_TAIL, DEFAULT_FOLLOW, DEFAULT_DRY_RUN, DEFAULT_QUIETLY, DEFAULT_LOG_LEVEL } = require("./defaults"),
19
19
  { HELP_COMMAND,
20
20
  OPEN_COMMAND,
@@ -40,44 +40,64 @@ function main(command, argument, options) {
40
40
  logLevel = DEFAULT_LOG_LEVEL } = options;
41
41
 
42
42
  switch (command) {
43
- case null: {
44
- console.log(NO_COMMAND_GIVEN_MESSAGE);
43
+ case HELP_COMMAND: {
44
+ helpAction();
45
45
 
46
46
  break;
47
47
  }
48
48
 
49
- case HELP_COMMAND: {
50
- helpAction();
49
+ case VERSION_COMMAND: {
50
+ versionAction();
51
51
 
52
52
  break;
53
53
  }
54
54
 
55
- case OPEN_COMMAND: {
56
- openAction(argument, quietly, yes, no);
55
+ case INITIALISE_COMMAND: {
56
+ initialiseAction();
57
57
 
58
58
  break;
59
59
  }
60
60
 
61
- case CLONE_COMMAND: {
62
- cloneAction(argument, quietly, yes, no);
61
+ case OPEN_COMMAND: {
62
+ if (argument === null) {
63
+ console.log(NO_ARGUMENT_GIVEN_MESSAGE);
64
+ } else {
65
+ const releaseName = argument; ///
66
+
67
+ openAction(releaseName, quietly, yes, no);
68
+ }
63
69
 
64
70
  break;
65
71
  }
66
72
 
67
- case VERSION_COMMAND: {
68
- versionAction();
73
+ case CLONE_COMMAND: {
74
+ if (argument === null) {
75
+ console.log(NO_ARGUMENT_GIVEN_MESSAGE);
76
+ } else {
77
+ const releaseName = argument; ///
78
+
79
+ cloneAction(releaseName, quietly, yes, no);
80
+ }
69
81
 
70
82
  break;
71
83
  }
72
84
 
73
85
  case PUBLISH_COMMAND: {
74
- publishAction(argument, tail, follow, dryRun, logLevel);
86
+ if (argument === null) {
87
+ console.log(NO_ARGUMENT_GIVEN_MESSAGE);
88
+ } else {
89
+ const releaseName = argument; ///
90
+
91
+ publishAction(releaseName, tail, follow, dryRun, logLevel);
92
+ }
75
93
 
76
94
  break;
77
95
  }
78
96
 
79
97
  case SIGN_IN_COMMAND: {
80
- signInAction(argument);
98
+ const emailAddressOrUsername = argument; ///
99
+
100
+ signInAction(emailAddressOrUsername);
81
101
 
82
102
  break;
83
103
  }
@@ -89,13 +109,9 @@ function main(command, argument, options) {
89
109
  }
90
110
 
91
111
  case WITHDRAW_COMMAND: {
92
- withdrawAction(argument);
112
+ const releaseName = argument; ///
93
113
 
94
- break;
95
- }
96
-
97
- case INITIALISE_COMMAND: {
98
- initialiseAction();
114
+ withdrawAction(releaseName);
99
115
 
100
116
  break;
101
117
  }
@@ -107,13 +123,17 @@ function main(command, argument, options) {
107
123
  }
108
124
 
109
125
  case CREATE_ACCOUNT_COMMAND: {
110
- createAccountAction(argument);
126
+ const emailAddress = argument; ///
127
+
128
+ createAccountAction(emailAddress);
111
129
 
112
130
  break;
113
131
  }
114
132
 
115
133
  case RESET_PASSWORD_COMMAND: {
116
- resetPasswordAction(argument);
134
+ const emailAddress = argument; ///
135
+
136
+ resetPasswordAction(emailAddress);
117
137
 
118
138
  break;
119
139
  }
@@ -125,9 +145,7 @@ function main(command, argument, options) {
125
145
  }
126
146
 
127
147
  default: {
128
- argument = command; ///
129
-
130
- openAction(argument, quietly, yes, no);
148
+ console.log(COMMAND_NOT_RECOGNISED_MESSAGE);
131
149
 
132
150
  break;
133
151
  }
package/bin/messages.js CHANGED
@@ -1,6 +1,7 @@
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
+ COMMAND_NOT_RECOGNISED_MESSAGE = "The command is not recognised.",
4
5
  PASSWORDS_DO_NOT_MATCH_MESSAGE = "The passwords do not match.",
5
6
  SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE = "The server did not respond in a timely or intelligible fashion. If this problem persists then please be kind enough to report it.",
6
7
  CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE = "The action cannot be performed because the configuration file is missing. Run 'open initialise' to create one.",
@@ -29,7 +30,8 @@ const NO_COMMAND_GIVEN_MESSAGE = "No command has been given.",
29
30
  SUCCESSFUL_SET_SHELL_COMMANDS_MESSAGE = "The shell commands have been set successfully.";
30
31
 
31
32
  module.exports = {
32
- NO_COMMAND_GIVEN_MESSAGE,
33
+ NO_ARGUMENT_GIVEN_MESSAGE,
34
+ COMMAND_NOT_RECOGNISED_MESSAGE,
33
35
  PASSWORDS_DO_NOT_MATCH_MESSAGE,
34
36
  SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE,
35
37
  CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE,
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { updateIdentityToken } = require("../configuration");
4
4
 
5
- function setIdentityTokenOperation(proceed, abort, context) {
5
+ function updateIdentityTokenOperation(proceed, abort, context) {
6
6
  const { identityToken } = context;
7
7
 
8
8
  if (identityToken !== null) {
@@ -12,4 +12,4 @@ function setIdentityTokenOperation(proceed, abort, context) {
12
12
  proceed();
13
13
  }
14
14
 
15
- module.exports = setIdentityTokenOperation;
15
+ module.exports = updateIdentityTokenOperation;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { updateOptions } = require("../configuration");
4
4
 
5
- function setOptionsOperation(proceed, abort, context) {
5
+ function updateOptionsOperation(proceed, abort, context) {
6
6
  const { useSSH } = context,
7
7
  options = {};
8
8
 
@@ -22,4 +22,4 @@ function setOptionsOperation(proceed, abort, context) {
22
22
  proceed();
23
23
  }
24
24
 
25
- module.exports = setOptionsOperation;
25
+ module.exports = updateOptionsOperation;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ const { updateShellCommands } = require("../configuration");
4
+
5
+ function updateShellCommandsOperation(proceed, abort, context) {
6
+ const { shellCommands } = context;
7
+
8
+ updateShellCommands(shellCommands);
9
+
10
+ proceed();
11
+ }
12
+
13
+ module.exports = updateShellCommandsOperation;
package/bin/prepare.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ const changeDirectory = require("./changeDirectory");
4
+
5
+ const { DEFAULT_HELP, DEFAULT_VERSION } = require("./defaults"),
6
+ { HELP_COMMAND, VERSION_COMMAND, INITIALISE_COMMAND, OPEN_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 directoryName = changeDirectory();
26
+
27
+ if (directoryName !== null) {
28
+ argument = directoryName; ///
29
+ }
30
+
31
+ if (argument === null) {
32
+ argument = command; ///
33
+
34
+ command = OPEN_COMMAND;
35
+ }
36
+
37
+ if (command === null) {
38
+ command = OPEN_COMMAND;
39
+ }
40
+
41
+ main(command, argument, options);
42
+ }
43
+
44
+ module.exports = prepare;
@@ -2,12 +2,6 @@
2
2
 
3
3
  const { EMPTY_STRING } = require("../constants");
4
4
 
5
- function trimTrailingSlash(string) {
6
- string = string.replace(/\/$/, EMPTY_STRING); ///
7
-
8
- return string;
9
- }
10
-
11
5
  function trimTrailingCarriageReturn(string) {
12
6
  string = string.replace(/\n$/, EMPTY_STRING); ///
13
7
 
@@ -15,6 +9,5 @@ function trimTrailingCarriageReturn(string) {
15
9
  }
16
10
 
17
11
  module.exports = {
18
- trimTrailingSlash,
19
12
  trimTrailingCarriageReturn
20
13
  };
package/open.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": "occam-open-cli",
3
3
  "author": "James Smith",
4
- "version": "6.0.172",
4
+ "version": "6.0.174",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/occam-open-cli",
7
7
  "description": "Occam's command line package management tool.",
package/bin/configure.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
-
3
- const { pathUtilities } = require("necessary");
4
-
5
- const { DOUBLE_DOTS } = require("./constants"),
6
- { DEFAULT_HELP, DEFAULT_VERSION } = require("./defaults"),
7
- { migrateConfigurationFile, checkConfigurationFileExists } = require("./configuration"),
8
- { HELP_COMMAND, VERSION_COMMAND, INITIALISE_COMMAND, PUBLISH_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
- if (directoryName !== null) {
32
- if (command === null) {
33
- command = PUBLISH_COMMAND;
34
- }
35
-
36
- argument = directoryName; ///
37
- }
38
-
39
- if (argument === null) {
40
- argument = command; ///
41
-
42
- command = PUBLISH_COMMAND;
43
- }
44
-
45
- main(command, argument, options);
46
- }
47
-
48
- module.exports = configure;
49
-
50
- function changeDirectory(command) {
51
- let directoryName = null,
52
- configurationFileExists = checkConfigurationFileExists();
53
-
54
- if (!configurationFileExists) {
55
- const currentWorkingDirectoryPath = process.cwd(); ///
56
-
57
- process.chdir(DOUBLE_DOTS);
58
-
59
- const oldCurrentWorkingDirectoryPath = currentWorkingDirectoryPath; ///
60
-
61
- configurationFileExists = checkConfigurationFileExists();
62
-
63
- if (configurationFileExists) {
64
- const bottommostOldCurrentWorkingDirectoryName = bottommostNameFromPath(oldCurrentWorkingDirectoryPath);
65
-
66
- directoryName = bottommostOldCurrentWorkingDirectoryName; ///
67
- } else {
68
- process.chdir(oldCurrentWorkingDirectoryPath);
69
- }
70
- }
71
-
72
- if (command !== INITIALISE_COMMAND) {
73
- migrateConfigurationFile();
74
- }
75
-
76
- return directoryName;
77
- }