cleepcli 1.48.0__tar.gz → 1.49.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {cleepcli-1.48.0/cleepcli.egg-info → cleepcli-1.49.0}/PKG-INFO +8 -8
  2. {cleepcli-1.48.0 → cleepcli-1.49.0}/README.md +2 -2
  3. {cleepcli-1.48.0 → cleepcli-1.49.0}/bin/ccli +193 -14
  4. {cleepcli-1.48.0 → cleepcli-1.49.0}/bin/cleep-cli +193 -14
  5. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/check.py +32 -9
  6. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/cleepapi.py +26 -0
  7. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/config.py +11 -0
  8. cleepcli-1.49.0/cleepcli/pico.py +407 -0
  9. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/version.py +1 -1
  10. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/watch.py +15 -0
  11. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/watchsvc.py +32 -1
  12. {cleepcli-1.48.0 → cleepcli-1.49.0/cleepcli.egg-info}/PKG-INFO +8 -8
  13. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli.egg-info/SOURCES.txt +2 -0
  14. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli.egg-info/requires.txt +5 -5
  15. cleepcli-1.49.0/requirements.txt +18 -0
  16. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_file_sync_all.py +70 -4
  17. cleepcli-1.49.0/tests/test_pico.py +95 -0
  18. cleepcli-1.49.0/tests/test_watchsvc.py +109 -0
  19. cleepcli-1.48.0/requirements.txt +0 -15
  20. cleepcli-1.48.0/tests/test_watchsvc.py +0 -57
  21. {cleepcli-1.48.0 → cleepcli-1.49.0}/LICENSE +0 -0
  22. {cleepcli-1.48.0 → cleepcli-1.49.0}/MANIFEST.in +0 -0
  23. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/__init__.py +0 -0
  24. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/ci.py +0 -0
  25. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/console.py +0 -0
  26. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/docs.py +0 -0
  27. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/file.py +0 -0
  28. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/git.py +0 -0
  29. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/module.py +0 -0
  30. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/package.py +0 -0
  31. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/systemd/cleep-watch.service +0 -0
  32. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/test.py +0 -0
  33. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli/tools.py +0 -0
  34. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli.egg-info/dependency_links.txt +0 -0
  35. {cleepcli-1.48.0 → cleepcli-1.49.0}/cleepcli.egg-info/top_level.txt +0 -0
  36. {cleepcli-1.48.0 → cleepcli-1.49.0}/pyproject.toml +0 -0
  37. {cleepcli-1.48.0 → cleepcli-1.49.0}/setup.cfg +0 -0
  38. {cleepcli-1.48.0 → cleepcli-1.49.0}/setup.py +0 -0
  39. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_check.py +0 -0
  40. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_config.py +0 -0
  41. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_console.py +0 -0
  42. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_coverage.py +0 -0
  43. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_docs_breaking.py +0 -0
  44. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_module_scaffold.py +0 -0
  45. {cleepcli-1.48.0 → cleepcli-1.49.0}/tests/test_watch.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cleepcli
3
- Version: 1.48.0
3
+ Version: 1.49.0
4
4
  Summary: Cleep-cli helps developers to build great Cleep applications from command line.
5
5
  Home-page: https://github.com/CleepDevice/cleep-cli
6
6
  Author: Tanguy Bonneau
@@ -17,11 +17,11 @@ Requires-Dist: sphinx-rtd-theme>=1.0.0
17
17
  Requires-Dist: CProfileV>=1.0.7
18
18
  Requires-Dist: PyGithub==1.54.1
19
19
  Requires-Dist: pylint<3.0.0,>=2.11.1
