@ui5/webcomponents-tools 0.0.0-b6f02e4b3 → 0.0.0-b93bc8b37

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 (52) hide show
  1. package/CHANGELOG.md +277 -0
  2. package/README.md +5 -6
  3. package/bin/dev.js +1 -5
  4. package/components-package/eslint.js +34 -0
  5. package/components-package/nps.js +85 -45
  6. package/components-package/postcss.components.js +13 -13
  7. package/components-package/postcss.themes.js +15 -15
  8. package/components-package/vite.config.js +13 -0
  9. package/components-package/wdio.js +393 -369
  10. package/components-package/wdio.sync.js +1 -1
  11. package/icons-collection/nps.js +6 -3
  12. package/lib/copy-and-watch/index.js +0 -1
  13. package/lib/copy-list/index.js +2 -2
  14. package/lib/create-icons/index.js +58 -10
  15. package/lib/create-new-component/index.js +71 -104
  16. package/lib/create-new-component/jsFileContentTemplate.js +73 -0
  17. package/lib/create-new-component/tsFileContentTemplate.js +80 -0
  18. package/lib/dev-server/dev-server.js +66 -0
  19. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  20. package/lib/esm-abs-to-rel/index.js +1 -1
  21. package/lib/generate-custom-elements-manifest/index.js +327 -0
  22. package/lib/generate-js-imports/illustrations.js +72 -0
  23. package/lib/generate-json-imports/themes.js +3 -3
  24. package/lib/hbs2lit/src/compiler.js +8 -0
  25. package/lib/hbs2lit/src/litVisitor2.js +46 -8
  26. package/lib/i18n/defaults.js +18 -2
  27. package/lib/i18n/toJSON.js +1 -1
  28. package/lib/jsdoc/configTypescript.json +29 -0
  29. package/lib/jsdoc/plugin.js +32 -0
  30. package/lib/jsdoc/preprocess.js +146 -0
  31. package/lib/jsdoc/template/publish.js +9 -1
  32. package/lib/postcss-css-to-esm/index.js +51 -6
  33. package/lib/postcss-css-to-json/index.js +12 -1
  34. package/lib/postcss-p/postcss-p.mjs +3 -0
  35. package/lib/replace-global-core/index.js +1 -1
  36. package/lib/scoping/get-all-tags.js +1 -8
  37. package/lib/scoping/scope-test-pages.js +1 -1
  38. package/lib/test-runner/test-runner.js +71 -0
  39. package/package.json +23 -16
  40. package/components-package/rollup-plugins/empty-module.js +0 -15
  41. package/components-package/rollup.js +0 -150
  42. package/lib/documentation/index.js +0 -168
  43. package/lib/documentation/templates/api-component-since.js +0 -3
  44. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  45. package/lib/documentation/templates/api-events-section.js +0 -35
  46. package/lib/documentation/templates/api-methods-section.js +0 -26
  47. package/lib/documentation/templates/api-properties-section.js +0 -42
  48. package/lib/documentation/templates/api-slots-section.js +0 -28
  49. package/lib/documentation/templates/template.js +0 -39
  50. package/lib/serve/index.js +0 -46
  51. package/lib/serve/serve.json +0 -3
  52. package/package-lock.json +0 -48
