@salesforce/webapp-template-app-react-sample-b2e-experimental 1.84.0 → 1.85.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.
Files changed (21) hide show
  1. package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/SKILL.md +5 -3
  2. package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/implementation/header-footer.md +8 -0
  3. package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/implementation/page.md +8 -7
  4. package/dist/.a4drules/skills/webapp-ui-ux/SKILL.md +11 -8
  5. package/dist/.a4drules/webapp-react.md +54 -0
  6. package/dist/CHANGELOG.md +16 -0
  7. package/dist/README.md +24 -0
  8. package/dist/force-app/main/default/data/Property_Image__c.json +1 -1
  9. package/dist/force-app/main/default/data/Property_Listing__c.json +1 -1
  10. package/dist/force-app/main/default/data/prepare-import-unique-fields.js +85 -0
  11. package/dist/force-app/main/default/permissionsets/Property_Management_Access.permissionset-meta.xml +0 -7
  12. package/dist/force-app/main/default/webapplications/appreactsampleb2e/package.json +4 -4
  13. package/dist/force-app/main/default/webapplications/appreactsampleb2e/src/api/applications.ts +8 -21
  14. package/dist/force-app/main/default/webapplications/appreactsampleb2e/src/api/dashboard.ts +12 -34
  15. package/dist/force-app/main/default/webapplications/appreactsampleb2e/src/api/graphqlClient.ts +22 -0
  16. package/dist/force-app/main/default/webapplications/appreactsampleb2e/src/api/maintenance.ts +10 -30
  17. package/dist/force-app/main/default/webapplications/appreactsampleb2e/src/api/properties.ts +8 -13
  18. package/dist/package.json +1 -1
  19. package/dist/setup-cli.mjs +271 -0
  20. package/package.json +3 -3
  21. /package/dist/.a4drules/skills/{webapp-react-add-component → webapp-react}/implementation/component.md +0 -0
@@ -1,9 +1,11 @@
1
1
  ---
2
- name: webapp-react-add-component
3
- description: Creates React components, pages, headers, and footers using shadcn UI and Tailwind CSS. Use when the user asks to create a component, add a widget, build a UI element, add a page, create a new page, add a section (e.g. "add a contacts page"), add a header, add a footer, add a navigation bar, or add anything to the web application.
2
+ name: webapp-react
3
+ description: Use when editing any React code in the web application creating or modifying components, pages, layout, headers, footers, or any TSX/JSX files. Follow this skill for add component, add page, header/footer, and general React UI implementation patterns (shadcn UI and Tailwind CSS).
4
4
  ---
5
5
 
6
- # Add React Component
6
+ # React Web App (Components, Pages, Layout)
7
+
8
+ Use this skill whenever you are editing React/TSX code in the web app (creating or modifying components, pages, header/footer, or layout).
7
9
 
8
10
  ## Step 1 — Identify the type of component
9
11
 
@@ -116,6 +116,14 @@ AppLayout (appLayout.tsx)
116
116
  - **Icons:** `lucide-react`; add `aria-hidden="true"` on decorative icons
117
117
  - **Design tokens:** `bg-background`, `text-foreground`, `text-muted-foreground`, `border`, `bg-primary`
118
118
 
119
+ ### Mobile hamburger / Menu icon — Must be functional
120
+
121
+ If the header includes a hamburger or `Menu` icon for mobile:
122
+
123
+ - **Do not** add a Menu/hamburger icon that does nothing. It must toggle a visible mobile menu.
124
+ - **Required:** (1) State: `const [isOpen, setIsOpen] = useState(false)`. (2) Button: `onClick={() => setIsOpen(!isOpen)}`, `aria-label="Toggle menu"`. (3) Conditional panel: `{isOpen && ( <div>...nav links...</div> )}` with responsive visibility (e.g. `md:hidden`). (4) Close on navigate: each link in the panel should `onClick={() => setIsOpen(false)}`.
125
+ - Implement in `appLayout.tsx` (or the component that owns the header). Use the `Menu` icon from `lucide-react`.
126
+
119
127
  ### Confirm — Header / Footer
120
128
 
121
129
  - Header and footer appear on every page (navigate to at least two routes)
@@ -2,13 +2,14 @@
2
2
 
3
3
  ### Rules
4
4
 
5
- 1. **`routes.tsx` is the only route registry** — never add routes in `app.tsx` or inside page files.
6
- 2. **All pages are children of the AppLayout route** — do not create top-level routes that bypass the layout shell.
7
- 3. **Default export per page** — each page file has exactly one default-export component.
8
- 4. **Path aliases in all imports** — use `@/pages/...`, `@/components/...`; no deep relative paths.
9
- 5. **No inline styles** — Tailwind utility classes and design tokens only.
10
- 6. **Catch-all last** — `path: '*'` (NotFound) must always remain the last child in the layout route.
11
- 7. **Never modify `appLayout.tsx`** when adding a page layout changes are a separate concern.
5
+ 1. **Edit the component that owns the UI, never output raw HTML** — When editing the home page or any page content, modify the actual `.tsx` file that renders the target. If the target is inside a child component (e.g. `<GlobalSearchInput />` in `Home.tsx`), edit the child's file (e.g. `GlobalSearchInput.tsx`), not the parent. Do not wrap the component with extra elements in the parent; go into the component and change its JSX. Do not paste or generate raw HTML.
6
+ 2. **`routes.tsx` is the only route registry** — never add routes in `app.tsx` or inside page files.
7
+ 3. **All pages are children of the AppLayout route** — do not create top-level routes that bypass the layout shell.
8
+ 4. **Default export per page** — each page file has exactly one default-export component.
9
+ 5. **Path aliases in all imports** — use `@/pages/...`, `@/components/...`; no deep relative paths.
10
+ 6. **No inline styles** — Tailwind utility classes and design tokens only.
11
+ 7. **Catch-all last** `path: '*'` (NotFound) must always remain the last child in the layout route.
12
+ 8. **Never modify `appLayout.tsx`** when adding a page — layout changes are a separate concern.
12
13
 
13
14
  ### Step 1 — Create the page file
14
15
 
@@ -1,11 +1,13 @@
1
1
  ---
2
- name: ui-ux
3
- description: Comprehensive design guide for React + Tailwind + shadcn/ui applications. Searchable database with priority-based recommendations for styles, color palettes, font pairings, UX guidelines, and chart types.
2
+ name: webapp-ui-ux
3
+ description: Use when editing any UI code in the web application — styling, layout, design, appearance, Tailwind, shadcn, colors, typography, icons, or visual/UX changes. Comprehensive design guide and searchable database for React + Tailwind + shadcn/ui (styles, color palettes, font pairings, UX guidelines, chart types).
4
4
  ---
5
5
 
