Skip to content

Commit e9f39ea

Browse files
authored
docs: added basic usage instructions (#114)
## Description Getting started with Nupm's current basic functionality required reverse-engineering the needed commands from the code, so I thought a good start would be to define this in the readme. Some of the existing detailed commands weren't quite accurate so I've also fixed those. Note that I'm only documenting the functionality I've used for now. It probably makes sense to add the registry stuff once it's more fleshed out.
1 parent f4c4007 commit e9f39ea

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

Diff for: README.md

+53-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
## Table of content
44
- [*installation*](#recycle-installation-toc)
55
- [*configuration*](#gear-configuration-toc)
6+
- [*usage*](#rocket-usage-toc)
7+
- [*install a package*](#install-a-package-toc)
8+
- [*update a package*](#update-a-package-toc)
9+
- [*define a package*](#define-a-package-toc)
610
- [*running a test suite*](#test_tube-running-a-test-suite-toc)
7-
- [*run the tests*](#run-the-tests-of-Nupm-toc)
11+
- [*run the tests*](#run-the-tests-of-Nupm-toc)
812
- [*design*](#memo-design-of-nupm-toc)
913

1014
:warning: **This project is in an experimentation stage and not intended for serious use!** :warning:
@@ -20,10 +24,10 @@
2024
Both of the above commands will make `nupm` and all its subcommands available in your current scope. `overlay use` will allow you to `overlay hide` the `nupm` overlay when you don't need it.
2125

2226
> **Note**
23-
> `nupm` is able to install itself: from inside the root of your local copy of `nupm`, run
27+
> `nupm` is able to install itself: from outside the root of your local copy of `nupm`, run
2428
> ```nushell
25-
> use nupm/
26-
> nupm install --force --path .
29+
> use nupm/nupm
30+
> nupm install nupm --force --path
2731
> ```
2832
2933
## :gear: configuration [[toc](#table-of-content)]
@@ -52,6 +56,51 @@ $env.PATH = (
5256
)
5357
```
5458

59+
## :rocket: usage [[toc](#table-of-content)]
60+
61+
Nupm can install different types of packages, such as modules and scripts. It also provides a mechanism for a custom installation using a `build.nu` file.
62+
63+
As an illustrative example, the following demonstrates use of a fictional `foo` module-based package.
64+
65+
### install a package [[toc](#table-of-content)]
66+
67+
```nushell
68+
git clone https://github.com/nushell/foo.git
69+
nupm install foo --path
70+
```
71+
72+
### update a package [[toc](#table-of-content)]
73+
74+
Assuming the repository is already cloned, you can update the module package with the following:
75+
76+
```nushell
77+
do { cd foo; git pull }
78+
nupm install foo --force --path
79+
```
80+
This usage will likely change once a dedicated `nupm update` command is added.
81+
82+
### define a package [[toc](#table-of-content)]
83+
84+
In order to use a module-based package with Nupm, a directory should be structured similar to the following `foo` module:
85+
86+
- `foo/`
87+
- `mod.nu`
88+
- (other scripts and modules)
89+
- `nupm.nuon`
90+
91+
The `nupm.nuon` file is a metadata file that describes the package. It should contain the following fields:
92+
93+
```nushell
94+
{
95+
name: "foo"
96+
description: "A package that demonstrates use of Nupm"
97+
type: "module"
98+
license: "MIT"
99+
}
100+
```
101+
102+
Nupm also supports other types of packages. See [Project Structure](https://github.com/nushell/nupm/blob/main/docs/design/README.md#project-structure-toc) for more details.
103+
55104
## :test_tube: running a test suite [[toc](#table-of-content)]
56105
as it is done in Nupm, one can define tests in a project and run them with the `nupm test` command:
57106
- create a Nushell package with a `nupm.nuon` file, let's call this example package `package`

Diff for: docs/design/references/METADATA.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- `supported-os`: Operating systems supported by the package, the most broad possibility: `{"arch": ["*"], "family": ["*"], "name": ["*"]}`. Matched by `$nu.os-info`
1313
- `url`: Package website/GitHub repository. Basically a place where one can find some additional info about the package
1414

15-
## Optional attribtues
15+
## Optional attributes
1616
- `dependencies`: Packages needed by the package — versions have to be specified. e.g. `[nupm/0.7.0]`. Semantic versioning is also supported: `[nupm/~0.7]`
1717
- `installer`: Name of a script (relative to the package scope) that will install the package instead (or in addition to) of default `nupm` logic
1818
- `keywords`: List of keywords used by `nupm search` in addition to `name`

0 commit comments

Comments
 (0)