@ui5/create-webcomponents-package 0.0.0-e55c2cec6 → 0.0.0-e5b03d3e8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +1463 -0
  2. package/README.md +30 -12
  3. package/create-package.js +215 -0
  4. package/package.json +4 -3
  5. package/template/.eslintignore +2 -0
  6. package/template/.eslintrc.cjs +5 -0
  7. package/template/.npsrc.json +3 -0
  8. package/template/bundle.esm.js +0 -2
  9. package/template/gitignore +3 -0
  10. package/template/npmrc +2 -0
  11. package/template/{package-scripts.js → package-scripts.cjs} +1 -1
  12. package/template/src/MyFirstComponent.ts +56 -0
  13. package/template/src/MyFirstComponentTemplate.tsx +9 -0
  14. package/template/src/i18n/messagebundle.properties +3 -2
  15. package/template/src/i18n/messagebundle_de.properties +1 -1
  16. package/template/src/i18n/messagebundle_en.properties +1 -1
  17. package/template/src/i18n/messagebundle_es.properties +1 -1
  18. package/template/src/i18n/messagebundle_fr.properties +1 -1
  19. package/template/src/themes/MyFirstComponent.css +16 -10
  20. package/template/src/themes/sap_fiori_3/parameters-bundle.css +1 -1
  21. package/template/src/themes/sap_horizon_dark/parameters-bundle.css +3 -0
  22. package/template/src/themes/sap_horizon_hcb/parameters-bundle.css +3 -0
  23. package/template/test/pages/css/index.css +41 -0
  24. package/template/test/pages/img/logo.png +0 -0
  25. package/template/test/pages/index.html +35 -30
  26. package/template/test/specs/Demo.spec.js +4 -3
  27. package/template/tsconfig.json +13 -0
  28. package/template/vite.config.js +14 -0
  29. package/index.js +0 -169
  30. package/template/config/postcss.components/postcss.config.js +0 -1
  31. package/template/config/postcss.themes/postcss.config.js +0 -1
  32. package/template/src/MyFirstComponent.hbs +0 -1
  33. package/template/src/MyFirstComponent.js +0 -67
  34. package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  35. package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  36. package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  37. package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  38. /package/template/config/{wdio.conf.js → wdio.conf.cjs} +0 -0
  39. /package/template/src/{Assets.js → Assets.ts} +0 -0
  40. /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
  41. /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