20
- Requires-Dist: semver==3.0.0
21
- Requires-Dist: coverage==7.2.7
22
- Requires-Dist: passlib==1.7.4
23
- Requires-Dist: requests==2.31.0
24
- Requires-Dist: psutil==5.9.4
20
+ Requires-Dist: semver<4.0.0,>=3.0.0
21
+ Requires-Dist: coverage<8.0.0,>=7.2.7
22
+ Requires-Dist: passlib<2.0.0,>=1.7.4
23
+ Requires-Dist: requests<3.0.0,>=2.32.5
24
+ Requires-Dist: psutil<8.0.0,>=5.9.4
25
25
  Dynamic: author
26
26
  Dynamic: author-email
27
27
  Dynamic: description
@@ -63,7 +63,7 @@ This utility helps developers to build Cleep applications providing some useful
63
63
  - Watch commands:
64
64
  - `watch` to watch for repository filesystem changes and automatically update files on execution folders. It also restart backend or/and frontend according to changes (catch-up sync on start).
65
65
  - `watchsvc` to install/enable/disable/restart the durable `cleep-watch` systemd unit (runs `watch` outside `cleep.service`).
66
- - `syncall` to force a one-shot sync of core + all modules (same catch-up as watch start).
66
+ - `syncall` to force a one-shot sync of core + all modules, disable static cache, and reload the UI.
67
67
  - Misc commands:
68
68
  - `version` to get cleep-cli version
69
69
 
@@ -96,7 +96,7 @@ cleep-cli watchsvc enable
96
96
 
97
97
  The unit runs `cleep-cli watch`, survives `systemctl restart cleep`, and on each start performs a catch-up `syncall` so files written while the watcher was down are applied.
98
98
 
99
- Manual one-shot resync (when the UI looks stale):
99
+ Manual one-shot resync (when the UI looks stale) — `syncall` also mints a fresh asset bust and reloads the device UI:
100
100
 
101
101
  ```
102
102
  cleep-cli syncall
@@ -27,7 +27,7 @@ This utility helps developers to build Cleep applications providing some useful
27
27
  - Watch commands:
28
28
  - `watch` to watch for repository filesystem changes and automatically update files on execution folders. It also restart backend or/and frontend according to changes (catch-up sync on start).
29
29
  - `watchsvc` to install/enable/disable/restart the durable `cleep-watch` systemd unit (runs `watch` outside `cleep.service`).
30
- - `syncall` to force a one-shot sync of core + all modules (same catch-up as watch start).
30
+ - `syncall` to force a one-shot sync of core + all modules, disable static cache, and reload the UI.
31
31
  - Misc commands:
32
32
  - `version` to get cleep-cli version
33
33
 
@@ -60,7 +60,7 @@ cleep-cli watchsvc enable
60
60
 
61
61
  The unit runs `cleep-cli watch`, survives `systemctl restart cleep`, and on each start performs a catch-up `syncall` so files written while the watcher was down are applied.
62
62
 
63
- Manual one-shot resync (when the UI looks stale):
63
+ Manual one-shot resync (when the UI looks stale) — `syncall` also mints a fresh asset bust and reloads the device UI:
64
64
 
65
65
  ```
66
66
  cleep-cli syncall
@@ -23,6 +23,7 @@ from cleepcli.package import Package
23
23
  from cleepcli.docs import Docs
24
24
  from cleepcli.check import Check
25
25
  from cleepcli.ci import Ci
26
+ from cleepcli.pico import Pico, PicoError
26
27
  import cleepcli.config as config
27
28
  from cleepcli.version import VERSION
28
29
 
@@ -114,12 +115,20 @@ def syncall():
114
115
  """
115
116
  Synchronize core and all modules from /root/cleep-dev to execution folders.
116
117
 
117
- Same catch-up used when cleep-watch.service starts. Safe one-shot resync when
118
- the UI looks stale: run this, then reload the device page.
118
+ Same catch-up used when cleep-watch.service starts. Disables frontend static
119
+ cache, then restarts the Cleep backend so Python modules (not only JS) reload.
119
120
  """
121
+ from cleepcli.cleepapi import CleepApi
122
+
120
123
  f = File()
