diff --git a/frontend/.gitignore b/frontend/.gitignore
index 72bce9bf8df..d5db9ad9937 100644
--- a/frontend/.gitignore
+++ b/frontend/.gitignore
@@ -7,7 +7,6 @@
/dist-server
/tmp
/out-tsc
-src/environments/version.ts
# test coverage
/coverage
@@ -31,3 +30,6 @@ src/environments/version.ts
# nx migration
/migrations.json
+
+# Generated by build-version.js on prod builds.
+/src/environments/version.prod.ts
diff --git a/frontend/angular.json b/frontend/angular.json
index b9e9961d027..4eea66f5fc2 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -62,6 +62,10 @@
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
+ },
+ {
+ "replace": "src/environments/version.ts",
+ "with": "src/environments/version.prod.ts"
}
]
},
diff --git a/frontend/git-version.js b/frontend/build-version.js
similarity index 53%
rename from frontend/git-version.js
rename to frontend/build-version.js
index 54cfdf8d3f5..089c0dcb455 100644
--- a/frontend/git-version.js
+++ b/frontend/build-version.js
@@ -17,30 +17,25 @@
* under the License.
*/
-const { gitDescribeSync } = require("git-describe");
-const { version } = require("./package.json");
-const { resolve, relative } = require("path");
-const { writeFileSync, existsSync, mkdirSync } = require("fs-extra");
-
-const gitInfo = gitDescribeSync({
- dirtyMark: false,
- dirtySemver: false,
-});
+// Runs as the first step of `yarn build` / `yarn build:ci`. Writes
+// version.prod.ts with a timestamped build number; Angular's production
+// fileReplacements (angular.json) swaps version.ts for version.prod.ts.
+// Dev builds (`yarn start`) keep the static "dev" string in version.ts.
-gitInfo.version = version;
+const { generate } = require("build-number-generator");
+const { version } = require("./package.json");
+const { resolve } = require("path");
+const { writeFileSync } = require("fs");
-if (!existsSync(__dirname + "/src/environments")) {
- mkdirSync(__dirname + "/src/environments");
-}
-const file = resolve(__dirname, "src", "environments", "version.ts");
+const buildNumber = generate(version);
+const out = resolve(__dirname, "src", "environments", "version.prod.ts");
writeFileSync(
- file,
- `// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
-/* tslint:disable */
-export const Version = ${JSON.stringify(gitInfo, null, 4)};
-/* tslint:enable */
+ out,
+ `// AUTO-GENERATED by build-version.js — do not edit or commit.
+export const Version = {
+ buildNumber: ${JSON.stringify(buildNumber)},
+ version: ${JSON.stringify(version)},
+};
`,
- { encoding: "utf-8" }
);
-
-console.log(`Wrote version info ${gitInfo.raw} to ${relative(resolve(__dirname, ".."), file)}`);
+console.log(`build-version: ${buildNumber}`);
diff --git a/frontend/package.json b/frontend/package.json
index 481e720d976..55b286be6f6 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -7,8 +7,8 @@
"license": "Apache-2.0",
"scripts": {
"start": "concurrently --kill-others \"npx y-websocket\" \"ng serve\"",
- "build": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --configuration=production --progress=false --source-map=false",
- "build:ci": "node --max-old-space-size=8192 ./node_modules/nx/dist/bin/nx.js build --configuration=production --progress=false --source-map=false",
+ "build": "node build-version.js && node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --configuration=production --progress=false --source-map=false",
+ "build:ci": "node build-version.js && node --max-old-space-size=8192 ./node_modules/nx/dist/bin/nx.js build --configuration=production --progress=false --source-map=false",
"analyze": "ng build --configuration=production --stats-json && webpack-bundle-analyzer dist/stats.json",
"test": "ng test --watch=false",
"test:ci": "node --max-old-space-size=8192 ./node_modules/nx/dist/bin/nx.js test --watch=false --progress=false --coverage --coverage-reporters=lcovonly",
@@ -16,8 +16,7 @@
"lint": "eslint ./src",
"eslint:fix": "yarn eslint --fix ./src",
"format:fix": "yarn prettier-eslint --write \"src/**/*.{ts,js,html,scss,less,json}\"",
- "format:ci": "yarn prettier-eslint --list-different \"src/**/*.{ts,js,html,scss,less,json}\" && yarn eslint ./src",
- "postinstall": "node git-version.js"
+ "format:ci": "yarn prettier-eslint --list-different \"src/**/*.{ts,js,html,scss,less,json}\" && yarn eslint ./src"
},
"private": true,
"dependencies": {
@@ -122,12 +121,12 @@
"@vitest/browser": "4.1.5",
"@vitest/browser-playwright": "4.1.5",
"@vitest/coverage-v8": "4.1.5",
+ "build-number-generator": "3.1.0",
"concurrently": "7.4.0",
"eslint": "8.57.0",
"eslint-plugin-rxjs": "5.0.3",
"eslint-plugin-rxjs-angular": "2.0.1",
"fs-extra": "10.0.1",
- "git-describe": "4.1.0",
"jsdom": "25.0.1",
"nodecat": "2.0.0",
"nx": "22.7.0",
diff --git a/frontend/src/app/dashboard/component/dashboard.component.html b/frontend/src/app/dashboard/component/dashboard.component.html
index 9edea629159..27e4af82dd5 100644
--- a/frontend/src/app/dashboard/component/dashboard.component.html
+++ b/frontend/src/app/dashboard/component/dashboard.component.html
@@ -201,7 +201,7 @@
About
- Git hash: {{ gitCommitHash }}
+ Build: {{ buildNumber }}
diff --git a/frontend/src/app/dashboard/component/dashboard.component.scss b/frontend/src/app/dashboard/component/dashboard.component.scss
index edbe88658fb..3e404ecf6f7 100644
--- a/frontend/src/app/dashboard/component/dashboard.component.scss
+++ b/frontend/src/app/dashboard/component/dashboard.component.scss
@@ -100,7 +100,7 @@ nz-content {
padding: 5px 0;
}
-#git-commit-id {
+#build-number {
position: absolute;
left: 5px;
bottom: 5px;
diff --git a/frontend/src/app/dashboard/component/dashboard.component.ts b/frontend/src/app/dashboard/component/dashboard.component.ts
index 57e6e8e284e..99c346a8dd9 100644
--- a/frontend/src/app/dashboard/component/dashboard.component.ts
+++ b/frontend/src/app/dashboard/component/dashboard.component.ts
@@ -83,7 +83,7 @@ export class DashboardComponent implements OnInit {
isAdmin: boolean = this.userService.isAdmin();
isLogin = this.userService.isLogin();
- public gitCommitHash: string = Version.raw;
+ public buildNumber: string = Version.buildNumber;
displayForum: boolean = true;
displayNavbar: boolean = true;
isCollapsed: boolean = false;
diff --git a/frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts b/frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts
index d3d7d23d179..eb86194e7cf 100644
--- a/frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts
+++ b/frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts
@@ -248,7 +248,7 @@ export class ExecuteWorkflowService {
const workflowExecuteRequest = {
executionName: executionName,
- engineVersion: version.hash,
+ engineVersion: version.buildNumber,
logicalPlan: logicalPlan,
replayFromExecution: replayExecutionInfo,
workflowSettings: workflowSettings,
diff --git a/frontend/src/environments/version.ts b/frontend/src/environments/version.ts
new file mode 100644
index 00000000000..34748af22b9
--- /dev/null
+++ b/frontend/src/environments/version.ts
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { version } from "../../package.json";
+
+// Dev placeholder. Production builds replace this file with the generated
+// version.prod.ts (see angular.json fileReplacements + frontend/build-version.js).
+export const Version = {
+ buildNumber: "dev",
+ version,
+};
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index 57bd0161ccc..5407b53efc0 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -2,6 +2,7 @@
"compileOnSave": false,
"compilerOptions": {
"allowSyntheticDefaultImports": true,
+ "resolveJsonModule": true,
"paths": {
"path": [
"./node_modules/path-browserify"
diff --git a/frontend/yarn.lock b/frontend/yarn.lock
index b929da0c62c..46a49e1e1ec 100644
--- a/frontend/yarn.lock
+++ b/frontend/yarn.lock
@@ -6397,7 +6397,7 @@ __metadata:
languageName: node
linkType: hard
-"@types/semver@npm:^7.3.12, @types/semver@npm:^7.3.8":
+"@types/semver@npm:^7.3.12":
version: 7.7.1
resolution: "@types/semver@npm:7.7.1"
checksum: 10c0/c938aef3bf79a73f0f3f6037c16e2e759ff40c54122ddf0b2583703393d8d3127130823facb880e694caa324eb6845628186aac1997ee8b31dc2d18fafe26268
@@ -8135,6 +8135,15 @@ __metadata:
languageName: node
linkType: hard
+"build-number-generator@npm:3.1.0":
+ version: 3.1.0
+ resolution: "build-number-generator@npm:3.1.0"
+ bin:
+ buildnumgen: bin/buildnumgen.js
+ checksum: 10c0/10d2366b74493a12aa7390e08dc5cd27f77ba600234c757e59ae9436eb7b7dde837322d34f0e177de5e5da3f4e5cabb089a03f9fcb32195ceaecd3ebab0b3c5b
+ languageName: node
+ linkType: hard
+
"bundle-name@npm:^4.1.0":
version: 4.1.0
resolution: "bundle-name@npm:4.1.0"
@@ -10869,20 +10878,6 @@ __metadata:
languageName: node
linkType: hard
-"git-describe@npm:4.1.0":
- version: 4.1.0
- resolution: "git-describe@npm:4.1.0"
- dependencies:
- "@types/semver": "npm:^7.3.8"
- lodash: "npm:^4.17.21"
- semver: "npm:^5.6.0"
- dependenciesMeta:
- semver:
- optional: true
- checksum: 10c0/2e5cbb0f5aa4a6f4dc9135276a85a29ec627a88dd0d73b63d1a3cd2ec2477a8d1d5fc83ae480a00c587c0ea8a193c6a9696a5b549dc6af02db0be74cdfac0eb5
- languageName: node
- linkType: hard
-
"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2":
version: 5.1.2
resolution: "glob-parent@npm:5.1.2"
@@ -11094,6 +11089,7 @@ __metadata:
"@vitest/coverage-v8": "npm:4.1.5"
ai: "npm:5.0.93"
ajv: "npm:8.10.0"
+ build-number-generator: "npm:3.1.0"
concaveman: "npm:2.0.0"
concurrently: "npm:7.4.0"
d3-shape: "npm:2.1.0"
@@ -11104,7 +11100,6 @@ __metadata:
file-saver: "npm:2.0.5"
fs-extra: "npm:10.0.1"
fuse.js: "npm:6.5.3"
- git-describe: "npm:4.1.0"
html2canvas: "npm:1.4.1"
jointjs: "npm:3.5.4"
jsdom: "npm:25.0.1"