@tywalk/pcf-helper-run 1.2.16 → 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
@@ -252,6 +252,21 @@ pcf-helper-run session [options]
252
252
  - `-f, --config <path>` - Config file path (default: `session.config.json`)
253
253
  - `-w, --watch` - Start pcf-scripts watch process to automatically rebuild on changes
254
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
+ ```
269
+
255
270
  #### Examples
256
271
 
257
272
  ```bash
@@ -259,10 +274,13 @@ pcf-helper-run session [options]
259
274
  pcf-helper-run session
260
275
 
261
276
  # Session with custom configuration
262
- 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
263
278
 
264
279
  # Session with watch mode for automatic rebuilds
265
280
  pcf-helper-run session --watch
281
+
282
+ # Session with custom config file
283
+ pcf-helper-run session -f ./my-session.config.json
266
284
  ```
267
285
 
268
286
  ## ⚙️ Global Options
@@ -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);
@@ -158,7 +162,7 @@ addPathOptions(commander_1.program.command('upgrade'))
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);
@@ -178,7 +182,7 @@ addPathOptions(commander_1.program.command('build'))
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);
@@ -202,7 +206,7 @@ addPathOptions(commander_1.program.command('import'))
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);
@@ -244,19 +248,21 @@ addPathOptions(commander_1.program.command('deploy'))
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
268
  logger.error('[PCF Helper Run] One or more tasks failed while initializing: ', e instanceof Error ? e.message : 'unknown error');
@@ -265,7 +271,7 @@ addCommonOptions(commander_1.program.command('init'))
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')
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper-run",
3
- "version": "1.2.15",
3
+ "version": "1.2.16",
4
4
  "description": "Unified CLI interface for Power Platform Component Framework (PCF) development — init, build, import, deploy, and manage PCF controls in Dataverse.",
5
5
  "main": "dist/index.js",
6
6
  "types": "./types/",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@tywalk/color-logger": "^1.0.3",
55
- "@tywalk/pcf-helper": "^1.6.0"
55
+ "@tywalk/pcf-helper": "^1.9.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@semantic-release/git": "^10.0.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper-run",
3
- "version": "1.2.16",
3
+ "version": "1.3.0",
4
4
  "description": "Unified CLI interface for Power Platform Component Framework (PCF) development — init, build, import, deploy, and manage PCF controls in Dataverse.",
5
5
  "main": "dist/index.js",
6
6
  "types": "./types/",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@tywalk/color-logger": "^1.0.3",
55
- "@tywalk/pcf-helper": "^1.6.0"
55
+ "@tywalk/pcf-helper": "^1.9.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@semantic-release/git": "^10.0.1",