121
124
  if not f.sync_all():
122
125
  sys.exit(1)
126
+ api = CleepApi(None)
127
+ api.ensure_frontend_nocache()
128
+ # Backend restart is required: sync_all updates on-disk apps, but a
129
+ # frontend-only reload would keep stale Python RPC commands in memory.
130
+ if not api.restart_backend():
131
+ sys.exit(1)
123
132
 
124
133
  @core.command()
125
134
  @click.option('--coverage', is_flag=True, help='Display coverage report.')
@@ -400,7 +409,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
400
409
  ['install', 'uninstall', 'enable', 'disable', 'start', 'stop', 'restart', 'status']
401
410
  ),
402
411
  )
403
- def watchsvc_cmd(action):
412
+ @click.option(
413
+ '--restart-if-active',
414
+ is_flag=True,
415
+ help='With install: restart the unit if it is already running (pick up a new cleep-cli).',
416
+ )
417
+ def watchsvc_cmd(action, restart_if_active):
404
418
  """
405
419
  Manage the durable cleep-watch systemd unit.
406
420
 
@@ -410,17 +424,12 @@ def watchsvc_cmd(action):
410
424
 
411
425
  cleep-cli watchsvc install
412
426
  cleep-cli watchsvc enable
427
+
428
+ After upgrading cleep-cli (pip), restart the watcher so it loads the new code::
429
+
430
+ cleep-cli watchsvc restart
413
431
  """
414
432
  svc = WatchService()
415
- handlers = {
416
- 'install': svc.install,
417
- 'uninstall': svc.uninstall,
418
- 'enable': svc.enable,
419
- 'disable': svc.disable,
420
- 'start': svc.start,
421
- 'stop': svc.stop,
422
- 'restart': svc.restart,
423
- }
424
433
  if action == 'status':
425
434
  status = svc.status()
426
435
  logging.info(status)
@@ -428,7 +437,19 @@ def watchsvc_cmd(action):
428
437
  sys.exit(1)
429
438
  return
430
439
 
431
- if not handlers[action]():
440
+ if action == 'install':
441
+ ok = svc.install(restart_if_active=restart_if_active)
442
+ else:
443
+ handlers = {
444
+ 'uninstall': svc.uninstall,
445
+ 'enable': svc.enable,
446
+ 'disable': svc.disable,
447
+ 'start': svc.start,
448
+ 'stop': svc.stop,
449
+ 'restart': svc.restart,
450
+ }
451
+ ok = handlers[action]()
452
+ if not ok:
432
453
  sys.exit(1)
433
454
 
434
455
  @click.group()
@@ -929,14 +950,172 @@ def cicorecheckversion():
929
950
  sys.exit(1)
930
951
 
931
952
 
