Skip to content

Commit

Permalink
chore: update docs and cli params parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorrusakov committed Oct 27, 2023
1 parent db966ac commit bca0f30
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ The Paragon CLI (Command Line Interface) is a tool that provides various utility

### Available Commands

- `paragon install-theme [theme]`: Installs the specific [@edx/brand](https://github.com/edx/brand-edx.org) package.
- `build-tokens`: Build Paragon's design tokens.
- `replace-variables`: Replace SCSS variables usages or definitions to CSS variables and vice versa in `.scss` files.
- `build-scss`: Compile Paragon's core and themes SCSS into CSS.
- `paragon install-theme [theme]`: Installs the specific [brand package](https://github.com/openedx/brand-openedx).
- `paragon build-tokens`: Build Paragon's design tokens.
- `paragon replace-variables`: Replace SCSS variables usages or definitions to CSS variables and vice versa in `.scss` files.
- `paragon build-scss`: Compile Paragon's core and themes SCSS into CSS.

Use `paragon help` to see more information.

Expand Down
21 changes: 16 additions & 5 deletions lib/build-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@ const { createIndexCssFile } = require('../tokens/utils');
* @param {string|string[]} [commandArgs.themes=['light']] - The themes (variants) for which to build tokens.
*/
async function buildTokensCommand(commandArgs) {
const args = minimist(commandArgs);
const buildDir = args['build-dir'] || args.b || './build/';
const tokensSource = args.source;
const hasSourceTokensOnly = Boolean(args['source-tokens-only']);
const themes = args.themes || args.t || ['light'];
const defaultParams = {
themes: ['light'],
'build-dir': './build/',
};

const alias = {
'build-dir': 'b',
themes: 't',
};

const {
'build-dir': buildDir,
source: tokensSource,
'source-tokens-only': hasSourceTokensOnly,
themes,
} = minimist(commandArgs, { alias, default: defaultParams, boolean: 'source-tokens-only' });

const coreConfig = {
include: [path.resolve(__dirname, '../tokens/src/core/**/*.json')],
Expand Down
18 changes: 13 additions & 5 deletions lib/replace-variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ const mapSCSStoCSS = require('../tokens/map-scss-to-css');
* @param {string} [commandArgs.direction] - The direction of replacement ('forward' or 'backward').
*/
async function replaceVariablesCommand(commandArgs) {
const args = minimist(commandArgs);
const filePath = args.p || args.filePath;
const sourcePath = args.s || args.source;
const replacementType = args.t || args.replacementType;
const direction = args.d || args.direction;
const alias = {
filePath: 'p',
source: 's',
replacementType: 't',
direction: 'd',
};

const {
filePath,
source: sourcePath,
replacementType,
direction,
} = minimist(commandArgs, { alias });

const variablesMap = mapSCSStoCSS(sourcePath);

Expand Down

0 comments on commit bca0f30

Please sign in to comment.