Skip to content

Commit 7c65744

Browse files
committed
fix: allow processing edx and openedx brand scope
1 parent c019cc9 commit 7c65744

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

config/data/paragonUtils.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
const path = require('path');
22
const fs = require('fs');
33

4+
/**
5+
* Retrieves the name of the brand package from the dependencies in the application.
6+
*
7+
* @param {string} dir - The root path of the application.
8+
* @returns {string | undefined} The name of the brand package, or undefined if not found.
9+
*/
10+
function getBrandPackageName(dir) {
11+
const appDependencies = JSON.parse(fs.readFileSync(path.resolve(dir, 'package.json'), 'utf-8')).dependencies;
12+
return Object.keys(appDependencies).find((key) => key.match(/@(open)?edx\/brand/));
13+
}
14+
415
/**
516
* Attempts to extract the Paragon version from the `node_modules` of
617
* the consuming application.
@@ -9,7 +20,7 @@ const fs = require('fs');
920
* @returns {string} Paragon dependency version of the consuming application
1021
*/
1122
function getParagonVersion(dir, { isBrandOverride = false } = {}) {
12-
const npmPackageName = isBrandOverride ? '@openedx/brand' : '@openedx/paragon';
23+
const npmPackageName = isBrandOverride ? getBrandPackageName(dir) : '@openedx/paragon';
1324
const pathToPackageJson = `${dir}/node_modules/${npmPackageName}/package.json`;
1425
if (!fs.existsSync(pathToPackageJson)) {
1526
return undefined;
@@ -44,7 +55,7 @@ function getParagonVersion(dir, { isBrandOverride = false } = {}) {
4455
* @returns {ParagonThemeCss}
4556
*/
4657
function getParagonThemeCss(dir, { isBrandOverride = false } = {}) {
47-
const npmPackageName = isBrandOverride ? '@openedx/brand' : '@openedx/paragon';
58+
const npmPackageName = isBrandOverride ? getBrandPackageName(dir) : '@openedx/paragon';
4859
const pathToParagonThemeOutput = path.resolve(dir, 'node_modules', npmPackageName, 'dist', 'theme-urls.json');
4960

5061
if (!fs.existsSync(pathToParagonThemeOutput)) {

config/webpack.common.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ module.exports = {
2525
/**
2626
* The entry points for the brand theme CSS. Example: ```
2727
* {
28-
* "paragon.theme.core": "/path/to/node_modules/@openedx/brand/dist/core.min.css",
29-
* "paragon.theme.variants.light": "/path/to/node_modules/@openedx/brand/dist/light.min.css"
28+
* "paragon.theme.core": "/path/to/node_modules/@(open)edx/brand/dist/core.min.css",
29+
* "paragon.theme.variants.light": "/path/to/node_modules/@(open)edx/brand/dist/light.min.css"
3030
* }
3131
*/
3232
...getParagonEntryPoints(brandThemeCss),

config/webpack.dev.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = merge(commonConfig, {
109109
test: /(.scss|.css)$/,
110110
oneOf: [
111111
{
112-
resource: /(@openedx\/paragon|@openedx\/brand)/,
112+
resource: /(@openedx\/paragon|@(open)?edx\/brand)/,
113113
use: [
114114
MiniCssExtractPlugin.loader,
115115
...getStyleUseConfig(),

0 commit comments

Comments
 (0)