UNPKG

@google/clasp

Version:

Develop Apps Script Projects locally

24 lines (23 loc) 1.36 kB
import { Command } from 'commander'; import { intl } from '../intl.js'; import { assertGcpProjectConfigured, maybePromptForProjectId, withSpinner } from './utils.js'; export const command = new Command('list-apis') .alias('apis') .description('List enabled APIs for the current project') .action(async function () { const clasp = this.opts().clasp; await maybePromptForProjectId(clasp); assertGcpProjectConfigured(clasp); const spinnerMsg = intl.formatMessage({ id: "aY+ZR2", defaultMessage: [{ type: 0, value: "Fetching APIs..." }] }); const [enabledApis, availableApis] = await withSpinner(spinnerMsg, () => Promise.all([clasp.services.getEnabledServices(), clasp.services.getAvailableServices()])); const enabledApisLabel = intl.formatMessage({ id: "QfnjZ4", defaultMessage: [{ type: 0, value: "# Currently enabled APIs:" }] }); console.log(`\n${enabledApisLabel}`); for (const service of enabledApis) { console.log(`${service.name.padEnd(25)} - ${service.description.padEnd(60)}`); } const availableApisLabel = intl.formatMessage({ id: "qnV3uR", defaultMessage: [{ type: 0, value: "# List of available APIs:" }] }); console.log(`\n${availableApisLabel}`); for (const service of availableApis) { console.log(`${service.name.padEnd(25)} - ${service.description.padEnd(60)}`); } });