@sap-ux/adp-tooling 0.1.4 → 0.1.5
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/prompt.d.ts +4 -15
- package/dist/base/prompt.js +1 -46
- package/dist/preview/adp-preview.js +48 -3
- package/dist/types.d.ts +6 -9
- package/package.json +4 -4
- package/dist/preview/service.d.ts +0 -42
- package/dist/preview/service.js +0 -205
package/dist/base/prompt.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { ServiceInfo } from '@sap-ux/btp-utils';
|
|
2
|
-
import prompts from 'prompts';
|
|
3
1
|
import type { AdpWriterConfig } from '../types';
|
|
2
|
+
export declare const enum flexLayer {
|
|
3
|
+
CUSTOMER_BASE = "CUSTOMER_BASE",
|
|
4
|
+
VENDOR = "VENDOR"
|
|
5
|
+
}
|
|
4
6
|
/**
|
|
5
7
|
* Prompt the user for the required properties for an adaptation project.
|
|
6
8
|
*
|
|
@@ -15,17 +17,4 @@ export declare function promptGeneratorInput({ id, reference, url }?: {
|
|
|
15
17
|
reference?: string;
|
|
16
18
|
url?: string;
|
|
17
19
|
}): Promise<AdpWriterConfig>;
|
|
18
|
-
/**
|
|
19
|
-
* Prompt for username and password.
|
|
20
|
-
*
|
|
21
|
-
* @param username - optional username that is to be offered as default
|
|
22
|
-
* @returns credentials object with username/password
|
|
23
|
-
*/
|
|
24
|
-
export declare function promptCredentials(username?: string): Promise<prompts.Answers<"password" | "username">>;
|
|
25
|
-
/**
|
|
26
|
-
* Prompt for the location of the service keys.
|
|
27
|
-
*
|
|
28
|
-
* @returns credentials object with service keys
|
|
29
|
-
*/
|
|
30
|
-
export declare function promptServiceKeys(): Promise<ServiceInfo>;
|
|
31
20
|
//# sourceMappingURL=prompt.d.ts.map
|
package/dist/base/prompt.js
CHANGED
|
@@ -12,8 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
16
|
-
const fs_1 = require("fs");
|
|
15
|
+
exports.promptGeneratorInput = void 0;
|
|
17
16
|
const prompts_1 = __importDefault(require("prompts"));
|
|
18
17
|
/**
|
|
19
18
|
* Prompt the user for the required properties for an adaptation project.
|
|
@@ -84,48 +83,4 @@ function promptGeneratorInput({ id, reference, url } = {}) {
|
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
85
|
exports.promptGeneratorInput = promptGeneratorInput;
|
|
87
|
-
/**
|
|
88
|
-
* Prompt for username and password.
|
|
89
|
-
*
|
|
90
|
-
* @param username - optional username that is to be offered as default
|
|
91
|
-
* @returns credentials object with username/password
|
|
92
|
-
*/
|
|
93
|
-
function promptCredentials(username) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const credentials = yield (0, prompts_1.default)([
|
|
96
|
-
{
|
|
97
|
-
type: 'text',
|
|
98
|
-
name: 'username',
|
|
99
|
-
initial: username,
|
|
100
|
-
message: 'Username:'
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: 'password',
|
|
104
|
-
name: 'password',
|
|
105
|
-
message: 'Password:'
|
|
106
|
-
}
|
|
107
|
-
]);
|
|
108
|
-
return credentials;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
exports.promptCredentials = promptCredentials;
|
|
112
|
-
/**
|
|
113
|
-
* Prompt for the location of the service keys.
|
|
114
|
-
*
|
|
115
|
-
* @returns credentials object with service keys
|
|
116
|
-
*/
|
|
117
|
-
function promptServiceKeys() {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
const { path } = yield (0, prompts_1.default)([
|
|
120
|
-
{
|
|
121
|
-
type: 'text',
|
|
122
|
-
name: 'path',
|
|
123
|
-
message: 'Please provide the service keys as file:',
|
|
124
|
-
validate: (input) => (0, fs_1.existsSync)(input)
|
|
125
|
-
}
|
|
126
|
-
]);
|
|
127
|
-
return JSON.parse((0, fs_1.readFileSync)(path, 'utf-8'));
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
exports.promptServiceKeys = promptServiceKeys;
|
|
131
86
|
//# sourceMappingURL=prompt.js.map
|
|
@@ -8,10 +8,55 @@ 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 __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); }
|
|
17
|
+
};
|
|
11
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
19
|
exports.AdpPreview = void 0;
|
|
13
20
|
const yazl_1 = require("yazl");
|
|
14
|
-
const
|
|
21
|
+
const system_access_1 = require("@sap-ux/system-access");
|
|
22
|
+
/**
|
|
23
|
+
* Create a buffer based on the given zip file object.
|
|
24
|
+
*
|
|
25
|
+
* @param zip object representing a zip file
|
|
26
|
+
* @returns a buffer
|
|
27
|
+
*/
|
|
28
|
+
function createBuffer(zip) {
|
|
29
|
+
var _a, e_1, _b, _c;
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
yield new Promise((resolve) => {
|
|
32
|
+
zip.end({ forceZip64Format: false }, () => {
|
|
33
|
+
resolve();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
const chunks = [];
|
|
37
|
+
try {
|
|
38
|
+
for (var _d = true, _e = __asyncValues(zip.outputStream), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
39
|
+
_c = _f.value;
|
|
40
|
+
_d = false;
|
|
41
|
+
try {
|
|
42
|
+
const chunk = _c;
|
|
43
|
+
chunks.push(chunk);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
_d = true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
51
|
+
finally {
|
|
52
|
+
try {
|
|
53
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
54
|
+
}
|
|
55
|
+
finally { if (e_1) throw e_1.error; }
|
|
56
|
+
}
|
|
57
|
+
return Buffer.concat(chunks);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
15
60
|
/**
|
|
16
61
|
* Instance of an adaptation project handling requests and data transformation.
|
|
17
62
|
*/
|
|
@@ -67,14 +112,14 @@ class AdpPreview {
|
|
|
67
112
|
*/
|
|
68
113
|
init(descriptorVariant) {
|
|
69
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const provider = yield (0,
|
|
115
|
+
const provider = yield (0, system_access_1.createAbapServiceProvider)(this.config.target, { ignoreCertErrors: this.config.ignoreCertErrors }, true, this.logger);
|
|
71
116
|
const lrep = provider.getLayeredRepository();
|
|
72
117
|
const zip = new yazl_1.ZipFile();
|
|
73
118
|
const files = yield this.project.byGlob('**/*.*');
|
|
74
119
|
for (const file of files) {
|
|
75
120
|
zip.addBuffer(yield file.getBuffer(), file.getPath().substring(1));
|
|
76
121
|
}
|
|
77
|
-
const buffer = yield
|
|
122
|
+
const buffer = yield createBuffer(zip);
|
|
78
123
|
// validate namespace & layer combination and fetch csrf token
|
|
79
124
|
yield lrep.isExistingVariant(descriptorVariant.namespace, descriptorVariant.layer);
|
|
80
125
|
this.mergedDescriptor = (yield lrep.mergeAppDescriptorVariant(buffer))[descriptorVariant.id];
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UI5FlexLayer } from '@sap-ux/project-access';
|
|
2
|
+
import type { DestinationAbapTarget, UrlAbapTarget } from '@sap-ux/system-access';
|
|
2
3
|
export interface DescriptorVariant {
|
|
3
4
|
layer: UI5FlexLayer;
|
|
4
5
|
reference: string;
|
|
@@ -6,15 +7,10 @@ export interface DescriptorVariant {
|
|
|
6
7
|
namespace: string;
|
|
7
8
|
content: object[];
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
export interface DestinationAbapTarget {
|
|
15
|
-
destination: string;
|
|
16
|
-
}
|
|
17
|
-
export type AbapTarget = (UrlAbapTarget & Partial<DestinationAbapTarget>) | (DestinationAbapTarget & Partial<UrlAbapTarget>);
|
|
10
|
+
/**
|
|
11
|
+
* Reduce the options exposed as target configuration.
|
|
12
|
+
*/
|
|
13
|
+
type AbapTarget = DestinationAbapTarget | Pick<UrlAbapTarget, 'url' | 'client' | 'scp'>;
|
|
18
14
|
export interface AdpPreviewConfig {
|
|
19
15
|
target: AbapTarget;
|
|
20
16
|
/**
|
|
@@ -38,4 +34,5 @@ export interface AdpWriterConfig {
|
|
|
38
34
|
description?: string;
|
|
39
35
|
};
|
|
40
36
|
}
|
|
37
|
+
export {};
|
|
41
38
|
//# sourceMappingURL=types.d.ts.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%3Aadp-tooling"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.1.
|
|
12
|
+
"version": "0.1.5",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -29,9 +29,8 @@
|
|
|
29
29
|
"prompts": "2.4.2",
|
|
30
30
|
"yazl": "2.5.1",
|
|
31
31
|
"@sap-ux/axios-extension": "1.4.1",
|
|
32
|
-
"@sap-ux/btp-utils": "0.11.8",
|
|
33
32
|
"@sap-ux/logger": "0.3.7",
|
|
34
|
-
"@sap-ux/
|
|
33
|
+
"@sap-ux/system-access": "0.2.0",
|
|
35
34
|
"@sap-ux/ui5-config": "0.19.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
@@ -47,7 +46,8 @@
|
|
|
47
46
|
"nock": "13.2.1",
|
|
48
47
|
"rimraf": "5.0.1",
|
|
49
48
|
"supertest": "6.3.2",
|
|
50
|
-
"@sap-ux/project-access": "1.11.2"
|
|
49
|
+
"@sap-ux/project-access": "1.11.2",
|
|
50
|
+
"@sap-ux/store": "0.3.12"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import type { Logger } from '@sap-ux/logger';
|
|
4
|
-
import type { BackendSystem } from '@sap-ux/store';
|
|
5
|
-
import type { AbapTarget, AdpPreviewConfig, UrlAbapTarget } from '../types';
|
|
6
|
-
import type { AbapServiceProvider } from '@sap-ux/axios-extension';
|
|
7
|
-
import type { ZipFile } from 'yazl';
|
|
8
|
-
type BasicAuth = Required<Pick<BackendSystem, 'username' | 'password'>>;
|
|
9
|
-
type ServiceAuth = Required<Pick<BackendSystem, 'serviceKeys' | 'name'>> & {
|
|
10
|
-
refreshToken?: string;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Create a buffer based on the given zip file object.
|
|
14
|
-
*
|
|
15
|
-
* @param zip object representing a zip file
|
|
16
|
-
* @returns a buffer
|
|
17
|
-
*/
|
|
18
|
-
export declare function createBuffer(zip: ZipFile): Promise<Buffer>;
|
|
19
|
-
/**
|
|
20
|
-
* Check the secure storage if it has credentials for the given target.
|
|
21
|
-
*
|
|
22
|
-
* @param target ABAP target
|
|
23
|
-
* @returns credentials from the store or undefined.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getCredentials<T extends BasicAuth | ServiceAuth | undefined>(target: UrlAbapTarget): Promise<T | undefined>;
|
|
26
|
-
/**
|
|
27
|
-
* Check if it is a url or destination target.
|
|
28
|
-
*
|
|
29
|
-
* @param target target configuration
|
|
30
|
-
* @returns true is it is a UrlAbapTarget
|
|
31
|
-
*/
|
|
32
|
-
export declare function isUrlTarget(target: AbapTarget): target is UrlAbapTarget;
|
|
33
|
-
/**
|
|
34
|
-
* Create an instance of a UI5AbapRepository service connected to the given target configuration.
|
|
35
|
-
*
|
|
36
|
-
* @param config - deployment configuration
|
|
37
|
-
* @param logger - optional reference to the logger instance
|
|
38
|
-
* @returns service instance
|
|
39
|
-
*/
|
|
40
|
-
export declare function createProvider(config: AdpPreviewConfig, logger: Logger): Promise<AbapServiceProvider>;
|
|
41
|
-
export {};
|
|
42
|
-
//# sourceMappingURL=service.d.ts.map
|
package/dist/preview/service.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
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
|
-
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); }
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.createProvider = exports.isUrlTarget = exports.getCredentials = exports.createBuffer = void 0;
|
|
20
|
-
const store_1 = require("@sap-ux/store");
|
|
21
|
-
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
22
|
-
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
23
|
-
const prompt_1 = require("../base/prompt");
|
|
24
|
-
/**
|
|
25
|
-
* Create a buffer based on the given zip file object.
|
|
26
|
-
*
|
|
27
|
-
* @param zip object representing a zip file
|
|
28
|
-
* @returns a buffer
|
|
29
|
-
*/
|
|
30
|
-
function createBuffer(zip) {
|
|
31
|
-
var _a, e_1, _b, _c;
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
yield new Promise((resolve) => {
|
|
34
|
-
zip.end({ forceZip64Format: false }, () => {
|
|
35
|
-
resolve();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
const chunks = [];
|
|
39
|
-
try {
|
|
40
|
-
for (var _d = true, _e = __asyncValues(zip.outputStream), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
41
|
-
_c = _f.value;
|
|
42
|
-
_d = false;
|
|
43
|
-
try {
|
|
44
|
-
const chunk = _c;
|
|
45
|
-
chunks.push(chunk);
|
|
46
|
-
}
|
|
47
|
-
finally {
|
|
48
|
-
_d = true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
53
|
-
finally {
|
|
54
|
-
try {
|
|
55
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
56
|
-
}
|
|
57
|
-
finally { if (e_1) throw e_1.error; }
|
|
58
|
-
}
|
|
59
|
-
return Buffer.concat(chunks);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
exports.createBuffer = createBuffer;
|
|
63
|
-
/**
|
|
64
|
-
* Check the secure storage if it has credentials for the given target.
|
|
65
|
-
*
|
|
66
|
-
* @param target ABAP target
|
|
67
|
-
* @returns credentials from the store or undefined.
|
|
68
|
-
*/
|
|
69
|
-
function getCredentials(target) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
if (!(0, btp_utils_1.isAppStudio)()) {
|
|
72
|
-
const systemService = yield (0, store_1.getService)({ entityName: 'system' });
|
|
73
|
-
let system = yield systemService.read(new store_1.BackendSystemKey({ url: target.url, client: target.client }));
|
|
74
|
-
if (!system && target.client) {
|
|
75
|
-
// check if there are credentials for the default client
|
|
76
|
-
system = yield systemService.read(new store_1.BackendSystemKey({ url: target.url }));
|
|
77
|
-
}
|
|
78
|
-
return system;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
exports.getCredentials = getCredentials;
|
|
86
|
-
/**
|
|
87
|
-
* Enhance axios options and create a service provider instance for an ABAP Cloud system.
|
|
88
|
-
*
|
|
89
|
-
* @param options - predefined axios options
|
|
90
|
-
* @param target - url target configuration
|
|
91
|
-
* @param logger - reference to the logger instance
|
|
92
|
-
* @returns an abap service provider
|
|
93
|
-
*/
|
|
94
|
-
function createAbapCloudServiceProvider(options, target, logger) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const providerConfig = Object.assign(Object.assign({}, options), { environment: axios_extension_1.AbapCloudEnvironment.Standalone });
|
|
97
|
-
// first try reading the keys from the store
|
|
98
|
-
const storedOpts = yield getCredentials(target);
|
|
99
|
-
if (logger && storedOpts) {
|
|
100
|
-
providerConfig.service = storedOpts.serviceKeys;
|
|
101
|
-
providerConfig.refreshToken = storedOpts.refreshToken;
|
|
102
|
-
logger.info(`Using system [${storedOpts.name}] from System store`);
|
|
103
|
-
}
|
|
104
|
-
// next prompt the user for the keys
|
|
105
|
-
if (!storedOpts) {
|
|
106
|
-
providerConfig.service = yield (0, prompt_1.promptServiceKeys)();
|
|
107
|
-
}
|
|
108
|
-
// if no keys are available throw and error
|
|
109
|
-
if (providerConfig.service) {
|
|
110
|
-
return (0, axios_extension_1.createForAbapOnCloud)(providerConfig);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
throw new Error('Service keys required for deployment to an ABAP Cloud environment.');
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Enhance axios options and create a service provider instance for an on-premise ABAP system.
|
|
119
|
-
*
|
|
120
|
-
* @param options predefined axios options
|
|
121
|
-
* @param target url target configuration
|
|
122
|
-
* @param logger reference to the logger instance
|
|
123
|
-
* @returns an ABAPServiceProvider instance
|
|
124
|
-
*/
|
|
125
|
-
function createAbapServiceProvider(options, target, logger) {
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
options.baseURL = target.url;
|
|
128
|
-
if (target.client) {
|
|
129
|
-
options.params['sap-client'] = target.client;
|
|
130
|
-
}
|
|
131
|
-
if (!options.auth) {
|
|
132
|
-
let storedOpts;
|
|
133
|
-
try {
|
|
134
|
-
storedOpts = yield getCredentials(target);
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
logger.debug('Could not read credentials from store.');
|
|
138
|
-
// something went wrong but it doesn't matter, we just prompt the user
|
|
139
|
-
}
|
|
140
|
-
if ((storedOpts === null || storedOpts === void 0 ? void 0 : storedOpts.username) && (storedOpts === null || storedOpts === void 0 ? void 0 : storedOpts.password)) {
|
|
141
|
-
options.auth = {
|
|
142
|
-
username: storedOpts.username,
|
|
143
|
-
password: storedOpts.password
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
const credentials = yield (0, prompt_1.promptCredentials)(storedOpts === null || storedOpts === void 0 ? void 0 : storedOpts.username);
|
|
148
|
-
options.auth = credentials;
|
|
149
|
-
process.env.FIORI_TOOLS_USER = credentials.username;
|
|
150
|
-
process.env.FIORI_TOOLS_PASSWORD = credentials.password;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return (0, axios_extension_1.createForAbap)(options);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Check if it is a url or destination target.
|
|
158
|
-
*
|
|
159
|
-
* @param target target configuration
|
|
160
|
-
* @returns true is it is a UrlAbapTarget
|
|
161
|
-
*/
|
|
162
|
-
function isUrlTarget(target) {
|
|
163
|
-
return target.url !== undefined;
|
|
164
|
-
}
|
|
165
|
-
exports.isUrlTarget = isUrlTarget;
|
|
166
|
-
/**
|
|
167
|
-
* Create an instance of a UI5AbapRepository service connected to the given target configuration.
|
|
168
|
-
*
|
|
169
|
-
* @param config - deployment configuration
|
|
170
|
-
* @param logger - optional reference to the logger instance
|
|
171
|
-
* @returns service instance
|
|
172
|
-
*/
|
|
173
|
-
function createProvider(config, logger) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
let provider;
|
|
176
|
-
const options = {
|
|
177
|
-
params: {},
|
|
178
|
-
ignoreCertErrors: config.ignoreCertErrors
|
|
179
|
-
};
|
|
180
|
-
// Destination only supported on Business Application studio
|
|
181
|
-
if ((0, btp_utils_1.isAppStudio)() && config.target.destination) {
|
|
182
|
-
// Need additional properties to determine the type of destination we are dealing with
|
|
183
|
-
const destinations = yield (0, btp_utils_1.listDestinations)();
|
|
184
|
-
const destination = destinations === null || destinations === void 0 ? void 0 : destinations[config.target.destination];
|
|
185
|
-
if (!destination) {
|
|
186
|
-
throw new Error(`Destination ${config.target.destination} not found on subaccount`);
|
|
187
|
-
}
|
|
188
|
-
provider = (0, axios_extension_1.createForDestination)(options, destination);
|
|
189
|
-
}
|
|
190
|
-
else if (isUrlTarget(config.target)) {
|
|
191
|
-
if (config.target.scp) {
|
|
192
|
-
provider = yield createAbapCloudServiceProvider(options, config.target, logger);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
provider = yield createAbapServiceProvider(options, config.target, logger);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
throw new Error('Unable to handle the configuration in the current environment.');
|
|
200
|
-
}
|
|
201
|
-
return provider;
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
exports.createProvider = createProvider;
|
|
205
|
-
//# sourceMappingURL=service.js.map
|