-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce versions to build on Netlify (#757)
* Reduce versions to build on Netlify * Remove imagebackground and safeareaview from 0.5 * Keep 0.46 and 0.50
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[build] | ||
base = "website" | ||
publish = "website/build/react-native" | ||
command = "sed -i -e \"s|const baseUrl .*|const baseUrl = '/';|g\" siteConfig.js && yarn install && yarn build" | ||
command = "sed -i -e \"s|const baseUrl .*|const baseUrl = '/';|g\" siteConfig.js && yarn install && node netlify-reduce-versions && yarn build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** | ||
* During the build process, we build a complete website for each version | ||
* which is 9.2 MB / version. | ||
* | ||
* On Netlify, our deploy preview infrastructure, we have to upload every | ||
* changed file. Each time we cut a new version or making multiple changes | ||
* we're facing timeout errors from Netlify trying to upload megabytes of HTML | ||
* file. | ||
* | ||
* This script makes sure we're not deploying unnecessary versions on Netlify. | ||
* | ||
* We only need 0.5 which is the first draft of each doc, and the recent ones. | ||
*/ | ||
|
||
const fs = require('fs-extra'); | ||
const versions = require('./versions.json'); | ||
|
||
const filterWantedVersions = version => | ||
+version === 0.5 || | ||
((version.length > 3 && +version >= 0.56) || | ||
+version === 0.46 || | ||
version === '0.50'); | ||
|
||
fs.writeFileSync( | ||
'./versions.json', | ||
JSON.stringify(versions.filter(filterWantedVersions)) | ||
); | ||
|
||
fs.readdirSync('./versioned_docs').map(directory => { | ||
if (!filterWantedVersions(directory.replace('version-', ''))) { | ||
fs.removeSync(`./versioned_docs/${directory}`); | ||
} | ||
}); | ||
|
||
fs.readdirSync('./versioned_sidebars').map(directory => { | ||
const match = /version-(\d.\d\d?)-sidebars.json/g.exec(directory); | ||
|
||
if (match && !filterWantedVersions(match[1])) { | ||
fs.removeSync(`./versioned_sidebars/${directory}`); | ||
} | ||
}); |