Skip to content

Package manager

Francesco Saverio Castellano edited this page Apr 1, 2020 · 23 revisions

The TINN executable is also a package manager and builder for native modules.

The package manager is inspired by npm and provides install/uninstall commands what work in the same fashion as the ones in npm. Dependencies are automatically resolved and installed/uninstalled.
Packages can be installed locally (in the local tinn_modules directory in the current project) or globally (in the TINN root directory or in TINN_PATH if this environment variable is set).
 
The TINN package manager does not have its own registry. It uses github APIs to search and download packages. This means that only github projects can be installed via the TINN package manager.
 
A note on dependencies: this package manager has basic support for dependencies. Just like with npm dependencies can be specified in the package.json file of a project (see dependencies).

List of supported commands

search

Searches for a package in git.

$ tinn search search_string

All packages matching search_string will be returned.
For instance the following command:

$ tinn search tinn_web

Returns this output:

 tinn_web 249009685 - Simple web framework for TINN
 WebtechExamen_TinneJacobs 56081942 - Webtech
 TinnesWebsite 150573377
 angular-web-application-TinnyNoyens 192178214 - angular-web-application-TinnyNoyens
 tinnker-web 33100986 - Website for the tinnker
 Tinn-R-Website 151596616 - Tinn-R Editor Website
 tinng-client-web 25534302 - Standard web client for the "tinng" communication service

SUCCESS 7 projects found.

For each project search returns the following information: project name, id and description

info

Returns information about a package.

$ tinn info package_name

Here package_name must be the name of the package or a search string (in this case the information returned corresponds to the first package matching the search string). When using this command in order to be sure that the right project is identified it is possible to add the project id after a space following the project name:

 $ tinn info tinn_web 249009685

The following details are returned: project name, id, description, url, creation date, date of last update, tags.

install

Installs the requested package and all its dependencies.

$ tinn install package_name

By default the package is installed locally in tinn_modules directory. If package.json exists in the current project then the package being installed is saved as a dependency of the current project in its package.json file.
if the --global or -g flag is provided then the package is installed globally. The global installation path is the directory pointed to by the NODE_PATH environment variable when set or the tinn_modules directory in the TINN root directory.
As for the info command, in order to be sure that the right project is install, it is possible to add a space after project_name followed by the id of the project:

 $ tinn install tinn_web 249009685

In order to install a specific tag of a project specify the tag name by appending it to the project name using @ as a separator:

$ tinn install tinn_web@0.0.1 249009685

uninstall

Uninstalls a package and it dependencies. If the --global or -g flag is provided the package is uninstalled globally (in this case its dependencies are not uninstalled).
When a package is uninstalled locally its dependencies are also uninstall and the current project's package.json file is updated is there is any.
Uninstalling a package that is a dependency of one or more packages currently installed produces an error.
A package can be forced to uninstall by using the --force or -f flag.

remove

This is an alias for uninstall.

Dependencies

Dependencies of a project are specified in package.json file inside the project directory.
Here is an example package.json file of a project called myproject that has four dependencies:

{
    "version": "0.5.2",
    "name": "simple_project",
    "dependencies": {
        "other_project": "2.0.0",
        "second_project 48586003": "1.5.2",
        "third_project": "~3.5.0",
        "fourth_project": "^4.2.0"
     }
}

As shown in the above example, the dependencies are specified in an object whose keys are project identifiers and values are project versions. Project identifiers can be either the bare name of the project or the project name followed by a space and the project id (see info and install commands).
The project version can be either a specific version, or a version prefixed with ~ (tilde) or a version prefixed with ^ (caret). The tilde and caret have the following meanings:

  • ~version "Approximately equivalent to version", will update you to all future patch versions, without incrementing the minor version. ~1.2.3 will use releases from 1.2.3 to <1.3.0.
  • ^version "Compatible with version", will update you to all future minor/patch versions, without incrementing the major version. ^2.3.4 will use releases from 2.3.4 to <3.0.0.

Native module builder

The TINN executable is also capable of building native modules.
Native modules once built are shared libraries whose files are located in the modules/ directory.
The files needed to build a module are located under build/modules/module_name where module_name is the name of the module.
Use the build command to build all modules:

$ tinn build

To build only a specific module add its name to the command:

$ tinn build http

Use the clean command to clean all modules:

$ tinn clean

To build only a specific module add its name to the command:

$ tinn clean http