Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e58a9e8
refactor(commands): infer command services from setup
edusperoni Sep 14, 2026
c502143
feat(commands): provide the invocation context through an injection t…
edusperoni Sep 14, 2026
2ffeb51
feat(commands): add a class form built on defineCommand
edusperoni Sep 14, 2026
1aed823
refactor(commands): move three commands to the class form
edusperoni Sep 14, 2026
92002a2
refactor(commands): build one context per invocation
edusperoni Sep 14, 2026
60d2885
feat(commands): ask another command whether it can execute
edusperoni Sep 14, 2026
955efb2
refactor(commands): move the structured commands to the class form
edusperoni Sep 14, 2026
0b8d65b
refactor(commands): inline the simple command definitions
edusperoni Sep 14, 2026
0158722
docs(commands): describe where a handler gets its services
edusperoni Sep 14, 2026
25f15ec
feat(commands): make the in-process dispatcher a contract
edusperoni Sep 14, 2026
71c4324
fix(commands): run a definition passed to the dispatcher as given
edusperoni Sep 14, 2026
f40ff39
refactor: move package managers into lib/package-managers
rigor789 Sep 16, 2026
1157cae
refactor: type package manager install and uninstall options
rigor789 Sep 16, 2026
f3f4e1b
refactor: manager-agnostic view/search and resolution-based package l…
rigor789 Sep 16, 2026
c8d2a28
feat(package-managers): resolve installed packages through the packag…
rigor789 Sep 16, 2026
14a41fa
refactor: resolve bundler, test runner and extension packages via the…
rigor789 Sep 16, 2026
2000f91
refactor(package-managers): select the package manager and resolve pa…
rigor789 Sep 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions PublicAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ tns.settingsService.setSettings({ userAgentName: "myUserAgent", profileDir: "cus
`npm` module provides a way to interact with npm specifically the use of install, uninstall, search and view commands.

### install
Installs specified package. Note that you can use the third argument in order to pass different options to the installation like `ignore-scripts`, `save` or `save-exact` which work exactly like they would if you would execute npm from the command line and pass them as `--` flags.
Installs specified package. The third argument takes package-manager-agnostic options (`dev`, `exact`, `save`, `optional`, `silent`, `ignoreScripts`); the selected package manager maps them onto its own command line flags.
* Auxiliary interfaces:
```TypeScript
/**
Expand Down Expand Up @@ -533,11 +533,11 @@ Uninstalls a specified package.
/**
* Uninstalls a dependency
* @param {string} packageName The name of the dependency.
* @param {IDictionary<string | boolean>} config Additional options that can be passed to manipulate uninstallation.
* @param {IPackageUninstallOptions} options Package-manager-agnostic uninstallation options (`save`).
* @param {string} path The destination of the uninstallation.
* @return {Promise<any>} The output of the uninstallation.
*/
uninstall(packageName: string, config?: IDictionary<string | boolean>, path?: string): Promise<string>;
uninstall(packageName: string, options?: IPackageUninstallOptions, path?: string): Promise<string>;
```

* Usage:
Expand All @@ -556,39 +556,57 @@ Searches for a package using keywords.
```TypeScript
/**
* Searches for a package.
* @param {string[]} filter Keywords with which to perform the search.
* @param {IDictionary<string | boolean>} config Additional options that can be passed to manipulate search.
* @return {Promise<string>} The output of the uninstallation.
* @param {string[]} filter Keywords with which to perform the search.
* @return {Promise<string>} The raw search output.
*/
search(filter: string[], config: IDictionary<string | boolean>): Promise<string>;
search(filter: string[]): Promise<string>;
```

* Usage:
```JavaScript
tns.npm.search(["nativescript", "cloud"], { silent: true }).then(output => {
tns.npm.search(["nativescript", "cloud"]).then(output => {
console.log(`Found: ${output}`);
}, err => {
console.log("An error occurred during searching", err);
});
```

### getInstalledPackagePath
Locates a package the way the selected package manager laid it out on disk, so callers never have to assume a `node_modules` layout.

* Definition:
```TypeScript
/**
* @param {string} packageName The name of the package.
* @param {string} fromDir The directory whose dependencies are searched, usually the project directory.
* @return {string} The absolute path of the package directory, or null when it is not installed.
*/
getInstalledPackagePath(packageName: string, fromDir: string): string;
```

* Usage:
```JavaScript
const pathToPackage = tns.packageManager.getInstalledPackagePath("@nativescript/core", "/tmp/myProject");
console.log(pathToPackage ? `Installed at ${pathToPackage}` : "Not installed");
```

### view
Provides information about a given package.

* Definition
```TypeScript
/**
* Provides information about a given package.
* @param {string} packageName The name of the package.
* @param {IDictionary<string | boolean>} config Additional options that can be passed to manipulate view.
* @return {Promise<any>} Object, containing information about the package.
* Provides registry information about a package.
* @param {string} packageName The name of the package, optionally with a version.
* @param {string} field Optional single registry field (e.g. "versions" or "dist-tags") to return instead of the whole document.
* @return {Promise<any>} The parsed registry data.
*/
view(packageName: string, config: Object): Promise<any>;
view(packageName: string, field?: string): Promise<any>;
```

* Usage:
```JavaScript
tns.npm.view(["nativescript"], {}).then(result => {
tns.npm.view("nativescript").then(result => {
console.log(`${result.name}'s latest version is ${result["dist-tags"].latest}`);
}, err => {
console.log("An error occurred during viewing", err);
Expand Down
Loading