UNPKG

@puls-atlas/cli

Version:

The Puls Atlas CLI tool for managing Atlas projects

101 lines 4.27 kB
import chalk from 'chalk'; import inquirer from 'inquirer'; import composer from '../auth/composer.js'; import replaceVars from './replaceVars.js'; import createSecrets from './createSecrets.js'; import createTaskQueue from './createTaskQueue.js'; import addDefaultRoles from './addDefaultRoles.js'; import createLocalEnvFile from './createLocalEnvFile.js'; import createRealtimeDatabase from './createRealtimeDatabase.js'; import createFirestoreDatabase from './createFirestoreDatabase.js'; import { logger } from './../../utils/index.js'; const log = (msg, color = 'yellow') => { if (Array.isArray(msg)) { return msg.forEach((line, i) => console.log(chalk[color](`${i + 1}. ${line}`))); } console.log(chalk[color](msg)); }; const intro = async () => { log(); log('🚀 WELCOME TO PULS ATLAS 🚀'); log(); log('Initializing your project... Prepare for launch!'); log(); log("You're about to bootstrap a Puls Atlas project with all the right configs.", 'cyan'); log("Before we warp into setup, let's run through your pre-flight checklist:", 'cyan'); log(); log('1. You created a new repo for this project, using the atlas-project-template:'); log(' ' + chalk.yellow.underline('https://github.com/new?template_name=atlas-project-template&template_owner=limebooth')); log('2. You are running this command from the root of your project.'); log('3. You have the latest version of the Puls CLI installed.'); log('4. You have a Google Cloud project set up with billing enabled, both for production and development.'); log('5. You have the Google Cloud SDK installed and configured:'); log(' ' + chalk.yellow.underline('https://cloud.google.com/sdk/docs/install')); log('6. You have the necessary permissions to create resources in your Google Cloud project.'); log('7. You have created a Firebase project in the Firebase console, for both production and development:'); log(' ' + chalk.yellow.underline('https://console.firebase.google.com/')); log('8. You have created a firestore database for both production and development.'); log('9. You have created a vendor in Packagist (composer):'); log(' ' + chalk.yellow.underline('https://packagist.com/orgs/puls/customers')); log(); log("If you checked all the boxes, you're ready to go."); log(); log('May the source be with you! 🖖'); log(); const { continue: shouldContinue } = await inquirer.prompt([{ type: 'confirm', name: 'continue', message: 'Ready to initialize?', default: true }]); if (!shouldContinue) { console.log(chalk.red('Initialization aborted.')); process.exit(0); } }; const outro = () => { log(); log('Initialization complete!', 'green'); log('Your Puls Atlas project is now set up and ready to go.', 'cyan'); log(); log('Next steps:'); log(); log('1. Create a new App in Firebase Console, both for production and development.'); log('2. Create a new user in the Identity Platform in the Google Cloud Console.'); log(' ' + chalk.yellow.underline('https://console.cloud.google.com/customer-identity/providers')); log('3. Validate that all secrets are created in the Google Cloud Secret Manager.'); log('4. Run `atlas auth print-developer-token your-email@puls.be` to get your developer token.'); log('5. Run `atlas i app` to install the necessary packages.'); log('6. Run `atlas start` to start your development server.'); log(); }; export default async (options = {}) => { const steps = []; if (Object.keys(options).length === 0) { steps.push(intro, replaceVars, composer, addDefaultRoles, createSecrets, createTaskQueue, createLocalEnvFile, createFirestoreDatabase, outro); } else { if (options['secrets']) { steps.push(createSecrets); } if (options['localEnv']) { steps.push(createLocalEnvFile); } if (options['database']) { steps.push(createFirestoreDatabase, createRealtimeDatabase); } if (options['taskQueue']) { steps.push(createTaskQueue); } } for await (const step of steps) { try { await step(); } catch (error) { return Promise.reject(error); } } logger.success('Atlas initialized successfully. Live long and code on! 🖖'); return Promise.resolve(); };