@@ -12,6 +12,22 @@ const {
12
12
13
13
const UPDATE_CONFIGS = require ( './update-dependencies-config' ) ;
14
14
15
+ async function findLGDependencies ( ) {
16
+ const compassComponentsPackageJson = path . join (
17
+ __dirname ,
18
+ '../packages/compass-components/package.json'
19
+ ) ;
20
+ const pkgJson = JSON . parse (
21
+ fs . readFileSync ( compassComponentsPackageJson , 'utf8' )
22
+ ) ;
23
+
24
+ const leafygreenDeps = Object . keys ( pkgJson . dependencies ) . filter ( ( dep ) =>
25
+ dep . startsWith ( '@leafygreen-ui/' )
26
+ ) ;
27
+
28
+ return leafygreenDeps ;
29
+ }
30
+
15
31
async function hoistSharedDependencies ( root , newVersions ) {
16
32
try {
17
33
await withProgress ( 'Cleaning up existing node_modules' , async ( ) => {
@@ -131,17 +147,22 @@ async function main() {
131
147
132
148
if ( args [ 0 ] . startsWith ( 'preset-' ) ) {
133
149
const presetName = args [ 0 ] . replace ( 'preset-' , '' ) ;
134
- dependencies = UPDATE_CONFIGS [ args [ 0 ] . replace ( 'preset-' , '' ) ] ;
135
- if ( ! dependencies ) {
136
- throw new Error (
137
- `Can not find update config for preset "${ presetName } ". Available presets: ${ Object . keys (
138
- UPDATE_CONFIGS
139
- ) . join ( ', ' ) } `
140
- ) ;
150
+
151
+ if ( presetName === 'leafygreen' ) {
152
+ dependencies = await findLGDependencies ( ) ;
153
+ } else {
154
+ dependencies = UPDATE_CONFIGS [ args [ 0 ] . replace ( 'preset-' , '' ) ] ;
155
+ if ( ! dependencies ) {
156
+ throw new Error (
157
+ `Can not find update config for preset "${ presetName } ". Available presets: ${ Object . keys (
158
+ UPDATE_CONFIGS
159
+ ) . join ( ', ' ) } `
160
+ ) ;
161
+ }
162
+ console . log ( ) ;
163
+ console . log ( 'Running update for preset "%s" ...' , presetName ) ;
164
+ console . log ( ) ;
141
165
}
142
- console . log ( ) ;
143
- console . log ( 'Running update for preset "%s" ...' , presetName ) ;
144
- console . log ( ) ;
145
166
} else {
146
167
dependencies = args ;
147
168
}
0 commit comments