occam-open-cli 5.0.105 → 5.0.106
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 +2 -0
- package/bin/abbreviations.js +3 -1
- package/bin/action/help.js +2 -0
- package/bin/action/open.js +26 -5
- package/bin/action/publish.js +2 -2
- package/bin/actions.js +3 -2
- package/bin/defaults.js +2 -0
- package/bin/messages.js +4 -2
- package/bin/operation/open.js +24 -0
- package/bin/operation/packRelease.js +17 -0
- package/bin/operation/publish.js +3 -3
- package/bin/operation/unpackReleases.js +42 -0
- package/bin/operation/updateMetaJSONFileVersion.js +1 -2
- package/bin/options.js +2 -0
- package/bin/uris.js +3 -1
- package/package.json +2 -3
- package/bin/operation/zipRelease.js +0 -36
package/README.md
CHANGED
package/bin/abbreviations.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { HELP_OPTION, DRY_RUN_OPTION, VERSION_OPTION, LOG_LEVEL_OPTION } = require("./options");
|
|
3
|
+
const { HELP_OPTION, DRY_RUN_OPTION, VERSION_OPTION, QUIETLY_OPTION, LOG_LEVEL_OPTION } = require("./options");
|
|
4
4
|
|
|
5
5
|
const h = HELP_OPTION,
|
|
6
6
|
d = DRY_RUN_OPTION,
|
|
7
7
|
v = VERSION_OPTION,
|
|
8
|
+
q = QUIETLY_OPTION,
|
|
8
9
|
l = LOG_LEVEL_OPTION
|
|
9
10
|
|
|
10
11
|
module.exports = {
|
|
11
12
|
h,
|
|
12
13
|
d,
|
|
13
14
|
v,
|
|
15
|
+
q,
|
|
14
16
|
l
|
|
15
17
|
};
|
package/bin/action/help.js
CHANGED
package/bin/action/open.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const openOperation = require("../operation/open"),
|
|
4
|
+
unpackReleasesOperation = require("../operation/unpackReleases"),
|
|
5
|
+
releaseNamePromptOperation = require("../operation/prompt/releaseName");
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const { executeOperations } = require("../utilities/operation"),
|
|
8
|
+
{ SUCCESSFUL_OPEN_MESSAGE, FAILED_OPEN_MESSAGE } = require("../messages");
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
function openAction(argument, quietly) {
|
|
11
|
+
const releaseName = argument, ///
|
|
12
|
+
operations = [
|
|
13
|
+
releaseNamePromptOperation,
|
|
14
|
+
openOperation,
|
|
15
|
+
unpackReleasesOperation
|
|
16
|
+
],
|
|
17
|
+
context = {
|
|
18
|
+
quietly,
|
|
19
|
+
releaseName
|
|
20
|
+
};
|
|
9
21
|
|
|
10
|
-
|
|
22
|
+
executeOperations(operations, (completed) => {
|
|
23
|
+
const success = completed, ///
|
|
24
|
+
message = success ?
|
|
25
|
+
SUCCESSFUL_OPEN_MESSAGE :
|
|
26
|
+
FAILED_OPEN_MESSAGE;
|
|
27
|
+
|
|
28
|
+
console.log(message);
|
|
29
|
+
|
|
30
|
+
process.exit();
|
|
31
|
+
}, context);
|
|
11
32
|
}
|
|
12
33
|
|
|
13
34
|
module.exports = openAction;
|
package/bin/action/publish.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const publishOperation = require("../operation/publish"),
|
|
4
|
-
zipReleaseOperation = require("../operation/zipRelease"),
|
|
5
4
|
loadReleaseOperation = require("../operation/loadRelease"),
|
|
5
|
+
packReleaseOperation = require("../operation/packRelease"),
|
|
6
6
|
getIdentityTokenOperation = require("../operation/getIdentityToken"),
|
|
7
7
|
releaseNamePromptOperation = require("../operation/prompt/releaseName"),
|
|
8
8
|
updateMetaJSONFileVersionOperation = require("../operation/updateMetaJSONFileVersion");
|
|
@@ -17,7 +17,7 @@ function publishAction(argument, dryRun, logLevel) {
|
|
|
17
17
|
getIdentityTokenOperation,
|
|
18
18
|
releaseNamePromptOperation,
|
|
19
19
|
loadReleaseOperation,
|
|
20
|
-
|
|
20
|
+
packReleaseOperation,
|
|
21
21
|
publishOperation,
|
|
22
22
|
updateMetaJSONFileVersionOperation
|
|
23
23
|
],
|
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_LOG_LEVEL } = require("./defaults"),
|
|
16
|
+
const { DEFAULT_HELP, DEFAULT_DRY_RUN, DEFAULT_VERSION, DEFAULT_QUIETLY, DEFAULT_LOG_LEVEL } = require("./defaults"),
|
|
17
17
|
{ HELP_COMMAND,
|
|
18
18
|
CLONE_COMMAND,
|
|
19
19
|
VERSION_COMMAND,
|
|
@@ -32,6 +32,7 @@ function actions(command, argument, options) {
|
|
|
32
32
|
{ help = DEFAULT_HELP,
|
|
33
33
|
dryRun = DEFAULT_DRY_RUN,
|
|
34
34
|
version = DEFAULT_VERSION,
|
|
35
|
+
quietly = DEFAULT_QUIETLY,
|
|
35
36
|
logLevel = DEFAULT_LOG_LEVEL } = options;
|
|
36
37
|
|
|
37
38
|
if (false) {
|
|
@@ -59,7 +60,7 @@ function actions(command, argument, options) {
|
|
|
59
60
|
default :
|
|
60
61
|
argument = command; ///
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
openAction(argument, quietly);
|
|
63
64
|
|
|
64
65
|
break;
|
|
65
66
|
}
|
package/bin/defaults.js
CHANGED
|
@@ -8,6 +8,7 @@ const DEFAULT_HELP = false,
|
|
|
8
8
|
DEFAULT_HOST = "https://openmathematics.org",
|
|
9
9
|
DEFAULT_DRY_RUN = false,
|
|
10
10
|
DEFAULT_VERSION = false,
|
|
11
|
+
DEFAULT_QUIETLY = false,
|
|
11
12
|
DEFAULT_LOG_LEVEL = INFO_LEVEL,
|
|
12
13
|
DEFAULT_GITHUB_HOST_NAME = "github.com";
|
|
13
14
|
|
|
@@ -16,6 +17,7 @@ module.exports = {
|
|
|
16
17
|
DEFAULT_HOST,
|
|
17
18
|
DEFAULT_DRY_RUN,
|
|
18
19
|
DEFAULT_VERSION,
|
|
20
|
+
DEFAULT_QUIETLY,
|
|
19
21
|
DEFAULT_LOG_LEVEL,
|
|
20
22
|
DEFAULT_GITHUB_HOST_NAME
|
|
21
23
|
};
|
package/bin/messages.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
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
|
-
OPEN_MESSAGE = "The open functionality is not implemented yet.",
|
|
7
6
|
SIGN_OUT_MESSAGE = "You have been signed out.",
|
|
8
7
|
INVALID_USERNAME_MESSAGE = "Usernames must consist of groups of at least two and no more than sixteen numbers or lowercase letters, separated by dashes.",
|
|
9
8
|
INVALID_PASSWORD_MESSAGE = "Passwords must consist of at least eight letters, numbers or common punctuation symbols.",
|
|
@@ -12,11 +11,13 @@ const PASSWORDS_DO_NOT_MATCH_MESSAGE = "The passwords do not match.",
|
|
|
12
11
|
INVALID_EMAIL_ADDRESS_MESSAGE = "The email address does not appear to be a valid one.",
|
|
13
12
|
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.",
|
|
14
13
|
INVALID_EMAIL_ADDRESS_OR_USERNAME_MESSAGE = "The email address or username does not appear to be a valid one.",
|
|
14
|
+
FAILED_OPEN_MESSAGE = "Failed to open the package.",
|
|
15
15
|
FAILED_CLONE_MESSAGE = "Failed to clone the package.",
|
|
16
16
|
FAILED_PUBLISH_MESSAGE = "Failed to publish the package.",
|
|
17
17
|
FAILED_DEPRECATE_MESSAGE = "Failed to deprecate the package.",
|
|
18
18
|
FAILED_INITIALISE_MESSAGE = "Failed to create a configuration file because one is already present.",
|
|
19
19
|
FAILED_SET_OPTIONS_MESSAGE = "Failed to set the options.",
|
|
20
|
+
SUCCESSFUL_OPEN_MESSAGE = "The package has been opened successfully.",
|
|
20
21
|
SUCCESSFUL_CLONE_MESSAGE = "The package has been cloned successfully.",
|
|
21
22
|
SUCCESSFUL_PUBLISH_MESSAGE = "The package has been published successfully.",
|
|
22
23
|
SUCCESSFUL_DEPRECATE_MESSAGE = "The package has been deprecated successfully.",
|
|
@@ -27,7 +28,6 @@ module.exports = {
|
|
|
27
28
|
PASSWORDS_DO_NOT_MATCH_MESSAGE,
|
|
28
29
|
SERVER_FAILED_TO_RESPOND_ERROR_MESSAGE,
|
|
29
30
|
CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE,
|
|
30
|
-
OPEN_MESSAGE,
|
|
31
31
|
SIGN_OUT_MESSAGE,
|
|
32
32
|
INVALID_USERNAME_MESSAGE,
|
|
33
33
|
INVALID_PASSWORD_MESSAGE,
|
|
@@ -36,11 +36,13 @@ module.exports = {
|
|
|
36
36
|
INVALID_EMAIL_ADDRESS_MESSAGE,
|
|
37
37
|
INVALID_GITHUB_HOST_NAME_MESSAGE,
|
|
38
38
|
INVALID_EMAIL_ADDRESS_OR_USERNAME_MESSAGE,
|
|
39
|
+
FAILED_OPEN_MESSAGE,
|
|
39
40
|
FAILED_CLONE_MESSAGE,
|
|
40
41
|
FAILED_PUBLISH_MESSAGE,
|
|
41
42
|
FAILED_DEPRECATE_MESSAGE,
|
|
42
43
|
FAILED_INITIALISE_MESSAGE,
|
|
43
44
|
FAILED_SET_OPTIONS_MESSAGE,
|
|
45
|
+
SUCCESSFUL_OPEN_MESSAGE,
|
|
44
46
|
SUCCESSFUL_CLONE_MESSAGE,
|
|
45
47
|
SUCCESSFUL_PUBLISH_MESSAGE,
|
|
46
48
|
SUCCESSFUL_DEPRECATE_MESSAGE,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const post = require("../post");
|
|
4
|
+
|
|
5
|
+
const { OPEN_API_URI } = require("../uris");
|
|
6
|
+
|
|
7
|
+
function openOperation(proceed, abort, context) {
|
|
8
|
+
const { releaseName } = context,
|
|
9
|
+
uri = `${OPEN_API_URI}/${releaseName}`,
|
|
10
|
+
json = {};
|
|
11
|
+
|
|
12
|
+
post(uri, json, (json) => {
|
|
13
|
+
const { success, releases = null } = json;
|
|
14
|
+
|
|
15
|
+
Object.assign(context, {
|
|
16
|
+
success,
|
|
17
|
+
releases
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
proceed();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = openOperation;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function packReleaseOperation(proceed, abort, context) {
|
|
4
|
+
let { release } = context;
|
|
5
|
+
|
|
6
|
+
const releaseJSON = release.toJSON();
|
|
7
|
+
|
|
8
|
+
release = releaseJSON; ///
|
|
9
|
+
|
|
10
|
+
Object.assign(context, {
|
|
11
|
+
release
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
proceed();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = packReleaseOperation;
|
package/bin/operation/publish.js
CHANGED
|
@@ -7,13 +7,13 @@ const post = require("../post");
|
|
|
7
7
|
const { PUBLISH_API_URI } = require("../uris");
|
|
8
8
|
|
|
9
9
|
function publishOperation(proceed, abort, context) {
|
|
10
|
-
const { dryRun, logLevel, releaseName, identityToken
|
|
10
|
+
const { dryRun, release, logLevel, releaseName, identityToken } = context,
|
|
11
11
|
uri = `${PUBLISH_API_URI}/${releaseName}`,
|
|
12
12
|
json = {
|
|
13
13
|
dryRun,
|
|
14
|
+
release,
|
|
14
15
|
logLevel,
|
|
15
|
-
identityToken
|
|
16
|
-
zippedRelease
|
|
16
|
+
identityToken
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
post(uri, json, (json) => {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { fileSystemUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { writeFile, checkEntryExists } = fileSystemUtilities;
|
|
6
|
+
|
|
7
|
+
function unpackReleasesOperation(proceed, abort, context) {
|
|
8
|
+
const { releases } = context;
|
|
9
|
+
|
|
10
|
+
if (releases === null) {
|
|
11
|
+
abort();
|
|
12
|
+
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { quietly } = context;
|
|
17
|
+
|
|
18
|
+
releases.forEach((release) => {
|
|
19
|
+
const { name } = release,
|
|
20
|
+
path = name, ///
|
|
21
|
+
entryExists = checkEntryExists(path);
|
|
22
|
+
|
|
23
|
+
if (!entryExists) {
|
|
24
|
+
const filePath = path, ///
|
|
25
|
+
releaseJSON = release, ///
|
|
26
|
+
releaseJSONString = JSON.stringify(releaseJSON),
|
|
27
|
+
content = releaseJSONString; ///
|
|
28
|
+
|
|
29
|
+
writeFile(filePath, content);
|
|
30
|
+
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!quietly) {
|
|
35
|
+
console.log(`Cannot write the '${name}' package to disk because an entry of that name already exists.`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
proceed();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = unpackReleasesOperation;
|
|
@@ -10,8 +10,7 @@ function updateMetaJSONFileVersionOperation(proceed, abort, context) {
|
|
|
10
10
|
const { success } = context;
|
|
11
11
|
|
|
12
12
|
if (success) {
|
|
13
|
-
const {
|
|
14
|
-
releaseName = release.getName(),
|
|
13
|
+
const { version, releaseName } = context,
|
|
15
14
|
metaJSONFilePath = `${releaseName}/${META_JSON_FILE_NAME}`,
|
|
16
15
|
projectsDirectoryPath = process.cwd(), ///
|
|
17
16
|
metaJSONFile = loadFile(metaJSONFilePath, projectsDirectoryPath);
|
package/bin/options.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const HELP_OPTION = "help",
|
|
4
4
|
VERSION_OPTION = "version",
|
|
5
|
+
QUIETLY_OPTION = "quietly",
|
|
5
6
|
DRY_RUN_OPTION = "dry-run",
|
|
6
7
|
LOG_LEVEL_OPTION = "log-level";
|
|
7
8
|
|
|
8
9
|
module.exports = {
|
|
9
10
|
HELP_OPTION,
|
|
10
11
|
VERSION_OPTION,
|
|
12
|
+
QUIETLY_OPTION,
|
|
11
13
|
DRY_RUN_OPTION,
|
|
12
14
|
LOG_LEVEL_OPTION
|
|
13
15
|
};
|
package/bin/uris.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const OPEN_API_URI = "/api/open",
|
|
4
|
+
CLONE_API_URI = "/api/clone",
|
|
4
5
|
PUBLISH_API_URI = "/api/publish",
|
|
5
6
|
SIGN_IN_API_URI = "/api/sign-in",
|
|
6
7
|
DEPRECATE_API_URI = "/api/deprecate",
|
|
@@ -8,6 +9,7 @@ const CLONE_API_URI = "/api/clone",
|
|
|
8
9
|
CREATE_ACCOUNT_API_URI = "/api/create-account";
|
|
9
10
|
|
|
10
11
|
module.exports = {
|
|
12
|
+
OPEN_API_URI,
|
|
11
13
|
CLONE_API_URI,
|
|
12
14
|
PUBLISH_API_URI,
|
|
13
15
|
SIGN_IN_API_URI,
|
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.106",
|
|
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,9 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"argumentative": "^2.0.21",
|
|
14
|
-
"jszip": "^3.10.1",
|
|
15
14
|
"necessary": "^11.1.4",
|
|
16
|
-
"occam-file-system": "^5.0.
|
|
15
|
+
"occam-file-system": "^5.0.76"
|
|
17
16
|
},
|
|
18
17
|
"scripts": {},
|
|
19
18
|
"bin": {
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const JSZip = require("jszip");
|
|
4
|
-
|
|
5
|
-
const { encodings } = require("necessary");
|
|
6
|
-
|
|
7
|
-
const { RELEASE_JSON } = require("../constants");
|
|
8
|
-
|
|
9
|
-
const { BASE64_ENCODING } = encodings;
|
|
10
|
-
|
|
11
|
-
function zipReleaseOperation(proceed, abort, context) {
|
|
12
|
-
const { release } = context,
|
|
13
|
-
type = BASE64_ENCODING, ///
|
|
14
|
-
jsZip = new JSZip(),
|
|
15
|
-
releaseJSON = release.toJSON(),
|
|
16
|
-
releaseJSONString = JSON.stringify(releaseJSON),
|
|
17
|
-
name = RELEASE_JSON,
|
|
18
|
-
content = releaseJSONString, ///
|
|
19
|
-
options = {
|
|
20
|
-
type
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
jsZip.file(name, content);
|
|
24
|
-
|
|
25
|
-
jsZip.generateAsync(options)
|
|
26
|
-
.catch(abort)
|
|
27
|
-
.then((zippedRelease) => {
|
|
28
|
-
Object.assign(context, {
|
|
29
|
-
zippedRelease
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
proceed();
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = zipReleaseOperation;
|