@ui5/create-webcomponents-package 0.0.0-4b9b0ab7c → 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.
Files changed (52) hide show
  1. package/CHANGELOG.md +1452 -0
  2. package/README.md +9 -13
  3. package/create-package.js +187 -158
  4. package/package.json +4 -1
  5. package/template/.eslintignore +3 -1
  6. package/template/.eslintrc.cjs +5 -0
  7. package/template/.npsrc.json +3 -0
  8. package/template/cypress/component/MyFirstComponent.cy.tsx +13 -0
  9. package/template/cypress/fixtures/example.json +5 -0
  10. package/template/cypress/support/commands.ts +37 -0
  11. package/template/cypress/support/component-index.html +12 -0
  12. package/template/cypress/support/component.ts +36 -0
  13. package/template/cypress/tsconfig.template.json +19 -0
  14. package/template/cypress.config.ts +10 -0
  15. package/template/env +1 -0
  16. package/template/gitignore +4 -0
  17. package/template/npmrc +2 -0
  18. package/template/{package-scripts.js → package-scripts.cjs} +0 -1
  19. package/template/package.json +35 -0
  20. package/template/src/Assets.ts +1 -1
  21. package/template/src/MyFirstComponent.ts +28 -20
  22. package/template/src/MyFirstComponentTemplate.tsx +9 -0
  23. package/template/{bundle.esm.js → src/bundle.esm.ts} +4 -5
  24. package/template/src/i18n/messagebundle.properties +3 -2
  25. package/template/src/i18n/messagebundle_de.properties +1 -1
  26. package/template/src/i18n/messagebundle_en.properties +1 -1
  27. package/template/src/i18n/messagebundle_es.properties +1 -1
  28. package/template/src/i18n/messagebundle_fr.properties +1 -1
  29. package/template/src/themes/MyFirstComponent.css +16 -10
  30. package/template/src/themes/sap_horizon_dark/parameters-bundle.css +3 -0
  31. package/template/src/themes/sap_horizon_hcb/parameters-bundle.css +3 -0
  32. package/template/test/pages/css/index.css +89 -0
  33. package/template/test/pages/img/logo.png +0 -0
  34. package/template/test/pages/index.html +42 -41
  35. package/template/tsconfig.template.json +14 -0
  36. package/template/vite.config.js +14 -0
  37. package/template/config/postcss.components/postcss.config.js +0 -1
  38. package/template/config/postcss.themes/postcss.config.js +0 -1
  39. package/template/config/wdio.conf.js +0 -1
  40. package/template/global.d.ts +0 -12
  41. package/template/src/Assets.js +0 -5
  42. package/template/src/MyFirstComponent.hbs +0 -1
  43. package/template/src/MyFirstComponent.js +0 -67
  44. package/template/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  45. package/template/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  46. package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  47. package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  48. package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  49. package/template/test/specs/Demo.spec.js +0 -12
  50. package/template/tsconfig.json +0 -14
  51. /package/template/src/themes/{sap_belize → sap_horizon}/parameters-bundle.css +0 -0
  52. /package/template/src/themes/{sap_belize_hcb → sap_horizon_hcw}/parameters-bundle.css +0 -0
package/README.md CHANGED
@@ -1,6 +1,4 @@
1
- ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_wide.png)
2
-
3
- # UI5 Web Components - Create Package
1
+ # ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-webcomponents/main/docs/images/UI5_logo_water.png)UI5 Web Components - Create Package
4
2
 
5
3
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fwebcomponents.svg)](https://www.npmjs.com/package/@ui5/webcomponents)
6
4
 
@@ -17,10 +15,9 @@ Usage:
17
15
  npm init @ui5/webcomponents-package -- [OPTIONS]
18
16
 
19
17
  Options:
20
- --name <string> - defines the package name
21
- --tag <string> - defines the tag name of the sample web component that will be created in your new package
22
- --enable-typescript - enables TypeScript support for the package
23
- --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
24
21
  ```
25
22
 
26
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
@@ -32,10 +29,9 @@ components package.
32
29
  Usage:
33
30
  yarn create @ui5/webcomponents-package [OPTIONS]
34
31
  Options:
35
- --name <string> - defines the package name
36
- --tag <string> - defines the tag name of the sample web component that will be created in your new package
37
- --enable-typescript - enables TypeScript support for the package
38
- --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
39
35
  ```
40
36
 
41
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
@@ -44,10 +40,10 @@ components package.
44
40
  ## Resources
45
41
  - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
46
42
  - [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
47
- - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
43
+ - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/play/)
48
44
 
49
45
  ## Support
50
- We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
46
+ We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com/).
51
47
 
52
48
  ## Contribute
53
49
  Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
package/create-package.js CHANGED
@@ -1,164 +1,200 @@
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
- // String utils
19
- const capitalizeFirst = str => str.substr(0,1).toUpperCase() + str.substr(1);
20
- const kebabToCamelCase = string => toCamelCase(string.split("-"));
21
- const toCamelCase = parts => {
22
- return parts.map((string, index) => {
23
- return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
24
- }).join("");
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"
25
31
  };
