@@ -61,6 +61,8 @@ async function main() {
6161 . option ( '--content-scrape <char>' , 'CSS Selector for `body` in resource' )
6262 . option ( '--items-import <char>' , 'import items from a file / site' )
6363 . option ( '--recipe <char>' , 'path to recipe file' )
64+ . option ( '--custom-theme-name <char>' , 'custom theme name' )
65+ . option ( '--custom-theme-template <char>' , 'custom theme template; (options: base, polaris-flex, polaris-sidebar)' )
6466 . version ( await HAXCMS . getHAXCMSVersion ( ) )
6567 . helpCommand ( true ) ;
6668
@@ -119,6 +121,8 @@ async function main() {
119121 . option ( '--content-scrape <char>' , 'CSS Selector for `body` in resource' )
120122 . option ( '--item-import <char>' , 'import items from a file / site' )
121123 . option ( '--recipe <char>' , 'path to recipe file' )
124+ . option ( '--custom-theme-name <char>' , 'custom theme name' )
125+ . option ( '--custom-theme-template <char>' , 'custom theme template (options: base, polaris-flex, polaris-sidebar)' )
122126 . version ( await HAXCMS . getHAXCMSVersion ( ) ) ;
123127 let siteNodeOps = siteNodeOperations ( ) ;
124128 for ( var i in siteNodeOps ) {
@@ -203,6 +207,11 @@ async function main() {
203207 commandRun . options . author = author ;
204208 }
205209 }
210+ // validate theme cli commands
211+ if ( commandRun . options . theme !== 'custom-theme' && ( commandRun . options . customThemeName || commandRun . options . customThemeTemplate ) ) {
212+ program . error ( color . red ( 'ERROR: You can only use the --custom-theme-name option with --theme custom-theme' ) ) ;
213+ }
214+
206215 let packageData = { } ;
207216 let testPackages = [
208217 path . join ( process . cwd ( ) , 'package.json' ) ,
@@ -332,6 +341,15 @@ async function main() {
332341 activeProject = project . type ;
333342 // silly but this way we don't have to take options for quitting
334343 if ( project . type !== 'quit' ) {
344+ // also silly temp spot
345+ let themes = await siteThemeList ( ) ;
346+ const custom = {
347+ value : 'custom-theme' ,
348+ label : 'Create Custom Theme' ,
349+ }
350+ // Append custom option to list of core themes
351+ themes . push ( custom ) ;
352+
335353 project = await p . group (
336354 {
337355 type : ( { results } ) => {
@@ -422,13 +440,6 @@ async function main() {
422440 }
423441 } ,
424442 theme : async ( { results } ) => {
425- let themes = await siteThemeList ( ) ;
426- let custom = {
427- value : 'custom-theme' ,
428- label : 'Create Custom Theme' ,
429- }
430- themes . push ( custom ) ;
431-
432443 if ( results . type === "site" && ! commandRun . options . theme ) {
433444 // support having no theme but autoselecting
434445 if ( commandRun . options . auto && commandRun . options . skip ) {
@@ -444,30 +455,34 @@ async function main() {
444455 }
445456 }
446457 } ,
447- customName ( { results } ) {
458+ customThemeName : async ( { results } ) => {
448459 if ( results . theme === "custom-theme" ) {
449- return p . text ( {
460+ let tmpCustomName = await p . text ( {
450461 message : 'Theme Name:' ,
451- placeholder : results . theme ,
462+ placeholder : ` ${ results . name } ` ,
452463 required : false ,
453464 validate : ( value ) => {
454465 if ( ! value ) {
455- return "Name is required (tab writes default)" ;
466+ return "Theme name is required (tab writes default)" ;
467+ }
468+ if ( themes . some ( theme => theme . value === value ) ) {
469+ return "Theme name is already in use" ;
456470 }
457471 if ( / ^ \d / . test ( value ) ) {
458- return "Name cannot start with a number" ;
472+ return "Theme name cannot start with a number" ;
459473 }
460- if ( value . indexOf ( ' ' ) !== - 1 ) {
461- return "No spaces allowed in project name" ;
474+ if ( / [ A - Z ] / . test ( value ) ) {
475+ return "No uppercase letters allowed in theme name" ;
462476 }
463- if ( value . indexOf ( '-' ) === - 1 && value . indexOf ( '-' ) !== 0 && value . indexOf ( '-' ) !== value . length - 1 ) {
464- return "Name must include at least one `-` and must not start or end name. " ;
477+ if ( value . indexOf ( ' ' ) !== - 1 ) {
478+ return "No spaces allowed in theme name" ;
465479 }
466480 }
467481 } )
482+ return tmpCustomName ;
468483 }
469484 } ,
470- customTemplate ( { results } ) {
485+ customThemeTemplate : ( { results } ) => {
471486 if ( results . theme === "custom-theme" ) {
472487 const options = [
473488 { value : 'base' , label : 'Vanilla Theme with Hearty Documentation' } ,
0 commit comments