From 94703e9182b03ddf0737721b031daf88797f0566 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Mon, 20 Jun 2022 21:37:47 +0200 Subject: [PATCH] jsq: upgrade to 2 compiled executable goes brrr --- jsq/APKBUILD | 28 ++++++++++++++++++++++------ jsq/jsq | 11 ----------- jsq/jsq.js | 23 +++++++++++++++++++++++ 3 files changed, 45 insertions(+), 17 deletions(-) delete mode 100644 jsq/jsq create mode 100644 jsq/jsq.js diff --git a/jsq/APKBUILD b/jsq/APKBUILD index 63c948b..50ee2e6 100644 --- a/jsq/APKBUILD +++ b/jsq/APKBUILD @@ -1,20 +1,36 @@ # Contributor: Patrycja Rosa # Maintainer: Patrycja Rosa pkgname=jsq -pkgver=1 +pkgver=2 pkgrel=0 pkgdesc="QuickJS-based jq-like data processing tool" url="https://git.ddd.rip/ptrcnull/ptrcports" -arch="noarch" +arch="all" license="BSD-2-Clause" -depends="quickjs" -source="jsq" +makedepends="quickjs" +source="jsq.js" builddir="$srcdir" -options="!check" # nice + +build() { + qjsc -o jsq \ + -flto \ + -fno-date \ + -fno-proxy \ + -fno-promise \ + -fno-module-loader \ + -fno-bigint \ + jsq.js +} + +check() { + out=$(echo '{"test":"passed"}' | ./jsq ".test") + [ "$out" = "passed" ] +} package() { install -Dm755 jsq -t "$pkgdir"/usr/bin } + sha512sums=" -a1404bb221f1b42efcba3973fca5aff4525b0e0e37b32f5a53f57eeb2eae5a90d419c7434e9a7818c96c79e0d96b5be2d80dc2af8e7bc38344b9b8d5b7590e46 jsq +01453f4dfcf0263b37c7c87c0d7c220efe210c3d03ef36c06aa7001bcf97b490bd17953df15a5dc3d88603da1f8498010b2c1ba5659b706e64df6d9b862b0dd9 jsq.js " diff --git a/jsq/jsq b/jsq/jsq deleted file mode 100644 index abeda75..0000000 --- a/jsq/jsq +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -exec qjs --std -e " - var input = JSON.parse(std.in.readAsString()) - var output = input$@; - if (typeof output === 'object') { - console.log(JSON.stringify(output, null, 2)) - } else { - console.log(output) - } -" diff --git a/jsq/jsq.js b/jsq/jsq.js new file mode 100644 index 0000000..f9443bd --- /dev/null +++ b/jsq/jsq.js @@ -0,0 +1,23 @@ +import * as std from "std" + +// helper stuff +var url = (text, link) => `\x1b]8;;${link}\x1b\\${text}\x1b]8;;\x1b\\` +var colors = { + reset: `\x1b[0m`, + black: `\x1b[30m`, + red: `\x1b[31m`, + green: `\x1b[32m`, + yellow: `\x1b[33m`, + blue: `\x1b[34m`, + magenta: `\x1b[35m`, + cyan: `\x1b[36m`, + white: `\x1b[37m`, +} + +var input = JSON.parse(std.in.readAsString()) +var output = eval('input' + scriptArgs.slice(1).join(' ')); +if (typeof output === "object") { + console.log(JSON.stringify(output, null, 2)) +} else { + console.log(output) +}