@ui5/create-webcomponents-package 2.9.1-rc.0 → 2.10.0-rc.1

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 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.1](https://github.com/SAP/ui5-webcomponents/compare/v2.10.0-rc.0...v2.10.0-rc.1) (2025-04-17)
7
+
8
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
9
+
10
+
11
+
12
+
13
+
14
+ # [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)
15
+
16
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
17
+
18
+
19
+
20
+
21
+
6
22
  ## [2.9.1-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.9.0...v2.9.1-rc.0) (2025-04-10)
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> - 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. The tag will be derived from the component name if not provided.
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
+ --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> - defines the package name
34
- --component-name <string> - defines the component class name that will be created in your new package
35
- --tag <string> - defines the tag name of the sample web component that will be created in your new package
36
- --skip - skips configuration and generates package with a default value for each parameter that wasn't passed
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,211 @@
1
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
- const yargs = require("yargs/yargs");
9
- const { hideBin } = require("yargs/helpers");
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
- const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))).version;
14
-
15
- // from where all the files will be copied
16
- const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
17
-
18
- const isGitIgnore = sourcePath => {
19
- return sourcePath.includes("gitignore");
20
- };
21
- const isLogo = sourcePath => {
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",
25
+ "tsconfig.template.json": "tsconfig.json",
26
+ "cypress/tsconfig.template.json": "cypress/tsconfig.json"
26
27
  };
28
+ const FILES_TO_COPY = ["test/pages/img/logo.png"];
27
29
 
28
- // Validation of user input
30
+ // Validation Patterns
29
31
  const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
30
- const isPackageNameValid = name => typeof name === "string" && name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
31
- const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
32
- const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
32
+ const PackageNamePattern =
33
+ /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
34
+ const TagPattern = /^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/;
35
+
36
+ // Utility Functions
37
+ const isPackageNameValid = name =>
38
+ typeof name === "string" && PackageNamePattern.test(name);
39
+ const isComponentNameValid = name =>
40
+ typeof name === "string" && ComponentNamePattern.test(name);
41
+ const isTagValid = tag => typeof tag === "string" && TagPattern.test(tag);
42
+ const isTestSetupValid = setup =>
43
+ typeof setup === "string" && SUPPORTED_TEST_SETUPS.includes(setup);
33
44
 
34
45
  /**
35
46
  * Hyphanates the given PascalCase string, f.e.:
36
47
  * Foo -> "my-foo" (adds preffix)
37
48
  * FooBar -> "foo-bar"
38
49
  */
