UNPKG

@puls-atlas/cli

Version:

The Puls Atlas CLI tool for managing Atlas projects

44 lines 1.14 kB
import fs from 'fs'; import path from 'path'; import inquirer from 'inquirer'; import { logger } from '../../utils/index.js'; export default async () => { const authJsonPath = path.join(process.cwd(), 'auth.json'); if (fs.existsSync(authJsonPath)) { logger.error('An auth.json file already exists.', false); const { overwrite } = await inquirer.prompt([{ type: 'confirm', name: 'overwrite', message: 'Do you want to overwrite the existing auth.json file?', default: false }]); if (!overwrite) { return; } } const { token } = await inquirer.prompt([{ type: 'input', name: 'token', message: 'Enter the vendor token from packagist.com:', validate: input => { if (input.length === 0) { return 'Please enter a valid developer token.'; } return true; } }]); const authJson = { 'http-basic': { 'puls.repo.packagist.com': { username: 'token', password: token } } }; fs.writeFileSync(authJsonPath, JSON.stringify(authJson, null, 4)); logger.success('auth.json file created.'); };