Fork me on GitHub
#proton
<
2016-09-21
>
dvcrn08:09:32

@geksilla here currently?

dvcrn08:09:14

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

geksilla08:09:32

what issue?

dvcrn08:09:45

@geksilla ah you’re here!

dvcrn08:09:16

ok so adding support for case-insensitive packages is quite simple because apm is case-insensitive already. Just atom internal API is case-sensitive.

dvcrn08:09:16

I updated get-to-install and get-to-remove to down-case all packages before comparing, then returning case-sensitive packages

dvcrn08:09:38

If we use atom.packages.getLoadedPackages instead of atom.packages.isPackageLoaded, we can downcase them as well

dvcrn08:09:42

but I think I have problems understanding when the new logic is marking packages as deleted and when not

dvcrn08:09:57

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)))

dvcrn08:09:15

and :proton-disabled / :atom-disabled

dvcrn08:09:00

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

dvcrn08:09:26

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

dvcrn08:09:40

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

geksilla08:09:24

in this case we need to reflect packages' state when user disable/enable package manually e.g. through Settings View

dvcrn08:09:18

but isn’t that only relevant on editor start? then we can just read the disabled packages through API and downcase it as well

dvcrn08:09:52

ah, there is no API for disabled packages

geksilla09:09:01

you can get disabled state with atom.packages.isPackageDisabled

dvcrn09:09:08

how about we generate this kind of map then {:package-name {:original “Package-Name” :disabled True / False}

dvcrn09:09:33

similar to what we do right now, but we add information for original name

geksilla09:09:01

and you want to use this map to search package in case-insensitive way?

dvcrn09:09:22

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

dvcrn09:09:35

This way case doesn’t matter anymore

geksilla09:09:52

I think it should be ok

dvcrn09:09:57

I think we need to add a lot more comments though

dvcrn09:09:02

I think code is getting hard to understand

geksilla09:09:09

sorry about that

dvcrn09:09:18

also my doing 😛

dvcrn09:09:53

maybe also document the init flow somewhere on github I think

dvcrn09:09:04

like from beginning to end, all phases

geksilla09:09:16

my plan was to use custom method to find package within atom API where we can ignore case and use it across package management

dvcrn09:09:30

what do you mean?

dvcrn09:09:38

ah need to move. I’ll be back asap

geksilla09:09:24

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?

geksilla09:09:20

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.