[JS Addons] Map package.json to AddonModel and check if is valid addon package or not#10586
[JS Addons] Map package.json to AddonModel and check if is valid addon package or not#10586mikehardy merged 4 commits intoankidroid:mainfrom
Conversation
mikehardy
left a comment
There was a problem hiding this comment.
Nice! I left some comments that are mostly about developer experience. The big question I have is about what is going in the SharedPrefs and that will affect how to get this finished I think
69d83ac to
28fb02b
Compare
|
Really happy to see these moving through, I know you basically have the whole system up and running already in your local builds @krmanik and I'm excited to have all the functionality go through and merge to main, even if it takes a little while for each chunk. We will get there! |
|
I am using this feature on local build. The split PR is faster than earlier single PR. |
|
Resolve the conflicts. |
AnkiDroid/src/test/java/com/ichi2/anki/jsaddons/AddonModelTest.kt
Outdated
Show resolved
Hide resolved
07ec4e3 to
444b10d
Compare
|
This appears to be ready for a re-scan? |
added timber log when validname checks return false
|
In this commit 56a00b9, I have created AddonData class then mapped json then validate the data. After validation, created AddonModel and returned. |
david-allison
left a comment
There was a problem hiding this comment.
Looks great! Two minor changes
david-allison
left a comment
There was a problem hiding this comment.
One optional extension to make AddonModel fully immutable.
Happy to merge when CI passes
move test on json file to assets
0362163 to
ff4ed0c
Compare
|
@krmanik lint issue - I'm testing it locally: |
|
Thanks, I am also running the lint. |
|
passes all the other tests though, for me locally. Just some "needless blank lines" away from a merge :-)
|
|
I will push the changes. |
change data to class and rename AddonModel to AddonData add values to error list change var to val to make it immuatable
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Do we have anywhere else to discuss this? It doesn't seem relevant to the PR. |
To the original issue. I hide it and paste there |
|
I checked the implementation again I think front/back/styling content addition should be handled in JS API. I will create PR if needed till then this PR does not need any changes. |
|
Hi there @krmanik! This is the OpenCollective Notice for PRs merged from 2022-04-01 through 2022-04-30 If you are interested in compensation for this work, the process with details is here: https://github.com/ankidroid/Anki-Android/wiki/OpenCollective-Payment-Process#how-to-get-paid We only post one comment per person per month to avoid spamming you, regardless of the number of PRs merged, but this note applies to all PRs merged for this month Please note that GSoC contributions are okay for this process. Our philosophy is that our users have donated to AnkiDroid for all contributions. The only PRs that will not go through the OpenCollective process are ones directly related to am accepted GSoC project from a selected participant, since those receive a stipend from GSoC itself. Please understand that our monthly budget is never guaranteed to cover all claims - the cap on payments-per-person may be lower, but we try to make our process as fair and transparent as possible, we just need your understanding. Thanks! |



Pull Request template
Purpose / Description
This is second PR in JS Addons series.
Before downloading addon tgz packages, it needs to check if the addon package is valid or not for AnkiDroid using
package.json.The validity checked using three fields
addonTitle,ankiDroidJsApiandankidroid-js-addonkeyword which are not present in other npm package'spackage.jsonfile. These fields will be used to distinguish it from other npm packages. It is required for addon developer to add these fields topackage.jsonfile otherwise the packages will not be downloaded and extracted.Also it needs to check that name should be valid npm packages. The
validatenamemethod is implemented to check if name follow the naming convention of npm packages.Fixes
Fixes #7959
Approach
package.jsonto AddonModel class.updatePrefsmethod will be used to enable and disable addon, the prefs will stored as HashSetisValidAnkiDroidAddonmethod have multiple checks like empty name or fields present or not in package.json andvalidateNamefor naming conventionHow Has This Been Tested?
There are test class for each class.
Learning (optional, can help others)
https://github.com/npm/validate-npm-package-name
https://github.com/lassjs/is-valid-npm-name
https://stackoverflow.com/questions/50050436/use-npm-package-to-validate-a-package-name
Checklist
Please, go through these checks before submitting the PR.
ifstatements)