From 1872064b479a41e14fd1bddcb9ad5049a27f6e5c Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Fri, 13 Dec 2024 23:42:51 +0100 Subject: [PATCH 1/2] Improve developer tooling --- apps.ts | 1 + package.json | 8 ++++---- scripts/download-jaeger-ui.mts | 6 +++++- webpack.common.ts | 24 +++++++++++++++++------- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/apps.ts b/apps.ts index 41192db24..5c591889f 100644 --- a/apps.ts +++ b/apps.ts @@ -63,4 +63,5 @@ export interface WebpackEnv { WEBPACK_BUILD: true; platform?: string; compress?: boolean; + ["zip-filename-format"]?: string; } diff --git a/package.json b/package.json index 42b22c31a..1d8eb0964 100644 --- a/package.json +++ b/package.json @@ -18,14 +18,14 @@ "prebuild": "rimraf dist && npm run download-jaeger-ui", "build:dev": "npm run prebuild && webpack --progress --config webpack.dev.ts", "build:dev:jetbrains": "npm run build:dev --env platform=JetBrains", - "build:dev:jetbrains:zip": "npm run build:dev:jetbrains -- --env compress=true", + "build:dev:jetbrains:zip": "npm run build:dev:jetbrains -- --env compress=true --env zip-filename-format=JetBrains", "build:dev:web": "npm run build:dev --env platform=Web", - "build:dev:web:zip": "npm run build:dev:web -- --env zip=true", + "build:dev:web:zip": "npm run build:dev:web -- --env compress=true", "build:prod": "npm run prebuild && webpack --progress --config webpack.prod.ts", "build:prod:jetbrains": "npm run build:prod -- --env platform=JetBrains", - "build:prod:jetbrains:zip": "npm run build:prod:jetbrains -- --env compress=true", + "build:prod:jetbrains:zip": "npm run build:prod:jetbrains -- --env compress=true --env zip-filename-format=JetBrains", "build:prod:web": "npm run build:prod -- --env platform=Web", - "build:prod:web:zip": "npm run build:prod:web -- --env zip=true", + "build:prod:web:zip": "npm run build:prod:web -- --env compress=true", "precommit": "lint-staged", "prepare": "husky" }, diff --git a/scripts/download-jaeger-ui.mts b/scripts/download-jaeger-ui.mts index 0ed92f321..72d1582b4 100644 --- a/scripts/download-jaeger-ui.mts +++ b/scripts/download-jaeger-ui.mts @@ -34,8 +34,12 @@ if (outputArgIndex !== -1 && process.argv[outputArgIndex + 1]) { fs.mkdirSync(outputPath, { recursive: true }); const extractZip = (zipPath: string, extractPath: string) => { + if (fs.existsSync(extractPath)) { + fs.rmdirSync(extractPath, { recursive: true }); + } + const zip = new AdmZip(zipPath); - zip.extractAllTo(extractPath, true); + zip.extractAllTo(extractPath); }; const downloadReleaseAsset = async ({ diff --git a/webpack.common.ts b/webpack.common.ts index 8b037f339..1c4bd12fa 100644 --- a/webpack.common.ts +++ b/webpack.common.ts @@ -10,6 +10,22 @@ interface PackageJson { version: string; } +const getZipFilename = (env: WebpackEnv): string => { + const ZIP_NAME_FORMATS: Record = { + default: "dist-{platform}-v{version}", + JetBrains: "digma-ui-{version}" + }; + + const argFormat = env["zip-filename-format"]; + const format = + (argFormat && ZIP_NAME_FORMATS[argFormat]) ?? ZIP_NAME_FORMATS.default; + + return format + .replace("{platform}", (env.platform ?? "").toLocaleLowerCase()) + .replace("{version}", (packageJson as PackageJson).version) + .replace(/-{2,}/g, "-"); +}; + const getConfig = (env: WebpackEnv): WebpackConfiguration => { const entriesToBuild: Record = Object.entries(appData) .filter( @@ -76,13 +92,7 @@ const getConfig = (env: WebpackEnv): WebpackConfiguration => { ...(env.compress ? [ new ZipPlugin({ - filename: [ - "dist", - (env.platform ?? "").toLocaleLowerCase(), - `v${(packageJson as PackageJson).version}.zip` - ] - .filter(Boolean) - .join("-") + filename: getZipFilename(env) }) ] : []) From 347d9a792f0c2660c02b1abecc5466433ec2079f Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Sat, 14 Dec 2024 01:06:15 +0100 Subject: [PATCH 2/2] Display version in index.html --- assets/index.ejs | 1 + assets/index.web.ejs | 1 + webpack.common.ts | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/index.ejs b/assets/index.ejs index b3ba0fddb..d36d4d9cc 100644 --- a/assets/index.ejs +++ b/assets/index.ejs @@ -2,6 +2,7 @@ +