prepackage-plugins.mjs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. const __dirname = path.dirname(new URL(import.meta.url).pathname)
  9. let target = path.resolve(__dirname, '../builtin-plugins')
  10. sh.mkdir('-p', target)
  11. fs.writeFileSync(path.join(target, 'package.json'), '{}')
  12. sh.cd(target)
  13. vars.builtinPlugins.forEach(plugin => {
  14. if (plugin === 'tabby-web') {
  15. return
  16. }
  17. log.info('install', plugin)
  18. sh.cp('-r', path.join('..', plugin), '.')
  19. sh.rm('-rf', path.join(plugin, 'node_modules'))
  20. sh.cd(plugin)
  21. sh.exec(`yarn install --force --production`, { fatal: true })
  22. log.info('rebuild', 'native')
  23. if (fs.existsSync('node_modules')) {
  24. rebuild({
  25. buildPath: path.resolve('.'),
  26. electronVersion: vars.electronVersion,
  27. arch: process.env.ARCH ?? process.arch,
  28. force: true,
  29. useCache: false,
  30. })
  31. }
  32. sh.cd('..')
  33. })
  34. fs.unlinkSync(path.join(target, 'package.json'), '{}')