6
- # ui-ux
6
+ # Web App UI/UX
7
7
 
8
- Comprehensive design guide for React + Tailwind + shadcn/ui applications. Contains 67 styles, 96 color palettes, 57 font pairings, 99 UX guidelines, and 25 chart types. Searchable database with priority-based recommendations.
8
+ Use this skill whenever you are editing UI code in the web application styling, layout, design, appearance, Tailwind, shadcn, colors, typography, icons, or any visual/UX change.
9
+
10
+ Comprehensive design guide for React + Tailwind + shadcn/ui. Contains 67 styles, 96 color palettes, 57 font pairings, 99 UX guidelines, and 25 chart types. Searchable database with priority-based recommendations.
9
11
 
10
12
  ## Prerequisites
11
13
 
@@ -200,9 +202,10 @@ These are frequently overlooked issues that make UI look unprofessional:
200
202
 
201
203
  | Rule | Do | Don't |
202
204
  |------|----|----- |
203
- | **No emoji icons** | Use SVG icons (Heroicons, Lucide, Simple Icons) | Use emojis like 🎨 🚀 ⚙️ as UI icons |
205
+ | **Icons: Lucide only** | Use **lucide-react** for all UI icons: `import { IconName } from 'lucide-react'` | Use Heroicons, react-icons, or other icon libraries; use emojis as icons |
206
+ | **No emojis ever** | Use words + Lucide icons for labels, empty states, tooltips, headings | Use emojis anywhere in UI or user-facing text (e.g. 🎨 🚀 ⚙️) |
204
207
  | **Stable hover states** | Use color/opacity transitions on hover | Use scale transforms that shift layout |
205
- | **Correct brand logos** | Research official SVG from Simple Icons | Guess or use incorrect logo paths |
208
+ | **Correct brand logos** | Research official SVG from Simple Icons (when needed outside Lucide) | Guess or use incorrect logo paths |
206
209
  | **Consistent icon sizing** | Use fixed viewBox (24x24) with w-6 h-6 | Mix different icon sizes randomly |
207
210
 
208
211
  ### Interaction & Cursor
@@ -237,8 +240,8 @@ These are frequently overlooked issues that make UI look unprofessional:
237
240
  Before delivering UI code, verify these items:
238
241
 
239
242
  ### Visual Quality
240
- - [ ] No emojis used as icons (use SVG instead)
241
- - [ ] All icons from consistent icon set (Heroicons/Lucide)
243
+ - [ ] No emojis anywhere (UI, labels, empty states, tooltips—use words + Lucide icons only)
244
+ - [ ] All icons from **lucide-react** only (no Heroicons, react-icons, or emojis)
242
245
  - [ ] Brand logos are correct (verified from Simple Icons)
243
246
  - [ ] Hover states don't cause layout shift
244
247
  - [ ] Use theme colors directly (bg-primary) not var() wrapper
@@ -18,6 +18,15 @@ For layout, navigation, and generation rules, see **webapp.md**.
18
18
  - Dev server: `npm run dev`
19
19
  - Build: `npm run build`
20
20
 
21
+ ## Routing (React Router)
22
+
23
+ Use a **single** router package for the app. When using `createBrowserRouter` and `RouterProvider` from `react-router`, all routing imports must come from **`react-router`** — not from `react-router-dom`.
24
+
25
+ - ✅ `import { createBrowserRouter, RouterProvider, Link, useNavigate, useLocation, Outlet } from 'react-router';`
26
+ - ❌ `import { Link } from 'react-router-dom';` when the app uses `RouterProvider` from `react-router`
27
+
28
+ Mixing packages causes "Cannot destructure property 'basename' of ... as it is null" because `Link`/hooks from `react-router-dom` read a different context than the one provided by `RouterProvider` from `react-router`.
29
+
21
30
  ## Component Library (MANDATORY)
22
31
 
23
32
  Use **shadcn/ui** for UI components:
@@ -28,6 +37,42 @@ import { Card, CardHeader, CardContent } from '@/components/ui/card';
28
37
  import { Input } from '@/components/ui/input';
