@@ -15,34 +15,64 @@ const sh = require('shelljs')
1515const pkg = require ( '../package.json' )
1616
1717const versionShort = pkg . config . version_short
18- const folderName = `bootstrap-${ pkg . version } -examples`
18+ const distFolder = `bootstrap-${ pkg . version } -examples`
19+ const rootDocsDir = '_gh_pages'
20+ const docsDir = `${ rootDocsDir } /docs/${ versionShort } /`
21+
22+ // these are the files we need in the examples
23+ const cssFiles = [
24+ 'bootstrap.min.css' ,
25+ 'bootstrap.min.css.map' ,
26+ 'bootstrap.rtl.min.css' ,
27+ 'bootstrap.rtl.min.css.map'
28+ ]
29+ const jsFiles = [
30+ 'bootstrap.bundle.min.js' ,
31+ 'bootstrap.bundle.min.js.map'
32+ ]
33+ const imgFiles = [
34+ 'bootstrap-logo.svg' ,
35+ 'bootstrap-logo-white.svg'
36+ ]
1937
2038sh . config . fatal = true
2139
22- if ( ! sh . test ( '-d' , '_gh_pages' ) ) {
23- throw new Error ( ' The "_gh_pages " folder does not exist, did you forget building the docs?' )
40+ if ( ! sh . test ( '-d' , rootDocsDir ) ) {
41+ throw new Error ( ` The "${ rootDocsDir } " folder does not exist, did you forget building the docs?` )
2442}
2543
2644// switch to the root dir
2745sh . cd ( path . join ( __dirname , '..' ) )
2846
2947// remove any previously created folder with the same name
30- sh . rm ( '-rf' , folderName )
48+ sh . rm ( '-rf' , distFolder )
49+
3150// create any folders so that `cp` works
32- sh . mkdir ( '-p' , folderName )
33- sh . mkdir ( '-p' , `${ folderName } /assets/brand/` )
34-
35- sh . cp ( '-Rf' , `_gh_pages/docs/${ versionShort } /examples/*` , folderName )
36- sh . cp ( '-Rf' , `_gh_pages/docs/${ versionShort } /dist/` , `${ folderName } /assets/` )
37- // also copy the two brand images we use in the examples
38- sh . cp ( '-f' , [
39- `_gh_pages/docs/${ versionShort } /assets/brand/bootstrap-logo.svg` ,
40- `_gh_pages/docs/${ versionShort } /assets/brand/bootstrap-logo-white.svg`
41- ] , `${ folderName } /assets/brand/` )
42- sh . rm ( `${ folderName } /index.html` )
51+ sh . mkdir ( '-p' , [
52+ distFolder ,
53+ `${ distFolder } /assets/brand/` ,
54+ `${ distFolder } /assets/dist/css/` ,
55+ `${ distFolder } /assets/dist/js/`
56+ ] )
57+
58+ sh . cp ( '-Rf' , `${ docsDir } /examples/*` , distFolder )
59+
60+ cssFiles . forEach ( file => {
61+ sh . cp ( '-f' , `${ docsDir } /dist/css/${ file } ` , `${ distFolder } /assets/dist/css/` )
62+ } )
63+
64+ jsFiles . forEach ( file => {
65+ sh . cp ( '-f' , `${ docsDir } /dist/js/${ file } ` , `${ distFolder } /assets/dist/js/` )
66+ } )
67+
68+ imgFiles . forEach ( file => {
69+ sh . cp ( '-f' , `${ docsDir } /assets/brand/${ file } ` , `${ distFolder } /assets/brand/` )
70+ } )
71+
72+ sh . rm ( `${ distFolder } /index.html` )
4373
4474// get all examples' HTML files
45- sh . find ( `${ folderName } /**/*.html` ) . forEach ( file => {
75+ sh . find ( `${ distFolder } /**/*.html` ) . forEach ( file => {
4676 const fileContents = sh . cat ( file )
4777 . toString ( )
4878 . replace ( new RegExp ( `"/docs/${ versionShort } /` , 'g' ) , '"../' )
@@ -54,7 +84,7 @@ sh.find(`${folderName}/**/*.html`).forEach(file => {
5484} )
5585
5686// create the zip file
57- sh . exec ( `zip -r9 "${ folderName } .zip" "${ folderName } "` , { fatal : true } )
87+ sh . exec ( `zip -r9 "${ distFolder } .zip" "${ distFolder } "` )
5888
5989// remove the folder we created
60- sh . rm ( '-rf' , folderName )
90+ sh . rm ( '-rf' , distFolder )
0 commit comments