@ui5/webcomponents-tools 0.0.0-cc312800a → 0.0.0-cf069fb29
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 +69 -0
- package/README.md +1 -1
- package/assets-meta.js +3 -1
- package/components-package/nps.js +10 -4
- package/components-package/postcss.themes.js +5 -2
- package/components-package/rollup-plugins/empty-module.js +15 -0
- package/components-package/rollup.js +52 -8
- package/components-package/wdio.js +50 -25
- package/components-package/wdio.sync.js +360 -0
- package/icons-collection/nps.js +42 -8
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +20 -6
- package/lib/create-illustrations/index.js +150 -0
- package/lib/create-new-component/index.js +12 -4
- package/lib/documentation/templates/template.js +1 -1
- package/lib/esm-abs-to-rel/index.js +54 -0
- package/lib/hbs2lit/src/litVisitor2.js +31 -6
- package/lib/hbs2lit/src/svgProcessor.js +3 -3
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +4 -11
- package/lib/postcss-css-to-esm/index.js +4 -4
- package/lib/postcss-css-to-json/index.js +7 -2
- package/lib/replace-global-core/index.js +20 -0
- package/lib/scoping/lint-src.js +1 -1
- package/lib/serve/index.js +1 -1
- package/package.json +23 -27
- package/bin/init-ui5-package.js +0 -3
- package/lib/init-package/index.js +0 -123
- 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 -31
- 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/MyFirstComponent.hbs +0 -1
- package/lib/init-package/resources/src/MyFirstComponent.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/MyFirstComponent.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/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/test/pages/index.html +0 -56
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
@@ -33,6 +33,6 @@ module.exports = {
|
|
33
33
|
<a class="separator" href="https://www.sap.com/about/legal/privacy.html" target="_blank">Privacy Policy</a>
|
34
34
|
<a href="https://www.sap.com/about/legal/impressum.html" target="_blank">Legal</a>
|
35
35
|
</div>
|
36
|
-
<img src="
|
36
|
+
<img src="../../../assets/images/sap-logo-svg.svg" alt="Sap Logo" />
|
37
37
|
</footer>`
|
38
38
|
};
|
@@ -0,0 +1,54 @@
|
|
1
|
+
const esprima = require("esprima");
|
2
|
+
const escodegen = require("escodegen");
|
3
|
+
|
4
|
+
const fs = require("fs");
|
5
|
+
const path = require("path");
|
6
|
+
const glob = require("glob");
|
7
|
+
const basePath = process.argv[2];
|
8
|
+
|
9
|
+
const convertImports = (srcPath) => {
|
10
|
+
let changed = false;
|
11
|
+
// console.log("scanning imports of", srcPath);
|
12
|
+
let code = fs.readFileSync(srcPath).toString();
|
13
|
+
const tree = esprima.parseModule(code);
|
14
|
+
const importer = srcPath.replace(basePath, "");
|
15
|
+
const importerDir = path.dirname(importer);
|
16
|
+
// console.log("-> ", importer);
|
17
|
+
tree.body.forEach(node => {
|
18
|
+
if (node.type === "ImportDeclaration") {
|
19
|
+
let importee = node.source.value;
|
20
|
+
if (importee.startsWith(".")) {
|
21
|
+
// add .js extension if missing
|
22
|
+
if (!importee.endsWith(".js")) {
|
23
|
+
node.source.value += ".js"
|
24
|
+
changed = true;
|
25
|
+
}
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
let importeeDir = path.dirname(importee);
|
29
|
+
let importeeFile = path.basename(importee);
|
30
|
+
let relativePath = path.relative(importerDir, importeeDir);
|
31
|
+
if (relativePath.length === 0) {
|
32
|
+
relativePath = "."
|
33
|
+
}
|
34
|
+
if (!relativePath.startsWith(".")) {
|
35
|
+
relativePath = "./" + relativePath;
|
36
|
+
}
|
37
|
+
|
38
|
+
relativePath = relativePath.replace(/\\/g, "/"); // the browser expects unix paths
|
39
|
+
let relativeImport = `${relativePath}/${importeeFile}.js`;
|
40
|
+
// console.log(importee + " --> " + relativeImport);
|
41
|
+
node.source.value = relativeImport;
|
42
|
+
changed = true;
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
if (changed) {
|
47
|
+
fs.writeFileSync(srcPath, escodegen.generate(tree));
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
const fileNames = glob.sync(basePath + "**/*.js");
|
52
|
+
// console.log(fileNames);
|
53
|
+
fileNames.forEach(convertImports);
|
54
|
+
console.log("Success: Converted absolute imports to relative for files in:", basePath)
|
@@ -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(", ") + ") =>
|
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
|
-
|
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 (
|
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) =>
|
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
|
-
|
4
|
-
|
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
|
-
|
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 = {
|
@@ -8,10 +8,10 @@ const DEFAULT_THEME = assets.themes.default;
|
|
8
8
|
const getDefaultThemeCode = packageName => {
|
9
9
|
return `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
10
10
|
|
11
|
-
import defaultThemeBase from "@ui5/webcomponents-
|
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-
|
14
|
+
registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", () => defaultThemeBase);
|
15
15
|
registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", () => defaultTheme);
|
16
16
|
`;
|
17
17
|
};
|
@@ -38,8 +38,8 @@ module.exports = function (opts) {
|
|
38
38
|
|
39
39
|
const filePath = `${targetFile}.js`;
|
40
40
|
const defaultTheme = opts.includeDefaultTheme ? getDefaultThemeCode(opts.packageName) : ``;
|
41
|
-
fs.writeFileSync(filePath, `${defaultTheme}export default ${css}
|
41
|
+
fs.writeFileSync(filePath, `${defaultTheme}export default {packageName:"${opts.packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`);
|
42
42
|
}
|
43
43
|
};
|
44
44
|
};
|
45
|
-
module.exports.postcss = true;
|
45
|
+
module.exports.postcss = true;
|
@@ -23,9 +23,14 @@ module.exports = function (opts) {
|
|
23
23
|
mkdirp.sync(path.dirname(targetFile));
|
24
24
|
|
25
25
|
const filePath = `${targetFile}.json`;
|
26
|
-
|
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}));
|
27
32
|
}
|
28
33
|
};
|
29
34
|
};
|
30
35
|
|
31
|
-
module.exports.postcss = true;
|
36
|
+
module.exports.postcss = true;
|
@@ -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);
|
package/lib/scoping/lint-src.js
CHANGED
@@ -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(`(^|[
|
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
|
});
|
package/lib/serve/index.js
CHANGED
@@ -2,7 +2,7 @@ const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
3
3
|
const commandLineArgs = require("command-line-args");
|
4
4
|
const { exec } = require("child_process");
|
5
|
-
const colors = require("
|
5
|
+
const colors = require("cli-color");
|
6
6
|
const isPortReachable = require("is-port-reachable");
|
7
7
|
|
8
8
|
const options = commandLineArgs([
|
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-cf069fb29",
|
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,31 +21,30 @@
|
|
22
21
|
"directory": "packages/tools"
|
23
22
|
},
|
24
23
|
"dependencies": {
|
25
|
-
"@babel/cli": "^7.13.10",
|
26
24
|
"@babel/core": "^7.13.10",
|
27
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
|
28
25
|
"@babel/preset-env": "^7.13.10",
|
26
|
+
"@openui5/sap.ui.core": "1.95.0",
|
29
27
|
"@rollup/plugin-babel": "^5.3.0",
|
28
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
30
29
|
"@rollup/plugin-json": "^4.1.0",
|
31
|
-
"@rollup/plugin-node-resolve": "^
|
30
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
31
|
+
"@rollup/plugin-replace": "^3.0.0",
|
32
32
|
"@rollup/plugin-url": "^6.0.0",
|
33
|
-
"@wdio/cli": "^7.2
|
34
|
-
"@wdio/dot-reporter": "^7.
|
35
|
-
"@wdio/local-runner": "^7.2
|
36
|
-
"@wdio/mocha-framework": "^7.2
|
37
|
-
"@wdio/spec-reporter": "^7.
|
38
|
-
"@wdio/sync": "^7.2.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",
|
39
38
|
"@webcomponents/webcomponentsjs": "^2.5.0",
|
40
39
|
"chai": "^4.3.4",
|
41
40
|
"child_process": "^1.0.2",
|
42
41
|
"chokidar": "^3.5.1",
|
43
|
-
"chokidar-cli": "^
|
44
|
-
"
|
45
|
-
"colors": "^1.4.0",
|
42
|
+
"chokidar-cli": "^3.0.0",
|
43
|
+
"cli-color": "^2.0.1",
|
46
44
|
"command-line-args": "^5.1.1",
|
47
45
|
"concurrently": "^6.0.0",
|
48
46
|
"cross-env": "^7.0.3",
|
49
|
-
"cssnano": "^4.1.
|
47
|
+
"cssnano": "^4.1.11",
|
50
48
|
"escodegen": "^2.0.0",
|
51
49
|
"eslint": "^7.22.0",
|
52
50
|
"eslint-config-airbnb-base": "^14.2.1",
|
@@ -55,29 +53,27 @@
|
|
55
53
|
"folder-hash": "^4.0.1",
|
56
54
|
"getopts": "^2.3.0",
|
57
55
|
"glob": "^7.1.6",
|
56
|
+
"glob-parent": "^6.0.2",
|
58
57
|
"handlebars": "^4.7.7",
|
59
|
-
"is-port-reachable": "^3.
|
58
|
+
"is-port-reachable": "^3.1.0",
|
60
59
|
"jsdoc": "^3.6.6",
|
61
60
|
"json-beautify": "^1.1.1",
|
62
61
|
"mkdirp": "^1.0.4",
|
63
|
-
"npm-run-all": "^4.1.3",
|
64
62
|
"nps": "^5.10.0",
|
65
|
-
"postcss": "^8.
|
66
|
-
"postcss-cli": "^
|
67
|
-
"postcss-combine-duplicated-selectors": "^10.0.
|
68
|
-
"postcss-import": "^14.0.
|
63
|
+
"postcss": "^8.4.5",
|
64
|
+
"postcss-cli": "^9.1.0",
|
65
|
+
"postcss-combine-duplicated-selectors": "^10.0.3",
|
66
|
+
"postcss-import": "^14.0.2",
|
69
67
|
"properties-reader": "^2.2.0",
|
70
|
-
"puppeteer": "^8.0.0",
|
71
68
|
"recursive-readdir": "^2.2.2",
|
69
|
+
"resolve": "^1.20.0",
|
72
70
|
"rimraf": "^3.0.2",
|
73
71
|
"rollup": "^2.41.4",
|
74
72
|
"rollup-plugin-filesize": "^9.1.1",
|
75
73
|
"rollup-plugin-livereload": "^2.0.0",
|
76
|
-
"rollup-plugin-notify": "^1.1.0",
|
77
|
-
"rollup-plugin-string": "^3.0.0",
|
78
74
|
"rollup-plugin-terser": "^7.0.2",
|
79
|
-
"
|
80
|
-
"
|
75
|
+
"serve": "^12.0.0",
|
76
|
+
"slash": "3.0.0",
|
81
77
|
"wdio-chromedriver-service": "^7.0.0"
|
82
78
|
},
|
83
79
|
"peerDependencies": {
|
package/bin/init-ui5-package.js
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const path = require("path");
|
3
|
-
const mkdirp = require("mkdirp");
|
4
|
-
const commandLineArgs = require('command-line-args');
|
5
|
-
const beautify = require("json-beautify");
|
6
|
-
|
7
|
-
// String utils
|
8
|
-
const kebabToCamelCase = string => toCamelCase(string.split("-"));
|
9
|
-
const toCamelCase = parts => {
|
10
|
-
return parts.map((string, index) => {
|
11
|
-
return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
12
|
-
}).join("");
|
13
|
-
};
|
14
|
-
const capitalizeFirst = str => str.substr(0,1).toUpperCase() + str.substr(1);
|
15
|
-
|
16
|
-
// content of package.json
|
17
|
-
let packageContent;
|
18
|
-
|
19
|
-
const DEFAULT_PORT = 8080;
|
20
|
-
const DEFAULT_TAG = 'my-first-component';
|
21
|
-
|
22
|
-
// from where all the files will be copied
|
23
|
-
const RESOURCES_DIR = path.join(`${__dirname}`, `resources/`);
|
24
|
-
|
25
|
-
// Command line options
|
26
|
-
const options = commandLineArgs([
|
27
|
-
{name: 'port', alias: 'p', type: Number},
|
28
|
-
{name: 'tag', type: String},
|
29
|
-
]);
|
30
|
-
|
31
|
-
// Ensure there is package.json
|
32
|
-
try {
|
33
|
-
packageContent = JSON.parse(fs.readFileSync("package.json"));
|
34
|
-
} catch (err) {
|
35
|
-
console.log("No package.json found, please run: 'npm init' first");
|
36
|
-
process.exit(1);
|
37
|
-
}
|
38
|
-
|
39
|
-
// Ensure correct tag
|
40
|
-
const tag = options.tag || DEFAULT_TAG;
|
41
|
-
if (!tag.includes("-")) {
|
42
|
-
console.log("tag name should contain at least one dash");
|
43
|
-
process.exit(1);
|
44
|
-
}
|
45
|
-
if (tag.startsWith("ui5-")) {
|
46
|
-
console.log("The ui5- prefix is reserved for the standard UI5 Web Components due to future possible name clashes.");
|
47
|
-
process.exit(1);
|
48
|
-
}
|
49
|
-
|
50
|
-
const className = capitalizeFirst(kebabToCamelCase(tag));
|
51
|
-
|
52
|
-
// All variables that will be replaced in the content of the resources/
|
53
|
-
const vars = {
|
54
|
-
INIT_PACKAGE_VAR_NAME: packageContent.name,
|
55
|
-
INIT_PACKAGE_VAR_PORT: options.port || DEFAULT_PORT,
|
56
|
-
INIT_PACKAGE_VAR_TAG: tag,
|
57
|
-
INIT_PACKAGE_VAR_CLASS_NAME: className,
|
58
|
-
};
|
59
|
-
console.log(vars);
|
60
|
-
|
61
|
-
const replaceVarsInFileContent = content => {
|
62
|
-
for (let key in vars) {
|
63
|
-
const re = new RegExp(key, "g");
|
64
|
-
content = content.replace(re, vars[key]);
|
65
|
-
}
|
66
|
-
return content;
|
67
|
-
};
|
68
|
-
|
69
|
-
const replaceVarsInFileName = fileName => {
|
70
|
-
return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME) ;
|
71
|
-
};
|
72
|
-
|
73
|
-
const copyFile = (sourcePath, destPath) => {
|
74
|
-
let content = fs.readFileSync(sourcePath, {encoding: "UTF-8"});
|
75
|
-
content = replaceVarsInFileContent(content);
|
76
|
-
destPath = replaceVarsInFileName(destPath);
|
77
|
-
fs.writeFileSync(destPath, content);
|
78
|
-
console.log(destPath);
|
79
|
-
};
|
80
|
-
|
81
|
-
const copyResources = sourcePath => {
|
82
|
-
const destPath = sourcePath.substr(RESOURCES_DIR.length);
|
83
|
-
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
84
|
-
if (isDir) {
|
85
|
-
if (destPath) {
|
86
|
-
mkdirp.sync(destPath);
|
87
|
-
console.log(destPath);
|
88
|
-
}
|
89
|
-
fs.readdirSync(sourcePath).forEach(file => {
|
90
|
-
copyResources(path.join(sourcePath, file));
|
91
|
-
});
|
92
|
-
} else {
|
93
|
-
copyFile(sourcePath, destPath);
|
94
|
-
}
|
95
|
-
};
|
96
|
-
|
97
|
-
const updatePackageFile = () => {
|
98
|
-
packageContent.scripts = {
|
99
|
-
"clean": "wc-dev clean",
|
100
|
-
"lint": "wc-dev lint",
|
101
|
-
"start": "wc-dev start",
|
102
|
-
"watch": "wc-dev watch",
|
103
|
-
"serve": "wc-dev serve",
|
104
|
-
"build": "wc-dev build",
|
105
|
-
"test": "wc-dev test",
|
106
|
-
"create-ui5-element": "wc-create-ui5-element",
|
107
|
-
"prepublishOnly": "npm run build"
|
108
|
-
};
|
109
|
-
|
110
|
-
packageContent.ui5 = {
|
111
|
-
webComponentsPackage: true
|
112
|
-
};
|
113
|
-
|
114
|
-
fs.writeFileSync("package.json", beautify(packageContent, null, 2, 100));
|
115
|
-
};
|
116
|
-
|
117
|
-
// Copy files
|
118
|
-
copyResources(RESOURCES_DIR);
|
119
|
-
|
120
|
-
// Update package.json
|
121
|
-
updatePackageFile();
|
122
|
-
|
123
|
-
console.log("Package successfully initialized.");
|
@@ -1,25 +0,0 @@
|
|
1
|
-
// ES5 bundle targets IE11 only
|
2
|
-
import "@ui5/webcomponents-ie11/dist/features/IE11.js";
|
3
|
-
|
4
|
-
import "./bundle.esm.js";
|
5
|
-
|
6
|
-
import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
|
7
|
-
import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
|
8
|
-
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
|
9
|
-
import { getTheme, setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
10
|
-
import { getNoConflict, setNoConflict } from "@ui5/webcomponents-base/dist/config/NoConflict.js";
|
11
|
-
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
|
12
|
-
import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js";
|
13
|
-
|
14
|
-
const configuration = {
|
15
|
-
getAnimationMode,
|
16
|
-
getLanguage,
|
17
|
-
getTheme,
|
18
|
-
setTheme,
|
19
|
-
getNoConflict,
|
20
|
-
setNoConflict,
|
21
|
-
getCalendarType,
|
22
|
-
getRTL,
|
23
|
-
getFirstDayOfWeek,
|
24
|
-
};
|
25
|
-
export default configuration;
|
@@ -1,31 +0,0 @@
|
|
1
|
-
// used in test pages
|
2
|
-
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
|
3
|
-
|
4
|
-
import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
|
5
|
-
import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
|
6
|
-
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
|
7
|
-
import { getTheme, setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
|
8
|
-
import { getNoConflict, setNoConflict } from "@ui5/webcomponents-base/dist/config/NoConflict.js";
|
9
|
-
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
|
10
|
-
import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js";
|
11
|
-
|
12
|
-
// Enable additional themes and i18n texts
|
13
|
-
import "./dist/Assets.js";
|
14
|
-
|
15
|
-
// Import your web components here from the dist/ directory
|
16
|
-
import "./dist/INIT_PACKAGE_VAR_CLASS_NAME.js";
|
17
|
-
|
18
|
-
window["sap-ui-webcomponents-bundle"] = {
|
19
|
-
renderFinished,
|
20
|
-
configuration: {
|
21
|
-
getAnimationMode,
|
22
|
-
getLanguage,
|
23
|
-
getTheme,
|
24
|
-
setTheme,
|
25
|
-
getNoConflict,
|
26
|
-
setNoConflict,
|
27
|
-
getCalendarType,
|
28
|
-
getRTL,
|
29
|
-
getFirstDayOfWeek,
|
30
|
-
},
|
31
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/eslint.js");
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/postcss.components.js");
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/postcss.themes.js");
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/rollup.js");
|
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/wdio.js");
|
@@ -1 +0,0 @@
|
|
1
|
-
<div>This is: INIT_PACKAGE_VAR_TAG. {{pleaseWaitText}}</div>
|