@ui5/task-adaptation 1.2.0 → 1.3.1

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 (106) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/eslint.config.js +52 -0
  3. package/package.json +42 -52
  4. package/scripts/metadataDownloadHelper.ts +8 -7
  5. package/scripts/rollup/bundle.d.ts +25 -0
  6. package/scripts/rollup/bundleDefinition.js +11 -1
  7. package/scripts/{bundler.ts → rollup/bundler.ts} +6 -17
  8. package/scripts/rollup/overrides/sap/base/config.js +10 -0
  9. package/scripts/rollup/project/package.json +2 -1
  10. package/scripts/rollup/project/ui5.yaml +1 -1
  11. package/scripts/rollup/ui5Resolve.ts +14 -38
  12. package/scripts/rollup.ts +67 -23
  13. package/types/ui5.d.ts +44 -0
  14. package/dist/annotationManager.d.ts +0 -18
  15. package/dist/annotationManager.js +0 -80
  16. package/dist/annotations/comparator/comparator.d.ts +0 -47
  17. package/dist/annotations/comparator/comparator.js +0 -279
  18. package/dist/annotations/comparator/diffCase.d.ts +0 -4
  19. package/dist/annotations/comparator/diffCase.js +0 -3
  20. package/dist/annotations/comparator/interchangableCase.d.ts +0 -25
  21. package/dist/annotations/comparator/interchangableCase.js +0 -65
  22. package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +0 -12
  23. package/dist/annotations/converter/metadataJsonReferenceUtil.js +0 -50
  24. package/dist/annotations/converter/metadataJsonUtil.d.ts +0 -30
  25. package/dist/annotations/converter/metadataJsonUtil.js +0 -73
  26. package/dist/annotations/converter/ui5JsonConverter.d.ts +0 -21
  27. package/dist/annotations/converter/ui5JsonConverter.js +0 -253
  28. package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +0 -3
  29. package/dist/annotations/converter/ui5MetadataJsonUtil.js +0 -13
  30. package/dist/annotations/converter/ui5XmlConverter.d.ts +0 -5
  31. package/dist/annotations/converter/ui5XmlConverter.js +0 -17
  32. package/dist/annotations/dataSource/dataSource.d.ts +0 -34
  33. package/dist/annotations/dataSource/dataSource.js +0 -62
  34. package/dist/annotations/dataSource/dataSourceManager.d.ts +0 -12
  35. package/dist/annotations/dataSource/dataSourceManager.js +0 -50
  36. package/dist/annotations/dataSource/dataSourceOData.d.ts +0 -17
  37. package/dist/annotations/dataSource/dataSourceOData.js +0 -47
  38. package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +0 -6
  39. package/dist/annotations/dataSource/dataSourceODataAnnotation.js +0 -18
  40. package/dist/annotations/serviceRequestor.d.ts +0 -9
  41. package/dist/annotations/serviceRequestor.js +0 -71
  42. package/dist/annotations/transformers/convertV2ToV4.d.ts +0 -4
  43. package/dist/annotations/transformers/convertV2ToV4.js +0 -16
  44. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +0 -6
  45. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +0 -44
  46. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +0 -4
  47. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +0 -17
  48. package/dist/annotations/transformers/transformer.d.ts +0 -12
  49. package/dist/annotations/transformers/transformer.js +0 -3
  50. package/dist/annotations/transformers/traverseReferences.d.ts +0 -9
  51. package/dist/annotations/transformers/traverseReferences.js +0 -67
  52. package/dist/appVariantManager.d.ts +0 -12
  53. package/dist/appVariantManager.js +0 -105
  54. package/dist/baseAppManager.d.ts +0 -29
  55. package/dist/baseAppManager.js +0 -141
  56. package/dist/buildStrategy.d.ts +0 -7
  57. package/dist/buildStrategy.js +0 -21
  58. package/dist/bundle-odata.js +0 -5498
  59. package/dist/bundle.js +0 -3475
  60. package/dist/cache/annotationsCacheManager.d.ts +0 -8
  61. package/dist/cache/annotationsCacheManager.js +0 -18
  62. package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
  63. package/dist/cache/baseAppFilesCacheManager.js +0 -15
  64. package/dist/cache/cacheManager.d.ts +0 -16
  65. package/dist/cache/cacheManager.js +0 -68
  66. package/dist/i18nManager.d.ts +0 -43
  67. package/dist/i18nManager.js +0 -203
  68. package/dist/index.d.ts +0 -1
  69. package/dist/index.js +0 -27
  70. package/dist/model/annotationDiffStructureError.d.ts +0 -3
  71. package/dist/model/annotationDiffStructureError.js +0 -11
  72. package/dist/model/language.d.ts +0 -13
  73. package/dist/model/language.js +0 -37
  74. package/dist/model/noAuthorizationProvidedError.d.ts +0 -3
  75. package/dist/model/noAuthorizationProvidedError.js +0 -9
  76. package/dist/model/serverError.d.ts +0 -3
  77. package/dist/model/serverError.js +0 -9
  78. package/dist/model/types.d.ts +0 -119
  79. package/dist/model/types.js +0 -3
  80. package/dist/processors/abapProcessor.d.ts +0 -21
  81. package/dist/processors/abapProcessor.js +0 -36
  82. package/dist/processors/cfProcessor.d.ts +0 -17
  83. package/dist/processors/cfProcessor.js +0 -46
  84. package/dist/processors/processor.d.ts +0 -7
  85. package/dist/processors/processor.js +0 -36
  86. package/dist/repositories/abapRepoManager.d.ts +0 -13
  87. package/dist/repositories/abapRepoManager.js +0 -82
  88. package/dist/repositories/html5RepoManager.d.ts +0 -11
  89. package/dist/repositories/html5RepoManager.js +0 -89
  90. package/dist/util/cfUtil.d.ts +0 -30
  91. package/dist/util/cfUtil.js +0 -173
  92. package/dist/util/commonUtil.d.ts +0 -13
  93. package/dist/util/commonUtil.js +0 -129
  94. package/dist/util/i18nMerger.d.ts +0 -28
  95. package/dist/util/i18nMerger.js +0 -103
  96. package/dist/util/requestUtil.d.ts +0 -8
  97. package/dist/util/requestUtil.js +0 -57
  98. package/dist/util/resourceUtil.d.ts +0 -11
  99. package/dist/util/resourceUtil.js +0 -65
  100. package/dist/util/urlUtil.d.ts +0 -4
  101. package/dist/util/urlUtil.js +0 -21
  102. package/dist/util/xmlUtil.d.ts +0 -4
  103. package/dist/util/xmlUtil.js +0 -24
  104. package/dist/util/zipUtil.d.ts +0 -2
  105. package/dist/util/zipUtil.js +0 -20
  106. package/scripts/rollup/bundleDefinition-odata.js +0 -9
