-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow marking of stubbed API #35
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alvsan09
added a commit
that referenced
this pull request
Aug 13, 2022
Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
alvsan09
force-pushed
the
asl/mark_stubbed_api
branch
from
August 13, 2022 16:34
abb889b
to
3322572
Compare
alvsan09
added a commit
that referenced
this pull request
Aug 14, 2022
Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
alvsan09
force-pushed
the
asl/mark_stubbed_api
branch
from
August 14, 2022 12:27
3322572
to
4010873
Compare
alvsan09
added a commit
that referenced
this pull request
Aug 14, 2022
Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
alvsan09
force-pushed
the
asl/mark_stubbed_api
branch
from
August 14, 2022 12:35
4010873
to
e04f1d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/stubbed-ranges.ts
Outdated
Comment on lines
61
to
118
/** | ||
* Each argument represents a semantic version | ||
*/ | ||
function isVersionInRange(input: string, from: string, to?: string): boolean { | ||
const inputArr = input.split('.'); | ||
const fromArr = from.split('.'); | ||
const toArr = to ? to.split('.') : undefined; | ||
|
||
if ( | ||
inputArr.length !== semverLength || | ||
fromArr.length !== semverLength || | ||
!!(toArr && toArr.length !== semverLength) | ||
) { | ||
throw new Error('The expected length of semantic versions is 3'); | ||
} | ||
|
||
const greaterOrEqual = isGreaterOrEqual(inputArr, fromArr); | ||
if (!greaterOrEqual) { | ||
return false; | ||
} | ||
|
||
if (!toArr) { | ||
// Not having a 'to' version means the condition is still present i.e. stubbing applies. | ||
return true; | ||
} | ||
|
||
return isLessOrEqual(inputArr, toArr); | ||
} | ||
|
||
function isGreaterOrEqual(inputArr: string[], referenceArr: string[]): boolean { | ||
for (let i = 0; i < semverLength; i++) { | ||
if (+inputArr[i] > +referenceArr[i]) { | ||
return true; | ||
} | ||
|
||
if (+inputArr[i] < +referenceArr[i]) { | ||
return false; | ||
} | ||
} | ||
|
||
// Must be equal | ||
return true; | ||
} | ||
|
||
function isLessOrEqual(inputArr: string[], referenceArr: string[]): boolean { | ||
for (let i = 0; i < semverLength; i++) { | ||
if (+inputArr[i] < +referenceArr[i]) { | ||
return true; | ||
} | ||
|
||
if (+inputArr[i] > +referenceArr[i]) { | ||
return false; | ||
} | ||
} | ||
|
||
// Must be equal | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use the semver
package for these comparisons. Let them handle any corner cases :-).
alvsan09
force-pushed
the
asl/mark_stubbed_api
branch
from
August 26, 2022 20:12
e04f1d7
to
9a51ed9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #34
Allow marking types/members specifically as stubbed, so that they show up as warning (orange), meaning that the types are available but actually not functional.
The markings are provisioned in the existing
infos.yml
file via a new optional entry called_stubbed
which can have two attributesfrom
(mandatory)and
to` (optional), these two attributes represent the start and end versions where stubbing applies.The following applies:
_stubbed
yml
entry can be entered as a child of any type/member_stubbed
can shall have afrom
attribute and an optionalto
attributefrom
andto
shall hold string values representing the versions where stubbing appliesv1.27.0
,master
,local
.
e.g.1.26.0
to
version is optional, meaning that stubbing appliesfrom
a given version until latest (master
orlocal
)local
version is considered equivalent tomaster
i.e. representinglatest
.from
havingmaster
orlocal
to
havingmaster
orlocal
, this behaves the same as not having theto
versionstatus.html
as well asfiltered-status.html
include stubbed markingstooltip
is appended with the word(stubbed)
which clarifies the meaning.How to Test:
The following
gist
contains three files, use theinfos.yml
file to test differentstubbed
markings,The other two files are generated
status.html
andfiltered-status.html
files generated with the above mentionedinfos.yml
https://gist.github.com/alvsan09/e6c6aaf18a3e343109a01c02a56ca5b6
Example: