@@ -25,10 +25,6 @@ module.exports = function (plop) {
25
25
const capitalized = camel . charAt ( 0 ) . toUpperCase ( ) + camel . substring ( 1 ) ;
26
26
return capitalized ;
27
27
} ) ;
28
- // name of Spectrum CSS package
29
- plop . setHelper ( 'spectrumCSS' , function ( name ) {
30
- return name . replace ( / - / g, '' ) ;
31
- } ) ;
32
28
// name used as title in storybook and documentation
33
29
plop . setHelper ( 'displayName' , function ( name ) {
34
30
const camel = name . replace ( / - ( [ a - z ] ) / g, ( g ) => {
@@ -40,22 +36,43 @@ module.exports = function (plop) {
40
36
} ) ;
41
37
42
38
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
50
45
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 `
52
47
) ;
48
+ } catch ( error ) {
49
+ // Silently fail, dependencies will need to be added manually
50
+ }
53
51
} ) ;
54
52
55
53
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
+ }
59
76
} ) ;
60
77
61
78
plop . setGenerator ( 'component' , {
@@ -73,17 +90,6 @@ module.exports = function (plop) {
73
90
// Convert the input into kebab case if not provided as such and strip swc- prefixing if present
74
91
filter : ( response ) => kebabCase ( response . replace ( / ^ s p - / , '' ) ) ,
75
92
} ,
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
- } ,
87
93
] ,
88
94
actions : [
89
95
{
@@ -108,8 +114,13 @@ module.exports = function (plop) {
108
114
} ,
109
115
{
110
116
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' ,
113
124
} ,
114
125
{
115
126
type : 'add' ,
0 commit comments