@salesforce/webapp-template-feature-react-file-upload-experimental 1.106.1 → 1.107.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.
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: salesforce-data-access
2
+ name: accessing-data
3
3
  description: Salesforce data access patterns. Use when adding or modifying any code that fetches data from Salesforce (records, Chatter, Connect API, etc.).
4
4
  paths:
5
5
  - "**/*.ts"
@@ -42,7 +42,7 @@ For GraphQL, if `sdk.graphql` is undefined, the call returns `undefined` — han
42
42
  - Creating, updating, or deleting records (when GraphQL supports the operation)
43
43
  - Fetching related data, filters, sorting, pagination
44
44
 
45
- **Use `sdk.fetch` only when GraphQL is not sufficient.** For REST API usage, invoke the `salesforce-rest-api-fetch` skill, which documents:
45
+ **Use `sdk.fetch` only when GraphQL is not sufficient.** For REST API usage, invoke the `fetching-rest-api` skill, which documents:
46
46
 
47
47
  - Chatter API (e.g., `/services/data/v65.0/chatter/users/me`)
48
48
  - Connect REST API (e.g., `/services/data/v65.0/connect/file/upload/config`)
@@ -64,7 +64,7 @@ const sdk = await createDataSDK();
64
64
 
65
65
  ## Example 1: GraphQL (Preferred)
66
66
 
67
- For record queries and mutations, use GraphQL via the Data SDK. Invoke the `salesforce-graphql` skill for the full workflow (schema exploration, query authoring, codegen, lint validate).
67
+ For record queries and mutations, use GraphQL via the Data SDK. Invoke the `using-graphql` skill for the full workflow (schema exploration, query authoring, codegen, lint validate).
68
68
 
69
69
  ```typescript
70
70
  import { createDataSDK, gql } from "@salesforce/sdk-data";
@@ -103,7 +103,7 @@ export async function getAccounts() {
103
103
 
104
104
  ## Example 2: Fetch (When GraphQL Is Not Sufficient)
105
105
 
106
- For REST endpoints that have no GraphQL equivalent, use `sdk.fetch`. **Invoke the `salesforce-rest-api-fetch` skill** for full documentation of Chatter, Connect REST, Apex REST, UI API REST, and Einstein LLM endpoints.
106
+ For REST endpoints that have no GraphQL equivalent, use `sdk.fetch`. **Invoke the `fetching-rest-api` skill** for full documentation of Chatter, Connect REST, Apex REST, UI API REST, and Einstein LLM endpoints.
107
107
 
108
108
  ```typescript
109
109
  import { createDataSDK } from "@salesforce/sdk-data";
@@ -151,15 +151,15 @@ const res = await sdk.fetch?.("/services/data/v65.0/chatter/users/me");
151
151
 
152
152
  ## Decision Flow
153
153
 
154
- 1. **Need to query or mutate Salesforce records?** → Use GraphQL via the Data SDK. Invoke the `salesforce-graphql` skill.
155
- 2. **Need Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM?** → Use `sdk.fetch`. Invoke the `salesforce-rest-api-fetch` skill.
154
+ 1. **Need to query or mutate Salesforce records?** → Use GraphQL via the Data SDK. Invoke the `using-graphql` skill.
155
+ 2. **Need Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM?** → Use `sdk.fetch`. Invoke the `fetching-rest-api` skill.
156
156
  3. **Never** use `fetch`, `axios`, or similar directly for Salesforce API calls.
157
157
 
158
158
  ---
159
159
 
160
160
  ## Reference
161
161
 
162
- - GraphQL workflow: invoke the `salesforce-graphql` skill (`.a4drules/skills/salesforce-graphql/`)
163
- - REST API via fetch: invoke the `salesforce-rest-api-fetch` skill (`.a4drules/skills/salesforce-rest-api-fetch/`)
162
+ - GraphQL workflow: invoke the `using-graphql` skill (`.a4drules/skills/using-graphql/`)
163
+ - REST API via fetch: invoke the `fetching-rest-api` skill (`.a4drules/skills/fetching-rest-api/`)
164
164
  - Data SDK package: `@salesforce/sdk-data` (`createDataSDK`, `gql`, `NodeOfConnection`)
165
165
  - `createRecord` for UI API record creation: `@salesforce/webapp-experimental/api` (uses Data SDK internally)
@@ -1,7 +1,6 @@
1
-
2
1
  ---
3
- paths:
4
- - "**/webapplications/**/*"
2
+ name: configuring-webapp-metadata
3
+ description: Rules for web application metadata structure, webapplication.json configuration, and bundle organization
5
4
  ---
6
5
 
7
6
  # WebApplication Requirements
@@ -1,4 +1,5 @@
1
1
  ---
2
+ name: creating-webapp
2
3
  description: Core web application rules for SFDX React apps
3
4
  paths:
4
5
  - "**/webapplications/**/*"
@@ -81,7 +82,7 @@ Agents consistently miss these. **You must not leave them default.**
81
82
 
82
83
  # Shell Command Safety (MUST FOLLOW)
83
84
 
84
- **Never use complex `node -e` one-liners** for file edits or multi-line transforms. They break in Zsh due to `!` history expansion and backtick interpolation. Use a temporary `.js` file, `sed`/`awk`, `jq`, or IDE file-editing tools instead. See **webapp-cli-commands.md** for full details and approved alternatives.
85
+ **Never use complex `node -e` one-liners** for file edits or multi-line transforms. They break in Zsh due to `!` history expansion and backtick interpolation. Use a temporary `.js` file, `sed`/`awk`, `jq`, or IDE file-editing tools instead.
85
86
 
86
87
  # Development Cycle
87
88
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: salesforce-graphql-explore-schema
2
+ name: exploring-graphql-schema
3
3
  description: Explore the Salesforce GraphQL schema via grep-only lookups. Use before generating any GraphQL query — schema exploration must complete first.
4
4
  paths:
5
5
  - "**/*.ts"
@@ -125,7 +125,7 @@ Salesforce GraphQL returns field values wrapped in typed objects:
125
125
  2. **Run the "Find Available Fields" grep command** for your object (copy only the field names visible in the grep output; do not open the file)
126
126
  3. **Run the "Find Filter Options" grep command** (`<Object>_Filter`) to understand filtering options
127
127
  4. **Run the "Find OrderBy Options" grep command** (`<Object>_OrderBy`) for sorting capabilities
128
- 5. **Build the query** following the patterns in the `salesforce-graphql-read-query` or `salesforce-graphql-mutation-query` skill using only values returned by grep
128
+ 5. **Build the query** following the patterns in the `generating-graphql-read-query` or `generating-graphql-mutation-query` skill using only values returned by grep
129
129
  6. **Validate field names** using grep matches (case-sensitive). Do not open or parse the file beyond grep.
130
130
 
