UNPKG

@puls-atlas/cli

Version:

The Puls Atlas CLI tool for managing Atlas projects

79 lines 3.06 kB
import { execSync as nodeExecSync } from 'child_process'; import logger from './logger.js'; const LOCATION_NAMES = { 'africa-south1': 'Johannesburg', 'asia-east1': 'Taiwan', 'asia-east2': 'Hong Kong', 'asia-northeast1': 'Tokyo', 'asia-northeast2': 'Osaka', 'asia-northeast3': 'Seoul', 'asia-south1': 'Mumbai', 'asia-south2': 'Delhi', 'asia-southeast1': 'Singapore', 'asia-southeast2': 'Jakarta', 'australia-southeast1': 'Sydney', 'australia-southeast2': 'Melbourne', 'europe-central2': 'Warsaw', 'europe-north1': 'Finland', 'europe-north2': 'Stockholm', 'europe-southwest1': 'Madrid', 'europe-west1': 'Belgium', 'europe-west10': 'Berlin', 'europe-west12': 'Turin', 'europe-west2': 'London', 'europe-west3': 'Frankfurt', 'europe-west4': 'Netherlands', 'europe-west6': 'Zurich', 'europe-west8': 'Milan', 'europe-west9': 'Paris', 'me-central1': 'Doha', 'me-central2': 'Dammam', 'me-west1': 'Tel Aviv', 'northamerica-northeast1': 'Montreal', 'northamerica-northeast2': 'Toronto', 'northamerica-south1': 'Mexico', 'southamerica-east1': 'Sao Paulo', 'southamerica-west1': 'Santiago', 'us-central1': 'Iowa', 'us-east1': 'South Carolina', 'us-east4': 'Northern Virginia', 'us-east5': 'Columbus', 'us-south1': 'Dallas', 'us-west1': 'Oregon', 'us-west2': 'Los Angeles', 'us-west3': 'Salt Lake City', 'us-west4': 'Las Vegas', eur3: 'Europe', nam5: 'United States', nam7: 'United States' }; const FALLBACK_LOCATIONS = ['europe-west1 (Belgium)', 'europe-central2 (Warsaw)', 'europe-west2 (London)', 'europe-west3 (Frankfurt)', 'europe-west6 (Zurich)', 'us-central1 (Iowa)', 'us-east1 (South Carolina)', 'us-east4 (Northern Virginia)', 'us-west1 (Oregon)', 'northamerica-northeast1 (Montreal)', 'southamerica-east1 (Sao Paulo)', 'us-west2 (Los Angeles)', 'asia-northeast1 (Tokyo)', 'asia-southeast1 (Singapore)', 'australia-southeast1 (Sydney)']; export const getFirestoreLocations = async projectId => { try { const output = nodeExecSync(`gcloud firestore locations list --project=${projectId} --format=json`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }); const locations = JSON.parse(output); return locations.map(loc => `${loc.locationId} (${loc.displayName})`).sort((a, b) => a.localeCompare(b)); } catch (error) { logger.warn(`Could not fetch Firestore locations: ${error.message}`); return FALLBACK_LOCATIONS; } }; export const getTasksLocations = async projectId => { try { const output = nodeExecSync(`gcloud tasks locations list --project=${projectId} --format=json`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] }); const locations = JSON.parse(output); return locations.map(loc => { const displayName = LOCATION_NAMES[loc.locationId] || loc.locationId; return `${loc.locationId} (${displayName})`; }).sort((a, b) => a.localeCompare(b)); } catch (error) { logger.warn(`Could not fetch Tasks locations: ${error.message}`); return FALLBACK_LOCATIONS; } };