chlorine-clover

About Chlorine for Atom and Clover for VS Code: https://atom.io/packages/chlorine and https://marketplace.visualstudio.com/items?itemName=mauricioszabo.clover
seancorfield 2021-04-15T01:55:24.063500Z

I’m updating my test-running code as local config.cljs functions and stuff mostly works the way I expect, but if I eval-and-render and the result is a long string that gets an ellipsis, it seems that (:result res) is some sort of JS object (where res is bound via p/let to the result of the eval).

seancorfield 2021-04-15T01:56:09.064300Z

Is there an easy way to get the first chunk of the string (I don’t care about the rest of it)?

mauricio.szabo 2021-04-15T02:10:27.064400Z

I believe that if you use str or pr-str, it'll return the string. If it doesn't, I can look at it tomorrow morning

seancorfield 2021-04-15T02:58:00.067400Z

I have this code

(editor/run-callback
         :notify
         (if (:error res)
           {:type :warn
            :title "Failed to run tests for"
            :message test-name}
           {:type :info
            :title test-name
            :message (:result res)}))
and if it is an ellipsis string, I get [object Object] and I don’t seem to be able to perform any operations on it at all…

seancorfield 2021-04-15T03:14:26.068100Z

Ah, looks like :warn isn’t valid and that’s hiding my notifications… Sorry for the noise.

seancorfield 2021-04-15T03:15:45.068500Z

Has to be :warning… OK, making progress again… sorry 😐

seancorfield 2021-04-15T03:21:05.069300Z

OK, confirmed that calling (str (:result res)) just produces [object Object] in the case of a long (ellipsis) string.

seancorfield 2021-04-15T04:01:22.070300Z

Presumably I can call some JS methods on it, but I haven't figured what's valid (and I don't know what JS interop is available in sci for this anyway).

borkdude 2021-04-15T06:58:18.070600Z

@seancorfield JS interop is supported in sci

borkdude 2021-04-15T06:58:47.071200Z

At least it should be, if something doesn't work, you can bug me about it in #sci

seancorfield 2021-04-15T06:59:26.072Z

I found I could (catch js/Error e ..) so that helped. But my JS knowledge is pretty much non-existent so, given some arbitrary JS object, I’ve no idea how to debug what methods I could call on it…

borkdude 2021-04-15T07:00:13.072600Z

@seancorfield (.log js/console x) sometimes gives some hint

seancorfield 2021-04-15T07:00:36.073Z

Inside VS Code? Where would I even find the “console” log?

seancorfield 2021-04-15T07:01:06.073600Z

(and I already know it renders as [object Object] when I try to print it as a string)

seancorfield 2021-04-15T07:03:41.074500Z

I tried adding (.log js/console res) to my config.cljs file and none of the tasks will run at all.

borkdude 2021-04-15T07:04:23.075200Z

oh I don't know about VSCode and this tooling. It also depends on how sci is configured. I will wait for @mauricio.szabo's reply on this.

seancorfield 2021-04-15T07:05:04.075800Z

Yeah, I’ve spent hours trying to debug this but none of the “standard” stuff seems to work.

pez 2021-04-15T08:03:15.079100Z

js/JSON.stringify (or something like that) should print the object, unless you have circular references there. It takes a second argument where you can prettify the output. Not sure what the context is for this you are trying to do, but it sounds like you might find the js/console.log output in VS Code’s Developer console, which you find both in the Help menu and in the command palette.

mauricio.szabo 2021-04-15T11:59:00.079400Z

Hi, just woke up :)

mauricio.szabo 2021-04-15T12:05:15.079500Z

So, for some context - unrepl exposes long strings as these ellipsis. This converts to a deftype in Clover, that's being shown as [Object]

seancorfield 2021-04-15T14:24:41.080800Z

Yup, figured that was it. Calling str doesn’t return all/part of it though. Is there some other instance method I can call?

mauricio.szabo 2021-04-15T14:24:56.081Z

I believe it's a bug. I'll fix it

mauricio.szabo 2021-04-15T14:25:50.081500Z

In the meantime, see if calling (.only_str (:result....)) works

seancorfield 2021-04-15T14:27:08.081700Z

Will try…

seancorfield 2021-04-15T14:28:25.082Z

Could not find instance method only_str

mauricio.szabo 2021-04-15T14:28:36.082200Z

😢

mauricio.szabo 2021-04-15T14:28:43.082400Z

I'll push a fix real quick now

borkdude 2021-04-15T14:34:06.082700Z

@mauricio.szabo if this is a bug with #sci somehow, let me know

mauricio.szabo 2021-04-15T14:34:17.082900Z

No, it's on my side

seancorfield 2021-04-15T14:38:31.083100Z

Thanks @mauricio.szabo

seancorfield 2021-04-15T14:39:08.083900Z

Once it is “fixed”, what should I expect to do in my code to get at the actual string (or even just the first segment of that string)?

mauricio.szabo 2021-04-15T14:39:27.084200Z

Just (str ....) will do

mauricio.szabo 2021-04-15T14:39:33.084400Z

I'll add a default conversion to string

seancorfield 2021-04-15T14:39:57.084700Z

Nice.

seancorfield 2021-04-15T14:42:08.086200Z

For background, I’m updating “run test at cursor” to a) work when the cursor is anywhere inside the whole form and b) inspect the result so it detects success/failure and pops up a notification about it.

seancorfield 2021-04-15T14:42:33.086800Z

Where I tripped up on this was trying to display (the first part of) the failure message in the popup.

mauricio.szabo 2021-04-15T15:10:55.087500Z

Oh, wow! I had a test for this issue, but I saw that it indeed works for some commands but not all 😞

mauricio.szabo 2021-04-15T19:21:01.088600Z

