occam-open-cli 5.0.124 → 5.0.125
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/bin/action/clone.js +8 -5
- package/bin/action/open.js +2 -2
- package/bin/actions.js +1 -1
- package/bin/descriptions.js +2 -0
- package/bin/operation/clone.js +13 -39
- package/bin/operation/clone.old.js +52 -0
- package/bin/operation/cloneReleases.js +75 -0
- package/bin/operation/{unpackReleases.js → openReleases.js} +10 -17
- package/bin/operation/prompt/areYouSure.js +2 -2
- package/bin/operation/prompt/cloneDependencies.js +48 -0
- package/bin/operation/prompt/releaseName.js +2 -2
- package/package.json +1 -1
- package/bin/operation/repository.js +0 -29
package/bin/action/clone.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cloneOperation = require("../operation/clone"),
|
|
4
|
-
|
|
5
|
-
releaseNamePromptOperation = require("../operation/prompt/releaseName")
|
|
4
|
+
cloneReleasesOperation = require("../operation/cloneReleases"),
|
|
5
|
+
releaseNamePromptOperation = require("../operation/prompt/releaseName"),
|
|
6
|
+
cloneDependenciesPromptOperation = require("../operation/prompt/cloneDependencies");
|
|
6
7
|
|
|
7
8
|
const { executeOperations } = require("../utilities/operation"),
|
|
8
9
|
{ SUCCESSFUL_CLONE_MESSAGE, FAILED_CLONE_MESSAGE } = require("../messages");
|
|
9
10
|
|
|
10
|
-
function cloneAction(argument, quietly) {
|
|
11
|
+
function cloneAction(argument, quietly, yes) {
|
|
11
12
|
const releaseName = argument, ///
|
|
12
13
|
operations = [
|
|
13
14
|
releaseNamePromptOperation,
|
|
14
|
-
|
|
15
|
-
cloneOperation
|
|
15
|
+
cloneDependenciesPromptOperation,
|
|
16
|
+
cloneOperation,
|
|
17
|
+
cloneReleasesOperation
|
|
16
18
|
],
|
|
17
19
|
context = {
|
|
20
|
+
yes,
|
|
18
21
|
quietly,
|
|
19
22
|
releaseName
|
|
20
23
|
};
|
package/bin/action/open.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const openOperation = require("../operation/open"),
|
|
4
|
-
|
|
4
|
+
openReleasesOperation = require("../operation/openReleases"),
|
|
5
5
|
releaseNamePromptOperation = require("../operation/prompt/releaseName");
|
|
6
6
|
|
|
7
7
|
const { executeOperations } = require("../utilities/operation"),
|
|
@@ -12,7 +12,7 @@ function openAction(argument, quietly, yes) {
|
|
|
12
12
|
operations = [
|
|
13
13
|
releaseNamePromptOperation,
|
|
14
14
|
openOperation,
|
|
15
|
-
|
|
15
|
+
openReleasesOperation
|
|
16
16
|
],
|
|
17
17
|
context = {
|
|
18
18
|
yes,
|
package/bin/actions.js
CHANGED
|
@@ -49,7 +49,7 @@ function actions(command, argument, options) {
|
|
|
49
49
|
switch (command) {
|
|
50
50
|
case HELP_COMMAND : helpAction(); break;
|
|
51
51
|
case OPEN_COMMAND : openAction(argument, quietly, yes); break;
|
|
52
|
-
case CLONE_COMMAND : cloneAction(argument, quietly); break;
|
|
52
|
+
case CLONE_COMMAND : cloneAction(argument, quietly, yes); break;
|
|
53
53
|
case VERSION_COMMAND : versionAction(); break;
|
|
54
54
|
case PUBLISH_COMMAND : publishAction(argument, dryRun, logLevel); break;
|
|
55
55
|
case SIGN_IN_COMMAND : signInAction(argument); break;
|
package/bin/descriptions.js
CHANGED
|
@@ -8,6 +8,7 @@ const USE_SSH_DESCRIPTION = "Use SSH when cloning: ",
|
|
|
8
8
|
EMAIL_ADDRESS_DESCRIPTION = "Email address: ",
|
|
9
9
|
CONFIRM_PASSWORD_DESCRIPTION = "Confirm password: ",
|
|
10
10
|
GITHUB_HOST_NAME_DESCRIPTION = "GitHub host name (leave blank for default): ",
|
|
11
|
+
CLONE_DEPENDENCIES_DESCRIPTION = "Clone dependencies? (y)es (n)o: ",
|
|
11
12
|
EMAIL_ADDRESS_OR_USERNAME_DESCRIPTION = "Email address or username: ";
|
|
12
13
|
|
|
13
14
|
module.exports = {
|
|
@@ -19,5 +20,6 @@ module.exports = {
|
|
|
19
20
|
EMAIL_ADDRESS_DESCRIPTION,
|
|
20
21
|
CONFIRM_PASSWORD_DESCRIPTION,
|
|
21
22
|
GITHUB_HOST_NAME_DESCRIPTION,
|
|
23
|
+
CLONE_DEPENDENCIES_DESCRIPTION,
|
|
22
24
|
EMAIL_ADDRESS_OR_USERNAME_DESCRIPTION
|
|
23
25
|
};
|
package/bin/operation/clone.js
CHANGED
|
@@ -1,51 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
{ fileSystemUtilities } = require("necessary");
|
|
3
|
+
const post = require("../post");
|
|
5
4
|
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
const { getOptions } = require("../configuration"),
|
|
9
|
-
{ DEFAULT_GITHUB_HOST_NAME } = require("../defaults");
|
|
5
|
+
const { CLONE_API_URI } = require("../uris");
|
|
10
6
|
|
|
11
7
|
function cloneOperation(proceed, abort, context) {
|
|
12
8
|
const { releaseName } = context,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (entryExists) {
|
|
17
|
-
const { quietly } = context;
|
|
18
|
-
|
|
19
|
-
if (!quietly) {
|
|
20
|
-
console.log(`Cannot clone the '${releaseName}' package because an entry of that name already exists.`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
proceed();
|
|
24
|
-
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let { repository } = context;
|
|
29
|
-
|
|
30
|
-
const options = getOptions(),
|
|
31
|
-
{ ssh } = options;
|
|
32
|
-
|
|
33
|
-
if (ssh) {
|
|
34
|
-
const { gitHubHostName } = ssh;
|
|
35
|
-
|
|
36
|
-
repository = repository.replace(`https://${DEFAULT_GITHUB_HOST_NAME}/`, `git@${gitHubHostName}:`)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const command = `git clone ${repository}.git`;
|
|
9
|
+
uri = `${CLONE_API_URI}/${releaseName}`,
|
|
10
|
+
json = {};
|
|
40
11
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
abort();
|
|
12
|
+
post(uri, json, (json) => {
|
|
13
|
+
const { success, releases = null } = json;
|
|
44
14
|
|
|
45
|
-
|
|
46
|
-
|
|
15
|
+
Object.assign(context, {
|
|
16
|
+
success,
|
|
17
|
+
releases
|
|
18
|
+
});
|
|
47
19
|
|
|
48
|
-
|
|
20
|
+
success ?
|
|
21
|
+
proceed() :
|
|
22
|
+
abort();
|
|
49
23
|
});
|
|
50
24
|
}
|
|
51
25
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { exec } = require("child_process"),
|
|
4
|
+
{ fileSystemUtilities } = require("necessary");
|
|
5
|
+
|
|
6
|
+
const { checkEntryExists } = fileSystemUtilities;
|
|
7
|
+
|
|
8
|
+
const { getOptions } = require("../configuration"),
|
|
9
|
+
{ DEFAULT_GITHUB_HOST_NAME } = require("../defaults");
|
|
10
|
+
|
|
11
|
+
function cloneOperation(proceed, abort, context) {
|
|
12
|
+
const { releaseName } = context,
|
|
13
|
+
path = releaseName, ///
|
|
14
|
+
entryExists = checkEntryExists(path);
|
|
15
|
+
|
|
16
|
+
if (entryExists) {
|
|
17
|
+
const { quietly } = context;
|
|
18
|
+
|
|
19
|
+
if (!quietly) {
|
|
20
|
+
console.log(`Cannot clone the '${releaseName}' package because an entry of that name already exists.`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
proceed();
|
|
24
|
+
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let { repository } = context;
|
|
29
|
+
|
|
30
|
+
const options = getOptions(),
|
|
31
|
+
{ ssh } = options;
|
|
32
|
+
|
|
33
|
+
if (ssh) {
|
|
34
|
+
const { gitHubHostName } = ssh;
|
|
35
|
+
|
|
36
|
+
repository = repository.replace(`https://${DEFAULT_GITHUB_HOST_NAME}/`, `git@${gitHubHostName}:`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const command = `git clone ${repository}.git`;
|
|
40
|
+
|
|
41
|
+
exec(command, (error) => {
|
|
42
|
+
if (error) {
|
|
43
|
+
abort();
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
proceed();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = cloneOperation;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { exec } = require("child_process"),
|
|
4
|
+
{ fileSystemUtilities, asynchronousUtilities } = require("necessary");
|
|
5
|
+
|
|
6
|
+
const { getOptions } = require("../configuration"),
|
|
7
|
+
{ DEFAULT_GITHUB_HOST_NAME } = require("../defaults");
|
|
8
|
+
|
|
9
|
+
const { checkEntryExists } = fileSystemUtilities;
|
|
10
|
+
|
|
11
|
+
const { forEach } = asynchronousUtilities;
|
|
12
|
+
|
|
13
|
+
function cloneReleasesOperation(proceed, abort, context) {
|
|
14
|
+
const { releases } = context,
|
|
15
|
+
done = proceed; ///
|
|
16
|
+
|
|
17
|
+
forEach(releases, cloneReleasePromptOperation, done, context);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = cloneReleasesOperation;
|
|
21
|
+
|
|
22
|
+
function cloneReleasePromptOperation(release, next, done, context, index) {
|
|
23
|
+
const { cloneDependencies } = context;
|
|
24
|
+
|
|
25
|
+
if (!cloneDependencies) {
|
|
26
|
+
if (index > 0) {
|
|
27
|
+
next();
|
|
28
|
+
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { name } = release,
|
|
34
|
+
entryPath = name, ///
|
|
35
|
+
entryExists = checkEntryExists(entryPath);
|
|
36
|
+
|
|
37
|
+
if (entryExists) {
|
|
38
|
+
const { quietly } = context;
|
|
39
|
+
|
|
40
|
+
if (!quietly) {
|
|
41
|
+
console.log(`Cannot clone the '${name}' package because a directory of that name already exists.`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
next();
|
|
45
|
+
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
done = next; ///
|
|
50
|
+
|
|
51
|
+
cloneRelease(release, done);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function cloneRelease(release, done) {
|
|
55
|
+
let repository = release.getRepository();
|
|
56
|
+
|
|
57
|
+
const options = getOptions(),
|
|
58
|
+
{ ssh } = options;
|
|
59
|
+
|
|
60
|
+
if (ssh) {
|
|
61
|
+
const { gitHubHostName } = ssh;
|
|
62
|
+
|
|
63
|
+
repository = repository.replace(`https://${DEFAULT_GITHUB_HOST_NAME}/`, `git@${gitHubHostName}:`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const command = `git clone ${repository}.git`;
|
|
67
|
+
|
|
68
|
+
exec(command, (error) => {
|
|
69
|
+
if (error) {
|
|
70
|
+
console.log(error);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
done();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -12,29 +12,22 @@ const { writeFile, removeEntry, checkEntryExists, isEntryDirectory } = fileSyste
|
|
|
12
12
|
const { prompt } = shellUtilities,
|
|
13
13
|
{ forEach } = asynchronousUtilities;
|
|
14
14
|
|
|
15
|
-
function
|
|
16
|
-
const { releases } = context
|
|
15
|
+
function openReleasesOperation(proceed, abort, context) {
|
|
16
|
+
const { releases } = context,
|
|
17
|
+
done = proceed; ///
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
abort();
|
|
20
|
-
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const done = proceed; ///
|
|
25
|
-
|
|
26
|
-
forEach(releases, unpackReleasePromptOperation, done, context);
|
|
19
|
+
forEach(releases, openReleasePromptOperation, done, context);
|
|
27
20
|
}
|
|
28
21
|
|
|
29
|
-
module.exports =
|
|
22
|
+
module.exports = openReleasesOperation;
|
|
30
23
|
|
|
31
|
-
function
|
|
24
|
+
function openReleasePromptOperation(release, next, done, context) {
|
|
32
25
|
const { name } = release,
|
|
33
26
|
entryPath = name, ///
|
|
34
27
|
entryExists = checkEntryExists(entryPath);
|
|
35
28
|
|
|
36
29
|
if (!entryExists) {
|
|
37
|
-
|
|
30
|
+
openRelease(release);
|
|
38
31
|
|
|
39
32
|
next();
|
|
40
33
|
|
|
@@ -47,7 +40,7 @@ function unpackReleasePromptOperation(release, next, done, context) {
|
|
|
47
40
|
const { quietly } = context;
|
|
48
41
|
|
|
49
42
|
if (!quietly) {
|
|
50
|
-
console.log(`Cannot
|
|
43
|
+
console.log(`Cannot open the '${name}' package because a directory of that name already exists.`);
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
next();
|
|
@@ -78,7 +71,7 @@ function unpackReleasePromptOperation(release, next, done, context) {
|
|
|
78
71
|
if (affirmative) {
|
|
79
72
|
removeEntry(entryPath);
|
|
80
73
|
|
|
81
|
-
|
|
74
|
+
openRelease(release);
|
|
82
75
|
}
|
|
83
76
|
|
|
84
77
|
next();
|
|
@@ -86,7 +79,7 @@ function unpackReleasePromptOperation(release, next, done, context) {
|
|
|
86
79
|
});
|
|
87
80
|
}
|
|
88
81
|
|
|
89
|
-
function
|
|
82
|
+
function openRelease(release) {
|
|
90
83
|
const { name } = release,
|
|
91
84
|
filePath = name, ///
|
|
92
85
|
releaseJSON = release, ///
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const { shellUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
{
|
|
5
|
+
const { isAnswerAffirmative } = require("../../utilities/prompt"),
|
|
6
|
+
{ validateAffirmation } = require("../../utilities/validate"),
|
|
7
7
|
{ ARE_YOU_SURE_DESCRIPTION } = require("../../descriptions"),
|
|
8
8
|
{ INVALID_AFFIRMATION_MESSAGE } = require("../../messages");
|
|
9
9
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { shellUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { YES } = require("../../constants"),
|
|
6
|
+
{ isAnswerAffirmative } = require("../../utilities/prompt"),
|
|
7
|
+
{ validateAffirmation } = require("../../utilities/validate"),
|
|
8
|
+
{ INVALID_AFFIRMATION_MESSAGE } = require("../../messages"),
|
|
9
|
+
{ CLONE_DEPENDENCIES_DESCRIPTION } = require("../../descriptions");
|
|
10
|
+
|
|
11
|
+
const { prompt } = shellUtilities;
|
|
12
|
+
|
|
13
|
+
function cloneDependenciesPromptOperation(proceed, abort, context) {
|
|
14
|
+
const { yes } = context,
|
|
15
|
+
answer = yes ?
|
|
16
|
+
YES :
|
|
17
|
+
null,
|
|
18
|
+
description = CLONE_DEPENDENCIES_DESCRIPTION,
|
|
19
|
+
errorMessage = INVALID_AFFIRMATION_MESSAGE,
|
|
20
|
+
validationFunction = validateAffirmation, ///
|
|
21
|
+
options = {
|
|
22
|
+
answer,
|
|
23
|
+
description,
|
|
24
|
+
errorMessage,
|
|
25
|
+
validationFunction
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
prompt(options, (answer) => {
|
|
29
|
+
const valid = (answer !== null);
|
|
30
|
+
|
|
31
|
+
if (valid) {
|
|
32
|
+
const affirmative = isAnswerAffirmative(answer),
|
|
33
|
+
cloneDependencies = affirmative; ///
|
|
34
|
+
|
|
35
|
+
Object.assign(context, {
|
|
36
|
+
cloneDependencies
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
proceed();
|
|
40
|
+
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
abort();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = cloneDependenciesPromptOperation;
|
package/package.json
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const post = require("../post");
|
|
4
|
-
|
|
5
|
-
const { CLONE_API_URI } = require("../uris");
|
|
6
|
-
|
|
7
|
-
function repositoryOperation(proceed, abort, context) {
|
|
8
|
-
const { releaseName } = context,
|
|
9
|
-
uri = `${CLONE_API_URI}/${releaseName}`,
|
|
10
|
-
json = {};
|
|
11
|
-
|
|
12
|
-
post(uri, json, (json) => {
|
|
13
|
-
const { repository = null } = json;
|
|
14
|
-
|
|
15
|
-
if (repository === null) {
|
|
16
|
-
abort();
|
|
17
|
-
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
Object.assign(context, {
|
|
22
|
-
repository
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
proceed();
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = repositoryOperation;
|