@ui5/create-webcomponents-package 0.0.0-b6f02e4b3 → 0.0.0-b804b8982

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 (43) hide show
  1. package/CHANGELOG.md +1530 -0
  2. package/README.md +33 -16
  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 +36 -33
  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 -168
  30. package/template/config/.eslintrc.js +0 -1
  31. package/template/config/postcss.components/postcss.config.js +0 -1
  32. package/template/config/postcss.themes/postcss.config.js +0 -1
  33. package/template/config/rollup.config.js +0 -1
  34. package/template/src/MyFirstComponent.hbs +0 -1
  35. package/template/src/MyFirstComponent.js +0 -51
  36. package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  37. package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  38. package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  39. package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  40. /package/template/config/{wdio.conf.js → wdio.conf.cjs} +0 -0
  41. /package/template/src/{Assets.js → Assets.ts} +0 -0
  42. /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
  43. /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "@ui5/webcomponents-tools/tsconfig.json",
3
+ "include": [
4
+ "src/**/*",
5
+ "global.d.ts"
6
+ ],
7
+ "compilerOptions": {
8
+ "outDir": "dist",
9
+ "experimentalDecorators": true,
10
+ "module": "NodeNext",
11
+ "moduleResolution": "NodeNext",
12
+ },
13
+ }
@@ -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,168 +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
- // from where all the files will be copied
10
- const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
11
-
12
- // String utils
13
- const capitalizeFirst = str => str.substr(0,1).toUpperCase() + str.substr(1);
14
- const kebabToCamelCase = string => toCamelCase(string.split("-"));
15
- const toCamelCase = parts => {
16
- return parts.map((string, index) => {
17
- return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
18
- }).join("");
19
- };
20
-
21
- // Validation of user input
22
- const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
23
- const isPortValid = port => typeof port === "string" && port.match(/^[0-9]+$/);
24
- const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
25
-
26
- // Utils for building the file structure
27
- const replaceVarsInFileContent = (vars, content) => {
28
- for (let key in vars) {
29
- const re = new RegExp(key, "g");
30
- content = content.replace(re, vars[key]);
31
- }
32
- return content;
33
- };
34
-
35
- const replaceVarsInFileName = (vars, fileName) => {
36
- return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
37
- };
38
-
39
- const copyFile = (vars, sourcePath, destPath) => {
40
- let content = fs.readFileSync(sourcePath, {encoding: "UTF-8"});
41
- content = replaceVarsInFileContent(vars, content);
42
- destPath = replaceVarsInFileName(vars, destPath);
43
- fs.writeFileSync(destPath, content);
44
- };
45
-
46
- const copyFiles = (vars, sourcePath, destPath) => {
47
- const isDir = fs.lstatSync(sourcePath).isDirectory();
48
- if (isDir) {
49
- if (destPath) {
50
- mkdirp.sync(destPath);
51
- }
52
- fs.readdirSync(sourcePath).forEach(file => {
53
- copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
54
- });
55
- } else {
56
- copyFile(vars, sourcePath, destPath);
57
- }
58
- };
59
-
60
- // Main function
61
- const createWebcomponentsPackage = async () => {
62
- let response;
63
-
64
- // Get the name
65
- let name = process.argv[2];
66
-
67
- if (!isNameValid(name)) {
68
- response = await prompts({
69
- type: "text",
70
- name: "name",
71
- message: "Package name:",
72
- validate: isNameValid,
73
- });
74
- name = response.name;
75
- }
76
-
77
- // Get the port
78
- response = await prompts({
79
- type: "text",
80
- name: "port",
81
- message: "Dev server port:",
82
- validate: isPortValid,
83
- initial: "8080",
84
- });
85
- const port = response.port;
86
-
87
- // Get the tag
88
- response = await prompts({
89
- type: "text",
90
- name: "tag",
91
- message: "Demo component name:",
92
- initial: "my-first-component",
93
- validate: isTagValid,
94
- });
95
- const tag = response.tag;
96
-
97
- const className = capitalizeFirst(kebabToCamelCase(tag));
98
-
99
- // All variables that will be replaced in the content of the resources/
100
- const vars = {
101
- INIT_PACKAGE_VAR_NAME: name,
102
- INIT_PACKAGE_VAR_PORT: port,
103
- INIT_PACKAGE_VAR_TAG: tag,
104
- INIT_PACKAGE_VAR_CLASS_NAME: className,
105
- };
106
-
107
- const packageContent = {
108
- name,
109
- version: "0.0.1",
110
- ui5: {
111
- webComponentsPackage: true,
112
- },
113
- scripts: {
114
- "clean": "wc-dev clean",
115
- "lint": "wc-dev lint",
116
- "start": "wc-dev start",
117
- "watch": "wc-dev watch",
118
- "serve": "wc-dev serve",
119
- "build": "wc-dev build",
120
- "test": "wc-dev test",
121
- "create-ui5-element": "wc-create-ui5-element",
122
- "prepublishOnly": "npm run build",
123
- },
124
- exports: {
125
- "./.port": "./.port",
126
- "./src/*": "./src/*",
127
- "./dist/*": "./dist/*",
128
- "./package.json": "./package.json",
129
- "./bundle.js": "./bundle.js",
130
- "./*": "./dist/*",
131
- },
132
- "dependencies": {
133
- "@ui5/webcomponents-base": "1.1.1",
134
- "@ui5/webcomponents-theming": "1.1.1",
135
- },
136
- "devDependencies": {
137
- "@ui5/webcomponents-tools": "1.1.1",
138
- "chromedriver": "*",
139
- },
140
- };
141
-
142
- // Update package.json
143
- const destDir = path.join(`./`, name);
144
- mkdirp.sync(destDir);
145
- fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
146
- // Copy files
147
- copyFiles(vars, TEMPLATE_DIR, destDir);
148
-
149
- console.log("\nPackage successfully created!\nNext steps:\n");
150
- console.log(`$ cd ${name}`);
151
-
152
- let userAgentInfo;
153
- try {
154
- userAgentInfo = parser(process.env.npm_config_user_agent);
155
- } catch (e) {}
156
-
157
- if (userAgentInfo && userAgentInfo.yarn) {
158
- console.log(`$ yarn`);
159
- console.log(`$ yarn start`);
160
- } else {
161
- console.log(`$ npm i`);
162
- console.log(`$ npm start`);
163
- }
164
-
165
- console.log("\n");
166
- };
167
-
168
- createWebcomponentsPackage();
@@ -1 +0,0 @@
1
- module.exports = require("@ui5/webcomponents-tools/components-package/eslint.js"); // eslint-disable-line
@@ -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
- module.exports = require("@ui5/webcomponents-tools/components-package/rollup.js"); // eslint-disable-line
@@ -1 +0,0 @@
1
- <div>This is: INIT_PACKAGE_VAR_TAG. {{pleaseWaitText}}</div>
@@ -1,51 +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
- const metadata = {
14
- tag: "INIT_PACKAGE_VAR_TAG",
15
- properties: {
16
- },
17
- slots: {
18
- },
19
- events: {
20
- },
21
- };
22
-
23
- class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
24
- static get metadata() {
25
- return metadata;
26
- }
27
-
28
- static get render() {
29
- return litRender;
30
- }
31
-
32
- static get template() {
33
- return INIT_PACKAGE_VAR_CLASS_NAMETemplate;
34
- }
35
-
36
- static get styles() {
37
- return INIT_PACKAGE_VAR_CLASS_NAMECss;
38
- }
39
-
40
- static async onDefine() {
41
- INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
42
- }
43
-
44
- get pleaseWaitText() {
45
- return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(PLEASE_WAIT);
46
- }
47
- }
48
-
49
- INIT_PACKAGE_VAR_CLASS_NAME.define();
50
-
51
- 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