Skip to content

Commit

Permalink
Revert i18n in startup-check
Browse files Browse the repository at this point in the history
- Removes preinstall dependencies
- Reintroduce old plain english strings
- Remove translations for startup check

closes #6332
  • Loading branch information
halfdan committed Jan 13, 2016
1 parent f3409ad commit eef37ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 42 deletions.
24 changes: 0 additions & 24 deletions core/server/translations/en.json
Expand Up @@ -116,30 +116,6 @@
"willBeRequired": "This will be required in future. Please see {url}",
"themeFileIsMalformed": "Theme package.json file is malformed"
},
"startupcheck": {
"unsupportedNodeVersion": {
"error": "ERROR: Unsupported version of Node",
"context": "Ghost needs Node version {neededVersion} you are using version {usedVersion}\n",
"help": "Please see {url} for more information"
},
"cannotFindConfigForCurrentNode": {
"error": "ERROR: Cannot find the configuration for the current NODE_ENV: {nodeEnv}\n",
"help": "Ensure your config.js has a section for the current NODE_ENV value and is formatted properly."
},
"ghostMissingDependencies": {
"error": "ERROR: Ghost is unable to start due to missing dependencies:\n {error}",
"explain": "\nPlease run `npm install --production` and try starting Ghost again.",
"help": "Help and documentation can be found at {url}.\n"
},
"unableToAccessContentPath": {
"error": "ERROR: Unable to access Ghost's content path:",
"help": "Check that the content path exists and file system permissions are correct. \nHelp and documentation can be found at {url}."
},
"unableToOpenSqlite3Db": {
"error": "ERROR: Unable to open sqlite3 database file for read/write",
"help": "\nCheck that the sqlite3 database file permissions allow read and write access. \nHelp and documentation can be found at {url}."
}
},
"validatethemes": {
"themeWithNoPackage": {
"message": "Found a theme with no package.json file",
Expand Down
34 changes: 17 additions & 17 deletions core/server/utils/startup-check.js
Expand Up @@ -2,7 +2,6 @@ var packages = require('../../../package.json'),
path = require('path'),
crypto = require('crypto'),
fs = require('fs'),
i18n = require('../i18n'),
mode = process.env.NODE_ENV === undefined ? 'development' : process.env.NODE_ENV,
appRoot = path.resolve(__dirname, '../../../'),
configFilePath = process.env.GHOST_CONFIG || path.join(appRoot, 'config.js'),
Expand All @@ -29,16 +28,14 @@ checks = {
nodeVersion: function checkNodeVersion() {
// Tell users if their node version is not supported, and exit
var semver = require('semver');
i18n.init();

if (process.env.GHOST_NODE_VERSION_CHECK !== 'false' &&
!semver.satisfies(process.versions.node, packages.engines.node) &&
!semver.satisfies(process.versions.node, packages.engines.iojs)) {
console.error(i18n.t('errors.utils.startupcheck.unsupportedNodeVersion.error'));
console.error(i18n.t('errors.utils.startupcheck.unsupportedNodeVersion.context',
{neededVersion: packages.engines.node, usedVersion: process.versions.node}));
console.error(i18n.t('errors.utils.startupcheck.unsupportedNodeVersion.help',
{url: 'http://support.ghost.org/supported-node-versions/'}));
console.error('\x1B[31mERROR: Unsupported version of Node');
console.error('\x1B[31mGhost needs Node version ' + packages.engines.node +
' you are using version ' + process.versions.node + '\033[0m\n');
console.error('\x1B[32mPlease see http://support.ghost.org/supported-node-versions/ for more information\033[0m');

process.exit(exitCodes.NODE_VERSION_UNSUPPORTED);
}
Expand All @@ -61,9 +58,10 @@ checks = {
config = configFile[mode];

if (!config) {
console.error(i18n.t('errors.utils.startupcheck.cannotFindConfigForCurrentNode.error',
{nodeEnv: process.env.NODE_ENV}));
console.error(i18n.t('errors.utils.startupcheck.cannotFindConfigForCurrentNode.help'));
console.error('\x1B[31mERROR: Cannot find the configuration for the current NODE_ENV: ' +
process.env.NODE_ENV + '\033[0m\n');
console.error('\x1B[32mEnsure your config.js has a section for the current NODE_ENV value' +
' and is formatted properly.\033[0m');

process.exit(exitCodes.NODE_ENV_CONFIG_MISSING);
}
Expand Down Expand Up @@ -91,9 +89,9 @@ checks = {

errors = errors.join('\n ');

console.error(i18n.t('errors.utils.startupcheck.ghostMissingDependencies.error', {error: errors}));
console.error(i18n.t('errors.utils.startupcheck.ghostMissingDependencies.explain'));
console.error(i18n.t('errors.utils.startupcheck.ghostMissingDependencies.help', {url: 'http://support.ghost.org'}));
console.error('\x1B[31mERROR: Ghost is unable to start due to missing dependencies:\033[0m\n ' + errors);
console.error('\x1B[32m\nPlease run `npm install --production` and try starting Ghost again.');
console.error('\x1B[32mHelp and documentation can be found at http://support.ghost.org.\033[0m\n');

process.exit(exitCodes.DEPENDENCIES_MISSING);
},
Expand All @@ -109,8 +107,9 @@ checks = {
contentPath,
contentSubPaths = ['apps', 'data', 'images', 'themes'],
fd,
errorHeader = i18n.t('errors.utils.startupcheck.unableToAccessContentPath.error'),
errorHelp = i18n.t('errors.utils.startupcheck.unableToAccessContentPath.help', {url: 'http://support.ghost.org'});
errorHeader = '\x1B[31mERROR: Unable to access Ghost\'s content path:\033[0m',
errorHelp = '\x1B[32mCheck that the content path exists and file system permissions are correct.' +
'\nHelp and documentation can be found at http://support.ghost.org.\033[0m';

// Get the content path to test. If it's defined in config.js use that, if not use the default
try {
Expand Down Expand Up @@ -203,9 +202,10 @@ checks = {
return;
}

console.error(i18n.t('errors.utils.startupcheck.unableToOpenSqlite3Db.error'));
console.error('\x1B[31mERROR: Unable to open sqlite3 database file for read/write\033[0m');
console.error(' ' + e.message);
console.error(i18n.t('errors.utils.startupcheck.unableToOpenSqlite3Db.help', {url: 'http://support.ghost.org'}));
console.error('\n\x1B[32mCheck that the sqlite3 database file permissions allow read and write access.');
console.error('Help and documentation can be found at http://support.ghost.org.\033[0m');

process.exit(exitCodes.SQLITE_DB_NOT_WRITABLE);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -18,7 +18,7 @@
"license": "MIT",
"main": "./core/index",
"scripts": {
"preinstall": "npm install semver lodash chalk intl-messageformat intl && node -e \"require('./core/server/utils/startup-check.js').nodeVersion()\"",
"preinstall": "npm install semver && node -e \"require('./core/server/utils/startup-check.js').nodeVersion()\"",
"start": "node index",
"test": "grunt validate --verbose"
},
Expand Down

0 comments on commit eef37ac

Please sign in to comment.