1
0

prepackage-plugins.mjs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env node
  2. import { rebuild } from 'electron-rebuild'
  3. import sh from 'shelljs'
  4. import path from 'node:path'
  5. import fs from 'node:fs'
  6. import * as vars from './vars.mjs'
  7. import log from 'npmlog'
  8. import * as url from 'url'
  9. const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
  10. let target = path.resolve(__dirname, '../builtin-plugins')
  11. sh.mkdir('-p', target)
  12. fs.writeFileSync(path.join(target, 'package.json'), '{}')
  13. sh.cd(target)
  14. vars.builtinPlugins.forEach(plugin => {
  15. if (plugin === 'tabby-web') {
  16. return
  17. }
  18. log.info('install', plugin)
  19. sh.cp('-r', path.join('..', plugin), '.')
  20. sh.rm('-rf', path.join(plugin, 'node_modules'))
  21. sh.cd(plugin)
  22. sh.exec(`yarn install --force --production`, { fatal: true })
  23. log.info('rebuild', 'native')
  24. if (fs.existsSync('node_modules')) {
  25. rebuild({
  26. buildPath: path.resolve('.'),
  27. electronVersion: vars.electronVersion,
  28. arch: process.env.ARCH ?? process.arch,
  29. force: true,
  30. useCache: false,
  31. })
  32. }
  33. sh.cd('..')
  34. })
  35. fs.unlinkSync(path.join(target, 'package.json'), '{}')