@sap-ux/deploy-tooling 0.14.47 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.mergeConfig = exports.getDeploymentConfig = exports.getVersion = void 0;
13
4
  const ui5_config_1 = require("@sap-ux/ui5-config");
@@ -35,17 +26,14 @@ exports.getVersion = getVersion;
35
26
  * @param path - path to the ui5*.yaml file
36
27
  * @returns the configuration object or throws an error if it cannot be read.
37
28
  */
38
- function getDeploymentConfig(path) {
39
- var _a;
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const content = (0, fs_1.readFileSync)(path, 'utf-8');
42
- const ui5Config = yield ui5_config_1.UI5Config.newInstance(content);
43
- const config = (_a = ui5Config.findCustomTask(types_1.NAME)) === null || _a === void 0 ? void 0 : _a.configuration;
44
- if (!config) {
45
- throw new Error('The deployment configuration is missing.');
46
- }
47
- return config;
48
- });
29
+ async function getDeploymentConfig(path) {
30
+ const content = (0, fs_1.readFileSync)(path, 'utf-8');
31
+ const ui5Config = await ui5_config_1.UI5Config.newInstance(content);
32
+ const config = ui5Config.findCustomTask(types_1.NAME)?.configuration;
33
+ if (!config) {
34
+ throw new Error('The deployment configuration is missing.');
35
+ }
36
+ return config;
49
37
  }
50
38
  exports.getDeploymentConfig = getDeploymentConfig;
51
39
  /**
@@ -77,7 +65,7 @@ function getServiceFromEnv(targetUrl) {
77
65
  username: process.env.SERVICE_USERNAME,
78
66
  password: process.env.SERVICE_PASSWORD
79
67
  },
80
- url: targetUrl !== null && targetUrl !== void 0 ? targetUrl : process.env.SERVICE_URL,
68
+ url: targetUrl ?? process.env.SERVICE_URL,
81
69
  systemid: process.env.SERVICE_SYSTEM_ID
82
70
  };
83
71
  }
@@ -133,17 +121,16 @@ function getServiceKey(options, targetUrl) {
133
121
  * @returns merged target object
134
122
  */
135
123
  function mergeTarget(baseTarget, options) {
136
- var _a, _b, _c, _d, _e;
137
- const targetUrl = (_a = options.url) !== null && _a !== void 0 ? _a : baseTarget === null || baseTarget === void 0 ? void 0 : baseTarget.url;
124
+ const targetUrl = options.url ?? baseTarget?.url;
138
125
  return {
139
126
  url: targetUrl,
140
- client: (_b = options.client) !== null && _b !== void 0 ? _b : baseTarget === null || baseTarget === void 0 ? void 0 : baseTarget.client,
141
- scp: options.cloud !== undefined ? options.cloud : baseTarget === null || baseTarget === void 0 ? void 0 : baseTarget.cloud,
142
- authenticationType: (_c = options.authenticationType) !== null && _c !== void 0 ? _c : baseTarget === null || baseTarget === void 0 ? void 0 : baseTarget.authenticationType,
143
- destination: (_d = options.destination) !== null && _d !== void 0 ? _d : baseTarget === null || baseTarget === void 0 ? void 0 : baseTarget.destination,
127
+ client: options.client ?? baseTarget?.client,
128
+ scp: options.cloud !== undefined ? options.cloud : baseTarget?.cloud,
129
+ authenticationType: options.authenticationType ?? baseTarget?.authenticationType,
130
+ destination: options.destination ?? baseTarget?.destination,
144
131
  serviceKey: getServiceKey(options, targetUrl),
145
132
  params: options.queryParams ? parseQueryParams(options.queryParams) : undefined,
146
- service: (_e = options.service) !== null && _e !== void 0 ? _e : baseTarget === null || baseTarget === void 0 ? void 0 : baseTarget.service
133
+ service: options.service ?? baseTarget?.service
147
134
  };
148
135
  }
