build-extension.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. dpkg -s zip &> /dev/null
  3. if [ $? -ne 0 ]
  4. then
  5. if ! command -v zip &> /dev/null; then
  6. echo "Installing zip"
  7. sudo apt install zip
  8. fi
  9. fi
  10. dpkg -s jq &> /dev/null
  11. if [ $? -ne 0 ]
  12. then
  13. if ! command -v jq &> /dev/null; then
  14. echo "Installing jq"
  15. sudo apt install jq
  16. fi
  17. fi
  18. npm install
  19. npm update
  20. npx rollup -c rollup.config.js
  21. cp package.json package.copy.json
  22. jq 'del(.dependencies."single-file-cli")' package.copy.json > package.json
  23. zip -r singlefile-extension-source.zip manifest.json package.json _locales src rollup*.js eslint.config.mjs build-extension.sh
  24. mv package.copy.json package.json
  25. rm -f singlefile-extension-firefox.zip
  26. cp src/core/bg/config.js config.copy.js
  27. cp src/core/bg/companion.js companion.copy.js
  28. node -e "const fs=require('fs');const file='src/core/bg/config.js';const updated=fs.readFileSync(file,'utf8').replace(/forceWebAuthFlow: false/g,'forceWebAuthFlow: true');fs.writeFileSync(file,updated);"
  29. node -e "const fs=require('fs');const file='src/core/bg/companion.js';const updated=fs.readFileSync(file,'utf8').replace(/enabled: true/g,'enabled: false');fs.writeFileSync(file,updated);"
  30. zip -r singlefile-extension-firefox.zip manifest.json lib _locales src
  31. mv config.copy.js src/core/bg/config.js
  32. mv companion.copy.js src/core/bg/companion.js