131
131
  ## Tips for Agents
@@ -156,5 +156,5 @@ If any of the above occurs, stop and replace the action with one of the Allowed
156
156
 
157
157
  ## Related Skills
158
158
 
159
- - For generating read queries, invoke the `salesforce-graphql-read-query` skill
160
- - For generating mutation queries, invoke the `salesforce-graphql-mutation-query` skill
159
+ - For generating read queries, invoke the `generating-graphql-read-query` skill
160
+ - For generating mutation queries, invoke the `generating-graphql-mutation-query` skill
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: salesforce-rest-api-fetch
2
+ name: fetching-rest-api
3
3
  description: REST API usage via the Data SDK fetch method. Use when implementing Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM calls — only when GraphQL is not sufficient.
4
4
  paths:
5
5
  - "**/*.ts"
@@ -162,6 +162,6 @@ const data = await response.json();
162
162
 
163
163
  ## Reference
164
164
 
165
- - Parent: `salesforce-data-access` — enforces Data SDK usage for all Salesforce data fetches
166
- - GraphQL: `salesforce-graphql` — use for record queries and mutations when possible
165
+ - Parent: `accessing-data` — enforces Data SDK usage for all Salesforce data fetches
166
+ - GraphQL: `using-graphql` — use for record queries and mutations when possible
167
167
  - `createRecord` from `@salesforce/webapp-experimental/api` for UI API record creation (uses SDK internally)
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: salesforce-graphql-mutation-query
3
- description: Generate Salesforce GraphQL mutation queries. Use when the query to generate is a mutation query. Schema exploration must complete first — invoke salesforce-graphql-explore-schema first.
2
+ name: generating-graphql-mutation-query
3
+ description: Generate Salesforce GraphQL mutation queries. Use when the query to generate is a mutation query. Schema exploration must complete first — invoke exploring-graphql-schema first.
4
4
  paths:
5
5
  - "**/*.ts"
6
6
  - "**/*.tsx"
@@ -11,16 +11,16 @@ paths:
11
11
 
12
12
  **Triggering conditions**
13
13
 
14
- 1. Only if the schema exploration phase completed successfully (invoke `salesforce-graphql-explore-schema` first)
14
+ 1. Only if the schema exploration phase completed successfully (invoke `exploring-graphql-schema` first)
15
15
  2. Only if the query to generate is a mutation query
16
16
 
17
17
  ## Schema Access Policy
18
18
 
19
- > ⚠️ **GREP ONLY** — During mutation generation you may need to verify field names, input types, or representations. All schema lookups **MUST** use the grep-only commands defined in the `salesforce-graphql-explore-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
19
+ > ⚠️ **GREP ONLY** — During mutation generation you may need to verify field names, input types, or representations. All schema lookups **MUST** use the grep-only commands defined in the `exploring-graphql-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
20
20
 
21
21
  ## Your Role
22
22
 
23
- You are a GraphQL expert. Generate Salesforce-compatible mutation queries. Schema exploration must complete first. If the schema exploration has not been executed yet, you **MUST** run the full exploration workflow from the `salesforce-graphql-explore-schema` skill first, then return here for mutation query generation.
23
+ You are a GraphQL expert. Generate Salesforce-compatible mutation queries. Schema exploration must complete first. If the schema exploration has not been executed yet, you **MUST** run the full exploration workflow from the `exploring-graphql-schema` skill first, then return here for mutation query generation.
24
24
 
25
25
  ## Mutation Queries General Information
26
26
 
@@ -186,7 +186,7 @@ npx eslint <path-to-file-containing-mutation>
186
186
 
187
187
  **On failure:** Fix the reported issues, re-run `npx eslint <file>` until clean, then proceed to testing.
188
188
 
189
- > ⚠️ **Prerequisites**: The `schema.graphql` file must exist (invoke `salesforce-graphql-explore-schema` first) and project dependencies must be installed (`npm install`).
189
+ > ⚠️ **Prerequisites**: The `schema.graphql` file must exist (invoke `exploring-graphql-schema` first) and project dependencies must be installed (`npm install`).
190
190
 
191
191
  ## Generated Mutation Query Testing
192
192
 
@@ -234,12 +234,12 @@ The query is invalid:
234
234
  3. **Targeted Resolution** - Depending on the root cause categorization
235
235
  - **Execution** - You're trying to update or delete an unknown/no longer available entity: either create an entity first, if you have generated the related query, or ask for a valid entity id to use. **STOP and WAIT** for the user to provide a valid Id
236
236
  - **Syntax** - Update the query using the error message information to fix the syntax errors
237
- - **Validation** - The field name is most probably invalid. Re-run the relevant grep command from the `salesforce-graphql-explore-schema` skill to verify the correct field name. If still unclear, ask the user for clarification and **STOP and WAIT** for their answer
237
+ - **Validation** - The field name is most probably invalid. Re-run the relevant grep command from the `exploring-graphql-schema` skill to verify the correct field name. If still unclear, ask the user for clarification and **STOP and WAIT** for their answer
238
238
  - **Type** - Use the error details and re-verify the type via grep lookup in the schema. Correct the argument type and adjust variables accordingly
