Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4d9d899
init commit
mkatychev Jun 13, 2025
573100b
changed const
mkatychev Jun 13, 2025
5409a71
get_index impl
mkatychev Jun 13, 2025
3bcf1e9
removed TODOs for callout of registry subcommand
mkatychev Jun 13, 2025
87ed5d1
Merge branch 'main' into feat/registry-submodule
mkatychev Jun 20, 2025
26c3444
made nupm config declarative
mkatychev Jun 24, 2025
67c2826
Merge branch 'main' into feat/registry-submodule
mkatychev Jun 24, 2025
fce3057
updated NUPM_ variables to match nested structure
mkatychev Jun 24, 2025
354dc8e
typos
mkatychev Jun 24, 2025
2efd004
updated initial test variables
mkatychev Jun 24, 2025
5e96f1a
fixed registry typo
mkatychev Jun 24, 2025
0821712
renamed tmp to temp
mkatychev Jun 24, 2025
445be0f
revert temp
mkatychev Jun 24, 2025
1f12490
fixed tmp-dir variable resolution issue
mkatychev Jun 26, 2025
f33f29e
updated with workaround
mkatychev Jun 26, 2025
7d3a1cf
updated test cases for exitsting registry subcommands
mkatychev Jun 26, 2025
12d95c1
initial naive registry describe impl
mkatychev Jun 26, 2025
fe5b26c
registry describe passing test
mkatychev Jun 26, 2025
2907762
moved open-index to module root
mkatychev Jun 26, 2025
11a7a38
removed log calls intest
mkatychev Jun 26, 2025
b054db3
update registry header comment
mkatychev Jun 26, 2025
aa12a95
update registry init shim
mkatychev Jun 26, 2025
d5d6699
partial test pass
mkatychev Jun 27, 2025
bac9659
all tests pass
mkatychev Jun 27, 2025
baaf4f4
revert test mod closuer
mkatychev Jun 27, 2025
8542850
simplify variable setting
mkatychev Jun 28, 2025
af2a6ad
reverted nested nupm config
mkatychev Jul 7, 2025
081677b
remove flaten-nupm-env
mkatychev Jul 7, 2025
01b33b2
added registry_filename constants
mkatychev Jul 7, 2025
b2e85f2
removed fetch command
mkatychev Jul 10, 2025
4c55581
remoted editorconfig
mkatychev Jul 10, 2025
102d970
PR feedback on addtion of registry values
mkatychev Jul 16, 2025
78848fe
revert README
mkatychev Jul 16, 2025
919865b
updated formatting messages
mkatychev Jul 16, 2025
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
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true
Comment thread
mkatychev marked this conversation as resolved.
Outdated

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
22 changes: 11 additions & 11 deletions docs/design/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Design of `nupm` :warning: Work In Progress :warning:
Comment thread
mkatychev marked this conversation as resolved.
# Design of `nupm` :warning: Work In Progress :warning:

This file collects design ideas and directions. The intention is iterate on this document by PRs with discussion.

