From 027916799e3c0e42fa472c240b610f70efd2dc97 Mon Sep 17 00:00:00 2001 From: "la .panon." Date: Sun, 7 Jul 2024 12:20:31 +0900 Subject: [PATCH 1/4] Omit cloning if the package is on local When developing local dependent packages, the unmodified implementation should use ```console nimble develop file:///absolute/path/to/package ``` but this is not suitable for development since it will be cloned into a subdirectory. If the package is a local package, it is easier to handle it as is without cloning. With this change, ```console nimble develop file:///absolute/path/to/package --withDependencies ``` would change nimble.develop as follows: ```diff "dependencies": [ ... + "absolute/path/to/package" ] ``` --- src/nimblepkg/download.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nimblepkg/download.nim b/src/nimblepkg/download.nim index 86381df02..6b9ad6de4 100644 --- a/src/nimblepkg/download.nim +++ b/src/nimblepkg/download.nim @@ -531,15 +531,19 @@ proc getDevelopDownloadDir*(url, subdir: string, options: Options): string = let url = url.removeTrailingSlash let subdir = subdir.removeTrailingSlash + let uri = parseUri(url) + let downloadDirName = if subdir.len == 0: - parseUri(url).path.splitFile.name + uri.path.splitFile.name else: subdir.splitFile.name result = if options.action.path.isAbsolute: options.action.path / downloadDirName + elif uri.scheme == "file": + uri.path else: getCurrentDir() / options.action.path / downloadDirName From 88fda434d1714303cdad610e2dc2e12ac5e92090 Mon Sep 17 00:00:00 2001 From: "la .panon." Date: Sun, 7 Jul 2024 13:32:04 +0900 Subject: [PATCH 2/4] Attempt to interpret as a file path before the package name ```console nimble develop file:///absolute/path/to/package ``` is still a bit cumbersome and confusing for those not familiar with uri. ```console nimble develop /absolute/path/to/package ``` directory exists, the preferred UX would be to interpret this implicitly as file://. --- src/nimblepkg/download.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nimblepkg/download.nim b/src/nimblepkg/download.nim index 6b9ad6de4..e8fc09f43 100644 --- a/src/nimblepkg/download.nim +++ b/src/nimblepkg/download.nim @@ -581,6 +581,9 @@ proc getDownloadInfo*(pv: PkgTuple, options: Options, if pv.name.isURL: let (url, metadata) = getUrlData(pv.name) return (checkUrlType(url), url, metadata) + elif dirExists(pv.name): + let (url, metadata) = getUrlData("file://" & pv.name) + return (checkUrlType(url), url, metadata) else: var pkg = initPackage() if getPackage(pv.name, options, pkg, ignorePackageCache): From ea2ed50b536166285ea8d41be2240762561caa3f Mon Sep 17 00:00:00 2001 From: "la .panon." Date: Sun, 7 Jul 2024 13:50:32 +0900 Subject: [PATCH 3/4] Allow relative paths to be specified --- src/nimblepkg/download.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nimblepkg/download.nim b/src/nimblepkg/download.nim index e8fc09f43..4e7824c17 100644 --- a/src/nimblepkg/download.nim +++ b/src/nimblepkg/download.nim @@ -582,7 +582,7 @@ proc getDownloadInfo*(pv: PkgTuple, options: Options, let (url, metadata) = getUrlData(pv.name) return (checkUrlType(url), url, metadata) elif dirExists(pv.name): - let (url, metadata) = getUrlData("file://" & pv.name) + let (url, metadata) = getUrlData("file://" & expandFilename(pv.name)) return (checkUrlType(url), url, metadata) else: var pkg = initPackage() From 940b24be190598171965535df3da716c6c493b55 Mon Sep 17 00:00:00 2001 From: "la .panon." Date: Sun, 7 Jul 2024 15:23:09 +0900 Subject: [PATCH 4/4] Without the `--withDependencies` option, behaves the same as before --- src/nimblepkg/download.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nimblepkg/download.nim b/src/nimblepkg/download.nim index 4e7824c17..82849eaa6 100644 --- a/src/nimblepkg/download.nim +++ b/src/nimblepkg/download.nim @@ -542,7 +542,7 @@ proc getDevelopDownloadDir*(url, subdir: string, options: Options): string = result = if options.action.path.isAbsolute: options.action.path / downloadDirName - elif uri.scheme == "file": + elif options.action.withDependencies and uri.scheme == "file": uri.path else: getCurrentDir() / options.action.path / downloadDirName