@@ -25,10 +25,6 @@ module.exports = function (plop) {
2525 const capitalized = camel . charAt ( 0 ) . toUpperCase ( ) + camel . substring ( 1 ) ;
2626 return capitalized ;
2727 } ) ;
28- // name of Spectrum CSS package
29- plop . setHelper ( 'spectrumCSS' , function ( name ) {
30- return name . replace ( / - / g, '' ) ;
31- } ) ;
3228 // name used as title in storybook and documentation
3329 plop . setHelper ( 'displayName' , function ( name ) {
3430 const camel = name . replace ( / - ( [ a - z ] ) / g, ( g ) => {
@@ -40,22 +36,43 @@ module.exports = function (plop) {
4036 } ) ;
4137
4238 plop . setActionType ( 'install deps' , function ( answers ) {
43- execSync (
44- `cd ../../ && yarn lerna add @spectrum-web-components/base --scope=@spectrum-web-components/${ answers . name } --no-bootstrap`
45- ) ;
46- execSync (
47- `cd ../../ && yarn lerna add @spectrum-web-components/${ answers . name } --scope=@spectrum-web-components/bundle --no-bootstrap`
48- ) ;
49- if ( answers . spectrum )
39+ try {
40+ // Add base as a workspace dependency to the new package
41+ execSync (
42+ `cd ../../ && yarn workspace @spectrum-web-components/${ answers . name } add @spectrum-web-components/base@workspace:^`
43+ ) ;
44+ // Add the new package to bundle with a fixed version
5045 execSync (
51- `cd ../../ && yarn lerna add @spectrum-css/ ${ answers . spectrum } --scope= @spectrum-web-components/${ answers . name } --dev --no-bootstrap `
46+ `cd ../../ && yarn workspace @spectrum-web-components/bundle add @spectrum-web-components/${ answers . name } @0.0.1 `
5247 ) ;
48+ } catch ( error ) {
49+ // Silently fail, dependencies will need to be added manually
50+ }
5351 } ) ;
5452
5553 plop . setActionType ( 'format files' , function ( answers ) {
56- execSync (
57- `cd ../../ && yarn prettier --write packages/${ answers . name } && yarn eslint --fix -f pretty packages/${ answers . name } && yarn stylelint --fix packages/${ answers . name } `
58- ) ;
54+ try {
55+ // Run formatters separately so one failing doesn't block the others
56+ execSync (
57+ `cd ../../ && yarn prettier --write packages/${ answers . name } `
58+ ) ;
59+ } catch ( error ) {
60+ // Continue if prettier fails
61+ }
62+ try {
63+ execSync (
64+ `cd ../../ && yarn eslint --fix -f pretty packages/${ answers . name } `
65+ ) ;
66+ } catch ( error ) {
67+ // Continue if eslint fails
68+ }
69+ try {
70+ execSync (
71+ `cd ../../ && yarn stylelint --fix packages/${ answers . name } /src/*.css`
72+ ) ;
73+ } catch ( error ) {
74+ // Continue if stylelint fails
75+ }
5976 } ) ;
6077
6178 plop . setGenerator ( 'component' , {
@@ -73,17 +90,6 @@ module.exports = function (plop) {
7390 // Convert the input into kebab case if not provided as such and strip swc- prefixing if present
7491 filter : ( response ) => kebabCase ( response . replace ( / ^ s p - / , '' ) ) ,
7592 } ,
76- {
77- type : 'input' ,
78- name : 'spectrum' ,
79- message : 'Spectrum CSS package name (i.e. colorarea)' ,
80- // Remove the package prefix if provided and strip out any dashes or spaces in the result
81- filter : ( response ) => {
82- return response
83- . replace ( / ^ \@ s p e c t r u m - c s s \/ / , '' )
84- . replace ( / [ - | \s ] / g, '' ) ;
85- } ,
86- } ,
8793 ] ,
8894 actions : [
8995 {
@@ -108,8 +114,13 @@ module.exports = function (plop) {
108114 } ,
109115 {
110116 type : 'add' ,
111- path : '../../packages/{{name}}/src/spectrum-config.js' ,
112- templateFile : 'plop-templates/spectrum-config.js.hbs' ,
117+ path : '../../packages/{{name}}/src/spectrum-{{name}}.css' ,
118+ templateFile : 'plop-templates/spectrum-component.css.hbs' ,
119+ } ,
120+ {
121+ type : 'add' ,
122+ path : '../../packages/{{name}}/src/{{name}}-overrides.css' ,
123+ templateFile : 'plop-templates/component-overrides.css.hbs' ,
113124 } ,
114125 {
115126 type : 'add' ,
0 commit comments