@openedx/paragon 23.21.1 → 23.21.3
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.
package/bin/paragon-scripts.js
CHANGED
|
@@ -192,7 +192,10 @@ const COMMANDS = {
|
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
name: '--defaultThemeVariants',
|
|
195
|
-
description: `Specifies
|
|
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(
|
|
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
|
|
181
|
-
fs.readdirSync(themesPath, { withFileTypes: true })
|
|
182
|
-
.filter((item) => item.isDirectory())
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
@@ -311,10 +311,9 @@ const initializeStyleDictionary = async ({ themes }) => {
|
|
|
311
311
|
format: async ({ dictionary, file, options = {} }) => {
|
|
312
312
|
const { fileHeader } = await getStyleDictionaryUtils();
|
|
313
313
|
const { formatting } = options;
|
|
314
|
-
const { breakpoint } = dictionary.tokens.size;
|
|
315
314
|
|
|
316
315
|
let customMediaVariables = '';
|
|
317
|
-
const breakpoints = Object.values(breakpoint || {});
|
|
316
|
+
const breakpoints = Object.values(dictionary.tokens?.size?.breakpoint || {});
|
|
318
317
|
|
|
319
318
|
for (let i = 0; i < breakpoints.length; i++) {
|
|
320
319
|
const [currentBreakpoint, nextBreakpoint] = [breakpoints[i], breakpoints[i + 1]];
|