@xylabs/jest-helpers 2.12.14 → 2.12.16

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 (127) hide show
  1. package/dist/browser/index.cjs +63 -0
  2. package/dist/browser/index.cjs.map +1 -1
  3. package/dist/browser/index.d.cts +1 -0
  4. package/dist/browser/index.d.cts.map +1 -1
  5. package/dist/browser/index.d.mts +1 -0
  6. package/dist/browser/index.d.mts.map +1 -1
  7. package/dist/browser/index.d.ts +1 -0
  8. package/dist/browser/index.d.ts.map +1 -1
  9. package/dist/browser/index.js +71 -0
  10. package/dist/browser/index.js.map +1 -1
  11. package/dist/browser/tags/config.cjs +33 -0
  12. package/dist/browser/tags/config.cjs.map +1 -0
  13. package/dist/browser/tags/config.d.cts +5 -0
  14. package/dist/browser/tags/config.d.cts.map +1 -0
  15. package/dist/browser/tags/config.d.mts +5 -0
  16. package/dist/browser/tags/config.d.mts.map +1 -0
  17. package/dist/browser/tags/config.d.ts +5 -0
  18. package/dist/browser/tags/config.d.ts.map +1 -0
  19. package/dist/browser/tags/config.js +12 -0
  20. package/dist/browser/tags/config.js.map +1 -0
  21. package/dist/browser/tags/filter.cjs +72 -0
  22. package/dist/browser/tags/filter.cjs.map +1 -0
  23. package/dist/browser/tags/filter.d.cts +2 -0
  24. package/dist/browser/tags/filter.d.cts.map +1 -0
  25. package/dist/browser/tags/filter.d.mts +2 -0
  26. package/dist/browser/tags/filter.d.mts.map +1 -0
  27. package/dist/browser/tags/filter.d.ts +2 -0
  28. package/dist/browser/tags/filter.d.ts.map +1 -0
  29. package/dist/browser/tags/filter.js +49 -0
  30. package/dist/browser/tags/filter.js.map +1 -0
  31. package/dist/browser/tags/index.cjs +88 -0
  32. package/dist/browser/tags/index.cjs.map +1 -0
  33. package/dist/browser/tags/index.d.cts +3 -0
  34. package/dist/browser/tags/index.d.cts.map +1 -0
  35. package/dist/browser/tags/index.d.mts +3 -0
  36. package/dist/browser/tags/index.d.mts.map +1 -0
  37. package/dist/browser/tags/index.d.ts +3 -0
  38. package/dist/browser/tags/index.d.ts.map +1 -0
  39. package/dist/browser/tags/index.js +73 -0
  40. package/dist/browser/tags/index.js.map +1 -0
  41. package/dist/browser/tags/regexps.cjs +44 -0
  42. package/dist/browser/tags/regexps.cjs.map +1 -0
  43. package/dist/browser/tags/regexps.d.cts +7 -0
  44. package/dist/browser/tags/regexps.d.cts.map +1 -0
  45. package/dist/browser/tags/regexps.d.mts +7 -0
  46. package/dist/browser/tags/regexps.d.mts.map +1 -0
  47. package/dist/browser/tags/regexps.d.ts +7 -0
  48. package/dist/browser/tags/regexps.d.ts.map +1 -0
  49. package/dist/browser/tags/regexps.js +21 -0
  50. package/dist/browser/tags/regexps.js.map +1 -0
  51. package/dist/browser/tags/utils.cjs +36 -0
  52. package/dist/browser/tags/utils.cjs.map +1 -0
  53. package/dist/browser/tags/utils.d.cts +2 -0
  54. package/dist/browser/tags/utils.d.cts.map +1 -0
  55. package/dist/browser/tags/utils.d.mts +2 -0
  56. package/dist/browser/tags/utils.d.mts.map +1 -0
  57. package/dist/browser/tags/utils.d.ts +2 -0
  58. package/dist/browser/tags/utils.d.ts.map +1 -0
  59. package/dist/browser/tags/utils.js +13 -0
  60. package/dist/browser/tags/utils.js.map +1 -0
  61. package/dist/node/index.cjs +65 -0
  62. package/dist/node/index.cjs.map +1 -1
  63. package/dist/node/index.d.cts +1 -0
  64. package/dist/node/index.d.cts.map +1 -1
  65. package/dist/node/index.d.mts +1 -0
  66. package/dist/node/index.d.mts.map +1 -1
  67. package/dist/node/index.d.ts +1 -0
  68. package/dist/node/index.d.ts.map +1 -1
  69. package/dist/node/index.js +71 -0
  70. package/dist/node/index.js.map +1 -1
  71. package/dist/node/tags/config.cjs +40 -0
  72. package/dist/node/tags/config.cjs.map +1 -0
  73. package/dist/node/tags/config.d.cts +5 -0
  74. package/dist/node/tags/config.d.cts.map +1 -0
  75. package/dist/node/tags/config.d.mts +5 -0
  76. package/dist/node/tags/config.d.mts.map +1 -0
  77. package/dist/node/tags/config.d.ts +5 -0
  78. package/dist/node/tags/config.d.ts.map +1 -0
  79. package/dist/node/tags/config.js +12 -0
  80. package/dist/node/tags/config.js.map +1 -0
  81. package/dist/node/tags/filter.cjs +76 -0
  82. package/dist/node/tags/filter.cjs.map +1 -0
  83. package/dist/node/tags/filter.d.cts +2 -0
  84. package/dist/node/tags/filter.d.cts.map +1 -0
  85. package/dist/node/tags/filter.d.mts +2 -0
  86. package/dist/node/tags/filter.d.mts.map +1 -0
  87. package/dist/node/tags/filter.d.ts +2 -0
  88. package/dist/node/tags/filter.d.ts.map +1 -0
  89. package/dist/node/tags/filter.js +49 -0
  90. package/dist/node/tags/filter.js.map +1 -0
  91. package/dist/node/tags/index.cjs +93 -0
  92. package/dist/node/tags/index.cjs.map +1 -0
  93. package/dist/node/tags/index.d.cts +3 -0
  94. package/dist/node/tags/index.d.cts.map +1 -0
  95. package/dist/node/tags/index.d.mts +3 -0
  96. package/dist/node/tags/index.d.mts.map +1 -0
  97. package/dist/node/tags/index.d.ts +3 -0
  98. package/dist/node/tags/index.d.ts.map +1 -0
  99. package/dist/node/tags/index.js +73 -0
  100. package/dist/node/tags/index.js.map +1 -0
  101. package/dist/node/tags/regexps.cjs +53 -0
  102. package/dist/node/tags/regexps.cjs.map +1 -0
  103. package/dist/node/tags/regexps.d.cts +7 -0
  104. package/dist/node/tags/regexps.d.cts.map +1 -0
  105. package/dist/node/tags/regexps.d.mts +7 -0
  106. package/dist/node/tags/regexps.d.mts.map +1 -0
  107. package/dist/node/tags/regexps.d.ts +7 -0
  108. package/dist/node/tags/regexps.d.ts.map +1 -0
  109. package/dist/node/tags/regexps.js +21 -0
  110. package/dist/node/tags/regexps.js.map +1 -0
  111. package/dist/node/tags/utils.cjs +40 -0
  112. package/dist/node/tags/utils.cjs.map +1 -0
  113. package/dist/node/tags/utils.d.cts +2 -0
  114. package/dist/node/tags/utils.d.cts.map +1 -0
  115. package/dist/node/tags/utils.d.mts +2 -0
  116. package/dist/node/tags/utils.d.mts.map +1 -0
  117. package/dist/node/tags/utils.d.ts +2 -0
  118. package/dist/node/tags/utils.d.ts.map +1 -0
  119. package/dist/node/tags/utils.js +13 -0
  120. package/dist/node/tags/utils.js.map +1 -0
  121. package/package.json +6 -3
  122. package/src/index.ts +1 -0
  123. package/src/tags/config.ts +7 -0
  124. package/src/tags/filter.ts +46 -0
  125. package/src/tags/index.ts +25 -0
  126. package/src/tags/regexps.ts +17 -0
  127. package/src/tags/utils.ts +8 -0
