@ui5/webcomponents-tools 0.0.0-e463d2345 → 0.0.0-e818f286e

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 (81) hide show
  1. package/CHANGELOG.md +263 -1
  2. package/README.md +5 -6
  3. package/assets-meta.js +153 -0
  4. package/bin/dev.js +12 -1
  5. package/components-package/nps.js +81 -44
  6. package/components-package/postcss.themes.js +6 -3
  7. package/components-package/vite.config.js +12 -0
  8. package/components-package/wdio.js +118 -65
  9. package/components-package/wdio.sync.js +360 -0
  10. package/icons-collection/nps.js +66 -28
  11. package/lib/copy-and-watch/index.js +145 -0
  12. package/lib/copy-list/index.js +28 -0
  13. package/lib/create-icons/index.js +82 -50
  14. package/lib/create-illustrations/index.js +161 -0
  15. package/lib/create-new-component/index.js +18 -6
  16. package/lib/dev-server/dev-server.js +66 -0
  17. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  18. package/lib/esm-abs-to-rel/index.js +58 -0
  19. package/lib/generate-json-imports/i18n.js +98 -47
  20. package/lib/generate-json-imports/themes.js +71 -16
  21. package/lib/hbs2lit/index.js +2 -4
  22. package/lib/hbs2lit/src/compiler.js +18 -8
  23. package/lib/hbs2lit/src/includesReplacer.js +23 -17
  24. package/lib/hbs2lit/src/litVisitor2.js +57 -11
  25. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  26. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
  27. package/lib/hbs2ui5/index.js +52 -30
  28. package/lib/i18n/defaults.js +63 -52
  29. package/lib/i18n/toJSON.js +25 -13
  30. package/lib/jsdoc/config.json +1 -1
  31. package/lib/jsdoc/plugin.js +33 -4
  32. package/lib/jsdoc/template/publish.js +24 -4
  33. package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
  34. package/lib/postcss-css-to-esm/index.js +45 -21
  35. package/lib/postcss-css-to-json/index.js +38 -11
  36. package/lib/postcss-new-files/index.js +36 -0
  37. package/lib/postcss-p/postcss-p.mjs +14 -0
  38. package/lib/replace-global-core/index.js +25 -0
  39. package/lib/scoping/get-all-tags.js +44 -0
  40. package/lib/scoping/lint-src.js +31 -0
  41. package/lib/scoping/missing-dependencies.js +65 -0
  42. package/lib/scoping/report-tags-usage.js +28 -0
  43. package/lib/scoping/scope-test-pages.js +40 -0
  44. package/lib/test-runner/test-runner.js +63 -0
  45. package/package.json +46 -55
  46. package/bin/init-ui5-package.js +0 -3
  47. package/components-package/rollup.js +0 -134
  48. package/components-package/serve.json +0 -3
  49. package/lib/documentation/index.js +0 -143
  50. package/lib/documentation/templates/api-component-since.js +0 -3
  51. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  52. package/lib/documentation/templates/api-events-section.js +0 -35
  53. package/lib/documentation/templates/api-methods-section.js +0 -26
  54. package/lib/documentation/templates/api-properties-section.js +0 -40
  55. package/lib/documentation/templates/api-slots-section.js +0 -28
  56. package/lib/documentation/templates/template.js +0 -38
  57. package/lib/init-package/index.js +0 -119
  58. package/lib/init-package/resources/.eslintignore +0 -3
  59. package/lib/init-package/resources/bundle.es5.js +0 -25
  60. package/lib/init-package/resources/bundle.esm.js +0 -34
  61. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  62. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  63. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  64. package/lib/init-package/resources/config/rollup.config.js +0 -1
  65. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  66. package/lib/init-package/resources/package-scripts.js +0 -11
  67. package/lib/init-package/resources/src/Assets.js +0 -6
  68. package/lib/init-package/resources/src/Demo.hbs +0 -1
  69. package/lib/init-package/resources/src/Demo.js +0 -57
  70. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  71. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  72. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  73. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  74. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  75. package/lib/init-package/resources/src/themes/Demo.css +0 -11
  76. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  77. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  78. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  79. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  80. package/lib/init-package/resources/test/pages/index.html +0 -51
  81. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -1,33 +1,57 @@
