find-cli 0.0.3 → 1.4.4
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 +43 -5
- package/bin/abbreviations.js +10 -0
- package/bin/action/addRootDirectoryPath.js +31 -0
- package/bin/action/find.js +84 -0
- package/bin/action/help.js +40 -0
- package/bin/action/initialise.js +18 -0
- package/bin/action/listRootDirectoryPaths.js +18 -0
- package/bin/action/removeRootDirectoryPath.js +33 -0
- package/bin/action/version.js +15 -0
- package/bin/commands.js +19 -0
- package/bin/configuration/version_1_1.js +26 -0
- package/bin/configuration/version_1_2.js +48 -0
- package/bin/configuration/version_1_3.js +22 -0
- package/bin/configuration/version_1_4.js +58 -0
- package/bin/configuration.js +230 -0
- package/bin/constants.js +25 -0
- package/bin/converter/alternates.js +29 -0
- package/bin/converter/characterClass.js +45 -0
- package/bin/converter/default.js +19 -0
- package/bin/converter/directory.js +19 -0
- package/bin/converter/escapedCharacter.js +19 -0
- package/bin/converter/period.js +19 -0
- package/bin/converter/questionMark.js +19 -0
- package/bin/converter/repeatedDirectories.js +19 -0
- package/bin/converter/repeatedWildcard.js +19 -0
- package/bin/converter/singleDirectory.js +19 -0
- package/bin/converter/singleWildcard.js +19 -0
- package/bin/converter.js +48 -0
- package/bin/converters.js +29 -0
- package/bin/defaults.js +13 -0
- package/bin/descriptions.js +11 -0
- package/bin/find.js +55 -0
- package/bin/isIgnored/asynchronous.js +59 -0
- package/bin/isIgnored/synchronous.js +104 -0
- package/bin/line.js +181 -0
- package/bin/main.js +85 -0
- package/bin/messages.js +37 -0
- package/bin/occurrence.js +40 -0
- package/bin/operation/addRootDirectoryPath.js +16 -0
- package/bin/operation/find.js +201 -0
- package/bin/operation/listRootDirectoryPaths.js +34 -0
- package/bin/operation/prompt/addRootDirectoryPath.js +48 -0
- package/bin/operation/prompt/ignoreOrPermitPath.js +46 -0
- package/bin/operation/prompt/removeRootDirectoryPath.js +61 -0
- package/bin/operation/prompt/rule.js +50 -0
- package/bin/operation/readConfiguration.js +27 -0
- package/bin/operation/removeRootDirectoryPath.js +29 -0
- package/bin/operation/removeRootDirectoryPathByIndex.js +34 -0
- package/bin/operation/rule.js +32 -0
- package/bin/operation/updatePatRules.js +54 -0
- package/bin/operation/validateRootDirectoryPath.js +30 -0
- package/bin/options.js +13 -0
- package/bin/prepare.js +51 -0
- package/bin/rule/glob.js +170 -0
- package/bin/rule/regex.js +141 -0
- package/bin/rule/string.js +117 -0
- package/bin/types.js +11 -0
- package/bin/utilities/literal.js +19 -0
- package/bin/utilities/log.js +26 -0
- package/bin/utilities/operation.js +38 -0
- package/bin/utilities/path.js +58 -0
- package/bin/utilities/prompt.js +7 -0
- package/bin/utilities/rule.js +18 -0
- package/bin/utilities/string.js +36 -0
- package/bin/utilities/validate.js +56 -0
- package/bin/versions.js +15 -0
- package/find.js +18 -0
- package/package.json +5 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { ruleFromStringAnchoredAndDirectory } = require("../utilities/rule");
|
|
4
|
+
|
|
5
|
+
function validateIndex(answer, lastIndex) {
|
|
6
|
+
let valid = true;
|
|
7
|
+
|
|
8
|
+
if (valid) {
|
|
9
|
+
valid = /^[1-9][0-9]*$/.test(answer);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (valid) {
|
|
13
|
+
const index = Number(answer);
|
|
14
|
+
|
|
15
|
+
valid = (index <= lastIndex);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return valid;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function validateIgnoreOrPermit(answer) { return /^(:?ignore|permit|i|p)$/i.test(answer); }
|
|
22
|
+
|
|
23
|
+
function validateRootDirectoryPath(answer) {
|
|
24
|
+
let valid = true;
|
|
25
|
+
|
|
26
|
+
if (valid) {
|
|
27
|
+
valid = /^\.\.\/(?:[^/]*\/)+$/i.test(answer);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (valid) {
|
|
31
|
+
const directory = true,
|
|
32
|
+
glob = globFromAnswerAndDirectory(answer, directory);
|
|
33
|
+
|
|
34
|
+
if (glob === null) {
|
|
35
|
+
valid = false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return valid;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function validateGlobStringOrPattern(answer, directory) {
|
|
43
|
+
const string = answer, ///
|
|
44
|
+
anchored = false,
|
|
45
|
+
rule = ruleFromStringAnchoredAndDirectory(string, anchored, directory),
|
|
46
|
+
valid = (rule !== null)
|
|
47
|
+
|
|
48
|
+
return valid;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
validateIndex,
|
|
53
|
+
validateIgnoreOrPermit,
|
|
54
|
+
validateRootDirectoryPath,
|
|
55
|
+
validateGlobStringOrPattern
|
|
56
|
+
};
|
package/bin/versions.js
ADDED
package/find.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { parseArgv } = require("argumentative"),
|
|
4
|
+
{ arrayUtilities } = require("necessary");
|
|
5
|
+
|
|
6
|
+
const main = require("./bin/main"),
|
|
7
|
+
prepare = require("./bin/prepare"),
|
|
8
|
+
abbreviations = require("./bin/abbreviations");
|
|
9
|
+
|
|
10
|
+
const { first, second } = arrayUtilities;
|
|
11
|
+
|
|
12
|
+
const { commands, options } = parseArgv(process.argv, abbreviations),
|
|
13
|
+
firstCommand = first(commands),
|
|
14
|
+
secondCommand = second(commands),
|
|
15
|
+
command = firstCommand || null, ///
|
|
16
|
+
argument = secondCommand || null; ///
|
|
17
|
+
|
|
18
|
+
prepare(command, argument, options, main);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.4.4",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/find-cli",
|
|
7
7
|
"description": "An alternative to grep.",
|
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/djalbat/find-cli"
|
|
11
11
|
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"find": "./find.js"
|
|
14
|
+
},
|
|
12
15
|
"dependencies": {
|
|
13
16
|
"argumentative": "^2.0.32",
|
|
14
|
-
"necessary": "^14.2.
|
|
17
|
+
"necessary": "^14.2.3"
|
|
15
18
|
},
|
|
16
19
|
"scripts": {}
|
|
17
20
|
}
|