@tywalk/pcf-helper 1.5.5 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -21
- package/dist/__tests__/pcf-helper-build.test.js +7 -3
- package/dist/__tests__/pcf-helper-deploy.test.js +7 -3
- package/dist/__tests__/pcf-helper-import.test.js +7 -3
- package/dist/__tests__/pcf-helper-init.test.js +7 -3
- package/dist/__tests__/pcf-helper-session.test.js +7 -3
- package/dist/__tests__/pcf-helper-upgrade.test.js +7 -3
- package/dist/bin/session.js +1 -1
- package/dist/package.json +12 -2
- package/dist/tasks/session-pcf.js +42 -15
- package/package.json +12 -2
- package/types/tasks/session-pcf.d.ts +17 -0
package/README.md
CHANGED
|
@@ -1,33 +1,257 @@
|
|
|
1
|
-
# PCF Helper
|
|
1
|
+
# PCF Helper Core 🔧
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/js/%40tywalk%2Fpcf-helper)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**Individual CLI commands and core library for Power Platform Component Framework (PCF) development.**
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
This package provides discrete command-line utilities for each PCF operation, making it ideal for automation scripts and developers who prefer granular control over their PCF workflows.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
## 📋 Table of Contents
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Available Commands](#available-commands)
|
|
14
|
+
- [Command Reference](#command-reference)
|
|
15
|
+
- [API Reference](#api-reference)
|
|
16
|
+
- [Troubleshooting](#troubleshooting)
|
|
13
17
|
|
|
14
|
-
##
|
|
18
|
+
## 📦 Installation
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
2. In your project's `package.json` file, add commands as npm scripts:
|
|
20
|
+
### Global Installation (Recommended)
|
|
18
21
|
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
"upgrade": "pcf-helper-upgrade --path <path to pcf project folder>",
|
|
22
|
-
"build": "pcf-helper-build --path <path to pcf project folder>",
|
|
23
|
-
"import": "pcf-helper-import --path <path to pcf project folder> --environment <environment guid or url>",
|
|
24
|
-
"deploy": "pcf-helper-deploy --path <path to pcf project folder> --environment <environment guid or url>",
|
|
25
|
-
"init": "pcf-helper-init --path <path to pcf project folder (optional)> --name <name of the pcf project> --publisher-name <powerapps publisher name> --publisher-prefix <powerapps publisher prefix>"
|
|
26
|
-
},
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g @tywalk/pcf-helper
|
|
27
24
|
```
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
### Local Installation
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
```bash
|
|
29
|
+
npm install @tywalk/pcf-helper
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🛠️ Available Commands
|
|
33
|
+
|
|
34
|
+
Each command is available as a standalone executable:
|
|
35
|
+
|
|
36
|
+
| Command | Purpose | Global Usage |
|
|
37
|
+
|---------|---------|--------------|
|
|
38
|
+
| `pcf-helper-init` | Initialize new PCF project | `pcf-helper-init [options]` |
|
|
39
|
+
| `pcf-helper-build` | Build PCF controls | `pcf-helper-build [options]` |
|
|
40
|
+
| `pcf-helper-import` | Import controls to solution | `pcf-helper-import [options]` |
|
|
41
|
+
| `pcf-helper-deploy` | Deploy controls (upgrade + build + import) | `pcf-helper-deploy [options]` |
|
|
42
|
+
| `pcf-helper-upgrade` | Upgrade project dependencies | `pcf-helper-upgrade [options]` |
|
|
43
|
+
| `pcf-helper-session` | Manage development sessions | `pcf-helper-session [options]` |
|
|
44
|
+
|
|
45
|
+
## 📖 Command Reference
|
|
46
|
+
|
|
47
|
+
### 🏗️ pcf-helper-init
|
|
48
|
+
|
|
49
|
+
Initialize a new PCF project with proper scaffolding.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pcf-helper-init -n <control-name> [options]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Options
|
|
56
|
+
|
|
57
|
+
| Option | Description | Required | Default |
|
|
58
|
+
|--------|-------------|----------|---------|
|
|
59
|
+
| `-n, --name <name>` | Name of the PCF control | ✅ | - |
|
|
60
|
+
| `--publisher-name <name>` | Publisher name for the control | ❌ | - |
|
|
61
|
+
| `--publisher-prefix <prefix>` | Publisher prefix | ❌ | - |
|
|
62
|
+
| `-p, --path <path>` | Path to create the project | ❌ | Current directory |
|
|
63
|
+
| `--run-npm-install` | Run npm install after init | ❌ | `true` |
|
|
64
|
+
| `-V, --verbose` | Enable verbose logging | ❌ | `false` |
|
|
65
|
+
| `-v, --version` | Display version | ❌ | - |
|
|
66
|
+
|
|
67
|
+
#### Example
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Basic initialization
|
|
71
|
+
pcf-helper-init -n MyCustomControl
|
|
72
|
+
|
|
73
|
+
# Full initialization with custom settings
|
|
74
|
+
pcf-helper-init -n MyCustomControl \
|
|
75
|
+
--publisher-name "Contoso" \
|
|
76
|
+
--publisher-prefix "con" \
|
|
77
|
+
-p ./my-pcf-project \
|
|
78
|
+
--verbose
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### ⚡ pcf-helper-build
|
|
82
|
+
|
|
83
|
+
Build and compile your PCF controls.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pcf-helper-build -p <solution-path> [options]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Options
|
|
90
|
+
|
|
91
|
+
| Option | Description | Required | Default |
|
|
92
|
+
|--------|-------------|----------|---------|
|
|
93
|
+
| `-p, --path <path>` | Path to solution folder | ✅ | - |
|
|
94
|
+
| `-t, --timeout <ms>` | Timeout in milliseconds | ❌ | 300000 |
|
|
95
|
+
| `-V, --verbose` | Enable verbose logging | ❌ | `false` |
|
|
96
|
+
| `-v, --version` | Display version | ❌ | - |
|
|
97
|
+
|
|
98
|
+
#### Example
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Build with default settings
|
|
102
|
+
pcf-helper-build -p ./MySolution
|
|
103
|
+
|
|
104
|
+
# Build with custom timeout and verbose output
|
|
105
|
+
pcf-helper-build -p ./MySolution --timeout 120000 --verbose
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 📦 pcf-helper-import
|
|
109
|
+
|
|
110
|
+
Import PCF controls into your Dataverse solution.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pcf-helper-import -p <solution-path> [options]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### Options
|
|
117
|
+
|
|
118
|
+
| Option | Description | Required | Default |
|
|
119
|
+
|--------|-------------|----------|---------|
|
|
120
|
+
| `-p, --path <path>` | Path to solution folder | ✅ | - |
|
|
121
|
+
| `-e, --environment <environment>` | Target environment | ❌ | - |
|
|
122
|
+
| `-t, --timeout <ms>` | Timeout in milliseconds | ❌ | 300000 |
|
|
123
|
+
| `-V, --verbose` | Enable verbose logging | ❌ | `false` |
|
|
124
|
+
| `-v, --version` | Display version | ❌ | - |
|
|
125
|
+
|
|
126
|
+
### 🚀 pcf-helper-deploy
|
|
127
|
+
|
|
128
|
+
Deploy your PCF controls to the target environment. This command runs upgrade, build, and import in sequence.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pcf-helper-deploy -p <solution-path> [options]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Options
|
|
135
|
+
|
|
136
|
+
Same as pcf-helper-import, but runs the full deployment pipeline.
|
|
137
|
+
|
|
138
|
+
### 🔄 pcf-helper-upgrade
|
|
139
|
+
|
|
140
|
+
Upgrade project dependencies and framework versions.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
pcf-helper-upgrade -p <solution-path> [options]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Options
|
|
147
|
+
|
|
148
|
+
| Option | Description | Required | Default |
|
|
149
|
+
|--------|-------------|----------|---------|
|
|
150
|
+
| `-p, --path <path>` | Path to solution folder | ✅ | - |
|
|
151
|
+
| `-V, --verbose` | Enable verbose logging | ❌ | `false` |
|
|
152
|
+
| `-v, --version` | Display version | ❌ | - |
|
|
153
|
+
|
|
154
|
+
### 🎯 pcf-helper-session
|
|
155
|
+
|
|
156
|
+
Manage development sessions with live reloading capabilities.
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pcf-helper-session [options]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Options
|
|
163
|
+
|
|
164
|
+
| Option | Description | Required | Default |
|
|
165
|
+
|--------|-------------|----------|---------|
|
|
166
|
+
| `-u, --url <url>` | Remote environment URL | ❌ | - |
|
|
167
|
+
| `-s, --script <path>` | Remote script to intercept | ❌ | - |
|
|
168
|
+
| `-t, --stylesheet <path>` | Remote stylesheet to intercept | ❌ | - |
|
|
169
|
+
| `-b, --bundle <path>` | Local bundle path | ❌ | - |
|
|
170
|
+
| `-c, --css <path>` | Local CSS path | ❌ | - |
|
|
171
|
+
| `-f, --config <path>` | Config file path | ❌ | `session.config.json` |
|
|
172
|
+
| `-V, --verbose` | Enable verbose logging | ❌ | `false` |
|
|
173
|
+
| `-v, --version` | Display version | ❌ | - |
|
|
174
|
+
|
|
175
|
+
## 🔧 API Reference
|
|
176
|
+
|
|
177
|
+
You can also use PCF Helper programmatically in your Node.js applications:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import * as pcfHelper from '@tywalk/pcf-helper';
|
|
181
|
+
|
|
182
|
+
// Build a PCF control
|
|
183
|
+
const result = pcfHelper.runBuild('./my-solution', true, 120000);
|
|
184
|
+
|
|
185
|
+
// Initialize a new project
|
|
186
|
+
const initResult = pcfHelper.runInit(
|
|
187
|
+
'./new-project',
|
|
188
|
+
'MyControl',
|
|
189
|
+
'My Publisher',
|
|
190
|
+
'mp',
|
|
191
|
+
true,
|
|
192
|
+
true
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
// Set logging level
|
|
196
|
+
pcfHelper.setLogLevel('debug');
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Available Functions
|
|
200
|
+
|
|
201
|
+
- `runBuild(path, verbose, timeout?)` - Build PCF controls
|
|
202
|
+
- `runInit(path, name, publisherName, publisherPrefix, runNpmInstall, verbose)` - Initialize new PCF project
|
|
203
|
+
- `runImport(path, environment, verbose, timeout?)` - Import controls to solution
|
|
204
|
+
- `runUpgrade(path, verbose)` - Upgrade project
|
|
205
|
+
- `runSession(...)` - Manage development sessions
|
|
206
|
+
- `setLogLevel(level)` - Set logging verbosity ('debug' | 'info' | 'warn' | 'error')
|
|
207
|
+
|
|
208
|
+
## 🐛 Troubleshooting
|
|
209
|
+
|
|
210
|
+
### Common Issues
|
|
211
|
+
|
|
212
|
+
#### Build Failures
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Enable verbose logging for detailed error information
|
|
216
|
+
pcf-helper-build -p . --verbose
|
|
217
|
+
|
|
218
|
+
# Check if PAC CLI is properly installed
|
|
219
|
+
pac --version
|
|
220
|
+
|
|
221
|
+
# Verify .NET SDK installation
|
|
222
|
+
dotnet --version
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### Timeout Errors
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Increase timeout for large projects
|
|
229
|
+
pcf-helper-build -p . --timeout 600000 # 10 minutes
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Getting Help
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# Show help for any command
|
|
236
|
+
pcf-helper-build --help
|
|
237
|
+
pcf-helper-init --help
|
|
238
|
+
|
|
239
|
+
# Show version
|
|
240
|
+
pcf-helper-build --version
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## 📚 Additional Resources
|
|
244
|
+
|
|
245
|
+
- [Power Platform Component Framework Documentation](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/)
|
|
246
|
+
- [Power Platform CLI Reference](https://docs.microsoft.com/en-us/powerapps/developer/data-platform/powerapps-cli)
|
|
247
|
+
|
|
248
|
+
## 🔗 Related Packages
|
|
249
|
+
|
|
250
|
+
- **[@tywalk/pcf-helper-run](../pcf-helper-run/README.md)** - Unified CLI interface
|
|
251
|
+
- **[@tywalk/color-logger](https://www.npmjs.com/package/@tywalk/color-logger)** - Enhanced logging utilities
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 🏠 [← Back to Main Package](../../README.md)
|
|
32
256
|
|
|
33
|
-
|
|
257
|
+
For questions or issues, please visit our [GitHub Issues](https://github.com/tywalk/pcf-helper/issues) page.
|
|
@@ -12,14 +12,18 @@ test('build displays version', (done) => {
|
|
|
12
12
|
console.error(`stderr: ${data}`);
|
|
13
13
|
});
|
|
14
14
|
task.on('close', (code) => {
|
|
15
|
-
|
|
16
|
-
expect(output).toContain(`v${package_json_1.version}`);
|
|
15
|
+
expect(output).toContain(package_json_1.version);
|
|
17
16
|
expect(code).toBe(0);
|
|
18
17
|
done();
|
|
19
18
|
});
|
|
20
19
|
});
|
|
21
20
|
test('build errors if no path is provided', (done) => {
|
|
22
21
|
const task = (0, child_process_1.spawn)('node', ['./dist/bin/build.js', '-p']);
|
|
22
|
+
// Add timeout
|
|
23
|
+
const timeout = setTimeout(() => {
|
|
24
|
+
task.kill();
|
|
25
|
+
done.fail('Test timed out');
|
|
26
|
+
}, 5000);
|
|
23
27
|
let output = '';
|
|
24
28
|
task.stdout.on('data', (data) => {
|
|
25
29
|
output += data.toString();
|
|
@@ -28,8 +32,8 @@ test('build errors if no path is provided', (done) => {
|
|
|
28
32
|
console.error(`stderr: ${data}`);
|
|
29
33
|
});
|
|
30
34
|
task.on('close', (code) => {
|
|
31
|
-
console.log(output);
|
|
32
35
|
expect(code).toBe(1);
|
|
36
|
+
clearTimeout(timeout);
|
|
33
37
|
done();
|
|
34
38
|
});
|
|
35
39
|
});
|
|
@@ -12,14 +12,18 @@ test('deploy displays version', (done) => {
|
|
|
12
12
|
console.error(`stderr: ${data}`);
|
|
13
13
|
});
|
|
14
14
|
task.on('close', (code) => {
|
|
15
|
-
|
|
16
|
-
expect(output).toContain(`v${package_json_1.version}`);
|
|
15
|
+
expect(output).toContain(package_json_1.version);
|
|
17
16
|
expect(code).toBe(0);
|
|
18
17
|
done();
|
|
19
18
|
});
|
|
20
19
|
});
|
|
21
20
|
test('deploy errors if no path is provided', (done) => {
|
|
22
21
|
const task = (0, child_process_1.spawn)('node', ['./dist/bin/deploy.js', '-p']);
|
|
22
|
+
// Add timeout
|
|
23
|
+
const timeout = setTimeout(() => {
|
|
24
|
+
task.kill();
|
|
25
|
+
done.fail('Test timed out');
|
|
26
|
+
}, 5000);
|
|
23
27
|
let output = '';
|
|
24
28
|
task.stdout.on('data', (data) => {
|
|
25
29
|
output += data.toString();
|
|
@@ -28,8 +32,8 @@ test('deploy errors if no path is provided', (done) => {
|
|
|
28
32
|
console.error(`stderr: ${data}`);
|
|
29
33
|
});
|
|
30
34
|
task.on('close', (code) => {
|
|
31
|
-
console.log(output);
|
|
32
35
|
expect(code).toBe(1);
|
|
36
|
+
clearTimeout(timeout);
|
|
33
37
|
done();
|
|
34
38
|
});
|
|
35
39
|
});
|
|
@@ -9,14 +9,18 @@ test('import displays version', (done) => {
|
|
|
9
9
|
output += data.toString();
|
|
10
10
|
});
|
|
11
11
|
task.on('close', (code) => {
|
|
12
|
-
|
|
13
|
-
expect(output).toContain(`v${package_json_1.version}`);
|
|
12
|
+
expect(output).toContain(package_json_1.version);
|
|
14
13
|
expect(code).toBe(0);
|
|
15
14
|
done();
|
|
16
15
|
});
|
|
17
16
|
});
|
|
18
17
|
test('import errors if no path is provided', (done) => {
|
|
19
18
|
const task = (0, child_process_1.spawn)('node', ['./dist/bin/import.js', '-p']);
|
|
19
|
+
// Add timeout
|
|
20
|
+
const timeout = setTimeout(() => {
|
|
21
|
+
task.kill();
|
|
22
|
+
done.fail('Test timed out');
|
|
23
|
+
}, 5000);
|
|
20
24
|
let output = '';
|
|
21
25
|
task.stdout.on('data', (data) => {
|
|
22
26
|
output += data.toString();
|
|
@@ -25,8 +29,8 @@ test('import errors if no path is provided', (done) => {
|
|
|
25
29
|
console.error(`stderr: ${data}`);
|
|
26
30
|
});
|
|
27
31
|
task.on('close', (code) => {
|
|
28
|
-
console.log(output);
|
|
29
32
|
expect(code).toBe(1);
|
|
33
|
+
clearTimeout(timeout);
|
|
30
34
|
done();
|
|
31
35
|
});
|
|
32
36
|
});
|
|
@@ -9,14 +9,18 @@ test('init displays version', (done) => {
|
|
|
9
9
|
output += data.toString();
|
|
10
10
|
});
|
|
11
11
|
task.on('close', (code) => {
|
|
12
|
-
|
|
13
|
-
expect(output).toContain(`v${package_json_1.version}`);
|
|
12
|
+
expect(output).toContain(package_json_1.version);
|
|
14
13
|
expect(code).toBe(0);
|
|
15
14
|
done();
|
|
16
15
|
});
|
|
17
16
|
});
|
|
18
17
|
test('init errors if no path is provided', (done) => {
|
|
19
18
|
const task = (0, child_process_1.spawn)('node', ['./dist/bin/init.js', '-p']);
|
|
19
|
+
// Add timeout
|
|
20
|
+
const timeout = setTimeout(() => {
|
|
21
|
+
task.kill();
|
|
22
|
+
done.fail('Test timed out');
|
|
23
|
+
}, 5000);
|
|
20
24
|
let output = '';
|
|
21
25
|
task.stdout.on('data', (data) => {
|
|
22
26
|
output += data.toString();
|
|
@@ -25,8 +29,8 @@ test('init errors if no path is provided', (done) => {
|
|
|
25
29
|
console.error(`stderr: ${data}`);
|
|
26
30
|
});
|
|
27
31
|
task.on('close', (code) => {
|
|
28
|
-
console.log(output);
|
|
29
32
|
expect(code).toBe(1);
|
|
33
|
+
clearTimeout(timeout);
|
|
30
34
|
done();
|
|
31
35
|
});
|
|
32
36
|
});
|
|
@@ -9,14 +9,18 @@ test('session displays version', (done) => {
|
|
|
9
9
|
output += data.toString();
|
|
10
10
|
});
|
|
11
11
|
task.on('close', (code) => {
|
|
12
|
-
|
|
13
|
-
expect(output).toContain(`v${package_json_1.version}`);
|
|
12
|
+
expect(output).toContain(package_json_1.version);
|
|
14
13
|
expect(code).toBe(0);
|
|
15
14
|
done();
|
|
16
15
|
});
|
|
17
16
|
});
|
|
18
17
|
test('session errors if no args are provided', (done) => {
|
|
19
18
|
const task = (0, child_process_1.spawn)('node', ['./dist/bin/session.js', '-e']);
|
|
19
|
+
// Add timeout
|
|
20
|
+
const timeout = setTimeout(() => {
|
|
21
|
+
task.kill();
|
|
22
|
+
done.fail('Test timed out');
|
|
23
|
+
}, 5000);
|
|
20
24
|
let output = '';
|
|
21
25
|
task.stdout.on('data', (data) => {
|
|
22
26
|
output += data.toString();
|
|
@@ -25,8 +29,8 @@ test('session errors if no args are provided', (done) => {
|
|
|
25
29
|
console.error(`stderr: ${data}`);
|
|
26
30
|
});
|
|
27
31
|
task.on('close', (code) => {
|
|
28
|
-
console.log(output);
|
|
29
32
|
expect(code).toBe(1);
|
|
33
|
+
clearTimeout(timeout);
|
|
30
34
|
done();
|
|
31
35
|
});
|
|
32
36
|
});
|
|
@@ -9,14 +9,18 @@ test('upgrade displays version', (done) => {
|
|
|
9
9
|
output += data.toString();
|
|
10
10
|
});
|
|
11
11
|
task.on('close', (code) => {
|
|
12
|
-
|
|
13
|
-
expect(output).toContain(`v${package_json_1.version}`);
|
|
12
|
+
expect(output).toContain(package_json_1.version);
|
|
14
13
|
expect(code).toBe(0);
|
|
15
14
|
done();
|
|
16
15
|
});
|
|
17
16
|
});
|
|
18
17
|
test('upgrade errors if no path is provided', (done) => {
|
|
19
18
|
const task = (0, child_process_1.spawn)('node', ['./dist/bin/upgrade.js', '-p']);
|
|
19
|
+
// Add timeout
|
|
20
|
+
const timeout = setTimeout(() => {
|
|
21
|
+
task.kill();
|
|
22
|
+
done.fail('Test timed out');
|
|
23
|
+
}, 5000);
|
|
20
24
|
let output = '';
|
|
21
25
|
task.stdout.on('data', (data) => {
|
|
22
26
|
output += data.toString();
|
|
@@ -25,8 +29,8 @@ test('upgrade errors if no path is provided', (done) => {
|
|
|
25
29
|
console.error(`stderr: ${data}`);
|
|
26
30
|
});
|
|
27
31
|
task.on('close', (code) => {
|
|
28
|
-
console.log(output);
|
|
29
32
|
expect(code).toBe(1);
|
|
33
|
+
clearTimeout(timeout);
|
|
30
34
|
done();
|
|
31
35
|
});
|
|
32
36
|
});
|
package/dist/bin/session.js
CHANGED
|
@@ -52,7 +52,7 @@ program
|
|
|
52
52
|
.option('-t, --stylesheet <stylesheet>', 'remote stylesheet to intercept')
|
|
53
53
|
.option('-b, --bundle <path>', 'local bundle path')
|
|
54
54
|
.option('-c, --css <path>', 'local CSS path')
|
|
55
|
-
.option('-f, --config <path>', 'config file path', '
|
|
55
|
+
.option('-f, --config <path>', 'config file path', 'session.config.json')
|
|
56
56
|
.parse();
|
|
57
57
|
const options = program.opts();
|
|
58
58
|
if (options.verbose) {
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Command line helper for building and publishing PCF controls to Dataverse.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/",
|
|
@@ -11,11 +11,17 @@
|
|
|
11
11
|
"repository": {
|
|
12
12
|
"url": "git+https://github.com/tywalk/pcf-helper.git"
|
|
13
13
|
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
14
18
|
"scripts": {
|
|
15
19
|
"test": "jest",
|
|
16
20
|
"build": "tsc",
|
|
17
21
|
"upgrade": "npm version patch --no-git-tag-version",
|
|
18
|
-
"ready": "npm run upgrade && npm run build
|
|
22
|
+
"ready": "npm run upgrade && npm run build",
|
|
23
|
+
"update": "npm run ready && npm publish --access public",
|
|
24
|
+
"temp": "echo $version"
|
|
19
25
|
},
|
|
20
26
|
"keywords": [
|
|
21
27
|
"pcf"
|
|
@@ -30,9 +36,13 @@
|
|
|
30
36
|
"pcf-helper-session": "dist/bin/session.js"
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
39
|
+
"@semantic-release/git": "^10.0.1",
|
|
40
|
+
"@semantic-release/github": "^12.0.6",
|
|
41
|
+
"@semantic-release/npm": "^13.1.5",
|
|
33
42
|
"@types/jest": "^29.5.14",
|
|
34
43
|
"@types/node": "^22.13.11",
|
|
35
44
|
"jest": "^29.7.0",
|
|
45
|
+
"semantic-release": "^25.0.3",
|
|
36
46
|
"ts-jest": "^29.2.6",
|
|
37
47
|
"typescript": "^5.8.2"
|
|
38
48
|
},
|
|
@@ -18,10 +18,18 @@ const color_logger_1 = __importDefault(require("@tywalk/color-logger"));
|
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const fs_1 = __importDefault(require("fs"));
|
|
20
20
|
const playwright_1 = require("playwright");
|
|
21
|
+
/**
|
|
22
|
+
* Loads configuration for the session task, supporting a combination of config file, environment variables, and CLI arguments.
|
|
23
|
+
* The priority order is: CLI arguments > environment variables > config file > defaults.
|
|
24
|
+
* It also handles constructing full URLs for the script and stylesheet to intercept, allowing for relative paths in the config that are combined with the base URL.
|
|
25
|
+
* @param config Optional path to a JSON config file. If not provided, it will look for 'session.config.json' in the current working directory.
|
|
26
|
+
* @returns An object containing the resolved configuration values for the session task.
|
|
27
|
+
*/
|
|
21
28
|
function loadConfig(config) {
|
|
29
|
+
var _a, _b;
|
|
22
30
|
// Load file config if exists
|
|
23
31
|
let fileConfig = {};
|
|
24
|
-
const configPath = path_1.default.join(process.cwd(), config || '
|
|
32
|
+
const configPath = path_1.default.join(process.cwd(), config || 'session.config.json');
|
|
25
33
|
color_logger_1.default.log(`📁 Looking for config file at: ${configPath}`);
|
|
26
34
|
if (fs_1.default.existsSync(configPath)) {
|
|
27
35
|
fileConfig = JSON.parse(fs_1.default.readFileSync(configPath, 'utf8'));
|
|
@@ -35,12 +43,10 @@ function loadConfig(config) {
|
|
|
35
43
|
}
|
|
36
44
|
// Get the base URL first
|
|
37
45
|
const remoteEnvironmentUrl = process.env.REMOTE_ENVIRONMENT_URL ||
|
|
38
|
-
fileConfig.remoteEnvironmentUrl
|
|
39
|
-
'https://app.your-remote-environment.com';
|
|
46
|
+
fileConfig.remoteEnvironmentUrl;
|
|
40
47
|
// Handle script argument - support both relative paths and full URLs
|
|
41
48
|
let remoteScriptToIntercept = process.env.REMOTE_SCRIPT_TO_INTERCEPT ||
|
|
42
|
-
fileConfig.remoteScriptToIntercept
|
|
43
|
-
'https://app.your-remote-environment.com/static/js/remote-control-bundle.js';
|
|
49
|
+
fileConfig.remoteScriptToIntercept;
|
|
44
50
|
// If script is a relative path (doesn't start with http/https), combine with base URL
|
|
45
51
|
if (remoteScriptToIntercept && !remoteScriptToIntercept.startsWith('http')) {
|
|
46
52
|
// Normalize the base URL (remove trailing slash)
|
|
@@ -52,8 +58,7 @@ function loadConfig(config) {
|
|
|
52
58
|
remoteScriptToIntercept = `${baseUrl}${scriptPath}`;
|
|
53
59
|
}
|
|
54
60
|
let remoteStylesheetToIntercept = process.env.REMOTE_STYLESHEET_TO_INTERCEPT ||
|
|
55
|
-
fileConfig.remoteStylesheetToIntercept
|
|
56
|
-
'https://app.your-remote-environment.com/static/css/remote-control-styles.css';
|
|
61
|
+
fileConfig.remoteStylesheetToIntercept;
|
|
57
62
|
// If stylesheet is a relative path (doesn't start with http/https), combine with base URL
|
|
58
63
|
if (remoteStylesheetToIntercept && !remoteStylesheetToIntercept.startsWith('http')) {
|
|
59
64
|
// Normalize the base URL (remove trailing slash)
|
|
@@ -69,19 +74,41 @@ function loadConfig(config) {
|
|
|
69
74
|
remoteEnvironmentUrl: remoteEnvironmentUrl,
|
|
70
75
|
remoteScriptToIntercept: remoteScriptToIntercept,
|
|
71
76
|
remoteStylesheetToIntercept: remoteStylesheetToIntercept,
|
|
72
|
-
localCssPath: process.env.LOCAL_CSS_PATH
|
|
73
|
-
|
|
74
|
-
path_1.default.join(process.cwd(), 'dist', 'local-control-styles.css'),
|
|
75
|
-
localBundlePath: process.env.LOCAL_BUNDLE_PATH ||
|
|
76
|
-
fileConfig.localBundlePath ||
|
|
77
|
-
path_1.default.join(process.cwd(), 'dist', 'local-control-bundle.js')
|
|
77
|
+
localCssPath: (_a = process.env.LOCAL_CSS_PATH) !== null && _a !== void 0 ? _a : fileConfig.localCssPath,
|
|
78
|
+
localBundlePath: (_b = process.env.LOCAL_BUNDLE_PATH) !== null && _b !== void 0 ? _b : fileConfig.localBundlePath,
|
|
78
79
|
};
|
|
79
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Runs an ephemeral browser session that intercepts requests to the specified remote script and stylesheet URLs, serving local files instead.
|
|
83
|
+
* It also manages session state by saving cookies and local storage to a file, allowing for persistent login sessions across runs.
|
|
84
|
+
* The session will automatically clean up and save state on exit, including handling various exit signals and browser events.
|
|
85
|
+
* @param remoteEnvironmentUrl The URL of the remote environment to navigate to.
|
|
86
|
+
* @param remoteScriptToIntercept The full URL of the remote script to intercept (e.g., https://app.your-remote-environment.com/static/js/remote-control-bundle.js).
|
|
87
|
+
* @param remoteStylesheetToIntercept The full URL of the remote stylesheet to intercept (e.g., https://app.your-remote-environment.com/static/css/remote-control-styles.css).
|
|
88
|
+
* @param localBundlePath The local file path to the JavaScript bundle that should be served when the remote script URL is requested.
|
|
89
|
+
* @param localCssPath The local file path to the CSS file that should be served when the remote stylesheet URL is requested.
|
|
90
|
+
*/
|
|
80
91
|
function runSession(remoteEnvironmentUrl, remoteScriptToIntercept, remoteStylesheetToIntercept, localBundlePath, localCssPath) {
|
|
81
92
|
if (!remoteEnvironmentUrl) {
|
|
82
93
|
color_logger_1.default.error('❌ Remote environment URL is required. Please provide it via CLI, config file, or environment variable.');
|
|
83
94
|
process.exit(1);
|
|
84
95
|
}
|
|
96
|
+
if (!remoteScriptToIntercept) {
|
|
97
|
+
color_logger_1.default.error('❌ Remote script URL to intercept is required. Please provide it via CLI, config file, or environment variable.');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
if (!remoteStylesheetToIntercept) {
|
|
101
|
+
color_logger_1.default.error('❌ Remote stylesheet URL to intercept is required. Please provide it via CLI, config file, or environment variable.');
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
if (!localBundlePath) {
|
|
105
|
+
color_logger_1.default.error('❌ Local bundle path is required. Please provide it via CLI, config file, or environment variable.');
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
if (!localCssPath) {
|
|
109
|
+
color_logger_1.default.error('❌ Local CSS path is required. Please provide it via CLI, config file, or environment variable.');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
85
112
|
const REMOTE_ENVIRONMENT_URL = remoteEnvironmentUrl;
|
|
86
113
|
const REMOTE_SCRIPT_TO_INTERCEPT = remoteScriptToIntercept;
|
|
87
114
|
const REMOTE_STYLESHEET_TO_INTERCEPT = remoteStylesheetToIntercept;
|
|
@@ -180,7 +207,7 @@ function runSession(remoteEnvironmentUrl, remoteScriptToIntercept, remoteStylesh
|
|
|
180
207
|
return false;
|
|
181
208
|
}
|
|
182
209
|
// Match script URLs that end with the same path structure
|
|
183
|
-
return route.href.includes(scriptPattern)
|
|
210
|
+
return route.href.includes(scriptPattern);
|
|
184
211
|
}, (route) => __awaiter(this, void 0, void 0, function* () {
|
|
185
212
|
color_logger_1.default.log(`✅ Intercepted script request: ${route.request().url()}`);
|
|
186
213
|
color_logger_1.default.log(` Serving local file: ${LOCAL_BUNDLE_PATH}`);
|
|
@@ -195,7 +222,7 @@ function runSession(remoteEnvironmentUrl, remoteScriptToIntercept, remoteStylesh
|
|
|
195
222
|
return false;
|
|
196
223
|
}
|
|
197
224
|
// Match CSS URLs that end with the same path structure
|
|
198
|
-
return route.href.includes(stylesheetPattern)
|
|
225
|
+
return route.href.includes(stylesheetPattern);
|
|
199
226
|
}, (route) => __awaiter(this, void 0, void 0, function* () {
|
|
200
227
|
color_logger_1.default.log(`✅ Intercepted CSS request: ${route.request().url()}`);
|
|
201
228
|
color_logger_1.default.log(` Serving local file: ${LOCAL_CSS_PATH}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "Command line helper for building and publishing PCF controls to Dataverse.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./types/",
|
|
@@ -11,11 +11,17 @@
|
|
|
11
11
|
"repository": {
|
|
12
12
|
"url": "git+https://github.com/tywalk/pcf-helper.git"
|
|
13
13
|
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
14
18
|
"scripts": {
|
|
15
19
|
"test": "jest",
|
|
16
20
|
"build": "tsc",
|
|
17
21
|
"upgrade": "npm version patch --no-git-tag-version",
|
|
18
|
-
"ready": "npm run upgrade && npm run build
|
|
22
|
+
"ready": "npm run upgrade && npm run build",
|
|
23
|
+
"update": "npm run ready && npm publish --access public",
|
|
24
|
+
"temp": "echo $version"
|
|
19
25
|
},
|
|
20
26
|
"keywords": [
|
|
21
27
|
"pcf"
|
|
@@ -30,9 +36,13 @@
|
|
|
30
36
|
"pcf-helper-session": "dist/bin/session.js"
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
39
|
+
"@semantic-release/git": "^10.0.1",
|
|
40
|
+
"@semantic-release/github": "^12.0.6",
|
|
41
|
+
"@semantic-release/npm": "^13.1.5",
|
|
33
42
|
"@types/jest": "^29.5.14",
|
|
34
43
|
"@types/node": "^22.13.11",
|
|
35
44
|
"jest": "^29.7.0",
|
|
45
|
+
"semantic-release": "^25.0.3",
|
|
36
46
|
"ts-jest": "^29.2.6",
|
|
37
47
|
"typescript": "^5.8.2"
|
|
38
48
|
},
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads configuration for the session task, supporting a combination of config file, environment variables, and CLI arguments.
|
|
3
|
+
* The priority order is: CLI arguments > environment variables > config file > defaults.
|
|
4
|
+
* It also handles constructing full URLs for the script and stylesheet to intercept, allowing for relative paths in the config that are combined with the base URL.
|
|
5
|
+
* @param config Optional path to a JSON config file. If not provided, it will look for 'session.config.json' in the current working directory.
|
|
6
|
+
* @returns An object containing the resolved configuration values for the session task.
|
|
7
|
+
*/
|
|
1
8
|
declare function loadConfig(config?: string): {
|
|
2
9
|
remoteEnvironmentUrl?: undefined;
|
|
3
10
|
remoteScriptToIntercept?: undefined;
|
|
@@ -11,5 +18,15 @@ declare function loadConfig(config?: string): {
|
|
|
11
18
|
localCssPath: any;
|
|
12
19
|
localBundlePath: any;
|
|
13
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Runs an ephemeral browser session that intercepts requests to the specified remote script and stylesheet URLs, serving local files instead.
|
|
23
|
+
* It also manages session state by saving cookies and local storage to a file, allowing for persistent login sessions across runs.
|
|
24
|
+
* The session will automatically clean up and save state on exit, including handling various exit signals and browser events.
|
|
25
|
+
* @param remoteEnvironmentUrl The URL of the remote environment to navigate to.
|
|
26
|
+
* @param remoteScriptToIntercept The full URL of the remote script to intercept (e.g., https://app.your-remote-environment.com/static/js/remote-control-bundle.js).
|
|
27
|
+
* @param remoteStylesheetToIntercept The full URL of the remote stylesheet to intercept (e.g., https://app.your-remote-environment.com/static/css/remote-control-styles.css).
|
|
28
|
+
* @param localBundlePath The local file path to the JavaScript bundle that should be served when the remote script URL is requested.
|
|
29
|
+
* @param localCssPath The local file path to the CSS file that should be served when the remote stylesheet URL is requested.
|
|
30
|
+
*/
|
|
14
31
|
declare function runSession(remoteEnvironmentUrl: string, remoteScriptToIntercept: string, remoteStylesheetToIntercept: string, localBundlePath: string, localCssPath: string): void;
|
|
15
32
|
export { runSession, loadConfig };
|