@openedx/paragon 23.21.0 → 23.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -192,7 +192,10 @@ const COMMANDS = {
192
192
  },
193
193
  {
194
194
  name: '--defaultThemeVariants',
195
- description: `Specifies default theme variants. Defaults to a single 'light' theme variant.
195
+ description: `Specifies which theme variants are marked as defaults in the generated theme-urls.json.
196
+ Consuming applications (Open edX micro-frontends) use theme-urls.json to determine
197
+ which theme CSS files to load; variants listed here are loaded automatically without
198
+ requiring explicit configuration.
196
199
  You can provide multiple default theme variants by passing multiple values, for
197
200
  example: \`--defaultThemeVariants light dark\`
198
201
  `,
@@ -262,6 +265,10 @@ const COMMANDS = {
262
265
  * @function executeParagonCommand
263
266
  */
264
267
  (async () => {
268
+ process.on('SIGINT', () => {
269
+ process.exit(130);
270
+ });
271
+
265
272
  const [command, ...commandArgs] = process.argv.slice(2);
266
273
  const resolvedCommand = commandAliases[command] || command;
267
274
  const executor = COMMANDS[resolvedCommand];
@@ -1,4 +1,7 @@
1
1
  const fs = require('fs');
2
+ const path = require('path');
3
+ const { spawn } = require('child_process');
4
+ const os = require('os');
2
5
  const sass = require('sass');
3
6
 
4
7
  const buildScssCommand = require('../build-scss');
@@ -135,8 +138,8 @@ describe('buildScssCommand', () => {
135
138
  );
136
139
  });
137
140
 
138
- it('should use default arguments when none provided', () => {
139
- buildScssCommand([]);
141
+ it('should use default arguments when none provided', async () => {
142
+ await buildScssCommand([]);
140
143
 
141
144
  expect(sass.compile).toHaveBeenCalledWith(
142
145
  expect.stringContaining('core.scss'),
@@ -144,8 +147,8 @@ describe('buildScssCommand', () => {
144
147
  );
145
148
  });
146
149
 
147
- it('should exclude core properly', () => {
148
- buildScssCommand(['--excludeCore']);
150
+ it('should exclude core properly', async () => {
151
+ await buildScssCommand(['--excludeCore']);
149
152
 
150
153
  expect(sass.compile).not.toHaveBeenCalledWith(
151
154
  expect.stringContaining('core.scss'),
@@ -158,3 +161,25 @@ describe('buildScssCommand', () => {
158
161
  );
159
162
  });
160
163
  });
164
+
165
+ describe('SIGINT handling', () => {
166
+ it('should exit with code 130 when SIGINT is received during build', async () => {
167
+ const child = spawn(process.execPath, [
168
+ path.resolve(__dirname, '../../bin/paragon-scripts.js'),
169
+ 'build-scss',
170
+ `--outDir=${path.join(os.tmpdir(), 'build-scss-sigint-test')}`,
171
+ ], {
172
+ cwd: path.resolve(__dirname, '../..'),
173
+ stdio: 'ignore',
174
+ });
175
+
176
+ const { code, signal } = await new Promise((resolve) => {
177
+ child.on('exit', (exitCode, exitSignal) => resolve({ code: exitCode, signal: exitSignal }));
178
+ setTimeout(() => child.kill('SIGINT'), 500);
179
+ });
180
+
181
+ // Process was terminated by SIGINT — either our handler called process.exit(130)
182
+ // or default signal handling killed it before the handler was registered
183
+ expect(code === 130 || signal === 'SIGINT').toBe(true);
184
+ }, 30000);
185
+ });
@@ -135,7 +135,15 @@ describe('helpCommand', () => {
135
135
  expect(console.log).toHaveBeenCalledWith(
136
136
  expect.stringContaining(`${chalk.yellow.bold('--defaultThemeVariants')} ${chalk.grey('Default: light')}`),
137
137
  );
138
- expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Specifies default theme variants'));
138
+ expect(console.log).toHaveBeenCalledWith(
139
+ expect.stringContaining('Specifies which theme variants are marked as defaults in the generated theme-urls.json.'),
140
+ );
141
+ expect(console.log).toHaveBeenCalledWith(
142
+ expect.stringContaining('Consuming applications (Open edX micro-frontends) use theme-urls.json'),
143
+ );
144
+ expect(console.log).toHaveBeenCalledWith(
145
+ expect.stringContaining('variants listed here are loaded automatically without'),
146
+ );
139
147
  expect(console.log).toHaveBeenCalledWith(expect.stringContaining('You can provide multiple default theme variants'));
140
148
  expect(console.log).toHaveBeenCalledWith(expect.stringContaining('example: `--defaultThemeVariants light dark`'));
141
149
  /* eslint-enable no-console */
package/lib/build-scss.js CHANGED
@@ -177,18 +177,19 @@ function buildScssCommand(commandArgs) {
177
177
  });
178
178
  }
179
179
 
180
- // Theme Variants CSS
181
- fs.readdirSync(themesPath, { withFileTypes: true })
182
- .filter((item) => item.isDirectory())
183
- .forEach((themeDir) => {
184
- compileAndWriteStyleSheets({
185
- name: themeDir.name,
186
- stylesPath: `${themesPath}/${themeDir.name}/index.css`,
187
- outDir,
188
- isThemeVariant: true,
189
- isDefaultThemeVariant: defaultThemeVariants.includes(themeDir.name),
190
- });
180
+ // Theme variants CSS
181
+ const themeDirs = fs.readdirSync(themesPath, { withFileTypes: true })
182
+ .filter((item) => item.isDirectory());
183
+
184
+ for (const themeDir of themeDirs) {
185
+ compileAndWriteStyleSheets({
186
+ name: themeDir.name,
187
+ stylesPath: `${themesPath}/${themeDir.name}/index.css`,
188
+ outDir,
189
+ isThemeVariant: true,
190
+ isDefaultThemeVariant: defaultThemeVariants.includes(themeDir.name),
191
191
  });
192
+ }
192
193
  }
193
194
 
194
195
  module.exports = buildScssCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/paragon",
3
- "version": "23.21.0",
3
+ "version": "23.21.2",
4
4
  "description": "Accessible, responsive UI component library based on Bootstrap.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -74,7 +74,7 @@
74
74
  "commander": "^9.4.1",
75
75
  "email-prop-type": "^3.0.0",
76
76
  "file-selector": "^0.10.0",
77
- "glob": "^10.0.0",
77
+ "glob": "^13.0.0",
78
78
  "inquirer": "^8.2.5",
79
79
  "js-toml": "^1.0.0",
80
80
  "lodash.uniqby": "^4.7.0",