UNPKG

@sap/cds-dk

Version:

Command line client and development toolkit for the SAP Cloud Application Programming Model

79 lines (56 loc) 2.35 kB
module.exports = Object.assign(upgrade, { init: cmd => new (require('../lib/mtx/tenant_action'))(cmd), options: ['--at', '--user'], flags: ['--local', '--resolve-bindings'], shortcuts: ['-a', '-u', '-l', '-b'], help: ` # SYNOPSIS *cds upgrade* <tenant> Upgrade a tenant subscribed to a multitenant SaaS app to its latest base model. Running *cds upgrade* with a URL is intended for non-productive use only, including against SaaS apps running on localhost with mock authentication. # OPTIONS *-a* | *--at* <url> Specify the URL of the SaaS app. Determined from the current user's active CDS or Cloud Foundry login by default. *-u* | *--user* <name>[:[<password>]] Username and optionally password for authentication with Basic Auth in test scenarios. Only relevant if <url> is given. May be omitted in case of dummy authentication. Tokens saved with *cds login* are not used for this command. *-l* | *--local* Run a locally-installed @sap/cds-mtxs and connect to it instead of a URL. Ignore settings saved with *cds login*. *-b* | *--resolve-bindings* Resolve remote service bindings configured via *cds bind*. # SEE ALSO *cds login* for more information on authentication options. *cds login* to save project settings and Basic-Auth data, simplifying multiple runs of this command. `}); async function upgrade([tenant], options = {}) { const { getMessage } = require('../lib/mtx/util/logging'); if (!tenant) { throw getMessage('Tenant not given.', { command: 'upgrade' }); } const libOptions = { tenant }; if (options.local) { libOptions.local = true; delete options.local; if (options.user) { throw getMessage('Username cannot be specified when running @sap/cds-mtxs locally.', { command: 'upgrade' }); } if (options.at) { throw getMessage('URL cannot be specified when running @sap/cds-mtxs locally.', { command: 'upgrade' }); } } const [username, password] = options.user?.split(':') ?? []; delete options.user; delete options['resolve-bindings']; await upgrade.init('upgrade').run({ ...options, username, password }, libOptions); }