occam-open-cli 4.0.66 → 5.0.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.
Files changed (66) hide show
  1. package/README.md +7 -17
  2. package/bin/action/clone.js +15 -24
  3. package/bin/action/createAccount.js +41 -0
  4. package/bin/action/deprecate.js +13 -14
  5. package/bin/action/help.js +4 -14
  6. package/bin/action/initialise.js +12 -2
  7. package/bin/action/install.js +6 -6
  8. package/bin/action/publish.js +12 -11
  9. package/bin/action/resetPassword.js +11 -13
  10. package/bin/action/setOptions.js +10 -26
  11. package/bin/action/signIn.js +37 -0
  12. package/bin/action/signOut.js +16 -0
  13. package/bin/actions.js +11 -26
  14. package/bin/commands.js +8 -18
  15. package/bin/configuration/version_1_5.js +1 -22
  16. package/bin/configuration/version_2_0.js +1 -16
  17. package/bin/configuration/version_5_0.js +42 -0
  18. package/bin/configuration.js +26 -21
  19. package/bin/constants.js +2 -0
  20. package/bin/defaults.js +3 -3
  21. package/bin/descriptions.js +2 -8
  22. package/bin/messages.js +24 -50
  23. package/bin/operation/checkMetaJSONFileExists.js +0 -4
  24. package/bin/operation/checkReadmeFileExists.js +0 -4
  25. package/bin/{cloneRepository.js → operation/clone.js} +12 -8
  26. package/bin/operation/createAccount.js +33 -0
  27. package/bin/operation/createRelease.js +1 -4
  28. package/bin/operation/deflateRelease.js +1 -1
  29. package/bin/operation/deprecate.js +23 -0
  30. package/bin/operation/getIdentityToken.js +21 -0
  31. package/bin/operation/prompt/areYouSure.js +5 -5
  32. package/bin/operation/prompt/emailAddressOrUsername.js +53 -0
  33. package/bin/operation/prompt/useSSH.js +4 -4
  34. package/bin/operation/publish.js +24 -0
  35. package/bin/operation/repository.js +29 -0
  36. package/bin/operation/resetPassword.js +19 -0
  37. package/bin/operation/setIdentityToken.js +13 -0
  38. package/bin/operation/setOptions.js +25 -0
  39. package/bin/operation/signIn.js +32 -0
  40. package/bin/post.js +16 -49
  41. package/bin/uris.js +5 -15
  42. package/bin/utilities/validate.js +21 -4
  43. package/bin/versions.js +4 -2
  44. package/lib/entries.js +5 -5
  45. package/lib/node/dependency.js +4 -4
  46. package/lib/node/repository.js +4 -4
  47. package/lib/project.js +5 -5
  48. package/lib/projects.js +3 -3
  49. package/lib/utilities/fileSystem.js +4 -4
  50. package/lib/utilities/tokens.js +3 -3
  51. package/package.json +3 -3
  52. package/bin/action/changeEmailAddress.js +0 -38
  53. package/bin/action/changePassword.js +0 -42
  54. package/bin/action/confirmEmailAddress.js +0 -36
  55. package/bin/action/login.js +0 -41
  56. package/bin/action/logout.js +0 -26
  57. package/bin/action/register.js +0 -40
  58. package/bin/action/remove.js +0 -9
  59. package/bin/action/resendConfirmationCode.js +0 -32
  60. package/bin/action.js +0 -19
  61. package/bin/configuration/unversioned.js +0 -24
  62. package/bin/operation/prompt/confirmNewPassword.js +0 -42
  63. package/bin/operation/prompt/confirmationCode.js +0 -41
  64. package/bin/operation/prompt/newEmailAddress.js +0 -41
  65. package/bin/operation/prompt/newPassword.js +0 -41
  66. package/bin/operation/retrieveAccessToken.js +0 -24
@@ -1,20 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const { VERSION_2_0 } = require("../versions"),
4
- { DEFAULT_HOST_URL } = require("../defaults");
5
-
6
- function createConfiguration() {
7
- const version = VERSION_2_0, ///
8
- options = {},
9
- hostURL = DEFAULT_HOST_URL, ///
10
- configuration = {
11
- version,
12
- options,
13
- hostURL
14
- };
15
-
16
- return configuration;
17
- }
3
+ const { VERSION_2_0 } = require("../versions");
18
4
 
