create-liferay-react-cx 1.0.2 → 1.0.3

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.
Files changed (3) hide show
  1. package/README.md +80 -267
  2. package/bin/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,267 +1,80 @@
1
- # create-liferay-react-cx
2
-
3
- > ⚡ Zero-config CLI scaffold for **Liferay React Client Extensions** (custom element type).
4
- > Powered by [Vite](https://vitejs.dev/) · Compatible with **Liferay 7.4 / DXP 2024.Q1+**
5
-
6
- [![npm version](https://img.shields.io/npm/v/create-liferay-react-cx?color=8B5CF6&label=npm)](https://www.npmjs.com/package/create-liferay-react-cx)
7
- [![license](https://img.shields.io/npm/l/create-liferay-react-cx?color=8B5CF6)](./LICENSE)
8
- [![node](https://img.shields.io/node/v/create-liferay-react-cx?color=8B5CF6)](https://nodejs.org)
9
-
10
- ---
11
-
12
- ## Table of Contents
13
-
14
- - [What is a Liferay Client Extension?](#what-is-a-liferay-client-extension)
15
- - [Requirements](#requirements)
16
- - [Quick Start](#quick-start)
17
- - [All Ways to Use This CLI](#all-ways-to-use-this-cli)
18
- - [Method 1 — npm create (Recommended)](#method-1--npm-create-recommended)
19
- - [Method 2 — npx (No Install)](#method-2--npx-no-install)
20
- - [Options & Flags](#options--flags)
21
- - [Interactive Mode](#interactive-mode)
22
- - [Generated Project Structure](#generated-project-structure)
23
- - [Development Workflow](#development-workflow)
24
- - [React Version Compatibility](#react-version-compatibility)
25
- - [Contributing](#contributing)
26
- - [License](#license)
27
-
28
- ---
29
-
30
- ## What is a Liferay Client Extension?
31
-
32
- A **Client Extension (CE)** is the modern, decoupled way to extend Liferay DXP / Community Edition — no Java, no OSGi, no portal restarts required.
33
-
34
- A **Custom Element** CE wraps your React app as a standard Web Component (`<my-widget />`), which Liferay embeds directly on any page. This CLI scaffolds everything you need to build, preview, and deploy one in seconds.
35
-
36
- ---
37
-
38
- ## Requirements
39
-
40
- Before you start, make sure you have:
41
-
42
- | Requirement | Version |
43
- |---|---|
44
- | Node.js | 18.0.0 |
45
- | npm | ≥ 9.0.0 |
46
- | [Liferay Workspace](https://learn.liferay.com/dxp/latest/en/building-applications/tooling/liferay-workspace/what-is-liferay-workspace.html) | For `gradlew deploy` |
47
-
48
- > **Note:** The generated project must sit inside a Liferay Workspace at `[workspace]/client-extensions/my-widget/` for Gradle deployment to work.
49
-
50
- ---
51
-
52
- ## Quick Start
53
-
54
- ```bash
55
- npx create-liferay-react-cx my-widget
56
- cd my-widget
57
- ../../gradlew deploy
58
- ```
59
-
60
- That's it. Your custom element is live in Liferay. 🚀
61
-
62
- ---
63
-
64
- ## All Ways to Use This CLI
65
-
66
- ### Method 1 `npm create` (Recommended)
67
-
68
- `npm create` is the standard npm convention for scaffolding tools (like `npm create vite`, `npm create react-app`). It automatically resolves `create-liferay-react-cx` under the hood.
69
-
70
- **With a project name (fastest):**
71
- ```bash
72
- npm create liferay-react-cx my-widget
73
- ```
74
-
75
- **With a specific React version:**
76
- ```bash
77
- npm create liferay-react-cx -- --name my-widget --react-version 18.2.0
78
- ```
79
- > ⚠️ Note the `--` before flags — this is required when using `npm create` with named options, so npm passes them through to the CLI correctly.
80
-
81
- **Interactive wizard (no arguments):**
82
- ```bash
83
- npm create liferay-react-cx
84
- ```
85
-
86
- ---
87
-
88
- ### Method 2 — `npx` (No Install)
89
-
90
- Use `npx` to run the CLI directly without installing anything globally. The full package name `create-liferay-react-cx` is used here.
91
-
92
- **With a project name:**
93
- ```bash
94
- npx create-liferay-react-cx my-widget
95
- ```
96
-
97
- **With a specific React version:**
98
- ```bash
99
- npx create-liferay-react-cx --name my-widget --react-version 18.2.0
100
- ```
101
-
102
- **Interactive wizard:**
103
- ```bash
104
- npx create-liferay-react-cx
105
- ```
106
-
107
- ---
108
-
109
- ## Options & Flags
110
-
111
- | Flag | Short | Description | Default |
112
- |------|-------|-------------|---------|
113
- | `--name` | `-n` | App name in **kebab-case** | _(prompted)_ |
114
- | `--react-version` | `-r` | React version to scaffold with | `16.12.0` |
115
- | `--help` | `-h` | Print help and exit | — |
116
- | `--version` | `-v` | Print version and exit | — |
117
-
118
- **App name rules:** lowercase letters, numbers, and hyphens only. Must start with a letter. Examples: `my-widget`, `employee-portal`, `news-feed`.
119
-
120
- ---
121
-
122
- ## Interactive Mode
123
-
124
- Run the CLI with no arguments to enter the interactive wizard:
125
-
126
- ```bash
127
- npx create-liferay-react-cx
128
- # or
129
- npm create liferay-react-cx
130
- ```
131
-
132
- You will be asked:
133
-
134
- 1. **App name** — enter a kebab-case name for your widget
135
- 2. **React version** — choose from a list or enter a custom version:
136
- - `16.12.0` — Liferay 7.4 / DXP classic
137
- - `18.2.0` — Liferay 7.4 U45+ / DXP 2024.Q1+
138
- - `Custom` — enter any valid semver (e.g. `17.0.2`)
139
- 3. **Install dependencies now?** — yes/no confirm
140
-
141
- ---
142
-
143
- ## Generated Project Structure
144
-
145
- Running the CLI creates the following layout:
146
-
147
- ```
148
- my-widget/
149
- ├── client-extension.yaml ← Liferay CE descriptor (auto-configured)
150
- ├── index.html ← Vite dev-server entry point
151
- ├── package.json ← Project dependencies & scripts
152
- ├── vite.config.js ← Vite build config
153
- ├── eslint.config.js ← ESLint flat config
154
- └── src/
155
- ├── main.jsx ← Web Component registration (HTMLElement)
156
- ├── App.jsx ← Your React component — start editing here
157
- ├── index.css ← Global reset (shadow DOM scoped)
158
- └── assets/
159
- └── style.css ← Component styles (shadow DOM isolated)
160
- ```
161
-
162
- ### What `client-extension.yaml` does
163
-
164
- This file tells Liferay how to register and display your widget:
165
-
166
- ```yaml
167
- my-widget:
168
- type: customElement # renders as <my-widget> on Liferay pages
169
- htmlElementName: my-widget # the HTML tag name
170
- urls:
171
- - assets/*.js # built JS bundle from vite-build/
172
- cssURLs:
173
- - assets/*.css # built CSS bundle from vite-build/
174
- useESM: true # ES module support
175
- instanceable: false # one instance per page
176
- portletCategoryName: category.client-extensions
177
- ```
178
-
179
- All values are automatically replaced with your app name during scaffolding.
180
-
181
- ---
182
-
183
- ## Development Workflow
184
-
185
- ### ✅ Deploying to Liferay (Standard Workflow)
186
-
187
- When working inside a Liferay Workspace, **you only need one command**. Gradle handles the npm install, Vite build, and deployment automatically — no manual `npm run build` needed.
188
-
189
- **1. Navigate into your project:**
190
- ```bash
191
- cd my-widget
192
- ```
193
-
194
- **2. Deploy directly to Liferay** (from the Liferay Workspace root):
195
- ```bash
196
- ../../gradlew deploy
197
- ```
198
-
199
- That's it. Under the hood, Gradle will:
200
- - Run `npm install` (if `node_modules` is missing)
201
- - Run `npm run build` (Vite compiles to `vite-build/`)
202
- - Copy the output into Liferay's deploy folder
203
- - Hot-reload the bundle in your running Liferay instance
204
-
205
- > After deployment, go to **Liferay Admin → Fragments and Resources → Client Extensions** to find and add your widget to a page.
206
-
207
- ---
208
-
209
- ### 🖥️ Local Preview (Optional)
210
-
211
- If you want to preview your React component in a browser **outside of Liferay** during development (faster feedback, hot reload), you can use Vite's dev server:
212
-
213
- ```bash
214
- npm install # only needed once
215
- npm run dev # starts at http://localhost:5173
216
- ```
217
-
218
- > This is purely optional and useful for rapid UI development. The component will render standalone — not inside Liferay's portal context.
219
-
220
- ---
221
-
222
- ## React Version Compatibility
223
-
224
- | React Version | Liferay Compatibility | Notes |
225
- |:---:|:---|:---|
226
- | `16.12.0` | Liferay 7.4 GA / DXP classic | Uses Liferay's bundled React. Smaller bundle. |
227
- | `18.2.0` | Liferay 7.4 U45+ / DXP 2024.Q1+ | Fully isolated in shadow DOM. Concurrent features. |
228
-
229
- Not sure which to pick? Use `16.12.0` for maximum compatibility with older Liferay instances, or `18.2.0` for newer deployments that support isolated client extensions.
230
-
231
- ---
232
-
233
- ## Contributing
234
-
235
- Contributions, issues, and feature requests are welcome!
236
-
237
- ```bash
238
- # 1. Clone the repo
239
- git clone https://github.com/laxitkhanpara/liferay-react-ce.git
240
- cd liferay-react-cx
241
-
242
- # 2. Install dependencies
243
- npm install
244
-
245
- # 3. Test locally
246
- node bin/index.js my-test-app
247
-
248
- # 4. Clean up
249
- rm -rf my-test-app
250
- ```
251
-
252
- Please open an [issue](https://github.com/laxitkhanpara/liferay-react-ce/issues) first to discuss any significant changes.
253
-
254
- ---
255
-
256
- ## License
257
-
258
- [MIT](./LICENSE) © [Laxit Khanpara](https://github.com/laxitkhanpara)
259
-
260
- ---
261
-
262
- ## Links
263
-
264
- - 📦 [npm package](https://www.npmjs.com/package/create-liferay-react-cx)
265
- - 🐛 [Report a bug](https://github.com/laxitkhanpara/liferay-react-ce/issues)
266
- - 📖 [Liferay Client Extensions docs](https://learn.liferay.com/dxp/latest/en/building-applications/client-extensions.html)
267
- - 🏗️ [Liferay Workspace docs](https://learn.liferay.com/dxp/latest/en/building-applications/tooling/liferay-workspace/what-is-liferay-workspace.html)
1
+ # create-liferay-react-cx
2
+
3
+ **Zero-config CLI** to scaffold **Liferay React Client Extensions** in seconds.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/create-liferay-react-cx)](https://www.npmjs.com/package/create-liferay-react-cx)
6
+ [![license](https://img.shields.io/npm/l/create-liferay-react-cx)](https://github.com/laxitkhanpara/create-liferay-react-cx/blob/main/LICENSE)
7
+
8
+ ---
9
+
10
+ ## Quick Start
11
+
12
+ ```bash
13
+ npx create-liferay-react-cx my-widget
14
+ cd my-widget
15
+ ../../gradlew deploy
16
+ ```
17
+
18
+ ## What You Get
19
+
20
+ - **Vite-powered** React project (fast builds, HMR)
21
+ - **client-extension.yaml** pre-configured
22
+ - **Shadow DOM** isolated styles
23
+ - **Ready to deploy** to Liferay 7.4+ / DXP
24
+
25
+ ## Usage
26
+
27
+ ### Interactive Mode
28
+ ```bash
29
+ npx create-liferay-react-cx
30
+ ```
31
+
32
+ ### With Arguments
33
+ ```bash
34
+ npx create-liferay-react-cx my-widget --react-version 18.2.0
35
+ ```
36
+
37
+ ### Using npm create
38
+ ```bash
39
+ npm create liferay-react-cx my-widget
40
+ ```
41
+
42
+ ## Options
43
+
44
+ | Flag | Description | Default |
45
+ |------|-------------|---------|
46
+ | `--name, -n` | App name (kebab-case) | _(prompted)_ |
47
+ | `--react-version, -r` | React version | `16.12.0` |
48
+ | `--help, -h` | Show help | |
49
+ | `--version, -v` | Show version | — |
50
+
51
+ ## Requirements
52
+
53
+ - **Node.js** ≥ 18.0.0
54
+ - **npm** ≥ 9.0.0
55
+ - **Liferay Workspace** (for deployment)
56
+
57
+ ## React Version Guide
58
+
59
+ - **16.12.0** → Liferay 7.4 GA / DXP classic
60
+ - **18.2.0** Liferay 7.4 U45+ / DXP 2024.Q1+
61
+
62
+ ## After Scaffolding
63
+
64
+ 1. Navigate into your project: `cd my-widget`
65
+ 2. Deploy to Liferay: `../../gradlew deploy`
66
+ 3. Add widget to a page in **Liferay Admin → Client Extensions**
67
+
68
+ ## Documentation
69
+
70
+ 📖 Full documentation: [GitHub Repository](https://github.com/laxitkhanpara/create-liferay-react-cx)
71
+
72
+ ## Links
73
+
74
+ - [GitHub](https://github.com/laxitkhanpara/create-liferay-react-cx)
75
+ - [Issues](https://github.com/laxitkhanpara/create-liferay-react-cx/issues)
76
+ - [Liferay Docs](https://learn.liferay.com/dxp/latest/en/building-applications/client-extensions.html)
77
+
78
+ ## License
79
+
80
+ MIT © [Laxit Khanpara](https://github.com/laxitkhanpara)
package/bin/index.js CHANGED
@@ -12,7 +12,7 @@ const __dirname = path.dirname(__filename);
12
12
 
13
13
  const commandName = 'create-liferay-react-cx';
14
14
 
15
- const PKG_VERSION = '1.0.2';
15
+ const PKG_VERSION = '1.0.3';
16
16
 
17
17
  // ─── Helpers ────────────────────────────────────────────────────────────────
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-liferay-react-cx",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Zero-config CLI to scaffold Liferay React Client Extensions (custom element) — Vite-powered, shadow DOM isolated, ready to deploy.",
5
5
  "type": "module",
6
6
  "main": "./bin/index.js",