Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashboard 0.1.1 #683

Merged
merged 3 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/check_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: rooch-network/rooch/.github/actions/rust-setup@main
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.OS }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.OS }}-pnpm-
# with:
# fetch-depth: 0
- name: Check code format
Expand All @@ -51,17 +62,6 @@ jobs:
- name: Build and test example projects
run: ./scripts/pr.sh -e
## Build and test sdk start
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.OS }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.OS }}-pnpm-
- name: Install SDK dependencies
run: cd sdk/typescript && npm install pnpm -g && pnpm install
- name: Gen SDK dependencie Code
Expand Down
4 changes: 4 additions & 0 deletions crates/rooch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dashboard
/public
3 changes: 3 additions & 0 deletions crates/rooch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ rooch-rpc-api = { workspace = true }
rooch-rpc-server = { workspace = true }
rooch-rpc-client = { workspace = true }
rooch-integration-test-runner = { workspace = true }

[features]
dashboard = []
90 changes: 90 additions & 0 deletions crates/rooch/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use std::{
env, fs,
path::Path,
process::{self, Command},
};

fn main() {
// build dashboard
if cfg!(feature = "dashboard") {
let base_path: String;
let dashboard_dir = "dashboard";
let out_put_dir = "crates/rooch/public/dashboard/";

if let Ok(output) = Command::new("git")
.args(["rev-parse", "--show-toplevel"])
.output()
{
base_path = String::from_utf8_lossy(&output.stdout).trim().to_string();

println!("cargo:rerun-if-changed={}/{}", base_path, dashboard_dir);

let dashboard_path = Path::new(&base_path).join(dashboard_dir);
env::set_current_dir(dashboard_path.clone()).unwrap();

let npm_status = Command::new("npm").args(["install", "-g", "yarn"]).status();

if npm_status.is_err() {
eprintln!("yarn install failed");
process::exit(1);
}

let yarn_status = Command::new("yarn").status();

if yarn_status.is_err() {
eprintln!("yarn install failed");
process::exit(1);
}

let export_status = Command::new("yarn").args(["export"]).status();

if let Ok(status) = export_status {
if status.success() {
let out_dir = dashboard_path.join("out");
let destination_dir = Path::new(&base_path).join(out_put_dir);
println!("{:?}", destination_dir);
if let Err(err) = copy_directory(&out_dir, &destination_dir) {
eprintln!("Failed to copy directory: {}", err);
process::exit(1);
}
} else {
eprintln!("yarn build failed");
process::exit(1);
}
} else {
eprintln!("yarn build failed");
process::exit(1);
}
}
}
}

fn copy_directory(source: &Path, destination: &Path) -> Result<(), std::io::Error> {
if !source.is_dir() {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"Source directory does not exist",
));
}

if !destination.exists() {
fs::create_dir_all(destination)?;
}

for entry in fs::read_dir(source)? {
let entry = entry?;
let source_path = entry.path();
let destination_path = destination.join(entry.file_name());

if source_path.is_dir() {
copy_directory(&source_path, &destination_path)?;
} else {
fs::copy(&source_path, &destination_path)?;
}
}

Ok(())
}
1 change: 0 additions & 1 deletion crates/rooch/public/dashboard/401/index.html

This file was deleted.

Loading
Loading