diff --git a/Taskfile.yml b/Taskfile.yml index edce5c074..2e3422168 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -10,6 +10,7 @@ vars: G_BUILD_DIR: "{{.ROOT_DIR}}/build" G_CORE_COMPONENT_BUILD_DIR: "{{.G_BUILD_DIR}}/core" G_METEOR_BUILD_DIR: "{{.G_BUILD_DIR}}/meteor" + G_NODEJS_22_DIR: "{{.G_BUILD_DIR}}/nodejs-22" G_PACKAGE_BUILD_DIR: "{{.G_BUILD_DIR}}/clp-package" G_PACKAGE_VENV_DIR: "{{.G_BUILD_DIR}}/package-venv" G_WEBUI_BUILD_DIR: "{{.G_BUILD_DIR}}/webui" @@ -26,6 +27,7 @@ tasks: clean: cmds: - "rm -rf '{{.G_BUILD_DIR}}'" + - task: "clean-log-viewer-webui" - task: "clean-python-component" vars: COMPONENT: "clp-package-utils" @@ -35,6 +37,18 @@ tasks: - task: "clean-python-component" vars: COMPONENT: "job-orchestration" + - task: "clean-webui" + + clean-log-viewer-webui: + cmds: + - "rm -rf 'components/log-viewer-webui/client/node_modules'" + - "rm -rf 'components/log-viewer-webui/node_modules'" + - "rm -rf 'components/log-viewer-webui/server/node_modules'" + + clean-webui: + cmds: + - "rm -rf 'components/webui/.meteor/local'" + - "rm -rf 'components/webui/node_modules'" clp-json-pkg-tar: cmds: @@ -204,6 +218,19 @@ tasks: - "tests/**/*" generates: ["{{.CHECKSUM_FILE}}"] + nodejs-22: + internal: true + vars: + CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK}}.md5" + OUTPUT_DIR: "{{.G_NODEJS_22_DIR}}" + run: "once" + cmds: + - task: "nodejs" + vars: + CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" + NODEJS_VERSION: "v22.4.0" + OUTPUT_DIR: "{{.OUTPUT_DIR}}" + webui-nodejs: internal: true vars: @@ -274,6 +301,78 @@ tasks: sources: ["{{.TASKFILE}}"] generates: ["{{.CHECKSUM_FILE}}"] + # NOTE: The log-viewer-webui has three different node_modules directories (client, server, and the + # top-level one we call "package"), meaning we have to create three different checksums. To allow + # tasks which depend on this task to only have to check one checksum file, we concatenate the + # three checksum files into one. + log-viewer-webui-node-modules: + internal: true + vars: + # Checksum files + CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK}}.md5" + CLIENT_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/log-viewer-webui-client-node-modules.md5" + PACKAGE_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/log-viewer-webui-package-node-modules.md5" + SERVER_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/log-viewer-webui-server-node-modules.md5" + + # Directories + SRC_DIR: "{{.TASKFILE_DIR}}/components/log-viewer-webui" + CLIENT_OUTPUT_DIR: "{{.SRC_DIR}}/client/node_modules" + PACKAGE_OUTPUT_DIR: "{{.SRC_DIR}}/node_modules" + SERVER_OUTPUT_DIR: "{{.SRC_DIR}}/server/node_modules" + dir: "{{.SRC_DIR}}" + deps: + - "nodejs-22" + - task: "utils:validate-checksum" + vars: + CHECKSUM_FILE: "{{.CLIENT_CHECKSUM_FILE}}" + DATA_DIR: "{{.CLIENT_OUTPUT_DIR}}" + - task: "utils:validate-checksum" + vars: + CHECKSUM_FILE: "{{.SERVER_CHECKSUM_FILE}}" + DATA_DIR: "{{.SERVER_OUTPUT_DIR}}" + - task: "utils:validate-checksum" + vars: + CHECKSUM_FILE: "{{.PACKAGE_CHECKSUM_FILE}}" + DATA_DIR: "{{.PACKAGE_OUTPUT_DIR}}" + cmds: + - "rm -f {{.CHECKSUM_FILE}}" + - task: "clean-log-viewer-webui" + - "PATH='{{.G_NODEJS_22_DIR}}/bin':$PATH npm run init" + # These commands must be last + - task: "utils:compute-checksum" + vars: + DATA_DIR: "{{.CLIENT_OUTPUT_DIR}}" + OUTPUT_FILE: "{{.CLIENT_CHECKSUM_FILE}}" + - task: "utils:compute-checksum" + vars: + DATA_DIR: "{{.PACKAGE_OUTPUT_DIR}}" + OUTPUT_FILE: "{{.PACKAGE_CHECKSUM_FILE}}" + - task: "utils:compute-checksum" + vars: + DATA_DIR: "{{.SERVER_OUTPUT_DIR}}" + OUTPUT_FILE: "{{.SERVER_CHECKSUM_FILE}}" + # This command must be last + - >- + cat + "{{.CLIENT_CHECKSUM_FILE}}" + "{{.PACKAGE_CHECKSUM_FILE}}" + "{{.SERVER_CHECKSUM_FILE}}" + > "{{.CHECKSUM_FILE}}" + sources: + - "{{.G_BUILD_DIR}}/nodejs-22.md5" + - "{{.TASKFILE}}" + - "client/package.json" + - "client/package-lock.json" + - "package.json" + - "package-lock.json" + - "server/package.json" + - "server/package-lock.json" + generates: + - "{{.CHECKSUM_FILE}}" + - "{{.CLIENT_CHECKSUM_FILE}}" + - "{{.PACKAGE_CHECKSUM_FILE}}" + - "{{.SERVER_CHECKSUM_FILE}}" + meteor: run: "once" preconditions: diff --git a/docs/src/dev-guide/components-log-viewer-webui.md b/docs/src/dev-guide/components-log-viewer-webui.md index e1facc232..463d67c78 100644 --- a/docs/src/dev-guide/components-log-viewer-webui.md +++ b/docs/src/dev-guide/components-log-viewer-webui.md @@ -50,13 +50,31 @@ npm test ## Linting -To check for linting errors in either the client or server: +You can lint this component either as part of the entire project or as a standalone component. + +### Lint as part of the project + +To check for linting errors: + +```shell +task lint:js-check +``` + +To also fix linting errors (if applicable): + +```shell +task lint:js-fix +``` + +### Lint the component alone + +To check for linting errors: ```shell npm run lint:check ``` -To also fix linting errors (if possible): +To also fix linting errors (if applicable): ```shell npm run lint:fix diff --git a/lint-tasks.yml b/lint-tasks.yml index 996b49734..075ee2ec8 100644 --- a/lint-tasks.yml +++ b/lint-tasks.yml @@ -1,9 +1,10 @@ version: "3" vars: - G_LINTER_NODEJS_BUILD_DIR: "{{.G_BUILD_DIR}}/linter-nodejs" - G_LINTER_NODEJS_BIN_DIR: "{{.G_LINTER_NODEJS_BUILD_DIR}}/bin" G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv" + G_LOG_VIEWER_WEBUI_SRC_DIR: "{{.ROOT_DIR}}/components/log-viewer-webui" + G_NODEJS_22_BIN_DIR: "{{.G_NODEJS_22_DIR}}/bin" + G_WEBUI_SRC_DIR: "{{.ROOT_DIR}}/components/webui" tasks: check: @@ -47,29 +48,34 @@ tasks: sources: *cpp_source_files js-check: - dir: "components/webui" cmds: - task: "js" vars: LINT_CMD: "check" sources: &js_source_files - "{{.G_BUILD_DIR}}/lint#linter-node-modules.md5" + - "{{.G_BUILD_DIR}}/log-viewer-webui-node-modules.md5" - "{{.G_BUILD_DIR}}/webui-node-modules.md5" + - "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/client/src/**/*.css" + - "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/client/src/**/*.jsx" + - "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/client/src/package.json" + - "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/client/src/webpack.config.js" + - "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/server/src/**/*.js" + - "{{.G_LOG_VIEWER_WEBUI_SRC_DIR}}/server/src/**/package.json" + - "{{.G_WEBUI_SRC_DIR}}/client/**/*.js" + - "{{.G_WEBUI_SRC_DIR}}/client/**/*.jsx" + - "{{.G_WEBUI_SRC_DIR}}/imports/**/*.js" + - "{{.G_WEBUI_SRC_DIR}}/imports/**/*.jsx" + - "{{.G_WEBUI_SRC_DIR}}/launcher.js" + - "{{.G_WEBUI_SRC_DIR}}/package.json" + - "{{.G_WEBUI_SRC_DIR}}/server/**/*.js" + - "{{.G_WEBUI_SRC_DIR}}/server/**/*.jsx" + - "{{.G_WEBUI_SRC_DIR}}/tests/**/*.js" + - "{{.G_WEBUI_SRC_DIR}}/tests/**/*.jsx" - "{{.ROOT_DIR}}/Taskfile.yml" - "{{.TASKFILE}}" - - "client/**/*.js" - - "client/**/*.jsx" - - "imports/**/*.js" - - "imports/**/*.jsx" - - "launcher.js" - - "package.json" - - "server/**/*.js" - - "server/**/*.jsx" - - "tests/**/*.js" - - "tests/**/*.jsx" js-fix: - dir: "components/webui" cmds: - task: "js" vars: @@ -127,10 +133,14 @@ tasks: internal: true requires: vars: ["LINT_CMD"] - deps: ["linter-node-modules"] - dir: "components/webui" + deps: [":log-viewer-webui-node-modules", "linter-node-modules"] cmds: - - "PATH='{{.G_LINTER_NODEJS_BIN_DIR}}':$PATH npm run 'lint:{{.LINT_CMD}}'" + - for: + - "components/log-viewer-webui" + - "components/webui" + cmd: |- + cd "{{.ITEM}}" + PATH="{{.G_NODEJS_22_BIN_DIR}}":$PATH npm run "lint:{{.LINT_CMD}}" py: internal: true @@ -149,18 +159,6 @@ tasks: black --color --line-length 100 {{.BLACK_FLAGS}} . ruff check {{.RUFF_FLAGS}} . - linter-nodejs: - internal: true - vars: - CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK | replace \":\" \"#\"}}.md5" - OUTPUT_DIR: "{{.G_LINTER_NODEJS_BUILD_DIR}}" - cmds: - - task: ":nodejs" - vars: - CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" - NODEJS_VERSION: "latest" - OUTPUT_DIR: "{{.OUTPUT_DIR}}" - linter-node-modules: internal: true deps: @@ -170,7 +168,7 @@ tasks: vars: CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" DATA_DIR: "{{.OUTPUT_DIR}}" - - "linter-nodejs" + - ":nodejs-22" dir: "{{.WEBUI_LINTER_DIR}}" vars: WEBUI_LINTER_DIR: "{{.ROOT_DIR}}/components/webui/linter" @@ -178,14 +176,14 @@ tasks: CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK | replace \":\" \"#\"}}.md5" cmds: - "rm -rf '{{.OUTPUT_DIR}}'" - - "PATH='{{.G_LINTER_NODEJS_BIN_DIR}}':$PATH npm update" + - "PATH='{{.G_NODEJS_22_BIN_DIR}}':$PATH npm update" # This command must be last - task: ":utils:compute-checksum" vars: DATA_DIR: "{{.OUTPUT_DIR}}" OUTPUT_FILE: "{{.CHECKSUM_FILE}}" sources: - - "{{.G_BUILD_DIR}}/lint#linter-nodejs.md5" + - "{{.G_BUILD_DIR}}/nodejs-22.md5" - "{{.G_BUILD_DIR}}/webui-node-modules.md5" - "{{.ROOT_DIR}}/Taskfile.yml" - "{{.TASKFILE}}"