find-cli 1.4.5 → 1.4.8
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/find.js +3 -8
- package/bin/line.js +5 -4
- package/bin/messages.js +0 -4
- package/bin/utilities/log.js +14 -6
- package/package.json +1 -1
package/bin/action/find.js
CHANGED
|
@@ -5,8 +5,7 @@ const ruleOperation = require("../operation/rule"),
|
|
|
5
5
|
readConfigurationOperation = require("../operation/readConfiguration");
|
|
6
6
|
|
|
7
7
|
const { S, EMPTY_STRING } = require("../constants"),
|
|
8
|
-
{ executeOperations } = require("../utilities/operation")
|
|
9
|
-
{ FAILED_FIND_MESSAGE, SUCCESSFUL_FIND_MESSAGE } = require("../messages");
|
|
8
|
+
{ executeOperations } = require("../utilities/operation");
|
|
10
9
|
|
|
11
10
|
function findAction(string, dryRun, quietly) {
|
|
12
11
|
const operations = [
|
|
@@ -33,17 +32,13 @@ function findAction(string, dryRun, quietly) {
|
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
executeOperations(operations, (completed) => {
|
|
36
|
-
|
|
35
|
+
logLines(context);
|
|
37
36
|
|
|
38
37
|
if (!completed) {
|
|
39
|
-
console.log(FAILED_FIND_MESSAGE);
|
|
40
|
-
|
|
41
38
|
return;
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
console.log(SUCCESSFUL_FIND_MESSAGE);
|
|
41
|
+
logTottals(context);
|
|
47
42
|
}, context);
|
|
48
43
|
}
|
|
49
44
|
|
package/bin/line.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { arrayUtilities } = require("necessary");
|
|
4
4
|
|
|
5
|
-
const { grey, blue, yellow } = require("./utilities/log"),
|
|
5
|
+
const { grey, blue, yellow, cyan } = require("./utilities/log"),
|
|
6
6
|
{ EMPTY_STRING, SINGLE_SPACE } = require("./constants");
|
|
7
7
|
|
|
8
8
|
const { backwardsForEach } = arrayUtilities;
|
|
@@ -128,7 +128,7 @@ class Line {
|
|
|
128
128
|
|
|
129
129
|
gap = grey(gap); ///
|
|
130
130
|
|
|
131
|
-
match =
|
|
131
|
+
match = cyan(match); ///
|
|
132
132
|
|
|
133
133
|
string = `${string}${match}${gap}`;
|
|
134
134
|
});
|
|
@@ -142,7 +142,8 @@ class Line {
|
|
|
142
142
|
const filePathLength = this.getFilePathLength(),
|
|
143
143
|
paddingLength = requiredFilePathLength - filePathLength,
|
|
144
144
|
padding = paddingFromPaddingLength(paddingLength),
|
|
145
|
-
|
|
145
|
+
filePath = `${this.filePath}${padding}`,
|
|
146
|
+
formattedFilePath = blue(filePath);
|
|
146
147
|
|
|
147
148
|
return formattedFilePath;
|
|
148
149
|
}
|
|
@@ -151,7 +152,7 @@ class Line {
|
|
|
151
152
|
const formattedIndex = this.getFormattedIndex(requiredIndexLength),
|
|
152
153
|
formattedContent = this.getFormattedContent(),
|
|
153
154
|
formattedFilePath = this.getFormattedFilePath(requiredFilePathLength),
|
|
154
|
-
message =
|
|
155
|
+
message = `${formattedFilePath} ${formattedIndex} | ${formattedContent}`;
|
|
155
156
|
|
|
156
157
|
return message;
|
|
157
158
|
}
|
package/bin/messages.js
CHANGED
|
@@ -8,11 +8,9 @@ const NO_ARGUMENT_GIVEN_MESSAGE = "No argument has been given.",
|
|
|
8
8
|
INVALID_ROOT_DIRECTORY_PATH_MESSAGE = "Additional root directories must be globs of the form '../**/'.",
|
|
9
9
|
INVALID_GLOB_REGEX_OR_STRING_MESSAGE = "The glob, regex or string is invalid.",
|
|
10
10
|
INVALID_ROOT_DIRECTORY_PATH_INDEX_MESSAGE = "The index is either not a number or not within range.",
|
|
11
|
-
FAILED_FIND_MESSAGE = "Failed to search everything.",
|
|
12
11
|
FAILED_INITIALISE_MESSAGE = "Failed to create a configuration file because one is already present.",
|
|
13
12
|
FAILED_ADD_ROOT_DIRECTORY_MESSAGE = "Failed to add the root directory.",
|
|
14
13
|
FAILED_REMOVE_ROOT_DIRECTORY_MESSAGE = "Failed to remove the root directory.",
|
|
15
|
-
SUCCESSFUL_FIND_MESSAGE = "Searched everything successfully.",
|
|
16
14
|
SUCCESSFUL_INITIALISE_MESSAGE = "The configuration file has been created successfully.",
|
|
17
15
|
SUCCESSFUL_ADD_ROOT_DIRECTORY_MESSAGE = "Added the root directory successfully.",
|
|
18
16
|
SUCCESSFUL_REMOVE_ROOT_DIRECTORY_MESSAGE = "Removed the root directory successfully.";
|
|
@@ -26,11 +24,9 @@ module.exports = {
|
|
|
26
24
|
INVALID_ROOT_DIRECTORY_PATH_MESSAGE,
|
|
27
25
|
INVALID_GLOB_REGEX_OR_STRING_MESSAGE,
|
|
28
26
|
INVALID_ROOT_DIRECTORY_PATH_INDEX_MESSAGE,
|
|
29
|
-
FAILED_FIND_MESSAGE,
|
|
30
27
|
FAILED_INITIALISE_MESSAGE,
|
|
31
28
|
FAILED_ADD_ROOT_DIRECTORY_MESSAGE,
|
|
32
29
|
FAILED_REMOVE_ROOT_DIRECTORY_MESSAGE,
|
|
33
|
-
SUCCESSFUL_FIND_MESSAGE,
|
|
34
30
|
SUCCESSFUL_INITIALISE_MESSAGE,
|
|
35
31
|
SUCCESSFUL_ADD_ROOT_DIRECTORY_MESSAGE,
|
|
36
32
|
SUCCESSFUL_REMOVE_ROOT_DIRECTORY_MESSAGE
|
package/bin/utilities/log.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const RED_FOREGROUND_COLOUR = "\u001b[31m",
|
|
4
|
+
GREY_FOREGROUND_COLOUR = "\u001b[90m",
|
|
5
5
|
BLUE_FOREGROUND_COLOUR = "\u001b[34m",
|
|
6
|
+
CYAN_FOREGROUND_COLOUR = "\u001b[36m",
|
|
6
7
|
GREEN_FOREGROUND_COLOUR = "\u001b[32m",
|
|
7
8
|
YELLOW_FOREGROUND_COLOUR = "\u001b[33m",
|
|
9
|
+
MAGENTA_FOREGROUND_COLOUR = "\u001b[35m",
|
|
8
10
|
RESET_FOREGROUND_COLOUR = "\u001b[39m";
|
|
9
11
|
|
|
10
|
-
function grey(string) { return `${GREY_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
11
|
-
|
|
12
12
|
function red(string) { return `${RED_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
13
13
|
|
|
14
|
+
function grey(string) { return `${GREY_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
15
|
+
|
|
14
16
|
function blue(string) { return `${BLUE_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
15
17
|
|
|
18
|
+
function cyan(string) { return `${CYAN_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
19
|
+
|
|
16
20
|
function green(string) { return `${GREEN_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
17
21
|
|
|
18
22
|
function yellow(string) { return `${YELLOW_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
19
23
|
|
|
24
|
+
function magenta(string) { return `${MAGENTA_FOREGROUND_COLOUR}${string}${RESET_FOREGROUND_COLOUR}`; }
|
|
25
|
+
|
|
20
26
|
module.exports = {
|
|
21
|
-
grey,
|
|
22
27
|
red,
|
|
28
|
+
grey,
|
|
23
29
|
blue,
|
|
30
|
+
cyan,
|
|
24
31
|
green,
|
|
25
|
-
yellow
|
|
32
|
+
yellow,
|
|
33
|
+
magenta
|
|
26
34
|
};
|