-
-
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
refactor: introduce branded types #61
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
Add type information indicating that result code will always be either 0 or 1
Use information found in test usage to adjust types throughout the project. Also type constants in tests
Add utility functions to de-duplicate the common logic of adding packages and search results to the mock package registry in tests
Split utilities file into mock-work-dir and mock-console
Hide implementation detail of what mock console is used from tests
Add helpers to check for correct manifest in add cmd tests
Move logic for, creating, resetting and querying mock console content into dedicated functions
To avoid warnings. Only dev dependencies
Move manifest assertion helpers to own module so they can be reused
prepare for allowing to chain multiple assertions on same manifest
Use manifest assertions in cmd remove tests. Also add a few new ones
Use manifest assertions in manifest tests
There should never be a version inside the name
Add branded type for reverse-domain-name. This showed a lot of cases where pkg-name type was used, where reverse-domain-name should have been used. Fixed these cases
Note: This is an extension of #60, so the first few commits are the same |
Extends project tsconfig, but without emits
Rename to just domain-name since it should also work for regular domain names. Also it's a little shorter that way. The rules for what makes a valid name also changes a little bit. Now single segment names like just "com" are also valid. We don't need to do that much validation.
Add a builder function for making pkg-info objects for tests. Includes validation logic and auto-sets derived properties, such as also setting the package _id to the name
Builder does validation and allows for shorter test setups
Fix errors from passing strings to functions expecting domain names. Fix by using name fields from packages or asserting validity using "as"
The response object used by npm-registry-fetch is node-fetch Response, not request Response
Function acts on domain-types and so should be in a different file
Introduce package-url type which represents an url pointing to a package. Also add a few tests
Add type-checking for semantic-version strings. Currently not much validation
Package at specific version
Ok, I kind of messed up this PR branch, I'll redo it an open it again |
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.
Introduce branded types for many of the simple types in the project. This has two primary effects/goals:
name@version
was used where onlyname
should have been allowed etc.Tests were added for all new types.
This PR also includes some helpers for constructing
PkgInfo
andPkgManifest
objects for tests, as well as some other minor changes.