@sap-ux/deploy-tooling 0.2.8 → 0.2.10
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.
- package/dist/base/deploy.d.ts +1 -1
- package/dist/base/deploy.js +104 -46
- package/package.json +3 -3
package/dist/base/deploy.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function getCredentials<T extends BasicAuth | ServiceAuth | undef
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function deploy(archive: Buffer, config: AbapDeployConfig, logger: Logger): Promise<void>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Undeploy the given project from the given target using the given app name.
|
|
26
26
|
*
|
|
27
27
|
* @param config - deployment configuration
|
|
28
28
|
* @param logger - reference to the logger instance
|
package/dist/base/deploy.js
CHANGED
|
@@ -16,6 +16,7 @@ const store_1 = require("@sap-ux/store");
|
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const config_1 = require("./config");
|
|
18
18
|
const prompt_1 = require("./prompt");
|
|
19
|
+
const deploymentCommands = { tryUndeploy, tryDeploy };
|
|
19
20
|
/**
|
|
20
21
|
* Check the secure storage if it has credentials for the given target.
|
|
21
22
|
*
|
|
@@ -139,56 +140,54 @@ function createDeployService(config, logger) {
|
|
|
139
140
|
});
|
|
140
141
|
}
|
|
141
142
|
/**
|
|
142
|
-
*
|
|
143
|
+
* Handle exceptions thrown, in some cases we to retry them.
|
|
143
144
|
*
|
|
144
|
-
* @param
|
|
145
|
+
* @param command - the request type deploy | undeploy
|
|
146
|
+
* @param error - thrown error object
|
|
145
147
|
* @param service - instance of the axios-extension deployment service
|
|
146
|
-
* @param config -
|
|
148
|
+
* @param config - configuration used for the previous request
|
|
147
149
|
* @param logger - reference to the logger instance
|
|
150
|
+
* @param archive - archive file that is to be deployed
|
|
148
151
|
*/
|
|
149
|
-
function
|
|
152
|
+
function handleError(command, error, service, config, logger, archive) {
|
|
150
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
|
|
152
|
-
yield
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (!config.noRetry && (0, axios_extension_1.isAxiosError)(e)) {
|
|
156
|
-
const success = yield handleAxiosError(e.response, archive, service, config, logger);
|
|
157
|
-
if (success) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
logger.error('Deployment has failed.');
|
|
162
|
-
logger.debug((0, config_1.getConfigForLogging)(config));
|
|
163
|
-
if (!config.verbose) {
|
|
164
|
-
logger.error('Change logging level to debug your issue\n\t(see examples https://github.com/SAP/open-ux-tools/tree/main/packages/deploy-tooling#configuration-with-logging-enabled)');
|
|
154
|
+
if (!config.noRetry && (0, axios_extension_1.isAxiosError)(error)) {
|
|
155
|
+
const success = yield handleAxiosError(command, error.response, service, config, logger, archive);
|
|
156
|
+
if (success) {
|
|
157
|
+
return;
|
|
165
158
|
}
|
|
166
|
-
throw e;
|
|
167
159
|
}
|
|
160
|
+
logger.error(`${command === "tryDeploy" /* TryCommands.Deploy */ ? 'Deployment' : 'Undeployment'} has failed.`);
|
|
161
|
+
logger.debug((0, config_1.getConfigForLogging)(config));
|
|
162
|
+
if (!config.verbose) {
|
|
163
|
+
logger.error('Change logging level to debug your issue\n\t(see examples https://github.com/SAP/open-ux-tools/tree/main/packages/deploy-tooling#configuration-with-logging-enabled)');
|
|
164
|
+
}
|
|
165
|
+
throw error;
|
|
168
166
|
});
|
|
169
167
|
}
|
|
170
168
|
/**
|
|
171
169
|
* Main function for different deploy retry handling.
|
|
172
170
|
*
|
|
171
|
+
* @param command - the request type deploy | undeploy
|
|
173
172
|
* @param response - response of that triggered and axios error
|
|
174
|
-
* @param archive - archive file that is to be deployed
|
|
175
173
|
* @param service - instance of the axios-extension deployment service
|
|
176
174
|
* @param config - configuration used for the previous request
|
|
177
175
|
* @param logger - reference to the logger instance
|
|
176
|
+
* @param archive - archive file that is to be deployed
|
|
178
177
|
* @returns true if the error was handled otherwise false is return or an error is raised
|
|
179
178
|
*/
|
|
180
|
-
function handleAxiosError(
|
|
179
|
+
function handleAxiosError(command, response, service, config, logger, archive) {
|
|
181
180
|
var _a;
|
|
182
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
182
|
switch (response === null || response === void 0 ? void 0 : response.status) {
|
|
184
183
|
case 401:
|
|
185
|
-
logger.warn('Deployment failed with authentication error
|
|
184
|
+
logger.warn(`${command === "tryDeploy" /* TryCommands.Deploy */ ? 'Deployment' : 'Undeployment'} failed with authentication error.`);
|
|
186
185
|
logger.info('Please maintain correct credentials to avoid seeing this error\n\t(see help: https://www.npmjs.com/package/@sap/ux-ui5-tooling#setting-environment-variables-in-a-env-file)');
|
|
187
|
-
logger.info('Please enter your credentials
|
|
186
|
+
logger.info('Please enter your credentials.');
|
|
188
187
|
const credentials = yield (0, prompt_1.promptCredentials)((_a = service.defaults.auth) === null || _a === void 0 ? void 0 : _a.username);
|
|
189
188
|
if (Object.keys(credentials).length) {
|
|
190
189
|
service.defaults.auth = credentials;
|
|
191
|
-
yield
|
|
190
|
+
yield deploymentCommands[command](service, config, logger, archive);
|
|
192
191
|
return true;
|
|
193
192
|
}
|
|
194
193
|
else {
|
|
@@ -197,7 +196,7 @@ function handleAxiosError(response, archive, service, config, logger) {
|
|
|
197
196
|
case 412:
|
|
198
197
|
logger.warn('An app in the same repository with different sap app id found.');
|
|
199
198
|
if (config.yes || (yield (0, prompt_1.promptConfirmation)('Do you want to overwrite (Y/n)?'))) {
|
|
200
|
-
yield
|
|
199
|
+
yield deploymentCommands[command](service, Object.assign(Object.assign({}, config), { safe: false, noRetry: true }), logger, archive);
|
|
201
200
|
return true;
|
|
202
201
|
}
|
|
203
202
|
else {
|
|
@@ -209,51 +208,110 @@ function handleAxiosError(response, archive, service, config, logger) {
|
|
|
209
208
|
});
|
|
210
209
|
}
|
|
211
210
|
/**
|
|
212
|
-
*
|
|
211
|
+
* Generate a Ui5AbapRepositoryService instance from the supplied deployment config.
|
|
213
212
|
*
|
|
214
|
-
* @param archive - archive file that is to be deployed
|
|
215
213
|
* @param config - deployment configuration
|
|
216
214
|
* @param logger - reference to the logger instance
|
|
215
|
+
* @returns service returns the UI5 ABAP Repository service
|
|
217
216
|
*/
|
|
218
|
-
function
|
|
217
|
+
function getAbapService(config, logger) {
|
|
219
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
if (config.keep) {
|
|
221
|
-
(0, fs_1.writeFileSync)(`archive.zip`, archive);
|
|
222
|
-
}
|
|
223
219
|
const service = yield createDeployService(config, logger);
|
|
224
220
|
service.log = logger;
|
|
225
221
|
if (!config.strictSsl) {
|
|
226
222
|
logger.warn('You chose not to validate SSL certificate. Please verify the server certificate is trustful before proceeding. See documentation for recommended configuration (https://help.sap.com/viewer/17d50220bcd848aa854c9c182d65b699/Latest/en-US/4b318bede7eb4021a8be385c46c74045.html).');
|
|
227
223
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
224
|
+
return service;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Generic method to run the deployment request i.e. deploy | undeploy.
|
|
229
|
+
*
|
|
230
|
+
* @param command - the request type deploy | undeploy to be executed
|
|
231
|
+
* @param config - deployment configuration
|
|
232
|
+
* @param logger - reference to the logger instance
|
|
233
|
+
* @param archive - archive file that is to be deployed
|
|
234
|
+
*/
|
|
235
|
+
function runCommand(command, config, logger, archive = Buffer.from('')) {
|
|
236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
const service = yield getAbapService(config, logger);
|
|
238
|
+
logger.info(`Starting to ${command === "tryDeploy" /* TryCommands.Deploy */ ? 'deploy' : 'undeploy'}${config.test === true ? ' in test mode' : ''}.`);
|
|
239
|
+
yield deploymentCommands[command](service, config, logger, archive);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Try executing the deployment command and handle known errors.
|
|
244
|
+
*
|
|
245
|
+
* @param service - instance of the axios-extension deployment service
|
|
246
|
+
* @param config - deployment configuration
|
|
247
|
+
* @param logger - reference to the logger instance
|
|
248
|
+
* @param archive - archive file that is to be deployed
|
|
249
|
+
*/
|
|
250
|
+
function tryDeploy(service, config, logger, archive) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
try {
|
|
253
|
+
yield service.deploy({ archive, bsp: config.app, testMode: config.test, safeMode: config.safe });
|
|
254
|
+
if (config.test === true) {
|
|
255
|
+
logger.info('Deployment in TestMode completed. A successful TestMode execution does not necessarily mean that your upload will be successful.');
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
logger.info('Successfully deployed.');
|
|
259
|
+
}
|
|
232
260
|
}
|
|
233
|
-
|
|
234
|
-
|
|
261
|
+
catch (error) {
|
|
262
|
+
yield handleError("tryDeploy" /* TryCommands.Deploy */, error, service, config, logger, archive);
|
|
235
263
|
}
|
|
236
264
|
});
|
|
237
265
|
}
|
|
238
|
-
exports.deploy = deploy;
|
|
239
266
|
/**
|
|
240
267
|
* Deploy the given archive to the given target using the given app description.
|
|
241
268
|
*
|
|
269
|
+
* @param archive - archive file that is to be deployed
|
|
242
270
|
* @param config - deployment configuration
|
|
243
271
|
* @param logger - reference to the logger instance
|
|
244
272
|
*/
|
|
245
|
-
function
|
|
273
|
+
function deploy(archive, config, logger) {
|
|
246
274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (!config.strictSsl) {
|
|
250
|
-
logger.warn('You chose not to validate SSL certificate. Please verify the server certificate is trustful before proceeding. See documentation for recommended configuration (https://help.sap.com/viewer/17d50220bcd848aa854c9c182d65b699/Latest/en-US/4b318bede7eb4021a8be385c46c74045.html).');
|
|
275
|
+
if (config.keep) {
|
|
276
|
+
(0, fs_1.writeFileSync)(`archive.zip`, archive);
|
|
251
277
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
278
|
+
yield runCommand("tryDeploy" /* TryCommands.Deploy */, config, logger, archive);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
exports.deploy = deploy;
|
|
282
|
+
/**
|
|
283
|
+
* Try executing the undeployment command and handle known errors.
|
|
284
|
+
*
|
|
285
|
+
* @param service - instance of the axios-extension deployment service
|
|
286
|
+
* @param config - deployment configuration
|
|
287
|
+
* @param logger - reference to the logger instance
|
|
288
|
+
*/
|
|
289
|
+
function tryUndeploy(service, config, logger) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
+
try {
|
|
292
|
+
yield service.undeploy({ bsp: config.app, testMode: config.test });
|
|
293
|
+
if (config.test === true) {
|
|
294
|
+
logger.info('Undeployment in TestMode completed. A successful TestMode execution does not necessarily mean that your undeploy will be successful.');
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
logger.info('Successfully undeployed.');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
yield handleError("tryUndeploy" /* TryCommands.UnDeploy */, error, service, config, logger, Buffer.from(''));
|
|
255
302
|
}
|
|
256
303
|
});
|
|
257
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Undeploy the given project from the given target using the given app name.
|
|
307
|
+
*
|
|
308
|
+
* @param config - deployment configuration
|
|
309
|
+
* @param logger - reference to the logger instance
|
|
310
|
+
*/
|
|
311
|
+
function undeploy(config, logger) {
|
|
312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
+
yield runCommand("tryUndeploy" /* TryCommands.UnDeploy */, config, logger);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
258
316
|
exports.undeploy = undeploy;
|
|
259
317
|
//# sourceMappingURL=deploy.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.2.
|
|
12
|
+
"version": "0.2.10",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"dotenv": "16.0.0",
|
|
32
32
|
"prompts": "2.4.2",
|
|
33
33
|
"yazl": "2.5.1",
|
|
34
|
-
"@sap-ux/axios-extension": "1.2.
|
|
34
|
+
"@sap-ux/axios-extension": "1.2.6",
|
|
35
35
|
"@sap-ux/btp-utils": "0.11.5",
|
|
36
36
|
"@sap-ux/logger": "0.3.5",
|
|
37
37
|
"@sap-ux/store": "0.3.10",
|
|
38
|
-
"@sap-ux/ui5-config": "0.
|
|
38
|
+
"@sap-ux/ui5-config": "0.17.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/prompts": "2.0.14",
|