forked from dataform-co/dataform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dataform server boilerplate (dataform-co#601)
* Dataform UI app & server boilerplate * Remove storybook * Update yargs * Revert yargs upgrade * Fix some types * Fix tag * Revert accidental change
- Loading branch information
Showing
23 changed files
with
2,989 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("//tools:css_typings.bzl", "css_typings") | ||
|
||
filegroup( | ||
name = "assets", | ||
srcs = glob([ | ||
"**/*.html", | ||
"public/**/*.*", | ||
]), | ||
) | ||
|
||
load("@io_bazel_rules_sass//:defs.bzl", "multi_sass_binary") | ||
|
||
multi_sass_binary( | ||
name = "sass", | ||
srcs = glob(["**/*.scss"]), | ||
output_style = "expanded", | ||
sourcemap = False, | ||
) | ||
|
||
css_typings( | ||
name = "css_typings", | ||
srcs = [ | ||
":sass", | ||
], | ||
) | ||
|
||
load("@npm_bazel_typescript//:index.bzl", "ts_library") | ||
|
||
ts_library( | ||
name = "app", | ||
srcs = glob( | ||
[ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
], | ||
exclude = ["webpack.ts"], | ||
), | ||
data = [":sass"], | ||
deps = [ | ||
":css_typings", | ||
"//protos", | ||
"//tools/protobufjs:grpc_web_rpc_impl", | ||
"@npm//@blueprintjs/core", | ||
"@npm//@types/node", | ||
"@npm//@types/react", | ||
"@npm//@types/react-dom", | ||
"@npm//@types/react-router", | ||
"@npm//@types/react-router-dom", | ||
"@npm//protobufjs", | ||
"@npm//react", | ||
"@npm//react-dom", | ||
"@npm//react-router", | ||
"@npm//react-router-dom", | ||
], | ||
) | ||
|
||
load("@npm//webpack-dev-server:index.bzl", "webpack_dev_server") | ||
|
||
webpack_dev_server( | ||
name = "devserver", | ||
args = [ | ||
"--config=app/webpack.config.js", | ||
"--output=./app.bundle.js", | ||
"--history-api-fallback", | ||
], | ||
data = [ | ||
":assets", | ||
":app", | ||
":sass", | ||
":webpack.config.js", | ||
"@npm//webpack-cli", | ||
], | ||
tags = [ | ||
# "ibazel_notify_changes", | ||
], | ||
) | ||
|
||
load("@npm//webpack:index.bzl", "webpack") | ||
|
||
webpack( | ||
name = "bundler", | ||
data = [ | ||
":assets", | ||
":app", | ||
":sass", | ||
":webpack.config.js", | ||
"@npm//webpack-cli", | ||
], | ||
) | ||
|
||
load("@build_bazel_rules_nodejs//:index.bzl", "npm_package_bin") | ||
|
||
npm_package_bin( | ||
name = "bundle", | ||
outs = [ | ||
"app.bundle.js", | ||
], | ||
args = [ | ||
"--config=app/webpack.config.js", | ||
"--output=$(location app.bundle.js)", | ||
], | ||
data = [ | ||
":webpack.config.js", | ||
"@npm//css-loader", | ||
"@npm//style-loader", | ||
"@npm//umd-compat-loader", | ||
], | ||
tool = ":bundler", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.css" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/@blueprintjs/core@3.19.1/lib/css/blueprint.css" | ||
/> | ||
<style> | ||
#preloader { | ||
display: flex; | ||
position: absolute; | ||
width: 100vw; | ||
height: 100vh; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 100; | ||
background-color: white; | ||
-webkit-transition: opacity 0.5s ease-in; | ||
-moz-transition: opacity 0.5s ease-in; | ||
-o-transition: opacity 0.5s ease-in; | ||
-ms-transition: opacity 0.5s ease-in; | ||
transition: opacity 0.5s ease-in; | ||
} | ||
#preloader_logo { | ||
width: 400px; | ||
max-width: 100%; | ||
opacity: 0; | ||
-webkit-transition: opacity 0.5s ease-in; | ||
-moz-transition: opacity 0.5s ease-in; | ||
-o-transition: opacity 0.5s ease-in; | ||
-ms-transition: opacity 0.5s ease-in; | ||
transition: opacity 0.5s ease-in; | ||
} | ||
</style> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", function() { | ||
document.getElementById("preloader_logo").style.opacity = 1; | ||
window.setTimeout(function() { | ||
document.getElementById("preloader").style.opacity = 0; | ||
}, 750); | ||
window.setTimeout(function() { | ||
document.getElementById("preloader").style.display = "none"; | ||
}, 1500); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div id="preloader"> | ||
<img id="preloader_logo" src="/public/new_logo_with_text.svg" /> | ||
</div> | ||
<div id="root"></div> | ||
<script src="app.bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Overview } from "df/app/overview"; | ||
import { Service } from "df/app/service"; | ||
import * as React from "react"; | ||
import * as ReactDOM from "react-dom"; | ||
import { Route } from "react-router"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
|
||
const service = Service.get(); | ||
|
||
async function render() { | ||
const metadata = await service.metadata({}); | ||
ReactDOM.render( | ||
<BrowserRouter> | ||
<Route | ||
path={"/"} | ||
exact={true} | ||
component={(props: any) => <Overview {...props} service={service} metadata={metadata} />} | ||
/> | ||
</BrowserRouter>, | ||
document.getElementById("root") | ||
); | ||
} | ||
|
||
const _ = render(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.overviewContainer { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100vh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Button, Navbar, NavbarGroup, Tag } from "@blueprintjs/core"; | ||
import { dataform } from "@dataform/protos"; | ||
import * as styles from "df/app/overview.css"; | ||
import { Service } from "df/app/service"; | ||
import * as React from "react"; | ||
|
||
interface IProps { | ||
service: Service; | ||
metadata: dataform.server.MetadataResponse; | ||
} | ||
|
||
export class Overview extends React.Component<IProps> { | ||
public render() { | ||
return ( | ||
<div className={styles.overviewContainer}> | ||
<Navbar> | ||
<NavbarGroup> | ||
<img src="/public/new_logo_with_text.svg" /> | ||
</NavbarGroup> | ||
<NavbarGroup align="right"> | ||
<Tag>{this.props.metadata.projectDir}</Tag> | ||
</NavbarGroup> | ||
</Navbar> | ||
</div> | ||
); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { dataform } from "@dataform/protos"; | ||
import { rpcImpl } from "df/tools/protobufjs/grpc_web_rpc_impl"; | ||
|
||
export class Service extends dataform.server.Service { | ||
public static get(): Service { | ||
if (!Service.instance) { | ||
Service.instance = new Service(); | ||
} | ||
return Service.instance; | ||
} | ||
private static instance: Service; | ||
|
||
constructor() { | ||
super(rpcImpl("http://localhost:9111", "dataform.server.Service"), false, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
const path = require("path"); | ||
const webpack = require("webpack"); | ||
const fs = require("fs"); | ||
|
||
module.exports = (env, argv) => { | ||
const config = { | ||
mode: argv.mode || "development", | ||
entry: [path.resolve(process.env.RUNFILES, "df/app/index")], | ||
output: { | ||
path: path.dirname(path.resolve(argv.output)), | ||
filename: path.basename(argv.output) | ||
}, | ||
optimization: { | ||
minimize: argv.mode === "production" | ||
}, | ||
watchOptions: { | ||
ignored: [/node_modules/] | ||
}, | ||
stats: { | ||
warnings: true | ||
}, | ||
node: { | ||
fs: "empty", | ||
child_process: "empty" | ||
}, | ||
devServer: { | ||
port: 9110, | ||
open: false, | ||
publicPath: "/", | ||
contentBase: path.resolve("./app"), | ||
stats: { | ||
colors: true | ||
} | ||
}, | ||
resolve: { | ||
extensions: [".ts", ".tsx", ".js", ".jsx", ".json", ".css"], | ||
alias: { | ||
"@dataform": path.resolve(process.env.RUNFILES, "df"), | ||
df: path.resolve(process.env.RUNFILES, "df") | ||
} | ||
}, | ||
|
||
plugins: [ | ||
new webpack.optimize.LimitChunkCountPlugin({ | ||
maxChunks: 1 | ||
}) | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
include: /node_modules/, | ||
use: ["style-loader", "css-loader"] | ||
}, | ||
{ | ||
test: /\.css$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ loader: "style-loader" }, | ||
{ | ||
loader: "css-loader", | ||
query: { | ||
modules: true | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
test: /\.jsx?$/, | ||
exclude: /node_modules/, | ||
use: [{ loader: "umd-compat-loader" }] | ||
} | ||
] | ||
} | ||
}; | ||
// Only add the babel transpilation in production mode. | ||
if (argv.mode === "production") { | ||
config.module.rules.push({ | ||
test: /\.jsx?$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: "babel-loader", | ||
options: { | ||
presets: [["env", { targets: { browsers: ["defaults"] } }]], | ||
plugins: [ | ||
[ | ||
"transform-runtime", | ||
{ | ||
polyfill: false, | ||
regenerator: true | ||
} | ||
] | ||
] | ||
} | ||
} | ||
] | ||
}); | ||
} | ||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.