39
- const hyphaneteComponentName = (componentName) => {
40
- const result = componentName.replace(/([a-z])([A-Z])/g, '$1-$2' ).toLowerCase();
41
-
50
+ const hyphenateComponentName = componentName => {
51
+ const result = componentName
52
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
53
+ .toLowerCase();
42
54
  return result.includes("-") ? result : `my-${result}`;
43
55
  };
44
56
 
45
- // Utils for building the file structure
46
- const replaceVarsInFileContent = (vars, content) => {
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);
57
+ const replacePlaceholders = (content, replacements) =>
58
+ content.replace(/{{(.*?)}}/g, (_, key) => replacements[key.trim()] || "");
97
59
 
98
- // All variables that will be replaced in the content of the resources/
60
+ const generateFilesContent = async (
61
+ packageName,
62
+ componentName,
63
+ skipSubfolder,
64
+ testSetup,
65
+ ) => {
66
+ // All variables that will be replaced in the content of the template folder/
99
67
  const vars = {
100
68
  INIT_PACKAGE_VAR_NAME: packageName,
101
- INIT_PACKAGE_VAR_TAG: tagName,
69
+ INIT_PACKAGE_VERSION: VERSION,
70
+ INIT_PACKAGE_VAR_TAG: argv.tag || hyphenateComponentName(componentName),
102
71
  INIT_PACKAGE_VAR_CLASS_NAME: componentName,
72
+ INIT_PACKAGE_CYPRESS_ROOT_TSCONFIG:
73
+ testSetup === "cypress"
74
+ ? `"tsBuildInfoFile": "dist/.tsbuildinfo",\n"rootDir": "src",\n"composite": true,`
75
+ : "",
76
+ INIT_PACKAGE_CYPRESS_DEV_DEPS:
77
+ testSetup === "cypress"
78
+ ? `"@ui5/cypress-ct-ui5-webc": "^0.0.3",\n"cypress": "^13.11.0",`
79
+ : "",
80
+ INIT_PACKAGE_CYPRESS_TEST_COMMANDS:
81
+ testSetup === "cypress"
82
+ ? `"test": "cypress run --component --browser chrome",\n"test:open": "cypress open --component --browser chrome",`
83
+ : "",
84
+ INIT_PACKAGE_CYPRESS_ESLINT_IGNORES:
85
+ testSetup === "cypress" ? `cypress/*\ncypress.config.*` : "",
103
86
  };
104
87
 
105
- const packageContent = {
106
- name: packageName,
107
- version: "0.0.1",
108
- ui5: {
109
- webComponentsPackage: true,
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;
88
+ const packageBaseName = packageName.includes("@")
89
+ ? packageName.slice(packageName.lastIndexOf("/") + 1)
90
+ : packageName;
91
+ const destDir = skipSubfolder
92
+ ? path.join("./")
93
+ : path.join("./", packageBaseName);
142
94
 
143
- destDir = skipSubfolder ? path.join("./") : path.join("./", destDir);
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);
95
+ await processFiles(destDir, vars, testSetup);
148
96
 
149
97
  console.log("\nPackage successfully created!\nNext steps:\n");
150
98
  console.log(`$ cd ${destDir}`);
151
99
 
152
- let userAgentInfo;
153
100
  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`);
101
+ const userAgent = parser(process.env.npm_config_user_agent);
102
+ userAgent.yarn
103
+ ? console.log(`$ yarn\n$ yarn start`)
104
+ : console.log(`$ npm i\n$ npm start`);
105
+ } catch {
106
+ console.log(`$ npm i\n$ npm start`);
163
107
  }
164
108
 
165
109
  console.log("\n");
166
110
  };
167
111
 
168
- // Main function
112
+ async function processFiles(destDir, replacements, testSetup) {
113
+ const files = await globby(`${SRC_DIR}/**/*`, { dot: true });
114
+ const FILE_PATHS_TO_SKIP = [
115
+ testSetup !== "cypress" ? "cypress" : undefined,
116
+ ].filter(Boolean);
117
+
118
+ for (const file of files) {
119
+ const relativePath = path.relative(SRC_DIR, file);
120
+ let destPath = path.join(destDir, relativePath);
121
+
122
+ if (FILE_PATHS_TO_SKIP.some(filePath => file.includes(filePath))) {
123
+ // console.log(`Skipped: ${file} -> ${destPath}`);
124
+ continue;
125
+ }
126
+
127
+ // Component related file based on the user input
128
+ destPath = destPath.replace(
129
+ "/MyFirstComponent",
130
+ `/${replacements.INIT_PACKAGE_VAR_CLASS_NAME}`,
131
+ );
132
+
133
+ // Files that need to be renamed
134
+ if (FILES_TO_RENAME[relativePath]) {
135
+ destPath = destPath.replace(
136
+ relativePath,
137
+ FILES_TO_RENAME[relativePath],
138
+ );
139
+ }
140
+
141
+ await fs.mkdir(path.dirname(destPath), { recursive: true });
142
+
143
+ if (FILES_TO_COPY.includes(relativePath)) {
144
+ // Image like files that doesn't need proccessing
145
+ await fs.copyFile(file, destPath);
146
+ } else {
147
+ const content = await fs.readFile(file, { encoding: "utf8" });
148
+ const replaced = replacePlaceholders(content, replacements);
149
+ let formatted;
150
+ try {
151
+ formatted = await prettier.format(replaced, {
152
+ useTabs: true,
153
+ tabWidth: 4,
154
+ quoteProps: "consistent",
155
+ arrowParens: "avoid",
156
+ filepath: file,
157
+ });
158
+ // console.log(`Formatted: ${file} -> ${destPath}`);
159
+ } catch {
160
+ // console.log(`Not formatted: ${file} -> ${destPath}`);
161
+ formatted = replaced;
162
+ }
163
+
164
+ await fs.writeFile(destPath, formatted);
165
+ }
166
+
167
+ // console.log(`Processed: ${file} -> ${destPath}`);
168
+ }
169
+ }
170
+
169
171
  const createWebcomponentsPackage = async () => {
170
172
  let response;
171
173
  if (argv.name && !isPackageNameValid(argv.name)) {
172
- throw new Error("The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].");
174
+ throw new Error(
175
+ "The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].",
176
+ );
173
177
  }
174
178
 
175
179
  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.");
180
+ throw new Error(
181
+ "The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.",
182
+ );
183
+ }
184
+
185
+ if (argv.tag && !isTagValid(argv.tag)) {
186
+ throw new Error(
187
+ "The tag should be in kebab-case (f.e my-component) and it can't be a single word.",
188
+ );
177
189
  }
178
190
 
179
- if (argv.tag && !isTagValid(argv.tag) ) {
180
- throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
191
+ if (argv.testSetup && !isTestSetupValid(argv.testSetup)) {
192
+ throw new Error(
193
+ `The test setup should be a string and one of the following options: ${SUPPORTED_TEST_SETUPS.join(", ")}`,
194
+ );
181
195
  }
182
196
 
183
197
  let packageName = argv.name || "my-package";
184
198
  let componentName = argv.componentName || "MyComponent";
199
+ let testSetup = argv.testSetup || "manual";
185
200
  const skipSubfolder = !!argv.skipSubfolder;
186
201
 
187
202
  if (argv.skip) {
188
- return generateFilesContent(packageName, componentName, skipSubfolder);
203
+ return generateFilesContent(
204
+ packageName,
205
+ componentName,
206
+ skipSubfolder,
207
+ testSetup,
208
+ );
189
209
  }
190
210
 
191
211
  if (!argv.name) {
@@ -193,7 +213,10 @@ const createWebcomponentsPackage = async () => {
193
213
  type: "text",
194
214
  name: "name",
195
215
  message: "Package name:",
196
- validate: (value) => isPackageNameValid(value) ? true : "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
216
+ validate: value =>
217
+ isPackageNameValid(value)
218
+ ? true
219
+ : "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
197
220
  });
198
221
  packageName = response.name;
199
222
  }
@@ -204,12 +227,35 @@ const createWebcomponentsPackage = async () => {
204
227
  name: "componentName",
205
228
  message: "Component name:",
206
229
  initial: "MyComponent",
207
- validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
230
+ validate: value =>
231
+ isComponentNameValid(value)
232
+ ? true
233
+ : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
208
234
  });
209
235
  componentName = response.componentName;
210
236
  }
211
237
 
212
- return generateFilesContent(packageName, componentName, skipSubfolder);
238
+ if (!argv.testSetup) {
239
+ response = await prompts({
240
+ type: "select",
241
+ name: "testSetup",
242
+ message: "How would you like to set up testing?",
243
+ choices: [
244
+ { title: "Cypress", value: "cypress" },
245
+ { title: "I'll set it up manually", value: "manual" },
246
+ ],
247
+ initial: 0,
248
+ });
249
+
250
+ testSetup = response.testSetup;
251
+ }
252
+
253
+ return generateFilesContent(
254
+ packageName,
255
+ componentName,
256
+ skipSubfolder,
257
+ testSetup,
258
+ );
213
259
  };
214
260
 
215
261
  createWebcomponentsPackage();
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@ui5/create-webcomponents-package",
3
- "version": "2.9.1-rc.0",
3
+ "version": "2.10.0-rc.1",
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": "13677147aa78c5fdbc650b671c1794f1aa8f1671"
30
+ "gitHead": "30fe06a368825d1cdfdccb68e5c5a4806af98a4b"
28
31
  }
@@ -2,4 +2,6 @@
2
2
  dist
3
3
  test
4
4
  src/generated
5
- .eslintrc.cjs
5
+ .eslintrc.cjs
6
+
7
+ {{INIT_PACKAGE_CYPRESS_ESLINT_IGNORES}}
@@ -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,5 @@
1
+ {
2
+ "name": "Using fixtures to represent data",
3
+ "email": "hello@cypress.io",
4
+ "body": "Fixtures are a great way to mock data for responses to routes"
5
+ }
@@ -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
+ }
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from "cypress";
2
+
3
+ export default defineConfig({
4
+ component: {
5
+ devServer: {
6
+ framework: "@ui5/cypress-ct-ui5-webc" as any,
7
+ bundler: "vite",
8
+ },
9
+ },
10
+ });
@@ -1,3 +1,4 @@
1
1
  node_modules
2
2
  dist
3
- src/generated
3
+ src/generated
4
+ .dev-server-port
@@ -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
+ }
@@ -1,5 +1,5 @@
1
1
  import "@ui5/webcomponents-theming/dist/Assets.js"; // Theming
2
2
 
3
- // own INIT_PACKAGE_VAR_NAME package assets
3
+ // own {{INIT_PACKAGE_VAR_NAME}} package assets
4
4
  import "./generated/json-imports/Themes.js";
5
5
  import "./generated/json-imports/i18n.js";
@@ -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 INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./INIT_PACKAGE_VAR_CLASS_NAMETemplate.js";
9
+ import {{INIT_PACKAGE_VAR_CLASS_NAME}}Template from "./{{INIT_PACKAGE_VAR_CLASS_NAME}}Template.js";
10
10
 
11
11
  // Styles
12
- import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
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: INIT_PACKAGE_VAR_CLASS_NAMECss,
31
- template: INIT_PACKAGE_VAR_CLASS_NAMETemplate,
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 INIT_PACKAGE_VAR_CLASS_NAMETemplate(this: INIT_PACKAGE_VAR_CLASS_NAME) {
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>&lt;INIT_PACKAGE_VAR_TAG>&lt;/INIT_PACKAGE_VAR_TAG> </pre></div>
29
- <INIT_PACKAGE_VAR_TAG id="myFirstComponent"></INIT_PACKAGE_VAR_TAG>
28
+ <div> <pre>&lt;{{INIT_PACKAGE_VAR_TAG}}>&lt;/{{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
- <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>
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>
@@ -5,9 +5,10 @@
5
5
  "global.d.ts"
6
6
  ],
7
7
  "compilerOptions": {
8
+ {{INIT_PACKAGE_CYPRESS_ROOT_TSCONFIG}}
8
9
  "outDir": "dist",
9
10
  "experimentalDecorators": true,
10
11
  "module": "NodeNext",
11
- "moduleResolution": "NodeNext",
12
+ "moduleResolution": "NodeNext"
12
13
  },
13
14
  }
@@ -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
- });