From a6949e9991fe3e21c95a979554e4c7b1aa00c10f Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 23 Jul 2026 10:43:04 +0000 Subject: [PATCH] chore: update Makefile for local translation configurations --- Makefile | 91 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 18d1049..bfa8676 100644 --- a/Makefile +++ b/Makefile @@ -1,54 +1,65 @@ -intl_imports = ./node_modules/.bin/intl-imports.js -transifex_utils = ./node_modules/.bin/transifex-utils.js -i18n = ./src/i18n -transifex_input = $(i18n)/transifex_input.json +TURBO = TURBO_TELEMETRY_DISABLED=1 turbo --dangerously-disable-package-manager-check -# This directory must match .babelrc . -transifex_temp = ./temp/babel-plugin-formatjs - -build: - rm -rf ./dist - ./node_modules/.bin/fedx-scripts babel src --out-dir dist --source-maps --ignore **/*.test.jsx,**/*.test.js,**/setupTest.jsx --copy-files - @# --copy-files will bring in everything else that wasn't processed by babel. Remove what we don't want. - @find dist -name '*.test.js*' -delete - cp ./package.json ./dist/package.json - cp ./LICENSE ./dist/LICENSE - cp ./README.rst ./dist/README.rst - -precommit: - npm run lint - npm audit +# Variables for additional translation sources and imports (define in local deployment if needed) +ATLAS_EXTRA_SOURCES ?= +ATLAS_EXTRA_INTL_IMPORTS ?= +ATLAS_OPTIONS ?= +.PHONY: requirements requirements: npm ci +clean: + rm -rf dist + +build: + tsc --project tsconfig.build.json + find src -type f \( -name '*.scss' -o -path '*/assets/*' \) -exec sh -c '\ + for f in "$$@"; do \ + d="dist/$${f#src/}"; \ + mkdir -p "$$(dirname "$$d")"; \ + cp "$$f" "$$d"; \ + done' sh {} + + tsc-alias -p tsconfig.build.json + +build-ci: + SITE_CONFIG_PATH=site.config.ci.tsx openedx build + +# turbo.site.json is the standalone turbo config for this package. It is +# renamed to avoid conflicts with turbo v2's workspace validation, which +# rejects root task syntax (//#) and requires "extends" in package-level +# turbo.json files, such as when running in a site repository. The targets +# below copy it into place before running turbo and clean up after. +turbo.json: turbo.site.json + cp $< $@ + +# NPM doesn't bin-link workspace packages during install, so it must be done manually. +bin-link: + [ -f packages/frontend-base/package.json ] && npm rebuild --ignore-scripts @openedx/frontend-base || true + +build-packages: turbo.json + $(TURBO) run build; rm -f turbo.json + $(MAKE) bin-link + +clean-packages: turbo.json + $(TURBO) run clean; rm -f turbo.json + +dev-packages: build-packages turbo.json + $(TURBO) run watch:build dev:site; rm -f turbo.json + +dev-site: bin-link + npm run dev + i18n.extract: - # Pulling display strings from .jsx files into .json files... - rm -rf $(transifex_temp) npm run-script i18n_extract -i18n.concat: - # Gathering JSON messages into one file... - $(transifex_utils) $(transifex_temp) $(transifex_input) +extract_translations: | requirements i18n.extract -extract_translations: | requirements i18n.extract i18n.concat +pull_translations: | requirements + ATLAS_EXTRA_INTL_IMPORTS="$(ATLAS_EXTRA_INTL_IMPORTS)" npm run translations:pull -- --atlas-options="$(strip $(ATLAS_OPTIONS) $(ATLAS_EXTRA_SOURCES))" -# Despite the name, we actually need this target to detect changes in the incoming translated message files as well. detect_changed_source_translations: - # Checking for changed translations... - git diff --exit-code $(i18n) - -# Pulls translations using atlas. -pull_translations: - mkdir src/i18n/messages - cd src/i18n/messages \ - && atlas pull $(ATLAS_OPTIONS) \ - translations/frontend-platform/src/i18n/messages:frontend-platform \ - translations/paragon/src/i18n/messages:paragon \ - translations/frontend-plugin-notifications/src/i18n/messages:frontend-plugin-notifications - - $(intl_imports) frontend-platform paragon frontend-plugin-notifications + git diff --exit-code ./src/i18n validate-no-uncommitted-package-lock-changes: - # Checking for package-lock.json changes... git diff --exit-code package-lock.json