Download prebuilt binary files at npm install time

issue #904
This commit is contained in:
Simon Edwards 2021-12-28 20:18:40 +01:00
parent 01d3c03fb2
commit a2f818c07f
3 changed files with 2972 additions and 2909 deletions

View File

@ -16,8 +16,9 @@
"scripts": {
"dev": "cross-env npm run build && node ./scripts/qode.js dist/demo.js",
"build": "cross-env tsc && npm run build:addon",
"install": "cross-env npm run setupqt && (node ./scripts/skip.js || npm run build:addon)",
"install": "cross-env npm run setupqt && (node ./scripts/skip.js || npm run setupbinary)",
"setupqt": "cross-env node ./scripts/setupMiniQt.js",
"setupbinary": "cross-env node ./scripts/setupBinary.js",
"build:addon": "cross-env CMAKE_BUILD_PARALLEL_LEVEL=8 cmake-js compile",
"test": "node ./scripts/qode.js ./node_modules/jest/bin/jest -i",
"lint:cpp": "cross-env clang-format -i --glob=src/cpp/**/*.[h,c]*",
@ -40,7 +41,8 @@
"memoize-one": "^5.2.1",
"node-addon-api": "^4.0.0",
"postcss": "^7.0.17",
"postcss-nodegui-autoprefixer": "0.0.7"
"postcss-nodegui-autoprefixer": "0.0.7",
"tar": "^6.0.1"
},
"devDependencies": {
"@types/bindings": "^1.5.1",

35
scripts/setupBinary.js Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env node
const os = require('os');
const fs = require('fs');
const path = require('path');
const { setupArtifact } = require('@nodegui/artifact-installer');
const tar = require('tar');
const SETUP_DIR = path.resolve(__dirname, '..', 'build', 'Release');
const packageJson = require('../package');
async function setupBinary() {
const packageVersion = packageJson.version;
const tarballName = `nodegui-binary-v${packageVersion}-${os.platform()}-${os.arch()}.tar.gz`;
const url = `https://github.com/nodegui/nodegui/releases/download/v${packageVersion}/${tarballName}`;
await setupArtifact({
outDir: SETUP_DIR,
id: 'nodegui-core',
displayName: `Precompiled NodeGui binary`,
downloadLink: url,
skipSetup: () => false,
});
const tarPath = path.join(SETUP_DIR, tarballName.slice(0, -3));
tar.extract({
cwd: SETUP_DIR,
file: tarPath,
sync: true,
});
fs.unlinkSync(tarPath);
}
setupBinary().catch((err) => {
console.error(err);
process.exit(1);
});

5840
yarn.lock

File diff suppressed because it is too large Load Diff