Skip to content

Commit

Permalink
bump Nushell and Nupm (#140)
Browse files Browse the repository at this point in the history
this PR
- bumps Nushell to `0.88.1`
- bumps Nupm to
nushell/nupm@6a9618f
and nushell/nupm#50

## full changelog
- move the `src/nu-git-manager/` module to
`pkgs/nu-git-manager/nu-git-manager/`
- move the `src/nu-git-manager-sugar/` module to
`pkgs/nu-git-manager/nu-git-manager-sugar/`
- split `package.nuon` into `pkgs/nu-git-manager/package.nuon` and
`pkgs/nu-git-manager-sugar/package.nuon
- fix all the imports, especially in the tests
- fix the `install-package` test of `nu-git-manager`
- clone the `install-package` test from `nu-git-manager` to
`nu-git-manager-sugar`
- fix the listing of modules in the toolkit

## TODO
- [x] fix the CI => #135
  • Loading branch information
amtoine authored Dec 15, 2023
1 parent 6d2d176 commit 529ff39
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
tests:
uses: ./.github/workflows/nupm-tests.yml
with:
nu_version: "0.88.0"
nupm_revision: "f7c0843f4d667194beae468614a46cc8d72cc5db"
nu_version: "0.88.1"
nupm_revision: "6a9618fa21453bca4000ac33707b7aace0da35c7"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ git clone https://github.com/amtoine/nu-git-manager
- activate the `nupm` module with `use nupm`
- install the `nu-git-manager` package
```nushell
nupm install --path --force nu-git-manager
nupm install --path --force pkgs/nu-git-manager
```

> **Note**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions pkgs/nu-git-manager-sugar/package.nuon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
name: "nu-git-manager-sugar"
version: 0.4.0
description: "A collection of extra Nushell tools to manage `git` repositories."
documentation: "https://github.com/amtoine/nu-git-manager/blob/main/README.md"
maintainers: [
@amtoine
@melMass
]
license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE"
dependencies: {
nushell: 0.88.1
git: 2.40.1
optionals: {
"sugar gh": {
gh: 2.29.0
}
}
}
type: "module"
}
18 changes: 12 additions & 6 deletions tests/sugar/git.nu → pkgs/nu-git-manager-sugar/tests/git.nu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std assert

use ../../src/nu-git-manager-sugar/ git [
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/ git [
"gm repo get commit"
"gm repo goto root"
"gm repo branches"
Expand All @@ -11,8 +11,8 @@ use ../../src/nu-git-manager-sugar/ git [
"gm repo branch wipe"
"gm repo compare"
]
use ../../src/nu-git-manager/fs/path.nu ["path sanitize"]
use ../common/setup.nu [get-random-test-dir]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"]
use ../../../tests/common/setup.nu [get-random-test-dir]

def --env init-repo-and-cd-into []: nothing -> path {
let repo = get-random-test-dir --no-sanitize
Expand Down Expand Up @@ -354,9 +354,15 @@ export def branch-compare [] {
}

export module prompt {
use ../../src/nu-git-manager-sugar/git/lib/lib.nu [get-revision, git-action]
use ../../src/nu-git-manager-sugar/git/lib/prompt.nu [get-left-prompt]
use ../../src/nu-git-manager-sugar/git/lib/style.nu [simplify-path]
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu [
get-revision, git-action
]
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu [
get-left-prompt
]
use ../../../pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/style.nu [
simplify-path
]

def "assert revision" [expected: record] {
let actual = get-revision --short-hash true
Expand Down
17 changes: 16 additions & 1 deletion tests/sugar/mod.nu → pkgs/nu-git-manager-sugar/tests/mod.nu
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std assert

use ../common/import.nu ["assert imports"]
use ../../../tests/common/import.nu ["assert imports"]
use ../../../tests/common/setup.nu [get-random-test-dir]

const MODULE = "nu-git-manager-sugar"

Expand Down Expand Up @@ -41,3 +42,17 @@ export module imports {
def report [] {
exit 1
}

export def install-package [] {
# FIXME: is there a way to not rely on hardcoded paths here?
use ~/.local/share/nupm/modules/nupm

with-env {NUPM_HOME: (get-random-test-dir)} {
nupm install --no-confirm --path .

assert (not ($env.NUPM_HOME | path join "scripts" | path exists))
assert equal (ls ($env.NUPM_HOME | path join "modules") --short-names | get name) [nu-git-manager-sugar]

rm --recursive --force --verbose $env.NUPM_HOME
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 2 additions & 10 deletions package.nuon → pkgs/nu-git-manager/package.nuon
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,9 @@
]
license: "https://github.com/amtoine/nu-git-manager/blob/main/LICENSE"
dependencies: {
nushell: 0.88.0
nushell: 0.88.1
git: 2.40.1
optionals: {
"sugar gh": {
gh: 2.29.0
}
}
}
type: "module"
modules: [
"./src/nu-git-manager/",
"./src/nu-git-manager-sugar/",
]
}

10 changes: 5 additions & 5 deletions tests/gm.nu → pkgs/nu-git-manager/tests/gm.nu
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std assert

use ../src/nu-git-manager/fs/path.nu ["path sanitize"]
use ../src/nu-git-manager/git/repo.nu [list-remotes]
use ../src/nu-git-manager/ *
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"]
use ../../../pkgs/nu-git-manager/nu-git-manager/git/repo.nu [list-remotes]
use ../../../pkgs/nu-git-manager/nu-git-manager/ *

use common/setup.nu [get-random-test-dir]
use common/import.nu ["assert imports"]
use ../../../tests/common/setup.nu [get-random-test-dir]
use ../../../tests/common/import.nu ["assert imports"]

def run-with-env [code: closure, --prepare-cache] {
let TEST_ENV_BASE = get-random-test-dir
Expand Down
24 changes: 15 additions & 9 deletions tests/mod.nu → pkgs/nu-git-manager/tests/mod.nu
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
use std assert

use ../src/nu-git-manager/git/url.nu [parse-git-url, get-fetch-push-urls]
use ../src/nu-git-manager/git/repo.nu [is-grafted, get-root-commit, list-remotes]
use ../src/nu-git-manager/fs/store.nu [get-repo-store-path, list-repos-in-store]
use ../src/nu-git-manager/fs/cache.nu [
use ../../../pkgs/nu-git-manager/nu-git-manager/git/url.nu [
parse-git-url, get-fetch-push-urls
]
use ../../../pkgs/nu-git-manager/nu-git-manager/git/repo.nu [
is-grafted, get-root-commit, list-remotes
]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/store.nu [
get-repo-store-path, list-repos-in-store
]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/cache.nu [
get-repo-store-cache-path, check-cache-file, add-to-cache, remove-from-cache, open-cache,
save-cache, clean-cache-dir
]
use ../src/nu-git-manager/fs/path.nu [
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu [
"path sanitize", "path remove-prefix", "path remove-trailing-path-sep"
]
use ../src/nu-git-manager/fs/dir.nu [clean-empty-directories-rec]
use ../../../pkgs/nu-git-manager/nu-git-manager/fs/dir.nu [clean-empty-directories-rec]

use common/setup.nu [get-random-test-dir]
use ../../../tests/common/setup.nu [get-random-test-dir]

export module path {
export def sanitization [] {
Expand Down Expand Up @@ -247,8 +253,8 @@ export def install-package [] {
with-env {NUPM_HOME: (get-random-test-dir)} {
nupm install --no-confirm --path .

assert length (ls ($env.NUPM_HOME | path join "scripts")) 0
assert equal (ls ($env.NUPM_HOME | path join "modules") --short-names | get name) [nu-git-manager, nu-git-manager-sugar]
assert (not ($env.NUPM_HOME | path join "scripts" | path exists))
assert equal (ls ($env.NUPM_HOME | path join "modules") --short-names | get name) [nu-git-manager]

rm --recursive --force --verbose $env.NUPM_HOME
}
Expand Down
2 changes: 1 addition & 1 deletion tests/common/import.nu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export def "assert imports" [
| to nuon
" | from nuon
let after = ^$nu.current-exe --no-config-file --commands $"
use ./src/($module)/ ($submodule) *
use ./($module)/ ($submodule) *
scope commands | get name
| to nuon" | from nuon

Expand Down
2 changes: 1 addition & 1 deletion tests/common/setup.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ../../src/nu-git-manager/fs/path.nu ["path sanitize"]
use ../../pkgs/nu-git-manager/nu-git-manager/fs/path.nu ["path sanitize"]

# return the path to a random test directory
#
Expand Down
33 changes: 25 additions & 8 deletions toolkit.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
use std repeat

# NOTE: this will likely get replaced by Nupm workspaces in the future
def list-modules-of-workspace []: nothing -> list<string> {
ls pkgs/**/package.nuon
| insert pkg {|it| open $it.name | get name }
| each {|it| $it.name | path dirname | path join $it.pkg }
}

# run the tests of the `nu-git-manager` package
#
# > **Important**
Expand All @@ -8,22 +15,32 @@ export def "test" [
pattern?: string = "" # the pattern a test name should match to run
--verbose # show the output of each tests
]: nothing -> nothing {
let command = if $verbose {
$"nupm test ($pattern) --show-stdout"
let args = if $verbose {
"--show-stdout"
} else {
$"nupm test ($pattern)"
""
}

# NOTE: this is for the CI to pass without installing Nupm
^$nu.current-exe --env-config $nu.env-path --commands $"use nupm; ($command)"
^$nu.current-exe --env-config $nu.env-path --commands $"
use nupm
(list-modules-of-workspace) | each {|pkg|
nupm test ($pattern) ($args) --dir \($pkg | path dirname\)
}
"
}

# install `nu-git-manager` with Nupm
export def "install" []: nothing -> nothing {
let command = "nupm install --force --path (^git rev-parse --show-toplevel)"

# NOTE: this is for the CI to pass without installing Nupm
^$nu.current-exe --env-config $nu.env-path --commands $"use nupm; ($command)"
^$nu.current-exe --env-config $nu.env-path --commands $"
use nupm
(list-modules-of-workspace) | each {|pkg|
nupm install --force --path \($pkg | path dirname\)
}
"

null
}

# run some code inside an isolated environment
Expand Down Expand Up @@ -283,7 +300,7 @@ def document-module [
}

export def doc [--documentation-dir: path = "./docs/"] {
let modules = open package.nuon | get modules
let modules = list-modules-of-workspace

let documentation_dir = $documentation_dir | path expand

Expand Down

0 comments on commit 529ff39

Please sign in to comment.