@@ -20,8 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ args: () => args,
23
24
  describeIf: () => describeIf,
24
25
  itIf: () => itIf,
26
+ tags: () => tags,
25
27
  testIf: () => testIf
26
28
  });
27
29
  module.exports = __toCommonJS(src_exports);
@@ -32,6 +34,67 @@ var describeIf = (expr) => expr ? describe : describe.skip;
32
34
  // src/itIf.ts
33
35
  var itIf = (expr) => expr ? it : it.skip;
34
36
 
37
+ // src/tags/config.ts
38
+ var NOT_SYMBOL = "!";
39
+ var AND_SYMBOL = "&&";
40
+ var OR_SYMBOL = "||";
41
+
42
+ // src/tags/regexps.ts
43
+ var escape = (str) => str.split("").map((symbol) => `\\${symbol}`).join("");
44
+ var AND_REGX = new RegExp(`\\s*${escape(AND_SYMBOL)}\\s*`);
45
+ var OR_REGX = new RegExp(`\\s*${escape(OR_SYMBOL)}\\s*`);
46
+ var PLAIN_REGX = new RegExp("\\s+");
47
+ var BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`);
48
+ var GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`);
49
+
50
+ // src/tags/filter.ts
51
+ var matchFilter = (strParam = "") => (tags2) => {
52
+ const str = strParam.trim();
53
+ if (typeof tags2 === "string") {
54
+ tags2 = [tags2];
55
+ }
56
+ if (str.includes(OR_SYMBOL)) {
57
+ const include2 = goodTags(str.split(OR_REGX));
58
+ const exclude2 = badTags(str.split(OR_REGX));
59
+ if (exclude2.length === 0) {
60
+ return include2.length === 0 || include2.some((s) => tags2.includes(s));
61
+ }
62
+ if (include2.length === 0 && exclude2.length !== 0) {
63
+ return exclude2.some((s) => !tags2.includes(s));
64
+ }
65
+ return include2.length === 0 || include2.some((s) => tags2.includes(s)) || exclude2.some((s) => !tags2.includes(s));
66
+ }
67
+ if (str.includes(AND_SYMBOL)) {
68
+ const include2 = goodTags(str.split(AND_REGX));
69
+ const exclude2 = badTags(str.split(AND_REGX));
70
+ return (include2.length === 0 || include2.every((s) => tags2.includes(s))) && !exclude2.some((s) => tags2.includes(s));
71
+ }
72
+ const include = goodTags(str.split(PLAIN_REGX));
73
+ const exclude = badTags(str.split(PLAIN_REGX));
74
+ return (include.length === 0 || include.some((s) => tags2.includes(s))) && !exclude.some((s) => tags2.includes(s));
75
+ };
76
+ var goodTags = (arr) => {
77
+ return arr.filter((s) => s.match(GOOD_REGX));
78
+ };
79
+ var badTags = (arr) => {
80
+ return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ""));
81
+ };
82
+
83
+ // src/tags/index.ts
84
+ var argv = require("minimist")(process.argv.slice(2));
85
+ var args = argv(process.argv.slice(2));
86
+ function tags(...tagLabels) {
87
+ const filter = matchFilter(args.tags);
88
+ const thisGlobal = global;
89
+ const chain = {};
90
+ const filterMatch = filter(tagLabels);
91
+ chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
92
+ chain.test.only = thisGlobal.test.only;
93
+ chain.test.skip = thisGlobal.test.skip;
94
+ chain.xtest = thisGlobal.xtest;
95
+ return chain;
96
+ }
97
+
35
98
  // src/testIf.ts
