@ui5/task-adaptation 1.5.2 → 1.6.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/.hyperspace/pull_request_bot.json +19 -0
- package/CHANGELOG.md +11 -6
- package/dist/appVariantManager.js +1 -1
- package/dist/baseAppManager.js +3 -3
- package/dist/buildStrategy.d.ts +0 -3
- package/dist/buildStrategy.js +0 -7
- package/dist/bundle.d.ts +4 -3
- package/dist/bundle.js +3650 -3595
- package/dist/cache/cacheHolder.d.ts +1 -1
- package/dist/cache/cacheHolder.js +8 -6
- package/dist/index.js +5 -1
- package/dist/model/authenticationError.d.ts +3 -0
- package/dist/model/authenticationError.js +8 -0
- package/dist/model/types.d.ts +12 -0
- package/dist/previewManager.d.ts +13 -0
- package/dist/previewManager.js +142 -0
- package/dist/processors/abapProcessor.d.ts +1 -0
- package/dist/processors/abapProcessor.js +3 -0
- package/dist/processors/cfProcessor.d.ts +2 -1
- package/dist/processors/cfProcessor.js +11 -1
- package/dist/processors/processor.d.ts +2 -1
- package/dist/repositories/html5RepoManager.d.ts +3 -2
- package/dist/repositories/html5RepoManager.js +18 -5
- package/dist/util/cfUtil.d.ts +8 -1
- package/dist/util/cfUtil.js +16 -8
- package/dist/util/movingHandler/changeFileMoveHandler.d.ts +8 -0
- package/dist/util/movingHandler/changeFileMoveHandler.js +77 -0
- package/dist/util/resourceUtil.d.ts +11 -3
- package/dist/util/resourceUtil.js +83 -18
- package/eslint.config.js +4 -3
- package/package.json +19 -20
- package/rollup/amdToEsm.ts +22 -0
- package/rollup/bundle.d.ts +25 -0
- package/rollup/bundleDefinition.js +19 -0
- package/rollup/bundler.ts +35 -0
- package/rollup/overrides/sap/base/config.js +59 -0
- package/rollup/overrides/sap/ui/fl/apply/_internal/flexObjects/AppDescriptorChange.js +68 -0
- package/rollup/overrides/sap/ui/performance/Measurement.js +4 -0
- package/rollup/project/package.json +4 -0
- package/rollup/project/ui5.yaml +13 -0
- package/rollup/project/webapp/manifest.json +5 -0
- package/rollup/rollup.ts +133 -0
- package/rollup/ui5Resolve.ts +145 -0
- package/scripts/publish.ts +256 -0
- package/scripts/test-integration-prep.sh +4 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as crypto from "crypto";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
|
|
5
|
+
//@ts-ignore
|
|
6
|
+
import convertAMDtoES6 from "@buxlabs/amd-to-es6";
|
|
7
|
+
import convertAMDtoESM from "./amdToEsm.js";
|
|
8
|
+
import { dirname } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { getLogger } from "@ui5/logger";
|
|
11
|
+
|
|
12
|
+
const log = getLogger("rollup-plugin-ui5-resolve-task-adaptation");
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
interface TransformCase {
|
|
17
|
+
accept(code: string, id: string): string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class UriTransformCase implements TransformCase {
|
|
21
|
+
accept(code: string, id: string) {
|
|
22
|
+
if (id !== "sap/ui/thirdparty/URI") {
|
|
23
|
+
return code;
|
|
24
|
+
}
|
|
25
|
+
const header = code.substring(0, code.indexOf("(function"));
|
|
26
|
+
const neededCode = code.substring(code.indexOf("root) {") + 8, code.lastIndexOf("}));"))
|
|
27
|
+
.replace(/root/g, "window");
|
|
28
|
+
return header + "define('sap/ui/thirdparty/URI', [], function () {" + neededCode + "});";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export default function (options: any) {
|
|
34
|
+
|
|
35
|
+
const skipTransformation = (id: string) => !options.skipTransformation?.includes(id);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
|
|
39
|
+
name: "ui5-resolve",
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Right before writing result to dist
|
|
43
|
+
*/
|
|
44
|
+
renderChunk: (code: string) => {
|
|
45
|
+
return `var window = {};\n${code}`;
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
resolveId: (source: string, importer: string) => {
|
|
50
|
+
log.verbose(`resolveId: ${source} from ${importer}`);
|
|
51
|
+
if (importer && source.startsWith(".")) {
|
|
52
|
+
source = path.posix.join(path.dirname(importer), source);
|
|
53
|
+
}
|
|
54
|
+
log.verbose(" --> resolve to: " + source);
|
|
55
|
+
return source;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
load: async (id: string) => {
|
|
60
|
+
log.verbose(`load: ${id}`);
|
|
61
|
+
|
|
62
|
+
const localFile = path.join(__dirname, id);
|
|
63
|
+
if (fs.existsSync(localFile)) {
|
|
64
|
+
log.info(`Bundle definition "${id}"`);
|
|
65
|
+
return fs.readFileSync(localFile, {
|
|
66
|
+
encoding: "utf8"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const localOverride = path.resolve(__dirname, "overrides", id + ".js");
|
|
71
|
+
if (fs.existsSync(localOverride)) {
|
|
72
|
+
log.info(`Override with "${id}"`);
|
|
73
|
+
return fs.readFileSync(localOverride, { encoding: "utf8" });
|
|
74
|
+
}
|
|
75
|
+
const filepath = `/resources/${id}.js`;
|
|
76
|
+
if (options.resources.has(filepath)) {
|
|
77
|
+
return await options.resources.get(filepath).getString();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
transform: (code: string, id: string): string | undefined => {
|
|
83
|
+
const skipped = !skipTransformation(id);
|
|
84
|
+
log.verbose(`transform: ${id} ${skipped ? "skipped" : ""}`);
|
|
85
|
+
if (skipped) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
code = replaceRequireAsync(code);
|
|
90
|
+
code = transform(code, id);
|
|
91
|
+
|
|
92
|
+
code = code
|
|
93
|
+
.replace(/sap\.ui\.define/g, "define")
|
|
94
|
+
.replace(/\, \/\* bExport\= \*\/ true\)/g, ")")
|
|
95
|
+
.replace(/},.*(true|false)\);$/g, "});")
|
|
96
|
+
.replace(/},.*(true|false)\);(\n\/\/# sourceMappingURL=)*/g, "});\n//# sourceMappingURL=");
|
|
97
|
+
try {
|
|
98
|
+
return convertAMDtoES6(code);
|
|
99
|
+
} catch (_: any) {
|
|
100
|
+
return convertAMDtoESM(code);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
function transform(code: string, id: string) {
|
|
109
|
+
const transformers = [
|
|
110
|
+
new UriTransformCase()
|
|
111
|
+
];
|
|
112
|
+
for (const transformer of transformers) {
|
|
113
|
+
code = transformer.accept(code, id);
|
|
114
|
+
}
|
|
115
|
+
return code;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
function replaceRequireAsync(code: string) {
|
|
120
|
+
const requireAsyncPattern = /requireAsync((.bind\(this, ")|(\("))+(?<url>[\/\w]*)"\)/mg;
|
|
121
|
+
let match, defineUrls = new Array<string>(), defineVars = new Array<string>(), matches = new Map();
|
|
122
|
+
// eslint-disable-next-line no-cond-assign
|
|
123
|
+
while (match = requireAsyncPattern.exec(code)) {
|
|
124
|
+
if (match.groups?.url) {
|
|
125
|
+
const varaibleName = match.groups.url.split("/").pop() + crypto.randomBytes(16).toString("hex");
|
|
126
|
+
defineUrls.push(`"${match.groups.url}"`);
|
|
127
|
+
defineVars.push(varaibleName);
|
|
128
|
+
const value = match[0].includes("requireAsync.bind")
|
|
129
|
+
? `() => Promise.resolve(${varaibleName})`
|
|
130
|
+
: varaibleName;
|
|
131
|
+
matches.set(match[0], value);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (defineUrls.length > 0 && defineVars.length > 0) {
|
|
135
|
+
matches.forEach((value, key) => code = code.replace(key, value));
|
|
136
|
+
code = replaceRequireAsyncWith(code, `"sap/ui/fl/requireAsync"`, defineUrls);
|
|
137
|
+
code = replaceRequireAsyncWith(code, "requireAsync", defineVars);
|
|
138
|
+
}
|
|
139
|
+
return code;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
function replaceRequireAsyncWith(code: string, requireAsyncSearchKeyword: string, inserts: string[]) {
|
|
144
|
+
return code.replace(requireAsyncSearchKeyword, inserts.join(",\n\t"));
|
|
145
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import yargs from "yargs";
|
|
4
|
+
import { hideBin } from "yargs/helpers";
|
|
5
|
+
import { Octokit } from "@octokit/rest";
|
|
6
|
+
import { retry } from "@octokit/plugin-retry";
|
|
7
|
+
|
|
8
|
+
const OctokitClass = Octokit.plugin(retry);
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Recursively get all file paths in the workspace root, excluding:
|
|
13
|
+
* - test/lib/integration
|
|
14
|
+
* - test/fixtures
|
|
15
|
+
* - test/expected
|
|
16
|
+
* - test/lib/index.perf.ts
|
|
17
|
+
* Returns relative paths from the root.
|
|
18
|
+
*/
|
|
19
|
+
async function getAllRootFilesExceptTestExclusions(root: string): Promise<string[]> {
|
|
20
|
+
const excludeDirs = [
|
|
21
|
+
"test/lib/integration",
|
|
22
|
+
"test/fixtures",
|
|
23
|
+
"test/expected",
|
|
24
|
+
".git",
|
|
25
|
+
"coverage",
|
|
26
|
+
".DS_Store",
|
|
27
|
+
"node_modules",
|
|
28
|
+
".nyc_output",
|
|
29
|
+
"coverage",
|
|
30
|
+
"dist",
|
|
31
|
+
"dist-debug",
|
|
32
|
+
"dist.zip",
|
|
33
|
+
".env",
|
|
34
|
+
"test/resources/metadata/download"
|
|
35
|
+
];
|
|
36
|
+
const excludeFiles = [
|
|
37
|
+
"test/lib/index.perf.ts",
|
|
38
|
+
"scripts/test-integration-prep.sh",
|
|
39
|
+
"Jenkinsfile"
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
async function walk(dir: string): Promise<string[]> {
|
|
43
|
+
const dirents = await fs.readdir(dir, { withFileTypes: true });
|
|
44
|
+
const files: string[] = [];
|
|
45
|
+
for (const dirent of dirents) {
|
|
46
|
+
const relPath = path.relative(root, path.join(dir, dirent.name));
|
|
47
|
+
if (excludeDirs.some(ex => relPath === ex || relPath.startsWith(ex + path.sep))) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (excludeFiles.includes(relPath)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (dirent.isDirectory()) {
|
|
54
|
+
files.push(...await walk(path.join(dir, dirent.name)));
|
|
55
|
+
} else {
|
|
56
|
+
files.push(relPath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return files;
|
|
60
|
+
}
|
|
61
|
+
return walk(root);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const FILES = await getAllRootFilesExceptTestExclusions(process.cwd());
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
interface PublishArgs {
|
|
68
|
+
p?: string;
|
|
69
|
+
dryRun?: boolean;
|
|
70
|
+
tag?: string;
|
|
71
|
+
branch?: string;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function publish() {
|
|
76
|
+
const argv = yargs(hideBin(process.argv))
|
|
77
|
+
.option("p", {
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "GitHub token (-p)",
|
|
80
|
+
alias: "p"
|
|
81
|
+
})
|
|
82
|
+
.option("dryRun", {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
description: "Run without publishing",
|
|
85
|
+
default: false
|
|
86
|
+
})
|
|
87
|
+
.option("tag", {
|
|
88
|
+
type: "string",
|
|
89
|
+
description: "Publish with a specific tag"
|
|
90
|
+
})
|
|
91
|
+
.option("branch", {
|
|
92
|
+
type: "string",
|
|
93
|
+
description: "Branch to update (default: main)",
|
|
94
|
+
default: "main",
|
|
95
|
+
alias: "b"
|
|
96
|
+
})
|
|
97
|
+
.help()
|
|
98
|
+
.alias("h", "help")
|
|
99
|
+
.parseSync() as PublishArgs;
|
|
100
|
+
|
|
101
|
+
if (argv.dryRun) {
|
|
102
|
+
console.log("Dry run: no publishing will be performed.");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const auth = argv.p;
|
|
106
|
+
if (auth) {
|
|
107
|
+
const octokit = new OctokitClass({ auth });
|
|
108
|
+
const ORGANIZATION = "SAP";
|
|
109
|
+
const REPO = "ui5-task-adaptation";
|
|
110
|
+
await uploadToRepo(octokit, ORGANIZATION, REPO, argv.branch);
|
|
111
|
+
if (argv.tag) {
|
|
112
|
+
console.log(`Published with tag: ${argv.tag}`);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
console.log("Github token is not provided.");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
async function getLatestVersion(): Promise<string> {
|
|
121
|
+
const pkg = await fs.readFile(path.join(process.cwd(), "package.json"), { encoding: "utf-8" });
|
|
122
|
+
const pkgJson = JSON.parse(pkg);
|
|
123
|
+
return pkgJson.version;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
async function uploadToRepo(
|
|
128
|
+
octokit: InstanceType<typeof OctokitClass>,
|
|
129
|
+
org: string,
|
|
130
|
+
repo: string,
|
|
131
|
+
branch: string = "main"
|
|
132
|
+
): Promise<void> {
|
|
133
|
+
const fileBlobs = await Promise.all(Object.values(FILES).map(file => toBlob(octokit, org, repo, path.join(process.cwd(), file))));
|
|
134
|
+
const currentCommit = await getCurrentCommit(octokit, org, repo, branch);
|
|
135
|
+
const newTree = await createNewTree(
|
|
136
|
+
octokit,
|
|
137
|
+
org,
|
|
138
|
+
repo,
|
|
139
|
+
fileBlobs,
|
|
140
|
+
FILES,
|
|
141
|
+
currentCommit.treeSha
|
|
142
|
+
);
|
|
143
|
+
const currentVersion = await getLatestVersion();
|
|
144
|
+
const commitMessage = `Release ${currentVersion}`;
|
|
145
|
+
const newCommit = await createNewCommit(
|
|
146
|
+
octokit,
|
|
147
|
+
org,
|
|
148
|
+
repo,
|
|
149
|
+
commitMessage,
|
|
150
|
+
newTree.sha,
|
|
151
|
+
currentCommit.commitSha
|
|
152
|
+
);
|
|
153
|
+
await setBranchToCommit(octokit, org, repo, branch, newCommit.sha);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
async function getCurrentCommit(
|
|
158
|
+
octokit: InstanceType<typeof OctokitClass>,
|
|
159
|
+
org: string,
|
|
160
|
+
repo: string,
|
|
161
|
+
branch: string = "main"
|
|
162
|
+
): Promise<{ commitSha: string; treeSha: string }> {
|
|
163
|
+
const { data: refData } = await octokit.git.getRef({
|
|
164
|
+
owner: org,
|
|
165
|
+
repo,
|
|
166
|
+
ref: `heads/${branch}`,
|
|
167
|
+
});
|
|
168
|
+
const commitSha = refData.object.sha
|
|
169
|
+
const { data: commitData } = await octokit.git.getCommit({
|
|
170
|
+
owner: org,
|
|
171
|
+
repo,
|
|
172
|
+
commit_sha: commitSha,
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
commitSha,
|
|
176
|
+
treeSha: commitData.tree.sha,
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
async function toBlob(
|
|
182
|
+
octokit: InstanceType<typeof OctokitClass>,
|
|
183
|
+
org: string,
|
|
184
|
+
repo: string,
|
|
185
|
+
filePath: string
|
|
186
|
+
): Promise<{ sha: string }> {
|
|
187
|
+
const content = await fs.readFile(filePath, { encoding: "utf8" });
|
|
188
|
+
const blobData = await octokit.git.createBlob({
|
|
189
|
+
owner: org,
|
|
190
|
+
repo,
|
|
191
|
+
content,
|
|
192
|
+
encoding: "utf-8",
|
|
193
|
+
})
|
|
194
|
+
return blobData.data;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
async function createNewTree(
|
|
199
|
+
octokit: InstanceType<typeof OctokitClass>,
|
|
200
|
+
owner: string,
|
|
201
|
+
repo: string,
|
|
202
|
+
blobs: { sha: string }[],
|
|
203
|
+
paths: string[],
|
|
204
|
+
parentTreeSha: string
|
|
205
|
+
): Promise<any> {
|
|
206
|
+
const tree = blobs.map(({ sha }, i) => ({
|
|
207
|
+
path: paths[i],
|
|
208
|
+
mode: "100644" as const,
|
|
209
|
+
type: "blob" as const,
|
|
210
|
+
sha,
|
|
211
|
+
}));
|
|
212
|
+
const { data } = await octokit.git.createTree({
|
|
213
|
+
owner,
|
|
214
|
+
repo,
|
|
215
|
+
tree,
|
|
216
|
+
base_tree: parentTreeSha,
|
|
217
|
+
})
|
|
218
|
+
return data;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
async function createNewCommit(
|
|
223
|
+
octokit: InstanceType<typeof OctokitClass>,
|
|
224
|
+
org: string,
|
|
225
|
+
repo: string,
|
|
226
|
+
message: string,
|
|
227
|
+
currentTreeSha: string,
|
|
228
|
+
currentCommitSha: string
|
|
229
|
+
): Promise<any> {
|
|
230
|
+
const commit = await octokit.git.createCommit({
|
|
231
|
+
owner: org,
|
|
232
|
+
repo,
|
|
233
|
+
message,
|
|
234
|
+
tree: currentTreeSha,
|
|
235
|
+
parents: [currentCommitSha],
|
|
236
|
+
});
|
|
237
|
+
return commit.data;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
async function setBranchToCommit(
|
|
242
|
+
octokit: InstanceType<typeof OctokitClass>,
|
|
243
|
+
org: string,
|
|
244
|
+
repo: string,
|
|
245
|
+
branch: string = "main",
|
|
246
|
+
commitSha: string
|
|
247
|
+
): Promise<any> {
|
|
248
|
+
return octokit.git.updateRef({
|
|
249
|
+
owner: org,
|
|
250
|
+
repo,
|
|
251
|
+
ref: `heads/${branch}`,
|
|
252
|
+
sha: commitSha,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
publish();
|