Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump up to jq 1.7 #625

Merged
merged 1 commit into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
![https://lima.codeclimate.com/github/sanack/node-jq/coverage](https://lima.codeclimate.com/github/sanack/node-jq/badges/coverage.svg)
![https://github.com/sanack/node-jq/actions/workflows/ci.yml](https://github.com/sanack/node-jq/actions/workflows/ci.yml/badge.svg)

[node-jq](https://github.com/sanack/node-jq) is a Node.js wrapper for [jq](https://stedolan.github.io/jq/) - a lightweight and flexible command-line JSON processor
[node-jq](https://github.com/sanack/node-jq) is a Node.js wrapper for [jq](https://jqlang.github.io/jq/) - a lightweight and flexible command-line JSON processor

---

Expand All @@ -20,7 +20,7 @@ $ yarn add node-jq

## Advanced installation

By default, `node-jq` downloads `jq` during the installation process with a post-install script. Depending on your SO downloads from [https://github.com/stedolan/jq/releases] into `./node_modules/node-jq/bin/jq` to avoid colisions with any global installation. Check #161 #167 #171 for more information. You can safely rely on this location for your installed `jq`, we won't change this path without a major version upgrade.
By default, `node-jq` downloads `jq` during the installation process with a post-install script. Depending on your SO downloads from [https://github.com/jqlang/jq/releases] into `./node_modules/node-jq/bin/jq` to avoid colisions with any global installation. Check #161 #167 #171 for more information. You can safely rely on this location for your installed `jq`, we won't change this path without a major version upgrade.

If you want to skip the installation step of `jq`, you can set `NODE_JQ_SKIP_INSTALL_BINARY` to `true` or ignore the post-install script from the installation `npm install node-jq --ignore-scripts`.

Expand Down Expand Up @@ -262,7 +262,7 @@ Seems hard to learn, but it really isn't.

Take a look at [this great introduction](https://robots.thoughtbot.com/jq-is-sed-for-json) or a [jq lesson](http://programminghistorian.org/lessons/json-and-jq).

You can check out the [official manual](https://stedolan.github.io/jq/manual) and fiddle around in the online playground [jqplay.org](https://jqplay.org).
You can check out the [official manual](https://jqlang.github.io/jq/manual) and fiddle around in the online playground [jqplay.org](https://jqplay.org).

## License

Expand Down
30 changes: 13 additions & 17 deletions scripts/install-binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const arch = process.arch

const JQ_INFO = {
name: 'jq',
url: 'https://github.com/stedolan/jq/releases/download/',
version: 'jq-1.6'
url: 'https://github.com/jqlang/jq/releases/download/',
version: 'jq-1.7'
}

const JQ_NAME_MAP = {
Expand Down Expand Up @@ -67,30 +67,27 @@ if (process.env.NODE_JQ_SKIP_INSTALL_BINARY === 'true') {
process.exit(0)
}

// if platform is missing, download source instead of executable
// if platform or arch is missing, download source instead of executable
const DOWNLOAD_MAP = {
win32: {
def: 'jq-win32.exe',
x64: 'jq-win64.exe'
x64: 'jq-windows-amd64.exe',
ia32: 'jq-windows-i386.exe'
},
darwin: {
def: 'jq-osx-amd64',
x64: 'jq-osx-amd64'
x64: 'jq-macos-amd64',
arm64: 'jq-macos-arm64'
},
linux: {
def: 'jq-linux32',
x64: 'jq-linux64'
x64: 'jq-linux-amd64',
ia32: 'jq-linux-i386',
arm64: 'jq-linux-arm64'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

}
}

if (platform in DOWNLOAD_MAP) {
if (platform in DOWNLOAD_MAP && arch in DOWNLOAD_MAP[platform]) {
// download the executable

const filename =
arch in DOWNLOAD_MAP[platform]
? DOWNLOAD_MAP[platform][arch]
: DOWNLOAD_MAP[platform].def

const filename = DOWNLOAD_MAP[platform][arch]
const url = `${JQ_INFO.url}${JQ_INFO.version}/${filename}`

console.log(`Downloading jq from ${url}`)
Expand Down Expand Up @@ -118,8 +115,7 @@ if (platform in DOWNLOAD_MAP) {
console.log(`Building jq from ${url}`)
binBuild
.url(url, [
'autoreconf -fi',
`./configure --disable-maintainer-mode --with-oniguruma=builtin --prefix=${tempfile()} --bindir=${OUTPUT_DIR}`,
`./configure --with-oniguruma=builtin --prefix=${tempfile()} --bindir=${OUTPUT_DIR}`,
'make -j8',
'make install'
])
Expand Down
15 changes: 0 additions & 15 deletions src/jq.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const PATH_JS_FIXTURE = path.join(PATH_FIXTURES, '1.js')
const PATH_LARGE_JSON_FIXTURE = path.join(PATH_FIXTURES, 'large.json')
const PATH_VARIABLE_JSON_FIXTURE = path.join(PATH_FIXTURES, 'var.json')

const FIXTURE_JSON = require('./__test__/fixtures/1.json')
const FIXTURE_JSON_STRING = JSON.stringify(FIXTURE_JSON, null, 2)

const FILTER_VALID = '.repository.type'
const FILTER_INVALID = 'invalid'
const FILTER_WITH_VARIABLE =
Expand All @@ -40,18 +37,6 @@ describe('jq core', () => {
})
})

it('should pass on an empty filter', done => {
run('', PATH_JSON_FIXTURE)
.then(output => {
const normalizedOutput = output.replace(/\r\n/g, '\n')
expect(normalizedOutput).to.equal(FIXTURE_JSON_STRING)
done()
})
.catch(error => {
done(error)
})
})
Comment on lines -43 to -53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does jq stopped supporting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, jq dropped supporting empty query;

 $ jq -n ''
jq: error: Top-level program not given (try ".")
jq: 1 compile error

See jqlang/jq#2785.


it('should pass on a null filter', done => {
run(null, PATH_JSON_FIXTURE)
.then(output => {
Expand Down