UNPKG

@sap/cds-dk

Version:

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

105 lines (73 loc) 2.97 kB
module.exports = Object.assign(push, { options: ['--subdomain', '--passcode', '--user', '--client', '--to', '--async', '--sync'], flags: [], shortcuts: ['-s', '-p', '-u', '-c', '-2'], help: ` # SYNOPSIS *cds push* [ <extension-project-directory> | <extension-archive> | <extension-url> ] Push your extension to the SaaS app in order to enable or update it. You may specify a project directory or a custom extension archive, either as a local file or as a URL to download it from. A download URL may contain Basic-Auth credentials as in 'https://user:pass@host'. By default, the current working directory is used as project directory. Unless a custom archive is given, the extension project will be automatically built in order to update the generated extension archive. This ensures the most recent extension model is pushed. Any authentication data will not be saved. # OPTIONS *-2* | *--to* <url> Specify the URL of the extensible SaaS app. Determined from the current user's active CDS or Cloud Foundry login by default. *-s* | *--subdomain* <tenant-subdomain> The tenant subdomain. Determined from project settings by default. *-p* | *--passcode* <passcode> Tenant-specific passcode for authentication. *-u* | *--user* <name>[:[<password>]] Username and optionally password for authentication with Basic Auth in test scenarios. *-c* | *--client* <clientid>[:<clientsecret>] Client ID and optionally Client Secret for authentication. *--async* Use the asynchronous server API to upload extensions. # SEE ALSO *cds pull* to get the CDS model of the SaaS app. *cds login* for more information on authentication options. *cds login* to save project settings and authentication data, simplifying multiple runs of this command. `}); async function push([projectFolder], options = {}) { const { statSync } = require('fs'); const { resolve } = require('path'); function isDir(dir) { return statSync(resolve(dir), { throwIfNoEntry: false })?.isDirectory(); } const [username, password] = options.user?.split(':') ?? []; delete options.user; const [clientid, clientsecret] = options.client?.split(':') ?? []; delete options.client; let extArchive; if (projectFolder) { if (isDir(projectFolder)) { const cds = require('../lib/cds'); cds.root = projectFolder; cds.env = cds.env.for('cds', projectFolder); } else { extArchive = projectFolder; projectFolder = undefined; } } const args = [{ ...options, projectFolder, username, password, clientid, clientsecret }]; if (extArchive) { args.push({ extArchive }); } await require('../lib/mtx/push').run(...args); }