@ui5/webcomponents-tools 0.0.0-037d08c67
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/CHANGELOG.md +2474 -0
- package/LICENSE.txt +201 -0
- package/README.md +21 -0
- package/assets-meta.js +154 -0
- package/bin/create-ui5-element.js +3 -0
- package/bin/dev.js +22 -0
- package/bin/ui5nps.js +301 -0
- package/components-package/eslint.js +195 -0
- package/components-package/nps.js +177 -0
- package/components-package/postcss.components.js +1 -0
- package/components-package/postcss.themes.js +1 -0
- package/components-package/vite.config.js +9 -0
- package/components-package/wdio.js +421 -0
- package/icons-collection/nps.js +80 -0
- package/lib/amd-to-es6/index.js +109 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/cem.js +16 -0
- package/lib/cem/custom-elements-manifest.config.mjs +575 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
- package/lib/cem/schema-internal.json +1422 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +808 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +429 -0
- package/lib/cem/validate.js +81 -0
- package/lib/chokidar/chokidar.js +28 -0
- package/lib/copy-and-watch/index.js +158 -0
- package/lib/copy-list/index.js +36 -0
- package/lib/create-icons/index.js +131 -0
- package/lib/create-illustrations/index.js +210 -0
- package/lib/create-new-component/Component.js +74 -0
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +115 -0
- package/lib/css-processors/css-processor-components.mjs +101 -0
- package/lib/css-processors/css-processor-themes.mjs +121 -0
- package/lib/css-processors/postcss-plugin.mjs +153 -0
- package/lib/css-processors/scope-variables.mjs +51 -0
- package/lib/css-processors/shared.mjs +47 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.mjs +78 -0
- package/lib/dev-server/virtual-index-html-plugin.js +56 -0
- package/lib/eslint/eslint.js +44 -0
- package/lib/generate-js-imports/illustrations.js +87 -0
- package/lib/generate-json-imports/i18n.js +93 -0
- package/lib/generate-json-imports/themes.js +75 -0
- package/lib/hbs2lit/index.js +3 -0
- package/lib/hbs2lit/src/compiler.js +60 -0
- package/lib/hbs2lit/src/extendedAttributeMapping.js +12 -0
- package/lib/hbs2lit/src/includesReplacer.js +31 -0
- package/lib/hbs2lit/src/litVisitor2.js +278 -0
- package/lib/hbs2lit/src/partials2.js +51 -0
- package/lib/hbs2lit/src/partialsVisitor.js +187 -0
- package/lib/hbs2lit/src/svgProcessor.js +76 -0
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +45 -0
- package/lib/hbs2ui5/index.js +119 -0
- package/lib/i18n/defaults.js +90 -0
- package/lib/i18n/toJSON.js +71 -0
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
- package/lib/rimraf/rimraf.js +31 -0
- package/lib/scoping/get-all-tags.js +44 -0
- package/lib/scoping/lint-src.js +32 -0
- package/lib/scoping/missing-dependencies.js +65 -0
- package/lib/scoping/report-tags-usage.js +28 -0
- package/lib/scoping/scope-test-pages.js +41 -0
- package/lib/test-runner/test-runner.js +79 -0
- package/lib/vite-bundler/vite-bundler.mjs +35 -0
- package/package.json +86 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
const dns = require("node:dns");
|
|
2
|
+
const assert = require("chai").assert;
|
|
3
|
+
|
|
4
|
+
exports.config = {
|
|
5
|
+
//
|
|
6
|
+
// ====================
|
|
7
|
+
// Runner Configuration
|
|
8
|
+
// ====================
|
|
9
|
+
//
|
|
10
|
+
// WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
|
|
11
|
+
// on a remote machine).
|
|
12
|
+
runner: 'local',
|
|
13
|
+
|
|
14
|
+
//
|
|
15
|
+
// ==================
|
|
16
|
+
// Specify Test Files
|
|
17
|
+
// ==================
|
|
18
|
+
// Define which test specs should run. The pattern is relative to the directory
|
|
19
|
+
// from which `wdio` was called. Notice that, if you are calling `wdio` from an
|
|
20
|
+
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
|
|
21
|
+
// directory is where your package.json resides, so `wdio` will be called from there.
|
|
22
|
+
//
|
|
23
|
+
specs: [
|
|
24
|
+
'./test/specs/**/*.js'
|
|
25
|
+
],
|
|
26
|
+
// Patterns to exclude.
|
|
27
|
+
exclude: [
|
|
28
|
+
// 'path/to/excluded/files'
|
|
29
|
+
],
|
|
30
|
+
//
|
|
31
|
+
// ============
|
|
32
|
+
// Capabilities
|
|
33
|
+
// ============
|
|
34
|
+
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
|
|
35
|
+
// time. Depending on the number of capabilities, WebdriverIO launches several test
|
|
36
|
+
// sessions. Within your capabilities you can overwrite the spec and exclude options in
|
|
37
|
+
// order to group specific specs to a specific capability.
|
|
38
|
+
//
|
|
39
|
+
// First, you can define how many instances should be started at the same time. Let's
|
|
40
|
+
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
|
|
41
|
+
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
|
|
42
|
+
// files and you set maxInstances to 10, all spec files will get tested at the same time
|
|
43
|
+
// and 30 processes will get spawned. The property handles how many capabilities
|
|
44
|
+
// from the same test should run tests.
|
|
45
|
+
//
|
|
46
|
+
maxInstances: 10,
|
|
47
|
+
//
|
|
48
|
+
// If you have trouble getting all important capabilities together, check out the
|
|
49
|
+
// Sauce Labs platform configurator - a great tool to configure your capabilities:
|
|
50
|
+
// https://docs.saucelabs.com/reference/platforms-configurator
|
|
51
|
+
//
|
|
52
|
+
capabilities: [{
|
|
53
|
+
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
|
|
54
|
+
// grid with only 5 firefox instances available you can make sure that not more than
|
|
55
|
+
// 5 instances get started at a time.
|
|
56
|
+
maxInstances: 5,
|
|
57
|
+
//
|
|
58
|
+
browserName: 'chrome',
|
|
59
|
+
'goog:chromeOptions': {
|
|
60
|
+
// to run chrome headless the following flags are required
|
|
61
|
+
// (see https://developers.google.com/web/updates/2017/04/headless-chrome)
|
|
62
|
+
args: [
|
|
63
|
+
'--headless',
|
|
64
|
+
'--disable-search-engine-choice-screen',
|
|
65
|
+
'--start-maximized',
|
|
66
|
+
'--no-sandbox',
|
|
67
|
+
'--disable-gpu',
|
|
68
|
+
'--disable-infobars',
|
|
69
|
+
'--disable-extensions',
|
|
70
|
+
'--disable-dev-shm-usage',
|
|
71
|
+
],
|
|
72
|
+
// args: ['--disable-gpu'],
|
|
73
|
+
}
|
|
74
|
+
}],
|
|
75
|
+
//
|
|
76
|
+
// port to find chromedriver
|
|
77
|
+
port: 9515, // default
|
|
78
|
+
// ===================
|
|
79
|
+
// Test Configurations
|
|
80
|
+
// ===================
|
|
81
|
+
// Define all options that are relevant for the WebdriverIO instance here
|
|
82
|
+
//
|
|
83
|
+
// Level of logging verbosity: trace | debug | info | warn | error
|
|
84
|
+
logLevel: 'error',
|
|
85
|
+
//
|
|
86
|
+
// Warns when a deprecated command is used
|
|
87
|
+
deprecationWarnings: true,
|
|
88
|
+
//
|
|
89
|
+
// If you only want to run your tests until a specific amount of tests have failed use
|
|
90
|
+
// bail (default is 0 - don't bail, run all tests).
|
|
91
|
+
bail: 0,
|
|
92
|
+
//
|
|
93
|
+
// Set a base URL in order to shorten url command calls. If your `url` parameter starts
|
|
94
|
+
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
|
|
95
|
+
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
|
|
96
|
+
// gets prepended directly.
|
|
97
|
+
baseUrl: 'http://localhost:4567', // This is important since WDIO 7+ does not accept an empty string for baseUrl
|
|
98
|
+
path: '',
|
|
99
|
+
//
|
|
100
|
+
// Default timeout for all waitFor* commands.
|
|
101
|
+
waitforTimeout: 10000,
|
|
102
|
+
//
|
|
103
|
+
// Default timeout in milliseconds for request
|
|
104
|
+
// if Selenium Grid doesn't send response
|
|
105
|
+
connectionRetryTimeout: 90000,
|
|
106
|
+
//
|
|
107
|
+
// Default request retries count
|
|
108
|
+
connectionRetryCount: 3,
|
|
109
|
+
//
|
|
110
|
+
// Test runner services
|
|
111
|
+
// Services take over a specific job you don't want to take care of. They enhance
|
|
112
|
+
// your test setup with almost no effort. Unlike plugins, they don't add new
|
|
113
|
+
// commands. Instead, they hook themselves up into the test process.
|
|
114
|
+
services: ['chromedriver', ['static-server', {
|
|
115
|
+
folders: [
|
|
116
|
+
{ mount: '/', path: './dist' },
|
|
117
|
+
],
|
|
118
|
+
port: '4567',
|
|
119
|
+
}],
|
|
120
|
+
],
|
|
121
|
+
// options
|
|
122
|
+
chromeDriverArgs: ['--port=9515'], // default
|
|
123
|
+
// Framework you want to run your specs with.
|
|
124
|
+
// The following are supported: Mocha, Jasmine, and Cucumber
|
|
125
|
+
// see also: https://webdriver.io/docs/frameworks.html
|
|
126
|
+
//
|
|
127
|
+
// Make sure you have the wdio adapter package for the specific framework installed
|
|
128
|
+
// before running any tests.
|
|
129
|
+
framework: 'mocha',
|
|
130
|
+
//
|
|
131
|
+
// Test reporter for stdout.
|
|
132
|
+
// The only one supported by default is 'dot'
|
|
133
|
+
// see also: https://webdriver.io/docs/dot-reporter.html
|
|
134
|
+
reporters: ['dot', 'spec'],
|
|
135
|
+
|
|
136
|
+
//
|
|
137
|
+
// Options to be passed to Mocha.
|
|
138
|
+
// See the full list at http://mochajs.org/
|
|
139
|
+
mochaOpts: {
|
|
140
|
+
ui: 'bdd',
|
|
141
|
+
timeout: 60000
|
|
142
|
+
},
|
|
143
|
+
//
|
|
144
|
+
// =====
|
|
145
|
+
// Hooks
|
|
146
|
+
// =====
|
|
147
|
+
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
|
|
148
|
+
// it and to build services around it. You can either apply a single function or an array of
|
|
149
|
+
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
|
|
150
|
+
// resolved to continue.
|
|
151
|
+
/**
|
|
152
|
+
* Gets executed once before all workers get launched.
|
|
153
|
+
* @param {Object} config wdio configuration object
|
|
154
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
155
|
+
*/
|
|
156
|
+
// onPrepare: function (config, capabilities) {
|
|
157
|
+
// },
|
|
158
|
+
/**
|
|
159
|
+
* Gets executed just before initialising the webdriver session and test framework. It allows you
|
|
160
|
+
* to manipulate configurations depending on the capability or spec.
|
|
161
|
+
* @param {Object} config wdio configuration object
|
|
162
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
163
|
+
* @param {Array.<String>} specs List of spec file paths that are to be run
|
|
164
|
+
*/
|
|
165
|
+
// beforeSession: function (config, capabilities, specs) {
|
|
166
|
+
// },
|
|
167
|
+
beforeSession: () => {
|
|
168
|
+
dns.setDefaultResultOrder('ipv4first');
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* Gets executed before test execution begins. At this point you can access to all global
|
|
172
|
+
* variables like `browser`. It is the perfect place to define custom commands.
|
|
173
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
174
|
+
* @param {Array.<String>} specs List of spec file paths that are to be run
|
|
175
|
+
*/
|
|
176
|
+
before: async function (capabilities, specs) {
|
|
177
|
+
await browser.addCommand("isFocusedDeep", async function () {
|
|
178
|
+
return browser.executeAsync(function (elem, done) {
|
|
179
|
+
let activeElement = document.activeElement;
|
|
180
|
+
|
|
181
|
+
while (activeElement.shadowRoot) {
|
|
182
|
+
if (activeElement.shadowRoot.activeElement) {
|
|
183
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
184
|
+
} else {
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
done(elem === activeElement);
|
|
189
|
+
}, this);
|
|
190
|
+
}, true);
|
|
191
|
+
|
|
192
|
+
await browser.addCommand("isFocusedDeepElement", async function (element) {
|
|
193
|
+
return browser.executeAsync(function (elem, element, done) {
|
|
194
|
+
let activeElement = document.activeElement;
|
|
195
|
+
|
|
196
|
+
while (activeElement.shadowRoot) {
|
|
197
|
+
if (activeElement.shadowRoot.activeElement) {
|
|
198
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
199
|
+
} else {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
done(element === activeElement);
|
|
204
|
+
}, this, element);
|
|
205
|
+
}, true);
|
|
206
|
+
|
|
207
|
+
await browser.addCommand("setProperty", async function(property, value) {
|
|
208
|
+
return browser.executeAsync((elem, property, value, done) => {
|
|
209
|
+
elem[property] = value;
|
|
210
|
+
done();
|
|
211
|
+
}, this, property, value);
|
|
212
|
+
}, true);
|
|
213
|
+
|
|
214
|
+
await browser.addCommand("setAttribute", async function(attribute, value) {
|
|
215
|
+
return browser.executeAsync((elem, attribute, value, done) => {
|
|
216
|
+
elem.setAttribute(attribute, value);
|
|
217
|
+
done();
|
|
218
|
+
}, this, attribute, value);
|
|
219
|
+
}, true);
|
|
220
|
+
|
|
221
|
+
await browser.addCommand("removeAttribute", async function(attribute) {
|
|
222
|
+
return browser.executeAsync((elem, attribute, done) => {
|
|
223
|
+
elem.removeAttribute(attribute);
|
|
224
|
+
done();
|
|
225
|
+
}, this, attribute);
|
|
226
|
+
}, true);
|
|
227
|
+
|
|
228
|
+
await browser.addCommand("hasClass", async function(className) {
|
|
229
|
+
return browser.executeAsync((elem, className, done) => {
|
|
230
|
+
done(elem.classList.contains(className));
|
|
231
|
+
}, this, className);
|
|
232
|
+
}, true);
|
|
233
|
+
|
|
234
|
+
await browser.addCommand("hasAttribute", async function(attrName) {
|
|
235
|
+
return browser.executeAsync((elem, attrName, done) => {
|
|
236
|
+
done(elem.hasAttribute(attrName));
|
|
237
|
+
}, this, attrName);
|
|
238
|
+
}, true);
|
|
239
|
+
|
|
240
|
+
await browser.addCommand("matches", async function(selector) {
|
|
241
|
+
return browser.executeAsync((elem, selector, done) => {
|
|
242
|
+
done(elem.matches(selector));
|
|
243
|
+
}, this, selector);
|
|
244
|
+
}, true);
|
|
245
|
+
|
|
246
|
+
await browser.addLocatorStrategy('activeElement', (selector) => {
|
|
247
|
+
return document.querySelector(selector).shadowRoot.activeElement;
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
/**
|
|
251
|
+
* Runs before a WebdriverIO command gets executed.
|
|
252
|
+
* @param {String} commandName hook command name
|
|
253
|
+
* @param {Array} args arguments that command would receive
|
|
254
|
+
*/
|
|
255
|
+
beforeCommand: async function (commandName, args) {
|
|
256
|
+
const waitFor = [
|
|
257
|
+
"$",
|
|
258
|
+
"$$",
|
|
259
|
+
"getAttribute",
|
|
260
|
+
"hasAttribute", // custom
|
|
261
|
+
"matches", // custom
|
|
262
|
+
"getCSSProperty",
|
|
263
|
+
"getHTML",
|
|
264
|
+
"getProperty",
|
|
265
|
+
"getSize",
|
|
266
|
+
"getText",
|
|
267
|
+
"getValue",
|
|
268
|
+
"hasClass", // custom
|
|
269
|
+
"isDisplayed",
|
|
270
|
+
"isDisplayedInViewport",
|
|
271
|
+
"isEnabled",
|
|
272
|
+
"isExisting",
|
|
273
|
+
"isFocused",
|
|
274
|
+
"isFocusedDeep", // custom
|
|
275
|
+
"isFocusedDeepElement", // custom
|
|
276
|
+
"shadow$",
|
|
277
|
+
"shadow$$"
|
|
278
|
+
];
|
|
279
|
+
if (waitFor.includes(commandName)) {
|
|
280
|
+
await browser.executeAsync(function (done) {
|
|
281
|
+
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Hook that gets executed before the suite starts
|
|
288
|
+
* @param {Object} suite suite details
|
|
289
|
+
*/
|
|
290
|
+
// beforeSuite: function (suite) {
|
|
291
|
+
// },
|
|
292
|
+
/**
|
|
293
|
+
* Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
|
294
|
+
* @param {Object} test test details
|
|
295
|
+
*/
|
|
296
|
+
// beforeTest: function (test) {
|
|
297
|
+
// },
|
|
298
|
+
/**
|
|
299
|
+
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
|
|
300
|
+
* beforeEach in Mocha)
|
|
301
|
+
*/
|
|
302
|
+
// beforeHook: function () {
|
|
303
|
+
// },
|
|
304
|
+
/**
|
|
305
|
+
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
|
|
306
|
+
* afterEach in Mocha)
|
|
307
|
+
*/
|
|
308
|
+
// afterHook: function () {
|
|
309
|
+
// },
|
|
310
|
+
/**
|
|
311
|
+
* Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
|
312
|
+
* @param {Object} test test details
|
|
313
|
+
*/
|
|
314
|
+
afterTest: async function (test) {
|
|
315
|
+
// fetch the browser logs and fail the test if there are `console.error` messages with the `[UI5-FWK]` marker
|
|
316
|
+
const logs = await browser.getLogs('browser');
|
|
317
|
+
const severeLogs = logs
|
|
318
|
+
.filter(l => l.level === "SEVERE" && l.message.includes("[UI5-FWK]"))
|
|
319
|
+
.map(l => l.message);
|
|
320
|
+
|
|
321
|
+
if (severeLogs.length) {
|
|
322
|
+
test.callback(new Error(`[${test.title}]\n\n ${severeLogs.join("\n ")}`));
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
/**
|
|
326
|
+
* Hook that gets executed after the suite has ended
|
|
327
|
+
* @param {Object} suite suite details
|
|
328
|
+
*/
|
|
329
|
+
// afterSuite: function (suite) {
|
|
330
|
+
// },
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Runs after a WebdriverIO command gets executed
|
|
334
|
+
* @param {String} commandName hook command name
|
|
335
|
+
* @param {Array} args arguments that command would receive
|
|
336
|
+
* @param {Number} result 0 - command success, 1 - command error
|
|
337
|
+
* @param {Object} error error object if any
|
|
338
|
+
*/
|
|
339
|
+
afterCommand: async function (commandName, args, result, error) {
|
|
340
|
+
|
|
341
|
+
// url -> set configuration first
|
|
342
|
+
if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
|
|
343
|
+
await browser.executeAsync(function(done) {
|
|
344
|
+
window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
|
|
345
|
+
done();
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const waitFor = [
|
|
350
|
+
"addValue",
|
|
351
|
+
"clearValue",
|
|
352
|
+
"click",
|
|
353
|
+
"doubleClick",
|
|
354
|
+
"dragAndDrop",
|
|
355
|
+
"pause",
|
|
356
|
+
"removeAttribute", // custom
|
|
357
|
+
"scrollIntoView",
|
|
358
|
+
"setAttribute", // custom
|
|
359
|
+
"setProperty", // custom
|
|
360
|
+
"setValue",
|
|
361
|
+
"setWindowSize",
|
|
362
|
+
"touchAction",
|
|
363
|
+
"url",
|
|
364
|
+
];
|
|
365
|
+
|
|
366
|
+
const waitForWithDelay = [
|
|
367
|
+
"keys",
|
|
368
|
+
];
|
|
369
|
+
|
|
370
|
+
if (waitFor.includes(commandName)) {
|
|
371
|
+
await browser.executeAsync(function (done) {
|
|
372
|
+
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
|
373
|
+
});
|
|
374
|
+
} else if (waitForWithDelay.includes(commandName)) {
|
|
375
|
+
await browser.executeAsync(function (done) {
|
|
376
|
+
setTimeout(() => {
|
|
377
|
+
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
|
378
|
+
}, 10);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
/**
|
|
383
|
+
* Gets executed after all tests are done. You still have access to all global variables from
|
|
384
|
+
* the test.
|
|
385
|
+
* @param {Number} result 0 - test pass, 1 - test fail
|
|
386
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
387
|
+
* @param {Array.<String>} specs List of spec file paths that ran
|
|
388
|
+
*/
|
|
389
|
+
// after: function (result, capabilities, specs) {
|
|
390
|
+
// },
|
|
391
|
+
/**
|
|
392
|
+
* Gets executed right after terminating the webdriver session.
|
|
393
|
+
* @param {Object} config wdio configuration object
|
|
394
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
395
|
+
* @param {Array.<String>} specs List of spec file paths that ran
|
|
396
|
+
*/
|
|
397
|
+
// afterSession: function (config, capabilities, specs) {
|
|
398
|
+
// },
|
|
399
|
+
/**
|
|
400
|
+
* Gets executed after all workers got shut down and the process is about to exit.
|
|
401
|
+
* @param {Object} exitCode 0 - success, 1 - fail
|
|
402
|
+
* @param {Object} config wdio configuration object
|
|
403
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
404
|
+
* @param {<Object>} results object containing test results
|
|
405
|
+
*/
|
|
406
|
+
onComplete: function (exitCode, config, capabilities, results) {
|
|
407
|
+
// The results object looks like: { finished: 0, passed: 0, retries: 0, failed: 0 }.
|
|
408
|
+
// If all values are 0, consider that no tests were found or executed.
|
|
409
|
+
if (exitCode === 1 && Object.values(results).every(result => result === 0)) {
|
|
410
|
+
console.log("✅ No specs were found or executed – treating as success.");
|
|
411
|
+
process.exit(0);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Gets executed when a refresh happens.
|
|
416
|
+
* @param {String} oldSessionId session ID of the old session
|
|
417
|
+
* @param {String} newSessionId session ID of the new session
|
|
418
|
+
*/
|
|
419
|
+
//onReload: function(oldSessionId, newSessionId) {
|
|
420
|
+
//}
|
|
421
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
const LIB = path.join(__dirname, `../lib/`);
|
|
4
|
+
|
|
5
|
+
const createIconImportsCommand = (options) => {
|
|
6
|
+
if (!options.versions) {
|
|
7
|
+
return `ui5nps-script "${LIB}/create-icons/index.js" "${options.collectionName}"`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const command = { default: "ui5nps" };
|
|
11
|
+
options.versions.forEach((v) => {
|
|
12
|
+
command.default += ` build.icons.create${v}`;
|
|
13
|
+
command[`create${v}`] = `ui5nps-script "${LIB}/create-icons/index.js" "${options.collectionName}" "${v}"`;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return command;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const hashesCheck = cmd => `(node "${LIB}/icons-hash/icons-hash.mjs" check) || (${cmd} && node "${LIB}/icons-hash/icons-hash.mjs" save)`;
|
|
20
|
+
|
|
21
|
+
const copyIconAssetsCommand = (options) => {
|
|
22
|
+
if (!options.versions) {
|
|
23
|
+
return {
|
|
24
|
+
default: "ui5nps copy.json-imports copy.icon-collection",
|
|
25
|
+
"json-imports": `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
|
26
|
+
"icon-collection": `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/*.json" src/generated/assets/`,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const command = {
|
|
31
|
+
default: "ui5nps copy.json-imports ",
|
|
32
|
+
"json-imports": `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
options.versions.forEach((v) => {
|
|
36
|
+
command.default += ` copy.icon-collection${v}`;
|
|
37
|
+
command[`icon-collection${v}`] = `ui5nps-script "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" src/generated/assets/${v}/`;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return command;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const getScripts = (options) => {
|
|
44
|
+
const createJSImportsCmd = createIconImportsCommand(options);
|
|
45
|
+
const copyAssetsCmd = copyIconAssetsCommand(options);
|
|
46
|
+
const tsCommand = !options.legacy ? "tsc --build" : "";
|
|
47
|
+
const tsOption = !options.legacy;
|
|
48
|
+
|
|
49
|
+
const scripts = {
|
|
50
|
+
__ui5envs: {
|
|
51
|
+
UI5_TS: `${tsOption}`,
|
|
52
|
+
},
|
|
53
|
+
clean: {
|
|
54
|
+
default: "ui5nps clean.generated clean.dist",
|
|
55
|
+
"generated": `ui5nps-script "${LIB}/rimraf/rimraf.js src/generated`,
|
|
56
|
+
"dist": `ui5nps-script "${LIB}/rimraf/rimraf.js dist`,
|
|
57
|
+
},
|
|
58
|
+
copy: copyAssetsCmd,
|
|
59
|
+
generate: hashesCheck(`ui5nps clean copy build.i18n build.icons build.jsonImports copyjson`),
|
|
60
|
+
copyjson: `ui5nps-script "${LIB}copy-and-watch/index.js" "src/generated/**/*.json" dist/generated`,
|
|
61
|
+
build: {
|
|
62
|
+
default: hashesCheck(`ui5nps clean copy build.i18n typescript build.icons build.jsonImports`),
|
|
63
|
+
i18n: {
|
|
64
|
+
default: "ui5nps build.i18n.defaultsjs build.i18n.json",
|
|
65
|
+
defaultsjs: `ui5nps-script "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
|
66
|
+
json: `ui5nps-script "${LIB}/i18n/toJSON.js" src/i18n src/generated/assets/i18n`,
|
|
67
|
+
},
|
|
68
|
+
jsonImports: {
|
|
69
|
+
default: "ui5nps build.jsonImports.i18n",
|
|
70
|
+
i18n: `ui5nps-script "${LIB}/generate-json-imports/i18n.js" src/generated/assets/i18n src/generated/json-imports`,
|
|
71
|
+
},
|
|
72
|
+
icons: createJSImportsCmd,
|
|
73
|
+
},
|
|
74
|
+
typescript: tsCommand,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return scripts;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
module.exports = getScripts;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const babelCore = require("@babel/core");
|
|
4
|
+
const babelParser = require("@babel/parser");
|
|
5
|
+
const babelGenerator = require("@babel/generator").default;
|
|
6
|
+
const replaceAsync = require('replace-in-file');
|
|
7
|
+
|
|
8
|
+
const convertSAPUIDefineToDefine = async (filePath) => {
|
|
9
|
+
return replaceAsync({
|
|
10
|
+
files: filePath,
|
|
11
|
+
processor: (input) => {
|
|
12
|
+
return input.replace("sap.ui.define", "define").replace(", /* bExport= */ false", "").replace(", /* bExport= */ true", "");
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const convertAmdToEs6 = async (code) => {
|
|
18
|
+
return (await babelCore.transformAsync(code, {
|
|
19
|
+
plugins: [['babel-plugin-amd-to-esm', {}]]
|
|
20
|
+
})).code;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const convertAbsImportsToRelative = (filePath, code, basePath) => {
|
|
24
|
+
let changed = false;
|
|
25
|
+
// console.log("File processing started: ", srcPath);
|
|
26
|
+
|
|
27
|
+
if (code.includes("import(")) {
|
|
28
|
+
// esprima can't parse this, but it's from the project files
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const tree = babelParser.parse(code, { sourceType: "module" });
|
|
33
|
+
const importer = filePath.replace(basePath, "");
|
|
34
|
+
const importerDir = path.dirname(importer);
|
|
35
|
+
// console.log("Importer -> ", importer);
|
|
36
|
+
|
|
37
|
+
tree?.program?.body?.forEach(node => {
|
|
38
|
+
if (node.type === "ImportDeclaration") {
|
|
39
|
+
let importee = node.source.value;
|
|
40
|
+
// console.log(importee);
|
|
41
|
+
if (importee.startsWith(".")) {
|
|
42
|
+
// add .js extension if missing
|
|
43
|
+
if (!importee.endsWith(".js")) {
|
|
44
|
+
node.source.value += ".js"
|
|
45
|
+
changed = true;
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let importeeDir = path.dirname(importee);
|
|
50
|
+
let importeeFile = path.basename(importee);
|
|
51
|
+
let relativePath = path.relative(importerDir, importeeDir);
|
|
52
|
+
if (relativePath.length === 0) {
|
|
53
|
+
relativePath = "."
|
|
54
|
+
}
|
|
55
|
+
if (!relativePath.startsWith(".")) {
|
|
56
|
+
relativePath = "./" + relativePath;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
relativePath = relativePath.replace(/\\/g, "/"); // the browser expects unix paths
|
|
60
|
+
let relativeImport = `${relativePath}/${importeeFile}.js`;
|
|
61
|
+
// console.log(importee + " --> " + relativeImport);
|
|
62
|
+
node.source.value = relativeImport;
|
|
63
|
+
changed = true;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return changed ? babelGenerator(tree).code : code;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const replaceGlobalCoreUsage = (filePath, code) => {
|
|
71
|
+
if (!filePath.includes("Configuration")) {
|
|
72
|
+
const replaced = code.replace(/sap\.ui\.getCore\(\)/g, `Core`);
|
|
73
|
+
return code !== replaced ? `import Core from 'sap/ui/core/Core';${replaced}` : code;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return code;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const transformAmdToES6Module = async (filePath, basePath) => {
|
|
80
|
+
await convertSAPUIDefineToDefine(filePath);
|
|
81
|
+
|
|
82
|
+
let code = (await fs.readFile(filePath)).toString();
|
|
83
|
+
|
|
84
|
+
code = await convertAmdToEs6(code);
|
|
85
|
+
|
|
86
|
+
code = replaceGlobalCoreUsage(filePath, code);
|
|
87
|
+
|
|
88
|
+
code = convertAbsImportsToRelative(filePath, code, basePath);
|
|
89
|
+
|
|
90
|
+
return fs.writeFile(filePath, code);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const transformAmdToES6Modules = async (argv) => {
|
|
94
|
+
const basePath = argv[2];
|
|
95
|
+
const { globby } = await import("globby");
|
|
96
|
+
const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
|
|
97
|
+
return Promise.all(fileNames.map(fileName => transformAmdToES6Module(fileName, basePath)).filter(x => !!x))
|
|
98
|
+
.then(() => {
|
|
99
|
+
if (process.env.UI5_VERBOSE === "true") {
|
|
100
|
+
console.log("Success: all amd modules are transformed to es6!");
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
if (require.main === module) {
|
|
106
|
+
transformAmdToES6Modules(process.argv)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
exports._ui5mainFn = transformAmdToES6Modules;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const fs = require("fs").promises;
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const basePath = process.argv[2];
|
|
4
|
+
const babelCore = require("@babel/core");
|
|
5
|
+
const babelParser = require("@babel/parser");
|
|
6
|
+
const babelGenerator = require("@babel/generator").default;
|
|
7
|
+
const walk = require("estree-walk");
|
|
8
|
+
|
|
9
|
+
const checkHasRequire = (filePath, code) => {
|
|
10
|
+
code = code.replace(/sap\.ui\.require/g, "unhandledRequire");
|
|
11
|
+
|
|
12
|
+
const tree = babelParser.parse(code, { sourceType: "module" });
|
|
13
|
+
walk(tree, {
|
|
14
|
+
CallExpression: function (node) {
|
|
15
|
+
if (node.type === "CallExpression" && node?.callee?.name === "unhandledRequire") {
|
|
16
|
+
throw new Error(`sap.ui.require found in ${filePath}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const checkFile = async (filePath) => {
|
|
23
|
+
let code = (await fs.readFile(filePath)).toString();
|
|
24
|
+
checkHasRequire(filePath, code);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const checkAll = async () => {
|
|
28
|
+
const { globby } = await import("globby");
|
|
29
|
+
const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
|
|
30
|
+
return Promise.all(fileNames.map(checkFile).filter(x => !!x));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
checkAll();
|
package/lib/cem/cem.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const cemCLI = require("./patch/@custom-elements-manifest/analyzer/cli.js")
|
|
2
|
+
|
|
3
|
+
const main = async argv => {
|
|
4
|
+
const patchedArgv = argv.slice(2);
|
|
5
|
+
// Add --quiet flag unless verbose mode is enabled
|
|
6
|
+
if (process.env.UI5_VERBOSE !== "true" && !patchedArgv.includes("--quiet")) {
|
|
7
|
+
patchedArgv.push("--quiet");
|
|
8
|
+
}
|
|
9
|
+
await cemCLI.cli({ argv: patchedArgv, cwd: process.cwd(), noWrite: false });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (require.main === module) {
|
|
13
|
+
main(process.argv)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports._ui5mainFn = main;
|