A "universal" / normalized API wrapper for git hosting services.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

55 lines
1.7 KiB

  1. #!/bin/bash
  2. set -e
  3. # Update version number in package.json (to match build.gradle def)
  4. PACKAGE_VERSION=$( cd .. && ./gradlew :gitrest:properties | grep -oP '(?<=^version: )[0-9\.]+' )
  5. PACKAGE_JSON=$(jq --arg version "$PACKAGE_VERSION" '.version = $version' package.json)
  6. echo "$PACKAGE_JSON" > package.json
  7. # Build JS file (ignore browser tests...)
  8. ( cd .. && ./gradlew :gitrest:build -x :gitrest:jsBrowserTest )
  9. # Copy generated git-rest-wrapper package
  10. cp ../build/js/packages/git-rest-wrapper-gitrest/kotlin/git-rest-wrapper-gitrest.js index.js
  11. # Copy browser bundle
  12. rm -rf bundle && mkdir bundle
  13. cp ../gitrest/build/distributions/* bundle/
  14. BUNDLE_PACKAGES=()
  15. function install_bundled_packages {
  16. # Re-create node_modules; fill with bundled dependencies
  17. rm -rf node_modules && mkdir node_modules
  18. for pkg in ../build/js/packages_imported/*
  19. do
  20. pkg_dir=$(ls -d ${pkg}/*)
  21. pkg_name=${pkg##*/}
  22. cp -r "$pkg_dir" "node_modules/${pkg_name}"
  23. BUNDLE_PACKAGES+=("\"$pkg_name\"")
  24. done
  25. }
  26. install_bundled_packages
  27. # Update 'bundledDependencies' value in package.json
  28. PACKAGE_DEPENDENCIES=$(echo "${BUNDLE_PACKAGES[@]}" | jq -s '.')
  29. PACKAGE_JSON=$(jq --argjson dependencies "$PACKAGE_DEPENDENCIES" '.bundledDependencies = $dependencies' package.json)
  30. echo "$PACKAGE_JSON" > package.json
  31. # Install regular NPM dependencies for testing
  32. NPM_PACKAGES=$(jq '.dependencies | to_entries | map("\(.key)@\(.value|tostring)") | .[]' package.json)
  33. npm install ${NPM_PACKAGES//\"/} --no-package-lock
  34. npm dedupe
  35. node test.js # Make sure the package actually works
  36. # Re-install bundled packages (remove dependencies fetched from npm for testing)
  37. install_bundled_packages
  38. # Copy meta-files from root dir
  39. cp -f ../README.md .
  40. cp -f ../LICENSE .
  41. # Publish the package!
  42. npm publish