149
136
  /**
@@ -154,10 +141,13 @@ function mergeTarget(baseTarget, options) {
154
141
  * @returns merged credentials
155
142
  */
156
143
  function mergeCredentials(taskConfig, options) {
157
- var _a, _b;
158
144
  let credentials = taskConfig.credentials;
159
145
  if (options.username || options.password) {
160
- credentials = Object.assign(Object.assign({}, (credentials !== null && credentials !== void 0 ? credentials : {})), { username: (_a = options.username) !== null && _a !== void 0 ? _a : '', password: (_b = options.password) !== null && _b !== void 0 ? _b : '' });
146
+ credentials = {
147
+ ...(credentials ?? {}),
148
+ username: options.username ?? '',
149
+ password: options.password ?? ''
150
+ };
161
151
  }
162
152
  return credentials;
163
153
  }
@@ -168,36 +158,33 @@ function mergeCredentials(taskConfig, options) {
168
158
  * @param options - CLI options
169
159
  * @returns the merged config
170
160
  */
171
- function mergeConfig(taskConfig, options) {
172
- var _a, _b, _c, _d, _e, _f, _g, _h;
173
- return __awaiter(this, void 0, void 0, function* () {
174
- const app = {
175
- name: (_a = options.name) !== null && _a !== void 0 ? _a : (_b = taskConfig.app) === null || _b === void 0 ? void 0 : _b.name,
176
- description: (_c = options.description) !== null && _c !== void 0 ? _c : (_d = taskConfig.app) === null || _d === void 0 ? void 0 : _d.description,
177
- package: (_e = options.package) !== null && _e !== void 0 ? _e : (_f = taskConfig.app) === null || _f === void 0 ? void 0 : _f.package,
178
- transport: (_g = options.transport) !== null && _g !== void 0 ? _g : (_h = taskConfig.app) === null || _h === void 0 ? void 0 : _h.transport
179
- };
180
- const target = mergeTarget(taskConfig.target, options);
181
- const config = { app, target, credentials: mergeCredentials(taskConfig, options) };
182
- config.test = mergeFlag(options.test, taskConfig.test);
183
- config.safe = mergeFlag(options.safe, taskConfig.safe);
184
- config.keep = mergeFlag(options.keep, taskConfig.keep);
185
- config.strictSsl = mergeFlag(options.strictSsl, taskConfig.strictSsl);
186
- config.yes = mergeFlag(options.yes, taskConfig.yes);
187
- config.createTransport = mergeFlag(options.createTransport, taskConfig.createTransport);
188
- config.retry = process.env.NO_RETRY ? !process.env.NO_RETRY : mergeFlag(options.retry, taskConfig.retry);
189
- config.lrep = options.lrep;
190
- if (!options.archiveUrl && !options.archivePath && !options.archiveFolder) {
191
- options.archiveFolder = 'dist';
192
- }
193
- if (options.config && options.archiveFolder && !(0, path_1.isAbsolute)(options.archiveFolder)) {
194
- options.archiveFolder = (0, path_1.join)((0, path_1.dirname)(options.config), options.archiveFolder);
195
- }
196
- if (options.config && options.archivePath && !(0, path_1.isAbsolute)(options.archivePath)) {
197
- options.archivePath = (0, path_1.join)((0, path_1.dirname)(options.config), options.archivePath);
198
- }
199
- return config;
200
- });
161
+ async function mergeConfig(taskConfig, options) {
162
+ const app = {
163
+ name: options.name ?? taskConfig.app?.name,
164
+ description: options.description ?? taskConfig.app?.description,
165
+ package: options.package ?? taskConfig.app?.package,
166
+ transport: options.transport ?? taskConfig.app?.transport
167
+ };
168
+ const target = mergeTarget(taskConfig.target, options);
169
+ const config = { app, target, credentials: mergeCredentials(taskConfig, options) };
170
+ config.test = mergeFlag(options.test, taskConfig.test);
171
+ config.safe = mergeFlag(options.safe, taskConfig.safe);
172
+ config.keep = mergeFlag(options.keep, taskConfig.keep);
173
+ config.strictSsl = mergeFlag(options.strictSsl, taskConfig.strictSsl);
174
+ config.yes = mergeFlag(options.yes, taskConfig.yes);
175
+ config.createTransport = mergeFlag(options.createTransport, taskConfig.createTransport);
176
+ config.retry = process.env.NO_RETRY ? !process.env.NO_RETRY : mergeFlag(options.retry, taskConfig.retry);
177
+ config.lrep = options.lrep;
178
+ if (!options.archiveUrl && !options.archivePath && !options.archiveFolder) {
179
+ options.archiveFolder = 'dist';
180
+ }
181
+ if (options.config && options.archiveFolder && !(0, path_1.isAbsolute)(options.archiveFolder)) {
182
+ options.archiveFolder = (0, path_1.join)((0, path_1.dirname)(options.config), options.archiveFolder);
183
+ }
184
+ if (options.config && options.archivePath && !(0, path_1.isAbsolute)(options.archivePath)) {
185
+ options.archivePath = (0, path_1.join)((0, path_1.dirname)(options.config), options.archivePath);
186
+ }
187
+ return config;
201
188
  }
202
189
  exports.mergeConfig = mergeConfig;
203
190
  //# sourceMappingURL=config.js.map
package/dist/cli/index.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.runUndeploy = exports.runDeploy = exports.createCommand = void 0;
13
4
  const commander_1 = require("commander");
@@ -86,61 +77,55 @@ exports.createCommand = createCommand;
86
77
  * @param cmd - CLI command configuration to be executed
87
78
  * @returns a set of objects required for the command execution
88
79
  */
89
- function prepareRun(cmd) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- if (process.argv.length < 3) {
92
- cmd.help();
93
- }
94
- (0, dotenv_1.config)();
95
- const options = cmd.parse().opts();
96
- const logLevel = options.verbose ? logger_1.LogLevel.Silly : logger_1.LogLevel.Info;
97
- const logger = new logger_1.ToolsLogger({
98
- transports: [new logger_1.ConsoleTransport()],
99
- logLevel,
100
- logPrefix: types_1.NAME
101
- });
102
- // Handle empty config when not passed in
103
- const taskConfig = options.config ? yield (0, config_1.getDeploymentConfig)(options.config) : {};
104
- const config = yield (0, config_1.mergeConfig)(taskConfig, options);
105
- if (logLevel >= logger_1.LogLevel.Debug) {
106
- logger.debug((0, base_1.getConfigForLogging)(config));
107
- }
108
- (0, base_1.validateConfig)(config);
109
- (0, ui5_config_1.replaceEnvVariables)(config);
110
- return { cmd, logger, config, options };
80
+ async function prepareRun(cmd) {
81
+ if (process.argv.length < 3) {
82
+ cmd.help();
83
+ }
84
+ (0, dotenv_1.config)();
85
+ const options = cmd.parse().opts();
86
+ const logLevel = options.verbose ? logger_1.LogLevel.Silly : logger_1.LogLevel.Info;
87
+ const logger = new logger_1.ToolsLogger({
88
+ transports: [new logger_1.ConsoleTransport()],
89
+ logLevel,
90
+ logPrefix: types_1.NAME
111
91
  });
92
+ // Handle empty config when not passed in
93
+ const taskConfig = options.config ? await (0, config_1.getDeploymentConfig)(options.config) : {};
94
+ const config = await (0, config_1.mergeConfig)(taskConfig, options);
95
+ if (logLevel >= logger_1.LogLevel.Debug) {
96
+ logger.debug((0, base_1.getConfigForLogging)(config));
97
+ }
98
+ (0, base_1.validateConfig)(config);
99
+ (0, ui5_config_1.replaceEnvVariables)(config);
100
+ return { cmd, logger, config, options };
112
101
  }
113
102
  /**
114
103
  * Function that is to be executed when the exposed deploy command is executed.
115
104
  */
116
- function runDeploy() {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const cmd = createCommand('deploy');
119
- try {
120
- const { logger, options, config } = yield prepareRun(cmd);
121
- const archive = yield (0, archive_1.getArchive)(logger, options);
122
- yield (0, base_1.deploy)(archive, config, logger);
123
- }
124
- catch (error) {
125
- cmd.error(error.message);
126
- }
127
- });
105
+ async function runDeploy() {
106
+ const cmd = createCommand('deploy');
107
+ try {
108
+ const { logger, options, config } = await prepareRun(cmd);
109
+ const archive = await (0, archive_1.getArchive)(logger, options);
110
+ await (0, base_1.deploy)(archive, config, logger);
111
+ }
112
+ catch (error) {
113
+ cmd.error(error.message);
114
+ }
128
115
  }
129
116
  exports.runDeploy = runDeploy;
130
117
  /**
131
118
  * Function that is to be executed when the exposed undeploy command is executed.
132
119
  */
133
- function runUndeploy() {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- const cmd = createCommand('undeploy');
136
- try {
137
- const { logger, config } = yield prepareRun(cmd);
138
- yield (0, base_1.undeploy)(config, logger);
139
- }
140
- catch (error) {
141
- cmd.error(error.message);
142
- }
143
- });
120
+ async function runUndeploy() {
121
+ const cmd = createCommand('undeploy');
122
+ try {
123
+ const { logger, config } = await prepareRun(cmd);
124
+ await (0, base_1.undeploy)(config, logger);
125
+ }
126
+ catch (error) {
127
+ cmd.error(error.message);
128
+ }
144
129
  }
