Skip to content

Commit bed2ab7

Browse files
authored
Lib management (#139)
Initial tests passed. Deploy to prod. Other features should be barely affected
1 parent 0f9a47c commit bed2ab7

36 files changed

+9123
-5598
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This IDE includes essential tools and useful features for CircuitPython microcon
1111
- Code editor with support for multiple tabs
1212
- Serial Console for communication and the Read-Evaluate-Print Loop (REPL)
1313
- Serial data plotter
14+
- Library Management
1415
- Project backup
1516

1617

@@ -61,7 +62,7 @@ REPL (Read-Evaluate-Print Loop) is a coding mode where you can interact with the
6162

6263
## About
6364

64-
Version: 2.1.0
65+
Version: 2.2.0
6566

6667
[CircuitPython](https://circuitpython.org/) is a version of Python that runs on microcontrollers and single-board computers. Its development is sponsored by [Adafruit](https://www.adafruit.com/).
6768

__tests__/testDummy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sum from "../src/utilFunctions/dummy";
1+
import { sum } from "../src/utilFunctions/dummy";
22

33
test("adds 1 + 2 to equal 3", () => {
44
expect(sum(1, 2)).toBe(3);

dev logs/lib manage.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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+
```

docs/index.html

Lines changed: 593 additions & 480 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)