36
99
  var testIf = (expr) => expr ? test : test.skip;
37
100
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts"],"sourcesContent":["export * from './describeIf'\nexport * from './itIf'\nexport * from './testIf'\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/describeIf.ts","../../src/itIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts","../../src/testIf.ts"],"sourcesContent":["export * from './describeIf'\nexport * from './itIf'\nexport * from './tags'\nexport * from './testIf'\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst argv = require('minimist')(process.argv.slice(2))\n\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport const args = argv(process.argv.slice(2))\n\nexport function tags(...tagLabels: string[]) {\n const filter = matchFilter(args.tags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n\n return chain\n}\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACLrD,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OAAO,MAAM;AAEpC,IAAM,WAAW,IAAI,OAAO,IAAI,OAAO,UAAU,CAAC,KAAK;AAEvD,IAAM,YAAY,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,MAAM;;;ACP3D,IAAM,c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CAAC,CAAC;AACjH;AAEF,IAAM,WAAW,CAAC,QAAkB;AAClC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C;AAEA,IAAM,UAAU,CAAC,QAAkB;AACjC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC;AAClF;;;AC5CA,IAAM,OAAO,QAAQ,UAAU,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC;AAM/C,IAAM,OAAO,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC;AAEvC,SAAS,QAAQ,WAAqB;AAC3C,QAAM,SAAS,YAAY,KAAK,IAAI;AACpC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAEpC,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AAEzB,SAAO;AACT;;;ACnBO,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;","names":["tags","include","exclude"]}
@@ -1,4 +1,5 @@
1
1
  export * from './describeIf';
2
2
  export * from './itIf';
3
+ export * from './tags';
3
4
  export * from './testIf';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from './describeIf';
2
2
  export * from './itIf';
3
+ export * from './tags';
3
4
  export * from './testIf';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export * from './describeIf';
2
2
  export * from './itIf';
3
+ export * from './tags';
3
4
  export * from './testIf';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
@@ -1,14 +1,85 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
1
9
  // src/describeIf.ts
2
10
  var describeIf = (expr) => expr ? describe : describe.skip;
3
11
 
4
12
  // src/itIf.ts
5
13
  var itIf = (expr) => expr ? it : it.skip;
6
14
 
15
+ // src/tags/config.ts
16
+ var NOT_SYMBOL = "!";
17
+ var AND_SYMBOL = "&&";
18
+ var OR_SYMBOL = "||";
19
+
20
+ // src/tags/regexps.ts
21
+ var escape = (str) => str.split("").map((symbol) => `\\${symbol}`).join("");
22
+ var AND_REGX = new RegExp(`\\s*${escape(AND_SYMBOL)}\\s*`);
23
+ var OR_REGX = new RegExp(`\\s*${escape(OR_SYMBOL)}\\s*`);
24
+ var PLAIN_REGX = new RegExp("\\s+");
25
+ var BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`);
26
+ var GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`);
27
+
28
+ // src/tags/filter.ts
29
+ var matchFilter = (strParam = "") => (tags2) => {
30
+ const str = strParam.trim();
31
+ if (typeof tags2 === "string") {
32
+ tags2 = [tags2];
33
+ }
34
+ if (str.includes(OR_SYMBOL)) {
35
+ const include2 = goodTags(str.split(OR_REGX));
36
+ const exclude2 = badTags(str.split(OR_REGX));
37
+ if (exclude2.length === 0) {
38
+ return include2.length === 0 || include2.some((s) => tags2.includes(s));
39
+ }
40
+ if (include2.length === 0 && exclude2.length !== 0) {
41
+ return exclude2.some((s) => !tags2.includes(s));
42
+ }
43
+ return include2.length === 0 || include2.some((s) => tags2.includes(s)) || exclude2.some((s) => !tags2.includes(s));
44
+ }
45
+ if (str.includes(AND_SYMBOL)) {
46
+ const include2 = goodTags(str.split(AND_REGX));
47
+ const exclude2 = badTags(str.split(AND_REGX));
48
+ return (include2.length === 0 || include2.every((s) => tags2.includes(s))) && !exclude2.some((s) => tags2.includes(s));
49
+ }
50
+ const include = goodTags(str.split(PLAIN_REGX));
51
+ const exclude = badTags(str.split(PLAIN_REGX));
52
+ return (include.length === 0 || include.some((s) => tags2.includes(s))) && !exclude.some((s) => tags2.includes(s));
53
+ };
54
+ var goodTags = (arr) => {
55
+ return arr.filter((s) => s.match(GOOD_REGX));
56
+ };
57
+ var badTags = (arr) => {
58
+ return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ""));
59
+ };
60
+
61
+ // src/tags/index.ts
62
+ var argv = __require("minimist")(process.argv.slice(2));
63
+ var args = argv(process.argv.slice(2));
64
+ function tags(...tagLabels) {
65
+ const filter = matchFilter(args.tags);
66
+ const thisGlobal = global;
67
+ const chain = {};
68
+ const filterMatch = filter(tagLabels);
69
+ chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
70
+ chain.test.only = thisGlobal.test.only;
71
+ chain.test.skip = thisGlobal.test.skip;
72
+ chain.xtest = thisGlobal.xtest;
73
+ return chain;
74
+ }
75
+
7
76
  // src/testIf.ts
