find-cli 1.6.4 → 1.7.2
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 +11 -1
- package/bin/action/find.js +8 -5
- package/bin/action/help.js +2 -0
- package/bin/configuration/version_1_4.js +1 -24
- package/bin/configuration/version_1_7.js +44 -0
- package/bin/configuration.js +30 -4
- package/bin/constants.js +2 -0
- package/bin/defaults.js +2 -0
- package/bin/descriptions.js +4 -2
- package/bin/main.js +4 -4
- package/bin/messages.js +4 -2
- package/bin/operation/find.js +33 -199
- package/bin/operation/previousRule.js +39 -0
- package/bin/operation/prompt/previousRule.js +52 -0
- package/bin/operation/prompt/rule.js +17 -5
- package/bin/operation/rule.js +2 -2
- package/bin/options.js +2 -0
- package/bin/rule/glob.js +27 -5
- package/bin/rule/regex.js +27 -5
- package/bin/rule/string.js +30 -5
- package/bin/utilities/find.js +203 -0
- package/bin/utilities/prompt.js +124 -2
- package/bin/versions.js +4 -2
- package/package.json +2 -2
- package/bin/operation/readConfiguration.js +0 -27
package/README.md
CHANGED
package/bin/abbreviations.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { HELP_OPTION,
|
|
3
|
+
const { HELP_OPTION,
|
|
4
|
+
GLOB_OPTION,
|
|
5
|
+
REGEX_OPTION,
|
|
6
|
+
STRING_OPTION,
|
|
7
|
+
FORMAT_OPTION,
|
|
8
|
+
VERSION_OPTION,
|
|
9
|
+
DRY_RUN_OPTION,
|
|
10
|
+
QUIETLY_OPTION,
|
|
11
|
+
PREVIOUS_OPTION,
|
|
12
|
+
INTERACTIVE_OPTION } = require("./options");
|
|
4
13
|
|
|
5
14
|
module.exports = {
|
|
6
15
|
"h": HELP_OPTION,
|
|
@@ -11,5 +20,6 @@ module.exports = {
|
|
|
11
20
|
"v": VERSION_OPTION,
|
|
12
21
|
"d": DRY_RUN_OPTION,
|
|
13
22
|
"q": QUIETLY_OPTION,
|
|
23
|
+
"p": PREVIOUS_OPTION,
|
|
14
24
|
"i": INTERACTIVE_OPTION
|
|
15
25
|
};
|
package/bin/action/find.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const findOperation = require("../operation/find"),
|
|
4
|
+
ruleOperation = require("../operation/rule"),
|
|
5
5
|
rulePromptOperation = require("../operation/prompt/rule"),
|
|
6
|
-
|
|
6
|
+
previousRuleOperation = require("../operation/previousRule"),
|
|
7
|
+
previousRulePromptOperation = require("../operation/prompt/previousRule");
|
|
7
8
|
|
|
8
9
|
const { S, EMPTY_STRING } = require("../constants"),
|
|
9
10
|
{ executeOperations } = require("../utilities/operation");
|
|
10
11
|
|
|
11
|
-
function findAction(string, dryRun, format, quietly, interactive) {
|
|
12
|
+
function findAction(string, dryRun, format, quietly, previous, interactive) {
|
|
12
13
|
const operations = [
|
|
13
14
|
ruleOperation,
|
|
15
|
+
previousRulePromptOperation,
|
|
14
16
|
rulePromptOperation,
|
|
15
|
-
|
|
17
|
+
previousRuleOperation,
|
|
16
18
|
findOperation
|
|
17
19
|
],
|
|
18
20
|
rule = null,
|
|
@@ -26,6 +28,7 @@ function findAction(string, dryRun, format, quietly, interactive) {
|
|
|
26
28
|
dryRun,
|
|
27
29
|
format,
|
|
28
30
|
quietly,
|
|
31
|
+
previous,
|
|
29
32
|
interactive,
|
|
30
33
|
rule,
|
|
31
34
|
lines,
|
package/bin/action/help.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { VERSION_1_4 } = require("../versions")
|
|
4
|
-
{ ROOT_DIRECTORY_PATH } = require("../constants");
|
|
3
|
+
const { VERSION_1_4 } = require("../versions");
|
|
5
4
|
|
|
6
5
|
function migrateConfigurationToVersion_1_4(configuration) {
|
|
7
6
|
const { ignoredFilePathMatchers,
|
|
@@ -31,28 +30,6 @@ function migrateConfigurationToVersion_1_4(configuration) {
|
|
|
31
30
|
return configuration;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
function createConfiguration() {
|
|
35
|
-
const version = VERSION_1_4, ///
|
|
36
|
-
rootDirectoryPaths = [
|
|
37
|
-
ROOT_DIRECTORY_PATH
|
|
38
|
-
],
|
|
39
|
-
ignoredFilePathRules = [],
|
|
40
|
-
permittedFilePathRules = [],
|
|
41
|
-
ignoredDirectoryPathRules = [],
|
|
42
|
-
permittedDirectoryPathRules = [],
|
|
43
|
-
configuration = {
|
|
44
|
-
version,
|
|
45
|
-
rootDirectoryPaths,
|
|
46
|
-
ignoredFilePathRules,
|
|
47
|
-
permittedFilePathRules,
|
|
48
|
-
ignoredDirectoryPathRules,
|
|
49
|
-
permittedDirectoryPathRules
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return configuration;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
33
|
module.exports = {
|
|
56
|
-
createConfiguration,
|
|
57
34
|
migrateConfigurationToVersion_1_4
|
|
58
35
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { VERSION_1_7 } = require("../versions"),
|
|
4
|
+
{ ROOT_DIRECTORY_PATH } = require("../constants");
|
|
5
|
+
|
|
6
|
+
function migrateConfigurationToVersion_1_7(configuration) {
|
|
7
|
+
const version = VERSION_1_7,
|
|
8
|
+
previousRules = [];
|
|
9
|
+
|
|
10
|
+
Object.assign(configuration, {
|
|
11
|
+
version,
|
|
12
|
+
previousRules
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return configuration;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createConfiguration() {
|
|
19
|
+
const version = VERSION_1_7, ///
|
|
20
|
+
rootDirectoryPaths = [
|
|
21
|
+
ROOT_DIRECTORY_PATH
|
|
22
|
+
],
|
|
23
|
+
previousRules = [],
|
|
24
|
+
ignoredFilePathRules = [],
|
|
25
|
+
permittedFilePathRules = [],
|
|
26
|
+
ignoredDirectoryPathRules = [],
|
|
27
|
+
permittedDirectoryPathRules = [],
|
|
28
|
+
configuration = {
|
|
29
|
+
version,
|
|
30
|
+
previousRules,
|
|
31
|
+
rootDirectoryPaths,
|
|
32
|
+
ignoredFilePathRules,
|
|
33
|
+
permittedFilePathRules,
|
|
34
|
+
ignoredDirectoryPathRules,
|
|
35
|
+
permittedDirectoryPathRules
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return configuration;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
createConfiguration,
|
|
43
|
+
migrateConfigurationToVersion_1_7
|
|
44
|
+
};
|
package/bin/configuration.js
CHANGED
|
@@ -7,13 +7,14 @@ const GlobRule = require("./rule/glob"),
|
|
|
7
7
|
StringRule = require("./rule/string");
|
|
8
8
|
|
|
9
9
|
const { FIND } = require("./constants"),
|
|
10
|
-
{ createConfiguration } = require("./configuration/
|
|
10
|
+
{ createConfiguration } = require("./configuration/version_1_7"),
|
|
11
11
|
{ migrateConfigurationToVersion_1_1 } = require("./configuration/version_1_1"),
|
|
12
12
|
{ migrateConfigurationToVersion_1_2 } = require("./configuration/version_1_2"),
|
|
13
13
|
{ migrateConfigurationToVersion_1_3 } = require("./configuration/version_1_3"),
|
|
14
14
|
{ migrateConfigurationToVersion_1_4 } = require("./configuration/version_1_4"),
|
|
15
|
+
{ migrateConfigurationToVersion_1_7 } = require("./configuration/version_1_7"),
|
|
15
16
|
{ CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE } = require("./messages"),
|
|
16
|
-
{ VERSION_1_0, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 } = require("./versions");
|
|
17
|
+
{ VERSION_1_0, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_7 } = require("./versions");
|
|
17
18
|
|
|
18
19
|
const { rc } = configurationUtilities,
|
|
19
20
|
{ migrate } = versionUtilities,
|
|
@@ -28,6 +29,18 @@ function retrieveRootDirectoryPaths() {
|
|
|
28
29
|
return rootDirectoryPaths;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
function retrievePreviousRules() {
|
|
33
|
+
const configuration = readConfigurationFile();
|
|
34
|
+
|
|
35
|
+
let { previousRules } = configuration;
|
|
36
|
+
|
|
37
|
+
const previousRulesJSON = previousRules; ///
|
|
38
|
+
|
|
39
|
+
previousRules = rulesFromPathRulesJSON(previousRulesJSON);
|
|
40
|
+
|
|
41
|
+
return previousRules;
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
function retrieveIgnoredFilePathRules() {
|
|
32
45
|
const configuration = readConfigurationFile();
|
|
33
46
|
|
|
@@ -82,6 +95,16 @@ function updateRootDirectoryPaths(rootDirectoryPaths) {
|
|
|
82
95
|
});
|
|
83
96
|
}
|
|
84
97
|
|
|
98
|
+
function updatePreviousRules(previousRules) {
|
|
99
|
+
const previousRulesJSON = rulesJSONFromRules(previousRules);
|
|
100
|
+
|
|
101
|
+
previousRules = previousRulesJSON; ///
|
|
102
|
+
|
|
103
|
+
updateConfigurationFile({
|
|
104
|
+
previousRules
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
85
108
|
function updateIgnoredFilePathRules(ignoredFilePathRules) {
|
|
86
109
|
const ignoredFilePathRulesJSON = rulesJSONFromRules(ignoredFilePathRules);
|
|
87
110
|
|
|
@@ -138,9 +161,10 @@ function migrateConfigurationFile() {
|
|
|
138
161
|
[ VERSION_1_0 ]: migrateConfigurationToVersion_1_1,
|
|
139
162
|
[ VERSION_1_1 ]: migrateConfigurationToVersion_1_2,
|
|
140
163
|
[ VERSION_1_2 ]: migrateConfigurationToVersion_1_3,
|
|
141
|
-
[ VERSION_1_3 ]: migrateConfigurationToVersion_1_4
|
|
164
|
+
[ VERSION_1_3 ]: migrateConfigurationToVersion_1_4,
|
|
165
|
+
[ VERSION_1_4 ]: migrateConfigurationToVersion_1_7
|
|
142
166
|
},
|
|
143
|
-
latestVersion =
|
|
167
|
+
latestVersion = VERSION_1_7;
|
|
144
168
|
|
|
145
169
|
json = migrate(json, migrationMap, latestVersion);
|
|
146
170
|
|
|
@@ -166,10 +190,12 @@ function assertConfigurationFileExists() {
|
|
|
166
190
|
|
|
167
191
|
module.exports = {
|
|
168
192
|
retrieveRootDirectoryPaths,
|
|
193
|
+
retrievePreviousRules,
|
|
169
194
|
retrieveIgnoredFilePathRules,
|
|
170
195
|
retrievePermittedFilePathRules,
|
|
171
196
|
retrieveIgnoredDirectoryPathRules,
|
|
172
197
|
retrievePermittedDirectoryPathRules,
|
|
198
|
+
updatePreviousRules,
|
|
173
199
|
updateRootDirectoryPaths,
|
|
174
200
|
updateIgnoredFilePathRules,
|
|
175
201
|
updatePermittedFilePathRules,
|
package/bin/constants.js
CHANGED
package/bin/defaults.js
CHANGED
|
@@ -7,6 +7,7 @@ const DEFAULT_HELP = false,
|
|
|
7
7
|
DEFAULT_VERSION = false,
|
|
8
8
|
DEFAULT_DRY_RUN = false,
|
|
9
9
|
DEFAULT_QUIETLY = false,
|
|
10
|
+
DEFAULT_PREVIOUS = false,
|
|
10
11
|
DEFAULT_INTERACTIVE = false;
|
|
11
12
|
|
|
12
13
|
module.exports = {
|
|
@@ -17,5 +18,6 @@ module.exports = {
|
|
|
17
18
|
DEFAULT_VERSION,
|
|
18
19
|
DEFAULT_DRY_RUN,
|
|
19
20
|
DEFAULT_QUIETLY,
|
|
21
|
+
DEFAULT_PREVIOUS,
|
|
20
22
|
DEFAULT_INTERACTIVE
|
|
21
23
|
};
|
package/bin/descriptions.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const GLOB_STRING_OR_REGEX_DESCRIPTION = `Glob, string or regex: `,
|
|
4
4
|
ADD_ROOT_DIRECTORY_PATH_DESCRIPTION = `Root directory: `,
|
|
5
|
-
REMOVE_ROOT_DIRECTORY_PATH_DESCRIPTION = `Root directory index:
|
|
5
|
+
REMOVE_ROOT_DIRECTORY_PATH_DESCRIPTION = `Root directory index: `,
|
|
6
|
+
PREVIOUS_GLOB_STRING_OR_REGEX_DESCRIPTION = `Previous glob, string or regex: `;
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
GLOB_STRING_OR_REGEX_DESCRIPTION,
|
|
9
10
|
ADD_ROOT_DIRECTORY_PATH_DESCRIPTION,
|
|
10
|
-
REMOVE_ROOT_DIRECTORY_PATH_DESCRIPTION
|
|
11
|
+
REMOVE_ROOT_DIRECTORY_PATH_DESCRIPTION,
|
|
12
|
+
PREVIOUS_GLOB_STRING_OR_REGEX_DESCRIPTION
|
|
11
13
|
};
|
package/bin/main.js
CHANGED
|
@@ -9,7 +9,7 @@ const findAction = require("./action/find"),
|
|
|
9
9
|
removeRootDirectoryPathAction = require("./action/removeRootDirectoryPath");
|
|
10
10
|
|
|
11
11
|
const { NO_ARGUMENT_GIVEN_MESSAGE, COMMAND_NOT_RECOGNISED_MESSAGE } = require("./messages"),
|
|
12
|
-
{ DEFAULT_REGEX, DEFAULT_STRING, DEFAULT_FORMAT, DEFAULT_DRY_RUN, DEFAULT_QUIETLY, DEFAULT_INTERACTIVE } = require("./defaults"),
|
|
12
|
+
{ DEFAULT_REGEX, DEFAULT_STRING, DEFAULT_FORMAT, DEFAULT_DRY_RUN, DEFAULT_QUIETLY, DEFAULT_PREVIOUS, DEFAULT_INTERACTIVE } = require("./defaults"),
|
|
13
13
|
{ FIND_COMMAND,
|
|
14
14
|
HELP_COMMAND,
|
|
15
15
|
VERSION_COMMAND,
|
|
@@ -19,7 +19,7 @@ const { NO_ARGUMENT_GIVEN_MESSAGE, COMMAND_NOT_RECOGNISED_MESSAGE } = require(".
|
|
|
19
19
|
REMOVE_ROOT_DIRECTORY_PATH_COMMAND } = require("./commands");
|
|
20
20
|
|
|
21
21
|
function main(command, argument, options) {
|
|
22
|
-
const { format = DEFAULT_FORMAT, dryRun = DEFAULT_DRY_RUN, quietly = DEFAULT_QUIETLY, interactive = DEFAULT_INTERACTIVE } = options;
|
|
22
|
+
const { format = DEFAULT_FORMAT, dryRun = DEFAULT_DRY_RUN, quietly = DEFAULT_QUIETLY, previous = DEFAULT_PREVIOUS, interactive = DEFAULT_INTERACTIVE } = options;
|
|
23
23
|
|
|
24
24
|
let { regex = DEFAULT_REGEX, string = DEFAULT_STRING } = options;
|
|
25
25
|
|
|
@@ -66,7 +66,7 @@ function main(command, argument, options) {
|
|
|
66
66
|
|
|
67
67
|
case FIND_COMMAND: {
|
|
68
68
|
if (argument === null) {
|
|
69
|
-
if (!dryRun && !interactive) {
|
|
69
|
+
if (!dryRun && !previous && !interactive) {
|
|
70
70
|
console.log(NO_ARGUMENT_GIVEN_MESSAGE);
|
|
71
71
|
|
|
72
72
|
break;
|
|
@@ -83,7 +83,7 @@ function main(command, argument, options) {
|
|
|
83
83
|
|
|
84
84
|
string = argument; ///
|
|
85
85
|
|
|
86
|
-
findAction(string, dryRun, format, quietly, interactive);
|
|
86
|
+
findAction(string, dryRun, format, quietly, previous, interactive);
|
|
87
87
|
|
|
88
88
|
break;
|
|
89
89
|
}
|
package/bin/messages.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const NO_ARGUMENT_GIVEN_MESSAGE = "No argument has been given.",
|
|
4
|
-
|
|
4
|
+
NO_PREVIOUS_RULES_MESSAGE = "There are no previous rules.",
|
|
5
5
|
NO_ROOT_DIRECTORY_PATHS_MESSAGE = "There are no root directory paths bar the default one.",
|
|
6
|
+
COMMAND_NOT_RECOGNISED_MESSAGE = "The command is not recognised.",
|
|
6
7
|
CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE = "The action cannot be performed because the configuration file is missing. Run 'find initialise' to create one.",
|
|
7
8
|
INVALID_IGNORE_OR_PERMIT_MESSAGE = "You must answer (i)gnore or (p)ermit.",
|
|
8
9
|
INVALID_ROOT_DIRECTORY_PATH_MESSAGE = "Additional root directories must be globs of the form '../**/'.",
|
|
@@ -17,8 +18,9 @@ const NO_ARGUMENT_GIVEN_MESSAGE = "No argument has been given.",
|
|
|
17
18
|
|
|
18
19
|
module.exports = {
|
|
19
20
|
NO_ARGUMENT_GIVEN_MESSAGE,
|
|
20
|
-
|
|
21
|
+
NO_PREVIOUS_RULES_MESSAGE,
|
|
21
22
|
NO_ROOT_DIRECTORY_PATHS_MESSAGE,
|
|
23
|
+
COMMAND_NOT_RECOGNISED_MESSAGE,
|
|
22
24
|
CONFIGURATION_FILE_DOES_NOT_EXIST_MESSAGE,
|
|
23
25
|
INVALID_IGNORE_OR_PERMIT_MESSAGE,
|
|
24
26
|
INVALID_ROOT_DIRECTORY_PATH_MESSAGE,
|
package/bin/operation/find.js
CHANGED
|
@@ -1,22 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{ asynchronousIsFilePathIgnored, asynchronousIsDirectoryPathIgnored } = require("../isIgnored/asynchronous"),
|
|
10
|
-
{ isDirectoryPathRootDirectoryPath, entryPathsFromEntryNamesAndDirectoryPath } = require("../utilities/path");
|
|
11
|
-
|
|
12
|
-
const { readDirectory, isEntryDirectory } = fileSystemUtilities;
|
|
3
|
+
const { findInEntries } = require("../utilities/find");
|
|
4
|
+
const { retrieveRootDirectoryPaths,
|
|
5
|
+
retrieveIgnoredFilePathRules,
|
|
6
|
+
retrievePermittedFilePathRules,
|
|
7
|
+
retrieveIgnoredDirectoryPathRules,
|
|
8
|
+
retrievePermittedDirectoryPathRules } = require("../configuration");
|
|
13
9
|
|
|
14
10
|
function findOperation(proceed, abort, context) {
|
|
15
|
-
const
|
|
16
|
-
|
|
11
|
+
const rootDirectoryPaths = retrieveRootDirectoryPaths(),
|
|
12
|
+
ignoredFilePathRules = retrieveIgnoredFilePathRules(),
|
|
13
|
+
permittedFilePathRules = retrievePermittedFilePathRules(),
|
|
14
|
+
ignoredDirectoryPathRules = retrieveIgnoredDirectoryPathRules(),
|
|
15
|
+
permittedDirectoryPathRules = retrievePermittedDirectoryPathRules();
|
|
16
|
+
|
|
17
|
+
Object.assign(context, {
|
|
18
|
+
rootDirectoryPaths,
|
|
19
|
+
ignoredFilePathRules,
|
|
20
|
+
permittedFilePathRules,
|
|
21
|
+
ignoredDirectoryPathRules,
|
|
22
|
+
permittedDirectoryPathRules
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const entryPaths = [ ///
|
|
17
26
|
...rootDirectoryPaths
|
|
18
27
|
],
|
|
19
28
|
synchronous = findInEntries(entryPaths, (pathIgnored) => {
|
|
29
|
+
delete context.rootDirectoryPaths;
|
|
30
|
+
delete context.ignoredFilePathRules;
|
|
31
|
+
delete context.permittedFilePathRules;
|
|
32
|
+
delete context.ignoredDirectoryPathRules;
|
|
33
|
+
delete context.permittedDirectoryPathRules;
|
|
34
|
+
|
|
20
35
|
if (pathIgnored === null) {
|
|
21
36
|
abort();
|
|
22
37
|
|
|
@@ -27,195 +42,14 @@ function findOperation(proceed, abort, context) {
|
|
|
27
42
|
}, context);
|
|
28
43
|
|
|
29
44
|
if (synchronous) {
|
|
45
|
+
delete context.rootDirectoryPaths;
|
|
46
|
+
delete context.ignoredFilePathRules;
|
|
47
|
+
delete context.permittedFilePathRules;
|
|
48
|
+
delete context.ignoredDirectoryPathRules;
|
|
49
|
+
delete context.permittedDirectoryPathRules;
|
|
50
|
+
|
|
30
51
|
proceed();
|
|
31
52
|
}
|
|
32
53
|
}
|
|
33
54
|
|
|
34
55
|
module.exports = findOperation;
|
|
35
|
-
|
|
36
|
-
function findInEntries(entryPaths, callback, context) {
|
|
37
|
-
let synchronous = true;
|
|
38
|
-
|
|
39
|
-
let entryNamesLength;
|
|
40
|
-
|
|
41
|
-
entryNamesLength = entryPaths.length;
|
|
42
|
-
|
|
43
|
-
while (entryNamesLength > 0) {
|
|
44
|
-
const entryPath = entryPaths.shift();
|
|
45
|
-
|
|
46
|
-
synchronous = findInEntry(entryPath, entryPaths, callback, context);
|
|
47
|
-
|
|
48
|
-
if (!synchronous) {
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
entryNamesLength = entryPaths.length;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return synchronous;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function findInEntry(entryPath, entryPaths, callback, context) {
|
|
59
|
-
let synchronous;
|
|
60
|
-
|
|
61
|
-
const path = entryPath,
|
|
62
|
-
directory = isEntryDirectory(path);
|
|
63
|
-
|
|
64
|
-
if (directory) {
|
|
65
|
-
const directoryPath = entryPath; ///
|
|
66
|
-
|
|
67
|
-
synchronous = findInDirectory(directoryPath, (pathIgnored) => {
|
|
68
|
-
const synchronous = (pathIgnored !== null) ?
|
|
69
|
-
findInEntries(entryPaths, callback, context) :
|
|
70
|
-
true;
|
|
71
|
-
|
|
72
|
-
if (synchronous) {
|
|
73
|
-
callback(pathIgnored);
|
|
74
|
-
}
|
|
75
|
-
}, context);
|
|
76
|
-
} else {
|
|
77
|
-
const filePath = entryPath; ///
|
|
78
|
-
|
|
79
|
-
synchronous = findInFile(filePath, (pathIgnored) => {
|
|
80
|
-
const synchronous = (pathIgnored !== null) ?
|
|
81
|
-
findInEntries(entryPaths, callback, context) :
|
|
82
|
-
true;
|
|
83
|
-
if (synchronous) {
|
|
84
|
-
callback(pathIgnored);
|
|
85
|
-
}
|
|
86
|
-
}, context);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (synchronous) {
|
|
90
|
-
synchronous = findInEntries(entryPaths, callback, context);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return synchronous;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function findInFile(filePath, callback, context) {
|
|
97
|
-
let synchronous;
|
|
98
|
-
|
|
99
|
-
const filePathIgnored = synchronousIsFilePathIgnored(filePath, context);
|
|
100
|
-
|
|
101
|
-
if (filePathIgnored !== null) {
|
|
102
|
-
synchronous = true;
|
|
103
|
-
|
|
104
|
-
const { quietly } = context;
|
|
105
|
-
|
|
106
|
-
if (!quietly) {
|
|
107
|
-
let message;
|
|
108
|
-
|
|
109
|
-
const { format, ruleString } = context;
|
|
110
|
-
|
|
111
|
-
message = filePathIgnored ?
|
|
112
|
-
`Ignore ${filePath}`:
|
|
113
|
-
`Permit ${filePath}`;
|
|
114
|
-
|
|
115
|
-
if (format) {
|
|
116
|
-
message = filePathIgnored ?
|
|
117
|
-
red(message) :
|
|
118
|
-
green(message);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
message = `${message} ${ruleString}`;
|
|
122
|
-
|
|
123
|
-
console.log(message);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!filePathIgnored) {
|
|
127
|
-
let { filesTotal } = context;
|
|
128
|
-
|
|
129
|
-
filesTotal++;
|
|
130
|
-
|
|
131
|
-
Object.assign(context, {
|
|
132
|
-
filesTotal
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const { dryRun } = context;
|
|
136
|
-
|
|
137
|
-
if (!dryRun) {
|
|
138
|
-
find(filePath, context);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
synchronous = false;
|
|
143
|
-
|
|
144
|
-
asynchronousIsFilePathIgnored(filePath, context, (pathIgnored) => {
|
|
145
|
-
const synchronous = (pathIgnored !== null) ?
|
|
146
|
-
findInFile(filePath, callback, context) :
|
|
147
|
-
true;
|
|
148
|
-
|
|
149
|
-
if (synchronous) {
|
|
150
|
-
callback(pathIgnored);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return synchronous;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function findInDirectory(directoryPath, callback, context) {
|
|
159
|
-
let synchronous;
|
|
160
|
-
|
|
161
|
-
const directoryPathIgnored = synchronousIsDirectoryPathIgnored(directoryPath, context);
|
|
162
|
-
|
|
163
|
-
if (directoryPathIgnored !== null) {
|
|
164
|
-
synchronous = true;
|
|
165
|
-
|
|
166
|
-
const directoryPathRootDirectoryPath = isDirectoryPathRootDirectoryPath(directoryPath, context);
|
|
167
|
-
|
|
168
|
-
if (!directoryPathRootDirectoryPath) {
|
|
169
|
-
const { quietly } = context;
|
|
170
|
-
|
|
171
|
-
if (!quietly) {
|
|
172
|
-
let message;
|
|
173
|
-
|
|
174
|
-
const { format, ruleString } = context;
|
|
175
|
-
|
|
176
|
-
message = directoryPathIgnored ?
|
|
177
|
-
`Ignore ${directoryPath}/` :
|
|
178
|
-
`Permit ${directoryPath}/`;
|
|
179
|
-
|
|
180
|
-
if (format) {
|
|
181
|
-
message = directoryPathIgnored ?
|
|
182
|
-
red(message) :
|
|
183
|
-
green(message);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
message = `${message} ${ruleString}`;
|
|
187
|
-
|
|
188
|
-
console.log(message);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (!directoryPathIgnored) {
|
|
193
|
-
let { directoriesTotal } = context;
|
|
194
|
-
|
|
195
|
-
directoriesTotal++;
|
|
196
|
-
|
|
197
|
-
Object.assign(context, {
|
|
198
|
-
directoriesTotal
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const entryNames = readDirectory(directoryPath),
|
|
202
|
-
entryPaths = entryPathsFromEntryNamesAndDirectoryPath(entryNames, directoryPath);
|
|
203
|
-
|
|
204
|
-
synchronous = findInEntries(entryPaths, callback, context);
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
synchronous = false;
|
|
208
|
-
|
|
209
|
-
asynchronousIsDirectoryPathIgnored(directoryPath, context, (pathIgnored) => {
|
|
210
|
-
const synchronous = (pathIgnored !== null) ?
|
|
211
|
-
findInDirectory(directoryPath, callback, context) :
|
|
212
|
-
true;
|
|
213
|
-
|
|
214
|
-
if (synchronous) {
|
|
215
|
-
callback(pathIgnored);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return synchronous;
|
|
221
|
-
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { arrayUtilities } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { updatePreviousRules, retrievePreviousRules } = require("../configuration");
|
|
6
|
+
|
|
7
|
+
const { filter } = arrayUtilities;
|
|
8
|
+
|
|
9
|
+
function previousRuleOperation(proceed, abort, context) {
|
|
10
|
+
const { dryRun } = context;
|
|
11
|
+
|
|
12
|
+
if (dryRun) {
|
|
13
|
+
proceed();
|
|
14
|
+
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { rule } = context;
|
|
19
|
+
|
|
20
|
+
const previousRules = retrievePreviousRules();
|
|
21
|
+
|
|
22
|
+
filter(previousRules, (previousRule) => {
|
|
23
|
+
const previousRuleEqualToRule = previousRule.isEqualTo(rule);
|
|
24
|
+
|
|
25
|
+
if (!previousRuleEqualToRule) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const previousRule = rule; ///
|
|
31
|
+
|
|
32
|
+
previousRules.unshift(previousRule);
|
|
33
|
+
|
|
34
|
+
updatePreviousRules(previousRules);
|
|
35
|
+
|
|
36
|
+
proceed();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = previousRuleOperation;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { selectPreviousRule } = require("../../utilities/prompt"),
|
|
4
|
+
{ retrievePreviousRules } = require("../../configuration"),
|
|
5
|
+
{ NO_PREVIOUS_RULES_MESSAGE } = require("../../messages");
|
|
6
|
+
|
|
7
|
+
function previousRulePromptOperation(proceed, abort, context) {
|
|
8
|
+
const { dryRun } = context;
|
|
9
|
+
|
|
10
|
+
if (dryRun) {
|
|
11
|
+
proceed();
|
|
12
|
+
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { previous } = context;
|
|
17
|
+
|
|
18
|
+
if (!previous) {
|
|
19
|
+
proceed();
|
|
20
|
+
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const previousRules = retrievePreviousRules(),
|
|
25
|
+
previousRulesLength = previousRules.length;
|
|
26
|
+
|
|
27
|
+
if (previousRulesLength === 0) {
|
|
28
|
+
console.log(NO_PREVIOUS_RULES_MESSAGE);
|
|
29
|
+
|
|
30
|
+
abort();
|
|
31
|
+
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
selectPreviousRule(previousRules, (previousRule) => {
|
|
36
|
+
if (previousRule === null) {
|
|
37
|
+
abort();
|
|
38
|
+
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const rule = previousRule; ///
|
|
43
|
+
|
|
44
|
+
Object.assign(context, {
|
|
45
|
+
rule
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
proceed();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = previousRulePromptOperation;
|