Added semver? symbol, added version task.
h3rald h3rald@h3rald.com
Sat, 05 Dec 2020 14:31:36 +0100
7 files changed,
66 insertions(+),
11 deletions(-)
M
core/interpreter.nim
→
core/interpreter.nim
@@ -301,7 +301,6 @@ contents = ";;\n" & fileLines[1..fileLines.len-1].join("\n")
else: contents = fileLines.join("\n") var i2 = i.copy(s) - echo contents i2.open(newStringStream(contents), s) discard i2.parser.getToken() result = i2.interpret(parseOnly)
M
lib/min_lang.nim
→
lib/min_lang.nim
@@ -82,7 +82,7 @@ let lines = s.strVal.split("\n")
for line in lines: let pair = line.split(":") i.dset(dict, pair[0].strip, pair[1].strip.newVal) - i.push(dict) + i.push(dict) except: raiseInvalid("Invalid/unsupported YAML object (only dictionaries with string values are supported)")
M
lib/min_str.nim
→
lib/min_str.nim
@@ -150,6 +150,11 @@ var res = newSeq[MinValue](0)
for r in results: res.add(r.newVal) i.push res.newVal + + def.symbol("semver?") do (i: In): + let vals = i.expect("string") + let v = vals[0].strVal + i.push v.match("^\\d+\\.\\d+\\.\\d+$").newVal def.symbol("from-semver") do (i: In): let vals = i.expect("string")
M
site/contents/reference-str.md
→
site/contents/reference-str.md
@@ -158,6 +158,9 @@
{#op||semver-inc-patch||{{s1}}||{{s2}}|| Increments the patch digit of the [SemVer](https://semver.org)-compliant string (with no additional labels) {{s1}}. #} +{#op||semver?||{{s}}||{{b}}|| +Checks whether {{s}} is a [SemVer](https://semver.org)-compliant version or not. #} + {#op||split||{{sl1}} {{sl2}}||{{q}}|| Splits {{sl1}} using separator {{sl2}} and returns the resulting strings within the quotation {{q}}. #}
M
site/settings.json
→
site/settings.json
@@ -1,10 +1,10 @@
{ - "contents": "contents", "assets": "assets", - "templates": "templates", - "temp": "temp", + "contents": "contents", "output": "output", + "rules": "rules.min", + "temp": "temp", + "templates": "templates", "title": "min language", - "version": "0.22.0", - "rules": "rules.min" -} + "version": "0.23.0" +}
A
tasks/version.min
@@ -0,0 +1,48 @@
+#!/usr/bin/env min + +"min.yml" :yaml-cfg +"site/settings.json" :json-site-cfg + +yaml-cfg fread from-yaml :config +config /version :old-version +( + :new-version + config new-version %version @config + config to-yaml yaml-cfg fwrite +) :update-yaml-config +( + :new-version + json-site-cfg fread from-json :site-config + site-config new-version %version @site-config + site-config to-json json-site-cfg fwrite +) :update-site-config + +; Module tasks +{} +( + "" :new-version + false :valid-semver + (valid-semver not) + ( + "New version" ask @new-version + new-version semver? @valid-semver + ) while + new-version update-yaml-config + new-version update-site-config +) %set +( + old-version semver-inc-major :new-version + new-version update-yaml-config + new-version update-site-config +) %major +( + old-version semver-inc-minor :new-version + new-version update-yaml-config + new-version update-site-config +) %minor +( + old-version semver-inc-patch :new-version + new-version update-yaml-config + new-version update-site-config +) %patch ++version-tasks