@ui5/create-webcomponents-package 0.0.0-4e88b8243 → 0.0.0-50f1454ef
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 +211 -0
- package/README.md +6 -8
- package/create-package.js +177 -156
- package/package.json +4 -1
- package/template/.eslintignore +3 -1
- package/template/cypress/component/MyFirstComponent.cy.tsx +13 -0
- package/template/cypress/fixtures/example.json +5 -0
- package/template/cypress/support/commands.ts +37 -0
- package/template/cypress/support/component-index.html +12 -0
- package/template/cypress/support/component.ts +36 -0
- package/template/cypress/tsconfig.template.json +19 -0
- package/template/cypress.config.ts +10 -0
- package/template/env +1 -0
- package/template/gitignore +2 -1
- package/template/package.json +35 -0
- package/template/src/Assets.ts +1 -1
- package/template/src/MyFirstComponent.ts +12 -15
- package/template/src/MyFirstComponentTemplate.tsx +9 -9
- package/template/{bundle.esm.js → src/bundle.esm.ts} +4 -3
- package/template/test/pages/css/index.css +62 -14
- package/template/test/pages/index.html +36 -40
- package/template/{tsconfig.json → tsconfig.template.json} +2 -1
- package/template/vite.config.js +14 -0
- package/template/config/wdio.conf.cjs +0 -1
- package/template/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/template/test/specs/Demo.spec.js +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,217 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.11.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.11.0-rc.0...v2.11.0-rc.1) (2025-05-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.11.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.10.0...v2.11.0-rc.0) (2025-05-08)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [2.10.0](https://github.com/SAP/ui5-webcomponents/compare/v2.10.0-rc.3...v2.10.0) (2025-05-07)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [2.10.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v2.10.0-rc.2...v2.10.0-rc.3) (2025-05-01)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [2.10.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.10.0-rc.1...v2.10.0-rc.2) (2025-04-24)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# [2.10.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.10.0-rc.0...v2.10.0-rc.1) (2025-04-17)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [2.10.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.9.1-rc.0...v2.10.0-rc.0) (2025-04-14)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## [2.9.1-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0...v2.9.1-rc.0) (2025-04-10)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# [2.9.0](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0-rc.3...v2.9.0) (2025-04-04)
|
|
71
|
+
|
|
72
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# [2.9.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0-rc.2...v2.9.0-rc.3) (2025-04-03)
|
|
79
|
+
|
|
80
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# [2.9.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0-rc.1...v2.9.0-rc.2) (2025-03-27)
|
|
87
|
+
|
|
88
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# [2.9.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0-rc.0...v2.9.0-rc.1) (2025-03-20)
|
|
95
|
+
|
|
96
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# [2.9.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.8.1-rc.0...v2.9.0-rc.0) (2025-03-13)
|
|
103
|
+
|
|
104
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## [2.8.1-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.8.0...v2.8.1-rc.0) (2025-03-06)
|
|
111
|
+
|
|
112
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# [2.8.0](https://github.com/SAP/ui5-webcomponents/compare/v2.8.0-rc.3...v2.8.0) (2025-03-04)
|
|
119
|
+
|
|
120
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# [2.8.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v2.8.0-rc.2...v2.8.0-rc.3) (2025-02-27)
|
|
127
|
+
|
|
128
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# [2.8.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.8.0-rc.1...v2.8.0-rc.2) (2025-02-20)
|
|
135
|
+
|
|
136
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# [2.8.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.8.0-rc.0...v2.8.0-rc.1) (2025-02-13)
|
|
143
|
+
|
|
144
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# [2.8.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.7.0...v2.8.0-rc.0) (2025-02-06)
|
|
151
|
+
|
|
152
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# [2.7.0](https://github.com/SAP/ui5-webcomponents/compare/v2.7.0-rc.2...v2.7.0) (2025-02-03)
|
|
159
|
+
|
|
160
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# [2.7.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.7.0-rc.1...v2.7.0-rc.2) (2025-01-30)
|
|
167
|
+
|
|
168
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# [2.7.0-rc.1](https://github.com/SAP/ui5-webcomponents/compare/v2.7.0-rc.0...v2.7.0-rc.1) (2025-01-23)
|
|
175
|
+
|
|
176
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# [2.7.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.6.2...v2.7.0-rc.0) (2025-01-16)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
### Features
|
|
186
|
+
|
|
187
|
+
* **create-package:** generate jsx component template ([#10531](https://github.com/SAP/ui5-webcomponents/issues/10531)) ([dd2d45d](https://github.com/SAP/ui5-webcomponents/commit/dd2d45d4c3947f52773272f6a77be294f240d28f))
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
## [2.6.2](https://github.com/SAP/ui5-webcomponents/compare/v2.6.2-rc.0...v2.6.2) (2025-01-09)
|
|
194
|
+
|
|
195
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
## [2.6.2-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.6.1...v2.6.2-rc.0) (2025-01-09)
|
|
202
|
+
|
|
203
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
## [2.6.1](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0...v2.6.1) (2025-01-08)
|
|
210
|
+
|
|
211
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
6
217
|
# [2.6.0](https://github.com/SAP/ui5-webcomponents/compare/v2.6.0-rc.5...v2.6.0) (2025-01-07)
|
|
7
218
|
|
|
8
219
|
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
package/README.md
CHANGED
|
@@ -15,10 +15,9 @@ Usage:
|
|
|
15
15
|
npm init @ui5/webcomponents-package -- [OPTIONS]
|
|
16
16
|
|
|
17
17
|
Options:
|
|
18
|
-
--name <string>
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
|
18
|
+
--name <string> - defines the package name
|
|
19
|
+
--test-setup <"cypress" | "manual"> - defines whether the predefined test setup should be added or it will be configured manually.
|
|
20
|
+
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
|
22
21
|
```
|
|
23
22
|
|
|
24
23
|
The script creates a new directory, and fills it with a `package.json` file and all necessary source files, and resources for a new
|
|
@@ -30,10 +29,9 @@ components package.
|
|
|
30
29
|
Usage:
|
|
31
30
|
yarn create @ui5/webcomponents-package [OPTIONS]
|
|
32
31
|
Options:
|
|
33
|
-
--name <string>
|
|
34
|
-
--
|
|
35
|
-
--
|
|
36
|
-
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
|
32
|
+
--name <string> - defines the package name
|
|
33
|
+
--test-setup <"cypress" | "manual"> - defines whether the predefined test setup should be added or it will be configured manually.
|
|
34
|
+
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
|
37
35
|
```
|
|
38
36
|
|
|
39
37
|
The script creates a new directory, and fills it with a `package.json` file and all necessary source files, and resources for a new
|
package/create-package.js
CHANGED
|
@@ -1,191 +1,200 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path, { dirname } from "path";
|
|
4
|
+
import prompts from "prompts";
|
|
5
|
+
import parser from "npm-config-user-agent-parser";
|
|
6
|
+
import yargs from "yargs/yargs";
|
|
7
|
+
import { globby } from "globby";
|
|
8
|
+
import { hideBin } from "yargs/helpers";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
import * as prettier from "prettier";
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
11
14
|
const argv = yargs(hideBin(process.argv)).argv;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
const VERSION = JSON.parse(
|
|
16
|
+
await fs.readFile(path.join(__dirname, "package.json")),
|
|
17
|
+
).version;
|
|
18
|
+
|
|
19
|
+
// Constants
|
|
20
|
+
const SUPPORTED_TEST_SETUPS = ["cypress", "manual"];
|
|
21
|
+
const SRC_DIR = "./template";
|
|
22
|
+
const FILES_TO_RENAME = {
|
|
23
|
+
"eslintignore": ".eslintignore",
|
|
24
|
+
"eslintrc.cjs": ".eslintrc.cjs",
|
|
25
|
+
"npsrc.json": ".npsrc.json",
|
|
26
|
+
"npmrc": ".npmrc",
|
|
27
|
+
"env": ".env",
|
|
28
|
+
"gitignore": ".gitignore",
|
|
29
|
+
"tsconfig.template.json": "tsconfig.json",
|
|
30
|
+
"cypress/tsconfig.template.json": "cypress/tsconfig.json"
|
|
26
31
|
};
|
|
32
|
+
const FILES_TO_COPY = ["test/pages/img/logo.png"];
|
|
33
|
+
|
|
34
|
+
// Validation Patterns
|
|
35
|
+
const PackageNamePattern =
|
|
36
|
+
/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
|
37
|
+
const TagPattern = /^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/;
|
|
27
38
|
|
|
28
|
-
//
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
39
|
+
// Utility Functions
|
|
40
|
+
const isPackageNameValid = name =>
|
|
41
|
+
typeof name === "string" && PackageNamePattern.test(name);
|
|
42
|
+
const isTagValid = tag => typeof tag === "string" && TagPattern.test(tag);
|
|
43
|
+
const isTestSetupValid = setup =>
|
|
44
|
+
typeof setup === "string" && SUPPORTED_TEST_SETUPS.includes(setup);
|
|
33
45
|
|
|
34
46
|
/**
|
|
35
47
|
* Hyphanates the given PascalCase string, f.e.:
|
|
36
48
|
* Foo -> "my-foo" (adds preffix)
|
|
37
49
|
* FooBar -> "foo-bar"
|
|
38
50
|
*/
|
|
39
|
-
const
|
|
40
|
-
const result = componentName
|
|
41
|
-
|
|
51
|
+
const hyphenateComponentName = componentName => {
|
|
52
|
+
const result = componentName
|
|
53
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
54
|
+
.toLowerCase();
|
|
42
55
|
return result.includes("-") ? result : `my-${result}`;
|
|
43
56
|
};
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
for (let key in vars) {
|
|
48
|
-
const re = new RegExp(key, "g");
|
|
49
|
-
content = content.replace(re, vars[key]);
|
|
50
|
-
}
|
|
51
|
-
return content;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const replaceVarsInFileName = (vars, fileName) => {
|
|
55
|
-
return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const copyFile = (vars, sourcePath, destPath) => {
|
|
59
|
-
if (isLogo(sourcePath)) {
|
|
60
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
|
|
65
|
-
content = replaceVarsInFileContent(vars, content);
|
|
66
|
-
destPath = replaceVarsInFileName(vars, destPath);
|
|
67
|
-
|
|
68
|
-
fs.writeFileSync(destPath, content);
|
|
69
|
-
|
|
70
|
-
// Rename "gitignore" to ".gitignore" (npm init won't include ".gitignore", so we add it as "gitignore" and rename it later)
|
|
71
|
-
if (isGitIgnore(sourcePath)) {
|
|
72
|
-
fs.renameSync(destPath, destPath.replace("gitignore", ".gitignore"))
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Rename "npmrc" to ".npmrc" (npm init won't include ".npmrc", so we add it as "npmrc" and rename it later)
|
|
76
|
-
if (isNPMRC(sourcePath)) {
|
|
77
|
-
fs.renameSync(destPath, destPath.replace("npmrc", ".npmrc"));
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const copyFiles = (vars, sourcePath, destPath) => {
|
|
82
|
-
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
|
83
|
-
if (isDir) {
|
|
84
|
-
if (destPath) {
|
|
85
|
-
mkdirp.sync(destPath);
|
|
86
|
-
}
|
|
87
|
-
fs.readdirSync(sourcePath).forEach(file => {
|
|
88
|
-
copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
copyFile(vars, sourcePath, destPath);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const generateFilesContent = (packageName, componentName, skipSubfolder) => {
|
|
96
|
-
const tagName = argv.tag || hyphaneteComponentName(componentName);
|
|
58
|
+
const replacePlaceholders = (content, replacements) =>
|
|
59
|
+
content.replace(/{{(.*?)}}/g, (_, key) => replacements[key.trim()] || "");
|
|
97
60
|
|
|
98
|
-
|
|
61
|
+
const generateFilesContent = async (
|
|
62
|
+
packageName,
|
|
63
|
+
componentName,
|
|
64
|
+
skipSubfolder,
|
|
65
|
+
testSetup,
|
|
66
|
+
) => {
|
|
67
|
+
// All variables that will be replaced in the content of the template folder/
|
|
99
68
|
const vars = {
|
|
100
69
|
INIT_PACKAGE_VAR_NAME: packageName,
|
|
101
|
-
|
|
70
|
+
INIT_PACKAGE_VERSION: VERSION,
|
|
71
|
+
INIT_PACKAGE_VAR_TAG: argv.tag || hyphenateComponentName(componentName),
|
|
102
72
|
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
|
73
|
+
INIT_PACKAGE_CYPRESS_ROOT_TSCONFIG:
|
|
74
|
+
testSetup === "cypress"
|
|
75
|
+
? `"tsBuildInfoFile": "dist/.tsbuildinfo",\n"rootDir": "src",\n"composite": true,`
|
|
76
|
+
: "",
|
|
77
|
+
INIT_PACKAGE_CYPRESS_DEV_DEPS:
|
|
78
|
+
testSetup === "cypress"
|
|
79
|
+
? `"@ui5/cypress-ct-ui5-webc": "^0.0.4",\n"cypress": "^13.11.0",`
|
|
80
|
+
: "",
|
|
81
|
+
INIT_PACKAGE_CYPRESS_TEST_COMMANDS:
|
|
82
|
+
testSetup === "cypress"
|
|
83
|
+
? `"test": "cypress run --component --browser chrome",\n"test:open": "cypress open --component --browser chrome",`
|
|
84
|
+
: "",
|
|
85
|
+
INIT_PACKAGE_CYPRESS_ESLINT_IGNORES:
|
|
86
|
+
testSetup === "cypress" ? `cypress/*\ncypress.config.*` : "",
|
|
103
87
|
};
|
|
104
88
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
type: "module",
|
|
112
|
-
scripts: {
|
|
113
|
-
"clean": "wc-dev clean",
|
|
114
|
-
"lint": "wc-dev lint",
|
|
115
|
-
"start": "wc-dev start",
|
|
116
|
-
"watch": "wc-dev watch",
|
|
117
|
-
"build": "wc-dev build",
|
|
118
|
-
"test": "wc-dev test",
|
|
119
|
-
"create-ui5-element": "wc-create-ui5-element",
|
|
120
|
-
"prepublishOnly": "npm run build",
|
|
121
|
-
},
|
|
122
|
-
exports: {
|
|
123
|
-
"./src/*": "./src/*",
|
|
124
|
-
"./dist/*": "./dist/*",
|
|
125
|
-
"./package.json": "./package.json",
|
|
126
|
-
"./bundle.js": "./bundle.js",
|
|
127
|
-
"./*": "./dist/*",
|
|
128
|
-
},
|
|
129
|
-
"dependencies": {
|
|
130
|
-
"@ui5/webcomponents-base": version,
|
|
131
|
-
"@ui5/webcomponents-theming": version,
|
|
132
|
-
},
|
|
133
|
-
"devDependencies": {
|
|
134
|
-
"@ui5/webcomponents-tools": version,
|
|
135
|
-
"chromedriver": "*",
|
|
136
|
-
"typescript": "^5.6.2"
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// Update package.json
|
|
141
|
-
let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
|
|
89
|
+
const packageBaseName = packageName.includes("@")
|
|
90
|
+
? packageName.slice(packageName.lastIndexOf("/") + 1)
|
|
91
|
+
: packageName;
|
|
92
|
+
const destDir = skipSubfolder
|
|
93
|
+
? path.join(process.cwd())
|
|
94
|
+
: path.join(process.cwd(), packageBaseName);
|
|
142
95
|
|
|
143
|
-
|
|
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);
|
|
96
|
+
await processFiles(destDir, vars, testSetup);
|
|
148
97
|
|
|
149
98
|
console.log("\nPackage successfully created!\nNext steps:\n");
|
|
150
99
|
console.log(`$ cd ${destDir}`);
|
|
151
100
|
|
|
152
|
-
let userAgentInfo;
|
|
153
101
|
try {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
console.log(`$
|
|
160
|
-
} else {
|
|
161
|
-
console.log(`$ npm i`);
|
|
162
|
-
console.log(`$ npm start`);
|
|
102
|
+
const userAgent = parser(process.env.npm_config_user_agent);
|
|
103
|
+
userAgent.yarn
|
|
104
|
+
? console.log(`$ yarn\n$ yarn start`)
|
|
105
|
+
: console.log(`$ npm i\n$ npm start`);
|
|
106
|
+
} catch {
|
|
107
|
+
console.log(`$ npm i\n$ npm start`);
|
|
163
108
|
}
|
|
164
109
|
|
|
165
110
|
console.log("\n");
|
|
166
111
|
};
|
|
167
112
|
|
|
168
|
-
|
|
113
|
+
async function processFiles(destDir, replacements, testSetup) {
|
|
114
|
+
const files = await globby(`${SRC_DIR}/**/*`);
|
|
115
|
+
const FILE_PATHS_TO_SKIP = [
|
|
116
|
+
testSetup !== "cypress" ? "cypress" : undefined,
|
|
117
|
+
].filter(Boolean);
|
|
118
|
+
|
|
119
|
+
for (const file of files) {
|
|
120
|
+
const relativePath = path.relative(SRC_DIR, file);
|
|
121
|
+
let destPath = path.join(destDir, relativePath);
|
|
122
|
+
|
|
123
|
+
if (FILE_PATHS_TO_SKIP.some(filePath => file.includes(filePath))) {
|
|
124
|
+
// console.log(`Skipped: ${file} -> ${destPath}`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Component related file based on the user input
|
|
129
|
+
destPath = destPath.replace(
|
|
130
|
+
"/MyFirstComponent",
|
|
131
|
+
`/${replacements.INIT_PACKAGE_VAR_CLASS_NAME}`,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// Files that need to be renamed
|
|
135
|
+
if (FILES_TO_RENAME[relativePath]) {
|
|
136
|
+
destPath = destPath.replace(
|
|
137
|
+
relativePath,
|
|
138
|
+
FILES_TO_RENAME[relativePath],
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
143
|
+
|
|
144
|
+
if (FILES_TO_COPY.includes(relativePath)) {
|
|
145
|
+
// Image like files that doesn't need proccessing
|
|
146
|
+
await fs.copyFile(file, destPath);
|
|
147
|
+
} else {
|
|
148
|
+
const content = await fs.readFile(file, { encoding: "utf8" });
|
|
149
|
+
const replaced = replacePlaceholders(content, replacements);
|
|
150
|
+
let formatted;
|
|
151
|
+
try {
|
|
152
|
+
formatted = await prettier.format(replaced, {
|
|
153
|
+
useTabs: true,
|
|
154
|
+
tabWidth: 4,
|
|
155
|
+
quoteProps: "consistent",
|
|
156
|
+
arrowParens: "avoid",
|
|
157
|
+
filepath: file,
|
|
158
|
+
});
|
|
159
|
+
// console.log(`Formatted: ${file} -> ${destPath}`);
|
|
160
|
+
} catch {
|
|
161
|
+
// console.log(`Not formatted: ${file} -> ${destPath}`);
|
|
162
|
+
formatted = replaced;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
await fs.writeFile(destPath, formatted);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// console.log(`Processed: ${file} -> ${destPath}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
169
172
|
const createWebcomponentsPackage = async () => {
|
|
170
173
|
let response;
|
|
171
174
|
if (argv.name && !isPackageNameValid(argv.name)) {
|
|
172
|
-
throw new Error(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
|
176
|
-
throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
|
|
175
|
+
throw new Error(
|
|
176
|
+
"The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].",
|
|
177
|
+
);
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
if (argv.
|
|
180
|
-
throw new Error(
|
|
180
|
+
if (argv.testSetup && !isTestSetupValid(argv.testSetup)) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`The test setup should be a string and one of the following options: ${SUPPORTED_TEST_SETUPS.join(", ")}`,
|
|
183
|
+
);
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
let packageName = argv.name || "my-package";
|
|
184
|
-
let componentName =
|
|
187
|
+
let componentName = "MyComponent";
|
|
188
|
+
let testSetup = argv.testSetup || "manual";
|
|
185
189
|
const skipSubfolder = !!argv.skipSubfolder;
|
|
186
190
|
|
|
187
191
|
if (argv.skip) {
|
|
188
|
-
return generateFilesContent(
|
|
192
|
+
return generateFilesContent(
|
|
193
|
+
packageName,
|
|
194
|
+
componentName,
|
|
195
|
+
skipSubfolder,
|
|
196
|
+
testSetup,
|
|
197
|
+
);
|
|
189
198
|
}
|
|
190
199
|
|
|
191
200
|
if (!argv.name) {
|
|
@@ -193,23 +202,35 @@ const createWebcomponentsPackage = async () => {
|
|
|
193
202
|
type: "text",
|
|
194
203
|
name: "name",
|
|
195
204
|
message: "Package name:",
|
|
196
|
-
validate:
|
|
205
|
+
validate: value =>
|
|
206
|
+
isPackageNameValid(value)
|
|
207
|
+
? true
|
|
208
|
+
: "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
|
|
197
209
|
});
|
|
198
210
|
packageName = response.name;
|
|
199
211
|
}
|
|
200
212
|
|
|
201
|
-
if (!argv.
|
|
213
|
+
if (!argv.testSetup) {
|
|
202
214
|
response = await prompts({
|
|
203
|
-
type: "
|
|
204
|
-
name: "
|
|
205
|
-
message: "
|
|
206
|
-
|
|
207
|
-
|
|
215
|
+
type: "select",
|
|
216
|
+
name: "testSetup",
|
|
217
|
+
message: "How would you like to set up testing?",
|
|
218
|
+
choices: [
|
|
219
|
+
{ title: "Cypress", value: "cypress" },
|
|
220
|
+
{ title: "I'll set it up manually", value: "manual" },
|
|
221
|
+
],
|
|
222
|
+
initial: 0,
|
|
208
223
|
});
|
|
209
|
-
|
|
224
|
+
|
|
225
|
+
testSetup = response.testSetup;
|
|
210
226
|
}
|
|
211
227
|
|
|
212
|
-
return generateFilesContent(
|
|
228
|
+
return generateFilesContent(
|
|
229
|
+
packageName,
|
|
230
|
+
componentName,
|
|
231
|
+
skipSubfolder,
|
|
232
|
+
testSetup,
|
|
233
|
+
);
|
|
213
234
|
};
|
|
214
235
|
|
|
215
236
|
createWebcomponentsPackage();
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/create-webcomponents-package",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-50f1454ef",
|
|
4
4
|
"description": "UI5 Web Components: create package",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"private": false,
|
|
8
9
|
"keywords": [
|
|
9
10
|
"openui5",
|
|
@@ -19,8 +20,10 @@
|
|
|
19
20
|
"directory": "packages/create-package"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
23
|
+
"globby": "^13.1.1",
|
|
22
24
|
"mkdirp": "^1.0.4",
|
|
23
25
|
"npm-config-user-agent-parser": "^1.0.0",
|
|
26
|
+
"prettier": "^3.5.3",
|
|
24
27
|
"prompts": "^2.4.1",
|
|
25
28
|
"yargs": "^17.5.1"
|
|
26
29
|
}
|
package/template/.eslintignore
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {{INIT_PACKAGE_VAR_CLASS_NAME}} from "../../src/{{INIT_PACKAGE_VAR_CLASS_NAME}}.js";
|
|
2
|
+
|
|
3
|
+
describe('{{INIT_PACKAGE_VAR_CLASS_NAME}}.cy.tsx', () => {
|
|
4
|
+
it('playground', () => {
|
|
5
|
+
cy.mount(<{{INIT_PACKAGE_VAR_CLASS_NAME}} />)
|
|
6
|
+
|
|
7
|
+
cy.get("[{{INIT_PACKAGE_VAR_TAG}}]")
|
|
8
|
+
.click();
|
|
9
|
+
|
|
10
|
+
cy.get("[{{INIT_PACKAGE_VAR_TAG}}]")
|
|
11
|
+
.should("have.prop", "count", 1)
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// ***********************************************
|
|
3
|
+
// This example commands.ts shows you how to
|
|
4
|
+
// create various custom commands and overwrite
|
|
5
|
+
// existing commands.
|
|
6
|
+
//
|
|
7
|
+
// For more comprehensive examples of custom
|
|
8
|
+
// commands please read more here:
|
|
9
|
+
// https://on.cypress.io/custom-commands
|
|
10
|
+
// ***********************************************
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
// -- This is a parent command --
|
|
14
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
15
|
+
//
|
|
16
|
+
//
|
|
17
|
+
// -- This is a child command --
|
|
18
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
// -- This is a dual command --
|
|
22
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
23
|
+
//
|
|
24
|
+
//
|
|
25
|
+
// -- This will overwrite an existing command --
|
|
26
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
27
|
+
//
|
|
28
|
+
// declare global {
|
|
29
|
+
// namespace Cypress {
|
|
30
|
+
// interface Chainable {
|
|
31
|
+
// login(email: string, password: string): Chainable<void>
|
|
32
|
+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
33
|
+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
34
|
+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
// }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
+
<title>Components App</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div data-cy-root></div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/component.ts is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
import { mount } from '@ui5/cypress-ct-ui5-webc'
|
|
20
|
+
|
|
21
|
+
// Augment the Cypress namespace to include type definitions for
|
|
22
|
+
// your custom command.
|
|
23
|
+
// Alternatively, can be defined in cypress/support/component.d.ts
|
|
24
|
+
// with a <reference path="./component" /> at the top of your spec.
|
|
25
|
+
declare global {
|
|
26
|
+
namespace Cypress {
|
|
27
|
+
interface Chainable {
|
|
28
|
+
mount: typeof mount
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Cypress.Commands.add('mount', mount)
|
|
34
|
+
|
|
35
|
+
// Example use:
|
|
36
|
+
// cy.mount(MyComponent)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"./**/*"
|
|
4
|
+
],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"module": "NodeNext",
|
|
7
|
+
"moduleResolution": "nodenext",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"jsxImportSource": "@ui5/webcomponents-base",
|
|
10
|
+
"types": [
|
|
11
|
+
"cypress"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "../"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
package/template/env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_BUNDLE_PATH="../../dist/bundle.esm.js"
|
package/template/gitignore
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{INIT_PACKAGE_VAR_NAME}}",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"ui5": {
|
|
5
|
+
"webComponentsPackage": true
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean": "wc-dev clean",
|
|
10
|
+
"lint": "wc-dev lint",
|
|
11
|
+
"start": "wc-dev start",
|
|
12
|
+
"watch": "wc-dev watch",
|
|
13
|
+
"build": "wc-dev build",
|
|
14
|
+
{{INIT_PACKAGE_CYPRESS_TEST_COMMANDS}}
|
|
15
|
+
"create-ui5-element": "wc-create-ui5-element",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
"./src/*": "./src/*",
|
|
20
|
+
"./dist/*": "./dist/*",
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
"./bundle.js": "./bundle.js",
|
|
23
|
+
"./*": "./dist/*"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@ui5/webcomponents-base": "{{INIT_PACKAGE_VERSION}}",
|
|
27
|
+
"@ui5/webcomponents-theming": "{{INIT_PACKAGE_VERSION}}"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
{{INIT_PACKAGE_CYPRESS_DEV_DEPS}}
|
|
31
|
+
"@ui5/webcomponents-tools": "{{INIT_PACKAGE_VERSION}}",
|
|
32
|
+
"chromedriver": "*",
|
|
33
|
+
"typescript": "^5.6.2"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/template/src/Assets.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
|
|
2
2
|
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
|
|
3
3
|
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
|
|
4
|
+
import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
|
|
4
5
|
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
|
|
5
|
-
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
6
6
|
import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
|
|
7
7
|
|
|
8
8
|
// Template
|
|
9
|
-
import
|
|
9
|
+
import {{INIT_PACKAGE_VAR_CLASS_NAME}}Template from "./{{INIT_PACKAGE_VAR_CLASS_NAME}}Template.js";
|
|
10
10
|
|
|
11
11
|
// Styles
|
|
12
|
-
import
|
|
12
|
+
import {{INIT_PACKAGE_VAR_CLASS_NAME}}Css from "./generated/themes/{{INIT_PACKAGE_VAR_CLASS_NAME}}.css.js";
|
|
13
13
|
|
|
14
14
|
import { COUNT } from "./generated/i18n/i18n-defaults.js";
|
|
15
15
|
|
|
@@ -18,25 +18,22 @@ import { COUNT } from "./generated/i18n/i18n-defaults.js";
|
|
|
18
18
|
*
|
|
19
19
|
* <h3 class="comment-api-title">Overview</h3>
|
|
20
20
|
*
|
|
21
|
-
* The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
|
|
21
|
+
* The <code>{{INIT_PACKAGE_VAR_TAG}}</code> component is a demo component that displays some text.
|
|
22
22
|
*
|
|
23
23
|
* @constructor
|
|
24
24
|
* @extends UI5Element
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
27
|
@customElement({
|
|
28
|
-
tag: "INIT_PACKAGE_VAR_TAG",
|
|
28
|
+
tag: "{{INIT_PACKAGE_VAR_TAG}}",
|
|
29
29
|
renderer: jsxRenderer,
|
|
30
|
-
styles:
|
|
31
|
-
template:
|
|
30
|
+
styles: {{INIT_PACKAGE_VAR_CLASS_NAME}}Css,
|
|
31
|
+
template: {{INIT_PACKAGE_VAR_CLASS_NAME}}Template,
|
|
32
32
|
})
|
|
33
|
-
class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
|
33
|
+
class {{INIT_PACKAGE_VAR_CLASS_NAME}} extends UI5Element {
|
|
34
|
+
@i18n("{{INIT_PACKAGE_VAR_NAME}}")
|
|
34
35
|
static i18nBundle: I18nBundle;
|
|
35
36
|
|
|
36
|
-
static async onDefine() {
|
|
37
|
-
INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
37
|
/**
|
|
41
38
|
* Defines the component count.
|
|
42
39
|
* @default 0
|
|
@@ -50,10 +47,10 @@ class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
get counterText() {
|
|
53
|
-
return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNT);
|
|
50
|
+
return {{INIT_PACKAGE_VAR_CLASS_NAME}}.i18nBundle.getText(COUNT);
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
INIT_PACKAGE_VAR_CLASS_NAME.define();
|
|
54
|
+
{{INIT_PACKAGE_VAR_CLASS_NAME}}.define();
|
|
58
55
|
|
|
59
|
-
export default INIT_PACKAGE_VAR_CLASS_NAME;
|
|
56
|
+
export default {{INIT_PACKAGE_VAR_CLASS_NAME}};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export default function
|
|
4
|
-
return (
|
|
5
|
-
<div class="root" onClick={this.onClick}>
|
|
6
|
-
{this.counterText} :: {this.count}
|
|
7
|
-
</div>
|
|
8
|
-
)
|
|
9
|
-
}
|
|
1
|
+
import type {{INIT_PACKAGE_VAR_CLASS_NAME}} from "./{{INIT_PACKAGE_VAR_CLASS_NAME}}.js";
|
|
2
|
+
|
|
3
|
+
export default function {{INIT_PACKAGE_VAR_CLASS_NAME}}Template(this: {{INIT_PACKAGE_VAR_CLASS_NAME}}) {
|
|
4
|
+
return (
|
|
5
|
+
<div class="root" onClick={this.onClick}>
|
|
6
|
+
{this.counterText} :: {this.count}
|
|
7
|
+
</div>
|
|
8
|
+
);
|
|
9
|
+
}
|
|
@@ -9,11 +9,12 @@ import { getNoConflict, setNoConflict } from "@ui5/webcomponents-base/dist/confi
|
|
|
9
9
|
import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js";
|
|
10
10
|
|
|
11
11
|
// Enable additional themes and i18n texts
|
|
12
|
-
import "./
|
|
12
|
+
import "./Assets.js";
|
|
13
13
|
|
|
14
|
-
// Import your web components here from the
|
|
15
|
-
import "./
|
|
14
|
+
// Import your web components here from the src/ directory
|
|
15
|
+
import "./{{INIT_PACKAGE_VAR_CLASS_NAME}}.js";
|
|
16
16
|
|
|
17
|
+
// @ts-expect-error
|
|
17
18
|
window["sap-ui-webcomponents-bundle"] = {
|
|
18
19
|
renderFinished,
|
|
19
20
|
configuration: {
|
|
@@ -3,6 +3,7 @@ body {
|
|
|
3
3
|
background-color: var(--sapBackgroundColor);
|
|
4
4
|
font-size: var(--sapFontSize);
|
|
5
5
|
font-family: var(--sapFontFamily);
|
|
6
|
+
padding: 2rem;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
h1 {
|
|
@@ -11,31 +12,78 @@ h1 {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
h2 {
|
|
14
|
-
font-size: var(--
|
|
15
|
-
|
|
15
|
+
font-size: var(--sapFontHeader4Size);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
a {
|
|
19
|
+
margin: 0.25rem;
|
|
20
|
+
padding: 0.5rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
a.link {
|
|
24
|
+
color: var(--sapLinkColor);
|
|
16
25
|
}
|
|
17
26
|
|
|
18
|
-
.
|
|
27
|
+
a.theme-link {
|
|
28
|
+
color: var(--sapButton_Emphasized_TextColor);
|
|
29
|
+
background-color: var(--sapButton_Emphasized_Background);
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
border-radius: 0.25rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
a.lang-link {
|
|
35
|
+
color: var(--sapButton_Attention_TextColor);
|
|
36
|
+
background-color: var(--sapButton_Attention_Background);
|
|
37
|
+
text-decoration: none;
|
|
38
|
+
border-radius: 0.25rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.app {
|
|
19
42
|
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
justify-content: center;
|
|
22
43
|
flex-direction: column;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.app-nav {
|
|
48
|
+
display: flex;
|
|
49
|
+
width: 100%;
|
|
50
|
+
flex-direction: row;
|
|
51
|
+
justify-content: flex-end;
|
|
23
52
|
}
|
|
24
53
|
|
|
25
54
|
.app-logo {
|
|
26
|
-
height:
|
|
27
|
-
width:
|
|
55
|
+
height: 5rem;
|
|
56
|
+
width: 5rem;
|
|
28
57
|
}
|
|
29
58
|
|
|
30
|
-
.app-
|
|
31
|
-
|
|
59
|
+
.app-header {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: row;
|
|
62
|
+
align-items: center;
|
|
32
63
|
}
|
|
33
64
|
|
|
34
|
-
.app-
|
|
35
|
-
|
|
65
|
+
.app-main {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: row;
|
|
68
|
+
align-items: flex-start;
|
|
69
|
+
padding-top: 2rem;
|
|
36
70
|
}
|
|
37
71
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
72
|
+
.app-main-demo {
|
|
73
|
+
padding: 2rem;
|
|
74
|
+
border-radius: 0.5rem;
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
background-color: var(--sapTile_Background);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.app-main-settings {
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
padding: 0 2rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@media (max-width: 768px) {
|
|
86
|
+
.app-main {
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
}
|
|
41
89
|
}
|
|
@@ -1,57 +1,53 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
2
|
+
<html lang="en">
|
|
3
3
|
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="utf-8">
|
|
6
|
-
|
|
7
|
-
<title>INIT_PACKAGE_VAR_TAG</title>
|
|
6
|
+
<title>UI5 Web Components</title>
|
|
8
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
8
|
<meta charset="utf-8">
|
|
10
|
-
|
|
11
|
-
<script data-ui5-config type="application/json">
|
|
12
|
-
{
|
|
13
|
-
"theme": "sap_horizon_dark",
|
|
14
|
-
"language": "EN"
|
|
15
|
-
}
|
|
16
|
-
</script>
|
|
17
|
-
|
|
18
9
|
<link rel="stylesheet" type="text/css" href="./css/index.css">
|
|
19
|
-
<script src="
|
|
10
|
+
<script src="%VITE_BUNDLE_PATH%" type="module"></script>
|
|
20
11
|
</head>
|
|
21
12
|
|
|
22
13
|
<body>
|
|
23
14
|
<div class="app">
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
<
|
|
15
|
+
<nav class="app-nav">
|
|
16
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/">Website</a>
|
|
17
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/components/">Components</a>
|
|
18
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/docs/development/package/">Development</a>
|
|
19
|
+
</nav>
|
|
20
|
+
|
|
21
|
+
<header class="app-header">
|
|
22
|
+
<a href="https://sap.github.io/ui5-webcomponents/" target="_blank"><img src="./img/logo.png" class="app-logo" alt="logo"/></a>
|
|
23
|
+
<h1>UI5 Web Components</h1>
|
|
24
|
+
</header>
|
|
25
|
+
|
|
26
|
+
<main class="app-main">
|
|
27
|
+
<div class="app-main-demo">
|
|
28
|
+
<h2>Congrats! It's your First Web Component 🎉</h2>
|
|
29
|
+
<div> <pre><{{INIT_PACKAGE_VAR_TAG}}></{{INIT_PACKAGE_VAR_TAG}}> </pre></div>
|
|
30
|
+
<{{INIT_PACKAGE_VAR_TAG}} id="myFirstComponent"></{{INIT_PACKAGE_VAR_TAG}}>
|
|
40
31
|
</div>
|
|
41
32
|
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
<div class="app-main-settings">
|
|
34
|
+
<h3>Switch theme</h3>
|
|
35
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr;">
|
|
36
|
+
<a class="link theme-link" href="?sap-ui-theme=sap_horizon">Horizon Morning</a>
|
|
37
|
+
<a class="link theme-link" href="?sap-ui-theme=sap_horizon_dark">Horizon Evening</a>
|
|
38
|
+
<a class="link theme-link" href="?sap-ui-theme=sap_horizon_hcb">High Contrast Black</a>
|
|
39
|
+
<a class="link theme-link" href="?sap-ui-theme=sap_horizon_hcw">High Contrast White</a>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<h3>Switch language</h3>
|
|
43
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr;">
|
|
44
|
+
<a class="link lang-link" href="?sap-ui-language=en">English</a>
|
|
45
|
+
<a class="link lang-link" href="?sap-ui-language=de">German</a>
|
|
46
|
+
<a class="link lang-link" href="?sap-ui-language=es">Spanish</a>
|
|
47
|
+
<a class="link lang-link" href="?sap-ui-language=fr">French</a>
|
|
48
|
+
</div>
|
|
48
49
|
</div>
|
|
49
|
-
</
|
|
50
|
-
|
|
51
|
-
<div class="app-docs">
|
|
52
|
-
<h2>Documentation</h2>
|
|
53
|
-
<a class="link" href="https://sap.github.io/ui5-webcomponents/docs/development/custom-UI5-Web-Components-Packages/">Custom Component Development</a>
|
|
54
|
-
</div>
|
|
50
|
+
</main>
|
|
55
51
|
</div>
|
|
56
52
|
</body>
|
|
57
53
|
</html>
|
|
@@ -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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("@ui5/webcomponents-tools/components-package/wdio.js"); // eslint-disable-line
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { assert } from "chai";
|
|
2
|
-
|
|
3
|
-
describe("INIT_PACKAGE_VAR_TAG rendering", async () => {
|
|
4
|
-
before(async () => {
|
|
5
|
-
await browser.url("test/pages/index.html");
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
it("tests if web component is correctly rendered", async () => {
|
|
9
|
-
const innerContent = await browser.$("#myFirstComponent").shadow$("div");
|
|
10
|
-
|
|
11
|
-
assert.ok(innerContent, "content rendered");
|
|
12
|
-
});
|
|
13
|
-
});
|