953
+ @click.group()
954
+ def pico():
955
+ """Raspberry Pi Pico SDK and UF2 firmware builds."""
956
+ pass
957
+
958
+
959
+ @click.group()
960
+ def pico_sdk():
961
+ """Install / update / remove the shared Pico SDK."""
962
+ pass
963
+
964
+
965
+ @pico_sdk.command('install')
966
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
967
+ def pico_sdk_install(as_json):
968
+ """Install toolchain packages and clone the Pico SDK."""
969
+ try:
970
+ meta = Pico().sdk_install()
971
+ except PicoError as error:
972
+ logging.error(str(error))
973
+ sys.exit(1)
974
+ if as_json:
975
+ click.echo(json.dumps(meta, indent=2))
976
+ else:
977
+ logging.info(
978
+ 'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
979
+ meta.get('installed'),
980
+ meta.get('version'),
981
+ meta.get('revision'),
982
+ meta.get('toolchain_ok'),
983
+ )
984
+
985
+
986
+ @pico_sdk.command('update')
987
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
988
+ def pico_sdk_update(as_json):
989
+ """Update the Pico SDK checkout."""
990
+ try:
991
+ meta = Pico().sdk_update()
992
+ except PicoError as error:
993
+ logging.error(str(error))
994
+ sys.exit(1)
995
+ if as_json:
996
+ click.echo(json.dumps(meta, indent=2))
997
+ else:
998
+ logging.info(
999
+ 'SDK updated version=%s revision=%s',
1000
+ meta.get('version'),
1001
+ meta.get('revision'),
1002
+ )
1003
+
1004
+
1005
+ @pico_sdk.command('uninstall')
1006
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
1007
+ def pico_sdk_uninstall(as_json):
1008
+ """Remove the Pico SDK (keeps apt toolchain packages)."""
1009
+ try:
1010
+ meta = Pico().sdk_uninstall()
1011
+ except PicoError as error:
1012
+ logging.error(str(error))
1013
+ sys.exit(1)
1014
+ if as_json:
1015
+ click.echo(json.dumps(meta, indent=2))
1016
+ else:
1017
+ logging.info('Pico SDK uninstalled')
1018
+
1019
+
1020
+ @pico_sdk.command('info')
1021
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
1022
+ def pico_sdk_info(as_json):
1023
+ """Show Pico SDK install status."""
1024
+ meta = Pico().sdk_info()
1025
+ if as_json:
1026
+ click.echo(json.dumps(meta, indent=2))
1027
+ else:
1028
+ logging.info(
1029
+ 'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
1030
+ meta.get('installed'),
1031
+ meta.get('path'),
1032
+ meta.get('version'),
1033
+ meta.get('revision'),
1034
+ meta.get('updated_at'),
1035
+ meta.get('toolchain_ok'),
1036
+ )
1037
+
1038
+
1039
+ @pico.command('build')
1040
+ @click.option('--module', required=True, help='Module name.')
1041
+ @click.option('--firmware', default=None, help='Firmware slug (default: all uf2).')
1042
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
1043
+ def pico_build(module, firmware, as_json):
1044
+ """Compile UF2 firmwares for a module (writes firmwares/<slug>/.build/)."""
1045
+ try:
1046
+ result = Pico().build_firmware(module, slug=firmware)
1047
+ except PicoError as error:
1048
+ logging.error(str(error))
1049
+ sys.exit(1)
1050
+ if as_json:
1051
+ click.echo(json.dumps(result, indent=2))
1052
+ else:
1053
+ logging.info('Built %s UF2 firmware(s)', result.get('count'))
1054
+
1055
+
1056
+ @pico.command('status')
1057
+ @click.option('--module', required=True, help='Module name.')
1058
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
1059
+ def pico_status(module, as_json):
1060
+ """Show UF2 build freshness for a module's firmwares."""
1061
+ try:
1062
+ result = Pico().status(module)
1063
+ except PicoError as error:
1064
+ logging.error(str(error))
1065
+ sys.exit(1)
1066
+ if as_json:
1067
+ click.echo(json.dumps(result, indent=2))
1068
+ else:
1069
+ logging.info(
1070
+ 'uf2_ready=%s count=%s',
1071
+ result.get('uf2_ready'),
1072
+ result.get('count'),
1073
+ )
1074
+ for item in result.get('items') or []:
1075
+ logging.info(
1076
+ ' %s [%s] %s — %s',
1077
+ item.get('slug'),
1078
+ item.get('kind'),
1079
+ item.get('status'),
1080
+ item.get('message'),
1081
+ )
1082
+ for msg in result.get('uf2_blocking') or []:
1083
+ logging.warning('blocking: %s', msg)
1084
+
1085
+
1086
+ pico.add_command(pico_sdk, name='sdk')
1087
+
1088
+
932
1089
  def print_version(ctx, param, value):
933
1090
  if not value or ctx.resilient_parsing:
934
1091
  return
935
1092
  click.echo('cleep-cli version %s' % VERSION)
936
1093
  ctx.exit()
937
1094
 
