@tywalk/pcf-helper 1.3.3 → 1.3.5

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/bin/deploy.js CHANGED
@@ -7,16 +7,18 @@ const [, , ...args] = process.argv;
7
7
  const pathArgument = args.find(a => ['-p', '--path'].includes(a));
8
8
  if (typeof pathArgument === 'undefined') {
9
9
  console.error('Path argument is required. Use --path to specify the path to solution folder.');
10
- return 0;
10
+ return 1;
11
11
  }
12
12
 
13
13
  const pathIndex = args.indexOf(pathArgument) + 1;
14
14
  const path = args.at(pathIndex);
15
15
  if (typeof path === 'undefined') {
16
16
  console.error('Path argument is required. Use --path to specify the path to solution folder.');
17
- return 0;
17
+ return 1;
18
18
  }
19
19
 
20
+ const tick = performance.now();
21
+
20
22
  const envArgument = args.find(a => ['-env', '--environment'].includes(a));
21
23
  let envIndex = args.indexOf(envArgument) + 1;
22
24
  let env = '';
@@ -24,6 +26,24 @@ if (envIndex > 0) {
24
26
  env = args.at(envIndex);
25
27
  }
26
28
 
27
- upgradeTask.run(path);
28
- buildTask.run(path);
29
- importTask.run(path, env);
29
+ function executeTasks() {
30
+ const upgradeResult = upgradeTask.run(path);
31
+ if (upgradeResult === 1) return 1;
32
+ const buildResult = buildTask.run(path);
33
+ if (buildResult === 1) return 1;
34
+ const importResult = importTask.run(path, env);
35
+ if (importResult === 1) return 1;
36
+ return 0;
37
+ }
38
+
39
+ try {
40
+ const result = executeTasks();
41
+ if (result === 0) {
42
+ console.log('Deploy complete!');
43
+ }
44
+ } catch (e) {
45
+ console.error('One or more tasks failed while deploying: ', (e && e.message) || 'unkown error');
46
+ } finally {
47
+ const tock = performance.now();
48
+ console.log('Deploy finished in %d ms.', tick - tock);
49
+ }
package/bin/upgrade.js CHANGED
@@ -5,14 +5,14 @@ const [, , ...args] = process.argv;
5
5
  const pathArgument = args.find(a => ['-p', '--path'].includes(a));
6
6
  if (typeof pathArgument === 'undefined') {
7
7
  console.error('Path argument is required. Use --path to specify the path to solution folder.');
8
- return 0;
8
+ return 1;
9
9
  }
10
10
 
11
11
  const pathIndex = args.indexOf(pathArgument) + 1;
12
12
  const path = args.at(pathIndex);
13
13
  if (typeof path === 'undefined') {
14
14
  console.error('Path argument is required. Use --path to specify the path to solution folder.');
15
- return 0;
15
+ return 1;
16
16
  }
17
17
 
18
18
  task.run(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Command line helper for building and publishing PCF controls to Dataverse.",
5
5
  "scripts": {
6
6
  "test": "node test.js"
@@ -1,13 +1,27 @@
1
1
  const { spawnSync } = require('child_process');
2
2
 
3
3
  function run(path) {
4
+ const tick = performance.now();
4
5
  const task = spawnSync('dotnet build', ['--restore', '-c', 'Release', path], {
5
6
  cwd: process.cwd(),
6
7
  stdio: 'inherit',
7
- shell: true
8
+ shell: true,
9
+ timeout: 1000 * 60 * 5 // 5 minutes
8
10
  });
11
+ const tock = performance.now();
9
12
 
10
- console.log('Build complete!: ', task.status);
13
+ if (task.status === 0) {
14
+ console.log('Build complete!');
15
+ } else {
16
+ if (task.error) {
17
+ console.error('Unable to complete build: ', task.error.message);
18
+ console.debug('Error details: ', task.error.name, task.error.stack);
19
+ } else {
20
+ console.error('Unable to complete build: One or more errors ocurred.');
21
+ }
22
+ }
23
+ console.log('Build finished in %d ms.', tick - tock);
24
+ return task.status;
11
25
  }
12
26
 
13
27
  exports.run = run;
@@ -3,6 +3,7 @@ const { join, extname } = require('path');
3
3
  const fs = require('fs');
4
4
 
5
5
  function run(path, env) {
6
+ const tick = performance.now();
6
7
  if (!env) {
7
8
  console.warn('Path argument not provided. Assuming active auth profile organization.');
8
9
  }
@@ -16,10 +17,23 @@ function run(path, env) {
16
17
  const task = spawnSync('pac solution import', ['-env', env, '-p', zipFilePath, '-pc'], {
17
18
  cwd: process.cwd(),
18
19
  stdio: 'inherit',
19
- shell: true
20
+ shell: true,
21
+ timeout: 1000 * 60 * 2 // 2 minutes
20
22
  });
23
+ const tock = performance.now();
21
24
 
22
- console.log('Import complete!: ', task.status);
25
+ if (task.status === 0) {
26
+ console.log('Import complete!');
27
+ } else {
28
+ if (task.error) {
29
+ console.error('Unable to complete import: ', task.error.message);
30
+ console.debug('Error details: ', task.error.name, task.error.stack);
31
+ } else {
32
+ console.error('Unable to complete import: One or more errors ocurred.');
33
+ }
34
+ }
35
+ console.log('Import finished in %d ms.', tick - tock);
36
+ return task.status;
23
37
  }
24
38
 
25
39
  exports.run = run;
@@ -1,13 +1,27 @@
1
1
  const { spawnSync } = require('child_process');
2
2
 
3
3
  function run(path) {
4
+ const tick = performance.now();
4
5
  const task = spawnSync(`pac solution version -s Solution -sp ${path} && pac pcf version -s Manifest && npm version patch`, {
5
6
  cwd: process.cwd(),
6
7
  stdio: 'inherit',
7
- shell: true
8
+ shell: true,
9
+ timeout: 1000 * 60 // 1 min
8
10
  });
11
+ const tock = performance.now();
9
12
 
10
- console.log('Upgrade complete!: ', task.status);
13
+ if (task.status === 0) {
14
+ console.log('Upgrade complete!');
15
+ } else {
16
+ if (task.error) {
17
+ console.error('Unable to complete upgrade: ', task.error.message);
18
+ console.debug('Error details: ', task.error.name, task.error.stack);
19
+ } else {
20
+ console.error('Unable to complete upgrade: One or more errors ocurred.');
21
+ }
22
+ }
23
+ console.log('Upgrade finished in %d ms.', tick - tock);
24
+ return task.status;
11
25
  }
12
26
 
13
27
  exports.run = run;