-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(v1): v1 deploy preview should be available (#3517)
* v1 deploy preview * Add /v1-migrated deployment
- Loading branch information
Showing
8 changed files
with
89 additions
and
6 deletions.
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
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
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
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,46 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// This is useful to speed up v1 deployment in Netlify PR deploy previews | ||
// | ||
// Command to test locally: | ||
// NETLIFY=true CONTEXT=deploy-preview yarn build:v1 | ||
// or | ||
// NETLIFY=true CONTEXT=deploy-preview yarn netlify:deployPreview:v1 | ||
// | ||
// See Netlify env variables here: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata | ||
const isDeployPreview = | ||
process.env.NETLIFY === 'true' && process.env.CONTEXT === 'deploy-preview'; | ||
if (isDeployPreview) { | ||
console.log('Docusaurus v1 running as a Netlify deploy preview'); | ||
} | ||
exports.isDeployPreview = isDeployPreview; | ||
|
||
// On netlify deploy previews, we don't deploy all versions to make deploy preview faster | ||
function updateDeployPreviewVersions(versions) { | ||
const newVersions = [versions[0], versions[versions.length - 1]]; | ||
console.log( | ||
'Netlify deploy previews will only deploy a subset of available versions: ' + | ||
newVersions.join(' - '), | ||
); | ||
return newVersions; | ||
} | ||
|
||
exports.setDeployPreviewVersions = function () { | ||
const versions = JSON.parse( | ||
fs.readFileSync(path.join(__dirname, 'versions.json'), 'utf8'), | ||
); | ||
const newVersions = updateDeployPreviewVersions(versions); | ||
fs.writeFileSync( | ||
path.join(__dirname, 'versions.json'), | ||
JSON.stringify(newVersions, null, 2), | ||
'utf8', | ||
); | ||
}; |
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
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,6 @@ | ||
/classic/* /classic/404.html 200 | ||
/bootstrap/* /bootstrap/404.html 200 | ||
/blog-only/* /blog-only/404.html 200 | ||
/v1/* /v1/404.html 200 | ||
/v1-migrated/* /v1-migrated/404.html 200 | ||
/* /classic/ |
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
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