2017-07-07 13:28:29 -04:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-25 10:12:28 -05:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-07-07 13:28:29 -04:00
|
|
|
*
|
2017-10-05 14:14:49 -04:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2017-07-07 13:28:29 -04:00
|
|
|
*/
|
|
|
|
|
|
2018-09-30 16:32:12 -04:00
|
|
|
require('@babel/register')({
|
2017-10-23 21:27:21 -04:00
|
|
|
babelrc: false,
|
2018-07-11 06:21:31 -04:00
|
|
|
only: [__dirname, `${process.cwd()}/core`],
|
2018-01-26 13:47:09 -05:00
|
|
|
plugins: [
|
|
|
|
|
require('./server/translate-plugin.js'),
|
2019-06-14 00:58:46 -04:00
|
|
|
require('@babel/plugin-proposal-class-properties').default,
|
|
|
|
|
require('@babel/plugin-proposal-object-rest-spread').default,
|
|
|
|
|
],
|
|
|
|
|
presets: [
|
|
|
|
|
require('@babel/preset-react').default,
|
|
|
|
|
require('@babel/preset-env').default,
|
2018-01-26 13:47:09 -05:00
|
|
|
],
|
2017-07-07 13:28:29 -04:00
|
|
|
});
|
|
|
|
|
|
2017-12-04 22:21:02 -05:00
|
|
|
const chalk = require('chalk');
|
|
|
|
|
const fs = require('fs');
|
2018-07-08 12:13:18 -04:00
|
|
|
const program = require('commander');
|
|
|
|
|
|
2017-08-09 18:43:30 -04:00
|
|
|
const CWD = process.cwd();
|
2018-06-03 02:45:36 -04:00
|
|
|
const env = require('./server/env.js');
|
2017-08-09 18:43:30 -04:00
|
|
|
|
2018-09-12 14:03:52 -04:00
|
|
|
const {startDocusaurus} = require('./server/start.js');
|
|
|
|
|
|
2018-07-11 06:21:31 -04:00
|
|
|
if (!fs.existsSync(`${CWD}/siteConfig.js`)) {
|
2017-10-23 21:27:21 -04:00
|
|
|
console.error(
|
2018-09-17 03:34:55 -04:00
|
|
|
chalk.red('Error: No siteConfig.js file found in website folder!'),
|
2017-10-23 21:27:21 -04:00
|
|
|
);
|
|
|
|
|
process.exit(1);
|
2017-08-09 18:43:30 -04:00
|
|
|
}
|
|
|
|
|
|
2018-06-03 02:45:36 -04:00
|
|
|
if (env.versioning.enabled && env.versioning.missingVersionsPage) {
|
|
|
|
|
env.versioning.printMissingVersionsPageError();
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 02:51:03 -04:00
|
|
|
program
|
|
|
|
|
.option('--port <number>', 'Specify port number')
|
|
|
|
|
.option('--no-watch', 'Toggle live reload file watching')
|
2019-05-20 12:31:41 -04:00
|
|
|
.option('--host <host>', 'use specified host (default: localhost)')
|
2018-06-15 02:51:03 -04:00
|
|
|
.parse(process.argv);
|
2017-07-13 16:40:24 -04:00
|
|
|
|
2020-04-05 10:38:12 -04:00
|
|
|
startDocusaurus().catch((ex) => {
|
2020-08-05 10:19:24 -04:00
|
|
|
console.error(chalk.red(ex && ex.stack ? ex.stack : ex));
|
2018-09-12 14:03:52 -04:00
|
|
|
process.exit(1);
|
|
|
|
|
});
|