Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.migrateAsNeeded = async function (cloud, dataPath) {
var dbPath = path.join(dataPath, 'db')
if (fs.existsSync(dbPath)) {
console.log('')
console.log(figures.star, 'A database migration is required!')
console.log(figures.heart, 'Don\'t worry, this will be easy.')
var sqlFilePath = path.join(dataPath, 'legacy-leveldb-to-sqlite-dump.sql')
var archivedDbPath = path.join(dataPath, 'legacy-leveldb')
var newDbPath = path.join(dataPath, 'main.db')
await generateMigrationDump(dbPath, sqlFilePath)
await generateSqliteDb(cloud)
console.log(figures.info, 'SQL File:', sqlFilePath)
console.log(figures.info, 'The old database will be archived at', archivedDbPath)
console.log(figures.info, 'The new database is at', newDbPath)
if (!(await ask(figures.play + ' Are you ready to run the migration? (Y/n)', 'y'))) {
console.log('Okay.')
console.log('We need to run this migration to start, so Hashbase is now going to close.')
console.log(figures.pointerSmall, 'Shutting down.')
process.exit(0)
}
archiveOldDb(dbPath, archivedDbPath)
console.log(figures.star, 'A database migration complete!')
module.exports = async function (config) {
console.log(figures.heart, 'Hello friend')
console.log(figures.pointerSmall, 'Instantiating backend')
addConfigHelpers(config)
var cloud = new Hypercloud(config)
cloud.version = packageJson.version
await cloud.setup()
cloud.loadAllArchives()
console.log(figures.pointerSmall, 'Instantiating server')
var app = express()
if (config.proxy) {
app.set('trust proxy', 'loopback')
}
app.cloud = cloud
app.config = config
app.approveDomains = approveDomains(config, cloud)
)}.
${bulletSymbol} Create local server config: ${chalk.yellow(
isYarn() ? 'yarn bootstrap' : 'npm run bootstrap'
)}.
${bulletSymbol} Create distributable zip: ${chalk.yellow(
isYarn() ? 'yarn archive' : 'npm run archive'
)}.
${bulletSymbol} For more info, visit: ${wpackLink}.
To enqueue the assets within your plugin or theme, make sure you
have ${chalk.yellow('wpackio/enqueue')} package from packagist.org/composer
and follow the intructions from documentation. To install now, run
${bulletSymbol} ${chalk.yellow('composer require wpackio/enqueue')}.
To spread the ${chalk.red(figures.heart)} please ${chalk.yellowBright(
figures.star
)} our repo and tweet.`;
console.log(msg);
}
console.log(list.map((item, index) => {
return `
${chalk.dim(`[${index}]`)} ${chalk.yellow(item.word)} ${chalk.red(figures.heart)} ${chalk.red(String(item.thumbs_up))}
${item.definition}
${chalk.underline.dim(`url: ${item.permalink}`)}
${chalk.dim(`example: ${item.example}`)}
`.trim()
}).join('\n\n'))
}