1095
+
1096
+ class CleepCliCollection(click.CommandCollection):
1097
+ """
1098
+ Flatten legacy command groups, but keep ``pico`` nested
1099
+ (``cleep-cli pico sdk install``, ``cleep-cli pico build``, …).
1100
+ """
1101
+
1102
+ def list_commands(self, ctx):
1103
+ names = list(click.CommandCollection.list_commands(self, ctx))
1104
+ if 'pico' not in names:
1105
+ names.append('pico')
1106
+ return names
1107
+
1108
+ def get_command(self, ctx, cmd_name):
1109
+ if cmd_name == 'pico':
1110
+ return pico
1111
+ return click.CommandCollection.get_command(self, ctx, cmd_name)
1112
+
1113
+
938
1114
  # https://github.com/pallets/click/issues/341
939
- @click.command(cls=click.CommandCollection, sources=[core, mod, watchdog, test, package, docs, check, ci])
1115
+ @click.command(
1116
+ cls=CleepCliCollection,
1117
+ sources=[core, mod, watchdog, test, package, docs, check, ci],
1118
+ )
940
1119
  @click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True)
941
1120
  def cli():
942
1121
  pass
@@ -23,6 +23,7 @@ from cleepcli.package import Package
23
23
  from cleepcli.docs import Docs
24
24
  from cleepcli.check import Check
25
25
  from cleepcli.ci import Ci
26
+ from cleepcli.pico import Pico, PicoError
26
27
  import cleepcli.config as config
27
28
  from cleepcli.version import VERSION
28
29
 
@@ -114,12 +115,20 @@ def syncall():
114
115
  """
115
116
  Synchronize core and all modules from /root/cleep-dev to execution folders.
116
117
 
117
- Same catch-up used when cleep-watch.service starts. Safe one-shot resync when
118
- the UI looks stale: run this, then reload the device page.
118
+ Same catch-up used when cleep-watch.service starts. Disables frontend static
119
+ cache, then restarts the Cleep backend so Python modules (not only JS) reload.
119
120
  """
121
+ from cleepcli.cleepapi import CleepApi
122
+
120
123
  f = File()
121
124
  if not f.sync_all():
122
125
  sys.exit(1)
126
+ api = CleepApi(None)
127
+ api.ensure_frontend_nocache()
128
+ # Backend restart is required: sync_all updates on-disk apps, but a
129
+ # frontend-only reload would keep stale Python RPC commands in memory.
130
+ if not api.restart_backend():
131
+ sys.exit(1)
123
132
 
124
133
  @core.command()
125
134
  @click.option('--coverage', is_flag=True, help='Display coverage report.')
@@ -400,7 +409,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
400
409
  ['install', 'uninstall', 'enable', 'disable', 'start', 'stop', 'restart', 'status']
401
410
  ),
402
411
  )
403
- def watchsvc_cmd(action):
412
+ @click.option(
413
+ '--restart-if-active',
414
+ is_flag=True,
415
+ help='With install: restart the unit if it is already running (pick up a new cleep-cli).',
416
+ )
417
+ def watchsvc_cmd(action, restart_if_active):
404
418
  """
405
419
  Manage the durable cleep-watch systemd unit.
406
420
 
@@ -410,17 +424,12 @@ def watchsvc_cmd(action):
410
424
 
411
425
  cleep-cli watchsvc install
412
426
  cleep-cli watchsvc enable
427
+
428
+ After upgrading cleep-cli (pip), restart the watcher so it loads the new code::
429
+
430
+ cleep-cli watchsvc restart
413
431
  """
414
432
  svc = WatchService()
415
- handlers = {
416
- 'install': svc.install,
417
- 'uninstall': svc.uninstall,
418
- 'enable': svc.enable,
419
- 'disable': svc.disable,
420
- 'start': svc.start,
421
- 'stop': svc.stop,
422
- 'restart': svc.restart,
423
- }
424
433
  if action == 'status':