19
5
  function migrateConfigurationToVersion_2_0(configuration) {
20
6
  const version = VERSION_2_0;
@@ -27,6 +13,5 @@ function migrateConfigurationToVersion_2_0(configuration) {
27
13
  }
28
14
 
29
15
  module.exports = {
30
- createConfiguration,
31
16
  migrateConfigurationToVersion_2_0
32
17
  };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ const { HOST_URL } = require("../constants"),
4
+ { VERSION_5_0 } = require("../versions"),
5
+ { DEFAULT_HOST } = require("../defaults");
6
+
7
+ function createConfiguration() {
8
+ const version = VERSION_5_0,
9
+ host = DEFAULT_HOST,
10
+ options = {},
11
+ identityToken = null,
12
+ configuration = {
13
+ version,
14
+ host,
15
+ options,
16
+ identityToken
17
+ };
18
+
19
+ return configuration;
20
+ }
21
+
22
+ function migrateConfigurationToVersion_5_0(configuration) {
23
+ const { hostURL } = configuration,
24
+ version = VERSION_5_0,
25
+ host = hostURL, ///
26
+ identityToken = null;
27
+
28
+ delete configuration[HOST_URL];
29
+
30
+ Object.assign(configuration, {
31
+ version,
32
+ host,
33
+ identityToken
34
+ });
35
+
36
+ return configuration;
37
+ }
38
+
39
+ module.exports = {
40
+ createConfiguration,
41
+ migrateConfigurationToVersion_5_0
42
+ };
@@ -4,9 +4,10 @@ const { configurationUtilities } = require("necessary");
4
4
 
5
5
  const { OPEN } = require("./constants"),
6
6
  { CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE } = require("./messages"),
7
- { UNVERSIONED, VERSION_1_5, CURRENT_VERSION } = require("./versions"),
8
7
  { migrateConfigurationToVersion_1_5 } = require("./configuration/version_1_5"),
9
- { migrateConfigurationToVersion_2_0, createConfiguration } = require("./configuration/version_2_0");
8
+ { migrateConfigurationToVersion_2_0 } = require("./configuration/version_2_0"),
9
+ { UNVERSIONED, VERSION_1_5, VERSION_2_0, CURRENT_VERSION } = require("./versions"),
10
+ { migrateConfigurationToVersion_5_0, createConfiguration } = require("./configuration/version_5_0");
10
11
 
11
12
  const { rc } = configurationUtilities,
12
13
  { setRCBaseExtension, checkRCFileExists, updateRCFile, writeRCFile, readRCFile } = rc;
@@ -15,41 +16,41 @@ const rcBaseExtension = OPEN;
15
16
 
16
17
  setRCBaseExtension(rcBaseExtension);
17
18
 
18
- function retrieveHostURL() {
19
+ function getHost() {
19
20
  const configuration = readConfigurationFile(),
20
- { hostURL } = configuration;
21
+ { host } = configuration;
21
22
 
22
- return hostURL;
23
+ return host;
23
24
  }
24
25
 
25
- function retrieveOptions() {
26
+ function getOptions() {
26
27
  const configuration = readConfigurationFile(),
27
28
  { options } = configuration;
28
29
 
29
30
  return options;
30
31
  }
31
32
 
32
- function retrieveAccessToken() {
33
+ function getIdentityToken() {
33
34
  const configuration = readConfigurationFile(),
34
- { accessToken } = configuration;
35
+ { identityToken } = configuration;
35
36
 
36
- return accessToken || null; ///
37
+ return identityToken;
37
38
  }
38
39
 
39
- function updateOptions(options) {
40
+ function setOptions(options) {
40
41
  updateConfigurationFile({
41
42
  options
42
43
  });
43
44
  }
44
45
 
45
- function addAccessToken(accessToken) {
46
+ function setIdentityToken(identityToken) {
46
47
  updateConfigurationFile({
47
- accessToken
48
+ identityToken
48
49
  });
49
50
  }
50
51
 
51
- function removeAccessToken() {
52
- updateConfigurationFile(null, "accessToken");
52
+ function removeIdentityToken() {
53
+ updateConfigurationFile(null, "identityToken");
53
54
  }
54
55
 
55
56
  function createConfigurationFile() {
@@ -77,6 +78,10 @@ function migrateConfigurationFile() {
77
78
  case VERSION_1_5 :
78
79
  configuration = migrateConfigurationToVersion_2_0(configuration);
79
80
  break;
81
+
82
+ case VERSION_2_0 :
83
+ configuration = migrateConfigurationToVersion_5_0(configuration);
84
+ break;
80
85
  }
81
86
 
82
87
  version = configuration.version || UNVERSIONED; ///
@@ -95,12 +100,12 @@ function checkConfigurationFileExists() {
95
100
  }
96
101
 
97
102
  module.exports = {
98
- retrieveHostURL,
99
- retrieveOptions,
100
- updateOptions,
101
- addAccessToken,
102
- removeAccessToken,
103
- retrieveAccessToken,
103
+ getHost,
104
+ getOptions,
105
+ getIdentityToken,
106
+ setOptions,
107
+ setIdentityToken,
108
+ removeIdentityToken,
104
109
  createConfigurationFile,
105
110
  migrateConfigurationFile,
106
111
  checkConfigurationFileExists
@@ -138,6 +143,6 @@ function assertConfigurationFileExists() {
138
143
  if (!configurationFileExists) {
139
144
  console.log(CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE);
140
145
 
141
- process.exit(1);
146
+ process.exit();
142
147
  }
143
148
  }
package/bin/constants.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const END = "end",
4
4
  DATA = "data",
5
5
  OPEN = "open",
6
+ HOST_URL = "hostURL",
6
7
  OPEN_CLI = "Open-CLI",
7
8
  DOUBLE_DOTS = "..",
8
9
  EMPTY_STRING = "",
@@ -12,6 +13,7 @@ module.exports = {
12
13
  END,
13
14
  DATA,
14
15
  OPEN,
16
+ HOST_URL,
15
17
  OPEN_CLI,
16
18
  DOUBLE_DOTS,
17
19
  EMPTY_STRING,
package/bin/defaults.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- const DEFAULT_USE_SSH = false,
4
- DEFAULT_HOST_URL = "https://openmathematics.org",
3
+ const DEFAULT_HOST = "https://openmathematics.org",
4
+ DEFAULT_USE_SSH = false,
5
5
  DEFAULT_HOST_NAME_SUFFIX = "",
6
6
  DEFAULT_GITHUB_HOST_NAME = "github.com";
7
7
 
8
8
  module.exports = {
9
+ DEFAULT_HOST,
9
10
  DEFAULT_USE_SSH,
10
- DEFAULT_HOST_URL,
11
11
  DEFAULT_HOST_NAME_SUFFIX,
12
12
  DEFAULT_GITHUB_HOST_NAME
13
13
  };
@@ -5,13 +5,10 @@ const USE_SSH_DESCRIPTION = "Use SSH when cloning: ",
5
5
  USERNAME_DESCRIPTION = "Username: ",
6
6
  RELEASE_NAME_DESCRIPTION = "Package name: ", ///
7
7
  ARE_YOU_SURE_DESCRIPTION = "Are you sure? (y)es (n)o: ",
8
- NEW_PASSWORD_DESCRIPTION = "New password: ",
9
8
  EMAIL_ADDRESS_DESCRIPTION = "Email address: ",
10
9
  CONFIRM_PASSWORD_DESCRIPTION = "Confirm password: ",
11
10
  GITHUB_HOST_NAME_DESCRIPTION = "GitHub host name (leave blank for default): ",
12
- NEW_EMAIL_ADDRESS_DESCRIPTION = "New email address: ",
13
- CONFIRMATION_CODE_DESCRIPTION = "Confirmation code: ",
14
- CONFIRM_NEW_PASSWORD_DESCRIPTION = "Confirm new password: ";
11
+ EMAIL_ADDRESS_OR_USERNAME_DESCRIPTION = "Email address or username: ";
15
12
 
16
13
  module.exports = {
17
14
  USE_SSH_DESCRIPTION,
@@ -19,11 +16,8 @@ module.exports = {
19
16
  USERNAME_DESCRIPTION,
20
17
  RELEASE_NAME_DESCRIPTION,
21
18
  ARE_YOU_SURE_DESCRIPTION,
22
- NEW_PASSWORD_DESCRIPTION,
23
19
  EMAIL_ADDRESS_DESCRIPTION,
24
20
  CONFIRM_PASSWORD_DESCRIPTION,
25
21
  GITHUB_HOST_NAME_DESCRIPTION,
26
- NEW_EMAIL_ADDRESS_DESCRIPTION,
27
- CONFIRMATION_CODE_DESCRIPTION,
28
- CONFIRM_NEW_PASSWORD_DESCRIPTION
22
+ EMAIL_ADDRESS_OR_USERNAME_DESCRIPTION
29
23
  };
package/bin/messages.js CHANGED
@@ -1,85 +1,59 @@
1
1
  "use strict";
2
2
 
3
- const SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE = "The server failed to respond in a timely fashion. If this problem persists, please be kind enough to report it.",
4
- SERVER_ERROR_MESSAGE = "There was an error on the server. If the problem persists, please be kind enough to report it (including the date and time).",
5
- PASSWORDS_DO_NOT_MATCH_MESSAGE = "The passwords do not match.",
6
- UNABLE_TO_CREATE_RELEASE_MESSAGE = "Unable to create a package.",
7
- README_FILE_DOES_NOT_EXIST_MESSAGE = "Published packages must include a readme file.",
8
- META_JSON_FILE_DOES_NOT_EXIST_MESSAGE = "Published packages must include a 'meta.json' file.",
3
+ const PASSWORDS_DO_NOT_MATCH_MESSAGE = "The passwords do not match.",
4
+ SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE = "The server failed to respond in a timely fashion. If this problem persists then please be kind enough to report it.",
9
5
  CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE = "The action cannot be performed because the configuration file is missing. Run 'open initialise' to create one.",
10
- NOT_LOGGED_IN_MESSAGE = "You are not logged in.",
11
- LOGGED_OUT_MESSAGE = "You have been logged out.",
12
- INVALID_ANSWER_MESSAGE = "You must answer (y)es or (n)o.",
6
+ INSTALL_MESSAGE = "The install functionality is not implemented yet.",
7
+ SIGN_OUT_MESSAGE = "You have been signed out.",
8
+ RESET_PASSWORD_MESSAGE = "If the email address corresponds to an account then an email will have been sent.",
13
9
  INVALID_USERNAME_MESSAGE = "Usernames must consist of groups of at least two and no more than sixteen numbers or lowercase letters, separated by dashes.",
14
10
  INVALID_PASSWORD_MESSAGE = "Passwords must consist of at least eight letters, numbers or common punctuation symbols.",
11
+ INVALID_AFFIRMATION_MESSAGE = "You must answer (y)es or (n)o.",
15
12
  INVALID_RELEASE_NAME_MESSAGE = "Package names must consist of groups of at least two and no more than sixteen numbers or lowercase letters, separated by dashes.",
16
13
  INVALID_EMAIL_ADDRESS_MESSAGE = "The email address does not appear to be a valid one.",
17
14
  INVALID_GITHUB_HOST_NAME_MESSAGE = "The GitHub host name can be any number of alphabetical, numeric, dash or period characters, or can be left blank.",
18
- INVALID_CONFIRMATION_CODE_MESSAGE = "Confirmation codes consist of six to ten alphabetical characters.",
19
- FAILED_CLONE_MESSAGE = "Failed to clone the package.",
20
- FAILED_LOGIN_MESSAGE = "Failed to login.",
15
+ INVALID_EMAIL_ADDRESS_OR_USERNAME_MESSAGE = "The email address or username does not appear to be a valid one.",
16
+ FAILED_CLONE_MESSAGE = "Failed to clone the package. Perhaps the readme file or meta JSON file is missing.",
17
+ FAILED_SIGN_IN_MESSAGE = "Failed to sign in.",
21
18
  FAILED_PUBLISH_MESSAGE = "Failed to publish the package.",
22
- FAILED_REGISTER_MESSAGE = "Failed to register.",
23
19
  FAILED_DEPRECATE_MESSAGE = "Failed to deprecate the package.",
24
20
  FAILED_INITIALISE_MESSAGE = "Failed to create a configuration file because one is already present.",
25
21
  FAILED_SET_OPTIONS_MESSAGE = "Failed to set the options.",
26
- FAILED_RESET_PASSWORD_MESSAGE = "Failed to reset the password.",
27
- FAILED_CHANGE_PASSWORD_MESSAGE = "Failed to change the password.",
28
- FAILED_CHANGE_EMAIL_ADDRESS_MESSAGE = "Failed to change the email address.",
29
- FAILED_CONFIRM_EMAIL_ADDRESS_MESSAGE = "Failed to confirm the email address.",
30
- FAILED_RESEND_CONFIRMATION_CODE_MESSAGE = "Failed to resend the confirmation code.",
22
+ FAILED_CREATE_ACCOUNT_MESSAGE = "Failed to create account.",
31
23
  SUCCESSFUL_CLONE_MESSAGE = "The package has been cloned successfully.",
32
- SUCCESSFUL_LOGIN_MESSAGE = "You have logged in successfully.",
24
+ SUCCESSFUL_SIGN_IN_MESSAGE = "You have signed in successfully.",
33
25
  SUCCESSFUL_PUBLISH_MESSAGE = "The package has been published successfully.",
34
- SUCCESSFUL_REGISTER_MESSAGE = "You have been registered successfully. You can now log in.",
26
+ SUCCESSFUL_CREATE_ACCOUNT_MESSAGE = "You have created an account successfully.",
35
27
  SUCCESSFUL_DEPRECATE_MESSAGE = "The package has been deprecated successfully.",
36
28
  SUCCESSFUL_INITIALISE_MESSAGE = "The configuration file has been created successfully.",
37
- SUCCESSFUL_SET_OPTIONS_MESSAGE = "The options have been set successfully.",
38
- SUCCESSFUL_RESET_PASSWORD_MESSAGE = "Your password has been reset successfully. Please check your email for further instructions.",
39
- SUCCESSFUL_CHANGE_PASSWORD_MESSAGE = "Your password has been changed successfully.",
40
- SUCCESSFUL_CHANGE_EMAIL_ADDRESS_MESSAGE = "You have successfully changed your email address.",
41
- SUCCESSFUL_CONFIRM_EMAIL_ADDRESS_MESSAGE = "You have successfully confirmed your email address.",
42
- SUCCESSFUL_RESEND_CONFIRMATION_CODE_MESSAGE = "A new confirmation code was sent successfully. Please check your email.";
29
+ SUCCESSFUL_SET_OPTIONS_MESSAGE = "The options have been set successfully.";
43
30
 
44
31
  module.exports = {
45
- SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE,
46
- SERVER_ERROR_MESSAGE,
47
32
  PASSWORDS_DO_NOT_MATCH_MESSAGE,
48
- UNABLE_TO_CREATE_RELEASE_MESSAGE,
49
- README_FILE_DOES_NOT_EXIST_MESSAGE,
50
- META_JSON_FILE_DOES_NOT_EXIST_MESSAGE,
33
+ SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE,
51
34
  CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE,
52
- NOT_LOGGED_IN_MESSAGE,
53
- LOGGED_OUT_MESSAGE,
54
- INVALID_ANSWER_MESSAGE,
35
+ INSTALL_MESSAGE,
36
+ SIGN_OUT_MESSAGE,
37
+ RESET_PASSWORD_MESSAGE,
55
38
  INVALID_USERNAME_MESSAGE,
56
39
  INVALID_PASSWORD_MESSAGE,
40
+ INVALID_AFFIRMATION_MESSAGE,
57
41
  INVALID_RELEASE_NAME_MESSAGE,
58
42
  INVALID_EMAIL_ADDRESS_MESSAGE,
59
43
  INVALID_GITHUB_HOST_NAME_MESSAGE,
60
- INVALID_CONFIRMATION_CODE_MESSAGE,
44
+ INVALID_EMAIL_ADDRESS_OR_USERNAME_MESSAGE,
61
45
  FAILED_CLONE_MESSAGE,
62
- FAILED_LOGIN_MESSAGE,
46
+ FAILED_SIGN_IN_MESSAGE,
63
47
  FAILED_PUBLISH_MESSAGE,
64
- FAILED_REGISTER_MESSAGE,
65
48
  FAILED_DEPRECATE_MESSAGE,
66
49
  FAILED_INITIALISE_MESSAGE,
67
50
  FAILED_SET_OPTIONS_MESSAGE,
68
- FAILED_RESET_PASSWORD_MESSAGE,
69
- FAILED_CHANGE_PASSWORD_MESSAGE,
70
- FAILED_CHANGE_EMAIL_ADDRESS_MESSAGE,
71
- FAILED_CONFIRM_EMAIL_ADDRESS_MESSAGE,
72
- FAILED_RESEND_CONFIRMATION_CODE_MESSAGE,
51
+ FAILED_CREATE_ACCOUNT_MESSAGE,
73
52
  SUCCESSFUL_CLONE_MESSAGE,
74
- SUCCESSFUL_LOGIN_MESSAGE,
53
+ SUCCESSFUL_SIGN_IN_MESSAGE,
75
54
  SUCCESSFUL_PUBLISH_MESSAGE,
76
- SUCCESSFUL_REGISTER_MESSAGE,
55
+ SUCCESSFUL_CREATE_ACCOUNT_MESSAGE,
77
56
  SUCCESSFUL_DEPRECATE_MESSAGE,
78
57
  SUCCESSFUL_INITIALISE_MESSAGE,
79
- SUCCESSFUL_SET_OPTIONS_MESSAGE,
80
- SUCCESSFUL_RESET_PASSWORD_MESSAGE,
81
- SUCCESSFUL_CHANGE_PASSWORD_MESSAGE,
82
- SUCCESSFUL_CHANGE_EMAIL_ADDRESS_MESSAGE,
83
- SUCCESSFUL_CONFIRM_EMAIL_ADDRESS_MESSAGE,
84
- SUCCESSFUL_RESEND_CONFIRMATION_CODE_MESSAGE
58
+ SUCCESSFUL_SET_OPTIONS_MESSAGE
85
59
  };
@@ -1,15 +1,11 @@
1
1
  "use strict";
2
2
 
3
- const { META_JSON_FILE_DOES_NOT_EXIST_MESSAGE } = require("../messages");
4
-
5
3
  function checkMetaJSONFileExistsOperation(proceed, abort, context) {
6
4
  const { release } = context,
7
5
  metaJSONFile = release.getMetaJSONFile(),
8
6
  metaJSONFileExists = (metaJSONFile !== null);
9
7
 
10
8
  if (!metaJSONFileExists) {
11
- console.log(META_JSON_FILE_DOES_NOT_EXIST_MESSAGE);
12
-
13
9
  abort();
14
10
 
15
11
  return;
@@ -1,15 +1,11 @@
1
1
  "use strict";
2
2
 
3
- const { README_FILE_DOES_NOT_EXIST_MESSAGE } = require("../messages");
4
-
5
3
  function checkReadmeFileExistsOperation(proceed, abort, context) {
6
4
  const { release } = context,
7
5
  readmeFile = release.getReadmeFile(),
8
6
  readmeFileExists = (readmeFile !== null);
9
7
 
10
8
  if (!readmeFileExists) {
11
- console.log(README_FILE_DOES_NOT_EXIST_MESSAGE);
12
-
13
9
  abort();
14
10
 
15
11
  return;
@@ -2,11 +2,13 @@
2
2
 
3
3
  const { exec } = require("child_process");
4
4
 
5
- const { retrieveOptions } = require("./configuration"),
6
- { DEFAULT_GITHUB_HOST_NAME } = require("./defaults");
5
+ const { getOptions } = require("../configuration"),
6
+ { DEFAULT_GITHUB_HOST_NAME } = require("../defaults");
7
7
 
8
- function cloneRepository(repository, callback) {
9
- const options = retrieveOptions(),
8
+ function cloneOperation(proceed, abort, context) {
9
+ let { repository } = context;
10
+
11
+ const options = getOptions(),
10
12
  { ssh } = options;
11
13
 
12
14
  if (ssh) {
@@ -18,14 +20,16 @@ function cloneRepository(repository, callback) {
18
20
  const command = `git clone ${repository}.git`;
19
21
 
20
22
  exec(command, (error) => {
21
- const success = !error;
22
-
23
23
  if (error) {
24
24
  console.log(`An error occurred: ${error}`);
25
+
26
+ abort();
27
+
28
+ return;
25
29
  }
26
30
 
27
- callback(success);
31
+ proceed();
28
32
  })
29
33
  }
30
34
 
31
- module.exports = cloneRepository;
35
+ module.exports = cloneOperation;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ const post = require("../post");
4
+
5
+ const { CREATE_ACCOUNT_API_URI } = require("../uris");
6
+
7
+ function createAccountOperation(proceed, abort, context) {
8
+ const { username, password, emailAddress } = context,
9
+ uri = CREATE_ACCOUNT_API_URI,
10
+ json = {
11
+ username,
12
+ password,
13
+ emailAddress
14
+ };
15
+
16
+ post(uri, json, (json) => {
17
+ const { identityToken = null } = json;
18
+
19
+ if (identityToken === null) {
20
+ abort();
21
+
22
+ return;
23
+ }
24
+
25
+ Object.assign(context, {
26
+ identityToken
27
+ });
28
+
29
+ proceed();
30
+ });
31
+ }
32
+
33
+ module.exports = createAccountOperation;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const { fileSystemUtilities } = require("../../lib/main"), ///
4
- { UNABLE_TO_CREATE_RELEASE_MESSAGE } = require("../messages");
3
+ const { fileSystemUtilities } = require("../../lib/main"); ///
5
4
 
6
5
  const { releaseFromName } = fileSystemUtilities;
7
6
 
@@ -11,8 +10,6 @@ function createReleaseOperation(proceed, abort, context) {
11
10
  release = releaseFromName(name);
12
11
 
13
12
  if (release === null) {
14
- console.log(UNABLE_TO_CREATE_RELEASE_MESSAGE);
15
-
16
13
  abort();
17
14
 
18
15
  return;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { encodings } from "necessary";
3
+ const { encodings } = require("necessary");
4
4
 
5
5
  const { deflate } = require("zlib");
6
6
 
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ const post = require("../post");
4
+
5
+ const { DEPRECATE_API_URI } = require("../uris");
6
+
7
+ function deprecateOperation(proceed, abort, context) {
8
+ const { releaseName, identityToken } = context,
9
+ uri = `${DEPRECATE_API_URI}/${releaseName}`,
10
+ json = {
11
+ identityToken
12
+ };
13
+
14
+ post(uri, json, (json) => {
15
+ const { success } = json;
16
+
17
+ success ?
18
+ proceed() :
19
+ abort();
20
+ });
21
+ }
22
+
23
+ module.exports = deprecateOperation;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ const { getIdentityToken } = require("../configuration");
4
+
5
+ function getIdentityTokenOperation(proceed, abort, context) {
6
+ const identityToken = getIdentityToken();
7
+
8
+ if (!identityToken) {
9
+ abort();
10
+
11
+ return;
12
+ }
13
+
14
+ Object.assign(context, {
15
+ identityToken
16
+ });
17
+
18
+ proceed();
19
+ }
20
+
21
+ module.exports = getIdentityTokenOperation;
@@ -2,17 +2,17 @@
2
2
 
3
3
  const { shellUtilities } = require("necessary");
4
4
 
5
- const { validateAnswer } = require("../../utilities/validate"),
5
+ const { validateAffirmation } = require("../../utilities/validate"),
6
6
  { isAnswerAffirmative } = require("../../utilities/prompt"),
7
- { INVALID_ANSWER_MESSAGE } = require("../../messages"),
8
- { ARE_YOU_SURE_DESCRIPTION } = require("../../descriptions");
7
+ { ARE_YOU_SURE_DESCRIPTION } = require("../../descriptions"),
8
+ { INVALID_AFFIRMATION_MESSAGE } = require("../../messages");
9
9
 
10
10
  const { prompt } = shellUtilities;
11
11
 
12
12
  function areYouSurePromptOperation(proceed, abort, context) {
13
13
  const description = ARE_YOU_SURE_DESCRIPTION,
14
- errorMessage = INVALID_ANSWER_MESSAGE,
15
- validationFunction = validateAnswer, ///
14
+ errorMessage = INVALID_AFFIRMATION_MESSAGE,
15
+ validationFunction = validateAffirmation, ///
16
16
  options = {
17
17
  description,
18
18
  errorMessage,
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ const { shellUtilities } = require("necessary");
4
+
5
+ const { validateEmailAddressOrUsername } = require("../../utilities/validate"),
6
+ { EMAIL_ADDRESS_OR_USERNAME_DESCRIPTION } = require("../../descriptions"),
7
+ { INVALID_EMAIL_ADDRESS_OR_USERNAME_MESSAGE } = require("../../messages");
8
+
9
+ const { prompt } = shellUtilities;
10
+
11
+ function emailAddressOrUsernamePromptOperation(proceed, abort, context) {
12
+ const { emailAddressOrUsername } = context,
13
+ errorMessage = INVALID_EMAIL_ADDRESS_OR_USERNAME_MESSAGE;
14
+
15
+ if (emailAddressOrUsername !== null) {
16
+ const valid = validateEmailAddressOrUsername(emailAddressOrUsername);
17
+
18
+ if (valid) {
19
+ proceed();
20
+
21
+ return;
22
+ } else {
23
+ console.log(errorMessage);
24
+ }
25
+ }
26
+
27
+ const description = EMAIL_ADDRESS_OR_USERNAME_DESCRIPTION,
28
+ validationFunction = validateEmailAddressOrUsername, ///
29
+ options = {
30
+ description,
31
+ errorMessage,
32
+ validationFunction
33
+ };
34
+
35
+ prompt(options, (answer) => {
36
+ const emailAddressOrUsername = answer, ///
37
+ valid = (emailAddressOrUsername !== null);
38
+
39
+ if (valid) {
40
+ Object.assign(context, {
41
+ emailAddressOrUsername
42
+ });
43
+
44
+ proceed();
45
+
46
+ return;
47
+ }
48
+
49
+ abort();
50
+ });
51
+ }
52
+
53
+ module.exports = emailAddressOrUsernamePromptOperation;
@@ -2,17 +2,17 @@
2
2
 
3
3
  const { shellUtilities } = require("necessary");
4
4
 
5
- const { validateAnswer } = require("../../utilities/validate"),
5
+ const { validateAffirmation } = require("../../utilities/validate"),
6
6
  { isAnswerAffirmative } = require("../../utilities/prompt"),
7
7
  { USE_SSH_DESCRIPTION } = require("../../descriptions"),
8
- { INVALID_ANSWER_MESSAGE } = require("../../messages");
8
+ { INVALID_AFFIRMATION_MESSAGE } = require("../../messages");
9
9
 
10
10
  const { prompt } = shellUtilities;
11
11
 
12
12
  function useSSHPromptOperation(proceed, abort, context) {
13
13
  const description = USE_SSH_DESCRIPTION,
14
- errorMessage = INVALID_ANSWER_MESSAGE,
15
- validationFunction = validateAnswer, ///
14
+ errorMessage = INVALID_AFFIRMATION_MESSAGE,
15
+ validationFunction = validateAffirmation, ///
16
16
  options = {
17
17
  description,
18
18
  errorMessage,
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ const post = require("../post");
4
+
5
+ const { PUBLISH_API_URI } = require("../uris");
6
+
7
+ function deprecateOperation(proceed, abort, context) {
8
+ const { releaseName, identityToken, deflatedRelease } = context,
9
+ uri = `${PUBLISH_API_URI}/${releaseName}`,
10
+ json = {
11
+ identityToken,
12
+ deflatedRelease
13
+ };
14
+
15
+ post(uri, json, (json) => {
16
+ const { success } = json;
17
+
18
+ success ?
19
+ proceed() :
20
+ abort();
21
+ });
22
+ }
23
+
24
+ module.exports = deprecateOperation;