proton

https://github.com/dvcrn/proton
dvcrn 2016-09-21T08:01:32.000020Z

@geksilla here currently?

dvcrn 2016-09-21T08:03:14.000021Z

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

geksilla 2016-09-21T08:26:16.000022Z

hi

geksilla 2016-09-21T08:26:32.000023Z

what issue?

dvcrn 2016-09-21T08:42:45.000024Z

@geksilla ah you’re here!

geksilla 2016-09-21T08:42:54.000025Z

yes)

dvcrn 2016-09-21T08:44:16.000026Z

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

dvcrn 2016-09-21T08:45:16.000027Z

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

dvcrn 2016-09-21T08:46:38.000028Z

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

dvcrn 2016-09-21T08:47:42.000029Z

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

dvcrn 2016-09-21T08:47:57.000030Z

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

dvcrn 2016-09-21T08:48:15.000031Z

and :proton-disabled / :atom-disabled

dvcrn 2016-09-21T08:49:00.000032Z

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

dvcrn 2016-09-21T08:54:26.000033Z

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

dvcrn 2016-09-21T08:55:40.000034Z

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

geksilla 2016-09-21T08:57:24.000035Z

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

dvcrn 2016-09-21T08:58:18.000036Z

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

dvcrn 2016-09-21T08:58:52.000037Z

ah, there is no API for disabled packages

geksilla 2016-09-21T09:00:01.000038Z

you can get disabled state with atom.packages.isPackageDisabled

dvcrn 2016-09-21T09:01:08.000040Z

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

dvcrn 2016-09-21T09:01:33.000042Z

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

geksilla 2016-09-21T09:04:01.000043Z

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

dvcrn 2016-09-21T09:05:22.000044Z

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

dvcrn 2016-09-21T09:05:35.000045Z

This way case doesn’t matter anymore

geksilla 2016-09-21T09:09:52.000046Z

I think it should be ok

dvcrn 2016-09-21T09:09:57.000047Z

I think we need to add a lot more comments though

dvcrn 2016-09-21T09:10:02.000048Z

I think code is getting hard to understand

geksilla 2016-09-21T09:10:04.000049Z

yes

geksilla 2016-09-21T09:10:09.000050Z

sorry about that

dvcrn 2016-09-21T09:10:18.000051Z

also my doing 😛

dvcrn 2016-09-21T09:11:53.000052Z

maybe also document the init flow somewhere on github I think

dvcrn 2016-09-21T09:12:04.000053Z

like from beginning to end, all phases

geksilla 2016-09-21T09:12:16.000054Z

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

dvcrn 2016-09-21T09:12:30.000055Z

what do you mean?

dvcrn 2016-09-21T09:12:38.000056Z

ah need to move. I’ll be back asap

geksilla 2016-09-21T09:33:24.000057Z

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?

geksilla 2016-09-21T09:48:20.000059Z

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.