@salesforce/webapp-template-app-react-template-b2x-experimental 1.83.0 → 1.84.1

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.
@@ -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/AGENT.md CHANGED
@@ -26,6 +26,8 @@ Used for SFDX metadata (LWC, Aura, etc.). Scripts here are for the base SFDX tem
26
26
  | `npm run prettier` | Format supported metadata files |
27
27
  | `npm run prettier:verify` | Check Prettier |
28
28
 
29
+ **One-command setup:** From project root run `node scripts/setup-cli.mjs --target-org <alias>` to run login (if needed), deploy, optional permset/data import, GraphQL schema/codegen, web app build, and optionally the dev server. Use `node scripts/setup-cli.mjs --help` for options (e.g. `--skip-login`, `--skip-data`, `--webapp-name`).
30
+
29
31
  Root **does not** run the React app. The root `npm run build` is a no-op for the base SFDX project.
30
32
 
31
33
  ### 2. React web app (where you do most work)
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
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.84.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.84.0...v1.84.1) (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.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.83.0...v1.84.0) (2026-03-09)
15
+
16
+
17
+ ### Features
18
+
19
+ * **template:** add setup-cli and prepare-import-unique-fields scripts ([#240](https://github.com/salesforce-experience-platform-emu/webapps/issues/240)) ([5cad14c](https://github.com/salesforce-experience-platform-emu/webapps/commit/5cad14c9be8176b2faf2429fe8e8a56383aac1ae))
20
+
21
+
22
+
23
+
24
+
6
25
  # [1.83.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.82.0...v1.83.0) (2026-03-09)
7
26
 
8
27
 
@@ -15,8 +15,8 @@
15
15
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
16
16
  },
17
17
  "dependencies": {
18
- "@salesforce/sdk-data": "^1.83.0",
19
- "@salesforce/webapp-experimental": "^1.83.0",
18
+ "@salesforce/sdk-data": "^1.84.1",
19
+ "@salesforce/webapp-experimental": "^1.84.1",
20
20
  "@tailwindcss/vite": "^4.1.17",
21
21
  "@tanstack/react-form": "^1.28.4",
22
22
  "class-variance-authority": "^0.7.1",
@@ -40,7 +40,7 @@
40
40
  "@graphql-eslint/eslint-plugin": "^4.1.0",
41
41
  "@graphql-tools/utils": "^11.0.0",
42
42
  "@playwright/test": "^1.49.0",
43
- "@salesforce/vite-plugin-webapp-experimental": "^1.83.0",
43
+ "@salesforce/vite-plugin-webapp-experimental": "^1.84.1",
44
44
  "@testing-library/jest-dom": "^6.6.3",
45
45
  "@testing-library/react": "^16.1.0",
46
46
  "@testing-library/user-event": "^14.5.2",
@@ -2,6 +2,6 @@
2
2
  "outputDir": "dist",
3
3
  "routing": {
4
4
  "trailingSlash": "never",
5
- "fallback": "/index.html"
5
+ "fallback": "index.html"
6
6
  }
7
7
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.83.0",
3
+ "version": "1.84.1",
4
4
  "description": "Base SFDX project template",
5
5
  "private": true,
6
6
  "files": [
@@ -18,7 +18,8 @@
18
18
  "test:unit:coverage": "sfdx-lwc-jest --coverage",
19
19
  "prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
20
20
  "prettier:verify": "prettier --check \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
21
- "precommit": "lint-staged"
21
+ "precommit": "lint-staged",
22
+ "setup": "node scripts/setup-cli.mjs"
22
23
  },
23
24
  "devDependencies": {
24
25
  "@lwc/eslint-plugin-lwc": "^2.0.0",
@@ -0,0 +1,108 @@
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 data import.
5
+ *
6
+ * Usage:
7
+ * node scripts/prepare-import-unique-fields.js
8
+ * node scripts/prepare-import-unique-fields.js --data-dir /path/to/force-app/main/default/data
9
+ *
10
+ * Expects data dir to contain (optional) JSON files:
11
+ * Contact.json (Email with unique domain per run, LastName, FirstName, Phone — standard Contact)
12
+ * Agent__c.json (License_Number__c — unique per record)
13
+ * Property_Management_Company__c.json (Company_Code__c, max 10 chars)
14
+ * Property_Owner__c.json (Email__c)
15
+ * Missing files are skipped. Customize this script for your app's objects/fields.
16
+ */
17
+
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+
21
+ // When run from project root: scripts/prepare-import-unique-fields.js → data dir under force-app
22
+ const DEFAULT_DATA_DIR = path.resolve(__dirname, '..', 'force-app/main/default/data');
23
+
24
+ function parseArgs() {
25
+ const args = process.argv.slice(2);
26
+ let dataDir = DEFAULT_DATA_DIR;
27
+ for (let i = 0; i < args.length; i++) {
28
+ if (args[i] === '--data-dir' && args[i + 1]) {
29
+ dataDir = path.resolve(args[++i]);
30
+ break;
31
+ }
32
+ }
33
+ return dataDir;
34
+ }
35
+
36
+ const dataDir = parseArgs();
37
+ const runId = Date.now();
38
+ const runSuffix2 = String(runId % 100).padStart(2, '0'); // 00-99 for Company_Code__c (10-char limit)
39
+
40
+ // Contact: Email (unique domain + local), LastName, FirstName, Phone — avoid duplicate rules
41
+ const contactPath = path.join(dataDir, 'Contact.json');
42
+ if (fs.existsSync(contactPath)) {
43
+ let contact = JSON.parse(fs.readFileSync(contactPath, 'utf8'));
44
+ if (contact.records) {
45
+ contact.records.forEach((r, i) => {
46
+ if (r.Email && r.Email.includes('@')) {
47
+ const parts = r.Email.replace(/\+[0-9]+@/, '@').split('@');
48
+ const local = (parts[0] || 'user') + '+' + runId;
49
+ const domain = 'run' + runId + '.example.com';
50
+ r.Email = local + '@' + domain;
51
+ }
52
+ if (r.LastName)
53
+ r.LastName = String(r.LastName).replace(/-[0-9]+$/, '') + '-' + runId;
54
+ if (r.FirstName)
55
+ r.FirstName = String(r.FirstName).replace(/-[0-9]+$/, '') + '-' + (i + 1);
56
+ if (r.Phone)
57
+ r.Phone = String(r.Phone).replace(/\d{2}$/, runSuffix2);
58
+ });
59
+ fs.writeFileSync(contactPath, JSON.stringify(contact, null, 2));
60
+ console.log('Updated Contact.json (Email, LastName, FirstName, Phone)');
61
+ }
62
+ }
63
+
64
+ // Agent__c: License_Number__c — unique per record (field is often unique in org)
65
+ const agentPath = path.join(dataDir, 'Agent__c.json');
66
+ if (fs.existsSync(agentPath)) {
67
+ let agent = JSON.parse(fs.readFileSync(agentPath, 'utf8'));
68
+ if (agent.records) {
69
+ agent.records.forEach((r, i) => {
70
+ if (r.License_Number__c) {
71
+ const base = r.License_Number__c.replace(/-[0-9]+(-[0-9]+)?$/, '');
72
+ r.License_Number__c = base + '-' + runId + '-' + (i + 1);
73
+ }
74
+ });
75
+ fs.writeFileSync(agentPath, JSON.stringify(agent, null, 2));
76
+ console.log('Updated Agent__c.json (License_Number__c)');
77
+ }
78
+ }
79
+
80
+ // Property_Management_Company__c: Company_Code__c — max 10 chars, use 8-char base + 2-digit suffix
81
+ const companyPath = path.join(dataDir, 'Property_Management_Company__c.json');
82
+ if (fs.existsSync(companyPath)) {
83
+ let company = JSON.parse(fs.readFileSync(companyPath, 'utf8'));
84
+ if (company.records) {
85
+ company.records.forEach((r) => {
86
+ if (r.Company_Code__c)
87
+ r.Company_Code__c = r.Company_Code__c.slice(0, 8) + runSuffix2;
88
+ });
89
+ fs.writeFileSync(companyPath, JSON.stringify(company, null, 2));
90
+ console.log('Updated Property_Management_Company__c.json (Company_Code__c)');
91
+ }
92
+ }
93
+
94
+ // Property_Owner__c: Email__c — add +runId before @
95
+ const ownerPath = path.join(dataDir, 'Property_Owner__c.json');
96
+ if (fs.existsSync(ownerPath)) {
97
+ let owner = JSON.parse(fs.readFileSync(ownerPath, 'utf8'));
98
+ if (owner.records) {
99
+ owner.records.forEach((r) => {
100
+ if (r.Email__c && r.Email__c.includes('@'))
101
+ r.Email__c = r.Email__c.replace(/\+[0-9]+@/, '@').replace('@', '+' + runId + '@');
102
+ });
103
+ fs.writeFileSync(ownerPath, JSON.stringify(owner, null, 2));
104
+ console.log('Updated Property_Owner__c.json (Email__c)');
105
+ }
106
+ }
107
+
108
+ console.log('Unique fields updated: runId=%s companySuffix=%s', runId, runSuffix2);
@@ -0,0 +1,282 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * One-command setup: login, deploy, optional permset/data, GraphQL schema/codegen, web app build.
4
+ * Use this script to make setup easier for each app generated from this template.
5
+ *
6
+ * Usage:
7
+ * node scripts/setup-cli.mjs --target-org <alias> # run all steps
8
+ * node scripts/setup-cli.mjs --target-org afv5 --skip-login
9
+ * node scripts/setup-cli.mjs --target-org afv5 --skip-data --skip-webapp-build
10
+ * node scripts/setup-cli.mjs --target-org myorg --webapp-name my-app
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 (skip with --skip-permset; name via --permset-name)
16
+ * 4. data — prepare unique fields + sf data import tree (skipped if no data dir/plan)
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 { resolve, dirname } from 'node:path';
24
+ import { fileURLToPath } from 'node:url';
25
+ import { readdirSync, existsSync } from 'node:fs';
26
+
27
+ const __dirname = dirname(fileURLToPath(import.meta.url));
28
+ const ROOT = resolve(__dirname, '..');
29
+ const WEBAPPLICATIONS_DIR = resolve(ROOT, 'force-app/main/default/webapplications');
30
+ const DATA_DIR = resolve(ROOT, 'force-app/main/default/data');
31
+ const DATA_PLAN = resolve(ROOT, 'force-app/main/default/data/data-plan.json');
32
+
33
+ function parseArgs() {
34
+ const args = process.argv.slice(2);
35
+ let targetOrg = null;
36
+ let webappName = null;
37
+ let permsetName = 'Property_Management_Access';
38
+ const flags = {
39
+ skipLogin: false,
40
+ skipDeploy: false,
41
+ skipPermset: false,
42
+ skipData: false,
43
+ skipGraphql: false,
44
+ skipWebappBuild: false,
45
+ skipDev: false,
46
+ };
47
+ for (let i = 0; i < args.length; i++) {
48
+ if (args[i] === '--target-org' && args[i + 1]) {
49
+ targetOrg = args[++i];
50
+ } else if (args[i] === '--webapp-name' && args[i + 1]) {
51
+ webappName = args[++i];
52
+ } else if (args[i] === '--permset-name' && args[i + 1]) {
53
+ permsetName = args[++i];
54
+ } else if (args[i] === '--skip-login') flags.skipLogin = true;
55
+ else if (args[i] === '--skip-deploy') flags.skipDeploy = true;
56
+ else if (args[i] === '--skip-permset') flags.skipPermset = true;
57
+ else if (args[i] === '--skip-data') flags.skipData = true;
58
+ else if (args[i] === '--skip-graphql') flags.skipGraphql = true;
59
+ else if (args[i] === '--skip-webapp-build') flags.skipWebappBuild = true;
60
+ else if (args[i] === '--skip-dev') flags.skipDev = true;
61
+ else if (args[i] === '--help' || args[i] === '-h') {
62
+ console.log(`
63
+ Setup CLI — one-command setup for apps in this project
64
+
65
+ Usage:
66
+ node scripts/setup-cli.mjs --target-org <alias> [options]
67
+
68
+ Required:
69
+ --target-org <alias> Target Salesforce org alias (e.g. myorg)
70
+
71
+ Options:
72
+ --webapp-name <name> Web app folder name under webapplications/ (default: auto-detect)
73
+ --permset-name <name> Permission set to assign (default: Property_Management_Access)
74
+ --skip-login Skip login step (login is auto-skipped if org is already connected)
75
+ --skip-deploy Do not deploy metadata
76
+ --skip-permset Do not assign permission set
77
+ --skip-data Do not prepare data or run data import
78
+ --skip-graphql Do not fetch schema or run GraphQL codegen
79
+ --skip-webapp-build Do not npm install / build the web application
80
+ --skip-dev Do not launch the dev server at the end
81
+ -h, --help Show this help
82
+ `);
83
+ process.exit(0);
84
+ }
85
+ }
86
+ if (!targetOrg) {
87
+ console.error('Error: --target-org <alias> is required.');
88
+ process.exit(1);
89
+ }
90
+ return { targetOrg, webappName, permsetName, ...flags };
91
+ }
92
+
93
+ function discoverWebappDir(webappName) {
94
+ if (webappName) {
95
+ const dir = resolve(WEBAPPLICATIONS_DIR, webappName);
96
+ if (!existsSync(dir)) {
97
+ console.error(`Error: Web app directory not found: ${dir}`);
98
+ process.exit(1);
99
+ }
100
+ return dir;
101
+ }
102
+ if (!existsSync(WEBAPPLICATIONS_DIR)) {
103
+ console.error(`Error: webapplications directory not found: ${WEBAPPLICATIONS_DIR}`);
104
+ process.exit(1);
105
+ }
106
+ const entries = readdirSync(WEBAPPLICATIONS_DIR, { withFileTypes: true });
107
+ const dirs = entries.filter((e) => e.isDirectory() && !e.name.startsWith('.'));
108
+ if (dirs.length === 0) {
109
+ console.error(`Error: No web app folder found under ${WEBAPPLICATIONS_DIR}`);
110
+ process.exit(1);
111
+ }
112
+ if (dirs.length > 1) {
113
+ console.log(`Multiple web apps found; using first: ${dirs[0].name}`);
114
+ }
115
+ return resolve(WEBAPPLICATIONS_DIR, dirs[0].name);
116
+ }
117
+
118
+ function isOrgConnected(targetOrg) {
119
+ const result = spawnSync('sf', ['org', 'display', '--target-org', targetOrg, '--json'], {
120
+ cwd: ROOT,
121
+ stdio: 'pipe',
122
+ shell: true,
123
+ });
124
+ return result.status === 0;
125
+ }
126
+
127
+ function run(name, cmd, args, opts = {}) {
128
+ const { cwd = ROOT, optional = false } = opts;
129
+ console.log('\n---', name, '---');
130
+ const result = spawnSync(cmd, args, {
131
+ cwd,
132
+ stdio: 'inherit',
133
+ shell: true,
134
+ ...(opts.timeout && { timeout: opts.timeout }),
135
+ });
136
+ if (result.status !== 0 && !optional) {
137
+ console.error(`\nSetup failed at step: ${name}`);
138
+ process.exit(result.status ?? 1);
139
+ }
140
+ return result;
141
+ }
142
+
143
+ function main() {
144
+ const {
145
+ targetOrg,
146
+ webappName,
147
+ permsetName,
148
+ skipLogin,
149
+ skipDeploy,
150
+ skipPermset,
151
+ skipData,
152
+ skipGraphql,
153
+ skipWebappBuild,
154
+ skipDev,
155
+ } = parseArgs();
156
+
157
+ const webappDir = discoverWebappDir(webappName);
158
+ const hasDataPlan = existsSync(DATA_PLAN) && existsSync(DATA_DIR);
159
+ const doData = !skipData && hasDataPlan;
160
+
161
+ console.log('Setup — target org:', targetOrg, '| web app:', webappDir);
162
+ console.log(
163
+ 'Steps: login=%s deploy=%s permset=%s data=%s graphql=%s webapp=%s dev=%s',
164
+ !skipLogin,
165
+ !skipDeploy,
166
+ !skipPermset,
167
+ doData,
168
+ !skipGraphql,
169
+ !skipWebappBuild,
170
+ !skipDev
171
+ );
172
+ if (skipData && hasDataPlan) {
173
+ console.log('(Data dir present; use without --skip-data to run data import.)');
174
+ } else if (!hasDataPlan && !skipData) {
175
+ console.log('(No data plan found; skipping data step.)');
176
+ }
177
+
178
+ if (!skipLogin) {
179
+ if (isOrgConnected(targetOrg)) {
180
+ console.log('\n--- Login ---');
181
+ console.log(`Org ${targetOrg} is already authenticated; skipping browser login.`);
182
+ } else {
183
+ run('Login (browser)', 'sf', ['org', 'login', 'web', '--alias', targetOrg], { optional: true });
184
+ }
185
+ }
186
+
187
+ if (!skipDeploy) {
188
+ run('Deploy metadata', 'sf', ['project', 'deploy', 'start', '--target-org', targetOrg], {
189
+ timeout: 180000,
190
+ });
191
+ }
192
+
193
+ if (!skipPermset && permsetName) {
194
+ console.log('\n--- Assign permission set ---');
195
+ const permsetResult = spawnSync(
196
+ 'sf',
197
+ ['org', 'assign', 'permset', '--name', permsetName, '--target-org', targetOrg],
198
+ {
199
+ cwd: ROOT,
200
+ stdio: 'pipe',
201
+ shell: true,
202
+ }
203
+ );
204
+ if (permsetResult.status === 0) {
205
+ console.log('Permission set assigned.');
206
+ } else {
207
+ const out =
208
+ (permsetResult.stderr?.toString() || '') + (permsetResult.stdout?.toString() || '');
209
+ if (out.includes('Duplicate') && out.includes('PermissionSet')) {
210
+ console.log('Permission set already assigned; skipping.');
211
+ } else if (out.includes('not found') && out.includes('target org')) {
212
+ console.log(`Permission set "${permsetName}" not in org; skipping.`);
213
+ } else {
214
+ process.stdout.write(permsetResult.stdout?.toString() || '');
215
+ process.stderr.write(permsetResult.stderr?.toString() || '');
216
+ console.error('\nSetup failed at step: Assign permission set');
217
+ process.exit(permsetResult.status ?? 1);
218
+ }
219
+ }
220
+ }
221
+
222
+ if (doData) {
223
+ // Prepare data for uniqueness (run before import so repeat imports don't conflict)
224
+ const prepareScript = resolve(__dirname, 'prepare-import-unique-fields.js');
225
+ run('Prepare data (unique fields)', 'node', [prepareScript, '--data-dir', DATA_DIR], {
226
+ cwd: ROOT,
227
+ });
228
+ // Data import tree: if only DUPLICATES_DETECTED (org duplicate rules), warn and continue
229
+ console.log('\n--- Data import tree ---');
230
+ const importResult = spawnSync(
231
+ 'sf',
232
+ ['data', 'import', 'tree', '--plan', DATA_PLAN, '--target-org', targetOrg, '--json'],
233
+ { cwd: ROOT, stdio: 'pipe', shell: true, timeout: 120000 }
234
+ );
235
+ const out = (importResult.stdout?.toString() || '') + (importResult.stderr?.toString() || '');
236
+ if (importResult.status !== 0) {
237
+ let onlyDuplicates = false;
238
+ try {
239
+ const j = JSON.parse(out);
240
+ const errors = Array.isArray(j?.data) ? j.data : [];
241
+ onlyDuplicates =
242
+ errors.length > 0 &&
243
+ errors.every((e) => e.StatusCode === 'DUPLICATES_DETECTED' || e.statusCode === 'DUPLICATES_DETECTED');
244
+ } catch (_) {
245
+ onlyDuplicates = out.includes('DUPLICATES_DETECTED') && /Use one of these records\?/.test(out);
246
+ }
247
+ if (onlyDuplicates) {
248
+ console.warn(
249
+ 'Data import hit org duplicate rules (e.g. Contact). Skipping import; rest of setup continues.'
250
+ );
251
+ } else {
252
+ process.stdout.write(importResult.stdout?.toString() || '');
253
+ process.stderr.write(importResult.stderr?.toString() || '');
254
+ console.error('\nSetup failed at step: Data import tree');
255
+ process.exit(importResult.status ?? 1);
256
+ }
257
+ }
258
+ }
259
+
260
+ if (!skipGraphql || !skipWebappBuild) {
261
+ run('Web app npm install', 'npm', ['install'], { cwd: webappDir });
262
+ }
263
+
264
+ if (!skipGraphql) {
265
+ run('Set default org for schema', 'sf', ['config', 'set', 'target-org', targetOrg, '--global']);
266
+ run('GraphQL schema (introspect)', 'npm', ['run', 'graphql:schema'], { cwd: webappDir });
267
+ run('GraphQL codegen', 'npm', ['run', 'graphql:codegen'], { cwd: webappDir });
268
+ }
269
+
270
+ if (!skipWebappBuild) {
271
+ run('Web app build', 'npm', ['run', 'build'], { cwd: webappDir });
272
+ }
273
+
274
+ console.log('\n--- Setup complete ---');
275
+
276
+ if (!skipDev) {
277
+ console.log('\n--- Launching dev server (Ctrl+C to stop) ---\n');
278
+ run('Dev server', 'npm', ['run', 'dev'], { cwd: webappDir });
279
+ }
280
+ }
281
+
282
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-app-react-template-b2x-experimental",
3
- "version": "1.83.0",
3
+ "version": "1.84.1",
4
4
  "description": "Base reference app template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",