Skip to content

Commit f0bc952

Browse files
committed
Rename -web to -playground
1 parent a1e9a0e commit f0bc952

File tree

14 files changed

+49
-111
lines changed

14 files changed

+49
-111
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jobs:
5050
- name: Web build
5151
if: ${{ matrix.os == 'ubuntu-latest' }}
5252
run: |
53-
cd website
5453
npm ci
5554
npm run build-production
5655
@@ -136,17 +135,17 @@ jobs:
136135
- name: Create archives for Github release
137136
run: |
138137
cd _release/platform-darwin-x64
139-
mv Bin.exe query-json
138+
mv query-json.exe query-json
140139
zip -r ../../query-json-darwin-x64.zip .
141140
cd ../..
142141
143142
cd _release/platform-linux-x64
144-
mv Bin.exe query-json
143+
mv query-json.exe query-json
145144
zip -r ../../query-json-linux-x64.zip .
146145
cd ../..
147146
148147
cd _release/platform-windows-x64
149-
mv Bin.exe query-json
148+
mv query-json.exe query-json
150149
zip -r ../../query-json-windows-x64.zip .
151150
cd ../..
152151

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ create-switch: ## Create opam switch
6464
opam switch create . 5.1.0 --deps-only --with-test -y
6565

6666
.PHONY: install
67-
install:
67+
install: ## Install opam deps
6868
opam install . --deps-only --with-test --with-doc --with-dev-setup -y
6969

70+
.PHONY: npm-install
71+
npm-install: ## Install npm dependencies
72+
npm install
73+
7074
.PHONY: init
7175
init: setup-githooks create-switch pin install install-npm ## Create a local dev enviroment

dune-project

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
(source
1717
(github davesnx/query-json))
1818

19-
(implicit_transitive_deps false)
19+
(implicit_transitive_deps true)
2020

2121
(version 0.5.10)
2222

@@ -47,27 +47,9 @@
4747
))
4848

4949
(package
50-
(name query-json-js)
51-
(synopsis "Faster, simpler and more portable implementation of `jq` in Reason. Shipped as a JavaScript library.")
52-
(description "query-json is a faster and simpler re-implementation of jq's language in Reason, compiled to a native binary and as a JavaScript library.
53-
54-
It's a CLI to run small programs against JSON, the same idea as sed but for JSON files.
55-
56-
Play around with it in the online playground: https://query-json.netlify.app")
57-
(depends
58-
ocaml
59-
reason
60-
dune
61-
yojson
62-
cmdliner
63-
js_of_ocaml
64-
js_of_ocaml-compiler
65-
))
66-
67-
(package
68-
(name query-json-web)
50+
(name query-json-playground)
6951
(allow_empty)
70-
(synopsis "query-json-web is the web playground for query-json, written in jsoo and jsoo-react.")
52+
(synopsis "query-json-playground is the web playground for query-json, written in jsoo and jsoo-react.")
7153
(description "query-json is a faster and simpler re-implementation of jq's language in Reason, compiled to a native binary and as a JavaScript library.
7254
7355
It's a CLI to run small programs against JSON, the same idea as sed but for JSON files.

js/Js.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
let run = QueryJsonJs.run;
1+
let run = QueryJsonCore.Main.run;

js/QueryJsonJs.re

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

js/QueryJsonJs.rei

Lines changed: 0 additions & 1 deletion
This file was deleted.

js/dune

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
(library
2-
(name QueryJsonJs)
3-
(public_name query-json-js)
4-
(modules QueryJsonJs)
5-
(libraries query-json.core yojson cmdliner js_of_ocaml))
6-
71
(executable
82
(name Js)
93
(modes js)
104
(modules Js)
11-
(libraries query-json-js yojson cmdliner js_of_ocaml))
5+
(libraries query-json.core))

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
"name": "query-json-website",
33
"version": "0.0.0",
44
"scripts": {
5-
"start": "run-p --aggregate-output dev serve",
6-
"dev": "webpack -w",
7-
"build": "webpack",
8-
"build-production": "vite build",
9-
"serve": "vite preview"
5+
"start": "run-p --aggregate-output build preview",
6+
"build": "vite build",
7+
"preview": "vite preview"
108
},
119
"dependencies": {
1210
"@emotion/css": "^11.7.1",

query-json-js.opam

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

query-json-web.opam renamed to query-json-playground.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
opam-version: "2.0"
33
version: "0.5.10"
44
synopsis:
5-
"query-json-web is the web playground for query-json, written in jsoo and jsoo-react."
5+
"query-json-playground is the web playground for query-json, written in jsoo and jsoo-react."
66
description: """
77
query-json is a faster and simpler re-implementation of jq's language in Reason, compiled to a native binary and as a JavaScript library.
88

source/Main.re

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,25 @@ let parse = (~debug=false, input): result(Ast.expression, string) => {
4646
Error(make(~input, ~start=loc_start, ~end_=loc_end));
4747
};
4848
};
49+
50+
let run = (query, json) => {
51+
let result =
52+
parse(query)
53+
|> Result.map(Compiler.compile)
54+
|> Result.bind(_, runtime => {
55+
switch (Json.parseString(json)) {
56+
| Ok(input) => runtime(input)
57+
| Error(err) => Error(err)
58+
}
59+
});
60+
61+
switch (result) {
62+
| Ok(res) =>
63+
Ok(
64+
res
65+
|> List.map(Json.toString(~colorize=false, ~summarize=false))
66+
|> String.concat("\n"),
67+
)
68+
| Error(e) => Error(e)
69+
};
70+
};

vite.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import polyfillNode from "rollup-plugin-polyfill-node"
77
import vitePluginRequire from "vite-plugin-require"
88

99
const isProd = process.env.NODE_ENV === 'production';
10+
1011
const monacoEditorPlugin = MonacoEditorPlugin({
1112
languages: ['json'],
1213
languageWorkers: ['json']

website/App.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ let make = () => {
179179
switch (state.json, state.query) {
180180
| (Some(_), "")
181181
| (None, _) => None
182-
| (Some(json), _) => Some(QueryJsonJs.run(state.query, json))
182+
| (Some(json), _) => Some(QueryJsonCore.Main.run(state.query, json))
183183
};
184184

185185
let onShareClick = _ => {

website/dune

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
(executable
22
(name Website)
33
(modes js)
4-
(libraries query-json-js js_of_ocaml jsoo-react.lib ojs jsoo-css brr jsonoo)
4+
(libraries
5+
query-json.core
6+
js_of_ocaml
7+
jsoo-react.lib
8+
ojs
9+
jsoo-css
10+
brr
11+
jsonoo)
512
(preprocess
613
(pps jsoo-react.ppx ppx_jsobject_conv)))
714

0 commit comments

Comments
 (0)