Skip to content

Commit fefffb0

Browse files
authored
Merge branch 'master' into update/master/scala-project-template
2 parents 47ecb1e + 73c0f70 commit fefffb0

File tree

18 files changed

+341
-44
lines changed

18 files changed

+341
-44
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Scala Steward: Reformat with scalafmt 3.1.2
22
fb6cfb8aea15a1b339e3ed69e1e96acd7df4cae6
3+
4+
# Scala Steward: Reformat with scalafmt 3.7.5
5+
8867de8094a45da697432404c9ad60de534321c0

.github/workflows/scala-steward.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
on:
2-
push:
3-
branches-ignore:
4-
- "update/**"
5-
schedule:
6-
- cron: "0 0 * * 0"
72
workflow_dispatch:
83

94
name: Launch Scala Steward

.github/workflows/scala.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414

15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
scala:
19-
- 2.12.20
20-
2115
steps:
2216
- uses: actions/checkout@v3
2317
with:
@@ -28,6 +22,11 @@ jobs:
2822
java-version: "11"
2923
distribution: temurin
3024
- uses: sbt/setup-sbt@v1
25+
- id: nodenv
26+
uses: nodenv/actions/node-version@v2
27+
- uses: actions/setup-node@v1
28+
with:
29+
node-version: "${{ steps.nodenv.outputs.node-version }}"
3130
- name: Cache SBT
3231
uses: actions/cache@v3
3332
with:
@@ -37,13 +36,7 @@ jobs:
3736
~/.sbt/
3837
~/.coursier/
3938
key: |
40-
${{runner.os}}-${{matrix.scala}}-${{hashFiles('**/*.sbt')}}-${{matrix.sbt-args}}
41-
${{runner.os}}-${{matrix.scala}}-${{hashFiles('**/*.sbt')}}-
42-
${{runner.os}}-${{matrix.scala}}-
39+
${{runner.os}}-${{hashFiles('**/build.sbt')}}
40+
${{runner.os}}-
4341
- name: Run tests
44-
run: sbt ${{matrix.sbt-args}} ++${{ matrix.scala }} test
45-
- name: Publish to Maven Central Repository
46-
env:
47-
GITHUB_PERSONAL_ACCESS_TOKEN: ${{secrets.PERSONAL_ACCESS_TOKEN}}
48-
if: ${{ env.GITHUB_PERSONAL_ACCESS_TOKEN != '' && github.event_name != 'pull_request' }}
49-
run: sbt ${{matrix.sbt-args}} ++${{ matrix.scala }} "set every Seq(sonatypeSessionName := \"${{github.workflow}} ${{github.run_id}}-${{github.run_number}}-${{github.run_attempt}}-$$ ${{ matrix.scala }}\", publishTo := sonatypePublishToBundle.value)" publishSigned sonatypeBundleRelease
42+
run: sbt test

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16.13.0

.sbtopts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-J-Xss5m
2+
-J-Xmx7g
3+
-J-XX:MaxMetaspaceSize=9999g