145
130
  exports.runUndeploy = runUndeploy;
146
131
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -23,23 +14,21 @@ const adm_zip_1 = __importDefault(require("adm-zip"));
23
14
  * @param exclude - array of regex patterns used to exclude folders from archive
24
15
  * @returns {*} {Promise<Buffer>} - archive
25
16
  */
26
- function createUi5Archive(logger, workspace, projectName, exclude = []) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- logger.info('Creating archive with UI5 build result.');
29
- const prefix = `/resources/${projectName}/`;
30
- const zip = new adm_zip_1.default();
31
- const resources = yield workspace.byGlob(`${prefix}**/*`);
32
- for (const resource of resources) {
33
- if (!exclude.some((regex) => RegExp(regex, 'g').exec(resource.getPath()))) {
34
- const path = resource.getPath().replace(prefix, '');
35
- logger.debug(`Adding ${path}`);
36
- const buffer = yield resource.getBuffer();
37
- zip.addFile(path, buffer);
38
- }
17
+ async function createUi5Archive(logger, workspace, projectName, exclude = []) {
18
+ logger.info('Creating archive with UI5 build result.');
19
+ const prefix = `/resources/${projectName}/`;
20
+ const zip = new adm_zip_1.default();
21
+ const resources = await workspace.byGlob(`${prefix}**/*`);
22
+ for (const resource of resources) {
23
+ if (!exclude.some((regex) => RegExp(regex, 'g').exec(resource.getPath()))) {
24
+ const path = resource.getPath().replace(prefix, '');
25
+ logger.debug(`Adding ${path}`);
26
+ const buffer = await resource.getBuffer();
27
+ zip.addFile(path, buffer);
39
28
  }
40
- logger.info('Archive created.');
41
- return zip.toBuffer();
42
- });
29
+ }
30
+ logger.info('Archive created.');
31
+ return zip.toBuffer();
43
32
  }
