diff --git a/.appveyor.yml b/.appveyor.yml index 0c9de3ac..07a72738 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -31,15 +31,15 @@ branches: before_deploy: - move target\release\tree-sitter.exe tree-sitter.exe - - 7z a tree-sitter-windows-%PLATFORM%.zip tree-sitter.exe - - appveyor PushArtifact tree-sitter-windows-%PLATFORM%.zip + - 7z a -tgzip tree-sitter-windows-%PLATFORM%.gz tree-sitter.exe + - appveyor PushArtifact tree-sitter-windows-%PLATFORM%.gz deploy: description: '' provider: GitHub auth_token: secure: VC9ntV5+inKoNteZyLQksKzWMKXF46P+Jx3JHKVSfF+o1rWtZn2iIHAVsQv5LaUi - artifact: /tree-sitter-windows-.*.zip/ + artifact: /tree-sitter-windows-.*/ draft: true force_update: true on: diff --git a/.gitignore b/.gitignore index 23c82fe6..bcb55844 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,17 @@ log.html + .idea *.xcodeproj -*.a -*.o + fuzz-results + test/fixtures/grammars/* !test/fixtures/grammars/.gitkeep /target -**/*.rs.bk +*.rs.bk +*.a +*.o +*.obj +*.exp +*.lib diff --git a/.travis.yml b/.travis.yml index 55fc9276..722a4dc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,15 +22,15 @@ branches: - /\d+\.\d+\.\d+/ before_deploy: - - mv target/release/tree-sitter . - - tar czf tree-sitter-${TRAVIS_OS_NAME}-x64.tar.gz tree-sitter + - cp target/release/tree-sitter . + - gzip --suffix "-${TRAVIS_OS_NAME}-x64.gz" tree-sitter deploy: provider: releases api_key: secure: "cAd2mQP+Q55v3zedo5ZyOVc3hq3XKMW93lp5LuXV6CYKYbIhkyfym4qfs+C9GJQiIP27cnePYM7B3+OMIFwSPIgXHWWSsuloMtDgYSc/PAwb2dZnJqAyog3BohW/QiGTSnvbVlxPF6P9RMQU6+JP0HJzEJy6QBTa4Und/j0jm24=" file_glob: true - file: "tree-sitter-*.tar.gz" + file: "tree-sitter-*.gz" draft: true overwrite: true skip_cleanup: true diff --git a/cli/npm/.gitignore b/cli/npm/.gitignore index 306613e7..f0475945 100644 --- a/cli/npm/.gitignore +++ b/cli/npm/.gitignore @@ -1,4 +1,3 @@ tree-sitter tree-sitter.exe -*.tar.gz -*.zip +*.gz diff --git a/cli/npm/install.js b/cli/npm/install.js index 5564ce98..d73c51cb 100755 --- a/cli/npm/install.js +++ b/cli/npm/install.js @@ -1,12 +1,11 @@ #!/usr/bin/env node const fs = require('fs'); +const zlib = require('zlib'); const https = require('https'); -const execFileSync = require('child_process').execFileSync; const packageJSON = require('./package.json'); // Determine the URL of the file. -const isWindows = process.platform === 'win32'; const platformName = { 'darwin': 'osx', 'linux': 'linux', @@ -15,48 +14,41 @@ const platformName = { if (!platformName) { throw new Error(`Cannot install tree-sitter-cli for platform ${process.platform}`); } + +const archName = { + 'x64': 'x64', + 'x86': 'x86', + 'ia32': 'x86' +}[process.arch]; +if (!archName) { + throw new Error(`Cannot install tree-sitter-cli for architecture ${process.arch}`); +} + const releaseURL = `https://github.com/tree-sitter/tree-sitter/releases/download/${packageJSON.version}`; -const assetExtension = isWindows ? 'zip' : 'tar.gz'; -const assetName = `tree-sitter-${platformName}-${process.arch}.${assetExtension}`; +const assetName = `tree-sitter-${platformName}-${archName}.gz`; const assetURL = `${releaseURL}/${assetName}`; // Remove previously-downloaded files. -const executableName = isWindows ? 'tree-sitter.exe' : 'tree-sitter'; +const executableName = process.platform === 'win32' ? 'tree-sitter.exe' : 'tree-sitter'; if (fs.existsSync(executableName)) { fs.unlinkSync(executableName); } -if (fs.existsSync(assetName)) { - fs.unlinkSync(assetName); -} // Download the compressed file. console.log(`Downloading ${assetURL}`); -const file = fs.createWriteStream(assetName); +const file = fs.createWriteStream(executableName); get(assetURL, response => { if (response.statusCode > 299) { throw new Error([ 'Download failed', '', - `url: ${url}`, + `url: ${assetURL}`, `status: ${response.statusCode}`, `headers: ${JSON.stringify(response.headers, null, 2)}`, '', ].join('\n')); } - - response.pipe(file); -}); - -// Extract the file. -file.on('finish', () => { - console.log(`Extracting ${assetName}`); - if (isWindows) { - execFileSync('7z', ['e', assetName]); - } else { - execFileSync('tar', ['xzf', assetName]); - } - fs.unlinkSync(assetName); - console.log(`Done`); + response.pipe(zlib.createGunzip()).pipe(file); }); // Follow redirects. diff --git a/cli/npm/package.json b/cli/npm/package.json index 01a50491..e459b551 100644 --- a/cli/npm/package.json +++ b/cli/npm/package.json @@ -14,7 +14,7 @@ ], "main": "lib/api/index.js", "scripts": { - "install": "./install.js" + "install": "install.js" }, "bin": { "tree-sitter": "tree-sitter"