@ui5/webcomponents-tools 0.0.0-dc606098a → 0.0.0-ddc5fe31b
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 +908 -0
- package/README.md +6 -6
- package/assets-meta.js +29 -3
- package/bin/dev.js +12 -1
- package/components-package/eslint.js +36 -0
- package/components-package/nps.js +119 -44
- 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 +405 -297
- package/components-package/wdio.sync.js +368 -0
- package/icons-collection/nps.js +55 -12
- package/lib/amd-to-es6/index.js +104 -0
- package/lib/cem/custom-elements-manifest.config.mjs +482 -0
- package/lib/cem/event.mjs +131 -0
- package/lib/cem/schema-internal.json +1357 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +802 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +379 -0
- package/lib/cem/validate.js +65 -0
- package/lib/copy-and-watch/index.js +145 -0
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +124 -54
- package/lib/create-illustrations/index.js +165 -0
- package/lib/create-new-component/index.js +72 -93
- package/lib/create-new-component/jsFileContentTemplate.js +73 -0
- 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 +79 -0
- package/lib/css-processors/scope-variables.mjs +46 -0
- package/lib/css-processors/shared.mjs +76 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.js +66 -0
- package/lib/dev-server/virtual-index-html-plugin.js +52 -0
- package/lib/generate-custom-elements-manifest/index.js +271 -0
- package/lib/generate-js-imports/illustrations.js +86 -0
- package/lib/generate-json-imports/i18n.js +80 -30
- package/lib/generate-json-imports/themes.js +70 -18
- 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 +35 -7
- package/lib/hbs2ui5/index.js +69 -30
- package/lib/i18n/defaults.js +65 -57
- package/lib/i18n/toJSON.js +13 -12
- package/lib/jsdoc/config.json +1 -1
- package/lib/jsdoc/configTypescript.json +29 -0
- package/lib/jsdoc/plugin.js +65 -4
- package/lib/jsdoc/preprocess.js +146 -0
- package/lib/jsdoc/template/publish.js +32 -4
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/scoping/get-all-tags.js +37 -0
- package/lib/scoping/lint-src.js +31 -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 +55 -54
- 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 -5
- 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/postcss-css-to-esm/index.js +0 -42
- package/lib/postcss-css-to-json/index.js +0 -27
@@ -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,41 @@
|
|
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
|
+
console.log(tags.length);
|
22
|
+
tags.forEach(tag => {
|
23
|
+
content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
|
24
|
+
});
|
25
|
+
return content;
|
26
|
+
};
|
27
|
+
|
28
|
+
// Replace bundle names and HTML tag names in test pages
|
29
|
+
glob.sync(path.join(root, "/**/*.html")).forEach(file => {
|
30
|
+
let content = String(fs.readFileSync(file));
|
31
|
+
content = content.replace("%VITE_BUNDLE_PATH%", "%VITE_BUNDLE_PATH_SCOPED%");
|
32
|
+
content = replaceTagsHTML(content);
|
33
|
+
fs.writeFileSync(file, content);
|
34
|
+
});
|
35
|
+
|
36
|
+
// Replace tag names everywhere
|
37
|
+
glob.sync(path.join(root, "/**/*.{html,css,js}")).forEach(file => {
|
38
|
+
let content = String(fs.readFileSync(file));
|
39
|
+
content = replaceTagsAny(content);
|
40
|
+
fs.writeFileSync(file, content);
|
41
|
+
});
|
@@ -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-
|
3
|
+
"version": "0.0.0-ddc5fe31b",
|
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,60 +21,62 @@
|
|
22
21
|
"directory": "packages/tools"
|
23
22
|
},
|
24
23
|
"dependencies": {
|
25
|
-
"@
|
26
|
-
"@
|
27
|
-
"@
|
28
|
-
"@
|
29
|
-
"@wdio/
|
30
|
-
"@wdio/
|
31
|
-
"@wdio/
|
32
|
-
"@wdio/
|
33
|
-
"@wdio/
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"chokidar
|
38
|
-
"
|
39
|
-
"clean-css": "^4.2.1",
|
24
|
+
"@custom-elements-manifest/analyzer": "^0.8.4",
|
25
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
26
|
+
"@typescript-eslint/parser": "^6.9.0",
|
27
|
+
"@wdio/cli": "^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",
|
33
|
+
"ajv": "^8.12.0",
|
34
|
+
"chai": "^4.3.4",
|
35
|
+
"child_process": "^1.0.2",
|
36
|
+
"chokidar": "^3.5.1",
|
37
|
+
"chokidar-cli": "^3.0.0",
|
40
38
|
"command-line-args": "^5.1.1",
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"cross-env": "^
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"eslint": "^
|
47
|
-
"eslint-
|
48
|
-
"eslint-plugin-import": "^2.14.0",
|
39
|
+
"comment-parser": "^1.4.0",
|
40
|
+
"concurrently": "^6.0.0",
|
41
|
+
"cross-env": "^7.0.3",
|
42
|
+
"escodegen": "^2.0.0",
|
43
|
+
"eslint": "^7.22.0",
|
44
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
45
|
+
"eslint-plugin-import": "^2.22.1",
|
49
46
|
"esprima": "^4.0.1",
|
50
|
-
"getopts": "^2.
|
51
|
-
"glob": "^7.1.
|
52
|
-
"
|
53
|
-
"
|
47
|
+
"getopts": "^2.3.0",
|
48
|
+
"glob": "^7.1.6",
|
49
|
+
"glob-parent": "^6.0.2",
|
50
|
+
"globby": "^13.1.1",
|
51
|
+
"handlebars": "^4.7.7",
|
52
|
+
"is-port-reachable": "^3.1.0",
|
53
|
+
"jsdoc": "^3.6.6",
|
54
54
|
"json-beautify": "^1.1.1",
|
55
|
-
"mkdirp": "^0.
|
56
|
-
"
|
57
|
-
"
|
58
|
-
"postcss": "^
|
59
|
-
"postcss-
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"rimraf": "^
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"rollup-plugin-livereload": "^1.0.4",
|
69
|
-
"rollup-plugin-node-resolve": "^4.0.0",
|
70
|
-
"rollup-plugin-notify": "^1.1.0",
|
71
|
-
"rollup-plugin-string": "^2.0.2",
|
72
|
-
"rollup-plugin-terser": "^5.1.3",
|
73
|
-
"rollup-plugin-url": "^2.2.0",
|
74
|
-
"rollup-plugin-visualizer": "^0.9.2",
|
75
|
-
"serve": "^10.1.1",
|
76
|
-
"wdio-chromedriver-service": "^6.0.2"
|
55
|
+
"mkdirp": "^1.0.4",
|
56
|
+
"nps": "^5.10.0",
|
57
|
+
"postcss": "^8.4.5",
|
58
|
+
"postcss-cli": "^9.1.0",
|
59
|
+
"postcss-selector-parser": "^6.0.10",
|
60
|
+
"prompts": "^2.4.2",
|
61
|
+
"properties-reader": "^2.2.0",
|
62
|
+
"recursive-readdir": "^2.2.2",
|
63
|
+
"resolve": "^1.20.0",
|
64
|
+
"rimraf": "^3.0.2",
|
65
|
+
"slash": "3.0.0",
|
66
|
+
"vite": "^4.4.9",
|
67
|
+
"wdio-chromedriver-service": "^7.3.2"
|
77
68
|
},
|
78
|
-
"
|
79
|
-
"
|
69
|
+
"peerDependencies": {
|
70
|
+
"chromedriver": "*",
|
71
|
+
"typescript": "^4.9.4"
|
72
|
+
},
|
73
|
+
"peerDependenciesMeta": {
|
74
|
+
"typescript": {
|
75
|
+
"optional": true
|
76
|
+
}
|
77
|
+
},
|
78
|
+
"devDependencies": {
|
79
|
+
"esbuild": "^0.19.9",
|
80
|
+
"yargs": "^17.5.1"
|
80
81
|
}
|
81
82
|
}
|
package/bin/init-ui5-package.js
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
const babel = require("rollup-plugin-babel");
|
2
|
-
const process = require("process");
|
3
|
-
const resolve = require("rollup-plugin-node-resolve");
|
4
|
-
const url = require("rollup-plugin-url");
|
5
|
-
const { terser } = require("rollup-plugin-terser");
|
6
|
-
const notify = require('rollup-plugin-notify');
|
7
|
-
const filesize = require('rollup-plugin-filesize');
|
8
|
-
const livereload = require('rollup-plugin-livereload');
|
9
|
-
const os = require("os");
|
10
|
-
const fs = require("fs");
|
11
|
-
|
12
|
-
const packageName = JSON.parse(fs.readFileSync("./package.json")).name;
|
13
|
-
const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
|
14
|
-
|
15
|
-
function ui5DevImportCheckerPlugin() {
|
16
|
-
return {
|
17
|
-
name: "ui5-dev-import-checker-plugin",
|
18
|
-
transform(code, file) {
|
19
|
-
const re = new RegExp(`^import.*"${packageName}/`);
|
20
|
-
if (re.test(code)) {
|
21
|
-
throw new Error(`illegal import in ${file}`);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
};
|
25
|
-
}
|
26
|
-
|
27
|
-
const getPlugins = ({ transpile }) => {
|
28
|
-
const plugins = [];
|
29
|
-
let publicPath = DEPLOY_PUBLIC_PATH || "/resources/";
|
30
|
-
|
31
|
-
if (!process.env.DEV) {
|
32
|
-
plugins.push(filesize({
|
33
|
-
render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){
|
34
|
-
return gzipSize;
|
35
|
-
}
|
36
|
-
}));
|
37
|
-
}
|
38
|
-
|
39
|
-
plugins.push(ui5DevImportCheckerPlugin());
|
40
|
-
|
41
|
-
plugins.push(url({
|
42
|
-
limit: 0,
|
43
|
-
include: [
|
44
|
-
/.*assets\/.*\.json/
|
45
|
-
],
|
46
|
-
emitFiles: true,
|
47
|
-
fileName: "[name].[hash][extname]",
|
48
|
-
publicPath,
|
49
|
-
}));
|
50
|
-
|
51
|
-
|
52
|
-
if (transpile) {
|
53
|
-
plugins.push(babel({
|
54
|
-
presets: ["@babel/preset-env"],
|
55
|
-
exclude: "node_modules/**",
|
56
|
-
sourcemap: true,
|
57
|
-
}));
|
58
|
-
}
|
59
|
-
|
60
|
-
plugins.push(resolve());
|
61
|
-
|
62
|
-
if (!process.env.DEV) {
|
63
|
-
plugins.push(terser());
|
64
|
-
}
|
65
|
-
|
66
|
-
if (process.env.DEV) {
|
67
|
-
plugins.push(notify());
|
68
|
-
}
|
69
|
-
|
70
|
-
const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
|
71
|
-
if (es6DevMain && os.platform() !== "win32") {
|
72
|
-
plugins.push(livereload({
|
73
|
-
watch: [
|
74
|
-
"dist/resources/bundle.esm.js",
|
75
|
-
"dist/**/*.html",
|
76
|
-
"dist/**/*.json",
|
77
|
-
]
|
78
|
-
}));
|
79
|
-
}
|
80
|
-
|
81
|
-
return plugins;
|
82
|
-
};
|
83
|
-
|
84
|
-
const getES6Config = () => {
|
85
|
-
return [{
|
86
|
-
input: "bundle.esm.js",
|
87
|
-
output: {
|
88
|
-
dir: "dist/resources",
|
89
|
-
format: "esm",
|
90
|
-
sourcemap: true
|
91
|
-
},
|
92
|
-
moduleContext: (id) => {
|
93
|
-
if (id.includes("url-search-params-polyfill")) {
|
94
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
95
|
-
return "window";
|
96
|
-
}
|
97
|
-
},
|
98
|
-
watch: {
|
99
|
-
clearScreen: false
|
100
|
-
},
|
101
|
-
plugins: getPlugins({transpile: false}),
|
102
|
-
}];
|
103
|
-
};
|
104
|
-
|
105
|
-
const getES5Config = () => {
|
106
|
-
return [ {
|
107
|
-
input: "bundle.es5.js",
|
108
|
-
output: {
|
109
|
-
dir: "dist/resources",
|
110
|
-
format: "iife",
|
111
|
-
name: "sap-ui-webcomponents-bundle",
|
112
|
-
extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
|
113
|
-
sourcemap: true
|
114
|
-
},
|
115
|
-
moduleContext: (id) => {
|
116
|
-
if (id.includes("url-search-params-polyfill")) {
|
117
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
118
|
-
return "window";
|
119
|
-
}
|
120
|
-
},
|
121
|
-
watch: {
|
122
|
-
clearScreen: false
|
123
|
-
},
|
124
|
-
plugins: getPlugins({transpile: true}),
|
125
|
-
}];
|
126
|
-
};
|
127
|
-
|
128
|
-
let config = getES6Config();
|
129
|
-
|
130
|
-
if (process.env.ES5_BUILD) {
|
131
|
-
config = config.concat(getES5Config());
|
132
|
-
}
|
133
|
-
|
134
|
-
module.exports = config;
|
@@ -1,143 +0,0 @@
|
|
1
|
-
const cssVariables = {};
|
2
|
-
const template = require('./templates/template').template;
|
3
|
-
const sinceTemplate = require('./templates/api-component-since').template;
|
4
|
-
const propertiesTemplate = require('./templates/api-properties-section').template;
|
5
|
-
const slotsTemplate = require('./templates/api-slots-section').template;
|
6
|
-
const eventsTemplate = require('./templates/api-events-section').template;
|
7
|
-
const methodsTemplate = require('./templates/api-methods-section').template;
|
8
|
-
const cssVariablesTemplate = require('./templates/api-css-variables-section').template;
|
9
|
-
const Handlebars = require('handlebars/dist/handlebars.min.js');
|
10
|
-
const fs = require('fs');
|
11
|
-
const path = require('path');
|
12
|
-
const mkdirp = require('mkdirp');
|
13
|
-
|
14
|
-
const api = JSON.parse(fs.readFileSync(path.normalize(process.argv[2])));
|
15
|
-
|
16
|
-
const entries = api['symbols'];
|
17
|
-
const compiledHandlebars = Handlebars.compile(template);
|
18
|
-
const compiledSinceTemplate = Handlebars.compile(sinceTemplate);
|
19
|
-
const linkMatcher = /{@link(\s)(\w+)\s*}/gi;
|
20
|
-
const sinceMarker = "<!--since_tag_marker-->";
|
21
|
-
|
22
|
-
const getComponentByName = name => {
|
23
|
-
return entries.find(element => {
|
24
|
-
return element.basename === name;
|
25
|
-
})
|
26
|
-
};
|
27
|
-
|
28
|
-
const getCSSVarsByName = name => {
|
29
|
-
return cssVariables[name] || [];
|
30
|
-
};
|
31
|
-
|
32
|
-
const capitalize = str => {
|
33
|
-
return str.replace(/^./, str => str.toUpperCase());
|
34
|
-
};
|
35
|
-
|
36
|
-
Handlebars.registerHelper('toLowerCase', function (str) {
|
37
|
-
return str ? str.toLowerCase() : "";
|
38
|
-
});
|
39
|
-
|
40
|
-
Handlebars.registerHelper('toKebabCase', function (str) {
|
41
|
-
const kebab = str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
42
|
-
return kebab !== str ? kebab : undefined;
|
43
|
-
});
|
44
|
-
|
45
|
-
Handlebars.registerHelper('checkEven', function (iIndex) {
|
46
|
-
return (iIndex % 2 === 0) ? "api-table-roll-even" : "api-table-roll-odd";
|
47
|
-
});
|
48
|
-
|
49
|
-
Handlebars.registerPartial('properties', propertiesTemplate);
|
50
|
-
Handlebars.registerPartial('slots', slotsTemplate);
|
51
|
-
Handlebars.registerPartial('events', eventsTemplate);
|
52
|
-
Handlebars.registerPartial('methods', methodsTemplate);
|
53
|
-
Handlebars.registerPartial('cssVariables', cssVariablesTemplate);
|
54
|
-
|
55
|
-
mkdirp.sync(`dist/test-resources/api`);
|
56
|
-
|
57
|
-
let entriesAPI = [];
|
58
|
-
|
59
|
-
const appendCSSVarsAPI = entry => {
|
60
|
-
entry.cssVariables = getCSSVarsByName(entry.basename);
|
61
|
-
return entry;
|
62
|
-
}
|
63
|
-
|
64
|
-
const calculateAPI = entry => {
|
65
|
-
if (entriesAPI.indexOf(entry.basename) !== -1) {
|
66
|
-
return entry;
|
67
|
-
}
|
68
|
-
|
69
|
-
let parent = getComponentByName(entry.extends) || {};
|
70
|
-
|
71
|
-
entry = appendCSSVarsAPI(entry);
|
72
|
-
parent = appendCSSVarsAPI(parent);
|
73
|
-
|
74
|
-
parent = { ...{ properties: [], events: [], slots: [], cssVariables: [] }, ...parent };
|
75
|
-
|
76
|
-
// extend component documentation
|
77
|
-
entry.properties = [...(entry.properties || []), ...(parent.properties || [])];
|
78
|
-
entry.events = [...(entry.events || []), ...(parent.events || [])];
|
79
|
-
entry.slots = [...(entry.slots || []), ...(parent.slots || [])];
|
80
|
-
entry.cssVariables = [...(entry.cssVariables || []), ...(parent.cssVariables || [])];
|
81
|
-
|
82
|
-
entriesAPI.push(entry.basename);
|
83
|
-
|
84
|
-
return entry;
|
85
|
-
}
|
86
|
-
|
87
|
-
const appendAdditionalEntriesAPI = entry => {
|
88
|
-
if (entry.appenddocs) {
|
89
|
-
const additionalEntries = entry.appenddocs.split(" ");
|
90
|
-
entry.additionalDocs = [];
|
91
|
-
|
92
|
-
additionalEntries.forEach(entryName => {
|
93
|
-
let additionalEntry = getComponentByName(entryName);
|
94
|
-
additionalEntry = calculateAPI(additionalEntry);
|
95
|
-
entry.additionalDocs.push(additionalEntry);
|
96
|
-
});
|
97
|
-
}
|
98
|
-
|
99
|
-
return entry;
|
100
|
-
}
|
101
|
-
|
102
|
-
const generateSamplePage = entry => {
|
103
|
-
let content = "";
|
104
|
-
|
105
|
-
try {
|
106
|
-
content = fs.readFileSync(`dist/test-resources/samples/${capitalize(entry.basename)}.sample.html`, 'utf8');
|
107
|
-
} catch (err) { }
|
108
|
-
|
109
|
-
if (content) {
|
110
|
-
const APIReference = compiledHandlebars(entry).replace(/\[\]/g, " [0..n]");
|
111
|
-
const EntitySince = compiledSinceTemplate(entry).replace(/\[\]/g, " [0..n]");
|
112
|
-
|
113
|
-
content = content.replace('<!-- JSDoc marker -->', APIReference);
|
114
|
-
content = content.replace(sinceMarker, EntitySince);
|
115
|
-
|
116
|
-
content = content.replace(linkMatcher, match => {
|
117
|
-
const component = linkMatcher.exec(match)[2];
|
118
|
-
|
119
|
-
// reset the regex
|
120
|
-
linkMatcher.lastIndex = 0;
|
121
|
-
|
122
|
-
return `<a href="#" onclick="redirect(event, '${component}')">${component}</a>`;
|
123
|
-
});
|
124
|
-
|
125
|
-
fs.writeFile(`dist/test-resources/api/${entry.basename}.sample.html`, content, (err) => {
|
126
|
-
// console.log(err);
|
127
|
-
});
|
128
|
-
}
|
129
|
-
}
|
130
|
-
|
131
|
-
const generateComponentAPI = entry => {
|
132
|
-
// (1) calculate the API
|
133
|
-
entry = calculateAPI(entry);
|
134
|
-
|
135
|
-
// (2) append additional API for composition components - List -> ListIems, TabContainer -> Tabs, Table -> TableRow/Column/Cell
|
136
|
-
entry = appendAdditionalEntriesAPI(entry);
|
137
|
-
|
138
|
-
// (3) generate sample page
|
139
|
-
generateSamplePage(entry);
|
140
|
-
}
|
141
|
-
|
142
|
-
entries.forEach(generateComponentAPI);
|
143
|
-
entriesAPI = [];
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
template: `
|
3
|
-
{{#if cssVariables}}
|
4
|
-
<h3 class="comment-api-title" >CSS variables</h3>
|
5
|
-
<p class="small-space-top">You can use the following CSS varialbes to change the component styling.</p>
|
6
|
-
|
7
|
-
<div class="small-space-top api-table">
|
8
|
-
<div class="head api-table-header-roll">
|
9
|
-
<div class="cell api-table-header-cell">Name</div>
|
10
|
-
<div class="cell api-table-header-cell">Description</div>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
{{#each cssVariables}}
|
14
|
-
<div class="row {{checkEven @index}}">
|
15
|
-
<div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
|
16
|
-
<div class="cell api-table-content-cell api-table-content-cell-description">
|
17
|
-
{{{this.description}}}
|
18
|
-
</div>
|
19
|
-
</div>
|
20
|
-
{{/each}}
|
21
|
-
|
22
|
-
</div>
|
23
|
-
{{/if}}`
|
24
|
-
};
|