@tywalk/pcf-helper 1.4.0 → 1.4.2

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
@@ -2,6 +2,7 @@
2
2
  const upgradeTask = require('../tasks/upgrade-pcf');
3
3
  const buildTask = require('../tasks/build-pcf');
4
4
  const importTask = require('../tasks/import-pcf');
5
+ const { formatMsToSec } = require('../util/performanceUtil');
5
6
  const [, , ...args] = process.argv;
6
7
 
7
8
  const pathArgument = args.find(a => ['-p', '--path'].includes(a));
@@ -36,14 +37,18 @@ function executeTasks() {
36
37
  return 0;
37
38
  }
38
39
 
40
+ var result = 0;
39
41
  try {
40
- const result = executeTasks();
42
+ result = executeTasks();
41
43
  if (result === 0) {
42
44
  console.log('Deploy complete!');
43
45
  }
44
46
  } catch (e) {
45
47
  console.error('One or more tasks failed while deploying: ', (e && e.message) || 'unkown error');
48
+ result = 1;
46
49
  } finally {
47
50
  const tock = performance.now();
48
- console.log('Deploy finished in %i ms.', tock - tick);
49
- }
51
+ console.log('Deploy finished in %is.', formatMsToSec(tock - tick));
52
+ }
53
+
54
+ return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Command line helper for building and publishing PCF controls to Dataverse.",
5
5
  "scripts": {
6
6
  "test": "node test.js"
@@ -1,4 +1,5 @@
1
1
  const { spawnSync } = require('child_process');
2
+ const { formatMsToSec } = require('../util/performanceUtil');
2
3
 
3
4
  function run(path) {
4
5
  const tick = performance.now();
@@ -14,13 +15,17 @@ function run(path) {
14
15
  console.log('Build complete!');
15
16
  } else {
16
17
  if (task.error) {
17
- console.error('Unable to complete build: ', task.error.message);
18
+ if (task.signal === 'SIGKILL') {
19
+ console.error('Unable to complete build. A timeout of 5 minutes was reached.', task.error.message);
20
+ } else {
21
+ console.error('Unable to complete build: ', task.error.message);
22
+ }
18
23
  console.debug('Error details: ', task.error.name, task.error.stack);
19
24
  } else {
20
25
  console.error('Unable to complete build: One or more errors ocurred.');
21
26
  }
22
27
  }
23
- console.log('Build finished in %i ms.', tock - tick);
28
+ console.log('Build finished in %is.', formatMsToSec(tock - tick));
24
29
  return task.status;
25
30
  }
26
31
 
@@ -1,8 +1,9 @@
1
1
  const { spawnSync } = require('child_process');
2
2
  const { join, extname } = require('path');
3
3
  const fs = require('fs');
4
+ const { formatMsToSec } = require('../util/performanceUtil');
4
5
 
5
- function run(path, env) {
6
+ function run(path, env, verbose) {
6
7
  const tick = performance.now();
7
8
  if (!env) {
8
9
  console.warn('Path argument not provided. Assuming active auth profile organization.');
@@ -18,7 +19,7 @@ function run(path, env) {
18
19
  cwd: process.cwd(),
19
20
  stdio: 'inherit',
20
21
  shell: true,
21
- timeout: 1000 * 60 * 2 // 2 minutes
22
+ timeout: 1000 * 60 * 5 // 5 minutes
22
23
  });
23
24
  const tock = performance.now();
24
25
 
@@ -26,13 +27,19 @@ function run(path, env) {
26
27
  console.log('Import complete!');
27
28
  } else {
28
29
  if (task.error) {
29
- console.error('Unable to complete import: ', task.error.message);
30
- console.debug('Error details: ', task.error.name, task.error.stack);
30
+ if (task.signal === 'SIGKILL') {
31
+ console.error('Unable to complete import. A timeout of 5 minutes was reached.', task.error.message);
32
+ } else {
33
+ console.error('Unable to complete import:', task.signal, task.error.message);
34
+ }
35
+ if (verbose) {
36
+ console.debug('Error details:', task.signal, task.error.stack);
37
+ }
31
38
  } else {
32
39
  console.error('Unable to complete import: One or more errors ocurred.');
33
40
  }
34
41
  }
35
- console.log('Import finished in %i ms.', tock - tick);
42
+ console.log('Import finished in %is.', formatMsToSec(tock - tick));
36
43
  return task.status;
37
44
  }
38
45
 
@@ -1,4 +1,5 @@
1
1
  const { spawnSync } = require('child_process');
2
+ const { formatMsToSec } = require('../util/performanceUtil');
2
3
 
3
4
  function run(path) {
4
5
  const tick = performance.now();
@@ -14,13 +15,17 @@ function run(path) {
14
15
  console.log('Upgrade complete!');
15
16
  } else {
16
17
  if (task.error) {
17
- console.error('Unable to complete upgrade: ', task.error.message);
18
+ if (task.signal === 'SIGKILL') {
19
+ console.error('Unable to complete upgrade. A timeout of 1 minutes was reached.', task.error.message);
20
+ } else {
21
+ console.error('Unable to complete upgrade: ', task.error.message);
22
+ }
18
23
  console.debug('Error details: ', task.error.name, task.error.stack);
19
24
  } else {
20
25
  console.error('Unable to complete upgrade: One or more errors ocurred.');
21
26
  }
22
27
  }
23
- console.log('Upgrade finished in %i ms.', tock - tick);
28
+ console.log('Upgrade finished in %is.', formatMsToSec(tock - tick));
24
29
  return task.status;
25
30
  }
26
31
 
@@ -0,0 +1,10 @@
1
+ const util = require('node:util');
2
+
3
+ function formatMsToSec(ms, format) {
4
+ const seconds = ms / 1000;
5
+ return util.format(format, seconds);
6
+ }
7
+
8
+ module.exports = {
9
+ formatMsToSec
10
+ }