@unifyapps/custom-component-cli 0.0.2 → 0.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.
package/Readme.md ADDED
@@ -0,0 +1,124 @@
1
+ # Add Custom Component
2
+
3
+ Unify lets you extend your app experience with **Custom Components**. This guide walks you through building a Component using the **Custom Component CLI**.
4
+
5
+ ## Step-by-Step: Build Your First Component
6
+
7
+ ### Step 1: Initialize a New Component
8
+
9
+ Start by scaffolding a new Component using the CLI. This creates a ready-to-edit project with a sample React component.
10
+
11
+ ```bash
12
+ pnpx @unifyapps/custom-component-cli init <ComponentName>
13
+ ```
14
+
15
+ This creates a folder `<ComponentName>/` with:
16
+
17
+ * `package.json` – project metadata
18
+ * `manifest.json` – config for Unify
19
+ * `src/index.jsx` – the main React component
20
+ * `src/style.css` – component styles
21
+
22
+ Navigate into the component directory:
23
+
24
+ ```bash
25
+ cd <ComponentName>
26
+ ```
27
+
28
+ **Example manifest format generated after initialization:**
29
+
30
+ ```json
31
+ {
32
+ "name": "SuperButton",
33
+ "type": "SuperButton",
34
+ "entry": "./src/index.jsx",
35
+ "keywords": "SuperButton",
36
+ "style": "./src/style.css",
37
+ "icon": "https://assets.unifyapps.com/user-uploads/theme/unify.svg"
38
+ }
39
+ ```
40
+
41
+ * **keywords** – used for block search in the block picker
42
+ * **icon** – URL of the icon to display in the block picker (optional)
43
+
44
+ You can add icon and modify the keywords before using the manifest in Unify.
45
+
46
+ ### Step 2: Run in Development Mode
47
+
48
+ To preview your Component as you build, run in development mode.
49
+ **Note:** The development server will only be accessible on your local machine.
50
+
51
+ ```bash
52
+ pnpm run dev
53
+ ```
54
+
55
+ Or
56
+
57
+ ```bash
58
+ pnpx @unifyapps/custom-component-cli dev
59
+ ```
60
+
61
+ Once started, the CLI hosts the manifest at a local URL like:
62
+
63
+ ```
64
+ http://localhost:5001/super-button.json
65
+ ```
66
+
67
+ You'll use this in the next step.
68
+
69
+ ### Step 3: Add the Component in Unify
70
+
71
+ To make your component available inside Unify:
72
+
73
+ 1. Go to Custom Components Manager
74
+ 2. Click **Add Component** and fill in:
75
+ * **Component Name** – e.g., SuperButton
76
+ * **Deployment Mode** – Select development mode for testing
77
+ * **Manifest URL** – The local URL from dev mode
78
+
79
+ On Clicking **Add**, Your Component will be added in the Application Builder **block picker**.
80
+
81
+ ### Step 4: Instant Reload
82
+
83
+ While running in `dev` mode, any changes to your React component are instantly reflected. Just refresh the Application Builder to see updates.
84
+
85
+ ### Step 5: Build for Production
86
+
87
+ After finalizing and testing your component, generate a production-ready build to prepare it for deployment:
88
+
89
+ ```bash
90
+ pnpm run build
91
+ ```
92
+
93
+ Or
94
+
95
+ ```bash
96
+ pnpx @unifyapps/custom-component-cli build
97
+ ```
98
+
99
+ This creates a `<ComponentName>.zip` containing:
100
+
101
+ * Compiled assets
102
+ * A production out.json manifest
103
+
104
+ ### Step 6: Adding Component to Production
105
+
106
+ Open the **Component Detail** panel and click the three-dot menu next to the manifest URL.
107
+
108
+ 1. From the dropdown, select **Move to Production** to promote the version.
109
+ 2. Upload the zip file
110
+
111
+ Your Component is now live and ready to use across your Unify interfaces.
112
+
113
+ ### Step 7: Removing a Component
114
+
115
+ To remove a Component:
116
+
117
+ 1. Remove the component from all apps where it is used (make sure it is not referenced or configured anywhere).
118
+ 2. After all usages are removed, go to the Custom Components Manager and delete the component from the list.
119
+
120
+ > note: if you skip step 1 and delete the component from the list, any apps still referencing it may break or show errors.
121
+
122
+ **You're All Set!**
123
+
124
+ With these steps, you can **build, test, and ship** custom Components in Unify with full flexibility. Components empower your team to reuse UI logic and deliver richer, more tailored app experiences.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifyapps/custom-component-cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,10 +13,10 @@
13
13
  "cli.js",
14
14
  "manifestPlugin.js",
15
15
  "entryMountTemplate.js",
16
- "CREATING_CUSTOM_BLOCK.md"
16
+ "Readme.md"
17
17
  ],