425
434
  status = svc.status()
426
435
  logging.info(status)
@@ -428,7 +437,19 @@ def watchsvc_cmd(action):
428
437
  sys.exit(1)
429
438
  return
430
439
 
431
- if not handlers[action]():
440
+ if action == 'install':
441
+ ok = svc.install(restart_if_active=restart_if_active)
442
+ else:
443
+ handlers = {
444
+ 'uninstall': svc.uninstall,
445
+ 'enable': svc.enable,
446
+ 'disable': svc.disable,
447
+ 'start': svc.start,
448
+ 'stop': svc.stop,
449
+ 'restart': svc.restart,
450
+ }
451
+ ok = handlers[action]()
452
+ if not ok:
432
453
  sys.exit(1)
433
454
 
434
455
  @click.group()
@@ -929,14 +950,172 @@ def cicorecheckversion():
929
950
  sys.exit(1)
930
951
 
931
952
 
953
+ @click.group()
954
+ def pico():
955
+ """Raspberry Pi Pico SDK and UF2 firmware builds."""
956
+ pass
957
+
958
+
959
+ @click.group()
960
+ def pico_sdk():
961
+ """Install / update / remove the shared Pico SDK."""
962
+ pass
963
+
964
+
965
+ @pico_sdk.command('install')
966
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
967
+ def pico_sdk_install(as_json):
968
+ """Install toolchain packages and clone the Pico SDK."""
969
+ try:
970
+ meta = Pico().sdk_install()
971
+ except PicoError as error:
972
+ logging.error(str(error))
973
+ sys.exit(1)
974
+ if as_json:
975
+ click.echo(json.dumps(meta, indent=2))
976
+ else:
977
+ logging.info(
978
+ 'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
979
+ meta.get('installed'),
980
+ meta.get('version'),
981
+ meta.get('revision'),
982
+ meta.get('toolchain_ok'),
983
+ )
984
+
985
+
986
+ @pico_sdk.command('update')
987
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
988
+ def pico_sdk_update(as_json):
989
+ """Update the Pico SDK checkout."""
990
+ try:
991
+ meta = Pico().sdk_update()
992
+ except PicoError as error:
993
+ logging.error(str(error))
994
+ sys.exit(1)
995
+ if as_json:
996
+ click.echo(json.dumps(meta, indent=2))
997
+ else:
998
+ logging.info(
999
+ 'SDK updated version=%s revision=%s',
1000
+ meta.get('version'),
1001
+ meta.get('revision'),
1002
+ )
1003
+
1004
+
1005
+ @pico_sdk.command('uninstall')
1006
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
1007
+ def pico_sdk_uninstall(as_json):
1008
+ """Remove the Pico SDK (keeps apt toolchain packages)."""
1009
+ try:
1010
+ meta = Pico().sdk_uninstall()
1011
+ except PicoError as error:
1012
+ logging.error(str(error))
1013
+ sys.exit(1)
1014
+ if as_json:
1015
+ click.echo(json.dumps(meta, indent=2))
1016
+ else:
1017
+ logging.info('Pico SDK uninstalled')
1018
+
1019
+
1020
+ @pico_sdk.command('info')
1021
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
1022
+ def pico_sdk_info(as_json):
1023
+ """Show Pico SDK install status."""
1024
+ meta = Pico().sdk_info()
1025
+ if as_json:
1026
+ click.echo(json.dumps(meta, indent=2))
1027
+ else:
1028
+ logging.info(
1029
+ 'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
1030
+ meta.get('installed'),
1031
+ meta.get('path'),
1032
+ meta.get('version'),
1033
+ meta.get('revision'),
1034
+ meta.get('updated_at'),
1035
+ meta.get('toolchain_ok'),
1036
+ )
1037
+
1038
+
1039
+ @pico.command('build')
1040
+ @click.option('--module', required=True, help='Module name.')
1041
+ @click.option('--firmware', default=None, help='Firmware slug (default: all uf2).')
1042
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
1043
+ def pico_build(module, firmware, as_json):
1044
+ """Compile UF2 firmwares for a module (writes firmwares/<slug>/.build/)."""
1045
+ try:
1046
+ result = Pico().build_firmware(module, slug=firmware)
1047
+ except PicoError as error:
1048
+ logging.error(str(error))
1049
+ sys.exit(1)
1050
+ if as_json:
1051
+ click.echo(json.dumps(result, indent=2))
1052
+ else:
1053
+ logging.info('Built %s UF2 firmware(s)', result.get('count'))
1054
+
1055
+
1056
+ @pico.command('status')
1057
+ @click.option('--module', required=True, help='Module name.')
1058
+ @click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
1059
+ def pico_status(module, as_json):
1060
+ """Show UF2 build freshness for a module's firmwares."""
1061
+ try:
1062
+ result = Pico().status(module)
1063
+ except PicoError as error:
1064
+ logging.error(str(error))
1065
+ sys.exit(1)
1066
+ if as_json:
1067
+ click.echo(json.dumps(result, indent=2))
1068
+ else:
1069
+ logging.info(
1070
+ 'uf2_ready=%s count=%s',
1071
+ result.get('uf2_ready'),
1072
+ result.get('count'),
1073
+ )
1074
+ for item in result.get('items') or []:
1075
+ logging.info(
1076
+ ' %s [%s] %s — %s',
1077
+ item.get('slug'),
1078
+ item.get('kind'),
1079
+ item.get('status'),
1080
+ item.get('message'),
1081
+ )
1082
+ for msg in result.get('uf2_blocking') or []:
1083
+ logging.warning('blocking: %s', msg)
1084
+
1085
+
1086
+ pico.add_command(pico_sdk, name='sdk')
1087
+
1088
+
932
1089
  def print_version(ctx, param, value):
