Skip to content

Commit 1f45a3f

Browse files
committed
Update examples
1 parent 9a0b909 commit 1f45a3f

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

.github/workflows/pull_request.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ 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 version
34+
run: sbt version | tail -n 1 | awk -F " " '{print $2}' > examples/version.txt
35+
36+
- name: Compile examples - compile
37+
run: cd examples && sbt compile

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ target/
66
.DS_Store
77
.bsp/
88
*.iml
9+
examples/version.txt
10+

examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Examples
2+
3+
These are simple application examples.
4+
5+
NOTE: There must be a [version.txt](./version.txt) file specifying the scala-js-chrome version to compile the examples with, for example:
6+
```txt
7+
0.8.0
8+
```

examples/build.sbt

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ 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 = scala.io.Source
7+
.fromInputStream(getClass.getClassLoader.getResourceAsStream("/version.txt"))
8+
.getLines()
9+
.toList
10+
.head
711

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

1014
lazy val exampleApp = project
1115
.in(file("app"))
12-
.dependsOn(scalaJsChrome)
1316
.enablePlugins(ChromeSbtPlugin)
1417
.settings(
1518
name := "Example App",
@@ -23,12 +26,12 @@ lazy val exampleApp = project
2326
"-Xfatal-warnings",
2427
"-feature"
2528
),
29+
libraryDependencies += "com.alexitc" %%% "scala-js-chrome" % scalajsChromeV,
2630
scalaJSUseMainModuleInitializer := true,
2731
Test / scalaJSUseMainModuleInitializer := false,
2832
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase(
2933
Some((Compile / fastOptJS / artifactPath).value.toURI)
3034
),
31-
packageJSDependencies / skip := false,
3235
// you can customize and have a static output name for lib and dependencies
3336
// instead of having the default files names like app-fastopt.js, ...
3437
(Compile / fastOptJS / artifactPath) := {
@@ -37,19 +40,13 @@ lazy val exampleApp = project
3740
(Compile / fullOptJS / artifactPath) := {
3841
(fullOptJS / crossTarget).value / "main.js"
3942
},
40-
(Compile / packageJSDependencies / artifactPath) := {
41-
(packageJSDependencies / crossTarget).value / "dependencies.js"
42-
},
43-
(Compile / packageMinifiedJSDependencies / artifactPath) := {
44-
(packageMinifiedJSDependencies / crossTarget).value / "dependencies.js"
45-
},
4643
chromeManifest := new AppManifest {
4744
val name = Keys.name.value
4845
val version = Keys.version.value
4946

5047
val app = App(
5148
background = Background(
52-
scripts = List("main.js", "dependencies.js")
49+
scripts = List("main.js", "main-bundle.js")
5350
)
5451
)
5552
override val defaultLocale = Some("en")
@@ -72,7 +69,6 @@ lazy val exampleApp = project
7269

7370
lazy val extension = project
7471
.in(file("extension"))
75-
.dependsOn(scalaJsChrome)
7672
.enablePlugins(ChromeSbtPlugin)
7773
.settings(
7874
name := "Example Extension",
@@ -86,12 +82,12 @@ lazy val extension = project
8682
"-Xfatal-warnings",
8783
"-feature"
8884
),
85+
libraryDependencies += "com.alexitc" %%% "scala-js-chrome" % scalajsChromeV,
8986
scalaJSUseMainModuleInitializer := true,
9087
Test / scalaJSUseMainModuleInitializer := false,
9188
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase(
9289
Some((Compile / fastOptJS / artifactPath).value.toURI)
9390
),
94-
packageJSDependencies / skip := false,
9591
// you can customize and have a static output name for lib and dependencies
9692
// instead of having the default files names like extension-fastopt.js, ...
9793
(Compile / fastOptJS / artifactPath) := {
@@ -100,16 +96,10 @@ lazy val extension = project
10096
(Compile / fullOptJS / artifactPath) := {
10197
(fullOptJS / crossTarget).value / "main.js"
10298
},
103-
(Compile / packageJSDependencies / artifactPath) := {
104-
(packageJSDependencies / crossTarget).value / "dependencies.js"
105-
},
106-
(Compile / packageMinifiedJSDependencies / artifactPath) := {
107-
(packageMinifiedJSDependencies / crossTarget).value / "dependencies.js"
108-
},
10999
chromeManifest := new ExtensionManifest {
110100

111101
val background = Background(
112-
scripts = List("main.js", "dependencies.js")
102+
scripts = List("main.js", "main-bundle.js")
113103
)
114104
val name = Keys.name.value
115105
val version = Keys.version.value

examples/project/plugins.sbt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
import sbt._
2-
lazy val sbtPlugin = ProjectRef(file("../../."), "plugin")
3-
lazy val root = project.in(file(".")).dependsOn(sbtPlugin)
1+
lazy val scalajsChromeV = scala.io.Source
2+
.fromInputStream(getClass.getClassLoader.getResourceAsStream("/version.txt"))
3+
.getLines()
4+
.toList
5+
.head
6+
7+
addSbtPlugin("com.alexitc" % "sbt-chrome-plugin" % scalajsChromeV)

0 commit comments

Comments
 (0)