29
38
  ```
30
39
 
40
+ ## Icons & No Emojis (MANDATORY)
41
+
42
+ - **Icons:** Use **lucide-react** only. Do not use Heroicons, Simple Icons, or other icon libraries in the web app.
43
+ - ✅ `import { Menu, Settings, Bell } from 'lucide-react';` then `<Menu className="w-5 h-5" />`
44
+ - ❌ Any emoji character as an icon or visual element (e.g. 🎨 🚀 ⚙️ 🔔)
45
+ - ❌ Other icon libraries (e.g. `@heroicons/react`, `react-icons`, custom SVG icon sets)
46
+ - **No emojis ever:** Do not use emojis anywhere in the app: no emojis in UI labels, buttons, headings, empty states, tooltips, or any user-facing text. Use words and lucide-react icons instead.
47
+ - ✅ "Settings" with `<Settings />` icon
48
+ - ❌ "⚙️ Settings" or "Settings 🔧"
49
+ - For icon usage patterns and naming, see the **webapp-ui-ux** skill (`.a4drules/skills/webapp-ui-ux/`, especially `data/icons.csv`).
50
+
51
+ ## Editing UI — Source Files Only (CRITICAL)
52
+
53
+ When asked to edit the home page, a section, or any on-screen UI:
54
+
55
+ - **Always edit the actual React/TSX source files.** Never output, paste, or generate raw HTML. The UI is built from components; the agent must locate the component file(s) that render the target area and change **JSX in those files**.
56
+ - **Do not** replace JSX with HTML strings, and do not copy browser-rendered DOM (e.g. expanded `<div>`, `data-slot`, long class strings) into the codebase. That is the output of React + shadcn; the source is `.tsx` with `<Card>`, `<Input>`, etc.
57
+ - **Edit inside the component that owns the UI.** If the element to change is rendered by a **child component** (e.g. `<GlobalSearchInput />` in `Home.tsx`), make the edit **inside that component's file** (e.g. `GlobalSearchInput.tsx`). Do **not** only wrap the component with extra elements in the parent (e.g. adding a `<section>` or `<div>` around `<GlobalSearchInput />`). The parent composes components; the visual/content change belongs in the component that actually renders that part of the UI.
58
+ - **Where to edit:**
59
+ - **Home page content:** `src/pages/Home.tsx` — but if the target is inside a child (e.g. `<GlobalSearchInput />`), edit the child's file, not the parent.
60
+ - **Layout, header, nav:** `src/appLayout.tsx`.
61
+ - **Feature-specific UI (e.g. search, list):** open the **specific component file** that renders the target (e.g. `GlobalSearchInput.tsx` for the search input UI).
62
+ - **Steps:** (1) Identify which **component** owns the section (follow the import: e.g. `GlobalSearchInput` → its file). (2) Open that component's file and modify the JSX there. (3) Only change the parent (e.g. `Home.tsx`) if the change is layout/ordering of components, not the internals of a child. Do not emit a standalone HTML snippet as the “edit.”
63
+
64
+ ## Mobile Nav / Hamburger — Must Be Functional
65
+
66
+ When adding a navigation menu that includes a hamburger (or Menu icon) for mobile:
67
+
68
+ - **Do not** add a hamburger/Menu icon that does nothing. The icon must **toggle a visible mobile menu**.
69
+ - **Required implementation:**
70
+ 1. **State:** e.g. `const [isOpen, setIsOpen] = useState(false);`
71
+ 2. **Toggle button:** The hamburger/Menu button must have `onClick={() => setIsOpen(!isOpen)}` and `aria-label="Toggle menu"` (or equivalent).
72
+ 3. **Conditional panel:** A mobile-only menu panel that renders when `isOpen` is true, e.g. `{isOpen && ( <div className="..."> ... nav links ... </div> )}`. Use responsive classes (e.g. `md:hidden`) so the panel is shown only on small screens if the desktop nav is separate.
73
+ 4. **Close on navigation:** Each nav link in the mobile panel should call `onClick={() => setIsOpen(false)}` (or similar) so the menu closes when the user navigates.
74
+ - Implement this in `appLayout.tsx` (or the component that owns the header/nav). See existing apps for the full pattern (state + button + conditional panel + link onClick).
75
+
31
76
  ## Styling
32
77
 
33
78
  - Use **Tailwind CSS** utility classes
@@ -137,11 +182,20 @@ window.location.reload();
137
182
  - ❌ Using LWC patterns (`@wire`, LDS) in React
138
183
  - ❌ Hardcoded Salesforce IDs or URLs
139
184
  - ❌ Missing error handling for async operations
185
+ - ❌ Mixing `react-router` and `react-router-dom` (e.g. `RouterProvider` from `react-router` but `Link` from `react-router-dom`) — use one package for all routing imports
186
+ - ❌ Using emojis anywhere in the app (labels, icons, empty states, headings, tooltips)
187
+ - ❌ Using any icon library other than **lucide-react** (no Heroicons, react-icons, or emoji-as-icon)
188
+ - ❌ Outputting or pasting raw HTML when editing UI — always edit the React/TSX source files (e.g. `Home.tsx`, `appLayout.tsx`, feature components)
189
+ - ❌ Adding a hamburger or Menu icon for mobile nav without implementing toggle state, conditional menu panel, and close-on-navigate
140
190
 
141
191
  ## Quality Checklist
142
192
 
143
193
  - [ ] Entry point maintained (`app.tsx`)
144
194
  - [ ] Uses shadcn/ui and Tailwind
195
+ - [ ] Icons from **lucide-react** only; no emojis anywhere in UI or user-facing text
196
+ - [ ] UI changes made by editing .tsx source files (never by pasting raw HTML)
197
+ - [ ] If mobile hamburger exists: it has toggle state, conditional menu panel, and close on link click
198
+ - [ ] All routing imports from same package as router (e.g. `react-router` only)
145
199
  - [ ] DataSDK used for all Salesforce API calls
146
200
  - [ ] Proper error handling with try/catch
147
201
  - [ ] Loading and error states implemented
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
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.85.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.84.1...v1.85.0) (2026-03-10)
7
+
8
+ **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.84.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.84.0...v1.84.1) (2026-03-10)
15
+
16
+ **Note:** Version bump only for package @salesforce/webapp-template-base-sfdx-project-experimental
17
+
18
+
19
+
20
+
21
+
6
22
  # [1.84.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.83.0...v1.84.0) (2026-03-09)
7
23
 
8
24
 
package/dist/README.md CHANGED
@@ -58,6 +58,30 @@ Replace `<alias>` with your target org alias.
58
58
  sf data import tree --plan force-app/main/default/data/data-plan.json --target-org <alias>
59
59
  ```
60
60
 
61
+ ## Using setup-cli.mjs
62
+
63
+ When this app is built (e.g. from the monorepo or from a published package), a `setup-cli.mjs` script is included at the project root. It runs the full setup in one go: login (if needed), deploy metadata, assign the `Property_Management_Access` permission set, prepare and import sample data, fetch GraphQL schema and run codegen, build the web app, and optionally start the dev server.
64
+
65
+ Run from the **project root** (the directory that contains `force-app/`, `sfdx-project.json`, and `setup-cli.mjs`):
66
+
67
+ ```bash
68
+ node setup-cli.mjs --target-org <alias>
69
+ ```
70
+
71
+ Common options:
72
+
73
+ | Option | Description |
74
+ | --------------------- | ---------------------------------------------------------------- |
75
+ | `--skip-login` | Skip browser login (org already authenticated) |
76
+ | `--skip-data` | Skip data preparation and import |
77
+ | `--skip-graphql` | Skip GraphQL schema fetch and codegen |
78
+ | `--skip-webapp-build` | Skip `npm install` and web app build |
79
+ | `--skip-dev` | Do not start the dev server at the end |
80
+ | `--permset <name>` | Permission set to assign (default: `Property_Management_Access`) |
81
+ | `--app <name>` | Web app folder name when multiple exist |
82
+
83
+ For all options: `node setup-cli.mjs --help`.
84
+
61
85
  ## Configure Your Salesforce DX Project
62
86
 
63
87
  The `sfdx-project.json` file contains useful configuration information for your project. See [Salesforce DX Project Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) in the _Salesforce DX Developer Guide_ for details about this file.
@@ -138,7 +138,7 @@
138
138
  "referenceId": "ImageRef12"
139
139
  },
140
140
  "Name": "Beverly Hills Estate Primary",
141
- "Property__c": "@PropertyRef11",
141
+ "Property__c": "@PropertyRef10",
142
142
  "Image_URL__c": "https://images.unsplash.com/photo-1613490493576-7fde63acd811?w=800&h=600&fit=crop",
143
143
  "Image_Type__c": "Primary",
144
144
  "Display_Order__c": 1,
@@ -90,7 +90,7 @@
90
90
  "referenceId": "ListingRef7"
91
91
  },
92
92
  "Name": "Beverly Hills Estate",
93
- "Property__c": "@PropertyRef11",
93
+ "Property__c": "@PropertyRef10",
94
94
  "Listing_Price__c": 9200000.0,
95
95
  "Listing_Status__c": "Active",
