@ui5/task-adaptation 1.0.15 → 1.0.16

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/README.md +1 -1
  3. package/dist/annotationManager.d.ts +32 -0
  4. package/dist/annotationManager.js +276 -0
  5. package/dist/appVariantManager.js +18 -32
  6. package/dist/baseAppManager.d.ts +8 -4
  7. package/dist/baseAppManager.js +37 -62
  8. package/dist/buildStrategy.js +3 -0
  9. package/dist/bundle-resourceBundle.js +692 -0
  10. package/dist/bundle.js +245 -102
  11. package/dist/cache/annotationsCacheManager.d.ts +8 -0
  12. package/dist/cache/annotationsCacheManager.js +18 -0
  13. package/dist/cache/baseAppFilesCacheManager.d.ts +6 -0
  14. package/dist/cache/baseAppFilesCacheManager.js +15 -0
  15. package/dist/cache/cacheManager.d.ts +16 -0
  16. package/dist/cache/cacheManager.js +67 -0
  17. package/dist/index.js +10 -18
  18. package/dist/model/noAuthorizationProvidedError.d.ts +3 -0
  19. package/dist/model/noAuthorizationProvidedError.js +9 -0
  20. package/dist/model/types.d.ts +12 -0
  21. package/dist/processors/abapProcessor.d.ts +21 -0
  22. package/dist/processors/abapProcessor.js +36 -0
  23. package/dist/processors/cfProcessor.d.ts +17 -0
  24. package/dist/processors/cfProcessor.js +46 -0
  25. package/dist/processors/processor.d.ts +7 -0
  26. package/dist/processors/processor.js +36 -0
  27. package/dist/repositories/abapRepoManager.d.ts +13 -0
  28. package/dist/repositories/abapRepoManager.js +81 -0
  29. package/dist/{html5RepoManager.d.ts → repositories/html5RepoManager.d.ts} +2 -2
  30. package/dist/repositories/html5RepoManager.js +89 -0
  31. package/dist/util/cfUtil.js +109 -138
  32. package/dist/util/commonUtil.js +1 -1
  33. package/dist/util/requestUtil.d.ts +6 -3
  34. package/dist/util/requestUtil.js +43 -24
  35. package/dist/util/resourceUtil.d.ts +2 -10
  36. package/dist/util/resourceUtil.js +6 -49
  37. package/dist/util/zipUtil.d.ts +2 -0
  38. package/dist/util/zipUtil.js +20 -0
  39. package/package.json +8 -3
  40. package/scripts/bundler.ts +75 -0
  41. package/scripts/rollup/bundleDefinition-resourceBundle.js +5 -0
  42. package/scripts/rollup/overrides/sap/base/i18n/Localization.js +1 -0
  43. package/scripts/rollup/overrides/sap/base/string/formatMessage.js +1 -0
  44. package/scripts/rollup/overrides/sap/base/util/Properties.js +1 -0
  45. package/scripts/rollup/overrides/sap/base/util/merge.js +1 -0
  46. package/scripts/rollup/project/ui5.yaml +1 -1
  47. package/scripts/rollup.ts +26 -50
  48. package/dist/html5RepoManager.js +0 -113
  49. package/dist/updateCache.d.ts +0 -5
  50. package/dist/updateCache.js +0 -36
@@ -0,0 +1,5 @@
1
+ import ResourceBundle from "sap/base/i18n/ResourceBundle";
2
+
3
+ export {
4
+ ResourceBundle
5
+ };
@@ -0,0 +1 @@
1
+ export default class Localization {}
@@ -0,0 +1 @@
1
+ export default class formatMessage {}
@@ -0,0 +1 @@
1
+ export default class Properties {}
@@ -0,0 +1 @@
1
+ export default class merge {}
@@ -6,7 +6,7 @@ metadata:
6
6
  allowSapInternal: true
7
7
  framework:
8
8
  name: SAPUI5
9
- version: "0.0.0"
9
+ version: "1.115.0"
10
10
  libraries:
11
11
  - name: sap.ui.fl
12
12
  - name: sap.suite.ui.generic.template
package/scripts/rollup.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
-
4
- import * as builtins from "builtin-modules";
5
- import { nodeResolve } from "@rollup/plugin-node-resolve";
6
- import * as rollup from "rollup";
7
3
  import * as semver from "semver";
8
4
  import * as yaml from "js-yaml";
9
- import ui5 from "./rollup/ui5Resolve";
5
+ import Bundler from "./bundler";
10
6
 
11
7
  const { normalizer } = require("@ui5/project");
12
8
  const log = require("@ui5/logger").getLogger("rollup-plugin-ui5-resolve-task-adaptation");
