@ui5/webcomponents-tools 0.0.0-32b659ddc → 0.0.0-35e2c9666
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 +189 -1
- package/README.md +1 -1
- package/assets-meta.js +153 -0
- package/bin/dev.js +16 -1
- package/components-package/nps.js +74 -35
- package/components-package/postcss.themes.js +5 -2
- package/components-package/rollup-plugins/empty-module.js +15 -0
- package/components-package/rollup.js +155 -50
- package/components-package/wdio.js +100 -64
- package/components-package/wdio.sync.js +360 -0
- package/icons-collection/nps.js +72 -28
- package/lib/copy-and-watch/index.js +122 -0
- package/lib/copy-list/index.js +28 -0
- package/lib/create-icons/index.js +41 -23
- package/lib/create-illustrations/index.js +150 -0
- package/lib/create-new-component/index.js +18 -6
- package/lib/documentation/index.js +43 -21
- package/lib/documentation/templates/api-properties-section.js +3 -1
- package/lib/documentation/templates/template.js +2 -1
- package/lib/esm-abs-to-rel/index.js +54 -0
- package/lib/generate-json-imports/i18n.js +91 -47
- package/lib/generate-json-imports/themes.js +61 -15
- package/lib/hash/config.js +10 -0
- package/lib/hash/generate.js +19 -0
- package/lib/hash/upToDate.js +31 -0
- package/lib/hbs2lit/index.js +2 -4
- package/lib/hbs2lit/src/compiler.js +8 -7
- package/lib/hbs2lit/src/includesReplacer.js +22 -16
- package/lib/hbs2lit/src/litVisitor2.js +44 -8
- package/lib/hbs2lit/src/svgProcessor.js +3 -3
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
- package/lib/hbs2ui5/index.js +26 -20
- package/lib/i18n/defaults.js +25 -6
- package/lib/i18n/toJSON.js +15 -4
- package/lib/jsdoc/config.json +1 -1
- package/lib/jsdoc/plugin.js +33 -4
- package/lib/jsdoc/template/publish.js +24 -4
- package/lib/polyfill-placeholder/index.js +5 -0
- package/lib/postcss-css-to-esm/index.js +31 -19
- package/lib/postcss-css-to-json/index.js +27 -11
- package/lib/postcss-new-files/index.js +36 -0
- package/lib/postcss-p/postcss-p.mjs +11 -0
- package/lib/replace-global-core/index.js +20 -0
- package/lib/scoping/get-all-tags.js +44 -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 +40 -0
- package/lib/serve/index.js +46 -0
- package/{components-package → lib/serve}/serve.json +0 -0
- package/package-lock.json +48 -0
- package/package.json +56 -55
- package/bin/init-ui5-package.js +0 -3
- 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 -6
- 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_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
@@ -2651,8 +2651,8 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2651
2651
|
|
2652
2652
|
attrib("name", symbol.longname);
|
2653
2653
|
attrib("basename", symbol.name);
|
2654
|
-
if (symbol.
|
2655
|
-
attrib("
|
2654
|
+
if (symbol.tagname) {
|
2655
|
+
attrib("tagname", symbol.tagname);
|
2656
2656
|
}
|
2657
2657
|
if (symbol.appenddocs) {
|
2658
2658
|
attrib("appenddocs", symbol.appenddocs);
|
@@ -2804,6 +2804,10 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2804
2804
|
attrib("export", undefined, '', true);
|
2805
2805
|
}
|
2806
2806
|
|
2807
|
+
if (member.noattribute) {
|
2808
|
+
attrib("noattribute", true);
|
2809
|
+
}
|
2810
|
+
|
2807
2811
|
if (member.readonly) {
|
2808
2812
|
attrib("readonly", member.readonly, null);
|
2809
2813
|
}
|
@@ -2815,7 +2819,14 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2815
2819
|
if ( member.since ) {
|
2816
2820
|
attrib("since", extractVersion(member.since));
|
2817
2821
|
}
|
2818
|
-
|
2822
|
+
|
2823
|
+
var type = listTypes(member.type);
|
2824
|
+
attrib("type", type);
|
2825
|
+
|
2826
|
+
if ((type === "object" || type === "Object") && visibility(member) === "public") {
|
2827
|
+
attrib("noattribute", true);
|
2828
|
+
}
|
2829
|
+
|
2819
2830
|
tag("description", normalizeWS(member.description), true);
|
2820
2831
|
if (member.defaultvalue) {
|
2821
2832
|
attrib("defaultValue", member.defaultvalue);
|
@@ -2838,6 +2849,9 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2838
2849
|
if (member.slot) {
|
2839
2850
|
tag("property");
|
2840
2851
|
attrib("name", member.name);
|
2852
|
+
if (member.propertyName) {
|
2853
|
+
attrib("propertyName", member.propertyName);
|
2854
|
+
}
|
2841
2855
|
if (member.__ui5.module && member.__ui5.module !== symbol.__ui5.module) {
|
2842
2856
|
attrib("module", member.__ui5.module);
|
2843
2857
|
attrib("export", undefined, '', true);
|
@@ -2879,6 +2893,12 @@ function createAPIJSON4Symbol(symbol, omitDefaults) {
|
|
2879
2893
|
attrib("module", member.__ui5.module);
|
2880
2894
|
attrib("export", undefined, '', true);
|
2881
2895
|
}
|
2896
|
+
if (member.allowPreventDefault) {
|
2897
|
+
attrib("allowPreventDefault", true);
|
2898
|
+
}
|
2899
|
+
if (member.native) {
|
2900
|
+
attrib("native", true);
|
2901
|
+
}
|
2882
2902
|
attrib("visibility", visibility(member), 'public');
|
2883
2903
|
if ( member.scope === 'static' ) {
|
2884
2904
|
attrib("static", true, false, /* raw = */true);
|
@@ -3845,7 +3865,7 @@ function createAPIJS(symbols, filename) {
|
|
3845
3865
|
|
3846
3866
|
var output = [];
|
3847
3867
|
|
3848
|
-
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|package|private|protected|public|return|short|static|super|switch|synchronized|this|throw|throws|transient|true|try|typeof|use|var|void|volatile|while|with)$/;
|
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)$/;
|
3849
3869
|
|
3850
3870
|
function isNoKeyword($) { return !rkeywords.test($.name); }
|
3851
3871
|
|
@@ -1,33 +1,45 @@
|
|
1
|
-
const postcss = require('postcss');
|
2
1
|
const fs = require('fs');
|
3
2
|
const path = require('path');
|
4
3
|
const mkdirp = require('mkdirp');
|
4
|
+
const assets = require("../../assets-meta.js");
|
5
5
|
|
6
|
-
const
|
7
|
-
return `import "@ui5/webcomponents-theme-base/dist/DefaultTheme.js";
|
8
|
-
|
9
|
-
import { registerThemeProperties } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
6
|
+
const DEFAULT_THEME = assets.themes.default;
|
10
7
|
|
11
|
-
|
8
|
+
const getDefaultThemeCode = packageName => {
|
9
|
+
return `import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
12
10
|
|
13
|
-
|
11
|
+
import defaultThemeBase from "@ui5/webcomponents-theming/dist/generated/themes/${DEFAULT_THEME}/parameters-bundle.css.js";
|
12
|
+
import defaultTheme from "./${DEFAULT_THEME}/parameters-bundle.css.js";
|
14
13
|
|
14
|
+
registerThemePropertiesLoader("@ui5/webcomponents-theming", "${DEFAULT_THEME}", () => defaultThemeBase);
|
15
|
+
registerThemePropertiesLoader("${packageName}", "${DEFAULT_THEME}", () => defaultTheme);
|
15
16
|
`;
|
16
17
|
};
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
const proccessCSS = css => {
|
20
|
+
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
21
|
+
css = css.replace(/\.background-image.*{.*}/, "");
|
22
|
+
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
23
|
+
css = css.replace(/--sapFontUrl.*\);?/, "");
|
24
|
+
return JSON.stringify(css);
|
25
|
+
}
|
24
26
|
|
25
|
-
|
27
|
+
module.exports = function (opts) {
|
28
|
+
opts = opts || {};
|
26
29
|
|
27
|
-
|
30
|
+
return {
|
31
|
+
postcssPlugin: 'postcss-css-to-esm',
|
32
|
+
Once (root) {
|
33
|
+
let css = root.toString();
|
34
|
+
css = proccessCSS(css);
|
28
35
|
|
29
|
-
|
36
|
+
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\");
|
37
|
+
mkdirp.sync(path.dirname(targetFile));
|
30
38
|
|
31
|
-
|
32
|
-
|
33
|
-
});
|
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,20 +1,36 @@
|
|
1
|
-
const postcss = require('postcss');
|
2
1
|
const fs = require('fs');
|
3
2
|
const path = require('path');
|
4
3
|
const mkdirp = require('mkdirp');
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
const proccessCSS = css => {
|
6
|
+
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
7
|
+
css = css.replace(/\.background-image.*{.*}/, "");
|
8
|
+
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
9
|
+
css = css.replace(/--sapFontUrl.*\);?/, "");
|
10
|
+
return css;
|
11
|
+
}
|
8
12
|
|
9
|
-
|
10
|
-
|
11
|
-
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\assets\\");
|
13
|
+
module.exports = function (opts) {
|
14
|
+
opts = opts || {};
|
12
15
|
|
13
|
-
|
16
|
+
return {
|
17
|
+
postcssPlugin: 'postcss-css-to-json',
|
18
|
+
Once (root) {
|
19
|
+
let css = root.toString();
|
20
|
+
css = proccessCSS(css);
|
14
21
|
|
15
|
-
|
22
|
+
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/dist/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\dist\\generated\\assets\\");
|
23
|
+
mkdirp.sync(path.dirname(targetFile));
|
16
24
|
|
17
|
-
|
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
|
+
};
|
18
35
|
|
19
|
-
|
20
|
-
});
|
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,11 @@
|
|
1
|
+
import 'zx/globals';
|
2
|
+
|
3
|
+
const inputFiles = await globby("src/**/parameters-bundle.css");
|
4
|
+
|
5
|
+
const restArgs = process.argv.slice(2);
|
6
|
+
|
7
|
+
// run all postcss processes in parallel as passing the glob directly to postcss makes them processed sequentially.
|
8
|
+
// and the amount of imports give a big speed up when run in parallel
|
9
|
+
await Promise.all(inputFiles.map(file => {
|
10
|
+
return $`postcss ${file} --config config/postcss.themes --base src --dir dist/css/ ${restArgs}`;
|
11
|
+
}));
|
@@ -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);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const glob = require("glob");
|
4
|
+
|
5
|
+
const getTag = file => {
|
6
|
+
const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
|
7
|
+
const matches = fileContent.match(/\btag\b:\s*\"(.*?)\"/);
|
8
|
+
return matches ? matches[1] : undefined;
|
9
|
+
};
|
10
|
+
|
11
|
+
const getAltTag = file => {
|
12
|
+
const fileContent = String(fs.readFileSync(file)).replace(/\n/g, "");
|
13
|
+
const matches = fileContent.match(/\baltTag\b:\s*\"(.*?)\"/);
|
14
|
+
return matches ? matches[1] : undefined;
|
15
|
+
};
|
16
|
+
|
17
|
+
const getPackageTags = (packageDir) => {
|
18
|
+
const srcDir = path.join(packageDir, "src/");
|
19
|
+
return glob.sync(path.join(srcDir, "/**/*.js")).flatMap(file => {
|
20
|
+
const tag = getTag(file);
|
21
|
+
const altTag = getAltTag(file);
|
22
|
+
return [tag, altTag];
|
23
|
+
}).filter(item => !!item);
|
24
|
+
};
|
25
|
+
|
26
|
+
const isComponentsPackage = (packageFileContent) => {
|
27
|
+
return packageFileContent.ui5 && packageFileContent.ui5.webComponentsPackage;
|
28
|
+
};
|
29
|
+
|
30
|
+
const getDepComponentPackages = packageDir => {
|
31
|
+
const packageFile = path.join(packageDir, "package.json");
|
32
|
+
const packageFileContent = JSON.parse(fs.readFileSync(packageFile));
|
33
|
+
if (!isComponentsPackage(packageFileContent)) {
|
34
|
+
return [];
|
35
|
+
}
|
36
|
+
|
37
|
+
return Object.keys(packageFileContent.dependencies || {}).map(dep => path.dirname(require.resolve(path.join(dep, "package.json"))));
|
38
|
+
};
|
39
|
+
|
40
|
+
const getAllTags = (packageDir) => {
|
41
|
+
return getPackageTags(packageDir).concat(getDepComponentPackages(packageDir).flatMap(getPackageTags));
|
42
|
+
};
|
43
|
+
|
44
|
+
module.exports = getAllTags;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const glob = require("glob");
|
4
|
+
const getAllTags = require("./get-all-tags.js");
|
5
|
+
|
6
|
+
const tags = getAllTags(process.cwd());
|
7
|
+
|
8
|
+
const errors = [];
|
9
|
+
|
10
|
+
glob.sync(path.join(process.cwd(), "src/**/*.css")).forEach(file => {
|
11
|
+
let content = String(fs.readFileSync(file));
|
12
|
+
tags.forEach(tag => {
|
13
|
+
if (content.match(new RegExp(`(^|[^\.\-_A-Za-z0-9"\[])(${tag})([^\-_A-Za-z0-9]|$)`, "g"))) {
|
14
|
+
errors.push(`Warning! ${tag} found in ${file}`);
|
15
|
+
}
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
glob.sync(path.join(process.cwd(), "src/**/*.js")).forEach(file => {
|
20
|
+
let content = String(fs.readFileSync(file));
|
21
|
+
tags.forEach(tag => {
|
22
|
+
if (content.match(new RegExp(`querySelector[A-Za-z]*..${tag}`, "g"))) {
|
23
|
+
errors.push(`Warning! querySelector for ${tag} found in ${file}`);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
});
|
27
|
+
|
28
|
+
if (errors.length) {
|
29
|
+
errors.forEach(error => console.log(error));
|
30
|
+
throw new Error("Errors found.");
|
31
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const glob = require("glob");
|
3
|
+
const path = require("path");
|
4
|
+
const process = require("process");
|
5
|
+
|
6
|
+
const projectPath = process.argv[2];
|
7
|
+
|
8
|
+
// gather all tags from all files
|
9
|
+
const tagsToFiles = new Map();
|
10
|
+
const filesToTags = new Map();
|
11
|
+
|
12
|
+
let files = [
|
13
|
+
...glob.sync(path.join("packages/main/src/**/*.js")),
|
14
|
+
...glob.sync(path.join("packages/fiori/src/**/*.js")),
|
15
|
+
];
|
16
|
+
files.forEach(file => {
|
17
|
+
let matches = file.match(/([a-zA-Z0-9_]+)\.js$/);
|
18
|
+
const name = matches[1];
|
19
|
+
|
20
|
+
const content = `${fs.readFileSync(file)}`;
|
21
|
+
matches = content.match(/tag: "(.*?)",/);
|
22
|
+
if (matches) {
|
23
|
+
const tag = matches[1];
|
24
|
+
tagsToFiles.set(tag, name);
|
25
|
+
filesToTags.set(name, tag);
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
// Process the package
|
30
|
+
files = glob.sync(path.join(projectPath, "src/**/*.js"));
|
31
|
+
tagsToFiles.forEach((file, tag) => {
|
32
|
+
const sourcePath = path.join(projectPath, "src/", `${file}.js`);
|
33
|
+
if (!fs.existsSync(sourcePath)) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
const sourceContent = `${fs.readFileSync(sourcePath)}`.split("\n").join(" ");
|
37
|
+
|
38
|
+
const hbsPath = path.join(projectPath, "src/", `${file}.hbs`);
|
39
|
+
const hbsContent = fs.existsSync(hbsPath) ? `${fs.readFileSync(hbsPath)}` : "";
|
40
|
+
|
41
|
+
const hbsPopoverPath = path.join(projectPath, "src/", `${file}Popover.hbs`);
|
42
|
+
const hbsPopoverContent = fs.existsSync(hbsPopoverPath) ? `${fs.readFileSync(hbsPopoverPath)}` : "";
|
43
|
+
|
44
|
+
// deps
|
45
|
+
let deps = [];
|
46
|
+
let matches = sourceContent.match(/static get dependencies\(\) \{\s+return \[(.*?)\]/);
|
47
|
+
if (matches) {
|
48
|
+
deps = matches[1].split(",").map(x => x.trim()).filter(x => !!x);
|
49
|
+
}
|
50
|
+
|
51
|
+
// tags
|
52
|
+
matches = [
|
53
|
+
...hbsContent.matchAll(/<ui5-[a-z0-9-]+/g),
|
54
|
+
...hbsPopoverContent.matchAll(/<ui5-[a-z0-9-]+/g),
|
55
|
+
];
|
56
|
+
if (matches) {
|
57
|
+
matches.forEach(match => {
|
58
|
+
const tagUsed = match[0].substr(1);
|
59
|
+
const dep = tagsToFiles.get(tagUsed);
|
60
|
+
if (!deps.includes(dep)) {
|
61
|
+
console.log(`${file} used ${tagUsed}`);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const glob = require("glob");
|
3
|
+
const path = require("path");
|
4
|
+
const process = require("process");
|
5
|
+
|
6
|
+
// gather all tags from all files
|
7
|
+
const tags = new Set();
|
8
|
+
const files = glob.sync(path.join(process.argv[2], "src/**/*.js"));
|
9
|
+
files.forEach(file => {
|
10
|
+
const content = `${fs.readFileSync(file)}`;
|
11
|
+
const matches = content.match(/tag: "(.*?)",/);
|
12
|
+
if (matches) {
|
13
|
+
tags.add(matches[1]);
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
// report all usages of any tag within any file, which is not the tag definition and is not hasAttribute
|
18
|
+
files.forEach(file => {
|
19
|
+
const content = `${fs.readFileSync(file)}`;
|
20
|
+
const lines = content.split("\n");
|
21
|
+
lines.forEach(line => {
|
22
|
+
tags.forEach(tag => {
|
23
|
+
if (line.includes(`"${tag}"`) && !line.includes(`tag: "${tag}",`) && !line.includes(`hasAttribute("${tag}")`)) {
|
24
|
+
console.log(`${file}: ${line.trim()}`);
|
25
|
+
}
|
26
|
+
});
|
27
|
+
});
|
28
|
+
});
|
@@ -0,0 +1,40 @@
|
|
1
|
+
const fs = require("fs");
|
2
|
+
const path = require("path");
|
3
|
+
const glob = require("glob");
|
4
|
+
const getAllTags = require("./get-all-tags.js");
|
5
|
+
|
6
|
+
const root = process.argv[2];
|
7
|
+
const suffix = process.argv[3];
|
8
|
+
|
9
|
+
const tags = getAllTags(process.cwd());
|
10
|
+
|
11
|
+
// Replaces tags in HTML content, f.e. <ui5-button> with <ui5-button-ver> or </ui5-button> with </ui5-button-ver>
|
12
|
+
const replaceTagsHTML = content => {
|
13
|
+
tags.forEach(tag => {
|
14
|
+
content = content.replace(new RegExp(`(<\/?)(${tag})(\/?[> \t\n])`, "g"), `$1$2-${suffix}$3`);
|
15
|
+
});
|
16
|
+
return content;
|
17
|
+
};
|
18
|
+
|
19
|
+
// Replace tags in any content
|
20
|
+
const replaceTagsAny = content => {
|
21
|
+
tags.forEach(tag => {
|
22
|
+
content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
|
23
|
+
});
|
24
|
+
return content;
|
25
|
+
};
|
26
|
+
|
27
|
+
// Replace bundle names and HTML tag names in test pages
|
28
|
+
glob.sync(path.join(root, "/**/*.html")).forEach(file => {
|
29
|
+
let content = String(fs.readFileSync(file));
|
30
|
+
content = content.replace(/bundle\.(.*?)\.js/g, `bundle.scoped.$1.js`);
|
31
|
+
content = replaceTagsHTML(content);
|
32
|
+
fs.writeFileSync(file, content);
|
33
|
+
});
|
34
|
+
|
35
|
+
// Replace tag names everywhere
|
36
|
+
glob.sync(path.join(root, "/**/*.{html,css,js}")).forEach(file => {
|
37
|
+
let content = String(fs.readFileSync(file));
|
38
|
+
content = replaceTagsAny(content);
|
39
|
+
fs.writeFileSync(file, content);
|
40
|
+
});
|
@@ -0,0 +1,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("cli-color");
|
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
|
@@ -0,0 +1,48 @@
|
|
1
|
+
{
|
2
|
+
"name": "@ui5/webcomponents-tools",
|
3
|
+
"version": "1.0.0-rc.8",
|
4
|
+
"lockfileVersion": 1,
|
5
|
+
"requires": true,
|
6
|
+
"dependencies": {
|
7
|
+
"balanced-match": {
|
8
|
+
"version": "1.0.0",
|
9
|
+
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
10
|
+
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
11
|
+
"dev": true
|
12
|
+
},
|
13
|
+
"brace-expansion": {
|
14
|
+
"version": "1.1.11",
|
15
|
+
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
16
|
+
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
17
|
+
"dev": true,
|
18
|
+
"requires": {
|
19
|
+
"balanced-match": "^1.0.0",
|
20
|
+
"concat-map": "0.0.1"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
"concat-map": {
|
24
|
+
"version": "0.0.1",
|
25
|
+
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
26
|
+
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
27
|
+
"dev": true
|
28
|
+
},
|
29
|
+
"minimatch": {
|
30
|
+
"version": "3.0.4",
|
31
|
+
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
32
|
+
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
33
|
+
"dev": true,
|
34
|
+
"requires": {
|
35
|
+
"brace-expansion": "^1.1.7"
|
36
|
+
}
|
37
|
+
},
|
38
|
+
"recursive-readdir": {
|
39
|
+
"version": "2.2.2",
|
40
|
+
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
|
41
|
+
"integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==",
|
42
|
+
"dev": true,
|
43
|
+
"requires": {
|
44
|
+
"minimatch": "3.0.4"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|