@ui5/create-webcomponents-package 0.0.0-cb061e041 → 0.0.0-ccb0705ac
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 +1786 -0
- package/LICENSE.txt +201 -0
- package/README.md +13 -18
- package/create-package.js +239 -191
- package/package.json +8 -9
- 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 -2
- package/template/gitignore +2 -2
- package/template/npmignore +6 -0
- package/template/npsrc.json +3 -0
- package/template/{package-scripts.js → package-scripts.cjs} +0 -1
- package/template/package.json +35 -0
- package/template/src/Assets.ts +1 -1
- package/template/src/MyFirstComponent.ts +28 -20
- package/template/src/MyFirstComponentTemplate.tsx +9 -0
- package/template/{bundle.esm.js → src/bundle.esm.ts} +4 -5
- package/template/src/i18n/messagebundle.properties +3 -2
- package/template/src/i18n/messagebundle_de.properties +1 -1
- package/template/src/i18n/messagebundle_en.properties +1 -1
- package/template/src/i18n/messagebundle_es.properties +1 -1
- package/template/src/i18n/messagebundle_fr.properties +1 -1
- package/template/src/themes/MyFirstComponent.css +16 -10
- package/template/src/themes/sap_horizon_dark/parameters-bundle.css +1 -1
- package/template/test/pages/css/index.css +89 -0
- package/template/test/pages/img/logo.png +0 -0
- package/template/test/pages/index.html +42 -42
- package/template/tsconfig.template.json +14 -0
- package/template/vite.config.js +14 -0
- package/template/config/postcss.components/postcss.config.js +0 -1
- package/template/config/postcss.themes/postcss.config.js +0 -1
- package/template/config/wdio.conf.js +0 -1
- package/template/src/Assets.js +0 -5
- package/template/src/MyFirstComponent.hbs +0 -1
- package/template/src/MyFirstComponent.js +0 -67
- package/template/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
- package/template/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
- package/template/test/specs/Demo.spec.js +0 -14
- package/template/tsconfig.json +0 -16
- /package/template/{.eslintrc.js → eslintrc.cjs} +0 -0
package/create-package.js
CHANGED
|
@@ -1,206 +1,261 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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);
|
|
13
|
+
const VERSION = JSON.parse(
|
|
14
|
+
await fs.readFile(path.join(__dirname, "package.json")),
|
|
15
|
+
).version;
|
|
16
|
+
|
|
17
|
+
const argv = yargs(hideBin(process.argv))
|
|
18
|
+
.usage("Usage: npm create @ui5/webcomponents-package [options]")
|
|
19
|
+
.option("name", {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Package name (npm-compatible)",
|
|
22
|
+
default: "my-package",
|
|
23
|
+
})
|
|
24
|
+
.option("tag", {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "Component tag name (e.g., my-button)",
|
|
27
|
+
})
|
|
28
|
+
.option("testSetup", {
|
|
29
|
+
type: "string",
|
|
30
|
+
choices: ["cypress", "manual"],
|
|
31
|
+
description: "Test setup configuration",
|
|
32
|
+
default: "manual",
|
|
33
|
+
})
|
|
34
|
+
.option("skip", {
|
|
35
|
+
type: "boolean",
|
|
36
|
+
description: "Skip interactive prompts and use defaults/provided values",
|
|
37
|
+
default: false,
|
|
38
|
+
})
|
|
39
|
+
.option("skipSubfolder", {
|
|
40
|
+
type: "boolean",
|
|
41
|
+
description: "Create files in current directory instead of a subfolder",
|
|
42
|
+
default: false,
|
|
43
|
+
})
|
|
44
|
+
.example(
|
|
45
|
+
"npm create @ui5/webcomponents-package",
|
|
46
|
+
"Interactive mode with prompts",
|
|
47
|
+
)
|
|
48
|
+
.example(
|
|
49
|
+
"npm create @ui5/webcomponents-package -- --name my-components --skip",
|
|
50
|
+
"Non-interactive with custom name",
|
|
51
|
+
)
|
|
52
|
+
.example(
|
|
53
|
+
"npm create @ui5/webcomponents-package -- --name @scope/my-lib --testSetup cypress --skip",
|
|
54
|
+
"Non-interactive with scoped name and Cypress",
|
|
55
|
+
)
|
|
56
|
+
.help()
|
|
57
|
+
.alias("h", "help")
|
|
58
|
+
.version(VERSION)
|
|
59
|
+
.alias("v", "version")
|
|
60
|
+
.wrap(100).argv;
|
|
61
|
+
|
|
62
|
+
// Constants
|
|
63
|
+
const SUPPORTED_TEST_SETUPS = ["cypress", "manual"];
|
|
64
|
+
const SRC_DIR = path.join(__dirname, "template");
|
|
65
|
+
const DEST_DIR = process.cwd();
|
|
66
|
+
|
|
67
|
+
const FILES_TO_RENAME = {
|
|
68
|
+
[path.normalize("eslintignore")]: path.normalize(".eslintignore"),
|
|
69
|
+
[path.normalize("eslintrc.cjs")]: path.normalize(".eslintrc.cjs"),
|
|
70
|
+
[path.normalize("gitignore")]: path.normalize(".gitignore"),
|
|
71
|
+
[path.normalize("npmignore")]: path.normalize(".npmignore"),
|
|
72
|
+
[path.normalize("npsrc.json")]: path.normalize(".npsrc.json"),
|
|
73
|
+
[path.normalize("npmrc")]: path.normalize(".npmrc"),
|
|
74
|
+
[path.normalize("env")]: path.normalize(".env"),
|
|
75
|
+
[path.normalize("tsconfig.template.json")]: path.normalize("tsconfig.json"),
|
|
76
|
+
[path.normalize("cypress/tsconfig.template.json")]: path.normalize("cypress/tsconfig.json")
|
|
37
77
|
};
|
|
78
|
+
const FILES_TO_COPY = ["test/pages/img/logo.png"];
|
|
79
|
+
|
|
80
|
+
// Validation Patterns
|
|
81
|
+
const PackageNamePattern =
|
|
82
|
+
/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
|
83
|
+
const TagPattern = /^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/;
|
|
84
|
+
|
|
85
|
+
// Utility Functions
|
|
86
|
+
const isPackageNameValid = name =>
|
|
87
|
+
typeof name === "string" && PackageNamePattern.test(name);
|
|
88
|
+
const isTagValid = tag => typeof tag === "string" && TagPattern.test(tag);
|
|
89
|
+
const isTestSetupValid = setup =>
|
|
90
|
+
typeof setup === "string" && SUPPORTED_TEST_SETUPS.includes(setup);
|
|
91
|
+
|
|
92
|
+
async function collectFiles(dir, fileList = []) {
|
|
93
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
94
|
+
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
const fullPath = path.join(dir, entry.name);
|
|
97
|
+
if (entry.isDirectory()) {
|
|
98
|
+
await collectFiles(fullPath, fileList);
|
|
99
|
+
} else if (entry.isFile()) {
|
|
100
|
+
fileList.push(fullPath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
38
103
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z][a-zA-Z0-9\-_]+$/);
|
|
42
|
-
const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
|
|
43
|
-
const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
|
|
104
|
+
return fileList;
|
|
105
|
+
}
|
|
44
106
|
|
|
45
107
|
/**
|
|
46
108
|
* Hyphanates the given PascalCase string, f.e.:
|
|
47
109
|
* Foo -> "my-foo" (adds preffix)
|
|
48
110
|
* FooBar -> "foo-bar"
|
|
49
111
|
*/
|
|
50
|
-
const
|
|
51
|
-
const result = componentName
|
|
52
|
-
|
|
112
|
+
const hyphenateComponentName = componentName => {
|
|
113
|
+
const result = componentName
|
|
114
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
115
|
+
.toLowerCase();
|
|
53
116
|
return result.includes("-") ? result : `my-${result}`;
|
|
54
117
|
};
|
|
55
118
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (let key in vars) {
|
|
59
|
-
const re = new RegExp(key, "g");
|
|
60
|
-
content = content.replace(re, vars[key]);
|
|
61
|
-
}
|
|
62
|
-
return content;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const replaceVarsInFileName = (vars, fileName) => {
|
|
66
|
-
return fileName.replace(/MyFirstComponent/, vars.INIT_PACKAGE_VAR_CLASS_NAME);
|
|
67
|
-
};
|
|
119
|
+
const replacePlaceholders = (content, replacements) =>
|
|
120
|
+
content.replace(/{{(.*?)}}/g, (_, key) => replacements[key.trim()] || "");
|
|
68
121
|
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
122
|
+
const generateFilesContent = async (
|
|
123
|
+
packageName,
|
|
124
|
+
componentName,
|
|
125
|
+
skipSubfolder,
|
|
126
|
+
testSetup,
|
|
127
|
+
) => {
|
|
128
|
+
// All variables that will be replaced in the content of the template folder/
|
|
129
|
+
const vars = {
|
|
130
|
+
INIT_PACKAGE_VAR_NAME: packageName,
|
|
131
|
+
INIT_PACKAGE_VERSION: VERSION,
|
|
132
|
+
INIT_PACKAGE_VAR_TAG: argv.tag || hyphenateComponentName(componentName),
|
|
133
|
+
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
|
134
|
+
INIT_PACKAGE_CYPRESS_ROOT_TSCONFIG:
|
|
135
|
+
testSetup === "cypress"
|
|
136
|
+
? `"tsBuildInfoFile": "dist/.tsbuildinfo",\n"rootDir": "src",\n"composite": true,`
|
|
137
|
+
: "",
|
|
138
|
+
INIT_PACKAGE_CYPRESS_DEV_DEPS:
|
|
139
|
+
testSetup === "cypress"
|
|
140
|
+
? `"@ui5/cypress-ct-ui5-webc": "^0.0.4",\n"cypress": "^13.11.0",`
|
|
141
|
+
: "",
|
|
142
|
+
INIT_PACKAGE_CYPRESS_TEST_COMMANDS:
|
|
143
|
+
testSetup === "cypress"
|
|
144
|
+
? `"test": "cypress run --component --browser chrome",\n"test:open": "cypress open --component --browser chrome",`
|
|
145
|
+
: "",
|
|
146
|
+
INIT_PACKAGE_CYPRESS_ESLINT_IGNORES:
|
|
147
|
+
testSetup === "cypress" ? `cypress/*\ncypress.config.*` : "",
|
|
148
|
+
};
|
|
76
149
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
150
|
+
const packageBaseName = packageName.includes("@")
|
|
151
|
+
? packageName.slice(packageName.lastIndexOf("/") + 1)
|
|
152
|
+
: packageName;
|
|
153
|
+
const destDir = skipSubfolder
|
|
154
|
+
? path.join(DEST_DIR)
|
|
155
|
+
: path.join(DEST_DIR, packageBaseName);
|
|
80
156
|
|
|
81
|
-
|
|
157
|
+
await processFiles(destDir, vars, testSetup);
|
|
82
158
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fs.renameSync(destPath, destPath.replace("gitignore", ".gitignore"))
|
|
86
|
-
}
|
|
159
|
+
console.log("\nPackage successfully created!\nNext steps:\n");
|
|
160
|
+
console.log(`$ cd ${packageBaseName}`);
|
|
87
161
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
162
|
+
try {
|
|
163
|
+
const userAgent = parser(process.env.npm_config_user_agent);
|
|
164
|
+
userAgent.yarn
|
|
165
|
+
? console.log(`$ yarn\n$ yarn start`)
|
|
166
|
+
: console.log(`$ npm i\n$ npm start`);
|
|
167
|
+
} catch {
|
|
168
|
+
console.log(`$ npm i\n$ npm start`);
|
|
91
169
|
}
|
|
92
|
-
};
|
|
93
170
|
|
|
94
|
-
|
|
95
|
-
const isDir = fs.lstatSync(sourcePath).isDirectory();
|
|
96
|
-
if (isDir) {
|
|
97
|
-
if (destPath) {
|
|
98
|
-
mkdirp.sync(destPath);
|
|
99
|
-
}
|
|
100
|
-
fs.readdirSync(sourcePath).forEach(file => {
|
|
101
|
-
copyFiles(vars, path.join(sourcePath, file), path.join(destPath, file));
|
|
102
|
-
});
|
|
103
|
-
} else {
|
|
104
|
-
copyFile(vars, sourcePath, destPath);
|
|
105
|
-
}
|
|
171
|
+
console.log("\n");
|
|
106
172
|
};
|
|
107
173
|
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
INIT_PACKAGE_VAR_NAME: name,
|
|
114
|
-
INIT_PACKAGE_VAR_TAG: tagName,
|
|
115
|
-
INIT_PACKAGE_VAR_CLASS_NAME: componentName,
|
|
116
|
-
INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
|
|
117
|
-
};
|
|
174
|
+
async function processFiles(destDir, replacements, testSetup) {
|
|
175
|
+
const files = await collectFiles(SRC_DIR);
|
|
176
|
+
const FILE_PATHS_TO_SKIP = [
|
|
177
|
+
testSetup !== "cypress" ? path.normalize("cypress") : undefined,
|
|
178
|
+
].filter(Boolean);
|
|
118
179
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
ui5: {
|
|
123
|
-
webComponentsPackage: true,
|
|
124
|
-
},
|
|
125
|
-
scripts: {
|
|
126
|
-
"clean": "wc-dev clean",
|
|
127
|
-
"lint": "wc-dev lint",
|
|
128
|
-
"start": "wc-dev start",
|
|
129
|
-
"watch": "wc-dev watch",
|
|
130
|
-
"build": "wc-dev build",
|
|
131
|
-
"test": "wc-dev test",
|
|
132
|
-
"create-ui5-element": "wc-create-ui5-element",
|
|
133
|
-
"prepublishOnly": "npm run build",
|
|
134
|
-
},
|
|
135
|
-
exports: {
|
|
136
|
-
"./src/*": "./src/*",
|
|
137
|
-
"./dist/*": "./dist/*",
|
|
138
|
-
"./package.json": "./package.json",
|
|
139
|
-
"./bundle.js": "./bundle.js",
|
|
140
|
-
"./*": "./dist/*",
|
|
141
|
-
},
|
|
142
|
-
"dependencies": {
|
|
143
|
-
"@ui5/webcomponents-base": version,
|
|
144
|
-
"@ui5/webcomponents-theming": version,
|
|
145
|
-
},
|
|
146
|
-
"devDependencies": {
|
|
147
|
-
"@ui5/webcomponents-tools": version,
|
|
148
|
-
"chromedriver": "*",
|
|
149
|
-
},
|
|
150
|
-
};
|
|
180
|
+
for (const file of files) {
|
|
181
|
+
const relativePath = path.relative(SRC_DIR, file);
|
|
182
|
+
let destPath = path.join(destDir, relativePath);
|
|
151
183
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
if (FILE_PATHS_TO_SKIP.some(filePath => file.includes(filePath))) {
|
|
185
|
+
// console.log(`Skipped: ${file} -> ${destPath}`);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
155
188
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
189
|
+
// // Component related file based on the user input
|
|
190
|
+
// destPath = destPath.replace(
|
|
191
|
+
// "MyFirstComponent",
|
|
192
|
+
// replacements.INIT_PACKAGE_VAR_CLASS_NAME,
|
|
193
|
+
// );
|
|
194
|
+
|
|
195
|
+
// Files that need to be renamed
|
|
196
|
+
if (FILES_TO_RENAME[relativePath]) {
|
|
197
|
+
destPath = destPath.replace(
|
|
198
|
+
relativePath,
|
|
199
|
+
FILES_TO_RENAME[relativePath],
|
|
200
|
+
);
|
|
201
|
+
}
|
|
162
202
|
|
|
163
|
-
|
|
164
|
-
|
|
203
|
+
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
|
204
|
+
|
|
205
|
+
if (FILES_TO_COPY.includes(relativePath)) {
|
|
206
|
+
// Image like files that doesn't need proccessing
|
|
207
|
+
await fs.copyFile(file, destPath);
|
|
208
|
+
} else {
|
|
209
|
+
const content = await fs.readFile(file, { encoding: "utf8" });
|
|
210
|
+
const replaced = replacePlaceholders(content, replacements);
|
|
211
|
+
let formatted;
|
|
212
|
+
try {
|
|
213
|
+
formatted = await prettier.format(replaced, {
|
|
214
|
+
useTabs: true,
|
|
215
|
+
tabWidth: 4,
|
|
216
|
+
quoteProps: "consistent",
|
|
217
|
+
arrowParens: "avoid",
|
|
218
|
+
filepath: file,
|
|
219
|
+
});
|
|
220
|
+
// console.log(`Formatted: ${file} -> ${destPath}`);
|
|
221
|
+
} catch {
|
|
222
|
+
// console.log(`Not formatted: ${file} -> ${destPath}`);
|
|
223
|
+
formatted = replaced;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
await fs.writeFile(destPath, formatted);
|
|
227
|
+
}
|
|
165
228
|
|
|
166
|
-
|
|
167
|
-
try {
|
|
168
|
-
userAgentInfo = parser(process.env.npm_config_user_agent);
|
|
169
|
-
} catch (e) {}
|
|
170
|
-
|
|
171
|
-
if (userAgentInfo && userAgentInfo.yarn) {
|
|
172
|
-
console.log(`$ yarn`);
|
|
173
|
-
console.log(`$ yarn start`);
|
|
174
|
-
} else {
|
|
175
|
-
console.log(`$ npm i`);
|
|
176
|
-
console.log(`$ npm start`);
|
|
229
|
+
// console.log(`Processed: ${file} -> ${destPath}`);
|
|
177
230
|
}
|
|
231
|
+
}
|
|
178
232
|
|
|
179
|
-
console.log("\n");
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
// Main function
|
|
183
233
|
const createWebcomponentsPackage = async () => {
|
|
184
234
|
let response;
|
|
185
|
-
if (argv.name && !
|
|
186
|
-
throw new Error(
|
|
235
|
+
if (argv.name && !isPackageNameValid(argv.name)) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
"The package name should be a string, starting with letter and containing the following symbols [a-z, A-Z, 0-9].",
|
|
238
|
+
);
|
|
187
239
|
}
|
|
188
240
|
|
|
189
|
-
if (argv.
|
|
190
|
-
throw new Error(
|
|
241
|
+
if (argv.testSetup && !isTestSetupValid(argv.testSetup)) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
`The test setup should be a string and one of the following options: ${SUPPORTED_TEST_SETUPS.join(", ")}`,
|
|
244
|
+
);
|
|
191
245
|
}
|
|
192
246
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
let name = argv.name || "my-package";
|
|
198
|
-
let componentName = argv.componentName || "MyComponent";
|
|
199
|
-
let typescriptSupport = !!argv.enableTypescript;
|
|
247
|
+
let packageName = argv.name || "my-package";
|
|
248
|
+
let componentName = "MyFirstComponent";
|
|
249
|
+
let testSetup = argv.testSetup || "manual";
|
|
200
250
|
const skipSubfolder = !!argv.skipSubfolder;
|
|
201
251
|
|
|
202
252
|
if (argv.skip) {
|
|
203
|
-
return generateFilesContent(
|
|
253
|
+
return generateFilesContent(
|
|
254
|
+
packageName,
|
|
255
|
+
componentName,
|
|
256
|
+
skipSubfolder,
|
|
257
|
+
testSetup,
|
|
258
|
+
);
|
|
204
259
|
}
|
|
205
260
|
|
|
206
261
|
if (!argv.name) {
|
|
@@ -208,42 +263,35 @@ const createWebcomponentsPackage = async () => {
|
|
|
208
263
|
type: "text",
|
|
209
264
|
name: "name",
|
|
210
265
|
message: "Package name:",
|
|
211
|
-
validate:
|
|
266
|
+
validate: value =>
|
|
267
|
+
isPackageNameValid(value)
|
|
268
|
+
? true
|
|
269
|
+
: "Package name should be a string, starting with a letter and containing the following symbols [a-z, A-Z ,0-9, _, -].",
|
|
212
270
|
});
|
|
213
|
-
|
|
271
|
+
packageName = response.name;
|
|
214
272
|
}
|
|
215
273
|
|
|
216
|
-
if (!
|
|
274
|
+
if (!argv.testSetup) {
|
|
217
275
|
response = await prompts({
|
|
218
276
|
type: "select",
|
|
219
|
-
name: "
|
|
220
|
-
message: "
|
|
277
|
+
name: "testSetup",
|
|
278
|
+
message: "How would you like to set up testing?",
|
|
221
279
|
choices: [
|
|
222
|
-
{
|
|
223
|
-
|
|
224
|
-
value: false,
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
title: "TypeScript",
|
|
228
|
-
value: true,
|
|
229
|
-
},
|
|
280
|
+
{ title: "Cypress", value: "cypress" },
|
|
281
|
+
{ title: "I'll set it up manually", value: "manual" },
|
|
230
282
|
],
|
|
283
|
+
initial: 0,
|
|
231
284
|
});
|
|
232
|
-
typescriptSupport = response.language;
|
|
233
|
-
}
|
|
234
285
|
|
|
235
|
-
|
|
236
|
-
response = await prompts({
|
|
237
|
-
type: "text",
|
|
238
|
-
name: "componentName",
|
|
239
|
-
message: "Component name:",
|
|
240
|
-
initial: "MyComponent",
|
|
241
|
-
validate: (value) => isComponentNameValid(value) ? true : "Component name should follow PascalCase naming convention (f.e. Button, MyButton, etc.).",
|
|
242
|
-
});
|
|
243
|
-
componentName = response.componentName;
|
|
286
|
+
testSetup = response.testSetup;
|
|
244
287
|
}
|
|
245
288
|
|
|
246
|
-
return generateFilesContent(
|
|
289
|
+
return generateFilesContent(
|
|
290
|
+
packageName,
|
|
291
|
+
componentName,
|
|
292
|
+
skipSubfolder,
|
|
293
|
+
testSetup,
|
|
294
|
+
);
|
|
247
295
|
};
|
|
248
296
|
|
|
249
297
|
createWebcomponentsPackage();
|
package/package.json
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/create-webcomponents-package",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-ccb0705ac",
|
|
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": {
|
|
22
|
-
"mkdirp": "^1.0.4",
|
|
23
20
|
"npm-config-user-agent-parser": "^1.0.0",
|
|
21
|
+
"prettier": "^3.5.3",
|
|
24
22
|
"prompts": "^2.4.1",
|
|
25
23
|
"yargs": "^17.5.1"
|
|
26
|
-
}
|
|
27
|
-
|
|
24
|
+
},
|
|
25
|
+
"gitHead": "4105faf5a1081635cad0e0446370e0c3b66cb7e2"
|
|
26
|
+
}
|
|
@@ -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"
|