@@ -11,6 +11,8 @@ const packages = [
1111 'core' ,
1212 'docs' ,
1313 'angular' ,
14+ 'packages/react' ,
15+ 'packages/react-router'
1416] ;
1517
1618function readPkg ( project ) {
@@ -36,33 +38,47 @@ function checkGit(tasks) {
3638 tasks . push (
3739 {
3840 title : 'Check current branch' ,
39- task : ( ) => execa . stdout ( 'git' , [ 'symbolic-ref' , '--short' , 'HEAD' ] ) . then ( branch => {
40- if ( branch . indexOf ( 'release' ) === - 1 && branch . indexOf ( 'hotfix' ) === - 1 ) {
41- throw new Error ( `Must be on a "release" or "hotfix" branch.` ) ;
42- }
43- } )
41+ task : ( ) =>
42+ execa . stdout ( 'git' , [ 'symbolic-ref' , '--short' , 'HEAD' ] ) . then ( branch => {
43+ if ( branch . indexOf ( 'release' ) === - 1 && branch . indexOf ( 'hotfix' ) === - 1 ) {
44+ throw new Error ( `Must be on a "release" or "hotfix" branch.` ) ;
45+ }
46+ } )
4447 } ,
4548 {
4649 title : 'Check local working tree' ,
47- task : ( ) => execa . stdout ( 'git' , [ 'status' , '--porcelain' ] ) . then ( status => {
48- if ( status !== '' ) {
49- throw new Error ( `Unclean working tree. Commit or stash changes first.` ) ;
50- }
51- } )
50+ task : ( ) =>
51+ execa . stdout ( 'git' , [ 'status' , '--porcelain' ] ) . then ( status => {
52+ if ( status !== '' ) {
53+ throw new Error ( `Unclean working tree. Commit or stash changes first.` ) ;
54+ }
55+ } )
5256 } ,
5357 {
5458 title : 'Check remote history' ,
55- task : ( ) => execa . stdout ( 'git' , [ 'rev-list' , '--count' , '--left-only' , '@{u}...HEAD' ] ) . then ( result => {
56- if ( result !== '0' ) {
57- throw new Error ( `Remote history differs. Please pull changes.` ) ;
58- }
59- } )
59+ task : ( ) =>
60+ execa . stdout ( 'git' , [ 'rev-list' , '--count' , '--left-only' , '@{u}...HEAD' ] ) . then ( result => {
61+ if ( result !== '0' ) {
62+ throw new Error ( `Remote history differs. Please pull changes.` ) ;
63+ }
64+ } )
6065 }
6166 ) ;
6267}
6368
64- const isValidVersion = input => Boolean ( semver . valid ( input ) ) ;
69+ function checkTestDist ( tasks ) {
70+ tasks . push ( {
71+ title : 'Check dist folders for required files' ,
72+ task : ( ) =>
73+ execa . stdout ( 'node' , [ '.scripts/test-dist.js' ] ) . then ( status => {
74+ if ( status . indexOf ( '✅ test.dist' ) === - 1 ) {
75+ throw new Error ( `Test Dist did not find some required files` ) ;
76+ }
77+ } )
78+ } ) ;
79+ }
6580
81+ const isValidVersion = input => Boolean ( semver . valid ( input ) ) ;
6682
6783function preparePackage ( tasks , package , version , install ) {
6884 const projectRoot = projectPath ( package ) ;
@@ -74,15 +90,17 @@ function preparePackage(tasks, package, version, install) {
7490 title : `${ pkg . name } : validate new version` ,
7591 task : ( ) => {
7692 if ( ! isVersionGreater ( pkg . version , version ) ) {
77- throw new Error ( `New version \`${ version } \` should be higher than current version \`${ pkg . version } \`` ) ;
93+ throw new Error (
94+ `New version \`${ version } \` should be higher than current version \`${ pkg . version } \``
95+ ) ;
7896 }
7997 }
8098 } ) ;
8199 if ( install ) {
82100 projectTasks . push ( {
83101 title : `${ pkg . name } : install npm dependencies` ,
84102 task : async ( ) => {
85- await fs . remove ( path . join ( projectRoot , 'node_modules' ) )
103+ await fs . remove ( path . join ( projectRoot , 'node_modules' ) ) ;
86104 await execa ( 'npm' , [ 'i' ] , { cwd : projectRoot } ) ;
87105 }
88106 } ) ;
@@ -95,6 +113,13 @@ function preparePackage(tasks, package, version, install) {
95113 title : `${ pkg . name } : npm link @ionic/core` ,
96114 task : ( ) => execa ( 'npm' , [ 'link' , '@ionic/core' ] , { cwd : projectRoot } )
97115 } ) ;
116+
117+ if ( package === 'packages/react-router' ) {
118+ projectTasks . push ( {
119+ title : `${ pkg . name } : npm link @ionic/react` ,
120+ task : ( ) => execa ( 'npm' , [ 'link' , '@ionic/react' ] , { cwd : projectRoot } )
121+ } ) ;
122+ }
98123 }
99124
100125 if ( version ) {
@@ -105,7 +130,7 @@ function preparePackage(tasks, package, version, install) {
105130 projectTasks . push ( {
106131 title : `${ pkg . name } : update ionic/core dep to ${ version } ` ,
107132 task : ( ) => {
108- updateDependency ( pkg , " @ionic/core" , version ) ;
133+ updateDependency ( pkg , ' @ionic/core' , version ) ;
109134 writePkg ( package , pkg ) ;
110135 }
111136 } ) ;
@@ -134,7 +159,6 @@ function preparePackage(tasks, package, version, install) {
134159 } ) ;
135160}
136161
137-
138162function prepareDevPackage ( tasks , package , version ) {
139163 const projectRoot = projectPath ( package ) ;
140164 const pkg = readPkg ( package ) ;
@@ -152,7 +176,7 @@ function prepareDevPackage(tasks, package, version) {
152176 projectTasks . push ( {
153177 title : `${ pkg . name } : update ionic/core dep to ${ version } ` ,
154178 task : ( ) => {
155- updateDependency ( pkg , " @ionic/core" , version ) ;
179+ updateDependency ( pkg , ' @ionic/core' , version ) ;
156180 writePkg ( package , pkg ) ;
157181 }
158182 } ) ;
@@ -181,33 +205,38 @@ function updatePackageVersions(tasks, packages, version) {
181205 packages . forEach ( package => {
182206 updatePackageVersion ( tasks , package , version ) ;
183207
184- tasks . push (
185- {
186- title : `${ package } update @ionic/core dependency, if present ${ tc . dim ( `(${ version } )` ) } ` ,
187- task : async ( ) => {
188- if ( package !== 'core' ) {
189- const pkg = readPkg ( package ) ;
190- updateDependency ( pkg , '@ionic/core' , version ) ;
191- writePkg ( package , pkg ) ;
192- }
193- } ,
208+ tasks . push ( {
209+ title : `${ package } update @ionic/core dependency, if present ${ tc . dim ( `(${ version } )` ) } ` ,
210+ task : async ( ) => {
211+ if ( package !== 'core' ) {
212+ const pkg = readPkg ( package ) ;
213+ updateDependency ( pkg , '@ionic/core' , version ) ;
214+ writePkg ( package , pkg ) ;
215+ }
194216 }
195- )
217+ } ) ;
218+ if ( package === 'packages/react-router' ) {
219+ tasks . push ( {
220+ title : `${ package } update @ionic/react dependency, if present ${ tc . dim ( `(${ version } )` ) } ` ,
221+ task : async ( ) => {
222+ const pkg = readPkg ( package ) ;
223+ updateDependency ( pkg , '@ionic/react' , version ) ;
224+ writePkg ( package , pkg ) ;
225+ }
226+ } ) ;
227+ }
196228 } ) ;
197229}
198230
199-
200231function updatePackageVersion ( tasks , package , version ) {
201232 const projectRoot = projectPath ( package ) ;
202233
203- tasks . push (
204- {
205- title : `${ package } : update package.json ${ tc . dim ( `(${ version } )` ) } ` ,
206- task : async ( ) => {
207- await execa ( 'npm' , [ 'version' , version ] , { cwd : projectRoot } ) ;
208- }
234+ tasks . push ( {
235+ title : `${ package } : update package.json ${ tc . dim ( `(${ version } )` ) } ` ,
236+ task : async ( ) => {
237+ await execa ( 'npm' , [ 'version' , version ] , { cwd : projectRoot } ) ;
209238 }
210- ) ;
239+ } ) ;
211240}
212241
213242function publishPackages ( tasks , packages , version , tag = 'latest' ) {
@@ -237,7 +266,7 @@ function publishPackages(tasks, packages, version, tag = 'latest') {
237266 title : `${ package } : publish to ${ tag } tag` ,
238267 task : async ( ) => {
239268 await execa ( 'npm' , [ 'publish' , '--tag' , tag ] , { cwd : projectRoot } ) ;
240- } ,
269+ }
241270 } ) ;
242271 } ) ;
243272}
@@ -261,11 +290,12 @@ function isVersionGreater(oldVersion, newVersion) {
261290function copyCDNLoader ( tasks , version ) {
262291 tasks . push ( {
263292 title : `Copy CDN loader` ,
264- task : ( ) => execa ( 'node' , [ 'copy-cdn-loader.js' , version ] , { cwd : path . join ( rootDir , 'core' , 'scripts' ) } ) ,
293+ task : ( ) => execa ( 'node' , [ 'copy-cdn-loader.js' , version ] , { cwd : path . join ( rootDir , 'core' , 'scripts' ) } )
265294 } ) ;
266295}
267296
268297module . exports = {
298+ checkTestDist,
269299 checkGit,
270300 isValidVersion,
271301 isVersionGreater,
@@ -281,5 +311,5 @@ module.exports = {
281311 updateDependency,
282312 updatePackageVersion,
283313 updatePackageVersions,
284- writePkg,
314+ writePkg
285315} ;
0 commit comments