Skip to content

Commit 31bfc42

Browse files
committed
Update examples
1 parent 9a0b909 commit 31bfc42

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

.github/workflows/pull_request.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,16 @@ jobs:
2525

2626
- name: Run tests
2727
run: sbt test
28+
29+
- name: Publish local
30+
run: sbt +publishLocal
31+
32+
# Examples
33+
- name: Compile examples - check library version
34+
run: sbt version | tail -n 1 | awk -F " " '{print $2}' > .version
35+
36+
- name: Compile examples - set library version
37+
run: sed -i -e "s#SCALAJS_CHROME_VERSION#$(cat .version)#" examples/project/plugins.sbt && sed -i -e "s#SCALAJS_CHROME_VERSION#$(cat .version)#" examples/build.sbt
38+
39+
- name: Compile examples
40+
run: cd examples && sbt compile

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ target/
66
.DS_Store
77
.bsp/
88
*.iml
9+
.version

examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Examples
2+
3+
These are simple application examples.
4+
5+
NOTE: Update `project/plugins.sbt` and `build.sbt` to set the library version.

examples/build.sbt

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import chrome.permissions.Permission
33
import chrome.permissions.Permission.{API, Host}
44
import com.alexitc.{Chrome, ChromeSbtPlugin}
55

6-
lazy val examples = project.in(file(".")).aggregate(exampleApp, extension)
6+
lazy val scalajsChromeV = "SCALAJS_CHROME_VERSION"
77

8-
lazy val scalaJsChrome = ProjectRef(file("../."), "bindings")
8+
lazy val examples = project.in(file(".")).aggregate(exampleApp, extension)
99

1010
lazy val exampleApp = project
1111
.in(file("app"))
12-
.dependsOn(scalaJsChrome)
1312
.enablePlugins(ChromeSbtPlugin)
1413
.settings(
1514
name := "Example App",
@@ -23,12 +22,12 @@ lazy val exampleApp = project
2322
"-Xfatal-warnings",
2423
"-feature"
2524
),
25+
libraryDependencies += "com.alexitc" %%% "scala-js-chrome" % scalajsChromeV,
2626
scalaJSUseMainModuleInitializer := true,
2727
Test / scalaJSUseMainModuleInitializer := false,
2828
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase(
2929
Some((Compile / fastOptJS / artifactPath).value.toURI)
3030
),
31-
packageJSDependencies / skip := false,
3231
// you can customize and have a static output name for lib and dependencies
3332
// instead of having the default files names like app-fastopt.js, ...
3433
(Compile / fastOptJS / artifactPath) := {
@@ -37,19 +36,13 @@ lazy val exampleApp = project
3736
(Compile / fullOptJS / artifactPath) := {
3837
(fullOptJS / crossTarget).value / "main.js"
3938
},
40-
(Compile / packageJSDependencies / artifactPath) := {
41-
(packageJSDependencies / crossTarget).value / "dependencies.js"
42-
},
43-
(Compile / packageMinifiedJSDependencies / artifactPath) := {
44-
(packageMinifiedJSDependencies / crossTarget).value / "dependencies.js"
45-
},
4639
chromeManifest := new AppManifest {
4740
val name = Keys.name.value
4841
val version = Keys.version.value
4942

5043
val app = App(
5144
background = Background(
52-
scripts = List("main.js", "dependencies.js")
45+
scripts = List("main.js", "main-bundle.js")
5346
)
5447
)
5548
override val defaultLocale = Some("en")
@@ -72,7 +65,6 @@ lazy val exampleApp = project
7265

7366
lazy val extension = project
7467
.in(file("extension"))
75-
.dependsOn(scalaJsChrome)
7668
.enablePlugins(ChromeSbtPlugin)
7769
.settings(
7870
name := "Example Extension",
@@ -86,12 +78,12 @@ lazy val extension = project
8678
"-Xfatal-warnings",
8779
"-feature"
8880
),
81+
libraryDependencies += "com.alexitc" %%% "scala-js-chrome" % scalajsChromeV,
8982
scalaJSUseMainModuleInitializer := true,
9083
Test / scalaJSUseMainModuleInitializer := false,
9184
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase(
9285
Some((Compile / fastOptJS / artifactPath).value.toURI)
9386
),
94-
packageJSDependencies / skip := false,
9587
// you can customize and have a static output name for lib and dependencies
9688
// instead of having the default files names like extension-fastopt.js, ...
9789
(Compile / fastOptJS / artifactPath) := {
@@ -100,16 +92,10 @@ lazy val extension = project
10092
(Compile / fullOptJS / artifactPath) := {
10193
(fullOptJS / crossTarget).value / "main.js"
10294
},
103-
(Compile / packageJSDependencies / artifactPath) := {
104-
(packageJSDependencies / crossTarget).value / "dependencies.js"
105-
},
106-
(Compile / packageMinifiedJSDependencies / artifactPath) := {
107-
(packageMinifiedJSDependencies / crossTarget).value / "dependencies.js"
108-
},
10995
chromeManifest := new ExtensionManifest {
11096

11197
val background = Background(
112-
scripts = List("main.js", "dependencies.js")
98+
scripts = List("main.js", "main-bundle.js")
11399
)
114100
val name = Keys.name.value
115101
val version = Keys.version.value

examples/project/plugins.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import sbt._
2-
lazy val sbtPlugin = ProjectRef(file("../../."), "plugin")
3-
lazy val root = project.in(file(".")).dependsOn(sbtPlugin)
1+
lazy val scalajsChromeV = "SCALAJS_CHROME_VERSION"
2+
3+
addSbtPlugin("com.alexitc" % "sbt-chrome-plugin" % scalajsChromeV)

0 commit comments

Comments
 (0)