26
- const isTypescriptRelatedFile = sourcePath => {
27
- return ["Assets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
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]$/;
38
+
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);
45
+
46
+ /**
47
+ * Hyphanates the given PascalCase string, f.e.:
48
+ * Foo -> "my-foo" (adds preffix)
49
+ * FooBar -> "foo-bar"
50
+ */
51
+ const hyphenateComponentName = componentName => {
52
+ const result = componentName
53
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
54
+ .toLowerCase();
55
+ return result.includes("-") ? result : `my-${result}`;
28
56
  };
29
57
 
30
- // Validation of user input
31
- const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
32
- const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
58
+ const replacePlaceholders = (content, replacements) =>
59
+ content.replace(/{{(.*?)}}/g, (_, key) => replacements[key.trim()] || "");
33
60
 
34
- // Utils for building the file structure
35
- const replaceVarsInFileContent = (vars, content) => {
36
- for (let key in vars) {
37
- const re = new RegExp(key, "g");
38
- content = content.replace(re, vars[key]);
39
- }
40
- return content;
41
- };
42
-
43
- const replaceVarsInFileName = (vars, fileName) => {
44
- return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
45
- };
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/
68
+ const vars = {
69
+ INIT_PACKAGE_VAR_NAME: packageName,
70
+ INIT_PACKAGE_VERSION: VERSION,
71
+ INIT_PACKAGE_VAR_TAG: argv.tag || hyphenateComponentName(componentName),
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.*` : "",
87
+ };
46
88
 
47
- const copyFile = (vars, sourcePath, destPath) => {
48
- const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && sourcePath.includes("MyFirstComponent.js");
49
- const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTypescriptRelatedFile(sourcePath);
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);
50
95
 
51
- if (ignoreJsRelated || ignoreTsRelated) {
52
- return;
53
- }
96
+ await processFiles(destDir, vars, testSetup);
54
97
 
55
- let content = fs.readFileSync(sourcePath, { encoding: "UTF-8" });
56
- content = replaceVarsInFileContent(vars, content);
57
- destPath = replaceVarsInFileName(vars, destPath);
58
- fs.writeFileSync(destPath, content);
59
- };
98
+ console.log("\nPackage successfully created!\nNext steps:\n");
99
+ console.log(`$ cd ${destDir}`);
60
100
 
61
- const copyFiles = (vars, sourcePath, destPath) => {
62
- const isDir = fs.lstatSync(sourcePath).isDirectory();
63
- if (isDir) {
64
- if (destPath) {
65
- mkdirp.sync(destPath);
66
- }
67
- fs.readdirSync(sourcePath).forEach(file => {
68
- copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
69
- });
70
- } else {
71
- copyFile(vars, sourcePath, destPath);
101
+ try {
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`);
72
108
  }
109
+
110
+ console.log("\n");
73
111
  };
74
112
 
75
- const generateFilesContent = (name, tag, typescript) => {
76
- const className = capitalizeFirst(kebabToCamelCase(tag));
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);
77
118
 
78
- // All variables that will be replaced in the content of the resources/
79
- const vars = {
80
- INIT_PACKAGE_VAR_NAME: name,
81
- INIT_PACKAGE_VAR_TAG: tag,
82
- INIT_PACKAGE_VAR_CLASS_NAME: className,
83
- INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
84
- };
119
+ for (const file of files) {
120
+ const relativePath = path.relative(SRC_DIR, file);
121
+ let destPath = path.join(destDir, relativePath);
85
122
 
86
- const packageContent = {
87
- name,
88
- version: "0.0.1",
89
- ui5: {
90
- webComponentsPackage: true,
91
- },
92
- scripts: {
93
- "clean": "wc-dev clean",
94
- "lint": "wc-dev lint",
95
- "start": "wc-dev start",
96
- "watch": "wc-dev watch",
97
- "build": "wc-dev build",
98
- "test": "wc-dev test",
99
- "create-ui5-element": "wc-create-ui5-element",
100
- "prepublishOnly": "npm run build",
101
- },
102
- exports: {
103
- "./src/*": "./src/*",
104
- "./dist/*": "./dist/*",
105
- "./package.json": "./package.json",
106
- "./bundle.js": "./bundle.js",
107
- "./*": "./dist/*",
108
- },
109
- "dependencies": {
110
- "@ui5/webcomponents-base": version,
111
- "@ui5/webcomponents-theming": version,
112
- },
113
- "devDependencies": {
114
- "@ui5/webcomponents-tools": version,
115
- "chromedriver": "*",
116
- },
117
- };
123
+ if (FILE_PATHS_TO_SKIP.some(filePath => file.includes(filePath))) {
124
+ // console.log(`Skipped: ${file} -> ${destPath}`);
125
+ continue;
126
+ }
118
127
 
119
- // Update package.json
120
- const destDir = path.join(`./`, name);
121
- mkdirp.sync(destDir);
122
- fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
123
- // Copy files
124
- copyFiles(vars, TEMPLATE_DIR, destDir);
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
+ }
125
141
 
126
- console.log("\nPackage successfully created!\nNext steps:\n");
127
- console.log(`$ cd ${name}`);
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
+ }
128
167
 
