UNPKG

@google/clasp

Version:

Develop Apps Script Projects locally

29 lines (28 loc) 1.48 kB
import { Command } from 'commander'; import { intl } from '../intl.js'; import { ellipsize, withSpinner } from './utils.js'; export const command = new Command('list-scripts') .alias('list') .description('List App Scripts projects') .option('--noShorten', 'Do not shorten long names', false) .action(async function (options) { const clasp = this.opts().clasp; const spinnerMsg = intl.formatMessage({ id: "x0awdZ", defaultMessage: [{ type: 0, value: "Finding your scripts..." }] }); const files = await withSpinner(spinnerMsg, async () => { return clasp.project.listScripts(); }); if (!files.results.length) { const msg = intl.formatMessage({ id: "rPMgOk", defaultMessage: [{ type: 0, value: "No script files found." }] }); console.log(msg); return; } const successMessage = intl.formatMessage({ id: "TBJtFJ", defaultMessage: [{ type: 0, value: "Found " }, { type: 6, value: "count", options: { one: { value: [{ type: 7 }, { type: 0, value: " script" }] }, other: { value: [{ type: 7 }, { type: 0, value: " scripts" }] } }, offset: 0, pluralType: "cardinal" }, { type: 0, value: "." }] }, { count: files.results.length, }); console.log(successMessage); files.results.forEach(file => { const name = options.noShorten ? file.name : ellipsize(file.name, 20); const url = `https://script.google.com/d/${file.id}/edit`; console.log(`${name} - ${url}`); }); });