18
18
  "lint-staged": {
19
- "*.{md,css,gql,graphql,json}": "biome check --linter-enabled=false --write",
19
+ "*.{css,gql,graphql,json}": "biome check --linter-enabled=false --write",
20
20
  "*.{js,jsx,ts,tsx}": [
21
21
  "oxlint --fix",
22
22
  "biome check --linter-enabled=false --write"
@@ -36,8 +36,5 @@
36
36
  "vite-plugin-dts": "^4.5.4",
37
37
  "vite-tsconfig-paths": "^5.1.4"
38
38
  },
39
- "scripts": {
40
- "dev": "vite",
41
- "build": "vite build"
42
- }
39
+ "scripts": {}
43
40
  }
@@ -0,0 +1,9 @@
1
+ node_modules
2
+ .ua-entry-mount.js
3
+ dist
4
+ {{kebabName}}.zip
5
+ .env
6
+ .env.local
7
+ .env.development.local
8
+ .env.test.local
9
+ .env.production.local
@@ -1,111 +0,0 @@
1
- # Creating a Custom Block with the Block CLI
2
-
3
- This guide explains how to build and register a Custom Block using the block CLI. Blocks can be served locally for development and then exported for use in the Unify application.
4
-
5
- ## 0. Initialize a new Block
6
-
7
- To scaffold a new block with a simple React component, package.json, and a manifest.json, run:
8
-
9
- ```bash
10
- pnpx @unifyapps/block-cli init <BlockName>
11
- ```
12
-
13
- This creates a new `<BlockName>/` folder containing:
14
- - `package.json`
15
- - `manifest.json`
16
- - `src/index.jsx`
17
- - `src/style.css`
18
-
19
- ```bash
20
- cd <BlockName>
21
- ```
22
-
23
- ## 1. Set up your workspace
24
-
25
- Navigate to the directory containing the React component you want to expose as a Block. The CLI commands should be executed from this path so that relative imports resolve correctly.
26
-
27
- ```bash
28
- cd path/to/project
29
- ```
30
-
31
- ## 2. Start the Block in development mode
32
-
33
- With a `manifest.json` in your project folder, you can simply run:
34
-
35
- ```bash
36
- pnpx @unifyapps/block-cli dev
37
- ```
38
-
39
- You can still override using CLI arguments:
40
-
41
- ```bash
42
- pnpx @unifyapps/block-cli dev <BlockName> <component-path>
43
- ```
44
-
45
- Example (using manifest):
46
-
47
- ```bash
48
- pnpx @unifyapps/block-cli dev
49
- ```
50
-
51
- The CLI serves the block manifest at `http://localhost:5001/super-button.json`. Note this URL for the next step.
52
-
53
- ## 3. Register the Block in the Unify app
54
-
55
- 1. Visit `qa.unifyapps.com/p/0/object/custom_blocks/records`.
56
- 2. Click **Add Record** and fill out the form:
57
- - **BlockName** – the name used in the CLI, e.g. `SuperButton`.
58
- - **Manifest URL** – the local URL from the previous step.
59
- 3. Save the record.
60
-
61
- Once saved, the Block appears in the Application Builder under the **components** section. You can now test it in your interfaces.
62
-
63
- ## 4. Iterate on the Block
64
-
65
- While running in `dev` mode, any changes to the component are reflected automatically. Refresh the Application Builder to load the latest version.
66
-
67
- ## 5. Build the Block for production
68
-
69
- After testing, build a production bundle. From your project folder with a `manifest.json`, run:
70
-
71
- ```bash
72
- pnpx @unifyapps/block-cli build
73
- ```
74
-
75
- Or override using CLI arguments:
76
-
77
- ```bash
78
- pnpx @unifyapps/block-cli build <BlockName> <component-path>
79
- ```
80
-
81
- Example (using manifest):
82
-
83
- ```bash
84
- pnpx @unifyapps/block-cli build
85
- ```
86
-
87
- The CLI outputs a `dist` directory containing the compiled block files, an `out.json` manifest, and a `<BlockName>.zip` archive of the `dist/` folder.
88
-
89
- ## 6. Upload the build output
90
-
91
- 1. Upload the contents of the `dist` directory to the Unify app.
92
- 2. Update the record created earlier with the new **Manifest URL** pointing to your uploaded `out.json`.
93
-
94
- ## 7. Removing a Block
95
-
96
- To remove a Block from the system, delete its record from the custom blocks page in the Unify app.
97
-
98
- ## 8. Additional CLI examples
99
-
100
- While the CLI will eventually be published, you can run it directly from this repository:
101
-
102
- ```bash
103
- pnpx /path/to/www/packages/block-cli dev
104
- pnpx /path/to/www/packages/block-cli build
105
- ```
106
-
107
- Replace `/path/to/www` with the absolute path on your machine.
108
-
109
- ---
110
-
111
- With these steps you can develop, test, and deploy custom Blocks to extend the Unify platform.