@ui5/create-webcomponents-package 1.10.3 → 1.10.4-rc.0

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.10.4-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v1.10.3...v1.10.4-rc.0) (2023-01-26)
7
+
8
+ **Note:** Version bump only for package @ui5/create-webcomponents-package
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.10.3](https://github.com/SAP/ui5-webcomponents/compare/v1.10.2...v1.10.3) (2023-01-25)
7
15
 
8
16
  **Note:** Version bump only for package @ui5/create-webcomponents-package
package/index.js CHANGED
@@ -19,6 +19,9 @@ const toCamelCase = parts => {
19
19
  return index === 0 ? string.toLowerCase() : string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
20
20
  }).join("");
21
21
  };
22
+ const isTypescriptRelatedFile = sourcePath => {
23
+ return ["MyFirstComponent.ts", "tsconfig.json", "global.d.ts"].some(fileName => sourcePath.includes(fileName));
24
+ }
22
25
 
23
26
  // Validation of user input
24
27
  const isNameValid = name => typeof name === "string" && name.match(/^[a-zA-Z0-9\-_]+$/);
@@ -39,6 +42,13 @@ const replaceVarsInFileName = (vars, fileName) => {
39
42
  };
40
43
 
41
44
  const copyFile = (vars, sourcePath, destPath) => {
45
+ const ignoreJsRelated = vars.INIT_PACKAGE_VAR_TYPESCRIPT && sourcePath.includes("MyFirstComponent.js")
46
+ const ignoreTsRelated = !vars.INIT_PACKAGE_VAR_TYPESCRIPT && isTypescriptRelatedFile(sourcePath)
47
+
48
+ if (ignoreJsRelated || ignoreTsRelated) {
49
+ return;
50
+ }
51
+
42
52
  let content = fs.readFileSync(sourcePath, {encoding: "UTF-8"});
43
53
  content = replaceVarsInFileContent(vars, content);
44
54
  destPath = replaceVarsInFileName(vars, destPath);
@@ -76,6 +86,24 @@ const createWebcomponentsPackage = async () => {
76
86
  name = response.name;
77
87
  }
78
88
 
89
+ // Add TypeScript support
90
+ response = await prompts({
91
+ type: "select",
92
+ name: "language",
93
+ message: "Support TypeScript:",
94
+ choices: [
95
+ {
96
+ title: "JavaScript",
97
+ value: "js",
98
+ },
99
+ {
100
+ title: "TypeScript",
101
+ value: "ts",
102
+ },
103
+ ]
104
+ });
105
+ const typescript = response.language === "ts";
106
+
79
107
  // Get the port
80
108
  response = await prompts({
81
109
  type: "text",
@@ -104,6 +132,7 @@ const createWebcomponentsPackage = async () => {
104
132
  INIT_PACKAGE_VAR_PORT: port,
105
133
  INIT_PACKAGE_VAR_TAG: tag,
106
134
  INIT_PACKAGE_VAR_CLASS_NAME: className,
135
+ INIT_PACKAGE_VAR_TYPESCRIPT: typescript
107
136
  };
108
137
 
109
138
  const packageContent = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/create-webcomponents-package",
3
- "version": "1.10.3",
3
+ "version": "1.10.4-rc.0",
4
4
  "description": "UI5 Web Components: create package",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -23,5 +23,5 @@
23
23
  "npm-config-user-agent-parser": "^1.0.0",
24
24
  "prompts": "^2.4.1"
25
25
  },
26
- "gitHead": "78222ac6ff90e19163d924b84ef405d39943e98d"
26
+ "gitHead": "b618aed1a969ce5a738b620cb8b2d7d796638d4c"
27
27
  }
@@ -0,0 +1,12 @@
1
+ // eslint-disable-next-line
2
+ import "@ui5/webcomponents-base/dist/global";
3
+ import { TemplateFunction } from "@ui5/webcomponents-base/dist/renderer/executeTemplate.js";
4
+
5
+ export {};
6
+
7
+ declare global {
8
+ module "*.lit.js" {
9
+ const content: TemplateFunction;
10
+ export default content;
11
+ }
12
+ }
@@ -2,6 +2,7 @@ const getScripts = require("@ui5/webcomponents-tools/components-package/nps.js")
2
2
 
3
3
  const options = {
4
4
  port: INIT_PACKAGE_VAR_PORT,
5
+ typescript: INIT_PACKAGE_VAR_TYPESCRIPT,
5
6
  };
6
7
 
7
8
  const scripts = getScripts(options);
@@ -0,0 +1,57 @@
1
+ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
+ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
3
+ import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
4
+ import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
5
+ import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
6
+ import type { I18nText } from "@ui5/webcomponents-base/dist/i18nBundle.js";
7
+
8
+ // Template
9
+ import INIT_PACKAGE_VAR_CLASS_NAMETemplate from "./generated/templates/INIT_PACKAGE_VAR_CLASS_NAMETemplate.lit.js";
10
+
11
+ // Styles
12
+ import INIT_PACKAGE_VAR_CLASS_NAMECss from "./generated/themes/INIT_PACKAGE_VAR_CLASS_NAME.css.js";
13
+
14
+ // @ts-ignore
15
+ import { PLEASE_WAIT } from "./generated/i18n/i18n-defaults.js";
16
+
17
+ /**
18
+ * @class
19
+ *
20
+ * <h3 class="comment-api-title">Overview</h3>
21
+ *
22
+ * The <code>INIT_PACKAGE_VAR_TAG</code> component is a demo component that displays some text.
23
+ *
24
+ * @constructor
25
+ * @alias demo.components.INIT_PACKAGE_VAR_CLASS_NAME
26
+ * @extends sap.ui.webc.base.UI5Element
27
+ * @tagname INIT_PACKAGE_VAR_TAG
28
+ * @public
29
+ */
30
+ @customElement("INIT_PACKAGE_VAR_TAG")
31
+ class INIT_PACKAGE_VAR_CLASS_NAME extends UI5Element {
32
+ static i18nBundle: I18nBundle;
33
+
34
+ static get render() {
35
+ return litRender;
36
+ }
37
+
38
+ static get template() {
39
+ return INIT_PACKAGE_VAR_CLASS_NAMETemplate;
40
+ }
41
+
42
+ static get styles() {
43
+ return INIT_PACKAGE_VAR_CLASS_NAMECss;
44
+ }
45
+
46
+ static async onDefine() {
47
+ INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle = await getI18nBundle("INIT_PACKAGE_VAR_NAME");
48
+ }
49
+
50
+ get pleaseWaitText() {
51
+ return INIT_PACKAGE_VAR_CLASS_NAME.i18nBundle.getText(PLEASE_WAIT as I18nText);
52
+ }
53
+ }
54
+
55
+ INIT_PACKAGE_VAR_CLASS_NAME.define();
56
+
57
+ export default INIT_PACKAGE_VAR_CLASS_NAME;
@@ -0,0 +1,14 @@
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
+ "strict": true,
11
+ "moduleResolution": "node",
12
+ "experimentalDecorators": true,
13
+ },
14
+ }