occam-open-cli 5.0.122 → 5.0.124
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 +4 -2
- package/bin/abbreviations.js +4 -2
- package/bin/action/help.js +4 -2
- package/bin/action/open.js +2 -1
- package/bin/actions.js +4 -3
- package/bin/constants.js +3 -1
- package/bin/defaults.js +3 -1
- package/bin/messages.js +2 -0
- package/bin/operation/open.js +3 -1
- package/bin/operation/unpackReleases.js +75 -20
- package/bin/options.js +3 -1
- package/bin/utilities/validate.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,10 +35,10 @@ These are the commands and options:
|
|
|
35
35
|
|
|
36
36
|
Commands:
|
|
37
37
|
|
|
38
|
-
version Show the version
|
|
39
|
-
|
|
40
38
|
help Show this help
|
|
41
39
|
|
|
40
|
+
version Show the version
|
|
41
|
+
|
|
42
42
|
[install] <package_name> Install a package
|
|
43
43
|
|
|
44
44
|
initialise Create a configuration file
|
|
@@ -68,6 +68,8 @@ Options:
|
|
|
68
68
|
--quietly|-q Run with almost no console logging
|
|
69
69
|
|
|
70
70
|
--log-level|-l Set the log level when publishing
|
|
71
|
+
|
|
72
|
+
--yes|-y Initially answer yes to prompts
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
This is slightly different from `npm` in that `open` is usually executed from the parent directory of a project rather than from within the project sub-directory itself. Projects might reside in a `~/Mathematics/` directory, for example, in which case you should initialise `open` in there:
|
package/bin/abbreviations.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { HELP_OPTION, DRY_RUN_OPTION, VERSION_OPTION, QUIETLY_OPTION, LOG_LEVEL_OPTION } = require("./options");
|
|
3
|
+
const { YES_OPTION, HELP_OPTION, DRY_RUN_OPTION, VERSION_OPTION, QUIETLY_OPTION, LOG_LEVEL_OPTION } = require("./options");
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const y = YES_OPTION,
|
|
6
|
+
h = HELP_OPTION,
|
|
6
7
|
d = DRY_RUN_OPTION,
|
|
7
8
|
v = VERSION_OPTION,
|
|
8
9
|
q = QUIETLY_OPTION,
|
|
9
10
|
l = LOG_LEVEL_OPTION
|
|
10
11
|
|
|
11
12
|
module.exports = {
|
|
13
|
+
y,
|
|
12
14
|
h,
|
|
13
15
|
d,
|
|
14
16
|
v,
|
package/bin/action/help.js
CHANGED
|
@@ -7,10 +7,10 @@ function helpAction() {
|
|
|
7
7
|
|
|
8
8
|
Commands:
|
|
9
9
|
|
|
10
|
-
version Show the version
|
|
11
|
-
|
|
12
10
|
help Show this help
|
|
13
11
|
|
|
12
|
+
version Show the version
|
|
13
|
+
|
|
14
14
|
[install] <package_name> Install a package
|
|
15
15
|
|
|
16
16
|
initialise Create a configuration file
|
|
@@ -40,6 +40,8 @@ Options:
|
|
|
40
40
|
--quietly|-q Run with almost no console logging
|
|
41
41
|
|
|
42
42
|
--log-level|-l Set the log level when publishing
|
|
43
|
+
|
|
44
|
+
--yes|-y Initially answer yes to prompts
|
|
43
45
|
|
|
44
46
|
Further information:
|
|
45
47
|
|
package/bin/action/open.js
CHANGED
|
@@ -7,7 +7,7 @@ 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) {
|
|
10
|
+
function openAction(argument, quietly, yes) {
|
|
11
11
|
const releaseName = argument, ///
|
|
12
12
|
operations = [
|
|
13
13
|
releaseNamePromptOperation,
|
|
@@ -15,6 +15,7 @@ function openAction(argument, quietly) {
|
|
|
15
15
|
unpackReleasesOperation
|
|
16
16
|
],
|
|
17
17
|
context = {
|
|
18
|
+
yes,
|
|
18
19
|
quietly,
|
|
19
20
|
releaseName
|
|
20
21
|
};
|
package/bin/actions.js
CHANGED
|
@@ -13,7 +13,7 @@ const helpAction = require("./action/help"),
|
|
|
13
13
|
createAccountAction = require("./action/createAccount"),
|
|
14
14
|
resetPasswordAction = require("./action/resetPassword");
|
|
15
15
|
|
|
16
|
-
const { DEFAULT_HELP, DEFAULT_DRY_RUN, DEFAULT_VERSION, DEFAULT_QUIETLY, DEFAULT_LOG_LEVEL } = require("./defaults"),
|
|
16
|
+
const { DEFAULT_YES, DEFAULT_HELP, DEFAULT_DRY_RUN, DEFAULT_VERSION, DEFAULT_QUIETLY, DEFAULT_LOG_LEVEL } = require("./defaults"),
|
|
17
17
|
{ HELP_COMMAND,
|
|
18
18
|
OPEN_COMMAND,
|
|
19
19
|
CLONE_COMMAND,
|
|
@@ -29,7 +29,8 @@ const { DEFAULT_HELP, DEFAULT_DRY_RUN, DEFAULT_VERSION, DEFAULT_QUIETLY, DEFAULT
|
|
|
29
29
|
|
|
30
30
|
function actions(command, argument, options) {
|
|
31
31
|
const commandMissing = (command === null),
|
|
32
|
-
{
|
|
32
|
+
{ yes = DEFAULT_YES,
|
|
33
|
+
help = DEFAULT_HELP,
|
|
33
34
|
dryRun = DEFAULT_DRY_RUN,
|
|
34
35
|
version = DEFAULT_VERSION,
|
|
35
36
|
quietly = DEFAULT_QUIETLY,
|
|
@@ -47,7 +48,7 @@ function actions(command, argument, options) {
|
|
|
47
48
|
|
|
48
49
|
switch (command) {
|
|
49
50
|
case HELP_COMMAND : helpAction(); break;
|
|
50
|
-
case OPEN_COMMAND : openAction(argument, quietly); break;
|
|
51
|
+
case OPEN_COMMAND : openAction(argument, quietly, yes); break;
|
|
51
52
|
case CLONE_COMMAND : cloneAction(argument, quietly); break;
|
|
52
53
|
case VERSION_COMMAND : versionAction(); break;
|
|
53
54
|
case PUBLISH_COMMAND : publishAction(argument, dryRun, logLevel); break;
|
package/bin/constants.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const YES = "yes",
|
|
4
|
+
END = "end",
|
|
4
5
|
DATA = "data",
|
|
5
6
|
OPEN = "open",
|
|
6
7
|
HOST_URL = "hostURL",
|
|
@@ -12,6 +13,7 @@ const END = "end",
|
|
|
12
13
|
PACKAGE_JSON = "package.json";
|
|
13
14
|
|
|
14
15
|
module.exports = {
|
|
16
|
+
YES,
|
|
15
17
|
END,
|
|
16
18
|
DATA,
|
|
17
19
|
OPEN,
|
package/bin/defaults.js
CHANGED
|
@@ -4,7 +4,8 @@ const { levels } = require("necessary");
|
|
|
4
4
|
|
|
5
5
|
const { INFO_LEVEL } = levels;
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const DEFAULT_YES = false,
|
|
8
|
+
DEFAULT_HELP = false,
|
|
8
9
|
DEFAULT_HOST = "https://openmathematics.org",
|
|
9
10
|
DEFAULT_DRY_RUN = false,
|
|
10
11
|
DEFAULT_VERSION = false,
|
|
@@ -13,6 +14,7 @@ const DEFAULT_HELP = false,
|
|
|
13
14
|
DEFAULT_GITHUB_HOST_NAME = "github.com";
|
|
14
15
|
|
|
15
16
|
module.exports = {
|
|
17
|
+
DEFAULT_YES,
|
|
16
18
|
DEFAULT_HELP,
|
|
17
19
|
DEFAULT_HOST,
|
|
18
20
|
DEFAULT_DRY_RUN,
|
package/bin/messages.js
CHANGED
|
@@ -4,6 +4,7 @@ const PASSWORDS_DO_NOT_MATCH_MESSAGE = "The passwords do not match.",
|
|
|
4
4
|
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.",
|
|
5
5
|
CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE = "The action cannot be performed because the configuration file is missing. Run 'open initialise' to create one.",
|
|
6
6
|
SIGN_OUT_MESSAGE = "You have been signed out.",
|
|
7
|
+
INVALID_ANSWER_MESSAGE = "You must answer (y)es or (n)o.",
|
|
7
8
|
INVALID_USERNAME_MESSAGE = "Usernames must consist of groups of at least two and no more than sixteen numbers or lowercase letters, separated by dashes.",
|
|
8
9
|
INVALID_PASSWORD_MESSAGE = "Passwords must consist of at least eight letters, numbers or common punctuation symbols.",
|
|
9
10
|
INVALID_AFFIRMATION_MESSAGE = "You must answer (y)es or (n)o.",
|
|
@@ -29,6 +30,7 @@ module.exports = {
|
|
|
29
30
|
SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE,
|
|
30
31
|
CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE,
|
|
31
32
|
SIGN_OUT_MESSAGE,
|
|
33
|
+
INVALID_ANSWER_MESSAGE,
|
|
32
34
|
INVALID_USERNAME_MESSAGE,
|
|
33
35
|
INVALID_PASSWORD_MESSAGE,
|
|
34
36
|
INVALID_AFFIRMATION_MESSAGE,
|
package/bin/operation/open.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { fileSystemUtilities } = require("necessary");
|
|
3
|
+
const { shellUtilities, fileSystemUtilities, asynchronousUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { YES } = require("../constants"),
|
|
6
|
+
{ validateAnswer } = require("../utilities/validate"),
|
|
7
|
+
{ isAnswerAffirmative } = require("../utilities/prompt"),
|
|
8
|
+
{ INVALID_ANSWER_MESSAGE } = require("../messages");
|
|
9
|
+
|
|
10
|
+
const { writeFile, removeEntry, checkEntryExists, isEntryDirectory } = fileSystemUtilities;
|
|
11
|
+
|
|
12
|
+
const { prompt } = shellUtilities,
|
|
13
|
+
{ forEach } = asynchronousUtilities;
|
|
6
14
|
|
|
7
15
|
function unpackReleasesOperation(proceed, abort, context) {
|
|
8
16
|
const { releases } = context;
|
|
@@ -13,30 +21,77 @@ function unpackReleasesOperation(proceed, abort, context) {
|
|
|
13
21
|
return;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
const { name } = release,
|
|
18
|
-
path = name, ///
|
|
19
|
-
entryExists = checkEntryExists(path);
|
|
24
|
+
const done = proceed; ///
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
forEach(releases, unpackReleasePromptOperation, done, context);
|
|
27
|
+
}
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
module.exports = unpackReleasesOperation;
|
|
30
|
+
|
|
31
|
+
function unpackReleasePromptOperation(release, next, done, context) {
|
|
32
|
+
const { name } = release,
|
|
33
|
+
entryPath = name, ///
|
|
34
|
+
entryExists = checkEntryExists(entryPath);
|
|
35
|
+
|
|
36
|
+
if (!entryExists) {
|
|
37
|
+
unpackRelease(release);
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
next();
|
|
40
|
+
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const entryDirectory = isEntryDirectory(entryPath);
|
|
45
|
+
|
|
46
|
+
if (entryDirectory) {
|
|
47
|
+
const { quietly } = context;
|
|
48
|
+
|
|
49
|
+
if (!quietly) {
|
|
50
|
+
console.log(`Cannot write the '${name}' package to disk because a directory of that name already exists.`);
|
|
29
51
|
}
|
|
30
52
|
|
|
31
|
-
|
|
32
|
-
releaseJSON = release, ///
|
|
33
|
-
releaseJSONString = JSON.stringify(releaseJSON),
|
|
34
|
-
content = releaseJSONString; ///
|
|
53
|
+
next();
|
|
35
54
|
|
|
36
|
-
|
|
37
|
-
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { yes } = context,
|
|
59
|
+
answer = yes ?
|
|
60
|
+
YES :
|
|
61
|
+
null,
|
|
62
|
+
description = `Overwrite the existing '${name}' package? (y)es (n)o: `,
|
|
63
|
+
errorMessage = INVALID_ANSWER_MESSAGE,
|
|
64
|
+
validationFunction = validateAnswer, ///
|
|
65
|
+
options = {
|
|
66
|
+
answer,
|
|
67
|
+
description,
|
|
68
|
+
errorMessage,
|
|
69
|
+
validationFunction
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
prompt(options, (answer) => {
|
|
73
|
+
const valid = (answer !== null);
|
|
38
74
|
|
|
39
|
-
|
|
75
|
+
if (valid) {
|
|
76
|
+
const affirmative = isAnswerAffirmative(answer);
|
|
77
|
+
|
|
78
|
+
if (affirmative) {
|
|
79
|
+
removeEntry(entryPath);
|
|
80
|
+
|
|
81
|
+
unpackRelease(release);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
next();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
40
87
|
}
|
|
41
88
|
|
|
42
|
-
|
|
89
|
+
function unpackRelease(release) {
|
|
90
|
+
const { name } = release,
|
|
91
|
+
filePath = name, ///
|
|
92
|
+
releaseJSON = release, ///
|
|
93
|
+
releaseJSONString = JSON.stringify(releaseJSON),
|
|
94
|
+
content = releaseJSONString; ///
|
|
95
|
+
|
|
96
|
+
writeFile(filePath, content);
|
|
97
|
+
}
|
package/bin/options.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const YES_OPTION = "yes",
|
|
4
|
+
HELP_OPTION = "help",
|
|
4
5
|
VERSION_OPTION = "version",
|
|
5
6
|
QUIETLY_OPTION = "quietly",
|
|
6
7
|
DRY_RUN_OPTION = "dry-run",
|
|
7
8
|
LOG_LEVEL_OPTION = "log-level";
|
|
8
9
|
|
|
9
10
|
module.exports = {
|
|
11
|
+
YES_OPTION,
|
|
10
12
|
HELP_OPTION,
|
|
11
13
|
VERSION_OPTION,
|
|
12
14
|
QUIETLY_OPTION,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function validateAnswer(answer) { return /^(:?yes|no|y|n)$/i.test(answer); }
|
|
3
4
|
|
|
4
5
|
function validateUsername(username) { return /^[a-z0-9]{2,16}(?:-[a-z0-9]{2,16}){0,4}$/.test(username); }
|
|
5
6
|
|
|
@@ -32,6 +33,7 @@ function validateEmailAddressOrUsername(emailAddressOrUsername) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
module.exports = {
|
|
36
|
+
validateAnswer,
|
|
35
37
|
validateUsername,
|
|
36
38
|
validatePassword,
|
|
37
39
|
validateAffirmation,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "occam-open-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.124",
|
|
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.",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.21",
|
|
14
|
-
"necessary": "^11.
|
|
14
|
+
"necessary": "^11.2.0",
|
|
15
15
|
"occam-file-system": "^5.0.83"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {},
|