@ui5/create-webcomponents-package 2.9.0 → 2.10.0-rc.0
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 +16 -0
- package/README.md +10 -8
- package/create-package.js +189 -145
- package/package.json +5 -2
- package/template/.eslintignore +3 -1
- package/template/bundle.esm.js +1 -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.json +19 -0
- package/template/cypress.config.ts +10 -0
- package/template/gitignore +2 -1
- package/template/package.json +35 -0
- package/template/src/Assets.ts +1 -1
- package/template/src/MyFirstComponent.ts +11 -11
- package/template/src/MyFirstComponentTemplate.tsx +2 -2
- package/template/test/pages/index.html +7 -5
- package/template/tsconfig.json +2 -1
- package/template/config/wdio.conf.cjs +0 -1
- package/template/test/specs/Demo.spec.js +0 -13
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
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.10.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.9.1-rc.0...v2.10.0-rc.0) (2025-04-14)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [2.9.1-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0...v2.9.1-rc.0) (2025-04-10)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
6
22
|
# [2.9.0](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0-rc.3...v2.9.0) (2025-04-04)
|
7
23
|
|
8
24
|
**Note:** Version bump only for package @ui5/create-webcomponents-package
|
package/README.md
CHANGED
@@ -15,10 +15,11 @@ Usage:
|
|
15
15
|
npm init @ui5/webcomponents-package -- [OPTIONS]
|
16
16
|
|
17
17
|
Options:
|
18
|
-
--name <string>
|
19
|
-
--component-name <string>
|
20
|
-
--tag <string>
|
21
|
-
--
|
18
|
+
--name <string> - defines the package name
|
19
|
+
--component-name <string> - defines the component class name that will be created in your new package
|
20
|
+
--tag <string> - defines the tag name of the sample web component that will be created in your new package
|
21
|
+
--test-setup <"cypress" | "manual"> - defines whether the predefined test setup should be added or it will be configured manually.
|
22
|
+
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
22
23
|
```
|
23
24
|
|
24
25
|
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 +31,11 @@ components package.
|
|
30
31
|
Usage:
|
31
32
|
yarn create @ui5/webcomponents-package [OPTIONS]
|
32
33
|
Options:
|
33
|
-
--name <string>
|
34
|
-
--component-name <string>
|
35
|
-
--tag <string>
|
36
|
-
--
|
34
|
+
--name <string> - defines the package name
|
35
|
+
--component-name <string> - defines the component class name that will be created in your new package
|
36
|
+
--tag <string> - defines the tag name of the sample web component that will be created in your new package
|
37
|
+
--test-setup <"cypress" | "manual"> - defines whether the predefined test setup should be added or it will be configured manually.
|
38
|
+
--skip - skips configuration and generates package with a default value for each parameter that wasn't passed
|
37
39
|
```
|
38
40
|
|
39
41
|
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,209 @@
|
|
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
|
-
return sourcePath.includes("logo");
|
23
|
-
};
|
24
|
-
const isNPMRC = sourcePath => {
|
25
|
-
return sourcePath.includes("npmrc");
|
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
|
+
"npmrc": ".npmrc",
|
24
|
+
"gitignore": ".gitignore",
|
26
25
|
};
|
26
|
+
const FILES_TO_COPY = ["test/pages/img/logo.png"];
|
27
27
|
|
28
|
-
// Validation
|
28
|
+
// Validation Patterns
|
29
29
|
const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
|
30
|
-
const
|
31
|
-
|
32
|
-
const
|
30
|
+
const PackageNamePattern =
|
31
|
+
/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
32
|
+
const TagPattern = /^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/;
|
33
|
+
|
34
|
+
// Utility Functions
|
35
|
+
const isPackageNameValid = name =>
|
36
|
+
typeof name === "string" && PackageNamePattern.test(name);
|
37
|
+
const isComponentNameValid = name =>
|
38
|
+
typeof name === "string" && ComponentNamePattern.test(name);
|
39
|
+
const isTagValid = tag => typeof tag === "string" && TagPattern.test(tag);
|
40
|
+
const isTestSetupValid = setup =>
|
41
|
+
typeof setup === "string" && SUPPORTED_TEST_SETUPS.includes(setup);
|
33
42
|
|
34
43
|
/**
|
35
44
|
* Hyphanates the given PascalCase string, f.e.:
|
36
45
|
* Foo -> "my-foo" (adds preffix)
|
37
46
|
* FooBar -> "foo-bar"
|
38
47
|
*/
|
39
|
-
const
|
40
|
-
const result = componentName
|
41
|
-
|
48
|
+
const hyphenateComponentName = componentName => {
|
49
|
+
const result = componentName
|
50
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
51
|
+
.toLowerCase();
|
42
52
|
return result.includes("-") ? result : `my-${result}`;
|
43
53
|
};
|
44
54
|
|
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);
|
55
|
+
const replacePlaceholders = (content, replacements) =>
|
56
|
+
content.replace(/{{(.*?)}}/g, (_, key) => replacements[key.trim()] || "");
|
97
57
|
|
98
|
-
|
58
|
+
const generateFilesContent = async (
|
59
|
+
packageName,
|
60
|
+
componentName,
|
61
|
+
skipSubfolder,
|
62
|
+
testSetup,
|
63
|
+
) => {
|
64
|
+
// All variables that will be replaced in the content of the template folder/
|
99
65
|
const vars = {
|
100
66
|
INIT_PACKAGE_VAR_NAME: packageName,
|
101
|
-
|
67
|
+
INIT_PACKAGE_VERSION: VERSION,
|
68
|
+
INIT_PACKAGE_VAR_TAG: argv.tag || hyphenateComponentName(componentName),
|
102
69
|
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
70
|
+
INIT_PACKAGE_CYPRESS_ROOT_TSCONFIG:
|
71
|
+
testSetup === "cypress"
|
72
|
+
? `"tsBuildInfoFile": "dist/.tsbuildinfo",\n"rootDir": "src",\n"composite": true,`
|
73
|
+
: "",
|
74
|
+
INIT_PACKAGE_CYPRESS_DEV_DEPS:
|
75
|
+
testSetup === "cypress"
|
76
|
+
? `"@ui5/cypress-ct-ui5-webc": "^0.0.3",\n"cypress": "^13.11.0",`
|
77
|
+
: "",
|
78
|
+
INIT_PACKAGE_CYPRESS_TEST_COMMANDS:
|
79
|
+
testSetup === "cypress"
|
80
|
+
? `"test": "cypress run --component --browser chrome",\n"test:open": "cypress open --component --browser chrome",`
|
81
|
+
: "",
|
82
|
+
INIT_PACKAGE_CYPRESS_ESLINT_IGNORES:
|
83
|
+
testSetup === "cypress" ? `cypress/*\ncypress.config.*` : "",
|
103
84
|
};
|
104
85
|
|
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;
|
86
|
+
const packageBaseName = packageName.includes("@")
|
87
|
+
? packageName.slice(packageName.lastIndexOf("/") + 1)
|
88
|
+
: packageName;
|
89
|
+
const destDir = skipSubfolder
|
90
|
+
? path.join("./")
|
91
|
+
: path.join("./", packageBaseName);
|
142
92
|
|
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);
|
93
|
+
await processFiles(destDir, vars, testSetup);
|
148
94
|
|
149
95
|
console.log("\nPackage successfully created!\nNext steps:\n");
|
150
96
|
console.log(`$ cd ${destDir}`);
|
151
97
|
|
152
|
-
let userAgentInfo;
|
153
98
|
try {
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
console.log(`$
|
160
|
-
} else {
|
161
|
-
console.log(`$ npm i`);
|
162
|
-
console.log(`$ npm start`);
|
99
|
+
const userAgent = parser(process.env.npm_config_user_agent);
|
100
|
+
userAgent.yarn
|
101
|
+
? console.log(`$ yarn\n$ yarn start`)
|
102
|
+
: console.log(`$ npm i\n$ npm start`);
|
103
|
+
} catch {
|
104
|
+
console.log(`$ npm i\n$ npm start`);
|
163
105
|
}
|
164
106
|
|
165
107
|
console.log("\n");
|
166
108
|
};
|
167
109
|
|
168
|
-
|
110
|
+
async function processFiles(destDir, replacements, testSetup) {
|
111
|
+
const files = await globby(`${SRC_DIR}/**/*`, { dot: true });
|
112
|
+
const FILE_PATHS_TO_SKIP = [
|
113
|
+
testSetup !== "cypress" ? "cypress" : undefined,
|
114
|
+
].filter(Boolean);
|
115
|
+
|
116
|
+
for (const file of files) {
|
117
|
+
const relativePath = path.relative(SRC_DIR, file);
|
118
|
+
let destPath = path.join(destDir, relativePath);
|
119
|
+
|
120
|
+
if (FILE_PATHS_TO_SKIP.some(filePath => file.includes(filePath))) {
|
121
|
+
// console.log(`Skipped: ${file} -> ${destPath}`);
|
122
|
+
continue;
|
123
|
+
}
|
124
|
+
|
125
|
+
// Component related file based on the user input
|
126
|
+
destPath = destPath.replace(
|
127
|
+
"/MyFirstComponent",
|
128
|
+
`/${replacements.INIT_PACKAGE_VAR_CLASS_NAME}`,
|
129
|
+
);
|
130
|
+
|
131
|
+
// Files that need to be renamed
|
132
|
+
if (FILES_TO_RENAME[relativePath]) {
|
133
|
+
destPath = destPath.replace(
|
134
|
+
relativePath,
|
135
|
+
FILES_TO_RENAME[relativePath],
|
136
|
+
);
|
137
|
+
}
|
138
|
+
|
139
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
140
|
+
|
141
|
+
if (FILES_TO_COPY.includes(relativePath)) {
|
142
|
+
// Image like files that doesn't need proccessing
|
143
|
+
await fs.copyFile(file, destPath);
|
144
|
+
} else {
|
145
|
+
const content = await fs.readFile(file, { encoding: "utf8" });
|
146
|
+
const replaced = replacePlaceholders(content, replacements);
|
147
|
+
let formatted;
|
148
|
+
try {
|
149
|
+
formatted = await prettier.format(replaced, {
|
150
|
+
useTabs: true,
|
151
|
+
tabWidth: 4,
|
152
|
+
quoteProps: "consistent",
|
153
|
+
arrowParens: "avoid",
|
154
|
+
filepath: file,
|
155
|
+
});
|
156
|
+
// console.log(`Formatted: ${file} -> ${destPath}`);
|
157
|
+
} catch {
|
158
|
+
// console.log(`Not formatted: ${file} -> ${destPath}`);
|
159
|
+
formatted = replaced;
|
160
|
+
}
|
161
|
+
|
162
|
+
await fs.writeFile(destPath, formatted);
|
163
|
+
}
|
164
|
+
|
165
|
+
// console.log(`Processed: ${file} -> ${destPath}`);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
169
|
const createWebcomponentsPackage = async () => {
|
170
170
|
let response;
|
171
171
|
if (argv.name && !isPackageNameValid(argv.name)) {
|
172
|
-
throw new Error(
|
172
|
+
throw new Error(
|
173
|
+
"The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].",
|
174
|
+
);
|
173
175
|
}
|
174
176
|
|
175
177
|
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
176
|
-
throw new Error(
|
178
|
+
throw new Error(
|
179
|
+
"The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.",
|
180
|
+
);
|
181
|
+
}
|
182
|
+
|
183
|
+
if (argv.tag && !isTagValid(argv.tag)) {
|
184
|
+
throw new Error(
|
185
|
+
"The tag should be in kebab-case (f.e my-component) and it can't be a single word.",
|
186
|
+
);
|
177
187
|
}
|
178
188
|
|
179
|
-
if (argv.
|
180
|
-
throw new Error(
|
189
|
+
if (argv.testSetup && !isTestSetupValid(argv.testSetup)) {
|
190
|
+
throw new Error(
|
191
|
+
`The test setup should be a string and one of the following options: ${SUPPORTED_TEST_SETUPS.join(", ")}`,
|
192
|
+
);
|
181
193
|
}
|
182
194
|
|
183
195
|
let packageName = argv.name || "my-package";
|
184
196
|
let componentName = argv.componentName || "MyComponent";
|
197
|
+
let testSetup = argv.testSetup || "manual";
|
185
198
|
const skipSubfolder = !!argv.skipSubfolder;
|
186
199
|
|
187
200
|
if (argv.skip) {
|
188
|
-
return generateFilesContent(
|
201
|
+
return generateFilesContent(
|
202
|
+
packageName,
|
203
|
+
componentName,
|
204
|
+
skipSubfolder,
|
205
|
+
testSetup,
|
206
|
+
);
|
189
207
|
}
|
190
208
|
|
191
209
|
if (!argv.name) {
|
@@ -193,7 +211,10 @@ const createWebcomponentsPackage = async () => {
|
|
193
211
|
type: "text",
|
194
212
|
name: "name",
|
195
213
|
message: "Package name:",
|
196
|
-
validate:
|
214
|
+
validate: value =>
|
215
|
+
isPackageNameValid(value)
|
216
|
+
? true
|
217
|
+
: "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
|
197
218
|
});
|
198
219
|
packageName = response.name;
|
199
220
|
}
|
@@ -204,12 +225,35 @@ const createWebcomponentsPackage = async () => {
|
|
204
225
|
name: "componentName",
|
205
226
|
message: "Component name:",
|
206
227
|
initial: "MyComponent",
|
207
|
-
validate:
|
228
|
+
validate: value =>
|
229
|
+
isComponentNameValid(value)
|
230
|
+
? true
|
231
|
+
: "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
208
232
|
});
|
209
233
|
componentName = response.componentName;
|
210
234
|
}
|
211
235
|
|
212
|
-
|
236
|
+
if (!argv.testSetup) {
|
237
|
+
response = await prompts({
|
238
|
+
type: "select",
|
239
|
+
name: "testSetup",
|
240
|
+
message: "How would you like to set up testing?",
|
241
|
+
choices: [
|
242
|
+
{ title: "Cypress", value: "cypress" },
|
243
|
+
{ title: "I'll set it up manually", value: "manual" },
|
244
|
+
],
|
245
|
+
initial: 0,
|
246
|
+
});
|
247
|
+
|
248
|
+
testSetup = response.testSetup;
|
249
|
+
}
|
250
|
+
|
251
|
+
return generateFilesContent(
|
252
|
+
packageName,
|
253
|
+
componentName,
|
254
|
+
skipSubfolder,
|
255
|
+
testSetup,
|
256
|
+
);
|
213
257
|
};
|
214
258
|
|
215
259
|
createWebcomponentsPackage();
|
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/create-webcomponents-package",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.10.0-rc.0",
|
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,10 +20,12 @@
|
|
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
|
},
|
27
|
-
"gitHead": "
|
30
|
+
"gitHead": "6f1bf67e35896acdd8b39e8a6f9ad01cac0c58ce"
|
28
31
|
}
|
package/template/.eslintignore
CHANGED
package/template/bundle.esm.js
CHANGED
@@ -12,7 +12,7 @@ import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSet
|
|
12
12
|
import "./dist/Assets.js";
|
13
13
|
|
14
14
|
// Import your web components here from the dist/ directory
|
15
|
-
import "./dist/INIT_PACKAGE_VAR_CLASS_NAME.js";
|
15
|
+
import "./dist/{{INIT_PACKAGE_VAR_CLASS_NAME}}.js";
|
16
16
|
|
17
17
|
window["sap-ui-webcomponents-bundle"] = {
|
18
18
|
renderFinished,
|
@@ -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("[hardcoded-button]")
|
8
|
+
.click();
|
9
|
+
|
10
|
+
cy.get("[hardcoded-button]")
|
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/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
@@ -6,10 +6,10 @@ import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.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,20 +18,20 @@ 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 {
|
34
|
-
@i18n("INIT_PACKAGE_VAR_NAME")
|
33
|
+
class {{INIT_PACKAGE_VAR_CLASS_NAME}} extends UI5Element {
|
34
|
+
@i18n("{{INIT_PACKAGE_VAR_NAME}}")
|
35
35
|
static i18nBundle: I18nBundle;
|
36
36
|
|
37
37
|
/**
|
@@ -47,10 +47,10 @@ class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
|
|
47
47
|
}
|
48
48
|
|
49
49
|
get counterText() {
|
50
|
-
return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNT);
|
50
|
+
return {{INIT_PACKAGE_VAR_CLASS_NAME}}.i18nBundle.getText(COUNT);
|
51
51
|
}
|
52
52
|
}
|
53
53
|
|
54
|
-
INIT_PACKAGE_VAR_CLASS_NAME.define();
|
54
|
+
{{INIT_PACKAGE_VAR_CLASS_NAME}}.define();
|
55
55
|
|
56
|
-
export default INIT_PACKAGE_VAR_CLASS_NAME;
|
56
|
+
export default {{INIT_PACKAGE_VAR_CLASS_NAME}};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type INIT_PACKAGE_VAR_CLASS_NAME from "./INIT_PACKAGE_VAR_CLASS_NAME.js";
|
1
|
+
import type {{INIT_PACKAGE_VAR_CLASS_NAME}} from "./{{INIT_PACKAGE_VAR_CLASS_NAME}}.js";
|
2
2
|
|
3
|
-
export default function
|
3
|
+
export default function {{INIT_PACKAGE_VAR_CLASS_NAME}}Template(this: {{INIT_PACKAGE_VAR_CLASS_NAME}}) {
|
4
4
|
return (
|
5
5
|
<div class="root" onClick={this.onClick}>
|
6
6
|
{this.counterText} :: {this.count}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<meta charset="utf-8">
|
6
6
|
|
7
|
-
<title>INIT_PACKAGE_VAR_TAG</title>
|
7
|
+
<title>{{INIT_PACKAGE_VAR_TAG}}</title>
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
9
|
<meta charset="utf-8">
|
10
10
|
|
@@ -25,8 +25,8 @@
|
|
25
25
|
|
26
26
|
<div class="app-first-component">
|
27
27
|
<h1>Hooray! It's Your First Web Component!</h1>
|
28
|
-
<div> <pre><INIT_PACKAGE_VAR_TAG></INIT_PACKAGE_VAR_TAG> </pre></div>
|
29
|
-
<INIT_PACKAGE_VAR_TAG id="myFirstComponent"></INIT_PACKAGE_VAR_TAG>
|
28
|
+
<div> <pre><{{INIT_PACKAGE_VAR_TAG}}></{{INIT_PACKAGE_VAR_TAG}}> </pre></div>
|
29
|
+
<{{INIT_PACKAGE_VAR_TAG}} id="myFirstComponent"></{{INIT_PACKAGE_VAR_TAG}}>
|
30
30
|
</div>
|
31
31
|
|
32
32
|
<div class="app-settings">
|
@@ -49,8 +49,10 @@
|
|
49
49
|
</div>
|
50
50
|
|
51
51
|
<div class="app-docs">
|
52
|
-
<
|
53
|
-
<a class="link" href="https://sap.github.io/ui5-webcomponents/
|
52
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/">Website</a>
|
53
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/components/">Components</a>
|
54
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/play/">Playground</a>
|
55
|
+
<a class="link" href="https://sap.github.io/ui5-webcomponents/docs/development/package/">Development Docs</a>
|
54
56
|
</div>
|
55
57
|
</div>
|
56
58
|
</body>
|
package/template/tsconfig.json
CHANGED
@@ -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
|
-
});
|