239
239
  - **Navigation** - Use the [`PARTIAL` status handling workflow](#partial-status-handling-workflow) below
240
240
  - **API Version** - `Record` selection is only available with API version 64 and higher, **report** the issue, and try again with API version 64
241
241
  4. **Test Again** - Resume the [query testing workflow](#generated-mutation-query-testing) with the updated query (increment and track attempt counter)
242
- 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow from the `salesforce-graphql-explore-schema` skill
242
+ 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow from the `exploring-graphql-schema` skill
243
243
 
244
244
  ### `PARTIAL` Status Handling Workflow
245
245
 
@@ -254,5 +254,5 @@ The query can be improved:
254
254
 
255
255
  ## Related Skills
256
256
 
257
- - Schema exploration: `salesforce-graphql-explore-schema` (must complete first)
258
- - Read query generation: `salesforce-graphql-read-query`
257
+ - Schema exploration: `exploring-graphql-schema` (must complete first)
258
+ - Read query generation: `generating-graphql-read-query`
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: salesforce-graphql-read-query
3
- description: Generate Salesforce GraphQL read queries. Use when the query to generate is a read query. Schema exploration must complete first — invoke salesforce-graphql-explore-schema first.
2
+ name: generating-graphql-read-query
3
+ description: Generate Salesforce GraphQL read queries. Use when the query to generate is a read query. Schema exploration must complete first — invoke exploring-graphql-schema first.
4
4
  paths:
5
5
  - "**/*.ts"
6
6
  - "**/*.tsx"
@@ -11,12 +11,12 @@ paths:
11
11
 
12
12
  **Triggering conditions**
13
13
 
14
- 1. Only if the schema exploration phase completed successfully (invoke `salesforce-graphql-explore-schema` first)
14
+ 1. Only if the schema exploration phase completed successfully (invoke `exploring-graphql-schema` first)
15
15
  2. Only if the query to generate is a read query
16
16
 
17
17
  ## Schema Access Policy
18
18
 
19
- > ⚠️ **GREP ONLY** — During query generation you may need to verify field names, types, or relationships. All schema lookups **MUST** use the grep-only commands defined in the `salesforce-graphql-explore-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
19
+ > ⚠️ **GREP ONLY** — During query generation you may need to verify field names, types, or relationships. All schema lookups **MUST** use the grep-only commands defined in the `exploring-graphql-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
20
20
 
21
21
  ## Field-Level Security and @optional
22
22
 
@@ -35,7 +35,7 @@ const name = node.Name.value;
35
35
 
36
36
  ## Your Role
37
37
 
38
- You are a GraphQL expert. Generate Salesforce-compatible read queries. Schema exploration must complete first. If the schema exploration has not been executed yet, you **MUST** run the full exploration workflow from the `salesforce-graphql-explore-schema` skill first, then return here for read query generation.
38
+ You are a GraphQL expert. Generate Salesforce-compatible read queries. Schema exploration must complete first. If the schema exploration has not been executed yet, you **MUST** run the full exploration workflow from the `exploring-graphql-schema` skill first, then return here for read query generation.
39
39
 
40
40
  ## Read Query Generation Workflow
41
41
 
@@ -202,7 +202,7 @@ npx eslint <path-to-file-containing-query>
202
202
 
203
203
  **On failure:** Fix the reported issues, re-run `npx eslint <file>` until clean, then proceed to testing.
204
204
 
205
- > ⚠️ **Prerequisites**: The `schema.graphql` file must exist (invoke `salesforce-graphql-explore-schema` first) and project dependencies must be installed (`npm install`).
205
+ > ⚠️ **Prerequisites**: The `schema.graphql` file must exist (invoke `exploring-graphql-schema` first) and project dependencies must be installed (`npm install`).
206
206
 
207
207
  ## Generated Read Query Testing
208
208
 
@@ -242,12 +242,12 @@ The query is invalid:
242
242
  - **Type** - Error contains `VariableTypeMismatch` or `UnknownType`
243
243
  3. **Targeted Resolution** - Depending on the root cause categorization
244
244
  - **Syntax** - Update the query using the error message information to fix the syntax errors
245
- - **Validation** - The field name is most probably invalid. Re-run the relevant grep command from the `salesforce-graphql-explore-schema` skill to verify the correct field name. If still unclear, ask the user for clarification and **STOP and WAIT** for their answer
245
+ - **Validation** - The field name is most probably invalid. Re-run the relevant grep command from the `exploring-graphql-schema` skill to verify the correct field name. If still unclear, ask the user for clarification and **STOP and WAIT** for their answer
246
246
  - **Type** - Use the error details and re-verify the type via grep lookup in the schema. Correct the argument type and adjust variables accordingly
247
247
  4. **Test Again** - Resume the [query testing workflow](#generated-read-query-testing) with the updated query (increment and track attempt counter)
248
- 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow from the `salesforce-graphql-explore-schema` skill
248
+ 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow from the `exploring-graphql-schema` skill
249
249
 
250
250
  ## Related Skills
251
251
 
252
- - Schema exploration: `salesforce-graphql-explore-schema` (must complete first)
253
- - Mutation generation: `salesforce-graphql-mutation-query`
252
+ - Schema exploration: `exploring-graphql-schema` (must complete first)
253
+ - Mutation generation: `generating-graphql-mutation-query`
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: salesforce-graphql
2
+ name: using-graphql
3
3
  description: Salesforce GraphQL data access. Use when the user asks to fetch, query, or mutate Salesforce data, or add a GraphQL operation for an object like Account, Contact, or Opportunity.
4
4
  paths:
5
5
  - "**/*.ts"
@@ -20,7 +20,7 @@ Guidance for querying and mutating Salesforce data via the Salesforce GraphQL AP
20
20
 
21
21
  ## Schema Access Policy (GREP ONLY)
22
22
 
23
- > **GREP ONLY** — The `schema.graphql` file is very large (~265,000+ lines). All schema lookups **MUST** use the grep-only commands defined in the `salesforce-graphql-explore-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
23
+ > **GREP ONLY** — The `schema.graphql` file is very large (~265,000+ lines). All schema lookups **MUST** use the grep-only commands defined in the `exploring-graphql-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
24
24
 
25
25
  ## Directory Context
26
26
 
@@ -80,9 +80,9 @@ Ensure `schema.graphql` exists at the project root. If missing, run `npm run gra
80
80
 
81
81
  Before writing any query, verify the target object and its fields exist in the schema.
82
82
 
83
- **Invoke the `salesforce-graphql-explore-schema` skill** for the full exploration workflow and **mandatory grep-only access policy**.
83
+ **Invoke the `exploring-graphql-schema` skill** for the full exploration workflow and **mandatory grep-only access policy**.
84
84
 
85
- > **GREP ONLY** — All schema lookups MUST use the grep commands defined in the `salesforce-graphql-explore-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
85
+ > **GREP ONLY** — All schema lookups MUST use the grep commands defined in the `exploring-graphql-schema` skill. Do NOT open, read, stream, or parse `./schema.graphql` with any tool other than grep.
86
86
 
87
87
  Key actions (all via grep):
88
88
 
@@ -113,8 +113,8 @@ For **Pattern 1**:
113
113
 
114
114
  1. Create a `.graphql` file under `src/api/utils/query/`
115
115
  2. Follow UIAPI structure: `query { uiapi { query { ObjectName(...) { edges { node { ... } } } } } }`
116
- 3. For mutations, invoke the `salesforce-graphql-mutation-query` skill
117
- 4. For read queries, invoke the `salesforce-graphql-read-query` skill
116
+ 3. For mutations, invoke the `generating-graphql-mutation-query` skill
117
+ 4. For read queries, invoke the `generating-graphql-read-query` skill
118
118
 
119
119
  For **Pattern 2**:
120
120
 
@@ -123,7 +123,7 @@ For **Pattern 2**:
123
123
 
124
124
  ### Step 5: Test Queries Against Live Org
125
125
 
126
- Use the testing workflows in the `salesforce-graphql-read-query` and `salesforce-graphql-mutation-query` skills to validate queries against the connected org before integrating into the app.
126
+ Use the testing workflows in the `generating-graphql-read-query` and `generating-graphql-mutation-query` skills to validate queries against the connected org before integrating into the app.
127
127
 
128
128
  ### Step 6: Generate Types
129
129
 
@@ -284,7 +284,7 @@ Before completing GraphQL data access code:
284
284
 
285
285
  ### For Pattern 1 (.graphql files):
286
286
 
287
- 1. [ ] All field names verified via grep against `schema.graphql` (invoke `salesforce-graphql-explore-schema`)
287
+ 1. [ ] All field names verified via grep against `schema.graphql` (invoke `exploring-graphql-schema`)
288
288
  2. [ ] Create `.graphql` file for the query/mutation
289
289
  3. [ ] Run `npm run graphql:codegen` to generate types
290
290
  4. [ ] Import query with `?raw` suffix
@@ -315,9 +315,9 @@ Before completing GraphQL data access code:
315
315
 
316
316
  ## Reference
317
317
 
318
- - Schema exploration: invoke the `salesforce-graphql-explore-schema` skill
319
- - Read query generation: invoke the `salesforce-graphql-read-query` skill
320
- - Mutation query generation: invoke the `salesforce-graphql-mutation-query` skill
318
+ - Schema exploration: invoke the `exploring-graphql-schema` skill
319
+ - Read query generation: invoke the `generating-graphql-read-query` skill
320
+ - Mutation query generation: invoke the `generating-graphql-mutation-query` skill
321
321
  - Shared GraphQL schema types: `shared-schema.graphqls` (in this skill directory)
322
322
  - Schema download: `npm run graphql:schema` (run from webapp dir)
323
323
  - Type generation: `npm run graphql:codegen` (run from webapp dir)
@@ -0,0 +1,28 @@
1
+ ---
2
+ description: Code quality and build validation standards
3
+ paths:
4
+ - "**/webapplications/**/*"
5
+ ---
6
+
7
+ # Code Quality & Build Validation
8
+
9
+ Enforces ESLint, TypeScript, and build validation for consistent, maintainable code.
10
+
11
+ ## MANDATORY Quality Gates
12
+
13
+ **Before completing any coding session** (from the web app directory `force-app/main/default/webapplications/<appName>/`):
14
+
15
+ ```bash
16
+ npm run lint # MUST result in 0 errors
17
+ npm run build # MUST succeed (includes TypeScript check)
18
+ npm run graphql:codegen # MUST succeed (verifies graphql queries)
19
+ ```
20
+
21
+ **Must Pass:**
22
+ - `npm run build` completes successfully
23
+ - No TypeScript compilation errors
24
+ - No critical ESLint errors (0 errors)
25
+
26
+ **Can Be Warnings:**
27
+ - ESLint warnings (fix when convenient)
28
+ - Minor TypeScript warnings
@@ -4,79 +4,12 @@ paths:
4
4
  - "**/webapplications/**/*"
5
5
  ---
6
6
 
7
- # TypeScript Standards
8
-
9
- ## MANDATORY Configuration
10
- - `strict: true` - Enable all strict type checking
11
- - `noUncheckedIndexedAccess: true` - Prevent unsafe array/object access
12
- - `noUnusedLocals: true` - Report unused variables
13
- - `noUnusedParameters: true` - Report unused parameters
14
-
15
- ## Function Return Types (REQUIRED)
16
- ```typescript
17
- // Always specify return types
18
- function fetchUserData(id: string): Promise<User> {
19
- return api.get(`/users/${id}`);
20
- }
21
-
22
- const calculateTotal = (items: Item[]): number => {
23
- return items.reduce((sum, item) => sum + item.price, 0);
24
- };
25
- ```
26
-
27
- ## Interface Definitions (REQUIRED)
28
- ```typescript
29
- // Data structures
30
- interface User {
31
- id: string;
32
- name: string;
33
- email: string;
34
- createdAt: Date;
35
- }
36
-
37
- // React component props
38
- interface ButtonProps {
39
- variant: 'primary' | 'secondary';
40
- onClick: () => void;
41
- disabled?: boolean;
42
- children: React.ReactNode;
43
- }
44
-
45
- export const Button: React.FC<ButtonProps> = ({ variant, onClick, disabled, children }) => {
46
- // Implementation
47
- };
48
- ```
49
-
50
7
  ## Type Safety Rules
51
8
 
52
9
  ### Never Use `any`
53
10
  ```typescript
54
11
  // FORBIDDEN
55
12
  const data: any = await fetchData();
56
-
57
- // REQUIRED: Proper typing
58
- interface ApiResponse {
59
- data: User[];
60
- status: 'success' | 'error';
61
- }
62
- const response: ApiResponse = await fetchData();
63
-
64
- // ACCEPTABLE: Unknown when type is truly unknown
65
- const parseJson = (input: string): unknown => JSON.parse(input);
66
- ```
67
-
68
- ### Null Safety
69
- ```typescript
70
- // Handle null/undefined explicitly
71
- interface UserProfile {
72
- user: User | null;
73
- loading: boolean;
74
- error: string | null;
75
- }
76
-
77
- // Use optional chaining and nullish coalescing
78
- const displayName = user?.name ?? 'Anonymous';
79
- const avatarUrl = user?.profile?.avatar ?? '/default-avatar.png';
80
13
  ```
81
14
 
82
15
  ## React TypeScript Patterns
@@ -86,53 +19,12 @@ const avatarUrl = user?.profile?.avatar ?? '/default-avatar.png';
86
19
  const handleSubmit = (event: React.FormEvent<HTMLFormElement>): void => {
87
20
  event.preventDefault();
88
21
  };
89
-
90
- const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
91
- setInputValue(event.target.value);
92
- };
93
-
94
- const handleClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
95
- console.log('Button clicked');
96
- };
97
22
  ```
98
23
 
99
24
  ### State and Hooks
100
25
  ```typescript
101
26
  // Type useState properly
102
27
  const [user, setUser] = useState<User | null>(null);
103
- const [loading, setLoading] = useState<boolean>(false);
104
- const [errors, setErrors] = useState<string[]>([]);
105
-
106
- // Type custom hooks
107
- interface UseApiResult<T> {
108
- data: T | null;
109
- loading: boolean;
110
- error: string | null;
111
- refetch: () => Promise<void>;
112
- }
113
-
114
- function useApi<T>(url: string): UseApiResult<T> {
115
- const [data, setData] = useState<T | null>(null);
116
- const [loading, setLoading] = useState<boolean>(false);
117
- const [error, setError] = useState<string | null>(null);
118
-
119
- return { data, loading, error, refetch };
120
- }
121
- ```
122
-
123
- ## API Types
124
-
125
- ### Salesforce Records
126
- ```typescript
127
- interface SalesforceRecord {
128
- Id: string;
129
- attributes: { type: string; url: string };
130
- }
131
-
132
- interface Account extends SalesforceRecord {
133
- Name: { value: string };
134
- Industry?: { value: string | null };
135
- }
136
28
  ```
137
29
 
138
30
  ### GraphQL via DataSDK
@@ -143,24 +35,6 @@ See **webapp-react.md** for DataSDK usage patterns. Type your GraphQL responses:
143
35
  const response = await sdk.graphql?.<GetAccountsQuery>(QUERY, variables);
144
36
  ```
145
37
 
146
- ## Error Handling Types
147
- ```typescript
148
- interface ApiError {
149
- message: string;
150
- status: number;
151
- code?: string;
152
- }
153
-
154
- class CustomError extends Error {
155
- constructor(message: string, public readonly status: number, public readonly code?: string) {
156
- super(message);
157
- this.name = 'CustomError';
158
- }
159
- }
160
- ```
161
-
162
- ## Anti-Patterns (FORBIDDEN)
163
-
164
38
  ### Type Assertions
165
39
  ```typescript
166
40
  // FORBIDDEN: Unsafe assertions
@@ -175,31 +49,3 @@ if (isUser(data)) {
175
49
  console.log(data.name); // Now safely typed
176
50
  }
177
51
  ```
178
-
179
- ### Missing Return Types
180
- ```typescript
181
- // FORBIDDEN: No return type
182
- const fetchData = async (id: string) => {
183
- return await api.get(`/data/${id}`);
184
- };
185
-
186
- // REQUIRED: Explicit return type
187
- const fetchData = async (id: string): Promise<ApiResponse> => {
188
- return await api.get(`/data/${id}`);
189
- };
190
- ```
191
-
192
- ## Quality Checklist
193
- Before completing TypeScript code:
194
- 1. All functions have explicit return types
195
- 2. All interfaces are properly defined
196
- 3. No `any` types used (use `unknown` if necessary)
197
- 4. Null/undefined handling is explicit
198
- 5. React components are properly typed
199
- 6. API calls have proper type definitions
200
- 7. `tsc -b` compiles without errors
201
-
202
- ## Enforcement
203
- - TypeScript errors MUST be fixed before any commit
204
- - NEVER disable TypeScript strict mode
205
- - Code reviews MUST check for proper typing
@@ -6,149 +6,29 @@ paths:
6
6
 
7
7
  # React Web App (SFDX)
8
8
 
9
- React-specific guidelines for data access, component library, and Salesforce integration.
10
-
11
9
  For layout, navigation, and generation rules, see **webapp.md**.
12
10
 
13
- ## Project Structure
14
-
15
- - Web app root: `force-app/main/default/webapplications/<appName>/`
16
- - Entry: `src/app.tsx`
17
- - Layout shell: `src/appLayout.tsx`
18
- - Dev server: `npm run dev`
19
- - Build: `npm run build`
20
-
21
11
  ## Routing (React Router)
22
12
 
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
-
30
- ## Component Library (MANDATORY)
31
-
32
- Use **shadcn/ui** for UI components:
33
-
34
- ```typescript
35
- import { Button } from '@/components/ui/button';
36
- import { Card, CardHeader, CardContent } from '@/components/ui/card';
37
- import { Input } from '@/components/ui/input';
38
- ```
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 **designing-webapp-ui-ux** skill (`.a4drules/skills/designing-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.”
13
+ 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`.
63
14
 
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
-
76
- ## Styling
15
+ ## Component Library + Styling (MANDATORY)
77
16
 
17
+ - Use **shadcn/ui** for UI components: `import { Button } from '@/components/ui/button';`
78
18
  - Use **Tailwind CSS** utility classes
79
- - Follow consistent spacing, color, and typography conventions
80
19
 
81
20
  ## Module & Platform Restrictions
82
21
 
83
- React apps must NOT import Salesforce platform modules:
84
-
85
- - ❌ `@salesforce/*` (except `@salesforce/sdk-data`)
86
- - ❌ `lightning/*`
87
- - ❌ `@wire` (LWC-only)
88
-
89
- Use standard web APIs and npm packages only.
22
+ React apps must NOT import Salesforce platform modules like `lightning/*` or `@wire` (LWC-only)
90
23
 
91
24
  ## Data Access (CRITICAL)
92
25
 
93
- For all Salesforce data access (GraphQL, REST, Chatter, Connect, Apex REST, UI API, Einstein LLM), invoke the **`salesforce-data-access`** skill (`.a4drules/skills/salesforce-data-access/`). It enforces Data SDK usage, GraphQL-first preference, optional chaining, and documents when to use `sdk.fetch` via the `salesforce-rest-api-fetch` skill.
94
-
95
- ## Error Handling
96
-
97
- ```typescript
98
- async function safeFetch<T>(fn: () => Promise<T>): Promise<T> {
99
- try {
100
- return await fn();
101
- } catch (err) {
102
- console.error('API Error:', err);
103
- throw err;
104
- }
105
- }
106
- ```
107
-
108
- ### Authentication Errors
109
-
110
- On 401/403 response, trigger page refresh to redirect to login:
111
- ```typescript
112
- window.location.reload();
113
- ```
114
-
115
- ## Security Standards
116
-
117
- - Validate user permissions before data operations
118
- - Respect record sharing rules and field-level security
119
- - Never hardcode credentials or secrets
120
- - Sanitize all user inputs
121
- - Use HTTPS for all API calls
122
-
123
- ## Performance
124
-
125
- - Use React Query or RTK Query for caching API data
126
- - Use `React.memo`, `useMemo`, `useCallback` where appropriate
127
- - Implement loading and error states
26
+ For all Salesforce data access (GraphQL, REST, Chatter, Connect, Apex REST, UI API, Einstein LLM), invoke the **`accessing-data`** skill (`.a4drules/skills/accessing-data/`). It enforces Data SDK usage, GraphQL-first preference, optional chaining, and documents when to use `sdk.fetch` via the `fetching-rest-api` skill.
128
27
 
129
- ## Anti-Patterns (FORBIDDEN)
28
+ ### GraphQL (Preferred)
130
29
 
131
- - Calling Apex REST from React
132
- - ❌ Using `axios` or raw `fetch` for Salesforce APIs
133
- - ❌ Direct DOM manipulation in React
134
- - ❌ Using LWC patterns (`@wire`, LDS) in React
135
- - ❌ Hardcoded Salesforce IDs or URLs
136
- - ❌ Missing error handling for async operations
137
- - ❌ 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
138
- - ❌ Using emojis anywhere in the app (labels, icons, empty states, headings, tooltips)
139
- - ❌ Using any icon library other than **lucide-react** (no Heroicons, react-icons, or emoji-as-icon)
140
- - ❌ Outputting or pasting raw HTML when editing UI — always edit the React/TSX source files (e.g. `Home.tsx`, `appLayout.tsx`, feature components)
141
- - ❌ Adding a hamburger or Menu icon for mobile nav without implementing toggle state, conditional menu panel, and close-on-navigate
30
+ For queries and mutations, invoke the **`using-graphql`** skill (`.a4drules/skills/using-graphql/`). It covers schema exploration, query patterns, codegen, type generation, and guardrails.
142
31
 
143
- ## Quality Checklist
32
+ ### UI API (Fallback)
144
33
 
145
- - [ ] Entry point maintained (`app.tsx`)
146
- - [ ] Uses shadcn/ui and Tailwind
147
- - [ ] Icons from **lucide-react** only; no emojis anywhere in UI or user-facing text
148
- - [ ] UI changes made by editing .tsx source files (never by pasting raw HTML)
149
- - [ ] If mobile hamburger exists: it has toggle state, conditional menu panel, and close on link click
150
- - [ ] All routing imports from same package as router (e.g. `react-router` only)
151
- - [ ] DataSDK used for all Salesforce API calls
152
- - [ ] Proper error handling with try/catch
153
- - [ ] Loading and error states implemented
154
- - [ ] No hardcoded credentials or IDs
34
+ When GraphQL cannot cover the use case, use `sdk.fetch?.()` for UI API endpoints. See the **`fetching-rest-api`** skill (`.a4drules/skills/fetching-rest-api/`) for full REST API documentation.
@@ -6,10 +6,7 @@ paths:
6
6
 
7
7
  # Skills-First Protocol (MUST FOLLOW)
8
8
 
9
- **Before writing any code or executing any command**, search for relevant skills that may already provide guidance, patterns, or step-by-step instructions for the task at hand.
10
-
11
- ## Core Directive
12
- Before planning, executing a task, generating code, or running terminal commands, you MUST explicitly check if an existing Skill is available to handle the request. Do not default to manual implementation if a specialized domain Skill exists.
9
+ **Before planning, executing any task, generating code, or running terminal commands**, you MUST explicitly check if an existing Skill is available to handle the request. Do not default to manual implementation if a specialized domain Skill exists.
13
10
 
14
11
  ## Pre-Task Sequence
15
12
  1. **Skill Discovery:** Review the names and descriptions of all available/loaded Skills in your current context.
package/dist/AGENT.md CHANGED
@@ -58,9 +58,9 @@ cd <sfdx-source>/webapplications/<appName>
58
58
 
59
59
  This project includes **.a4drules/** at the project root. Follow them when generating or editing code.
60
60
 
61
- - **Salesforce Data Access** (`.a4drules/skills/salesforce-data-access/`): Use for all Salesforce data fetches. Enforces Data SDK usage (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`); GraphQL preferred, fetch when GraphQL is not sufficient.
62
- - **Salesforce REST API Fetch** (`.a4drules/skills/salesforce-rest-api-fetch/`): Use when implementing Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM calls via `sdk.fetch`.
63
- - **Salesforce GraphQL** (`.a4drules/skills/salesforce-graphql/`): Use when implementing Salesforce GraphQL queries or mutations. Sub-skills: `salesforce-graphql-explore-schema`, `salesforce-graphql-read-query`, `salesforce-graphql-mutation-query`.
61
+ - **Accessing Data** (`.a4drules/skills/accessing-data/`): Use for all Salesforce data fetches. Enforces Data SDK usage (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`); GraphQL preferred, fetch when GraphQL is not sufficient.
62
+ - **Fetching REST API** (`.a4drules/skills/fetching-rest-api/`): Use when implementing Chatter, Connect REST, Apex REST, UI API REST, or Einstein LLM calls via `sdk.fetch`.
63
+ - **Using GraphQL** (`.a4drules/skills/using-graphql/`): Use when implementing Salesforce GraphQL queries or mutations. Sub-skills: `exploring-graphql-schema`, `generating-graphql-read-query`, `generating-graphql-mutation-query`.
64
64
 
65
65
  When rules refer to "web app directory" or `<sfdx-source>/webapplications/<appName>/`, resolve `<sfdx-source>` from `sfdx-project.json` and use the **actual app folder name** for this project.
66
66
 
@@ -83,4 +83,4 @@ sf project deploy start --source-dir <packageDir> --target-org <alias>
83
83
 
84
84
  - **UI**: shadcn/ui + Tailwind. Import from `@/components/ui/...`.
85
85
  - **Entry**: Keep `App.tsx` and routes in `src/`; add features as new routes or sections, don't replace the app shell but you may modify it to match the requested design.
86
- - **Data (Salesforce)**: Invoke the `salesforce-data-access` skill for all Salesforce data fetches. The skill enforces use of the Data SDK (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`) — never use `fetch` or `axios` directly. GraphQL is preferred; use `sdk.fetch` when GraphQL is not sufficient (e.g., Chatter, Connect REST). For GraphQL implementation, invoke the `salesforce-graphql` skill.
86
+ - **Data (Salesforce)**: Invoke the `accessing-data` skill for all Salesforce data fetches. The skill enforces use of the Data SDK (`createDataSDK()` + `sdk.graphql` or `sdk.fetch`) — never use `fetch` or `axios` directly. GraphQL is preferred; use `sdk.fetch` when GraphQL is not sufficient (e.g., Chatter, Connect REST). For GraphQL implementation, invoke the `using-graphql` skill.
package/dist/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
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.107.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.106.2...v1.107.0) (2026-03-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * **template:** add sf-project-setup command at SFDX project root ([#301](https://github.com/salesforce-experience-platform-emu/webapps/issues/301)) ([5a187cd](https://github.com/salesforce-experience-platform-emu/webapps/commit/5a187cd2faeadcab6c8f206d8c110c29763983ec))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.106.2](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.106.1...v1.106.2) (2026-03-17)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * attempt to make rules more concise ([#298](https://github.com/salesforce-experience-platform-emu/webapps/issues/298)) ([69b3dab](https://github.com/salesforce-experience-platform-emu/webapps/commit/69b3dab574caf140e549ef092fa8b8ac1819afd8))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [1.106.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.106.0...v1.106.1) (2026-03-17)
7
29
 
8
30
 
package/dist/README.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  Now that you’ve created a Salesforce DX project, what’s next? Here are some documentation resources to get you started.
4
4
 
5
+ ## Web app: install, build, and dev server
6
+
7
+ From the **SFDX project root** (this directory), run:
8
+
9
+ ```bash
10
+ npm run sf-project-setup
11
+ ```
12
+
13
+ This installs dependencies in the web app, builds it, and starts the Vite dev server. Use this after cloning or extracting the project.
14
+
5
15
  ## How Do You Plan to Deploy Your Changes?
6
16
 
7
17
  Do you want to deploy a set of changes, or create a self-contained application? Choose a [development model](https://developer.salesforce.com/tools/vscode/en/user-guide/development-models).
package/dist/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-sfdx-project-experimental",
3
- "version": "1.106.1",
3
+ "version": "1.107.0",
4
4
  "description": "Base SFDX project template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "scripts": {
10
+ "sf-project-setup": "node scripts/sf-project-setup.mjs",
10
11
  "build": "echo 'No build required for base-sfdx-project'",
11
12
  "clean": "echo 'No clean required for base-sfdx-project'",
12
13
  "lint": "eslint **/{aura,lwc}/**/*.js",
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Run from SFDX project root: install dependencies, build, and launch the dev server
4
+ * for the web app in force-app/main/default/webapplications/.
5
+ *
6
+ * Usage: npm run sf-project-setup
7
+ * (from the directory that contains force-app/ and sfdx-project.json)
8
+ */
9
+
10
+ import { spawnSync } from 'node:child_process';
11
+ import { resolve, dirname } from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+ import { readdirSync, existsSync, readFileSync } from 'node:fs';
14
+
15
+ const __dirname = dirname(fileURLToPath(import.meta.url));
16
+ const ROOT = resolve(__dirname, '..');
17
+
18
+ function resolveWebapplicationsDir() {
19
+ const sfdxPath = resolve(ROOT, 'sfdx-project.json');
20
+ if (!existsSync(sfdxPath)) {
21
+ console.error('Error: sfdx-project.json not found at project root.');
22
+ process.exit(1);
23
+ }
24
+ const sfdxProject = JSON.parse(readFileSync(sfdxPath, 'utf8'));
25
+ const pkgDir = sfdxProject?.packageDirectories?.[0]?.path;
26
+ if (!pkgDir) {
27
+ console.error('Error: No packageDirectories[].path found in sfdx-project.json.');
28
+ process.exit(1);
29
+ }
30
+ return resolve(ROOT, pkgDir, 'main', 'default', 'webapplications');
31
+ }
32
+
33
+ function discoverWebappDir() {
34
+ const webapplicationsDir = resolveWebapplicationsDir();
35
+ if (!existsSync(webapplicationsDir)) {
36
+ console.error(`Error: webapplications directory not found: ${webapplicationsDir}`);
37
+ process.exit(1);
38
+ }
39
+ const entries = readdirSync(webapplicationsDir, { withFileTypes: true });
40
+ const dirs = entries.filter((e) => e.isDirectory() && !e.name.startsWith('.'));
41
+ if (dirs.length === 0) {
42
+ console.error(`Error: No web app folder found under ${webapplicationsDir}`);
43
+ process.exit(1);
44
+ }
45
+ if (dirs.length > 1) {
46
+ console.log(`Multiple web apps found; using first: ${dirs[0].name}`);
47
+ }
48
+ return resolve(webapplicationsDir, dirs[0].name);
49
+ }
50
+
51
+ function run(label, cmd, args, opts) {
52
+ console.log(`\n--- ${label} ---\n`);
53
+ const result = spawnSync(cmd, args, { stdio: 'inherit', ...opts });
54
+ if (result.status !== 0) {
55
+ process.exit(result.status ?? 1);
56
+ }
57
+ }
58
+
59
+ const webappDir = discoverWebappDir();
60
+ console.log('SFDX project root:', ROOT);
61
+ console.log('Web app directory:', webappDir);
62
+
63
+ run('npm install', 'npm', ['install'], { cwd: webappDir });
64
+ run('npm run build', 'npm', ['run', 'build'], { cwd: webappDir });
65
+ console.log('\n--- Launching dev server (Ctrl+C to stop) ---\n');
66
+ run('npm run dev', 'npm', ['run', 'dev'], { cwd: webappDir });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-feature-react-file-upload-experimental",
3
- "version": "1.106.1",
3
+ "version": "1.107.0",
4
4
  "description": "File upload feature with a component to upload files to core",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "",
@@ -41,7 +41,7 @@
41
41
  }
42
42
  },