129
- let userAgentInfo;
130
- try {
131
- userAgentInfo = parser(process.env.npm_config_user_agent);
132
- } catch (e) {}
133
-
134
- if (userAgentInfo && userAgentInfo.yarn) {
135
- console.log(`$ yarn`);
136
- console.log(`$ yarn start`);
137
- } else {
138
- console.log(`$ npm i`);
139
- console.log(`$ npm start`);
168
+ // console.log(`Processed: ${file} -> ${destPath}`);
140
169
  }
170
+ }
141
171
 
142
- console.log("\n");
143
- };
144
-
145
- // Main function
146
172
  const createWebcomponentsPackage = async () => {
147
173
  let response;
148
- if (argv.name && !isNameValid(argv.name)) {
149
- throw new Error("The package name should be a string (a-z, A-Z, 0-9).");
174
+ if (argv.name && !isPackageNameValid(argv.name)) {
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
+ );
150
178
  }
151
179
 
152
- if (argv.tag && !isTagValid(argv.tag) ) {
153
- throw new Error("The tag should be in kebab-case (my-first-component f.e) and it can't be a single word.");
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
+ );
154
184
  }
155
185
 
156
- let name = argv.name || "my-package";
157
- let tag = argv.tag || "my-first-component";
158
- let typescriptSupport = !!argv.enableTypescript;
186
+ let packageName = argv.name || "my-package";
187
+ let componentName = "MyComponent";
188
+ let testSetup = argv.testSetup || "manual";
189
+ const skipSubfolder = !!argv.skipSubfolder;
159
190
 
160
191
  if (argv.skip) {
161
- return generateFilesContent(name, tag, typescriptSupport);
192
+ return generateFilesContent(
193
+ packageName,
194
+ componentName,
195
+ skipSubfolder,
196
+ testSetup,
197
+ );
162
198
  }
163
199
 
164
200
  if (!argv.name) {
@@ -166,42 +202,35 @@ const createWebcomponentsPackage = async () => {
166
202
  type: "text",
167
203
  name: "name",
168
204
  message: "Package name:",
169
- validate: isNameValid,
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, _, -].",
170
209
  });
171
- name = response.name;
210
+ packageName = response.name;
172
211
  }
173
212
 
174
- if (!typescriptSupport) {
213
+ if (!argv.testSetup) {
175
214
  response = await prompts({
176
215
  type: "select",
177
- name: "language",
178
- message: "Project type:",
216
+ name: "testSetup",
217
+ message: "How would you like to set up testing?",
179
218
  choices: [
180
- {
181
- title: "JavaScript",
182
- value: false,
183
- },
184
- {
185
- title: "TypeScript",
186
- value: true,
187
- },
219
+ { title: "Cypress", value: "cypress" },
220
+ { title: "I'll set it up manually", value: "manual" },
188
221
  ],
222
+ initial: 0,
189
223
  });
190
- typescriptSupport = response.language;
191
- }
192
224
 
193
- if (!argv.tag) {
194
- response = await prompts({
195
- type: "text",
196
- name: "tag",
197
- message: "Component name:",
198
- initial: "my-first-component",
199
- validate: isTagValid,
200
- });
201
- tag = response.tag;
225
+ testSetup = response.testSetup;
202
226
  }
203
227
 
204
- return generateFilesContent(name, tag, typescriptSupport);
228
+ return generateFilesContent(
229
+ packageName,
230
+ componentName,
231
+ skipSubfolder,
232
+ testSetup,
233
+ );
205
234
  };
206
235
 
207
236
  createWebcomponentsPackage();
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@ui5/create-webcomponents-package",
3
- "version": "0.0.0-4b9b0ab7c",
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
  }
@@ -2,4 +2,6 @@
2
2
  dist
3
3
  test
4
4
  src/generated
5
- jsdoc-dist
5
+ .eslintrc.cjs
6
+
7
+ {{INIT_PACKAGE_CYPRESS_ESLINT_IGNORES}}
@@ -0,0 +1,5 @@
1
+ const config = require("@ui5/webcomponents-tools/components-package/eslint.js");
2
+
3
+ // This eslint config is defined @ui5/webcomponents-tools,
4
+ // Feel free to override part of the configuration or provide entirely new config to fit your dev requirements.
5
+ module.exports = config;
@@ -0,0 +1,3 @@
1
+ {
2
+ "config": "./package-scripts.cjs"
3
+ }
@@ -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,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
+ });
package/template/env ADDED
@@ -0,0 +1 @@
1
+ VITE_BUNDLE_PATH="../../dist/bundle.esm.js"
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ dist
3
+ src/generated
4
+ .dev-server-port
package/template/npmrc ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect the chromedriver version
2
+ detect_chromedriver_version=true
@@ -2,7 +2,6 @@ const getScripts = require("@ui5/webcomponents-tools/components-package/nps.js")
2
2
 
3
3
  const options = {
4
4
  port: 8080,
5
- typescript: INIT_PACKAGE_VAR_TYPESCRIPT,
6
5
  };
7
6
 
8
7
  const scripts = getScripts(options);