nbb

mkvlr 2023-04-14T12:49:31.721689Z

want: target nbb for https://playwright.dev/docs/debug#playwright-inspector.

borkdude 2023-04-14T12:51:59.763629Z

@mkvlr why do we need this if have already have a REPL, and e.g. https://github.com/borkdude/deflet? You can "debug" your build as you're writing it and use the code you wrote to "debug" as the final product

mkvlr 2023-04-14T12:52:29.000309Z

yeah, doesn’t get me the selectors/locators though

mkvlr 2023-04-14T12:53:10.981609Z

the inspector lets me drive the browser interactively and generates the test code for us

πŸ‘€ 1
🀩 1
borkdude 2023-04-14T12:53:25.236009Z

oh, right

mkvlr 2023-04-14T12:53:28.040669Z

including the locators at the right specificity

mkvlr 2023-04-14T12:53:43.800009Z

it’s pretty neat

borkdude 2023-04-14T12:54:04.771769Z

then maybe you don't need to write any CLJS, just use what it produced?

borkdude 2023-04-14T12:54:14.980489Z

you can load / wrap that code from nbb

mkvlr 2023-04-14T12:54:15.723929Z

yeah, considering that

mkvlr 2023-04-14T12:54:16.661729Z

https://playwright.dev/docs/debug

mkvlr 2023-04-14T12:55:17.980139Z

all this tooling is pretty great, uphill battle to replicate it, maybe better to just use nbb to talk to our api but stick to js for the browser tests

borkdude 2023-04-14T12:56:13.222569Z

sure

mkvlr 2023-04-14T12:57:16.598809Z

these reports and traces also look pretty nice https://playwright.dev/docs/trace-viewer-intro

borkdude 2023-04-14T12:58:16.012339Z

Maybe they have an API to let you plug in what language you want to generate, but not sure if it's worth it compared to the generated JS

mkvlr 2023-04-14T12:58:53.928669Z

yep

2023-04-16T20:21:17.490039Z

npx playwright codegen is so good and the reason we have typescript test files in our cljs project

ericdallo 2023-04-14T15:12:49.465199Z

Regarding https://github.com/clojure-lsp/clojure-lsp/issues/1418#issuecomment-1443705502, I tried add that to nbb and failed after recall I can't shell-out in js πŸ˜… any tips?

ericdallo 2023-04-14T15:12:58.644029Z

what I tried to add at src/nbb/impl/main.cljs

(when (:print-classpath opts)
  (println (process/shell "bb" "print-deps" "--format" "classpath"))
  (js/process.exit 0))

borkdude 2023-04-14T15:24:59.474299Z

what is process here?

ericdallo 2023-04-14T15:25:51.144679Z

I tried with both babaska.process and clojure.java.shell, for babashka.process I tried adding on deps.edn but didn't find the deps, not sure if I should do something else

borkdude 2023-04-14T15:25:59.118899Z

you can look at impl/deps.cljs to see how to shell out to bb

πŸ‘€ 1
borkdude 2023-04-14T15:26:20.832779Z

babashka.process and clojure.java.shell don't work in CLJS

ericdallo 2023-04-14T15:26:41.996119Z

yeah, that was what I thought since runs on js, thanks will take a look

ericdallo 2023-04-14T15:39:10.068079Z

Works :)

πŸŽ‰ 1
ericdallo 2023-04-14T15:40:12.091089Z

I'm doing ATM

(println (.toString (cproc/execSync "bb --config nbb.edn print-deps --format classpath")))
now we need to include nbb deps or you think this is already enough? (note the --config nbb.edn there, not sure if we should pass a different cwd)

borkdude 2023-04-14T15:40:54.512489Z

config should be sufficient

ericdallo 2023-04-14T15:44:39.854159Z

nice, so I think it's done, I will try to add tests and send a PR, thanks!

πŸ‘ 1
ericdallo 2023-04-14T17:51:00.678039Z

I couldn't find a better way to test the shell-out https://github.com/babashka/nbb/pull/321

ericdallo 2023-04-14T17:58:16.721679Z

My first nbb PR :D

borkdude 2023-04-14T18:11:26.098179Z

I think it would be useful to have the same API as with bb:

bb print-deps --format <classpath> | <deps>

ericdallo 2023-04-14T18:22:12.788349Z

Sounds good, is it ok to support only classpath format for now?

ericdallo 2023-04-14T18:25:36.297629Z

well I will only delegate to bb so I think it's ok to support both right now

borkdude 2023-04-14T18:27:04.711809Z

yes, only classpath is ok

borkdude 2023-04-14T18:27:10.774249Z

you can use babashka.cli to parse args

borkdude 2023-04-14T18:27:25.178929Z

haven't looked at the code yet ;)

borkdude 2023-04-14T18:28:14.255569Z

I think print-deps might print too much when going through bb though, it will print its own deps too and e.g. not promesa etc, I think?

ericdallo 2023-04-14T18:32:54.566619Z

hum, yeah, I think so

ericdallo 2023-04-14T18:33:02.895089Z

what you think nbb should print?

borkdude 2023-04-14T18:37:16.170629Z

the deps that it has built-in, see the nbb deps.edn

ericdallo 2023-04-14T18:37:39.943389Z

Ah yeah, what's your suggestion of print those deps?

borkdude 2023-04-14T18:41:23.271109Z

what do you mean?

ericdallo 2023-04-14T18:43:07.921809Z

I mean, the correct for nbb would be to print the deps from nbb's deps.edn right? but bb print-deps --format classpath would print bb deps which are not included in nbb IIUC

borkdude 2023-04-14T18:43:24.067169Z

yeah

borkdude 2023-04-14T18:43:54.466909Z

I think we need to include the deps.edn into the CLJS build via a macro

borkdude 2023-04-14T18:44:03.705829Z

so we can print it later

ericdallo 2023-04-14T18:44:04.953889Z

bb print-deps --config <nbb-deps.edn-location> would probably work right?

ericdallo 2023-04-14T18:44:09.787579Z

yes

borkdude 2023-04-14T18:44:31.657639Z

that will work, but it will not print the built-in deps

borkdude 2023-04-14T18:44:45.841999Z

and it will also still print the built-in deps of bb

ericdallo 2023-04-14T18:44:52.875899Z

I see

ericdallo 2023-04-14T18:45:26.588029Z

> include the deps.edn into the CLJS build via a macro how can we do that, not sure I get how that will work

borkdude 2023-04-14T18:46:59.139549Z

I think it might be better to not use bb print-deps after all. See nbb.impl.deps which extracts the dependencies of nbb.edn into .nbb/.cache/.blablabla and this is what nbb uses as its classpath. you can get this classpath with nbb.classpath/get-classpath

borkdude 2023-04-14T18:47:15.362369Z

The only thing left is to add the built-in deps to the classpath

ericdallo 2023-04-14T18:47:52.129889Z

humm I see

ericdallo 2023-04-14T18:48:32.705629Z

so would be a merge of nbb.classpath/get-classpath + builtin deps that are in nbb's deps.edn

borkdude 2023-04-14T18:48:43.575189Z

yeah

borkdude 2023-04-14T18:49:42.797369Z

for the built-ins we can still use babashka, by doing:

(babashka.deps/add-deps {:deps {built-in-deps}}) + babashka.classpath/get-classpath

ericdallo 2023-04-14T18:50:13.215069Z

🀯

borkdude 2023-04-14T18:50:24.221699Z

and then combine those

ericdallo 2023-04-14T18:50:27.678459Z

cool, I'll give it a try, I think I got it