@geksilla here currently?
I am trying to implement the case insensitive installing / removing of packages but keep running into a small issue that I think you worked on
hi
what issue?
@geksilla ah you’re here!
yes)
ok so adding support for case-insensitive packages is quite simple because apm
is case-insensitive already. Just atom internal API is case-sensitive.
I updated get-to-install
and get-to-remove
to down-case all packages before comparing, then returning case-sensitive packages
If we use atom.packages.getLoadedPackages instead of atom.packages.isPackageLoaded
, we can downcase them as well
but I think I have problems understanding when the new logic is marking packages as deleted and when not
for example
(defn register-removable
"Takes package-name (string) and register package as removable.
Removable packages determined by :init-state :removed.
Packages bundled with atom should not be removed, so they
marked as installable and disabled."
[package-name]
(println "marking as to remove: " package-name)
(-> package-name
(register-init-state :removed)
(update-in-package :proton-disabled true)
(update-bundled-removable)))
and :proton-disabled
/ :atom-disabled
so in my tests the package always got marked as delete. When I removed (update-in-package :proton-disabled true)
, the package got disabled but not activated
an idea:
1. Add atoms for holding atom.packages.getXXXXPackages
(active, disabled, loaded) in a map, mapped from lowercase -> uppercase
2. Replace isPackageXXXX
to use map instead of atom API call
3. Replace logic for finding layer packages to always downcase
4. Work with down-cased packages
with this we can filter out to-install / to-remove packages. If we need to use atom-api to disable a package or similar, we can use the uppercase version from the map. For install / remove we just pass the package name to apm
in this case we need to reflect packages' state when user disable/enable package manually e.g. through Settings View
but isn’t that only relevant on editor start? then we can just read the disabled packages through API and downcase it as well
ah, there is no API for disabled packages
you can get disabled state with atom.packages.isPackageDisabled
how about we generate this kind of map then
{:package-name {:original “Package-Name” :disabled True / False}
similar to what we do right now, but we add information for original name
and you want to use this map to search package in case-insensitive way?
to have all logic for comparing and filtering maps / sets (like get-to-remove
) to use lowercase packages.
Though we need a case if there is a new package like :parinfer
without information, we just pipe it into apm
for installing. Then on next start we have all the infos
This way case doesn’t matter anymore
I think it should be ok
I think we need to add a lot more comments though
I think code is getting hard to understand
yes
sorry about that
also my doing 😛
maybe also document the init flow somewhere on github I think
like from beginning to end, all phases
my plan was to use custom method to find package within atom API where we can ignore case and use it across package management
what do you mean?
ah need to move. I’ll be back asap
1. convert package names to down case https://github.com/dvcrn/proton/blob/4f0f97b1f794d3cd142cd05ba5f24c8d779b1c8d/src/cljs/proton/lib/atom.cljs#L198
2. convert packages-map
to down case https://github.com/dvcrn/proton/blob/4f0f97b1f794d3cd142cd05ba5f24c8d779b1c8d/src/cljs/proton/lib/package_manager.cljs#L88
3. change methods in proton.lib.atom
related to atom single package API get-package
:
(defn get-package [package-name]
(.getLoadedPackage packages package-name))
but instead of .getLoadedPackage
search through .getLoadedPackages
and ignore case like:
atom.packages.getLoadedPackages().filter(x => x.name.toLowerCase() == searchPackageName.toLowerCase())
So we will search for appropriate package in arrays like atom.package.getActivePackages()
, atom.package.getLoadedPackages()
etc.
and change another methods where we using Atom API e.g. is-activated?
, is-package-disabled?
, is-package-installed?
, is-package-bundled?
, enable-package
, disable-package
, is-activated?
or another case for 3.
add method get-original-package-name
to proton.lib.atom
which will search for package through atom.package.getLoadedPackages()
ignoring name case-sensitivity and returns original package name.
use original package name in methods is-activated?
, is-package-disabled?
, is-package-installed?
, is-package-bundled?
, enable-package
, disable-package
, is-activated?
etc.
https://github.com/geksilla/proton/commit/412c370a159678a9df66e194c43afbdaa8d43f3d