@ui5/create-webcomponents-package 0.0.0-bf8366eb6 → 0.0.0-c143e338b
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 +847 -0
- package/LICENSE.txt +201 -0
- package/README.md +13 -18
- package/create-package.js +195 -156
- package/package.json +9 -8
- 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/{.eslintignore → eslintignore} +3 -1
- package/template/gitignore +2 -1
- package/template/npmignore +6 -0
- package/template/npsrc.json +3 -0
- package/template/package.json +35 -0
- package/template/src/Assets.ts +1 -1
- package/template/src/MyFirstComponent.ts +16 -20
- package/template/src/MyFirstComponentTemplate.tsx +9 -0
- package/template/{bundle.esm.js → src/bundle.esm.ts} +4 -3
- package/template/test/pages/css/index.css +65 -12
- package/template/test/pages/img/logo.png +0 -0
- package/template/test/pages/index.html +36 -40
- package/template/tsconfig.template.json +14 -0
- package/template/vite.config.js +14 -0
- package/template/config/wdio.conf.js +0 -1
- package/template/src/MyFirstComponent.hbs +0 -6
- package/template/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/template/test/specs/Demo.spec.js +0 -13
- package/template/tsconfig.json +0 -16
- /package/template/{.eslintrc.js → eslintrc.cjs} +0 -0
- /package/template/{package-scripts.js → package-scripts.cjs} +0 -0
package/create-package.js
CHANGED
|
@@ -1,190 +1,217 @@
|
|
|
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 { hideBin } from "yargs/helpers";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
import * as prettier from "prettier";
|
|
10
|
+
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
11
13
|
const argv = yargs(hideBin(process.argv)).argv;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const VERSION = JSON.parse(
|
|
15
|
+
await fs.readFile(path.join(__dirname, "package.json")),
|
|
16
|
+
).version;
|
|
17
|
+
|
|
18
|
+
// Constants
|
|
19
|
+
const SUPPORTED_TEST_SETUPS = ["cypress", "manual"];
|
|
20
|
+
const SRC_DIR = path.join(__dirname, "template");
|
|
21
|
+
const DEST_DIR = process.cwd();
|
|
22
|
+
|
|
23
|
+
const FILES_TO_RENAME = {
|
|
24
|
+
[path.normalize("eslintignore")]: path.normalize(".eslintignore"),
|
|
25
|
+
[path.normalize("eslintrc.cjs")]: path.normalize(".eslintrc.cjs"),
|
|
26
|
+
[path.normalize("gitignore")]: path.normalize(".gitignore"),
|
|
27
|
+
[path.normalize("npmignore")]: path.normalize(".npmignore"),
|
|
28
|
+
[path.normalize("npsrc.json")]: path.normalize(".npsrc.json"),
|
|
29
|
+
[path.normalize("npmrc")]: path.normalize(".npmrc"),
|
|
30
|
+
[path.normalize("env")]: path.normalize(".env"),
|
|
31
|
+
[path.normalize("tsconfig.template.json")]: path.normalize("tsconfig.json"),
|
|
32
|
+
[path.normalize("cypress/tsconfig.template.json")]: path.normalize("cypress/tsconfig.json")
|
|
26
33
|
};
|
|
34
|
+
const FILES_TO_COPY = ["test/pages/img/logo.png"];
|
|
35
|
+
|
|
36
|
+
// Validation Patterns
|
|
37
|
+
const PackageNamePattern =
|
|
38
|
+
/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
|
39
|
+
const TagPattern = /^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/;
|
|
40
|
+
|
|
41
|
+
// Utility Functions
|
|
42
|
+
const isPackageNameValid = name =>
|
|
43
|
+
typeof name === "string" && PackageNamePattern.test(name);
|
|
44
|
+
const isTagValid = tag => typeof tag === "string" && TagPattern.test(tag);
|
|
45
|
+
const isTestSetupValid = setup =>
|
|
46
|
+
typeof setup === "string" && SUPPORTED_TEST_SETUPS.includes(setup);
|
|
47
|
+
|
|
48
|
+
async function collectFiles(dir, fileList = []) {
|
|
49
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
50
|
+
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
const fullPath = path.join(dir, entry.name);
|
|
53
|
+
if (entry.isDirectory()) {
|
|
54
|
+
await collectFiles(fullPath, fileList);
|
|
55
|
+
} else if (entry.isFile()) {
|
|
56
|
+
fileList.push(fullPath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
27
59
|
|
|
28
|
-
|
|
29
|
-
|
|
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]$/);
|
|
60
|
+
return fileList;
|
|
61
|
+
}
|
|
33
62
|
|
|
34
63
|
/**
|
|
35
64
|
* Hyphanates the given PascalCase string, f.e.:
|
|
36
65
|
* Foo -> "my-foo" (adds preffix)
|
|
37
66
|
* FooBar -> "foo-bar"
|
|
38
67
|
*/
|
|
39
|
-
const
|
|
40
|
-
const result = componentName
|
|
41
|
-
|
|
68
|
+
const hyphenateComponentName = componentName => {
|
|
69
|
+
const result = componentName
|
|
70
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
71
|
+
.toLowerCase();
|
|
42
72
|
return result.includes("-") ? result : `my-${result}`;
|
|
43
73
|
};
|
|
44
74
|
|
|
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
|
-
};
|
|
75
|
+
const replacePlaceholders = (content, replacements) =>
|
|
76
|
+
content.replace(/{{(.*?)}}/g, (_, key) => replacements[key.trim()] || "");
|
|
80
77
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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);
|
|
97
|
-
|
|
98
|
-
// All variables that will be replaced in the content of the resources/
|
|
78
|
+
const generateFilesContent = async (
|
|
79
|
+
packageName,
|
|
80
|
+
componentName,
|
|
81
|
+
skipSubfolder,
|
|
82
|
+
testSetup,
|
|
83
|
+
) => {
|
|
84
|
+
// All variables that will be replaced in the content of the template folder/
|
|
99
85
|
const vars = {
|
|
100
86
|
INIT_PACKAGE_VAR_NAME: packageName,
|
|
101
|
-
|
|
87
|
+
INIT_PACKAGE_VERSION: VERSION,
|
|
88
|
+
INIT_PACKAGE_VAR_TAG: argv.tag || hyphenateComponentName(componentName),
|
|
102
89
|
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
|
90
|
+
INIT_PACKAGE_CYPRESS_ROOT_TSCONFIG:
|
|
91
|
+
testSetup === "cypress"
|
|
92
|
+
? `"tsBuildInfoFile": "dist/.tsbuildinfo",\n"rootDir": "src",\n"composite": true,`
|
|
93
|
+
: "",
|
|
94
|
+
INIT_PACKAGE_CYPRESS_DEV_DEPS:
|
|
95
|
+
testSetup === "cypress"
|
|
96
|
+
? `"@ui5/cypress-ct-ui5-webc": "^0.0.4",\n"cypress": "^13.11.0",`
|
|
97
|
+
: "",
|
|
98
|
+
INIT_PACKAGE_CYPRESS_TEST_COMMANDS:
|
|
99
|
+
testSetup === "cypress"
|
|
100
|
+
? `"test": "cypress run --component --browser chrome",\n"test:open": "cypress open --component --browser chrome",`
|
|
101
|
+
: "",
|
|
102
|
+
INIT_PACKAGE_CYPRESS_ESLINT_IGNORES:
|
|
103
|
+
testSetup === "cypress" ? `cypress/*\ncypress.config.*` : "",
|
|
103
104
|
};
|
|
104
105
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
scripts: {
|
|
112
|
-
"clean": "wc-dev clean",
|
|
113
|
-
"lint": "wc-dev lint",
|
|
114
|
-
"start": "wc-dev start",
|
|
115
|
-
"watch": "wc-dev watch",
|
|
116
|
-
"build": "wc-dev build",
|
|
117
|
-
"test": "wc-dev test",
|
|
118
|
-
"create-ui5-element": "wc-create-ui5-element",
|
|
119
|
-
"prepublishOnly": "npm run build",
|
|
120
|
-
},
|
|
121
|
-
exports: {
|
|
122
|
-
"./src/*": "./src/*",
|
|
123
|
-
"./dist/*": "./dist/*",
|
|
124
|
-
"./package.json": "./package.json",
|
|
125
|
-
"./bundle.js": "./bundle.js",
|
|
126
|
-
"./*": "./dist/*",
|
|
127
|
-
},
|
|
128
|
-
"dependencies": {
|
|
129
|
-
"@ui5/webcomponents-base": version,
|
|
130
|
-
"@ui5/webcomponents-theming": version,
|
|
131
|
-
},
|
|
132
|
-
"devDependencies": {
|
|
133
|
-
"@ui5/webcomponents-tools": version,
|
|
134
|
-
"chromedriver": "*",
|
|
135
|
-
"typescript": "^5.2.2"
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// Update package.json
|
|
140
|
-
let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
|
|
106
|
+
const packageBaseName = packageName.includes("@")
|
|
107
|
+
? packageName.slice(packageName.lastIndexOf("/") + 1)
|
|
108
|
+
: packageName;
|
|
109
|
+
const destDir = skipSubfolder
|
|
110
|
+
? path.join(DEST_DIR)
|
|
111
|
+
: path.join(DEST_DIR, packageBaseName);
|
|
141
112
|
|
|
142
|
-
|
|
143
|
-
mkdirp.sync(destDir);
|
|
144
|
-
fs.writeFileSync(path.join(destDir, "package.json"), JSON.stringify(packageContent, null, 2));
|
|
145
|
-
// Copy files
|
|
146
|
-
copyFiles(vars, TEMPLATE_DIR, destDir);
|
|
113
|
+
await processFiles(destDir, vars, testSetup);
|
|
147
114
|
|
|
148
115
|
console.log("\nPackage successfully created!\nNext steps:\n");
|
|
149
|
-
console.log(`$ cd ${
|
|
116
|
+
console.log(`$ cd ${packageBaseName}`);
|
|
150
117
|
|
|
151
|
-
let userAgentInfo;
|
|
152
118
|
try {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
console.log(`$
|
|
159
|
-
} else {
|
|
160
|
-
console.log(`$ npm i`);
|
|
161
|
-
console.log(`$ npm start`);
|
|
119
|
+
const userAgent = parser(process.env.npm_config_user_agent);
|
|
120
|
+
userAgent.yarn
|
|
121
|
+
? console.log(`$ yarn\n$ yarn start`)
|
|
122
|
+
: console.log(`$ npm i\n$ npm start`);
|
|
123
|
+
} catch {
|
|
124
|
+
console.log(`$ npm i\n$ npm start`);
|
|
162
125
|
}
|
|
163
126
|
|
|
164
127
|
console.log("\n");
|
|
165
128
|
};
|
|
166
129
|
|
|
167
|
-
|
|
130
|
+
async function processFiles(destDir, replacements, testSetup) {
|
|
131
|
+
const files = await collectFiles(SRC_DIR);
|
|
132
|
+
const FILE_PATHS_TO_SKIP = [
|
|
133
|
+
testSetup !== "cypress" ? path.normalize("cypress") : undefined,
|
|
134
|
+
].filter(Boolean);
|
|
135
|
+
|
|
136
|
+
for (const file of files) {
|
|
137
|
+
const relativePath = path.relative(SRC_DIR, file);
|
|
138
|
+
let destPath = path.join(destDir, relativePath);
|
|
139
|
+
|
|
140
|
+
if (FILE_PATHS_TO_SKIP.some(filePath => file.includes(filePath))) {
|
|
141
|
+
// console.log(`Skipped: ${file} -> ${destPath}`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// // Component related file based on the user input
|
|
146
|
+
// destPath = destPath.replace(
|
|
147
|
+
// "MyFirstComponent",
|
|
148
|
+
// replacements.INIT_PACKAGE_VAR_CLASS_NAME,
|
|
149
|
+
// );
|
|
150
|
+
|
|
151
|
+
// Files that need to be renamed
|
|
152
|
+
if (FILES_TO_RENAME[relativePath]) {
|
|
153
|
+
destPath = destPath.replace(
|
|
154
|
+
relativePath,
|
|
155
|
+
FILES_TO_RENAME[relativePath],
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
160
|
+
|
|
161
|
+
if (FILES_TO_COPY.includes(relativePath)) {
|
|
162
|
+
// Image like files that doesn't need proccessing
|
|
163
|
+
await fs.copyFile(file, destPath);
|
|
164
|
+
} else {
|
|
165
|
+
const content = await fs.readFile(file, { encoding: "utf8" });
|
|
166
|
+
const replaced = replacePlaceholders(content, replacements);
|
|
167
|
+
let formatted;
|
|
168
|
+
try {
|
|
169
|
+
formatted = await prettier.format(replaced, {
|
|
170
|
+
useTabs: true,
|
|
171
|
+
tabWidth: 4,
|
|
172
|
+
quoteProps: "consistent",
|
|
173
|
+
arrowParens: "avoid",
|
|
174
|
+
filepath: file,
|
|
175
|
+
});
|
|
176
|
+
// console.log(`Formatted: ${file} -> ${destPath}`);
|
|
177
|
+
} catch {
|
|
178
|
+
// console.log(`Not formatted: ${file} -> ${destPath}`);
|
|
179
|
+
formatted = replaced;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
await fs.writeFile(destPath, formatted);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// console.log(`Processed: ${file} -> ${destPath}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
168
189
|
const createWebcomponentsPackage = async () => {
|
|
169
190
|
let response;
|
|
170
191
|
if (argv.name && !isPackageNameValid(argv.name)) {
|
|
171
|
-
throw new Error(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (argv.componentName && !isComponentNameValid(argv.componentName)) {
|
|
175
|
-
throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
|
|
192
|
+
throw new Error(
|
|
193
|
+
"The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].",
|
|
194
|
+
);
|
|
176
195
|
}
|
|
177
196
|
|
|
178
|
-
if (argv.
|
|
179
|
-
throw new Error(
|
|
197
|
+
if (argv.testSetup && !isTestSetupValid(argv.testSetup)) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
`The test setup should be a string and one of the following options: ${SUPPORTED_TEST_SETUPS.join(", ")}`,
|
|
200
|
+
);
|
|
180
201
|
}
|
|
181
202
|
|
|
182
203
|
let packageName = argv.name || "my-package";
|
|
183
|
-
let componentName =
|
|
204
|
+
let componentName = "MyFirstComponent";
|
|
205
|
+
let testSetup = argv.testSetup || "manual";
|
|
184
206
|
const skipSubfolder = !!argv.skipSubfolder;
|
|
185
207
|
|
|
186
208
|
if (argv.skip) {
|
|
187
|
-
return generateFilesContent(
|
|
209
|
+
return generateFilesContent(
|
|
210
|
+
packageName,
|
|
211
|
+
componentName,
|
|
212
|
+
skipSubfolder,
|
|
213
|
+
testSetup,
|
|
214
|
+
);
|
|
188
215
|
}
|
|
189
216
|
|
|
190
217
|
if (!argv.name) {
|
|
@@ -192,23 +219,35 @@ const createWebcomponentsPackage = async () => {
|
|
|
192
219
|
type: "text",
|
|
193
220
|
name: "name",
|
|
194
221
|
message: "Package name:",
|
|
195
|
-
validate:
|
|
222
|
+
validate: value =>
|
|
223
|
+
isPackageNameValid(value)
|
|
224
|
+
? true
|
|
225
|
+
: "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
|
|
196
226
|
});
|
|
197
227
|
packageName = response.name;
|
|
198
228
|
}
|
|
199
229
|
|
|
200
|
-
if (!argv.
|
|
230
|
+
if (!argv.testSetup) {
|
|
201
231
|
response = await prompts({
|
|
202
|
-
type: "
|
|
203
|
-
name: "
|
|
204
|
-
message: "
|
|
205
|
-
|
|
206
|
-
|
|
232
|
+
type: "select",
|
|
233
|
+
name: "testSetup",
|
|
234
|
+
message: "How would you like to set up testing?",
|
|
235
|
+
choices: [
|
|
236
|
+
{ title: "Cypress", value: "cypress" },
|
|
237
|
+
{ title: "I'll set it up manually", value: "manual" },
|
|
238
|
+
],
|
|
239
|
+
initial: 0,
|
|
207
240
|
});
|
|
208
|
-
|
|
241
|
+
|
|
242
|
+
testSetup = response.testSetup;
|
|
209
243
|
}
|
|
210
244
|
|
|
211
|
-
return generateFilesContent(
|
|
245
|
+
return generateFilesContent(
|
|
246
|
+
packageName,
|
|
247
|
+
componentName,
|
|
248
|
+
skipSubfolder,
|
|
249
|
+
testSetup,
|
|
250
|
+
);
|
|
212
251
|
};
|
|
213
252
|
|
|
214
253
|
createWebcomponentsPackage();
|
package/package.json
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/create-webcomponents-package",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-c143e338b",
|
|
4
4
|
"description": "UI5 Web Components: create package",
|
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"
|
|
7
|
+
"type": "module",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"openui5",
|
|
10
10
|
"sapui5",
|
|
11
11
|
"ui5"
|
|
12
12
|
],
|
|
13
|
-
"bin":
|
|
14
|
-
"create-webcomponents-package": "create-package.js"
|
|
15
|
-
},
|
|
13
|
+
"bin": "create-package.js",
|
|
16
14
|
"repository": {
|
|
17
15
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/UI5/webcomponents.git",
|
|
19
17
|
"directory": "packages/create-package"
|
|
20
18
|
},
|
|
21
19
|
"dependencies": {
|
|
20
|
+
"chokidar-cli": "^3.0.0",
|
|
22
21
|
"mkdirp": "^1.0.4",
|
|
23
22
|
"npm-config-user-agent-parser": "^1.0.0",
|
|
23
|
+
"prettier": "^3.5.3",
|
|
24
24
|
"prompts": "^2.4.1",
|
|
25
25
|
"yargs": "^17.5.1"
|
|
26
|
-
}
|
|
27
|
-
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "6309e8d90fa82344a60be72084660c1e3e52e107"
|
|
28
|
+
}
|
|
@@ -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