1
- const postcss = require('postcss');
2
1
  const fs = require('fs');
3
2
  const path = require('path');
4
3
  const mkdirp = require('mkdirp');
4
+ const assets = require("../../assets-meta.js");
5
5
 
6
- const getDefaultThemeCode = packageName => {
7
- return `import "@ui5/webcomponents-theme-base/dist/DefaultTheme.js";
8
-
9
- import { registerThemeProperties } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
6
+ const DEFAULT_THEME = assets.themes.default;
10
7
 
11
- import fiori3 from "./sap_fiori_3/parameters-bundle.css.js";
8
+ const getDefaultThemeCode = packageName => {
9
+ return `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
12
10
 
13
- registerThemeProperties("${packageName}", "sap_fiori_3", fiori3);
11
+ import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
12
+ import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
14
13
 
14
+ registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", () => defaultThemeBase);
15
+ registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", () => defaultTheme);
15
16
  `;
16
17
  };
17
18
 
18
- module.exports = postcss.plugin('add css to esm transform plugin', function (opts) {
19
- opts = opts || {};
20
-
21
- return function (root) {
22
- const css = JSON.stringify(root.toString());
23
- const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
19
+ const proccessCSS = css => {
20
+ css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
21
+ css = css.replace(/\.background-image.*{.*}/, "");
22
+ css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
23
+ css = css.replace(/--sapFontUrl.*\);?/, "");
24
+ return JSON.stringify(css);
25
+ }
24
26
 
25
- mkdirp.sync(path.dirname(targetFile));
26
-
27
- const filePath = `${targetFile}.js`;
28
-
29
- const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
27
+ module.exports = function (opts) {
28
+ opts = opts || {};
30
29
 
31
- fs.writeFileSync(filePath, `${defaultTheme}export default ${css};`);
32
- }
33
- });
30
+ return {
31
+ postcssPlugin: 'postcss-css-to-esm',
32
+ Once (root) {
33
+ let css = root.toString();
34
+ css = proccessCSS(css);
35
+
36
+ const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
37
+ mkdirp.sync(path.dirname(targetFile));
38
+
39
+ const filePath = `${targetFile}.js`;
40
+ const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
41
+
42
+ // it seems slower to read the old content, but writing the same content with no real changes
43
+ // (as in initial build and then watch mode) will cause an unnecessary dev server refresh
44
+ let oldContent = "";
45
+ try {
46
+ oldContent = fs.readFileSync(filePath).toString();
47
+ } catch (e) {
48
+ // file not found
49
+ }
50
+ const content = `${defaultTheme}export default {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
51
+ if (content !== oldContent) {
52
+ fs.writeFileSync(filePath, content);
53
+ }
54
+ }
55
+ };
56
+ };
57
+ module.exports.postcss = true;
@@ -1,20 +1,47 @@
1
- const postcss = require('postcss');
2
1
  const fs = require('fs');
3
2
  const path = require('path');
4
3
  const mkdirp = require('mkdirp');
5
4
 
6
- module.exports = postcss.plugin('add css to JSON transform plugin', function (opts) {
7
- opts = opts || {};
5
+ const proccessCSS = css => {
6
+ css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
7
+ css = css.replace(/\.background-image.*{.*}/, "");
8
+ css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
9
+ css = css.replace(/--sapFontUrl.*\);?/, "");
10
+ return css;
11
+ }
8
12
 
9
- return function (root) {
10
- const css = root.toString();
11
- const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\assets\\");
13
+ module.exports = function (opts) {
14
+ opts = opts || {};
12
15
 
13
- mkdirp.sync(path.dirname(targetFile));
16
+ return {
17
+ postcssPlugin: 'postcss-css-to-json',
18
+ Once (root) {
19
+ let css = root.toString();
20
+ css = proccessCSS(css);
14
21
 
15
- const filePath = `${targetFile}.json`;
22
+ const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\assets\\");
23
+ mkdirp.sync(path.dirname(targetFile));
16
24
 
17
- fs.writeFileSync(filePath, JSON.stringify({_: css}));
25
+ const filePath = `${targetFile}.json`;
26
+ const data = {
27
+ packageName: opts.packageName,
28
+ fileName: targetFile.substr(targetFile.lastIndexOf("themes")),
29
+ content: css
30
+ };
31
+ // it seems slower to read the old content, but writing the same content with no real changes
32
+ // (as in initial build and then watch mode) will cause an unnecessary dev server refresh
33
+ let oldContent = "";
34
+ try {
35
+ oldContent = fs.readFileSync(filePath).toString();
36
+ } catch (e) {
37
+ // file not found
38
+ }
39
+ const content = JSON.stringify({_: data});
40
+ if (content !== oldContent) {
41
+ fs.writeFileSync(filePath, content);
42
+ }
43
+ }
44
+ };
45
+ };
18
46
 
19
- }
20
- });
47
+ module.exports.postcss = true;
@@ -0,0 +1,36 @@
1
+ const chokidar = require("chokidar");
2
+ const commandLineArgs = require("command-line-args");
3
+ const { exec } = require("child_process");
4
+
5
+ const options = commandLineArgs([
6
+ { name: "srcFiles", type: String },
7
+ ]);
8
+
9
+ const runPostcss = path => {
10
+ let command = `postcss ${path} --config config/postcss.components --base src --dir dist/css/`;
11
+ console.log(`Executing: ${command}`);
12
+ exec(command, (err, stdout, stderr) => {
13
+ if (err) {
14
+ console.log(`Could not run postcss for ${path}. Error: ${err}`);
15
+ }
16
+ });
17
+
18
+ command = `${command} -w`;
19
+ console.log(`Executing: ${command}`);
20
+ exec(command, (err, stdout, stderr) => {
21
+ if (err) {
22
+ console.log(`Could not run postcss in watch mode for ${path}. Error: ${err}`);
23
+ }
24
+ });
25
+ };
26
+
27
+ let ready = false; // Do nothing until the ready event has been fired (we don't want to recompile all files initially)
28
+ const watcher = chokidar.watch(options.srcFiles);
29
+ watcher.on("ready", () => {
30
+ ready = true; // Initial scan is over -> waiting for new files
31
+ });
32
+ watcher.on("add", path => {
33
+ if (ready) {
34
+ runPostcss(path);
35
+ }
36
+ });
@@ -0,0 +1,14 @@
1
+ import 'zx/globals';
2
+
3
+ // don't print executed commands and their output
4
+ $.verbose = false;
5
+
6
+ const inputFiles = await globby("src/**/parameters-bundle.css");
7
+
8
+ const restArgs = process.argv.slice(2);
9
+
10
+ // run all postcss processes in parallel as passing the glob directly to postcss makes them processed sequentially.
11
+ // and the amount of imports give a big speed up when run in parallel
12
+ await Promise.all(inputFiles.map(file => {
13
+ return $`postcss ${file} --config config/postcss.themes --base src --dir dist/css/ ${restArgs}`;
14
+ }));
@@ -0,0 +1,25 @@
1
+ const fs = require("fs").promises;
2
+
3
+ const basePath = process.argv[2];
4
+
5
+ const replaceGlobalCoreUsage = async (srcPath) => {
6
+
7
+ const original = (await fs.readFile(srcPath)).toString();
8
+ let replaced = original.replace(/sap\.ui\.getCore\(\)/g, `Core`);
9
+
10
+ if (original !== replaced) {
11
+ replaced = `import Core from 'sap/ui/core/Core';
12
+ ${replaced}`;
13
+ return fs.writeFile(srcPath, replaced);
14
+ }
15
+ };
16
+
17
+ const generate = async () => {
18
+ const { globby } = await import("globby");
19
+ const fileNames = await globby(basePath + "**/*.js");
20
+ return Promise.all(fileNames.map(replaceGlobalCoreUsage).filter(x => !!x));
21
+ };
22
+
23
+ generate().then(() => {
24
+ console.log("Success: Replaced global core usage in:", basePath);
25
+ });
@@ -0,0 +1,44 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const glob = require("glob");
4
+
5
+ const getTag = file => {
6
+ const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
7
+ const matches = fileContent.match(/\btag\b:\s*\"(.*?)\"/);
8
+ return matches ? matches[1] : undefined;
9
+ };
10
+
11
+ const getAltTag = file => {
12
+ const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
13
+ const matches = fileContent.match(/\baltTag\b:\s*\"(.*?)\"/);
14
+ return matches ? matches[1] : undefined;
15
+ };
16
+
17
+ const getPackageTags = (packageDir) => {
18
+ const srcDir = path.join(packageDir, "src/");
19
+ return glob.sync(path.join(srcDir, "/**/*.js")).flatMap(file => {
20
+ const tag = getTag(file);
21
+ const altTag = getAltTag(file);
22
+ return [tag, altTag];
23
+ }).filter(item => !!item);
24
+ };
25
+
26
+ const isComponentsPackage = (packageFileContent) => {
27
+ return packageFileContent.ui5 && packageFileContent.ui5.webComponentsPackage;
28
+ };
29
+
30
+ const getDepComponentPackages = packageDir => {
31
+ const packageFile = path.join(packageDir, "package.json");
32
+ const packageFileContent = JSON.parse(fs.readFileSync(packageFile));
33
+ if (!isComponentsPackage(packageFileContent)) {
34
+ return [];
35
+ }
36
+
37
+ return Object.keys(packageFileContent.dependencies || {}).map(dep => path.dirname(require.resolve(path.join(dep, "package.json"))));
38
+ };
39
+
40
+ const getAllTags = (packageDir) => {
41
+ return getPackageTags(packageDir).concat(getDepComponentPackages(packageDir).flatMap(getPackageTags));
42
+ };
43
+
44
+ module.exports = getAllTags;
@@ -0,0 +1,31 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const glob = require("glob");
4
+ const getAllTags = require("./get-all-tags.js");
5
+
6
+ const tags = getAllTags(process.cwd());
7
+
8
+ const errors = [];
9
+
10
+ glob.sync(path.join(process.cwd(), "src/**/*.css")).forEach(file => {
11
+ let content = String(fs.readFileSync(file));
12
+ tags.forEach(tag => {
13
+ if (content.match(new RegExp(`(^|[^\.\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
14
+ errors.push(`Warning! ${tag} found in ${file}`);
15
+ }
16
+ });
17
+ });
18
+
19
+ glob.sync(path.join(process.cwd(), "src/**/*.js")).forEach(file => {
20
+ let content = String(fs.readFileSync(file));
21
+ tags.forEach(tag => {
22
+ if (content.match(new RegExp(`querySelector[A-Za-z]*..${tag}`, "g"))) {
23
+ errors.push(`Warning! querySelector for ${tag} found in ${file}`);
24
+ }
25
+ });
26
+ });
27
+
28
+ if (errors.length) {
29
+ errors.forEach(error => console.log(error));
30
+ throw new Error("Errors found.");
31
+ }
@@ -0,0 +1,65 @@
1
+ const fs = require("fs");
2
+ const glob = require("glob");
3
+ const path = require("path");
4
+ const process = require("process");
5
+
6
+ const projectPath = process.argv[2];
7
+
8
+ // gather all tags from all files
9
+ const tagsToFiles = new Map();
10
+ const filesToTags = new Map();
11
+
12
+ let files = [
13
+ ...glob.sync(path.join("packages/main/src/**/*.js")),
14
+ ...glob.sync(path.join("packages/fiori/src/**/*.js")),
15
+ ];
16
+ files.forEach(file => {
17
+ let matches = file.match(/([a-zA-Z0-9_]+)\.js$/);
18
+ const name = matches[1];
19
+
20
+ const content = `${fs.readFileSync(file)}`;
21
+ matches = content.match(/tag: "(.*?)",/);
22
+ if (matches) {
23
+ const tag = matches[1];
24
+ tagsToFiles.set(tag, name);
25
+ filesToTags.set(name, tag);
26
+ }
27
+ });
28
+
29
+ // Process the package
30
+ files = glob.sync(path.join(projectPath, "src/**/*.js"));
31
+ tagsToFiles.forEach((file, tag) => {
32
+ const sourcePath = path.join(projectPath, "src/", `${file}.js`);
33
+ if (!fs.existsSync(sourcePath)) {
34
+ return;
35
+ }
36
+ const sourceContent = `${fs.readFileSync(sourcePath)}`.split("\n").join(" ");
37
+
38
+ const hbsPath = path.join(projectPath, "src/", `${file}.hbs`);
39
+ const hbsContent = fs.existsSync(hbsPath) ? `${fs.readFileSync(hbsPath)}` : "";
40
+
41
+ const hbsPopoverPath = path.join(projectPath, "src/", `${file}Popover.hbs`);
42
+ const hbsPopoverContent = fs.existsSync(hbsPopoverPath) ? `${fs.readFileSync(hbsPopoverPath)}` : "";
43
+
44
+ // deps
45
+ let deps = [];
46
+ let matches = sourceContent.match(/static get dependencies\(\) \{\s+return \[(.*?)\]/);
47
+ if (matches) {
48
+ deps = matches[1].split(",").map(x => x.trim()).filter(x => !!x);
49
+ }
50
+
51
+ // tags
52
+ matches = [
53
+ ...hbsContent.matchAll(/<ui5-[a-z0-9-]+/g),
54
+ ...hbsPopoverContent.matchAll(/<ui5-[a-z0-9-]+/g),
55
+ ];
56
+ if (matches) {
57
+ matches.forEach(match => {
58
+ const tagUsed = match[0].substr(1);
59
+ const dep = tagsToFiles.get(tagUsed);
60
+ if (!deps.includes(dep)) {
61
+ console.log(`${file} used ${tagUsed}`);
62
+ }
63
+ });
64
+ }
65
+ });
@@ -0,0 +1,28 @@
1
+ const fs = require("fs");
2
+ const glob = require("glob");
3
+ const path = require("path");
4
+ const process = require("process");
5
+
6
+ // gather all tags from all files
7
+ const tags = new Set();
8
+ const files = glob.sync(path.join(process.argv[2], "src/**/*.js"));
9
+ files.forEach(file => {
10
+ const content = `${fs.readFileSync(file)}`;
11
+ const matches = content.match(/tag: "(.*?)",/);
12
+ if (matches) {
13
+ tags.add(matches[1]);
14
+ }
15
+ });
16
+
17
+ // report all usages of any tag within any file, which is not the tag definition and is not hasAttribute
18
+ files.forEach(file => {
19
+ const content = `${fs.readFileSync(file)}`;
20
+ const lines = content.split("\n");
21
+ lines.forEach(line => {
22
+ tags.forEach(tag => {
23
+ if (line.includes(`"${tag}"`) && !line.includes(`tag: "${tag}",`) && !line.includes(`hasAttribute("${tag}")`)) {
24
+ console.log(`${file}: ${line.trim()}`);
25
+ }
26
+ });
27
+ });
28
+ });
@@ -0,0 +1,40 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const glob = require("glob");
4
+ const getAllTags = require("./get-all-tags.js");
5
+
6
+ const root = process.argv[2];
7
+ const suffix = process.argv[3];
8
+
9
+ const tags = getAllTags(process.cwd());
10
+
11
+ // Replaces tags in HTML content, f.e. <ui5-button> with <ui5-button-ver> or </ui5-button> with </ui5-button-ver>
12
+ const replaceTagsHTML = content => {
13
+ tags.forEach(tag => {
14
+ content = content.replace(new RegExp(`(<\/?)(${tag})(\/?[> \t\n])`, "g"), `$1$2-${suffix}$3`);
15
+ });
16
+ return content;
17
+ };
18
+
19
+ // Replace tags in any content
20
+ const replaceTagsAny = content => {
21
+ tags.forEach(tag => {
22
+ content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
23
+ });
24
+ return content;
25
+ };
26
+
27
+ // Replace bundle names and HTML tag names in test pages
28
+ glob.sync(path.join(root, "/**/*.html")).forEach(file => {
29
+ let content = String(fs.readFileSync(file));
30
+ content = content.replace(/bundle\.(.*?)\.js/g, `../bundle.scoped.$1.js`);
31
+ content = replaceTagsHTML(content);
32
+ fs.writeFileSync(file, content);
33
+ });
34
+
35
+ // Replace tag names everywhere
36
+ glob.sync(path.join(root, "/**/*.{html,css,js}")).forEach(file => {
37
+ let content = String(fs.readFileSync(file));
38
+ content = replaceTagsAny(content);
39
+ fs.writeFileSync(file, content);
40
+ });
@@ -0,0 +1,63 @@
1
+ const child_process = require("child_process");
2
+ const { readFileSync } = require("fs");
3
+ const path = require("path");
4
+
5
+ // search for dev-server port
6
+ // start in current folder
7
+ // traversing upwards in case of mono repo tests and dev-server running in root folder of repository
8
+ let devServerFolder = process.cwd();
9
+ let devServerPort;
10
+ while (true) {
11
+ try {
12
+ devServerPort = readFileSync(path.join(devServerFolder, ".dev-server-port")).toString();
13
+ break; // found
14
+ } catch (e) {
15
+ // file not found
16
+ if (devServerFolder === path.dirname(devServerFolder)) {
17
+ break; // reached root folder "/"
18
+ }
19
+ devServerFolder = path.dirname(devServerFolder);
20
+ }
21
+ }
22
+
23
+ // check if we are in a monorepo and extract path from package.json
24
+ let packageRepositoryPath = "";
25
+ const pkg = require(path.join(process.cwd(), "package.json"));
26
+ packageRepositoryPath = pkg.repository.directory;
27
+
28
+ // construct base url
29
+ // use devServerPort if a dev server is running, otherwise let the baseUrl in the wdio config be used
30
+ // if a dev server is running in the root of a mono repo, append tha package path like this
31
+ // http://localhost:${devServerPort}/packages/main/
32
+ let baseUrl = "";
33
+ if (devServerPort) {
34
+ console.log(`Found port ${devServerPort} from '${path.join(devServerFolder, ".dev-server-port")}'`);
35
+ const devServerInRoot = !devServerFolder.includes(packageRepositoryPath);
36
+ if (devServerInRoot) {
37
+ baseUrl = `--base-url http://localhost:${devServerPort}/${packageRepositoryPath}/`;
38
+ } else {
39
+ baseUrl = `--base-url http://localhost:${devServerPort}/`;
40
+ }
41
+ }
42
+
43
+ if (!baseUrl) {
44
+ console.log("No dev server running, running tests served from `dist`, make sure it is up to date");
45
+ }
46
+
47
+ // add single spec parameter if passed
48
+ let spec = "";
49
+ if (process.argv.length === 3) {
50
+ const specFile = process.argv[2];
51
+ spec = `--spec ${specFile}`;
52
+ }
53
+
54
+ // more parameters - pass them to wdio
55
+ let restParams = "";
56
+ if (process.argv.length > 3) {
57
+ restParams = process.argv.slice(2).join(" ");
58
+ }
59
+
60
+ // run wdio with calculated parameters
61
+ const cmd = `yarn cross-env WDIO_LOG_LEVEL=error wdio config/wdio.conf.js ${spec} ${baseUrl} ${restParams}`;
62
+ console.log(`executing: ${cmd}`);
63
+ child_process.execSync(cmd, {stdio: 'inherit'});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "0.0.0-e463d2345",
3
+ "version": "0.0.0-e818f286e",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -13,8 +13,7 @@
13
13
  "scripts": {},
14
14
  "bin": {
15
15
  "wc-dev": "bin/dev.js",
16
- "wc-create-ui5-element": "bin/create-ui5-element.js",
17
- "wc-init-ui5-package": "bin/init-ui5-package.js"
16
+ "wc-create-ui5-element": "bin/create-ui5-element.js"
18
17
  },
19
18
  "repository": {
20
19
  "type": "git",
@@ -22,61 +21,53 @@
22
21
  "directory": "packages/tools"
23
22
  },
24
23
  "dependencies": {
25
- "@babel/cli": "^7.1.2",
26
- "@babel/core": "^7.1.2",
27
- "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
28
- "@babel/preset-env": "^7.1.0",
29
- "@wdio/cli": "^5.12.1",
30
- "@wdio/dot-reporter": "^5.12.1",
31
- "@wdio/local-runner": "^5.12.1",
32
- "@wdio/mocha-framework": "^5.12.1",
33
- "@wdio/spec-reporter": "^5.12.1",
34
- "@wdio/sync": "^5.12.1",
35
- "@webcomponents/webcomponentsjs": "^2.4.0",
36
- "chai": "^4.2.0",
37
- "chokidar-cli": "^2.0.0",
38
- "chromedriver": "^79.0.0",
39
- "clean-css": "^4.2.1",
24
+ "@wdio/cli": "^7.19.7",
25
+ "@wdio/devtools-service": "^7.19.7",
26
+ "@wdio/dot-reporter": "^7.19.7",
27
+ "@wdio/local-runner": "^7.19.7",
28
+ "@wdio/mocha-framework": "^7.19.7",
29
+ "@wdio/spec-reporter": "^7.19.7",
30
+ "@wdio/static-server-service": "^7.19.5",
31
+ "chai": "^4.3.4",
32
+ "child_process": "^1.0.2",
33
+ "chokidar": "^3.5.1",
34
+ "chokidar-cli": "^3.0.0",
40
35
  "command-line-args": "^5.1.1",
41
- "concurrently": "^5.0.0",
42
- "copy-and-watch": "^0.1.4",
43
- "cross-env": "^5.2.0",
44
- "cssnano": "^4.1.10",
45
- "escodegen": "^1.11.0",
46
- "eslint": "^5.10.0",
47
- "eslint-config-airbnb-base": "^13.1.0",
48
- "eslint-plugin-import": "^2.14.0",
36
+ "concurrently": "^6.0.0",
37
+ "cross-env": "^7.0.3",
38
+ "cssnano": "^4.1.11",
39
+ "escodegen": "^2.0.0",
40
+ "eslint": "^7.22.0",
41
+ "eslint-config-airbnb-base": "^14.2.1",
42
+ "eslint-plugin-import": "^2.22.1",
49
43
  "esprima": "^4.0.1",
50
- "getopts": "^2.2.3",
51
- "glob": "^7.1.3",
52
- "handlebars": "^4.1.2",
53
- "jsdoc": "^3.6.3",
44
+ "getopts": "^2.3.0",
45
+ "glob": "^7.1.6",
46
+ "glob-parent": "^6.0.2",
47
+ "globby": "^13.1.1",
48
+ "handlebars": "^4.7.7",
49
+ "is-port-reachable": "^3.1.0",
50
+ "jsdoc": "^3.6.6",
54
51
  "json-beautify": "^1.1.1",
55
- "mkdirp": "^0.5.1",
56
- "npm-run-all": "^4.1.3",
57
- "nps": "^5.9.8",
58
- "postcss": "^7.0.18",
59
- "postcss-cli": "^6.1.3",
60
- "postcss-combine-duplicated-selectors": "^7.0.0",
61
- "postcss-import": "^12.0.1",
62
- "properties-reader": "^0.3.1",
63
- "puppeteer": "^1.11.0",
64
- "rimraf": "^2.6.2",
65
- "rollup": "^1.1.2",
66
- "rollup-plugin-babel": "^4.0.3",
67
- "rollup-plugin-filesize": "^6.0.1",
68
- "rollup-plugin-less": "^1.1.2",
69
- "rollup-plugin-livereload": "^1.0.4",
70
- "rollup-plugin-node-resolve": "^4.0.0",
71
- "rollup-plugin-notify": "^1.1.0",
72
- "rollup-plugin-string": "^2.0.2",
73
- "rollup-plugin-terser": "^5.1.3",
74
- "rollup-plugin-url": "^2.2.0",
75
- "rollup-plugin-visualizer": "^0.9.2",
76
- "serve": "^10.1.1",
77
- "wdio-chromedriver-service": "^5.0.2"
52
+ "mkdirp": "^1.0.4",
53
+ "nps": "^5.10.0",
54
+ "postcss": "^8.4.5",
55
+ "postcss-cli": "^9.1.0",
56
+ "postcss-import": "^14.0.2",
57
+ "postcss-selector-parser": "^6.0.10",
58
+ "properties-reader": "^2.2.0",
59
+ "recursive-readdir": "^2.2.2",
60
+ "resolve": "^1.20.0",
61
+ "rimraf": "^3.0.2",
62
+ "slash": "3.0.0",
63
+ "vite": "^2.9.12",
64
+ "wdio-chromedriver-service": "^7.3.2",
65
+ "zx": "^4.3.0"
78
66
  },
79
- "resolutions": {
80
- "rollup-plugin-livereload/livereload/chokidar": "^3.x"
67
+ "peerDependencies": {
68
+ "chromedriver": "*"
69
+ },
70
+ "devDependencies": {
71
+ "yargs": "^17.5.1"
81
72
  }
82
73
  }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../lib/init-package/index.js");