UNPKG

@google/clasp

Version:

Develop Apps Script Projects locally

34 lines (33 loc) 1.86 kB
import { Command } from 'commander'; import { intl } from '../intl.js'; import { withSpinner } from './utils.js'; export const command = new Command('create-deployment') .alias('deploy') .description('Deploy a project') .option('-V, --versionNumber <version>', 'The project version') .option('-d, --description <description>', 'The deployment description') .option('-i, --deploymentId <id>', 'The deployment ID to redeploy') .action(async function (options) { var _a, _b, _c; const clasp = this.opts().clasp; const deploymentId = options.deploymentId; const description = (_a = options.description) !== null && _a !== void 0 ? _a : ''; const versionNumber = options.versionNumber ? Number(options.versionNumber) : undefined; try { const spinnerMsg = intl.formatMessage({ id: "oL8t7p", defaultMessage: [{ type: 0, value: "Deploying project..." }] }); const deployment = await withSpinner(spinnerMsg, async () => { return await clasp.project.deploy(description, deploymentId, versionNumber); }); const successMessage = intl.formatMessage({ id: "182gSV", defaultMessage: [{ type: 0, value: "Deployed " }, { type: 1, value: "deploymentId" }, { type: 0, value: " " }, { type: 5, value: "version", options: { undefined: { value: [{ type: 0, value: "@HEAD" }] }, other: { value: [{ type: 0, value: "@" }, { type: 1, value: "version" }] } } }] }, { deploymentId: deployment.deploymentId, version: (_b = deployment.deploymentConfig) === null || _b === void 0 ? void 0 : _b.versionNumber, }); console.log(successMessage); } catch (error) { if (((_c = error.cause) === null || _c === void 0 ? void 0 : _c.code) === 'INVALID_ARGUMENT') { this.error(error.cause.message); } throw error; } });