Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// let users know which database is being initialised
var logging = require('ghost-ignition').logging();
var config = require('ghost/core/server/config');
logging.info('Initialising ' + config.get('env'));
// if we're running in Azure and not configuring production, warn the user
if ((process.env.REGION_NAME) && (process.env.WEBSITE_SKU) && (!process.env.EMULATED) && (config.get('env') !== 'production')) {
logging.warn('Appear to be running in Azure but not configuring production database');
};
// re-initialise database by resetting it and then initialising it
var KnexMigrator = require('knex-migrator');
knexMigrator = new KnexMigrator({
knexMigratorFilePath: __dirname + '\\node_modules\\ghost'
});
logging.info('Resetting ' + config.get('env'));
knexMigrator.reset()
.then(function onResetSuccess() {
logging.info('Reset succeeded');
knexMigrator.init()
.then(function onInitSuccess() {
logging.info('Initialisation succeeded');
// let users know which database is being initialised
var logging = require('ghost-ignition').logging();
var config = require('ghost/core/server/config');
logging.info('Initialising ' + config.get('env'));
// if we're running in Azure and not configuring production, warn the user
if ((process.env.REGION_NAME) && (process.env.WEBSITE_SKU) && (!process.env.EMULATED) && (config.get('env') !== 'production')) {
logging.warn('Appear to be running in Azure but not configuring production database');
};
// re-initialise database by resetting it and then initialising it
var KnexMigrator = require('knex-migrator');
knexMigrator = new KnexMigrator({
knexMigratorFilePath: __dirname + '\\node_modules\\ghost'
});
logging.info('Resetting ' + config.get('env'));
knexMigrator.reset()
.then(function onResetSuccess() {
logging.info('Reset succeeded');
var serverCacheVariableName = 's'; // use a single letter to minimize the file size
// we do different post-install processes depending on where we're deployed and the environment; first see if we're in Azure
if ((process.env.REGION_NAME) && (process.env.WEBSITE_SKU) && (!process.env.EMULATED) && (process.env.WEBSITE_SITE_NAME)) {
logging.info('Appear to be running in Azure, performing post-install for ' + config.get('env'));
ensureProductionConfigMatchesAzureDeployment();
ensureDatabaseHasBeenMigratedToLatestVersion();
createServerJs();
createServerCacheJs();
createServerCacheModulePathJs();
createServerCacheStatJs();
copyGhostAdmin();
} else {
// not running in Azure, so we should be running locally, only do post-install if we're not in production; if we're in
// production, but running locally, assume the user is doing something specific and is handling things themselves
if (config.get('env') !== 'production') {
logging.info('Don\'t appear to be running in Azure, performing post-install for ' + config.get('env'));
ensureDatabaseHasBeenMigratedToLatestVersion();
createServerJs();
createServerCacheJs();
createServerCacheModulePathJs();
createServerCacheStatJs();
copyGhostAdmin();
} else {
logging.warn('Don\'t appear to be running in Azure, skipping post-install as environment is currently ' + config.get('env'));
logging.warn('When repo is deployed to Azure the database in Azure will be automatically migrated to the latest version so you don\'t need to; if you still wish to migrate the local database to the latest version use node dbmigrate.js');
};
};
// updates config.production.json to match where we're deployed
function ensureProductionConfigMatchesAzureDeployment() {
logging.info('Updating config.production.json to match site name ' + process.env.WEBSITE_SITE_NAME.toLowerCase());
// let users know which database is being initialised
var logging = require('ghost-ignition').logging();
var config = require('ghost/core/server/config');
logging.info('Migrating ' + config.get('env'));
// if we're running in Azure and not configuring production, warn the user
if ((process.env.REGION_NAME) && (process.env.WEBSITE_SKU) && (!process.env.EMULATED) && (config.get('env') !== 'production')) {
logging.warn('Appear to be running in Azure but not configuring production database');
};
// migrate database to latest version
var KnexMigrator = require('knex-migrator');
knexMigrator = new KnexMigrator({
knexMigratorFilePath: __dirname + '\\node_modules\\ghost'
});
knexMigrator.migrate()
.then(function onMigrateSuccess() {
logging.info('Migration succeeded');
return null;
})
.catch(function onMigrateError(err) {
logging.error('Migration failed: ' + err.message);
// let users know which database is being initialised
var logging = require('ghost-ignition').logging();
var config = require('ghost/core/server/config');
logging.info('Migrating ' + config.get('env'));
// if we're running in Azure and not configuring production, warn the user
if ((process.env.REGION_NAME) && (process.env.WEBSITE_SKU) && (!process.env.EMULATED) && (config.get('env') !== 'production')) {
logging.warn('Appear to be running in Azure but not configuring production database');
};
// migrate database to latest version
var KnexMigrator = require('knex-migrator');
knexMigrator = new KnexMigrator({
knexMigratorFilePath: __dirname + '\\node_modules\\ghost'
});
knexMigrator.migrate()
.then(function onMigrateSuccess() {
logging.info('Migration succeeded');
return null;
var configProductionJsonPath = path.resolve(__dirname, 'config.production.json');
var knexMigratorPath = path.resolve(__dirname, 'node_modules/ghost');
var serverJsPath = path.resolve(__dirname, 'server.js');
var serverCacheJsPath = path.resolve(__dirname, 'server.cache.js');
var serverCacheJsZippedPath = path.resolve(__dirname, 'server.cache.js.gz');
var serverCacheModulePathJs = path.resolve(__dirname, 'server.cache.modulePath.js');
var serverCacheModulePathTemplateJs = path.resolve(__dirname, 'server.cache.modulePath.template.js');
var serverCacheStatJs = path.resolve(__dirname, 'server.cache.stat.js');
var serverCacheStatTemplateJs = path.resolve(__dirname, 'server.cache.stat.template.js');
var serverTemplateJsPath = path.resolve(__dirname, 'server.template.js');
var ghostPath = path.resolve(__dirname, 'node_modules/ghost/index.js');
var serverCacheVariableName = 's'; // use a single letter to minimize the file size
// we do different post-install processes depending on where we're deployed and the environment; first see if we're in Azure
if ((process.env.REGION_NAME) && (process.env.WEBSITE_SKU) && (!process.env.EMULATED) && (process.env.WEBSITE_SITE_NAME)) {
logging.info('Appear to be running in Azure, performing post-install for ' + config.get('env'));
ensureProductionConfigMatchesAzureDeployment();
ensureDatabaseHasBeenMigratedToLatestVersion();
createServerJs();
createServerCacheJs();
createServerCacheModulePathJs();
createServerCacheStatJs();
copyGhostAdmin();
} else {
// not running in Azure, so we should be running locally, only do post-install if we're not in production; if we're in
// production, but running locally, assume the user is doing something specific and is handling things themselves
if (config.get('env') !== 'production') {
logging.info('Don\'t appear to be running in Azure, performing post-install for ' + config.get('env'));
ensureDatabaseHasBeenMigratedToLatestVersion();
createServerJs();
createServerCacheJs();
createServerCacheModulePathJs();