create-ec-app 1.4.0 → 1.5.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/README.md CHANGED
@@ -54,24 +54,61 @@ bash update-templates.sh
54
54
 
55
55
  The script updates `package.patch.json` files, template `package.json` files, installs dependencies to refresh lockfiles, then removes template `node_modules` directories.
56
56
 
57
- ## Generate A PCF Control
57
+ ## Generate a PCF Control
58
58
 
59
- After creating a webresource app, build it first so `dist/main.css` exists:
59
+ If you want to host the React webresource inside a PCF control instead of loading the HTML webresource directly in an iframe, use `create-ec-app` itself to generate the wrapper for an existing webresource project.
60
+
61
+ Basic flow:
62
+
63
+ 1. Build the webresource:
60
64
 
61
65
  ```bash
62
- cd my-app
63
66
  npm run build
64
67
  ```
65
68
 
66
- Then run the published CLI and install the generated PCF project's dependencies:
69
+ 2. Run the generator and point `--pcf-dir` at the generated PCF project directory:
67
70
 
68
71
  ```bash
69
72
  npx create-ec-app@latest --pcf-dir ./pcf/{{ControlName}} namespace {{EC}} --constructor {{ControlName}} --display-name "Control Name"
73
+ ```
74
+
75
+ 3. Install dependencies inside that generated PCF directory:
76
+
77
+ ```bash
70
78
  cd ./pcf/{{ControlName}}
71
79
  npm install
72
80
  ```
73
81
 
74
- This creates a PCF wrapper under the webresource project, reuses the app's built CSS, and keeps the generated app wrapped in `EcAppShell` so scoped styles and app-local portals continue to work inside the PCF host.
82
+ This writes a standalone PCF project to the `--pcf-dir` folder. The generated control:
83
+
84
+ - imports `src/App.tsx` directly instead of wrapping built HTML in an iframe
85
+ - reuses the built stylesheet from `dist/main.css`
86
+ - creates `src/runtime/types.ts` only if that file does not already exist
87
+ - provides a runtime object with record context and `context.webAPI` access inside the generated PCF shell, following the `PcfBase` pattern
88
+ - mounts your React app directly into the PCF container
89
+
90
+ Typical conversion flow from inside a generated webresource project:
91
+
92
+ ```bash
93
+ npm install
94
+ npm run build
95
+ npx create-ec-app@latest --pcf-dir ./pcf/FusionNotebookHost namespace EC --constructor FusionNotebookHost --display-name "Fusion Notebook Host"
96
+ cd pcf/FusionNotebookHost
97
+ npm install
98
+ npm run build
99
+ ```
100
+
101
+ What gets generated:
102
+
103
+ - a minimal PCF wrapper project under `pcf/<ConstructorName>`
104
+ - a checked-in PCF shell stamped out from `create-ec-app/templates/pcf/base`
105
+ - direct imports back to your webresource source and built CSS
106
+
107
+ What does not happen:
108
+
109
+ - your existing webresource project is not converted in place
110
+ - your React source is not moved into the PCF project
111
+ - the generated PCF project does not automatically get added to a Dataverse solution
75
112
 
76
113
  ## Verification
