| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | /* | 
					
						
							|  |  |  | 	NodeBB - A better forum platform for the modern web | 
					
						
							|  |  |  | 	https://github.com/NodeBB/NodeBB/
 | 
					
						
							| 
									
										
										
										
											2016-12-21 21:11:40 -05:00
										 |  |  | 	Copyright (C) 2013-2017  NodeBB Inc. | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  | 	it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  | 	the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  | 	(at your option) any later version. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | 	but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  | 	GNU General Public License for more details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  | 	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-18 01:56:23 -07:00
										 |  |  | 'use strict'; | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-31 07:58:37 -06:00
										 |  |  | require('./require-main'); | 
					
						
							| 
									
										
										
										
											2017-04-12 15:22:58 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 23:58:24 -04:00
										 |  |  | const nconf = require('nconf'); | 
					
						
							| 
									
										
										
										
											2017-06-22 11:10:23 -04:00
										 |  |  | nconf.argv().env({ | 
					
						
							|  |  |  | 	separator: '__', | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 23:58:24 -04:00
										 |  |  | const winston = require('winston'); | 
					
						
							|  |  |  | const path = require('path'); | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 23:58:24 -04:00
										 |  |  | const file = require('./src/file'); | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-19 21:15:51 -04:00
										 |  |  | process.env.NODE_ENV = process.env.NODE_ENV || 'production'; | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | global.env = process.env.NODE_ENV || 'production'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Alternate configuration file support
 | 
					
						
							| 
									
										
										
										
											2020-06-23 00:23:46 -04:00
										 |  |  | const configFile = path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json'); | 
					
						
							| 
									
										
										
										
											2015-09-17 21:54:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 23:58:24 -04:00
										 |  |  | const configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database')); | 
					
						
							| 
									
										
										
										
											2015-09-17 21:54:12 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 23:58:24 -04:00
										 |  |  | const prestart = require('./src/prestart'); | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | prestart.loadConfig(configFile); | 
					
						
							| 
									
										
										
										
											2017-11-23 12:27:21 -07:00
										 |  |  | prestart.setupWinston(); | 
					
						
							| 
									
										
										
										
											2018-10-16 13:07:13 -04:00
										 |  |  | prestart.versionCheck(); | 
					
						
							|  |  |  | winston.verbose('* using configuration stored in: %s', configFile); | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-24 22:32:40 -04:00
										 |  |  | if (!process.send) { | 
					
						
							|  |  |  | 	// If run using `node app`, log GNU copyright info along with server info
 | 
					
						
							| 
									
										
										
										
											2016-08-29 17:38:53 -04:00
										 |  |  | 	winston.info('NodeBB v' + nconf.get('version') + ' Copyright (C) 2013-' + (new Date()).getFullYear() + ' NodeBB Inc.'); | 
					
						
							| 
									
										
										
										
											2015-09-24 22:32:40 -04:00
										 |  |  | 	winston.info('This program comes with ABSOLUTELY NO WARRANTY.'); | 
					
						
							|  |  |  | 	winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); | 
					
						
							|  |  |  | 	winston.info(''); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-16 19:25:05 -04:00
										 |  |  | if (nconf.get('setup') || nconf.get('install')) { | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | 	require('./src/cli/setup').setup(); | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | } else if (!configExists) { | 
					
						
							|  |  |  | 	require('./install/web').install(nconf.get('port')); | 
					
						
							|  |  |  | } else if (nconf.get('upgrade')) { | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | 	require('./src/cli/upgrade').upgrade(true); | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | } else if (nconf.get('reset')) { | 
					
						
							| 
									
										
										
										
											2019-10-09 23:58:24 -04:00
										 |  |  | 	require('./src/cli/reset').reset({ | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | 		theme: nconf.get('t'), | 
					
						
							|  |  |  | 		plugin: nconf.get('p'), | 
					
						
							|  |  |  | 		widgets: nconf.get('w'), | 
					
						
							|  |  |  | 		settings: nconf.get('s'), | 
					
						
							|  |  |  | 		all: nconf.get('a'), | 
					
						
							| 
									
										
										
										
											2016-12-05 10:23:28 -05:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2015-09-16 19:25:05 -04:00
										 |  |  | } else if (nconf.get('activate')) { | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | 	require('./src/cli/manage').activate(nconf.get('activate')); | 
					
						
							| 
									
										
										
										
											2015-11-03 11:50:14 -05:00
										 |  |  | } else if (nconf.get('plugins')) { | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | 	require('./src/cli/manage').listPlugins(); | 
					
						
							| 
									
										
										
										
											2016-11-16 19:49:50 -05:00
										 |  |  | } else if (nconf.get('build')) { | 
					
						
							| 
									
										
										
										
											2019-09-13 18:24:21 -04:00
										 |  |  | 	require('./src/cli/manage').build(nconf.get('build')); | 
					
						
							| 
									
										
										
										
											2017-06-01 16:24:40 -04:00
										 |  |  | } else if (nconf.get('events')) { | 
					
						
							| 
									
										
											  
											
												CLI refactor with commander (#6058)
* CLI refactor with commander
- Modularized the functionality
- All functionality done directly from `./nodebb` now
(still available from `app` for backwards compatibility)
- Moved all CLI code from `./nodebb` to `src/cli`
- Fixed `nodebb.bat` to work from any location, like `./nodebb`, and
also hides command output
- Overwrite some commander methods to add CLI color support
- Added `./nodebb info` for quick info including git hash, NodeBB
version, node version, and some database info
- Refactored `./nodebb reset` to allow multiple resets at once
- Changed `./nodebb restart` to essentially stop and start, as Windows
doesn't support signals
- Added `-l, --log` option which works on `./nodebb start` and `./nodebb
restart` to show logging, like `./nodebb slog`
- Expanded `-d, --dev` option which works on them as well, like
`./nodebb dev`
- Improvements to self-help. `./nodebb build -h` will output all
possible targets
- `./nodebb reset` explains usage better
* Fix some style inconsistencies
* Fix prestart being required before modules installed
* Fix travis failures
* Fix `help` command to output help for subcommands
* Pick steps of the upgrade process to run
* Fix formatting for upgrade help
* Fix web installer
											
										 
											2017-11-23 08:55:03 -07:00
										 |  |  | 	require('./src/cli/manage').listEvents(); | 
					
						
							| 
									
										
										
										
											2015-09-16 19:25:05 -04:00
										 |  |  | } else { | 
					
						
							| 
									
										
										
										
											2016-12-23 14:45:37 +03:00
										 |  |  | 	require('./src/start').start(); | 
					
						
							| 
									
										
										
										
											2015-07-21 11:23:16 -04:00
										 |  |  | } |