-
Notifications
You must be signed in to change notification settings - Fork 81
Opam Onboarding #1737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Opam Onboarding #1737
Changes from 42 commits
acc926b
7cabcfd
9117b4e
0f2164e
83b1346
33dfc13
5bf3191
68af690
5c7e4be
a0e84bc
6512210
5f5e0d3
570dc15
42ad0b3
db4bec5
6142976
6363262
a79f64f
354485a
2f5515a
ef7d5c9
c345991
b0c0c35
a4cc07b
7dfdeba
0b4a255
bdc802f
ee1f2cb
debb683
a54a6e3
cf54ef3
b472f24
fe8bf76
615d911
0ca33be
19d7dce
e9090e3
ee84804
41045b3
d4008f2
da40616
6a38ad3
b735fa8
30b0c79
050e3b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,6 +247,184 @@ let _switch_impl_intf = | |
| command Command_api.Internal.switch_impl_intf callback | ||
| ;; | ||
|
|
||
| let walkthrough_terminal_instance = ref None | ||
|
|
||
| let walkthrough_terminal instance = | ||
| match !walkthrough_terminal_instance with | ||
| | Some t -> t | ||
| | None -> | ||
| let t = | ||
| Terminal_sandbox.create | ||
| ~name:"OCaml Platform Walkthrough" | ||
| (Extension_instance.sandbox instance) | ||
| in | ||
| walkthrough_terminal_instance := Some t; | ||
| t | ||
| ;; | ||
|
|
||
| let _install_opam = | ||
| let callback (instance : Extension_instance.t) () = | ||
| let process_installation () = | ||
| let open Promise.Syntax in | ||
| let* opam = Opam.make () in | ||
| match opam with | ||
| | None -> | ||
| let options = | ||
| ProgressOptions.create | ||
| ~location:(`ProgressLocation Notification) | ||
| ~title:"Installing opam package manager" | ||
| ~cancellable:false | ||
| () | ||
| in | ||
| let task ~progress:_ ~token:_ = | ||
| let+ result = | ||
| match Platform.t with | ||
| | Win32 -> | ||
| let _ = | ||
| let terminal = | ||
| Extension_instance.sandbox instance |> Terminal_sandbox.create | ||
| in | ||
| let _ = Terminal_sandbox.show ~preserveFocus:true terminal in | ||
| Terminal_sandbox.send terminal "winget install Git.Git OCaml.opam" | ||
pitag-ha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| in | ||
| Ok () |> Promise.return | ||
| | Darwin | Linux | Other -> | ||
| let open Promise.Result.Syntax in | ||
| let+ _ = | ||
| let _ = | ||
| let terminal = walkthrough_terminal instance in | ||
| let _ = Terminal_sandbox.show ~preserveFocus:true terminal in | ||
| Terminal_sandbox.send | ||
| terminal | ||
| "bash -c \"sh <(curl -fsSL https://opam.ocaml.org/install.sh)\"" | ||
| in | ||
|
Comment on lines
+297
to
+301
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For people who are on Windows and use WSL2 without having set up their DNS specifically, this will fail, right? Do you have an idea of how the walk-through could catch and handle a DNS-related failure here, @PizieDust ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes indeed, without setting up DNS this step will certainly fail. Usually we just return whatever error vscode gives |
||
| Ok () |> Promise.return | ||
| in | ||
| () | ||
| in | ||
| match result with | ||
| | Ok () -> Ojs.null | ||
| | Error err -> | ||
| show_message `Error "An error occured while installing opam %s" err; | ||
| Ojs.null | ||
| in | ||
| let+ _ = Vscode.Window.withProgress (module Ojs) ~options ~task in | ||
| () | ||
| | Some _ -> show_message `Info "Opam is already installed!" |> Promise.return | ||
pitag-ha marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| in | ||
| let (_ : unit Promise.t) = process_installation () in | ||
| () | ||
| in | ||
| command Command_api.Internal.install_opam callback | ||
| ;; | ||
|
|
||
| let _init_opam = | ||
| let callback (instance : Extension_instance.t) () = | ||
| let options = | ||
| ProgressOptions.create | ||
| ~location:(`ProgressLocation Notification) | ||
| ~title:"Initialising opam" | ||
| ~cancellable:false | ||
| () | ||
| in | ||
| let task ~progress:_ ~token:_ = | ||
| let open Promise.Syntax in | ||
| let+ result = | ||
| let open Promise.Result.Syntax in | ||
| let+ _ = | ||
| let _ = | ||
| let terminal = walkthrough_terminal instance in | ||
| let _ = Terminal_sandbox.show ~preserveFocus:true terminal in | ||
| Terminal_sandbox.send terminal "opam init" | ||
| in | ||
| Ok () |> Promise.return | ||
| in | ||
| () | ||
| in | ||
| match result with | ||
| | Ok () -> Ojs.null | ||
| | Error err -> | ||
| show_message `Error "An error occured while initializing opam %s" err; | ||
| Ojs.null | ||
| in | ||
| let _ = Vscode.Window.withProgress (module Ojs) ~options ~task in | ||
| () | ||
| in | ||
| command Command_api.Internal.init_opam callback | ||
| ;; | ||
|
|
||
| let _install_ocaml_dev = | ||
| let callback (instance : Extension_instance.t) () = | ||
| let options = | ||
| ProgressOptions.create | ||
| ~location:(`ProgressLocation Notification) | ||
| ~title:"Installing development packages" | ||
| ~cancellable:false | ||
| () | ||
| in | ||
| let task ~progress:_ ~token:_ = | ||
| let open Promise.Syntax in | ||
| let+ result = | ||
| let open Promise.Result.Syntax in | ||
| let+ _ = | ||
| let _ = | ||
| let terminal = walkthrough_terminal instance in | ||
| let _ = Terminal_sandbox.show ~preserveFocus:true terminal in | ||
| Terminal_sandbox.send | ||
| terminal | ||
| "opam install ocaml-lsp-server odoc ocamlformat utop" | ||
| in | ||
| Ok () |> Promise.return | ||
| in | ||
| () | ||
| in | ||
| match result with | ||
| | Ok () -> Ojs.null | ||
| | Error err -> | ||
| show_message `Error "An error occured while installing packages %s" err; | ||
| Ojs.null | ||
| in | ||
| let _ = Vscode.Window.withProgress (module Ojs) ~options ~task in | ||
| () | ||
| in | ||
| command Command_api.Internal.install_ocaml_dev callback | ||
| ;; | ||
|
|
||
| let _open_utop = | ||
| let callback (instance : Extension_instance.t) () = | ||
| let options = | ||
| ProgressOptions.create | ||
| ~location:(`ProgressLocation Notification) | ||
| ~title:"Launching utop" | ||
| ~cancellable:false | ||
| () | ||
| in | ||
| let task ~progress:_ ~token:_ = | ||
| let open Promise.Syntax in | ||
| let+ result = | ||
| let open Promise.Result.Syntax in | ||
| let+ _ = | ||
| let _ = | ||
| let terminal = walkthrough_terminal instance in | ||
| let _ = Terminal_sandbox.show ~preserveFocus:true terminal in | ||
| Terminal_sandbox.send terminal "opam exec -- utop" | ||
| in | ||
| Ok () |> Promise.return | ||
| in | ||
| () | ||
| in | ||
| match result with | ||
| | Ok () -> Ojs.null | ||
| | Error err -> | ||
| show_message `Error "An error occured while opening utop %s" err; | ||
| Ojs.null | ||
| in | ||
| let _ = Vscode.Window.withProgress (module Ojs) ~options ~task in | ||
| () | ||
| in | ||
| command Command_api.Internal.open_utop callback | ||
| ;; | ||
|
|
||
| let _open_current_dune_file = | ||
| let callback (_ : Extension_instance.t) () = | ||
| match Vscode.Window.activeTextEditor () with | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.