Skip to content

Commit

Permalink
Create a standalone package (#263)
Browse files Browse the repository at this point in the history
* Create a standalone package

* Update doc
  • Loading branch information
xerial authored Oct 21, 2022
1 parent 77fa1da commit 48349d0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 16 deletions.
39 changes: 29 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ Database for queries.
## Roadmap

- Interactive query editor
- Reuse SQL queries as functions
- Referencing and parameterization
- Reuse SQL queries as functions
- Referencing and parameterization
- Collect, analyze, and visualize query logs
- Define query-engine agonistic IR for analyzing logs
- Define query-engine agonistic IR for analyzing logs
- Reporting
- Summarizing query usage
- Tracking lineage of data flows
- Summarizing query usage
- Tracking lineage of data flows

## Developer Note
## Quick Start

### For Treasure Data
```sh
// Set up Node.js and jsdom
$ brew install node npm
$ npm install jsdom

# Install querybase to ~/local/bin/querybase
$ ./sbt packInstall
```

Add service settings:
Add service settings (for using Treasure Data):

__.querybase/services.json__

```json
{
"services": [
Expand Down Expand Up @@ -48,14 +56,25 @@ __.querybase/services.json__

```

Launch a standalone server at localhost:8080

```sh
$ ~/local/bin/querybase standalone
```

Open http://localhost:8080/

## For Developers

Run querybase server:

Run querybase server:
```
$ ./sbt
> ~server/reStart standalone
```

Build Scala.js UI:

```
// Set up Node.js and jsdom
$ brew install node
Expand All @@ -68,8 +87,8 @@ $ ./sbt

Open http://localhost:8080/ui/


If you use [Browsersync](https://browsersync.io/), the UI will be reloaded automatically upon Scala.js change:

```
# Install Browsersync
$ npm -g install browser-sync
Expand Down
38 changes: 33 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ val buildSettings = Seq[Setting[_]](
crossScalaVersions := targetScalaVersions,
crossPaths := true,
publishMavenStyle := true,
// Support JDK8 for Spark
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions ++= Seq("-feature", "-deprecation"),
// Use AirSpec for testing
Expand All @@ -46,9 +45,7 @@ val buildSettings = Seq[Setting[_]](
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.8.1",
"org.wvlet.airframe" %%% "airspec" % AIRFRAME_VERSION % Test
),
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)
resolvers ++= Resolver.sonatypeOssRepos("snapshots")
)

ThisBuild / publishTo := sonatypePublishToBundle.value
Expand All @@ -64,7 +61,7 @@ val noPublish = Seq(
publishLocal := {}
)

lazy val jvmProjects = Seq[ProjectReference](apiJVM, server, apiClient, sql, frontendClientJVM)
lazy val jvmProjects = Seq[ProjectReference](apiJVM, server, apiClient, sql, frontendClientJVM, main)
lazy val jsProjects = Seq[ProjectReference](apiJS, ui, frontendClientJS)

lazy val projectJVM = project.aggregate(jvmProjects: _*)
Expand All @@ -78,6 +75,37 @@ lazy val querybase =
.settings(noPublish)
.aggregate((jvmProjects ++ jsProjects): _*)

lazy val main =
project
.in(file("querybase-main"))
.enablePlugins(PackPlugin)
.settings(buildSettings)
.settings(
name := "querybase-main",
packMain := Map(
"querybase" -> "wvlet.querybase.server.QuerybaseServerMain"
),
packResourceDir ++= Map(
(ThisBuild / baseDirectory).value / "querybase-ui" / "src" / "main" / "public" -> "public",
(Compile / managedResourceDirectories).value.head -> "public"
),
Compile / resourceGenerators += Def.task {
val assetFiles = (ui / Compile / fastOptJS / webpack).value
val inputDir = (ui / crossTarget).value / "scalajs-bundler" / "main"
val outputDir = (Compile / managedResourceDirectories).value.head
assetFiles.flatMap { f =>
val file = f.data
file.relativeTo(inputDir).map { x: File =>
val outFile = outputDir / x.getPath
outFile.getParentFile.mkdirs()
IO.copyFile(file, outFile)
outFile
}
}
}.taskValue
)
.dependsOn(server)

lazy val api =
crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Pure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class StaticContentApi extends LogSupport {
case Some(webResourceDir) =>
// For production server
StaticContent
.fromDirectory(webResourceDir)
.fromDirectory(s"${webResourceDir}/public")
case _ =>
// For testing
val baseDir = "."
Expand Down

0 comments on commit 48349d0

Please sign in to comment.