@ui5/webcomponents-tools 0.0.0-aadaf0b2a → 0.0.0-acc6fea96
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 +1784 -1
- package/README.md +6 -9
- package/assets-meta.js +158 -0
- package/bin/dev.js +12 -1
- package/components-package/cypress/support/commands.js +39 -0
- package/components-package/cypress/support/component-index.html +17 -0
- package/components-package/cypress/support/component.d.ts +23 -0
- package/components-package/cypress/support/component.js +34 -0
- package/components-package/cypress.config.js +19 -0
- package/components-package/eslint.js +99 -2
- package/components-package/nps.js +121 -45
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -23
- package/components-package/vite.config.js +13 -0
- package/components-package/wdio.js +153 -72
- package/icons-collection/nps.js +55 -12
- package/lib/amd-to-es6/index.js +102 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/custom-elements-manifest.config.mjs +527 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/schema-internal.json +1413 -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 +413 -0
- package/lib/cem/validate.js +70 -0
- package/lib/copy-and-watch/index.js +145 -0
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +126 -54
- package/lib/create-illustrations/index.js +182 -0
- package/lib/create-new-component/index.js +63 -93
- package/lib/create-new-component/tsFileContentTemplate.js +71 -0
- package/lib/css-processors/css-processor-components.mjs +77 -0
- package/lib/css-processors/css-processor-themes.mjs +74 -0
- package/lib/css-processors/scope-variables.mjs +49 -0
- package/lib/css-processors/shared.mjs +56 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.mjs +66 -0
- package/lib/dev-server/virtual-index-html-plugin.js +52 -0
- package/lib/generate-js-imports/illustrations.js +86 -0
- package/lib/generate-json-imports/i18n.js +82 -47
- package/lib/generate-json-imports/themes.js +55 -19
- package/lib/hbs2lit/index.js +2 -4
- package/lib/hbs2lit/src/compiler.js +30 -9
- package/lib/hbs2lit/src/includesReplacer.js +23 -17
- package/lib/hbs2lit/src/litVisitor2.js +125 -26
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +40 -7
- package/lib/hbs2ui5/index.js +69 -30
- package/lib/i18n/defaults.js +78 -50
- package/lib/i18n/toJSON.js +25 -13
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -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 +71 -0
- package/package.json +62 -55
- package/tsconfig.json +18 -0
- package/types/index.d.ts +1 -0
- package/bin/init-ui5-package.js +0 -3
- package/components-package/rollup.js +0 -134
- package/components-package/serve.json +0 -3
- package/lib/documentation/index.js +0 -143
- package/lib/documentation/templates/api-component-since.js +0 -3
- package/lib/documentation/templates/api-css-variables-section.js +0 -24
- package/lib/documentation/templates/api-events-section.js +0 -35
- package/lib/documentation/templates/api-methods-section.js +0 -26
- package/lib/documentation/templates/api-properties-section.js +0 -40
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -38
- package/lib/init-package/index.js +0 -119
- package/lib/init-package/resources/.eslintignore +0 -3
- package/lib/init-package/resources/bundle.es5.js +0 -25
- package/lib/init-package/resources/bundle.esm.js +0 -34
- package/lib/init-package/resources/config/.eslintrc.js +0 -1
- package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
- package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
- package/lib/init-package/resources/config/rollup.config.js +0 -1
- package/lib/init-package/resources/config/wdio.conf.js +0 -1
- package/lib/init-package/resources/package-scripts.js +0 -11
- package/lib/init-package/resources/src/Assets.js +0 -6
- package/lib/init-package/resources/src/Demo.hbs +0 -1
- package/lib/init-package/resources/src/Demo.js +0 -56
- package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
- package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
- package/lib/init-package/resources/src/themes/Demo.css +0 -11
- package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
- package/lib/init-package/resources/test/pages/index.html +0 -51
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2407
- package/lib/jsdoc/template/publish.js +0 -4092
- package/lib/postcss-css-to-esm/index.js +0 -33
- package/lib/postcss-css-to-json/index.js +0 -20
@@ -1,73 +1,149 @@
|
|
1
1
|
const path = require("path");
|
2
|
-
|
2
|
+
const fs = require("fs");
|
3
3
|
const LIB = path.join(__dirname, `../lib/`);
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let websiteBaseUrl = "/";
|
5
|
+
|
6
|
+
if (process.env.DEPLOY) {
|
7
|
+
websiteBaseUrl = "/ui5-webcomponents/";
|
8
|
+
} else if (process.env.DEPLOY_NIGHTLY) {
|
9
|
+
websiteBaseUrl = "/ui5-webcomponents/nightly/";
|
10
|
+
}
|
7
11
|
|
8
12
|
const getScripts = (options) => {
|
9
13
|
|
10
|
-
|
14
|
+
// The script creates all JS modules (dist/illustrations/{illustrationName}.js) out of the existing SVGs
|
15
|
+
const illustrationsData = options.illustrationsData || [];
|
16
|
+
const illustrations = illustrationsData.map(illustration => `node "${LIB}/create-illustrations/index.js" ${illustration.path} ${illustration.defaultText} ${illustration.illustrationsPrefix} ${illustration.set} ${illustration.destinationPath} ${illustration.collection}`);
|
17
|
+
const createIllustrationsJSImportsScript = illustrations.join(" && ");
|
18
|
+
|
19
|
+
// The script creates the "src/generated/js-imports/Illustration.js" file that registers loaders (dynamic JS imports) for each illustration
|
20
|
+
const createIllustrationsLoadersScript = illustrationsData.map(illustrations => `node ${LIB}/generate-js-imports/illustrations.js ${illustrations.destinationPath} ${illustrations.dynamicImports.outputFile} ${illustrations.set} ${illustrations.collection} ${illustrations.dynamicImports.location} ${illustrations.dynamicImports.filterOut.join(" ")}`).join(" && ");
|
21
|
+
|
22
|
+
const tsOption = !options.legacy;
|
23
|
+
const tsCommandOld = tsOption ? "tsc" : "";
|
24
|
+
let tsWatchCommandStandalone = tsOption ? "tsc --watch" : "";
|
25
|
+
// this command is only used for standalone projects. monorepo projects get their watch from vite, so opt-out here
|
26
|
+
if (options.noWatchTS) {
|
27
|
+
tsWatchCommandStandalone = "";
|
28
|
+
}
|
29
|
+
const tsCrossEnv = tsOption ? "cross-env UI5_TS=true" : "";
|
30
|
+
|
31
|
+
if (tsOption) {
|
32
|
+
try {
|
33
|
+
require("typescript");
|
34
|
+
} catch(e) {
|
35
|
+
console.error(`TypeScript is not found. Try to install it by running \`npm install --save-dev typescript\` if you are using npm or by running \`yarn add --dev typescript\` if you are using yarn.`);
|
36
|
+
process.exit(e.code);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
let viteConfig;
|
41
|
+
if (fs.existsSync("config/vite.config.js")) {
|
42
|
+
// old project setup where config file is in separate folder
|
43
|
+
viteConfig = "-c config/vite.config.js";
|
44
|
+
} else if (fs.existsSync("vite.config.js")) {
|
45
|
+
// preferred way of custom configuration in root project folder
|
46
|
+
viteConfig = "";
|
47
|
+
} else {
|
48
|
+
// no custom configuration - use default from tools project
|
49
|
+
viteConfig = `-c "${require.resolve("@ui5/webcomponents-tools/components-package/vite.config.js")}"`;
|
50
|
+
}
|
51
|
+
|
52
|
+
let eslintConfig;
|
53
|
+
if (fs.existsSync(".eslintrc.js") || fs.existsSync(".eslintrc.cjs")) {
|
54
|
+
// preferred way of custom configuration in root project folder
|
55
|
+
eslintConfig = "";
|
56
|
+
} else {
|
57
|
+
// no custom configuration - use default from tools project
|
58
|
+
eslintConfig = `--config "${require.resolve("@ui5/webcomponents-tools/components-package/eslint.js")}"`;
|
59
|
+
}
|
11
60
|
|
12
61
|
const scripts = {
|
13
|
-
clean:
|
14
|
-
lint:
|
15
|
-
|
62
|
+
clean: 'rimraf src/generated && rimraf dist && rimraf .port && nps "scope.testPages.clean"',
|
63
|
+
lint: `eslint . ${eslintConfig}`,
|
64
|
+
lintfix: `eslint . ${eslintConfig} --fix`,
|
65
|
+
generate: {
|
66
|
+
default: `${tsCrossEnv} nps prepare.all`,
|
67
|
+
all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps copyProps" "nps build.illustrations"',
|
68
|
+
styleRelated: "nps build.styles build.jsonImports build.jsImports",
|
69
|
+
},
|
70
|
+
prepare: {
|
71
|
+
default: `${tsCrossEnv} nps clean prepare.all ${options.legacy ? "copy" : ""} copyProps prepare.typescript generateAPI`,
|
72
|
+
all: 'concurrently "nps build.templates" "nps build.i18n" "nps prepare.styleRelated" "nps build.illustrations"',
|
73
|
+
styleRelated: "nps build.styles build.jsonImports build.jsImports",
|
74
|
+
typescript: tsCommandOld,
|
75
|
+
},
|
16
76
|
build: {
|
17
|
-
default: "nps lint
|
18
|
-
templates: `mkdirp
|
77
|
+
default: "nps prepare lint build.bundle", // build.bundle2
|
78
|
+
templates: `mkdirp src/generated/templates && ${tsCrossEnv} node "${LIB}/hbs2ui5/index.js" -d src/ -o src/generated/templates`,
|
19
79
|
styles: {
|
20
|
-
default: "nps build.styles.themes build.styles.components"
|
21
|
-
themes: "
|
22
|
-
components: "
|
80
|
+
default: `concurrently "nps build.styles.themes" "nps build.styles.components"`,
|
81
|
+
themes: `node "${LIB}/css-processors/css-processor-themes.mjs"`,
|
82
|
+
components: `node "${LIB}/css-processors/css-processor-components.mjs"`,
|
23
83
|
},
|
24
84
|
i18n: {
|
25
85
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
26
|
-
defaultsjs: `
|
27
|
-
json: `
|
86
|
+
defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
87
|
+
json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
|
28
88
|
},
|
29
89
|
jsonImports: {
|
30
|
-
default: "mkdirp
|
31
|
-
themes: `node "${LIB}/generate-json-imports/themes.js"`,
|
32
|
-
i18n: `node "${LIB}/generate-json-imports/i18n.js"`,
|
90
|
+
default: "mkdirp src/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
|
91
|
+
themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes src/generated/json-imports`,
|
92
|
+
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n src/generated/json-imports`,
|
33
93
|
},
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
94
|
+
jsImports: {
|
95
|
+
default: "mkdirp src/generated/js-imports && nps build.jsImports.illustrationsLoaders",
|
96
|
+
illustrationsLoaders: createIllustrationsLoadersScript,
|
97
|
+
},
|
98
|
+
bundle: `vite build ${viteConfig} --mode testing --base ${websiteBaseUrl}`,
|
99
|
+
bundle2: ``,
|
100
|
+
illustrations: createIllustrationsJSImportsScript,
|
40
101
|
},
|
102
|
+
copyProps: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
|
41
103
|
copy: {
|
42
|
-
default: "nps copy.src copy.
|
43
|
-
src: "copy-and-watch
|
44
|
-
|
45
|
-
"webcomponents-polyfill": `copy-and-watch "${polyfillPath}" dist/webcomponentsjs/`,
|
104
|
+
default: "nps copy.src copy.props",
|
105
|
+
src: `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.{js,json}" dist/`,
|
106
|
+
props: `node "${LIB}/copy-and-watch/index.js" --silent "src/i18n/*.properties" dist/`,
|
46
107
|
},
|
47
108
|
watch: {
|
48
|
-
default:
|
49
|
-
|
50
|
-
|
51
|
-
|
109
|
+
default: `${tsCrossEnv} concurrently "nps watch.templates" "nps watch.typescript" ${options.legacy ? '"nps watch.src"' : ""} "nps watch.styles" "nps watch.i18n" "nps watch.props"`,
|
110
|
+
devServer: 'concurrently "nps watch.default" "nps watch.bundle"',
|
111
|
+
src: 'nps "copy.src --watch --safe --skip-initial-copy"',
|
112
|
+
typescript: tsWatchCommandStandalone,
|
113
|
+
props: 'nps "copyProps --watch --safe --skip-initial-copy"',
|
114
|
+
bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
|
52
115
|
styles: {
|
53
116
|
default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
|
54
117
|
themes: 'nps "build.styles.themes -w"',
|
55
|
-
components:
|
118
|
+
components: `nps "build.styles.components -w"`,
|
56
119
|
},
|
57
|
-
templates:
|
58
|
-
|
120
|
+
templates: 'chokidar "src/**/*.hbs" -i "src/generated" -c "nps build.templates"',
|
121
|
+
i18n: 'chokidar "src/i18n/messagebundle.properties" -c "nps build.i18n.defaultsjs"'
|
59
122
|
},
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
123
|
+
start: "nps prepare watch.devServer",
|
124
|
+
test: `node "${LIB}/test-runner/test-runner.js"`,
|
125
|
+
"test-cy-ci": `yarn cypress run --component --browser chrome`,
|
126
|
+
"test-cy-open": `yarn cypress open --component --browser chrome`,
|
127
|
+
"test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
|
128
|
+
"test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
|
129
|
+
startWithScope: "nps scope.prepare scope.watchWithBundle",
|
130
|
+
scope: {
|
131
|
+
prepare: "nps scope.lint scope.testPages",
|
132
|
+
lint: `node "${LIB}/scoping/lint-src.js"`,
|
133
|
+
testPages: {
|
134
|
+
default: "nps scope.testPages.clean scope.testPages.copy scope.testPages.replace",
|
135
|
+
clean: "rimraf test/pages/scoped",
|
136
|
+
copy: `node "${LIB}/copy-and-watch/index.js" --silent "test/pages/**/*" test/pages/scoped`,
|
137
|
+
replace: `node "${LIB}/scoping/scope-test-pages.js" test/pages/scoped demo`,
|
138
|
+
},
|
139
|
+
watchWithBundle: 'concurrently "nps scope.watch" "nps scope.bundle" ',
|
140
|
+
watch: 'concurrently "nps watch.templates" "nps watch.props" "nps watch.styles"',
|
141
|
+
bundle: `node ${LIB}/dev-server/dev-server.mjs ${viteConfig}`,
|
66
142
|
},
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
143
|
+
generateAPI: {
|
144
|
+
default: tsOption ? "nps generateAPI.generateCEM generateAPI.validateCEM" : "",
|
145
|
+
generateCEM: `cem analyze --config "${LIB}/cem/custom-elements-manifest.config.mjs" ${ options.dev ? "--dev" : "" }`,
|
146
|
+
validateCEM: `node "${LIB}/cem/validate.js" ${ options.dev ? "--dev" : "" }`,
|
71
147
|
},
|
72
148
|
};
|
73
149
|
|
@@ -1,21 +1 @@
|
|
1
|
-
|
2
|
-
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
3
|
-
const cssnano = require('cssnano');
|
4
|
-
const fs = require("fs");
|
5
|
-
|
6
|
-
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
7
|
-
|
8
|
-
module.exports = {
|
9
|
-
plugins: [
|
10
|
-
postcssImport(),
|
11
|
-
cssnano({
|
12
|
-
preset: [
|
13
|
-
'default', {
|
14
|
-
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
15
|
-
mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
|
16
|
-
},
|
17
|
-
]
|
18
|
-
}),
|
19
|
-
postcssCSStoESM({toReplace: 'src', includeDefaultTheme: true, packageName}),
|
20
|
-
]
|
21
|
-
};
|
1
|
+
module.exports = {}
|
@@ -1,23 +1 @@
|
|
1
|
-
|
2
|
-
const combineSelectors = require('postcss-combine-duplicated-selectors');
|
3
|
-
const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
|
4
|
-
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
5
|
-
const cssnano = require('cssnano');
|
6
|
-
|
7
|
-
module.exports = {
|
8
|
-
plugins: [
|
9
|
-
postcssImport(),
|
10
|
-
combineSelectors({
|
11
|
-
removeDuplicatedProperties: true
|
12
|
-
}),
|
13
|
-
cssnano({
|
14
|
-
preset: [
|
15
|
-
'default', {
|
16
|
-
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
17
|
-
},
|
18
|
-
]
|
19
|
-
},),
|
20
|
-
postcssCSStoJSON({toReplace: 'src'}),
|
21
|
-
postcssCSStoESM({toReplace: 'src'}),
|
22
|
-
]
|
23
|
-
};
|
1
|
+
module.exports = {};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// vite.config.js
|
2
|
+
import { defineConfig } from 'vite';
|
3
|
+
import virtualIndex from '../lib/dev-server/virtual-index-html-plugin.js';
|
4
|
+
|
5
|
+
export default defineConfig(async () => {
|
6
|
+
const data = await virtualIndex();
|
7
|
+
return {
|
8
|
+
build: {
|
9
|
+
emptyOutDir: false,
|
10
|
+
},
|
11
|
+
plugins: [data],
|
12
|
+
}
|
13
|
+
})
|
@@ -1,3 +1,6 @@
|
|
1
|
+
const dns = require("node:dns");
|
2
|
+
const assert = require("chai").assert;
|
3
|
+
|
1
4
|
exports.config = {
|
2
5
|
//
|
3
6
|
// ====================
|
@@ -50,14 +53,23 @@ exports.config = {
|
|
50
53
|
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
|
51
54
|
// grid with only 5 firefox instances available you can make sure that not more than
|
52
55
|
// 5 instances get started at a time.
|
53
|
-
maxInstances:
|
56
|
+
maxInstances: 5,
|
54
57
|
//
|
55
58
|
browserName: 'chrome',
|
56
59
|
'goog:chromeOptions': {
|
57
60
|
// to run chrome headless the following flags are required
|
58
61
|
// (see https://developers.google.com/web/updates/2017/04/headless-chrome)
|
59
|
-
args: [
|
60
|
-
|
62
|
+
args: [
|
63
|
+
'--headless=old',
|
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'],
|
61
73
|
}
|
62
74
|
}],
|
63
75
|
//
|
@@ -82,7 +94,7 @@ exports.config = {
|
|
82
94
|
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
|
83
95
|
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
|
84
96
|
// gets prepended directly.
|
85
|
-
baseUrl: '',
|
97
|
+
baseUrl: 'http://localhost:4567', // This is important since WDIO 7+ does not accept an empty string for baseUrl
|
86
98
|
path: '',
|
87
99
|
//
|
88
100
|
// Default timeout for all waitFor* commands.
|
@@ -99,7 +111,13 @@ exports.config = {
|
|
99
111
|
// Services take over a specific job you don't want to take care of. They enhance
|
100
112
|
// your test setup with almost no effort. Unlike plugins, they don't add new
|
101
113
|
// commands. Instead, they hook themselves up into the test process.
|
102
|
-
services: ['chromedriver'
|
114
|
+
services: ['chromedriver', ['static-server', {
|
115
|
+
folders: [
|
116
|
+
{ mount: '/', path: './dist' },
|
117
|
+
],
|
118
|
+
port: '4567',
|
119
|
+
}],
|
120
|
+
],
|
103
121
|
// options
|
104
122
|
chromeDriverArgs: ['--port=9515'], // default
|
105
123
|
// Framework you want to run your specs with.
|
@@ -146,52 +164,33 @@ exports.config = {
|
|
146
164
|
*/
|
147
165
|
// beforeSession: function (config, capabilities, specs) {
|
148
166
|
// },
|
167
|
+
beforeSession: () => {
|
168
|
+
dns.setDefaultResultOrder('ipv4first');
|
169
|
+
},
|
149
170
|
/**
|
150
171
|
* Gets executed before test execution begins. At this point you can access to all global
|
151
172
|
* variables like `browser`. It is the perfect place to define custom commands.
|
152
173
|
* @param {Array.<Object>} capabilities list of capabilities details
|
153
174
|
* @param {Array.<String>} specs List of spec file paths that are to be run
|
154
175
|
*/
|
155
|
-
before: function (capabilities, specs) {
|
156
|
-
browser.addCommand("
|
157
|
-
|
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;
|
158
180
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
181
|
+
while (activeElement.shadowRoot) {
|
182
|
+
if (activeElement.shadowRoot.activeElement) {
|
183
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
184
|
+
} else {
|
185
|
+
break;
|
186
|
+
}
|
163
187
|
}
|
188
|
+
done(elem === activeElement);
|
189
|
+
}, this);
|
190
|
+
}, true);
|
164
191
|
|
165
|
-
|
166
|
-
|
167
|
-
elem._waitForDomRef().then(done);
|
168
|
-
}, curElement);
|
169
|
-
|
170
|
-
// find the next element from the selector
|
171
|
-
curElement = curElement.$(new Function (`
|
172
|
-
return this.shadowRoot.querySelector("${selectors[i]}");
|
173
|
-
`));
|
174
|
-
}
|
175
|
-
|
176
|
-
return curElement;
|
177
|
-
|
178
|
-
});
|
179
|
-
|
180
|
-
browser.addCommand("findElementDeep", function (selector) {
|
181
|
-
const selectors = selector.split(">>>");
|
182
|
-
let curElement = this;
|
183
|
-
|
184
|
-
for (var i = 0; i < selectors.length; i++) {
|
185
|
-
curElement = curElement.$(new Function (`
|
186
|
-
return this.shadowRoot.querySelector("${selectors[i]}");
|
187
|
-
`));
|
188
|
-
}
|
189
|
-
|
190
|
-
return curElement;
|
191
|
-
}, this);
|
192
|
-
|
193
|
-
browser.addCommand("isFocusedDeep", function () {
|
194
|
-
return browser.execute(function (elem) {
|
192
|
+
await browser.addCommand("isFocusedDeepElement", async function (element) {
|
193
|
+
return browser.executeAsync(function (elem, element, done) {
|
195
194
|
let activeElement = document.activeElement;
|
196
195
|
|
197
196
|
while (activeElement.shadowRoot) {
|
@@ -201,48 +200,88 @@ exports.config = {
|
|
201
200
|
break;
|
202
201
|
}
|
203
202
|
}
|
204
|
-
|
205
|
-
}, this);
|
203
|
+
done(element === activeElement);
|
204
|
+
}, this, element);
|
206
205
|
}, true);
|
207
206
|
|
208
|
-
browser.addCommand("setProperty", function(property, value) {
|
209
|
-
return browser.
|
210
|
-
|
207
|
+
await browser.addCommand("setProperty", async function(property, value) {
|
208
|
+
return browser.executeAsync((elem, property, value, done) => {
|
209
|
+
elem[property] = value;
|
210
|
+
done();
|
211
211
|
}, this, property, value);
|
212
212
|
}, true);
|
213
213
|
|
214
|
-
browser.addCommand("setAttribute", function(attribute, value) {
|
215
|
-
return browser.
|
216
|
-
|
214
|
+
await browser.addCommand("setAttribute", async function(attribute, value) {
|
215
|
+
return browser.executeAsync((elem, attribute, value, done) => {
|
216
|
+
elem.setAttribute(attribute, value);
|
217
|
+
done();
|
217
218
|
}, this, attribute, value);
|
218
219
|
}, true);
|
219
220
|
|
220
|
-
browser.addCommand("removeAttribute", function(attribute) {
|
221
|
-
return browser.
|
222
|
-
|
221
|
+
await browser.addCommand("removeAttribute", async function(attribute) {
|
222
|
+
return browser.executeAsync((elem, attribute, done) => {
|
223
|
+
elem.removeAttribute(attribute);
|
224
|
+
done();
|
223
225
|
}, this, attribute);
|
224
226
|
}, true);
|
225
227
|
|
226
|
-
browser.addCommand("hasClass", function(className) {
|
227
|
-
return browser.
|
228
|
-
|
228
|
+
await browser.addCommand("hasClass", async function(className) {
|
229
|
+
return browser.executeAsync((elem, className, done) => {
|
230
|
+
done(elem.classList.contains(className));
|
229
231
|
}, this, className);
|
230
232
|
}, true);
|
231
233
|
|
232
|
-
browser.addCommand("
|
233
|
-
return browser.
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
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
|
+
});
|
238
249
|
},
|
239
250
|
/**
|
240
251
|
* Runs before a WebdriverIO command gets executed.
|
241
252
|
* @param {String} commandName hook command name
|
242
253
|
* @param {Array} args arguments that command would receive
|
243
254
|
*/
|
244
|
-
|
245
|
-
|
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
|
+
},
|
246
285
|
|
247
286
|
/**
|
248
287
|
* Hook that gets executed before the suite starts
|
@@ -272,8 +311,17 @@ exports.config = {
|
|
272
311
|
* Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
273
312
|
* @param {Object} test test details
|
274
313
|
*/
|
275
|
-
|
276
|
-
|
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
|
+
},
|
277
325
|
/**
|
278
326
|
* Hook that gets executed after the suite has ended
|
279
327
|
* @param {Object} suite suite details
|
@@ -288,13 +336,46 @@ exports.config = {
|
|
288
336
|
* @param {Number} result 0 - command success, 1 - command error
|
289
337
|
* @param {Object} error error object if any
|
290
338
|
*/
|
291
|
-
afterCommand: function (commandName, args, result, error) {
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
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) {
|
296
344
|
window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
|
297
|
-
|
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);
|
298
379
|
});
|
299
380
|
}
|
300
381
|
},
|
package/icons-collection/nps.js
CHANGED
@@ -2,24 +2,67 @@ const path = require("path");
|
|
2
2
|
|
3
3
|
const LIB = path.join(__dirname, `../lib/`);
|
4
4
|
|
5
|
-
const
|
5
|
+
const createIconImportsCommand = (options) => {
|
6
|
+
if (!options.versions) {
|
7
|
+
return `node "${LIB}/create-icons/index.js" "${options.collectionName}"`;
|
8
|
+
}
|
9
|
+
|
10
|
+
const command = { default: "nps" };
|
11
|
+
options.versions.forEach((v) => {
|
12
|
+
command.default += ` build.icons.create${v}`;
|
13
|
+
command[`create${v}`] = `node "${LIB}/create-icons/index.js" "${options.collectionName}" "${v}"`;
|
14
|
+
});
|
15
|
+
|
16
|
+
return command;
|
17
|
+
}
|
18
|
+
|
19
|
+
const copyIconAssetsCommand = (options) => {
|
20
|
+
if (!options.versions) {
|
21
|
+
return {
|
22
|
+
default: "nps copy.json-imports copy.icon-collection",
|
23
|
+
"json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
24
|
+
"icon-collection": `node "${LIB}/copy-and-watch/index.js" --silent "src/*.json" src/generated/assets/`,
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
const command = {
|
29
|
+
default: "nps copy.json-imports ",
|
30
|
+
"json-imports": `node "${LIB}/copy-and-watch/index.js" --silent "src/**/*.js" dist/`,
|
31
|
+
};
|
32
|
+
|
33
|
+
options.versions.forEach((v) => {
|
34
|
+
command.default += ` copy.icon-collection${v}`;
|
35
|
+
command[`icon-collection${v}`] = `node "${LIB}/copy-and-watch/index.js" --silent "src/${v}/*.json" src/generated/assets/${v}/`;
|
36
|
+
});
|
37
|
+
|
38
|
+
return command;
|
39
|
+
}
|
40
|
+
|
41
|
+
const getScripts = (options) => {
|
42
|
+
const createJSImportsCmd = createIconImportsCommand(options);
|
43
|
+
const copyAssetsCmd = copyIconAssetsCommand(options);
|
44
|
+
const tsCommand = !options.legacy ? "tsc --build" : "";
|
45
|
+
const tsCrossEnv = !options.legacy ? "cross-env UI5_TS=true" : "";
|
6
46
|
|
7
47
|
const scripts = {
|
8
|
-
clean: "rimraf dist",
|
9
|
-
copy:
|
10
|
-
|
11
|
-
|
12
|
-
"icon-collections": 'copy-and-watch "src/icon-collections/**/*.json" dist/generated/assets/icon-collections/'
|
13
|
-
},
|
48
|
+
clean: "rimraf dist && rimraf src/generated",
|
49
|
+
copy: copyAssetsCmd,
|
50
|
+
generate: `${tsCrossEnv} nps clean copy build.i18n build.icons build.jsonImports copyjson`,
|
51
|
+
copyjson: "copy-and-watch \"src/generated/**/*.json\" dist/generated/",
|
14
52
|
build: {
|
15
|
-
default:
|
53
|
+
default: `${tsCrossEnv} nps clean copy build.i18n typescript build.icons build.jsonImports`,
|
16
54
|
i18n: {
|
17
55
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
18
|
-
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n
|
19
|
-
json: `mkdirp
|
56
|
+
defaultsjs: `mkdirp dist/generated/i18n && node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
57
|
+
json: `mkdirp src/generated/assets/i18n && node "${LIB}/i18n/toJSON.js" src/i18n src/generated/assets/i18n`,
|
20
58
|
},
|
21
|
-
|
22
|
-
|
59
|
+
jsonImports: {
|
60
|
+
default: "mkdirp src/generated/json-imports && nps build.jsonImports.i18n",
|
61
|
+
i18n: `node "${LIB}/generate-json-imports/i18n.js" src/generated/assets/i18n src/generated/json-imports`,
|
62
|
+
},
|
63
|
+
icons: createJSImportsCmd,
|
64
|
+
},
|
65
|
+
typescript: tsCommand,
|
23
66
|
};
|
24
67
|
|
25
68
|
return scripts;
|