-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [BD-46] add paragon-cli (#2460)
Exposes a `paragon` CLI with an `install-theme` command. Example usage in `package.json`: ``` { "scripts": { "start:with-theme": "paragon install-theme && npm start", "build:with-theme": "paragon install-theme && npm run build" } } ``` The Paragon CLI will prompt from which NPM package you wish to install as the `@edx/brand` package (e.g., `@edx/brand-edx.org@latest`), and install it without modifying the `package.json` or `package-lock.json` files. Additional commands will be added to the `paragon` CLI tool in the future.
- Loading branch information
Showing
6 changed files
with
571 additions
and
2,476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const inquirer = require('inquirer'); | ||
const childProcess = require('child_process'); | ||
|
||
function promptUserForTheme() { | ||
return inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'theme', | ||
message: 'What @edx/brand package do you want to install?', | ||
default: '@edx/brand-openedx@latest', | ||
}, | ||
]); | ||
} | ||
|
||
function installTheme(theme) { | ||
const version = theme ? `npm:${theme}` : ''; | ||
|
||
const installCommand = `npm install "@edx/brand@${version}" --no-save`; | ||
|
||
childProcess.execSync(installCommand, { stdio: 'inherit' }); | ||
} | ||
|
||
async function themeCommand() { | ||
const answers = await promptUserForTheme(); | ||
installTheme(answers.theme); | ||
} | ||
|
||
module.exports = themeCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env node | ||
const chalk = require('chalk'); | ||
const themeCommand = require('./install-theme'); | ||
|
||
// command: executor function | ||
const COMMANDS = { | ||
'install-theme': themeCommand, | ||
}; | ||
|
||
(async () => { | ||
const [command] = process.argv.slice(2); | ||
const executor = COMMANDS[command]; | ||
|
||
if (!executor) { | ||
// eslint-disable-next-line no-console | ||
console.log(chalk.red.bold('Unknown command. Usage: paragon <command>')); | ||
return; | ||
} | ||
|
||
try { | ||
await executor(); | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(chalk.red.bold('An error occurred:', error.message)); | ||
process.exit(1); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@import "@edx/brand-openedx/paragon/fonts"; | ||
@import "@edx/brand-openedx/paragon/variables"; | ||
@import "@edx/brand/paragon/fonts"; | ||
@import "@edx/brand/paragon/variables"; | ||
@import "~@edx/paragon/scss/core/core"; | ||
@import "@edx/brand-openedx/paragon/overrides"; | ||
@import "@edx/brand/paragon/overrides"; |
Oops, something went wrong.