.scalafmt.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
runner.dialect = scala212source3
22
version = "3.7.17"
33
maxColumn = 80
4+
xmlLiterals.assumeFormatted = true

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "pwa-chrome",
9+
"request": "launch",
10+
"name": "Launch Chrome against localhost",
11+
"url": "file:${workspaceFolder}/web/target/web/public/main/devMod.html",
12+
"webRoot": "${workspaceFolder}/web/target/web/public/main"
13+
}
14+
]
15+
}

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org>

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# All-in-One Scala.js Static Web Project Template
2+
[![Open in Gitpod](https://img.shields.io/badge/Gitpod-open%20in%20an%20online%20IDE-%230092CF.svg )](https://gitpod.io/#https://github.com/Atry/scalajs-all-in-one-template)
3+
[![Scala CI](https://github.com/Atry/scalajs-all-in-one-template/actions/workflows/scala.yml/badge.svg)](https://github.com/Atry/scalajs-all-in-one-template/actions/workflows/scala.yml)
4+
5+
This repository is a template of the basic structure for a Scala.js web project, contains all the best technologies in Scala.js community until 2023:
6+
7+
* [Sbt](https://scala-sbt.org) is the build tool.
8+
* [Scala.js](https://www.scala-js.org/) to compile [Scala](https://scala-lang.org) to JavaScript.
9+
* [html.scala](https://github.com/GlasslabGames/html.scala/) for reactive HTML templating.
10+
* [Binding.scala](https://github.com/ThoughtWorksInc/Binding.scala) for data-binding.
11+
* [sbt-sassify](https://github.com/irundaia/sbt-sassify/) for compiling [Sass](https://sass-lang.com/) to CSS.
12+
* [Font Awesome](https://fontawesome.com/) as an example of Sass dependency.
13+
* [Bootstrap](https://getbootstrap.com/) for responsive UI components.
14+
* [sbt-scala-js-map](https://github.com/ThoughtWorksInc/sbt-scala-js-map) for source mapping.
15+
* [scalajs-bundler](https://github.com/scalacenter/scalajs-bundler) for [webpack](https://webpack.js.org/) and [NPM](https://www.npmjs.com/) (or [YARN](https://yarnpkg.com)).
16+
* [ScalablyTyped](https://scalablytyped.org/) for type definition of NPM dependencies.
17+
* [pad](https://pad-project.js.org/) as an example of NPM dependency.
18+
* [sbt-web](https://github.com/sbt/sbt-web) for [WebJars](https://www.webjars.org/).
19+
* [sbt-buildinfo](https://github.com/sbt/sbt-buildinfo) to expose sbt settings to runtime.
20+
* [Coursier](https://get-coursier.io/) for fast downloading Maven and ivy dependencies.
21+
* [sbt-example](https://github.com/ThoughtWorksInc/sbt-example) to generate [ScalaTest](http://www.scalatest.org/) from from examples in Scaladoc comments.
22+
* [sbt-dynver](https://github.com/dwijnand/sbt-dynver) to determine the build version from git tags.
23+
24+
Note that the default branch of this repository is written in Scala 3. Check out the [scala-2.13](https://github.com/Atry/scalajs-all-in-one-template/tree/scala-2.13) branch for a project template in Scala 2.13.
25+
26+
Other libraries and tools can be found in [sbt settings](https://github.com/Atry/Binding.scala-template/search?q=extension%3Asbt&unscoped_q=extension%3Asbt).
27+
28+
This template contains settings for a static web project, and you can additionally configure Play or Akka HTTP dependencies in `web/build.sbt` to turn it into a dynamic web project.
29+
30+
## Directory Structure
31+
32+
* web/
33+
34+
The sbt-web project for web assets
35+
* build.sbt
36+
37+
Sbt settings for the sbt-web project, which contains WebJars dependency configurations, including SASS / SCSS dependencies and static resources from external libraries.
38+
* src/main/assets/
39+
40+
The root directory of static assets sources.
41+
* index.html
42+
43+
The main page in release mode, which references uglified CSS and JS resources.
44+
* devMod.html
45+
46+
The main page in development mode, which references indented CSS and JS resources.
47+
* style.scss
48+
49+
The style sheet used by main page in SCSS syntax, which will be compiled to `style.css` by a sbt-web pipeline.
50+
* target/web/public/main/
51+
52+
The root directory of static assets output.
53+
* lib/
54+
55+
The output directory for Webjars dependencies.
56+
* js/
57+
58+
The Scala.js project to create JS output used in the sbt-web project.
59+
60+
* build.sbt
61+
62+
Sbt settings for the Scala.js project, which contains Scala.js settings, NPM dependencies and type definitions.
63+
64+
* src/main/scala/
65+
66+
The directory contains Scala.js source files.
67+
* project/
68+
* plugins.sbt
69+
70+
Sbt plugins dependencies.
71+
72+
## Requirements
73+
74+
* [Java](https://openjdk.java.net/) 8+
75+
* [Sbt](https://www.scala-sbt.org/) launcher
76+
* [Node.js](https://nodejs.org/) or [nodenv](https://github.com/nodenv/nodenv)
77+
78+
## How to use this template?
79+
80+
Just clone this repository, and the following sbt tasks are available.
81+
82+
### Build
83+
84+
Run the following command:
85+
86+
``` shell
87+
sbt assets
88+
```
89+
90+
Then visit `web/target/web/public/main/devMod.html` to browse the main page.
91+
92+
#### Release mode build
93+
94+
By default, the `assets` command builds Scala.js in development mode. To build this project in release mode
95+
96+
``` shell
97+
sbt "set scalaJSStage := FullOptStage" assets
98+
```
99+
100+
Then visit `web/target/web/public/main/index.html` to browse the main page in release mode.
101+
102+
### Test
103+
104+
Run the following command:
105+
106+
``` shell
107+
sbt test
108+
```
109+
110+
Then the examples in Scaladoc comments will be ran by ScalaTest.

build.sbt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
lazy val js = project
2+
3+
lazy val web = project.settings(
4+
scalaJSProjects += js
5+
)
6+
7+
ThisBuild / scalaVersion := "3.2.2"

0 commit comments

Comments
 (0)