@ui5/create-webcomponents-package 0.0.0-d1315d658 → 0.0.0-d160e83dd

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/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
 
@@ -20,7 +18,6 @@ Options:
20
18
  --name <string> - defines the package name
21
19
  --component-name <string> - defines the component class name that will be created in your new package
22
20
  --tag <string> - defines the tag name of the sample web component that will be created in your new package. The tag will be derived from the component name if not provided.
23
- --enable-typescript - enables TypeScript support for the package
24
21
  --skip - skips configuration and generates package with a default value for each parameter that wasn't passed
25
22
  ```
26
23
 
@@ -36,7 +33,6 @@ Options:
36
33
  --name <string> - defines the package name
37
34
  --component-name <string> - defines the component class name that will be created in your new package
38
35
  --tag <string> - defines the tag name of the sample web component that will be created in your new package
39
- --enable-typescript - enables TypeScript support for the package
40
36
  --skip - skips configuration and generates package with a default value for each parameter that wasn't passed
41
37
  ```
42
38
 
@@ -46,10 +42,10 @@ components package.
46
42
  ## Resources
47
43
  - [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
48
44
  - [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
49
- - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
45
+ - [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/play/)
50
46
 
51
47
  ## Support
52
- 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/).
48
+ 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/).
53
49
 
54
50
  ## Contribute
55
51
  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
@@ -15,13 +15,6 @@ const version = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))
15
15
  // from where all the files will be copied
16
16
  const TEMPLATE_DIR = path.join(`${__dirname}`, `template/`);
17
17
 