@@ -0,0 +1,14 @@
1
+ import viteConfig from "@ui5/webcomponents-tools/components-package/vite.config.js"; //eslint-disable-line
2
+
3
+ // Modifying the default Vite configuration provided by the @ui5/webcomponents-tools package.
4
+ // You can directly access and update the properties you need to change.
5
+ // Ensure that the property exists before modifying it to avoid unintended errors.
6
+ // For available configuration options, refer to: https://vite.dev/config/#configuring-vite
7
+ //
8
+ // Ensure the plugins array exists
9
+ // viteConfig.plugins = viteConfig.plugins || [];
10
+ //
11
+ // Push a new fake plugin
12
+ // viteConfig.plugins.push({ name: 'my-custom-plugin' });
13
+
14
+ export default viteConfig;
package/index.js DELETED
@@ -1,169 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const mkdirp = require("mkdirp");
6
- const prompts = require("prompts");
7
- const parser = require("npm-config-user-agent-parser");
8
-
9
- const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))).version;
10
-
11
- // from where all the files will be copied
12
- const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
13
-
14
- // String utils
15
- const capitalizeFirst = str => str.substr(0,1).toUpperCase() + str.substr(1);
16
- const kebabToCamelCase = string => toCamelCase(string.split("-"));
17
- const toCamelCase = parts => {
18
- return parts.map((string, index) => {
19
- return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
20
- }).join("");
21
- };
22
-
23
- // Validation of user input
24
- const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
25
- const isPortValid = port => typeof port === "string" && port.match(/^[0-9]+$/);
26
- const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
27
-
28
- // Utils for building the file structure
29
- const replaceVarsInFileContent = (vars, content) => {
30
- for (let key in vars) {
31
- const re = new RegExp(key, "g");
32
- content = content.replace(re, vars[key]);
33
- }
34
- return content;
35
- };
36
-
37
- const replaceVarsInFileName = (vars, fileName) => {
38
- return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
39
- };
40
-
41
- const copyFile = (vars, sourcePath, destPath) => {
42
- let content = fs.readFileSync(sourcePath, {encoding: "UTF-8"});
43
- content = replaceVarsInFileContent(vars, content);
44
- destPath = replaceVarsInFileName(vars, destPath);
45
- fs.writeFileSync(destPath, content);
46
- };
47
-
48
- const copyFiles = (vars, sourcePath, destPath) => {
49
- const isDir = fs.lstatSync(sourcePath).isDirectory();
50
- if (isDir) {
51
- if (destPath) {
52
- mkdirp.sync(destPath);
53
- }
54
- fs.readdirSync(sourcePath).forEach(file => {
55
- copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
56
- });
57
- } else {
58
- copyFile(vars, sourcePath, destPath);
59
- }
60
- };
61
-
62
- // Main function
63
- const createWebcomponentsPackage = async () => {
64
- let response;
65
-
66
- // Get the name
67
- let name = process.argv[2];
68
-
69
- if (!isNameValid(name)) {
70
- response = await prompts({
71
- type: "text",
72
- name: "name",
73
- message: "Package name:",
74
- validate: isNameValid,
75
- });
76
- name = response.name;
77
- }
78
-
79
- // Get the port
80
- response = await prompts({
81
- type: "text",
82
- name: "port",
83
- message: "Dev server port:",
84
- validate: isPortValid,
85
- initial: "8080",
86
- });
87
- const port = response.port;
88
-
89
- // Get the tag
90
- response = await prompts({
91
- type: "text",
92
- name: "tag",
93
- message: "Demo component name:",
94
- initial: "my-first-component",
95
- validate: isTagValid,
96
- });
97
- const tag = response.tag;
98
-
99
- const className = capitalizeFirst(kebabToCamelCase(tag));
100
-
101
- // All variables that will be replaced in the content of the resources/
102
- const vars = {
103
- INIT_PACKAGE_VAR_NAME: name,
104
- INIT_PACKAGE_VAR_PORT: port,
105
- INIT_PACKAGE_VAR_TAG: tag,
106
- INIT_PACKAGE_VAR_CLASS_NAME: className,
107
- };
108
-
109
- const packageContent = {
110
- name,
111
- version: "0.0.1",
112
- ui5: {
113
- webComponentsPackage: true,
114
- },
115
- scripts: {
116
- "clean": "wc-dev clean",
117
- "lint": "wc-dev lint",
118
- "start": "wc-dev start",
119
- "watch": "wc-dev watch",
120
- "build": "wc-dev build",
121
- "test": "wc-dev test",
122
- "create-ui5-element": "wc-create-ui5-element",
123
- "prepublishOnly": "npm run build",
124
- },
125
- exports: {
126
- "./.port": "./.port",
127
- "./src/*": "./src/*",
128
- "./dist/*": "./dist/*",
129
- "./package.json": "./package.json",
130
- "./bundle.js": "./bundle.js",
131
- "./*": "./dist/*",
132
- },
133
- "dependencies": {
134
- "@ui5/webcomponents-base": version,
135
- "@ui5/webcomponents-theming": version,
136
- },
137
- "devDependencies": {
138
- "@ui5/webcomponents-tools": version,
139
- "chromedriver": "*",
140
- },
141
- };
142
-
143
- // Update package.json
144
- const destDir = path.join(`./`, name);
145
- mkdirp.sync(destDir);
146
- fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
147
- // Copy files
148
- copyFiles(vars, TEMPLATE_DIR, destDir);
149
-
150
- console.log("\nPackage successfully created!\nNext steps:\n");
151
- console.log(`$ cd ${name}`);
152
-
153
- let userAgentInfo;
154
- try {
155
- userAgentInfo = parser(process.env.npm_config_user_agent);
156
- } catch (e) {}
157
-
158
- if (userAgentInfo && userAgentInfo.yarn) {
159
- console.log(`$ yarn`);
160
- console.log(`$ yarn start`);
161
- } else {
162
- console.log(`$ npm i`);
163
- console.log(`$ npm start`);
164
- }
165
-
166
- console.log("\n");
167
- };
168
-
169
- createWebcomponentsPackage();
@@ -1 +0,0 @@
1
- module.exports = require("@ui5/webcomponents-tools/components-package/postcss.components.js"); // eslint-disable-line
@@ -1 +0,0 @@
1
- module.exports = require("@ui5/webcomponents-tools/components-package/postcss.themes.js"); // eslint-disable-line
@@ -1 +0,0 @@
1
- <div>This is: INIT_PACKAGE_VAR_TAG. {{pleaseWaitText}}</div>
@@ -1,67 +0,0 @@
1
- import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
- import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3
- import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
4
-
5
- // Template
6
- import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
7
-
8
- // Styles
9
- import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
10
-
11
- import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
12
-
13
- /**
14
- * @public
15
- */
16
- const metadata = {
17
- tag: "INIT_PACKAGE_VAR_TAG",
18
- properties: {
19
- },
20
- slots: {
21
- },
22
- events: {
23
- },
24
- };
25
-
26
- /**
27
- * @class
28
- *
29
- * <h3 class="comment-api-title">Overview</h3>
30
- *
31
- * The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
32
- *
33
- * @constructor
34
- * @alias demo.components.INIT_PACKAGE_VAR_CLASS_NAME
35
- * @extends sap.ui.webc.base.UI5Element
36
- * @tagname INIT_PACKAGE_VAR_TAG
37
- * @public
38
- */
39
- class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
40
- static get metadata() {
41
- return metadata;
42
- }
43
-
44
- static get render() {
45
- return litRender;
46
- }
47
-
48
- static get template() {
49
- return INIT_PACKAGE_VAR_CLASS_NAMETemplate;
50
- }
51
-
52
- static get styles() {
53
- return INIT_PACKAGE_VAR_CLASS_NAMECss;
54
- }
55
-
56
- static async onDefine() {
57
- INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
58
- }
59
-
60
- get pleaseWaitText() {
61
- return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(PLEASE_WAIT);
62
- }
63
- }
64
-
65
- INIT_PACKAGE_VAR_CLASS_NAME.define();
66
-
67
- export default INIT_PACKAGE_VAR_CLASS_NAME;
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: black;
3
- }
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: blue;
3
- }
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: lightblue;
3
- }
@@ -1,3 +0,0 @@
1
- :root {
2
- --my-component-border-color: gray;
3
- }
File without changes
File without changes