@tywalk/pcf-helper 1.4.13 → 1.4.15
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 +2 -1
- package/package.json +21 -10
- package/__tests__/pcf-helper-build.test.js +0 -41
- package/__tests__/pcf-helper-deploy.test.js +0 -37
- package/__tests__/pcf-helper-import.test.js +0 -37
- package/__tests__/pcf-helper-upgrade.test.js +0 -37
- package/bin/build.js +0 -33
- package/bin/deploy.js +0 -69
- package/bin/import.js +0 -40
- package/bin/upgrade.js +0 -33
- package/tasks/build-pcf.js +0 -42
- package/tasks/import-pcf.js +0 -59
- package/tasks/upgrade-pcf.js +0 -42
- package/util/performanceUtil.js +0 -37
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ This tool requires the following:
|
|
|
21
21
|
"upgrade": "pcf-helper-upgrade --path <path to pcf project folder>",
|
|
22
22
|
"build": "pcf-helper-build --path <path to pcf project folder>",
|
|
23
23
|
"import": "pcf-helper-import --path <path to pcf project folder> --environment <environment guid or url>",
|
|
24
|
-
"deploy": "pcf-helper-deploy --path <path to pcf project folder> --environment <environment guid or url>"
|
|
24
|
+
"deploy": "pcf-helper-deploy --path <path to pcf project folder> --environment <environment guid or url>",
|
|
25
|
+
"init": "pcf-helper-init --path <path to pcf project folder (optional)> --name <name of the pcf project> --publisher-name <powerapps publisher name> --publisher-prefix <powerapps publisher prefix>"
|
|
25
26
|
},
|
|
26
27
|
```
|
package/package.json
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tywalk/pcf-helper",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.15",
|
|
4
4
|
"description": "Command line helper for building and publishing PCF controls to Dataverse.",
|
|
5
|
+
"types": "./types/",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"types"
|
|
9
|
+
],
|
|
5
10
|
"repository": {
|
|
6
11
|
"url": "git+https://github.com/tywalk/pcf-helper.git"
|
|
7
12
|
},
|
|
8
13
|
"scripts": {
|
|
9
|
-
"test": "jest"
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"upgrade": "npm version patch --no-git-tag-version",
|
|
17
|
+
"ready": "npm run upgrade && npm run build"
|
|
10
18
|
},
|
|
11
19
|
"keywords": [
|
|
12
20
|
"pcf"
|
|
13
21
|
],
|
|
14
22
|
"author": "tywalk",
|
|
15
23
|
"bin": {
|
|
16
|
-
"pcf-helper-upgrade": "bin/upgrade.js",
|
|
17
|
-
"pcf-helper-build": "bin/build.js",
|
|
18
|
-
"pcf-helper-import": "bin/import.js",
|
|
19
|
-
"pcf-helper-deploy": "bin/deploy.js"
|
|
20
|
-
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@tywalk/color-logger": "^1.0.1"
|
|
24
|
+
"pcf-helper-upgrade": "dist/bin/upgrade.js",
|
|
25
|
+
"pcf-helper-build": "dist/bin/build.js",
|
|
26
|
+
"pcf-helper-import": "dist/bin/import.js",
|
|
27
|
+
"pcf-helper-deploy": "dist/bin/deploy.js",
|
|
28
|
+
"pcf-helper-init": "dist/bin/init.js"
|
|
23
29
|
},
|
|
24
30
|
"devDependencies": {
|
|
25
|
-
"jest": "^29.
|
|
31
|
+
"@types/jest": "^29.5.14",
|
|
32
|
+
"@types/node": "^22.13.11",
|
|
33
|
+
"@tywalk/color-logger": "^1.0.3",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"ts-jest": "^29.2.6",
|
|
36
|
+
"typescript": "^5.8.2"
|
|
26
37
|
}
|
|
27
38
|
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const version = require('../package.json').version;
|
|
3
|
-
|
|
4
|
-
test('build displays version', (done) => {
|
|
5
|
-
const task = spawn('node', ['./bin/build.js', '-v']);
|
|
6
|
-
|
|
7
|
-
let output = '';
|
|
8
|
-
task.stdout.on('data', (data) => {
|
|
9
|
-
output += data.toString();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
task.stderr.on('data', (data) => {
|
|
13
|
-
console.error(`stderr: ${data}`);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
task.on('close', (code) => {
|
|
17
|
-
console.log(output);
|
|
18
|
-
expect(output).toContain(version);
|
|
19
|
-
expect(code).toBe(0);
|
|
20
|
-
done();
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('build errors if no path is provided', (done) => {
|
|
25
|
-
const task = spawn('node', ['./bin/build.js', '-p']);
|
|
26
|
-
|
|
27
|
-
let output = '';
|
|
28
|
-
task.stdout.on('data', (data) => {
|
|
29
|
-
output += data.toString();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
task.stderr.on('data', (data) => {
|
|
33
|
-
console.error(`stderr: ${data}`);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
task.on('close', (code) => {
|
|
37
|
-
console.log(output);
|
|
38
|
-
expect(code).toBe(1);
|
|
39
|
-
done();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const version = require('../package.json').version;
|
|
3
|
-
|
|
4
|
-
test('deploy displays version', (done) => {
|
|
5
|
-
const task = spawn('node', ['./bin/deploy.js', '-v']);
|
|
6
|
-
|
|
7
|
-
let output = '';
|
|
8
|
-
task.stdout.on('data', (data) => {
|
|
9
|
-
output += data.toString();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
task.on('close', (code) => {
|
|
13
|
-
console.log(output);
|
|
14
|
-
expect(output).toContain(version);
|
|
15
|
-
expect(code).toBe(0);
|
|
16
|
-
done();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('deploy errors if no path is provided', (done) => {
|
|
21
|
-
const task = spawn('node', ['./bin/deploy.js', '-p']);
|
|
22
|
-
|
|
23
|
-
let output = '';
|
|
24
|
-
task.stdout.on('data', (data) => {
|
|
25
|
-
output += data.toString();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
task.stderr.on('data', (data) => {
|
|
29
|
-
console.error(`stderr: ${data}`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
task.on('close', (code) => {
|
|
33
|
-
console.log(output);
|
|
34
|
-
expect(code).toBe(1);
|
|
35
|
-
done();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const version = require('../package.json').version;
|
|
3
|
-
|
|
4
|
-
test('import displays version', (done) => {
|
|
5
|
-
const task = spawn('node', ['./bin/import.js', '-v']);
|
|
6
|
-
|
|
7
|
-
let output = '';
|
|
8
|
-
task.stdout.on('data', (data) => {
|
|
9
|
-
output += data.toString();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
task.on('close', (code) => {
|
|
13
|
-
console.log(output);
|
|
14
|
-
expect(output).toContain(version);
|
|
15
|
-
expect(code).toBe(0);
|
|
16
|
-
done();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('import errors if no path is provided', (done) => {
|
|
21
|
-
const task = spawn('node', ['./bin/import.js', '-p']);
|
|
22
|
-
|
|
23
|
-
let output = '';
|
|
24
|
-
task.stdout.on('data', (data) => {
|
|
25
|
-
output += data.toString();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
task.stderr.on('data', (data) => {
|
|
29
|
-
console.error(`stderr: ${data}`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
task.on('close', (code) => {
|
|
33
|
-
console.log(output);
|
|
34
|
-
expect(code).toBe(1);
|
|
35
|
-
done();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const version = require('../package.json').version;
|
|
3
|
-
|
|
4
|
-
test('upgrade displays version', (done) => {
|
|
5
|
-
const task = spawn('node', ['./bin/upgrade.js', '-v']);
|
|
6
|
-
|
|
7
|
-
let output = '';
|
|
8
|
-
task.stdout.on('data', (data) => {
|
|
9
|
-
output += data.toString();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
task.on('close', (code) => {
|
|
13
|
-
console.log(output);
|
|
14
|
-
expect(output).toContain(version);
|
|
15
|
-
expect(code).toBe(0);
|
|
16
|
-
done();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('upgrade errors if no path is provided', (done) => {
|
|
21
|
-
const task = spawn('node', ['./bin/upgrade.js', '-p']);
|
|
22
|
-
|
|
23
|
-
let output = '';
|
|
24
|
-
task.stdout.on('data', (data) => {
|
|
25
|
-
output += data.toString();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
task.stderr.on('data', (data) => {
|
|
29
|
-
console.error(`stderr: ${data}`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
task.on('close', (code) => {
|
|
33
|
-
console.log(output);
|
|
34
|
-
expect(code).toBe(1);
|
|
35
|
-
done();
|
|
36
|
-
});
|
|
37
|
-
});
|
package/bin/build.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const task = require('../tasks/build-pcf');
|
|
3
|
-
const version = require('../package.json').version;
|
|
4
|
-
const logger = require('@tywalk/color-logger').default;
|
|
5
|
-
const [, , ...args] = process.argv;
|
|
6
|
-
|
|
7
|
-
const commandArgument = args.at(0)?.toLowerCase();
|
|
8
|
-
if (['-v', '--version'].includes(commandArgument)) {
|
|
9
|
-
console.log('v%s', version);
|
|
10
|
-
process.exit(0);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
|
|
14
|
-
if (typeof verboseArgument !== 'undefined') {
|
|
15
|
-
logger.setDebug(true);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
logger.log('PCF Helper version', version);
|
|
19
|
-
|
|
20
|
-
const pathArgument = args.find(a => ['-p', '--path'].includes(a));
|
|
21
|
-
if (typeof pathArgument === 'undefined') {
|
|
22
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const pathIndex = args.indexOf(pathArgument) + 1;
|
|
27
|
-
const path = args.at(pathIndex);
|
|
28
|
-
if (typeof path === 'undefined') {
|
|
29
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
task.run(path);
|
package/bin/deploy.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const upgradeTask = require('../tasks/upgrade-pcf');
|
|
3
|
-
const buildTask = require('../tasks/build-pcf');
|
|
4
|
-
const importTask = require('../tasks/import-pcf');
|
|
5
|
-
const { formatMsToSec } = require('../util/performanceUtil');
|
|
6
|
-
const version = require('../package.json').version;
|
|
7
|
-
const logger = require('@tywalk/color-logger').default;
|
|
8
|
-
const [, , ...args] = process.argv;
|
|
9
|
-
|
|
10
|
-
const commandArgument = args.at(0)?.toLowerCase();
|
|
11
|
-
if (['-v', '--version'].includes(commandArgument)) {
|
|
12
|
-
console.log('v%s', version);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
|
|
17
|
-
if (typeof verboseArgument !== 'undefined') {
|
|
18
|
-
logger.setDebug(true);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
logger.log('PCF Helper version', version);
|
|
22
|
-
|
|
23
|
-
const pathArgument = args.find(a => ['-p', '--path'].includes(a));
|
|
24
|
-
if (typeof pathArgument === 'undefined') {
|
|
25
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const pathIndex = args.indexOf(pathArgument) + 1;
|
|
30
|
-
const path = args.at(pathIndex);
|
|
31
|
-
if (typeof path === 'undefined') {
|
|
32
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const tick = performance.now();
|
|
37
|
-
|
|
38
|
-
const envArgument = args.find(a => ['-env', '--environment'].includes(a));
|
|
39
|
-
let envIndex = args.indexOf(envArgument) + 1;
|
|
40
|
-
let env = '';
|
|
41
|
-
if (envIndex > 0) {
|
|
42
|
-
env = args.at(envIndex);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function executeTasks() {
|
|
46
|
-
const upgradeResult = upgradeTask.run(path);
|
|
47
|
-
if (upgradeResult === 1) return 1;
|
|
48
|
-
const buildResult = buildTask.run(path);
|
|
49
|
-
if (buildResult === 1) return 1;
|
|
50
|
-
const importResult = importTask.run(path, env);
|
|
51
|
-
if (importResult === 1) return 1;
|
|
52
|
-
return 0;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var result = 0;
|
|
56
|
-
try {
|
|
57
|
-
result = executeTasks();
|
|
58
|
-
if (result === 0) {
|
|
59
|
-
logger.log('Deploy complete!');
|
|
60
|
-
}
|
|
61
|
-
} catch (e) {
|
|
62
|
-
logger.error('One or more tasks failed while deploying: ', (e && e.message) || 'unkown error');
|
|
63
|
-
result = 1;
|
|
64
|
-
} finally {
|
|
65
|
-
const tock = performance.now();
|
|
66
|
-
logger.log(formatMsToSec('Deploy finished in %is.', tock - tick));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return result;
|
package/bin/import.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const task = require('../tasks/import-pcf');
|
|
3
|
-
const version = require('../package.json').version;
|
|
4
|
-
const logger = require('@tywalk/color-logger').default;
|
|
5
|
-
const [, , ...args] = process.argv;
|
|
6
|
-
|
|
7
|
-
const commandArgument = args.at(0)?.toLowerCase();
|
|
8
|
-
if (['-v', '--version'].includes(commandArgument)) {
|
|
9
|
-
console.log('v%s', version);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
|
|
14
|
-
if (typeof verboseArgument !== 'undefined') {
|
|
15
|
-
logger.setDebug(true);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
logger.log('PCF Helper version', version);
|
|
19
|
-
|
|
20
|
-
const pathArgument = args.find(a => ['-p', '--path'].includes(a));
|
|
21
|
-
if (typeof pathArgument === 'undefined') {
|
|
22
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const pathIndex = args.indexOf(pathArgument) + 1;
|
|
27
|
-
const path = args.at(pathIndex);
|
|
28
|
-
if (typeof path === 'undefined') {
|
|
29
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const envArgument = args.find(a => ['-env', '--environment'].includes(a));
|
|
34
|
-
let envIndex = args.indexOf(envArgument) + 1;
|
|
35
|
-
let env = '';
|
|
36
|
-
if (envIndex > 0) {
|
|
37
|
-
env = args.at(envIndex);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
task.run(path, env);
|
package/bin/upgrade.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const task = require('../tasks/upgrade-pcf');
|
|
3
|
-
const version = require('../package.json').version;
|
|
4
|
-
const logger = require('@tywalk/color-logger').default;
|
|
5
|
-
const [, , ...args] = process.argv;
|
|
6
|
-
|
|
7
|
-
const commandArgument = args.at(0)?.toLowerCase();
|
|
8
|
-
if (['-v', '--version'].includes(commandArgument)) {
|
|
9
|
-
console.log('v%s', version);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const verboseArgument = args.find(a => ['-v', '--verbose'].includes(a));
|
|
14
|
-
if (typeof verboseArgument !== 'undefined') {
|
|
15
|
-
logger.setDebug(true);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
logger.log('PCF Helper version', version);
|
|
19
|
-
|
|
20
|
-
const pathArgument = args.find(a => ['-p', '--path'].includes(a));
|
|
21
|
-
if (typeof pathArgument === 'undefined') {
|
|
22
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const pathIndex = args.indexOf(pathArgument) + 1;
|
|
27
|
-
const path = args.at(pathIndex);
|
|
28
|
-
if (typeof path === 'undefined') {
|
|
29
|
-
logger.error('Path argument is required. Use --path to specify the path to solution folder.');
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
task.run(path);
|
package/tasks/build-pcf.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const { spawnSync } = require('child_process');
|
|
2
|
-
const { formatMsToSec, formatTime } = require('../util/performanceUtil');
|
|
3
|
-
const logger = require('@tywalk/color-logger').default;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Builds the Power Apps component framework project.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} path The path to the project folder containing the pcfproj.json file.
|
|
9
|
-
*
|
|
10
|
-
* @returns {number} The exit code of the spawned process.
|
|
11
|
-
*/
|
|
12
|
-
function run(path) {
|
|
13
|
-
logger.log('[PCF Helper] ' + formatTime(new Date()) + ' Starting build...\n');
|
|
14
|
-
const tick = performance.now();
|
|
15
|
-
const task = spawnSync('dotnet build', ['--restore', '-c', 'Release', path], {
|
|
16
|
-
cwd: process.cwd(),
|
|
17
|
-
stdio: 'inherit',
|
|
18
|
-
shell: true,
|
|
19
|
-
timeout: 1000 * 60 * 5 // 5 minutes
|
|
20
|
-
});
|
|
21
|
-
const tock = performance.now();
|
|
22
|
-
|
|
23
|
-
if (task.status === 0) {
|
|
24
|
-
logger.success('[PCF Helper] Build complete!');
|
|
25
|
-
logger.debug(formatMsToSec('[PCF Helper] ' + formatTime(new Date()) + ' Build finished in %is.\n', tock - tick));
|
|
26
|
-
} else {
|
|
27
|
-
if (task.error) {
|
|
28
|
-
if (task.signal === 'SIGTERM') {
|
|
29
|
-
logger.error('[PCF Helper] Unable to complete build. A timeout of 5 minutes was reached.', task.error.message);
|
|
30
|
-
} else {
|
|
31
|
-
logger.error('[PCF Helper] Unable to complete build: ', task.signal, task.error.message);
|
|
32
|
-
}
|
|
33
|
-
logger.debug('[PCF Helper] Error details: ', task.signal, task.error.stack);
|
|
34
|
-
} else {
|
|
35
|
-
logger.error('[PCF Helper] Unable to complete build: One or more errors ocurred.');
|
|
36
|
-
}
|
|
37
|
-
logger.debug(formatMsToSec('[PCF Helper] ' + formatTime(new Date()) + ' Build finished with errors in %is.\n', tock - tick));
|
|
38
|
-
}
|
|
39
|
-
return task.status;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.run = run;
|
package/tasks/import-pcf.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const { spawnSync } = require('child_process');
|
|
2
|
-
const { join, extname } = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const logger = require('@tywalk/color-logger').default;
|
|
5
|
-
const { formatMsToSec, formatTime } = require('../util/performanceUtil');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Imports a PCF solution into a specified Dataverse environment.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} path - The path to the solution folder containing the build output.
|
|
11
|
-
* @param {string} env - The environment identifier (GUID or URL) where the solution will be imported.
|
|
12
|
-
* @param {boolean} verbose - If true, additional debug information is logged.
|
|
13
|
-
*
|
|
14
|
-
* @returns {number} The exit status of the import process.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
function run(path, env, verbose) {
|
|
18
|
-
logger.log('[PCF Helper] ' + formatTime(new Date()) + ' Starting import...\n');
|
|
19
|
-
const tick = performance.now();
|
|
20
|
-
if (!env) {
|
|
21
|
-
logger.warn('Path argument not provided. Assuming active auth profile organization.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const zipDirPath = join(path, '/bin/release');
|
|
25
|
-
// const zipDirPath = join(path, '');
|
|
26
|
-
const zipDirFiles = fs.readdirSync(zipDirPath);
|
|
27
|
-
const zipFile = zipDirFiles.find(file => extname(file).toLowerCase() === '.zip');
|
|
28
|
-
const zipFilePath = join(zipDirPath, zipFile);
|
|
29
|
-
|
|
30
|
-
const task = spawnSync('pac solution import', ['-env', env, '-p', zipFilePath, '-pc'], {
|
|
31
|
-
cwd: process.cwd(),
|
|
32
|
-
stdio: 'inherit',
|
|
33
|
-
shell: true,
|
|
34
|
-
timeout: 1000 * 60 * 5, // 5 minutes
|
|
35
|
-
});
|
|
36
|
-
const tock = performance.now();
|
|
37
|
-
|
|
38
|
-
if (task.status === 0) {
|
|
39
|
-
logger.success('[PCF Helper] Import complete!');
|
|
40
|
-
logger.debug(formatMsToSec('[PCF Helper] ' + formatTime(new Date()) + ' Import finished in %is.\n', tock - tick));
|
|
41
|
-
} else {
|
|
42
|
-
if (task.error) {
|
|
43
|
-
if (task.signal === 'SIGTERM') {
|
|
44
|
-
logger.error('[PCF Helper] Unable to complete import. A timeout of 5 minutes was reached.', task.error.message);
|
|
45
|
-
} else {
|
|
46
|
-
logger.error('[PCF Helper] Unable to complete import:', task.signal, task.error.message);
|
|
47
|
-
}
|
|
48
|
-
if (verbose) {
|
|
49
|
-
logger.debug('[PCF Helper] Error details:', task.signal, task.error.stack);
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
logger.error('[PCF Helper] Unable to complete import: One or more errors ocurred.');
|
|
53
|
-
}
|
|
54
|
-
logger.debug(formatMsToSec('[PCF Helper] ' + formatTime(new Date()) + ' Import finished with errors in %is.\n', tock - tick));
|
|
55
|
-
}
|
|
56
|
-
return task.status;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
exports.run = run;
|
package/tasks/upgrade-pcf.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const { spawnSync } = require('child_process');
|
|
2
|
-
const { formatMsToSec, formatTime } = require('../util/performanceUtil');
|
|
3
|
-
const logger = require('@tywalk/color-logger').default;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Upgrades the Power Apps component framework project.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} path The path to the project folder containing the pcfproj.json file.
|
|
9
|
-
*
|
|
10
|
-
* @returns {number} The exit code of the spawned process.
|
|
11
|
-
*/
|
|
12
|
-
function run(path) {
|
|
13
|
-
logger.log('[PCF Helper] ' + formatTime(new Date()) + ' Starting upgrade...\n');
|
|
14
|
-
const tick = performance.now();
|
|
15
|
-
const task = spawnSync(`pac solution version -s Solution -sp ${path} && pac pcf version -s Manifest && npm version patch --no-git-tag-version`, {
|
|
16
|
-
cwd: process.cwd(),
|
|
17
|
-
stdio: 'inherit',
|
|
18
|
-
shell: true,
|
|
19
|
-
timeout: 1000 * 60 // 1 min
|
|
20
|
-
});
|
|
21
|
-
const tock = performance.now();
|
|
22
|
-
|
|
23
|
-
if (task.status === 0) {
|
|
24
|
-
logger.success('[PCF Helper] Upgrade complete!');
|
|
25
|
-
logger.debug(formatMsToSec('[PCF Helper] ' + formatTime(new Date()) + ' Upgrade finished in %is.\n', tock - tick));
|
|
26
|
-
} else {
|
|
27
|
-
if (task.error) {
|
|
28
|
-
if (task.signal === 'SIGTERM') {
|
|
29
|
-
logger.error('[PCF Helper] Unable to complete upgrade. A timeout of 1 minutes was reached.', task.error.message);
|
|
30
|
-
} else {
|
|
31
|
-
logger.error('[PCF Helper] Unable to complete upgrade:', task.signal, task.error.message);
|
|
32
|
-
}
|
|
33
|
-
logger.debug('[PCF Helper] Error details:', task.signal, task.error.stack);
|
|
34
|
-
} else {
|
|
35
|
-
logger.error('[PCF Helper] Unable to complete upgrade: One or more errors ocurred.');
|
|
36
|
-
}
|
|
37
|
-
logger.debug(formatMsToSec('[PCF Helper] ' + formatTime(new Date()) + ' Upgrade finished with errors in %is.\n', tock - tick));
|
|
38
|
-
}
|
|
39
|
-
return task.status;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.run = run;
|
package/util/performanceUtil.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const util = require('node:util');
|
|
2
|
-
|
|
3
|
-
var formatter = new Intl.DateTimeFormat('en-US', {
|
|
4
|
-
hour: '2-digit',
|
|
5
|
-
minute: '2-digit',
|
|
6
|
-
second: '2-digit',
|
|
7
|
-
hour12: false
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Formats a number of milliseconds into seconds.
|
|
12
|
-
*
|
|
13
|
-
* @param {string} format - The string format to use when formatting the number of seconds.
|
|
14
|
-
* @param {number} ms - The number of milliseconds to be formatted.
|
|
15
|
-
*
|
|
16
|
-
* @returns {string} The formatted number of seconds.
|
|
17
|
-
*/
|
|
18
|
-
function formatMsToSec(format, ms) {
|
|
19
|
-
const seconds = ms / 1000;
|
|
20
|
-
return util.format(format, seconds);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Formats a Date object into a human-readable string.
|
|
25
|
-
*
|
|
26
|
-
* @param {Date} date - The date object to be formatted.
|
|
27
|
-
*
|
|
28
|
-
* @returns {string} The formatted string.
|
|
29
|
-
*/
|
|
30
|
-
function formatTime(date) {
|
|
31
|
-
return formatter.format(date);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = {
|
|
35
|
-
formatMsToSec,
|
|
36
|
-
formatTime
|
|
37
|
-
}
|