Skip to content

Commit 724d291

Browse files
committed
Refactor tools/
Signed-off-by: Andrew Stein <steinlink@gmail.com>
1 parent 79009b4 commit 724d291

File tree

15 files changed

+56
-564
lines changed

15 files changed

+56
-564
lines changed

rust/perspective/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ include = ["src/**/*", "tests/**/*", "Cargo.toml"]
2424

2525
[lib]
2626
crate-type = ["cdylib", "rlib"]
27+
doctest = false
2728
path = "src/lib.rs"
2829

2930

rust/perspective/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
//! computes a "Group By" operation, returning a new Arrow.
2121
//!
2222
//! ```rust
23-
//! use perspective::LocalClient;
2423
//! use perspective::client::config::ViewConfigUpdate;
2524
//! use perspective::client::{TableInitOptions, UpdateData, ViewWindow};
2625
//! use perspective::server::Server;
2726
//!
28-
//! # let arow_vec_data: Vec<u8> = vec![];
27+
//! # let arrow_vec_data: Vec<u8> = vec![];
28+
//! let server = Server::default();
29+
//! let client = server.new_local_client();
2930
//! let data = UpdateData::Arrow(arrow_vec_data);
3031
//! let options = TableInitOptions::default();
3132
//! let table = client.table(data.into(), options).await?;

tools/scripts/bench.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

1313
import * as dotenv from "dotenv";
14-
import sh from "./sh.mjs";
1514
import { get_scope } from "./sh_perspective.mjs";
1615

16+
import "zx/globals";
17+
1718
dotenv.config({ path: "./.perspectiverc", quiet: true });
1819
const scope = get_scope();
1920
if (scope.includes("client")) {
20-
sh`pnpm run --recursive --filter bench bench_js`.runSync();
21+
$.sync`pnpm run --recursive --filter bench bench_js`;
2122
} else if (scope.includes("python")) {
22-
sh`pnpm run --recursive --filter bench bench_python`.runSync();
23+
$.sync`pnpm run --recursive --filter bench bench_python`;
2324
}

tools/scripts/emsdk.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.

tools/scripts/fix_cpp.mjs

Lines changed: 0 additions & 26 deletions
This file was deleted.

tools/scripts/install_emsdk.mjs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import path from "path";
1414
import os from "os";
1515
import fs from "fs";
1616
import * as dotenv from "dotenv";
17-
import sh from "./sh.mjs";
1817
import { getWorkspaceRoot, getWorkspacePackageJson } from "./workspace.mjs";
1918

2019
import "zx/globals";
@@ -26,27 +25,23 @@ const emscripten = pkg.emscripten;
2625
dotenv.config({ path: "./.perspectiverc", quiet: true });
2726

2827
function base() {
29-
return sh.path`${getWorkspaceRoot()}/.emsdk`;
28+
return path.resolve(getWorkspaceRoot(), ".emsdk");
3029
}
3130

3231
function emsdk_checkout() {
33-
function git(args) {
34-
sh`git ${args}`.runSync();
35-
}
36-
37-
git(["clone", "https://github.com/emscripten-core/emsdk.git", base()]);
32+
$.sync`git clone https://github.com/emscripten-core/emsdk.git ${base()}`;
3833
}
3934

4035
function emsdk(...args) {
4136
const basedir = base();
4237
const suffix = os.type() == "Windows_NT" ? ".bat" : "";
43-
const emsdk = path.join(basedir, "emsdk" + suffix);
44-
sh`${emsdk} ${args}`.runSync();
38+
const emsdkBin = path.join(basedir, "emsdk" + suffix);
39+
$.sync`${emsdkBin} ${args}`;
4540
}
4641

4742
function toolchain_install() {
4843
console.log(`-- Installing Emscripten ${emscripten}`);
49-
sh`git pull`.cwd(".emsdk").runSync();
44+
$.sync({ cwd: ".emsdk" })`git pull`;
5045
emsdk("install", emscripten);
5146
emsdk("activate", emscripten);
5247
console.log(`-- Emscripten ${emscripten} installed`);
@@ -68,5 +63,4 @@ if (!process.env.PSP_SKIP_EMSDK_INSTALL) {
6863
}
6964

7065
toolchain_install();
71-
$.sync`cd .emsdk && git apply ../tools/scripts/emsdk.patch`;
7266
}

tools/scripts/lint_headers.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const FIX_PATHS = [
2828
["**/*.mjs", ["//", "/*", " *", " */"]],
2929
// ["**/*.css", ["//", "/*", " *", " */"]],
3030
["**/*.scss", ["//", "/*", " *", " */"]],
31-
["**/*.less", ["//", "/*", " *", " */"]],
3231
["**/*.toml", ["# ", "#"]],
3332
["**/*.yaml", ["# ", "#"]],
3433
["**/*.py", ["# ", "#"]],

tools/scripts/publish.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

1313
import { Octokit } from "octokit";
14-
import sh from "./sh.mjs";
1514
import fs from "node:fs/promises";
1615

1716
import "zx/globals";
@@ -21,11 +20,11 @@ const OCTOKIT = new Octokit({
2120
auth: process.env.GITHUB_TOKEN,
2221
});
2322

24-
const CURRENT_TAG = sh`git describe --exact-match --tags`.execSync();
23+
const CURRENT_TAG = $.sync`git describe --exact-match --tags`.toString().trim();
2524

26-
const IS_DIRTY = await sh`git status --untracked-files=no --porcelain`
27-
.exec()
28-
.then((x) => x.length > 0);
25+
const IS_DIRTY =
26+
(await $`git status --untracked-files=no --porcelain`).stdout.trim()
27+
.length > 0;
2928

3029
async function get_release_assets() {
3130
const resp = await OCTOKIT.request("GET /repos/{owner}/{repo}/releases", {
@@ -71,9 +70,9 @@ async function publish_release_assets(releases) {
7170
release.name.endsWith("tar.gz")) &&
7271
release.name.indexOf("wasm") === -1
7372
) {
74-
sh`twine upload ${release.name}`.runSync();
73+
$.sync`twine upload ${release.name}`;
7574
} else if (release.name.endsWith(".tgz")) {
76-
sh`npm publish ${release.name}`.runSync();
75+
$.sync`npm publish ${release.name}`;
7776
} else {
7877
console.log(`Skipping "${release.name}"`);
7978
}

tools/scripts/run_emsdk.mjs

Lines changed: 0 additions & 32 deletions
This file was deleted.

tools/scripts/setup.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
1111
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

13-
import sh from "./sh.mjs";
1413
import inquirer from "inquirer";
1514
import fs from "fs";
1615
import * as dotenv from "dotenv";
16+
import { execSync } from "child_process";
1717

1818
const original = dotenv.config({
1919
path: "./.perspectiverc",
@@ -50,7 +50,7 @@ const CONFIG = new Proxy(
5050
write() {
5151
fs.writeFileSync("./.perspectiverc", this.config.join("\n"));
5252
if (process.env.PSP_BUILD_IMMEDIATELY || process.env.PSP_ONCE) {
53-
sh`node tools/scripts/build.mjs`.runSync();
53+
execSync("node tools/scripts/build.mjs", { stdio: "inherit" });
5454
if (process.env.PSP_ONCE) {
5555
while (this.config.length > 0) {
5656
this.config.pop();

0 commit comments

Comments
 (0)