mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
76ceb707f4
This PR builds console static assets into the server docker image at `/srv/console-assets`. When env var `HASURA_GRAPHQL_CONSOLE_ASSETS_DIR=/srv/console-assets` or flag `--console-assets-dir=/srv/console-assets` is set on the server, the files in this directory are served at `/console/assets/*`. The console html template will have a variable called `cdnAssets: false` when this flag is set and it loads assets from server itself instead of CDN. The assets are moved to a new bucket with a new naming scheme: ``` graphql-engine-cdn.hasura.io/console/assets/ /common/{} /versioned/<version/{} /channel/<channel>/<version>/{} ``` Console served by CLI will still load assets from CDN - will fix that in the next release.
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package version
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
preReleaseVersion = "v1.0-alpha"
|
|
unversioned = "unversioned"
|
|
versioned = "versioned"
|
|
)
|
|
|
|
// GetConsoleTemplateVersion returns the template version tv required to render
|
|
// the console html.
|
|
func (v *Version) GetConsoleTemplateVersion() (tv string) {
|
|
// pre-release builds
|
|
if v.Server == "" {
|
|
return preReleaseVersion
|
|
}
|
|
// tagged build
|
|
if v.Server != "" {
|
|
if v.ServerSemver != nil {
|
|
return fmt.Sprintf("v%d.%d", v.ServerSemver.Major(), v.ServerSemver.Minor())
|
|
}
|
|
}
|
|
// untagged version
|
|
return unversioned
|
|
}
|
|
|
|
// GetConsoleAssetsVersion returns the assets version av to be used in the
|
|
// console template. This function is supposed to return the following:
|
|
// > input -> output
|
|
// > dev-build -> versioned/dev-build
|
|
// > v1.0.0-beta.01 -> beta/v1.0
|
|
// > v1.0.0-alpha.01 -> alpha/v1.0
|
|
// > v1.2.1-rc.03 -> rc/v1.2
|
|
// > v1.1.0 -> stable/v1.1
|
|
func (v *Version) GetConsoleAssetsVersion() (av string) {
|
|
// server has a version
|
|
if v.Server != "" {
|
|
// version is semver
|
|
if v.ServerSemver != nil {
|
|
// check for release channels
|
|
preRelease := v.ServerSemver.Prerelease()
|
|
channel := "stable"
|
|
if strings.HasPrefix(preRelease, "alpha") {
|
|
channel = "alpha"
|
|
}
|
|
if strings.HasPrefix(preRelease, "beta") {
|
|
channel = "beta"
|
|
}
|
|
if strings.HasPrefix(preRelease, "rc") {
|
|
channel = "rc"
|
|
}
|
|
return fmt.Sprintf("channel/%s/v%d.%d", channel, v.ServerSemver.Major(), v.ServerSemver.Minor())
|
|
}
|
|
// version is not semver
|
|
return fmt.Sprintf("%s/%s", versioned, v.Server)
|
|
}
|
|
// server doesn't have a version - very old server :(
|
|
return preReleaseVersion
|
|
}
|