43
43
  "devDependencies": {
44
- "@salesforce/webapp-experimental": "^1.106.1",
44
+ "@salesforce/webapp-experimental": "^1.107.0",
45
45
  "@types/react": "^19.2.7",
46
46
  "@types/react-dom": "^19.2.3",
47
47
  "nodemon": "^3.1.0",
@@ -1,88 +0,0 @@
1
- ---
2
- description: CLI command generation rules — no node -e one-liners; safe quoting and scripts
3
- paths:
4
- - "**/webapplications/**/*"
5
- ---
6
-
7
- # A4D Enforcement: CLI Command Generation & No `node -e` One-Liners
8
-
9
- When **generating any CLI/shell commands** (for the user or for automation), follow the rules below. Default shell is **Zsh** (macOS); commands must work there without Bash-only syntax.
10
-
11
- ---
12
-
13
- ## 1. Never Use Complex `node -e` One-Liners
14
-
15
- **Forbidden:** `node -e` (or `node -p`, `node --eval`) for file manipulation, string replacement, reading/writing configs, or multi-line logic.
16
-
17
- **Why:** In Zsh, `node -e '...'` **silently breaks** due to:
18
- - **`!` (history expansion):** Zsh expands `!` in double-quoted strings → `event not found` or wrong output.
19
- - **Backticks:** `` ` `` is command substitution; the shell runs it before Node sees the string.
20
- - **Nested quoting:** Escaping differs between Bash and Zsh; multi-line JS in one string is fragile.
21
-
22
- **Allowed:** Trivial one-line only if it has **no** backticks, no `!`, no nested quotes, no multi-line, no `fs` usage. Example: `node -e "console.log(1+1)"`. If in doubt, **use a script file**.
23
-
24
- ---
25
-
26
- ## 2. How To Generate CLI Commands Correctly
27
-
28
- ### Run Node scripts by path, not inline code
29
-
30
- - **Do:** `node scripts/setup-cli.mjs --target-org myorg`
31
- - **Do:** `node path/to/script.mjs arg1 arg2`
32
- - **Do not:** `node -e "require('fs').writeFileSync(...)"` or any non-trivial inline JS.
33
-
34
- ### For file edits or transforms
35
-
36
- 1. **Prefer IDE/agent file tools** (StrReplace, Write, etc.) — they avoid the shell.
37
- 2. **Otherwise:** write a **temporary `.js` or `.mjs` file**, run it, then remove it. Use a **heredoc with quoted delimiter** so the shell does not interpret `$`, `` ` ``, or `!`:
38
-
39
- ```bash
40
- cat > /tmp/_transform.js << 'SCRIPT'
41
- const fs = require('fs');
42
- const data = JSON.parse(fs.readFileSync('package.json', 'utf8'));
43
- data.name = 'my-app';
44
- fs.writeFileSync('package.json', JSON.stringify(data, null, 2) + '\n');
45
- SCRIPT
46
- node /tmp/_transform.js && rm /tmp/_transform.js
47
- ```
48
-
49
- 3. **Simple replacements:** `sed -i '' 's/old/new/g' path/to/file` (macOS: `-i ''`).
50
- 4. **JSON:** `jq '.name = "my-app"' package.json > tmp.json && mv tmp.json package.json`.
51
-
52
- ### Quoting and shell safety
53
-
54
- - Use **single quotes** around the outer shell string when the inner content has `$`, `` ` ``, or `!`.
55
- - For heredocs that must be literal, use **`<< 'END'`** (quoted delimiter) so the body is not expanded.
56
- - **Do not** generate commands that rely on Bash-only features (e.g. `[[ ]]` is fine in Zsh; avoid `source` vs `.` if you need POSIX).
57
-
58
- ### Paths and working directory
59
-
60
- - **State where to run from** when it matters, e.g. "From project root" or "From `force-app/main/default/webapplications/<appName>`".
61
- - Prefer **explicit paths** or `cd <dir> && ...` so the command is copy-paste safe.
62
- - This project: setup is `node scripts/setup-cli.mjs --target-org <alias>` from **project root**. Web app commands (`npm run dev`, `npm run build`, `npm run lint`) run from the **web app directory** (e.g. `force-app/main/default/webapplications/<appName>` or `**/webapplications/<appName>`).
63
-
64
- ### npm / npx
65
-
66
- - Use **exact package names** (e.g. `npx @salesforce/webapps-features-experimental list`).
67
- - For app-specific scripts, **cd to the web app directory first**, then run `npm run <script>` or `npm install ...`.
68
- - Chain steps with `&&`; one logical command per line is clearer than one giant line.
69
-
70
- ### Summary checklist when generating a command
71
-
72
- - [ ] No `node -e` / `node -p` / `node --eval` with complex or multi-line code.
73
- - [ ] If Node logic is needed, use `node path/to/script.mjs` or a temp script with heredoc `<< 'SCRIPT'`.
74
- - [ ] No unescaped `!`, `` ` ``, or `$` in double-quoted strings in Zsh.
75
- - [ ] Working directory and required args (e.g. `--target-org`) are clear.
76
- - [ ] Prefer file-editing tools over shell one-liners when editing project files.
77
-
78
- ---
79
-
80
- ## 3. Violation Handling
81
-
82
- - If a generated command used a complex `node -e` one-liner, **revert and redo** using a script file, `sed`/`jq`, or IDE file tools.
83
- - If the user sees `event not found`, `unexpected token`, or garbled output, **check for**:
84
- - `node -e` with special characters,
85
- - Double-quoted strings containing `!` or backticks,
86
- - Wrong working directory or missing args.
87
-
88
- **Cross-reference:** **webapp.md** (MUST FOLLOW #1) summarizes the no–`node -e` rule; this file is the full reference for CLI command generation and alternatives.
@@ -1,136 +0,0 @@
1
- ---
2
- description: Code quality and build validation standards
3
- paths:
4
- - "**/webapplications/**/*"
5
- ---
6
-
7
- # Code Quality & Build Validation
8
-
9
- Enforces ESLint, TypeScript, and build validation for consistent, maintainable code.
10
-
11
- ## MANDATORY Quality Gates
12
-
13
- **Before completing any coding session** (from the web app directory `force-app/main/default/webapplications/<appName>/`):
14
-
15
- ```bash
16
- npm run lint # MUST result in 0 errors
17
- npm run build # MUST succeed (includes TypeScript check)
18
- ```
19
-
20
- ## Requirements
21
-
22
- **Must Pass:**
23
- - `npm run build` completes successfully
24
- - No TypeScript compilation errors
25
- - No critical ESLint errors (0 errors)
26
-
27
- **Can Be Warnings:**
28
- - ESLint warnings (fix when convenient)
29
- - Minor TypeScript warnings
30
-
31
- ## Key Commands
32
-
33
- ```bash
34
- npm run dev # Start development server (vite)
35
- npm run lint # Run ESLint
36
- npm run build # TypeScript + Vite build; check deployment readiness
37
- ```
38
-
39
- ## Error Priority
40
-
41
- **Fix Immediately:**
42
- - TypeScript compilation errors
43
- - Import/export errors
44
- - Syntax errors
45
-
46
- **Fix When Convenient:**
47
- - ESLint warnings
48
- - Unused variables
49
-
50
- ## Import Order (MANDATORY)
51
-
52
- ```typescript
53
- // 1. React ecosystem
54
- import { useState, useEffect } from 'react';
55
-
56
- // 2. External libraries (alphabetical)
57
- import clsx from 'clsx';
58
-
59
- // 3. UI components (alphabetical)
60
- import { Button } from '@/components/ui/button';
61
- import { Card } from '@/components/ui/card';
62
-
63
- // 4. Internal utilities (alphabetical)
64
- import { useAuth } from '../hooks/useAuth';
65
- import { formatDate } from '../utils/dateUtils';
66
-
67
- // 5. Relative imports
68
- import { ComponentA } from './ComponentA';
69
-
70
- // 6. Type imports (separate, at end)
71
- import type { User, ApiResponse } from '../types';
72
- ```
73
-
74
- ## Naming Conventions
75
-
76
- ```typescript
77
- // PascalCase: Components, classes
78
- const UserProfile = () => {};
79
-
80
- // camelCase: Variables, functions, properties
81
- const userName = 'john';
82
- const fetchUserData = async () => {};
83
-
84
- // SCREAMING_SNAKE_CASE: Constants
85
- const API_BASE_URL = 'https://api.example.com';
86
-
87
- // kebab-case: Files
88
- // user-profile.tsx, api-client.ts
89
- ```
90
-
91
- ## React Component Structure
92
-
93
- ```typescript
94
- interface ComponentProps {
95
- // Props interface first
96
- }
97
-
98
- const Component: React.FC<ComponentProps> = ({ prop1, prop2 }) => {
99
- // 1. Hooks
100
- // 2. Computed values
101
- // 3. Event handlers
102
- // 4. JSX return
103
-
104
- return <div />;
105
- };
106
-
107
- export default Component;
108
- ```
109
-
110
- ## Anti-Patterns (FORBIDDEN)
111
-
112
- ```typescript
113
- // NEVER disable ESLint without justification
114
- // eslint-disable-next-line
115
-
116
- // NEVER mutate state directly
117
- state.items.push(newItem); // Wrong
118
- setItems(prev => [...prev, newItem]); // Correct
119
-
120
- // NEVER use magic numbers/strings
121
- setTimeout(() => {}, 5000); // Wrong
122
- const DEBOUNCE_DELAY = 5000; // Correct
123
- ```
124
-
125
- ## Troubleshooting
126
-
127
- **Import Errors:**
128
- ```bash
129
- npm install # Check missing dependencies
130
- # Verify: file exists, case sensitivity, export/import match
131
- ```
132
-
133
- **Build Failures:**
134
- 1. Run `npm run lint` to identify issues
135
- 2. Fix TypeScript/ESLint errors
136
- 3. Retry `npm run build`