@@ -0,0 +1,146 @@
1
+ const process = require("process");
2
+ const path = require("path");
3
+ const fs = require("fs/promises");
4
+
5
+ const inputDir = process.argv[2];
6
+ const sourceDir = process.argv[3];
7
+
8
+ const preprocessTypes = async () => {
9
+ try {
10
+ const { globby } = await import("globby");
11
+ const fileNames = await globby(inputDir.replace(/\\/g, "/") + "**/types/*.js");
12
+
13
+ return Promise.all(fileNames.map(processTypeFile));
14
+ } catch(e) {
15
+ console.log("JSDoc types preprocess failed: ", e);
16
+ }
17
+ };
18
+
19
+ const processTypeFile = async (fileName) => {
20
+ let fileContent = `${await fs.readFile(fileName)}`;
21
+
22
+ const re = new RegExp(`(\\/\\*\\*\\s*\\n([^\\*]|(\\*(?!\\/)))*\\*\\/)\\s+[\\w\\d]+\\[\\"([\\w\\d]+)\\"\\]\\s*=\\s*\\"([\\w\\d]+)\\";`, "gm")
23
+ let matches = [...fileContent.matchAll(re)];
24
+
25
+ // Get all type values
26
+ const typeData = matches.map(match => {
27
+ return {
28
+ comment: match[1],
29
+ key: match[4],
30
+ value: match[5],
31
+ };
32
+ });
33
+ if (typeData.length === 0) {
34
+ return;
35
+ }
36
+
37
+ const typeName = path.parse(fileName).name;
38
+
39
+ matches = fileContent.match(/\/\*\*\s*\n([^\*]|(\*(?!\/)))*\*\//gm);
40
+ const comment = matches[0];
41
+
42
+ const propsCode = typeData.map(item => {
43
+ return `${item.comment}\n get ${item.key}() { return "${item.value}"; }`;
44
+ }).join("\n");
45
+
46
+ const newClassCode = `
47
+ ${comment}
48
+ class ${typeName} {
49
+ ${propsCode}
50
+ };
51
+
52
+ export default ${typeName};`;
53
+
54
+ fileContent = newClassCode;
55
+
56
+ return fs.writeFile(fileName, fileContent);
57
+ };
58
+
59
+ const preprocessComponents = async () => {
60
+ if (!sourceDir) {
61
+ return; // if the second param was not passed, there are no components
62
+ }
63
+
64
+ try {
65
+ const { globby } = await import("globby");
66
+ const fileNames = await globby(sourceDir.replace(/\\/g, "/") + "/*.ts");
67
+
68
+ return Promise.all(fileNames.map(processComponentFile));
69
+ } catch(e) {
70
+ console.log("JSDoc components preprocess failed: ", e);
71
+ }
72
+ };
73
+
74
+ const isClass = text => {
75
+ return text.includes("@abstract") || text.includes("@class");
76
+ };
77
+
78
+ const isAnnotationComment = (comment) => {
79
+ return comment.includes("@name");
80
+ }
81
+
82
+ const processComponentFile = async (fileName) => {
83
+ // source file (src/*.ts)
84
+ let tsFileContent = `${await fs.readFile(fileName)}`;
85
+
86
+ // Skip all non-component files
87
+ if (!isClass(tsFileContent)) {
88
+ return;
89
+ }
90
+
91
+ // Gather all JSDocs from the original .ts file
92
+ const allJSDocsRegExp = new RegExp(`\\/\\*\\*(.|\\n)+?\\s+\\*\\/`, "gm");
93
+ let allJSDocs = [...tsFileContent.matchAll(allJSDocsRegExp)];
94
+ allJSDocs = allJSDocs.map(match => match[0]); // all /** ..... */ comments
95
+
96
+ // Find where the class is defined in the original file
97
+ const tsClassDefinitionRegExp = new RegExp(`^(abstract\\s)?class [\\w\\d_]+`, "gm");
98
+ let tsClassDefinitionMatch = tsFileContent.match(tsClassDefinitionRegExp);
99
+ if (!tsClassDefinitionMatch) {
100
+ return; // no class defined in this .ts file
101
+ }
102
+ const tsClassDefinition = tsClassDefinitionMatch[0];
103
+ const tsClassDefinitionIndex = tsFileContent.indexOf(tsClassDefinition);
104
+
105
+ // Gather all JSDocs that are before the class definition (except for the @class one)
106
+ const JSDocsToAppend = [];
107
+ allJSDocs.forEach(JSDoc => {
108
+ if (!isClass(JSDoc) && (tsFileContent.indexOf(JSDoc) < tsClassDefinitionIndex || isAnnotationComment(JSDoc, tsFileContent))) {
109
+ JSDocsToAppend.push(JSDoc);
110
+ }
111
+ });
112
+
113
+
114
+
115
+ // destination file (jsdoc-dist/*.js)
116
+ const destFileName = fileName.replace(sourceDir, inputDir).replace(/\.ts$/, ".js");
117
+ let jsFileContent = `${await fs.readFile(destFileName)}`;
118
+
119
+ const classDefinitionRegExp = new RegExp(`let.*? = class`, "gm");
120
+ let classDefinitionMatch = jsFileContent.match(classDefinitionRegExp);
121
+ if (!classDefinitionMatch) {
122
+ return; // not a file, generated by typescript, nothing to do here
123
+ }
124
+
125
+ const classDefinition = classDefinitionMatch[0];
126
+ const classDefinitionIndex = jsFileContent.indexOf(classDefinition); // classDefinitionIndex is the position in the file where the class is defined
127
+
128
+ // All comments before the class definition, except for the @class comment, must be removed
129
+ allJSDocs.forEach(JSDoc => {
130
+ if (!isClass(JSDoc) && jsFileContent.indexOf(JSDoc) < classDefinitionIndex) {
131
+ jsFileContent = jsFileContent.replace(JSDoc, "");
132
+ }
133
+ });
134
+
135
+ // Put all other comments at the end of the file
136
+ jsFileContent = jsFileContent + "\n\n" + JSDocsToAppend.join("\n\n");
137
+ return fs.writeFile(destFileName, jsFileContent);
138
+ };
139
+
140
+ Promise.all([
141
+ preprocessTypes(),
142
+ preprocessComponents(),
143
+ ]).then(() => {
144
+ console.log("JSDoc preprocess ready.");
145
+ });
146
+
@@ -2820,6 +2820,14 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
2820
2820
  attrib("since", extractVersion(member.since));
2821
2821
  }
