@tywalk/pcf-helper-run 1.1.1 → 1.1.3

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/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  const upgradeTask = require('@tywalk/pcf-helper/tasks/upgrade-pcf');
3
3
  const buildTask = require('@tywalk/pcf-helper/tasks/build-pcf');
4
4
  const importTask = require('@tywalk/pcf-helper/tasks/import-pcf');
5
+ const { formatMsToSec } = require('./util/performanceUtil');
5
6
  const [, , ...args] = process.argv;
6
7
 
7
8
  const commandArgument = args.at(0)?.toLowerCase();
@@ -31,16 +32,34 @@ if (envIndex > 0) {
31
32
  env = args.at(envIndex);
32
33
  }
33
34
 
34
- if (commandArgument === 'upgrade' || runAll) {
35
- const upgradeResult = upgradeTask.run(path);
36
- if (upgradeResult === 1) return 1;
35
+ function executeTasks() {
36
+ if (commandArgument === 'upgrade' || runAll) {
37
+ const upgradeResult = upgradeTask.run(path);
38
+ if (upgradeResult === 1) return 1;
39
+ }
40
+ if (commandArgument === 'build' || runAll) {
41
+ const buildResult = buildTask.run(path);
42
+ if (buildResult === 1) return 1;
43
+ }
44
+ if (commandArgument === 'import' || runAll) {
45
+ const importResult = importTask.run(path, env);
46
+ if (importResult === 1) return 1;
47
+ }
48
+ return 0;
37
49
  }
38
- if (commandArgument === 'build' || runAll) {
39
- const buildResult = buildTask.run(path);
40
- if (buildResult === 1) return 1;
41
- }
42
- if (commandArgument === 'import' || runAll) {
43
- const importResult = importTask.run(path, env);
44
- if (importResult === 1) return 1;
50
+
51
+ var result = 0;
52
+ try {
53
+ result = executeTasks();
54
+ if (result === 0) {
55
+ console.log('Deploy complete!');
56
+ }
57
+ } catch (e) {
58
+ console.error('One or more tasks failed while deploying: ', (e && e.message) || 'unkown error');
59
+ result = 1;
60
+ } finally {
61
+ const tock = performance.now();
62
+ console.log('Deploy finished in %is.', formatMsToSec(tock - tick));
45
63
  }
46
- return 0;
64
+
65
+ return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tywalk/pcf-helper-run",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "A simple command-line utility for building and publishing PCF controls to Dataverse.",
5
5
  "scripts": {
6
6
  "test": "node test.js"
@@ -13,6 +13,6 @@
13
13
  "pcf-helper-run": "./index.js"
14
14
  },
15
15
  "dependencies": {
16
- "@tywalk/pcf-helper": "^1.4.1"
16
+ "@tywalk/pcf-helper": "^1.4.3"
17
17
  }
18
18
  }
@@ -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
+ }