@ui5/create-webcomponents-package 0.0.0-ee3bbe46b → 0.0.0-f42e7c18c

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 (38) hide show
  1. package/CHANGELOG.md +1284 -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.hbs +6 -1
  13. package/template/src/{MyFirstComponent.js → MyFirstComponent.ts} +25 -33
  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/index.js +0 -169
  29. package/template/config/postcss.components/postcss.config.js +0 -1
  30. package/template/config/postcss.themes/postcss.config.js +0 -1
  31. package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  32. package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  33. package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  34. package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  35. /package/template/config/{wdio.conf.js → wdio.conf.cjs} +0 -0
  36. /package/template/src/{Assets.js → Assets.ts} +0 -0
  37. /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
  38. /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
@@ -1,10 +1,11 @@
1
- const assert = require("assert");
1
+ import { assert } from "chai";
2
2
 
3
3
  describe("INIT_PACKAGE_VAR_TAG rendering", async () => {
4
- await browser.url("test/pages/index.html");
4
+ before(async () => {
5
+ await browser.url("test/pages/index.html");
6
+ });
5
7
 
6
8
  it("tests if web component is correctly rendered", async () => {
7
-
8
9
  const innerContent = await browser.$("#myFirstComponent").shadow$("div");
9
10
 
10
11
  assert.ok(innerContent, "content rendered");
@@ -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
+ }
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,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