Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor deps dir for 'atlas init --deps=deps' #131

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/atlas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import std / [parseopt, strutils, os, osproc, tables, sets, json, jsonutils]
import versions, context, osutils, packagesjson, gitops, nimenv, lockfiles,
depgraphs, confighandler, configutils, cloner, nimblechecksums, reporters,

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / linux-amd64-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-i386-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / windows-amd64-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'nimblechecksums' [UnusedImport]

Check warning on line 14 in src/atlas.nim

View workflow job for this annotation

GitHub Actions / macos-amd64-nim-devel (master)

imported and not used: 'cloner' [UnusedImport]
nimbleparser, pkgurls

from std/terminal import isatty
Expand Down Expand Up @@ -382,7 +382,7 @@
c.currentDir = getCurrentDir() / val
of "deps":
if val.len > 0:
c.depsDir = val
c.origDepsDir = val
explicitDepsDirOverride = true
else:
writeHelp()
Expand Down Expand Up @@ -435,8 +435,8 @@
elif action notin ["search", "list"]:
fatal "No workspace found. Run `atlas init` if you want this current directory to be your workspace."

if not explicitDepsDirOverride and action notin ["init", "tag"] and c.depsDir.len == 0:
c.depsDir = c.workspace
if not explicitDepsDirOverride and action notin ["init", "tag"] and c.origDepsDir.len == 0:
c.origDepsDir = ""
if action != "tag":
createDir(c.depsDir)

Expand Down
4 changes: 1 addition & 3 deletions src/confighandler.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type
graph: JsonNode

proc writeDefaultConfigFile*(c: var AtlasContext) =
let config = JsonConfig(resolver: $SemVer, graph: newJNull())
let config = JsonConfig(deps: c.origDepsDir, resolver: $SemVer, graph: newJNull())
let configFile = c.workspace / AtlasWorkspace
writeFile(configFile, pretty %*config)

Expand All @@ -67,9 +67,7 @@ proc readConfig*(c: var AtlasContext) =
try:
let m = j.to(JsonConfig)
if m.deps.len > 0:
c.depsDir = m.deps
c.origDepsDir = m.deps
#absoluteDepsDir(c.workspace, m.deps)
if m.overrides.len > 0:
c.overridesFile = m.overrides
parseOverridesFile(c, m.overrides)
Expand Down
11 changes: 9 additions & 2 deletions src/context.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,26 @@ type
IgnoreUrls

AtlasContext* = object of Reporter
projectDir*, workspace*, depsDir*, currentDir*: string
projectDir*, workspace*, origDepsDir*, currentDir*: string
flags*: set[Flag]
#urlMapping*: Table[string, Package] # name -> url mapping
overrides*: Patterns
defaultAlgo*: ResolutionAlgorithm
plugins*: PluginInfo
overridesFile*: string
pluginsFile*: string
origDepsDir*: string


proc `==`*(a, b: CfgPath): bool {.borrow.}

proc depsDir*(c: AtlasContext): string =
if c.origDepsDir == "":
c.workspace
elif c.origDepsDir.isAbsolute:
c.origDepsDir
else:
(c.workspace / c.origDepsDir).absolutePath

proc displayName(c: AtlasContext; p: string): string =
if p == c.workspace:
p.absolutePath
Expand Down
3 changes: 1 addition & 2 deletions src/depgraphs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ proc pkgUrlToDirname(c: var AtlasContext; g: var DepGraph; d: Dependency): (stri
if d.isTopLevel:
dest = c.workspace
else:
let depsDir = if d.isRoot: c.workspace else: c.depsDir
dest = depsDir / d.pkg.projectName
dest = c.depsDir / d.pkg.projectName
result = (dest, if dirExists(dest): DoNothing else: DoClone)

proc toDestDir*(g: DepGraph; d: Dependency): string =
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let

proc initBasicWorkspace(typ: type AtlasContext): AtlasContext =
result.workspace = currentSourcePath().parentDir / "ws_basic"
result.depsDir = result.workspace
result.origDepsDir = result.workspace

when false:
suite "urls and naming":
Expand Down
Loading