@sap-ux/adp-tooling 0.1.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/LICENSE +201 -0
- package/README.md +12 -0
- package/dist/base/prompt.d.ts +31 -0
- package/dist/base/prompt.js +131 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -0
- package/dist/preview/adp-preview.d.ts +51 -0
- package/dist/preview/adp-preview.js +104 -0
- package/dist/preview/service.d.ts +42 -0
- package/dist/preview/service.js +205 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.js +3 -0
- package/dist/writer/index.d.ts +12 -0
- package/dist/writer/index.js +97 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# `@sap-ux/adp-tooling`
|
|
2
|
+
|
|
3
|
+
Module containing different tooling modules helpful when working with SAP UI5 adaptation projects.
|
|
4
|
+
|
|
5
|
+
## preview
|
|
6
|
+
The submodule preview contains functionality allowing to preview adaptation projects. It is not a standalone UI5 middleware but designed to be integrated into the `@sap-ux/preview-middleware.`.
|
|
7
|
+
|
|
8
|
+
## writer
|
|
9
|
+
The submodule writer contains functionality to generate the core project structure of an SAP UI5 adaptation project. It is not a standalone generator but designed to be integrated into `@sap-ux/create` or any kind of yeoman generator.
|
|
10
|
+
|
|
11
|
+
## base
|
|
12
|
+
The submodule contains functionality required in different scenarios, e.g. prompting for generation or when initializing the preview.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ServiceInfo } from '@sap-ux/btp-utils';
|
|
2
|
+
import prompts from 'prompts';
|
|
3
|
+
import type { AdpWriterConfig } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Prompt the user for the required properties for an adaptation project.
|
|
6
|
+
*
|
|
7
|
+
* @param defaults optional default values for the prompts
|
|
8
|
+
* @param defaults.id initial id to be used for the new adaptation id prompt
|
|
9
|
+
* @param defaults.reference initial id used for the original application id prompt
|
|
10
|
+
* @param defaults.url initial url used for the target url prompt
|
|
11
|
+
* @returns a configuration for the adp writer
|
|
12
|
+
*/
|
|
13
|
+
export declare function promptGeneratorInput({ id, reference, url }?: {
|
|
14
|
+
id?: string;
|
|
15
|
+
reference?: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
}): 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
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1,131 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.promptServiceKeys = exports.promptCredentials = exports.promptGeneratorInput = void 0;
|
|
16
|
+
const fs_1 = require("fs");
|
|
17
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
18
|
+
/**
|
|
19
|
+
* Prompt the user for the required properties for an adaptation project.
|
|
20
|
+
*
|
|
21
|
+
* @param defaults optional default values for the prompts
|
|
22
|
+
* @param defaults.id initial id to be used for the new adaptation id prompt
|
|
23
|
+
* @param defaults.reference initial id used for the original application id prompt
|
|
24
|
+
* @param defaults.url initial url used for the target url prompt
|
|
25
|
+
* @returns a configuration for the adp writer
|
|
26
|
+
*/
|
|
27
|
+
function promptGeneratorInput({ id, reference, url } = {}) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const app = yield (0, prompts_1.default)([
|
|
30
|
+
{
|
|
31
|
+
type: 'select',
|
|
32
|
+
choices: [
|
|
33
|
+
{ title: "CUSTOMER_BASE" /* flexLayer.CUSTOMER_BASE */, value: "CUSTOMER_BASE" /* flexLayer.CUSTOMER_BASE */ },
|
|
34
|
+
{ title: "VENDOR" /* flexLayer.VENDOR */, value: "VENDOR" /* flexLayer.VENDOR */ }
|
|
35
|
+
],
|
|
36
|
+
name: 'layer',
|
|
37
|
+
message: 'Flex layer:'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'text',
|
|
41
|
+
name: 'id',
|
|
42
|
+
message: (_prev, values) => {
|
|
43
|
+
if (values.layer === "CUSTOMER_BASE" /* flexLayer.CUSTOMER_BASE */) {
|
|
44
|
+
return 'New adaptation id (CUSTOMER_BASE selected, customer prefix will be automatically added to the id):';
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return 'New adaptation id:';
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
initial: id,
|
|
51
|
+
format: (input, values) => {
|
|
52
|
+
if (values.layer === "CUSTOMER_BASE" /* flexLayer.CUSTOMER_BASE */ && !input.startsWith('customer.')) {
|
|
53
|
+
return `customer.${input}`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return input;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
name: 'reference',
|
|
64
|
+
message: 'Original application id:',
|
|
65
|
+
initial: reference,
|
|
66
|
+
validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
70
|
+
name: 'title',
|
|
71
|
+
message: 'Application title:'
|
|
72
|
+
}
|
|
73
|
+
]);
|
|
74
|
+
const target = yield (0, prompts_1.default)([
|
|
75
|
+
{
|
|
76
|
+
type: 'text',
|
|
77
|
+
name: 'url',
|
|
78
|
+
message: 'Target system url:',
|
|
79
|
+
initial: url,
|
|
80
|
+
validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
|
|
81
|
+
}
|
|
82
|
+
]);
|
|
83
|
+
return { app, target };
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
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
|
+
//# sourceMappingURL=prompt.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.generate = void 0;
|
|
18
|
+
__exportStar(require("./preview/adp-preview"), exports);
|
|
19
|
+
var writer_1 = require("./writer");
|
|
20
|
+
Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return writer_1.generate; } });
|
|
21
|
+
__exportStar(require("./base/prompt"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ToolsLogger } from '@sap-ux/logger';
|
|
2
|
+
import type { AdpPreviewConfig, DescriptorVariant } from '../types';
|
|
3
|
+
import type { NextFunction, Request, Response } from 'express';
|
|
4
|
+
import type { MergedAppDescriptor } from '@sap-ux/axios-extension';
|
|
5
|
+
import type { Resource } from '@ui5/fs';
|
|
6
|
+
import type { UI5FlexLayer } from '@sap-ux/project-access';
|
|
7
|
+
/**
|
|
8
|
+
* Instance of an adaptation project handling requests and data transformation.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AdpPreview {
|
|
11
|
+
private readonly config;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
/**
|
|
14
|
+
* Merged descriptor variant with reference app manifest
|
|
15
|
+
*/
|
|
16
|
+
private mergedDescriptor;
|
|
17
|
+
/**
|
|
18
|
+
* @returns merged manifest.
|
|
19
|
+
*/
|
|
20
|
+
get descriptor(): MergedAppDescriptor;
|
|
21
|
+
/**
|
|
22
|
+
* @returns a list of resources required to the adaptation project as well as the original app.
|
|
23
|
+
*/
|
|
24
|
+
get resources(): {
|
|
25
|
+
[x: string]: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Constructor taking the config and a logger as input.
|
|
29
|
+
*
|
|
30
|
+
* @param config adp config
|
|
31
|
+
* @param logger logger instance
|
|
32
|
+
*/
|
|
33
|
+
constructor(config: AdpPreviewConfig, logger: ToolsLogger);
|
|
34
|
+
/**
|
|
35
|
+
* Fetch all required configurations from the backend and initialize all configurations.
|
|
36
|
+
*
|
|
37
|
+
* @param descriptorVariant descriptor variant from the project
|
|
38
|
+
* @param files all relevant project files (e.g. webapp content)
|
|
39
|
+
* @returns the UI5 flex layer for which editing is enabled
|
|
40
|
+
*/
|
|
41
|
+
init(descriptorVariant: DescriptorVariant, files: Resource[]): Promise<UI5FlexLayer>;
|
|
42
|
+
/**
|
|
43
|
+
* Proxy for the merged application manifest.json and blocking of preload files.
|
|
44
|
+
*
|
|
45
|
+
* @param req incoming request
|
|
46
|
+
* @param res outgoing response object
|
|
47
|
+
* @param next next middleware that is to be called if the request cannot be handled
|
|
48
|
+
*/
|
|
49
|
+
proxy(req: Request, res: Response, next: NextFunction): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=adp-preview.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AdpPreview = void 0;
|
|
13
|
+
const yazl_1 = require("yazl");
|
|
14
|
+
const service_1 = require("./service");
|
|
15
|
+
/**
|
|
16
|
+
* Instance of an adaptation project handling requests and data transformation.
|
|
17
|
+
*/
|
|
18
|
+
class AdpPreview {
|
|
19
|
+
/**
|
|
20
|
+
* @returns merged manifest.
|
|
21
|
+
*/
|
|
22
|
+
get descriptor() {
|
|
23
|
+
if (this.mergedDescriptor) {
|
|
24
|
+
return this.mergedDescriptor;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new Error('Not initialized');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @returns a list of resources required to the adaptation project as well as the original app.
|
|
32
|
+
*/
|
|
33
|
+
get resources() {
|
|
34
|
+
if (this.mergedDescriptor) {
|
|
35
|
+
const resources = {
|
|
36
|
+
[this.mergedDescriptor.name]: this.mergedDescriptor.url,
|
|
37
|
+
[this.mergedDescriptor.manifest['sap.app'].id]: this.mergedDescriptor.url
|
|
38
|
+
};
|
|
39
|
+
this.mergedDescriptor.asyncHints.libs.forEach((lib) => {
|
|
40
|
+
var _a;
|
|
41
|
+
if ((_a = lib.url) === null || _a === void 0 ? void 0 : _a.url) {
|
|
42
|
+
resources[lib.name] = lib.url.url;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return resources;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error('Not initialized');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Constructor taking the config and a logger as input.
|
|
53
|
+
*
|
|
54
|
+
* @param config adp config
|
|
55
|
+
* @param logger logger instance
|
|
56
|
+
*/
|
|
57
|
+
constructor(config, logger) {
|
|
58
|
+
this.config = config;
|
|
59
|
+
this.logger = logger;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fetch all required configurations from the backend and initialize all configurations.
|
|
63
|
+
*
|
|
64
|
+
* @param descriptorVariant descriptor variant from the project
|
|
65
|
+
* @param files all relevant project files (e.g. webapp content)
|
|
66
|
+
* @returns the UI5 flex layer for which editing is enabled
|
|
67
|
+
*/
|
|
68
|
+
init(descriptorVariant, files) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const provider = yield (0, service_1.createProvider)(this.config, this.logger);
|
|
71
|
+
const lrep = provider.getLayeredRepository();
|
|
72
|
+
const zip = new yazl_1.ZipFile();
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
zip.addBuffer(yield file.getBuffer(), file.getPath().substring(1));
|
|
75
|
+
}
|
|
76
|
+
const buffer = yield (0, service_1.createBuffer)(zip);
|
|
77
|
+
// validate namespace & layer combination and fetch csrf token
|
|
78
|
+
yield lrep.isExistingVariant(descriptorVariant.namespace, descriptorVariant.layer);
|
|
79
|
+
this.mergedDescriptor = (yield lrep.mergeAppDescriptorVariant(buffer))[descriptorVariant.id];
|
|
80
|
+
return descriptorVariant.layer;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Proxy for the merged application manifest.json and blocking of preload files.
|
|
85
|
+
*
|
|
86
|
+
* @param req incoming request
|
|
87
|
+
* @param res outgoing response object
|
|
88
|
+
* @param next next middleware that is to be called if the request cannot be handled
|
|
89
|
+
*/
|
|
90
|
+
proxy(req, res, next) {
|
|
91
|
+
if (req.path.endsWith('manifest.json')) {
|
|
92
|
+
res.status(200);
|
|
93
|
+
res.send(JSON.stringify(this.descriptor.manifest, undefined, 2));
|
|
94
|
+
}
|
|
95
|
+
else if (req.path.endsWith('Component-preload.js')) {
|
|
96
|
+
res.status(404).send();
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
next();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.AdpPreview = AdpPreview;
|
|
104
|
+
//# sourceMappingURL=adp-preview.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { UI5FlexLayer } from '@sap-ux/project-access';
|
|
2
|
+
export interface DescriptorVariant {
|
|
3
|
+
layer: UI5FlexLayer;
|
|
4
|
+
reference: string;
|
|
5
|
+
id: string;
|
|
6
|
+
namespace: string;
|
|
7
|
+
content: object[];
|
|
8
|
+
}
|
|
9
|
+
export interface UrlAbapTarget {
|
|
10
|
+
url: string;
|
|
11
|
+
client?: string;
|
|
12
|
+
scp?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DestinationAbapTarget {
|
|
15
|
+
destination: string;
|
|
16
|
+
}
|
|
17
|
+
export type AbapTarget = (UrlAbapTarget & Partial<DestinationAbapTarget>) | (DestinationAbapTarget & Partial<UrlAbapTarget>);
|
|
18
|
+
export interface AdpPreviewConfig {
|
|
19
|
+
target: AbapTarget;
|
|
20
|
+
/**
|
|
21
|
+
* If set to true then certification validation errors are ignored.
|
|
22
|
+
*/
|
|
23
|
+
ignoreCertErrors?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface AdpWriterConfig {
|
|
26
|
+
app: {
|
|
27
|
+
id: string;
|
|
28
|
+
reference: string;
|
|
29
|
+
layer?: UI5FlexLayer;
|
|
30
|
+
title?: string;
|
|
31
|
+
};
|
|
32
|
+
target: AbapTarget;
|
|
33
|
+
ui5?: {
|
|
34
|
+
minVersion?: string;
|
|
35
|
+
};
|
|
36
|
+
package?: {
|
|
37
|
+
name?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { AdpWriterConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Writes the adp-project template to the memfs editor instance.
|
|
5
|
+
*
|
|
6
|
+
* @param basePath - the base path
|
|
7
|
+
* @param config - the writer configuration
|
|
8
|
+
* @param fs - the memfs editor instance
|
|
9
|
+
* @returns the updated memfs editor instance
|
|
10
|
+
*/
|
|
11
|
+
export declare function generate(basePath: string, config: AdpWriterConfig, fs?: Editor): Promise<Editor>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.generate = void 0;
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const mem_fs_1 = require("mem-fs");
|
|
15
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
16
|
+
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
17
|
+
/**
|
|
18
|
+
* Set default values for optional properties.
|
|
19
|
+
*
|
|
20
|
+
* @param config configuration provided by the calling middleware
|
|
21
|
+
* @returns enhanced configuration with default values
|
|
22
|
+
*/
|
|
23
|
+
function setDefaults(config) {
|
|
24
|
+
var _a, _b, _c, _d, _e;
|
|
25
|
+
var _f, _g, _h, _j;
|
|
26
|
+
const configWithDefaults = {
|
|
27
|
+
app: Object.assign({}, config.app),
|
|
28
|
+
target: Object.assign({}, config.target),
|
|
29
|
+
ui5: Object.assign({}, config.ui5)
|
|
30
|
+
};
|
|
31
|
+
(_a = (_f = configWithDefaults.app).title) !== null && _a !== void 0 ? _a : (_f.title = `Adaptation of ${config.app.reference}`);
|
|
32
|
+
(_b = (_g = configWithDefaults.app).layer) !== null && _b !== void 0 ? _b : (_g.layer = 'CUSTOMER_BASE');
|
|
33
|
+
(_c = configWithDefaults.package) !== null && _c !== void 0 ? _c : (configWithDefaults.package = config.package ? Object.assign({}, config.package) : {});
|
|
34
|
+
(_d = (_h = configWithDefaults.package).name) !== null && _d !== void 0 ? _d : (_h.name = config.app.id.toLowerCase().replace(/\./g, '-'));
|
|
35
|
+
(_e = (_j = configWithDefaults.package).description) !== null && _e !== void 0 ? _e : (_j.description = configWithDefaults.app.title);
|
|
36
|
+
return configWithDefaults;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Writes the adp-project template to the memfs editor instance.
|
|
40
|
+
*
|
|
41
|
+
* @param basePath - the base path
|
|
42
|
+
* @param config - the writer configuration
|
|
43
|
+
* @param fs - the memfs editor instance
|
|
44
|
+
* @returns the updated memfs editor instance
|
|
45
|
+
*/
|
|
46
|
+
function generate(basePath, config, fs) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
if (!fs) {
|
|
49
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
50
|
+
}
|
|
51
|
+
const tmplPath = (0, path_1.join)(__dirname, '../../templates');
|
|
52
|
+
const fullConfig = setDefaults(config);
|
|
53
|
+
fs.copyTpl((0, path_1.join)(tmplPath, '**/*.*'), (0, path_1.join)(basePath), fullConfig, undefined, {
|
|
54
|
+
globOptions: { dot: true },
|
|
55
|
+
processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
|
|
56
|
+
});
|
|
57
|
+
// ui5.yaml
|
|
58
|
+
const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
|
|
59
|
+
const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
|
|
60
|
+
ui5Config.addCustomMiddleware([
|
|
61
|
+
{
|
|
62
|
+
name: 'preview-middleware',
|
|
63
|
+
afterMiddleware: 'compression',
|
|
64
|
+
configuration: {
|
|
65
|
+
adp: {
|
|
66
|
+
target: fullConfig.target,
|
|
67
|
+
ignoreCertErrors: false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'ui5-proxy-middleware',
|
|
73
|
+
afterMiddleware: 'preview-middleware',
|
|
74
|
+
configuration: {
|
|
75
|
+
ui5: {
|
|
76
|
+
path: ['/resources', '/test-resources'],
|
|
77
|
+
url: 'https://ui5.sap.com'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'backend-proxy-middleware',
|
|
83
|
+
afterMiddleware: 'preview-middleware',
|
|
84
|
+
configuration: {
|
|
85
|
+
backend: Object.assign(Object.assign({}, fullConfig.target), { path: '/sap' }),
|
|
86
|
+
options: {
|
|
87
|
+
secure: true
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]);
|
|
92
|
+
fs.write(ui5ConfigPath, ui5Config.toString());
|
|
93
|
+
return fs;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.generate = generate;
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sap-ux/adp-tooling",
|
|
3
|
+
"description": "Tooling for UI5 adaptation projects",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
7
|
+
"directory": "packages/adp-tooling"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
|
|
11
|
+
},
|
|
12
|
+
"version": "0.1.0",
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"author": "@SAP/ux-tools-team",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"files": [
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"dist",
|
|
19
|
+
"ui5.yaml",
|
|
20
|
+
"bin",
|
|
21
|
+
"!dist/*.map",
|
|
22
|
+
"!dist/**/*.map"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"ejs": "3.1.7",
|
|
26
|
+
"mem-fs": "2.1.0",
|
|
27
|
+
"mem-fs-editor": "9.4.0",
|
|
28
|
+
"prompts": "2.4.2",
|
|
29
|
+
"yazl": "2.5.1",
|
|
30
|
+
"@sap-ux/axios-extension": "1.4.0",
|
|
31
|
+
"@sap-ux/btp-utils": "0.11.7",
|
|
32
|
+
"@sap-ux/logger": "0.3.7",
|
|
33
|
+
"@sap-ux/store": "0.3.12",
|
|
34
|
+
"@sap-ux/ui5-config": "0.18.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/ejs": "3.1.0",
|
|
38
|
+
"@types/express": "4.17.13",
|
|
39
|
+
"@types/mem-fs": "1.1.2",
|
|
40
|
+
"@types/mem-fs-editor": "7.0.1",
|
|
41
|
+
"@types/prompts": "2.0.14",
|
|
42
|
+
"@types/supertest": "2.0.12",
|
|
43
|
+
"@types/yazl": "2.4.2",
|
|
44
|
+
"dotenv": "16.0.0",
|
|
45
|
+
"express": "4.18.2",
|
|
46
|
+
"nock": "13.2.1",
|
|
47
|
+
"rimraf": "5.0.1",
|
|
48
|
+
"supertest": "6.3.2",
|
|
49
|
+
"@sap-ux/project-access": "1.10.1"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0",
|
|
53
|
+
"node": ">= 14.16.0 < 15.0.0 || >=16.1.0 < 17.0.0 || >=18.0.0 < 19.0.0"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsc --build",
|
|
57
|
+
"watch": "tsc --watch",
|
|
58
|
+
"clean": "rimraf --glob dist test/test-output coverage *.tsbuildinfo",
|
|
59
|
+
"format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",
|
|
60
|
+
"lint": "eslint . --ext .ts",
|
|
61
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
62
|
+
"test": "jest --ci --forceExit --detectOpenHandles --colors --testPathPattern=test/unit",
|
|
63
|
+
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
64
|
+
"link": "pnpm link --global",
|
|
65
|
+
"unlink": "pnpm unlink --global"
|
|
66
|
+
}
|
|
67
|
+
}
|