1+ #############################################################################
2+ # Copyright (c) 2018, Voila Contributors #
3+ # Copyright (c) 2018, QuantStack #
4+ # #
5+ # Distributed under the terms of the BSD 3-Clause License. #
6+ # #
7+ # The full license is in the file LICENSE, distributed with this software. #
8+ #############################################################################
9+
10+ import click
11+ from jupyter_releaser .util import get_version , run
12+ from pkg_resources import parse_version
13+
14+ LERNA_CMD = "jlpm run lerna version --no-push --force-publish --no-git-tag-version"
15+
16+
17+ @click .command ()
18+ @click .option ("--force" , default = False , is_flag = True )
19+ @click .argument ("spec" , nargs = 1 )
20+ def bump (force , spec ):
21+ status = run ("git status --porcelain" ).strip ()
22+ if len (status ) > 0 :
23+ raise Exception ("Must be in a clean git state with no untracked files" )
24+
25+ curr = parse_version (get_version ())
26+ if spec == 'next' :
27+ spec = f"{ curr .major } .{ curr .minor } ."
28+ if curr .pre :
29+ p , x = curr .pre
30+ spec += f"{ curr .micro } { p } { x + 1 } "
31+ else :
32+ spec += f"{ curr .micro + 1 } "
33+
34+ elif spec == 'patch' :
35+ spec = f"{ curr .major } .{ curr .minor } ."
36+ if curr .pre :
37+ spec += f"{ curr .micro } "
38+ else :
39+ spec += f"{ curr .micro + 1 } "
40+
41+
42+ version = parse_version (spec )
43+
44+ # convert the Python version
45+ js_version = f"{ version .major } .{ version .minor } .{ version .micro } "
46+ if version .pre :
47+ p , x = version .pre
48+ p = p .replace ("a" , "alpha" ).replace ("b" , "beta" )
49+ js_version += f"-{ p } .{ x } "
50+
51+ # bump the JS packages
52+ lerna_cmd = f"{ LERNA_CMD } { js_version } "
53+ if force :
54+ lerna_cmd += " --yes"
55+ run (lerna_cmd )
56+
57+
58+ if __name__ == "__main__" :
59+ bump ()
0 commit comments