Commit 620cecdf authored by Fabien Maniere's avatar Fabien Maniere

Merge branch '747-dev-git-hash-in-version' into 'dev'

Resolve "Inject commit hash in the version popup"

See merge request !517
parents e9280bbd cc72a0cd
Pipeline #7868 canceled with stages
...@@ -110,3 +110,16 @@ nix-shell --run "npm run css" ...@@ -110,3 +110,16 @@ nix-shell --run "npm run css"
``` ```
#### Feature flags
Some functionality is hidden behind feature flags (mostly it's because
the work is in progress). To enable "expert" mode, issue this in your
JS console:
```javascript
document.cookie = 'expert=true'
```
To unset expert mode:
```javascript
document.cookie = 'expert=false'
```
...@@ -36,16 +36,16 @@ ...@@ -36,16 +36,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1731603435, "lastModified": 1748026580,
"narHash": "sha256-CqCX4JG7UiHvkrBTpYC3wcEurvbtTADLbo3Ns2CEoL8=", "narHash": "sha256-rWtXrcIzU5wm/C8F9LWvUfBGu5U5E7cFzPYT1pHIJaQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8b27c1239e5c421a2bbc2c65d52e4a6fbf2ff296", "rev": "11cb3517b3af6af300dd6c055aeda73c9bf52c48",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "24.11", "ref": "25.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
...@@ -59,11 +59,11 @@ ...@@ -59,11 +59,11 @@
"slimlock": "slimlock" "slimlock": "slimlock"
}, },
"locked": { "locked": {
"lastModified": 1739795788, "lastModified": 1749721661,
"narHash": "sha256-PG4lO49fvWHpQoCN3mIGflisXF+5vEf91ceV9hsWTLU=", "narHash": "sha256-z0Wfm2ThrUilogAeewLf/0Oc2a/4ODrxrA+4NWAdoAQ=",
"owner": "thomashoneyman", "owner": "thomashoneyman",
"repo": "purescript-overlay", "repo": "purescript-overlay",
"rev": "f754c2ef94cef46e5d5223c25d3f361e1f6cb509", "rev": "c73f85b379dcb30f4f3f1bca152b19c880309d01",
"type": "github" "type": "github"
}, },
"original": { "original": {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=24.11"; inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=25.05";
inputs.purescript-overlay = { inputs.purescript-overlay = {
url = "github:thomashoneyman/purescript-overlay"; url = "github:thomashoneyman/purescript-overlay";
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
}; };
dependencies = with pkgs; [ dependencies = with pkgs; [
purs-bin.purs-0_15_16-4 # from the purescript-overlay purs-bin.purs-0_15_16-5 # from the purescript-overlay
spago-bin.spago-0_93_43 spago-bin.spago-0_93_44
nodePackages.purs-tidy nodePackages.purs-tidy
watchexec watchexec
esbuild esbuild
...@@ -46,14 +46,6 @@ ...@@ -46,14 +46,6 @@
fi fi
''; '';
build-zephyr = pkgs.writeShellScriptBin "build-zephyr" ''
set -e
npm spago build --purs-args '--codegen corefn,js'
zephyr -f Main.main
browserify-zephyr
'';
minify-bundle = pkgs.writeShellScriptBin "minify-bundle" '' minify-bundle = pkgs.writeShellScriptBin "minify-bundle" ''
set -e set -e
...@@ -124,7 +116,9 @@ ...@@ -124,7 +116,9 @@
# compile # compile
echo "Bundling" echo "Bundling"
echo "{\"commit_hash\": \"$(git rev-parse HEAD)\"}" > .commit-hash.json
npm run bundle npm run bundle
rm .commit-hash.json
''; '';
}; };
test-ps = pkgs.writeShellApplication { test-ps = pkgs.writeShellApplication {
...@@ -171,7 +165,6 @@ ...@@ -171,7 +165,6 @@
self.packages.${system}.test-ps self.packages.${system}.test-ps
self.packages.${system}.repl self.packages.${system}.repl
setup-gitblame setup-gitblame
build-zephyr
minify-bundle minify-bundle
serve serve
]); ]);
......
...@@ -11,6 +11,7 @@ import Data.Foldable (intercalate) ...@@ -11,6 +11,7 @@ import Data.Foldable (intercalate)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), maybe)
import Data.String.Regex as Regex import Data.String.Regex as Regex
import Data.Tuple (Tuple(..))
import Effect (Effect) import Effect (Effect)
import Effect.Aff (Aff, launchAff) import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
...@@ -36,6 +37,7 @@ import Gargantext.Context.Progress (asyncContext, asyncProgress) ...@@ -36,6 +37,7 @@ import Gargantext.Context.Progress (asyncContext, asyncProgress)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.UpdateEffect (useUpdateEffect1') import Gargantext.Hooks.UpdateEffect (useUpdateEffect1')
import Gargantext.Hooks.UseFeatureFlag as Feature
import Gargantext.Hooks.Version (Version, useVersion) import Gargantext.Hooks.Version (Version, useVersion)
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
...@@ -738,7 +740,9 @@ listNodeActionsLoadedCpt = here.component "listNodeActionsLoaded" cpt ...@@ -738,7 +740,9 @@ listNodeActionsLoadedCpt = here.component "listNodeActionsLoaded" cpt
type VersionComparatorProps = type VersionComparatorProps =
( clientVersion :: Version ( clientVersion :: Version
, clientCommit :: String
, remoteVersion :: Version , remoteVersion :: Version
, remoteCommit :: String
) )
versionComparator :: R2.Leaf VersionComparatorProps versionComparator :: R2.Leaf VersionComparatorProps
...@@ -747,41 +751,46 @@ versionComparator = R2.leaf versionComparatorCpt ...@@ -747,41 +751,46 @@ versionComparator = R2.leaf versionComparatorCpt
versionComparatorCpt :: R.Component VersionComparatorProps versionComparatorCpt :: R.Component VersionComparatorProps
versionComparatorCpt = here.component "versionComparator" cpt versionComparatorCpt = here.component "versionComparator" cpt
where where
cpt { clientVersion, remoteVersion } _ cpt { clientCommit, clientVersion, remoteVersion, remoteCommit } _ = do
| clientVersion == remoteVersion = pure $ let
B.caveat Tuple variant msg =
{ variant: Success if clientVersion == remoteVersion then Tuple Success "Versions match"
, className: "mainleaf__version-comparator" else Tuple Warning "Versions mismatch"
}
[ B.b_ "Versions match" commitEl hash =
, content clientVersion remoteVersion H.span {}
] [ H.text " ("
| otherwise = pure $ , B.code_ hash
B.caveat , H.text ")"
{ variant: Warning
, className: "mainleaf__version-comparator"
}
[ B.b_ "Versions mismatch"
, content clientVersion remoteVersion
] ]
content :: Version -> Version -> R.Element pure $
content clientVersion remoteVersion = B.caveat
H.ul { variant
{} , className: "mainleaf__version-comparator"
[ H.li }
{} [ B.b_ msg
[ B.span_ "frontend: " , H.ul {}
, H.text $ nbsp 1 [ H.li {}
, B.code_ clientVersion [ B.span_ "frontend: "
] , H.text $ nbsp 1
, H.li , B.code_ clientVersion
{} , Feature.hide
[ B.span_ "backend: " { keys: [ "expert" ]
, H.text $ nbsp 1 , render: commitEl clientCommit
, B.code_ remoteVersion }
] ]
] , H.li {}
[ B.span_ "backend: "
, H.text $ nbsp 1
, B.code_ remoteVersion
, Feature.hide
{ keys: [ "expert" ]
, render: commitEl remoteCommit
}
]
]
]
------------------------------------------------------- -------------------------------------------------------
......
'use strict'; 'use strict';
import pkg from '../../package.json'; import pkg from '../../package.json';
import ch from '../../.commit-hash.json';
let version = pkg.version let version = pkg.version;
let commitHash = ch.commit_hash;
export { version }; export { version, commitHash };
...@@ -22,6 +22,7 @@ import Toestand as T ...@@ -22,6 +22,7 @@ import Toestand as T
-- | (ie. Frontend Version) -- | (ie. Frontend Version)
foreign import version :: Version foreign import version :: Version
foreign import commitHash :: String
type Version = String type Version = String
...@@ -33,7 +34,9 @@ type R_Input = ...@@ -33,7 +34,9 @@ type R_Input =
type Output = Maybe R_Output type Output = Maybe R_Output
type R_Output = type R_Output =
{ clientVersion :: String { clientVersion :: String
, clientCommit :: String
, remoteVersion :: String , remoteVersion :: String
, remoteCommit :: String
} }
-- | Conditional Hooks checking release version match between client and remove -- | Conditional Hooks checking release version match between client and remove
...@@ -49,7 +52,9 @@ useVersion mInput = do ...@@ -49,7 +52,9 @@ useVersion mInput = do
Left err -> liftEffect $ log2 "[version] error" err Left err -> liftEffect $ log2 "[version] error" err
Right v -> liftEffect $ flip T.write_ mOutputBox $ Just Right v -> liftEffect $ flip T.write_ mOutputBox $ Just
{ clientVersion: version { clientVersion: version
, remoteVersion: v , clientCommit: commitHash
, remoteVersion: v.version
, remoteCommit: v.commitHash
} }
-- Hooks -- Hooks
useFirstEffect' $ case mInput of useFirstEffect' $ case mInput of
...@@ -58,5 +63,5 @@ useVersion mInput = do ...@@ -58,5 +63,5 @@ useVersion mInput = do
-- Output -- Output
pure mOutput pure mOutput
getBackendVersion :: Session -> REST.AffRESTError Version getBackendVersion :: Session -> REST.AffRESTError { version :: Version, commitHash :: String }
getBackendVersion (Session { backend }) = REST.get Nothing (toUrl backend "version") getBackendVersion (Session { backend }) = REST.get Nothing (toUrl backend "version")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment