@ui5/webcomponents-tools 1.0.0-rc.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +1 -1
  3. package/assets-meta.js +12 -1
  4. package/components-package/nps.js +51 -27
  5. package/components-package/postcss.themes.js +5 -2
  6. package/components-package/rollup-plugins/empty-module.js +15 -0
  7. package/components-package/rollup.js +134 -40
  8. package/components-package/wdio.js +53 -28
  9. package/components-package/wdio.sync.js +360 -0
  10. package/icons-collection/nps.js +53 -9
  11. package/lib/copy-and-watch/index.js +6 -4
  12. package/lib/copy-list/index.js +28 -0
  13. package/lib/create-icons/index.js +32 -14
  14. package/lib/create-illustrations/index.js +150 -0
  15. package/lib/create-new-component/index.js +12 -4
  16. package/lib/documentation/index.js +42 -20
  17. package/lib/documentation/templates/template.js +1 -1
  18. package/lib/esm-abs-to-rel/index.js +54 -0
  19. package/lib/generate-json-imports/i18n.js +56 -18
  20. package/lib/generate-json-imports/themes.js +44 -13
  21. package/lib/hash/config.js +10 -0
  22. package/lib/hash/generate.js +19 -0
  23. package/lib/hash/upToDate.js +31 -0
  24. package/lib/hbs2lit/src/litVisitor2.js +31 -6
  25. package/lib/hbs2lit/src/svgProcessor.js +3 -3
  26. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +4 -11
  27. package/lib/i18n/toJSON.js +1 -1
  28. package/lib/jsdoc/config.json +1 -1
  29. package/lib/jsdoc/plugin.js +21 -1
  30. package/lib/jsdoc/template/publish.js +9 -0
  31. package/lib/polyfill-placeholder/index.js +5 -0
  32. package/lib/postcss-css-to-esm/index.js +19 -16
  33. package/lib/postcss-css-to-json/index.js +20 -11
  34. package/lib/postcss-new-files/index.js +36 -0
  35. package/lib/replace-global-core/index.js +20 -0
  36. package/lib/scoping/lint-src.js +1 -1
  37. package/lib/serve/index.js +46 -0
  38. package/{components-package → lib/serve}/serve.json +0 -0
  39. package/package.json +52 -53
  40. package/bin/init-ui5-package.js +0 -3
  41. package/lib/init-package/index.js +0 -123
  42. package/lib/init-package/resources/.eslintignore +0 -3
  43. package/lib/init-package/resources/bundle.es5.js +0 -25
  44. package/lib/init-package/resources/bundle.esm.js +0 -34
  45. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  46. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  47. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  48. package/lib/init-package/resources/config/rollup.config.js +0 -1
  49. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  50. package/lib/init-package/resources/package-scripts.js +0 -11
  51. package/lib/init-package/resources/src/Assets.js +0 -5
  52. package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
  53. package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
  54. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  55. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  56. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  57. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  58. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  59. package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
  60. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  61. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  62. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  63. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  64. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  65. package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  66. package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  67. package/lib/init-package/resources/test/pages/index.html +0 -56
  68. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -8,9 +8,26 @@ let skipIfDefined = false;
8
8
  // when true => an HTML node value, when false => an attribute value
9
9
  let isNodeValue = false;
10
10
 
11
+ // when true => the current attribute is "style"
12
+ let isStyleAttribute = false;
13
+
11
14
  // matches event handlers @click= and boolean attrs ?disabled=
12
15
  const dynamicAttributeRgx = /\s(\?|@)([a-zA-Z|-]+)="?\s*$/;
13
16
 
17
+ if (!String.prototype.replaceAll) {
18
+ String.prototype.replaceAll = function(str, newStr){
19
+
20
+ // If a regex pattern
21
+ if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
22
+ return this.replace(str, newStr);
23
+ }
24
+
25
+ // If a string
26
+ return this.replace(new RegExp(str, 'g'), newStr);
27
+
28
+ };
29
+ }
30
+
14
31
  function HTMLLitVisitor(debug) {
15
32
  this.blockCounter = 0;
16
33
  this.keys = [];
@@ -18,7 +35,7 @@ function HTMLLitVisitor(debug) {
18
35
  this.result = "";
19
36
  this.mainBlock = "";
20
37
  this.blockPath = "context";
21
- this.blockParameters = ["context"];
38
+ this.blockParameters = ["context", "tags", "suffix"];
22
39
  this.paths = []; //contains all normalized relative paths
23
40
  this.debug = debug;
24
41
  if (this.debug) {
@@ -34,7 +51,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
34
51
  this.keys.push(key);
35
52
  this.debug && this.blockByNumber.push(key);
36
53
 
37
- this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") => { return ";
54
+ this.blocks[this.currentKey()] = "const " + this.currentKey() + " = (" + this.blockParameters.join(", ") + ") => ";
38
55
 
39
56
  if (this.keys.length > 1) { //it's a nested block
40
57
  this.blocks[this.prevKey()] += this.currentKey() + "(" + this.blockParameters.join(", ") + ")";
@@ -45,7 +62,7 @@ HTMLLitVisitor.prototype.Program = function(program) {
45
62
 
46
63
  this.blocks[this.currentKey()] += "html`";
47
64
  Visitor.prototype.Program.call(this, program);
48
- this.blocks[this.currentKey()] += "`; };";
65
+ this.blocks[this.currentKey()] += "`;";
49
66
 
50
67
  this.keys.pop(key);
51
68
  };
@@ -54,7 +71,7 @@ HTMLLitVisitor.prototype.ContentStatement = function(content) {
54
71
  Visitor.prototype.ContentStatement.call(this, content);
55
72
  // let content = content.orgiinal; // attribute="__ attribute = "__ attribute ="__
56
73
 
57
- const contentStatement = content.original;
74
+ let contentStatement = content.original;
58
75
  skipIfDefined = !!dynamicAttributeRgx.exec(contentStatement);
59
76
 
60
77
  const closingIndex = contentStatement.lastIndexOf(">");
@@ -63,6 +80,15 @@ HTMLLitVisitor.prototype.ContentStatement = function(content) {
63
80
  isNodeValue = closingIndex > openingIndex;
64
81
  }
65
82
 
83
+ isStyleAttribute = !isNodeValue && contentStatement.match(/style *= *["']? *$/);
84
+
85
+ if (!isStyleAttribute && contentStatement.match(/style=/)) {
86
+ console.log("WARNING: style hard-coded", contentStatement);
87
+ }
88
+
89
+ // Scope custom element tags
90
+ contentStatement = contentStatement.replaceAll(/(<\/?\s*)([a-zA-Z0-9_]+-[a-zA-Z0-9_-]+)/g, "$1\${scopeTag(\"$2\", tags, suffix)}");
91
+
66
92
  this.blocks[this.currentKey()] += contentStatement;
67
93
  };
68
94
 
@@ -74,7 +100,6 @@ HTMLLitVisitor.prototype.MustacheStatement = function(mustache) {
74
100
  } else {
75
101
  const path = normalizePath.call(this, mustache.path.original);
76
102
  const hasCalculatingClasses = path.includes("context.classes");
77
- const hasStylesCalculation = path.includes("context.styles");
78
103
 
79
104
  let parsedCode = "";
80
105
 
@@ -82,7 +107,7 @@ HTMLLitVisitor.prototype.MustacheStatement = function(mustache) {
82
107
  parsedCode = `\${unsafeHTML(${path})}`;
83
108
  } else if (hasCalculatingClasses) {
84
109
  parsedCode = `\${classMap(${path})}`;
85
- } else if (hasStylesCalculation) {
110
+ } else if (isStyleAttribute) {
86
111
  parsedCode = `\${styleMap(${path})}`;
87
112
  } else if (skipIfDefined){
88
113
  parsedCode = `\${${path}}`;
@@ -46,8 +46,8 @@ function getSVGMatches(template) {
46
46
 
47
47
  function getSVGBlock(input, blockCounter) {
48
48
  return {
49
- usage: `\${blockSVG${blockCounter}(context)}`,
50
- definition: `\nconst blockSVG${blockCounter} = (context) => {return svg\`${input}\`};`,
49
+ usage: `\${blockSVG${blockCounter}(context, tags, suffix)}`,
50
+ definition: `\nconst blockSVG${blockCounter} = (context, tags, suffix) => svg\`${input}\`;`,
51
51
  };
52
52
  }
53
53
 
@@ -55,7 +55,7 @@ function replaceInternalBlocks(template, svgContent) {
55
55
  const internalBlocks = svgContent.match(blockrx) || [];
56
56
 
57
57
  internalBlocks.forEach(blockName => {
58
- const rx = new RegExp(`const ${blockName}.*(html\`).*};`);
58
+ const rx = new RegExp(`const ${blockName}.*(html\`).*;`);
59
59
  template = template.replace(rx, (match, p1) => {
60
60
  return match.replace(p1, "svg\`");
61
61
  });
@@ -1,17 +1,10 @@
1
1
  const buildRenderer = (controlName, litTemplate) => {
2
- return `
3
- /* eslint no-unused-vars: 0 */
4
- import ifDefined from '@ui5/webcomponents-base/dist/renderer/ifDefined.js';
5
- import { html, svg, repeat, classMap, styleMap, unsafeHTML, setTags, setSuffix } from '@ui5/webcomponents-base/dist/renderer/LitRenderer.js';
2
+ return `/* eslint no-unused-vars: 0 */
3
+ import { html, svg, repeat, classMap, styleMap, ifDefined, unsafeHTML, scopeTag } from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
4
+
6
5
  ${litTemplate}
7
6
 
8
- const main = (context, tags, suffix) => {
9
- setTags(tags);
10
- setSuffix(suffix);
11
- return block0(context);
12
- };
13
-
14
- export default main;`
7
+ export default block0;`;
15
8
  };
16
9
 
17
10
  module.exports = {
@@ -30,7 +30,7 @@ const messagesJSONDist = path.normalize(`${process.argv[3]}`);
30
30
  const outputFile = path.normalize(`${messagesJSONDist}/${filename}.json`);
31
31
 
32
32
  fs.writeFileSync(outputFile, JSON.stringify(properties));
33
- console.log(`[i18n]: "${filename}.json" has been generated!`);
33
+ // console.log(`[i18n]: "${filename}.json" has been generated!`);
34
34
  };
35
35
 
36
36
  mkdirp.sync(messagesJSONDist);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "source": {
3
3
  "include": "src",
4
- "excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js"
4
+ "excludePattern": "(/|\\\\)library-all\\.js|(/|\\\\).*-preload\\.js|^jquery-.*\\.js|^sap-.*\\.js|.+Renderer\\.lit\\.js|.*library\\.js|thirdparty"
5
5
  },
6
6
  "opts" : {
7
7
  "recurse": true,
@@ -31,6 +31,10 @@
31
31
  *
32
32
  * tagname
33
33
  *
34
+ * native
35
+ *
36
+ * allowPreventDefault
37
+ *
34
38
  * It furthermore listens to the following JSDoc3 events to implement additional functionality
35
39
  *
36
40
  * parseBegin
@@ -2060,9 +2064,11 @@ exports.defineTags = function(dictionary) {
2060
2064
  });
2061
2065
 
2062
2066
  dictionary.defineTag('slot', {
2063
- mustNotHaveValue: true,
2064
2067
  onTagged: function(doclet, tag) {
2065
2068
  doclet.slot = true;
2069
+ if (tag.value) {
2070
+ doclet.propertyName = tag.value;
2071
+ }
2066
2072
  }
2067
2073
  });
2068
2074
 
@@ -2079,6 +2085,20 @@ exports.defineTags = function(dictionary) {
2079
2085
  doclet.tagname = tag.value;
2080
2086
  }
2081
2087
  });
2088
+
2089
+ dictionary.defineTag('allowPreventDefault', {
2090
+ mustHaveValue: false,
2091
+ onTagged: function(doclet, tag) {
2092
+ doclet.allowPreventDefault = true;
2093
+ }
2094
+ });
2095
+
2096
+ dictionary.defineTag('native', {
2097
+ mustHaveValue: false,
2098
+ onTagged: function(doclet, tag) {
2099
+ doclet.native = true;
2100
+ }
2101
+ });
2082
2102
  };
2083
2103
 
2084
2104
  exports.handlers = {
@@ -2838,6 +2838,9 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
2838
2838
  if (member.slot) {
2839
2839
  tag("property");
2840
2840
  attrib("name", member.name);
2841
+ if (member.propertyName) {
2842
+ attrib("propertyName", member.propertyName);
2843
+ }
2841
2844
  if (member.__ui5.module && member.__ui5.module !== symbol.__ui5.module) {
2842
2845
  attrib("module", member.__ui5.module);
2843
2846
  attrib("export", undefined, '', true);
@@ -2879,6 +2882,12 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
2879
2882
  attrib("module", member.__ui5.module);
2880
2883
  attrib("export", undefined, '', true);
2881
2884
  }
2885
+ if (member.allowPreventDefault) {
2886
+ attrib("allowPreventDefault", true);
2887
+ }
2888
+ if (member.native) {
2889
+ attrib("native", true);
2890
+ }
2882
2891
  attrib("visibility", visibility(member), 'public');
2883
2892
  if ( member.scope === 'static' ) {
2884
2893
  attrib("static", true, false, /* raw = */true);
@@ -0,0 +1,5 @@
1
+ const mkdirp = require("mkdirp");
2
+ const fs = require("fs");
3
+
4
+ mkdirp.sync("dist/webcomponentsjs/");
5
+ fs.writeFileSync("dist/webcomponentsjs/webcomponents-loader.js", "");
@@ -1,4 +1,3 @@
1
- const postcss = require('postcss');
2
1
  const fs = require('fs');
3
2
  const path = require('path');
4
3
  const mkdirp = require('mkdirp');
@@ -7,13 +6,13 @@ const assets = require("../../assets-meta.js");
7
6
  const DEFAULT_THEME = assets.themes.default;
8
7
 
9
8
  const getDefaultThemeCode = packageName => {
10
- return `import { registerThemeProperties } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
9
+ return `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
11
10
 
12
- import defaultThemeBase from "@ui5/webcomponents-theme-base/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
11
+ import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
13
12
  import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
14
13
 
15
- registerThemeProperties("@ui5/webcomponents-theme-base", "${DEFAULT_THEME}", defaultThemeBase);
16
- registerThemeProperties("${packageName}", "${DEFAULT_THEME}", defaultTheme);
14
+ registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", () => defaultThemeBase);
15
+ registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", () => defaultTheme);
17
16
  `;
18
17
  };
19
18
 
@@ -25,18 +24,22 @@ const proccessCSS = css => {
25
24
  return JSON.stringify(css);
26
25
  }
27
26
 
28
- module.exports = postcss.plugin('add css to esm transform plugin', function (opts) {
27
+ module.exports = function (opts) {
29
28
  opts = opts || {};
30
29
 
31
- return function (root) {
32
- let css = root.toString();
33
- css = proccessCSS(css);
30
+ return {
31
+ postcssPlugin: 'postcss-css-to-esm',
32
+ Once (root) {
33
+ let css = root.toString();
34
+ css = proccessCSS(css);
34
35
 
35
- const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
36
- mkdirp.sync(path.dirname(targetFile));
36
+ const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
37
+ mkdirp.sync(path.dirname(targetFile));
37
38
 
38
- const filePath = `${targetFile}.js`;
39
- const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
40
- fs.writeFileSync(filePath, `${defaultTheme}export default ${css};`);
41
- }
42
- });
39
+ const filePath = `${targetFile}.js`;
40
+ const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
41
+ fs.writeFileSync(filePath, `${defaultTheme}export default {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`);
42
+ }
43
+ };
44
+ };
45
+ module.exports.postcss = true;
@@ -1,4 +1,3 @@
1
- const postcss = require('postcss');
2
1
  const fs = require('fs');
3
2
  const path = require('path');
4
3
  const mkdirp = require('mkdirp');
@@ -11,17 +10,27 @@ const proccessCSS = css => {
11
10
  return css;
12
11
  }
13
12
 
14
- module.exports = postcss.plugin('add css to JSON transform plugin', function (opts) {
13
+ module.exports = function (opts) {
15
14
  opts = opts || {};
16
15
 
17
- return function (root) {
18
- let css = root.toString();
19
- css = proccessCSS(css);
16
+ return {
17
+ postcssPlugin: 'postcss-css-to-json',
18
+ Once (root) {
19
+ let css = root.toString();
20
+ css = proccessCSS(css);
20
21
 
21
- const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\assets\\");
22
- mkdirp.sync(path.dirname(targetFile));
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));
23
24
 
24
- const filePath = `${targetFile}.json`;
25
- fs.writeFileSync(filePath, JSON.stringify({_: css}));
26
- }
27
- });
25
+ const filePath = `${targetFile}.json`;
26
+ const data = {
27
+ packageName: opts.packageName,
28
+ fileName: targetFile.substr(targetFile.lastIndexOf("themes")),
29
+ content: css
30
+ };
31
+ fs.writeFileSync(filePath, JSON.stringify({_: data}));
32
+ }
33
+ };
34
+ };
35
+
36
+ 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,20 @@
1
+ const fs = require("fs");
2
+ const glob = require("glob");
3
+
4
+ const basePath = process.argv[2];
5
+
6
+ const replaceGlobalCoreUsage = (srcPath) => {
7
+
8
+ const original = fs.readFileSync(srcPath).toString();
9
+ let replaced = original.replace(/sap\.ui\.getCore\(\)/g, `Core`);
10
+
11
+ if (original !== replaced) {
12
+ replaced = `import Core from 'sap/ui/core/Core';
13
+ ${replaced}`;
14
+ fs.writeFileSync(srcPath, replaced);
15
+ }
16
+ };
17
+
18
+ const fileNames = glob.sync(basePath + "**/*.js");
19
+ fileNames.forEach(replaceGlobalCoreUsage);
20
+ console.log("Success: Replaced global core usage in:", basePath);
@@ -10,7 +10,7 @@ const errors = [];
10
10
  glob.sync(path.join(process.cwd(), "src/**/*.css")).forEach(file => {
11
11
  let content = String(fs.readFileSync(file));
12
12
  tags.forEach(tag => {
13
- if (content.match(new RegExp(`(^|[^\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
13
+ if (content.match(new RegExp(`(^|[^\.\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
14
14
  errors.push(`Warning! ${tag} found in ${file}`);
15
15
  }
16
16
  });
@@ -0,0 +1,46 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const commandLineArgs = require("command-line-args");
4
+ const { exec } = require("child_process");
5
+ const colors = require("colors/safe");
6
+ const isPortReachable = require("is-port-reachable");
7
+
8
+ const options = commandLineArgs([
9
+ { name: "port", type: Number },
10
+ { name: "portStep", type: Number },
11
+ { name: "packageName", type: String },
12
+ { name: "dir", type: String },
13
+ { name: "config", type: String },
14
+ ]);
15
+ const serveConfig = path.join(__dirname, `serve.json`);
16
+
17
+ const requestPort = async () => {
18
+ const serveProcess = (await gen.next()).value;
19
+ serveProcess.stdout.on('data', data => {
20
+ const matches = data.match(/Accepting connections at .*?:(\d+)/);
21
+ if (matches) {
22
+ console.log(colors.yellow(`Reserved port ${matches[1]} for the ${options.packageName} package.`));
23
+ fs.writeFileSync(".port", matches[1]);
24
+ }
25
+ });
26
+ };
27
+
28
+ async function* serverGenerator(callback, port = 8080, step = 1) {
29
+ while (true) {
30
+ const portInUse = await isPortReachable(port, { host: "127.0.0.1" });
31
+ if (!portInUse) {
32
+ const command = `serve --config "${serveConfig}" --no-port-switching --no-clipboard -l ${port} ${options.dir}`;
33
+ console.log(colors.yellow(`Executing: ${command}`));
34
+ const serveProcess = exec(command, (err) => {
35
+ console.log(colors.yellow(`Port ${port} already in use.`));
36
+ callback();
37
+ });
38
+ yield serveProcess;
39
+ }
40
+ port += step;
41
+ }
42
+ }
43
+
44
+ const gen = serverGenerator(requestPort, options.port, options.portStep);
45
+
46
+ requestPort();
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "1.0.0-rc.9",
3
+ "version": "1.1.0",
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,62 +21,62 @@
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
- "@rollup/plugin-babel": "^5.2.1",
30
- "@rollup/plugin-node-resolve": "^9.0.0",
31
- "@rollup/plugin-url": "^5.0.1",
32
- "@wdio/cli": "^6.1.3",
33
- "@wdio/dot-reporter": "^6.0.16",
34
- "@wdio/local-runner": "^6.1.3",
35
- "@wdio/mocha-framework": "^6.1.0",
36
- "@wdio/spec-reporter": "^6.0.16",
37
- "@wdio/sync": "^6.1.0",
38
- "@webcomponents/webcomponentsjs": "^2.4.0",
39
- "chai": "^4.2.0",
40
- "chokidar-cli": "^2.0.0",
41
- "clean-css": "^4.2.1",
24
+ "@babel/core": "^7.13.10",
25
+ "@babel/preset-env": "^7.13.10",
26
+ "@openui5/sap.ui.core": "1.95.0",
27
+ "@rollup/plugin-babel": "^5.3.0",
28
+ "@rollup/plugin-commonjs": "^21.0.1",
29
+ "@rollup/plugin-json": "^4.1.0",
30
+ "@rollup/plugin-node-resolve": "^13.0.5",
31
+ "@rollup/plugin-replace": "^3.0.0",
32
+ "@rollup/plugin-url": "^6.0.0",
33
+ "@wdio/cli": "^7.12.2",
34
+ "@wdio/dot-reporter": "^7.10.1",
35
+ "@wdio/local-runner": "^7.12.2",
36
+ "@wdio/mocha-framework": "^7.12.2",
37
+ "@wdio/spec-reporter": "^7.10.1",
38
+ "@webcomponents/webcomponentsjs": "^2.5.0",
39
+ "chai": "^4.3.4",
40
+ "child_process": "^1.0.2",
41
+ "chokidar": "^3.5.1",
42
+ "chokidar-cli": "^3.0.0",
43
+ "colors": "^1.4.0",
42
44
  "command-line-args": "^5.1.1",
43
- "concurrently": "^5.0.0",
44
- "cross-env": "^5.2.0",
45
- "cssnano": "^4.1.10",
46
- "escodegen": "^1.11.0",
47
- "eslint": "^5.10.0",
48
- "eslint-config-airbnb-base": "^13.1.0",
49
- "eslint-plugin-import": "^2.14.0",
45
+ "concurrently": "^6.0.0",
46
+ "cross-env": "^7.0.3",
47
+ "cssnano": "^4.1.11",
48
+ "escodegen": "^2.0.0",
49
+ "eslint": "^7.22.0",
50
+ "eslint-config-airbnb-base": "^14.2.1",
51
+ "eslint-plugin-import": "^2.22.1",
50
52
  "esprima": "^4.0.1",
51
- "getopts": "^2.2.3",
52
- "glob": "^7.1.3",
53
- "handlebars": "^4.7.6",
54
- "jsdoc": "^3.6.3",
53
+ "folder-hash": "^4.0.1",
54
+ "getopts": "^2.3.0",
55
+ "glob": "^7.1.6",
56
+ "glob-parent": "^6.0.2",
57
+ "handlebars": "^4.7.7",
58
+ "is-port-reachable": "^3.1.0",
59
+ "jsdoc": "^3.6.6",
55
60
  "json-beautify": "^1.1.1",
56
- "mkdirp": "^0.5.1",
57
- "npm-run-all": "^4.1.3",
58
- "nps": "^5.9.8",
59
- "postcss": "^7.0.18",
60
- "postcss-cli": "^6.1.3",
61
- "postcss-combine-duplicated-selectors": "^7.0.0",
62
- "postcss-import": "^12.0.1",
63
- "properties-reader": "^0.3.1",
64
- "puppeteer": "^1.11.0",
61
+ "mkdirp": "^1.0.4",
62
+ "nps": "^5.10.0",
63
+ "postcss": "^8.2.10",
64
+ "postcss-cli": "^9.0.1",
65
+ "postcss-combine-duplicated-selectors": "^10.0.3",
66
+ "postcss-import": "^14.0.0",
67
+ "properties-reader": "^2.2.0",
65
68
  "recursive-readdir": "^2.2.2",
66
- "rimraf": "^2.6.2",
67
- "rollup": "^2.28.2",
68
- "rollup-plugin-filesize": "^6.0.1",
69
- "rollup-plugin-livereload": "^1.0.4",
70
- "rollup-plugin-notify": "^1.1.0",
71
- "rollup-plugin-string": "^2.0.2",
69
+ "resolve": "^1.20.0",
70
+ "rimraf": "^3.0.2",
71
+ "rollup": "^2.41.4",
72
+ "rollup-plugin-filesize": "^9.1.1",
73
+ "rollup-plugin-livereload": "^2.0.0",
72
74
  "rollup-plugin-terser": "^7.0.2",
73
- "rollup-plugin-visualizer": "^0.9.2",
74
- "serve": "^10.1.1",
75
- "wdio-chromedriver-service": "^6.0.2"
75
+ "serve": "^12.0.0",
76
+ "slash": "3.0.0",
77
+ "wdio-chromedriver-service": "^7.0.0"
76
78
  },
77
79
  "peerDependencies": {
78
80
  "chromedriver": "*"
79
- },
80
- "resolutions": {
81
- "rollup-plugin-livereload/livereload/chokidar": "^3.x"
82
81
  }
83
- }
82
+ }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../lib/init-package/index.js");