96
96
  "Featured__c": true,
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Updates unique fields in data JSON files so "sf data import tree" can be run
4
+ * repeatedly (e.g. after org already has data). Run before: node prepare-import-unique-fields.js
5
+ */
6
+ const fs = require("fs");
7
+ const path = require("path");
8
+ const dataDir = __dirname;
9
+ const runId = Date.now();
10
+ const runSuffix2 = String(runId % 100).padStart(2, "0"); // 00-99 for Company_Code__c (10-char limit)
11
+
12
+ // Contact: Email + LastName — unique so re-runs don't hit DUPLICATES_DETECTED (matching may use name)
13
+ const contactPath = path.join(dataDir, "Contact.json");
14
+ let contact = JSON.parse(fs.readFileSync(contactPath, "utf8"));
15
+ contact.records.forEach((r, i) => {
16
+ if (r.Email && r.Email.includes("@"))
17
+ r.Email = r.Email.replace(/\+[0-9]+@/, "@").replace("@", "+" + runId + "@");
18
+ if (r.LastName)
19
+ r.LastName = r.LastName.replace(/\s*\[[0-9-]+\]$/, "") + " [" + runId + "-" + i + "]";
20
+ });
21
+ fs.writeFileSync(contactPath, JSON.stringify(contact, null, 2));
22
+
23
+ // Agent__c: License_Number__c — strip any existing suffix and add run id + index (each record must be unique)
24
+ const agentPath = path.join(dataDir, "Agent__c.json");
25
+ let agent = JSON.parse(fs.readFileSync(agentPath, "utf8"));
26
+ agent.records.forEach((r, i) => {
27
+ if (r.License_Number__c)
28
+ r.License_Number__c =
29
+ r.License_Number__c.replace(/-[0-9]+(-[0-9]+)?$/, "") + "-" + runId + "-" + i;
30
+ });
31
+ fs.writeFileSync(agentPath, JSON.stringify(agent, null, 2));
32
+
33
+ // Property_Management_Company__c: Company_Code__c — max 10 chars, use 8-char base + 2-digit suffix
34
+ const companyPath = path.join(dataDir, "Property_Management_Company__c.json");
35
+ let company = JSON.parse(fs.readFileSync(companyPath, "utf8"));
36
+ company.records.forEach((r) => {
37
+ if (r.Company_Code__c) r.Company_Code__c = r.Company_Code__c.slice(0, 8) + runSuffix2; // 8-char base + 2-digit = 10 chars max
38
+ });
39
+ fs.writeFileSync(companyPath, JSON.stringify(company, null, 2));
40
+
41
+ // Property_Owner__c: Email__c — add +runId before @
42
+ const ownerPath = path.join(dataDir, "Property_Owner__c.json");
43
+ let owner = JSON.parse(fs.readFileSync(ownerPath, "utf8"));
44
+ owner.records.forEach((r) => {
45
+ if (r.Email__c && r.Email__c.includes("@"))
46
+ r.Email__c = r.Email__c.replace(/\+[0-9]+@/, "@").replace("@", "+" + runId + "@");
47
+ });
48
+ fs.writeFileSync(ownerPath, JSON.stringify(owner, null, 2));
49
+
50
+ // Remap @TenantRefN in dependent files to only use refs that exist in Tenant__c.json (fix UnresolvableRefsError)
51
+ const tenantPath = path.join(dataDir, "Tenant__c.json");
52
+ const tenantData = JSON.parse(fs.readFileSync(tenantPath, "utf8"));
53
+ const validTenantRefs = tenantData.records.map((r) => r.attributes?.referenceId).filter(Boolean);
54
+ if (validTenantRefs.length === 0) throw new Error("Tenant__c.json has no referenceIds");
55
+
56
+ function remapTenantRef(refValue) {
57
+ if (typeof refValue !== "string" || !refValue.startsWith("@TenantRef")) return refValue;
58
+ const match = refValue.match(/^@(TenantRef)(\d+)$/);
59
+ if (!match) return refValue;
60
+ const n = parseInt(match[2], 10);
61
+ const idx = (n - 1) % validTenantRefs.length;
62
+ return "@" + validTenantRefs[idx];
63
+ }
64
+
65
+ const leasePath = path.join(dataDir, "Lease__c.json");
66
+ let lease = JSON.parse(fs.readFileSync(leasePath, "utf8"));
67
+ lease.records.forEach((r) => {
68
+ if (r.Tenant__c) r.Tenant__c = remapTenantRef(r.Tenant__c);
69
+ });
70
+ fs.writeFileSync(leasePath, JSON.stringify(lease, null, 2));
71
+
72
+ const maintPath = path.join(dataDir, "Maintenance_Request__c.json");
73
+ let maint = JSON.parse(fs.readFileSync(maintPath, "utf8"));
74
+ maint.records.forEach((r) => {
75
+ if (r.User__c && String(r.User__c).startsWith("@TenantRef"))
76
+ r.User__c = remapTenantRef(r.User__c);
77
+ });
78
+ fs.writeFileSync(maintPath, JSON.stringify(maint, null, 2));
79
+
80
+ console.log(
81
+ "Unique fields updated: runId=%s companySuffix=%s validTenants=%s",
82
+ runId,
83
+ runSuffix2,
84
+ validTenantRefs.length,
85
+ );
@@ -367,43 +367,36 @@
367
367
  <field>Agent__c.License_Number__c</field>
368
368
  <readable>true</readable>
369
369
  </fieldPermissions>
370
-
371
370
  <fieldPermissions>
372
371
  <editable>true</editable>
373
372
  <field>Agent__c.License_Expiry__c</field>
374
373
  <readable>true</readable>
375
374
  </fieldPermissions>
376
-
377
375
  <fieldPermissions>
378
376
  <editable>true</editable>
379
377
  <field>Agent__c.Agent_Type__c</field>
380
378
  <readable>true</readable>
381
379
  </fieldPermissions>
382
-
383
380
  <fieldPermissions>
384
381
  <editable>true</editable>
385
382
  <field>Agent__c.Territory__c</field>
386
383
  <readable>true</readable>
387
384
  </fieldPermissions>
388
-
389
385
  <fieldPermissions>
390
386
  <editable>true</editable>
391
387
  <field>Agent__c.Emergency_Alt__c</field>
392
388
  <readable>true</readable>
393
389
  </fieldPermissions>
394
-
395
390
  <fieldPermissions>
396
391
  <editable>true</editable>
397
392
  <field>Agent__c.Language__c</field>
398
393
  <readable>true</readable>
399
394
  </fieldPermissions>
400
-
401
395
  <fieldPermissions>
402
396
  <editable>true</editable>
403
397
  <field>Agent__c.Availability__c</field>
404
398
  <readable>true</readable>
405
399
  </fieldPermissions>
406
-
407
400
  <fieldPermissions>
408
401
  <editable>true</editable>
409
402
  <field>Agent__c.Office_Location__c</field>
@@ -15,9 +15,9 @@
15
15
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
16
16
  },
