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.
Files changed (68) hide show
  1. package/README.md +43 -5
  2. package/bin/abbreviations.js +10 -0
  3. package/bin/action/addRootDirectoryPath.js +31 -0
  4. package/bin/action/find.js +84 -0
  5. package/bin/action/help.js +40 -0
  6. package/bin/action/initialise.js +18 -0
  7. package/bin/action/listRootDirectoryPaths.js +18 -0
  8. package/bin/action/removeRootDirectoryPath.js +33 -0
  9. package/bin/action/version.js +15 -0
  10. package/bin/commands.js +19 -0
  11. package/bin/configuration/version_1_1.js +26 -0
  12. package/bin/configuration/version_1_2.js +48 -0
  13. package/bin/configuration/version_1_3.js +22 -0
  14. package/bin/configuration/version_1_4.js +58 -0
  15. package/bin/configuration.js +230 -0
  16. package/bin/constants.js +25 -0
  17. package/bin/converter/alternates.js +29 -0
  18. package/bin/converter/characterClass.js +45 -0
  19. package/bin/converter/default.js +19 -0
  20. package/bin/converter/directory.js +19 -0
  21. package/bin/converter/escapedCharacter.js +19 -0
  22. package/bin/converter/period.js +19 -0
  23. package/bin/converter/questionMark.js +19 -0
  24. package/bin/converter/repeatedDirectories.js +19 -0
  25. package/bin/converter/repeatedWildcard.js +19 -0
  26. package/bin/converter/singleDirectory.js +19 -0
  27. package/bin/converter/singleWildcard.js +19 -0
  28. package/bin/converter.js +48 -0
  29. package/bin/converters.js +29 -0
  30. package/bin/defaults.js +13 -0
  31. package/bin/descriptions.js +11 -0
  32. package/bin/find.js +55 -0
  33. package/bin/isIgnored/asynchronous.js +59 -0
  34. package/bin/isIgnored/synchronous.js +104 -0
  35. package/bin/line.js +181 -0
  36. package/bin/main.js +85 -0
  37. package/bin/messages.js +37 -0
  38. package/bin/occurrence.js +40 -0
  39. package/bin/operation/addRootDirectoryPath.js +16 -0
  40. package/bin/operation/find.js +201 -0
  41. package/bin/operation/listRootDirectoryPaths.js +34 -0
  42. package/bin/operation/prompt/addRootDirectoryPath.js +48 -0
  43. package/bin/operation/prompt/ignoreOrPermitPath.js +46 -0
  44. package/bin/operation/prompt/removeRootDirectoryPath.js +61 -0
  45. package/bin/operation/prompt/rule.js +50 -0
  46. package/bin/operation/readConfiguration.js +27 -0
  47. package/bin/operation/removeRootDirectoryPath.js +29 -0
  48. package/bin/operation/removeRootDirectoryPathByIndex.js +34 -0
  49. package/bin/operation/rule.js +32 -0
  50. package/bin/operation/updatePatRules.js +54 -0
  51. package/bin/operation/validateRootDirectoryPath.js +30 -0
  52. package/bin/options.js +13 -0
  53. package/bin/prepare.js +51 -0
  54. package/bin/rule/glob.js +170 -0
  55. package/bin/rule/regex.js +141 -0
  56. package/bin/rule/string.js +117 -0
  57. package/bin/types.js +11 -0
  58. package/bin/utilities/literal.js +19 -0
  59. package/bin/utilities/log.js +26 -0
  60. package/bin/utilities/operation.js +38 -0
  61. package/bin/utilities/path.js +58 -0
  62. package/bin/utilities/prompt.js +7 -0
  63. package/bin/utilities/rule.js +18 -0
  64. package/bin/utilities/string.js +36 -0
  65. package/bin/utilities/validate.js +56 -0
  66. package/bin/versions.js +15 -0
  67. package/find.js +18 -0
  68. 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
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ const VERSION_1_0 = "1.0",
4
+ VERSION_1_1 = "1.1",
5
+ VERSION_1_2 = "1.2",
6
+ VERSION_1_3 = "1.3",
7
+ VERSION_1_4 = "1.4";
8
+
9
+ module.exports = {
10
+ VERSION_1_0,
11
+ VERSION_1_1,
12
+ VERSION_1_2,
13
+ VERSION_1_3,
14
+ VERSION_1_4
15
+ };
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": "0.0.3",
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.1"
17
+ "necessary": "^14.2.3"
15
18
  },
16
19
  "scripts": {}
17
20
  }