@@ -60,55 +56,35 @@ export default class Builder {
60
56
  }
61
57
  }
62
58
 
63
- static async run(destination: string): Promise<void> {
64
- const bundledUI5Version = this.getBundledUI5Version(destination);
59
+ static async run(): Promise<void> {
65
60
  const project = await this.getProjectInfo(projectPaths);
66
61
  if (!project) {
67
62
  throw new Error("ui5.yaml is not found or incorrect");
68
63
  }
69
- const isSapUiFl = (dependency: any) => dependency.id.endsWith("/sap.ui.fl");
70
- const sapUiFlDependency = project.dependencies.find(isSapUiFl);
71
- if (bundledUI5Version == null || sapUiFlDependency && semver.neq(bundledUI5Version, sapUiFlDependency.version)) {
72
- if (sapUiFlDependency.version) {
73
- log.info(`Using UI5 version ${sapUiFlDependency.version.toString()} to bundle`);
74
- }
75
- const inputOptions = <rollup.RollupOptions>{
76
- input: "bundleDefinition.js",
77
- plugins: [
78
- ui5({
79
- assets: [
80
- "/resources/sap/ui/fl/**",
81
- "/resources/sap/suite/ui/generic/template/**"
82
- ],
83
- skipTransformation: [
84
- "bundleDefinition.js",
85
- "sap/ui/thirdparty/URI"
86
- ],
87
- output: destination,
88
- project: project,
89
- ui5version: sapUiFlDependency.version
90
- }),
91
- nodeResolve({
92
- preferBuiltins: true
93
- })
94
- ],
95
- external: builtins
96
- }
97
- const bundle = await rollup.rollup(inputOptions);
98
-
99
- const outputOptions = <rollup.RollupOptions>{
100
- file: destination,
101
- format: "commonjs"
102
- }
103
- await bundle.write(outputOptions);
104
- await bundle.close();
105
- } else {
106
- log.info(`UI5 version ${bundledUI5Version!.toString()} is already bundled`);
107
- }
108
-
64
+ await Bundler.run(
65
+ project,
66
+ "bundleDefinition.js",
67
+ "./dist/bundle.js",
68
+ "/sap.ui.fl",
69
+ [
70
+ "/resources/sap/ui/fl/**",
71
+ "/resources/sap/suite/ui/generic/template/**"
72
+ ],
73
+ [
74
+ "sap/ui/thirdparty/URI"
75
+ ]);
76
+ await Bundler.run(
77
+ project,
78
+ "bundleDefinition-resourceBundle.js",
79
+ "./dist/bundle-resourceBundle.js",
80
+ "/sap.ui.core",
81
+ [
82
+ "/resources/sap/base/**"
83
+ ]
84
+ );
109
85
  }
110
86
  }
111
87
 