933
1090
  if not value or ctx.resilient_parsing:
934
1091
  return
935
1092
  click.echo('cleep-cli version %s' % VERSION)
936
1093
  ctx.exit()
937
1094
 
1095
+
1096
+ class CleepCliCollection(click.CommandCollection):
1097
+ """
1098
+ Flatten legacy command groups, but keep ``pico`` nested
1099
+ (``cleep-cli pico sdk install``, ``cleep-cli pico build``, …).
1100
+ """
1101
+
1102
+ def list_commands(self, ctx):
1103
+ names = list(click.CommandCollection.list_commands(self, ctx))
1104
+ if 'pico' not in names:
1105
+ names.append('pico')
1106
+ return names
1107
+
1108
+ def get_command(self, ctx, cmd_name):
1109
+ if cmd_name == 'pico':
1110
+ return pico
1111
+ return click.CommandCollection.get_command(self, ctx, cmd_name)
1112
+
1113
+
938
1114
  # https://github.com/pallets/click/issues/341
939
- @click.command(cls=click.CommandCollection, sources=[core, mod, watchdog, test, package, docs, check, ci])
1115
+ @click.command(
1116
+ cls=CleepCliCollection,
1117
+ sources=[core, mod, watchdog, test, package, docs, check, ci],
1118
+ )
940
1119
  @click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True)
941
1120
  def cli():
942
1121
  pass
@@ -1499,11 +1499,14 @@ overgeneral-exceptions=Exception
1499
1499
 
1500
1500
  def check_firmwares(self, module_name):
1501
1501
  """
1502
- Validate optional ``firmwares/`` zip+sidecar ``.manifest`` pairs and list
1503
- files for packaging (see ``cleep.libs.internals.firmware_manifest``).
1502
+ Validate optional ``firmwares/<slug>/`` source folders (author manifests)
1503
+ and list **built** zip+manifest pairs for packaging.
1504
+
1505
+ Sources live under one folder per firmware. Packaging files come from
1506
+ ``firmwares/.dist/`` after :func:`build_all_firmware_packages`.
1504
1507
 
1505
1508
  Returns:
1506
- dict: errors / warnings / files (same shape as check_scripts)
1509
+ dict: errors / warnings / files / count
1507
1510
  """
