feat(extensibility): Add hint how to get access to a command from extension#3394
Merged
Conversation
Contributor
Author
rosen-vladimirov
left a comment
There was a problem hiding this comment.
- Add additional tests to ensure calls to
getExtensionNameWhereCommandIsRegisteredwill never throw error. - Handle default commands, i.e. containing
|*
| return { | ||
| extensionName, | ||
| registeredCommandName: currentCommand, | ||
| installationMessage: `The command ${currentCommand} is registered in extension ${extensionName}. You can install it by executing 'tns extension install ${extensionName}'` |
Contributor
Author
There was a problem hiding this comment.
beautify the command name (replace | with ).
Fatme
approved these changes
Feb 27, 2018
| const url = `https://registry.npmjs.org/${packageName}`; | ||
| this.$logger.trace(`Trying to get data from npm registry for package ${packageName}, url is: ${url}`); | ||
| const responseData = (await this.$httpClient.httpRequest(url)).body; | ||
| this.$logger.trace(`Successfully received data from npm registry for package ${packageName}.`); |
Contributor
There was a problem hiding this comment.
Shouldn't print responseData as well?
dfbe0b5 to
338f815
Compare
…ension In case user executes any command that is registered in extension, but this extension is not installed, they'll receive error: `Unknown command ...`. Instead of showing this, it is better to tell them how to get access to this command. In order to achieve this, implement a new logic in `extensibilityService` to find commands registered in all extensions. CLI searches npm (via npms API) for packages that have the keyword `nativescript:extension`. After that, CLI gets the package.json of the latest version of each dependency (via registry.npmjs.org) and searches for nativescript key in it. In case it has nativescript key, CLI reads the commands value inside it. The value should be string array containg all commands registered in extension's bootstrap. When user writes down a command that is not registered in CLI, we check if there's such command and in case it is found, CLI will instruc the user how to install the respective extension. Same will happen in case user tries to access the help content of a command that is registered in extension.
338f815 to
e411ca5
Compare
This file contains hidden or 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
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.
In case user executes any command that is registered in extension, but this extension is not installed, they'll receive error:
Unknown command .... Instead of showing this, it is better to tell them how to get access to this command.In order to achieve this, implement a new logic in
extensibilityServiceto find commands registered in all extensions. CLI searches npm (via npms API) for packages that have the keywordnativescript:extension.After that, CLI gets the package.json of the latest version of each dependency (via registry.npmjs.org) and searches for nativescript key in it. In case it has nativescript key, CLI reads the commands value inside it. The value should be string array containg all commands registered in extension's bootstrap.
When user writes down a command that is not registered in CLI, we check if there's such command and in case it is found, CLI will instruct the user how to install the respective extension.
Same will happen in case user tries to access the help content of a command that is registered in extension.