package/CHANGELOG.md CHANGED
@@ -2,7 +2,13 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.2.0...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.3.1...HEAD).
6
+
7
+ <a name="v1.3.1"></a>
8
+ ## [v1.3.1] - 2024-06-04
9
+
10
+ <a name="v1.3.0"></a>
11
+ ## [v1.3.0] - 2024-03-22
6
12
 
7
13
  <a name="v1.2.0"></a>
8
14
  ## [v1.2.0] - 2024-03-05
@@ -85,6 +91,8 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
85
91
  <a name="v1.0.0"></a>
86
92
  ## v1.0.0 - 2020-12-09
87
93
 
94
+ [v1.3.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.3.0...v1.3.1
95
+ [v1.3.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.2.0...v1.3.0
88
96
  [v1.2.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.1.3...v1.2.0
89
97
  [v1.1.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.1.2...v1.1.3
90
98
  [v1.1.2]: https://github.com/SAP/ui5-task-adaptation/compare/v1.1.1...v1.1.2
@@ -0,0 +1,52 @@
1
+ // @ts-check
2
+
3
+ import * as eslintimport from "eslint-plugin-import";
4
+
5
+ import eslint from "@eslint/js";
6
+ import tseslint from "typescript-eslint";
7
+
8
+ export default tseslint.config(
9
+ eslint.configs.recommended,
10
+ ...tseslint.configs.recommendedTypeChecked,
11
+ {
12
+ languageOptions: {
13
+ parserOptions: {
14
+ project: true,
15
+ tsconfigRootDir: import.meta.dirname,
16
+ },
17
+ },
18
+ plugins: {
19
+ import: eslintimport
20
+ },
21
+ rules: {
22
+ "@typescript-eslint/no-explicit-any": "off",
23
+ "@typescript-eslint/no-unsafe-call": "off",
24
+ "@typescript-eslint/no-unsafe-member-access": "off",
25
+ "@typescript-eslint/no-unsafe-assignment": "off",
26
+ "@typescript-eslint/no-unsafe-return": "off",
27
+ "@typescript-eslint/no-unsafe-argument": "off",
28
+ "@typescript-eslint/no-redundant-type-constituents": "off",
29
+ "@typescript-eslint/ban-ts-comment": "off",
30
+ "@typescript-eslint/no-base-to-string": "off",
31
+ "@typescript-eslint/restrict-template-expressions": "off",
32
+ "@typescript-eslint/unbound-method": "off",
33
+ "@typescript-eslint/no-unnecessary-type-assertion": "off",
34
+ "@typescript-eslint/require-await": "off",
35
+ "@typescript-eslint/no-floating-promises": "off",
36
+ "@typescript-eslint/ban-types": "off",
37
+ "@typescript-eslint/await-thenable": "off",
38
+ "no-constant-condition": "off",
39
+ "no-useless-escape": "off",
40
+ "no-unsafe-optional-chaining": "off",
41
+ "no-extra-semi": "off",
42
+ "prefer-const": "off",
43
+ "import/extensions": [
44
+ "error",
45
+ "ignorePackages",
46
+ {
47
+ "js": "always"
48
+ }
49
+ ]
50
+ }
51
+ }
52
+ );
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@ui5/task-adaptation",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "npm run build && npm run coverage",
8
- "dev": "mocha --no-timeouts -r ts-node/register 'test/**/*.spec.ts'",
9
- "perf": "mocha --no-timeouts -r ts-node/register 'test/**/*.perf.ts'",
10
- "coverage": "nyc mocha -r ts-node/register 'test/**/*.spec.ts'",
11
- "coverage-verbose": "nyc --reporter=html --reporter=text mocha -r ts-node/register 'test/**/*.spec.ts'",
12
- "preversion": "npm test",
7
+ "test": "npm run lint && npm run build && npm run coverage",
8
+ "lint": "npx eslint ./src",
9
+ "dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.spec.ts'",
10
+ "perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.perf.ts'",
11
+ "coverage": "npx c8 npm run dev",
12
+ "preversion": "",
13
13
  "version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
14
14
  "prepublishOnly": "git push --follow-tags",
15
15
  "release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
16
- "rollup": "npx ts-node scripts/rollup.ts",
17
- "build": "npm run rollup && rimraf dist/resources && tsc -p ./",
18
- "download-metadata": "npx ts-node scripts/metadataDownloadHelper.ts"
16
+ "rollup": "tsx scripts/rollup.ts",
17
+ "build": "npm run rollup && tsc -p ./",
18
+ "download-metadata": "tsx scripts/metadataDownloadHelper.ts"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
@@ -33,29 +33,21 @@
33
33
  "author": "SAP SE",
34
34
  "license": "Apache-2.0",
35
35
  "dependencies": {
36
- "@buxlabs/amd-to-es6": "^0.16.1",
37
- "@rollup/plugin-node-resolve": "^13.0.4",
38
- "@sap/cf-tools": "^2.0.1",
39
- "@ui5/fs": "^2.0.6",
40
- "@ui5/logger": "^2.0.1",
41
- "@ui5/project": "^2.6.0",
36
+ "@sap/cf-tools": "^3.2.0",
37
+ "@ui5/fs": "^3.0.5",
38
+ "@ui5/logger": "^3.0.0",
42
39
  "adm-zip": "^0.5.5",
43
- "amdextract": "^3.0.0",
44
40
  "axios": "^1.6.2",
45
- "builtin-modules": "^3.2.0",
46
41
  "crc": "^4.3.2",
47
42
  "dotenv": "^16.0.3",
48
- "glob": "^10.3.10",
49
- "js-yaml": "^4.1.0",
50
43
  "jsdom": "^23.0.1",
51
- "rimraf": "^5.0.5",
52
- "rollup": "^2.56.3",
53
- "semver": "^7.3.5",
54
44
  "temp-dir": "^2.0.0",
55
45
  "xml-js": "^1.6.11"
56
46
  },
57
47
  "devDependencies": {
48
+ "@buxlabs/amd-to-es6": "^0.16.1",
58
49
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
50
+ "@rollup/plugin-node-resolve": "^15.2.3",
59
51
  "@types/adm-zip": "^0.4.34",
60
52
  "@types/chai": "^4.2.21",
61
53
  "@types/chai-as-promised": "^7.1.4",
@@ -63,22 +55,36 @@
63
55
  "@types/jsdom": "^21.1.6",
64
56
  "@types/lodash": "^4.14.196",
65
57
  "@types/mocha": "^9.1.0",
66
- "@types/rimraf": "^4.0.5",
67
58
  "@types/semver": "^7.3.8",
68
59
  "@types/sinon": "^10.0.16",
60
+ "@ui5/project": "^3.9.0",
61
+ "amdextract": "^3.0.0",
62
+ "builtin-modules": "^3.2.0",
63
+ "c8": "^9.1.0",
69
64
  "chai": "^4.3.4",
70
65
  "chai-as-promised": "^7.1.1",
71
66
  "chalk": "^4.1.2",
67
+ "eslint": "^8.57.0",
68
+ "eslint-plugin-import": "^2.29.1",
69
+ "esmock": "^2.6.3",
70
+ "glob": "^10.3.10",
71
+ "js-yaml": "^4.1.0",
72
+ "lodash": "^4.17.21",
72
73
  "minimatch": "^9.0.3",
73
- "mocha": "^9.2.0",
74
+ "mocha": "^10.2.0",
74
75
  "mock-require": "^3.0.3",
75
76
  "nyc": "^15.1.0",
76
- "sinon": "^15.2.0",
77
+ "rollup": "^4.9.6",
78
+ "semver": "^7.3.5",
79
+ "sinon": "^17.0.1",
77
80
  "source-map-support": "^0.5.19",
78
- "ts-node": "^10.4.0",
79
- "typescript": "^4.3.5"
81
+ "tsx": "^4.7.1",
82
+ "typescript": "^5.4.2",
83
+ "typescript-eslint": "^7.2.0"
80
84
  },
81
- "nyc": {
85
+ "c8": {
86
+ "src": "./src",
87
+ "all": true,
82
88
  "reporter": [
83
89
  "lcov",
84
90
  "text",
@@ -95,33 +101,17 @@
95
101
  "src/model/types.ts",
96
102
  "src/util/requestUtil.ts",
97
103
  "scripts/**/*.js",
98
- "scripts/git/octokitUtil.ts"
104
+ "scripts/git/octokitUtil.ts",
105
+ "*/**/*.d.ts",
106
+ "src/annotations/comparator/diffCase.ts",
107
+ "src/annotations/transformers/transformer.ts"
99
108
  ],
100
109
  "check-coverage": true,
101
110
  "statements": 85,
102
111
  "branches": 70,
103
112
  "functions": 90,
104
- "lines": 85,
105
- "watermarks": {
106
- "statements": [
107
- 70,
108
- 90
109
- ],
110
- "branches": [
111
- 70,
112
- 90
113
- ],
114
- "functions": [
115
- 70,
116
- 90
117
- ],
118
- "lines": [
119
- 70,
120
- 90
121
- ]
122
- },
123
- "cache": true,
124
- "all": true
113
+ "lines": 85
125
114
  },
126
- "types": "dist/index.d.ts"
115
+ "types": "dist/index.d.ts",
116
+ "type": "module"
127
117
  }
@@ -1,7 +1,8 @@
1
1
  import * as dotenv from "dotenv";
2
2
  import * as fs from "fs/promises";
3
+
3
4
  import { Agent } from "https";
4
- import RequestUtil from "../src/util/requestUtil";
5
+ import RequestUtil from "../src/util/requestUtil.js";
5
6
 
6
7
  dotenv.config();
7
8
  const httpsAgent = new Agent({ rejectUnauthorized: false });
@@ -75,13 +76,13 @@ const hostArgIndex = args.findIndex(arg => arg.startsWith('--host='));
75
76
 
76
77
  // If the `--host=` argument is found
77
78
  if (hostArgIndex !== -1) {
78
- // Extract the value of the `--host=` argument
79
- const hostArg = args[hostArgIndex];
80
- let host = hostArg.split('=')[1];
81
- host = host.endsWith("/") ? host.substring(0, host.lastIndexOf("/")) : host;
79
+ // Extract the value of the `--host=` argument
80
+ const hostArg = args[hostArgIndex];
81
+ let host = hostArg.split('=')[1];
82
+ host = host.endsWith("/") ? host.substring(0, host.lastIndexOf("/")) : host;
82
83
 
83
- // Use the `host` variable as needed
84
- MetadataDownloadHelper.fetchAllUrls(host);
84
+ // Use the `host` variable as needed
85
+ MetadataDownloadHelper.fetchAllUrls(host);
85
86
  } else {
86
87
  console.info("Please provide missing host parameter");
87
88
  }
@@ -0,0 +1,25 @@
1
+ export declare const RegistrationBuild: () => void;
2
+
3
+ export declare class Applier {
4
+ static applyChanges(manifest: any, changes: Change[], strategy: any): Promise<void>;
5
+ }
6
+
7
+ export declare class Change {
8
+ constructor(change: any);
9
+ getLayer(): string;
10
+ _oDefinition: any;
11
+ }
12
+
13
+ export declare class V2MetadataConverter {
14
+ convertXMLMetadata(jsdom: any): any;
15
+ }
16
+
17
+ export declare class V4MetadataConverter {
18
+ convertXMLMetadata(jsdom: any): any;
19
+ }
20
+
21
+ export declare class URI {
22
+ constructor(relativeUrl: string);
23
+ absoluteTo(url: string): string;
24
+ static parse(url: string): { path: string };
25
+ }
@@ -1,11 +1,21 @@
1
+ //Flex
1
2
  import Applier from "sap/ui/fl/apply/_internal/changes/descriptor/Applier";
2
3
  import ApplyUtil from "sap/ui/fl/apply/_internal/changes/descriptor/ApplyUtil";
3
4
  import Change from "sap/ui/fl/Change";
4
5
  import RegistrationBuild from "sap/ui/fl/apply/_internal/changes/descriptor/RegistrationBuild";
6
+ //OData
7
+ import URI from "sap/ui/thirdparty/URI";
8
+ import V2MetadataConverter from "sap/ui/model/odata/v4/lib/_V2MetadataConverter";
9
+ import V4MetadataConverter from "sap/ui/model/odata/v4/lib/_V4MetadataConverter";
5
10
 
6
11
  export {
12
+ //Flex
7
13
  Applier,
8
14
  ApplyUtil,
9
15
  Change,
10
- RegistrationBuild
16
+ RegistrationBuild,
17
+ //OData
18
+ URI,
19
+ V4MetadataConverter,
20
+ V2MetadataConverter
11
21
  };
@@ -1,32 +1,22 @@
1
1
  import * as rollup from "rollup";
2
2
  import * as builtins from "builtin-modules";
3
- import ui5 from "./rollup/ui5Resolve";
3
+ import ui5 from "./ui5Resolve.js";
4
4
  import { nodeResolve } from "@rollup/plugin-node-resolve";
5
5
 
6
6
 
7
7
  export default abstract class Bundler {
8
8
 
9
- static async run(project: any, input: string, output: string,
10
- assets: string[], skipTransformation?: string[]): Promise<void> {
11
- if (skipTransformation == null) {
12
- skipTransformation = [];
13
- }
14
- if (skipTransformation.includes(input) === false) {
9
+ static async run(resources: Map<string, any>, input: string, output: string, skipTransformation: string[] = []): Promise<void> {
10
+ if (!skipTransformation.includes(input)) {
15
11
  skipTransformation.push(input);
16
12
  }
17
- await this.bundle(project, input, output, assets, skipTransformation);
18
- }
19
-
20
- private static async bundle(project: any, input: string, output: string,
21
- assets: string[], skipTransformation: string[]): Promise<void> {
22
13
  const inputOptions = <rollup.RollupOptions>{
23
14
  input,
24
15
  plugins: [
25
16
  ui5({
26
- assets,
17
+ resources,
27
18
  skipTransformation,
28
- output,
29
- project
19
+ output
30
20
  }),
31
21
  nodeResolve({
32
22
  preferBuiltins: true
@@ -35,10 +25,9 @@ export default abstract class Bundler {
35
25
  external: builtins
36
26
  };
37
27
  const bundle = await rollup.rollup(inputOptions);
38
-
39
28
  const outputOptions = <rollup.RollupOptions>{
40
29
  file: output,
41
- format: "commonjs"
30
+ format: "esm"
42
31
  };
43
32
  await bundle.write(outputOptions);
44
33
  await bundle.close();
@@ -0,0 +1,10 @@
1
+ export default class config {
2
+ static get Type() {
3
+ return {
4
+ String: "string"
5
+ }
6
+ }
7
+ static get({ name }) {
8
+ return name === "sapUiLogLevel" ? "Error" : undefined;
9
+ }
10
+ }
@@ -1,3 +1,4 @@
1
1
  {
2
- "name": "rollup"
2
+ "name": "rollup",
3
+ "version": "1.0.0"
3
4
  }
@@ -6,7 +6,7 @@ metadata:
6
6
  allowSapInternal: true
7
7
  framework:
8
8
  name: SAPUI5
9
- version: "1.115.0"
9
+ version: 0.0.0
10
10
  libraries:
11
11
  - name: sap.ui.fl
12
12
  - name: sap.suite.ui.generic.template
@@ -1,13 +1,15 @@
1
1
  import * as crypto from "crypto";
2
2
  import * as fs from "fs";
3
3
  import * as path from "path";
4
- import * as stream from "stream";
5
4
 
6
- import { promisify } from "util";
5
+ //@ts-ignore
6
+ import convertAMDtoES6 from "@buxlabs/amd-to-es6";
7
+ import { dirname } from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+ import { getLogger } from "@ui5/logger";
7
10
 
8
- const convertAMDtoES6 = require("@buxlabs/amd-to-es6");
9
- const log = require("@ui5/logger").getLogger("rollup-plugin-ui5-resolve-task-adaptation");
10
- const { resourceFactory } = require("@ui5/fs");
11
+ const log = getLogger("rollup-plugin-ui5-resolve-task-adaptation");
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
13
 
12
14
 
13
15
  interface TransformCase {
@@ -29,35 +31,12 @@ class UriTransformCase implements TransformCase {
29
31
 
30
32
  export default function (options: any) {
31
33
 
32
- let dependencies: any;
33
-
34
34
  const skipTransformation = (id: string) => !options.skipTransformation?.includes(id);
35
35
 
36
36
  return {
37
37
 
38
38
  name: "ui5-resolve",
39
39
 
40
- buildStart: async (_: any) => {
41
-
42
- dependencies = resourceFactory.createCollectionsForTree(options.project, {}).dependencies;
43
-
44
- const pipe = promisify(stream.pipeline);
45
- const resources: any[] = await Promise.all(options.assets.map((asset: string) => dependencies.byGlob(asset)));
46
- const writePromises = [].concat(...resources).map((resource: any) => {
47
- const file = `./dist${resource.getPath()}`;
48
- const folder = path.dirname(file);
49
- if (!fs.existsSync(folder)) {
50
- fs.mkdirSync(folder, { recursive: true });
51
- }
52
- if (fs.existsSync(file)) {
53
- fs.unlinkSync(file);
54
- }
55
- return pipe(resource.getStream(), fs.createWriteStream(file));
56
- });
57
- await Promise.all(writePromises);
58
- },
59
-
60
-
61
40
  /*
62
41
  * Right before writing result to dist
63
42
  */
@@ -79,13 +58,9 @@ export default function (options: any) {
79
58
  load: async (id: string) => {
80
59
  log.verbose(`load: ${id}`);
81
60
 
82
- if (!dependencies) {
83
- dependencies = resourceFactory.createCollectionsForTree(options.project, {}).dependencies;
84
- }
85
-
86
61
  const localFile = path.join(__dirname, id);
87
62
  if (fs.existsSync(localFile)) {
88
- log.info(`Using local file "${id}"`);
63
+ log.info(`Bundle definition "${id}"`);
89
64
  return fs.readFileSync(localFile, {
90
65
  encoding: "utf8"
91
66
  });
@@ -93,12 +68,13 @@ export default function (options: any) {
93
68
 
94
69
  const localOverride = path.resolve(__dirname, "overrides", id + ".js");
95
70
  if (fs.existsSync(localOverride)) {
96
- log.info(`Using local override for "${id}"`);
71
+ log.info(`Override with "${id}"`);
97
72
  return fs.readFileSync(localOverride, { encoding: "utf8" });
98
73
  }
99
-
100
- const resource = await dependencies.byPath(`/resources/${id}.js`);
101
- return resource.getString();
74
+ const filepath = `/resources/${id}.js`;
75
+ if (options.resources.has(filepath)) {
76
+ return await options.resources.get(filepath).getString();
77
+ }
102
78
  },
103
79
 
104
80
 
@@ -160,4 +136,4 @@ function replaceRequireAsync(code: string) {
160
136
 
161
137
  function replaceRequireAsyncWith(code: string, requireAsyncSearchKeyword: string, inserts: string[]) {
162
138
  return code.replace(requireAsyncSearchKeyword, inserts.join(",\n\t"));
163
- }
139
+ }
package/scripts/rollup.ts CHANGED
@@ -2,10 +2,16 @@ import * as fs from "fs";
2
2
  import * as path from "path";
3
3
  import * as semver from "semver";
4
4
  import * as yaml from "js-yaml";
5
- import Bundler from "./bundler";
5
+ import Bundler from "./rollup/bundler.js";
6
+ import { dirname } from "node:path";
7
+ import { fileURLToPath } from "node:url";
6
8
 
7
- const { normalizer } = require("@ui5/project");
8
- const log = require("@ui5/logger").getLogger("rollup-plugin-ui5-resolve-task-adaptation");
9
+ import * as resourceFactory from "@ui5/fs/resourceFactory";
10
+ import { graphFromPackageDependencies } from "@ui5/project/graph";
11
+ import { getLogger } from "@ui5/logger";
12
+
13
+ const log = getLogger("rollup-plugin-ui5-resolve-task-adaptation");
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
15
 
10
16
  const projectPaths = [
11
17
  path.resolve(__dirname, "rollup", "project")
@@ -22,11 +28,9 @@ export default class Builder {
22
28
  };
23
29
  const version = this.validateProjectSettings(cwd);
24
30
  if (version === LATEST_VERSION_PLACEHOLDER) {
25
- options.frameworkOptions = {
26
- versionOverride: "latest"
27
- }
31
+ options.versionOverride = "latest";
28
32
  }
29
- return normalizer.generateProjectTree(options);
33
+ return await graphFromPackageDependencies(options);
30
34
  } catch (error: any) {
31
35
  log.info(`${error.message}`);
32
36
  }
@@ -56,35 +60,75 @@ export default class Builder {
56
60
  }
57
61
  }
58
62
 
63
+ static async getResources(namespaces: Map<string, string[]>, projectGraph: any): Promise<Map<string, any>> {
64
+ const fsBasePaths = new Set<string>();
65
+ const adapters = new Map<string, any>();
66
+ for (const project of [...projectGraph.getProjects("rollup")]) {
67
+ const fsBasePath = project.getSourcePath();
68
+ if (!fsBasePaths.has(fsBasePath)) {
69
+ adapters.set(project.getNamespace(), resourceFactory.createReader({
70
+ fsBasePath,
71
+ virBasePath: "/resources/"
72
+ }));
73
+ fsBasePaths.add(fsBasePath);
74
+ }
75
+ }
76
+
77
+ const resources = new Map<string, any>();
78
+ for (const [namespace, adapter] of adapters.entries()) {
79
+ const patterns = namespaces.get(namespace);
80
+ if (patterns) {
81
+ for (const pattern of patterns) {
82
+ const result = await adapter.byGlob(pattern) as any[];
83
+ result.forEach(resource => resources.set(resource.getPath(), resource));
84
+ }
85
+ }
86
+ }
87
+
88
+ return resources;
89
+ }
90
+
91
+ static copyTypeDefinition() {
92
+ fs.copyFileSync(path.join(__dirname, "rollup", "bundle.d.ts"), path.join(process.cwd(), "dist", "bundle.d.ts"))
93
+ }
94
+
59
95
  static async run(): Promise<void> {
60
96
  const project = await this.getProjectInfo(projectPaths);
61
97
  if (!project) {
62
98
  throw new Error("ui5.yaml is not found or incorrect");
63
99
  }
100
+ const namespaces = new Map([
101
+ ["sap/fe/core", [
102
+ "/resources/sap/fe/core/**"
103
+ ]],
104
+ ["sap/ui/fl", [
105
+ "/resources/sap/ui/fl/**"
106
+ ]],
107
+ ["sap/ui/core", [
108
+ "/resources/ui5loader-autoconfig.js",
109
+ "/resources/sap/base/**",
110
+ "/resources/sap/ui/{base,thirdparty,model}/**"
111
+ ]],
112
+ ["sap/suite/ui/generic/template", [
113
+ "/resources/sap/suite/ui/generic/template/**"
114
+ ]]
115
+ ]);
116
+ const resources = await this.getResources(namespaces, project);
64
117
  await Bundler.run(
65
- project,
118
+ resources,
66
119
  "bundleDefinition.js",
67
120
  "./dist/bundle.js",
68
121
  [
69
- "/resources/sap/ui/fl/**",
70
- "/resources/sap/suite/ui/generic/template/**"
71
- ]);
72
- await Bundler.run(
73
- project,
74
- "bundleDefinition-odata.js",
75
- "./dist/bundle-odata.js",
76
- [
77
- "/resources/sap/ui/model/**",
78
- "sap/ui/util/XMLHelper",
79
- "sap/ui/core/Core"
80
- ],
81
- [
82
- "sap/ui/performance/Measurement"
122
+ "sap/ui/performance/Measurement",
123
+ "sap/base/config.js"
83
124
  ]
84
125
  );
126
+ this.copyTypeDefinition();
85
127
  }
86
128
  }
87
129
 
88
130
  if (process.argv.length === 2) {
89
- Builder.run();
131
+ const start = Date.now();
132
+ await Builder.run();
133
+ log.info(`Bundled in ${Date.now() - start} ms`);
90
134
  }
package/types/ui5.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ declare module "@ui5/logger" {
2
+ export function getLogger(name: string): any;
3
+ }
4
+
5
+ declare module "@ui5/fs/resourceFactory" {
6
+ export function createResource(options: any): any;
7
+ export function createReader(options: any): any;
8
+ export function createAdapter(options: any): any;
9
+ export function createWorkspace(options: any): any;
10
+ export function createCollectionsForTree(project: any, options: any): any;
11
+ }
12
+
13
+ declare class Resource {
14
+ getPath(): string;
15
+ clone(): Resource;
16
+ setPath(path: string): void;
17
+ getString(): Promise<string>;
18
+ setString(string: string): void;
19
+ }
20
+
21
+ declare module "@ui5/fs/Resource" {
22
+ export function getPath(): string;
23
+ export function clone(): Resource;
24
+ export function setPath(path: string): void;
25
+ export function getString(): Promise<string>;
26
+ export function setString(string: string): void;
27
+ }
28
+
29
+ declare module "@ui5/project/graph" {
30
+ export function graphFromPackageDependencies(options: any): any;
31
+ }
32
+
33
+ declare module "@ui5/project/build/helpers/BuildContext" {
34
+ export default class BuildContext {
35
+ constructor(projectGraph: any, options: any);
36
+ createProjectContext(options: any): any;
37
+ }
38
+ }
39
+
40
+ declare module "@ui5/project/build/helpers/TaskUtil" {
41
+ export default class TaskUtil {
42
+ constructor(options: any);
43
+ }
44
+ }