1508
1511
  if not os.path.exists(os.path.join(config.MODULES_DST, module_name)):
1509
1512
  raise Exception('Module "%s" does not exist' % module_name)
@@ -1513,6 +1516,7 @@ overgeneral-exceptions=Exception
1513
1516
  "errors": [],
1514
1517
  "warnings": [],
1515
1518
  "files": [],
1519
+ "count": 0,
1516
1520
  }
1517
1521
  if not os.path.isdir(firmwares_path):
1518
1522
  return out
@@ -1520,7 +1524,8 @@ overgeneral-exceptions=Exception
1520
1524
  try:
1521
1525
  from cleep.libs.internals.firmware_manifest import (
1522
1526
  FirmwareManifestError,
1523
- scan_firmwares_dir,
1527
+ build_all_firmware_packages,
1528
+ scan_firmware_sources,
1524
1529
  )
1525
1530
  except ImportError:
1526
1531
  out["errors"].append(
@@ -1530,15 +1535,33 @@ overgeneral-exceptions=Exception
1530
1535
  return out
1531
1536
 
1532
1537
  try:
1533
- scan_firmwares_dir(firmwares_path)
1538
+ sources = scan_firmware_sources(firmwares_path)
1534
1539
  except FirmwareManifestError as error:
1535
1540
  out["errors"].append(str(error))
1536
1541
  return out
1537
1542
 
1538
- # Include valid pairs in the package file list
1539
- tree = self._check_module_tree(module_name, "firmwares")
1540
- out["files"] = tree["files"]
1541
- out["warnings"] = tree["warnings"]
1543
+ out["count"] = len(sources)
1544
+ if not sources:
1545
+ return out
1546
+
1547
+ try:
1548
+ built = build_all_firmware_packages(firmwares_path)
1549
+ except FirmwareManifestError as error:
1550
+ out["errors"].append(str(error))
1551
+ return out
1552
+
1553
+ for item in built:
1554
+ for key, ext in (("zip", ".zip"), ("manifest", ".manifest")):
1555
+ fullpath = item[key]
1556
+ out["files"].append(
1557
+ {
1558
+ "fullpath": fullpath,
1559
+ "filename": os.path.basename(fullpath),
1560
+ "path": os.path.join(
1561
+ "firmwares", os.path.basename(fullpath)
1562
+ ),
1563
+ }
1564
+ )
1542
1565
  return out
1543
1566
 
1544
1567
  def check_tests(self, module_name):
@@ -243,6 +243,32 @@ class CleepApi():
243
243
  return False
244
244
  return True
245
245
 
246
+ def ensure_frontend_nocache(self):
247
+ """
248
+ Disable RPC static cache and mint a fresh asset bust token.
249
+
250
+ Safe to call repeatedly; used after syncall / frontend watch batches so
251
+ the browser cannot keep stale core or module JS.
252
+ """
253
+ data = {
254
+ 'to': 'inventory',
255
+ 'command': 'bump_rpc_asset_cache',
256
+ 'params': {},
257
+ }
258
+ result = self.__post(self.command_url, data)
259
+ if not result or result[0] != 200:
260
+ # Older cores only expose set_rpc_cache_control
261
+ data = {
262
+ 'to': 'inventory',
263
+ 'command': 'set_rpc_cache_control',
264
+ 'params': {'cache_enabled': False},
265
+ }
266
+ result = self.__post(self.command_url, data)
267
+ if not result or result[0] != 200:
268
+ self.logger.debug('Unable to disable frontend static cache')
269
+ return False
270
+ return True
271
+
246
272
  def notify_sync_started(self):
247
273
  """
248
274
  Tell the developer UI a watch sync is starting.