2822
2822
 
2823
+ if ( member.formEvents ) {
2824
+ attrib("formEvents", member.formEvents);
2825
+ }
2826
+
2827
+ if ( member.formEvents ) {
2828
+ attrib("formProperty", member.formProperty);
2829
+ }
2830
+
2823
2831
  var type = listTypes(member.type);
2824
2832
  attrib("type", type);
2825
2833
 
@@ -3865,7 +3873,7 @@ function createAPIJS(symbols, filename) {
3865
3873
 
3866
3874
  var output = [];
3867
3875
 
3868
- var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|noattribute|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
3876
+ var rkeywords = /^(?:abstract|as|boolean|break|byte|case|catch|char|class|continue|const|debugger|default|delete|do|double|else|enum|export|extends|false|final|finally|float|for|function|formEvents|formProperty|goto|if|implements|import|in|instanceof|int|interface|is|long|namespace|native|new|null|noattribute|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
3869
3877
 
3870
3878
  function isNoKeyword($) { return !rkeywords.test($.name); }
3871
3879
 
@@ -11,11 +11,38 @@ const getDefaultThemeCode = packageName => {
11
11
  import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
12
12
  import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
13
13
 
14
- registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", () => defaultThemeBase);
15
- registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", () => defaultTheme);
14
+ registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", async () => defaultThemeBase);
15
+ registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", async () => defaultTheme);
16
16
  `;
17
17
  };
18
18
 
19
+ const getFileContent = (tsMode, targetFile, packageName, css, includeDefaultTheme) => {
20
+ if (tsMode) {
21
+ return getTSContent(targetFile, packageName, css, includeDefaultTheme);
22
+ }
23
+
24
+ return getJSContent(targetFile, packageName, css, includeDefaultTheme);
25
+ }
26
+
27
+ const getTSContent = (targetFile, packageName, css, includeDefaultTheme) => {
28
+ const typeImport = "import type { StyleData } from \"@ui5/webcomponents-base/dist/types.js\";"
29
+ const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
30
+
31
+ // tabs are intentionally mixed to have proper identation in the produced file
32
+ return `${typeImport}
33
+ ${defaultTheme}
34
+ const styleData: StyleData = {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}};
35
+ export default styleData;
36
+ `;
37
+ }
38
+
39
+ const getJSContent = (targetFile, packageName, css, includeDefaultTheme) => {
40
+ const defaultTheme = includeDefaultTheme ? getDefaultThemeCode(packageName) : "";
41
+
42
+ return `${defaultTheme}export default {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
43
+ }
44
+
45
+
19
46
  const proccessCSS = css => {
20
47
  css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
21
48
  css = css.replace(/\.background-image.*{.*}/, "");
@@ -27,18 +54,36 @@ const proccessCSS = css => {
27
54
  module.exports = function (opts) {
28
55
  opts = opts || {};
29
56
 
57
+ const packageName = opts.packageName;
58
+ const includeDefaultTheme = opts.includeDefaultTheme;
59
+ const toReplace = opts.toReplace;
60
+
30
61
  return {
31
62
  postcssPlugin: 'postcss-css-to-esm',
32
63
  Once (root) {
64
+ const tsMode = process.env.UI5_TS === "true";
65
+
33
66
  let css = root.toString();
34
67
  css = proccessCSS(css);
35
68
 
36
- const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
69
+ const targetFile = root.source.input.from.replace(`/${toReplace}/`, "/src/generated/").replace(`\\${toReplace}\\`, "\\src\\generated\\");
37
70
  mkdirp.sync(path.dirname(targetFile));
38
71
 
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}}`);
72
+ const filePath = `${targetFile}.${tsMode ? "ts" : "js"}`;
73
+
74
+ // it seems slower to read the old content, but writing the same content with no real changes
75
+ // (as in initial build and then watch mode) will cause an unnecessary dev server refresh
76
+ let oldContent = "";
77
+ try {
78
+ oldContent = fs.readFileSync(filePath).toString();
79
+ } catch (e) {
80
+ // file not found
81
+ }
82
+
83
+ const content = getFileContent(tsMode, targetFile, packageName, css, includeDefaultTheme);
84
+ if (content !== oldContent) {
85
+ fs.writeFileSync(filePath, content);
86
+ }
42
87
  }
43
88
  };
44
89
  };
@@ -28,7 +28,18 @@ module.exports = function (opts) {
28
28
  fileName: targetFile.substr(targetFile.lastIndexOf("themes")),
29
29
  content: css
30
30
  };
31
- fs.writeFileSync(filePath, JSON.stringify({_: data}));
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
+ }
32
43
  }
33
44
  };
34
45
  };
@@ -1,5 +1,8 @@
1
1
  import 'zx/globals';
2
2
 
3
+ // don't print executed commands and their output
4
+ $.verbose = false;
5
+
3
6
  const inputFiles = await globby("src/**/parameters-bundle.css");
4
7
 
5
8
  const restArgs = process.argv.slice(2);
@@ -16,7 +16,7 @@ const replaceGlobalCoreUsage = async (srcPath) => {
16
16
 
17
17
  const generate = async () => {
18
18
  const { globby } = await import("globby");
19
- const fileNames = await globby(basePath + "**/*.js");
19
+ const fileNames = await globby(basePath.replace(/\\/g, "/") + "**/*.js");
20
20
  return Promise.all(fileNames.map(replaceGlobalCoreUsage).filter(x => !!x));
21
21
  };
22
22
 
@@ -8,18 +8,11 @@ const getTag = file => {
8
8
  return matches ? matches[1] : undefined;
9
9
  };
10
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
11
  const getPackageTags = (packageDir) => {
18
12
  const srcDir = path.join(packageDir, "src/");
19
13
  return glob.sync(path.join(srcDir, "/**/*.js")).flatMap(file => {
20
14
  const tag = getTag(file);
21
- const altTag = getAltTag(file);
22
- return [tag, altTag];
15
+ return [tag];
23
16
  }).filter(item => !!item);
24
17
  };
25
18
 
@@ -27,7 +27,7 @@ const replaceTagsAny = content => {
27
27
  // Replace bundle names and HTML tag names in test pages
28
28
  glob.sync(path.join(root, "/**/*.html")).forEach(file => {
29
29
  let content = String(fs.readFileSync(file));
30
- content = content.replace(/bundle\.(.*?)\.js/g, `bundle.scoped.$1.js`);
30
+ content = content.replace(/bundle\.(.*?)\.js/g, `../bundle.scoped.$1.js`);
31
31
  content = replaceTagsHTML(content);
32
32
  fs.writeFileSync(file, content);
33
33
  });
@@ -0,0 +1,71 @@
1
+ const child_process = require("child_process");
2
+ const { readFileSync } = require("fs");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ // search for dev-server port
7
+ // start in current folder
8
+ // traversing upwards in case of mono repo tests and dev-server running in root folder of repository
9
+ let devServerFolder = process.cwd();
10
+ let devServerPort;
11
+ while (true) {
12
+ try {
13
+ devServerPort = readFileSync(path.join(devServerFolder, ".dev-server-port")).toString();
14
+ break; // found
15
+ } catch (e) {
16
+ // file not found
17
+ if (devServerFolder === path.dirname(devServerFolder)) {
18
+ break; // reached root folder "/"
19
+ }
20
+ devServerFolder = path.dirname(devServerFolder);
21
+ }
22
+ }
23
+
24
+ // check if we are in a monorepo and extract path from package.json
25
+ let packageRepositoryPath = "";
26
+ const pkg = require(path.join(process.cwd(), "package.json"));
27
+ packageRepositoryPath = pkg.repository ? pkg.repository.directory : "";
28
+
29
+ // construct base url
30
+ // use devServerPort if a dev server is running, otherwise let the baseUrl in the wdio config be used
31
+ // if a dev server is running in the root of a mono repo, append tha package path like this
32
+ // http://localhost:${devServerPort}/packages/main/
33
+ let baseUrl = "";
34
+ if (devServerPort) {
35
+ console.log(`Found port ${devServerPort} from '${path.join(devServerFolder, ".dev-server-port")}'`);
36
+ const devServerInRoot = !devServerFolder.includes(packageRepositoryPath);
37
+ if (devServerInRoot) {
38
+ baseUrl = `--base-url http://localhost:${devServerPort}/${packageRepositoryPath}/`;
39
+ } else {
40
+ baseUrl = `--base-url http://localhost:${devServerPort}/`;
41
+ }
42
+ }
43
+
44
+ if (!baseUrl) {
45
+ console.log("No dev server running, running tests served from `dist`, make sure it is up to date");
46
+ }
47
+
48
+ // add single spec parameter if passed
49
+ let spec = "";
50
+ if (process.argv.length === 3) {
51
+ const specFile = process.argv[2];
52
+ spec = `--spec ${specFile}`;
53
+ }
54
+
55
+ // more parameters - pass them to wdio
56
+ let restParams = "";
57
+ if (process.argv.length > 3) {
58
+ restParams = process.argv.slice(2).join(" ");
59
+ }
60
+
61
+ let wdioConfig = "";
62
+ if (fs.existsSync("config/wdio.conf.cjs")) {
63
+ wdioConfig = "config/wdio.conf.cjs";
64
+ } else if (fs.existsSync("config/wdio.conf.js")) {
65
+ wdioConfig = "config/wdio.conf.js";
66
+ }
67
+
68
+ // run wdio with calculated parameters
69
+ const cmd = `yarn cross-env WDIO_LOG_LEVEL=error wdio ${wdioConfig} ${spec} ${baseUrl} ${restParams}`;
70
+ console.log(`executing: ${cmd}`);
71
+ 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-b6f02e4b3",
3
+ "version": "0.0.0-b93bc8b37",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -21,19 +21,19 @@
21
21
  "directory": "packages/tools"
22
22
  },
23
23
  "dependencies": {
24
- "@rollup/plugin-json": "^4.1.0",
25
- "@rollup/plugin-node-resolve": "^13.0.5",
26
- "@rollup/plugin-replace": "^3.0.0",
27
- "@wdio/cli": "^7.12.2",
28
- "@wdio/dot-reporter": "^7.10.1",
29
- "@wdio/local-runner": "^7.12.2",
30
- "@wdio/mocha-framework": "^7.12.2",
31
- "@wdio/spec-reporter": "^7.10.1",
24
+ "@typescript-eslint/eslint-plugin": "^5.42.1",
25
+ "@typescript-eslint/parser": "^5.42.1",
26
+ "@wdio/cli": "^7.19.7",
27
+ "@wdio/devtools-service": "^7.19.7",
28
+ "@wdio/dot-reporter": "^7.19.7",
29
+ "@wdio/local-runner": "^7.19.7",
30
+ "@wdio/mocha-framework": "^7.19.7",
31
+ "@wdio/spec-reporter": "^7.19.7",
32
+ "@wdio/static-server-service": "^7.19.5",
32
33
  "chai": "^4.3.4",
33
34
  "child_process": "^1.0.2",
34
35
  "chokidar": "^3.5.1",
35
36
  "chokidar-cli": "^3.0.0",
36
- "cli-color": "^2.0.1",
37
37
  "command-line-args": "^5.1.1",
38
38
  "concurrently": "^6.0.0",
39
39
  "cross-env": "^7.0.3",
@@ -57,19 +57,26 @@
57
57
  "postcss-cli": "^9.1.0",
58
58
  "postcss-import": "^14.0.2",
59
59
  "postcss-selector-parser": "^6.0.10",
60
+ "prompts": "^2.4.2",
60
61
  "properties-reader": "^2.2.0",
61
62
  "recursive-readdir": "^2.2.2",
62
63
  "resolve": "^1.20.0",
63
64
  "rimraf": "^3.0.2",
64
- "rollup": "^2.41.4",
65
- "rollup-plugin-livereload": "^2.0.0",
66
- "rollup-plugin-terser": "^7.0.2",
67
- "serve": "^12.0.0",
68
65
  "slash": "3.0.0",
69
- "wdio-chromedriver-service": "^7.0.0",
66
+ "vite": "^3.0.4",
67
+ "wdio-chromedriver-service": "^7.3.2",
70
68
  "zx": "^4.3.0"
71
69
  },
72
70
  "peerDependencies": {
73
- "chromedriver": "*"
71
+ "chromedriver": "*",
72
+ "typescript": "^4.9.4"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "typescript": {
76
+ "optional": true
77
+ }
78
+ },
79
+ "devDependencies": {
80
+ "yargs": "^17.5.1"
74
81
  }
75
82
  }
@@ -1,15 +0,0 @@
1
- const slash = require("slash");
2
-
3
- function emptyModulePlugin({ emptyModules }) {
4
- return {
5
- name: "ui5-dev-empty-module-plugin",
6
- load(id) {
7
- if (emptyModules.some(mod => slash(id).includes(mod))) {
8
- return `export default ""`;
9
- }
10
- return null;
11
- },
12
- };
13
- }
14
-
15
- module.exports = emptyModulePlugin;
@@ -1,150 +0,0 @@
1
- const process = require("process");
2
- const fs = require("fs");
3
- const os = require("os");
4
- const { nodeResolve } = require("@rollup/plugin-node-resolve");
5
- const { terser } = require("rollup-plugin-terser");
6
- const json = require("@rollup/plugin-json");
7
- const replace = require("@rollup/plugin-replace");
8
- const colors = require("cli-color");
9
- const livereload = require("rollup-plugin-livereload");
10
- const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
11
-
12
- const packageFile = JSON.parse(fs.readFileSync("./package.json"));
13
- const packageName = packageFile.name;
14
-
15
- const warningsToSkip = [{
16
- warningCode: "THIS_IS_UNDEFINED",
17
- filePath: /.+zxing.+/,
18
- }];
19
-
20
- function ui5DevImportCheckerPlugin() {
21
- return {
22
- name: "ui5-dev-import-checker-plugin",
23
- transform(code, file) {
24
- const re = new RegExp(`^import.*"${packageName}/`);
25
- if (re.test(code)) {
26
- throw new Error(`illegal import in ${file}`);
27
- }
28
- },
29
- };
30
- }
31
-
32
- function onwarn(warning, warn) {
33
- // Skip warning for known false positives that will otherwise polute the log
34
- let skip = warningsToSkip.find(warningToSkip => {
35
- let loc, file;
36
- return warning.code === warningToSkip.warningCode
37
- && (loc = warning.loc)
38
- && (file = loc.file)
39
- && file.match(warningToSkip.filePath);
40
- });
41
- if (skip) {
42
- return;
43
- }
44
-
45
- // warn everything else
46
- warn( warning );
47
- }
48
-
49
- const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
50
- function ui5DevReadyMessagePlugin() {
51
- return {
52
- name: "ui5-dev-message-ready-plugin",
53
- writeBundle: (assets, bundle) => {
54
- if (reportedForPackages.has(packageName)) {
55
- return;
56
- }
57
- console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
58
-
59
- if (fs.existsSync(".port")) {
60
- const port = `${fs.readFileSync(".port")}`;
61
- if (port) {
62
- console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
63
- }
64
- }
65
- reportedForPackages.add(packageName);
66
- },
67
- };
68
- }
69
-
70
- const getPlugins = () => {
71
- const plugins = [];
72
-
73
- if (process.env.DEV) {
74
- plugins.push(replace({
75
- values: {
76
- 'const DEV_MODE = false': 'const DEV_MODE = true',
77
- },
78
- preventAssignment: false,
79
- }));
80
- }
81
-
82
- if (process.env.DEV && !process.env.ENABLE_CLDR) {
83
- // Empty the CLDR assets file for better performance during development
84
- plugins.push(emptyModulePlugin({
85
- emptyModules: [
86
- "localization/dist/Assets.js",
87
- ],
88
- }));
89
- }
90
-
91
- plugins.push(ui5DevImportCheckerPlugin());
92
-
93
- plugins.push(json({
94
- include: [
95
- /.*assets\/.*\.json/,
96
- ],
97
- namedExports: false,
98
- }));
99
-
100
- plugins.push(nodeResolve());
101
-
102
- if (!process.env.DEV) {
103
- plugins.push(terser({
104
- numWorkers: 1,
105
- }));
106
- }
107
-
108
- const es6DevMain = process.env.DEV && packageName === "@ui5/webcomponents";
109
- if (es6DevMain && os.platform() !== "win32") {
110
- plugins.push(livereload({
111
- watch: [
112
- "dist/resources/bundle.esm.js",
113
- "dist/**/*.html",
114
- "dist/**/*.json",
115
- ],
116
- }));
117
- }
118
-
119
- if (process.env.DEV) {
120
- plugins.push(ui5DevReadyMessagePlugin());
121
- }
122
-
123
- return plugins;
124
- };
125
-
126
- const getES6Config = (input = "bundle.esm.js") => {
127
- return [{
128
- input,
129
- output: {
130
- dir: "dist/resources",
131
- format: "esm",
132
- sourcemap: true,
133
- },
134
- watch: {
135
- clearScreen: false,
136
- },
137
- plugins: getPlugins(),
138
- onwarn: onwarn,
139
- }];
140
- };
141
-
142
- let config = getES6Config();
143
-
144
- if (process.env.SCOPE) {
145
- if (fs.existsSync("bundle.scoped.esm.js")) {
146
- config = config.concat(getES6Config("bundle.scoped.esm.js"));
147
- }
148
- }
149
-
150
- module.exports = config;