|
| 1 | + |
| 2 | +given a lib/libs |
| 3 | +- names bundle(libs) return libs that are in the bundles |
| 4 | +- names dep(lib) dependencies of all lib/libs |
| 5 | + - treat dependency and external dependency the same |
| 6 | + - only return bundle(libs) in each recursion |
| 7 | + |
| 8 | +existing libs |
| 9 | +- names libs_on_disk: top level names in /libs folder |
| 10 | +- names_w_ver libs_installed: bundle(libs_on_disk) |
| 11 | + - version from installed package |
| 12 | + |
| 13 | +needed libs |
| 14 | +- names libs_in_code: libs that are imported in python code |
| 15 | +- names libs_imported: bundle(libs_in_code) |
| 16 | +- names_w_ver libs_needed: dep(libs_imported) |
| 17 | + - versions from bundles |
| 18 | + |
| 19 | +supported actions |
| 20 | +- auto: reinstall all libs used in the code with dependencies |
| 21 | + - remove libs_installed from MCU |
| 22 | + - add libs_needed to MCU from bundle |
| 23 | + - warn if libs_needed_ext not on MCU |
| 24 | +- manual: |
| 25 | + - install/upgrade lib_selected (same) |
| 26 | + - remove dep(lib_selected) if exist |
| 27 | + - add dep(lib_selected) to MCU from bundle |
| 28 | + - uninstall lib_selected |
| 29 | + - remove lib_selected only |
| 30 | + - will not go back to check unused dependencies, use auto function instead. |
| 31 | + |
| 32 | +display |
| 33 | +- display all libs in both bundles |
| 34 | +- item |
| 35 | + - name |
| 36 | + - version or cur_version -> new_version |
| 37 | + - bundle (Icon) |
| 38 | + - instal status |
| 39 | + - action buttons |
| 40 | +- action buttons |
| 41 | + - uninstall: if in libs_installed |
| 42 | + - upgrade: if in libs_installed AND version different from bundle |
| 43 | + - install: if not in libs_installed |
| 44 | +- instal status: check mark to indicate installation |
| 45 | + - green means latest version |
| 46 | + - yellow means upgradable |
| 47 | +- sort by |
| 48 | + - installation: green -> yellow -> not installed |
| 49 | + - name |
| 50 | + - bundle: Adafruit -> Community |
| 51 | + |
| 52 | +menu |
| 53 | +- refresh |
| 54 | + - actually, auto refresh at the start, then refresh on demand |
| 55 | +- auto |
| 56 | +- hamburger |
| 57 | + - help |
| 58 | + - config |
| 59 | + |
| 60 | +config |
| 61 | +- clear unused libs in auto mode, boolean |
| 62 | + |
| 63 | + |
| 64 | +data flow |
| 65 | +- const repo names |
| 66 | +- repo names -> asset links |
| 67 | + - json |
| 68 | + - zip |
| 69 | + - int version number |
| 70 | +- store into local storage |
| 71 | + - json combined |
| 72 | + - for each version |
| 73 | + - zip combined |
| 74 | +- read |
| 75 | + - given a name |
| 76 | + - if it is a top level file, return an emulated file handle |
| 77 | + - if it is a top level folder, return an emulated file handle |
| 78 | + - then use copy folder util to copy to real directory |
| 79 | + |
| 80 | +work flow and exceptions |
| 81 | +- on load, unconditional: get resource |
| 82 | + - get asset lists from git api |
| 83 | + - if get failed |
| 84 | + - check if resources are cached and up to date |
| 85 | + - check time stamp |
| 86 | + - if not exist |
| 87 | + - continue |
| 88 | + - if not the same as assets |
| 89 | + - dialog |
| 90 | + - continue if confirm |
| 91 | + - if same as assets |
| 92 | + - stop get resource process |
| 93 | + - get JSON and zips |
| 94 | + - if get failed |
| 95 | + - dialog: proxy error, upload bundle manually |
| 96 | + - stop get resource process |
| 97 | +- unconditional: get mcu info |
| 98 | + - get cpy version of the MCU |
| 99 | + - if cpy version not in bundle list |
| 100 | + - error, cpy version not supported |
| 101 | + - get installed libs |
| 102 | + - if cannot get MCU status |
| 103 | + - dialog not supported |
| 104 | + - stop get resource process |
| 105 | + - block all features |
| 106 | +- on button clicked |
| 107 | + - check if cpy version has data in bundle |
| 108 | + - dialog manual upload |
| 109 | + - get imported libs / selected ; libs |
| 110 | + - get list of libs to be installed: imports + dependencies |
| 111 | + - check |
| 112 | + - time stamp exist (which means the resource is downloaded) |
| 113 | + |
| 114 | +prompt for lib card |
| 115 | + |
| 116 | +``` |
| 117 | +write a jsx component with mui with template |
| 118 | +
|
| 119 | +function LibCard({ lib, installedLib }) {} |
| 120 | +
|
| 121 | +where lib is an object like |
| 122 | +
|
| 123 | +{ |
| 124 | + "dependencies": [ |
| 125 | + "adafruit_bus_device", |
| 126 | + "adafruit_register" |
| 127 | + ], |
| 128 | + "external_dependencies": [], |
| 129 | + "package": false, |
| 130 | + "path": "lib/adafruit_24lc32", |
| 131 | + "pypi_name": "adafruit-circuitpython-24lc32", |
| 132 | + "repo": "https://github.com/adafruit/adafruit_circuitpython_24lc32", |
| 133 | + "version": "1.2.3" |
| 134 | +} |
| 135 | +
|
| 136 | +installedLib is an object like |
| 137 | +
|
| 138 | +{ |
| 139 | + "name": "adafruit_ina219", |
| 140 | + "version": { |
| 141 | + "major": 3, |
| 142 | + "minor": 4, |
| 143 | + "patch": 29 |
| 144 | + } |
| 145 | +} |
| 146 | +
|
| 147 | +please also make use of function |
| 148 | +
|
| 149 | +export function parseVersion(versionStr) { |
| 150 | + const m = /^(\d+)\.(\d+)\.(\d+)$/.exec(versionStr.trim()); |
| 151 | + if (!m) { |
| 152 | + return { major: null, minor: null, patch: null, raw: versionStr }; |
| 153 | + } |
| 154 | + return { |
| 155 | + major: Number(m[1]), |
| 156 | + minor: Number(m[2]), |
| 157 | + patch: Number(m[3]), |
| 158 | + }; |
| 159 | +} |
| 160 | +
|
| 161 | +
|
| 162 | +the object should display the info as |
| 163 | +TODO |
| 164 | +``` |
0 commit comments