> **Note**
> **Note**
> in the following, until we settle down on precise names, we use the following placeholders:
> - `METADATA_FILE`: the file containing the metadata of a package,
> e.g. `project.nuon`, `metadata.json` or `nupm.nuon`
Expand All @@ -13,7 +13,7 @@ This file collects design ideas and directions. The intention is iterate on this
# Table of content
- [Project Structure](#project-structure-toc)
- [Separate virtual environments](#separate-virtual-environments-toc)
- [Installation, bootstraping](#installation-bootstraping-toc)
- [Installation, bootstrapping](#installation-bootstrapping-toc)
- [Dependency handling](#dependency-handling-toc)
- [Package repository](#package-repository-toc)
- [API / CLI Interface](#api--cli-interface-toc)
Expand All @@ -24,7 +24,7 @@ This file collects design ideas and directions. The intention is iterate on this

A `nupm` project is defined by `METADATA_FILE`.
This is where you define name of the project, version, dependencies, etc., and the type of the project.
> **Note**
> **Note**
> see [`METADATA.md`](references/METADATA.md) for a more in-depth description of
> the `METADATA_FILE`

Expand Down Expand Up @@ -73,17 +73,17 @@ The overlays could be used to achieve all three goals at the same time. When ins
* This file can be installed into a global location that's in your `NU_LIB_DIRS` (e.g., `NUPM_HOME/overlays`) -- now you have a global Python-like virtual environment
* Each overlay under `NUPM_HOME/overlays` will mimic the main NUPM_HOME structure, e.g., for an overlay `spam` there will be `NUPM_HOME/overlays/spam/bin`, `NUPM_HOME/overlays/spam/modules` (`NUPM_HOME/overlays/spam/overlays`? It might not be the best idea to have it recursive)

Each package would basically have its own overlay. This overlay file (it's just a module) could be used to also handle dependencies. If your project depends on `foo` and `bar` which both depend on `spam` but different versions, they could both import the different verions privately in their own overlay files and in your project's overlay file would be just `export use path/to/foo` and `export use path/to/bar`. This should prevent name clashing of `spam`. The only problem that needs to be figured out is how to tell `foo` to be aware of its overlay.
Each package would basically have its own overlay. This overlay file (it's just a module) could be used to also handle dependencies. If your project depends on `foo` and `bar` which both depend on `spam` but different versions, they could both import the different versions privately in their own overlay files and in your project's overlay file would be just `export use path/to/foo` and `export use path/to/bar`. This should prevent name clashing of `spam`. The only problem that needs to be figured out is how to tell `foo` to be aware of its overlay.

## Installation, bootstraping [[toc](#table-of-content)]
## Installation, bootstrapping [[toc](#table-of-content)]

Requires these actions from the user (this should be kept as minimal as possible):
* Add `NUPM_HOME/bin` to PATH (install location for binary projects)
* Add `NUPM_HOME/modules` to NU_LIB_DIRS
* Add `NUPM_HOME/overlays` to NU_LIB_DIRS
* Make the `nupm` command available somehow (e.g., `use` inside `config.nu`)

> :warning: **WIP**
> :warning: **WIP**
> The disadvantage of this is that the default install location is not an overlay. We could make `nupm` itself an overlay that adds itself as a command, so that you can activate/deactivate it. We might need a few attempts to get to the right solution.

There are several approaches:
Expand All @@ -98,7 +98,7 @@ There are several approaches:
In compiled programming languages, there are two kinds of dependencies: static and dynamic. Static are included statically and compiled when compiling the project,
dynamic are pre-compiled libraries linked to the project.

> **Note**
> **Note**
> Nushell is [similar to compiled languages][Nushell compiled] rather than typical dynamic languages like Python, so these concepts are relevant for Nushell.

Static dependencies:
Expand All @@ -120,7 +120,7 @@ as long as it has `METADATA_FILE` telling `nupm` what to do.

Nushell's module design conflates CLI interface with API -- they are the same. Not all of the below are of the same priority.

> **Note**
> **Note**
> commands like `list`, `install`, `search`, `uninstall`, `update`, ..., i.e. should
> - print short descriptions by default
> - print long descriptions with `--long-description (-l)`
Expand Down Expand Up @@ -161,7 +161,7 @@ Nushell's module design conflates CLI interface with API -- they are the same. N
- publish package to a repository
- **NOT SUPPORTED FOR NOW**: the repository will be a *GitHub* repo with packages submitted by PRs to start with

The following are for Python-style global overlays, we might need to re-think this for local package overlays:
The following are for Python-style global overlays, we might need to re-think this for local package overlays:
- `nupm overlay new`
- create a new global overlay (Python's virtual environment style)
- `--local` flag could generate an overlay locally from the currently opened project
Expand All @@ -178,7 +178,7 @@ The following are for Python-style global overlays, we might need to re-think th
### Other CLI-related notes [[toc](#table-of-content)]

* We could later think about being able to extend `nupm`, like `cargo` has plugins.
* Mutable actions (like install) have by default Y/n prompt, but can be overriden with `--yes`
* Mutable actions (like install) have by default Y/n prompt, but can be overridden with `--yes`
* By default, new projects are cross-platform:
* Windows
* MacOS
Expand Down
2 changes: 1 addition & 1 deletion docs/design/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ _See the new `registry/` directory, the following example slightly differs from

It is possible to only publish to a registry stored on your file system because we don't have a web service or anything like that.

The intented workflow for publishing a package is:
The intended workflow for publishing a package is:
1. Check out the git repository with the registry
2. `cd` into the package you want to publish
3. Run `nupm publish chosen_registry` to preview the changes
Expand Down
3 changes: 2 additions & 1 deletion nupm/install.nu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use utils/completions.nu complete-registries
use utils/dirs.nu [ nupm-home-prompt cache-dir module-dir script-dir tmp-dir ]
use utils/log.nu throw-error
use utils/misc.nu [check-cols hash-fn url]
use utils/misc.nu [check-cols hash-fn url flatten-nupm-env]
use utils/package.nu open-package-file
use utils/registry.nu search-package
use utils/version.nu filter-by-version
Expand Down Expand Up @@ -105,6 +105,7 @@ def install-path [
let tmp_dir = tmp-dir build --ensure

do {
flatten-nupm-env
cd $tmp_dir
^$nu.current-exe $build_file ($pkg_dir | path join 'nupm.nuon')
}
Expand Down
18 changes: 11 additions & 7 deletions nupm/mod.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ use std/log

use utils/dirs.nu [
DEFAULT_NUPM_HOME DEFAULT_NUPM_TEMP DEFAULT_NUPM_CACHE
DEFAULT_NUPM_REGISTRIES nupm-home-prompt
DEFAULT_NUPM_REGISTRIES DEFAULT_NUPM_INDEX_PATH nupm-home-prompt
]

use utils/registry.nu open-index

export module install.nu
export module publish.nu
export module registry.nu
export module search.nu
export module status.nu
export module test.nu


export-env {
# Ensure that $env.NUPM_HOME is always set when running nupm. Any missing
# $env.NUPM_HOME during nupm execution is a bug.
Expand All @@ -22,12 +26,12 @@ export-env {
# Ensure install cache is set
$env.NUPM_CACHE = ($env.NUPM_CACHE? | default $DEFAULT_NUPM_CACHE)

# TODO: Maybe this is not the best way to set registries, but should be
# good enough for now.
# TODO: Add `nupm registry` for showing info about registries
# TODO: Add `nupm registry add/remove` to add/remove registry from the env?
$env.NUPM_REGISTRIES = ($env.NUPM_REGISTRIES?
| default $DEFAULT_NUPM_REGISTRIES)
# check for the index path
$env.NUPM_INDEX_PATH = ($env.NUPM_INDEX_PATH? | default $DEFAULT_NUPM_INDEX_PATH)

# read from registry index but don't overwrite registires already present in $env.NUPM_REGISTRIES
$env.NUPM_REGISTRIES = ($env.NUPM_INDEX_PATH | open-index
| merge ($env.NUPM_REGISTRIES? | default $DEFAULT_NUPM_REGISTRIES))

use std/log []
}
Expand Down
Loading