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