@guru-ai-product/ai-product-kit 0.2.251113194913 → 0.2.251113205658

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 (129) hide show
  1. package/mcp/skills/aipk_init_project/template/AGENTS_TEMPLATE.md +1 -1
  2. package/mcp/src/server.js +1 -1
  3. package/package.json +1 -1
  4. package/skills/aipk_design/GURU_AI.md +119 -7
  5. package/skills/aipk_design/SKILL.md +8 -7
  6. package/skills/aipk_design/{auto_panel_splitter → update-requirements-from-design}/SKILL.md +18 -16
  7. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/.package-lock.json +113 -0
  8. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/LICENSE.md +82 -0
  9. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/README.md +15 -0
  10. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/color.cjs +1594 -0
  11. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/index.cjs +1 -0
  12. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/colour/package.json +45 -0
  13. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/LICENSE +191 -0
  14. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/README.md +18 -0
  15. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/lib/sharp-darwin-arm64.node +0 -0
  16. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-darwin-arm64/package.json +40 -0
  17. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/README.md +46 -0
  18. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/lib/glib-2.0/include/glibconfig.h +220 -0
  19. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/lib/index.js +1 -0
  20. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/lib/libvips-cpp.8.17.3.dylib +0 -0
  21. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/package.json +36 -0
  22. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/@img/sharp-libvips-darwin-arm64/versions.json +30 -0
  23. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/LICENSE +201 -0
  24. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/README.md +163 -0
  25. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/index.d.ts +14 -0
  26. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/detect-libc.js +313 -0
  27. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/elf.js +39 -0
  28. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/filesystem.js +51 -0
  29. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/lib/process.js +24 -0
  30. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/detect-libc/package.json +44 -0
  31. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/LICENSE +15 -0
  32. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/README.md +664 -0
  33. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/bin/semver.js +191 -0
  34. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/comparator.js +143 -0
  35. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/index.js +7 -0
  36. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/range.js +557 -0
  37. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/classes/semver.js +333 -0
  38. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/clean.js +8 -0
  39. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/cmp.js +54 -0
  40. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/coerce.js +62 -0
  41. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/compare-build.js +9 -0
  42. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/compare-loose.js +5 -0
  43. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/compare.js +7 -0
  44. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/diff.js +60 -0
  45. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/eq.js +5 -0
  46. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/gt.js +5 -0
  47. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/gte.js +5 -0
  48. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/inc.js +21 -0
  49. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/lt.js +5 -0
  50. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/lte.js +5 -0
  51. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/major.js +5 -0
  52. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/minor.js +5 -0
  53. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/neq.js +5 -0
  54. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/parse.js +18 -0
  55. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/patch.js +5 -0
  56. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/prerelease.js +8 -0
  57. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/rcompare.js +5 -0
  58. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/rsort.js +5 -0
  59. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/satisfies.js +12 -0
  60. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/sort.js +5 -0
  61. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/functions/valid.js +8 -0
  62. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/index.js +91 -0
  63. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/constants.js +37 -0
  64. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/debug.js +11 -0
  65. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/identifiers.js +29 -0
  66. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/lrucache.js +42 -0
  67. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/parse-options.js +17 -0
  68. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/internal/re.js +223 -0
  69. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/package.json +78 -0
  70. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/preload.js +4 -0
  71. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/range.bnf +16 -0
  72. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/gtr.js +6 -0
  73. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/intersects.js +9 -0
  74. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/ltr.js +6 -0
  75. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/max-satisfying.js +27 -0
  76. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/min-satisfying.js +26 -0
  77. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/min-version.js +63 -0
  78. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/outside.js +82 -0
  79. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/simplify.js +49 -0
  80. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/subset.js +249 -0
  81. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/to-comparators.js +10 -0
  82. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/semver/ranges/valid.js +13 -0
  83. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/LICENSE +191 -0
  84. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/README.md +118 -0
  85. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/install/build.js +38 -0
  86. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/install/check.js +14 -0
  87. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/channel.js +177 -0
  88. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/colour.js +195 -0
  89. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/composite.js +212 -0
  90. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/constructor.js +499 -0
  91. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/index.d.ts +1971 -0
  92. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/index.js +16 -0
  93. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/input.js +809 -0
  94. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/is.js +143 -0
  95. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/libvips.js +207 -0
  96. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/operation.js +1016 -0
  97. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/output.js +1666 -0
  98. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/resize.js +595 -0
  99. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/sharp.js +121 -0
  100. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/lib/utility.js +291 -0
  101. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/package.json +202 -0
  102. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/binding.gyp +298 -0
  103. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/common.cc +1130 -0
  104. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/common.h +402 -0
  105. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/metadata.cc +346 -0
  106. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/metadata.h +90 -0
  107. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/operations.cc +499 -0
  108. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/operations.h +137 -0
  109. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/pipeline.cc +1814 -0
  110. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/pipeline.h +408 -0
  111. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/sharp.cc +43 -0
  112. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/stats.cc +186 -0
  113. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/stats.h +62 -0
  114. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/utilities.cc +288 -0
  115. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/node_modules/sharp/src/utilities.h +22 -0
  116. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/package-lock.json +529 -0
  117. package/skills/aipk_design/update-requirements-from-design/scripts/sharp-runtime/package.json +5 -0
  118. package/skills/aipk_design/{auto_panel_splitter/scripts/auto_panel_splitter_bundle.js → update-requirements-from-design/scripts/split-design-boards-bundle.js} +10 -1
  119. package/skills/aipk_design/{auto_panel_splitter/scripts/panel_asset_mapper_bundle.js → update-requirements-from-design/scripts/sync-design-to-requirements-bundle.js} +10 -1
  120. package/skills/aipk_development/GURU_AI.md +1 -1
  121. package/skills/aipk_init_project/GURU_AI.md +2 -2
  122. package/skills/aipk_init_project/template/AGENTS_TEMPLATE.md +1 -1
  123. package/skills/aipk_operations/GURU_AI.md +1 -1
  124. package/skills/aipk_requirements/GURU_AI.md +2 -2
  125. package/skills/aipk_requirements/documentation/SKILL.md +23 -1
  126. package/skills/aipk_skill_generate/GURU_AI.md +1 -1
  127. package/skills/aipk_tool_prompts/GURU_AI.md +1 -1
  128. /package/skills/aipk_design/{auto_panel_splitter → update-requirements-from-design}/scripts/auto_panel_splitter.js +0 -0
  129. /package/skills/aipk_design/{auto_panel_splitter → update-requirements-from-design}/scripts/panel_asset_mapper.js +0 -0
