11/* eslint-disable import/no-commonjs */
22
3+ const { execSync } = require ( 'child_process' ) ;
34const fs = require ( 'fs' ) ;
45const path = require ( 'path' ) ;
56
@@ -19,18 +20,6 @@ module.exports = {
1920 return `yarn publish --access public --tag ${ tag } ` ;
2021 } ,
2122 versionUpdated ( { exec, dir, version } ) {
22- const updatePackageDependencies = ( ...changes ) => {
23- for ( const change of changes ) {
24- const { package, dependencies } = change ;
25-
26- exec (
27- `yarn workspace ${ package } add ${ dependencies
28- . map ( ( dep ) => `"${ dep } "` )
29- . join ( ' ' ) } `
30- ) ;
31- }
32- } ;
33-
3423 // Ship.js reads JSON and writes with `fs.writeFileSync(JSON.stringify(json, null, 2))`
3524 // which causes a lint error in the `lerna.json` file.
3625 exec ( 'yarn eslint lerna.json --fix' ) ;
@@ -42,11 +31,19 @@ module.exports = {
4231 `@algolia/autocomplete-preset-algolia@^${ version } ` ,
4332 ] ,
4433 } ) ;
45-
46- fs . writeFileSync (
47- path . resolve ( dir , 'packages' , 'autocomplete-core' , 'src' , 'version.ts' ) ,
48- `export const version = '${ version } ';\n`
49- ) ;
34+ updatePackagesVersion ( {
35+ version,
36+ files : [
37+ path . resolve ( dir , 'packages' , 'autocomplete-core' , 'src' , 'version.ts' ) ,
38+ path . resolve (
39+ dir ,
40+ 'packages' ,
41+ 'autocomplete-preset-algolia' ,
42+ 'src' ,
43+ 'version.ts'
44+ ) ,
45+ ] ,
46+ } ) ;
5047 } ,
5148 // Skip preparation if it contains only `chore` commits
5249 shouldPrepare : ( { releaseType, commitNumbersPerType } ) => {
@@ -59,3 +56,21 @@ module.exports = {
5956 return true ;
6057 } ,
6158} ;
59+
60+ function updatePackageDependencies ( ...changes ) {
61+ for ( const change of changes ) {
62+ const { package, dependencies } = change ;
63+
64+ execSync (
65+ `yarn workspace ${ package } add ${ dependencies
66+ . map ( ( dep ) => `"${ dep } "` )
67+ . join ( ' ' ) } `
68+ ) ;
69+ }
70+ }
71+
72+ function updatePackagesVersion ( { version, files } ) {
73+ for ( const file of files ) {
74+ fs . writeFileSync ( file , `export const version = '${ version } ';\n` ) ;
75+ }
76+ }
0 commit comments