UNPKG

@google/clasp

Version:

Develop Apps Script Projects locally

46 lines (45 loc) 2.08 kB
// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // This file defines the 'show-authorized-user' command for the clasp CLI. import { Command } from 'commander'; import { getUserInfo } from '../auth/auth.js'; import { intl } from '../intl.js'; export const command = new Command('show-authorized-user') .description('Show information about the current authorizations state.') .action(async function () { var _a; const options = this.optsWithGlobals(); const auth = options.authInfo; let user = undefined; if (auth.credentials) { user = await getUserInfo(auth.credentials); } if (options.json) { const output = { loggedIn: auth.credentials ? true : false, email: (_a = user === null || user === void 0 ? void 0 : user.email) !== null && _a !== void 0 ? _a : undefined, }; console.log(JSON.stringify(output, null, 2)); return; } if (!auth.credentials) { const msg = intl.formatMessage({ id: "ZqMsgV", defaultMessage: [{ type: 0, value: "Not logged in." }] }); console.log(msg); return; } const msg = intl.formatMessage({ id: "sZ9k34", defaultMessage: [{ type: 5, value: "email", options: { undefined: { value: [{ type: 0, value: "You are logged in as an unknown user." }] }, other: { value: [{ type: 0, value: "You are logged in as " }, { type: 1, value: "email" }, { type: 0, value: "." }] } } }] }, { email: user === null || user === void 0 ? void 0 : user.email, }); console.log(msg); });