Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(log-viewer-webui): Migrate server codebase to TypeScript and update dependencies. #647

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ tasks:
CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "{{.G_PACKAGE_BUILD_DIR}}"
sources:
- "{{.G_BUILD_DIR}}/log-viewer-webui-clients.md5"
- "{{.G_BUILD_DIR}}/log-viewer-webui.md5"
- "{{.G_BUILD_DIR}}/package-venv.md5"
- "{{.G_BUILD_DIR}}/webui.md5"
- "{{.G_BUILD_DIR}}/webui-nodejs.md5"
Expand All @@ -93,10 +93,6 @@ tasks:
- "{{.G_CORE_COMPONENT_BUILD_DIR}}/clp"
- "{{.G_CORE_COMPONENT_BUILD_DIR}}/clp-s"
- "{{.G_CORE_COMPONENT_BUILD_DIR}}/reducer-server"
- "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/server/package.json"
- "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/server/package-lock.json"
- "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/server/settings.json"
- "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/server/src/**/*.js"
- "{{.TASKFILE}}"
- "/etc/os-release"
- "components/clp-package-utils/dist/*.whl"
Expand All @@ -110,7 +106,7 @@ tasks:
- "clp-py-utils"
- "init"
- "job-orchestration"
- "log-viewer-webui-clients"
- "log-viewer-webui"
- "nodejs-14"
- "package-venv"
- task: "utils:validate-checksum"
Expand Down Expand Up @@ -159,16 +155,10 @@ tasks:
PATH="{{.G_NODEJS_14_BIN_DIR}}":$PATH npm install
- >-
rsync -a
"{{.G_LOG_VIEWER_WEBUI_BUILD_DIR}}/client"
"{{.G_LOG_VIEWER_WEBUI_BUILD_DIR}}/yscope-log-viewer"
"{{.OUTPUT_DIR}}/var/www/log_viewer_webui/"
"{{.G_LOG_VIEWER_WEBUI_BUILD_DIR}}/"
"{{.OUTPUT_DIR}}/var/www/log-viewer-webui"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note log_viewer_webui is renamed as log-viewer-webui here.

- |-
cd components/log-viewer-webui/server/
rsync -a \
package.json package-lock.json settings.json src \
"{{.OUTPUT_DIR}}/var/www/log_viewer_webui/server/"
- |-
cd "{{.OUTPUT_DIR}}/var/www/log_viewer_webui/server"
cd "{{.OUTPUT_DIR}}/var/www/log-viewer-webui/server"
PATH="{{.G_NODEJS_22_BIN_DIR}}":$PATH npm clean-install
# This command must be last
- task: "utils:compute-checksum"
Expand Down Expand Up @@ -217,7 +207,7 @@ tasks:
vars:
COMPONENT: "{{.TASK}}"

log-viewer-webui-clients:
log-viewer-webui:
vars:
CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK}}.md5"
OUTPUT_DIR: "{{.G_LOG_VIEWER_WEBUI_BUILD_DIR}}"
Expand All @@ -228,6 +218,11 @@ tasks:
- "client/src/**/*.css"
- "client/src/**/*.jsx"
- "client/src/webpack.config.js"
- "server/package.json"
- "server/package-lock.json"
- "server/settings.json"
- "server/src/**/*.ts"
- "server/tsconfig.json"
- "yscope-log-viewer/package.json"
- "yscope-log-viewer/public/**/*"
- "yscope-log-viewer/src/**/*"
Expand All @@ -245,6 +240,14 @@ tasks:
DATA_DIR: "{{.OUTPUT_DIR}}"
cmds:
- "rm -rf '{{.OUTPUT_DIR}}'"
- "mkdir -p '{{.OUTPUT_DIR}}'"
- |-
cd "server"
rsync -a \
package.json package-lock.json \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stupid question, don't we need to sync "src" as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not at all. How TypeScript compilation works is that the compiler performs type-checking then transpiles the TypeScript code into JavaScript code.

After we run npm run build to perform the compilation, the JS code would have been the dist folder and the sources stored in src can be thrown away.

"{{.OUTPUT_DIR}}/server/"
PATH="{{.G_NODEJS_22_BIN_DIR}}":$PATH npm run build -- \
--outDir "{{.OUTPUT_DIR}}/server/dist"
- for:
- "client"
- "yscope-log-viewer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,10 @@ def start_log_viewer_webui(
if container_exists(container_name):
return

container_log_viewer_webui_dir = CONTAINER_CLP_HOME / "var" / "www" / "log_viewer_webui"
container_log_viewer_webui_dir = CONTAINER_CLP_HOME / "var" / "www" / "log-viewer-webui"
node_path = str(container_log_viewer_webui_dir / "server" / "node_modules")
settings_json_path = (
get_clp_home() / "var" / "www" / "log_viewer_webui" / "server" / "settings.json"
get_clp_home() / "var" / "www" / "log-viewer-webui" / "server" / "dist" / "settings.json"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings.json is now part of the build assets so the path is changed.

)

validate_log_viewer_webui_config(clp_config, settings_json_path)
Expand Down Expand Up @@ -959,7 +959,7 @@ def start_log_viewer_webui(

node_cmd = [
str(CONTAINER_CLP_HOME / "bin" / "node-22"),
str(container_log_viewer_webui_dir / "server" / "src" / "main.js"),
str(container_log_viewer_webui_dir / "server" / "dist" / "src" / "main.js"),
]
cmd = container_cmd + node_cmd
subprocess.run(cmd, stdout=subprocess.DEVNULL, check=True)
Expand Down
Loading
Loading