Skip to content

Commit

Permalink
Added quiet & removed lipe from build
Browse files Browse the repository at this point in the history
  • Loading branch information
CEbbinghaus committed Dec 17, 2024
1 parent 2053f33 commit 5ab3fc2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
10 changes: 5 additions & 5 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ description = 'Build the CLI'

[tasks."build:backend"]
description = 'Build the Backend'
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -o backend"
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -q -o backend"
sources = ['backend/Cargo.toml', 'backend/src/**/*.rs']
outputs = ['build/bin/backend']

[tasks."build:frontend"]
description = 'Build the Frontend'
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -o frontend"
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -q -o frontend"
sources = ['package.json', 'lib/package.json', '{src,lib}/**/*.{ts,tsx,codegen}']
outputs = ['dist/index.js']

[tasks."build:collect"]
depends = ["build:backend", "build:frontend"]
description = 'Collect the build artifacts'
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -o collect"
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -q -o collect"
sources = ['backend/target/release/backend', 'dist/index.js', 'main.py', 'package.json', 'plugin.json', 'README.md']
outputs = ['build/**/*.*']

[tasks."copy"]
depends = ["build"]
description = 'Copy MicroSDeck to the SteamDeck Plugins'
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -o copy"
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -q -o copy"

[tasks."upload"]
depends = ["build"]
description = 'Upload MicroSDeck to the SteamDeck'
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -o upload"
run = "node --no-warnings=ExperimentalWarning 'util/build.mjs' -q -o upload"
27 changes: 21 additions & 6 deletions util/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { exit } from 'process';
import plugin from "../plugin.json" with { type: "json" };
const { name: PluginName } = plugin;

import deploy from "../deploy.json" with { type: "json" };

if (process.argv.includes('-h') || process.argv.includes('--help')) {
console.log(
` __ __ _ ___ ___ _ ___ _ _ _
Expand All @@ -25,6 +23,7 @@ if (process.argv.includes('-h') || process.argv.includes('--help')) {
Basic Usage: ./build [flags]
-h, --help: Prints this help dialogue
-q, --quiet: Prints only required output
-o, --only: Only run the specified part (backend, frontend, collect, copy, upload)
--skip-backend: Skips building the backend
--skip-frontend: Skips building the frontend
Expand All @@ -35,6 +34,8 @@ Basic Usage: ./build [flags]
process.exit(0);
}

const quiet = process.argv.includes('-q') || process.argv.includes('--quiet');

const tasks = [];
if (process.argv.includes('-o') || process.argv.includes('--only')) {
let [opt0, opt1] = [process.argv.indexOf('-o'), process.argv.indexOf('--only')];
Expand Down Expand Up @@ -91,7 +92,13 @@ function runCommand(command, directory = "") {
return output;
}

Logger.Log(`Building plugin ${PluginName}@${Version}`);
async function importJson(file) {
return (await import(file, { with: { type: "json" } })).default;
}


if (!quiet)
Logger.Log(`Building plugin ${PluginName}@${Version}`);

if (!existsSync('plugin.json')) {
console.error('Build script must be run from the root of the repository.');
Expand Down Expand Up @@ -138,9 +145,9 @@ if (is_local && tasks.includes('copy')) {
execSync(`sudo cp -r build/ /home/${current_user}/homebrew/plugins/${PluginName}`);
execSync(`sudo chmod 555 /home/${current_user}/homebrew/plugins/${PluginName}`);
} else {
if (!tasks.includes('copy')) {
if (!tasks.includes('copy') && !quiet) {
Logger.Log('Skipping copying build folder to local plugin directory');
} else if (!is_local) {
} else if (!is_local && !quiet) {
Logger.Info('Not running on steamdeck');
}
}
Expand All @@ -155,7 +162,15 @@ if (tasks.includes('upload')) {
exit(1);
}

const { host, user, keyfile } = deploy;
const { host, user, keyfile } = importJson('deploy.json');

// ping host to make sure its avaliable
try {
execSync(`ping -c 1 ${host}`);
} catch (e) {
Logger.Error(`Could not connect to ${host}`);
exit(1);
}

const deployPath = `/home/${user}/homebrew/plugins/${PluginName}`;

Expand Down
15 changes: 5 additions & 10 deletions util/log.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import Lipe, { LoggerPipe } from "lipe"
import { PrefixWithColor, Splat, Timestamped, Console } from "lipe/defaults"

const Pipe = new LoggerPipe()
.Pipe(PrefixWithColor)
.Pipe(Splat("{prefix} {Message}"))
.Pipe(Console())


export const Logger = new Lipe().AddPipe(Pipe);
export const Logger = {
Log: console.log,
Info: console.info,
Error: console.error,
}
2 changes: 1 addition & 1 deletion util/versioning.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, writeFileSync, openSync, fstatSync, utimesSync, closeSync, ftruncateSync, stat, statSync } from "fs";
import { readFileSync, writeFileSync, utimesSync, statSync } from "fs";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";

Expand Down

0 comments on commit 5ab3fc2

Please sign in to comment.