@@ -0,0 +1,63 @@
1
+ 'use strict'
2
+
3
+ const SemVer = require('../classes/semver')
4
+ const Range = require('../classes/range')
5
+ const gt = require('../functions/gt')
6
+
7
+ const minVersion = (range, loose) => {
8
+ range = new Range(range, loose)
9
+
10
+ let minver = new SemVer('0.0.0')
11
+ if (range.test(minver)) {
12
+ return minver
13
+ }
14
+
15
+ minver = new SemVer('0.0.0-0')
16
+ if (range.test(minver)) {
17
+ return minver
18
+ }
19
+
20
+ minver = null
21
+ for (let i = 0; i < range.set.length; ++i) {
22
+ const comparators = range.set[i]
23
+
24
+ let setMin = null
25
+ comparators.forEach((comparator) => {
26
+ // Clone to avoid manipulating the comparator's semver object.
27
+ const compver = new SemVer(comparator.semver.version)
28
+ switch (comparator.operator) {
29
+ case '>':
30
+ if (compver.prerelease.length === 0) {
31
+ compver.patch++
32
+ } else {
33
+ compver.prerelease.push(0)
34
+ }
35
+ compver.raw = compver.format()
36
+ /* fallthrough */
37
+ case '':
38
+ case '>=':
39
+ if (!setMin || gt(compver, setMin)) {
40
+ setMin = compver
41
+ }
42
+ break
43
+ case '<':
44
+ case '<=':
45
+ /* Ignore maximum versions */
46
+ break
47
+ /* istanbul ignore next */
48
+ default:
49
+ throw new Error(`Unexpected operation: ${comparator.operator}`)
50
+ }
51
+ })
52
+ if (setMin && (!minver || gt(minver, setMin))) {
53
+ minver = setMin
54
+ }
55
+ }
56
+
57
+ if (minver && range.test(minver)) {
58
+ return minver
59
+ }
60
+
61
+ return null
62
+ }
63
+ module.exports = minVersion
@@ -0,0 +1,82 @@
1
+ 'use strict'
2
+
3
+ const SemVer = require('../classes/semver')
4
+ const Comparator = require('../classes/comparator')
5
+ const { ANY } = Comparator
6
+ const Range = require('../classes/range')
7
+ const satisfies = require('../functions/satisfies')
8
+ const gt = require('../functions/gt')
9
+ const lt = require('../functions/lt')
10
+ const lte = require('../functions/lte')
11
+ const gte = require('../functions/gte')
12
+
13
+ const outside = (version, range, hilo, options) => {
14
+ version = new SemVer(version, options)
15
+ range = new Range(range, options)
16
+
17
+ let gtfn, ltefn, ltfn, comp, ecomp
18
+ switch (hilo) {
19
+ case '>':
20
+ gtfn = gt
21
+ ltefn = lte
22
+ ltfn = lt
23
+ comp = '>'
24
+ ecomp = '>='
25
+ break
26
+ case '<':
27
+ gtfn = lt
28
+ ltefn = gte
29
+ ltfn = gt
30
+ comp = '<'
31
+ ecomp = '<='
32
+ break
33
+ default:
34
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
35
+ }
36
+
37
+ // If it satisfies the range it is not outside
38
+ if (satisfies(version, range, options)) {
39
+ return false
40
+ }
41
+
42
+ // From now on, variable terms are as if we're in "gtr" mode.
43
+ // but note that everything is flipped for the "ltr" function.
44
+
45
+ for (let i = 0; i < range.set.length; ++i) {
46
+ const comparators = range.set[i]
47
+
48
+ let high = null
49
+ let low = null
50
+
51
+ comparators.forEach((comparator) => {
52
+ if (comparator.semver === ANY) {
53
+ comparator = new Comparator('>=0.0.0')
54
+ }
55
+ high = high || comparator
56
+ low = low || comparator
57
+ if (gtfn(comparator.semver, high.semver, options)) {
58
+ high = comparator
59
+ } else if (ltfn(comparator.semver, low.semver, options)) {
60
+ low = comparator
61
+ }
62
+ })
63
+
64
+ // If the edge version comparator has a operator then our version
65
+ // isn't outside it
66
+ if (high.operator === comp || high.operator === ecomp) {
67
+ return false
68
+ }
69
+
70
+ // If the lowest version comparator has an operator and our version
71
+ // is less than it then it isn't higher than the range
72
+ if ((!low.operator || low.operator === comp) &&
73
+ ltefn(version, low.semver)) {
74
+ return false
75
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
76
+ return false
77
+ }
78
+ }
79
+ return true
80
+ }
81
+
82
+ module.exports = outside
@@ -0,0 +1,49 @@
1
+ 'use strict'
2
+
3
+ // given a set of versions and a range, create a "simplified" range
4
+ // that includes the same versions that the original range does
5
+ // If the original range is shorter than the simplified one, return that.
6
+ const satisfies = require('../functions/satisfies.js')
7
+ const compare = require('../functions/compare.js')
8
+ module.exports = (versions, range, options) => {
9
+ const set = []
10
+ let first = null
11
+ let prev = null
12
+ const v = versions.sort((a, b) => compare(a, b, options))
13
+ for (const version of v) {
14
+ const included = satisfies(version, range, options)
15
+ if (included) {
16
+ prev = version
17
+ if (!first) {
18
+ first = version
19
+ }
20
+ } else {
21
+ if (prev) {
22
+ set.push([first, prev])
23
+ }
24
+ prev = null
25
+ first = null
26
+ }
27
+ }
28
+ if (first) {
29
+ set.push([first, null])
30
+ }
31
+
32
+ const ranges = []
33
+ for (const [min, max] of set) {
34
+ if (min === max) {
35
+ ranges.push(min)
36
+ } else if (!max && min === v[0]) {
37
+ ranges.push('*')
38
+ } else if (!max) {
39
+ ranges.push(`>=${min}`)
40
+ } else if (min === v[0]) {
41
+ ranges.push(`<=${max}`)
42
+ } else {
43
+ ranges.push(`${min} - ${max}`)
44
+ }
45
+ }
46
+ const simplified = ranges.join(' || ')
47
+ const original = typeof range.raw === 'string' ? range.raw : String(range)
48
+ return simplified.length < original.length ? simplified : range
49
+ }
@@ -0,0 +1,249 @@
1
+ 'use strict'
2
+
3
+ const Range = require('../classes/range.js')
4
+ const Comparator = require('../classes/comparator.js')
5
+ const { ANY } = Comparator
6
+ const satisfies = require('../functions/satisfies.js')
7
+ const compare = require('../functions/compare.js')
8
+
9
+ // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
10
+ // - Every simple range `r1, r2, ...` is a null set, OR
11
+ // - Every simple range `r1, r2, ...` which is not a null set is a subset of
12
+ // some `R1, R2, ...`
13
+ //
14
+ // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
15
+ // - If c is only the ANY comparator
16
+ // - If C is only the ANY comparator, return true
17
+ // - Else if in prerelease mode, return false
18
+ // - else replace c with `[>=0.0.0]`
19
+ // - If C is only the ANY comparator
20
+ // - if in prerelease mode, return true
21
+ // - else replace C with `[>=0.0.0]`
22
+ // - Let EQ be the set of = comparators in c
23
+ // - If EQ is more than one, return true (null set)
24
+ // - Let GT be the highest > or >= comparator in c
25
+ // - Let LT be the lowest < or <= comparator in c
26
+ // - If GT and LT, and GT.semver > LT.semver, return true (null set)
27
+ // - If any C is a = range, and GT or LT are set, return false
28
+ // - If EQ
29
+ // - If GT, and EQ does not satisfy GT, return true (null set)
30
+ // - If LT, and EQ does not satisfy LT, return true (null set)
31
+ // - If EQ satisfies every C, return true
32
+ // - Else return false
33
+ // - If GT
34
+ // - If GT.semver is lower than any > or >= comp in C, return false
35
+ // - If GT is >=, and GT.semver does not satisfy every C, return false
36
+ // - If GT.semver has a prerelease, and not in prerelease mode
37
+ // - If no C has a prerelease and the GT.semver tuple, return false
38
+ // - If LT
39
+ // - If LT.semver is greater than any < or <= comp in C, return false
40
+ // - If LT is <=, and LT.semver does not satisfy every C, return false
41
+ // - If GT.semver has a prerelease, and not in prerelease mode
42
+ // - If no C has a prerelease and the LT.semver tuple, return false
43
+ // - Else return true
44
+
45
+ const subset = (sub, dom, options = {}) => {
46
+ if (sub === dom) {
47
+ return true
48
+ }
49
+
50
+ sub = new Range(sub, options)
51
+ dom = new Range(dom, options)
52
+ let sawNonNull = false
53
+
54
+ OUTER: for (const simpleSub of sub.set) {
55
+ for (const simpleDom of dom.set) {
56
+ const isSub = simpleSubset(simpleSub, simpleDom, options)
57
+ sawNonNull = sawNonNull || isSub !== null
58
+ if (isSub) {
59
+ continue OUTER
60
+ }
61
+ }
62
+ // the null set is a subset of everything, but null simple ranges in
63
+ // a complex range should be ignored. so if we saw a non-null range,
64
+ // then we know this isn't a subset, but if EVERY simple range was null,
65
+ // then it is a subset.
66
+ if (sawNonNull) {
67
+ return false
68
+ }
69
+ }
70
+ return true
71
+ }
72
+
73
+ const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
74
+ const minimumVersion = [new Comparator('>=0.0.0')]
75
+
76
+ const simpleSubset = (sub, dom, options) => {
77
+ if (sub === dom) {
78
+ return true
79
+ }
80
+
81
+ if (sub.length === 1 && sub[0].semver === ANY) {
82
+ if (dom.length === 1 && dom[0].semver === ANY) {
83
+ return true
84
+ } else if (options.includePrerelease) {
85
+ sub = minimumVersionWithPreRelease
86
+ } else {
87
+ sub = minimumVersion
88
+ }
89
+ }
90
+
91
+ if (dom.length === 1 && dom[0].semver === ANY) {
92
+ if (options.includePrerelease) {
93
+ return true
94
+ } else {
95
+ dom = minimumVersion
96
+ }
97
+ }
98
+
99
+ const eqSet = new Set()
100
+ let gt, lt
101
+ for (const c of sub) {
102
+ if (c.operator === '>' || c.operator === '>=') {
103
+ gt = higherGT(gt, c, options)
104
+ } else if (c.operator === '<' || c.operator === '<=') {
105
+ lt = lowerLT(lt, c, options)
106
+ } else {
107
+ eqSet.add(c.semver)
108
+ }
109
+ }
110
+
111
+ if (eqSet.size > 1) {
112
+ return null
113
+ }
114
+
115
+ let gtltComp
116
+ if (gt && lt) {
117
+ gtltComp = compare(gt.semver, lt.semver, options)
118
+ if (gtltComp > 0) {
119
+ return null
120
+ } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
121
+ return null
122
+ }
123
+ }
124
+
125
+ // will iterate one or zero times
126
+ for (const eq of eqSet) {
127
+ if (gt && !satisfies(eq, String(gt), options)) {
128
+ return null
129
+ }
130
+
131
+ if (lt && !satisfies(eq, String(lt), options)) {
132
+ return null
133
+ }
134
+
135
+ for (const c of dom) {
136
+ if (!satisfies(eq, String(c), options)) {
137
+ return false
138
+ }
139
+ }
140
+
141
+ return true
142
+ }
143
+
144
+ let higher, lower
145
+ let hasDomLT, hasDomGT
146
+ // if the subset has a prerelease, we need a comparator in the superset
147
+ // with the same tuple and a prerelease, or it's not a subset
148
+ let needDomLTPre = lt &&
149
+ !options.includePrerelease &&
150
+ lt.semver.prerelease.length ? lt.semver : false
151
+ let needDomGTPre = gt &&
152
+ !options.includePrerelease &&
153
+ gt.semver.prerelease.length ? gt.semver : false
154
+ // exception: <1.2.3-0 is the same as <1.2.3
155
+ if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
156
+ lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
157
+ needDomLTPre = false
158
+ }
159
+
160
+ for (const c of dom) {
161
+ hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='
162
+ hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='
163
+ if (gt) {
164
+ if (needDomGTPre) {
165
+ if (c.semver.prerelease && c.semver.prerelease.length &&
166
+ c.semver.major === needDomGTPre.major &&
167
+ c.semver.minor === needDomGTPre.minor &&
168
+ c.semver.patch === needDomGTPre.patch) {
169
+ needDomGTPre = false
170
+ }
171
+ }
172
+ if (c.operator === '>' || c.operator === '>=') {
173
+ higher = higherGT(gt, c, options)
174
+ if (higher === c && higher !== gt) {
175
+ return false
176
+ }
177
+ } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
178
+ return false
179
+ }
180
+ }
181
+ if (lt) {
182
+ if (needDomLTPre) {
183
+ if (c.semver.prerelease && c.semver.prerelease.length &&
184
+ c.semver.major === needDomLTPre.major &&
185
+ c.semver.minor === needDomLTPre.minor &&
186
+ c.semver.patch === needDomLTPre.patch) {
187
+ needDomLTPre = false
188
+ }
189
+ }
190
+ if (c.operator === '<' || c.operator === '<=') {
191
+ lower = lowerLT(lt, c, options)
192
+ if (lower === c && lower !== lt) {
193
+ return false
194
+ }
195
+ } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
196
+ return false
197
+ }
198
+ }
199
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
200
+ return false
201
+ }
202
+ }
203
+
204
+ // if there was a < or >, and nothing in the dom, then must be false
205
+ // UNLESS it was limited by another range in the other direction.
206
+ // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
207
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
208
+ return false
209
+ }
210
+
211
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
212
+ return false
213
+ }
214
+
215
+ // we needed a prerelease range in a specific tuple, but didn't get one
216
+ // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
217
+ // because it includes prereleases in the 1.2.3 tuple
218
+ if (needDomGTPre || needDomLTPre) {
219
+ return false
220
+ }
221
+
222
+ return true
223
+ }
224
+
225
+ // >=1.2.3 is lower than >1.2.3
226
+ const higherGT = (a, b, options) => {
227
+ if (!a) {
228
+ return b
229
+ }
230
+ const comp = compare(a.semver, b.semver, options)
231
+ return comp > 0 ? a
232
+ : comp < 0 ? b
233
+ : b.operator === '>' && a.operator === '>=' ? b
234
+ : a
235
+ }
236
+
237
+ // <=1.2.3 is higher than <1.2.3
238
+ const lowerLT = (a, b, options) => {
239
+ if (!a) {
240
+ return b
241
+ }
242
+ const comp = compare(a.semver, b.semver, options)
243
+ return comp < 0 ? a
244
+ : comp > 0 ? b
245
+ : b.operator === '<' && a.operator === '<=' ? b
246
+ : a
247
+ }
248
+
249
+ module.exports = subset
@@ -0,0 +1,10 @@
1
+ 'use strict'
2
+
3
+ const Range = require('../classes/range')
4
+
5
+ // Mostly just for testing and legacy API reasons
6
+ const toComparators = (range, options) =>
7
+ new Range(range, options).set
8
+ .map(comp => comp.map(c => c.value).join(' ').trim().split(' '))
9
+
10
+ module.exports = toComparators
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ const Range = require('../classes/range')
4
+ const validRange = (range, options) => {
5
+ try {
6
+ // Return '*' instead of '' so that truthiness works.
7
+ // This will throw if it's invalid anyway
8
+ return new Range(range, options).range || '*'
9
+ } catch (er) {
10
+ return null
11
+ }
12
+ }
13
+ module.exports = validRange
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License.
62
+
63
+ Subject to the terms and conditions of this License, each Contributor hereby
64
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
65
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
66
+ publicly display, publicly perform, sublicense, and distribute the Work and such
67
+ Derivative Works in Source or Object form.
68
+
69
+ 3. Grant of Patent License.
70
+
71
+ Subject to the terms and conditions of this License, each Contributor hereby
72
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
73
+ irrevocable (except as stated in this section) patent license to make, have
74
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
75
+ such license applies only to those patent claims licensable by such Contributor
76
+ that are necessarily infringed by their Contribution(s) alone or by combination
77
+ of their Contribution(s) with the Work to which such Contribution(s) was
78
+ submitted. If You institute patent litigation against any entity (including a
79
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
80
+ Contribution incorporated within the Work constitutes direct or contributory
81
+ patent infringement, then any patent licenses granted to You under this License
82
+ for that Work shall terminate as of the date such litigation is filed.
83
+
84
+ 4. Redistribution.
85
+
86
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
87
+ in any medium, with or without modifications, and in Source or Object form,
88
+ provided that You meet the following conditions:
89
+
90
+ You must give any other recipients of the Work or Derivative Works a copy of
91
+ this License; and
92
+ You must cause any modified files to carry prominent notices stating that You
93
+ changed the files; and
94
+ You must retain, in the Source form of any Derivative Works that You distribute,
95
+ all copyright, patent, trademark, and attribution notices from the Source form
96
+ of the Work, excluding those notices that do not pertain to any part of the
97
+ Derivative Works; and
98
+ If the Work includes a "NOTICE" text file as part of its distribution, then any
99
+ Derivative Works that You distribute must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, excluding those notices
101
+ that do not pertain to any part of the Derivative Works, in at least one of the
102
+ following places: within a NOTICE text file distributed as part of the
103
+ Derivative Works; within the Source form or documentation, if provided along
104
+ with the Derivative Works; or, within a display generated by the Derivative
105
+ Works, if and wherever such third-party notices normally appear. The contents of
106
+ the NOTICE file are for informational purposes only and do not modify the
107
+ License. You may add Your own attribution notices within Derivative Works that
108
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
109
+ provided that such additional attribution notices cannot be construed as
110
+ modifying the License.
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions.
118
+
119
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
120
+ for inclusion in the Work by You to the Licensor shall be under the terms and
121
+ conditions of this License, without any additional terms or conditions.
122
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
123
+ any separate license agreement you may have executed with Licensor regarding
124
+ such Contributions.
125
+
126
+ 6. Trademarks.
127
+
128
+ This License does not grant permission to use the trade names, trademarks,
129
+ service marks, or product names of the Licensor, except as required for
130
+ reasonable and customary use in describing the origin of the Work and
131
+ reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty.
134
+
135
+ Unless required by applicable law or agreed to in writing, Licensor provides the
136
+ Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
137
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
138
+ including, without limitation, any warranties or conditions of TITLE,
139
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
140
+ solely responsible for determining the appropriateness of using or
141
+ redistributing the Work and assume any risks associated with Your exercise of
142
+ permissions under this License.
143
+
144
+ 8. Limitation of Liability.
145
+
146
+ In no event and under no legal theory, whether in tort (including negligence),
147
+ contract, or otherwise, unless required by applicable law (such as deliberate
148
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special, incidental,
150
+ or consequential damages of any character arising as a result of this License or
151
+ out of the use or inability to use the Work (including but not limited to
152
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
153
+ any and all other commercial damages or losses), even if such Contributor has
154
+ been advised of the possibility of such damages.
155
+
156
+ 9. Accepting Warranty or Additional Liability.
157
+
158
+ While redistributing the Work or Derivative Works thereof, You may choose to
159
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
160
+ other liability obligations and/or rights consistent with this License. However,
161
+ in accepting such obligations, You may act only on Your own behalf and on Your
162
+ sole responsibility, not on behalf of any other Contributor, and only if You
163
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
164
+ incurred by, or claims asserted against, such Contributor by reason of your
165
+ accepting any such warranty or additional liability.
166
+
167
+ END OF TERMS AND CONDITIONS
168
+
169
+ APPENDIX: How to apply the Apache License to your work
170
+
171
+ To apply the Apache License to your work, attach the following boilerplate
172
+ notice, with the fields enclosed by brackets "[]" replaced with your own
173
+ identifying information. (Don't include the brackets!) The text should be
174
+ enclosed in the appropriate comment syntax for the file format. We also
175
+ recommend that a file or class name and description of purpose be included on
176
+ the same "printed page" as the copyright notice for easier identification within
177
+ third-party archives.
178
+
179
+ Copyright [yyyy] [name of copyright owner]
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.