@tywalk/pcf-helper-run 1.2.15 → 1.3.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.
package/README.md CHANGED
@@ -250,6 +250,22 @@ pcf-helper-run session [options]
250
250
  - `-b, --bundle <path>` - Local bundle path
251
251
  - `-c, --css <path>` - Local CSS path
252
252
  - `-f, --config <path>` - Config file path (default: `session.config.json`)
253
+ - `-w, --watch` - Start pcf-scripts watch process to automatically rebuild on changes
254
+
255
+ #### Configuration File
256
+
257
+ Create a `session.config.json` file in your project root to avoid passing parameters repeatedly:
258
+
259
+ ```json
260
+ {
261
+ "remoteEnvironmentUrl": "https://contoso-dev.crm.dynamics.com",
262
+ "remoteScriptToIntercept": "/webresources/pub_MyControl/bundle.js",
263
+ "remoteStylesheetToIntercept": "/webresources/pub_MyControl/css/MyControl.css",
264
+ "localBundlePath": "./out/controls/MyControl/bundle.js",
265
+ "localCssPath": "./out/controls/MyControl/css/MyControl.css",
266
+ "startWatch": false
267
+ }
268
+ ```
253
269
 
254
270
  #### Examples
255
271
 
@@ -258,7 +274,13 @@ pcf-helper-run session [options]
258
274
  pcf-helper-run session
259
275
 
260
276
  # Session with custom configuration
