Skip to content

Commit 92a9118

Browse files
committed
Update examples
1 parent 9a0b909 commit 92a9118

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-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: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ 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+
.head
710

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

1013
lazy val exampleApp = project
1114
.in(file("app"))
12-
.dependsOn(scalaJsChrome)
1315
.enablePlugins(ChromeSbtPlugin)
1416
.settings(
1517
name := "Example App",
@@ -23,12 +25,12 @@ lazy val exampleApp = project
2325
"-Xfatal-warnings",
2426
"-feature"
2527
),
28+
libraryDependencies += "com.alexitc" %%% "scala-js-chrome" % scalajsChromeV,
2629
scalaJSUseMainModuleInitializer := true,
2730
Test / scalaJSUseMainModuleInitializer := false,
2831
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase(
2932
Some((Compile / fastOptJS / artifactPath).value.toURI)
3033
),
31-
packageJSDependencies / skip := false,
3234
// you can customize and have a static output name for lib and dependencies
3335
// instead of having the default files names like app-fastopt.js, ...
3436
(Compile / fastOptJS / artifactPath) := {
@@ -37,19 +39,13 @@ lazy val exampleApp = project
3739
(Compile / fullOptJS / artifactPath) := {
3840
(fullOptJS / crossTarget).value / "main.js"
3941
},
40-
(Compile / packageJSDependencies / artifactPath) := {
41-
(packageJSDependencies / crossTarget).value / "dependencies.js"
42-
},
43-
(Compile / packageMinifiedJSDependencies / artifactPath) := {
44-
(packageMinifiedJSDependencies / crossTarget).value / "dependencies.js"
45-
},
4642
chromeManifest := new AppManifest {
4743
val name = Keys.name.value
4844
val version = Keys.version.value
4945

5046
val app = App(
5147
background = Background(
52-
scripts = List("main.js", "dependencies.js")
48+
scripts = List("main.js", "main-bundle.js")
5349
)
5450
)
5551
override val defaultLocale = Some("en")
@@ -72,7 +68,6 @@ lazy val exampleApp = project
7268

7369
lazy val extension = project
7470
.in(file("extension"))
75-
.dependsOn(scalaJsChrome)
7671
.enablePlugins(ChromeSbtPlugin)
7772
.settings(
7873
name := "Example Extension",
@@ -86,12 +81,12 @@ lazy val extension = project
8681
"-Xfatal-warnings",
8782
"-feature"
8883
),
84+
libraryDependencies += "com.alexitc" %%% "scala-js-chrome" % scalajsChromeV,
8985
scalaJSUseMainModuleInitializer := true,
9086
Test / scalaJSUseMainModuleInitializer := false,
9187
scalaJSLinkerConfig := scalaJSLinkerConfig.value.withRelativizeSourceMapBase(
9288
Some((Compile / fastOptJS / artifactPath).value.toURI)
9389
),
94-
packageJSDependencies / skip := false,
9590
// you can customize and have a static output name for lib and dependencies
9691
// instead of having the default files names like extension-fastopt.js, ...
9792
(Compile / fastOptJS / artifactPath) := {
@@ -100,16 +95,10 @@ lazy val extension = project
10095
(Compile / fullOptJS / artifactPath) := {
10196
(fullOptJS / crossTarget).value / "main.js"
10297
},
103-
(Compile / packageJSDependencies / artifactPath) := {
104-
(packageJSDependencies / crossTarget).value / "dependencies.js"
105-
},
106-
(Compile / packageMinifiedJSDependencies / artifactPath) := {
107-
(packageMinifiedJSDependencies / crossTarget).value / "dependencies.js"
108-
},
10998
chromeManifest := new ExtensionManifest {
11099

111100
val background = Background(
112-
scripts = List("main.js", "dependencies.js")
101+
scripts = List("main.js", "main-bundle.js")
113102
)
114103
val name = Keys.name.value
115104
val version = Keys.version.value

examples/project/plugins.sbt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
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+
.head
5+
6+
addSbtPlugin("com.alexitc" % "sbt-chrome-plugin" % scalajsChromeV)

0 commit comments

Comments
 (0)