|
| 1 | +# Note: this justfile should work for anyone using MacOS, however with some work we can probably get it to also work on |
| 2 | +# Windows if we use the [unix] and [windows] attributes on the commands that execute shell scripts: |
| 3 | +# https://just.systems/man/en/attributes.html#enabling-and-disabling-recipes180 |
| 4 | + |
| 5 | +[private] |
| 6 | +default: |
| 7 | + just --list |
| 8 | + |
| 9 | +currentBranch := `git branch --show-current` |
| 10 | +branchAsTag := replace(currentBranch, '_', '-') |
| 11 | +packageName := '@labkey/api' |
| 12 | +pwd := `pwd` |
| 13 | + |
| 14 | +# We quote the paths from our environment variables so these variables will work even if the paths contains spaces |
| 15 | +# We trim the trailing / from our environment variables so we can treat them consistently with our other paths |
| 16 | +components := quote(trim_end_match(env('LABKEY_UI_COMPONENTS_HOME'), '/') / 'packages/components') |
| 17 | +premium := quote(trim_end_match(env('LABKEY_UI_PREMIUM_HOME'), '/')) |
| 18 | +distPath := 'node_modules' / packageName / 'dist' |
| 19 | +sourceDist := pwd / 'dist/' |
| 20 | +modulesToBump := components + ' ' + premium |
| 21 | +copyLocations := append('/' + distPath, modulesToBump) |
| 22 | + |
| 23 | +# Builds the package |
| 24 | +build: |
| 25 | + npm run build |
| 26 | + |
| 27 | +# Copies built package to NODE_MODULES directory for every module listed in copyLocations |
| 28 | +copy: |
| 29 | + #!/usr/bin/env zsh |
| 30 | + set -euo pipefail |
| 31 | + for module in {{ copyLocations }}; do |
| 32 | + echo '{{ GREEN }}'Copying built package to '{{CYAN}}'$module'{{ NORMAL }}' |
| 33 | + rsync -ra {{ sourceDist }} $module |
| 34 | + done |
| 35 | + |
| 36 | +# Builds the package and copies it to NODE_MODULES for every module listed in copyLocations |
| 37 | +bc: build copy |
| 38 | + |
| 39 | +# Bumps version to a prerelease version based on the current branch name |
| 40 | +preVersion: |
| 41 | + @echo {{ GREEN }}Bumping prerelease version with preid='{{CYAN}}'{{ branchAsTag }}{{ NORMAL }} |
| 42 | + @npm version prerelease --preid {{ branchAsTag }} --no-git-tag-version |
| 43 | + |
| 44 | +# Publishes the current version with the current branch name as a tag |
| 45 | +publishPreVersion: |
| 46 | + @echo {{ GREEN }}Publishing prerelease package{{ NORMAL }} |
| 47 | + @npm publish --tag {{ branchAsTag }} |
| 48 | + |
| 49 | +[private] |
| 50 | +sleep: |
| 51 | + @echo {{ GREEN }}"Sleeping so artifactory doesn't return 404"{{ NORMAL }} |
| 52 | + @sleep 6 |
| 53 | + |
| 54 | +# Lists the modules in the 'modulesToBump' variable |
| 55 | +listModules: |
| 56 | + #!/usr/bin/env zsh |
| 57 | + set -euo pipefail |
| 58 | + for module in {{ modulesToBump }}; do |
| 59 | + echo $module |
| 60 | + done |
| 61 | + |
| 62 | +# Stored as a string because we want to execute this when scripts are run, not when the justfile is evaluated, so we |
| 63 | +# always have the most up to date version. |
| 64 | +currentVersionImport := quote("require('./package.json').version") |
| 65 | + |
| 66 | +# lists the current package version |
| 67 | +version: |
| 68 | + @echo $(node -p -e {{ currentVersionImport }}) |
| 69 | + |
| 70 | +# Bumps the @labkey/premium package to the current version in every module listed in the modulesToBump variable |
| 71 | +bump: |
| 72 | + #!/usr/bin/env zsh |
| 73 | + set -euo pipefail |
| 74 | + v=$(node -p -e {{ currentVersionImport }}) |
| 75 | + echo '{{ GREEN }}'Bumping {{ packageName }} to '{{CYAN}}'$v'{{ NORMAL }}' |
| 76 | + for module in {{ modulesToBump }}; do |
| 77 | + pushd $module |
| 78 | + echo '{{ GREEN }}'Bumping {{ packageName }} in '{{CYAN}}'$(pwd)'{{ NORMAL }}' |
| 79 | + npm install --legacy-peer-deps --save-exact {{ packageName }}@$v |
| 80 | + popd |
| 81 | + done |
| 82 | + |
| 83 | +# Bumps the version to a prerelease version based on the current branch name, publishes the version, and bumps it in every module listed in modulesToBump |
| 84 | +release: preVersion publishPreVersion sleep bump |
| 85 | + |
| 86 | +# Bumps the major version |
| 87 | +major: |
| 88 | + npm version major --no-git-tag-version |
| 89 | + |
| 90 | +# Bumps the minor version |
| 91 | +minor: |
| 92 | + npm version minor --no-git-tag-version |
| 93 | + |
| 94 | +# Bumps the patch version |
| 95 | +patch: |
| 96 | + npm version patch --no-git-tag-version |
| 97 | + |
| 98 | +# Publishes the current version, must be a production version |
| 99 | +publish: |
| 100 | + npm publish |
| 101 | + |
| 102 | +pb: publish sleep bump |
0 commit comments