deploy.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. const git = require('simple-git')
  7. const path = require('path')
  8. const fs = require("fs")
  9. const fse = require("fs-extra")
  10. const remoteUrl = "https://github.com/molstar/molstar.github.io.git"
  11. const buildDir = path.resolve(__dirname, '../build/')
  12. const deployDir = path.resolve(buildDir, 'deploy/')
  13. const localPath = path.resolve(deployDir, 'molstar.github.io/')
  14. if (!fs.existsSync(localPath) || !git(localPath).checkIsRepo()) {
  15. fs.mkdirSync(localPath, { recursive: true })
  16. git(deployDir)
  17. .silent(false)
  18. .clone(remoteUrl)
  19. .fetch(['--all'])
  20. } else {
  21. git(localPath)
  22. .silent(false)
  23. .fetch(['--all'])
  24. .reset(['--hard', 'origin/master'])
  25. }
  26. const viewerBuildPath = path.resolve(buildDir, '../build/viewer/')
  27. const viewerDeployPath = path.resolve(localPath, 'viewer/')
  28. fse.copySync(viewerBuildPath, viewerDeployPath, { overwrite: true })
  29. git(localPath)
  30. .silent(false)
  31. .add(['-A'])
  32. .commit('updated viewer')
  33. .push()
  34. // #!/usr/bin/env bash
  35. // LEVEL=$1
  36. // DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
  37. // cd ${DIR};
  38. // mkdir -p ../build/;
  39. // cd ../build/;
  40. // if [ -d "arose.github.io" ]; then
  41. // cd ./arose.github.io/;
  42. // git fetch --all;
  43. // git reset --hard origin/master;
  44. // cd ../
  45. // else
  46. // git clone "https://github.com/arose/arose.github.io.git";
  47. // fi
  48. // if [ "$LEVEL" = "prerelease" ]; then
  49. // cd ./arose.github.io/ngldev/;
  50. // else
  51. // cd ./arose.github.io/ngl/;
  52. // fi
  53. // cp -r ${DIR}/../data/. ./data/;
  54. // cp -r ${DIR}/../examples/css/. ./css/;
  55. // cp -r ${DIR}/../examples/fonts/. ./fonts/;
  56. // cp -r ${DIR}/../examples/js/. ./js/;
  57. // cp -r ${DIR}/../examples/scripts/. ./scripts/;
  58. // cp -r ${DIR}/../build/docs/. ./api/;
  59. // cp -r ${DIR}/../build/gallery/. ./gallery/;
  60. // cp ${DIR}/../build/scriptsList.json ./scripts/list.json;
  61. // cp ${DIR}/../dist/ngl.js ./js/ngl.js;
  62. // cd ../;
  63. // git add -A;
  64. // if [ "$LEVEL" = "prerelease" ]; then
  65. // git commit -m "ngldev update";
  66. // else
  67. // git commit -m "ngl update";
  68. // fi
  69. // git push;