{"id":16129133,"url":"https://github.com/laughedelic/scalajs-probot","last_synced_at":"2025-03-18T14:30:32.363Z","repository":{"id":141990922,"uuid":"132536102","full_name":"laughedelic/scalajs-probot","owner":"laughedelic","description":"🤖Scala.js facades for the Probot framework","archived":false,"fork":false,"pushed_at":"2018-06-03T01:06:38.000Z","size":41,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T10:03:17.740Z","etag":null,"topics":["facades","github-apps","github-bot","probot","scala","scala-js","scalajs","scalajs-facade"],"latest_commit_sha":null,"homepage":"https://probot.github.io","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laughedelic.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-08T01:25:04.000Z","updated_at":"2020-05-07T16:02:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"0759e2af-ce76-496e-8fe5-165195182aee","html_url":"https://github.com/laughedelic/scalajs-probot","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"12609435ccd2c2300f4904f0b3963230dbbca495"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laughedelic%2Fscalajs-probot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laughedelic%2Fscalajs-probot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laughedelic%2Fscalajs-probot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laughedelic%2Fscalajs-probot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laughedelic","download_url":"https://codeload.github.com/laughedelic/scalajs-probot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933378,"owners_count":20370989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facades","github-apps","github-bot","probot","scala","scala-js","scalajs","scalajs-facade"],"created_at":"2024-10-09T22:08:43.602Z","updated_at":"2025-03-18T14:30:32.357Z","avatar_url":"https://github.com/laughedelic.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Scala.js] facades for the [Probot] framework :robot:\n\n[\u003cimg align=\"right\" src=\"https://img.shields.io/badge/probot-7.0.0--typescript.4-blue.svg\"\u003e](https://www.npmjs.com/package/probot/v/7.0.0-typescript.4)\n[\u003cimg align=\"right\" src=\"https://www.scala-js.org/assets/badges/scalajs-0.6.17.svg\"\u003e](https://www.scala-js.org)\n[![](https://travis-ci.com/laughedelic/scalajs-probot.svg?branch=master)](https://travis-ci.com/laughedelic/scalajs-probot)\n[![](http://img.shields.io/github/release/laughedelic/scalajs-probot/all.svg)](https://github.com/laughedelic/scalajs-probot/releases/latest)\n[![](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://www.tldrlegal.com/l/mpl-2.0)\n[![](https://img.shields.io/badge/contact-gitter_chat-dd1054.svg)](https://gitter.im/laughedelic/scalajs-probot)\n\nThis project contains Scala.js facades for the [Probot] framework used to build GitHub Apps on Node.js.\n\n## 🚧 WORK IN PROGRESS 🚧\n\n_This project is in active development, there are no published releases yet. Things may break without a warning, so don't rely on it._\n\nIf you want to experiment with it and write a GitHub bot in Scala.js, don't hesitate to write to the [Gitter chat](https://gitter.im/laughedelic/scalajs-probot) and ask any questions. And if you're looking for ideas, check out the dedicated [probot/ideas](https://github.com/probot/ideas) repo.\n\n## Usage\n\nFirst of all you should head to the [Probot docs](https://probot.github.io/docs/) and read at least the Getting Started part. It explains the basics very well and gives you a general understanding of how this framework functions.\n\nFor interacting with the GitHub API this library depends on the Scala.js facades for the Octokit library: [scalajs-octokit](https://github.com/laughedelic/scalajs-octokit).\n\nFor the usage example refer to the [scalafmt-probot](https://github.com/laughedelic/scalafmt-probot) project. The project setup will be simplified in the future.\n\n### Installation\n\n\u003cdetails\u003e\u003csummary\u003e🛠 Check installation instructions later, when there is a published release...\u003c/summary\u003e\n\n1. Add Probot dependency to your project. It's important that the version of the underlying JS library matches the one this facade is built for.\n\n    * If it's a Node.js project where you manage dependencies with npm, run\n        ```shell\n        npm install probot@next --save\n        ```\n\n    * If it's a Scala.js project use [scalajs-bundler] and add to your `build.sbt`:\n        ```scala\n        Compile/npmDependencies += \"probot\" -\u003e \"next\"\n        ```\n\n    These facades are based on the [TypeScript version of Probot](https://github.com/probot/probot/pull/372) which is not released yet, but is available under the `next` version tag.\n\n2. Add facades dependency to your `build.sbt`:\n    ```scala\n    resolvers += Resolver.jcenterRepo\n    libraryDependencies += \"laughedelic\" %%% \"scalajs-probot\" % \"\u003cversion\u003e\"\n    ```\n    (see the latest release version on the badge above)\n\n3. To turn the project into a runnable application add to your `build.sbt`:\n    ```scala\n    scalaJSUseMainModuleInitializer := true\n    ```\n\n    Then in the code implement a `Probot.Plugin` (which is a function `Application =\u003e Unit`) and define a `main` method:\n    ```scala\n    import laughedelic.probot._\n\n    object ProbotApp {\n\n      def plugin(app: Application): Unit = ???\n\n      def main(args: Array[String]): Unit = ProbotApp.run(plugin)\n    }\n    ```\n    See the [example](#example) below.\n\n4. (Optionally) for local testing you may want to add a dependency on the smee-client\n    ```scala\n    Compile/npmDependencies += \"smee-client\" -\u003e \"1.0.1\"\n    ```\n\n    Then you can run the application with `sbt run` it should work the same as the `npm start` (=`probot run ./lib/index.js`) from the [Probot docs](https://probot.github.io/docs/development/#running-the-app-locally). The only difference is that it ignores any command line args, so I have to set environment variables. You can set them in the `.env` file.\n\n\u003c/details\u003e\n\n### Example\n\nHere's a translation of the [Hello World example](https://probot.github.io/docs/hello-world/) from the Probot docs to Scala:\n\n```scala\nimport laughedelic.probot._\nimport scala.scalajs.concurrent.JSExecutionContext.Implicits.queue\n\nobject HelloWorld {\n\n  def plugin(app: Application): Unit = {\n\n    app.on(\"issues.opened\") { context =\u003e\n      // Post a comment on every new issue\n      context.github.issues.createComment(\n        owner  = context.issue().owner,\n        repo   = context.issue().repo,\n        number = context.issue().number,\n        body   = \"Hello World! 👋\"\n      )\n    }\n  }\n\n  def main(args: Array[String]): Unit = Probot.run(plugin)\n}\n```\n\nThe translation from JavaScript is pretty straightforward. A couple of things to notice:\n\n* In JS all GitHub API parameters are just objects, so it's possible to reuse `context.issue` and write\n    ```javascript\n    context.github.issues.createComment(\n      // context.issue appends given object to { owner: ..., repo: ..., number: ... }\n      context.issue({body: 'Hello World!'})\n    )\n    ```\n    In Scala `createComment` method has typed arguments, so we have to pass those values from the context explicitly. I don't think it's too verbose, but if anybody has an idea how to improve it, let me know.\n* `{ context =\u003e ... }` callback returns a `Future` which is converted to a `js.Promise`, this is why the execution context import is needed.\n\nFor a more complex example and the general project setup refer to the [scalafmt-probot](https://github.com/laughedelic/scalafmt-probot) project.\n\n\n[Scala.js]: https://www.scala-js.org\n[Probot]: https://probot.github.io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaughedelic%2Fscalajs-probot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaughedelic%2Fscalajs-probot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaughedelic%2Fscalajs-probot/lists"}