17
17
  "dependencies": {
18
- "@salesforce/agentforce-conversation-client": "^1.84.0",
19
- "@salesforce/sdk-data": "^1.84.0",
20
- "@salesforce/webapp-experimental": "^1.84.0",
18
+ "@salesforce/agentforce-conversation-client": "^1.85.0",
19
+ "@salesforce/sdk-data": "^1.85.0",
20
+ "@salesforce/webapp-experimental": "^1.85.0",
21
21
  "@tailwindcss/vite": "^4.1.17",
22
22
  "@tanstack/react-form": "^1.28.4",
23
23
  "class-variance-authority": "^0.7.1",
@@ -42,7 +42,7 @@
42
42
  "@graphql-eslint/eslint-plugin": "^4.1.0",
43
43
  "@graphql-tools/utils": "^11.0.0",
44
44
  "@playwright/test": "^1.49.0",
45
- "@salesforce/vite-plugin-webapp-experimental": "^1.84.0",
45
+ "@salesforce/vite-plugin-webapp-experimental": "^1.85.0",
46
46
  "@testing-library/jest-dom": "^6.6.3",
47
47
  "@testing-library/react": "^16.1.0",
48
48
  "@testing-library/user-event": "^14.5.2",
@@ -1,10 +1,11 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { Application } from "../lib/types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { Application } from "../lib/types.js";
3
3
  import type {
4
4
  GetApplicationsQuery,
5
5
  UpdateApplicationStatusMutationVariables,
6
6
  UpdateApplicationStatusMutation,
7
- } from "./graphql-operations-types";
7
+ } from "./graphql-operations-types.js";
8
+ import { executeGraphQL } from "./graphqlClient.js";
8
9
 
9
10
  // Query to get all applications
10
11
  const GET_APPLICATIONS = gql`
@@ -73,15 +74,8 @@ const UPDATE_APPLICATION_STATUS = gql`
73
74
 
