Skip to content

Commit adcf034

Browse files
authored
Update documentation for desktop and web extensions (#1334)
* Update documentation for desktop and web extensions - ✏️ Added detailed setup and contribution instructions for the desktop extension. - 📄 Created a new document for web extension setup and contribution guidelines. - 📚 Updated directory structure overview with relevant details. -Priyanshu * Update web extension instructions for clarity - 📝 Changed directory path example to a more generic format. - 🔍 Updated test locations to reflect the correct directory structure. - ✏️ Expanded contributing guidelines to clarify changes in both web and desktop extensions. -Priyanshu
1 parent 8b93cbb commit adcf034

File tree

4 files changed

+198
-1
lines changed

4 files changed

+198
-1
lines changed

.github/copilot-instructions.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
This is the **Power Platform VS Code extension** that provides tooling for creating, building, and deploying Power Platform solutions, packages, and portals. It integrates the Power Platform CLI (pac) directly into VS Code.
66

7+
Always refer to [memory-bank.instructions.md](instructions/memory-bank.instructions.md) for the latest architecture and coding guidelines.
8+
79
### Key Components
810

911
- **Client (`src/client/`)**: Main VS Code extension logic, UI components, and Power Pages tooling
@@ -22,21 +24,24 @@ This is the **Power Platform VS Code extension** that provides tooling for creat
2224
## Development Workflows
2325

2426
### Build Commands
27+
2528
- `npm run build` or `gulp`: Full build (uses gulpfile.mjs)
2629
- `npm run compile-web`: Build web version only
2730
- `npm run test-desktop-int`: Run desktop integration tests
2831
- `npm run test-web-integration`: Run web integration tests
2932

3033
### Key Files for Extension Development
34+
3135
- `src/client/extension.ts`: Main extension entry point
3236
- `package.json`: Extension manifest with commands and contributions
3337
- `src/client/lib/PacActivityBarUI.ts`: Activity bar panels and UI registration
3438
- `src/client/PortalWebView.ts`: Power Pages portal webview management
3539
- `src/client/pac/PacWrapper.ts`: Wrapper for Power Platform CLI commands
3640
- `src/client/power-pages/actions-hub/ActionsHubTreeDataProvider.ts`: Power Pages Actions Hub tree data provider
37-
-
41+
-
3842

3943
### PAC CLI Integration Patterns
44+
4045
```typescript
4146
// Always use PacWrapper for CLI operations
4247
const pacWrapper = new PacWrapper(context);
@@ -46,40 +51,47 @@ await pacWrapper.executeCommand(['solution', 'list']);
4651
## Coding Guidelines
4752

4853
### Indentation & Style
54+
4955
- Use 4 spaces for indentation (no tabs)
5056
- Arrow functions `=>` over anonymous functions
5157
- Curly braces on same line, always use braces for loops/conditionals
5258
- No whitespace in parenthesized constructs: `for (let i = 0; i < 10; i++)`
5359

5460
### Naming Conventions
61+
5562
- PascalCase: `type` names, `enum` values
5663
- camelCase: `function`/`method` names, `property` names, `local variables`
5764
- UPPER_CASE: constants
5865
- Use whole words when possible
5966

6067
### Strings & Localization
68+
6169
- "double quotes" for user-facing strings that need localization
6270
- 'single quotes' for internal strings
6371
- All user-visible strings MUST be externalized using `vscode-nls`
6472

6573
### Comments
74+
6675
- Use JSDoc style comments for functions, interfaces, enums, and classes
6776
- Include parameter descriptions and return types
6877

6978
## Testing Patterns
7079

7180
### Framework Usage
81+
7282
- **Mocha** test framework with `describe` and `it` blocks
7383
- **Chai** `expect` assertions (not assert)
7484
- **Sinon** for stubs and spies
7585
- Mock dependencies extensively for unit tests
7686

7787
### Test Organization
88+
7889
- Unit tests: `src/*/test/unit/`
7990
- Integration tests: `src/*/test/integration/`
8091
- No `//Arrange`, `//Act`, `//Assert` comments
8192

8293
### Running Tests
94+
8395
```bash
8496
npm run test # Unit tests
8597
npm run test-desktop-int # Desktop integration tests
@@ -89,16 +101,19 @@ npm run test-web-integration # Web integration tests
89101
## Power Platform Specific Patterns
90102

91103
### Power Pages Development
104+
92105
- Portal files use specific extensions: `.copy.html`, `.custom_javascript.js` (see `src/common/constants.ts`)
93106
- File system callbacks in `src/client/power-pages/fileSystemCallbacks.ts`
94107
- Bootstrap diff functionality for portal template updates
95108

96109
### CLI Version Management
110+
97111
- CLI versions managed in `src/client/lib/CliAcquisition.ts`
98112
- Global storage for CLI binaries in VS Code's global storage path
99113
- Cross-platform support (Windows `.exe`, Unix executables)
100114

101115
### Telemetry Implementation
116+
102117
- Use `oneDSLoggerWrapper` for all telemetry events
103118
- Events defined in `src/common/OneDSLoggerTelemetry/telemetryConstants.ts`
104119
- Separate telemetry for desktop vs web experiences
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
applyTo: src/client/**
3+
description: Desktop Extension Setup and Contribution Instructions
4+
---
5+
6+
# VS Code Desktop Extension
7+
8+
## 1. Project Overview
9+
10+
- The Power Platform VS Code extension desktop code is under `src/client/`.
11+
- Key files: `src/client/extension.ts` (entry), `package.json` (manifest), `src/client/lib/` (CLI integration), `src/client/power-pages/` (Power Pages tooling).
12+
13+
## 2. Development Environment
14+
15+
- Node.js 18+ and npm 9+ required.
16+
- Install dependencies: `npm install`
17+
- Build extension: `gulp ci`
18+
- Test extension: `npm run test-desktop-int`
19+
- Debug/launch in VS Code using provided launch configs.
20+
21+
## 3. Coding Standards
22+
23+
- TypeScript, 4-space indentation, arrow functions preferred.
24+
- Externalize all user-facing strings with `vscode-nls`.
25+
- PascalCase for types/enums, camelCase for functions/variables.
26+
- JSDoc comments for exported functions, classes, interfaces.
27+
28+
## 4. Key Architectural Patterns
29+
30+
- **PAC CLI Integration:** Use `PacWrapper` for CLI operations.
31+
- **Telemetry:** Use `oneDSLoggerWrapper` for events.
32+
- **Service Architecture:** Core services in `src/common/services/`.
33+
34+
## 5. Testing
35+
36+
- Unit tests: `npm run test`
37+
- Integration tests: `npm run test-desktop-int`
38+
- Use Mocha, Chai, Sinon. Mock dependencies.
39+
40+
## 6. Contribution Workflow
41+
42+
- Fork and clone repo. Create feature branch from `main`.
43+
- Make changes in `src/client/` for desktop features.
44+
- Cover new code with tests. Run all tests before PR.
45+
- Submit PR with clear description.
46+
47+
## 7. Localization
48+
49+
- Update localization files in `l10n/` and `localize/` as needed.
50+
- Add new strings to `package.nls.json`.
51+
52+
## 8. Common Tasks
53+
54+
- Add commands: update `package.json`, implement in `src/client/extension.ts`.
55+
- PAC CLI: use `PacWrapper`.
56+
- Telemetry: use `oneDSLoggerWrapper`.
57+
- UI: update files in `src/client/` and assets in `src/client/assets/`.
58+
59+
## 9. Reference Docs
60+
61+
- See `.github/copilot-instructions.md` for architecture/coding guidelines.
62+
- See `README.md` for project info.

.github/instructions/directoryStructure.instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
applyTo: "**"
23
description: Directory Structure Overview
34
---
45
Provide a brief overview of the directory structure for the Power Platform VS Code extension. This will help in understanding where to find specific components and how the project is organized.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
applyTo: "src/web/**"
3+
description: Web Extension Setup and Contribution Instructions
4+
---
5+
6+
# Web Extension Instructions
7+
8+
This document provides setup, architecture, coding, and testing instructions for the web extension located in `src/web`. It is designed to help both humans and AI agents contribute effectively.
9+
10+
## Table of Contents
11+
12+
- [Overview](#overview)
13+
- [Architecture](#architecture)
14+
- [Installation](#installation)
15+
- [Development](#development)
16+
- [Folder Structure](#folder-structure)
17+
- [Coding Guidelines](#coding-guidelines)
18+
- [Building the Extension](#building-the-extension)
19+
- [Testing](#testing)
20+
- [Power Platform Patterns](#power-platform-patterns)
21+
- [Contributing](#contributing)
22+
- [Troubleshooting](#troubleshooting)
23+
24+
## Overview
25+
26+
The web extension extends Visual Studio Code for Power Platform scenarios. All source code for the web extension is located in the `src/web` directory.
27+
28+
## Architecture
29+
30+
- **Client (`src/web/client/`)**: Main VS Code web extension logic and UI components.
31+
- **Common (`src/common/`)**: Shared utilities, telemetry, and services.
32+
- **Multi-Target Build**: Uses webpack for desktop, web, and language servers.
33+
- **Telemetry**: Uses OneDSLogger for web telemetry (`src/common/OneDSLoggerTelemetry/`).
34+
- **Service Architecture**: Core services in `src/common/services/`.
35+
- **Entrypoint**: `src/web/client/extension.ts` is the main entry point for the web extension.
36+
37+
## Installation
38+
39+
1. Ensure you have [Node.js](https://nodejs.org/) and [npm](https://www.npmjs.com/) installed.
40+
2. Navigate to the project root directory:
41+
42+
```sh
43+
cd /path/to/powerplatform-vscode
44+
```
45+
46+
3. Install dependencies:
47+
48+
```sh
49+
npm install
50+
```
51+
52+
## Development
53+
54+
- Main code for the web extension is inside `src/web/client/`.
55+
- Open the project in Visual Studio Code.
56+
- Make changes in the `src/web/client/` directory as needed.
57+
- For CLI operations, use the `PacWrapper` abstraction.
58+
59+
## Folder Structure
60+
61+
```text
62+
src/
63+
└── web/
64+
└── client/
65+
```
66+
67+
- `client/`: Contains the client-side code for the web extension.
68+
69+
## Coding Guidelines
70+
71+
- **Indentation**: 4 spaces, no tabs.
72+
- **Arrow functions**: Prefer `=>` over anonymous functions.
73+
- **Braces**: Always use braces for loops/conditionals, on the same line.
74+
- **Naming**: PascalCase for types/enums, camelCase for functions/properties/variables, UPPER_CASE for constants.
75+
- **Strings**: "double quotes" for user-facing strings (externalized via `vscode-nls`), 'single quotes' for internal strings.
76+
- **Comments**: Use JSDoc style for functions, interfaces, enums, and classes.
77+
- **Localization**: All user-visible strings must be externalized.
78+
79+
## Building the Extension
80+
81+
To build the web extension, run:
82+
83+
```sh
84+
gulp ci
85+
```
86+
87+
This will compile the extension and output the necessary files.
88+
89+
## Testing
90+
91+
- **Unit tests**: Located in `src/web/client/test/unit/`
92+
- **Integration tests**: Located in `src/web/client/test/integration/`
93+
- **Frameworks**: Mocha (describe/it), Chai (expect), Sinon (stubs/spies)
94+
- **Running tests**:
95+
96+
```sh
97+
npm run test-web-integration
98+
```
99+
100+
- Mock dependencies extensively for unit tests.
101+
102+
## Power Platform Patterns
103+
104+
- **Telemetry**: Use `oneDSLoggerWrapper` for all events, defined in `src/common/OneDSLoggerTelemetry/telemetryConstants.ts`.
105+
106+
## Contributing
107+
108+
1. Fork the repository and create a new branch for your feature or bugfix.
109+
2. Make your changes in `src/web/client/` and, if needed, in `src/common/` for shared utilities and services which can be used across web and desktop.
110+
3. Follow coding and testing guidelines above.
111+
4. Submit a pull request with a clear description of your changes.
112+
5. The main difference between web and desktop extension is that desktop extension runs in a Node.js environment, while the web extension runs in a browser-like environment. This affects how certain APIs and modules can be used.
113+
114+
## Troubleshooting
115+
116+
- Ensure your Node.js and npm versions are up to date.
117+
- Check for missing dependencies in `package.json`.
118+
- Review error messages in the terminal for guidance.
119+
- For build/test issues, consult architecture and coding guidelines above.

0 commit comments

Comments
 (0)