fetch-server.cjs 907 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env node
  2. const { fetchVersion } = require('gh-release-fetch');
  3. const path = require('path');
  4. const fs = require('fs').promises;
  5. (async () => {
  6. const serverVersion = process.argv[2];
  7. console.log(`Downloading Scrcpy server binary version ${serverVersion}...`);
  8. const binFolder = path.resolve(__dirname, '..', 'bin');
  9. await fetchVersion({
  10. repository: 'Genymobile/scrcpy',
  11. version: `v${serverVersion}`,
  12. package: `scrcpy-server-v${serverVersion}`,
  13. destination: binFolder,
  14. extract: false,
  15. });
  16. await fs.rename(
  17. path.resolve(binFolder, `scrcpy-server-v${serverVersion}`),
  18. path.resolve(binFolder, 'scrcpy-server')
  19. );
  20. fs.writeFile(path.resolve(binFolder, 'version.js'), `export default '${serverVersion}';`);
  21. fs.writeFile(path.resolve(binFolder, 'version.d.ts'), `export default '${serverVersion}';`);
  22. })();