@sap-ux/deploy-tooling 0.10.1 → 0.11.0
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/archive.d.ts +7 -12
- package/dist/base/archive.js +18 -70
- package/dist/base/config.d.ts +14 -0
- package/dist/base/config.js +13 -7
- package/dist/base/deploy.js +87 -48
- package/dist/base/index.d.ts +0 -1
- package/dist/base/index.js +0 -1
- package/dist/base/validate.d.ts +3 -2
- package/dist/base/validate.js +11 -2
- package/dist/cli/archive.js +6 -10
- package/dist/cli/config.js +1 -0
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +6 -3
- package/dist/types/index.d.ts +5 -1
- package/dist/ui5/archive.js +7 -5
- package/package.json +5 -5
package/dist/base/archive.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { ZipFile } from 'yazl';
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Check whether a given zip files contains an adaptation project and if yes returns the contained manisfest.appdesc_variant.
|
|
5
4
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
5
|
+
* @param archive buffer representing a zip file
|
|
6
|
+
* @returns the descriptor as object if the archive contains an adaptation project otherwise undefined
|
|
8
7
|
*/
|
|
9
|
-
export declare function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* @param zip zip file as object
|
|
14
|
-
* @returns the zip file as buffer
|
|
15
|
-
*/
|
|
16
|
-
export declare function createBuffer(zip: ZipFile): Promise<Buffer>;
|
|
8
|
+
export declare function getAppDescriptorVariant(archive: Buffer): {
|
|
9
|
+
namespace: string;
|
|
10
|
+
layer: 'CUSTOMER_BASE' | 'VENDOR';
|
|
11
|
+
} | undefined;
|
|
17
12
|
//# sourceMappingURL=archive.d.ts.map
|
package/dist/base/archive.js
CHANGED
|
@@ -1,82 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
4
|
};
|
|
18
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
20
|
-
const
|
|
21
|
-
const path_1 = require("path");
|
|
6
|
+
exports.getAppDescriptorVariant = void 0;
|
|
7
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
22
8
|
/**
|
|
23
|
-
*
|
|
9
|
+
* Check whether a given zip files contains an adaptation project and if yes returns the contained manisfest.appdesc_variant.
|
|
24
10
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
11
|
+
* @param archive buffer representing a zip file
|
|
12
|
+
* @returns the descriptor as object if the archive contains an adaptation project otherwise undefined
|
|
27
13
|
*/
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
names.push(...getFileNames(filePath));
|
|
14
|
+
function getAppDescriptorVariant(archive) {
|
|
15
|
+
try {
|
|
16
|
+
const zip = new adm_zip_1.default(archive);
|
|
17
|
+
const file = zip.getEntry('manifest.appdescr_variant');
|
|
18
|
+
if (file) {
|
|
19
|
+
return JSON.parse(file.getData().toString());
|
|
35
20
|
}
|
|
36
21
|
else {
|
|
37
|
-
|
|
22
|
+
return undefined;
|
|
38
23
|
}
|
|
39
24
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Create a zip file based on the given object.
|
|
45
|
-
*
|
|
46
|
-
* @param zip zip file as object
|
|
47
|
-
* @returns the zip file as buffer
|
|
48
|
-
*/
|
|
49
|
-
function createBuffer(zip) {
|
|
50
|
-
var _a, e_1, _b, _c;
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
yield new Promise((resolve) => {
|
|
53
|
-
zip.end({ forceZip64Format: false }, () => {
|
|
54
|
-
resolve();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
const chunks = [];
|
|
58
|
-
try {
|
|
59
|
-
for (var _d = true, _e = __asyncValues(zip.outputStream), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
60
|
-
_c = _f.value;
|
|
61
|
-
_d = false;
|
|
62
|
-
try {
|
|
63
|
-
const chunk = _c;
|
|
64
|
-
chunks.push(chunk);
|
|
65
|
-
}
|
|
66
|
-
finally {
|
|
67
|
-
_d = true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
72
|
-
finally {
|
|
73
|
-
try {
|
|
74
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
75
|
-
}
|
|
76
|
-
finally { if (e_1) throw e_1.error; }
|
|
77
|
-
}
|
|
78
|
-
return Buffer.concat(chunks);
|
|
79
|
-
});
|
|
25
|
+
catch (error) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
80
28
|
}
|
|
81
|
-
exports.
|
|
29
|
+
exports.getAppDescriptorVariant = getAppDescriptorVariant;
|
|
82
30
|
//# sourceMappingURL=archive.js.map
|
package/dist/base/config.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AbapDeployConfig } from '../types';
|
|
2
|
+
import type { BspConfig } from '@sap-ux/axios-extension';
|
|
2
3
|
/**
|
|
3
4
|
* Clones the given config and removes secrets so that it can be printed to a log file.
|
|
4
5
|
*
|
|
@@ -14,6 +15,19 @@ export declare function getConfigForLogging(config: AbapDeployConfig): AbapDeplo
|
|
|
14
15
|
* @param obj - any object structure
|
|
15
16
|
*/
|
|
16
17
|
export declare function replaceEnvVariables(obj: object): void;
|
|
18
|
+
/**
|
|
19
|
+
* Helper function for throwing a missing property error.
|
|
20
|
+
*
|
|
21
|
+
* @param property Invalid missing property
|
|
22
|
+
*/
|
|
23
|
+
export declare function throwConfigMissingError(property: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Type checking the config object.
|
|
26
|
+
*
|
|
27
|
+
* @param config - config to be checked
|
|
28
|
+
* @returns true if it is of type BSP config
|
|
29
|
+
*/
|
|
30
|
+
export declare function isBspConfig(config: Partial<BspConfig>): config is BspConfig;
|
|
17
31
|
/**
|
|
18
32
|
* Validate the given config. If anything mandatory is missing throw an error.
|
|
19
33
|
*
|
package/dist/base/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateConfig = exports.replaceEnvVariables = exports.getConfigForLogging = void 0;
|
|
3
|
+
exports.validateConfig = exports.isBspConfig = exports.throwConfigMissingError = exports.replaceEnvVariables = exports.getConfigForLogging = void 0;
|
|
4
4
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
5
5
|
const system_access_1 = require("@sap-ux/system-access");
|
|
6
6
|
/**
|
|
@@ -45,6 +45,7 @@ exports.replaceEnvVariables = replaceEnvVariables;
|
|
|
45
45
|
function throwConfigMissingError(property) {
|
|
46
46
|
throw new Error(`Invalid deployment configuration. Property ${property} is missing.`);
|
|
47
47
|
}
|
|
48
|
+
exports.throwConfigMissingError = throwConfigMissingError;
|
|
48
49
|
/**
|
|
49
50
|
* Validate the given target config. If anything mandatory is missing throw an error.
|
|
50
51
|
*
|
|
@@ -62,6 +63,16 @@ function validateTarget(target) {
|
|
|
62
63
|
}
|
|
63
64
|
return target;
|
|
64
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Type checking the config object.
|
|
68
|
+
*
|
|
69
|
+
* @param config - config to be checked
|
|
70
|
+
* @returns true if it is of type BSP config
|
|
71
|
+
*/
|
|
72
|
+
function isBspConfig(config) {
|
|
73
|
+
return config.name !== undefined;
|
|
74
|
+
}
|
|
75
|
+
exports.isBspConfig = isBspConfig;
|
|
65
76
|
/**
|
|
66
77
|
* Validate the given config. If anything mandatory is missing throw an error.
|
|
67
78
|
*
|
|
@@ -78,12 +89,7 @@ function validateConfig(config) {
|
|
|
78
89
|
else {
|
|
79
90
|
throwConfigMissingError('target');
|
|
80
91
|
}
|
|
81
|
-
if (config.app) {
|
|
82
|
-
if (!config.app.name) {
|
|
83
|
-
throwConfigMissingError('app-name');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
92
|
+
if (!config.app) {
|
|
87
93
|
throwConfigMissingError('app');
|
|
88
94
|
}
|
|
89
95
|
return config;
|
package/dist/base/deploy.js
CHANGED
|
@@ -15,8 +15,8 @@ const fs_1 = require("fs");
|
|
|
15
15
|
const config_1 = require("./config");
|
|
16
16
|
const prompt_1 = require("./prompt");
|
|
17
17
|
const system_access_1 = require("@sap-ux/system-access");
|
|
18
|
+
const archive_1 = require("./archive");
|
|
18
19
|
const validate_1 = require("./validate");
|
|
19
|
-
const deploymentCommands = { tryUndeploy, tryDeploy };
|
|
20
20
|
/**
|
|
21
21
|
* Handle exceptions thrown, in some cases we to retry them.
|
|
22
22
|
*
|
|
@@ -36,7 +36,7 @@ function handleError(command, error, provider, config, logger, archive) {
|
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
logger.error(`${command ===
|
|
39
|
+
logger.error(`${command === tryDeploy ? 'Deployment' : 'Undeployment'} has failed.`);
|
|
40
40
|
logger.debug((0, config_1.getConfigForLogging)(config));
|
|
41
41
|
if (!config.verbose) {
|
|
42
42
|
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)');
|
|
@@ -58,7 +58,7 @@ function handle412Error(command, provider, config, logger, archive) {
|
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
logger.warn('An app in the same repository with different sap app id found.');
|
|
60
60
|
if (config.yes || (yield (0, prompt_1.promptConfirmation)('Do you want to overwrite (Y/n)?'))) {
|
|
61
|
-
yield
|
|
61
|
+
yield command(provider, Object.assign(Object.assign({}, config), { safe: false, retry: false }), logger, archive);
|
|
62
62
|
return true;
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
@@ -77,13 +77,12 @@ function handle412Error(command, provider, config, logger, archive) {
|
|
|
77
77
|
* @returns true if the error was handled otherwise false is returned
|
|
78
78
|
*/
|
|
79
79
|
function handle401Error(command, provider, config, logger, archive) {
|
|
80
|
-
var _a;
|
|
80
|
+
var _a, _b;
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
logger.warn(`${command ===
|
|
82
|
+
logger.warn(`${command === tryDeploy ? 'Deployment' : 'Undeployment'} failed with authentication error.`);
|
|
83
83
|
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)');
|
|
84
84
|
logger.info('Please enter your credentials.');
|
|
85
|
-
const
|
|
86
|
-
const credentials = yield (0, system_access_1.getCredentialsWithPrompts)((_a = service.defaults.auth) === null || _a === void 0 ? void 0 : _a.username);
|
|
85
|
+
const credentials = yield (0, system_access_1.getCredentialsWithPrompts)((_b = (_a = provider.defaults) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.username);
|
|
87
86
|
if (Object.keys(credentials).length) {
|
|
88
87
|
if (config.target.serviceKey) {
|
|
89
88
|
config.target.serviceKey.uaa.username = credentials.username;
|
|
@@ -92,7 +91,7 @@ function handle401Error(command, provider, config, logger, archive) {
|
|
|
92
91
|
else {
|
|
93
92
|
config.credentials = credentials;
|
|
94
93
|
}
|
|
95
|
-
yield
|
|
94
|
+
yield command(provider, config, logger, archive);
|
|
96
95
|
return true;
|
|
97
96
|
}
|
|
98
97
|
else {
|
|
@@ -124,16 +123,16 @@ function axiosErrorRetryHandler(command, response, provider, config, logger, arc
|
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
/**
|
|
127
|
-
* Generate a
|
|
126
|
+
* Generate a service instance for deployment from the supplied deployment config.
|
|
128
127
|
*
|
|
129
|
-
* @param
|
|
128
|
+
* @param factoryFn - function to create a service
|
|
130
129
|
* @param config - deployment configuration
|
|
131
130
|
* @param logger - reference to the logger instance
|
|
132
131
|
* @returns service returns the UI5 ABAP Repository service
|
|
133
132
|
*/
|
|
134
|
-
function
|
|
133
|
+
function getDeployService(factoryFn, config, logger) {
|
|
135
134
|
var _a;
|
|
136
|
-
const service =
|
|
135
|
+
const service = factoryFn((_a = config.target) === null || _a === void 0 ? void 0 : _a.service);
|
|
137
136
|
service.log = logger;
|
|
138
137
|
if (!config.strictSsl) {
|
|
139
138
|
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).');
|
|
@@ -153,41 +152,68 @@ function createTransportRequest(config, logger, provider) {
|
|
|
153
152
|
var _a;
|
|
154
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
154
|
if (!provider) {
|
|
156
|
-
provider = yield (
|
|
157
|
-
auth: config.credentials,
|
|
158
|
-
ignoreCertErrors: !config.strictSsl
|
|
159
|
-
}, !!config.target.scp, logger);
|
|
155
|
+
provider = yield createProvider(config, logger);
|
|
160
156
|
}
|
|
161
157
|
const adtService = yield provider.getAdtService(axios_extension_1.TransportRequestService);
|
|
158
|
+
const ui5AppName = (0, config_1.isBspConfig)(config.app) ? config.app.name : '';
|
|
162
159
|
const transportRequest = yield (adtService === null || adtService === void 0 ? void 0 : adtService.createTransportRequest({
|
|
163
160
|
packageName: (_a = config.app.package) !== null && _a !== void 0 ? _a : '',
|
|
164
|
-
ui5AppName
|
|
161
|
+
ui5AppName,
|
|
165
162
|
description: 'Created by @sap-ux/deploy-tooling'
|
|
166
163
|
}));
|
|
167
164
|
if (transportRequest) {
|
|
168
|
-
logger.info(`Transport request ${transportRequest} created for application ${
|
|
165
|
+
logger.info(`Transport request ${transportRequest} created for application ${ui5AppName}.`);
|
|
169
166
|
return transportRequest;
|
|
170
167
|
}
|
|
171
|
-
throw new Error(`Transport request could not be created for application ${
|
|
168
|
+
throw new Error(`Transport request could not be created for application ${ui5AppName}.`);
|
|
172
169
|
});
|
|
173
170
|
}
|
|
174
171
|
exports.createTransportRequest = createTransportRequest;
|
|
175
172
|
/**
|
|
176
|
-
*
|
|
173
|
+
* Create a service provider based on the given config.
|
|
177
174
|
*
|
|
178
|
-
* @param command - the request type deploy | undeploy to be executed
|
|
179
175
|
* @param config - deployment configuration
|
|
180
176
|
* @param logger - reference to the logger instance
|
|
181
|
-
* @
|
|
177
|
+
* @returns an instance of an ABAP service provider
|
|
182
178
|
*/
|
|
183
|
-
function
|
|
179
|
+
function createProvider(config, logger) {
|
|
184
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
|
|
181
|
+
return yield (0, system_access_1.createAbapServiceProvider)(config.target, {
|
|
186
182
|
auth: config.credentials,
|
|
187
183
|
ignoreCertErrors: !config.strictSsl
|
|
188
184
|
}, !!config.target.scp, logger);
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Check if the archive is an adapation project and if yes, try to deploy it to the layered repository.
|
|
189
|
+
*
|
|
190
|
+
* @param provider - instance of the axios-extension abap service provider
|
|
191
|
+
* @param config - deployment configuration
|
|
192
|
+
* @param logger - reference to the logger instance
|
|
193
|
+
* @param archive - archive file that is to be deployed
|
|
194
|
+
*/
|
|
195
|
+
function tryDeployToLrep(provider, config, logger, archive) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
logger.debug('No BSP name provided, checking if it is an adaptation project');
|
|
198
|
+
const descriptor = (0, archive_1.getAppDescriptorVariant)(archive);
|
|
199
|
+
if (descriptor) {
|
|
200
|
+
if (config.test) {
|
|
201
|
+
throw new Error('Deployment in test mode not supported for deployments to the layered repository.');
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
logger.debug('Deploying an adaptation project to LREP');
|
|
205
|
+
const service = getDeployService(provider.getLayeredRepository.bind(provider), config, logger);
|
|
206
|
+
yield service.deploy(archive, {
|
|
207
|
+
namespace: descriptor.namespace,
|
|
208
|
+
layer: descriptor.layer,
|
|
209
|
+
package: config.app.package,
|
|
210
|
+
transport: config.app.transport
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
(0, config_1.throwConfigMissingError)('app-name');
|
|
216
|
+
}
|
|
191
217
|
});
|
|
192
218
|
}
|
|
193
219
|
/**
|
|
@@ -199,30 +225,27 @@ function runCommand(command, config, logger, archive = Buffer.from('')) {
|
|
|
199
225
|
* @param archive - archive file that is to be deployed
|
|
200
226
|
*/
|
|
201
227
|
function tryDeploy(provider, config, logger, archive) {
|
|
202
|
-
var _a, _b, _c, _d, _e;
|
|
203
228
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
229
|
try {
|
|
205
230
|
if (config.createTransport) {
|
|
206
231
|
config.app.transport = yield createTransportRequest(config, logger, provider);
|
|
207
|
-
// Reset as we
|
|
232
|
+
// Reset as we don't want other flows kicking it off again!
|
|
208
233
|
config.createTransport = false;
|
|
209
234
|
}
|
|
210
|
-
|
|
211
|
-
if (config.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
client: (_d = config.target.client) !== null && _d !== void 0 ? _d : '',
|
|
218
|
-
url: (_e = config.target.url) !== null && _e !== void 0 ? _e : ''
|
|
219
|
-
}, provider, logger);
|
|
220
|
-
if (!validateOutput.result) {
|
|
221
|
-
logger.info(`Results of validating the deployment configuration settings:${(0, validate_1.formatSummary)(validateOutput.summary)}`);
|
|
235
|
+
// check if deployment of BSP is requested
|
|
236
|
+
if ((0, config_1.isBspConfig)(config.app)) {
|
|
237
|
+
if (config.test === true) {
|
|
238
|
+
const validateOutput = yield (0, validate_1.validateBeforeDeploy)(config, provider, logger);
|
|
239
|
+
if (!validateOutput.result) {
|
|
240
|
+
logger.info(`Results of validating the deployment configuration settings:${(0, validate_1.formatSummary)(validateOutput.summary)}`);
|
|
241
|
+
}
|
|
222
242
|
}
|
|
243
|
+
const service = getDeployService(provider.getUi5AbapRepository.bind(provider), config, logger);
|
|
244
|
+
yield service.deploy({ archive, bsp: config.app, testMode: config.test, safeMode: config.safe });
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
yield tryDeployToLrep(provider, config, logger, archive);
|
|
223
248
|
}
|
|
224
|
-
const service = getUi5AbapRepositoryService(provider, config, logger);
|
|
225
|
-
yield service.deploy({ archive, bsp: config.app, testMode: config.test, safeMode: config.safe });
|
|
226
249
|
if (config.test === true) {
|
|
227
250
|
logger.info('Deployment in TestMode completed. A successful TestMode execution does not necessarily mean that your upload will be successful.');
|
|
228
251
|
}
|
|
@@ -231,7 +254,7 @@ function tryDeploy(provider, config, logger, archive) {
|
|
|
231
254
|
}
|
|
232
255
|
}
|
|
233
256
|
catch (error) {
|
|
234
|
-
yield handleError(
|
|
257
|
+
yield handleError(tryDeploy, error, provider, config, logger, archive);
|
|
235
258
|
}
|
|
236
259
|
});
|
|
237
260
|
}
|
|
@@ -247,7 +270,9 @@ function deploy(archive, config, logger) {
|
|
|
247
270
|
if (config.keep) {
|
|
248
271
|
(0, fs_1.writeFileSync)(`archive.zip`, archive);
|
|
249
272
|
}
|
|
250
|
-
|
|
273
|
+
const provider = yield createProvider(config, logger);
|
|
274
|
+
logger.info(`Starting to deploy${config.test === true ? ' in test mode' : ''}.`);
|
|
275
|
+
yield tryDeploy(provider, config, logger, archive);
|
|
251
276
|
});
|
|
252
277
|
}
|
|
253
278
|
exports.deploy = deploy;
|
|
@@ -265,8 +290,20 @@ function tryUndeploy(provider, config, logger) {
|
|
|
265
290
|
config.app.transport = yield createTransportRequest(config, logger, provider);
|
|
266
291
|
config.createTransport = false;
|
|
267
292
|
}
|
|
268
|
-
|
|
269
|
-
|
|
293
|
+
if (config.lrep) {
|
|
294
|
+
const service = getDeployService(provider.getLayeredRepository.bind(provider), config, logger);
|
|
295
|
+
yield service.undeploy({
|
|
296
|
+
namespace: config.lrep,
|
|
297
|
+
transport: config.app.transport
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
else if ((0, config_1.isBspConfig)(config.app)) {
|
|
301
|
+
const service = getDeployService(provider.getUi5AbapRepository.bind(provider), config, logger);
|
|
302
|
+
yield service.undeploy({ bsp: config.app, testMode: config.test });
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
(0, config_1.throwConfigMissingError)('app-name');
|
|
306
|
+
}
|
|
270
307
|
if (config.test === true) {
|
|
271
308
|
logger.info('Undeployment in TestMode completed. A successful TestMode execution does not necessarily mean that your undeploy will be successful.');
|
|
272
309
|
}
|
|
@@ -275,7 +312,7 @@ function tryUndeploy(provider, config, logger) {
|
|
|
275
312
|
}
|
|
276
313
|
}
|
|
277
314
|
catch (error) {
|
|
278
|
-
yield handleError(
|
|
315
|
+
yield handleError(tryUndeploy, error, provider, config, logger, Buffer.from(''));
|
|
279
316
|
}
|
|
280
317
|
});
|
|
281
318
|
}
|
|
@@ -287,7 +324,9 @@ function tryUndeploy(provider, config, logger) {
|
|
|
287
324
|
*/
|
|
288
325
|
function undeploy(config, logger) {
|
|
289
326
|
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
-
|
|
327
|
+
const provider = yield createProvider(config, logger);
|
|
328
|
+
logger.info(`Starting to undeploy ${config.test === true ? ' in test mode' : ''}.`);
|
|
329
|
+
yield tryUndeploy(provider, config, logger);
|
|
291
330
|
});
|
|
292
331
|
}
|
|
293
332
|
exports.undeploy = undeploy;
|
package/dist/base/index.d.ts
CHANGED
package/dist/base/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./archive"), exports);
|
|
18
17
|
__exportStar(require("./config"), exports);
|
|
19
18
|
__exportStar(require("./deploy"), exports);
|
|
20
19
|
__exportStar(require("./prompt"), exports);
|
package/dist/base/validate.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AbapServiceProvider } from '@sap-ux/axios-extension';
|
|
2
2
|
import type { Logger } from '@sap-ux/logger';
|
|
3
|
+
import type { AbapDeployConfig } from '../types';
|
|
3
4
|
export type ValidationInputs = {
|
|
4
5
|
appName: string;
|
|
5
6
|
description: string;
|
|
@@ -36,12 +37,12 @@ export declare const summaryMessage: {
|
|
|
36
37
|
/**
|
|
37
38
|
* Validation of deploy configuration before running deploy-test.
|
|
38
39
|
*
|
|
39
|
-
* @param
|
|
40
|
+
* @param config Deploy configuration that needs to be validated
|
|
40
41
|
* @param provider AbapServiceProvider
|
|
41
42
|
* @param logger Logger used by deploy tooling
|
|
42
43
|
* @returns Validation result and a summary report of identified issues.
|
|
43
44
|
*/
|
|
44
|
-
export declare function validateBeforeDeploy(
|
|
45
|
+
export declare function validateBeforeDeploy(config: AbapDeployConfig, provider: AbapServiceProvider, logger: Logger): Promise<ValidationOutput>;
|
|
45
46
|
/**
|
|
46
47
|
* Format a list of summary records that is ready to be printed on the console.
|
|
47
48
|
*
|
package/dist/base/validate.js
CHANGED
|
@@ -35,17 +35,26 @@ exports.summaryMessage = {
|
|
|
35
35
|
/**
|
|
36
36
|
* Validation of deploy configuration before running deploy-test.
|
|
37
37
|
*
|
|
38
|
-
* @param
|
|
38
|
+
* @param config Deploy configuration that needs to be validated
|
|
39
39
|
* @param provider AbapServiceProvider
|
|
40
40
|
* @param logger Logger used by deploy tooling
|
|
41
41
|
* @returns Validation result and a summary report of identified issues.
|
|
42
42
|
*/
|
|
43
|
-
function validateBeforeDeploy(
|
|
43
|
+
function validateBeforeDeploy(config, provider, logger) {
|
|
44
|
+
var _a, _b, _c, _d, _e, _f;
|
|
44
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
46
|
const output = {
|
|
46
47
|
summary: [],
|
|
47
48
|
result: true
|
|
48
49
|
};
|
|
50
|
+
const input = {
|
|
51
|
+
appName: (_a = config.app.name) !== null && _a !== void 0 ? _a : '',
|
|
52
|
+
description: (_b = config.app.description) !== null && _b !== void 0 ? _b : '',
|
|
53
|
+
package: (_c = config.app.package) !== null && _c !== void 0 ? _c : '',
|
|
54
|
+
transport: (_d = config.app.transport) !== null && _d !== void 0 ? _d : '',
|
|
55
|
+
client: (_e = config.target.client) !== null && _e !== void 0 ? _e : '',
|
|
56
|
+
url: (_f = config.target.url) !== null && _f !== void 0 ? _f : ''
|
|
57
|
+
};
|
|
49
58
|
// output is passed by reference and status updated during the internal pipeline below.
|
|
50
59
|
yield validateInputTextFormat(input, output, provider, logger);
|
|
51
60
|
yield validatePackageWithAdt(input, output, provider, logger);
|
package/dist/cli/archive.js
CHANGED
|
@@ -15,9 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getArchive = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const fs_1 = require("fs");
|
|
18
|
-
const
|
|
19
|
-
const path_1 = require("path");
|
|
20
|
-
const archive_1 = require("../base/archive");
|
|
18
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
21
19
|
const https_1 = require("https");
|
|
22
20
|
/**
|
|
23
21
|
* Get/read zip file from the given path.
|
|
@@ -74,15 +72,13 @@ function fetchArchiveFromUrl(logger, url, rejectUnauthorized) {
|
|
|
74
72
|
function createArchiveFromFolder(logger, path) {
|
|
75
73
|
try {
|
|
76
74
|
logger.info(`Creating archive from ${path}.`);
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
for (const
|
|
80
|
-
|
|
81
|
-
logger.debug(`Adding ${relPath}`);
|
|
82
|
-
zip.addFile(filePath, relPath);
|
|
75
|
+
const zip = new adm_zip_1.default();
|
|
76
|
+
zip.addLocalFolder(path);
|
|
77
|
+
for (const entry of zip.getEntries()) {
|
|
78
|
+
logger.debug(`Adding ${entry.entryName}`);
|
|
83
79
|
}
|
|
84
80
|
logger.info(`Archive created from ${path}.`);
|
|
85
|
-
return
|
|
81
|
+
return zip.toBufferPromise();
|
|
86
82
|
}
|
|
87
83
|
catch (error) {
|
|
88
84
|
throw new Error(`Archive creation has failed. Please ensure ${path} is valid and accessible.`);
|
package/dist/cli/config.js
CHANGED
|
@@ -185,6 +185,7 @@ function mergeConfig(taskConfig, options) {
|
|
|
185
185
|
config.yes = mergeFlag(options.yes, taskConfig.yes);
|
|
186
186
|
config.createTransport = mergeFlag(options.createTransport, taskConfig.createTransport);
|
|
187
187
|
config.retry = process.env.NO_RETRY ? !process.env.NO_RETRY : mergeFlag(options.retry, taskConfig.retry);
|
|
188
|
+
config.lrep = options.lrep;
|
|
188
189
|
if (!options.archiveUrl && !options.archivePath && !options.archiveFolder) {
|
|
189
190
|
options.archiveFolder = 'dist';
|
|
190
191
|
}
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ import { Command } from 'commander';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function createCommand(name: 'deploy' | 'undeploy'): Command;
|
|
9
9
|
/**
|
|
10
|
-
* Function that is to be
|
|
10
|
+
* Function that is to be executed when the exposed deploy command is executed.
|
|
11
11
|
*/
|
|
12
12
|
export declare function runDeploy(): Promise<void>;
|
|
13
13
|
/**
|
|
14
|
-
* Function that is to be
|
|
14
|
+
* Function that is to be executed when the exposed undeploy command is executed.
|
|
15
15
|
*/
|
|
16
16
|
export declare function runUndeploy(): Promise<void>;
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cli/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function createCommand(name) {
|
|
|
35
35
|
.addOption(new commander_1.Option('--url <target-url>', 'URL of target ABAP system').conflicts('destination'))
|
|
36
36
|
.addOption(new commander_1.Option('--client <sap-client>', 'Client number of target ABAP system').conflicts('destination'))
|
|
37
37
|
.addOption(new commander_1.Option('--cloud', 'Target is an ABAP Cloud system').conflicts('destination'))
|
|
38
|
-
.addOption(new commander_1.Option('--service <service-path>', 'Target
|
|
38
|
+
.addOption(new commander_1.Option('--service <service-path>', 'Target alias for deployment service'))
|
|
39
39
|
.addOption(new commander_1.Option('--cloud-service-key <file-location>', 'JSON file location with the ABAP cloud service key.').conflicts('destination'))
|
|
40
40
|
.addOption(new commander_1.Option('--cloud-service-env', 'Read ABAP cloud service properties from environment variables or .env file').conflicts(['cloudServiceKey', 'destination']))
|
|
41
41
|
.option('--package <abap-package>', 'Package name for deploy target ABAP system')
|
|
@@ -72,6 +72,9 @@ function createCommand(name) {
|
|
|
72
72
|
'archivePath'
|
|
73
73
|
]));
|
|
74
74
|
}
|
|
75
|
+
else if (name === 'undeploy') {
|
|
76
|
+
command.addOption(new commander_1.Option('--lrep <namespace>', 'Undeploy the given namespace from the layered repository (for adaptation projects)').conflicts(['test', 'name']));
|
|
77
|
+
}
|
|
75
78
|
return command.version((0, config_1.getVersion)(), '-v, --version', 'version of the deploy tooling');
|
|
76
79
|
}
|
|
77
80
|
exports.createCommand = createCommand;
|
|
@@ -106,7 +109,7 @@ function prepareRun(cmd) {
|
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
/**
|
|
109
|
-
* Function that is to be
|
|
112
|
+
* Function that is to be executed when the exposed deploy command is executed.
|
|
110
113
|
*/
|
|
111
114
|
function runDeploy() {
|
|
112
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -123,7 +126,7 @@ function runDeploy() {
|
|
|
123
126
|
}
|
|
124
127
|
exports.runDeploy = runDeploy;
|
|
125
128
|
/**
|
|
126
|
-
* Function that is to be
|
|
129
|
+
* Function that is to be executed when the exposed undeploy command is executed.
|
|
127
130
|
*/
|
|
128
131
|
function runUndeploy() {
|
|
129
132
|
return __awaiter(this, void 0, void 0, function* () {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export interface CommonOptions {
|
|
|
43
43
|
* If set to true, a transport request will be created during deployment
|
|
44
44
|
*/
|
|
45
45
|
createTransport?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Optional layered repository namespace.
|
|
48
|
+
*/
|
|
49
|
+
lrep?: string;
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* Enhancing the target with an optional service property allowing to use an alias for the deployment service.
|
|
@@ -52,7 +56,7 @@ export type AbapTarget = BaseAbapTarget & {
|
|
|
52
56
|
};
|
|
53
57
|
export interface AbapDeployConfig extends CommonOptions {
|
|
54
58
|
target: AbapTarget;
|
|
55
|
-
app: BspConfig
|
|
59
|
+
app: Partial<BspConfig>;
|
|
56
60
|
credentials?: AxiosRequestConfig['auth'];
|
|
57
61
|
exclude?: string[];
|
|
58
62
|
}
|
package/dist/ui5/archive.js
CHANGED
|
@@ -8,10 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.createUi5Archive = void 0;
|
|
13
|
-
const
|
|
14
|
-
const base_1 = require("../base");
|
|
16
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
15
17
|
/**
|
|
16
18
|
* Create an archive of files in the workspace.
|
|
17
19
|
*
|
|
@@ -25,18 +27,18 @@ function createUi5Archive(logger, workspace, projectName, exclude = []) {
|
|
|
25
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
28
|
logger.info('Creating archive with UI5 build result.');
|
|
27
29
|
const prefix = `/resources/${projectName}/`;
|
|
28
|
-
const zip = new
|
|
30
|
+
const zip = new adm_zip_1.default();
|
|
29
31
|
const resources = yield workspace.byGlob(`${prefix}**/*`);
|
|
30
32
|
for (const resource of resources) {
|
|
31
33
|
if (!exclude.some((regex) => RegExp(regex, 'g').exec(resource.getPath()))) {
|
|
32
34
|
const path = resource.getPath().replace(prefix, '');
|
|
33
35
|
logger.debug(`Adding ${path}`);
|
|
34
36
|
const buffer = yield resource.getBuffer();
|
|
35
|
-
zip.
|
|
37
|
+
zip.addFile(path, buffer);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
logger.info('Archive created.');
|
|
39
|
-
return
|
|
41
|
+
return zip.toBuffer();
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
exports.createUi5Archive = createUi5Archive;
|
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.
|
|
12
|
+
"version": "0.11.0",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"commander": "9.4.0",
|
|
31
31
|
"dotenv": "16.3.1",
|
|
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.
|
|
35
|
+
"@sap-ux/axios-extension": "1.7.0",
|
|
36
36
|
"@sap-ux/btp-utils": "0.12.0",
|
|
37
37
|
"@sap-ux/logger": "0.4.0",
|
|
38
|
-
"@sap-ux/system-access": "0.3.
|
|
38
|
+
"@sap-ux/system-access": "0.3.2",
|
|
39
39
|
"@sap-ux/ui5-config": "0.20.0",
|
|
40
40
|
"@sap-ux/project-input-validator": "0.1.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/prompts": "2.4.4",
|
|
44
|
-
"@types/
|
|
44
|
+
"@types/adm-zip": "0.5.2",
|
|
45
45
|
"@sap-ux/store": "0.4.0"
|
|
46
46
|
},
|
|
47
47
|
"ui5": {
|