all repos — min @ 877cfd95409ab21b1ec1ec77c24249bf1411b2fb

A small but practical concatenative programming language.

tasks/version.min

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
#!/usr/bin/env min

"min.yml" :yaml-cfg
"min.nimble" :nimble-cfg
"site/settings.json" :json-site-cfg

yaml-cfg fread from-yaml :config
config "version" dget :old-version
nimble-cfg fread :nimble-data


(
  symbol update-yaml-config
  ('sym :new-version ==>)
  (
    config new-version "version" dset @config
    config to-yaml yaml-cfg fwrite
  )  
) ::
;; Sets the version in the min.yml file to new-version.

(
  symbol update-site-config
  ('sym :new-version ==>)
  (
    json-site-cfg fread from-json :site-config
    site-config new-version "version" dset @site-config
    site-config to-json json-site-cfg fwrite
  )
) ::
;; Updates the version of the web site to new-version.

(
  symbol update-nimble-config
  ('sym :new-version ==>)
  (
    "(version\\s+=\\s*)([^\\s]+)(\\s*)" :version-regexp
    nimble-data version-regexp 
      (stack.dup 1 get :start 3 get :end "$#\"$#\"$#" (start new-version end) =%) replace-apply @nimble-data
    nimble-data nimble-cfg fwrite
  )
) ::
;; Updates the version in the nimble file to new-version.

#|| Tasks ||#

(
  symbol set
  (==>)
  (
    "" :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
  )
) ::
;; Asks and sets the new min version where appropriate.

(
  symbol major
  (==>)
  (
    old-version semver-inc-major :new-version
    new-version update-yaml-config
    new-version update-site-config
    new-version update-nimble-config
  )
) ::
;; Increments the min major version.

(
  symbol minor
  (==>)
  (
    old-version semver-inc-minor :new-version
    new-version update-yaml-config
    new-version update-site-config
    new-version update-nimble-config
  )
) ::
;; Increments the min minor version.

(
  symbol patch
  (==>)
  (
    old-version semver-inc-patch :new-version
    new-version update-yaml-config
    new-version update-site-config
    new-version update-nimble-config
  )
) ::
;; Increments the min patch version.