Skip to content

Commit

Permalink
feat!: Restructure theme commands to match new design guidelines (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-yeager authored Nov 26, 2024
1 parent d8bd3d6 commit 83feeab
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion commands/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { i18n } = require('../lib/lang');

const i18nKey = 'commands.theme';

exports.command = 'theme';
exports.command = ['theme', 'themes'];
exports.describe = i18n(`${i18nKey}.describe`);

exports.builder = yargs => {
Expand Down
16 changes: 8 additions & 8 deletions commands/theme/generate-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ const THEME_PATH_REGEX = new RegExp(/=\s*.*(theme\.(\w|\.)*)/, 'i');

const i18nKey = 'commands.theme.subcommands.generateSelectors';

exports.command = 'generate-selectors <themePath>';
exports.command = 'generate-selectors <path>';
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = options => {
const { themePath } = options;
const { path } = options;

const fieldsJsonPath = findFieldsJsonPath(themePath);
const fieldsJsonPath = findFieldsJsonPath(path);
if (!fieldsJsonPath) {
logger.error(i18n(`${i18nKey}.errors.fieldsNotFound`));
process.exit(EXIT_CODES.ERROR);
}

let fieldsJson = JSON.parse(fs.readFileSync(fieldsJsonPath));
let cssString = combineThemeCss(themePath);
let cssString = combineThemeCss(path);

/**
* Creates map of HubL variable names to theme field paths
Expand Down Expand Up @@ -190,7 +190,7 @@ exports.handler = options => {
}

const selectorsMap = generateSelectorsMap(fieldsJson);
const selectorsPath = `${themePath}/editor-preview.json`;
const selectorsPath = `${path}/editor-preview.json`;

fs.writeFileSync(
selectorsPath,
Expand All @@ -199,15 +199,15 @@ exports.handler = options => {

logger.success(
i18n(`${i18nKey}.success`, {
themePath,
themePath: path,
selectorsPath,
})
);
};

exports.builder = yargs => {
yargs.positional('themePath', {
describe: i18n(`${i18nKey}.positionals.themePath.describe`),
yargs.positional('path', {
describe: i18n(`${i18nKey}.positionals.path.describe`),
type: 'string',
});

Expand Down
12 changes: 6 additions & 6 deletions commands/theme/marketplace-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const { i18n } = require('../../lib/lang');

const i18nKey = 'commands.theme.subcommands.marketplaceValidate';

exports.command = 'marketplace-validate <src>';
exports.command = 'marketplace-validate <path>';
exports.describe = i18n(`${i18nKey}.describe`);

exports.handler = async options => {
const { src, derivedAccountId } = options;
const { path, derivedAccountId } = options;

await loadAndValidateOptions(options);

Expand All @@ -32,15 +32,15 @@ exports.handler = async options => {

SpinniesManager.add('marketplaceValidation', {
text: i18n(`${i18nKey}.logs.validatingTheme`, {
path: src,
path,
}),
});

const assetType = 'THEME';
const validationId = await kickOffValidation(
derivedAccountId,
assetType,
src
path
);
await pollForValidationFinish(derivedAccountId, validationId);

Expand All @@ -61,8 +61,8 @@ exports.builder = yargs => {
addAccountOptions(yargs);
addUseEnvironmentOptions(yargs);

yargs.positional('src', {
describe: i18n(`${i18nKey}.positionals.src.describe`),
yargs.positional('path', {
describe: i18n(`${i18nKey}.positionals.path.describe`),
type: 'string',
});
return yargs;
Expand Down
10 changes: 5 additions & 5 deletions lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ en:
update: "The secret \"{{ secretName }}\" was updated in the HubSpot account: {{ accountIdentifier }}"
updateExplanation: "Existing serverless functions will start using this new value within 10 seconds."
theme:
describe: "Commands for working with themes, including marketplace validation with the marketplace-validate subcommand."
describe: "Commands for managing themes."
subcommands:
generateSelectors:
describe: "Automatically generates an editor-preview.json file for the given theme. The selectors this command generates are not perfect, so please edit editor-preview.json after running."
Expand All @@ -866,10 +866,10 @@ en:
noSelectorsFound: "No selectors found."
success: "Selectors generated for {{ themePath }}, please double check the selectors generated at {{ selectorsPath }} before uploading the theme."
positionals:
themePath:
path:
describe: "The path of the theme you'd like to generate an editor-preview.json for."
marketplaceValidate:
describe: "Validate a theme for the marketplace"
describe: "Validate a theme for the marketplace."
errors:
invalidPath: "The path \"{{ path }}\" is not a path to a folder in the Design Manager"
logs:
Expand All @@ -882,10 +882,10 @@ en:
lineNumber: "Line number: {{ line }}"
noErrors: "No errors"
positionals:
src:
path:
describe: "Path to the theme within the Design Manager."
preview:
describe: "Upload and watch a theme directory on your computer for changes and start a local development server to preview theme changes on a site"
describe: "Upload and watch a theme directory on your computer for changes and start a local development server to preview theme changes on a site."
errors:
invalidPath: "The path \"{{ path }}\" is not a path to a directory"
noThemeComponents: "Your project has no theme components available to preview."
Expand Down

0 comments on commit 83feeab

Please sign in to comment.