18
- // String utils
19
- const isTSRelatedFile = sourcePath => {
20
- return ["Assets.ts", "MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
21
- };
22
- const isJSRelatedFile = sourcePath => {
23
- return ["Assets.js", "MyFirstComponent.js"].some(fileName => sourcePath.includes(fileName));
24
- };
25
18
  const isGitIgnore = sourcePath => {
26
19
  return sourcePath.includes("gitignore");
27
20
  };
@@ -34,10 +27,8 @@ const isNPMRC = sourcePath => {
34
27
 
35
28
  // Validation of user input
36
29
  const ComponentNamePattern = /^[A-Z][A-Za-z0-9]+$/;
37
- const NamespacePattern = /^[a-z][a-z0-9\.\-]+$/;
38
30
  const isPackageNameValid = name => typeof name === "string" && name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
39
31
  const isComponentNameValid = name => typeof name === "string" && ComponentNamePattern.test(name);
40
- const isNamespaceValid = name => typeof name === "string" && NamespacePattern.test(name);
41
32
  const isTagValid = tag => typeof tag === "string" && tag.match(/^[a-z0-9]+?-[a-zA-Z0-9\-_]+?[a-z0-9]$/);
42
33
 
43
34
  /**
@@ -65,13 +56,6 @@ const replaceVarsInFileName = (vars, fileName) => {
65
56
  };
66
57
 
67
58
  const copyFile = (vars, sourcePath, destPath) => {
68
- const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && isJSRelatedFile(sourcePath);
69
- const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTSRelatedFile(sourcePath);
70
-
71
- if (ignoreJsRelated || ignoreTsRelated) {
72
- return;
73
- }
74
-
75
59
  if (isLogo(sourcePath)) {
76
60
  fs.copyFileSync(sourcePath, destPath);
77
61
  return;
@@ -108,16 +92,14 @@ const copyFiles = (vars, sourcePath, destPath) => {
108
92
  }
109
93
  };
110
94
 
111
- const generateFilesContent = (packageName, componentName, namespace, typescript, skipSubfolder) => {
95
+ const generateFilesContent = (packageName, componentName, skipSubfolder) => {
112
96
  const tagName = argv.tag || hyphaneteComponentName(componentName);
113
97
 
114
98
  // All variables that will be replaced in the content of the resources/
115
99
  const vars = {
116
- INIT_PACKAGE_VAR_NAMESPACE: namespace, // namespace must be replaced before name
117
100
  INIT_PACKAGE_VAR_NAME: packageName,
118
101
  INIT_PACKAGE_VAR_TAG: tagName,
119
102
  INIT_PACKAGE_VAR_CLASS_NAME: componentName,
120
- INIT_PACKAGE_VAR_TYPESCRIPT: typescript,
121
103
  };
122
104
 
123
105
  const packageContent = {
@@ -126,6 +108,7 @@ const generateFilesContent = (packageName, componentName, namespace, typescript,
126
108
  ui5: {
127
109
  webComponentsPackage: true,
128
110
  },
111
+ type: "module",
129
112
  scripts: {
130
113
  "clean": "wc-dev clean",
131
114
  "lint": "wc-dev lint",
@@ -150,13 +133,10 @@ const generateFilesContent = (packageName, componentName, namespace, typescript,
150
133
  "devDependencies": {
151
134
  "@ui5/webcomponents-tools": version,
152
135
  "chromedriver": "*",
136
+ "typescript": "^5.6.2"
153
137
  },
154
138
  };
155
139
 
156
- if (typescript) {
157
- packageContent.devDependencies.typescript = "^4.9.4";
158
- }
159
-
160
140
  // Update package.json
161
141
  let destDir = packageName.includes("@") ? packageName.slice(packageName.lastIndexOf("/") + 1) : packageName;
162
142
 
@@ -196,22 +176,16 @@ const createWebcomponentsPackage = async () => {
196
176
  throw new Error("The component name should be a string, starting with a capital letter [A-Z][a-z], for example: Button, MyButton, etc.");
197
177
  }
198
178
 
199
- if (argv.namespace && !isNamespaceValid(argv.namespace)) {
200
- throw new Error("The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.");
201
- }
202
-
203
179
  if (argv.tag && !isTagValid(argv.tag) ) {
204
180
  throw new Error("The tag should be in kebab-case (f.e my-component) and it can't be a single word.");
205
181
  }
206
182
 
207
183
  let packageName = argv.name || "my-package";
208
184
  let componentName = argv.componentName || "MyComponent";
209
- let namespace = argv.namespace || "demo.components";
210
- let typescriptSupport = !!argv.enableTypescript;
211
185
  const skipSubfolder = !!argv.skipSubfolder;
212
186
 
213
187
  if (argv.skip) {
214
- return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
188
+ return generateFilesContent(packageName, componentName, skipSubfolder);
215
189
  }
216
190
 
217
191
  if (!argv.name) {
@@ -224,25 +198,6 @@ const createWebcomponentsPackage = async () => {
224
198
  packageName = response.name;
225
199
  }
226
200
 
227
- if (!typescriptSupport) {
228
- response = await prompts({
229
- type: "select",
230
- name: "language",
231
- message: "Project type:",
232
- choices: [
233
- {
234
- title: "JavaScript",
235
- value: false,
236
- },
237
- {
238
- title: "TypeScript",
239
- value: true,
240
- },
241
- ],
242
- });
243
- typescriptSupport = response.language;
244
- }
245
-
246
201
  if (!argv.componentName) {
247
202
  response = await prompts({
248
203
  type: "text",
@@ -254,18 +209,7 @@ const createWebcomponentsPackage = async () => {
254
209
  componentName = response.componentName;
255
210
  }
256
211
 
257
- if (!argv.namespace) {
258
- response = await prompts({
259
- type: "text",
260
- name: "namespace",
261
- message: "JSDoc namespace:",
262
- initial: "demo.components",
263
- validate: (value) => isNamespaceValid(value) ? true : "The JSDoc namespace must start with a letter and can only contain small-case letters, numbers, dots and dashes.",
264
- });
265
- namespace = response.namespace;
266
- }
267
-
268
- return generateFilesContent(packageName, componentName, namespace, typescriptSupport, skipSubfolder);
212
+ return generateFilesContent(packageName, componentName, skipSubfolder);
269
213
  };
270
214
 
271
215
  createWebcomponentsPackage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/create-webcomponents-package",
3
- "version": "0.0.0-d1315d658",
3
+ "version": "0.0.0-d160e83dd",
4
4
  "description": "UI5 Web Components: create package",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -2,5 +2,4 @@
2
2
  dist
3
3
  test
4
4
  src/generated
5
- jsdoc-dist
6
- .eslintrc.js
5
+ .eslintrc.cjs
@@ -0,0 +1,3 @@
1
+ {
2
+ "config": "./package-scripts.cjs"
3
+ }
@@ -6,7 +6,6 @@ import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
6
6
  import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
7
7
  import { getTheme, setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
8
8
  import { getNoConflict, setNoConflict } from "@ui5/webcomponents-base/dist/config/NoConflict.js";
9
- import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
10
9
  import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js";
11
10
 
12
11
  // Enable additional themes and i18n texts
@@ -25,7 +24,6 @@ window["sap-ui-webcomponents-bundle"] = {
25
24
  getNoConflict,
26
25
  setNoConflict,
27
26
  getCalendarType,
28
- getRTL,
29
27
  getFirstDayOfWeek,
30
28
  },
31
29
  };
@@ -1,4 +1,3 @@
1
1
  node_modules
2
2
  dist
3
- jsdoc-dist
4
3
  src/generated
@@ -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);
@@ -1,13 +1,12 @@
1
1
  import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
2
  import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
3
3
  import property from "@ui5/webcomponents-base/dist/decorators/property.js";
4
- import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
5
- import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
4
+ import i18n from "@ui5/webcomponents-base/dist/decorators/i18n.js";
5
+ import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
6
6
  import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
7
- import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
8
7
 
9
8
  // Template
10
- import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
9
+ import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./INIT_PACKAGE_VAR_CLASS_NAMETemplate.js";
11
10
 
12
11
  // Styles
13
12
  import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
@@ -22,32 +21,26 @@ import { COUNT } from "./generated/i18n/i18n-defaults.js";
22
21
  * The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
23
22
  *
24
23
  * @constructor
25
- * @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
26
- * @extends sap.ui.webc.base.UI5Element
27
- * @tagname INIT_PACKAGE_VAR_TAG
24
+ * @extends UI5Element
28
25
  * @public
29
26
  */
30
27
  @customElement({
31
28
  tag: "INIT_PACKAGE_VAR_TAG",
32
- renderer: litRender,
29
+ renderer: jsxRenderer,
33
30
  styles: INIT_PACKAGE_VAR_CLASS_NAMECss,
34
31
  template: INIT_PACKAGE_VAR_CLASS_NAMETemplate,
35
32
  })
36
33
  class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
34
+ @i18n("INIT_PACKAGE_VAR_NAME")
37
35
  static i18nBundle: I18nBundle;
38
36
 
39
- static async onDefine() {
40
- INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
41
- }
42
-
43
37
  /**
44
38
  * Defines the component count.
45
- * @name INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME.prototype.count
39
+ * @default 0
46
40
  * @public
47
- * @type { sap.ui.webc.base.types.Integer }
48
41
  */
49
- @property({ validator: Integer, defaultValue: 0 })
50
- count!: number;
42
+ @property({ type: Number })
43
+ count = 0;
51
44
 
52
45
  onClick() {
53
46
  this.count++;
@@ -0,0 +1,9 @@
1
+ import type INIT_PACKAGE_VAR_CLASS_NAME from "./INIT_PACKAGE_VAR_CLASS_NAME.js";
2
+
3
+ export default function INIT_PACKAGE_VAR_CLASS_NAMETemplate(this: INIT_PACKAGE_VAR_CLASS_NAME) {
4
+ return (
5
+ <div class="root" onClick={this.onClick}>
6
+ {this.counterText} :: {this.count}
7
+ </div>
8
+ );
9
+ }
@@ -1,4 +1,4 @@
1
- :host {
1
+ .root {
2
2
  display: inline-flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -13,4 +13,5 @@
13
13
  line-height: 3rem;
14
14
  font-size: 1.25rem;
15
15
  user-select: none;
16
+ cursor: pointer;
16
17
  }
@@ -22,6 +22,11 @@ h2 {
22
22
  flex-direction: column;
23
23
  }
24
24
 
25
+ .app-logo {
26
+ height: 230px;
27
+ width: 230px;
28
+ }
29
+
25
30
  .app-first-component {
26
31
  margin-bottom: 3rem;
27
32
  }
Binary file
@@ -21,7 +21,7 @@
21
21
 
22
22
  <body>
23
23
  <div class="app">
24
- <a href="https://sap.github.io/ui5-webcomponents/playground/?path=/docs/docs-getting-started-first-steps--docs" target="_blank"><img src="./img/logo.png" alt="logo"/></a>
24
+ <a href="https://sap.github.io/ui5-webcomponents/docs/getting-started/first-steps/" target="_blank"><img src="./img/logo.png" class="app-logo" alt="logo"/></a>
25
25
 
26
26
  <div class="app-first-component">
27
27
  <h1>Hooray! It's Your First Web Component!</h1>
@@ -50,7 +50,7 @@
50
50
 
51
51
  <div class="app-docs">
52
52
  <h2>Documentation</h2>
53
- <a class="link" href="https://sap.github.io/ui5-webcomponents/playground/?path=/docs/docs-development-custom-ui5-web-components-packages--docs">Custom Component Development</a>
53
+ <a class="link" href="https://sap.github.io/ui5-webcomponents/docs/development/custom-UI5-Web-Components-Packages/">Custom Component Development</a>
54
54
  </div>
55
55
  </div>
56
56
  </body>
@@ -1,4 +1,4 @@
1
- const assert = require("assert");
1
+ import { assert } from "chai";
2
2
 
3
3
  describe("INIT_PACKAGE_VAR_TAG rendering", async () => {
4
4
  before(async () => {
@@ -1,15 +1,13 @@
1
1
  {
2
- "include": ["src/**/*", "global.d.ts"],
3
- "compilerOptions": {
4
- "target": "ES2021",
5
- // Generate d.ts files
6
- "declaration": true,
7
- "outDir": "dist",
8
- "skipLibCheck": true,
9
- "sourceMap": true,
10
- "inlineSources": true,
11
- "strict": true,
12
- "moduleResolution": "node",
13
- "experimentalDecorators": true,
14
- },
15
- }
2
+ "extends": "@ui5/webcomponents-tools/tsconfig.json",
3
+ "include": [
4
+ "src/**/*",
5
+ "global.d.ts"
6
+ ],
7
+ "compilerOptions": {
8
+ "outDir": "dist",
9
+ "experimentalDecorators": true,
10
+ "module": "NodeNext",
11
+ "moduleResolution": "NodeNext",
12
+ },
13
+ }
@@ -0,0 +1,14 @@
1
+ import viteConfig from "@ui5/webcomponents-tools/components-package/vite.config.js"; //eslint-disable-line
2
+
3
+ // Modifying the default Vite configuration provided by the @ui5/webcomponents-tools package.
4
+ // You can directly access and update the properties you need to change.
5
+ // Ensure that the property exists before modifying it to avoid unintended errors.
6
+ // For available configuration options, refer to: https://vite.dev/config/#configuring-vite
7
+ //
8
+ // Ensure the plugins array exists
9
+ // viteConfig.plugins = viteConfig.plugins || [];
10
+ //
11
+ // Push a new fake plugin
12
+ // viteConfig.plugins.push({ name: 'my-custom-plugin' });
13
+
14
+ export default viteConfig;
@@ -1 +0,0 @@
1
- module.exports = require("@ui5/webcomponents-tools/components-package/postcss.components.js"); // eslint-disable-line
@@ -1 +0,0 @@
1
- module.exports = require("@ui5/webcomponents-tools/components-package/postcss.themes.js"); // eslint-disable-line
@@ -1,5 +0,0 @@
1
- import "@ui5/webcomponents-theming/dist/Assets.js"; // Theming
2
-
3
- // own INIT_PACKAGE_VAR_NAME package assets
4
- import "./generated/json-imports/Themes.js";
5
- import "./generated/json-imports/i18n.js";
@@ -1 +0,0 @@
1
- <div @click="{{onClick}}">{{counterText}} :: {{count}}</div>
@@ -1,82 +0,0 @@
1
- import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
- import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3
- import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
4
- import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
5
-
6
- // Template
7
- import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
8
-
9
- // Styles
10
- import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
11
-
12
- import { COUNT } from "./generated/i18n/i18n-defaults.js";
13
-
14
- /**
15
- * @public
16
- */
17
- const metadata = {
18
- tag: "INIT_PACKAGE_VAR_TAG",
19
- properties: /** @lends INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME.prototype */ {
20
- /**
21
- * Defines the count of the component.
22
- * @type { sap.ui.webc.base.types.Integer }
23
- * @defaultvalue 0
24
- * @public
25
- */
26
- count: {
27
- type: Integer,
28
- defaultValue: 0,
29
- },
30
- },
31
- slots: {
32
- },
33
- events: {
34
- },
35
- };
36
-
37
- /**
38
- * @class
39
- *
40
- * <h3 class="comment-api-title">Overview</h3>
41
- *
42
- * The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
43
- *
44
- * @constructor
45
- * @alias INIT_PACKAGE_VAR_NAMESPACE.INIT_PACKAGE_VAR_CLASS_NAME
46
- * @extends sap.ui.webc.base.UI5Element
47
- * @tagname INIT_PACKAGE_VAR_TAG
48
- * @public
49
- */
50
- class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
51
- static get metadata() {
52
- return metadata;
53
- }
54
-
55
- static get render() {
56
- return litRender;
57
- }
58
-
59
- static get template() {
60
- return INIT_PACKAGE_VAR_CLASS_NAMETemplate;
61
- }
62
-
63
- static get styles() {
64
- return INIT_PACKAGE_VAR_CLASS_NAMECss;
65
- }
66
-
67
- static async onDefine() {
68
- INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
69
- }
70
-
71
- onClick() {
72
- this.count++;
73
- }
74
-
75
- get counterText() {
76
- return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(COUNT);
77
- }
78
- }
79
-
80
- INIT_PACKAGE_VAR_CLASS_NAME.define();
81
-
82
- export default INIT_PACKAGE_VAR_CLASS_NAME;
File without changes
File without changes