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

revert: build: compile/watch sass with new npm scripts #34473

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
75 changes: 75 additions & 0 deletions openedx/core/djangoapps/theming/paver_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""
This file contains helpers for paver commands, Django is not initialized in paver commands.
So, django settings, models etc. can not be used here.
"""


import os

from path import Path


def get_theme_paths(themes, theme_dirs):
"""
get absolute path for all the given themes, if a theme is no found
at multiple places than all paths for the theme will be included.
If a theme is not found anywhere then theme will be skipped with
an error message printed on the console.

If themes is 'None' then all themes in given dirs are returned.

Args:
themes (list): list of all theme names
theme_dirs (list): list of base dirs that contain themes
Returns:
list of absolute paths to themes.
"""
theme_paths = []

for theme in themes:
theme_base_dirs = get_theme_base_dirs(theme, theme_dirs)
if not theme_base_dirs:
print((
"\033[91m\nSkipping '{theme}': \n"
"Theme ({theme}) not found in any of the theme dirs ({theme_dirs}). \033[00m".format(
theme=theme,
theme_dirs=", ".join(theme_dirs)
),
))
theme_paths.extend(theme_base_dirs)

return theme_paths


def get_theme_base_dirs(theme, theme_dirs):
"""
Get all base dirs where the given theme can be found.

Args:
theme (str): name of the theme to find
theme_dirs (list): list of all base dirs where the given theme could be found

Returns:
list of all the dirs for the goven theme
"""
theme_paths = []
for _dir in theme_dirs:
for dir_name in {theme}.intersection(os.listdir(_dir)):
if is_theme_dir(Path(_dir) / dir_name):
theme_paths.append(Path(_dir) / dir_name)
return theme_paths


def is_theme_dir(_dir):
"""
Returns true if given dir contains theme overrides.
A theme dir must have subdirectory 'lms' or 'cms' or both.

Args:
_dir: directory path to check for a theme

Returns:
Returns true if given dir is a theme directory.
"""
theme_sub_directories = {'lms', 'cms'}
return bool(os.path.isdir(_dir) and theme_sub_directories.intersection(os.listdir(_dir)))
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"repository": "https://github.com/openedx/edx-platform",
"scripts": {
"postinstall": "scripts/copy-node-modules.sh",
"build": "npm run webpack && npm run compile-sass",
"build-dev": "npm run webpack-dev && npm run compile-sass-dev",
"build": "echo 'WARNING: `npm run build` in edx-platform is experimental. Use at your own risk.' && npm run webpack && npm run compile-sass",
"build-dev": "echo 'WARNING: `npm run build-dev` in edx-platform is experimental. Use at your own risk.' && npm run webpack-dev && npm run compile-sass-dev",
"webpack": "NODE_ENV=${NODE_ENV:-production} \"$(npm bin)/webpack\" --config=${WEBPACK_CONFIG_PATH:-webpack.prod.config.js}",
"webpack-dev": "NODE_ENV=development \"$(npm bin)/webpack\" --config=webpack.dev.config.js",
"compile-sass": "scripts/compile_sass.py --env=${NODE_ENV:-production}",
"compile-sass-dev": "scripts/compile_sass.py --env=development",
"watch": "{ npm run watch-webpack& npm run watch-sass& } && sleep infinity",
"watch": "echo 'WARNING: `npm run watch` in edx-platform is experimental. Use at your own risk.' && { npm run watch-webpack& npm run watch-sass& } && sleep infinity",
"watch-webpack": "npm run webpack-dev -- --watch",
"watch-sass": "scripts/watch_sass.sh"
},
Expand Down
Loading
Loading