@@ -45,11 +45,10 @@ program
4545 switch ( templateVersion ) {
4646 case "stable" :
4747 files [ "shopify-cli.rb" ] = ( await readFile ( path . join ( outputDirectory , "shopify-cli.rb" ) ) ) . toString ( )
48- // Only keep the @3 versioned formula up to date while we are on major version 3.
49- // Once we move to v4+, shopify-cli@3.rb stays frozen at the last 3.x release.
50- if ( majorVersion === 3 ) {
51- files [ "shopify-cli@3.rb" ] = ( await readFile ( path . join ( outputDirectory , "shopify-cli@3.rb" ) ) ) . toString ( )
52- }
48+ // Always keep the versioned formula for the current major up to date.
49+ // When we bump to the next major, the previous major's formula naturally
50+ // freezes at its last release since we stop updating it.
51+ files [ `shopify-cli@${ majorVersion } .rb` ] = await renderVersionedFormula ( majorVersion , homebrewVariables )
5352 break
5453 case "pre" :
5554 files [ "shopify-cli-pre.rb" ] = ( await readFile ( path . join ( outputDirectory , "shopify-cli-pre.rb" ) ) ) . toString ( )
@@ -115,6 +114,13 @@ function getTemplateVersion(version) {
115114 throw `Unrecognized version string ${ version } `
116115}
117116
117+ async function renderVersionedFormula ( majorVersion , variables ) {
118+ const engine = new Liquid ( { root : packagingDirectory } )
119+ const templatePath = path . join ( packagingDirectory , "stable/src/shopify-cli.rb.liquid" )
120+ const content = ( await readFile ( templatePath ) ) . toString ( )
121+ return engine . render ( engine . parse ( content ) , { ...variables , formulaVersion : String ( majorVersion ) } )
122+ }
123+
118124async function getHomebrewVariables ( cliVersion ) {
119125 const [ cliTarball , cliSha ] = await getTarballAndShaForPackage ( '@shopify/cli' , cliVersion )
120126 return { cliTarball, cliSha}
0 commit comments