8
77
  var testIf = (expr) => expr ? test : test.skip;
9
78
  export {
79
+ args,
10
80
  describeIf,
11
81
  itIf,
82
+ tags,
12
83
  testIf
13
84
  };
14
85
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n"],"mappings":";AAKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;","names":[]}
1
+ {"version":3,"sources":["../../src/describeIf.ts","../../src/itIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts","../../src/testIf.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst argv = require('minimist')(process.argv.slice(2))\n\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport const args = argv(process.argv.slice(2))\n\nexport function tags(...tagLabels: string[]) {\n const filter = matchFilter(args.tags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n\n return chain\n}\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n"],"mappings":";;;;;;;;;AAKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACLrD,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAA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;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/tags/config.ts
21
+ var config_exports = {};
22
+ __export(config_exports, {
23
+ AND_SYMBOL: () => AND_SYMBOL,
24
+ NOT_SYMBOL: () => NOT_SYMBOL,
25
+ OR_SYMBOL: () => OR_SYMBOL,
26
+ RESERVED_COMMANDS: () => RESERVED_COMMANDS
27
+ });
28
+ module.exports = __toCommonJS(config_exports);
29
+ var NOT_SYMBOL = "!";
30
+ var AND_SYMBOL = "&&";
31
+ var OR_SYMBOL = "||";
32
+ var RESERVED_COMMANDS = ["--tags"];
33
+ //# sourceMappingURL=config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/tags/config.ts"],"sourcesContent":["export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;AAElB,IAAM,oBAAoB,CAAC,QAAQ;","names":[]}
@@ -0,0 +1,5 @@
1
+ export declare const NOT_SYMBOL = "!";
2
+ export declare const AND_SYMBOL = "&&";
3
+ export declare const OR_SYMBOL = "||";
4
+ export declare const RESERVED_COMMANDS: string[];
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tags/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,MAAM,CAAA;AAE7B,eAAO,MAAM,UAAU,OAAO,CAAA;AAE9B,eAAO,MAAM,SAAS,OAAO,CAAA;AAE7B,eAAO,MAAM,iBAAiB,UAAa,CAAA"}
@@ -0,0 +1,5 @@
1
+ export declare const NOT_SYMBOL = "!";
2
+ export declare const AND_SYMBOL = "&&";
3
+ export declare const OR_SYMBOL = "||";
4
+ export declare const RESERVED_COMMANDS: string[];
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tags/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,MAAM,CAAA;AAE7B,eAAO,MAAM,UAAU,OAAO,CAAA;AAE9B,eAAO,MAAM,SAAS,OAAO,CAAA;AAE7B,eAAO,MAAM,iBAAiB,UAAa,CAAA"}
@@ -0,0 +1,5 @@
1
+ export declare const NOT_SYMBOL = "!";
2
+ export declare const AND_SYMBOL = "&&";
3
+ export declare const OR_SYMBOL = "||";
4
+ export declare const RESERVED_COMMANDS: string[];
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/tags/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,MAAM,CAAA;AAE7B,eAAO,MAAM,UAAU,OAAO,CAAA;AAE9B,eAAO,MAAM,SAAS,OAAO,CAAA;AAE7B,eAAO,MAAM,iBAAiB,UAAa,CAAA"}
@@ -0,0 +1,12 @@
1
+ // src/tags/config.ts
2
+ var NOT_SYMBOL = "!";
3
+ var AND_SYMBOL = "&&";
4
+ var OR_SYMBOL = "||";
5
+ var RESERVED_COMMANDS = ["--tags"];
6
+ export {
7
+ AND_SYMBOL,
8
+ NOT_SYMBOL,
9
+ OR_SYMBOL,
10
+ RESERVED_COMMANDS
11
+ };
12
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/tags/config.ts"],"sourcesContent":["export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n"],"mappings":";AAAO,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;AAElB,IAAM,oBAAoB,CAAC,QAAQ;","names":[]}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/tags/filter.ts
21
+ var filter_exports = {};
22
+ __export(filter_exports, {
23
+ matchFilter: () => matchFilter
24
+ });
25
+ module.exports = __toCommonJS(filter_exports);
26
+
27
+ // src/tags/config.ts
28
+ var NOT_SYMBOL = "!";
29
+ var AND_SYMBOL = "&&";
30
+ var OR_SYMBOL = "||";
31
+
32
+ // src/tags/regexps.ts
33
+ var escape = (str) => str.split("").map((symbol) => `\\${symbol}`).join("");
34
+ var AND_REGX = new RegExp(`\\s*${escape(AND_SYMBOL)}\\s*`);
35
+ var OR_REGX = new RegExp(`\\s*${escape(OR_SYMBOL)}\\s*`);
36
+ var PLAIN_REGX = new RegExp("\\s+");
37
+ var BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`);
38
+ var GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`);
39
+
40
+ // src/tags/filter.ts
41
+ var matchFilter = (strParam = "") => (tags) => {
42
+ const str = strParam.trim();
43
+ if (typeof tags === "string") {
44
+ tags = [tags];
45
+ }
46
+ if (str.includes(OR_SYMBOL)) {
47
+ const include2 = goodTags(str.split(OR_REGX));
48
+ const exclude2 = badTags(str.split(OR_REGX));
49
+ if (exclude2.length === 0) {
50
+ return include2.length === 0 || include2.some((s) => tags.includes(s));
51
+ }
52
+ if (include2.length === 0 && exclude2.length !== 0) {
53
+ return exclude2.some((s) => !tags.includes(s));
54
+ }
55
+ return include2.length === 0 || include2.some((s) => tags.includes(s)) || exclude2.some((s) => !tags.includes(s));
56
+ }
57
+ if (str.includes(AND_SYMBOL)) {
58
+ const include2 = goodTags(str.split(AND_REGX));
59
+ const exclude2 = badTags(str.split(AND_REGX));
60
+ return (include2.length === 0 || include2.every((s) => tags.includes(s))) && !exclude2.some((s) => tags.includes(s));
61
+ }
62
+ const include = goodTags(str.split(PLAIN_REGX));
63
+ const exclude = badTags(str.split(PLAIN_REGX));
64
+ return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s));
65
+ };
66
+ var goodTags = (arr) => {
67
+ return arr.filter((s) => s.match(GOOD_REGX));
68
+ };
69
+ var badTags = (arr) => {
70
+ return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ""));
71
+ };
72
+ //# sourceMappingURL=filter.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/tags/filter.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts"],"sourcesContent":["import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\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AAA,IAC9C;AACA,WAAOD,SAAQ,WAAW,KAAKA,SAAQ,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,KAAKC,SAAQ,KAAK,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC;AAAA,EAC/G;AACA,MAAI,IAAI,SAAS,UAAU,GAAG;AAC5B,UAAMD,WAAU,SAAS,IAAI,MAAM,QAAQ,CAAC;AAC5C,UAAMC,WAAU,QAAQ,IAAI,MAAM,QAAQ,CAAC;AAE3C,YAAQD,SAAQ,WAAW,KAAKA,SAAQ,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAACC,SAAQ,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AAAA,EAClH;AACA,QAAM,UAAU,SAAS,IAAI,MAAM,UAAU,CAAC;AAC9C,QAAM,UAAU,QAAQ,IAAI,MAAM,UAAU,CAAC;AAE7C,UAAQ,QAAQ,WAAW,KAAK,QAAQ,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AACjH;AAEF,IAAM,WAAW,CAAC,QAAkB;AAClC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C;AAEA,IAAM,UAAU,CAAC,QAAkB;AACjC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC;AAClF;","names":["include","exclude"]}
@@ -0,0 +1,2 @@
1
+ export declare const matchFilter: (strParam?: string) => (tags: string[]) => boolean;
2
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/tags/filter.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,gCAEf,MAAM,EAAE,YA0Bd,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const matchFilter: (strParam?: string) => (tags: string[]) => boolean;
2
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/tags/filter.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,gCAEf,MAAM,EAAE,YA0Bd,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const matchFilter: (strParam?: string) => (tags: string[]) => boolean;
2
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/tags/filter.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,gCAEf,MAAM,EAAE,YA0Bd,CAAA"}
@@ -0,0 +1,49 @@
1
+ // src/tags/config.ts
2
+ var NOT_SYMBOL = "!";
3
+ var AND_SYMBOL = "&&";
4
+ var OR_SYMBOL = "||";
5
+
6
+ // src/tags/regexps.ts
7
+ var escape = (str) => str.split("").map((symbol) => `\\${symbol}`).join("");
8
+ var AND_REGX = new RegExp(`\\s*${escape(AND_SYMBOL)}\\s*`);
9
+ var OR_REGX = new RegExp(`\\s*${escape(OR_SYMBOL)}\\s*`);
10
+ var PLAIN_REGX = new RegExp("\\s+");
11
+ var BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`);
12
+ var GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`);
13
+
14
+ // src/tags/filter.ts
15
+ var matchFilter = (strParam = "") => (tags) => {
16
+ const str = strParam.trim();
17
+ if (typeof tags === "string") {
18
+ tags = [tags];
19
+ }
20
+ if (str.includes(OR_SYMBOL)) {
21
+ const include2 = goodTags(str.split(OR_REGX));
22
+ const exclude2 = badTags(str.split(OR_REGX));
23
+ if (exclude2.length === 0) {
24
+ return include2.length === 0 || include2.some((s) => tags.includes(s));
25
+ }
26
+ if (include2.length === 0 && exclude2.length !== 0) {
27
+ return exclude2.some((s) => !tags.includes(s));
28
+ }
29
+ return include2.length === 0 || include2.some((s) => tags.includes(s)) || exclude2.some((s) => !tags.includes(s));
30
+ }
31
+ if (str.includes(AND_SYMBOL)) {
32
+ const include2 = goodTags(str.split(AND_REGX));
33
+ const exclude2 = badTags(str.split(AND_REGX));
34
+ return (include2.length === 0 || include2.every((s) => tags.includes(s))) && !exclude2.some((s) => tags.includes(s));
35
+ }
36
+ const include = goodTags(str.split(PLAIN_REGX));
37
+ const exclude = badTags(str.split(PLAIN_REGX));
38
+ return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s));
39
+ };
40
+ var goodTags = (arr) => {
41
+ return arr.filter((s) => s.match(GOOD_REGX));
42
+ };
43
+ var badTags = (arr) => {
44
+ return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ""));
45
+ };
46
+ export {
47
+ matchFilter
48
+ };
49
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts"],"sourcesContent":["export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n"],"mappings":";AAAO,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OA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;AAE7C,UAAQ,QAAQ,WAAW,KAAK,QAAQ,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AACjH;AAEF,IAAM,WAAW,CAAC,QAAkB;AAClC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C;AAEA,IAAM,UAAU,CAAC,QAAkB;AACjC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC;AAClF;","names":["include","exclude"]}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/tags/index.ts
21
+ var tags_exports = {};
22
+ __export(tags_exports, {
23
+ args: () => args,
24
+ tags: () => tags
25
+ });
26
+ module.exports = __toCommonJS(tags_exports);
27
+
28
+ // src/tags/config.ts
29
+ var NOT_SYMBOL = "!";
30
+ var AND_SYMBOL = "&&";
31
+ var OR_SYMBOL = "||";
32
+
33
+ // src/tags/regexps.ts
34
+ var escape = (str) => str.split("").map((symbol) => `\\${symbol}`).join("");
35
+ var AND_REGX = new RegExp(`\\s*${escape(AND_SYMBOL)}\\s*`);
36
+ var OR_REGX = new RegExp(`\\s*${escape(OR_SYMBOL)}\\s*`);
37
+ var PLAIN_REGX = new RegExp("\\s+");
38
+ var BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`);
39
+ var GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`);
40
+
41
+ // src/tags/filter.ts
42
+ var matchFilter = (strParam = "") => (tags2) => {
43
+ const str = strParam.trim();
44
+ if (typeof tags2 === "string") {
45
+ tags2 = [tags2];
46
+ }
47
+ if (str.includes(OR_SYMBOL)) {
48
+ const include2 = goodTags(str.split(OR_REGX));
49
+ const exclude2 = badTags(str.split(OR_REGX));
50
+ if (exclude2.length === 0) {
51
+ return include2.length === 0 || include2.some((s) => tags2.includes(s));
52
+ }
53
+ if (include2.length === 0 && exclude2.length !== 0) {
54
+ return exclude2.some((s) => !tags2.includes(s));
55
+ }
56
+ return include2.length === 0 || include2.some((s) => tags2.includes(s)) || exclude2.some((s) => !tags2.includes(s));
57
+ }
58
+ if (str.includes(AND_SYMBOL)) {
59
+ const include2 = goodTags(str.split(AND_REGX));
60
+ const exclude2 = badTags(str.split(AND_REGX));
61
+ return (include2.length === 0 || include2.every((s) => tags2.includes(s))) && !exclude2.some((s) => tags2.includes(s));
62
+ }
63
+ const include = goodTags(str.split(PLAIN_REGX));
64
+ const exclude = badTags(str.split(PLAIN_REGX));
65
+ return (include.length === 0 || include.some((s) => tags2.includes(s))) && !exclude.some((s) => tags2.includes(s));
66
+ };
67
+ var goodTags = (arr) => {
68
+ return arr.filter((s) => s.match(GOOD_REGX));
69
+ };
70
+ var badTags = (arr) => {
71
+ return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ""));
72
+ };
73
+
74
+ // src/tags/index.ts
75
+ var argv = require("minimist")(process.argv.slice(2));
76
+ var args = argv(process.argv.slice(2));
77
+ function tags(...tagLabels) {
78
+ const filter = matchFilter(args.tags);
79
+ const thisGlobal = global;
80
+ const chain = {};
81
+ const filterMatch = filter(tagLabels);
82
+ chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
83
+ chain.test.only = thisGlobal.test.only;
84
+ chain.test.skip = thisGlobal.test.skip;
85
+ chain.xtest = thisGlobal.xtest;
86
+ return chain;
87
+ }
88
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/tags/index.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst argv = require('minimist')(process.argv.slice(2))\n\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport const args = argv(process.argv.slice(2))\n\nexport function tags(...tagLabels: string[]) {\n const filter = matchFilter(args.tags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n\n return chain\n}\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AA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,SAAQ,KAAK,CAAC,MAAMF,MAAK,SAAS,CAAC,CAAC;AAAA,EAClH;AACA,QAAM,UAAU,SAAS,IAAI,MAAM,UAAU,CAAC;AAC9C,QAAM,UAAU,QAAQ,IAAI,MAAM,UAAU,CAAC;AAE7C,UAAQ,QAAQ,WAAW,KAAK,QAAQ,KAAK,CAAC,MAAMA,MAAK,SAAS,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,MAAMA,MAAK,SAAS,CAAC,CAAC;AACjH;AAEF,IAAM,WAAW,CAAC,QAAkB;AAClC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C;AAEA,IAAM,UAAU,CAAC,QAAkB;AACjC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC;AAClF;;;AH5CA,IAAM,OAAO,QAAQ,UAAU,EAAE,QAAQ,KAAK,MAAM,CAAC,CAAC;AAM/C,IAAM,OAAO,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC;AAEvC,SAAS,QAAQ,WAAqB;AAC3C,QAAM,SAAS,YAAY,KAAK,IAAI;AACpC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAEpC,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AAEzB,SAAO;AACT;","names":["tags","include","exclude"]}
@@ -0,0 +1,3 @@
1
+ export declare const args: any;
2
+ export declare function tags(...tagLabels: string[]): Record<string, any>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI,KAA8B,CAAA;AAE/C,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBAe1C"}
@@ -0,0 +1,3 @@
1
+ export declare const args: any;
2
+ export declare function tags(...tagLabels: string[]): Record<string, any>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI,KAA8B,CAAA;AAE/C,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBAe1C"}
@@ -0,0 +1,3 @@
1
+ export declare const args: any;
2
+ export declare function tags(...tagLabels: string[]): Record<string, any>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,IAAI,KAA8B,CAAA;AAE/C,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBAe1C"}