261
- pcf-helper-run session -u "https://contoso.crm.dynamics.com" -s ./bundle.js
277
+ pcf-helper-run session -u "https://contoso.crm.dynamics.com" -s /webresources/pub_MyControl/bundle.js -b ./bundle.js
278
+
279
+ # Session with watch mode for automatic rebuilds
280
+ pcf-helper-run session --watch
281
+
282
+ # Session with custom config file
283
+ pcf-helper-run session -f ./my-session.config.json
262
284
  ```
263
285
 
264
286
  ## ⚙️ Global Options
@@ -390,8 +412,8 @@ pcf-helper-run deploy --help
390
412
 
391
413
  ### Documentation Links
392
414
 
393
- - [Power Platform Component Framework Documentation](https://docs.microsoft.com/en-us/powerapps/developer/component-framework/)
394
- - [Power Platform CLI Documentation](https://docs.microsoft.com/en-us/powerapps/developer/data-platform/powerapps-cli)
415
+ - [Power Platform Component Framework Documentation](https://learn.microsoft.com/en-us/power-apps/developer/component-framework/overview)
416
+ - [Power Platform CLI Documentation](https://learn.microsoft.com/en-us/power-platform/developer/cli/introduction)
395
417
  - [PCF Community Gallery](https://pcf.gallery/)
396
418
 
397
419
  ## 🔗 Related Packages
@@ -38,18 +38,12 @@ const package_json_1 = require("../package.json");
38
38
  const tasks = __importStar(require("@tywalk/pcf-helper"));
39
39
  test('displays version', (done) => {
40
40
  const task = (0, child_process_1.spawn)('node', ['./dist/index.js', '--version']);
41
- // Add timeout
42
- const timeout = setTimeout(() => {
43
- task.kill();
44
- done.fail('Test timed out');
45
- }, 5000);
46
41
  let output = '';
47
42
  task.stdout.on('data', (data) => {
48
43
  output += data.toString();
49
44
  });
50
45
  task.on('close', (code) => {
51
- clearTimeout(timeout);
52
- console.log(output);
46
+ console.log('Output:', output);
53
47
  expect(output).toContain(package_json_1.version);
54
48
  expect(code).toBe(0);
55
49
  done();
@@ -57,11 +51,6 @@ test('displays version', (done) => {
57
51
  }, 10000);
58
52
  test('errors if no path is provided', (done) => {
59
53
  const task = (0, child_process_1.spawn)('node', ['./dist/index.js', 'build']);
60
- // Add timeout
61
- const timeout = setTimeout(() => {
62
- task.kill();
63
- done.fail('Test timed out');
64
- }, 5000);
65
54
  let output = '';
66
55
  task.stdout.on('data', (data) => {
67
56
  output += data.toString();
@@ -70,8 +59,7 @@ test('errors if no path is provided', (done) => {
70
59
  console.error(`stderr: ${data}`);
71
60
  });
72
61
  task.on('close', (code) => {
73
- clearTimeout(timeout);
74
- console.log(output);
62
+ console.log('Output:', output);
75
63
  // The command should exit with non-zero code when required path is missing
76
64
  expect(code).not.toBe(0);
77
65
  done();
@@ -79,11 +67,6 @@ test('errors if no path is provided', (done) => {
79
67
  }, 10000);
80
68
  test('errors if incorrect command is provided', (done) => {
81
69
  const task = (0, child_process_1.spawn)('node', ['./dist/index.js', 'invalidcommand']);
82
- // Add timeout
83
- const timeout = setTimeout(() => {
84
- task.kill();
85
- done.fail('Test timed out');
86
- }, 5000);
87
70
  let output = '';
88
71
  task.stdout.on('data', (data) => {
89
72
  output += data.toString();
@@ -92,8 +75,7 @@ test('errors if incorrect command is provided', (done) => {
92
75
  console.error(`stderr: ${data}`);
93
76
  });
94
77
  task.on('close', (code) => {
95
- clearTimeout(timeout);
96
- console.log(output);
78
+ console.log('Output:', output);
97
79
  // Invalid command should exit with non-zero code
98
80
  expect(code).not.toBe(0);
99
81
  done();
package/dist/index.js CHANGED
@@ -69,8 +69,12 @@ commander_1.program
69
69
  .name('pcf-helper-run')
70
70
  .description('A simple command-line utility for building and publishing PCF controls to Dataverse.')
71
71
  .version(package_json_1.version);
72
+ // Helper function to add verbose option to commands
73
+ const withVerboseOption = (command) => {
74
+ return command.option('-v, --verbose', 'enable verbose logging');
75
+ };
72
76
  // Global options for commands that need them
73
- const addCommonOptions = (command) => {
77
+ const withCommonOptions = (command) => {
74
78
  return command
75
79
  .option('-v, --verbose', 'enable verbose logging')
76
80
  .option('-t, --timeout <milliseconds>', 'timeout in milliseconds', (value) => {
@@ -81,8 +85,8 @@ const addCommonOptions = (command) => {
81
85
  return value;
82
86
  });
83
87
  };
84
- const addPathOptions = (command) => {
85
- return addCommonOptions(command)
88
+ const withPathOptions = (command) => {
89
+ return withCommonOptions(command)
86
90
  .option('-p, --path <path>', 'path to solution folder')
87
91
  .option('-e, --environment <environment>', 'environment name')
88
92
  .option('--env <environment>', '[DEPRECATED: use -e/--environment] environment name (deprecated)');
@@ -138,7 +142,7 @@ const handleResults = (taskName, logger, tick, result) => {
138
142
  }
139
143
  };
140
144
  // Define the upgrade command
141
- addPathOptions(commander_1.program.command('upgrade'))
145
+ withPathOptions(commander_1.program.command('upgrade'))
142
146
  .description('upgrade PCF controls')
143
147
  .action((options) => {
144
148
  const { logger, tick } = setupExecutionContext(options);
@@ -152,13 +156,13 @@ addPathOptions(commander_1.program.command('upgrade'))
152
156
  result = tasks.runUpgrade(options.path, options.verbose || false);
153
157
  }
154
158
  catch (e) {
155
- logger.error('[PCF Helper Run] One or more tasks failed while upgrading: ', (e && e.message) || 'unknown error');
159
+ logger.error('[PCF Helper Run] One or more tasks failed while upgrading: ', e instanceof Error ? e.message : 'unknown error');
156
160
  result = 1;
157
161
  }
158
162
  handleResults('upgrade', logger, tick, result);
159
163
  });
160
164
  // Define the build command
161
- addPathOptions(commander_1.program.command('build'))
165
+ withPathOptions(commander_1.program.command('build'))
162
166
  .description('build PCF controls')
163
167
  .action((options) => {
164
168
  const { logger, tick } = setupExecutionContext(options);
@@ -172,13 +176,13 @@ addPathOptions(commander_1.program.command('build'))
172
176
  result = tasks.runBuild(options.path, options.verbose || false, options.timeout ? Number(options.timeout) : undefined);
173
177
  }
174
178
  catch (e) {
175
- logger.error('[PCF Helper Run] One or more tasks failed while building: ', (e && e.message) || 'unknown error');
179
+ logger.error('[PCF Helper Run] One or more tasks failed while building: ', e instanceof Error ? e.message : 'unknown error');
176
180
  result = 1;
177
181
  }
178
182
  handleResults('build', logger, tick, result);
179
183
  });
180
184
  // Define the import command
181
- addPathOptions(commander_1.program.command('import'))
185
+ withPathOptions(commander_1.program.command('import'))
182
186
  .description('import PCF controls')
183
187
  .action((options) => {
184
188
  const { logger, tick } = setupExecutionContext(options);
@@ -196,13 +200,13 @@ addPathOptions(commander_1.program.command('import'))
196
200
  result = tasks.runImport(options.path, env, options.verbose || false, options.timeout ? Number(options.timeout) : undefined);
197
201
  }
198
202
  catch (e) {
199
- logger.error('[PCF Helper Run] One or more tasks failed while importing: ', (e && e.message) || 'unknown error');
203
+ logger.error('[PCF Helper Run] One or more tasks failed while importing: ', e instanceof Error ? e.message : 'unknown error');
200
204
  result = 1;
201
205
  }
202
206
  handleResults('import', logger, tick, result);
203
207
  });
204
208
  // Define the deploy command (runs upgrade, build, and import)
205
- addPathOptions(commander_1.program.command('deploy'))
209
+ withPathOptions(commander_1.program.command('deploy'))
206
210
  .description('deploy PCF controls (runs upgrade, build, and import)')
207
211
  .action((options) => {
208
212
  const { logger, tick } = setupExecutionContext(options);
@@ -238,34 +242,36 @@ addPathOptions(commander_1.program.command('deploy'))
238
242
  }
239
243
  }
240
244
  catch (e) {
241
- logger.error('[PCF Helper Run] One or more tasks failed while deploying: ', (e && e.message) || 'unknown error');
245
+ logger.error('[PCF Helper Run] One or more tasks failed while deploying: ', e instanceof Error ? e.message : 'unknown error');
242
246
  result = 1;
243
247
  }
244
248
  handleResults('deploy', logger, tick, result);
245
249
  });
246
250
  // Define the init command
247
- addCommonOptions(commander_1.program.command('init'))
251
+ withVerboseOption(commander_1.program.command('init'))
248
252
  .description('initialize a new PCF project')
249
253
  .requiredOption('-p, --path <path>', 'path to PCF folder')
250
254
  .requiredOption('-n, --name <name>', 'name of the control')
251
255
  .requiredOption('--publisher-name <publisherName>', 'publisher name')
252
256
  .requiredOption('--publisher-prefix <publisherPrefix>', 'publisher prefix')
257
+ .option('-t, --template <template>', 'template for the component (field|dataset)', 'field')
258
+ .option('-f, --framework <framework>', 'rendering framework for control (none|react)', 'react')
253
259
  .option('--run-npm-install', 'run npm install after initialization', true)
254
260
  .action((options) => {
255
261
  const { logger, tick } = setupExecutionContext(options);
256
262
  let result = 0;
257
263
  try {
258
264
  logger.log('[PCF Helper Run] ' + (0, performanceUtil_1.formatTime)(new Date()) + ' init started.\n');
259
- result = tasks.runInit(options.path, options.name, options.publisherName, options.publisherPrefix, options.runNpmInstall !== false, options.verbose || false);
265
+ result = tasks.runInit(options.path, options.name, options.publisherName, options.publisherPrefix, options.template || 'field', options.framework || 'react', options.runNpmInstall !== false, options.verbose || false);
260
266
  }
261
267
  catch (e) {
262
- logger.error('[PCF Helper Run] One or more tasks failed while initializing: ', (e && e.message) || 'unknown error');
268
+ logger.error('[PCF Helper Run] One or more tasks failed while initializing: ', e instanceof Error ? e.message : 'unknown error');
263
269
  result = 1;
264
270
  }
265
271
  handleResults('init', logger, tick, result);
266
272
  });
267
273
  // Define the session command
268
- addCommonOptions(commander_1.program.command('session'))
274
+ withCommonOptions(commander_1.program.command('session'))
269
275
  .description('run development session')
270
276
  .option('-u, --url <url>', 'remote environment URL')
271
277
  .option('-i, --intercept-script <script>', 'remote script to intercept')
@@ -290,7 +296,7 @@ addCommonOptions(commander_1.program.command('session'))
290
296
  logger.log((0, performanceUtil_1.formatMsToSec)('Session started successfully in %is.', tock - tick));
291
297
  }
292
298
  catch (e) {
293
- logger.error('[PCF Helper Run] One or more tasks failed during session or session startup: ', (e && e.message) || 'unknown error');
299
+ logger.error('[PCF Helper Run] One or more tasks failed during session or session startup: ', e instanceof Error ? e.message : 'unknown error');
294
300
  }
295
301
  }));
296
302
  // Parse the command line arguments
package/dist/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper-run",
3
- "version": "1.2.14",
4
- "description": "A simple command-line utility for building and publishing PCF controls to Dataverse.",
3
+ "version": "1.2.16",
4
+ "description": "Unified CLI interface for Power Platform Component Framework (PCF) development — init, build, import, deploy, and manage PCF controls in Dataverse.",
5
+ "main": "dist/index.js",
5
6
  "types": "./types/",
6
7
  "files": [
7
8
  "dist",
@@ -22,15 +23,36 @@
22
23
  "update": "npm run ready && npm publish --access public"
23
24
  },
24
25
  "keywords": [
25
- "pcf"
26
+ "pcf",
27
+ "pcf-control",
28
+ "pcf-component",
29
+ "power-platform",
30
+ "powerapps",
31
+ "power-apps",
32
+ "dataverse",
33
+ "dynamics-365",
34
+ "microsoft",
35
+ "cli",
36
+ "command-line",
37
+ "developer-tools",
38
+ "build-tool",
39
+ "deployment",
40
+ "automation",
41
+ "typescript",
42
+ "pac"
26
43
  ],
44
+ "license": "MIT",
27
45
  "author": "tywalk",
46
+ "homepage": "https://github.com/tywalk/pcf-helper#readme",
47
+ "engines": {
48
+ "node": ">=16.0.0"
49
+ },
28
50
  "bin": {
29
51
  "pcf-helper-run": "dist/index.js"
30
52
  },
31
53
  "dependencies": {
32
54
  "@tywalk/color-logger": "^1.0.3",
33
- "@tywalk/pcf-helper": "^1.6.0"
55
+ "@tywalk/pcf-helper": "^1.9.0"
34
56
  },
35
57
  "devDependencies": {
36
58
  "@semantic-release/git": "^10.0.1",
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.formatMsToSec = formatMsToSec;
7
7
  exports.formatTime = formatTime;
8
8
  const util_1 = __importDefault(require("util"));
9
- var formatter = new Intl.DateTimeFormat('en-US', {
9
+ const formatter = new Intl.DateTimeFormat('en-US', {
10
10
  hour: '2-digit',
11
11
  minute: '2-digit',
12
12
  second: '2-digit',
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper-run",
3
- "version": "1.2.15",
4
- "description": "A simple command-line utility for building and publishing PCF controls to Dataverse.",
3
+ "version": "1.3.0",
4
+ "description": "Unified CLI interface for Power Platform Component Framework (PCF) development — init, build, import, deploy, and manage PCF controls in Dataverse.",
5
+ "main": "dist/index.js",
5
6
  "types": "./types/",
6
7
  "files": [
7
8
  "dist",
@@ -22,15 +23,36 @@
22
23
  "update": "npm run ready && npm publish --access public"
23
24
  },
24
25
  "keywords": [
25
- "pcf"
26
+ "pcf",
27
+ "pcf-control",
28
+ "pcf-component",
29
+ "power-platform",
30
+ "powerapps",
31
+ "power-apps",
32
+ "dataverse",
33
+ "dynamics-365",
34
+ "microsoft",
35
+ "cli",
36
+ "command-line",
37
+ "developer-tools",
38
+ "build-tool",
39
+ "deployment",
40
+ "automation",
41
+ "typescript",
42
+ "pac"
26
43
  ],
44
+ "license": "MIT",
27
45
  "author": "tywalk",
46
+ "homepage": "https://github.com/tywalk/pcf-helper#readme",
47
+ "engines": {
48
+ "node": ">=16.0.0"
49
+ },
28
50
  "bin": {
29
51
  "pcf-helper-run": "dist/index.js"
30
52
  },
31
53
  "dependencies": {
32
54
  "@tywalk/color-logger": "^1.0.3",
33
- "@tywalk/pcf-helper": "^1.6.0"
55
+ "@tywalk/pcf-helper": "^1.9.0"
34
56
  },
35
57
  "devDependencies": {
36
58
  "@semantic-release/git": "^10.0.1",
@@ -1,2 +1,2 @@
1
1
  export declare function getArg(args: string[], arg: string): string | undefined;
2
- export declare function getArgValue(args: string[], argOpts: string[], defaultIfExists?: any): string | undefined;
2
+ export declare function getArgValue(args: string[], argOpts: string[], defaultIfExists?: string): string | undefined;