@@ -35,7 +35,6 @@ def __call__(self, session: Session) -> Callable[[bool], None]:
35
35
SRC_DIR = ROOT_DIR / "src"
36
36
CLIENT_DIR = SRC_DIR / "client"
37
37
REACTPY_DIR = SRC_DIR / "reactpy"
38
- LANGUAGE_TYPES : list [LanguageName ] = ["py" , "js" ]
39
38
TAG_PATTERN = re .compile (
40
39
# start
41
40
r"^"
@@ -46,7 +45,6 @@ def __call__(self, session: Session) -> Callable[[bool], None]:
46
45
# end
47
46
r"$"
48
47
)
49
- print (TAG_PATTERN .pattern )
50
48
REMAINING_ARGS = Option (nargs = REMAINDER , type = str )
51
49
52
50
@@ -89,6 +87,12 @@ def format(session: Session) -> None:
89
87
session .run ("npm" , "run" , "format" , external = True )
90
88
91
89
90
+ @group .session
91
+ def tsc (session : Session ) -> None :
92
+ session .chdir (CLIENT_DIR )
93
+ session .run ("npx" , "tsc" , "-b" , "-w" , "packages/app" , external = True )
94
+
95
+
92
96
@group .session
93
97
def example (session : Session ) -> None :
94
98
"""Run an example"""
@@ -269,16 +273,38 @@ def build_python(session: Session) -> None:
269
273
270
274
271
275
@group .session
272
- def publish (session : Session , dry_run : bool = False ) -> None :
276
+ def publish (
277
+ session : Session ,
278
+ publish_dry_run : Annotated [
279
+ bool ,
280
+ Option (help = "whether to test the release process" ),
281
+ ] = False ,
282
+ publish_fake_tags : Annotated [
283
+ Sequence [str ],
284
+ Option (nargs = "*" , type = str , help = "fake tags to use for a dry run release" ),
285
+ ] = (),
286
+ ) -> None :
273
287
packages = get_packages (session )
274
288
275
289
release_prep : dict [LanguageName , ReleasePrepFunc ] = {
276
290
"js" : prepare_javascript_release ,
277
291
"py" : prepare_python_release ,
278
292
}
279
293
294
+ if publish_fake_tags and not publish_dry_run :
295
+ session .error ("Cannot specify --publish-fake-tags without --publish-dry-run" )
296
+
297
+ parsed_tags : list [TagInfo ] = []
298
+ for tag in publish_fake_tags or get_current_tags (session ):
299
+ tag_info = parse_tag (tag )
300
+ if tag_info is None :
301
+ session .error (
302
+ f"Invalid tag { tag } - must be of the form <package>-<language>-<version>"
303
+ )
304
+ parsed_tags .append (tag_info )
305
+
280
306
publishers : list [tuple [Path , Callable [[bool ], None ]]] = []
281
- for tag , tag_pkg , tag_ver in get_current_tags ( session ) :
307
+ for tag , tag_pkg , tag_ver in parsed_tags :
282
308
if tag_pkg not in packages :
283
309
session .error (f"Tag { tag } references package { tag_pkg } that does not exist" )
284
310
@@ -296,7 +322,7 @@ def publish(session: Session, dry_run: bool = False) -> None:
296
322
for pkg_path , publish in publishers :
297
323
session .log (f"Publishing { pkg_path } ..." )
298
324
session .chdir (pkg_path )
299
- publish (dry_run )
325
+ publish (publish_dry_run )
300
326
301
327
302
328
# --- Utilities ------------------------------------------------------------------------
@@ -420,7 +446,7 @@ class PackageInfo(NamedTuple):
420
446
version : str
421
447
422
448
423
- def get_current_tags (session : Session ) -> list [TagInfo ]:
449
+ def get_current_tags (session : Session ) -> list [str ]:
424
450
"""Get tags for the current commit"""
425
451
# check if unstaged changes
426
452
try :
@@ -468,24 +494,20 @@ def get_current_tags(session: Session) -> list[TagInfo]:
468
494
if not tags :
469
495
session .error ("No tags found for current commit" )
470
496
471
- parsed_tags : list [TagInfo ] = []
472
- for tag in tags :
473
- match = TAG_PATTERN .match (tag )
474
- if not match :
475
- session .error (
476
- f"Invalid tag { tag } - must be of the form <package>-<language>-<version>"
477
- )
478
- parsed_tags .append (
479
- TagInfo (
480
- tag ,
481
- match ["name" ], # type: ignore[index]
482
- match ["version" ], # type: ignore[index]
483
- )
484
- )
497
+ session .log (f"Found tags: { tags } " )
485
498
486
- session . log ( f"Found tags: { [ info . tag for info in parsed_tags ] } " )
499
+ return tags
487
500
488
- return parsed_tags
501
+
502
+ def parse_tag (tag : str ) -> TagInfo | None :
503
+ match = TAG_PATTERN .match (tag )
504
+ if not match :
505
+ return None
506
+ return TagInfo (
507
+ tag ,
508
+ match ["name" ], # type: ignore[index]
509
+ match ["version" ], # type: ignore[index]
510
+ )
489
511
490
512
491
513
class TagInfo (NamedTuple ):
0 commit comments