mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
Atlas: some final cleanups (#21947)
This commit is contained in:
20
doc/atlas.md
20
doc/atlas.md
@@ -1,7 +1,7 @@
|
||||
# Atlas Package Cloner
|
||||
|
||||
Atlas is a simple package cloner tool that automates some of the
|
||||
workflows and needs for Nim's stdlib evolution.
|
||||
Atlas is a simple package cloner tool. It manages an isolated workspace that
|
||||
contains projects and dependencies.
|
||||
|
||||
Atlas is compatible with Nimble in the sense that it supports the Nimble
|
||||
file format.
|
||||
@@ -103,7 +103,7 @@ For example:
|
||||
```
|
||||
|
||||
|
||||
### Clone/Update <url>
|
||||
### Clone/Update <url>/<package name>
|
||||
|
||||
Clones a URL and all of its dependencies (recursively) into the workspace.
|
||||
Creates or patches a `nim.cfg` file with the required `--path` entries.
|
||||
@@ -111,12 +111,8 @@ Creates or patches a `nim.cfg` file with the required `--path` entries.
|
||||
**Note**: Due to the used algorithms an `update` is the same as a `clone`.
|
||||
|
||||
|
||||
### Clone/Update <package name>
|
||||
|
||||
The `<package name>` is translated into an URL via `packages.json` and
|
||||
then `clone <url>` is performed.
|
||||
|
||||
**Note**: Due to the used algorithms an `update` is the same as a `clone`.
|
||||
If a `<package name>` is given instead the name is first translated into an URL
|
||||
via `packages.json` or via a github search.
|
||||
|
||||
|
||||
### Search <term term2 term3 ...>
|
||||
@@ -129,10 +125,10 @@ in its description (or name or list of tags).
|
||||
|
||||
Use the .nimble file to setup the project's dependencies.
|
||||
|
||||
### UpdateWorkspace [filter]
|
||||
### UpdateProjects / updateDeps [filter]
|
||||
|
||||
Update every package in the workspace that has a remote URL that
|
||||
matches `filter` if a filter is given. The package is only updated
|
||||
Update every project / dependency in the workspace that has a remote URL that
|
||||
matches `filter` if a filter is given. The project / dependency is only updated
|
||||
if there are no uncommitted changes.
|
||||
|
||||
### Others
|
||||
|
||||
@@ -42,5 +42,5 @@ The standard distribution ships with the following tools:
|
||||
so can be useful to run your tests, even the most complex ones.
|
||||
|
||||
- | [atlas](atlas.html)
|
||||
| `atlas`:cmd: is a simple package cloner tool that automates some of the
|
||||
workflows and needs for Nim's stdlib evolution.
|
||||
| `atlas`:cmd: is a simple package cloner tool. It manages an isolated workspace that
|
||||
contains projects and dependencies.
|
||||
|
||||
@@ -106,7 +106,7 @@ type
|
||||
keepCommits: bool
|
||||
cfgHere: bool
|
||||
p: Table[string, string] # name -> url mapping
|
||||
errors: int
|
||||
errors, warnings: int
|
||||
lockOption: LockOption
|
||||
lockFileToWrite: seq[LockFileEntry]
|
||||
lockFileToUse: Table[string, LockFileEntry]
|
||||
@@ -224,7 +224,7 @@ proc warn(c: var AtlasContext; p: PackageName; arg: string) =
|
||||
message(c, "[Warning] ", p, arg)
|
||||
else:
|
||||
stdout.styledWriteLine(fgYellow, styleBright, "[Warning] ", resetStyle, fgCyan, "(", p.string, ")", resetStyle, " ", arg)
|
||||
inc c.errors
|
||||
inc c.warnings
|
||||
|
||||
proc error(c: var AtlasContext; p: PackageName; arg: string) =
|
||||
if c.noColors:
|
||||
@@ -239,6 +239,8 @@ proc info(c: var AtlasContext; p: PackageName; arg: string) =
|
||||
else:
|
||||
stdout.styledWriteLine(fgGreen, styleBright, "[Info] ", resetStyle, fgCyan, "(", p.string, ")", resetStyle, " ", arg)
|
||||
|
||||
template projectFromCurrentDir(): PackageName = PackageName(getCurrentDir().splitPath.tail)
|
||||
|
||||
proc sameVersionAs(tag, ver: string): bool =
|
||||
const VersionChars = {'0'..'9', '.'}
|
||||
|
||||
@@ -317,14 +319,16 @@ proc pushTag(c: var AtlasContext; tag: string) =
|
||||
else:
|
||||
info(c, c.projectDir.PackageName, "successfully pushed tag: " & tag)
|
||||
|
||||
proc incrementTag(lastTag: string; field: Natural): string =
|
||||
proc incrementTag(c: var AtlasContext; lastTag: string; field: Natural): string =
|
||||
var startPos =
|
||||
if lastTag[0] in {'0'..'9'}: 0
|
||||
else: 1
|
||||
var endPos = lastTag.find('.', startPos)
|
||||
if field >= 1:
|
||||
for i in 1 .. field:
|
||||
assert endPos != -1, "the last tag '" & lastTag & "' is missing . periods"
|
||||
if endPos == -1:
|
||||
error c, projectFromCurrentDir(), "the last tag '" & lastTag & "' is missing . periods"
|
||||
return ""
|
||||
startPos = endPos + 1
|
||||
endPos = lastTag.find('.', startPos)
|
||||
if endPos == -1:
|
||||
@@ -344,7 +348,7 @@ proc incrementLastTag(c: var AtlasContext; field: Natural): string =
|
||||
info c, c.projectDir.PackageName, "the current commit '" & currentCommit & "' is already tagged '" & lastTag & "'"
|
||||
lastTag
|
||||
else:
|
||||
incrementTag(lastTag, field)
|
||||
incrementTag(c, lastTag, field)
|
||||
else: "v0.0.1" # assuming no tags have been made yet
|
||||
|
||||
proc tag(c: var AtlasContext; tag: string) =
|
||||
@@ -602,8 +606,6 @@ const
|
||||
configPatternBegin = "############# begin Atlas config section ##########\n"
|
||||
configPatternEnd = "############# end Atlas config section ##########\n"
|
||||
|
||||
template projectFromCurrentDir(): PackageName = PackageName(getCurrentDir().splitPath.tail)
|
||||
|
||||
proc patchNimCfg(c: var AtlasContext; deps: seq[CfgPath]; cfgPath: string) =
|
||||
var paths = "--noNimblePath\n"
|
||||
for d in deps:
|
||||
@@ -936,6 +938,9 @@ proc main =
|
||||
elif args[0].len == 1 and args[0][0] in {'a'..'z'}:
|
||||
let field = ord(args[0][0]) - ord('a')
|
||||
tag(c, field)
|
||||
elif args[0].len == 1 and args[0][0] in {'A'..'Z'}:
|
||||
let field = ord(args[0][0]) - ord('A')
|
||||
tag(c, field)
|
||||
elif '.' in args[0]:
|
||||
tag(c, args[0])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user