Skip to content

Commit

Permalink
build: Rename prql-js to prqlc-js (#4578)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
max-sixty and pre-commit-ci[bot] authored Jun 10, 2024
1 parent 9015c4c commit bae4698
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Dev Container for Rust, website, prql-js and prqlc-python
// Dev Container for Rust, website, prqlc-js and prqlc-python
{
"image": "ghcr.io/prql/prql-devcontainer-base:latest",
"features": {
Expand Down
2 changes: 2 additions & 0 deletions .mega-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ DISABLE_ERRORS_LINTERS:
- JSON_JSONLINT
- MAKEFILE_CHECKMAKE
- MARKDOWN_MARKDOWN_LINK_CHECK
# Prevents us from starting a new library, since it raises an error on unpublished libraries. Can remove after publishing...
- REPOSITORY_DUSTILOCK
- SPELL_MISSPELL
# Disabled for now, as @max-sixty didn't know whether "Unable to locate the
# project file. A project file (tsconfig.json or tsconfig.eslint.json) is
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ To stay in touch with PRQL:
- [pyprql Docs](https://pyprql.readthedocs.io) — the pyprql documentation, the
Python bindings to PRQL, including Jupyter magic.
- [PRQL VS Code extension](https://marketplace.visualstudio.com/items?itemName=prql-lang.prql-vscode)
- [prql-js](https://www.npmjs.com/package/prql-js) — JavaScript bindings for
- [prqlc-js](https://www.npmjs.com/package/prqlc) — JavaScript bindings for
PRQL.

## Repo organization
Expand Down
2 changes: 1 addition & 1 deletion prqlc/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ includes:
vars:
packages_core: -p prqlc-ast -p prqlc-parser -p prqlc
packages_addon: -p prql-compiler-macros -p compile-files
packages_bindings: -p prql -p prql-java -p prql-js -p prqlc-c -p prqlc-python
packages_bindings: -p prql -p prql-java -p prqlc-js -p prqlc-c -p prqlc-python

tasks:
fmt:
Expand Down
10 changes: 5 additions & 5 deletions prqlc/bindings/js/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
description = "Javascript bindings for prqlc"
name = "prql-js"
name = "prqlc-js"
publish = false

edition.workspace = true
Expand All @@ -11,9 +11,9 @@ version.workspace = true

[lib]
crate-type = ["cdylib", "rlib"]
doc = false
doctest = false
test = false
doc = false

[features]
default = ["console_error_panic_hook"]
Expand All @@ -27,9 +27,9 @@ wasm-bindgen = "0.2.92"
# for development, but requires all the `std::fmt` and `std::panicking`
# infrastructure, so isn't great for code size when deploying.", on testing with
# `--no-default-features`,
# `prql/target/wasm32-unknown-unknown/release/prql_js.wasm` is 7.416MB vs
# `prql/target/wasm32-unknown-unknown/release/prqlc_js.wasm` is 7.416MB vs
# 7.408MB. Maybe because we're already including lots of that with other library
# features? Even running `wasm-opt prql_js.wasm` makes similarly sized files of
# features? Even running `wasm-opt prqlc_js.wasm` makes similarly sized files of
# 5.7M. Feel free to try removing this as part of reducing code size (would be
# good to have a much smaller code size...).
console_error_panic_hook = {version = "0.1.7", optional = true}
Expand All @@ -55,7 +55,7 @@ exactly = 2
file = "package-lock.json"
replace = '$1"{{version}}"'
search = '''
(\s+"prql-js",
(\s+"prqlc",
\s+"version": )"[\d\.]+"'''

[[package.metadata.release.pre-release-replacements]]
Expand Down
24 changes: 12 additions & 12 deletions prqlc/bindings/js/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# prql-js
# prqlc-js

JavaScript bindings for [`prqlc`](https://github.com/PRQL/prql/).

## Installation

```sh
npm install prql-js
npm install prqlc
```

## Usage
Expand All @@ -29,29 +29,29 @@ function rq_to_sql(rq_json: string): string;
Direct usage

```javascript
const prqljs = require("prql-js");
const prqlc = require("prqlc");

const sql = prqljs.compile(`from employees | select first_name`);
const sql = prqlc.compile(`from employees | select first_name`);
console.log(sql);
```

Options

```javascript
const opts = new prql.CompileOptions();
const opts = new prqlc.CompileOptions();
opts.target = "sql.mssql";
opts.format = false;
opts.signature_comment = false;

const sql = prqljs.compile(`from employees | take 10`, opts);
const sql = prqlc.compile(`from employees | take 10`, opts);
console.log(sql);
```

Template literal

```javascript
const prqljs = require("prql-js");
const prql = (string) => prqljs.compile(string[0] || "");
const prqlc = require("prqlc");
const prql = (string) => prqlc.compile(string[0] || "");

const sql = prql`from employees | select first_name`;
console.log(sql);
Expand All @@ -60,8 +60,8 @@ console.log(sql);
Template literal with newlines

```javascript
const prqljs = require("prql-js");
const prql = (string) => prqljs.compile(string[0] || "");
const prqlc = require("prqlc");
const prql = (string) => prqlc.compile(string[0] || "");

const sql = prql`
from employees
Expand Down Expand Up @@ -91,7 +91,7 @@ console.log(sql);
### From a framework or a bundler

```typescript
import compile from "prql-js/dist/bundler";
import compile from "prqlc/dist/bundler";

const sql = compile(`from employees | select first_name`);
console.log(sql);
Expand Down Expand Up @@ -165,7 +165,7 @@ code hasn't changed, which can be slow. For a lower-latency dev loop, pass
`--profile=dev` to `npm install` for a faster, less optimized build.

```sh
npm install prql-js --profile=dev
npm install prqlc --profile=dev
```

## Notes
Expand Down
4 changes: 2 additions & 2 deletions prqlc/bindings/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions prqlc/bindings/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"browser": "dist/web/prql_js.js",
"browser": "dist/web/prqlc_js.js",
"description": "JavaScript bindings for prqlc",
"devDependencies": {
"chai": "^5.0.0",
Expand All @@ -12,8 +12,8 @@
],
"license": "Apache-2.0",
"author": "PRQL team",
"main": "dist/node/prql_js.js",
"name": "prql-js",
"main": "dist/node/prqlc_js.js",
"name": "prqlc",
"bugs": {
"url": "https://github.com/PRQL/prql/issues"
},
Expand All @@ -34,6 +34,6 @@
"prepare": "npm run build",
"test": "mocha tests"
},
"types": "dist/node/prql_js.d.ts",
"types": "dist/node/prqlc_js.d.ts",
"version": "0.12.2"
}
32 changes: 16 additions & 16 deletions prqlc/bindings/js/tests/test_all.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "assert";
import { expect } from "chai";
import prql from "../dist/node/prql_js.js";
import prqlc from "../dist/node/prqlc_js.js";

const employee_prql = `from employees
join salaries (==emp_no)
Expand All @@ -24,10 +24,10 @@ join managers=employees (==emp_no)
derive mng_name = s"managers.first_name || ' ' || managers.last_name"
select {mng_name, managers.gender, salary_avg, salary_sd}`;

describe("prql-js", () => {
describe("prqlc-js", () => {
describe("compile", () => {
it("should return valid sql from valid prql", () => {
const sql = prql.compile(employee_prql);
const sql = prqlc.compile(employee_prql);
assert(
sql.trim().toLowerCase().startsWith("with") ||
sql.trim().toLowerCase().startsWith("select"),
Expand All @@ -36,30 +36,30 @@ describe("prql-js", () => {

it("should throw an error on invalid prql", () => {
expect(() =>
prql.compile("Mississippi has four Ss and four Is."),
prqlc.compile("Mississippi has four Ss and four Is."),
).to.throw("Error");
});

it("should compile to dialect", () => {
const opts = new prql.CompileOptions();
const opts = new prqlc.CompileOptions();
opts.target = "sql.mssql";
opts.format = false;
opts.signature_comment = false;

const res = prql.compile("from a | take 10", opts);
const res = prqlc.compile("from a | take 10", opts);
assert.equal(
res,
"SELECT * FROM a ORDER BY (SELECT NULL) OFFSET 0 ROWS FETCH FIRST 10 ROWS ONLY",
);
});

it("CompileOptions should be preferred and should ignore target in header", () => {
const opts = new prql.CompileOptions();
const opts = new prqlc.CompileOptions();
opts.target = "sql.mssql";
opts.format = false;
opts.signature_comment = true;

const res = prql.compile(
const res = prqlc.compile(
"prql target:sql.sqlite\nfrom a | take 10",
opts,
);
Expand All @@ -74,34 +74,34 @@ describe("prql-js", () => {

describe("prql_to_pl", () => {
it("should return valid json from valid prql", () => {
JSON.parse(prql.prql_to_pl(employee_prql));
JSON.parse(prqlc.prql_to_pl(employee_prql));
});

it("should throw an error on invalid prql", () => {
expect(() => prql.prql_to_pl("Answer: T-H-A-T!")).to.throw("Error");
expect(() => prqlc.prql_to_pl("Answer: T-H-A-T!")).to.throw("Error");
});
});

describe("CompileOptions", () => {
it("should be able to create from constructor", () => {
const opts = new prql.CompileOptions();
const opts = new prqlc.CompileOptions();

opts.target = "sql.sqlite";
assert.equal(opts.target, "sql.sqlite");
});

it("should fallback to the target in header", () => {
const opts = new prql.CompileOptions();
const opts = new prqlc.CompileOptions();

opts.target = "sql.any";
const res = prql.compile("prql target:sql.mssql\nfrom a | take 1", opts);
const res = prqlc.compile("prql target:sql.mssql\nfrom a | take 1", opts);
assert(res.includes("1 ROWS ONLY"));
});
});

describe("get_targets", () => {
it("return a list of targets", () => {
const targets = new prql.get_targets();
const targets = new prqlc.get_targets();
assert(targets.length > 0);
assert(targets.includes("sql.sqlite"));
});
Expand All @@ -110,7 +110,7 @@ describe("prql-js", () => {
describe("compile error", () => {
it("should contain json", () => {
try {
prql.compile("from x | select a | select b");
prqlc.compile("from x | select a | select b");
} catch (error) {
const errorMessages = JSON.parse(error.message).inner;

Expand All @@ -122,7 +122,7 @@ describe("prql-js", () => {

it("should contain error code", () => {
try {
prql.compile("let a = (from x)");
prqlc.compile("let a = (from x)");
} catch (error) {
const errorMessages = JSON.parse(error.message).inner;

Expand Down
2 changes: 1 addition & 1 deletion prqlc/prqlc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ WHERE
has_dog
```

A PRQL query can be executed with CLI tools compatible with SQL,, such as
A PRQL query can be executed with CLI tools compatible with SQL, such as
[DuckDB CLI](https://duckdb.org/docs/api/cli.html).

```sh
Expand Down
6 changes: 3 additions & 3 deletions web/playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.0",
"monaco-editor": "^0.49.0",
"prql-js": "file:../../prqlc/bindings/js",
"prqlc": "file:../../prqlc/bindings/js",
"react": "^18.2.0",
"react-dom": "^18.3.0",
"react-syntax-highlighter": "^15.5.0",
Expand Down
2 changes: 1 addition & 1 deletion web/playground/src/workbench/Workbench.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./Workbench.css";

import * as prql from "prql-js/dist/bundler";
import * as prql from "prqlc/dist/bundler";
import React from "react";
import YAML from "yaml";

Expand Down
Loading

0 comments on commit bae4698

Please sign in to comment.