44
33
  exports.createUi5Archive = createUi5Archive;
45
34
  //# sourceMappingURL=archive.js.map
package/dist/ui5/index.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  const logger_1 = require("@sap-ux/logger");
12
3
  const types_1 = require("../types");
13
4
  const base_1 = require("../base");
@@ -21,24 +12,21 @@ const ui5_config_1 = require("@sap-ux/ui5-config");
21
12
  * @param params.workspace - reference to the UI5 tooling workspace object
22
13
  * @param params.options - project properties and configuration
23
14
  */
24
- function task({ workspace, options }) {
25
- var _a, _b, _c, _d, _e;
26
- return __awaiter(this, void 0, void 0, function* () {
27
- (0, dotenv_1.config)();
28
- const logLevel = (_b = (_a = options.configuration) === null || _a === void 0 ? void 0 : _a.log) !== null && _b !== void 0 ? _b : logger_1.LogLevel.Info;
29
- const logger = new logger_1.ToolsLogger({
30
- transports: [new logger_1.UI5ToolingTransport({ moduleName: `${types_1.NAME} ${options.projectName}` })],
31
- logLevel: (_d = (_c = options.configuration) === null || _c === void 0 ? void 0 : _c.log) !== null && _d !== void 0 ? _d : logger_1.LogLevel.Info
32
- });
33
- if (logLevel >= logger_1.LogLevel.Debug) {
34
- logger.debug(Object.assign(Object.assign({}, options.configuration), { credentials: undefined }));
35
- }
36
- const config = (0, base_1.validateConfig)(options.configuration);
37
- (0, ui5_config_1.replaceEnvVariables)(config);
38
- // The calling client can use either the projectNamespace or projectName when creating the workspace, needs to match when creating the archive.
39
- const archive = yield (0, archive_1.createUi5Archive)(logger, workspace, (_e = options.projectNamespace) !== null && _e !== void 0 ? _e : options.projectName, config.exclude);
40
- yield (0, base_1.deploy)(archive, config, logger);
15
+ async function task({ workspace, options }) {
16
+ (0, dotenv_1.config)();
17
+ const logLevel = options.configuration?.log ?? logger_1.LogLevel.Info;
18
+ const logger = new logger_1.ToolsLogger({
19
+ transports: [new logger_1.UI5ToolingTransport({ moduleName: `${types_1.NAME} ${options.projectName}` })],
20
+ logLevel: options.configuration?.log ?? logger_1.LogLevel.Info
41
21
  });
22
+ if (logLevel >= logger_1.LogLevel.Debug) {
23
+ logger.debug({ ...options.configuration, credentials: undefined });
24
+ }
25
+ const config = (0, base_1.validateConfig)(options.configuration);
26
+ (0, ui5_config_1.replaceEnvVariables)(config);
27
+ // The calling client can use either the projectNamespace or projectName when creating the workspace, needs to match when creating the archive.
28
+ const archive = await (0, archive_1.createUi5Archive)(logger, workspace, options.projectNamespace ?? options.projectName, config.exclude);
29
+ await (0, base_1.deploy)(archive, config, logger);
42
30
  }
43
31
  module.exports = task;
44
32
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Adeploy-tooling"
11
11
  },
12
- "version": "0.14.47",
12
+ "version": "0.15.2",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -32,17 +32,17 @@
32
32
  "prompts": "2.4.2",
33
33
  "adm-zip": "0.5.10",
34
34
  "chalk": "4.1.2",
35
- "@sap-ux/axios-extension": "1.14.4",
36
- "@sap-ux/btp-utils": "0.14.4",
37
- "@sap-ux/logger": "0.5.1",
38
- "@sap-ux/system-access": "0.4.7",
39
- "@sap-ux/ui5-config": "0.22.10",
40
- "@sap-ux/project-input-validator": "0.2.3"
35
+ "@sap-ux/axios-extension": "1.15.1",
36
+ "@sap-ux/btp-utils": "0.15.0",
37
+ "@sap-ux/logger": "0.6.0",
38
+ "@sap-ux/system-access": "0.5.1",
39
+ "@sap-ux/ui5-config": "0.23.1",
40
+ "@sap-ux/project-input-validator": "0.3.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/prompts": "2.4.4",
44
44
  "@types/adm-zip": "0.5.5",
45
- "@sap-ux/store": "0.6.0"
45
+ "@sap-ux/store": "0.7.0"
46
46
  },
47
47
  "ui5": {
48
48
  "dependencies": []