74
75
  export async function getApplications(): Promise<Application[]> {
75
76
  try {
76
- const data = await getDataSDK();
77
- const result = await data.graphql?.<GetApplicationsQuery>(GET_APPLICATIONS);
78
-
79
- if (result?.errors?.length) {
80
- const errorMessages = result.errors.map((e) => e.message).join("; ");
81
- throw new Error(`GraphQL Error: ${errorMessages}`);
82
- }
83
-
84
- const edges = result?.data?.uiapi?.query?.Application__c?.edges || [];
77
+ const data = await executeGraphQL<GetApplicationsQuery>(GET_APPLICATIONS);
78
+ const edges = data?.uiapi?.query?.Application__c?.edges || [];
85
79
 
86
80
  return edges
87
81
  .map((edge) => {
@@ -123,18 +117,11 @@ export async function updateApplicationStatus(
123
117
  },
124
118
  };
125
119
  try {
126
- const data = await getDataSDK();
127
- const result = await data.graphql?.<
120
+ const data = await executeGraphQL<
128
121
  UpdateApplicationStatusMutation,
129
122
  UpdateApplicationStatusMutationVariables
130
123
  >(UPDATE_APPLICATION_STATUS, variables);
131
-
132
- if (result?.errors?.length) {
133
- const errorMessages = result.errors.map((e) => e.message).join("; ");
134
- throw new Error(`GraphQL Error: ${errorMessages}`);
135
- }
136
-
137
- return !!result?.data?.uiapi?.Application__cUpdate?.success;
124
+ return !!data?.uiapi?.Application__cUpdate?.success;
138
125
  } catch (error) {
139
126
  console.error("Error updating application status:", error);
140
127
  return false;
@@ -1,11 +1,12 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { DashboardMetrics, Application } from "../lib/types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { DashboardMetrics, Application } from "../lib/types.js";
3
3
  import type {
4
4
  GetDashboardMetricsQuery,
5
5
  GetOpenApplicationsQuery,
6
6
  GetOpenApplicationsQueryVariables,
7
7
  GetUserInfoQuery,
8
- } from "./graphql-operations-types";
8
+ } from "./graphql-operations-types.js";
9
+ import { executeGraphQL } from "./graphqlClient.js";
9
10
 
10
11
  // Query to get property counts for dashboard metrics
11
12
  const GET_DASHBOARD_METRICS = gql`
@@ -99,18 +100,10 @@ const GET_USER_INFO = gql`
99
100
 
100
101
  // Fetch dashboard metrics
101
102
  export async function getDashboardMetrics(): Promise<{
102
- properties: any[];
103
- maintenanceRequests: any[];
103
+ properties: unknown[];
104
+ maintenanceRequests: unknown[];
104
105
  }> {
105
- const data = await getDataSDK();
106
- const result = await data.graphql?.<GetDashboardMetricsQuery>(GET_DASHBOARD_METRICS);
107
-
108
- if (result?.errors?.length) {
109
- const errorMessages = result.errors.map((e) => e.message).join("; ");
110
- throw new Error(`GraphQL Error: ${errorMessages}`);
111
- }
112
-
113
- const response = result?.data;
106
+ const response = await executeGraphQL<GetDashboardMetricsQuery>(GET_DASHBOARD_METRICS);
114
107
  const properties = response?.uiapi?.query?.allProperties?.edges?.map((edge) => edge?.node) || [];
115
108
  const maintenanceRequests =
116
109
  response?.uiapi?.query?.maintenanceRequests?.edges?.map((edge) => edge?.node) || [];
@@ -120,36 +113,21 @@ export async function getDashboardMetrics(): Promise<{
120
113
  // Fetch open applications
121
114
  export async function getOpenApplications(first: number = 5): Promise<Application[]> {
122
115
  const variables: GetOpenApplicationsQueryVariables = { first };
123
- const data = await getDataSDK();
124
- const result = await data.graphql?.<GetOpenApplicationsQuery, GetOpenApplicationsQueryVariables>(
116
+ const data = await executeGraphQL<GetOpenApplicationsQuery, GetOpenApplicationsQueryVariables>(
125
117
  GET_OPEN_APPLICATIONS,
126
118
  variables,
127
119
  );
128
-
129
- if (result?.errors?.length) {
130
- const errorMessages = result.errors.map((e) => e.message).join("; ");
131
- throw new Error(`GraphQL Error: ${errorMessages}`);
132
- }
133
-
134
120
  const apps =
135
- result?.data?.uiapi?.query?.Application__c?.edges?.map((edge) =>
136
- transformApplication(edge?.node),
137
- ) || [];
121
+ data?.uiapi?.query?.Application__c?.edges?.map((edge) => transformApplication(edge?.node)) ||
122
+ [];
138
123
  return apps;
139
124
  }
140
125
 
141
126
  // Fetch current user information
142
127
  export async function getUserInfo(): Promise<{ name: string; id: string } | null> {
143
128
  try {
144
- const data = await getDataSDK();
145
- const result = await data.graphql?.<GetUserInfoQuery>(GET_USER_INFO);
146
-
147
- if (result?.errors?.length) {
148
- const errorMessages = result.errors.map((e) => e.message).join("; ");
149
- throw new Error(`GraphQL Error: ${errorMessages}`);
150
- }
151
-
152
- const user = result?.data?.uiapi?.query?.User?.edges?.[0]?.node;
129
+ const data = await executeGraphQL<GetUserInfoQuery>(GET_USER_INFO);
130
+ const user = data?.uiapi?.query?.User?.edges?.[0]?.node;
153
131
  if (user) {
154
132
  return {
155
133
  id: user.Id,
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Thin GraphQL client: getDataSDK + data.graphql with centralized error handling.
3
+ * Use with gql-tagged queries and generated operation types for type-safe calls.
4
+ */
5
+ import { getDataSDK } from "@salesforce/sdk-data";
6
+
7
+ export async function executeGraphQL<TData, TVariables = Record<string, unknown>>(
8
+ query: string | { kind: string; definitions: unknown[] },
9
+ variables?: TVariables,
10
+ ): Promise<TData> {
11
+ const data = await getDataSDK();
12
+ // SDK types graphql() first param as string; at runtime it may accept gql DocumentNode too
13
+ const response = await data.graphql?.<TData>(
14
+ query as unknown as string,
15
+ variables as Record<string, unknown>,
16
+ );
17
+ if (response?.errors?.length) {
18
+ const msg = response.errors.map((e) => e.message).join("; ");
19
+ throw new Error(`GraphQL Error: ${msg}`);
20
+ }
21
+ return (response?.data ?? {}) as TData;
22
+ }
@@ -1,5 +1,5 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { MaintenanceRequest } from "../lib/types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { MaintenanceRequest } from "../lib/types.js";
3
3
  import type {
4
4
  GetMaintenanceRequestsQuery,
5
5
  GetMaintenanceRequestsQueryVariables,
@@ -7,7 +7,8 @@ import type {
7
7
  GetAllMaintenanceRequestsQueryVariables,
8
8
  UpdateMaintenanceStatusMutation,
9
9
  UpdateMaintenanceStatusMutationVariables,
10
- } from "./graphql-operations-types";
10
+ } from "./graphql-operations-types.js";
11
+ import { executeGraphQL } from "./graphqlClient.js";
11
12
 
12
13
  // Query to get recent maintenance requests
13
14
  const GET_MAINTENANCE_REQUESTS = gql`
@@ -149,19 +150,12 @@ const UPDATE_MAINTENANCE_STATUS = gql`
149
150
  // Fetch maintenance requests for dashboard
150
151
  export async function getMaintenanceRequests(first: number = 5): Promise<MaintenanceRequest[]> {
151
152
  const variables: GetMaintenanceRequestsQueryVariables = { first };
152
- const data = await getDataSDK();
153
- const result = await data.graphql?.<
153
+ const data = await executeGraphQL<
154
154
  GetMaintenanceRequestsQuery,
155
155
  GetMaintenanceRequestsQueryVariables
156
156
  >(GET_MAINTENANCE_REQUESTS, variables);
157
-
158
- if (result?.errors?.length) {
159
- const errorMessages = result.errors.map((e) => e.message).join("; ");
160
- throw new Error(`GraphQL Error: ${errorMessages}`);
161
- }
162
-
163
157
  const requests =
164
- result?.data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge) =>
158
+ data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge) =>
165
159
  transformMaintenanceRequest(edge?.node),
166
160
  ) || [];
167
161
  return requests;
@@ -172,19 +166,12 @@ export async function getAllMaintenanceRequests(
172
166
  first: number = 100,
173
167
  ): Promise<MaintenanceRequest[]> {
174
168
  const variables: GetAllMaintenanceRequestsQueryVariables = { first };
175
- const data = await getDataSDK();
176
- const result = await data.graphql?.<
169
+ const data = await executeGraphQL<
177
170
  GetAllMaintenanceRequestsQuery,
178
171
  GetAllMaintenanceRequestsQueryVariables
179
172
  >(GET_ALL_MAINTENANCE_REQUESTS, variables);
180
-
181
- if (result?.errors?.length) {
182
- const errorMessages = result.errors.map((e) => e.message).join("; ");
183
- throw new Error(`GraphQL Error: ${errorMessages}`);
184
- }
185
-
186
173
  const requests =
187
- result?.data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge: any) =>
174
+ data?.uiapi?.query?.Maintenance_Request__c?.edges?.map((edge) =>
188
175
  transformMaintenanceTaskFull(edge?.node),
189
176
  ) || [];
190
177
  return requests;
@@ -275,18 +262,11 @@ export async function updateMaintenanceStatus(requestId: string, status: string)
275
262
  },
276
263
  };
277
264
  try {
278
- const data = await getDataSDK();
279
- const result = await data.graphql?.<
265
+ const data = await executeGraphQL<
280
266
  UpdateMaintenanceStatusMutation,
281
267
  UpdateMaintenanceStatusMutationVariables
282
268
  >(UPDATE_MAINTENANCE_STATUS, variables);
283
-
284
- if (result?.errors?.length) {
285
- const errorMessages = result.errors.map((e) => e.message).join("; ");
286
- throw new Error(`GraphQL Error: ${errorMessages}`);
287
- }
288
-
289
- return !!result?.data?.uiapi?.Maintenance_Request__cUpdate?.success;
269
+ return !!data?.uiapi?.Maintenance_Request__cUpdate?.success;
290
270
  } catch (error) {
291
271
  console.error("Error updating maintenance status:", error);
292
272
  return false;
@@ -1,6 +1,10 @@
1
- import { getDataSDK, gql } from "@salesforce/sdk-data";
2
- import type { Property } from "../lib/types";
3
- import type { GetPropertiesQueryVariables, GetPropertiesQuery } from "./graphql-operations-types";
1
+ import { gql } from "@salesforce/sdk-data";
2
+ import type { Property } from "../lib/types.js";
3
+ import type {
4
+ GetPropertiesQueryVariables,
5
+ GetPropertiesQuery,
6
+ } from "./graphql-operations-types.js";
7
+ import { executeGraphQL } from "./graphqlClient.js";
4
8
 
5
9
  // GraphQL query to get properties with pagination
6
10
  const GET_PROPERTIES_PAGINATED = gql`
@@ -97,19 +101,10 @@ export async function getProperties(first: number = 12, after?: string): Promise
97
101
  if (after) {
98
102
  variables.after = after;
99
103
  }
100
-
101
- const data = await getDataSDK();
102
- const result = await data.graphql?.<GetPropertiesQuery, GetPropertiesQueryVariables>(
104
+ const response = await executeGraphQL<GetPropertiesQuery, GetPropertiesQueryVariables>(
103
105
  GET_PROPERTIES_PAGINATED,
104
106
  variables,
105
107
  );
106
-
107
- if (result?.errors?.length) {
108
- const errorMessages = result.errors.map((e) => e.message).join("; ");
109
- throw new Error(`GraphQL Error: ${errorMessages}`);
110
- }
111
-
112
- const response = result?.data;
113
108
  const edges = response?.uiapi?.query?.Property__c?.edges || [];
114
109
  const pageInfo = response?.uiapi?.query?.Property__c?.pageInfo || {
115
110
  hasNextPage: false,
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.84.0",
3
+ "version": "1.85.0",
4
4
  "description": "Base SFDX project template",
5
5
  "private": true,
6
6
  "files": [
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * One-command setup: login, deploy, data import, GraphQL schema/codegen, web app build.
4
+ * Provided by the property management feature. Run from the SFDX project root (e.g. dist/).
5
+ *
6
+ * Usage:
7
+ * node setup-cli.mjs --target-org <alias> # run all steps
8
+ * node setup-cli.mjs --target-org afv5 --skip-login
9
+ * node setup-cli.mjs --target-org afv5 --skip-data --skip-webapp-build
10
+ * node setup-cli.mjs --target-org myorg --app appreactsampleb2x # when multiple web apps
11
+ *
12
+ * Steps (in order):
13
+ * 1. login — sf org login web only if org not already connected (skip with --skip-login)
14
+ * 2. deploy — sf project deploy start --target-org <alias>
15
+ * 3. permset — sf org assign permset (default: Property_Management_Access; override with --permset)
16
+ * 4. data — prepare unique fields + sf data import tree (skipped if no data-plan.json)
17
+ * 5. graphql — (in webapp) npm run graphql:schema then npm run graphql:codegen
18
+ * 6. webapp — (in webapp) npm install && npm run build
19
+ * 7. dev — (in webapp) npm run dev — launch dev server (skip with --skip-dev)
20
+ */
21
+
22
+ import { spawnSync } from "node:child_process";
23
+ import { readdirSync, existsSync } from "node:fs";
24
+ import { resolve, dirname, basename } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+
27
+ const __dirname = dirname(fileURLToPath(import.meta.url));
28
+ /** SFDX project root: when run from dist/, the script lives in dist/ and force-app is under dist/ */
29
+ const ROOT = __dirname;
30
+ const WEBAPPLICATIONS_DIR = resolve(ROOT, "force-app/main/default/webapplications");
31
+ const DATA_DIR = resolve(ROOT, "force-app/main/default/data");
32
+ const DATA_PLAN = resolve(DATA_DIR, "data-plan.json");
33
+ const PREPARE_SCRIPT = resolve(DATA_DIR, "prepare-import-unique-fields.js");
34
+
35
+ function parseArgs() {
36
+ const args = process.argv.slice(2);
37
+ let targetOrg = null;
38
+ let appName = null;
39
+ let permsetName = "Property_Management_Access";
40
+ const flags = {
41
+ skipLogin: false,
42
+ skipDeploy: false,
43
+ skipPermset: false,
44
+ skipData: false,
45
+ skipGraphql: false,
46
+ skipWebappBuild: false,
47
+ skipDev: false,
48
+ };
49
+ for (let i = 0; i < args.length; i++) {
50
+ if (args[i] === "--target-org" && args[i + 1]) {
51
+ targetOrg = args[++i];
52
+ } else if (args[i] === "--app" && args[i + 1]) {
53
+ appName = args[++i];
54
+ } else if (args[i] === "--permset" && args[i + 1]) {
55
+ permsetName = args[++i];
56
+ } else if (args[i] === "--skip-login") flags.skipLogin = true;
57
+ else if (args[i] === "--skip-deploy") flags.skipDeploy = true;
58
+ else if (args[i] === "--skip-permset") flags.skipPermset = true;
59
+ else if (args[i] === "--skip-data") flags.skipData = true;
60
+ else if (args[i] === "--skip-graphql") flags.skipGraphql = true;
61
+ else if (args[i] === "--skip-webapp-build") flags.skipWebappBuild = true;
62
+ else if (args[i] === "--skip-dev") flags.skipDev = true;
63
+ else if (args[i] === "--help" || args[i] === "-h") {
64
+ console.log(`
65
+ Setup CLI (property management feature)
66
+
67
+ Usage:
68
+ node setup-cli.mjs --target-org <alias> [options]
69
+
70
+ Required:
71
+ --target-org <alias> Target Salesforce org alias (e.g. afv5)
72
+
73
+ Options:
74
+ --app <name> Web app folder name (default: auto-detect if only one in force-app/.../webapplications/)
75
+ --permset <name> Permission set to assign (default: Property_Management_Access)
76
+ --skip-login Skip login step (login is auto-skipped if org is already connected)
77
+ --skip-deploy Do not deploy metadata
78
+ --skip-permset Do not assign permission set
79
+ --skip-data Do not prepare data or run data import
80
+ --skip-graphql Do not fetch schema or run GraphQL codegen
81
+ --skip-webapp-build Do not npm install / build the web application
82
+ --skip-dev Do not launch the dev server at the end
83
+ -h, --help Show this help
84
+ `);
85
+ process.exit(0);
86
+ }
87
+ }
88
+ if (!targetOrg) {
89
+ console.error("Error: --target-org <alias> is required.");
90
+ process.exit(1);
91
+ }
92
+ return { targetOrg, appName, permsetName, ...flags };
93
+ }
94
+
95
+ function discoverWebAppDir(appNameOverride) {
96
+ if (appNameOverride) {
97
+ const dir = resolve(WEBAPPLICATIONS_DIR, appNameOverride);
98
+ if (!existsSync(dir)) {
99
+ console.error(`Error: Web app directory not found: ${dir}`);
100
+ process.exit(1);
101
+ }
102
+ return dir;
103
+ }
104
+ if (!existsSync(WEBAPPLICATIONS_DIR)) {
105
+ console.error(`Error: Web applications directory not found: ${WEBAPPLICATIONS_DIR}`);
106
+ process.exit(1);
107
+ }
108
+ const entries = readdirSync(WEBAPPLICATIONS_DIR, { withFileTypes: true });
109
+ const dirs = entries.filter((e) => e.isDirectory());
110
+ if (dirs.length === 0) {
111
+ console.error(
112
+ "Error: No web application folder found under force-app/main/default/webapplications/",
113
+ );
114
+ process.exit(1);
115
+ }
116
+ if (dirs.length > 1) {
117
+ console.error(
118
+ "Error: Multiple web applications found. Specify one with --app <name>. Choices:",
119
+ dirs.map((d) => d.name).join(", "),
120
+ );
121
+ process.exit(1);
122
+ }
123
+ return resolve(WEBAPPLICATIONS_DIR, dirs[0].name);
124
+ }
125
+
126
+ function isOrgConnected(targetOrg) {
127
+ const result = spawnSync("sf", ["org", "display", "--target-org", targetOrg, "--json"], {
128
+ cwd: ROOT,
129
+ stdio: "pipe",
130
+ shell: true,
131
+ });
132
+ return result.status === 0;
133
+ }
134
+
135
+ function run(name, cmd, args, opts = {}) {
136
+ const { cwd = ROOT, optional = false } = opts;
137
+ console.log("\n---", name, "---");
138
+ const result = spawnSync(cmd, args, {
139
+ cwd,
140
+ stdio: "inherit",
141
+ shell: true,
142
+ ...(opts.timeout && { timeout: opts.timeout }),
143
+ });
144
+ if (result.status !== 0 && !optional) {
145
+ console.error(`\nSetup failed at step: ${name}`);
146
+ process.exit(result.status ?? 1);
147
+ }
148
+ return result;
149
+ }
150
+
151
+ function main() {
152
+ const {
153
+ targetOrg,
154
+ appName: appNameOverride,
155
+ permsetName,
156
+ skipLogin,
157
+ skipDeploy,
158
+ skipPermset,
159
+ skipData,
160
+ skipGraphql,
161
+ skipWebappBuild,
162
+ skipDev,
163
+ } = parseArgs();
164
+
165
+ const WEBAPP_DIR = discoverWebAppDir(appNameOverride);
166
+ const webAppName = appNameOverride || basename(WEBAPP_DIR);
167
+
168
+ console.log("Setup — target org:", targetOrg, "| web app:", webAppName);
169
+ console.log(
170
+ "Steps: login=%s deploy=%s permset=%s data=%s graphql=%s webapp=%s dev=%s",
171
+ !skipLogin,
172
+ !skipDeploy,
173
+ !skipPermset,
174
+ !skipData,
175
+ !skipGraphql,
176
+ !skipWebappBuild,
177
+ !skipDev,
178
+ );
179
+
180
+ if (!skipLogin) {
181
+ if (isOrgConnected(targetOrg)) {
182
+ console.log("\n--- Login ---");
183
+ console.log(`Org ${targetOrg} is already authenticated; skipping browser login.`);
184
+ } else {
185
+ run("Login (browser)", "sf", ["org", "login", "web", "--alias", targetOrg], {
186
+ optional: true,
187
+ });
188
+ }
189
+ }
190
+
191
+ if (!skipDeploy) {
192
+ run("Deploy metadata", "sf", ["project", "deploy", "start", "--target-org", targetOrg], {
193
+ timeout: 180000,
194
+ });
195
+ }
196
+
197
+ if (!skipPermset) {
198
+ console.log("\n--- Assign permission set ---");
199
+ const permsetResult = spawnSync(
200
+ "sf",
201
+ ["org", "assign", "permset", "--name", permsetName, "--target-org", targetOrg],
202
+ {
203
+ cwd: ROOT,
204
+ stdio: "pipe",
205
+ shell: true,
206
+ },
207
+ );
208
+ if (permsetResult.status === 0) {
209
+ console.log("Permission set assigned.");
210
+ } else {
211
+ const out =
212
+ (permsetResult.stderr?.toString() || "") + (permsetResult.stdout?.toString() || "");
213
+ if (out.includes("Duplicate") && out.includes("PermissionSet")) {
214
+ console.log("Permission set already assigned; skipping.");
215
+ } else {
216
+ process.stdout.write(permsetResult.stdout?.toString() || "");
217
+ process.stderr.write(permsetResult.stderr?.toString() || "");
218
+ console.error("\nSetup failed at step: Assign permission set");
219
+ process.exit(permsetResult.status ?? 1);
220
+ }
221
+ }
222
+ }
223
+
224
+ const hasDataPlan = existsSync(DATA_PLAN);
225
+ const hasPrepareScript = existsSync(PREPARE_SCRIPT);
226
+
227
+ if (!skipData) {
228
+ if (hasPrepareScript) {
229
+ run("Prepare data (unique fields)", "node", [PREPARE_SCRIPT], { cwd: DATA_DIR });
230
+ } else {
231
+ console.log("\n--- Prepare data ---");
232
+ console.log("No prepare-import-unique-fields.js found; skipping.");
233
+ }
234
+ if (hasDataPlan) {
235
+ run(
236
+ "Data import tree",
237
+ "sf",
238
+ ["data", "import", "tree", "--plan", DATA_PLAN, "--target-org", targetOrg],
239
+ {
240
+ timeout: 120000,
241
+ },
242
+ );
243
+ } else {
244
+ console.log("\n--- Data import ---");
245
+ console.log("No data-plan.json found; skipping data import.");
246
+ }
247
+ }
248
+
249
+ if (!skipGraphql || !skipWebappBuild) {
250
+ run("Web app npm install", "npm", ["install"], { cwd: WEBAPP_DIR });
251
+ }
252
+
253
+ if (!skipGraphql) {
254
+ run("Set default org for schema", "sf", ["config", "set", "target-org", targetOrg, "--global"]);
255
+ run("GraphQL schema (introspect)", "npm", ["run", "graphql:schema"], { cwd: WEBAPP_DIR });
256
+ run("GraphQL codegen", "npm", ["run", "graphql:codegen"], { cwd: WEBAPP_DIR });
257
+ }
258
+
259
+ if (!skipWebappBuild) {
260
+ run("Web app build", "npm", ["run", "build"], { cwd: WEBAPP_DIR });
261
+ }
262
+
263
+ console.log("\n--- Setup complete ---");
264
+
265
+ if (!skipDev) {
266
+ console.log("\n--- Launching dev server (Ctrl+C to stop) ---\n");
267
+ run("Dev server", "npm", ["run", "dev"], { cwd: WEBAPP_DIR });
268
+ }
269
+ }
270
+
271
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-app-react-sample-b2e-experimental",
3
- "version": "1.84.0",
3
+ "version": "1.85.0",
4
4
  "description": "B2E starter app template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -16,8 +16,8 @@
16
16
  "clean": "rm -rf dist"
17
17
  },
18
18
  "dependencies": {
19
- "@salesforce/webapp-experimental": "^1.84.0",
20
- "@salesforce/webapp-template-feature-react-global-search-experimental": "^1.84.0"
19
+ "@salesforce/webapp-experimental": "^1.85.0",
20
+ "@salesforce/webapp-template-feature-react-global-search-experimental": "^1.85.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@testing-library/jest-dom": "^6.6.3",