Improves nimble init (more licenses and consistent identifiers).
This commit is contained in:
parent
094b6fe180
commit
cc71c6f80e
1 changed files with 48 additions and 18 deletions
|
|
@ -699,10 +699,13 @@ proc dump(options: Options) =
|
||||||
|
|
||||||
proc init(options: Options) =
|
proc init(options: Options) =
|
||||||
if options.forcePrompts != forcePromptYes:
|
if options.forcePrompts != forcePromptYes:
|
||||||
display("Info:",
|
display(
|
||||||
"In order to initialise a new Nimble package, I will need to ask you\n" &
|
"Info:",
|
||||||
"some questions. Default values are shown in square brackets, press\n" &
|
"Package initialisation requires info which could not be inferred.\n" &
|
||||||
"enter to use them.", priority = HighPriority)
|
"Default values are shown in square brackets, press\n" &
|
||||||
|
"enter to use them.",
|
||||||
|
priority = HighPriority
|
||||||
|
)
|
||||||
|
|
||||||
# Determine the package name.
|
# Determine the package name.
|
||||||
let pkgName =
|
let pkgName =
|
||||||
|
|
@ -715,7 +718,8 @@ proc init(options: Options) =
|
||||||
validatePackageName(pkgName)
|
validatePackageName(pkgName)
|
||||||
|
|
||||||
# Determine the package root.
|
# Determine the package root.
|
||||||
let pkgRoot = if pkgName == os.getCurrentDir().splitPath.tail:
|
let pkgRoot =
|
||||||
|
if pkgName == os.getCurrentDir().splitPath.tail:
|
||||||
os.getCurrentDir()
|
os.getCurrentDir()
|
||||||
else:
|
else:
|
||||||
os.getCurrentDir() / pkgName
|
os.getCurrentDir() / pkgName
|
||||||
|
|
@ -754,12 +758,16 @@ proc init(options: Options) =
|
||||||
priority = HighPriority)
|
priority = HighPriority)
|
||||||
|
|
||||||
# Determine the type of package
|
# Determine the type of package
|
||||||
let pkgType = promptList(options, """Package type?
|
let pkgType = promptList(
|
||||||
Library packages provide functionality for other packages.
|
options,
|
||||||
Binary packages produce executables.""", [
|
"""Package type?
|
||||||
"lib",
|
Library - provides functionality for other packages.
|
||||||
"bin",
|
Binary - produces an executable for the end-user.
|
||||||
])
|
Hybrid - combination of library and binary
|
||||||
|
|
||||||
|
For more information see https://goo.gl/cm2RX5""",
|
||||||
|
["library", "binary", "hybrid"]
|
||||||
|
)
|
||||||
|
|
||||||
# Ask for package version.
|
# Ask for package version.
|
||||||
let pkgVersion = promptCustom(options, "Initial version of package?", "0.1.0")
|
let pkgVersion = promptCustom(options, "Initial version of package?", "0.1.0")
|
||||||
|
|
@ -770,14 +778,33 @@ Binary packages produce executables.""", [
|
||||||
"A new awesome nimble package")
|
"A new awesome nimble package")
|
||||||
|
|
||||||
# Ask for license
|
# Ask for license
|
||||||
let pkgLicense = options.promptList("Package License?", [
|
# License list is based on:
|
||||||
|
# https://www.blackducksoftware.com/top-open-source-licenses
|
||||||
|
var pkgLicense = options.promptList(
|
||||||
|
"""Package License?
|
||||||
|
This should ideally be a valid SPDX identifier. See https://spdx.org/licenses/.
|
||||||
|
""", [
|
||||||
"MIT",
|
"MIT",
|
||||||
"BSD2",
|
"GPL-2.0",
|
||||||
"GPLv3",
|
"Apache-2.0",
|
||||||
"LGPLv3",
|
"ISC",
|
||||||
"Apache2",
|
"GPL-3.0",
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"LGPL-2.1",
|
||||||
|
"LGPL-3.0",
|
||||||
|
"EPL-2.0",
|
||||||
|
# This is what npm calls "UNLICENSED" (which is too similar to "Unlicense")
|
||||||
|
"Proprietary",
|
||||||
|
"Other"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if pkgLicense.toLower == "other":
|
||||||
|
pkgLicense = promptCustom(options,
|
||||||
|
"""Package license?
|
||||||
|
Please specify a valid SPDX identifier.""",
|
||||||
|
"MIT"
|
||||||
|
)
|
||||||
|
|
||||||
# Ask for Nim dependency
|
# Ask for Nim dependency
|
||||||
let nimDepDef = getNimrodVersion()
|
let nimDepDef = getNimrodVersion()
|
||||||
let pkgNimDep = promptCustom(options, "Lowest supported Nim version?",
|
let pkgNimDep = promptCustom(options, "Lowest supported Nim version?",
|
||||||
|
|
@ -864,8 +891,11 @@ requires "nim >= $#"
|
||||||
""" % [pkgVersion.escape(), pkgAuthor.escape(), pkgDesc.escape(),
|
""" % [pkgVersion.escape(), pkgAuthor.escape(), pkgDesc.escape(),
|
||||||
pkgLicense.escape(), pkgSrcDir.escape(), pkgName.escape(), pkgNimDep]
|
pkgLicense.escape(), pkgSrcDir.escape(), pkgName.escape(), pkgNimDep]
|
||||||
except:
|
except:
|
||||||
raise newException(NimbleError, "Unable to open file " & "test1.nim" &
|
raise newException(
|
||||||
" for writing: " & osErrorMsg(osLastError()))
|
NimbleError,
|
||||||
|
"Unable to open file " & nimbleFile & " for writing: " &
|
||||||
|
osErrorMsg(osLastError())
|
||||||
|
)
|
||||||
|
|
||||||
display("Success:", "Nimble file created successfully", Success,
|
display("Success:", "Nimble file created successfully", Success,
|
||||||
MediumPriority)
|
MediumPriority)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue