@ui5/task-adaptation 1.2.0 → 1.3.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/annotationManager.d.ts +3 -3
  3. package/dist/annotationManager.js +15 -16
  4. package/dist/annotations/comparator/comparator.js +30 -26
  5. package/dist/annotations/comparator/diffCase.js +1 -2
  6. package/dist/annotations/comparator/interchangableCase.d.ts +1 -1
  7. package/dist/annotations/comparator/interchangableCase.js +7 -12
  8. package/dist/annotations/converter/metadataJsonReferenceUtil.js +7 -9
  9. package/dist/annotations/converter/metadataJsonUtil.js +7 -10
  10. package/dist/annotations/converter/ui5JsonConverter.js +5 -6
  11. package/dist/annotations/converter/ui5MetadataJsonUtil.js +1 -4
  12. package/dist/annotations/converter/ui5XmlConverter.js +4 -7
  13. package/dist/annotations/dataSource/dataSource.d.ts +5 -5
  14. package/dist/annotations/dataSource/dataSource.js +8 -8
  15. package/dist/annotations/dataSource/dataSourceManager.d.ts +3 -3
  16. package/dist/annotations/dataSource/dataSourceManager.js +8 -13
  17. package/dist/annotations/dataSource/dataSourceOData.d.ts +3 -3
  18. package/dist/annotations/dataSource/dataSourceOData.js +13 -15
  19. package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +1 -1
  20. package/dist/annotations/dataSource/dataSourceODataAnnotation.js +5 -7
  21. package/dist/annotations/serviceRequestor.d.ts +3 -3
  22. package/dist/annotations/serviceRequestor.js +15 -13
  23. package/dist/annotations/transformers/convertV2ToV4.d.ts +1 -1
  24. package/dist/annotations/transformers/convertV2ToV4.js +7 -10
  25. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +1 -1
  26. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +8 -11
  27. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +1 -1
  28. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +3 -6
  29. package/dist/annotations/transformers/transformer.d.ts +2 -2
  30. package/dist/annotations/transformers/transformer.js +1 -2
  31. package/dist/annotations/transformers/traverseReferences.d.ts +1 -1
  32. package/dist/annotations/transformers/traverseReferences.js +16 -17
  33. package/dist/appVariantManager.d.ts +1 -1
  34. package/dist/appVariantManager.js +17 -20
  35. package/dist/baseAppManager.d.ts +2 -2
  36. package/dist/baseAppManager.js +18 -20
  37. package/dist/buildStrategy.js +2 -4
  38. package/dist/bundle.d.ts +25 -0
  39. package/dist/bundle.js +3696 -219
  40. package/dist/cache/annotationsCacheManager.d.ts +2 -2
  41. package/dist/cache/annotationsCacheManager.js +3 -5
  42. package/dist/cache/baseAppFilesCacheManager.d.ts +1 -1
  43. package/dist/cache/baseAppFilesCacheManager.js +3 -6
  44. package/dist/cache/cacheManager.d.ts +1 -1
  45. package/dist/cache/cacheManager.js +9 -12
  46. package/dist/i18nManager.d.ts +3 -3
  47. package/dist/i18nManager.js +23 -23
  48. package/dist/index.d.ts +6 -1
  49. package/dist/index.js +14 -16
  50. package/dist/model/annotationDiffStructureError.js +1 -4
  51. package/dist/model/language.js +4 -4
  52. package/dist/model/noAuthorizationProvidedError.js +1 -4
  53. package/dist/model/serverError.js +1 -4
  54. package/dist/model/types.d.ts +1 -1
  55. package/dist/model/types.js +1 -2
  56. package/dist/processors/abapProcessor.d.ts +5 -5
  57. package/dist/processors/abapProcessor.js +9 -8
  58. package/dist/processors/cfProcessor.d.ts +3 -3
  59. package/dist/processors/cfProcessor.js +7 -8
  60. package/dist/processors/processor.d.ts +1 -1
  61. package/dist/processors/processor.js +11 -15
  62. package/dist/repositories/abapRepoManager.d.ts +1 -1
  63. package/dist/repositories/abapRepoManager.js +14 -14
  64. package/dist/repositories/html5RepoManager.d.ts +1 -1
  65. package/dist/repositories/html5RepoManager.js +12 -14
  66. package/dist/util/cfUtil.d.ts +1 -1
  67. package/dist/util/cfUtil.js +12 -14
  68. package/dist/util/commonUtil.d.ts +2 -2
  69. package/dist/util/commonUtil.js +19 -32
  70. package/dist/util/i18nMerger.d.ts +6 -2
  71. package/dist/util/i18nMerger.js +10 -14
  72. package/dist/util/requestUtil.d.ts +1 -1
  73. package/dist/util/requestUtil.js +9 -12
  74. package/dist/util/resourceUtil.js +8 -11
  75. package/dist/util/urlUtil.d.ts +2 -2
  76. package/dist/util/urlUtil.js +3 -6
  77. package/dist/util/xmlUtil.js +2 -5
  78. package/dist/util/zipUtil.js +2 -6
  79. package/eslint.config.js +52 -0
  80. package/package.json +44 -51
  81. package/scripts/metadataDownloadHelper.ts +8 -7
  82. package/scripts/rollup/bundle.d.ts +25 -0
  83. package/scripts/rollup/bundleDefinition.js +11 -1
  84. package/scripts/{bundler.ts → rollup/bundler.ts} +6 -17
  85. package/scripts/rollup/overrides/sap/base/config.js +10 -0
  86. package/scripts/rollup/project/package.json +2 -1
  87. package/scripts/rollup/project/ui5.yaml +1 -1
  88. package/scripts/rollup/ui5Resolve.ts +14 -38
  89. package/scripts/rollup.ts +67 -23
  90. package/types/ui5.d.ts +44 -0
  91. package/dist/bundle-odata.js +0 -5498
  92. package/scripts/rollup/bundleDefinition-odata.js +0 -9
@@ -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
+ }