112
- if (process.argv.length === 3) {
113
- Builder.run(process.argv[2]);
114
- }
88
+ if (process.argv.length === 2) {
89
+ Builder.run();
90
+ }
@@ -1,113 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const AdmZip = require("adm-zip");
13
- const cfUtil_1 = require("./util/cfUtil");
14
- const requestUtil_1 = require("./util/requestUtil");
15
- const commonUtil_1 = require("./util/commonUtil");
16
- const log = require("@ui5/logger").getLogger("@ui5/task-adaptation::HTML5RepoManager");
17
- class HTML5RepoManager {
18
- static getBaseAppFiles(configuration) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const { token, baseUri } = yield this.getHtml5RepoInfo(configuration);
21
- const entries = yield this.getBaseAppZipEntries(configuration, baseUri, token);
22
- return this.mapEntries(entries);
23
- });
24
- }
25
- static getMetadata(configuration) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const { token, baseUri } = yield this.getHtml5RepoInfo(configuration);
28
- return this.requestMetadata(configuration, baseUri, token);
29
- });
30
- }
31
- static getHtml5RepoInfo(configuration) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const spaceGuid = yield cfUtil_1.default.getSpaceGuid(configuration === null || configuration === void 0 ? void 0 : configuration.spaceGuid);
34
- const credentials = yield this.getHTML5Credentials(spaceGuid);
35
- const token = yield this.getToken(credentials);
36
- return {
37
- token,
38
- baseUri: credentials.uri
39
- };
40
- });
41
- }
42
- static getHTML5Credentials(spaceGuid) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- log.verbose("Getting HTML5 Repo Runtime credentials from space " + spaceGuid);
45
- const PLAN_NAME = "app-runtime";
46
- const SERVIСE_INSTANCE_NAME = "html5-apps-repo-runtime";
47
- const getParams = {
48
- spaceGuids: [spaceGuid],
49
- planNames: [PLAN_NAME],
50
- names: [SERVIСE_INSTANCE_NAME]
51
- };
52
- const createParams = {
53
- spaceGuid,
54
- planName: PLAN_NAME,
55
- serviceName: SERVIСE_INSTANCE_NAME,
56
- tags: ["html5-apps-repo-rt"]
57
- };
58
- const serviceKeys = yield cfUtil_1.default.getServiceInstanceKeys(getParams, createParams);
59
- return serviceKeys.credentials;
60
- });
61
- }
62
- static getToken({ uaa }) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- log.verbose("Getting HTML5 Repo token");
65
- const auth = Buffer.from(uaa.clientid + ":" + uaa.clientsecret);
66
- const options = {
67
- headers: {
68
- "Content-Type": "application/json",
69
- "Authorization": "Basic " + auth.toString("base64")
70
- }
71
- };
72
- const uri = `${uaa.url}/oauth/token?grant_type=client_credentials`;
73
- return requestUtil_1.default.get(uri, options).then((json) => json["access_token"]);
74
- });
75
- }
76
- static requestMetadata(options, html5RepoBaseUri, token) {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- commonUtil_1.validateObject(options, ["appHostId", "appName", "appVersion"], "should be specified in ui5.yaml configuration");
79
- const { appHostId, appName, appVersion } = options;
80
- const uri = `${html5RepoBaseUri}/applications/metadata/`;
81
- const requestOptions = {
82
- headers: {
83
- "Content-Type": "application/json",
84
- "Authorization": "Bearer " + token,
85
- "x-app-host-id": appHostId
86
- }
87
- };
88
- const metadata = yield requestUtil_1.default.get(uri, requestOptions);
89
- return metadata.find((item) => item.appHostId === appHostId && item.applicationName === appName && item.applicationVersion === appVersion);
90
- });
91
- }
92
- static getBaseAppZipEntries(options, html5RepoBaseUri, token) {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- commonUtil_1.validateObject(options, ["appHostId", "appName", "appVersion"], "should be specified in ui5.yaml configuration");
95
- const { appHostId, appName, appVersion } = options;
96
- const uri = `${html5RepoBaseUri}/applications/content/${appName}-${appVersion}/`;
97
- const zip = yield requestUtil_1.default.download(token, appHostId, uri);
98
- let admZip;
99
- try {
100
- admZip = new AdmZip(zip);
101
- return admZip.getEntries();
102
- }
103
- catch (error) {
104
- throw new Error("Failed to parse zip content from HTML5 Repository: " + error.message);
105
- }
106
- });
107
- }
108
- static mapEntries(entries) {
109
- return new Map(entries.filter(entry => !entry.isDirectory).map(entry => [entry.entryName, entry.getData().toString("utf8")]));
110
- }
111
- }
112
- exports.default = HTML5RepoManager;
113
- //# sourceMappingURL=html5RepoManager.js.map
@@ -1,5 +0,0 @@
1
- import { IConfiguration } from "./model/types";
2
- /**
3
- * Updates temporary stored original app files
4
- */
5
- export default function (configuration: IConfiguration): Promise<Map<string, string>>;
@@ -1,36 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const html5RepoManager_1 = require("./html5RepoManager");
13
- const resourceUtil_1 = require("./util/resourceUtil");
14
- const commonUtil_1 = require("./util/commonUtil");
15
- /**
16
- * Updates temporary stored original app files
17
- */
18
- function default_1(configuration) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- commonUtil_1.validateObject(configuration, ["appHostId", "appName", "appVersion"], "should be specified in ui5.yaml configuration");
21
- const metadataPromise = html5RepoManager_1.default.getMetadata(configuration);
22
- const tempMetadata = resourceUtil_1.default.readTempMetadata(configuration);
23
- const metadata = yield metadataPromise;
24
- if (metadata.changedOn !== (tempMetadata === null || tempMetadata === void 0 ? void 0 : tempMetadata.changedOn)) {
25
- const baseAppFiles = yield html5RepoManager_1.default.getBaseAppFiles(configuration);
26
- const metadataMap = new Map([[resourceUtil_1.default.METADATA_FILENAME, JSON.stringify(metadata)]]);
27
- yield resourceUtil_1.default.writeTemp(configuration, new Map([...baseAppFiles, ...metadataMap]));
28
- return baseAppFiles;
29
- }
30
- else {
31
- return resourceUtil_1.default.readTemp(configuration);
32
- }
33
- });
34
- }
35
- exports.default = default_1;
36
- //# sourceMappingURL=updateCache.js.map