@google/clasp
Version:
Develop Apps Script Projects locally
30 lines (29 loc) • 1.71 kB
JavaScript
import { Command } from 'commander';
import { intl } from '../intl.js';
import { withSpinner } from './utils.js';
export const command = new Command('list-versions')
.alias('versions')
.description('List versions of a script')
.action(async function () {
const clasp = this.opts().clasp;
const spinnerMsg = intl.formatMessage({ id: "Cqxqh0", defaultMessage: [{ type: 0, value: "Fetching versions..." }] });
const versions = await withSpinner(spinnerMsg, async () => {
return await clasp.project.listVersions();
});
if (versions.results.length === 0) {
const msg = intl.formatMessage({ id: "Jmvq7L", defaultMessage: [{ type: 0, value: "No deployed versions of script." }] });
this.error(msg);
}
const successMessage = intl.formatMessage({ id: "6CS9SE", defaultMessage: [{ type: 0, value: "Found " }, { type: 6, value: "count", options: { one: { value: [{ type: 7 }, { type: 0, value: " version" }] }, other: { value: [{ type: 7 }, { type: 0, value: " versions" }] } }, offset: 0, pluralType: "cardinal" }, { type: 0, value: "." }] }, {
count: versions.results.length,
});
console.log(successMessage);
versions.results.reverse();
versions.results.forEach(version => {
const msg = intl.formatMessage({ id: "CAt8s3", defaultMessage: [{ type: 2, value: "version", style: null }, { type: 0, value: " - " }, { type: 5, value: "description", options: { undefined: { value: [{ type: 0, value: "No description" }] }, other: { value: [{ type: 1, value: "description" }] } } }] }, {
version: version.versionNumber,
description: version.description,
});
console.log(msg);
});
});