diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5263c022..5450e2e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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" diff --git a/README.md b/README.md index 0405f889..c46d6d6e 100644 --- a/README.md +++ b/README.md @@ -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** diff --git a/src/nu-git-manager-sugar/completions/nu-complete.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/completions/nu-complete.nu similarity index 100% rename from src/nu-git-manager-sugar/completions/nu-complete.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/completions/nu-complete.nu diff --git a/src/nu-git-manager-sugar/extra.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/extra.nu similarity index 100% rename from src/nu-git-manager-sugar/extra.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/extra.nu diff --git a/src/nu-git-manager-sugar/git/lib/lib.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu similarity index 100% rename from src/nu-git-manager-sugar/git/lib/lib.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/lib.nu diff --git a/src/nu-git-manager-sugar/git/lib/prompt.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu similarity index 100% rename from src/nu-git-manager-sugar/git/lib/prompt.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/prompt.nu diff --git a/src/nu-git-manager-sugar/git/lib/style.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/style.nu similarity index 100% rename from src/nu-git-manager-sugar/git/lib/style.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/lib/style.nu diff --git a/src/nu-git-manager-sugar/git/mod.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu similarity index 100% rename from src/nu-git-manager-sugar/git/mod.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/mod.nu diff --git a/src/nu-git-manager-sugar/git/prompt.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/prompt.nu similarity index 100% rename from src/nu-git-manager-sugar/git/prompt.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/git/prompt.nu diff --git a/src/nu-git-manager-sugar/github.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/github.nu similarity index 100% rename from src/nu-git-manager-sugar/github.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/github.nu diff --git a/src/nu-git-manager-sugar/mod.nu b/pkgs/nu-git-manager-sugar/nu-git-manager-sugar/mod.nu similarity index 100% rename from src/nu-git-manager-sugar/mod.nu rename to pkgs/nu-git-manager-sugar/nu-git-manager-sugar/mod.nu diff --git a/pkgs/nu-git-manager-sugar/package.nuon b/pkgs/nu-git-manager-sugar/package.nuon new file mode 100644 index 00000000..974b12fa --- /dev/null +++ b/pkgs/nu-git-manager-sugar/package.nuon @@ -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" +} diff --git a/tests/sugar/git.nu b/pkgs/nu-git-manager-sugar/tests/git.nu similarity index 95% rename from tests/sugar/git.nu rename to pkgs/nu-git-manager-sugar/tests/git.nu index 7da52c1b..879c2246 100644 --- a/tests/sugar/git.nu +++ b/pkgs/nu-git-manager-sugar/tests/git.nu @@ -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" @@ -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 @@ -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 diff --git a/tests/sugar/mod.nu b/pkgs/nu-git-manager-sugar/tests/mod.nu similarity index 61% rename from tests/sugar/mod.nu rename to pkgs/nu-git-manager-sugar/tests/mod.nu index fed29e15..188dfe7c 100644 --- a/tests/sugar/mod.nu +++ b/pkgs/nu-git-manager-sugar/tests/mod.nu @@ -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" @@ -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 + } +} diff --git a/src/nu-git-manager/completions/nu-complete.nu b/pkgs/nu-git-manager/nu-git-manager/completions/nu-complete.nu similarity index 100% rename from src/nu-git-manager/completions/nu-complete.nu rename to pkgs/nu-git-manager/nu-git-manager/completions/nu-complete.nu diff --git a/src/nu-git-manager/error/error.nu b/pkgs/nu-git-manager/nu-git-manager/error/error.nu similarity index 100% rename from src/nu-git-manager/error/error.nu rename to pkgs/nu-git-manager/nu-git-manager/error/error.nu diff --git a/src/nu-git-manager/fs/cache.nu b/pkgs/nu-git-manager/nu-git-manager/fs/cache.nu similarity index 100% rename from src/nu-git-manager/fs/cache.nu rename to pkgs/nu-git-manager/nu-git-manager/fs/cache.nu diff --git a/src/nu-git-manager/fs/dir.nu b/pkgs/nu-git-manager/nu-git-manager/fs/dir.nu similarity index 100% rename from src/nu-git-manager/fs/dir.nu rename to pkgs/nu-git-manager/nu-git-manager/fs/dir.nu diff --git a/src/nu-git-manager/fs/path.nu b/pkgs/nu-git-manager/nu-git-manager/fs/path.nu similarity index 100% rename from src/nu-git-manager/fs/path.nu rename to pkgs/nu-git-manager/nu-git-manager/fs/path.nu diff --git a/src/nu-git-manager/fs/store.nu b/pkgs/nu-git-manager/nu-git-manager/fs/store.nu similarity index 100% rename from src/nu-git-manager/fs/store.nu rename to pkgs/nu-git-manager/nu-git-manager/fs/store.nu diff --git a/src/nu-git-manager/git/repo.nu b/pkgs/nu-git-manager/nu-git-manager/git/repo.nu similarity index 100% rename from src/nu-git-manager/git/repo.nu rename to pkgs/nu-git-manager/nu-git-manager/git/repo.nu diff --git a/src/nu-git-manager/git/url.nu b/pkgs/nu-git-manager/nu-git-manager/git/url.nu similarity index 100% rename from src/nu-git-manager/git/url.nu rename to pkgs/nu-git-manager/nu-git-manager/git/url.nu diff --git a/src/nu-git-manager/mod.nu b/pkgs/nu-git-manager/nu-git-manager/mod.nu similarity index 100% rename from src/nu-git-manager/mod.nu rename to pkgs/nu-git-manager/nu-git-manager/mod.nu diff --git a/package.nuon b/pkgs/nu-git-manager/package.nuon similarity index 65% rename from package.nuon rename to pkgs/nu-git-manager/package.nuon index 3886fdf9..e17af38f 100644 --- a/package.nuon +++ b/pkgs/nu-git-manager/package.nuon @@ -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/", - ] } + diff --git a/tests/gm.nu b/pkgs/nu-git-manager/tests/gm.nu similarity index 97% rename from tests/gm.nu rename to pkgs/nu-git-manager/tests/gm.nu index f8262a9b..ceb9f978 100644 --- a/tests/gm.nu +++ b/pkgs/nu-git-manager/tests/gm.nu @@ -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 diff --git a/tests/mod.nu b/pkgs/nu-git-manager/tests/mod.nu similarity index 94% rename from tests/mod.nu rename to pkgs/nu-git-manager/tests/mod.nu index 59959648..e9f1f63a 100644 --- a/tests/mod.nu +++ b/pkgs/nu-git-manager/tests/mod.nu @@ -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 [] { @@ -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 } diff --git a/tests/common/import.nu b/tests/common/import.nu index ce754326..f3226ce3 100644 --- a/tests/common/import.nu +++ b/tests/common/import.nu @@ -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 diff --git a/tests/common/setup.nu b/tests/common/setup.nu index e4baf954..476e2588 100644 --- a/tests/common/setup.nu +++ b/tests/common/setup.nu @@ -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 # diff --git a/toolkit.nu b/toolkit.nu index 3b7e2374..fd3345e4 100644 --- a/toolkit.nu +++ b/toolkit.nu @@ -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 { + 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** @@ -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 @@ -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