Download scripts/prepare-native.cjs from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 3.33 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/scripts/prepare-native.cjs
- Command line
-
hf download hf://VanyaJ/bada-terminal/scripts/prepare-native.cjs
-
curl -L -o prepare-native.cjs https://huggingface.co/VanyaJ/bada-terminal/resolve/main/scripts/prepare-native.cjs
3.33 kB
| // ํ์ ๋ค์ดํฐ๋ธ ๋ชจ๋๋ง ์ค๋นํ๋ค. SSH์ ์ ํ์ CPU/์ํธ ๊ฐ์๊ธฐ๋ JS ๊ฒฝ๋ก๋ฅผ ์ ์งํ๋ค. | |
| // ์ค๋ช ๋ฌธ์: docs/specs/bong-dependency-repair.md (v1.0.0) | |
| const fs = require('node:fs'); | |
| const path = require('node:path'); | |
| async function prepareNative({ appDir = path.resolve(__dirname, '..'), platform = process.platform, | |
| arch = process.arch, electronVersion = require('electron/package.json').version } = {}) { | |
| if (platform !== process.platform) { | |
| // ๊ต์ฐจ ํ๋ซํผ ํจํค์ง(์: macOS์์ Windows ๋น๋) ์ ํธ์คํธ node-gyp๊ฐ ๋์ OS์ ๋ค๋ฅธ ๋ฐ์ด๋๋ฆฌ๋ก | |
| // ๋ฎ์ด์ฐ์ง ์๋๋ก ๋๋ด๋ N-API ์ฌ์ ๋น๋(better-sqlite3, node-pty) ์กด์ฌ ์ฌ๋ถ๋ฅผ ๊ฒ์ฆํ๋ค. | |
| const sqlitePrebuild = path.join(appDir, 'node_modules/better-sqlite3/prebuilds', `${platform}-${arch}.node`); | |
| const ptyPrebuild = path.join(appDir, 'node_modules/node-pty/prebuilds', `${platform}-${arch}`, 'pty.node'); | |
| if (fs.existsSync(sqlitePrebuild) && fs.existsSync(ptyPrebuild)) { | |
| if (platform === 'darwin') { | |
| const helper = path.join(appDir, 'node_modules/node-pty/prebuilds', `${platform}-${arch}`, 'spawn-helper'); | |
| if (fs.existsSync(helper)) fs.chmodSync(helper, fs.statSync(helper).mode | 0o111); | |
| } | |
| return; | |
| } | |
| } | |
| const { rebuild } = await import('@electron/rebuild'); | |
| await rebuild({ | |
| buildPath: appDir, | |
| electronVersion, | |
| platform, | |
| arch, | |
| onlyModules: ['better-sqlite3', 'node-pty'] | |
| }); | |
| if (platform === 'darwin') { | |
| // npm --ignore-scripts ์ค์น์ ๊ต์ฐจ ์ํคํ ์ฒ ํจํค์ง์๋ ์คํ ๊ถํ์ ๋ณต์ํ๋ค. | |
| const helper = path.join(appDir, 'node_modules/node-pty/prebuilds', `${platform}-${arch}`, 'spawn-helper'); | |
| fs.chmodSync(helper, fs.statSync(helper).mode | 0o111); | |
| } | |
| // Linux์๋ PTY ์ฌ์ ๋น๋๊ฐ ์์ผ๋ฏ๋ก ์ rebuild๊ฐ ์ ์ ์์ค ๋น๋๋ฅผ ์ํํด์ผ ํ๋ค. | |
| // ์คํจ๋ ๊ทธ๋๋ก ์ ํํ๋ค. beforeBuild=false๋ ๋น๋ 26์ ์์กด์ฑ ์์ง๊น์ง ์๋ตํ๋ฏ๋ก ์ฌ์ฉํ์ง ์๋๋ค. | |
| } | |
| module.exports = async ({ appOutDir, packager, electronPlatformName, arch }) => { | |
| const unpackedNodePtyBuild = appOutDir | |
| ? path.join(appOutDir, 'resources/app.asar.unpacked/node_modules/node-pty/build') | |
| : null; | |
| if (unpackedNodePtyBuild && fs.existsSync(path.join(appOutDir, 'resources/app.asar.unpacked'))) { | |
| if (electronPlatformName !== process.platform && fs.existsSync(unpackedNodePtyBuild)) { | |
| // ๊ต์ฐจ ํ๋ซํผ ํจํค์ง ์ฐ์ถ๋ฌผ์์ ํธ์คํธ OS์ node-pty/build ์์ฌ๋ฌผ์ ์ ๊ฑฐํด prebuilds/<platform>-<arch>๋ฅผ ๋ก๋ํ๊ฒ ํ๋ค. | |
| fs.rmSync(unpackedNodePtyBuild, { recursive: true, force: true }); | |
| } | |
| return; | |
| } | |
| const options = { appDir: packager.appDir, platform: electronPlatformName, | |
| arch: require('builder-util').Arch[arch], electronVersion: packager.info.framework.version }; | |
| // ์๋ชป๋ OS/์ํคํ ์ฒ์ ๋ด์ฅ ๋ธ๋ก์ปค๋ฅผ ์กฐ์ฉํ ๋ฐฐํฌํ์ง ์๋๋ค. ์ค์น ์์๋ ์๊ตฌํ์ง ์๋๋ค. | |
| // ์ค๋ช ๋ฌธ์: docs/specs/app-lifecycle.md v1.0.0 | |
| require('../src/services/nats-binary').validateNatsBinary(options); | |
| return prepareNative(options); | |
| }; | |
| if (require.main === module) prepareNative().catch(error => { | |
| console.error('[Native dependencies]', error.message); | |
| process.exitCode = 1; | |
| }); | |