@ui5/webcomponents-tools 0.0.0-c6155714e → 0.0.0-c638668a1
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 +164 -1
- package/README.md +1 -1
- package/assets-meta.js +149 -0
- package/bin/dev.js +16 -1
- package/components-package/nps.js +73 -34
- 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 +102 -60
- 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 +45 -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/template.js +1 -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 -13
- 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 +57 -11
- 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 +24 -4
- package/lib/jsdoc/template/publish.js +11 -2
- 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/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/scope-test-pages.js +40 -0
- package/lib/serve/index.js +46 -0
- package/{components-package → lib/serve}/serve.json +0 -0
- package/package.json +55 -55
- package/bin/init-ui5-package.js +0 -3
- package/lib/init-package/index.js +0 -119
- 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/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 -57
- 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/test/pages/index.html +0 -51
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
- package/package-lock.json +0 -9994
@@ -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,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,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
|
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-c638668a1",
|
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,61 +21,62 @@
|
|
22
21
|
"directory": "packages/tools"
|
23
22
|
},
|
24
23
|
"dependencies": {
|
25
|
-
"@babel/
|
26
|
-
"@babel/
|
27
|
-
"@
|
28
|
-
"@
|
29
|
-
"@
|
30
|
-
"@
|
31
|
-
"@
|
32
|
-
"@
|
33
|
-
"@
|
34
|
-
"@wdio/
|
35
|
-
"@
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"
|
39
|
-
"
|
24
|
+
"@babel/core": "^7.13.10",
|
25
|
+
"@babel/preset-env": "^7.13.10",
|
26
|
+
"@openui5/sap.ui.core": "1.95.0",
|
27
|
+
"@rollup/plugin-babel": "^5.3.0",
|
28
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
29
|
+
"@rollup/plugin-json": "^4.1.0",
|
30
|
+
"@rollup/plugin-node-resolve": "^13.0.5",
|
31
|
+
"@rollup/plugin-replace": "^3.0.0",
|
32
|
+
"@rollup/plugin-url": "^6.0.0",
|
33
|
+
"@wdio/cli": "^7.12.2",
|
34
|
+
"@wdio/dot-reporter": "^7.10.1",
|
35
|
+
"@wdio/local-runner": "^7.12.2",
|
36
|
+
"@wdio/mocha-framework": "^7.12.2",
|
37
|
+
"@wdio/spec-reporter": "^7.10.1",
|
38
|
+
"@webcomponents/webcomponentsjs": "^2.5.0",
|
39
|
+
"chai": "^4.3.4",
|
40
|
+
"child_process": "^1.0.2",
|
41
|
+
"chokidar": "^3.5.1",
|
42
|
+
"chokidar-cli": "^3.0.0",
|
43
|
+
"cli-color": "^2.0.1",
|
40
44
|
"command-line-args": "^5.1.1",
|
41
|
-
"concurrently": "^
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"eslint": "^
|
47
|
-
"eslint-
|
48
|
-
"eslint-plugin-import": "^2.14.0",
|
45
|
+
"concurrently": "^6.0.0",
|
46
|
+
"cross-env": "^7.0.3",
|
47
|
+
"cssnano": "^4.1.11",
|
48
|
+
"escodegen": "^2.0.0",
|
49
|
+
"eslint": "^7.22.0",
|
50
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
51
|
+
"eslint-plugin-import": "^2.22.1",
|
49
52
|
"esprima": "^4.0.1",
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
53
|
+
"folder-hash": "^4.0.1",
|
54
|
+
"getopts": "^2.3.0",
|
55
|
+
"glob": "^7.1.6",
|
56
|
+
"glob-parent": "^6.0.2",
|
57
|
+
"handlebars": "^4.7.7",
|
58
|
+
"is-port-reachable": "^3.1.0",
|
59
|
+
"jsdoc": "^3.6.6",
|
54
60
|
"json-beautify": "^1.1.1",
|
55
|
-
"mkdirp": "^0.
|
56
|
-
"
|
57
|
-
"
|
58
|
-
"postcss": "^
|
59
|
-
"postcss-
|
60
|
-
"postcss-
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
64
|
-
"rimraf": "^
|
65
|
-
"rollup": "^
|
66
|
-
"rollup-plugin-
|
67
|
-
"rollup-plugin-
|
68
|
-
"rollup-plugin-
|
69
|
-
"
|
70
|
-
"
|
71
|
-
"
|
72
|
-
"rollup-plugin-string": "^2.0.2",
|
73
|
-
"rollup-plugin-terser": "^5.1.3",
|
74
|
-
"rollup-plugin-url": "^2.2.0",
|
75
|
-
"rollup-plugin-visualizer": "^0.9.2",
|
76
|
-
"serve": "^10.1.1",
|
77
|
-
"wdio-chromedriver-service": "^5.0.2"
|
61
|
+
"mkdirp": "^1.0.4",
|
62
|
+
"nps": "^5.10.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",
|
67
|
+
"properties-reader": "^2.2.0",
|
68
|
+
"recursive-readdir": "^2.2.2",
|
69
|
+
"resolve": "^1.20.0",
|
70
|
+
"rimraf": "^3.0.2",
|
71
|
+
"rollup": "^2.41.4",
|
72
|
+
"rollup-plugin-filesize": "^9.1.1",
|
73
|
+
"rollup-plugin-livereload": "^2.0.0",
|
74
|
+
"rollup-plugin-terser": "^7.0.2",
|
75
|
+
"serve": "^12.0.0",
|
76
|
+
"slash": "3.0.0",
|
77
|
+
"wdio-chromedriver-service": "^7.0.0"
|
78
78
|
},
|
79
|
-
"
|
80
|
-
"
|
79
|
+
"peerDependencies": {
|
80
|
+
"chromedriver": "*"
|
81
81
|
}
|
82
82
|
}
|
package/bin/init-ui5-package.js
DELETED
@@ -1,119 +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 = 'ui5-demo';
|
21
|
-
const BETA_VER = "0.18.0";
|
22
|
-
const RC_VER = "1.0.0-rc.5";
|
23
|
-
|
24
|
-
// from where all the files will be copied
|
25
|
-
const RESOURCES_DIR = path.join(`${__dirname}`, `resources/`);
|
26
|
-
|
27
|
-
// Command line options
|
28
|
-
const options = commandLineArgs([
|
29
|
-
{name: 'port', alias: 'p', type: Number},
|
30
|
-
{name: 'tag', type: String},
|
31
|
-
]);
|
32
|
-
|
33
|
-
// Ensure there is package.json
|
34
|
-
try {
|
35
|
-
packageContent = JSON.parse(fs.readFileSync("package.json"));
|
36
|
-
} catch (err) {
|
37
|
-
console.log("No package.json found, please run: 'npm init' first");
|
38
|
-
process.exit(1);
|
39
|
-
}
|
40
|
-
|
41
|
-
// Ensure correct tag
|
42
|
-
const tag = options.tag || DEFAULT_TAG;
|
43
|
-
if (!tag.match(/^ui5-/)) {
|
44
|
-
console.log("tag name should start with ui5-");
|
45
|
-
process.exit(1);
|
46
|
-
}
|
47
|
-
const className = capitalizeFirst(kebabToCamelCase(tag.substr(4)));
|
48
|
-
|
49
|
-
// All variables that will be replaced in the content of the resources/
|
50
|
-
const vars = {
|
51
|
-
INIT_PACKAGE_VAR_NAME: packageContent.name,
|
52
|
-
INIT_PACKAGE_VAR_PORT: options.port || DEFAULT_PORT,
|
53
|
-
INIT_PACKAGE_VAR_TAG: tag,
|
54
|
-
INIT_PACKAGE_VAR_CLASS_NAME: className,
|
55
|
-
};
|
56
|
-
console.log(vars);
|
57
|
-
|
58
|
-
const replaceVarsInFileContent = content => {
|
59
|
-
for (let key in vars) {
|
60
|
-
const re = new RegExp(key, "g");
|
61
|
-
content = content.replace(re, vars[key]);
|
62
|
-
}
|
63
|
-
return content;
|
64
|
-
};
|
65
|
-
|
66
|
-
const replaceVarsInFileName = fileName => {
|
67
|
-
return fileName.replace(/Demo/, vars.INIT_PACKAGE_VAR_CLASS_NAME) ;
|
68
|
-
};
|
69
|
-
|
70
|
-
const copyFile = (sourcePath, destPath) => {
|
71
|
-
let content = fs.readFileSync(sourcePath, {encoding: "UTF-8"});
|
72
|
-
content = replaceVarsInFileContent(content);
|
73
|
-
destPath = replaceVarsInFileName(destPath);
|
74
|
-
fs.writeFileSync(destPath, content);
|
75
|
-
console.log(destPath);
|
76
|
-
};
|
77
|
-
|
78
|
-
const copyResources = sourcePath => {
|
79
|
-
const destPath = sourcePath.substr(RESOURCES_DIR.length);
|
80
|
-
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
81
|
-
if (isDir) {
|
82
|
-
if (destPath) {
|
83
|
-
mkdirp.sync(destPath);
|
84
|
-
console.log(destPath);
|
85
|
-
}
|
86
|
-
fs.readdirSync(sourcePath).forEach(file => {
|
87
|
-
copyResources(path.join(sourcePath, file));
|
88
|
-
});
|
89
|
-
} else {
|
90
|
-
copyFile(sourcePath, destPath);
|
91
|
-
}
|
92
|
-
};
|
93
|
-
|
94
|
-
const updatePackageFile = () => {
|
95
|
-
packageContent.scripts = {
|
96
|
-
"clean": "wc-dev clean",
|
97
|
-
"lint": "wc-dev lint",
|
98
|
-
"start": "wc-dev start",
|
99
|
-
"build": "wc-dev build",
|
100
|
-
"test": "wc-dev test",
|
101
|
-
"create-ui5-element": "wc-create-ui5-element",
|
102
|
-
"prepublishOnly": "npm run build"
|
103
|
-
};
|
104
|
-
|
105
|
-
packageContent.dependencies = packageContent.dependencies || {};
|
106
|
-
packageContent.dependencies["@ui5/webcomponents-base"] = BETA_VER;
|
107
|
-
packageContent.dependencies["@ui5/webcomponents-theme-base"] = RC_VER;
|
108
|
-
packageContent.dependencies["@ui5/webcomponents-tools"] = RC_VER;
|
109
|
-
|
110
|
-
fs.writeFileSync("package.json", beautify(packageContent, null, 2, 100));
|
111
|
-
};
|
112
|
-
|
113
|
-
// Copy files
|
114
|
-
copyResources(RESOURCES_DIR);
|
115
|
-
|
116
|
-
// Update package.json
|
117
|
-
updatePackageFile();
|
118
|
-
|
119
|
-
console.log("Package successfully initialized.");
|
@@ -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
|
-
<div>This is: INIT_PACKAGE_VAR_TAG. {{pleaseWaitText}}</div>
|