mirror of
https://github.com/status-im/react-native.git
synced 2025-01-09 17:15:54 +00:00
6f1417c849
Summary: Copy of #5760 reverted merge. We need to preserve history of docs changes on the webserver. The goal is to allow users to browse outdated versions of docs. To make things simple all websites will be released to https://facebook.github.io/react-native/releases/version/XX folder when there is a branch cut. I switched from Travis CI to Cirle CI because it works faster and I am more familiar with it. How it works: 1. If code is pushed to `master` branch then CI will build a fresh version of docs and put it in https://github.com/facebook/react-native/tree/gh-pages/releases/next folder. Github will serve this website from https://facebook.github.io/react-native/releases/version/next URL. All relative URLs will work within that website 2. If code is pushed to `0.20-stable` branch then CI will build a fresh version of docs and put it in https://github.com/facebook/react-native/tree/gh-pages/releases/0.20 folder. Github will serve this website from https://facebook.github.io/react-native/releases/v Closes https://github.com/facebook/react-native/pull/5873 Reviewed By: svcscm Differential Revision: D2926901 Pulled By: androidtrunkagent fb-gh-sync-id: 16aea430bac815933d9c603f03921cc6353906f1 shipit-source-id: 16aea430bac815933d9c603f03921cc6353906f1
68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
'use strict';
|
|
|
|
var Promise = require('bluebird');
|
|
var request = require('request');
|
|
var glob = require('glob');
|
|
var fs = require('fs.extra');
|
|
var mkdirp = require('mkdirp');
|
|
var server = require('./server.js');
|
|
|
|
require('./convert.js')();
|
|
server.noconvert = true;
|
|
|
|
// Sadly, our setup fatals when doing multiple concurrent requests
|
|
// I don't have the time to dig into why, it's easier to just serialize
|
|
// requests.
|
|
var queue = Promise.resolve();
|
|
|
|
glob('src/**/*.*', function(er, files) {
|
|
files.forEach(function(file) {
|
|
var targetFile = file.replace(/^src/, 'build');
|
|
|
|
if (file.match(/\.js$/) && !file.match(/src\/react-native\/js/)) {
|
|
targetFile = targetFile.replace(/\.js$/, '.html');
|
|
queue = queue.then(function() {
|
|
return new Promise(function(resolve, reject) {
|
|
request('http://localhost:8079/' + targetFile.replace(/^build\//, ''), function(error, response, body) {
|
|
if (error) {
|
|
reject(error);
|
|
return;
|
|
}
|
|
if (response.statusCode != 200) {
|
|
reject(new Error('Status ' + response.statusCode + ':\n' + body));
|
|
return;
|
|
}
|
|
mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), ''));
|
|
fs.writeFileSync(targetFile, body);
|
|
resolve();
|
|
});
|
|
});
|
|
});
|
|
} else {
|
|
queue = queue.then(function() {
|
|
return new Promise(function(resolve, reject) {
|
|
mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), ''));
|
|
fs.copy(file, targetFile, resolve);
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
queue = queue.then(function() {
|
|
console.log('Generated HTML files from JS');
|
|
}).finally(function() {
|
|
server.close();
|
|
}).catch(function(e) {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|
|
});
|