77
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ec-app",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Unified CLI tool to create different types of EC applications: Webresource, Portal, Power Pages",
5
5
  "bin": {
6
6
  "create-ec-app": "./dist/index.js"
@@ -3,6 +3,8 @@
3
3
  This is a Dynamics 365 / Dataverse web resource template using React + TypeScript + Vite.
4
4
  Treat it as a **Dynamics-hosted frontend** — not a generic SPA. Do not modernise it into something else unless explicitly asked.
5
5
 
6
+ The default philosophy is: keep the app small, readable, and easy to ship into Dynamics. Prefer obvious code, existing components, and the template's established runtime patterns over broad abstractions or clever defensive layers.
7
+
6
8
  ---
7
9
 
8
10
  ## Hard Constraints
@@ -43,10 +45,13 @@ Never mix the two modes or duplicate their logic — reuse `authService.ts`.
43
45
  - Always reuse `getApiUrl()` and `getAuthHeaders()` — never duplicate them
44
46
  - Use narrow `$select` queries; throw on non-OK responses
45
47
  - No raw fetch calls scattered across UI components
48
+ - Use Zod for validation where data crosses a boundary: form inputs, URL/search params, config, and Dataverse/API responses that the UI depends on
49
+ - Keep service functions boring and explicit: one fetch function, one hook, one mutation where needed
50
+ - Do not add repository/client layers unless the app has enough repeated API logic to justify them
46
51
 
47
52
  **Preferred pattern:**
48
53
  ```ts
49
- // service.ts — fetch function + TanStack Query hook
54
+ // {entity}Service.ts — fetch function + TanStack Query hook
50
55
  // invalidate relevant queryKey on mutation success
51
56
  ```
52
57
 
@@ -65,21 +70,24 @@ See the example at the bottom of this file.
65
70
 
66
71
  ## UI & Styling
67
72
 
68
- - Kendo UI or Shadcn/ui — stay consistent with whichever the project uses; don't mix
69
- - Tailwind is the default styling approach; preserve `main.css` output
70
- - Reuse existing components and utilities before building new ones
73
+ - Kendo UI or Shadcn/ui — stay consistent with whichever the project uses; don't mix UI systems unless explicitly asked.
74
+ - If the project uses Shadcn/ui, use Shadcn components from `@/components/ui` and style them with Tailwind utility classes.
75
+ - If the project uses Kendo UI, use Kendo React components for controls, grids, menus, dialogs, inputs, and other rich UI. Use Tailwind for layout, spacing, and local composition around those components.
76
+ - Tailwind is the default styling approach for both Shadcn/ui and Kendo projects; preserve `main.css` output.
77
+ - Do not hand-roll component styling or custom CSS unless Tailwind/component props cannot reasonably express the requirement.
78
+ - Prefer existing component APIs, theme tokens, variants, and utility helpers before creating new wrappers.
79
+ - Keep screen layouts practical for embedded Dynamics use: compact, scannable, responsive, and not marketing-page styled.
71
80
 
72
81
  ---
73
82
 
74
- ## Planning Rule
75
-
76
- For changes touching multiple files, auth, build config, or new service patterns — write a short plan first:
77
- - current state
78
- - intended change
79
- - files to touch
80
- - risks / compatibility concerns
83
+ ## Code Shape
81
84
 
82
- For large or risky changes, write an `ExecPlan` in `PLANS.md` before implementing.
85
+ - Keep code simple and readable. A future maintainer should understand the main path quickly.
86
+ - Avoid over-engineering: no generic frameworks, broad factories, speculative abstractions, or excessive configuration for small features.
87
+ - Avoid being overly defensive. Validate real external inputs and API responses where useful, but don't wrap every local value in ceremony.
88
+ - Prefer direct, typed functions over classes unless the existing code already uses classes for that concern.
89
+ - Keep React components focused: UI in components, reusable data access in services, shared client state in Zustand only when local state is no longer enough.
90
+ - Make the smallest change that solves the request cleanly.
83
91
 
84
92
  ---
85
93
 
@@ -120,4 +128,4 @@ export const useUpdateAccount = () => {
120
128
  onSuccess: () => queryClient.invalidateQueries({ queryKey: ["accounts"] }),
121
129
  });
122
130
  };
123
- ```
131
+ ```
@@ -302,33 +302,12 @@ npm install
302
302
  npm run build
303
303
  ```
304
304
 
305
- Useful options:
306
-
307
- - `--dist dist` to point at a different build folder
308
- - `--output pcf/MyControl` to choose the target folder
309
- - `--template /path/to/create-ec-app/templates/pcf/base` to swap the base shell
310
- - `--layer path/to/layer` to apply one or more patch layers after the base copy
311
-
312
- Build the generated PCF project from inside the generated folder:
313
-
314
- ```bash
315
- cd pcf/FusionNotebookHost
316
- npm install
317
- npm run build
318
- ```
319
-
320
305
  What gets generated:
321
306
 
322
307
  - a minimal PCF wrapper project under `pcf/<ConstructorName>`
323
308
  - a checked-in PCF shell stamped out from `create-ec-app/templates/pcf/base`
324
309
  - direct imports back to your webresource source and built CSS
325
310
 
326
- What does not happen:
327
-
328
- - your existing webresource project is not converted in place
329
- - your React source is not moved into the PCF project
330
- - the generated PCF project does not automatically get added to a Dataverse solution
331
-
332
311
  ## Notes
333
312
 
334
313
  - If you change the build, ensure code splitting stays disabled and asset names remain predictable to simplify web resource updates.
@@ -1 +0,0 @@
1
- [AGENTS.md](AGENTS.md)