@seancorfield just published a fix. MS says that it'll be on on some minutes 😄

seancorfield 2021-04-15T19:42:57.090600Z

Appreciated! I will let you know how it goes 🙂

2021-04-15T19:43:49.091700Z

Hey, I haven’t kept up with everything - am I now supposed to run Atom or VS Code/VSCodium? Have them both installed, no real opinion myself 🙂

seancorfield 2021-04-15T19:45:29.092300Z

@mattias504 You can run whichever you prefer — and have the “same” editing/evaluation experience in both.

2021-04-15T19:46:52.094400Z

Thanks! I had some vague notion that maybe VS Code was steamrolling everything. I’ve had only good experiences with Atom so... well. All good then, either way 😄

borkdude 2021-04-15T19:48:09.095400Z

@mauricio.szabo How do you manage to provide the same editing experience for both editors? Do they offer a similar API or do you abstract their API? I'm not a heavy user of VSCode and don't use Atom but I'm always curious to learn

seancorfield 2021-04-15T19:59:23.096300Z

@borkdude I’m not him but the core of the integration is in a common repl-tooling package and then he has both an Atom wrapper and a VS Code wrapper.

seancorfield 2021-04-15T20:00:04.097200Z

When I switched from Atom to VS Code, my custom config (ClojureScript code, run via sci) was identical on both editors and I set up the exact same key bindings in both editors.

👍 1
pez 2021-04-15T20:05:06.097600Z

If you haven’t seen @borkdude: https://www.youtube.com/watch?v=LNo-j-pD6co

seancorfield 2021-04-15T20:06:14.098700Z

@pez BTW, I am still loving the fact that I can run Calva for everything-except-nREPL and continue using Clover for my favorite REPL setup via a Socket REPL! Thank you!

borkdude 2021-04-15T20:06:59.100700Z

I have seen parts of it, but a REPL is not something you can run in an editor without doing some custom work for that editor, hence my question. It may have been discussed in the video and I might have missed that part.

seancorfield 2021-04-15T20:07:23.101700Z

Just the other day, I connected VS Code directly to a Socket REPL running on our staging server to debug (and fix!) a problem an app that I couldn’t repro locally. No nREPL, no restart of the app, and no code needed in the app.

pez 2021-04-15T20:08:10.103Z

You are welcome, @seancorfield! I failed at teasing apart the monolith, and got stuck in that trail of thought. It was @ericdallo who saw what the workaround could be. Super easy to fix.

seancorfield 2021-04-15T20:08:38.103700Z

Monoliths bad, polyliths good 😆

🤘 3
3
borkdude 2021-04-16T08:24:08.113100Z

Thanks

mauricio.szabo 2021-04-15T20:09:08.104600Z

@borkdude yes, it was like Sean said: there's a ClojureScript library called repl-tooling that handles everything. The library expects a bunch of callbacks, and if you register these callbacks (mostly) everything works 😄

🎉 1
pez 2021-04-15T20:09:10.104700Z

@borkdude, it was more towards you being curious than the particular question.

🙏 1
borkdude 2021-04-15T20:10:43.105800Z

I have seen the original polylith talk at ClojureD but all I remember is "it's like lego". Can you explain what polylith is other than creating libraries?

pez 2021-04-15T20:11:15.106400Z

Calva is more of a polylith under the hood actually. But not enough, or I should have managed to tease the structural editing out.

mauricio.szabo 2021-04-15T20:11:30.106900Z

In fact, there are a number of callbacks that are registered TWICE for vscode, because of its API limitations

pez 2021-04-15T20:11:55.107700Z

Drew this the other day. For my presentation at Seajure in May:

mauricio.szabo 2021-04-15T20:12:00.108200Z

In Atom, there's really only "one" API - the editor itself. On VS, there's the "editor" API and the "Webview" API

borkdude 2021-04-15T20:12:08.108600Z

ok, but you essentially created a library that you can hook up to the specifics of the editors, this is what I expected

mauricio.szabo 2021-04-15T20:13:17.109800Z

Yes, configurable by SCI so I can migrate the config between editors. In fact, I keep testing my code in Atom, and some bugs that appear on "Clover" are 100% reproducible/fixable from "Chlorine" 🎉

pez 2021-04-15T20:13:43.110100Z

Bug compatibility is the seal of success. 😃

mauricio.szabo 2021-04-15T20:14:12.110200Z

I keep using Atom. I don't really have any issues with it 🙂

👍 1
mauricio.szabo 2021-04-15T20:15:00.110900Z

I'll put on the description of Clover: Bug compatibility with Chlorine 😄

😂 2
seancorfield 2021-04-15T20:22:44.111300Z

@borkdude It really isn’t about libraries. It’s an approach to working in a monorepo that takes a very structured approach to code organization and provides a clean separation between how you develop/test and how you actually build deployable “projects” from parts of your monorepo. It’s kinda hard to really “get” until you’ve used it — although recent changes to the website are helping, I think. The core thing that makes it “different” is the focus on small code “components” (bricks) that only interact via “interfaces” that are purely function definitions and that’s part of what allows for the “mix’n’match” approach to building stuff.

seancorfield 2021-04-15T20:23:27.111500Z

Initially, I thought it was very similar to what we were already doing at work: we have 40 subprojects and we build just over a dozen artifacts from that in different combinations.

seancorfield 2021-04-15T20:24:53.111700Z

But our deployable artifacts are very closely tied to the “main” subproject that contains their entry point — Polylith separates these — and our subprojects are very coarse-grained so you tend to get a huge “blob” of code (and dependencies) even when you just want one small portion of a subproject.

seancorfield 2021-04-15T20:25:31.111900Z

Our subprojects have become complected over time. I think Polylith’s guiding principles will help guard against that.