UNPKG

@viewdo/dxp-story-cli

Version:
29 lines (19 loc) 851 B
const App = require('./app') module.exports = async (options, result = 0) => { const app = new App(options) app.console_service.log(`Authenticating folder: ${app.root}`.blue) let {force} = options if(app.configuration_manager.story_keys.length == 0) result = 'pull' if(await app.auth_manager.requireToken(false) && !force) { app.console_service.log('If you want to obtain a new token, use flag --force'.grey) return result } let email = app.auth_manager.email || await app.prompt_service .askFor('Email', null, app.prompt_service.validateEmail) await app.auth_manager.sendVerificationEmail(email) let code = await app.prompt_service .askFor('Enter the verification code we sent you', null, app.prompt_service.validateCode) await app.auth_manager.getTokenFromVerification(email, code) return result }